diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2015-02-02 14:53:19 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2015-02-02 15:12:25 +0200 |
commit | 4a72c67c34b1c5b348e61ab900fb0b64305b9f97 (patch) | |
tree | bd3c91c42a14ac50f2406ba8153b04d2099cd9ab /lib | |
parent | f9536d8285625d4263c5b2dd0ab2a6773dd2b618 (diff) | |
download | eclat-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')
-rw-r--r-- | lib/Makefile.am | 1 | ||||
-rw-r--r-- | lib/forlan.c | 17 | ||||
-rw-r--r-- | lib/libeclat.h | 9 | ||||
-rw-r--r-- | lib/paramlist.c | 57 | ||||
-rw-r--r-- | lib/reqcreat.c | 2 |
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 @@ -50,12 +50,13 @@ libeclat_a_SOURCES=\ getans.c\ getyn.c\ hmac_sha1.c\ hmac_sha256.c\ libeclat.h\ map.c\ + paramlist.c\ path.c\ req2url.c\ reqaddparm.c\ reqcreat.c\ reqencode.c\ reqfree.c\ diff --git a/lib/forlan.c b/lib/forlan.c index 2275bc7..977271d 100644 --- a/lib/forlan.c +++ b/lib/forlan.c @@ -1046,12 +1046,28 @@ func_decode(forlan_eval_env_t env, struct grecs_list *list) grecs_txtacc_grow_char(acc, 0); env->retval.v.string = grecs_txtacc_finish(acc, 1); grecs_txtacc_free(acc); } 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; unsigned long code; char *p; @@ -1124,12 +1140,13 @@ static struct forlan_function functab[] = { { "dump", forlan_value_void, "n", 1, 1, func_dump }, { "print", forlan_value_void, "", 1, -1, func_print }, { "error", forlan_value_void, "", 1, -1, func_error }, { "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 }, { "lookup", forlan_value_literal, "ss", 2, 2, func_lookup }, { "has_map",forlan_value_boolean, "s", 1, 1, func_has_map }, { NULL } diff --git a/lib/libeclat.h b/lib/libeclat.h index b33f0a2..770fb7d 100644 --- a/lib/libeclat.h +++ b/lib/libeclat.h @@ -102,12 +102,14 @@ struct ec2_request { }; 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, const char *value); void eclat_request_add_header(struct ec2_request *req, const char *name, const char *value); @@ -116,12 +118,19 @@ void eclat_request_sign(struct ec2_request *req, char *secret, char *version); 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; eclat_partial_tree_t eclat_partial_tree_create(void); void eclat_partial_tree_destroy(eclat_partial_tree_t); struct grecs_node *eclat_partial_tree_finish(eclat_partial_tree_t); diff --git a/lib/paramlist.c b/lib/paramlist.c new file mode 100644 index 0000000..6d6c40a --- /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 @@ -15,13 +15,13 @@ along with Eclat. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> #include "libeclat.h" #include "grecs.h" -static void +void ec2_param_free(void *ptr) { struct ec2_param *p = ptr; free(p->name); free(p->value); free(p); |