]> diplodocus.org Git - nmh/blobdiff - h/fmt_scan.h
Removed hyphen from all occurrences of RFC-*.
[nmh] / h / fmt_scan.h
index 7e21479ec14b6b8d4ee689ab85b4b7fedc4ab147..50b597e16e6312bc6079dde3eac5e3d388d61fba 100644 (file)
@@ -81,6 +81,21 @@ struct format {
  * prototypes used by the format engine
  */
 
  * 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:
  *
 /*
  * Create a new format string.  Arguments are:
  *
@@ -140,12 +155,20 @@ int fmt_compile (char *fstring, struct format **fmt, int reset);
  *             dat[3] - %(width)
  *             dat[4] - %(unseen)
  *
  *             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,
  * 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:
 
 /*
  * Free a format structure and/or component hash table.  Arguments are:
@@ -158,6 +181,12 @@ struct format *fmt_scan (struct format *format, char *scanl, size_t max,
 
 void fmt_free (struct format *fmt, int reset);
 
 
 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:
  *
 /*
  * Search for a component structure in the component hash table.  Arguments are:
  *
@@ -172,6 +201,25 @@ void fmt_free (struct format *fmt, int reset);
 
 struct comp *fmt_findcomp(char *component);
 
 
 struct comp *fmt_findcomp(char *component);
 
+/*
+ * Search for a component structure in the component hash table.
+ *
+ * Identical to fmd_findcomp(), but is case-INSENSITIVE.
+ */
+
+struct comp *fmt_findcasecomp(char *component);
+
+/*
+ * Add a component entry to the component hash table
+ *
+ * component   - The name of the component to add to the hash table.
+ *
+ * If the component is already in the hash table, this function will do
+ * nothing.  Returns 1 if a component was added, 0 if it already existed.
+ */
+
+int fmt_addcompentry(char *component);
+
 /*
  * Add a string to a component hash table entry.  Arguments are:
  *
 /*
  * Add a string to a component hash table entry.  Arguments are:
  *
@@ -194,16 +242,18 @@ struct comp *fmt_findcomp(char *component);
  *
  * This function is designed to be called when you start processing a new
  * component.  The function returns the integer value of the hash table
  *
  * This function is designed to be called when you start processing a new
  * component.  The function returns the integer value of the hash table
- * bucket corresponding to this component.
+ * bucket corresponding to this component.  If there was no entry found
+ * in the component hash table, this function will return -1.
  */
 
  */
 
-int fmt_addcomp(char *component, char *text);
+int fmt_addcomptext(char *component, char *text);
 
 /*
  * Append to an existing component.  Arguments are:
  *
  * bucket      - The hash table bucket corresponding to this component,
 
 /*
  * Append to an existing component.  Arguments are:
  *
  * bucket      - The hash table bucket corresponding to this component,
- *               as returned by fmt_addcomp().
+ *               as returned by fmt_addcomp().  If -1, this function will
+ *               return with no actions performed.
  * component   - The component to append text to.  Like fmt_addcomp, the
  *               component is searched case-INSENSITIVELY.
  * text                - The text to append to the component.  No special processing
  * component   - The component to append text to.  Like fmt_addcomp, the
  *               component is searched case-INSENSITIVELY.
  * text                - The text to append to the component.  No special processing