home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Spezial / SPEZIAL2_97.zip / SPEZIAL2_97.iso / ANWEND / ONLINE / ELM23-2 / ELM23-2.ZIP / hdrs / filter.h < prev    next >
C/C++ Source or Header  |  1993-09-26  |  6KB  |  202 lines

  1.  
  2. /* $Id: filter.h,v 4.1 90/04/28 22:42:09 syd Exp $ */
  3.  
  4. /*******************************************************************************
  5.  *  The Elm Mail System  -  $Revision: 4.1 $   $State: Exp $
  6.  *
  7.  *             Copyright (c) 1986, 1987 Dave Taylor
  8.  *             Copyright (c) 1988, 1989, 1990 USENET Community Trust
  9.  *******************************************************************************
  10.  * Bug reports, patches, comments, suggestions should be sent to:
  11.  *
  12.  *    Syd Weinstein, Elm Coordinator
  13.  *    elm@DSI.COM            dsinc!elm
  14.  *
  15.  *******************************************************************************
  16.  * $Log:    filter.h,v $
  17.  * Revision 4.1  90/04/28  22:42:09  syd
  18.  * checkin of Elm 2.3 as of Release PL0
  19.  *
  20.  *
  21.  ******************************************************************************/
  22.  
  23. /** Headers for the filter program.
  24.  
  25. **/
  26.  
  27. #ifdef   BSD
  28. # undef  tolower
  29. #endif
  30.  
  31. /** define a few handy macros for later use... **/
  32.  
  33. #define  the_same(a,b)    (strncmp(a,b,strlen(b)) == 0)
  34.  
  35. #define relationname(x)  (x == 1?"<=":x==2?"<":x==3?">=":x==4?">":x==5?"!=":"=")
  36.  
  37. #define quoteit(x)     (x == LINES? "" : "\"")
  38.  
  39. #define remove_return(s)    { if (s[strlen(s)-1] == '\n') \
  40.                     s[strlen(s)-1] = '\0';    \
  41.                    }
  42.  
  43. /** some of the files we'll be using, where they are, and so on... **/
  44.  
  45. #define  filter_temp    "filter"
  46. #define  filterfile    "elm/filter.rul"
  47. #define  filterlog    "elm/filter.log"
  48. #define  filtersum    "elm/filter.sum"
  49.  
  50. #define  EMERGENCY_MAILBOX      "emergenc.mbx"
  51. #define  EMERG_MBOX             "emerg.mbx"
  52.  
  53. /** and now the hardwired constraint of the program.. **/
  54.  
  55. #define  MAXRULES    25        /* can't have more den dis, boss! */
  56.  
  57. /** some random defines for mnemonic stuff in the program... **/
  58.  
  59. #ifdef SUBJECT
  60. # undef SUBJECT
  61. #endif
  62.  
  63. #define  TO        1
  64. #define  FROM        2
  65. #define  LINES        3
  66. #define  SUBJECT    4
  67. #define  CONTAINS    5
  68. #define  ALWAYS        6
  69.  
  70. #define  DELETE_MSG     7
  71. #define  SAVE        8
  72. #define  SAVECC        9
  73. #define  FORWARD    10
  74. #define  LEAVE        11
  75. #define  EXEC        12
  76.  
  77. #define  FAILED_SAVE    20
  78.  
  79. /** Some conditionals... **/
  80.  
  81. #define LE        1
  82. #define LT        2
  83. #define GE        3
  84. #define GT        4
  85. #define NE        5
  86. #define EQ        6
  87.  
  88. /** A funky way to open a file using open() to avoid file locking hassles **/
  89.  
  90. #define  FOLDERMODE    O_WRONLY | O_APPEND | O_CREAT
  91.  
  92. /** cheap but easy way to have two files share the same #include file **/
  93.  
  94. #ifdef MAIN_ROUTINE
  95.  
  96. char home[SLEN],                /* the users home directory */
  97.      hostname[SLEN],            /* the machine name...      */
  98.      username[SLEN];            /* the users login name...  */
  99. char hostfromname[SLEN];                /* name of FQDN we pretend to be in */
  100.  
  101. char to[VERY_LONG_STRING],
  102.      from[LONG_STRING],
  103.      subject[LONG_STRING];        /* from current message     */
  104.  
  105. FILE *outfd;
  106. char outfname[SLEN];
  107.  
  108. int  total_rules = 0,                /* how many rules to check  */
  109.      show_only = FALSE,                /* just for show?           */
  110.      long_summary = FALSE,            /* what sorta summary??     */
  111.      verbose   = FALSE,                /* spit out lots of stuff   */
  112.      lines     = 0,                /* lines in message..       */
  113.      clear_logs = FALSE,            /* clear files after sum?   */
  114.      already_been_forwarded = FALSE,        /* has this been filtered?  */
  115.      log_actions_only = FALSE,            /* log actions | everything */
  116.      printing_rules = FALSE,            /* are we just using '-r'?  */
  117.      rule_choosen;                /* which one we choose      */
  118.  
  119. #else
  120.  
  121. extern char home[SLEN],                /* the users home directory */
  122.             hostname[SLEN],            /* the machine name...      */
  123.             username[SLEN];            /* the users login name...  */
  124. extern char hostfromname[SLEN];         /* name of FQDN we pretend to be in */
  125.  
  126. extern char to[VERY_LONG_STRING],
  127.             from[LONG_STRING],
  128.             subject[LONG_STRING];        /* from current message     */
  129.  
  130. extern FILE *outfd;
  131. extern char outfname[SLEN];
  132.  
  133. extern int total_rules,                /* how many rules to check  */
  134.            show_only,                /* just for show?           */
  135.            long_summary,            /* what sorta summary??     */
  136.            verbose,                /* spit out lots of stuff   */
  137.            lines,                /* lines in message..       */
  138.            clear_logs,                    /* clear files after sum?   */
  139.        already_been_forwarded,        /* has this been filtered?  */
  140.            log_actions_only,            /* log actions | everything */
  141.            printing_rules,            /* are we just using '-r'?  */
  142.            rule_choosen;            /* which one we choose      */
  143. #endif
  144.  
  145. /** and our ruleset record structure... **/
  146.  
  147. struct condition_rec {
  148.     int     matchwhat;            /* type of 'if' clause      */
  149.     int     relation;            /* type of match (eq, etc)  */
  150.     char    argument1[SLEN];        /* match against this       */
  151.     struct  condition_rec  *next;        /* next condition...        */
  152.       };
  153.  
  154. struct ruleset_record {
  155.     char      printable[SLEN];        /* straight from file...    */
  156.     struct  condition_rec  *condition;
  157.     int     action;                /* what action to take      */
  158.     char    argument2[SLEN];        /* argument for action      */
  159.       };
  160.  
  161. #ifdef MAIN_ROUTINE
  162.   struct ruleset_record rules[MAXRULES];
  163. #else
  164.   extern struct ruleset_record rules[MAXRULES];
  165. #endif
  166.  
  167. /** finally let's keep LINT happy with the return values of all these pups! ***/
  168.  
  169. char *itoa();
  170.  
  171. #ifdef    _POSIX_SOURCE        /*{_POSIX_SOURCE*/
  172. #include <string.h>
  173. #include <unistd.h>
  174. #include <stdlib.h>
  175. #else                /*}_POSIX_SOURCE{*/
  176. unsigned short getuid();
  177.  
  178. unsigned long sleep();
  179.  
  180. char *malloc(), *strcpy(), *strcat();
  181.  
  182. void    exit();
  183.  
  184. #ifdef BSD
  185.  
  186.   FILE *popen();
  187.  
  188. #ifdef MAIN_ROUTINE
  189.   char  _vbuf[5*BUFSIZ];              /* space for file buffering */
  190. #else
  191.   extern char  _vbuf[5*BUFSIZ];        /* space for file buffering */
  192. #endif
  193.  
  194. #ifndef _IOFBF
  195. # define _IOFBF        0        /* doesn't matter - ignored */
  196. #endif
  197.  
  198. # define setvbuf(fd,a,b,c)    setbuffer(fd, _vbuf, 5*BUFSIZ)
  199.  
  200. #endif
  201. #endif                /*}_POSIX_SOURCE*/
  202.