The coding style guidelines include the following:
- Pick a unique name prefix (ending with an underscore) for each
module, and apply that prefix to all of that module's externally
visible names. Names of macro parameters, struct and union members,
and parameters in function prototypes are not considered externally
visible for this purpose.
This patch adds the new prefix to the externally visible names. This
makes it a bit more obvious what code is coming from common command
line handling code.
Signed-off-by: Russell Bryant <rbryant@redhat.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
27 files changed:
* passed to getopt() with the corresponding short options. The caller is
* responsible for freeing the string. */
char *
* passed to getopt() with the corresponding short options. The caller is
* responsible for freeing the string. */
char *
-long_options_to_short_options(const struct option options[])
+ovs_cmdl_long_options_to_short_options(const struct option options[])
{
char short_options[UCHAR_MAX * 3 + 1];
char *p = short_options;
{
char short_options[UCHAR_MAX * 3 + 1];
char *p = short_options;
return xstrdup(short_options);
}
return xstrdup(short_options);
}
-/* Given the 'struct command' array, prints the usage of all commands. */
+/* Given the 'struct ovs_cmdl_command' array, prints the usage of all commands. */
-print_commands(const struct command commands[])
+ovs_cmdl_print_commands(const struct ovs_cmdl_command commands[])
{
struct ds ds = DS_EMPTY_INITIALIZER;
ds_put_cstr(&ds, "The available commands are:\n");
for (; commands->name; commands++) {
{
struct ds ds = DS_EMPTY_INITIALIZER;
ds_put_cstr(&ds, "The available commands are:\n");
for (; commands->name; commands++) {
- const struct command *c = commands;
+ const struct ovs_cmdl_command *c = commands;
ds_put_format(&ds, " %-23s %s\n", c->name, c->usage ? c->usage : "");
}
printf("%s", ds.string);
ds_put_format(&ds, " %-23s %s\n", c->name, c->usage ? c->usage : "");
}
printf("%s", ds.string);
/* Given the GNU-style options in 'options', prints all options. */
void
/* Given the GNU-style options in 'options', prints all options. */
void
-print_options(const struct option options[])
+ovs_cmdl_print_options(const struct option options[])
{
struct ds ds = DS_EMPTY_INITIALIZER;
{
struct ds ds = DS_EMPTY_INITIALIZER;
* Command-line options should be stripped off, so that a typical invocation
* looks like "run_command(argc - optind, argv + optind, my_commands);". */
void
* Command-line options should be stripped off, so that a typical invocation
* looks like "run_command(argc - optind, argv + optind, my_commands);". */
void
-run_command(int argc, char *argv[], const struct command commands[])
+ovs_cmdl_run_command(int argc, char *argv[], const struct ovs_cmdl_command commands[])
- const struct command *p;
+ const struct ovs_cmdl_command *p;
if (argc < 1) {
ovs_fatal(0, "missing command name; use --help for help");
if (argc < 1) {
ovs_fatal(0, "missing command name; use --help for help");
* before anything else, period, at the very beginning of program
* execution. */
void
* before anything else, period, at the very beginning of program
* execution. */
void
-proctitle_init(int argc, char **argv)
+ovs_cmdl_proctitle_init(int argc, char **argv)
/* Changes the name of the process, as shown by "ps", to the program name
* followed by 'format', which is formatted as if by printf(). */
void
/* Changes the name of the process, as shown by "ps", to the program name
* followed by 'format', which is formatted as if by printf(). */
void
-proctitle_set(const char *format, ...)
+ovs_cmdl_proctitle_set(const char *format, ...)
/* Restores the process's original command line, as seen by "ps". */
void
/* Restores the process's original command line, as seen by "ps". */
void
+ovs_cmdl_proctitle_restore(void)
{
ovs_mutex_lock(&proctitle_mutex);
if (saved_proctitle) {
{
ovs_mutex_lock(&proctitle_mutex);
if (saved_proctitle) {
/* Stubs that don't do anything on non-Linux systems. */
void
/* Stubs that don't do anything on non-Linux systems. */
void
-proctitle_init(int argc OVS_UNUSED, char **argv OVS_UNUSED)
+ovs_cmdl_proctitle_init(int argc OVS_UNUSED, char **argv OVS_UNUSED)
{
}
#if !(defined(__FreeBSD__) || defined(__NetBSD__))
/* On these platforms we #define this to setproctitle. */
void
{
}
#if !(defined(__FreeBSD__) || defined(__NetBSD__))
/* On these platforms we #define this to setproctitle. */
void
-proctitle_set(const char *format OVS_UNUSED, ...)
+ovs_cmdl_proctitle_set(const char *format OVS_UNUSED, ...)
+ovs_cmdl_proctitle_restore(void)
{
}
#endif /* !__linux__ */
{
}
#endif /* !__linux__ */
+struct ovs_cmdl_command {
const char *name;
const char *usage;
int min_args;
const char *name;
const char *usage;
int min_args;
void (*handler)(int argc, char *argv[]);
};
void (*handler)(int argc, char *argv[]);
};
-char *long_options_to_short_options(const struct option *options);
-void print_options(const struct option *options);
-void print_commands(const struct command *commands);
-void run_command(int argc, char *argv[], const struct command[]);
+char *ovs_cmdl_long_options_to_short_options(const struct option *options);
+void ovs_cmdl_print_options(const struct option *options);
+void ovs_cmdl_print_commands(const struct ovs_cmdl_command *commands);
+void ovs_cmdl_run_command(int argc, char *argv[], const struct ovs_cmdl_command[]);
-void proctitle_init(int argc, char **argv);
+void ovs_cmdl_proctitle_init(int argc, char **argv);
#if defined(__FreeBSD__) || defined(__NetBSD__)
#if defined(__FreeBSD__) || defined(__NetBSD__)
-#define proctitle_set setproctitle
+#define ovs_cmdl_proctitle_set setproctitle
-void proctitle_set(const char *, ...)
+void ovs_cmdl_proctitle_set(const char *, ...)
OVS_PRINTF_FORMAT(1, 2);
#endif
OVS_PRINTF_FORMAT(1, 2);
#endif
-void proctitle_restore(void);
+void ovs_cmdl_proctitle_restore(void);
#endif /* command-line.h */
#endif /* command-line.h */
- proctitle_set("monitoring pid %lu (%s)",
- (unsigned long int) daemon_pid, status_msg);
+ ovs_cmdl_proctitle_set("monitoring pid %lu (%s)",
+ (unsigned long int) daemon_pid, status_msg);
free(status_msg);
/* Running in new daemon process. */
free(status_msg);
/* Running in new daemon process. */
+ ovs_cmdl_proctitle_restore();
set_subprogram_name("");
}
set_subprogram_name("");
}
const char *database;
struct jsonrpc *rpc;
const char *database;
struct jsonrpc *rpc;
- proctitle_init(argc, argv);
+ ovs_cmdl_proctitle_init(argc, argv);
set_program_name(argv[0]);
parse_options(argc, argv);
fatal_ignore_sigpipe();
set_program_name(argv[0]);
parse_options(argc, argv);
fatal_ignore_sigpipe();
TABLE_LONG_OPTIONS,
{NULL, 0, NULL, 0},
};
TABLE_LONG_OPTIONS,
{NULL, 0, NULL, 0},
};
- char *short_options = long_options_to_short_options(long_options);
+ char *short_options = ovs_cmdl_long_options_to_short_options(long_options);
- proctitle_init(argc, argv);
+ ovs_cmdl_proctitle_init(argc, argv);
set_program_name(argv[0]);
service_start(&argc, &argv);
fatal_ignore_sigpipe();
set_program_name(argv[0]);
service_start(&argc, &argv);
fatal_ignore_sigpipe();
{"ca-cert", required_argument, NULL, 'C'},
{NULL, 0, NULL, 0},
};
{"ca-cert", required_argument, NULL, 'C'},
{NULL, 0, NULL, 0},
};
- char *short_options = long_options_to_short_options(long_options);
+ char *short_options = ovs_cmdl_long_options_to_short_options(long_options);
int argc = *argcp;
char **argv = *argvp;
int argc = *argcp;
char **argv = *argvp;
/* -m, --more: Verbosity level for "show-log" command output. */
static int show_log_verbosity;
/* -m, --more: Verbosity level for "show-log" command output. */
static int show_log_verbosity;
-static const struct command *get_all_commands(void);
+static const struct ovs_cmdl_command *get_all_commands(void);
OVS_NO_RETURN static void usage(void);
static void parse_options(int argc, char *argv[]);
OVS_NO_RETURN static void usage(void);
static void parse_options(int argc, char *argv[]);
set_program_name(argv[0]);
parse_options(argc, argv);
fatal_ignore_sigpipe();
set_program_name(argv[0]);
parse_options(argc, argv);
fatal_ignore_sigpipe();
- run_command(argc - optind, argv + optind, get_all_commands());
+ ovs_cmdl_run_command(argc - optind, argv + optind, get_all_commands());
{"version", no_argument, NULL, 'V'},
{NULL, 0, NULL, 0},
};
{"version", no_argument, NULL, 'V'},
{NULL, 0, NULL, 0},
};
- char *short_options = long_options_to_short_options(long_options);
+ char *short_options = ovs_cmdl_long_options_to_short_options(long_options);
- print_options(long_options);
+ ovs_cmdl_print_options(long_options);
exit(EXIT_SUCCESS);
case 'V':
exit(EXIT_SUCCESS);
case 'V':
static void
do_list_commands(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
{
static void
do_list_commands(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
{
- print_commands(get_all_commands());
+ ovs_cmdl_print_commands(get_all_commands());
-static const struct command all_commands[] = {
+static const struct ovs_cmdl_command all_commands[] = {
{ "create", "[db [schema]]", 0, 2, do_create },
{ "compact", "[db [dst]]", 0, 2, do_compact },
{ "convert", "[db [schema [dst]]]", 0, 3, do_convert },
{ "create", "[db [schema]]", 0, 2, do_create },
{ "compact", "[db [dst]]", 0, 2, do_compact },
{ "convert", "[db [schema [dst]]]", 0, 3, do_convert },
{ NULL, NULL, 0, 0, NULL },
};
{ NULL, NULL, 0, 0, NULL },
};
-static const struct command *get_all_commands(void)
+static const struct ovs_cmdl_command *get_all_commands(void)
#include "ovstest.h"
#include "util.h"
#include "ovstest.h"
#include "util.h"
-static struct command *commands = NULL;
+static struct ovs_cmdl_command *commands = NULL;
static size_t n_commands = 0;
static size_t allocated_commands = 0;
static void
static size_t n_commands = 0;
static size_t allocated_commands = 0;
static void
-add_command(struct command *cmd)
+add_command(struct ovs_cmdl_command *cmd)
- const struct command nil = {NULL, NULL, 0, 0, NULL};
+ const struct ovs_cmdl_command nil = {NULL, NULL, 0, 0, NULL};
while (n_commands + 1 >= allocated_commands) {
commands = x2nrealloc(commands, &allocated_commands,
while (n_commands + 1 >= allocated_commands) {
commands = x2nrealloc(commands, &allocated_commands,
static void
help(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
{
static void
help(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
{
- const struct command *p;
+ const struct ovs_cmdl_command *p;
struct ds test_names = DS_EMPTY_INITIALIZER;
const int linesize = 70;
struct ds test_names = DS_EMPTY_INITIALIZER;
const int linesize = 70;
static void
add_top_level_commands(void)
{
static void
add_top_level_commands(void)
{
- struct command help_cmd = {"--help", NULL, 0, 0, help};
+ struct ovs_cmdl_command help_cmd = {"--help", NULL, 0, 0, help};
add_command(&help_cmd);
}
add_command(&help_cmd);
}
void
ovstest_register(const char *test_name, ovstest_func f)
{
void
ovstest_register(const char *test_name, ovstest_func f)
{
- struct command test_cmd;
+ struct ovs_cmdl_command test_cmd;
test_cmd.name = test_name;
test_cmd.usage = NULL;
test_cmd.name = test_name;
test_cmd.usage = NULL;
add_top_level_commands();
if (argc > 1) {
add_top_level_commands();
if (argc > 1) {
- run_command(argc - 1, argv + 1, commands);
+ ovs_cmdl_run_command(argc - 1, argv + 1, commands);
-static const struct command commands[] = {
+static const struct ovs_cmdl_command commands[] = {
{"check", NULL, 0, 0, run_tests},
{"benchmark", NULL, 1, 1, run_benchmarks},
{NULL, NULL, 0, 0, NULL},
{"check", NULL, 0, 0, run_tests},
{"benchmark", NULL, 1, 1, run_benchmarks},
{NULL, NULL, 0, 0, NULL},
test_bitmap_main(int argc, char *argv[])
{
set_program_name(argv[0]);
test_bitmap_main(int argc, char *argv[])
{
set_program_name(argv[0]);
- run_command(argc - 1, argv + 1, commands);
+ ovs_cmdl_run_command(argc - 1, argv + 1, commands);
}
OVSTEST_REGISTER("test-bitmap", test_bitmap_main);
}
OVSTEST_REGISTER("test-bitmap", test_bitmap_main);
minimask_destroy(&minicatchall);
}
\f
minimask_destroy(&minicatchall);
}
\f
-static const struct command commands[] = {
+static const struct ovs_cmdl_command commands[] = {
/* Classifier tests. */
{"empty", NULL, 0, 0, test_empty},
{"destroy-null", NULL, 0, 0, test_destroy_null},
/* Classifier tests. */
{"empty", NULL, 0, 0, test_empty},
{"destroy-null", NULL, 0, 0, test_destroy_null},
{
set_program_name(argv[0]);
init_values();
{
set_program_name(argv[0]);
init_values();
- run_command(argc - 1, argv + 1, commands);
+ ovs_cmdl_run_command(argc - 1, argv + 1, commands);
}
OVSTEST_REGISTER("test-classifier", test_classifier_main);
}
OVSTEST_REGISTER("test-classifier", test_classifier_main);
-static const struct command commands[] = {
+static const struct ovs_cmdl_command commands[] = {
{"check", NULL, 0, 1, run_tests},
{"benchmark", NULL, 3, 4, run_benchmarks},
{NULL, NULL, 0, 0, NULL},
{"check", NULL, 0, 1, run_tests},
{"benchmark", NULL, 3, 4, run_benchmarks},
{NULL, NULL, 0, 0, NULL},
test_cmap_main(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
{
set_program_name(argv[0]);
test_cmap_main(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
{
set_program_name(argv[0]);
- run_command(argc - optind, argv + optind, commands);
+ ovs_cmdl_run_command(argc - optind, argv + optind, commands);
}
OVSTEST_REGISTER("test-cmap", test_cmap_main);
}
OVSTEST_REGISTER("test-cmap", test_cmap_main);
-static const struct command commands[] = {
+static const struct ovs_cmdl_command commands[] = {
{ "insert-delete-same-order", NULL, 0, 0,
test_heap_insert_delete_same_order, },
{ "insert-delete-reverse-order", NULL, 0, 0,
{ "insert-delete-same-order", NULL, 0, 0,
test_heap_insert_delete_same_order, },
{ "insert-delete-reverse-order", NULL, 0, 0,
{
set_program_name(argv[0]);
{
set_program_name(argv[0]);
- run_command(argc - 1, argv + 1, commands);
+ ovs_cmdl_run_command(argc - 1, argv + 1, commands);
}
OVSTEST_REGISTER("test-heap", test_heap_main);
}
OVSTEST_REGISTER("test-heap", test_heap_main);
OVS_NO_RETURN static void usage(void);
static void parse_options(int argc, char *argv[]);
OVS_NO_RETURN static void usage(void);
static void parse_options(int argc, char *argv[]);
-static struct command *get_all_commands(void);
+static struct ovs_cmdl_command *get_all_commands(void);
static void
test_jsonrpc_main(int argc, char *argv[])
{
static void
test_jsonrpc_main(int argc, char *argv[])
{
- proctitle_init(argc, argv);
+ ovs_cmdl_proctitle_init(argc, argv);
set_program_name(argv[0]);
service_start(&argc, &argv);
parse_options(argc, argv);
set_program_name(argv[0]);
service_start(&argc, &argv);
parse_options(argc, argv);
- run_command(argc - optind, argv + optind, get_all_commands());
+ ovs_cmdl_run_command(argc - optind, argv + optind, get_all_commands());
STREAM_SSL_LONG_OPTIONS,
{NULL, 0, NULL, 0},
};
STREAM_SSL_LONG_OPTIONS,
{NULL, 0, NULL, 0},
};
- char *short_options = long_options_to_short_options(long_options);
+ char *short_options = ovs_cmdl_long_options_to_short_options(long_options);
for (;;) {
int c = getopt_long(argc, argv, short_options, long_options, NULL);
for (;;) {
int c = getopt_long(argc, argv, short_options, long_options, NULL);
-static struct command all_commands[] = {
+static struct ovs_cmdl_command all_commands[] = {
{ "listen", NULL, 1, 1, do_listen },
{ "request", NULL, 3, 3, do_request },
{ "notify", NULL, 3, 3, do_notify },
{ "listen", NULL, 1, 1, do_listen },
{ "request", NULL, 3, 3, do_request },
{ "notify", NULL, 3, 3, do_notify },
{ NULL, NULL, 0, 0, NULL },
};
{ NULL, NULL, 0, 0, NULL },
};
+static struct ovs_cmdl_command *
get_all_commands(void)
{
return all_commands;
get_all_commands(void)
{
return all_commands;
- proctitle_init(argc, argv);
+ ovs_cmdl_proctitle_init(argc, argv);
set_program_name(argv[0]);
service_start(&argc, &argv);
parse_options(argc, argv);
set_program_name(argv[0]);
service_start(&argc, &argv);
parse_options(argc, argv);
VLOG_LONG_OPTIONS,
{NULL, 0, NULL, 0},
};
VLOG_LONG_OPTIONS,
{NULL, 0, NULL, 0},
};
- char *short_options = long_options_to_short_options(long_options);
+ char *short_options = ovs_cmdl_long_options_to_short_options(long_options);
for (;;) {
int c = getopt_long(argc, argv, short_options, long_options, NULL);
for (;;) {
int c = getopt_long(argc, argv, short_options, long_options, NULL);
OVS_NO_RETURN static void usage(void);
static void parse_options(int argc, char *argv[]);
OVS_NO_RETURN static void usage(void);
static void parse_options(int argc, char *argv[]);
-static struct command *get_all_commands(void);
+static struct ovs_cmdl_command *get_all_commands(void);
int
main(int argc, char *argv[])
{
set_program_name(argv[0]);
parse_options(argc, argv);
int
main(int argc, char *argv[])
{
set_program_name(argv[0]);
parse_options(argc, argv);
- run_command(argc - optind, argv + optind, get_all_commands());
+ ovs_cmdl_run_command(argc - optind, argv + optind, get_all_commands());
{"help", no_argument, NULL, 'h'},
{NULL, 0, NULL, 0},
};
{"help", no_argument, NULL, 'h'},
{NULL, 0, NULL, 0},
};
- char *short_options = long_options_to_short_options(long_options);
+ char *short_options = ovs_cmdl_long_options_to_short_options(long_options);
for (;;) {
unsigned long int timeout;
for (;;) {
unsigned long int timeout;
static void
do_transact(int argc, char *argv[])
{
static void
do_transact(int argc, char *argv[])
{
- static const struct command do_transact_commands[] = {
+ static const struct ovs_cmdl_command do_transact_commands[] = {
{ "commit", NULL, 0, 0, do_transact_commit },
{ "abort", NULL, 0, 0, do_transact_abort },
{ "insert", NULL, 2, 3, do_transact_insert },
{ "commit", NULL, 0, 0, do_transact_commit },
{ "abort", NULL, 0, 0, do_transact_abort },
{ "insert", NULL, 2, 3, do_transact_insert },
fputs(args[j], stdout);
}
fputs(":", stdout);
fputs(args[j], stdout);
}
fputs(":", stdout);
- run_command(n_args, args, do_transact_commands);
+ ovs_cmdl_run_command(n_args, args, do_transact_commands);
putchar('\n');
for (j = 0; j < n_args; j++) {
putchar('\n');
for (j = 0; j < n_args; j++) {
printf("%03d: done\n", step);
}
printf("%03d: done\n", step);
}
-static struct command all_commands[] = {
+static struct ovs_cmdl_command all_commands[] = {
{ "log-io", NULL, 2, INT_MAX, do_log_io },
{ "default-atoms", NULL, 0, 0, do_default_atoms },
{ "default-data", NULL, 0, 0, do_default_data },
{ "log-io", NULL, 2, INT_MAX, do_log_io },
{ "default-atoms", NULL, 0, 0, do_default_atoms },
{ "default-data", NULL, 0, 0, do_default_data },
{ NULL, NULL, 0, 0, NULL },
};
{ NULL, NULL, 0, 0, NULL },
};
+static struct ovs_cmdl_command *
get_all_commands(void)
{
return all_commands;
get_all_commands(void)
{
return all_commands;
static void diff_stats(const struct reconnect_stats *old,
const struct reconnect_stats *new,
int delta);
static void diff_stats(const struct reconnect_stats *old,
const struct reconnect_stats *new,
int delta);
-static const struct command *get_all_commands(void);
+static const struct ovs_cmdl_command *get_all_commands(void);
static void
test_reconnect_main(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
static void
test_reconnect_main(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
svec_parse_words(&args, line);
svec_terminate(&args);
if (!svec_is_empty(&args)) {
svec_parse_words(&args, line);
svec_terminate(&args);
if (!svec_is_empty(&args)) {
- run_command(args.n, args.names, get_all_commands());
+ ovs_cmdl_run_command(args.n, args.names, get_all_commands());
reconnect_listen_error(reconnect, now, atoi(argv[1]));
}
reconnect_listen_error(reconnect, now, atoi(argv[1]));
}
-static const struct command all_commands[] = {
+static const struct ovs_cmdl_command all_commands[] = {
{ "enable", NULL, 0, 0, do_enable },
{ "disable", NULL, 0, 0, do_disable },
{ "force-reconnect", NULL, 0, 0, do_force_reconnect },
{ "enable", NULL, 0, 0, do_enable },
{ "disable", NULL, 0, 0, do_disable },
{ "force-reconnect", NULL, 0, 0, do_force_reconnect },
{ NULL, NULL, 0, 0, NULL },
};
{ NULL, NULL, 0, 0, NULL },
};
-static const struct command *
+static const struct ovs_cmdl_command *
get_all_commands(void)
{
return all_commands;
get_all_commands(void)
{
return all_commands;
- proctitle_init(argc, argv);
+ ovs_cmdl_proctitle_init(argc, argv);
set_program_name(argv[0]);
service_start(&argc, &argv);
parse_options(argc, argv);
set_program_name(argv[0]);
service_start(&argc, &argv);
parse_options(argc, argv);
VLOG_LONG_OPTIONS,
{NULL, 0, NULL, 0},
};
VLOG_LONG_OPTIONS,
{NULL, 0, NULL, 0},
};
- char *short_options = long_options_to_short_options(long_options);
+ char *short_options = ovs_cmdl_long_options_to_short_options(long_options);
for (;;) {
int c = getopt_long(argc, argv, short_options, long_options, NULL);
for (;;) {
int c = getopt_long(argc, argv, short_options, long_options, NULL);
-static const struct command commands[] = {
+static const struct ovs_cmdl_command commands[] = {
{"ctz", NULL, 0, 0, test_ctz},
{"clz", NULL, 0, 0, test_clz},
{"round_up_pow2", NULL, 0, 0, test_round_up_pow2},
{"ctz", NULL, 0, 0, test_ctz},
{"clz", NULL, 0, 0, test_clz},
{"round_up_pow2", NULL, 0, 0, test_round_up_pow2},
VLOG_LONG_OPTIONS,
{NULL, 0, NULL, 0},
};
VLOG_LONG_OPTIONS,
{NULL, 0, NULL, 0},
};
- char *short_options = long_options_to_short_options(long_options);
+ char *short_options = ovs_cmdl_long_options_to_short_options(long_options);
for (;;) {
int c = getopt_long(argc, argv, short_options, long_options, NULL);
for (;;) {
int c = getopt_long(argc, argv, short_options, long_options, NULL);
* POSIX doesn't define the circumstances in which stderr is
* fully buffered either. */
setvbuf(stderr, NULL, _IONBF, 0);
* POSIX doesn't define the circumstances in which stderr is
* fully buffered either. */
setvbuf(stderr, NULL, _IONBF, 0);
- run_command(argc - optind, argv + optind, commands);
+ ovs_cmdl_run_command(argc - optind, argv + optind, commands);
}
OVSTEST_REGISTER("test-util", test_util_main);
}
OVSTEST_REGISTER("test-util", test_util_main);
-static const struct command commands[] = {
+static const struct ovs_cmdl_command commands[] = {
{"refuse-connection", NULL, 1, 1, test_refuse_connection},
{"accept-then-close", NULL, 1, 1, test_accept_then_close},
{"read-hello", NULL, 1, 1, test_read_hello},
{"refuse-connection", NULL, 1, 1, test_refuse_connection},
{"accept-then-close", NULL, 1, 1, test_accept_then_close},
{"read-hello", NULL, 1, 1, test_read_hello},
- run_command(argc - 1, argv + 1, commands);
+ ovs_cmdl_run_command(argc - 1, argv + 1, commands);
}
OVSTEST_REGISTER("test-vconn", test_vconn_main);
}
OVSTEST_REGISTER("test-vconn", test_vconn_main);
VLOG_LONG_OPTIONS,
{NULL, 0, NULL, 0},
};
VLOG_LONG_OPTIONS,
{NULL, 0, NULL, 0},
};
- char *short_options_ = long_options_to_short_options(long_options);
+ char *short_options_ = ovs_cmdl_long_options_to_short_options(long_options);
char *short_options = xasprintf("+%s", short_options_);
const char *target;
int e_options;
char *short_options = xasprintf("+%s", short_options_);
const char *target;
int e_options;
- print_options(long_options);
+ ovs_cmdl_print_options(long_options);
exit(EXIT_SUCCESS);
case 'T':
exit(EXIT_SUCCESS);
case 'T':
-static const struct command *get_all_commands(void);
+static const struct ovs_cmdl_command *get_all_commands(void);
static void parse_options(int argc, char *argv[]);
static void usage(void);
static void parse_options(int argc, char *argv[]);
static void usage(void);
set_program_name(argv[0]);
vlog_set_levels(NULL, VLF_ANY_DESTINATION, VLL_EMER);
parse_options(argc, argv);
set_program_name(argv[0]);
vlog_set_levels(NULL, VLF_ANY_DESTINATION, VLL_EMER);
parse_options(argc, argv);
- run_command(argc - optind, argv + optind, get_all_commands());
+ ovs_cmdl_run_command(argc - optind, argv + optind, get_all_commands());
{"version", no_argument, NULL, 'V'},
{NULL, 0, NULL, 0},
};
{"version", no_argument, NULL, 'V'},
{NULL, 0, NULL, 0},
};
- char *short_options = long_options_to_short_options(long_options);
+ char *short_options = ovs_cmdl_long_options_to_short_options(long_options);
local_addr.s_addr = htonl(INADDR_ANY);
local_min_port = local_max_port = 0;
local_addr.s_addr = htonl(INADDR_ANY);
local_min_port = local_max_port = 0;
-static const struct command all_commands[] = {
+static const struct ovs_cmdl_command all_commands[] = {
{ "listen", NULL, 0, 0, cmd_listen },
{ "rate", NULL, 0, 0, cmd_rate },
{ "latency", NULL, 0, 0, cmd_latency },
{ "listen", NULL, 0, 0, cmd_listen },
{ "rate", NULL, 0, 0, cmd_rate },
{ "latency", NULL, 0, 0, cmd_latency },
{ NULL, NULL, 0, 0, NULL },
};
{ NULL, NULL, 0, 0, NULL },
};
-static const struct command *get_all_commands(void)
+static const struct ovs_cmdl_command *get_all_commands(void)
VLOG_LONG_OPTIONS,
{NULL, 0, NULL, 0},
};
VLOG_LONG_OPTIONS,
{NULL, 0, NULL, 0},
};
- char *short_options = long_options_to_short_options(long_options);
+ char *short_options = ovs_cmdl_long_options_to_short_options(long_options);
for (;;) {
unsigned long int timeout;
for (;;) {
unsigned long int timeout;
- print_options(long_options);
+ ovs_cmdl_print_options(long_options);
exit(EXIT_SUCCESS);
case 'V':
exit(EXIT_SUCCESS);
case 'V':
static struct sort_criterion *criteria;
static size_t n_criteria, allocated_criteria;
static struct sort_criterion *criteria;
static size_t n_criteria, allocated_criteria;
-static const struct command *get_all_commands(void);
+static const struct ovs_cmdl_command *get_all_commands(void);
OVS_NO_RETURN static void usage(void);
static void parse_options(int argc, char *argv[]);
OVS_NO_RETURN static void usage(void);
static void parse_options(int argc, char *argv[]);
service_start(&argc, &argv);
parse_options(argc, argv);
fatal_ignore_sigpipe();
service_start(&argc, &argv);
parse_options(argc, argv);
fatal_ignore_sigpipe();
- run_command(argc - optind, argv + optind, get_all_commands());
+ ovs_cmdl_run_command(argc - optind, argv + optind, get_all_commands());
STREAM_SSL_LONG_OPTIONS,
{NULL, 0, NULL, 0},
};
STREAM_SSL_LONG_OPTIONS,
{NULL, 0, NULL, 0},
};
- char *short_options = long_options_to_short_options(long_options);
+ char *short_options = ovs_cmdl_long_options_to_short_options(long_options);
uint32_t versions;
enum ofputil_protocol version_protocols;
uint32_t versions;
enum ofputil_protocol version_protocols;
- print_options(long_options);
+ ovs_cmdl_print_options(long_options);
exit(EXIT_SUCCESS);
case OPT_STRICT:
exit(EXIT_SUCCESS);
case OPT_STRICT:
static void
ofctl_list_commands(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
{
static void
ofctl_list_commands(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
{
- print_commands(get_all_commands());
+ ovs_cmdl_print_commands(get_all_commands());
}
\f
/* replace-flows and diff-flows commands. */
}
\f
/* replace-flows and diff-flows commands. */
-static const struct command all_commands[] = {
+static const struct ovs_cmdl_command all_commands[] = {
{ "show", "switch",
1, 1, ofctl_show },
{ "monitor", "switch [misslen] [invalid_ttl] [watch:[...]]",
{ "show", "switch",
1, 1, ofctl_show },
{ "monitor", "switch [misslen] [invalid_ttl] [watch:[...]]",
{ NULL, NULL, 0, 0, NULL },
};
{ NULL, NULL, 0, 0, NULL },
};
-static const struct command *get_all_commands(void)
+static const struct ovs_cmdl_command *get_all_commands(void)
- proctitle_init(argc, argv);
+ ovs_cmdl_proctitle_init(argc, argv);
set_program_name(argv[0]);
parse_options(argc, argv);
fatal_ignore_sigpipe();
set_program_name(argv[0]);
parse_options(argc, argv);
fatal_ignore_sigpipe();
{"peer-ca-cert", required_argument, NULL, OPT_PEER_CA_CERT},
{NULL, 0, NULL, 0},
};
{"peer-ca-cert", required_argument, NULL, OPT_PEER_CA_CERT},
{NULL, 0, NULL, 0},
};
- char *short_options = long_options_to_short_options(long_options);
+ char *short_options = ovs_cmdl_long_options_to_short_options(long_options);
{"version", no_argument, NULL, 'V'},
{NULL, 0, NULL, 0},
};
{"version", no_argument, NULL, 'V'},
{NULL, 0, NULL, 0},
};
- char *short_options = long_options_to_short_options(long_options);
+ char *short_options = ovs_cmdl_long_options_to_short_options(long_options);
size_t n_options;
size_t i;
size_t n_options;
size_t i;
- tmp = long_options_to_short_options(global_long_options);
+ tmp = ovs_cmdl_long_options_to_short_options(global_long_options);
short_options = xasprintf("+%s", tmp);
free(tmp);
short_options = xasprintf("+%s", tmp);
free(tmp);
argc -= retval;
argv += retval;
argc -= retval;
argv += retval;
- proctitle_init(argc, argv);
+ ovs_cmdl_proctitle_init(argc, argv);
service_start(&argc, &argv);
remote = parse_options(argc, argv, &unixctl_path);
fatal_ignore_sigpipe();
service_start(&argc, &argv);
remote = parse_options(argc, argv, &unixctl_path);
fatal_ignore_sigpipe();
{"dpdk", required_argument, NULL, OPT_DPDK},
{NULL, 0, NULL, 0},
};
{"dpdk", required_argument, NULL, OPT_DPDK},
{NULL, 0, NULL, 0},
};
- char *short_options = long_options_to_short_options(long_options);
+ char *short_options = ovs_cmdl_long_options_to_short_options(long_options);
size_t n_options;
size_t i;
size_t n_options;
size_t i;
- tmp = long_options_to_short_options(global_long_options);
+ tmp = ovs_cmdl_long_options_to_short_options(global_long_options);
short_options = xasprintf("+%s", tmp);
free(tmp);
short_options = xasprintf("+%s", tmp);
free(tmp);