From 000e65d7af7be31236e060064fb3b4a332e78cf3 Mon Sep 17 00:00:00 2001 From: Amar Tumballi Date: Tue, 13 Nov 2012 01:14:43 +0530 Subject: 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 BUG: 875913 Reviewed-on: http://review.gluster.org/4187 Tested-by: Gluster Build System Reviewed-by: Anand Avati --- libglusterfs/src/dict.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'libglusterfs/src/dict.c') diff --git a/libglusterfs/src/dict.c b/libglusterfs/src/dict.c index e9b8da1c..a8cdeaf2 100644 --- a/libglusterfs/src/dict.c +++ b/libglusterfs/src/dict.c @@ -1078,6 +1078,13 @@ data_to_bin (data_t *data) return data->data; } +int +dict_null_foreach_fn (dict_t *d, char *k, + data_t *v, void *tmp) +{ + return 0; +} + int dict_foreach (dict_t *dict, int (*fn)(dict_t *this, @@ -1148,6 +1155,45 @@ dict_foreach_fnmatch (dict_t *dict, char *pattern, } +/** + * dict_keys_join - pack the keys of the dictionary in a buffer. + * + * @value : buffer in which the keys will be packed (can be NULL) + * @size : size of the buffer which is sent (can be 0, in which case buffer + * is not packed but only length is returned) + * @dict : dictionary of which all the keys will be packed + * @filter_fn : keys matched in filter_fn() is counted. + * + * @return : @length of string after joining keys. + * + */ + +int +dict_keys_join (void *value, int size, dict_t *dict, + int (*filter_fn)(char *k)) +{ + int len = 0; + data_pair_t *pairs = NULL; + data_pair_t *next = NULL; + + pairs = dict->members_list; + while (pairs) { + next = pairs->next; + + if (filter_fn && filter_fn (pairs->key)) + continue; + + if (value && (size > len)) + strncpy (value + len, pairs->key, size - len); + + len += (strlen (pairs->key) + 1); + + pairs = next; + } + + return len; +} + static int _copy (dict_t *unused, char *key, -- cgit