summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src
diff options
context:
space:
mode:
Diffstat (limited to 'libglusterfs/src')
-rw-r--r--libglusterfs/src/dict.c45
-rw-r--r--libglusterfs/src/dict.h19
-rw-r--r--libglusterfs/src/libglusterfs.sym9
3 files changed, 68 insertions, 5 deletions
diff --git a/libglusterfs/src/dict.c b/libglusterfs/src/dict.c
index a3998c463eb..b7cf2b0c8fe 100644
--- a/libglusterfs/src/dict.c
+++ b/libglusterfs/src/dict.c
@@ -1810,6 +1810,32 @@ err:
}
int
+dict_get_int32n (dict_t *this, char *key, const int keylen, int32_t *val)
+{
+ data_t * data = NULL;
+ int ret = 0;
+
+ if (!this || !key || !val) {
+ ret = -EINVAL;
+ goto err;
+ }
+
+ ret = dict_get_with_refn (this, key, keylen, &data);
+ if (ret != 0) {
+ goto err;
+ }
+
+ VALIDATE_DATA_AND_LOG(data, GF_DATA_TYPE_INT, key, -EINVAL);
+
+ ret = data_to_int32_ptr (data, val);
+
+err:
+ if (data)
+ data_unref (data);
+ return ret;
+}
+
+int
dict_get_int32 (dict_t *this, char *key, int32_t *val)
{
data_t * data = NULL;
@@ -1835,6 +1861,25 @@ err:
return ret;
}
+int
+dict_set_int32n (dict_t *this, char *key, const int keylen, int32_t val)
+{
+ data_t * data = NULL;
+ int ret = 0;
+
+ data = data_from_int32 (val);
+ if (!data) {
+ ret = -EINVAL;
+ goto err;
+ }
+
+ ret = dict_setn (this, key, keylen, data);
+ if (ret < 0)
+ data_destroy (data);
+
+err:
+ return ret;
+}
int
dict_set_int32 (dict_t *this, char *key, int32_t val)
diff --git a/libglusterfs/src/dict.h b/libglusterfs/src/dict.h
index 009663aec2e..a8945d017b7 100644
--- a/libglusterfs/src/dict.h
+++ b/libglusterfs/src/dict.h
@@ -113,7 +113,8 @@ int32_t dict_setn (dict_t *this, char *key, const int keylen, data_t *value);
int32_t dict_add (dict_t *this, char *key, data_t *value);
int32_t dict_addn (dict_t *this, char *key, const int keylen, data_t *value);
int dict_get_with_ref (dict_t *this, char *key, data_t **data);
-int dict_get_with_refn (dict_t *this, char *key, const int keylen, data_t **data);
+int dict_get_with_refn (dict_t *this, char *key, const int keylen,
+ data_t **data);
data_t *dict_get (dict_t *this, char *key);
data_t *dict_getn (dict_t *this, char *key, const int keylen);
void dict_del (dict_t *this, char *key);
@@ -219,7 +220,11 @@ GF_MUST_CHECK int dict_get_int16 (dict_t *this, char *key, int16_t *val);
GF_MUST_CHECK int dict_set_int16 (dict_t *this, char *key, int16_t val);
GF_MUST_CHECK int dict_get_int32 (dict_t *this, char *key, int32_t *val);
+GF_MUST_CHECK int dict_get_int32n (dict_t *this, char *key, const int keylen,
+ int32_t *val);
GF_MUST_CHECK int dict_set_int32 (dict_t *this, char *key, int32_t val);
+GF_MUST_CHECK int dict_set_int32n (dict_t *this, char *key, const int keylen,
+ int32_t val);
GF_MUST_CHECK int dict_get_int64 (dict_t *this, char *key, int64_t *val);
GF_MUST_CHECK int dict_set_int64 (dict_t *this, char *key, int64_t val);
@@ -251,14 +256,18 @@ GF_MUST_CHECK int dict_set_static_bin (dict_t *this, char *key, void *ptr, size_
GF_MUST_CHECK int dict_set_option (dict_t *this, char *key, char *str);
GF_MUST_CHECK int dict_set_str (dict_t *this, char *key, char *str);
-GF_MUST_CHECK int dict_set_strn (dict_t *this, char *key, const int keylen, char *str);
-GF_MUST_CHECK int dict_set_nstrn (dict_t *this, char *key, const int keylen, char *str, const int vallen);
+GF_MUST_CHECK int dict_set_strn (dict_t *this, char *key, const int keylen,
+ char *str);
+GF_MUST_CHECK int dict_set_nstrn (dict_t *this, char *key, const int keylen,
+ char *str, const int vallen);
GF_MUST_CHECK int dict_set_dynstr (dict_t *this, char *key, char *str);
-GF_MUST_CHECK int dict_set_dynstrn (dict_t *this, char *key, const int keylen, char *str);
+GF_MUST_CHECK int dict_set_dynstrn (dict_t *this, char *key, const int keylen,
+ char *str);
GF_MUST_CHECK int dict_set_dynstr_with_alloc (dict_t *this, char *key, const char *str);
GF_MUST_CHECK int dict_add_dynstr_with_alloc (dict_t *this, char *key, char *str);
GF_MUST_CHECK int dict_get_str (dict_t *this, char *key, char **str);
-GF_MUST_CHECK int dict_get_strn (dict_t *this, char *key, const int keylen, char **str);
+GF_MUST_CHECK int dict_get_strn (dict_t *this, char *key, const int keylen,
+ char **str);
GF_MUST_CHECK int dict_get_str_boolean (dict_t *this, char *key, int default_val);
GF_MUST_CHECK int dict_rename_key (dict_t *this, char *key, char *replace_key);
diff --git a/libglusterfs/src/libglusterfs.sym b/libglusterfs/src/libglusterfs.sym
index 61a866a3d27..c5b322a9bdf 100644
--- a/libglusterfs/src/libglusterfs.sym
+++ b/libglusterfs/src/libglusterfs.sym
@@ -354,11 +354,13 @@ default_put_resume
__dentry_grep
dht_is_linkfile
dict_add
+dict_addn
dict_add_dynstr_with_alloc
dict_allocate_and_serialize
dict_copy
dict_copy_with_ref
dict_del
+dict_deln
dict_dump_to_statedump
dict_dump_to_str
dict_dump_to_log
@@ -367,17 +369,20 @@ dict_foreach_fnmatch
dict_foreach_match
dict_for_key_value
dict_get
+dict_getn
dict_get_bin
dict_get_double
dict_get_gfuuid
dict_get_iatt
dict_get_int16
dict_get_int32
+dict_get_int32n
dict_get_int64
dict_get_int8
dict_get_ptr
dict_get_ptr_and_len
dict_get_str
+dict_get_strn
dict_get_str_boolean
dict_get_uint32
dict_get_uint64
@@ -396,21 +401,25 @@ dict_serialize
dict_serialized_length
dict_serialize_value_with_delim
dict_set
+dict_setn
dict_set_bin
dict_set_double
dict_set_dynptr
dict_set_dynstr
+dict_set_dynstrn
dict_set_dynstr_with_alloc
dict_set_gfuuid
dict_set_iatt
dict_set_int16
dict_set_int32
+dict_set_int32n
dict_set_int64
dict_set_int8
dict_set_static_bin
dict_set_static_ptr
dict_set_str
dict_set_strn
+dict_setn_nstrn
dict_set_nstrn
dict_set_uint32
dict_set_uint64