diff options
Diffstat (limited to 'lib/paramlist.c')
-rw-r--r-- | lib/paramlist.c | 57 |
1 files changed, 57 insertions, 0 deletions
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 @@ | |||
1 | /* This file is part of Eclat. | ||
2 | Copyright (C) 2012-2015 Sergey Poznyakoff. | ||
3 | |||
4 | Eclat is free software; you can redistribute it and/or modify | ||
5 | it under the terms of the GNU General Public License as published by | ||
6 | the Free Software Foundation; either version 3, or (at your option) | ||
7 | any later version. | ||
8 | |||
9 | Eclat is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License | ||
15 | along with Eclat. If not, see <http://www.gnu.org/licenses/>. */ | ||
16 | |||
17 | #include <config.h> | ||
18 | #include <string.h> | ||
19 | #include "libeclat.h" | ||
20 | #include "grecs.h" | ||
21 | |||
22 | struct grecs_list * | ||
23 | ec2_param_list_create() | ||
24 | { | ||
25 | struct grecs_list *lp = grecs_list_create(); | ||
26 | lp->free_entry = ec2_param_free; | ||
27 | return lp; | ||
28 | } | ||
29 | |||
30 | void | ||
31 | ec2_param_list_append(struct grecs_list **lpp, char const *name, | ||
32 | char const *val) | ||
33 | { | ||
34 | struct ec2_param *p; | ||
35 | if (!*lpp) | ||
36 | *lpp = ec2_param_list_create(); | ||
37 | p = grecs_zalloc(sizeof(*p)); | ||
38 | p->name = grecs_strdup(name); | ||
39 | p->value = grecs_strdup(val); | ||
40 | p->encoded = 0; | ||
41 | grecs_list_append(*lpp, p); | ||
42 | } | ||
43 | |||
44 | void | ||
45 | eclat_request_add_param_list(struct ec2_request *req, struct grecs_list *lp) | ||
46 | { | ||
47 | struct grecs_list_entry *ep; | ||
48 | |||
49 | if (!lp) | ||
50 | return; | ||
51 | for (ep = lp->head; ep; ep = ep->next) { | ||
52 | struct ec2_param *param = ep->data; | ||
53 | eclat_request_add_param0(req, | ||
54 | param->name, param->value, | ||
55 | param->encoded); | ||
56 | } | ||
57 | } | ||