X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/a814e2957bf53b2ecef28593f325cd082122ba52..b4f2851d4:/h/fmt_scan.h?ds=inline diff --git a/h/fmt_scan.h b/h/fmt_scan.h index 8de6f23d..4d768b7b 100644 --- a/h/fmt_scan.h +++ b/h/fmt_scan.h @@ -37,6 +37,8 @@ struct comp { #define CT_ADDR (1<<0) /* referenced as address */ #define CT_DATE (1<<1) /* referenced as date */ +#define CT_BITS "\020\01ADDR\02DATE" + /* * c_flags bits */ @@ -45,7 +47,7 @@ struct comp { #define CF_DATEFAB (1<<2) /* datefield fabricated */ #define CF_TRIMMED (1<<3) /* Component has been trimmed */ -extern int fmt_norm; +#define CF_BITS "\020\01TRUE\02PARSED\03CF_DATEFAB\04TRIMMED" /* * This structure defines one formatting instruction. @@ -81,6 +83,21 @@ struct format { * prototypes used by the format engine */ +/* + * These are the definitions used by the callbacks for fmt_scan() + */ + +typedef char * (*formataddr_cb)(char *, char *); +typedef char * (*concataddr_cb)(char *, char *); +typedef void (*trace_cb)(void *, struct format *, int, char *, char *); + +struct fmt_callbacks { + formataddr_cb formataddr; + concataddr_cb concataddr; + trace_cb trace_func; + void * trace_context; +}; + /* * Create a new format string. Arguments are: * @@ -140,12 +157,20 @@ int fmt_compile (char *fstring, struct format **fmt, int reset); * dat[3] - %(width) * dat[4] - %(unseen) * + * callbacks - A set of a callback functions used by the format engine. + * Can be NULL. If structure elements are NULL, a default + * function will be used. Callback structure elements are: + * + * formataddr - A callback for the %(formataddr) instruction + * concataddr - A callback for the %(concataddr) instruction + * trace - Called for every format instruction executed + * * The return value is a pointer to the next format instruction to * execute, which is currently always NULL. */ struct format *fmt_scan (struct format *format, char *scanl, size_t max, - int width, int *dat); + int width, int *dat, struct fmt_callbacks *callbacks); /* * Free a format structure and/or component hash table. Arguments are: @@ -158,6 +183,12 @@ struct format *fmt_scan (struct format *format, char *scanl, size_t max, void fmt_free (struct format *fmt, int reset); +/* + * Free all of the component text structures in the component hash table + */ + +void fmt_freecomptext(void); + /* * Search for a component structure in the component hash table. Arguments are: *