summaryrefslogtreecommitdiff
path: root/src/helper
diff options
context:
space:
mode:
authorZachary T Welch <zw@superlucidity.net>2009-11-13 13:25:47 -0800
committerZachary T Welch <zw@superlucidity.net>2009-11-13 13:25:47 -0800
commit98723c4ecdbe06f90c66f3abec27b792c3b38e34 (patch)
treec6ea2a1627e8f7109e3aa0589cd625ac0c740aa7 /src/helper
parentd16968e24f5d9e436ae4e136cd27652c4c948203 (diff)
downloadopenocd_libswd-98723c4ecdbe06f90c66f3abec27b792c3b38e34.tar.gz
openocd_libswd-98723c4ecdbe06f90c66f3abec27b792c3b38e34.tar.bz2
openocd_libswd-98723c4ecdbe06f90c66f3abec27b792c3b38e34.tar.xz
openocd_libswd-98723c4ecdbe06f90c66f3abec27b792c3b38e34.zip
command_context_t -> struct command_context
Remove misleading typedef and redundant suffix from struct command_context.
Diffstat (limited to 'src/helper')
-rw-r--r--src/helper/command.c40
-rw-r--r--src/helper/command.h38
-rw-r--r--src/helper/configuration.c2
-rw-r--r--src/helper/configuration.h6
-rw-r--r--src/helper/ioutil.c2
-rw-r--r--src/helper/log.c6
-rw-r--r--src/helper/log.h6
-rw-r--r--src/helper/options.c4
8 files changed, 52 insertions, 52 deletions
diff --git a/src/helper/command.c b/src/helper/command.c
index 3cd11d21..60a4a26e 100644
--- a/src/helper/command.c
+++ b/src/helper/command.c
@@ -47,7 +47,7 @@
int fast_and_dangerous = 0;
Jim_Interp *interp = NULL;
-static int run_command(command_context_t *context,
+static int run_command(struct command_context *context,
command_t *c, const char *words[], unsigned num_words);
static void tcl_output(void *privData, const char *file, unsigned line,
@@ -57,7 +57,7 @@ static void tcl_output(void *privData, const char *file, unsigned line,
Jim_AppendString(interp, tclOutput, string, strlen(string));
}
-extern command_context_t *global_cmd_ctx;
+extern struct command_context *global_cmd_ctx;
void script_debug(Jim_Interp *interp, const char *name,
unsigned argc, Jim_Obj *const *argv)
@@ -80,7 +80,7 @@ static int script_command(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
/* the private data is stashed in the interp structure */
command_t *c;
- command_context_t *context;
+ struct command_context *context;
int retval;
int i;
int nwords;
@@ -226,7 +226,7 @@ static void command_add_child(struct command_s **head, struct command_s *c)
cc->next = c;
}
-command_t* register_command(command_context_t *context,
+command_t* register_command(struct command_context *context,
command_t *parent, char *name, command_handler_t handler,
enum command_mode mode, char *help)
{
@@ -274,7 +274,7 @@ command_t* register_command(command_context_t *context,
return c;
}
-int unregister_all_commands(command_context_t *context)
+int unregister_all_commands(struct command_context *context)
{
command_t *c, *c2;
@@ -306,7 +306,7 @@ int unregister_all_commands(command_context_t *context)
return ERROR_OK;
}
-int unregister_command(command_context_t *context, char *name)
+int unregister_command(struct command_context *context, char *name)
{
command_t *c, *p = NULL, *c2;
@@ -358,14 +358,14 @@ int unregister_command(command_context_t *context, char *name)
return ERROR_OK;
}
-void command_output_text(command_context_t *context, const char *data)
+void command_output_text(struct command_context *context, const char *data)
{
if (context && context->output_handler && data) {
context->output_handler(context, data);
}
}
-void command_print_sameline(command_context_t *context, const char *format, ...)
+void command_print_sameline(struct command_context *context, const char *format, ...)
{
char *string;
@@ -389,7 +389,7 @@ void command_print_sameline(command_context_t *context, const char *format, ...)
va_end(ap);
}
-void command_print(command_context_t *context, const char *format, ...)
+void command_print(struct command_context *context, const char *format, ...)
{
char *string;
@@ -436,7 +436,7 @@ char *command_name(struct command_s *c, char delim)
return __command_name(c, delim, 0);
}
-static int run_command(command_context_t *context,
+static int run_command(struct command_context *context,
command_t *c, const char *words[], unsigned num_words)
{
int start_word = 0;
@@ -475,7 +475,7 @@ static int run_command(command_context_t *context,
return retval;
}
-int command_run_line(command_context_t *context, char *line)
+int command_run_line(struct command_context *context, char *line)
{
/* all the parent commands have been registered with the interpreter
* so, can just evaluate the line as a script and check for
@@ -545,7 +545,7 @@ int command_run_line(command_context_t *context, char *line)
return retval;
}
-int command_run_linef(command_context_t *context, const char *format, ...)
+int command_run_linef(struct command_context *context, const char *format, ...)
{
int retval = ERROR_FAIL;
char *string;
@@ -560,23 +560,23 @@ int command_run_linef(command_context_t *context, const char *format, ...)
return retval;
}
-void command_set_output_handler(command_context_t* context,
+void command_set_output_handler(struct command_context* context,
command_output_handler_t output_handler, void *priv)
{
context->output_handler = output_handler;
context->output_handler_priv = priv;
}
-command_context_t* copy_command_context(command_context_t* context)
+struct command_context* copy_command_context(struct command_context* context)
{
- command_context_t* copy_context = malloc(sizeof(command_context_t));
+ struct command_context* copy_context = malloc(sizeof(struct command_context));
*copy_context = *context;
return copy_context;
}
-int command_done(command_context_t *context)
+int command_done(struct command_context *context)
{
free(context);
context = NULL;
@@ -764,9 +764,9 @@ COMMAND_HANDLER(handle_fast_command)
}
-command_context_t* command_init()
+struct command_context* command_init()
{
- command_context_t* context = malloc(sizeof(command_context_t));
+ struct command_context* context = malloc(sizeof(struct command_context));
extern const char startup_tcl[];
const char *HostOs;
@@ -846,7 +846,7 @@ command_context_t* command_init()
return context;
}
-int command_context_mode(command_context_t *cmd_ctx, enum command_mode mode)
+int command_context_mode(struct command_context *cmd_ctx, enum command_mode mode)
{
if (!cmd_ctx)
return ERROR_INVALID_ARGUMENTS;
@@ -869,7 +869,7 @@ void process_jim_events(void)
#endif
}
-void register_jim(struct command_context_s *cmd_ctx, const char *name, int (*cmd)(Jim_Interp *interp, int argc, Jim_Obj *const *argv), const char *help)
+void register_jim(struct command_context *cmd_ctx, const char *name, int (*cmd)(Jim_Interp *interp, int argc, Jim_Obj *const *argv), const char *help)
{
Jim_CreateCommand(interp, name, cmd, NULL, NULL);
diff --git a/src/helper/command.h b/src/helper/command.h
index bddb053e..169852ef 100644
--- a/src/helper/command.h
+++ b/src/helper/command.h
@@ -51,13 +51,13 @@ enum command_mode
COMMAND_ANY,
};
-struct command_context_s;
+struct command_context;
/// The type signature for command context's output handler.
-typedef int (*command_output_handler_t)(struct command_context_s *context,
+typedef int (*command_output_handler_t)(struct command_context *context,
const char* line);
-typedef struct command_context_s
+struct command_context
{
enum command_mode mode;
struct command_s *commands;
@@ -78,7 +78,7 @@ typedef struct command_context_s
*/
command_output_handler_t output_handler;
void *output_handler_priv;
-} command_context_t;
+};
/**
@@ -87,7 +87,7 @@ typedef struct command_context_s
* defining all such derivative types using this macro.
*/
#define __COMMAND_HANDLER(name, extra...) \
- int name(struct command_context_s *cmd_ctx, \
+ int name(struct command_context *cmd_ctx, \
const char *args[], unsigned argc, ##extra)
/**
@@ -151,31 +151,31 @@ typedef struct command_s
*/
char *command_name(struct command_s *c, char delim);
-command_t* register_command(command_context_t *context,
+command_t* register_command(struct command_context *context,
command_t *parent, char *name, command_handler_t handler,
enum command_mode mode, char *help);
-int unregister_command(command_context_t *context, char *name);
-int unregister_all_commands(command_context_t *context);
+int unregister_command(struct command_context *context, char *name);
+int unregister_all_commands(struct command_context *context);
-void command_set_output_handler(command_context_t* context,
+void command_set_output_handler(struct command_context* context,
command_output_handler_t output_handler, void *priv);
-command_context_t* copy_command_context(command_context_t* context);
+struct command_context* copy_command_context(struct command_context* context);
-int command_context_mode(command_context_t *context, enum command_mode mode);
+int command_context_mode(struct command_context *context, enum command_mode mode);
-command_context_t* command_init(void);
-int command_done(command_context_t *context);
+struct command_context* command_init(void);
+int command_done(struct command_context *context);
-void command_print(command_context_t *context, const char *format, ...)
+void command_print(struct command_context *context, const char *format, ...)
__attribute__ ((format (PRINTF_ATTRIBUTE_FORMAT, 2, 3)));
-void command_print_sameline(command_context_t *context, const char *format, ...)
+void command_print_sameline(struct command_context *context, const char *format, ...)
__attribute__ ((format (PRINTF_ATTRIBUTE_FORMAT, 2, 3)));
-int command_run_line(command_context_t *context, char *line);
-int command_run_linef(command_context_t *context, const char *format, ...)
+int command_run_line(struct command_context *context, char *line);
+int command_run_linef(struct command_context *context, const char *format, ...)
__attribute__ ((format (PRINTF_ATTRIBUTE_FORMAT, 2, 3)));
-void command_output_text(command_context_t *context, const char *data);
+void command_output_text(struct command_context *context, const char *data);
void process_jim_events(void);
@@ -190,7 +190,7 @@ extern int fast_and_dangerous;
extern Jim_Interp *interp;
-void register_jim(command_context_t *context, const char *name, int (*cmd)(Jim_Interp *interp, int argc, Jim_Obj *const *argv), const char *help);
+void register_jim(struct command_context *context, const char *name, int (*cmd)(Jim_Interp *interp, int argc, Jim_Obj *const *argv), const char *help);
long jim_global_long(const char *variable);
diff --git a/src/helper/configuration.c b/src/helper/configuration.c
index 3c44d6d4..1f7240d9 100644
--- a/src/helper/configuration.c
+++ b/src/helper/configuration.c
@@ -103,7 +103,7 @@ FILE *open_file_from_path (char *file, char *mode)
}
}
-int parse_config_file(struct command_context_s *cmd_ctx)
+int parse_config_file(struct command_context *cmd_ctx)
{
int retval;
char **cfg;
diff --git a/src/helper/configuration.h b/src/helper/configuration.h
index 5d601485..9b77a256 100644
--- a/src/helper/configuration.h
+++ b/src/helper/configuration.h
@@ -25,15 +25,15 @@
#include "command.h"
-int parse_cmdline_args(struct command_context_s *cmd_ctx,
+int parse_cmdline_args(struct command_context *cmd_ctx,
int argc, char *argv[]);
-int parse_config_file(struct command_context_s *cmd_ctx);
+int parse_config_file(struct command_context *cmd_ctx);
void add_config_command(const char *cfg);
void add_script_search_dir(const char *dir);
-int configuration_output_handler(struct command_context_s *cmd_ctx,
+int configuration_output_handler(struct command_context *cmd_ctx,
const char *line);
FILE *open_file_from_path(char *file, char *mode);
diff --git a/src/helper/ioutil.c b/src/helper/ioutil.c
index 3a629611..a9474a63 100644
--- a/src/helper/ioutil.c
+++ b/src/helper/ioutil.c
@@ -645,7 +645,7 @@ static int zylinjtag_Jim_Command_mac(Jim_Interp *interp, int argc,
-int ioutil_init(struct command_context_s *cmd_ctx)
+int ioutil_init(struct command_context *cmd_ctx)
{
register_command(cmd_ctx, NULL, "rm", handle_rm_command, COMMAND_ANY,
"remove file");
diff --git a/src/helper/log.c b/src/helper/log.c
index 1724becc..c6906543 100644
--- a/src/helper/log.c
+++ b/src/helper/log.c
@@ -317,7 +317,7 @@ COMMAND_HANDLER(handle_log_output_command)
return ERROR_OK;
}
-int log_register_commands(struct command_context_s *cmd_ctx)
+int log_register_commands(struct command_context *cmd_ctx)
{
start = timeval_ms();
register_command(cmd_ctx, NULL, "log_output", handle_log_output_command,
@@ -328,7 +328,7 @@ int log_register_commands(struct command_context_s *cmd_ctx)
return ERROR_OK;
}
-int log_init(struct command_context_s *cmd_ctx)
+int log_init(struct command_context *cmd_ctx)
{
/* set defaults for daemon configuration, if not set by cmdline or cfgfile */
if (debug_level == -1)
@@ -344,7 +344,7 @@ int log_init(struct command_context_s *cmd_ctx)
return ERROR_OK;
}
-int set_log_output(struct command_context_s *cmd_ctx, FILE *output)
+int set_log_output(struct command_context *cmd_ctx, FILE *output)
{
log_output = output;
return ERROR_OK;
diff --git a/src/helper/log.h b/src/helper/log.h
index 5742897d..3bf9840a 100644
--- a/src/helper/log.h
+++ b/src/helper/log.h
@@ -66,10 +66,10 @@ void log_printf_lf(enum log_levels level, const char *file, int line,
const char *function, const char *format, ...)
__attribute__ ((format (PRINTF_ATTRIBUTE_FORMAT, 5, 6)));
-int log_init(struct command_context_s *cmd_ctx);
-int set_log_output(struct command_context_s *cmd_ctx, FILE *output);
+int log_init(struct command_context *cmd_ctx);
+int set_log_output(struct command_context *cmd_ctx, FILE *output);
-int log_register_commands(struct command_context_s *cmd_ctx);
+int log_register_commands(struct command_context *cmd_ctx);
void keep_alive(void);
void kept_alive(void);
diff --git a/src/helper/options.c b/src/helper/options.c
index a0c9a9e9..3ffc6736 100644
--- a/src/helper/options.c
+++ b/src/helper/options.c
@@ -46,7 +46,7 @@ static struct option long_options[] =
{0, 0, 0, 0}
};
-int configuration_output_handler(struct command_context_s *context, const char* line)
+int configuration_output_handler(struct command_context *context, const char* line)
{
LOG_USER_N("%s", line);
@@ -108,7 +108,7 @@ static void add_default_dirs(void)
#endif
}
-int parse_cmdline_args(struct command_context_s *cmd_ctx, int argc, char *argv[])
+int parse_cmdline_args(struct command_context *cmd_ctx, int argc, char *argv[])
{
int c;
char command_buffer[128];