aboutsummaryrefslogtreecommitdiff
path: root/client/remctl.c
diff options
context:
space:
mode:
authorRuss Allbery <rra@stanford.edu>2010-02-20 19:55:05 -0800
committerRuss Allbery <rra@stanford.edu>2010-02-20 19:55:05 -0800
commita3ee976840e97d37022ec117bae09fef25ac4385 (patch)
treea2422d730079e2ce72f0245f5497685f27377960 /client/remctl.c
parent77581a6a1620118ca17e26ec8b549603ab67b91b (diff)
Add support in the wallet client for store of binary data
Refactor the wallet client code to use remctl_commandv and send stores with data containing nul.
Diffstat (limited to 'client/remctl.c')
-rw-r--r--client/remctl.c53
1 files changed, 41 insertions, 12 deletions
diff --git a/client/remctl.c b/client/remctl.c
index a4ff097..5a541d5 100644
--- a/client/remctl.c
+++ b/client/remctl.c
@@ -18,15 +18,14 @@
/*
- * Given a remctl connection and a command, run the command.
- *
- * If data is non-NULL, save the output in it and return the length in length.
- * Otherwise, send any output to stdout. Either way, send error output to
- * stderr, and return the exit status (or 255 if there is an error).
+ * Retrieve the results of a remctl command, which should be issued prior to
+ * calling this function. If data is non-NULL, save the output in it and
+ * return the length in length. Otherwise, send any output to stdout. Either
+ * way, send error output to stderr, and return the exit status (or 255 if
+ * there is an error).
*/
-int
-run_command(struct remctl *r, const char **command, char **data,
- size_t *length)
+static int
+command_results(struct remctl *r, char **data, size_t *length)
{
struct remctl_output *output;
int status = 255;
@@ -35,10 +34,6 @@ run_command(struct remctl *r, const char **command, char **data,
*data = NULL;
if (length != NULL)
*length = 0;
- if (!remctl_command(r, command)) {
- warn("%s", remctl_error(r));
- return 255;
- }
do {
output = remctl_output(r);
switch (output->type) {
@@ -74,6 +69,40 @@ run_command(struct remctl *r, const char **command, char **data,
/*
+ * Given a remctl connection and a NULL-terminated array of strings, run the
+ * command and return the results using command_results, optionally putting
+ * output into the data variable.
+ */
+int
+run_command(struct remctl *r, const char **command, char **data,
+ size_t *length)
+{
+ if (!remctl_command(r, command)) {
+ warn("%s", remctl_error(r));
+ return 255;
+ }
+ return command_results(r, data, length);
+}
+
+
+/*
+ * Given a remctl connection, an array of iovecs, and the length of the array,
+ * run the command and return the results using command_results, optionally
+ * putting output into the data variable.
+ */
+int
+run_commandv(struct remctl *r, const struct iovec *command, size_t count,
+ char **data, size_t *length)
+{
+ if (!remctl_commandv(r, command, count)) {
+ warn("%s", remctl_error(r));
+ return 255;
+ }
+ return command_results(r, data, length);
+}
+
+
+/*
* Check whether an object exists using the exists wallet interface. Returns
* true if it does, false if it doesn't, and dies on remctl errors.
*/