summaryrefslogtreecommitdiffhomepage
path: root/mixlib/mix_vm_command.h
diff options
context:
space:
mode:
Diffstat (limited to 'mixlib/mix_vm_command.h')
-rw-r--r--mixlib/mix_vm_command.h34
1 files changed, 33 insertions, 1 deletions
diff --git a/mixlib/mix_vm_command.h b/mixlib/mix_vm_command.h
index 4603f78..465ed3e 100644
--- a/mixlib/mix_vm_command.h
+++ b/mixlib/mix_vm_command.h
@@ -79,8 +79,19 @@ typedef enum {
MIX_CMD_TIMING, /* enable/disable timing statistics */
MIX_CMD_DEVDIR, /* print/set device directory */
MIX_CMD_INVALID, /* invalid command identifier */
+ MIX_CMD_LOCAL /* locally defined command */
} mix_vm_command_t;
+/* new commands definition */
+typedef gboolean (*mix_vm_cmd_function_t) (mix_vm_cmd_dispatcher_t *,
+ const gchar *);
+typedef struct {
+ const gchar *name; /* User printable name of the function. */
+ mix_vm_cmd_function_t func; /* Function to call to do the job. */
+ const char *doc; /* Documentation for this function. */
+ const char *usage; /* Usage */
+} mix_vm_command_info_t;
+
/* hook functions, to be invoked before and/or after command execution */
typedef void (*mix_vm_cmd_hook_t)(mix_vm_cmd_dispatcher_t *dis,
const gchar *arg, gpointer data);
@@ -104,7 +115,6 @@ mix_vm_command_help (mix_vm_command_t cmd);
extern const gchar *
mix_vm_command_usage (mix_vm_command_t cmd);
-
/* create a new command dispatcher */
extern mix_vm_cmd_dispatcher_t *
mix_vm_cmd_dispatcher_new (FILE *out, /* output messages file */
@@ -118,7 +128,23 @@ mix_vm_cmd_dispatcher_new_with_config (FILE *out, FILE *err,
extern void
mix_vm_cmd_dispatcher_delete (mix_vm_cmd_dispatcher_t *dis);
+/* register new commands for a dispatcher */
+extern void
+mix_vm_cmd_dispatcher_register_new (mix_vm_cmd_dispatcher_t *dis,
+ mix_vm_command_info_t *cmd);
+
+/* get command completion list */
+const GList *
+mix_vm_cmd_dispatcher_complete (const mix_vm_cmd_dispatcher_t *dis,
+ const gchar *cmd, gchar **prefix);
+
/* set/get out/error streams */
+extern FILE *
+mix_vm_cmd_dispatcher_get_out_stream (const mix_vm_cmd_dispatcher_t *dis);
+
+extern FILE *
+mix_vm_cmd_dispatcher_get_err_stream (const mix_vm_cmd_dispatcher_t *dis);
+
extern FILE * /* old output stream */
mix_vm_cmd_dispatcher_set_out_stream (mix_vm_cmd_dispatcher_t *dis,
FILE *out);
@@ -155,6 +181,12 @@ extern gboolean
mix_vm_cmd_dispatcher_dispatch_text (mix_vm_cmd_dispatcher_t *dis,
const gchar *text);
+/* dispatch a command in text format, with command and arg split */
+extern gboolean
+mix_vm_cmd_dispatcher_dispatch_split_text (mix_vm_cmd_dispatcher_t *dis,
+ const gchar *command,
+ const gchar *arg);
+
/* get the last dispatch's result */
extern gboolean
mix_vm_cmd_dispatcher_get_last_result (const mix_vm_cmd_dispatcher_t *dis);