home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / com / utils / elm / sources / defs.h < prev    next >
C/C++ Source or Header  |  1992-10-04  |  12KB  |  389 lines

  1.  
  2. /* $Id: defs.h,v 4.1.1.2 90/06/05 21:23:19 syd Exp $ */
  3.  
  4. /*******************************************************************************
  5.  *  The Elm Mail System  -  $Revision: 4.1.1.2 $   $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:    defs.h,v $
  17.  * Revision 4.1.1.2  90/06/05  21:23:19  syd
  18.  * Fix other side of same problem
  19.  * From: Syd
  20.  *
  21.  * Revision 4.1.1.1  90/06/05  21:16:42  syd
  22.  * Try and avoid double definitions for the null
  23.  * macro for htonl when the system includes aready
  24.  * have it
  25.  * From: Syd
  26.  *
  27.  * Revision 4.1  90/04/28  22:42:06  syd
  28.  * checkin of Elm 2.3 as of Release PL0
  29.  *
  30.  *
  31.  ******************************************************************************/
  32.  
  33. /**  define file for ELM mail system.  **/
  34.  
  35.  
  36. #include "../config.h"
  37. #include "sysdefs.h"    /* system/configurable defines */
  38.  
  39. #ifdef OS2
  40. #include "../os2/os2elm.h"
  41. #endif
  42.  
  43.  
  44. # define VERSION         "2.3"        /* Version number... */
  45. # define VERS_DATE    "May 1, 1990"        /* for elm -v option */
  46. # define WHAT_STRING    \
  47.     "@(#) Version 2.3, USENET supported version, released May 1990"
  48.  
  49. #define KLICK        25
  50.  
  51. #define SLEN        256        /* long for ensuring no overwrites... */
  52. #define SHORT        10        /* super short strings!          */
  53. #define NLEN        48        /* name length for aliases            */
  54. #define WLEN        20
  55. #define STRING        128    /* reasonable string length for most..      */
  56. #define LONG_STRING    512    /* even longer string for group expansion   */
  57. #define VERY_LONG_STRING 2560    /* huge string for group alias expansion    */
  58. #define MAX_LINE_LEN    5120    /* even bigger string for "filter" prog..   */
  59.  
  60. #define BREAK        '\0'          /* default interrupt    */
  61. #define BACKSPACE    '\b'         /* backspace character  */
  62. #define TAB        '\t'            /* tab character        */
  63. #define RETURN        '\r'         /* carriage return char */
  64. #define LINE_FEED    '\n'         /* line feed character  */
  65. #define FORMFEED    '\f'         /* form feed (^L) char  */
  66. #define COMMA        ','        /* comma character      */
  67. #define SPACE        ' '        /* space character      */
  68. #define DOT        '.'        /* period/dot character */
  69. #define BANG        '!'        /* exclaimation mark!   */
  70. #define AT_SIGN        '@'        /* at-sign character    */
  71. #define PERCENT        '%'        /* percent sign char.   */
  72. #define COLON        ':'        /* the colon ..        */
  73. #define BACKQUOTE    '`'        /* backquote character  */
  74. #define TILDE_ESCAPE    '~'        /* escape character~    */
  75. #define ESCAPE        '\033'        /* the escape        */
  76.  
  77. #define NO_OP_COMMAND    '\0'        /* no-op for timeouts   */
  78.  
  79. #define STANDARD_INPUT  0        /* file number of stdin */
  80.  
  81. #ifndef TRUE
  82. #define TRUE        1
  83. #define FALSE        0
  84. #endif
  85.  
  86. #define NO        0
  87. #define YES        1
  88. #define MAYBE        2        /* a definite define, eh?  */
  89. #define FORM        3        /*      <nevermind>        */
  90. #define PREFORMATTED    4        /* forwarded form...       */
  91.  
  92. #define SAME_PAGE    1        /* redraw current only     */
  93. #define NEW_PAGE    2        /* redraw message list     */
  94. #define ILLEGAL_PAGE    0        /* error in page list, punt */
  95.  
  96. #define PAD        0        /* for printing name of    */
  97. #define FULL        1        /*   the sort we're using  */
  98.  
  99. #define OUTGOING    0        /* defines for lock file   */
  100. #define INCOMING    1        /* creation..see lock()    */
  101.  
  102. #define SH        0        /* defines for system_call */
  103. #define USER_SHELL    1        /* to work correctly!      */
  104.  
  105. #define EXECUTE_ACCESS    01        /* These five are        */
  106. #define WRITE_ACCESS    02        /*    for the calls       */
  107. #define READ_ACCESS    04        /*       to access()       */
  108. #define ACCESS_EXISTS    00        /*           <etc>         */
  109. #define EDIT_ACCESS    06        /*  (this is r+w access)   */
  110.  
  111. #define BIG_NUM        999999        /* big number!             */
  112. #define BIGGER_NUM    9999999     /* bigger number!          */
  113.  
  114. #define START_ENCODE    "[encode]"
  115. #define END_ENCODE    "[clear]"
  116.  
  117. #define DONT_SAVE    "[no save]"
  118. #define DONT_SAVE2    "[nosave]"
  119.  
  120.  
  121. /** some defines for the 'userlevel' variable... **/
  122.  
  123. #define RANK_AMATEUR    0
  124. #define AMATEUR        1
  125. #define OKAY_AT_IT    2
  126. #define GOOD_AT_IT    3
  127. #define EXPERT        4
  128. #define SUPER_AT_IT    5
  129.  
  130. /** some defines for the "status" field of the header record **/
  131.  
  132. #define ACTION        1        /* bit masks, of course */
  133. #define CONFIDENTIAL    2
  134. #define DELETED        4
  135. #define EXPIRED        8
  136. #define FORM_LETTER    16
  137. #define NEW        32
  138. #define PRIVATE        64
  139. #define TAGGED        128
  140. #define URGENT        256
  141. #define VISIBLE        512
  142. #define UNREAD        1024
  143. #define STATUS_CHANGED    2048
  144.  
  145. #define UNDELETE    0        /* purely for ^U function... */
  146.  
  147. /** values for headers exit_disposition field */
  148. #define UNSET    0
  149. #define KEEP    1
  150. #define    STORE    2
  151. #define DELETE    3
  152.  
  153. /** some months... **/
  154.  
  155. #define JANUARY        0            /* months of the year */
  156. #define FEBRUARY    1
  157. #define MARCH        2
  158. #define APRIL        3
  159. #define MAY        4
  160. #define JUNE        5
  161. #define JULY        6
  162. #define AUGUST        7
  163. #define SEPTEMBER    8
  164. #define OCTOBER        9
  165. #define NOVEMBER    10
  166. #define DECEMBER    11
  167.  
  168. #define equal(s,w)    (strcmp(s,w) == 0)
  169. #define min(a,b)    (a < b? a : b)
  170. #define ctrl(c)            (c == '?' ? 127 : c - 'A' + 1)    /* control character mapping */
  171. #define plural(n)    n == 1 ? "" : "s"
  172. #define lastch(s)    s[strlen(s)-1]
  173.  
  174. /* find tab stops preceding or following a given column position 'a', where
  175.  * the column position starts counting from 1, NOT 0!
  176.  * The external integer "tabspacing" must be declared to use this. */
  177. #define prev_tab(a)    (((((a-1)/tabspacing))*tabspacing)+1)
  178. #define next_tab(a)    (((((a-1)/tabspacing)+1)*tabspacing)+1)
  179.  
  180. #define movement_command(c)    (c == 'j' || c == 'k' || c == ' ' ||           \
  181.                  c == BACKSPACE || c == ESCAPE || c == '*' || \
  182.                  c == '-' || c == '+' || c == '=' ||          \
  183.                  c == '#' || c == '@' || c == 'x' ||           \
  184.                  c == 'a' || c == 'q')
  185.  
  186. #define no_ret(s)    { register int xyz; /* varname is for lint */          \
  187.                   for (xyz=strlen(s)-1; xyz >= 0 &&               \
  188.                 (s[xyz] == '\r' || s[xyz] == '\n'); )          \
  189.                  s[xyz--] = '\0';                                 \
  190.             }
  191.  
  192. #define first_word(s,w) (strncmp(s,w, strlen(w)) == 0)
  193. #define ClearLine(n)    MoveCursor(n,0); CleartoEOLN()
  194. #define whitespace(c)    (c == ' ' || c == '\t')
  195. #define ok_rc_char(c)    (isalnum(c) || c == '-' || c == '_')
  196. #define ok_alias_char(c) (isalnum(c) || c == '-' || c == '_' || c == '.')
  197. #define quote(c)    (c == '"' || c == '\'')
  198. #define onoff(n)    (n == 0 ? "OFF" : "ON")
  199.  
  200. /** The next function is so certain commands can be processed from the showmsg
  201.     routine without rewriting the main menu in between... **/
  202.  
  203. #define special(c)    (c == 'j' || c == 'k')
  204.  
  205. /** and a couple for dealing with status flags... **/
  206.  
  207. #define ison(n,mask)    (n & mask)
  208. #define isoff(n,mask)    (!ison(n, mask))
  209.  
  210. #define setit(n,mask)        n |= mask
  211. #define clearit(n, mask)    n &= ~mask
  212.  
  213. /** a few for the usage of function keys... **/
  214.  
  215. #define f1    1
  216. #define f2    2
  217. #define f3    3
  218. #define f4    4
  219. #define f5    5
  220. #define f6    6
  221. #define f7    7
  222. #define f8    8
  223.  
  224. #define MAIN    0
  225. #define ALIAS   1
  226. #define YESNO    2
  227. #define CHANGE  3
  228. #define READ    4
  229.  
  230. #define MAIN_HELP    0
  231. #define OPTIONS_HELP 1
  232. #define ALIAS_HELP   2
  233. #define PAGER_HELP   3
  234.  
  235. /** types of folders **/
  236. #define NO_NAME        0        /* variable contains no file name */
  237. #define NON_SPOOL    1        /* mailfile not in mailhome */
  238. #define SPOOL        2        /* mailfile in mailhome */
  239.  
  240. /* the following is true if the current mailfile is the user's spool file*/
  241. #define USERS_SPOOL    (strcmp(cur_folder, defaultfile) == 0)
  242.  
  243. /** some possible sort styles... **/
  244.  
  245. #define REVERSE        -        /* for reverse sorting           */
  246. #define SENT_DATE    1        /* the date message was sent     */
  247. #define RECEIVED_DATE    2        /* the date message was received */
  248. #define SENDER        3        /* the name/address of sender    */
  249. #define SIZE        4        /* the # of lines of the message */
  250. #define SUBJECT        5        /* the subject of the message    */
  251. #define STATUS        6        /* the status (deleted, etc)     */
  252. #define MAILBOX_ORDER    7        /* the order it is in the file   */
  253.  
  254. /* some stuff for our own malloc call - pmalloc */
  255.  
  256. #define PMALLOC_THRESHOLD    256    /* if greater, then just use malloc */
  257. #define PMALLOC_BUFFER_SIZE    2048    /* internal [memory] buffer size... */
  258.  
  259.  
  260. /** the following macro is as suggested by Larry McVoy.  Thanks! **/
  261.  
  262. # ifdef DEBUG
  263. #  define   dprint(n,x)        {                 \
  264.                    if (debug >= n)  {        \
  265.                      fprintf x ;         \
  266.                      fflush(debugfile);         \
  267.                    }                \
  268.                 }
  269. # else
  270. #  define   dprint(n,x)
  271. # endif
  272.  
  273. /* some random structs... */
  274.  
  275. struct date_rec {
  276.     int  month;        /** this record stores a **/
  277.     int  day;        /**   specific date and  **/
  278.     int  year;        /**     time...         **/
  279.     int  hour;
  280.     int  minute;
  281.        };
  282.  
  283. struct header_rec {
  284.     int  lines;        /** # of lines in the message  **/
  285.     int  status;        /** Urgent, Deleted, Expired?  **/
  286.     int  index_number;    /** relative loc in file...    **/
  287.     int  encrypted;        /** whether msg has encryption **/
  288.     int  exit_disposition;    /** whether to keep, store, delete **/
  289.     int  status_chgd;    /** whether became read or old, etc. **/
  290.     long offset;        /** offset in bytes of message **/
  291.     struct date_rec received; /** when elm received here   **/
  292.     char from[STRING];    /** who sent the message?      **/
  293.     char to[STRING];    /** who it was sent to           **/
  294.     char messageid[STRING];    /** the Message-ID: value      **/
  295.     char dayname[8];    /**  when the                  **/
  296.     char month[10];        /**        message             **/
  297.     char day[3];        /**          was            **/
  298.     char year[5];        /**            sent            **/
  299.     char time[NLEN];    /**              to you!       **/
  300.     char time_zone[12];    /**                incl. tz    */
  301.     long time_sent;        /** gmt when sent for sorting  **/
  302.     char subject[STRING];   /** The subject of the mail    **/
  303.     char mailx_status[WLEN];/** mailx status flags (RO...) **/
  304.        };
  305.  
  306. struct alias_rec {
  307.     char   name[NLEN];    /* alias name                  */
  308.     long   byte;        /* offset into data file for address */
  309.        };
  310.  
  311. struct lsys_rec {
  312.     char   name[NLEN];    /* name of machine connected to      */
  313.     struct lsys_rec *next;    /* linked list pointer to next       */
  314.        };
  315.  
  316. struct addr_rec {
  317.      char   address[NLEN];    /* machine!user you get mail as      */
  318.      struct addr_rec *next;    /* linked list pointer to next       */
  319.     };
  320.  
  321. #ifdef SHORTNAMES    /* map long names to shorter ones */
  322. # include <shortname.h>
  323. #endif
  324.  
  325. /** Let's make sure that we're not going to have any annoying problems with
  326.     int pointer sizes versus char pointer sizes by guaranteeing that every-
  327.     thing vital is predefined... (Thanks go to Detlev Droege for this one)
  328. **/
  329.  
  330. #ifdef STRINGS
  331. #  include <strings.h>
  332. #else
  333. #  include <string.h>
  334. #endif
  335.  
  336. /*
  337.  * Macros for network/external number representation conversion.
  338.  *    Note, some system include files already have htonl defined
  339.  *    as this same macro, the ifndef should prevent conflicts.
  340.  */
  341. #ifdef NETWORK_ORDER
  342. #  ifndef ntohl
  343. unsigned short    ntohs(), htons();
  344. unsigned long    ntohl(), htonl();
  345. #  endif
  346. #else
  347. #  ifndef ntohl
  348. #     define    ntohl(x)    (x)
  349. #     define    ntohs(x)    (x)
  350. #     define    htonl(x)    (x)
  351. #     define    htons(x)    (x)
  352. #  endif
  353. #endif
  354.  
  355. char *argv_zero();
  356. char *bounce_off_remote();
  357. char *ctime();
  358. char *error_description();
  359. char *error_name();
  360. char *error_number();
  361. char *expand_address();
  362. char *expand_domain();
  363. char *expand_group();
  364. char *expand_logname();
  365. char *expand_system();
  366. char *find_path_to();
  367. char *format_long();
  368. char *get_alias_address();
  369. char *get_arpa_date();
  370. char *get_ctime_date();
  371. char *get_date();
  372. char *get_token();
  373. char *getenv();
  374. char *getlogin();
  375. char *level_name();
  376. char *match_and_expand_domain();
  377. char *shift_lower();
  378. char *strip_commas();
  379. char *strip_parens();
  380. char *strpbrk();
  381. char *strtok();
  382. char *tail_of_string();
  383. char *tgetstr();
  384. char *pmalloc();
  385.  
  386. long lseek();
  387. long times();
  388. long ulimit();
  389.