From dacb75f5c04b19e142762c81d5b13d3005c57c71 Mon Sep 17 00:00:00 2001 From: Andreas Steffen Date: Thu, 12 Jun 2014 22:57:15 +0200 Subject: Split swanctl --raw mode into single-line and --pretty mode --- src/swanctl/commands/install.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'src/swanctl/commands/install.c') diff --git a/src/swanctl/commands/install.c b/src/swanctl/commands/install.c index 594d2ffe3..e8727d573 100644 --- a/src/swanctl/commands/install.c +++ b/src/swanctl/commands/install.c @@ -21,7 +21,7 @@ static int manage_policy(vici_conn_t *conn, char *label) { vici_req_t *req; vici_res_t *res; - bool raw = FALSE; + command_format_options_t format = COMMAND_FORMAT_NONE; char *arg, *child = NULL; int ret = 0; @@ -31,8 +31,11 @@ static int manage_policy(vici_conn_t *conn, char *label) { case 'h': return command_usage(NULL); + case 'P': + format |= COMMAND_FORMAT_RAW; + /* fall through to raw */ case 'r': - raw = TRUE; + format |= COMMAND_FORMAT_PRETTY; continue; case 'c': child = arg; @@ -55,10 +58,10 @@ static int manage_policy(vici_conn_t *conn, char *label) fprintf(stderr, "%s request failed: %s\n", label, strerror(errno)); return errno; } - if (raw) + if (format & COMMAND_FORMAT_RAW) { puts(label); - vici_dump(res, " reply", stdout); + vici_dump(res, " reply", format & COMMAND_FORMAT_PRETTY, stdout); } else { @@ -94,11 +97,12 @@ static void __attribute__ ((constructor))reg_uninstall() { command_register((command_t) { uninstall, 'u', "uninstall", "uninstall a trap or shunt policy", - {"--child [--raw]"}, + {"--child [--raw|--pretty]"}, { {"help", 'h', 0, "show usage information"}, {"child", 'c', 1, "CHILD_SA configuration to uninstall"}, {"raw", 'r', 0, "dump raw response message"}, + {"pretty", 'P', 0, "dump raw response message in pretty print"}, } }); } @@ -110,11 +114,12 @@ static void __attribute__ ((constructor))reg_install() { command_register((command_t) { install, 'p', "install", "install a trap or shunt policy", - {"--child [--raw]"}, + {"--child [--raw|--pretty]"}, { {"help", 'h', 0, "show usage information"}, {"child", 'c', 1, "CHILD_SA configuration to install"}, {"raw", 'r', 0, "dump raw response message"}, + {"pretty", 'P', 0, "dump raw response message in pretty print"}, } }); } -- cgit v1.2.3