home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1999 March B / SCO_CASTOR4RRT.iso / uccs / root.14 / udk / usr / include / macros.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-08-19  |  2.5 KB  |  94 lines

  1. /*
  2.  * Copyright (c) 1998 The Santa Cruz Operation, Inc.. All Rights Reserved. 
  3.  *                                                                         
  4.  *        THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF THE               
  5.  *                   SANTA CRUZ OPERATION INC.                             
  6.  *                                                                         
  7.  *   The copyright notice above does not evidence any actual or intended   
  8.  *   publication of such source code.                                      
  9.  */
  10.  
  11. #ifndef _MACROS_H
  12. #define _MACROS_H
  13.  
  14. #ident    "@(#)sgs-head:common/head/macros.h    1.3.4.1"
  15. /*
  16.     numeric() is useful in while's, if's, etc., but don't use *p++
  17.     max() and min() depend on the types of the operands
  18.     abs() is absolute value
  19. */
  20. # define numeric(c)        ((c) >= '0' && (c) <= '9')
  21. # define max(a,b)         ((a)<(b) ? (b) : (a))
  22. # define min(a,b)         ((a)>(b) ? (b) : (a))
  23. # define abs(x)            ((x)>=0 ? (x) : -(x))
  24.  
  25. # define compare(str1,str2)    strcmp((str1),(str2))
  26. # define equal(str1,str2)    !strcmp((str1),(str2))
  27. # define length(str)        strlen(str)
  28. # define size(str)        (strlen(str) + 1)
  29.  
  30. /*
  31.     The global variable Statbuf is available for use as a stat(II)
  32.     structure.  Note that "stat.h" is included here and should
  33.     not be included elsewhere.
  34.     Exists(file) returns 0 if the file does not exist;
  35.     the flags word if it does (the flags word is always non-zero).
  36. */
  37.  
  38. #ifndef _SYS_TYPES_H
  39. #include <sys/types.h>
  40. #endif
  41.  
  42. #ifndef _SYS_STAT_H
  43. #include <sys/stat.h>
  44. #endif
  45.  
  46. extern struct stat Statbuf;
  47. # define exists(file)        (stat(file,&Statbuf)<0 ? 0:Statbuf.st_mode)
  48.  
  49. extern long itol();
  50.  
  51. /*
  52.     SAVE() and RSTR() use local data in nested blocks.
  53.     Make sure that they nest cleanly.
  54. */
  55. # define SAVE(name,place)    { int place = name;
  56. # define RSTR(name,place)    name = place;}
  57.  
  58. /*
  59.     Use: DEBUG(sum,d) which becomes fprintf(stderr,"sum = %d\n",sum)
  60. */
  61. #ifdef __STDC__
  62. # define DEBUG(var,type)    fprintf(stderr,#var "= %" #type "\n", var)
  63. # define SCCSID(arg)        static char Sccsid[]=#arg
  64. #else
  65. # define DEBUG(var,type)    fprintf(stderr,"var = %type\n", var)
  66. # define SCCSID(arg)        static char Sccsid[]="arg"
  67. #endif
  68.  
  69. /*
  70.     Use of ERRABORT() will cause libS.a internal
  71.     errors to cause aborts
  72. */
  73. # define ERRABORT()    _error() { abort(); }
  74.  
  75. /*
  76.     Use of USXALLOC() is required to force all calls to alloc()
  77.     (e.g., from libS.a) to call xalloc().
  78. */
  79.  
  80. # define NONBLANK(p)        while (*(p)==' ' || *(p)=='\t') (p)++
  81.  
  82.  
  83. /*
  84.     A global null string.
  85. */
  86. extern char    Null[1];
  87.  
  88. /*
  89.     A global error message string.
  90. */
  91. extern char    Error[128];
  92.  
  93. #endif /* _MACROS_H */
  94.