void cf_journal_block(void *ptr, uns len);
/* Declaration */
-void cf_declare_section(byte *name, struct cf_section *sec);
+void cf_declare_section(byte *name, struct cf_section *sec, uns allow_unknown);
void cf_init_section(byte *name, struct cf_section *sec, void *ptr);
/* Safe reloading and loading of configuration files */
byte *cf_parse_double(byte *str, double *ptr);
byte *cf_parse_ip(byte *p, u32 *varp);
+/* Direct access to configuration items */
+
+#define CF_OPERATIONS T(CLOSE) T(SET) T(CLEAR) T(APPEND) T(PREPEND) \
+ T(REMOVE) T(EDIT) T(AFTER) T(BEFORE)
+ /* Closing brace finishes previous block.
+ * Basic attributes (static, dynamic, parsed) can be used with SET.
+ * Dynamic arrays can be used with SET, APPEND, PREPEND.
+ * Sections can be used with SET.
+ * Lists can be used with everything. */
+#define T(x) OP_##x,
+enum operation { CF_OPERATIONS };
+#undef T
+
+byte *cf_find_item(byte *name, struct cf_item *item);
+byte *cf_write_item(struct cf_item *item, enum operation op, int number, byte **pars);
+
+/*
+ * When using cf_get_opt(), you must prefix your own short/long options by the
+ * CF_(SHORT|LONG)_OPTS.
+ *
+ * cf_def_file contains the name of a configuration file that will be
+ * automatically loaded before the first --set option is executed. If no --set
+ * option occurs, it will be loaded after getopt() returns -1 (i.e. at the end
+ * of the configuration options). cf_def_file will be ignored if another
+ * configuration file has already been loaded using the --config option. The
+ * initial value of cf_def_file is DEFAULT_CONFIG from config.h, but you can
+ * override it manually before calling cf_get_opt().
+ */
+
+#define CF_SHORT_OPTS "S:C:"
+#define CF_LONG_OPTS {"set", 1, 0, 'S'}, {"config", 1, 0, 'C'},
+#define CF_NO_LONG_OPTS (const struct option []) { CF_LONG_OPTS { NULL, 0, 0, 0 } }
+#ifndef CF_USAGE_TAB
+#define CF_USAGE_TAB ""
+#endif
+#define CF_USAGE \
+"-S, --set sec.item=val\t" CF_USAGE_TAB "Manual setting of a configuration item\n\
+-C, --config filename\t" CF_USAGE_TAB "Overwrite default configuration file\n"
+
+struct option;
+int cf_get_opt(int argc, char * const argv[], const char *short_opts, const struct option *long_opts, int *long_index);
+
#endif