+/*
+ * Compile our format string and save any parameters we care about.
+ */
+
+#define DEFAULT_HEADER "[ Message %{folder}%<{folder}:%>%(msg) ]"
+#define DEFAULT_MARKER "[ part %{part} - %{content-type} - " \
+ "%<{description}%{description}" \
+ "%?{cdispo-filename}%{cdispo-filename}" \
+ "%|%{ctype-name}%> " \
+ "%(kilo(size))B %<(unseen)\\(suppressed\\)%> ]"
+
+static struct format *
+compile_header(char *form)
+{
+ struct format *fmt;
+ char *fmtstring;
+ struct comp *comp = NULL;
+ unsigned int bucket;
+
+ fmtstring = new_fs(form, NULL, DEFAULT_HEADER);
+
+ (void) fmt_compile(fmtstring, &fmt, 1);
+ free_fs();
+
+ while ((comp = fmt_nextcomp(comp, &bucket)) != NULL) {
+ if (strcasecmp(comp->c_name, "folder") == 0) {
+ folder_comp = comp;
+ }
+ }
+
+ return fmt;
+}
+
+static struct format *
+compile_marker(char *form)
+{
+ struct format *fmt;
+ char *fmtstring;
+ struct comp *comp = NULL;
+ unsigned int bucket;
+ struct param_comp_list *pc_entry;
+
+ fmtstring = new_fs(form, NULL, DEFAULT_MARKER);
+
+ (void) fmt_compile(fmtstring, &fmt, 1);
+ free_fs();
+
+ /*
+ * Things we care about:
+ *
+ * part - Part name (e.g., 1.1)
+ * content-type - Content-Type
+ * description - Content-Description
+ * disposition - Content-Disposition (inline, attachment)
+ * ctype-<param> - Content-Type parameter
+ * cdispo-<param> - Content-Disposition parameter
+ */
+
+ while ((comp = fmt_nextcomp(comp, &bucket)) != NULL) {
+ if (strcasecmp(comp->c_name, "part") == 0) {
+ part_comp = comp;
+ } else if (strcasecmp(comp->c_name, "content-type") == 0) {
+ ctype_comp = comp;
+ } else if (strcasecmp(comp->c_name, "description") == 0) {
+ description_comp = comp;
+ } else if (strcasecmp(comp->c_name, "disposition") == 0) {
+ dispo_comp = comp;
+ } else if (strncasecmp(comp->c_name, "ctype-", 6) == 0 &&
+ strlen(comp->c_name) > 6) {
+ NEW(pc_entry);
+ pc_entry->param = mh_xstrdup(comp->c_name + 6);
+ pc_entry->comp = comp;
+ pc_entry->next = ctype_pc_list;
+ ctype_pc_list = pc_entry;
+ } else if (strncasecmp(comp->c_name, "cdispo-", 7) == 0 &&
+ strlen(comp->c_name) > 7) {
+ NEW(pc_entry);
+ pc_entry->param = mh_xstrdup(comp->c_name + 7);
+ pc_entry->comp = comp;
+ pc_entry->next = dispo_pc_list;
+ dispo_pc_list = pc_entry;
+ }
+ }
+
+ return fmt;
+}