Added all of the MH sources, including RCS files, in
[mmh] / docs / historical / mh-6.8.5 / h / RCS / formatsbr.h,v
1 head    1.1;
2 access;
3 symbols;
4 locks; strict;
5 comment @ * @;
6
7
8 1.1
9 date    92.01.23.23.14.54;      author jromine; state Exp;
10 branches;
11 next    ;
12
13
14 desc
15 @add id
16 @
17
18
19 1.1
20 log
21 @Initial revision
22 @
23 text
24 @/* formatsbr.h - definitions for fmtscan () */
25 /* $Id$ */
26
27 /*
28  * This structure describes an "interesting" component.  It holds
29  * the name & text from the component (if found) and one piece of
30  * auxilary info.  The structure for a particular component is located
31  * by hashing the name and using it as an index into the ptr array
32  * "wantcomp".  All format entries that reference a particular component
33  * point to its comp struct (so we only have to do component specific
34  * processing once.  e.g., parse an address.).
35  */
36 struct comp {
37         char            *c_name;        /* component name (in lower case) */
38         struct  comp    *c_next;        /* hash chain linkage */
39         char            *c_text;        /* component text (if found) */
40         short           c_flags;        /* misc. flags (from formatsbr) */
41         short           c_type;         /* type info (from fmtcompile) */
42         union {
43                 struct tws      *c_u_tws;
44                 struct mailname *c_u_mn;
45         } c_un;
46 #define c_tws c_un.c_u_tws
47 #define c_mn c_un.c_u_mn
48 };
49
50 /* c_type bits */
51 #define CT_ADDR         1       /* referenced as address */
52 #define CT_DATE         2       /* referenced as date */
53 #define CT_MYMBOX       4       /* "mymbox" test being done */
54 #define CT_ADDRPARSE    8       /* address parse being done */
55
56 extern int fmt_norm;
57
58 struct  comp    *wantcomp[128]; /* hash table for deciding if a
59                                  * component is "interesting" */
60
61 /* 
62  * Hash function for component name.  The function should be
63  * case independent and probably shouldn't involve a routine
64  * call.  This function is pretty good but will not work on
65  * single character component names.  
66  */
67 #define CHASH(nm)       (((((nm)[0]) - ((nm)[1])) & 0x1f) + (((nm)[2]) & 0x5f))
68
69 #ifdef  GOULD_PN
70 /* bug in the Gould PowerNode compiler: need a local pointer to name... */
71 #define FINDCOMP(comp,name1) \
72         { \
73         char *name = (name1); \
74         for (comp = wantcomp[CHASH(name)]; \
75                 comp && strcmp(comp->c_name,name); \
76                 comp = comp->c_next) ; \
77         }
78 #else
79 #define FINDCOMP(comp,name) \
80                 for (comp = wantcomp[CHASH(name)]; \
81                      comp && strcmp(comp->c_name,name); \
82                      comp = comp->c_next) ;
83 #endif
84
85 /*
86  * This structure defines one formatting instruction.
87  */
88 struct format {
89         unsigned char   f_type;
90         char            f_fill;
91         short           f_width;        /* output field width */
92 #define f_skip f_width                  /* instr to skip (false "if") */
93         union {
94                 struct comp     *f_u_comp;      /* associated component */
95                 char            *f_u_text;      /* literal text */
96                 char            f_u_char;       /* literal character */
97                 int             f_u_value;      /* literal value */
98         } f_un;
99 #define f_comp f_un.f_u_comp
100 #define f_text f_un.f_u_text
101 #define f_char f_un.f_u_char
102 #define f_value f_un.f_u_value
103 };
104
105 struct format *fmtscan ();
106 char   *new_fs ();
107 @