3 * fmt_scan.h -- definitions for fmt_scan()
7 * This structure describes an "interesting" component. It holds
8 * the name & text from the component (if found) and one piece of
9 * auxilary info. The structure for a particular component is located
10 * by (open) hashing the name and using it as an index into the ptr array
11 * "wantcomp". All format entries that reference a particular component
12 * point to its comp struct (so we only have to do component specific
13 * processing once. e.g., parse an address.).
16 char *c_name; /* component name (in lower case) */
17 char *c_text; /* component text (if found) */
18 struct comp *c_next; /* hash chain linkage */
19 short c_flags; /* misc. flags (from fmt_scan) */
20 short c_type; /* type info (from fmt_compile) */
23 struct mailname *c_u_mn;
27 #define c_tws c_un.c_u_tws
28 #define c_mn c_un.c_u_mn
33 #define CT_ADDR (1<<0) /* referenced as address */
34 #define CT_DATE (1<<1) /* referenced as date */
39 #define CF_TRUE (1<<0) /* usually means component is present */
40 #define CF_PARSED (1<<1) /* address/date has been parsed */
41 #define CF_DATEFAB (1<<2) /* datefield fabricated */
46 * Hash table for deciding if a component is "interesting".
48 extern struct comp *wantcomp[128];
51 * Hash function for component name. The function should be
52 * case independent and probably shouldn't involve a routine
53 * call. This function is pretty good but will not work on
54 * single character component names.
56 #define CHASH(nm) (((((nm)[0]) - ((nm)[1])) & 0x1f) + (((nm)[2]) & 0x5f))
59 * Find a component in the hash table.
61 #define FINDCOMP(comp,name) \
62 for (comp = wantcomp[CHASH(name)]; \
63 comp && strcmp(comp->c_name,name); \
64 comp = comp->c_next) ;
67 * This structure defines one formatting instruction.
72 short f_width; /* output field width */
74 struct comp *f_u_comp; /* associated component */
75 char *f_u_text; /* literal text */
76 char f_u_char; /* literal character */
77 int f_u_value; /* literal value */
81 #define f_skip f_width /* instr to skip (false "if") */
83 #define f_comp f_un.f_u_comp
84 #define f_text f_un.f_u_text
85 #define f_char f_un.f_u_char
86 #define f_value f_un.f_u_value
91 struct format *fmt_scan (struct format *, char *, int, int *);
92 char *new_fs (char *, char *, char *);
93 int fmt_compile (char *, struct format **);