aboutsummaryrefslogtreecommitdiffstats
path: root/src/actionparser.h
diff options
context:
space:
mode:
authorgramanas <anastasis.gramm2@gmail.com>2018-04-15 00:43:08 +0300
committergramanas <anastasis.gramm2@gmail.com>2018-04-15 00:43:08 +0300
commitbc25e14b448edb9f41260a23cf6567e6632db267 (patch)
tree71362a1c8d369f3d0080baee5f98edb3439f3735 /src/actionparser.h
parent0168c10023f0040ae2fa31a212eb6d2e411eefb3 (diff)
downloadck-bc25e14b448edb9f41260a23cf6567e6632db267.tar.gz
ck-bc25e14b448edb9f41260a23cf6567e6632db267.tar.bz2
ck-bc25e14b448edb9f41260a23cf6567e6632db267.zip
dummy init done
action parser conf parser db layer
Diffstat (limited to 'src/actionparser.h')
-rw-r--r--src/actionparser.h70
1 files changed, 70 insertions, 0 deletions
diff --git a/src/actionparser.h b/src/actionparser.h
new file mode 100644
index 0000000..97d9d52
--- /dev/null
+++ b/src/actionparser.h
@@ -0,0 +1,70 @@
+/* actionparser.h - Action parser for ck------------------------*- C -*-
+ *
+ * This file is part of ck, the config keeper
+ *
+ * ---------------------------------------------------------------------
+ *
+ * The code here and in actionparser.c is responsible for parsing
+ * the user's input from the command line and return a struct
+ * of the user's options ready to be handled by the rest of the
+ * procedures.
+ *
+ * Keeps track of what error occured where and provides
+ * printParserHelp() and printParserError() functions
+ * to notify the user
+ *
+ * ------------------------------------------------------------------ */
+#ifndef ACTIONPARSER_H
+#define ACTIONPARSER_H
+
+#define CK_ACTIONS \
+ X(INIT) \
+ X(ADD) \
+ X(DEL) \
+ X(EDIT) \
+ X(LIST) \
+ X(SEARCH) \
+ X(HELP)
+
+typedef enum ParseErrors ParseError;
+enum ParseErrors {
+ PERR_NOERR = 0,
+#define X(ACTION) \
+ PERR_##ACTION##_WRONG,
+ CK_ACTIONS
+#undef X
+ PERR_UNKONW_ACTION,
+};
+
+typedef enum CkActions CkAction;
+enum CkActions {
+ CKA_INIT,
+ CKA_ADD, // program, path, primary, secret
+ CKA_DEL, // program regexp, if only programm, delete everything related
+ CKA_EDIT, // program regexp, if only program, edit primary
+ CKA_LIST, // list_type{tree,paths,programs}
+ CKA_SEARCH, // search_mode, regexp
+ CKA_HELP // help
+};
+
+typedef enum OptParserResults ParseResult;
+enum OptParserResults {
+ OPR_OK,
+ OPR_ERR,
+ OPR_HELP
+};
+
+typedef struct UserOptions UserOpt;
+struct UserOptions {
+ ParseError err;
+ CkAction action;
+ int argc;
+ char *argv[10]; // action's options
+};
+
+
+extern ParseResult parseAction(int argc, char* argv[], UserOpt *opt);
+extern void printParserError();
+extern void printParserHelp();
+
+#endif // ACTIONPARSER_H