+ * f_flags bits
+ */
+
+#define FF_STRALLOC (1<<0) /* String has been allocated */
+#define FF_COMPREF (1<<1) /* Component reference */
+
+/*
+ * 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:
+ *
+ * form - Name of format file. Will be searched by etcpath(), see that
+ * function for details.
+ * format - The format string to be used if no format file is given
+ * default_fs - The default format string to be used if neither form nor
+ * format is given
+ *
+ * This function also takes care of processing \ escapes like \n, \t, etc.
+ *
+ * Returns an allocated format string.
+ */
+
+char *new_fs (char *form, char *format, char *default_fs);
+
+/*
+ * Compile a format string into a set of format instructions. Arguments are:
+ *
+ * fstring - The format string (the "source code").
+ * fmt - Returns an allocated array of "struct fmt" elements. Each
+ * struct fmt is one format instruction interpreted by the
+ * format engine.
+ * reset - If set to true, the format compiler will reset the
+ * component hash table. The component hash table contains
+ * all of the references to message components refered to in
+ * the format instructions. If you have multiple format
+ * strings that you want to compile and operate on the
+ * same message, this should be set to false.
+ *
+ * Returns the total number of components referenced by all format instructions
+ * since the last reset of the hash table.
+ */
+
+int fmt_compile (char *fstring, struct format **fmt, int reset);
+
+/*
+ * Interpret a sequence of compiled format instructions. Arguments are:
+ *
+ * format - Array of format instructions generated by fmt_compile()
+ * scanl - Passed-in character array that will contain the output
+ * of the format instructions. Is always terminated with
+ * a newline (\n).
+ * max - Maximum number of bytes to be written to "scanl" (in other
+ * words, the buffer size). Includes the trailing NUL.
+ * width - Maximum number of displayed characters. Does not include
+ * characters marked as nonprinting or (depending on the
+ * encoding) bytes in a multibyte encoding that exceed the
+ * character's column width.
+ * dat - An integer array that contains data used by certain format
+ * functions. Currently the following instructions use
+ * dat[]:
+ *
+ * dat[0] - %(msg), %(dat)
+ * dat[1] - %(cur)
+ * dat[2] - %(size)
+ * 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, struct fmt_callbacks *callbacks);
+
+/*
+ * Free a format structure and/or component hash table. Arguments are:
+ *
+ * format - An array of format structures allocated by fmt_compile,
+ * or NULL.
+ * reset - If true, reset and remove all references in the component
+ * hash table.
+ */
+
+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:
+ *
+ * component - The name of the component to search for. By convention
+ * all component names used in format strings are lower case,
+ * but for backwards compatibility this search is done in
+ * a case-SENSITIVE manner.
+ *
+ * This function returns a "struct comp" corresponding to the named component,
+ * or NULL if the component is not found in the hash table.
+ */
+
+struct comp *fmt_findcomp(char *component);
+
+/*
+ * Search for a component structure in the component hash table.
+ *
+ * Identical to fmd_findcomp(), but is case-INSENSITIVE.