summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGünther Deschner <gdeschner@redhat.com>2013-04-12 13:54:05 +0200
committerSimo Sorce <simo@redhat.com>2013-04-23 12:02:00 -0700
commitf7b3cd95cd812c6fdf9b66f771eb816d6002dc58 (patch)
treef4f86831dfe082936baeb489bc0317547114c556
parent11d93370415910dcbc437c13d3040232c9bd409c (diff)
downloadgss-proxy-f7b3cd95cd812c6fdf9b66f771eb816d6002dc58.tar.gz
gss-proxy-f7b3cd95cd812c6fdf9b66f771eb816d6002dc58.tar.xz
gss-proxy-f7b3cd95cd812c6fdf9b66f771eb816d6002dc58.zip
Add gp_config_get_string_array() and an implementation in dinglibs backend.
This call returns an allocated array of strings. It allows to return multiple values for a single parameter like: param = value1 param = value2 This cannot be supported with iniparser, so we have to remove iniparser support. Signed-off-by: Günther Deschner <gdeschner@redhat.com> Reviewed-by: Simo Sorce <simo@redhat.com>
-rw-r--r--proxy/src/gp_config.c16
-rw-r--r--proxy/src/gp_config.h4
-rw-r--r--proxy/src/gp_config_dinglibs.c80
-rw-r--r--proxy/src/gp_config_dinglibs.h4
4 files changed, 104 insertions, 0 deletions
diff --git a/proxy/src/gp_config.c b/proxy/src/gp_config.c
index e5cfb16..8f30c30 100644
--- a/proxy/src/gp_config.c
+++ b/proxy/src/gp_config.c
@@ -379,6 +379,14 @@ char *gp_config_get_string(struct gp_ini_context *ctx,
return gp_iniparser_get_string(ctx, secname, keyname);
}
+char **gp_config_get_string_array(struct gp_ini_context *ctx,
+ const char *secname,
+ const char *keyname,
+ int *num_values)
+{
+ return NULL;
+}
+
int gp_config_get_int(struct gp_ini_context *ctx,
const char *secname,
const char *keyname)
@@ -420,6 +428,14 @@ char *gp_config_get_string(struct gp_ini_context *ctx,
return gp_dinglibs_get_string(ctx, secname, keyname);
}
+char **gp_config_get_string_array(struct gp_ini_context *ctx,
+ const char *secname,
+ const char *keyname,
+ int *num_values)
+{
+ return gp_dinglibs_get_string_array(ctx, secname, keyname, num_values);
+}
+
int gp_config_get_int(struct gp_ini_context *ctx,
const char *secname,
const char *keyname)
diff --git a/proxy/src/gp_config.h b/proxy/src/gp_config.h
index 5ae3495..8b6341b 100644
--- a/proxy/src/gp_config.h
+++ b/proxy/src/gp_config.h
@@ -36,6 +36,10 @@ int gp_config_init(const char *config_file,
char *gp_config_get_string(struct gp_ini_context *ctx,
const char *secname,
const char *keyname);
+char **gp_config_get_string_array(struct gp_ini_context *ctx,
+ const char *secname,
+ const char *keyname,
+ int *num_values);
int gp_config_get_int(struct gp_ini_context *ctx,
const char *secname,
const char *keyname);
diff --git a/proxy/src/gp_config_dinglibs.c b/proxy/src/gp_config_dinglibs.c
index c6a5a01..3728799 100644
--- a/proxy/src/gp_config_dinglibs.c
+++ b/proxy/src/gp_config_dinglibs.c
@@ -63,6 +63,86 @@ char *gp_dinglibs_get_string(struct gp_ini_context *ctx,
return value;
}
+char **gp_dinglibs_get_string_array(struct gp_ini_context *ctx,
+ const char *secname,
+ const char *key,
+ int *num_values)
+{
+ struct ini_cfgobj *ini_config = (struct ini_cfgobj *)ctx->private_data;
+ struct value_obj *vo = NULL;
+ const char *value;
+ int ret;
+ int i, count = 0;
+ char **array = NULL;
+
+ ret = ini_get_config_valueobj(secname,
+ key,
+ ini_config,
+ INI_GET_FIRST_VALUE,
+ &vo);
+ if (ret || !vo) {
+ return NULL;
+ }
+
+ value = ini_get_const_string_config_value(vo, &ret);
+ if (ret) {
+ return NULL;
+ }
+
+ array = calloc(1, sizeof(char *));
+ if (array == NULL) {
+ goto failed;
+ }
+
+ array[count] = strdup(value);
+ if (array[count] == NULL) {
+ goto failed;
+ }
+
+ count++;
+
+ do {
+ ret = ini_get_config_valueobj(secname,
+ key,
+ ini_config,
+ INI_GET_NEXT_VALUE,
+ &vo);
+ if (ret || !vo) {
+ break;
+ }
+
+ value = ini_get_const_string_config_value(vo, &ret);
+ if (ret) {
+ break;
+ }
+
+ array = realloc(array, count);
+ if (array == NULL) {
+ goto failed;
+ }
+
+ array[count] = strdup(value);
+ if (array[count] == NULL) {
+ goto failed;
+ }
+
+ count++;
+
+ } while (1);
+
+ *num_values = count;
+ return array;
+
+ failed:
+ if (array) {
+ for (i=0; i < count; i++) {
+ free(array[i]);
+ }
+ free(array);
+ }
+ return NULL;
+}
+
int gp_dinglibs_get_int(struct gp_ini_context *ctx,
const char *secname,
const char *key)
diff --git a/proxy/src/gp_config_dinglibs.h b/proxy/src/gp_config_dinglibs.h
index 3dadbee..eb8baff 100644
--- a/proxy/src/gp_config_dinglibs.h
+++ b/proxy/src/gp_config_dinglibs.h
@@ -27,6 +27,10 @@
char *gp_dinglibs_get_string(struct gp_ini_context *ctx,
const char *secname,
const char *key);
+char **gp_dinglibs_get_string_array(struct gp_ini_context *ctx,
+ const char *secname,
+ const char *key,
+ int *num_values);
int gp_dinglibs_get_int(struct gp_ini_context *ctx,
const char *secname,
const char *key);