]> git.proxmox.com Git - mirror_ovs.git/commitdiff
command-line: add ovs_cmdl_ prefix
authorRussell Bryant <rbryant@redhat.com>
Mon, 16 Mar 2015 16:01:55 +0000 (12:01 -0400)
committerBen Pfaff <blp@nicira.com>
Mon, 16 Mar 2015 20:42:52 +0000 (13:42 -0700)
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:
lib/command-line.c
lib/command-line.h
lib/daemon-unix.c
ovsdb/ovsdb-client.c
ovsdb/ovsdb-server.c
ovsdb/ovsdb-tool.c
tests/ovstest.c
tests/test-bitmap.c
tests/test-classifier.c
tests/test-cmap.c
tests/test-heap.c
tests/test-jsonrpc.c
tests/test-netflow.c
tests/test-ovsdb.c
tests/test-reconnect.c
tests/test-sflow.c
tests/test-util.c
tests/test-vconn.c
utilities/ovs-appctl.c
utilities/ovs-benchmark.c
utilities/ovs-dpctl.c
utilities/ovs-ofctl.c
utilities/ovs-testcontroller.c
utilities/ovs-vlan-bug-workaround.c
utilities/ovs-vsctl.c
vswitchd/ovs-vswitchd.c
vtep/vtep-ctl.c

index 2eccdc68220e4630be141e7c596b547eadf81f7e..d9cec0db75faabe0e9aa58246770cd0c1fa30155 100644 (file)
@@ -30,7 +30,7 @@ VLOG_DEFINE_THIS_MODULE(command_line);
  * 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;
@@ -52,15 +52,15 @@ long_options_to_short_options(const struct option 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. */
 void
-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++) {
-        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);
@@ -69,7 +69,7 @@ print_commands(const struct command commands[])
 
 /* 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;
 
@@ -94,9 +94,9 @@ print_options(const struct option options[])
  * 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");
@@ -150,7 +150,7 @@ static char *saved_proctitle OVS_GUARDED_BY(proctitle_mutex);
  * 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)
 {
     int i;
 
@@ -190,7 +190,7 @@ 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
-proctitle_set(const char *format, ...)
+ovs_cmdl_proctitle_set(const char *format, ...)
 {
     va_list args;
     int n;
@@ -225,7 +225,7 @@ out:
 
 /* Restores the process's original command line, as seen by "ps". */
 void
