aboutsummaryrefslogtreecommitdiff
path: root/src/setiattr.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/setiattr.c')
-rw-r--r--src/setiattr.c35
1 files changed, 23 insertions, 12 deletions
diff --git a/src/setiattr.c b/src/setiattr.c
index 60687b7..e799bc7 100644
--- a/src/setiattr.c
+++ b/src/setiattr.c
@@ -1,5 +1,5 @@
/* This file is part of Eclat.
- Copyright (C) 2012-2014 Sergey Poznyakoff.
+ Copyright (C) 2012-2015 Sergey Poznyakoff.
Eclat is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -54,6 +54,9 @@ list_mod_attrs(FILE *fp)
fputc('\n', fp);
}
+int from_file;
+int is_base64;
+#include "setiattr-cl.h"
int
eclat_modify_instance_attribute(eclat_command_env_t *env, int argc, char **argv)
@@ -64,14 +67,10 @@ eclat_modify_instance_attribute(eclat_command_env_t *env, int argc, char **argv)
size_t canonlen;
char *bufptr = NULL;
size_t bufsize = 0;
-
- generic_proginfo->args_doc = "INST-ID ATTR VALUE [VALUE...]";
- generic_proginfo->print_help_hook = list_mod_attrs;
- generic_parse_options(env->cmd,
- "modify the attribute of an instance",
- argc, argv, &i);
- argv += i;
- argc -= i;
+
+ parse_options(env, argc, argv, &i);
+ argv += i;
+ argc -= i;
if (argc < 3)
die(EX_USAGE, "wrong number of arguments");
@@ -112,9 +111,21 @@ eclat_modify_instance_attribute(eclat_command_env_t *env, int argc, char **argv)
argv[i]);
eclat_query_add_param(q, bufptr, p);
}
- } else if (argc != 3)
- die(EX_USAGE, "wrong number of arguments");
- else
+ } else if (strcmp(canonattr, "UserData.Value") == 0) {
+ char *input = from_file ? read_file(argv[2]) : argv[2];
+ size_t enclen = 0;
+ char *data;
+
+ if (is_base64)
+ data = input;
+ else
+ eclat_base64_encode((unsigned char *)input,
+ strlen(input),
+ (unsigned char**) &data, &enclen);
+ eclat_query_add_param(q, canonattr, data);
+ if (enclen)
+ free(data);
+ } else
eclat_query_add_param(q, canonattr, argv[2]);
free(bufptr);
return 0;

Return to:

Send suggestions and report system problems to the System administrator.