home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_100 / 161_01 / local.h < prev    next >
C/C++ Source or Header  |  1985-08-29  |  1KB  |  50 lines

  1. /* local.h - definitions for use with
  2.  *      Learning to Program in C
  3.  */
  4. #ifndef LOCAL_H
  5. #define LOCAL_H
  6. #include <stdio.h>
  7. #define FAIL        1
  8. #define FOREVER        for (;;)
  9. #define NO            0
  10. #define STDERR        2
  11. #define STDIN        0
  12. #define STDOUT        1
  13. #define SUCCEED        0
  14. #define YES            1
  15. #define bits        ushort
  16. #define bool        int
  17. #define metachar    short
  18. #define tbool        char
  19. #define ushort      unsigned  /* use unsigned short, if you can */
  20. #define void        int        /* delete, if compiler supports void */
  21. #define getln(s, n) ((fgets(s, n, stdin)==NULL) ? EOF : strlen(s))
  22. #define ABS(x)        (((x) < 0) ? -(x) : (x))
  23. #define MAX(x, y)    (((x) < (y)) ? (y) : (x))
  24. #define MIN(x, y)    (((x) < (y)) ? (x) : (y))
  25.  
  26. /* new material - include standard fn declarations */
  27. #include <ctype.h>
  28. #include <math.h>
  29.  
  30. #define TRUE 1
  31. #define FALSE 0
  32.  
  33. #define DIM(a) (sizeof(a) / sizeof(a[0]))
  34. #define SWAP(a, b, t) (t = a, a = b, b = t)
  35. #define LOOPDN(r, n) for (r = n+1; --r > 0; )
  36. #ifndef NDEBUG
  37. #define asserts(cond, str) \
  38.     { if (!(cond)) fprintf(stderr, "Assertion '%s' failed\n", str); }
  39. #else
  40. #define asserts(e, s)
  41. #endif
  42. typedef char *data_ptr;
  43. typedef unsigned size_t;
  44. typedef unsigned index_t;
  45. #define STREQ(s, t) (strcmp(s, t) == 0)
  46. #define STRLT(s, t) (strcmp(s, t) < 0)
  47. #define STRGT(s, t) (strcmp(s, t) > 0)
  48. #define CHAR_BIT 8
  49. #endif
  50.