-proctitle_restore(void)
+ovs_cmdl_proctitle_restore(void)
 {
     ovs_mutex_lock(&proctitle_mutex);
     if (saved_proctitle) {
@@ -239,20 +239,20 @@ proctitle_restore(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
-proctitle_set(const char *format OVS_UNUSED, ...)
+ovs_cmdl_proctitle_set(const char *format OVS_UNUSED, ...)
 {
 }
 #endif
 
 void
-proctitle_restore(void)
+ovs_cmdl_proctitle_restore(void)
 {
 }
 #endif  /* !__linux__ */
index 7e68504b081cd99d87f30ab413514ea14e127303..b6da20585466fe5b6875a8fb060f195f5489432e 100644 (file)
@@ -23,7 +23,7 @@
 
 struct option;
 
-struct command {
+struct ovs_cmdl_command {
     const char *name;
     const char *usage;
     int min_args;
@@ -31,18 +31,18 @@ struct command {
     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__)
-#define proctitle_set setproctitle
+#define ovs_cmdl_proctitle_set setproctitle
 #else
-void proctitle_set(const char *, ...)
+void ovs_cmdl_proctitle_set(const char *, ...)
     OVS_PRINTF_FORMAT(1, 2);
 #endif
-void proctitle_restore(void);
+void ovs_cmdl_proctitle_restore(void);
 
 #endif /* command-line.h */
index 3b24fca831d46fdb860ed82b75e028a1dfa3d0f1..eb95521b41739e4208a95d1393cae88fed839630 100644 (file)
@@ -332,8 +332,8 @@ monitor_daemon(pid_t daemon_pid)
         int retval;
         int status;
 
-        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);
 
         if (child_ready) {
             do {
@@ -399,7 +399,7 @@ monitor_daemon(pid_t daemon_pid)
     free(status_msg);
 
     /* Running in new daemon process. */
-    proctitle_restore();
+    ovs_cmdl_proctitle_restore();
     set_subprogram_name("");
 }
 
index e3b08c71c097a8e89348549bbae1d9f3c9c38d40..575cf918751c19c297f94b803d0c0aadb856ed6a 100644 (file)
@@ -86,7 +86,7 @@ main(int argc, char *argv[])
     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();
@@ -183,7 +183,7 @@ parse_options(int argc, char *argv[])
         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);
 
     for (;;) {
         int c;
index d5277b11d3e7471ae217b9f91e62f53c58cb0e64..deb2b8bb3de08feacac468db5b04fded39aa05a8 100644 (file)
@@ -211,7 +211,7 @@ main(int argc, char *argv[])
     char *error;
     int i;
 
-    proctitle_init(argc, argv);
+    ovs_cmdl_proctitle_init(argc, argv);
     set_program_name(argv[0]);
     service_start(&argc, &argv);
     fatal_ignore_sigpipe();
@@ -1242,7 +1242,7 @@ parse_options(int *argcp, char **argvp[],
         {"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;
 
index 17116651837718a730b11feb386adb0ee8c74ba4..f6487070c7489c13f89d2d75230e8c63cb5f437f 100644 (file)
@@ -44,7 +44,7 @@
 /* -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[]);
@@ -58,7 +58,7 @@ main(int argc, char *argv[])
     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());
     return 0;
 }
 
@@ -73,7 +73,7 @@ parse_options(int argc, char *argv[])
         {"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);
 
     for (;;) {
         int c;
@@ -92,7 +92,7 @@ parse_options(int argc, char *argv[])
             usage();
 
         case 'o':
-            print_options(long_options);
+            ovs_cmdl_print_options(long_options);
             exit(EXIT_SUCCESS);
 
         case 'V':
@@ -566,10 +566,10 @@ do_help(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 },
@@ -586,7 +586,7 @@ static const struct command all_commands[] = {
     { NULL, NULL, 0, 0, NULL },
 };
 
-static const struct command *get_all_commands(void)
+static const struct ovs_cmdl_command *get_all_commands(void)
 {
     return all_commands;
 }
index 5e985ae59370a340493e5c1f6a14ed0e8bb40114..f05da0584d163942e7073d01f926d97030e7443f 100644 (file)
 #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
-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,
@@ -62,7 +62,7 @@ flush_help_string(struct ds *ds)
 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;
 
@@ -86,7 +86,7 @@ help(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
 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);
 }
@@ -94,7 +94,7 @@ add_top_level_commands(void)
 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;
@@ -125,7 +125,7 @@ main(int argc, char *argv[])
 
     add_top_level_commands();
     if (argc > 1) {
-        run_command(argc - 1, argv + 1, commands);
+        ovs_cmdl_run_command(argc - 1, argv + 1, commands);
     }
     cleanup();
 
index 932133252a6e5ac2d25238d13214db2994bd6219..9c09e1491201649b523a3a4c457e53be9cf98464 100644 (file)
@@ -148,7 +148,7 @@ run_benchmarks(int argc OVS_UNUSED, char *argv[])
     printf("\n");
 }
 
-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},
@@ -158,7 +158,7 @@ static void
 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);
index 6748da7a0319289fd48182108ce94d70c49c4e01..5d0e875c1cd31b05e68298c6f3e0da02d1bdbd07 100644 (file)
@@ -1400,7 +1400,7 @@ test_minimask_combine(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
     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},
@@ -1424,7 +1424,7 @@ test_classifier_main(int argc, char *argv[])
 {
     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);
index 13f590f380871448630bb72d748cc86a29df834b..f429cdd8ea6cff61be16f848e9432505fd125646 100644 (file)
@@ -636,7 +636,7 @@ benchmark_hmap(void)
     free(elements);
 }
 \f
-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},
@@ -646,7 +646,7 @@ static void
 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);
index 92ab57fd81c430ae5486e4cbc2668892410436c2..5340860c75efd50953d9a78bdb857abbafcea48f 100644 (file)
@@ -463,7 +463,7 @@ test_heap_raw_delete(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
     }
 }
 
-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,
@@ -482,7 +482,7 @@ test_heap_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-heap", test_heap_main);
index 2aad5c54328e7bfa3bb3076a8faebb87f539a2a0..d44543224cfbe056404ff5d1678b7aa3175e2c60 100644 (file)
 
 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[])
 {
-    proctitle_init(argc, argv);
+    ovs_cmdl_proctitle_init(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());
 }
 
 static void
@@ -62,7 +62,7 @@ parse_options(int argc, char *argv[])
         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);
@@ -327,7 +327,7 @@ do_help(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
     usage();
 }
 
-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 },
@@ -335,7 +335,7 @@ static struct command all_commands[] = {
     { NULL, NULL, 0, 0, NULL },
 };
 
-static struct command *
+static struct ovs_cmdl_command *
 get_all_commands(void)
 {
     return all_commands;
index d9f29d1c2e6c6c50b96d68cb3ef099d167d63b4f..631d7a21e52c3510fc1071174fbc353712c934dc 100644 (file)
@@ -178,7 +178,7 @@ test_netflow_main(int argc, char *argv[])
     int sock;
     int n;
 
-    proctitle_init(argc, argv);
+    ovs_cmdl_proctitle_init(argc, argv);
     set_program_name(argv[0]);
     service_start(&argc, &argv);
     parse_options(argc, argv);
@@ -248,7 +248,7 @@ parse_options(int argc, char *argv[])
         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);
index 99f41c1b5d9c0444ccc0472e7fad3c90c9a7ef72..540dcda169a5f9571d9055dcdd12666bef44aac0 100644 (file)
 
 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);
-    run_command(argc - optind, argv + optind, get_all_commands());
+    ovs_cmdl_run_command(argc - optind, argv + optind, get_all_commands());
     return 0;
 }
 
@@ -73,7 +73,7 @@ parse_options(int argc, char *argv[])
         {"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;
@@ -1507,7 +1507,7 @@ do_transact_print(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
 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 },
@@ -1569,7 +1569,7 @@ do_transact(int argc, char *argv[])
             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++) {
@@ -1962,7 +1962,7 @@ do_idl(int argc, char *argv[])
     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 },
@@ -1993,7 +1993,7 @@ static struct command all_commands[] = {
     { NULL, NULL, 0, 0, NULL },
 };
 
-static struct command *
+static struct ovs_cmdl_command *
 get_all_commands(void)
 {
     return all_commands;
index 7d3933910a4dfbaff15c780e83d9c61a78c601ae..2d6f62022331691fa1796ac9273cdbbe076fcaf4 100644 (file)
@@ -34,7 +34,7 @@ static int now;
 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)
@@ -67,7 +67,7 @@ test_reconnect_main(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
         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());
         }
         svec_destroy(&args);
 
@@ -268,7 +268,7 @@ do_listen_error(int argc OVS_UNUSED, char *argv[])
     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 },
@@ -287,7 +287,7 @@ static const struct command all_commands[] = {
     { NULL, NULL, 0, 0, NULL },
 };
 
-static const struct command *
+static const struct ovs_cmdl_command *
 get_all_commands(void)
 {
     return all_commands;
index 3e3c45014f699f572fb7889a07da8d8edb475220..70a037256d2fbcaadecd89541a34f3941df5e099 100644 (file)
@@ -634,7 +634,7 @@ test_sflow_main(int argc, char *argv[])
     int error;
     int sock;
 
-    proctitle_init(argc, argv);
+    ovs_cmdl_proctitle_init(argc, argv);
     set_program_name(argv[0]);
     service_start(&argc, &argv);
     parse_options(argc, argv);
@@ -701,7 +701,7 @@ parse_options(int argc, char *argv[])
         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);
index 2c985e71c8a4edb6b0ffdc7c03856b94bf1f92e6..01a1a78299a1fba91d9d87fbd084c09716420b53 100644 (file)
@@ -1049,7 +1049,7 @@ test_file_name(int argc, char *argv[])
 }
 #endif /* _WIN32 */
 \f
-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},
@@ -1080,7 +1080,7 @@ parse_options(int argc, char *argv[])
         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);
@@ -1111,7 +1111,7 @@ test_util_main(int argc, char *argv[])
      * 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);
index c3e8a3474411efb47b924071f85d4180e02ab6f3..6e6ec99e3fdc354fb46e799394c33ac5f3fdd793 100644 (file)
@@ -431,7 +431,7 @@ test_send_invalid_version_hello(int argc OVS_UNUSED, char *argv[])
     ofpbuf_delete(hello);
 }
 
-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},
@@ -453,7 +453,7 @@ test_vconn_main(int argc, char *argv[])
 
     time_alarm(10);
 
-    run_command(argc - 1, argv + 1, commands);
+    ovs_cmdl_run_command(argc - 1, argv + 1, commands);
 }
 
 OVSTEST_REGISTER("test-vconn", test_vconn_main);
index dee2d33a48c1606f787a9c1656e7eb4f85756918..f7403f7952c3deb1a484a1a7adb03cdf6cf91bb3 100644 (file)
@@ -123,7 +123,7 @@ parse_command_line(int argc, char *argv[])
         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;
@@ -160,7 +160,7 @@ parse_command_line(int argc, char *argv[])
             break;
 
         case 'o':
-            print_options(long_options);
+            ovs_cmdl_print_options(long_options);
             exit(EXIT_SUCCESS);
 
         case 'T':
index 64db63e6e24fd26c026892affe986f479252eb6f..d2f2e8b3484d3a8239f6821af3115e77ff91224b 100644 (file)
@@ -49,7 +49,7 @@ static double max_rate;
 
 static double timeout;
 
-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);
@@ -84,7 +84,7 @@ main(int argc, char *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());
     return 0;
 }
 
