summaryrefslogtreecommitdiffstats
path: root/cli
diff options
context:
space:
mode:
authorAmar Tumballi <amarts@redhat.com>2012-11-13 01:14:43 +0530
committerAnand Avati <avati@redhat.com>2012-12-19 23:35:29 -0800
commit000e65d7af7be31236e060064fb3b4a332e78cf3 (patch)
treeff9e3ca119d8c43b9a12402fe1de84d8142f105a /cli
parente5a19e2ab587175c91fde0f0c33319dcbff73018 (diff)
core: remove all the 'inner' functions in codebase
* move 'dict_keys_join()' from api/glfs_fops.c to libglusterfs/dict.c - also added an argument which is treated as a filter function if required, currently useful for fuse. * now 'make CFLAGS="-std=gnu99 -pedantic" 2>&1 | grep nested' gives no output. Change-Id: I4e18496fbd93ae1d3942026ef4931889cba015e8 Signed-off-by: Amar Tumballi <amarts@redhat.com> BUG: 875913 Reviewed-on: http://review.gluster.org/4187 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'cli')
-rw-r--r--cli/src/cli-rpc-ops.c44
-rw-r--r--cli/src/cli-xml-output.c56
2 files changed, 60 insertions, 40 deletions
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c
index 22a69da730f..c5a0fffb8a6 100644
--- a/cli/src/cli-rpc-ops.c
+++ b/cli/src/cli-rpc-ops.c
@@ -474,6 +474,30 @@ cli_out_options ( char *substr, char *optstr, char *valstr)
cli_out ("%s: %s",ptr2 , valstr);
}
+static int
+_gf_cli_output_volinfo_opts (dict_t *d, char *k,
+ data_t *v, void *tmp)
+{
+ int ret = 0;
+ char *key = NULL;
+ char *ptr = NULL;
+ data_t *value = NULL;
+
+ key = tmp;
+
+ ptr = strstr (k, "option.");
+ if (ptr) {
+ value = v;
+ if (!value) {
+ ret = -1;
+ goto out;
+ }
+ cli_out_options (key, k, v->data);
+ }
+out:
+ return ret;
+}
+
int
gf_cli_get_volume_cbk (struct rpc_req *req, struct iovec *iov,
@@ -491,12 +515,10 @@ gf_cli_get_volume_cbk (struct rpc_req *req, struct iovec *iov,
int32_t replica_count = 0;
int32_t vol_type = 0;
int32_t transport = 0;
- char *ptr = NULL;
char *volume_id_str = NULL;
char *brick = NULL;
char *volname = NULL;
dict_t *dict = NULL;
- data_t *value = NULL;
cli_local_t *local = NULL;
char key[1024] = {0};
char err_str[2048] = {0};
@@ -724,22 +746,8 @@ next:
cli_out ("Options Reconfigured:");
snprintf (key, 256, "volume%d.option.",i);
- int _output_volinfo_opts (dict_t *d, char *k,
- data_t *v, void *tmp)
- {
- ptr = strstr (k, "option.");
- if (ptr) {
- value = v;
- if (!value) {
- ret = -1;
- goto internal_out;
- }
- cli_out_options (key, k, v->data);
- }
- internal_out:
- return ret;
- }
- ret = dict_foreach (dict, _output_volinfo_opts, NULL);
+
+ ret = dict_foreach (dict, _gf_cli_output_volinfo_opts, key);
if (ret)
goto out;
diff --git a/cli/src/cli-xml-output.c b/cli/src/cli-xml-output.c
index 88410ef5767..7155ef539b8 100644
--- a/cli/src/cli-xml-output.c
+++ b/cli/src/cli-xml-output.c
@@ -2265,15 +2265,44 @@ out:
return ret;
}
+struct tmp_xml_option_logger {
+ char *key;
+ xmlTextWriterPtr writer;
+};
+
+static int
+_output_vol_info_option (dict_t *d, char *k, data_t *v,
+ void *data)
+{
+ int ret = 0;
+ char *ptr = NULL;
+ struct tmp_xml_option_logger *tmp = NULL;
+
+ tmp = data;
+
+ ptr = strstr (k, "option.");
+ if (!ptr)
+ goto out;
+
+ if (!v) {
+ ret = -1;
+ goto out;
+ }
+ ret = cli_xml_output_vol_info_option (tmp->writer, tmp->key, k,
+ v->data);
+
+out:
+ return ret;
+}
+
int
cli_xml_output_vol_info_options (xmlTextWriterPtr writer, dict_t *dict,
char *prefix)
{
int ret = -1;
int opt_count = 0;
- data_t *value = 0;
- char *ptr = NULL;
char key[1024] = {0,};
+ struct tmp_xml_option_logger tmp = {0,};
snprintf (key, sizeof (key), "%s.opt_count", prefix);
ret = dict_get_int32 (dict, key, &opt_count);
@@ -2288,26 +2317,9 @@ cli_xml_output_vol_info_options (xmlTextWriterPtr writer, dict_t *dict,
XML_RET_CHECK_AND_GOTO (ret, out);
snprintf (key, sizeof (key), "%s.option.", prefix);
- int _output_vol_info_option (dict_t *d, char *k, data_t *v,
- void *data)
- {
- int ret = 0;
- ptr = strstr (k, "option.");
- if (!ptr)
- goto internal_out;
-
- value = v;
- if (!value) {
- ret = -1;
- goto internal_out;
- }
- ret = cli_xml_output_vol_info_option (writer, key, k,
- v->data);
-
- internal_out:
- return ret;
- }
- ret = dict_foreach (dict, _output_vol_info_option, NULL);
+ tmp.key = key;
+ tmp.writer = writer;
+ ret = dict_foreach (dict, _output_vol_info_option, &tmp);
if (ret)
goto out;