summaryrefslogtreecommitdiffabout
path: root/lib
authorSergey Poznyakoff <gray@gnu.org.ua>2015-02-02 12:53:19 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2015-02-02 13:12:25 (GMT)
commit4a72c67c34b1c5b348e61ab900fb0b64305b9f97 (patch) (side-by-side diff)
treebd3c91c42a14ac50f2406ba8153b04d2099cd9ab /lib
parentf9536d8285625d4263c5b2dd0ab2a6773dd2b618 (diff)
downloadeclat-4a72c67c34b1c5b348e61ab900fb0b64305b9f97.tar.gz
eclat-4a72c67c34b1c5b348e61ab900fb0b64305b9f97.tar.bz2
New options: --check-permissions and --add-parameter
* NEWS: Update. * doc/eclat-stop.1: Update. * doc/eclat.1man: Update. * etc/default.fln: Special handling for DryRunOperation and UnauthorizedOperation codes. * lib/paramlist.c: New file. * lib/Makefile.am (libeclat_a_SOURCES): Add paramlist.c * lib/forlan.c: New function dequote. * lib/libeclat.h (eclat_request_add_param0) (ec2_param_free, ec2_param_list_create) (ec2_param_list_append) (eclat_request_add_param_list): New protos. * lib/reqcreat.c (ec2_param_free): Remove static qualifier. * src/stop-cl.opt: New file. * src/Makefile.am (OPTFILES): Add stop-cl.opt * src/cmdline.opt: New options: --check-permissions and --add-parameter. * src/eclat.c (extra_param): New global. (find_format): print error message if no such format is found. * src/startstop.c (eclat_stop_instance): Use parse_stop_options
Diffstat (limited to 'lib') (more/less context) (ignore whitespace changes)
-rw-r--r--lib/Makefile.am1
-rw-r--r--lib/forlan.c17
-rw-r--r--lib/libeclat.h9
-rw-r--r--lib/paramlist.c57
-rw-r--r--lib/reqcreat.c2
5 files changed, 85 insertions, 1 deletions
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 5cfa67a..711bc98 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -53,6 +53,7 @@ libeclat_a_SOURCES=\
hmac_sha256.c\
libeclat.h\
map.c\
+ paramlist.c\
path.c\
req2url.c\
reqaddparm.c\
diff --git a/lib/forlan.c b/lib/forlan.c
index 2275bc7..977271d 100644
--- a/lib/forlan.c
+++ b/lib/forlan.c
@@ -1049,6 +1049,22 @@ func_decode(forlan_eval_env_t env, struct grecs_list *list)
}
static void
+func_dequote(forlan_eval_env_t env, struct grecs_list *list)
+{
+ struct forlan_value *val = list->head->data;
+ char *s = val->v.string;
+ size_t l = strlen(s);
+
+ if (l >= 2 && s[0] == '"' && s[l-1] == '"') {
+ s++;
+ l -= 2;
+ }
+ env->retval.v.string = grecs_malloc(l + 1);
+ memcpy(env->retval.v.string, s, l);
+ env->retval.v.string[l] = 0;
+}
+
+static void
func_exit(forlan_eval_env_t env, struct grecs_list *list)
{
struct forlan_value *val = list->head->data;
@@ -1127,6 +1143,7 @@ static struct forlan_function functab[] = {
{ "parent", forlan_value_node, "n", 1, 1, func_parent },
{ "sort", forlan_value_void, "nss", 1, 3, func_sort },
{ "decode", forlan_value_literal, "s", 1, 1, func_decode },
+ { "dequote", forlan_value_literal, "s", 1, 1, func_dequote },
{ "exit", forlan_value_void, "s", 1, 1, func_exit },
{ "empty", forlan_value_boolean, "n", 1, 1, func_empty },
{ "timestamp", forlan_value_literal, "s", 1, 1, func_timestamp },
diff --git a/lib/libeclat.h b/lib/libeclat.h
index b33f0a2..770fb7d 100644
--- a/lib/libeclat.h
+++ b/lib/libeclat.h
@@ -105,6 +105,8 @@ struct ec2_request *eclat_request_create(int flags, const char *endpoint,
const char *uri, char const *region,
char const *access_key, char const *token);
void eclat_request_free(struct ec2_request *);
+void eclat_request_add_param0(struct ec2_request *req, const char *name,
+ const char *value, int encoded);
void eclat_request_add_param(struct ec2_request *req, const char *name,
const char *value);
void eclat_request_add_param_encoded(struct ec2_request *req, const char *name,
@@ -119,6 +121,13 @@ char *eclat_request_to_url(struct ec2_request *req);
void eclat_request_encode(struct ec2_request *req);
void eclat_request_finalize(struct ec2_request *req);
+void ec2_param_free(void *ptr);
+
+struct grecs_list *ec2_param_list_create(void);
+void ec2_param_list_append(struct grecs_list **lp, char const *name,
+ char const *val);
+void eclat_request_add_param_list(struct ec2_request *req,
+ struct grecs_list *lp);
typedef struct eclat_partial_tree *eclat_partial_tree_t;
diff --git a/lib/paramlist.c b/lib/paramlist.c
new file mode 100644
index 0000000..6d6c40a
--- a/dev/null
+++ b/lib/paramlist.c
@@ -0,0 +1,57 @@
+/* This file is part of Eclat.
+ 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
+ the Free Software Foundation; either version 3, or (at your option)
+ any later version.
+
+ Eclat is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Eclat. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+#include <string.h>
+#include "libeclat.h"
+#include "grecs.h"
+
+struct grecs_list *
+ec2_param_list_create()
+{
+ struct grecs_list *lp = grecs_list_create();
+ lp->free_entry = ec2_param_free;
+ return lp;
+}
+
+void
+ec2_param_list_append(struct grecs_list **lpp, char const *name,
+ char const *val)
+{
+ struct ec2_param *p;
+ if (!*lpp)
+ *lpp = ec2_param_list_create();
+ p = grecs_zalloc(sizeof(*p));
+ p->name = grecs_strdup(name);
+ p->value = grecs_strdup(val);
+ p->encoded = 0;
+ grecs_list_append(*lpp, p);
+}
+
+void
+eclat_request_add_param_list(struct ec2_request *req, struct grecs_list *lp)
+{
+ struct grecs_list_entry *ep;
+
+ if (!lp)
+ return;
+ for (ep = lp->head; ep; ep = ep->next) {
+ struct ec2_param *param = ep->data;
+ eclat_request_add_param0(req,
+ param->name, param->value,
+ param->encoded);
+ }
+}
diff --git a/lib/reqcreat.c b/lib/reqcreat.c
index 65f7880..58d7829 100644
--- a/lib/reqcreat.c
+++ b/lib/reqcreat.c
@@ -18,7 +18,7 @@
#include "libeclat.h"
#include "grecs.h"
-static void
+void
ec2_param_free(void *ptr)
{
struct ec2_param *p = ptr;

Return to:

Send suggestions and report system problems to the System administrator.