summaryrefslogtreecommitdiffstats
path: root/cli/src
diff options
context:
space:
mode:
Diffstat (limited to 'cli/src')
-rw-r--r--cli/src/input.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/cli/src/input.c b/cli/src/input.c
index a8ea46c6db6..26f337c3c27 100644
--- a/cli/src/input.c
+++ b/cli/src/input.c
@@ -87,7 +87,7 @@ cli_input_init (struct cli_state *state)
cli_rl_enable (state);
} else {
state->prompt = "";
- state->mode = GLUSTER_MODE_SCRIPT | GLUSTER_MODE_ERR_FATAL;
+ state->mode |= GLUSTER_MODE_SCRIPT | GLUSTER_MODE_ERR_FATAL;
}
if (!state->rl_enabled)
this->free_pair_in_use = _gf_true; } if (key_free) { /* It's ours. Use it. */ pair->key = key; key_free = 0; } else { pair->key = (char *) GF_CALLOC (1, strlen (key) + 1, gf_common_mt_char); if (!pair->key) { if (pair == &this->free_pair) { this->free_pair_in_use = _gf_false; } else { mem_put (pair); } return -1; } strcpy (pair->key, key); } pair->value = data_ref (value); pair->hash_next = this->members[hashval]; this->members[hashval] = pair; pair->next = this->members_list; pair->prev = NULL; if (this->members_list) this->members_list->prev = pair; this->members_list = pair; this->count++; if (key_free) GF_FREE (key); return 0; } int32_t dict_set (dict_t *this, char *key, data_t *value) { int32_t ret; if (!this || !value) { gf_log_callingfn ("dict", GF_LOG_WARNING, "!this || !value for key=%s", key); return -1; } LOCK (&this->lock); ret = _dict_set (this, key, value, 1); UNLOCK (&this->lock); return ret; } int32_t dict_add (dict_t *this, char *key, data_t *value) { int32_t ret; if (!this || !value) { gf_log_callingfn ("dict", GF_LOG_WARNING, "!this || !value for key=%s", key); return -1; } LOCK (&this->lock); ret = _dict_set (this, key, value, 0); UNLOCK (&this->lock); return ret; } data_t * dict_get (dict_t *this, char *key) { data_pair_t *pair; if (!this || !key) { gf_log_callingfn ("dict", GF_LOG_INFO, "!this || key=%s", (key) ? key : "()"); return NULL; } LOCK (&this->lock); pair = _dict_lookup (this, key); UNLOCK (&this->lock); if (pair) return pair->value; return NULL; } void dict_del (dict_t *this, char *key) { if (!this || !key) { gf_log_callingfn ("dict", GF_LOG_WARNING, "!this || key=%s", key); return; } LOCK (&this->lock); int hashval = SuperFastHash (key, strlen (key)) % this->hash_size; data_pair_t *pair = this->members[hashval]; data_pair_t *prev = NULL; while (pair) { if (strcmp (pair->key, key) == 0) { if (prev) prev->hash_next = pair->hash_next; else this->members[hashval] = pair->hash_next; data_unref (pair->value); if (pair->prev) pair->prev->next = pair->next; else this->members_list = pair->next; if (pair->next) pair->next->prev = pair->prev; GF_FREE (pair->key); if (pair == &this->free_pair) { this->free_pair_in_use = _gf_false; } else { mem_put (pair); } this->count--; break; } prev = pair; pair = pair->hash_next; } UNLOCK (&this->lock); return; } void dict_destroy (dict_t *this) { if (!this) { gf_log_callingfn ("dict", GF_LOG_WARNING, "dict is NULL"); return; } data_pair_t *pair = this->members_list; data_pair_t *prev = this->members_list; LOCK_DESTROY (&this->lock); while (prev) { pair = pair->next; data_unref (prev->value); GF_FREE (prev->key); if (prev != &this->free_pair) { mem_put (prev); } prev = pair; } if (this->members != &this->members_internal) { mem_put (this->members); } GF_FREE (this->extra_free); free (this->extra_stdfree); if (!this->is_static) mem_put (this); return; } void dict_unref (dict_t *this) { int32_t ref; if (!this) { gf_log_callingfn ("dict", GF_LOG_WARNING, "dict is NULL"); return; } LOCK (&this->lock); this->refcount--; ref = this->refcount; UNLOCK (&this->lock); if (!ref) dict_destroy (this); } dict_t * dict_ref (dict_t *this) { if (!this) { gf_log_callingfn ("dict", GF_LOG_WARNING, "dict is NULL"); return NULL; } LOCK (&this->lock); this->refcount++; UNLOCK (&this->lock); return this; } void data_unref (data_t *this) { int32_t ref; if (!this) { gf_log_callingfn ("dict", GF_LOG_WARNING, "dict is NULL"); return; } LOCK (&this->lock); this->refcount--; ref = this->refcount; UNLOCK (&this->lock); if (!ref) data_destroy (this); } data_t * data_ref (data_t *this) { if (!this) { gf_log_callingfn ("dict", GF_LOG_WARNING, "dict is NULL"); return NULL; } LOCK (&this->lock); this->refcount++; UNLOCK (&this->lock); return this; } data_t * int_to_data (int64_t value) { int ret = 0; data_t *data = get_new_data (); if (!data) { return NULL; } ret = gf_asprintf (&data->data, "%"PRId64, value); if (-1 == ret) { gf_log ("dict", GF_LOG_DEBUG, "asprintf failed"); return NULL; } data->len = strlen (data->data) + 1; return data; } data_t * data_from_int64 (int64_t value) { int ret = 0; data_t *data = get_new_data (); if (!data) { return NULL; } ret = gf_asprintf (&data->data, "%"PRId64, value); if (-1 == ret) { gf_log ("dict", GF_LOG_DEBUG, "asprintf failed"); return NULL; } data->len = strlen (data->data) + 1; return data; } data_t * data_from_int32 (int32_t value) { int ret = 0; data_t *data = get_new_data (); if (!data) { return NULL; } ret = gf_asprintf (&data->data, "%"PRId32, value); if (-1 == ret) { gf_log ("dict", GF_LOG_DEBUG, "asprintf failed"); return NULL; } data->len = strlen (data->data) + 1; return data; } data_t * data_from_int16 (int16_t value) { int ret = 0; data_t *data = get_new_data (); if (!data) { return NULL; } ret = gf_asprintf (&data->data, "%"PRId16, value); if (-1 == ret) { gf_log ("dict", GF_LOG_DEBUG, "asprintf failed"); return NULL; } data->len = strlen (data->data) + 1; return data; } data_t * data_from_int8 (int8_t value) { int ret = 0; data_t *data = get_new_data (); if (!data) { return NULL; } ret = gf_asprintf (&data->data, "%d", value); if (-1 == ret) { gf_log ("dict", GF_LOG_DEBUG, "asprintf failed"); return NULL; } data->len = strlen (data->data) + 1; return data; } data_t * data_from_uint64 (uint64_t value) { int ret = 0; data_t *data = get_new_data (); if (!data) { return NULL; } ret = gf_asprintf (&data->data, "%"PRIu64, value); if (-1 == ret) { gf_log ("dict", GF_LOG_DEBUG, "asprintf failed"); return NULL; } data->len = strlen (data->data) + 1; return data; } static data_t * data_from_double (double value) { d