@@ -141,7 +141,7 @@ parse_options(int argc, char *argv[])
         {"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;
@@ -616,7 +616,7 @@ cmd_help(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
     usage();
 }
 
-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 },
@@ -624,7 +624,7 @@ static const struct command all_commands[] = {
     { NULL, NULL, 0, 0, NULL },
 };
 
-static const struct command *get_all_commands(void)
+static const struct ovs_cmdl_command *get_all_commands(void)
 {
   return all_commands;
 }
index 9d279f0412aee1c2b574ce4bcac8d8b8e2f73ab0..c43066d263c4819c00370105045649442bfd23e1 100644 (file)
@@ -91,7 +91,7 @@ parse_options(int argc, char *argv[])
         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;
@@ -133,7 +133,7 @@ parse_options(int argc, char *argv[])
             usage(NULL);
 
         case 'o':
-            print_options(long_options);
+            ovs_cmdl_print_options(long_options);
             exit(EXIT_SUCCESS);
 
         case 'V':
index 44c52751cc50034c5393e3c0101add857e1df8fc..89b89a903c66aa982c797729cb339ccbbda6affd 100644 (file)
@@ -105,7 +105,7 @@ struct sort_criterion {
 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[]);
@@ -121,7 +121,7 @@ main(int argc, char *argv[])
     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());
     return 0;
 }
 
