home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 10 / Fresh_Fish_10_2352.bin / new / dev / lang / sgmls / src / tools.h < prev    next >
C/C++ Source or Header  |  1994-07-10  |  2KB  |  77 lines

  1. /* TOOLS.H: Definitions for type declarations, printing, bit handling, etc.
  2. */
  3.  
  4. #if CHAR_SIGNED
  5. typedef unsigned char UNCH;
  6. #else
  7. typedef char UNCH;
  8. #endif
  9.  
  10. #if CHAR_SIGNED
  11. #define ustrcmp(s1, s2) strcmp((char *)(s1), (char *)(s2))
  12. #define ustrcpy(s1, s2) strcpy((char *)(s1), (char *)(s2))
  13. #define ustrchr(s, c) (UNCH *)strchr((char *)(s), c)
  14. #define ustrncmp(s1, s2, n) strncmp((char *)(s1), (char *)(s2), n)
  15. #define ustrncpy(s1, s2, n) strncpy((char *)(s1), (char *)(s2), n)
  16. #define ustrlen(s1) strlen((char *)(s1))
  17. #else
  18. #define ustrcmp strcmp
  19. #define ustrcpy strcpy
  20. #define ustrchr strchr
  21. #define ustrncmp strncmp
  22. #define ustrncpy strncpy
  23. #define ustrlen strlen
  24. #endif
  25.  
  26. #if 0
  27. int ustrcmp(UNCH *, UNCH *);
  28. UNCH *ustrchr(UNCH *, int);
  29. int ustrncmp(UNCH *, UNCH *, UNS);
  30. int ustrncpy(UNCH *, UNCH *, UNS);
  31. int ustrlen(UNCH *);
  32. #endif
  33.  
  34. typedef unsigned UNS;
  35.  
  36. #ifdef USE_ISASCII
  37. #define ISASCII(c) isascii(c)
  38. #else
  39. #define ISASCII(c) (1)
  40. #endif
  41.  
  42. #ifdef BSD_STRINGS
  43. #define MEMZERO(s, n) bzero(s, n)
  44. #else /* not BSD_STRINGS */
  45. #define MEMZERO(s, n) memset(s, '\0', n)
  46. #endif /* not BSD_STRINGS */
  47.  
  48. /* Macros for bit manipulation.
  49. */
  50. #define SET(word, bits)          ((word) |= (bits))    /* Turn bits on */
  51. #define RESET(word, bits)        ((word) &= ~(bits))   /* Turn bits off */
  52. #define GET(word, bits)          ((word) & (bits))     /* 1=any bit on */
  53. #define BITOFF(word, bits)       (GET(word, bits)==0)  /* 1=no bits on */
  54. #define BITON(word, bits)        ((word) & (bits))     /* 1=any bit on */
  55.  
  56. #define ETDCDATA (dumetd)          /* Dummy etd pointer for #PCDATA. */
  57. #define ETDNULL  (dumetd + 1)      /* Dummy etd pointer for null tag. */
  58. #define ETDNET   (dumetd + 2)      /* Dummy etd pointer for NET delimiter. */
  59. #define BADPTR(p) \
  60.   ((p) == NULL || (p) == ETDCDATA || (p) == ETDNULL || (p) == ETDNET)
  61. #define PTRNUM(p) ((p) == NULL ? 0 : ((p) - dumetd) + 1)
  62.  
  63. #ifdef USE_PROTOTYPES
  64. #define P(parms) parms
  65. #else
  66. #define P(parms) ()
  67. #endif
  68.  
  69. /* VP is used for prototypes of varargs functions.  You can't have a
  70. prototype if the function is defined using varargs.h rather than
  71. stdarg.h. */
  72. #ifdef VARARGS
  73. #define VP(parms) ()
  74. #else
  75. #define VP(parms) P(parms)
  76. #endif
  77.