]> rtime.felk.cvut.cz Git - sysless.git/blobdiff - libs4c/cmdproc/cmd_proc.h
Fix missing ':' in Emacs setup
[sysless.git] / libs4c / cmdproc / cmd_proc.h
index 64af4dfcd2cdf50f0e964db8562a0ff2e8c129d0..a9b62d5b1ccce6245afe60538e09238e7dc27843 100644 (file)
@@ -112,11 +112,41 @@ int cmd_io_read_bychar(cmd_io_t *cmd_io,void *buf,int count);
 #define CDESM_RD       0x01    /* Value read is possible */
 #define CDESM_WR       0x02    /* Value write is possible */
 #define CDESM_RW       (CDESM_RD|CDESM_WR) /* Both */
-
+#define CDESM_SPACE_SEP 0x20    /* Whitespace separated params - replaces space with '\0' */
+
+/**
+ * Command descriptor.
+ *
+ * Command name may contain the following wildcards:
+ * - '?' stands for one alphanumeric character
+ * - '#' stands for one digit
+ * - '*' stands for any number of alphanumeric characters at the end of the command
+ *
+ * The fnc() function is passed the following information as the param array:
+ *   - param[0] points to the command (the longest sequence of alphanumeric characters)
+ *   If CDESM_OPCHR is specified in the command descriptor then
+ *   - param[1] points to the first wildcard in the command or is NULL for commands without wildcard in the name
+ *   - param[2] points to the operation character (':' or '?') and
+ *   - param[3] points to the string after the operation character (after skipping whitespace)
+ *   If CDESM_OPCHR is not specified then
+ *     If the command name contains a wildcard,
+ *     - param[1] points to the first wildcard in the command and
+ *     If the command has any parameters
+ *     - param[1] or param[2] (depending on the presence of a wildcard)
+ *       points to the beginning of those parameters (after skipping
+ *       whitespace)
+ *
+ *   If CDESM_SPACE_SEP is specified in the command descriptor, then
+ *   the command arguments are split at whitespace by '\0'
+ *   characters and stored in the next unused param elements. Param
+ *   array can contain up to 9 elements.
+ *
+ *   The param elements are always terminated by NULL element.
+ */
 typedef struct cmd_des{
-  int code;
-  int mode;
-  char *name;
+  int code;                    /* Application specific code */
+  int mode;                    /* CDESM_* constants */
+  char *name;                  /* Name of the command with possible wildcards */
   char *help;
   int (*fnc)(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]);
   char *info[];
@@ -168,4 +198,4 @@ int cmd_processor_run(cmd_io_t *cmd_io, cmd_des_t const **commands);
 
 /* Local Variables: */
 /* c-basic-offset: 2 */
-/* End */
+/* End: */