Move configuration parsing into libcmd
[openafs.git] / src / cmd / cmd.p.h
index 8280614..69b5fea 100644 (file)
@@ -45,6 +45,7 @@ struct cmd_parmdesc {
 #define        CMD_EXPANDS         2   /* if list, try to eat tokens through eoline, instead of just 1 */
 #define CMD_HIDE            4  /* A hidden option */
 #define        CMD_PROCESSED       8
+#define CMD_NOABBRV       16   /* Abbreviation not supported */
 
 struct cmd_syndesc {
     struct cmd_syndesc *next;  /* next one in system list */
@@ -74,8 +75,8 @@ extern int cmd_CreateAlias(struct cmd_syndesc *as, char *aname);
 extern int cmd_Seek(struct cmd_syndesc *as, int apos);
 extern int cmd_AddParm(struct cmd_syndesc *as, char *aname, int atype,
                       afs_int32 aflags, char *ahelp);
-extern int cmd_AddParmAtOffset(struct cmd_syndesc *as, char *name, int atype,
-                             afs_int32 aflags, char *ahelp, int ref);
+extern int cmd_AddParmAtOffset(struct cmd_syndesc *as, int ref, char *name,
+                              int atype, afs_int32 aflags, char *ahelp);
 extern int cmd_AddParmAlias(struct cmd_syndesc *as, int pos, char *alias);
 extern int cmd_Dispatch(int argc, char **argv);
 extern int cmd_FreeArgv(char **argv);
@@ -90,9 +91,37 @@ extern void PrintFlagHelp(struct cmd_syndesc *as);
 extern int cmd_Parse(int argc, char **argv, struct cmd_syndesc **outsyntax);
 extern void cmd_FreeOptions(struct cmd_syndesc **ts);
 extern int cmd_OptionAsInt(struct cmd_syndesc *syn, int pos, int *value);
+extern int cmd_OptionAsUint(struct cmd_syndesc *, int, unsigned int *);
 extern int cmd_OptionAsString(struct cmd_syndesc *syn, int pos, char **value);
 extern int cmd_OptionAsList(struct cmd_syndesc *syn, int pos, struct cmd_item **);
 extern int cmd_OptionAsFlag(struct cmd_syndesc *syn, int pos, int *value);
 extern int cmd_OptionPresent(struct cmd_syndesc *syn, int pos);
 
+/* Config files */
+
+struct cmd_config_binding {
+    enum { cmd_config_string, cmd_config_list } type;
+    char *name;
+    struct cmd_config_binding *next;
+    union {
+       char *string;
+       struct cmd_config_binding *list;
+       void *generic;
+    } u;
+};
+
+/* Raw config file access */
+typedef struct cmd_config_binding cmd_config_binding;
+typedef struct cmd_config_binding cmd_config_section;
+
+extern int cmd_RawConfigParseFileMulti(const char *, cmd_config_section **);
+extern int cmd_RawConfigParseFile(const char *, cmd_config_section **);
+extern int cmd_RawConfigFileFree(cmd_config_section *s);
+extern const char* cmd_RawConfigGetString(const cmd_config_section *,
+                                         const char *, ...);
+extern int cmd_RawConfigGetBool(const cmd_config_section *, int, ...);
+extern int cmd_RawConfigGetInt(const cmd_config_section *, int, ...);
+extern const cmd_config_binding *cmd_RawConfigGetList
+       (const cmd_config_section *, ...);
+
 #endif /* __CMD_INCL__ */