command-line: add ovs_cmdl_context
authorRussell Bryant <rbryant@redhat.com>
Tue, 17 Mar 2015 14:35:26 +0000 (10:35 -0400)
committerBen Pfaff <blp@nicira.com>
Tue, 17 Mar 2015 15:15:57 +0000 (08:15 -0700)
commit1636c76112b63c50bb586186eb0c3aa16f9541c7
treee04c48041d41a19ab7ffa3dc66137a3ec7db52e3
parent1774d762da192d26f0f1a6176d20358adfe57dd5
command-line: add ovs_cmdl_context

I started working on a new command line utility that used this shared
code.  I wanted the ability to pass some data from common
initialization code to all of the commands.  You can find a similar
pattern in ovs-vsctl.

This patch updates the command handler to take a new struct,
ovs_cmdl_context, instead of argc and argv directly.  It includes argc
and argv, but also includes an opaque type (void *), where the user of
this API can attach its custom data it wants passed along to command
handlers.

This patch affected the ovstest sub-programs, as well.  The patch
includes a bit of an odd hack to OVSTEST_REGISTER() to avoid making
the main() function of the sub-programs take a ovs_cmdl_context.
The test main() functions still receive argc and argv directly, as
that seems more natural.  The test-subprograms themselves are able to
make use of a context internally, though.

Signed-off-by: Russell Bryant <rbryant@redhat.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
16 files changed:
lib/command-line.c
lib/command-line.h
ovsdb/ovsdb-tool.c
tests/ovstest.c
tests/ovstest.h
tests/test-bitmap.c
tests/test-classifier.c
tests/test-cmap.c
tests/test-heap.c
tests/test-jsonrpc.c
tests/test-ovsdb.c
tests/test-reconnect.c
tests/test-util.c
tests/test-vconn.c
utilities/ovs-benchmark.c
utilities/ovs-ofctl.c