home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / amiga / comms / network / grn1src.lha / headers.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-07-04  |  3.6 KB  |  96 lines

  1. #ifndef _local_headers_h_
  2. #define _local_headers_h_
  3.  
  4. /* Stolen straight from C-News <news.h>. Thanks Henry and Geoff! */
  5.  
  6. /* macros, replacing functions for speed */
  7. #ifndef max
  8. #define max(a,b) ((a) > (b)? (a): (b))
  9. #endif
  10. #ifndef min
  11. #define min(a,b) ((a) < (b)? (a): (b))
  12. #endif
  13. #ifndef iswhite
  14. #define iswhite(c) ((c) == ' ' || (c) == '\t')
  15. #endif
  16. /* STREQ is an optimised strcmp(a,b)==0 */
  17. #define STREQ(a, b) ((a)[0] == (b)[0] && strcmp(a, b) == 0)
  18. /* STREQN is an optimised strncmp(a,b,n)==0; assumes n > 0 */
  19. #define STREQN(a, b, n) ((a)[0] == (b)[0] && strncmp(a, b, n) == 0)
  20.  
  21. /*
  22.         Begin GRn stuff
  23. */
  24. /*
  25.         The bits in an unsigned long to use when talking about these headers
  26.         (in alpha order by header name)
  27. */
  28. #define HEADER_DATE_B                   0
  29. #define HEADER_DISTRIBUTION_B           (HEADER_DATE_B + 1)
  30. #define HEADER_FOLLOWUP_TO_B            (HEADER_DISTRIBUTION_B + 1)
  31. #define HEADER_FROM_B                   (HEADER_FOLLOWUP_TO_B + 1)
  32. #define HEADER_MESSAGE_ID_B             (HEADER_FROM_B + 1)
  33. #define HEADER_NEWSGROUPS_B             (HEADER_MESSAGE_ID_B + 1)
  34. #define HEADER_ORGANIZATION_B           (HEADER_NEWSGROUPS_B + 1)
  35. #define HEADER_PATH_B                   (HEADER_ORGANIZATION_B + 1)
  36. #define HEADER_REFERENCES_B             (HEADER_PATH_B + 1)
  37. #define HEADER_REPLY_TO_B               (HEADER_REFERENCES_B + 1)
  38. #define HEADER_SUBJECT_B                (HEADER_REPLY_TO_B + 1)
  39. #define HEADER_TO_B                     (HEADER_SUBJECT_B + 1)
  40. #define HEADER_X_NEWSSOFTWARE_B         (HEADER_TO_B + 1)
  41. #define HEADER_LAST_B                   HEADER_X_NEWSSOFTWARE_B
  42. /*
  43.         You can have ONLY 32 headers in this list...
  44. */
  45. #define HEADER_DATE                     (1 << HEADER_DATE_B)
  46. #define HEADER_DISTRIBUTION             (1 << HEADER_DISTRIBUTION_B)
  47. #define HEADER_FOLLOWUP_TO              (1 << HEADER_FOLLOWUP_TO_B)
  48. #define HEADER_FROM                     (1 << HEADER_FROM_B)
  49. #define HEADER_MESSAGE_ID               (1 << HEADER_MESSAGE_ID_B)
  50. #define HEADER_NEWSGROUPS               (1 << HEADER_NEWSGROUPS_B)
  51. #define HEADER_ORGANIZATION             (1 << HEADER_ORGANIZATION_B)
  52. #define HEADER_PATH                     (1 << HEADER_PATH_B)
  53. #define HEADER_REFERENCES               (1 << HEADER_REFERENCES_B)
  54. #define HEADER_REPLY_TO                 (1 << HEADER_REPLY_TO_B)
  55. #define HEADER_SUBJECT                  (1 << HEADER_SUBJECT_B)
  56. #define HEADER_TO                       (1 << HEADER_TO_B)
  57. #define HEADER_X_NEWSSOFTWARE           (1 << HEADER_X_NEWSSOFTWARE_B)
  58. #define HEADER_LAST                     (1 << HEADER_LAST_B)
  59.  
  60. #define MAX_HEADER_SIZE                 4096
  61.         // MAX_HEADER_SIZE is an arbitrary size that should include
  62.         // all articles. Based on recent statistics (as of June 1992)
  63.         // the maximum header seen on Usenet was less than 3K. This
  64.         // size should be plenty for the forseeable future....
  65.  
  66. extern char
  67.         *Date,
  68.         *Distribution,
  69.         *Followup_To,
  70.         *From,
  71.         *Message_ID,
  72.         *Newsgroups,
  73.         *Organization,
  74.         *Path,
  75.         *References,
  76.         *Reply_To,
  77.         *Subject,
  78.         *To,
  79.         *X_NewsSoftware;
  80.  
  81. extern char *header_buf;       // buffer used by ScanAndLoadHeaders()
  82. extern int header_size;        // size of header_buf
  83. extern int header_len;         // length of header (until double newline)
  84.  
  85. // options for ScanAndLoadHeaders() --
  86. // Don't close the article file, return the fd as the result value.
  87. #define OPT_DONT_CLOSE                  1
  88.  
  89. // the header munging routine
  90. int ScanAndLoadHeaders (const char *filename,
  91.                         const unsigned long headers,
  92.                         const unsigned long opt);
  93.  
  94. void AllocHeaderBuf (int size);
  95. #endif
  96.