gras_dynar_t *p_dynar = NULL;
gras_dd_cbps_elm_t *p_var = NULL;
- gras_dict_retrieve(ps->space, name, (void **)&p_dynar);
+ gras_dict_get(ps->space, name, (void **)&p_dynar);
if (!p_dynar) {
gras_dynar_new(&p_dynar, sizeof (gras_dd_cbps_elm_t *), NULL);
- gras_dict_insert(ps->space, name, (void **)p_dynar, NULL);
+ gras_dict_set(ps->space, name, (void **)p_dynar, NULL);
/* FIXME: leaking on dynar. Insert in dict with a way to free it */
}
void *data = NULL;
/* FIXME: Error handling */
- gras_dict_retrieve(ps->space, name, (void **)&p_dynar);
+ gras_dict_get(ps->space, name, (void **)&p_dynar);
gras_dynar_pop(p_dynar, &p_elm);
if (!gras_dynar_length(p_dynar)) {
gras_dynar_t *p_dynar = NULL;
gras_dd_cbps_elm_t *p_elm = NULL;
- gras_dict_retrieve(ps->space, name, (void **)&p_dynar);
+ gras_dict_get(ps->space, name, (void **)&p_dynar);
if (!p_dynar) {
gras_dynar_new(&p_dynar, sizeof (gras_dd_cbps_elm_t *), NULL);
- gras_dict_insert(ps->space, name, (void **)p_dynar, NULL);
+ gras_dict_set(ps->space, name, (void **)p_dynar, NULL);
p_elm = calloc(1, sizeof(gras_dd_cbps_elm_t));
gras_dynar_push(ps->globals, &name);
gras_dd_cbps_elm_t *p_elm = NULL;
/* FIXME: Error handling */
- gras_dict_retrieve(ps->space, name, (void **)&p_dynar);
+ gras_dict_get(ps->space, name, (void **)&p_dynar);
gras_dynar_pop(p_dynar, &p_elm);
gras_dynar_push(p_dynar, &p_elm);
gras_dynar_t *p_dynar_elm = NULL;
gras_dd_cbps_elm_t *p_elm = NULL;
- gras_dict_retrieve(ps->space, name, (void **)&p_dynar_elm);
+ gras_dict_get(ps->space, name, (void **)&p_dynar_elm);
gras_dynar_pop(p_dynar_elm, &p_elm);
if (!gras_dynar_length(p_dynar_elm)) {
DEBUG2("Insert %p under %p",*(void**)ptr, *(void**)r_ref);
/* FIXME: Leaking on the ptr. Do I really need to copy it? */
- TRY(gras_dict_insert_ext(refs,(const char *) r_ref, r_len, ptr, NULL));
+ TRY(gras_dict_set_ext(refs,(const char *) r_ref, r_len, ptr, NULL));
}
return no_error;
}
VERB0("Not sending NULL referenced data");
break;
}
- errcode = gras_dict_retrieve_ext(refs,(char*)ref, sizeof(void*), &dummy);
+ errcode = gras_dict_get_ext(refs,(char*)ref, sizeof(void*), &dummy);
if (errcode == mismatch_error) {
VERB1("Sending data referenced at %p", *ref);
- TRY(gras_dict_insert_ext(refs, (char*)ref, sizeof(void*), ref, NULL));
+ TRY(gras_dict_set_ext(refs, (char*)ref, sizeof(void*), ref, NULL));
TRY(gras_datadesc_by_id(ref_code, &sub_type));
TRY(gras_datadesc_send_rec(sock,state,refs, sub_type, *ref));
*(void**)l_data = NULL;
break;
}
- errcode = gras_dict_retrieve_ext(refs,
- (char*)r_ref, pointer_type->size[r_arch],
- (void**)&l_ref);
+ errcode = gras_dict_get_ext(refs,
+ (char*)r_ref, pointer_type->size[r_arch],
+ (void**)&l_ref);
if (errcode == mismatch_error) {
/* TCP */
TRY(gras_trp_tcp_init(&plug));
- TRY(gras_dict_insert(_gras_trp_plugins,
- plug->name, plug, gras_trp_plugin_free));
+ TRY(gras_dict_set(_gras_trp_plugins,
+ plug->name, plug, gras_trp_plugin_free));
/* FILE */
TRY(gras_trp_file_init(&plug));
- TRY(gras_dict_insert(_gras_trp_plugins,
- plug->name, plug, gras_trp_plugin_free));
+ TRY(gras_dict_set(_gras_trp_plugins,
+ plug->name, plug, gras_trp_plugin_free));
return no_error;
}
gras_trp_plugin_get_by_name(const char *name,
gras_trp_plugin_t **dst){
- return gras_dict_retrieve(_gras_trp_plugins,name,(void**)dst);
+ return gras_dict_get(_gras_trp_plugins,name,(void**)dst);
}
int gras_socket_my_port (gras_socket_t *sock) {
gras_cfgelm_t *res;
gras_error_t errcode;
- TRYCATCH(mismatch_error,gras_dict_retrieve((gras_dict_t*)cfg,name,(void**)&res));
+ TRYCATCH(mismatch_error,gras_dict_get((gras_dict_t*)cfg,name,(void**)&res));
if (errcode != mismatch_error) {
WARN1("Config elem %s registered twice.",name);
ERROR1("%d is an invalide type code",type);
}
- return gras_dict_insert((gras_dict_t*)cfg,name,res,&gras_cfgelm_free);
+ return gras_dict_set((gras_dict_t*)cfg,name,res,&gras_cfgelm_free);
}
/**
/* OUT */ gras_cfgelm_t **whereto){
gras_error_t errcode;
- TRYCATCH(mismatch_error,gras_dict_retrieve((gras_dict_t*)cfg,name,(void**)whereto));
+ TRYCATCH(mismatch_error,gras_dict_get((gras_dict_t*)cfg,name,(void**)whereto));
if (errcode == mismatch_error) {
ERROR1("No registered cell %s in this config set",
gras_cfgelm_t *cell;
gras_error_t errcode;
- TRYCATCH(mismatch_error,gras_dict_retrieve((gras_dict_t*)cfg,name,(void**)&cell));
+ TRYCATCH(mismatch_error,gras_dict_get((gras_dict_t*)cfg,name,(void**)&cell));
if (errcode == mismatch_error) {
ERROR1("Can't get the type of '%s' since this cell does not exist",
DEBUG2("name='%s';val='%s'",name,val);
- errcode=gras_dict_retrieve((gras_dict_t*)cfg,name,(void**)&cell);
+ errcode=gras_dict_get((gras_dict_t*)cfg,name,(void**)&cell);
switch (errcode) {
case no_error:
break;
gras_error_t errcode;
TRYCATCH(mismatch_error,
- gras_dict_retrieve((gras_dict_t*)cfg,name,(void**)&cell));
+ gras_dict_get((gras_dict_t*)cfg,name,(void**)&cell));
if (errcode == mismatch_error) {
ERROR1("Can't empty '%s' since this config element does not exist",
name);
}
/**
- * gras_dict_insert_ext:
+ * gras_dict_set_ext:
*
* @p_dict: the container
- * @key: the key to insert the new data
+ * @key: the key to set the new data
* @data: the data to add in the dict
* @Returns: a gras_error
*
- * Insert the @data in the structure under the @key, which can be any kind
+ * set the @data in the structure under the @key, which can be any kind
* of data, as long as its length is provided in @key_len.
*/
gras_error_t
-gras_dict_insert_ext(gras_dict_t *p_dict,
+gras_dict_set_ext(gras_dict_t *p_dict,
const char *key,
int key_len,
void *data,
gras_assert(p_dict);
- return gras_dictelm_insert_ext(&(p_dict->head),
+ return gras_dictelm_set_ext(&(p_dict->head),
key, key_len, data, free_ctn);
}
/**
- * gras_dict_insert:
+ * gras_dict_set:
*
* @head: the head of the dict
- * @key: the key to insert the new data
+ * @key: the key to set the new data
* @data: the data to add in the dict
* @Returns: a gras_error
*
- * Insert the @data in the structure under the @key, which is a
+ * set the @data in the structure under the @key, which is a
* null terminated string.
*/
gras_error_t
-gras_dict_insert(gras_dict_t *p_dict,
+gras_dict_set(gras_dict_t *p_dict,
const char *key,
void *data,
void_f_pvoid_t *free_ctn) {
gras_assert(p_dict);
- return gras_dictelm_insert(&(p_dict->head), key, data, free_ctn);
+ return gras_dictelm_set(&(p_dict->head), key, data, free_ctn);
}
/**
- * gras_dict_retrieve_ext:
+ * gras_dict_get_ext:
*
* @dict: the dealer of data
* @key: the key to find data
* Search the given @key. mismatch_error when not found.
*/
gras_error_t
-gras_dict_retrieve_ext(gras_dict_t *dict,
+gras_dict_get_ext(gras_dict_t *dict,
const char *key,
int key_len,
/* OUT */void **data) {
gras_assert(dict);
- return gras_dictelm_retrieve_ext(dict->head, key, key_len, data);
+ return gras_dictelm_get_ext(dict->head, key, key_len, data);
}
/**
- * gras_dict_retrieve:
+ * gras_dict_get:
*
* @dict: the dealer of data
* @key: the key to find data
* Search the given @key. mismatch_error when not found.
*/
gras_error_t
-gras_dict_retrieve(gras_dict_t *dict,
+gras_dict_get(gras_dict_t *dict,
const char *key,
/* OUT */void **data) {
gras_assert(dict);
- return gras_dictelm_retrieve(dict->head, key, data);
+ return gras_dictelm_get(dict->head, key, data);
}
gras_dynar_get((*cursor)->keys, (*cursor)->pos, key );
gras_dynar_get((*cursor)->key_lens, (*cursor)->pos_len, &key_len);
- errcode = gras_dictelm_retrieve_ext((*cursor)->head, *key, key_len, data);
+ errcode = gras_dictelm_get_ext((*cursor)->head, *key, key_len, data);
if (errcode == mismatch_error) {
gras_dict_cursor_free(*cursor);
*cursor=NULL;
gras_dynar_get(p_cursor->keys, p_cursor->pos-1, &key );
gras_dynar_get(p_cursor->key_lens, p_cursor->pos_len-1, &key_len);
- TRY(gras_dictelm_retrieve_ext(p_cursor->head, key, key_len, data));
+ TRY(gras_dictelm_get_ext(p_cursor->head, key, key_len, data));
return errcode;
}
-static gras_error_t _gras_dictelm_insert_rec(gras_dictelm_t *head,
+static gras_error_t _gras_dictelm_set_rec(gras_dictelm_t *head,
char *key,
int key_len,
int offset,
void *data,
void_f_pvoid_t *free_ctn);
-static gras_error_t _gras_dictelm_retrieve_rec(gras_dictelm_t *head,
+static gras_error_t _gras_dictelm_get_rec(gras_dictelm_t *head,
const char *key,
int key_len,
int offset,
}
/**
- * _gras_dictelm_insert_rec:
+ * _gras_dictelm_set_rec:
*
* @head: the head of the dict
- * @key: the key to insert the new data
+ * @key: the key to set the new data
* @offset: offset on key.
* @data: the data to add in the dict
* @Returns: a gras_error
*
- * Insert the @data in the structure under the @key. The @key is destroyed
+ * set the @data in the structure under the @key. The @key is destroyed
* in the process. Think to strdup it before.
*
- * This is a helper function to gras_dict_insert which locks the struct and
+ * This is a helper function to gras_dict_set which locks the struct and
* strdup the key before action.
*/
gras_error_t
-_gras_dictelm_insert_rec(gras_dictelm_t *p_head,
+_gras_dictelm_set_rec(gras_dictelm_t *p_head,
char *key,
int key_len,
int offset,
gras_dynar_get(p_head->sub, pos, &p_child);
CDEBUG2(dict_add,"-> Recurse on %p (offset=%d)", p_child, offset);
- return _gras_dictelm_insert_rec(p_child, key, key_len,
+ return _gras_dictelm_set_rec(p_child, key, key_len,
offset, data, free_ctn);
}
}
/**
- * gras_dictelm_insert_ext:
+ * gras_dictelm_set_ext:
*
* @head: the head of the dict
- * @key: the key to insert the new data
+ * @key: the key to set the new data
* @data: the data to add in the dict
* @Returns: a gras_error
*
- * Insert the @data in the structure under the @key, which can be any kind
+ * set the @data in the structure under the @key, which can be any kind
* of data, as long as its length is provided in @key_len.
*/
gras_error_t
-gras_dictelm_insert_ext(gras_dictelm_t **pp_head,
+gras_dictelm_set_ext(gras_dictelm_t **pp_head,
const char *_key,
int key_len,
void *data,
return errcode;
}
- return _gras_dictelm_insert_rec(p_head, key, key_len, 0, data, free_ctn);
+ return _gras_dictelm_set_rec(p_head, key, key_len, 0, data, free_ctn);
}
/**
- * gras_dictelm_insert:
+ * gras_dictelm_set:
*
* @head: the head of the dict
- * @key: the key to insert the new data
+ * @key: the key to set the new data
* @data: the data to add in the dict
* @Returns: a gras_error
*
- * Insert the @data in the structure under the @key, which is a
+ * set the @data in the structure under the @key, which is a
* null terminated string.
*/
gras_error_t
-gras_dictelm_insert(gras_dictelm_t **pp_head,
+gras_dictelm_set(gras_dictelm_t **pp_head,
const char *_key,
void *data,
void_f_pvoid_t *free_ctn) {
- return gras_dictelm_insert_ext(pp_head, _key, 1+strlen(_key), data, free_ctn);
+ return gras_dictelm_set_ext(pp_head, _key, 1+strlen(_key), data, free_ctn);
}
/**
- * _gras_dict_retrieve_rec:
+ * _gras_dict_get_rec:
*
* @head: the head of the dict
* @key: the key to find data
*/
static
gras_error_t
-_gras_dictelm_retrieve_rec(gras_dictelm_t *p_head,
+_gras_dictelm_get_rec(gras_dictelm_t *p_head,
const char *key,
int key_len,
int offset,
gras_dynar_get(p_head->sub, pos, &p_child);
- return _gras_dictelm_retrieve_rec(p_child, key, key_len, offset, data);
+ return _gras_dictelm_get_rec(p_child, key, key_len, offset, data);
}
case 3: /* The key is a prefix of the child => not found */
}
/**
- * gras_dictelm_retrieve_ext:
+ * gras_dictelm_get_ext:
*
* @head: the head of the dict
* @key: the key to find data
* Search the given @key. mismatch_error when not found.
*/
gras_error_t
-gras_dictelm_retrieve_ext(gras_dictelm_t *p_head,
+gras_dictelm_get_ext(gras_dictelm_t *p_head,
const char *key,
int key_len,
/* OUT */void **data) {
return mismatch_error;
}
- return _gras_dictelm_retrieve_rec(p_head, key, key_len, 0, data);
+ return _gras_dictelm_get_rec(p_head, key, key_len, 0, data);
}
/**
- * gras_dictelm_retrieve:
+ * gras_dictelm_get:
*
* @head: the head of the dict
* @key: the key to find data
* Search the given @key. mismatch_error when not found.
*/
gras_error_t
-gras_dictelm_retrieve(gras_dictelm_t *p_head,
+gras_dictelm_get(gras_dictelm_t *p_head,
const char *key,
/* OUT */void **data) {
- return gras_dictelm_retrieve_ext(p_head, key, 1+strlen(key), data);
+ return gras_dictelm_get_ext(p_head, key, 1+strlen(key), data);
}
/*----[ _gras_dict_collapse ]------------------------------------------------*/
/*####[ Multi dict functions ]##############################################*/
/*###############################"##########################################*/
/**
- * gras_mutidict_insert:
+ * gras_mutidict_set:
*
* @head: the head of dict
* @keycount: the number of the key
* @key: the key
- * @data: the data to insert
+ * @data: the data to set
* @Returns: gras_error_t
*
- * Insert the data in the structure under the @keycount @key.
+ * set the data in the structure under the @keycount @key.
*/
gras_error_t
-gras_multidict_insert_ext(gras_dict_t **pp_head,
+gras_multidict_set_ext(gras_dict_t **pp_head,
int keycount,
char **key,
int *key_len,
gras_dictelm_t *p_subdict = NULL;
int i = 0;
- CDEBUG2(dict_multi, "fast_multidict_insert(%p,%d). Keys:", *pp_head, keycount);
+ CDEBUG2(dict_multi, "fast_multidict_set(%p,%d). Keys:", *pp_head, keycount);
/*
for (i = 0; i < keycount; i++) {
}
*/
- gras_assert0(keycount >= 1, "Can't insert less than one key in a multidict");
+ gras_assert0(keycount >= 1, "Can't set less than one key in a multidict");
if (keycount == 1)
- return gras_dict_insert_ext(pp_head, key[0], key_len[0], data, free_ctn);
+ return gras_dict_set_ext(pp_head, key[0], key_len[0], data, free_ctn);
if (!*pp_head) {
TRY(_gras_dict_alloc(NULL, 0, 0, NULL, NULL, pp_head));
for (i = 0; i < keycount-1; i++) {
/* search the dict of next level */
- TRYCATCH(gras_dict_retrieve(p_elm, key[i], (void*)&p_subdict), mismatch_error);
+ TRYCATCH(gras_dict_get(p_elm, key[i], (void*)&p_subdict), mismatch_error);
/* make sure the dict of next level exists */
if (errcode == mismatch_error) {
TRY(_gras_dict_alloc(NULL, 0, 0, NULL, NULL, &p_subdict));
- TRY(gras_dict_insert_ext(&p_elm, key[i], key_len[i], &p_subdict,
+ TRY(gras_dict_set_ext(&p_elm, key[i], key_len[i], &p_subdict,
_free_dict));
}
p_elm = p_subdict;
}
- return gras_dict_insert_ext(&p_elm, key[i], key_len[i], data, free_ctn);
+ return gras_dict_set_ext(&p_elm, key[i], key_len[i], data, free_ctn);
}
gras_error_t
-gras_multidict_insert(gras_dictelm_t **pp_head,
+gras_multidict_set(gras_dictelm_t **pp_head,
int keycount,
char **key,
void *data,
key_len[i] = 1+strlen(key[i]);
}
- TRYCLEAN(gras_multidict_insert_ext(pp_head, keycount, key, key_len, data, free_ctn),
+ TRYCLEAN(gras_multidict_set_ext(pp_head, keycount, key, key_len, data, free_ctn),
free(key_len));
free(key_len);
}
/**
- * gras_mutidict_retrieve:
+ * gras_mutidict_get:
*
* @head: the head of dict
* @keycount: the number of the key
* @key: the key
- * @data: where to put the data retrieved
+ * @data: where to put the got data
* @Returns: gras_error_t
*
* Search the given @key. data=NULL when not found
gras_error_t
-gras_multidict_retrieve_ext(gras_dictelm_t *p_head,
+gras_multidict_get_ext(gras_dictelm_t *p_head,
int keycount,
const char **key,
int *key_len,
gras_dictelm_t *p_elm = p_head;
int i = 0;
- CDEBUG2(dict_multi, "fast_multidict_retrieve(%p, %d). Keys:", p_head, keycount);
+ CDEBUG2(dict_multi, "fast_multidict_get(%p, %d). Keys:", p_head, keycount);
/*
for (i = 0; i < keycount; i++) {
while (p_elm && i < keycount-1) {
- TRY(gras_dict_retrieve_ext(p_elm, key[i], key_len[i], (void**)p_elm));
+ TRY(gras_dict_get_ext(p_elm, key[i], key_len[i], (void**)p_elm));
/*
if (p_elm) {
if (p_elm) { // Found all dicts to the data
// gras_dict_dump(dict,&gras_dict_prints);
- return gras_dict_retrieve_ext(p_elm, key[i], key_len[i], data);
+ return gras_dict_get_ext(p_elm, key[i], key_len[i], data);
} else {
}
gras_error_t
-gras_multidict_retrieve(gras_dictelm_t *p_head,
+gras_multidict_get(gras_dictelm_t *p_head,
int keycount,
const char **key,
/* OUT */void **data) {
key_len[i] = 1+strlen(key[i]);
}
- TRYCLEAN(gras_multidict_retrieve_ext(p_head, keycount, key, key_len, data),
+ TRYCLEAN(gras_multidict_get_ext(p_head, keycount, key, key_len, data),
free(key_len));
free(key_len);
int i = 0;
while (p_elm && i < keycount-1) {
- if (!gras_dict_retrieve_ext(p_elm, key[i], key_len[i], (void**)&p_elm)) {
+ if (!gras_dict_get_ext(p_elm, key[i], key_len[i], (void**)&p_elm)) {
return 0;
}
}
elm->name_len = strlen(elm->name);
}
- errcode = gras_dict_retrieve_ext (set->dict,
+ errcode = gras_dict_get_ext (set->dict,
elm->name, elm->name_len,
(void**) &found_in_dict);
if (errcode == no_error) {
elm->ID=found_in_dict->ID;
DEBUG2("Reinsertion of key %s (id %d)", elm->name, elm->ID);
- TRY(gras_dict_insert_ext(set->dict, elm->name, elm->name_len, elm, free_func));
+ TRY(gras_dict_set_ext(set->dict, elm->name, elm->name_len, elm, free_func));
TRY(gras_dynar_set(set->dynar, elm->ID, &elm));
return no_error;
}
elm->ID = gras_dynar_length( set->dynar );
- TRY(gras_dict_insert_ext(set->dict, elm->name, elm->name_len, elm, free_func));
+ TRY(gras_dict_set_ext(set->dict, elm->name, elm->name_len, elm, free_func));
TRY(gras_dynar_set(set->dynar, elm->ID, &elm));
DEBUG2("Insertion of key '%s' (id %d)", elm->name, elm->ID);
* @name: Name of the searched cell
* @dst: where to put the found data into
*
- * Retrieve a data stored in the cell by providing its name.
+ * get a data stored in the cell by providing its name.
*/
gras_error_t gras_set_get_by_name (gras_set_t *set,
const char *name,
/* OUT */gras_set_elm_t **dst) {
- return gras_dict_retrieve_ext(set->dict, name, strlen(name), (void**) dst);
+ return gras_dict_get_ext(set->dict, name, strlen(name), (void**) dst);
}
/**
* gras_set_get_by_name_ext:
* @name_len: length of the name, when strlen cannot be trusted
* @dst: where to put the found data into
*
- * Retrieve a data stored in the cell by providing its name (and the length
+ * get a data stored in the cell by providing its name (and the length
* of the name, when strlen cannot be trusted because you don't use a char*
* as name, you weird guy).
*/
int name_len,
/* OUT */gras_set_elm_t **dst) {
- return gras_dict_retrieve_ext (set->dict, name, name_len, (void**)dst);
+ return gras_dict_get_ext (set->dict, name, name_len, (void**)dst);
}
/**
* @name_len: length of the name, when strlen cannot be trusted
* @dst: where to put the found data into
*
- * Retrieve a data stored in the cell by providing its name (and the length
+ * get a data stored in the cell by providing its name (and the length
* of the name, when strlen cannot be trusted because you don't use a char*
* as name, you weird guy).
*/
key[k]=rand() % ('z' - 'a') + 'a';
key[k]='\0';
// printf("[%d %s]\n",j,key);
- TRYFAIL(gras_dict_insert(head,key,key,&free));
+ TRYFAIL(gras_dict_set(head,key,key,&free));
}
nb=0;
// gras_dict_dump(head,(void (*)(void*))&printf);
}
sprintf(key,"%d",j);
- TRYFAIL(gras_dict_insert(head,key,key,&free));
+ TRYFAIL(gras_dict_set(head,key,key,&free));
}
printf("\n Count the elements (retrieving the key and data for each): \n");
for (j=0;j<NB_ELM;j++) {
sprintf(key,"%d",j);
- TRYFAIL(gras_dict_retrieve(head,key,&data));
+ TRYFAIL(gras_dict_get(head,key,&data));
if (strcmp(key,(char*)data)) {
printf("key=%s != data=%s\n",key,(char*)data);
abort();
char *data=strdup(key);
printf(" - Add %s\n",key);
- errcode=gras_dict_insert(head,key,data,&free);
+ errcode=gras_dict_set(head,key,data,&free);
if (GRAS_LOG_ISENABLED(dict,gras_log_priority_debug)) {
gras_dict_dump(head,(void (*)(void*))&printf);
fflush(stdout);
gras_error_t errcode;
- errcode=gras_dict_retrieve(head,key,&data);
+ errcode=gras_dict_get(head,key,&data);
printf(" - Search %s. Found %s\n",key,data?(char*)data:"(null)");fflush(stdout);
if (strcmp((char*)data,key))
return mismatch_error;
printf(" - Change some values\n");
printf(" - Change 123 to 'Changed 123'\n");
- TRYFAIL(gras_dict_insert(head,"123",strdup("Changed 123"),&free));
+ TRYFAIL(gras_dict_set(head,"123",strdup("Changed 123"),&free));
printf(" - Change 123 back to '123'\n");
- TRYFAIL(gras_dict_insert(head,"123",strdup("123"),&free));
+ TRYFAIL(gras_dict_set(head,"123",strdup("123"),&free));
printf(" - Change 12a to 'Dummy 12a'\n");
- TRYFAIL(gras_dict_insert(head,"12a",strdup("Dummy 12a"),&free));
+ TRYFAIL(gras_dict_set(head,"12a",strdup("Dummy 12a"),&free));
printf(" - Change 12a to '12a'\n");
- TRYFAIL(gras_dict_insert(head,"12a",strdup("12a"),&free));
+ TRYFAIL(gras_dict_set(head,"12a",strdup("12a"),&free));
// gras_dict_dump(head,(void (*)(void*))&printf);
printf(" - Traverse the resulting dictionnary\n");
TRYFAIL(traverse(head));
printf(" - Retrive values\n");
- TRYFAIL(gras_dict_retrieve(head,"123",(void**)&data));
+ TRYFAIL(gras_dict_get(head,"123",(void**)&data));
assert(data);
TRYFAIL(strcmp("123",data));
- TRYEXPECT(gras_dict_retrieve(head,"Can't be found",(void**)&data),mismatch_error);
- TRYEXPECT(gras_dict_retrieve(head,"123 Can't be found",(void**)&data),mismatch_error);
- TRYEXPECT(gras_dict_retrieve(head,"12345678 NOT",(void**)&data),mismatch_error);
+ TRYEXPECT(gras_dict_get(head,"Can't be found",(void**)&data),mismatch_error);
+ TRYEXPECT(gras_dict_get(head,"123 Can't be found",(void**)&data),mismatch_error);
+ TRYEXPECT(gras_dict_get(head,"12345678 NOT",(void**)&data),mismatch_error);
TRYFAIL(search(head,"12a"));
TRYFAIL(search(head,"12b"));
key[l]=val[l];// NOWADAYS, no need to strdup the key.
}
if (verbose) printf("in multitree %p.\n",head);
- TRYFAIL(gras_multidict_insert(&head,MULTICACHE_DEPTH,key,
- strdup(val[0]),&free));
+ TRYFAIL(gras_multidict_set(&head,MULTICACHE_DEPTH,key,
+ strdup(val[0]),&free));
- TRYFAIL(gras_multidict_retrieve(head,
- MULTICACHE_DEPTH,(const char **)val,
- &data));
+ TRYFAIL(gras_multidict_get(head,
+ MULTICACHE_DEPTH,(const char **)val,
+ &data));
if (!data || strcmp((char*)data,val[0])) {
fprintf(stderr,"Retrieved value (%s) does not match the entrered one (%s)\n",
(char*)data,val[0]);