summaryrefslogtreecommitdiff
path: root/utilities/ovs-appctl.c
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2011-12-02 15:29:19 -0800
committerBen Pfaff <blp@nicira.com>2011-12-19 14:53:34 -0800
commit0e15264f96e3caff662c7998cc739a3dd5c1c0f2 (patch)
tree467de37d55baeb233530bfe948cb9020461b9099 /utilities/ovs-appctl.c
parent041dc07fd21b6987ffbcc6a597eb9918d44ae841 (diff)
downloadopenvswitch-0e15264f96e3caff662c7998cc739a3dd5c1c0f2.tar.gz
unixctl: Implement quoting.
The protocol used by ovs-appctl has a long-standing bug that there is no way to distinguish "ovs-appctl a b c" from "ovs-appctl 'a b c'". This isn't a big deal because none of the current commands really want to accept arguments that include spaces, but it's kind of a silly limitation. At the same time, the internal API is awkward because every user is stuck doing its own argument parsing, which is no fun. This commit fixes both problems, by adding shell-like quoting to the protocol and modifying the internal API from one that passes a string to one that passes in an array of pre-parsed strings. Command implementations may now specify how many arguments they expect. This simplifies some command implementations significantly. Signed-off-by: Ben Pfaff <blp@nicira.com>
Diffstat (limited to 'utilities/ovs-appctl.c')
-rw-r--r--utilities/ovs-appctl.c18
1 files changed, 5 insertions, 13 deletions
diff --git a/utilities/ovs-appctl.c b/utilities/ovs-appctl.c
index d3c701b48..e528af344 100644
--- a/utilities/ovs-appctl.c
+++ b/utilities/ovs-appctl.c
@@ -26,6 +26,7 @@
#include "daemon.h"
#include "dirs.h"
#include "dynamic-string.h"
+#include "process.h"
#include "timeval.h"
#include "unixctl.h"
#include "util.h"
@@ -39,10 +40,9 @@ main(int argc, char *argv[])
{
struct unixctl_client *client;
const char *target;
- struct ds request;
int code, error;
+ char *request;
char *reply;
- int i;
set_program_name(argv[0]);
@@ -50,17 +50,10 @@ main(int argc, char *argv[])
target = parse_command_line(argc, argv);
client = connect_to_target(target);
- /* Compose request. */
- ds_init(&request);
- for (i = optind; i < argc; i++) {
- if (i != optind) {
- ds_put_char(&request, ' ');
- }
- ds_put_cstr(&request, argv[i]);
- }
-
/* Transact request and process reply. */
- error = unixctl_client_transact(client, ds_cstr(&request), &code, &reply);
+ request = process_escape_args(argv + optind);
+ error = unixctl_client_transact(client, request, &code, &reply);
+ free(request);
if (error) {
ovs_fatal(error, "%s: transaction error", target);
}
@@ -73,7 +66,6 @@ main(int argc, char *argv[])
unixctl_client_destroy(client);
free(reply);
- ds_destroy(&request);
return 0;
}