X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Futils_cmds.h;h=205e89a0496df73a7b4cb80bc6ce511445113ff3;hb=b42b7eaaaa3d2b375dc17b52f8858c0ebe2f5f40;hp=21564cb855da87049640cc67dd0d1954c9f6b8fe;hpb=938471bee8cc86d32615144c5037f17338b19e70;p=collectd.git diff --git a/src/utils_cmds.h b/src/utils_cmds.h index 21564cb8..205e89a0 100644 --- a/src/utils_cmds.h +++ b/src/utils_cmds.h @@ -34,10 +34,14 @@ typedef enum { CMD_UNKNOWN = 0, CMD_FLUSH = 1, - CMD_PUTVAL = 2, + CMD_GETVAL = 2, + CMD_LISTVAL = 3, + CMD_PUTVAL = 4, } cmd_type_t; #define CMD_TO_STRING(type) \ ((type) == CMD_FLUSH) ? "FLUSH" \ + : ((type) == CMD_GETVAL) ? "GETVAL" \ + : ((type) == CMD_LISTVAL) ? "LISTVAL" \ : ((type) == CMD_PUTVAL) ? "PUTVAL" \ : "UNKNOWN" @@ -51,8 +55,16 @@ typedef struct { } cmd_flush_t; typedef struct { + char *raw_identifier; + identifier_t identifier; +} cmd_getval_t; + +typedef struct { +} cmd_listval_t; + +typedef struct { /* The raw identifier as provided by the user. */ - char *identifier; + char *raw_identifier; /* An array of the fully parsed identifier and all value lists, and their * options as provided by the user. */ @@ -71,12 +83,27 @@ typedef struct { cmd_type_t type; union { cmd_flush_t flush; + cmd_getval_t getval; + cmd_listval_t listval; cmd_putval_t putval; } cmd; } cmd_t; /* * NAME + * cmd_options_t + * + * DESCRIPTIONS + * Optional settings for tuning the parser behavior. + */ +typedef struct { + /* identifier_default_host: If non-NULL, the hostname is optional and will + * default to the specified value. */ + char *identifier_default_host; +} cmd_options_t; + +/* + * NAME * cmd_status_t * * DESCRIPTION @@ -126,16 +153,17 @@ void cmd_error (cmd_status_t status, cmd_error_handler_t *err, * PARAMETERS * `buffer' The command string to be parsed. * `ret_cmd' The parse result will be stored at this location. + * `opts' Parser options. If NULL, defaults will be used. * `err' An optional error handler to invoke on error. * * RETURN VALUE * CMD_OK on success or the respective error code otherwise. */ -cmd_status_t cmd_parse (char *buffer, - cmd_t *ret_cmd, cmd_error_handler_t *err); +cmd_status_t cmd_parse (char *buffer, cmd_t *ret_cmd, + const cmd_options_t *opts, cmd_error_handler_t *err); -cmd_status_t cmd_parsev (size_t argc, char **argv, - cmd_t *ret_cmd, cmd_error_handler_t *err); +cmd_status_t cmd_parsev (size_t argc, char **argv, cmd_t *ret_cmd, + const cmd_options_t *opts, cmd_error_handler_t *err); void cmd_destroy (cmd_t *cmd);