cmdline: allow quoted strings
[libcmdline.git] / src / lib / cmdline_parse.h
index 30fe8e9..146f15c 100644 (file)
 #define CMDLINE_PARSE_AMBIGUOUS     -1
 #define CMDLINE_PARSE_NOMATCH       -2
 #define CMDLINE_PARSE_BAD_ARGS      -3
+#define CMDLINE_PARSE_UNTERMINATED_QUOTE -4
 
 /* return status for completion */
 #define CMDLINE_PARSE_COMPLETE_FINISHED 0
 #define CMDLINE_PARSE_COMPLETE_AGAIN    1
 #define CMDLINE_PARSE_COMPLETED_BUFFER  2
 
+#define CMDLINE_MAX_TOKEN_SIZE 128 /* including '\0' */
+
 /**
  * Stores a pointer to the ops struct, and the offset: the place to
  * write the parsed result in the destination structure.
@@ -178,4 +181,10 @@ int cmdline_complete(struct cmdline *cl, const char *buf, int *state,
  * isendofline(c)) */
 int cmdline_isendoftoken(char c);
 
+/* quote a string and escape original quotes */
+int cmdline_quote_token(char *dst, unsigned dstlen, const char *src);
+
+/* remove quote and stop when we reach the end of token */
+int cmdline_unquote_token(char *dst, unsigned dstlen, const char *src);
+
 #endif /* _CMDLINE_PARSE_H_ */