@@ -179,7 +179,7 @@ parse_options(int argc, char *argv[])
         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;
 
@@ -243,7 +243,7 @@ parse_options(int argc, char *argv[])
             usage();
 
         case 'o':
-            print_options(long_options);
+            ovs_cmdl_print_options(long_options);
             exit(EXIT_SUCCESS);
 
         case OPT_STRICT:
@@ -2267,7 +2267,7 @@ ofctl_help(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. */
@@ -3481,7 +3481,7 @@ ofctl_encode_hello(int argc OVS_UNUSED, char *argv[])
     ofpbuf_delete(hello);
 }
 
-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:[...]]",
@@ -3597,7 +3597,7 @@ static const struct command all_commands[] = {
     { NULL, NULL, 0, 0, NULL },
 };
 
-static const struct command *get_all_commands(void)
+static const struct ovs_cmdl_command *get_all_commands(void)
 {
     return all_commands;
 }
index bb96701fdbca7ea6f083e86ab6b8dae4f4723950..3d59adbaf7486dd13bda905f7388d564baf5577f 100644 (file)
@@ -103,7 +103,7 @@ main(int argc, char *argv[])
     int retval;
     int i;
 
-    proctitle_init(argc, argv);
+    ovs_cmdl_proctitle_init(argc, argv);
     set_program_name(argv[0]);
     parse_options(argc, argv);
     fatal_ignore_sigpipe();
@@ -277,7 +277,7 @@ parse_options(int argc, char *argv[])
         {"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);
 
     for (;;) {
         int indexptr;
index 88fb2b197fd0668cbe641468a9b21c1725fbc6b2..add800e56633527341e90b8d9013511363b59c7c 100644 (file)
@@ -116,7 +116,7 @@ parse_options(int argc, char *argv[])
         {"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);
 
     for (;;) {
         int option;
index af1cfc0d5394be38a6fa3d76cf8b74488a9a4836..1abefb440e515fd85e2d7ddf020748e92a53b04d 100644 (file)
@@ -332,7 +332,7 @@ parse_options(int argc, char *argv[], struct shash *local_options)
     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);
 
index 812c00b913f957d0407cba471c0917a90a22525b..eda4aab21bddef761f0a53eeb106f4363f50c4fb 100644 (file)
@@ -75,7 +75,7 @@ main(int argc, char *argv[])
     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();
@@ -165,7 +165,7 @@ parse_options(int argc, char *argv[], char **unixctl_pathp)
         {"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);
 
     for (;;) {
         int c;
index 3e8066e0dc3d70de7b54dc930cb5f8498b135f53..ead22ea39aa95e42f0aa00f6c2a458d589027368 100644 (file)
@@ -272,7 +272,7 @@ parse_options(int argc, char *argv[], struct shash *local_options)
     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);