9 date 92.01.23.23.14.54; author jromine; state Exp;
24 @/* formatsbr.h - definitions for fmtscan () */
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.).
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) */
44 struct mailname *c_u_mn;
46 #define c_tws c_un.c_u_tws
47 #define c_mn c_un.c_u_mn
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 */
58 struct comp *wantcomp[128]; /* hash table for deciding if a
59 * component is "interesting" */
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.
67 #define CHASH(nm) (((((nm)[0]) - ((nm)[1])) & 0x1f) + (((nm)[2]) & 0x5f))
70 /* bug in the Gould PowerNode compiler: need a local pointer to name... */
71 #define FINDCOMP(comp,name1) \
73 char *name = (name1); \
74 for (comp = wantcomp[CHASH(name)]; \
75 comp && strcmp(comp->c_name,name); \
76 comp = comp->c_next) ; \
79 #define FINDCOMP(comp,name) \
80 for (comp = wantcomp[CHASH(name)]; \
81 comp && strcmp(comp->c_name,name); \
82 comp = comp->c_next) ;
86 * This structure defines one formatting instruction.
91 short f_width; /* output field width */
92 #define f_skip f_width /* instr to skip (false "if") */
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 */
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
105 struct format *fmtscan ();