1 /* formatsbr.h - definitions for fmtscan () */
2 /* $Id: formatsbr.h,v 1.1 1992/01/23 23:14:54 jromine Exp $ */
5 * This structure describes an "interesting" component. It holds
6 * the name & text from the component (if found) and one piece of
7 * auxilary info. The structure for a particular component is located
8 * by hashing the name and using it as an index into the ptr array
9 * "wantcomp". All format entries that reference a particular component
10 * point to its comp struct (so we only have to do component specific
11 * processing once. e.g., parse an address.).
14 char *c_name; /* component name (in lower case) */
15 struct comp *c_next; /* hash chain linkage */
16 char *c_text; /* component text (if found) */
17 short c_flags; /* misc. flags (from formatsbr) */
18 short c_type; /* type info (from fmtcompile) */
21 struct mailname *c_u_mn;
23 #define c_tws c_un.c_u_tws
24 #define c_mn c_un.c_u_mn
28 #define CT_ADDR 1 /* referenced as address */
29 #define CT_DATE 2 /* referenced as date */
30 #define CT_MYMBOX 4 /* "mymbox" test being done */
31 #define CT_ADDRPARSE 8 /* address parse being done */
35 struct comp *wantcomp[128]; /* hash table for deciding if a
36 * component is "interesting" */
39 * Hash function for component name. The function should be
40 * case independent and probably shouldn't involve a routine
41 * call. This function is pretty good but will not work on
42 * single character component names.
44 #define CHASH(nm) (((((nm)[0]) - ((nm)[1])) & 0x1f) + (((nm)[2]) & 0x5f))
47 /* bug in the Gould PowerNode compiler: need a local pointer to name... */
48 #define FINDCOMP(comp,name1) \
50 char *name = (name1); \
51 for (comp = wantcomp[CHASH(name)]; \
52 comp && strcmp(comp->c_name,name); \
53 comp = comp->c_next) ; \
56 #define FINDCOMP(comp,name) \
57 for (comp = wantcomp[CHASH(name)]; \
58 comp && strcmp(comp->c_name,name); \
59 comp = comp->c_next) ;
63 * This structure defines one formatting instruction.
68 short f_width; /* output field width */
69 #define f_skip f_width /* instr to skip (false "if") */
71 struct comp *f_u_comp; /* associated component */
72 char *f_u_text; /* literal text */
73 char f_u_char; /* literal character */
74 int f_u_value; /* literal value */
76 #define f_comp f_un.f_u_comp
77 #define f_text f_un.f_u_text
78 #define f_char f_un.f_u_char
79 #define f_value f_un.f_u_value
82 struct format *fmtscan ();