All hash_ functions have been prefixed with clicon_ to avoid name collision with other packages (frr)

This commit is contained in:
Olof hagsand 2019-06-18 14:49:18 +02:00
parent 3dba0b5370
commit 17e3e74ad5
8 changed files with 89 additions and 89 deletions

View file

@ -67,6 +67,7 @@
### API changes on existing features (you may need to change your code) ### API changes on existing features (you may need to change your code)
* All hash_ functions have been prefixed with `clicon_` to avoid name collision with other packages (frr)
* Added compiled regexp parameter as part of internal yang type resolution functions * Added compiled regexp parameter as part of internal yang type resolution functions
* `yang_type_resolve()`, `yang_type_get()` * `yang_type_resolve()`, `yang_type_get()`
* All internal `ys_populate_*()` functions (except ys_populate()) have switched parameters: `clicon_handle, yang_stmt *)` * All internal `ys_populate_*()` functions (except ys_populate()) have switched parameters: `clicon_handle, yang_stmt *)`

View file

@ -107,7 +107,7 @@ cli_notification_register(clicon_handle h,
goto done; goto done;
} }
snprintf(logname, len, "log_socket_%s", stream); snprintf(logname, len, "log_socket_%s", stream);
if ((p = hash_value(cdat, logname, &len)) != NULL) if ((p = clicon_hash_value(cdat, logname, &len)) != NULL)
s_exist = *(int*)p; s_exist = *(int*)p;
if (status){ /* start */ if (status){ /* start */
@ -119,14 +119,14 @@ cli_notification_register(clicon_handle h,
goto done; goto done;
if (cligen_regfd(s, fn, arg) < 0) if (cligen_regfd(s, fn, arg) < 0)
goto done; goto done;
if (hash_add(cdat, logname, &s, sizeof(s)) == NULL) if (clicon_hash_add(cdat, logname, &s, sizeof(s)) == NULL)
goto done; goto done;
} }
else{ /* stop */ else{ /* stop */
if (s_exist != -1){ if (s_exist != -1){
cligen_unregfd(s_exist); cligen_unregfd(s_exist);
} }
hash_del(cdat, logname); clicon_hash_del(cdat, logname);
#if 0 /* cant turn off */ #if 0 /* cant turn off */
if (clicon_rpc_create_subscription(h, status, stream, format, filter, NULL) < 0) if (clicon_rpc_create_subscription(h, status, stream, format, filter, NULL) < 0)
goto done; goto done;

View file

@ -44,14 +44,14 @@ struct clicon_hash {
}; };
typedef struct clicon_hash *clicon_hash_t; typedef struct clicon_hash *clicon_hash_t;
clicon_hash_t *hash_init (void); clicon_hash_t *clicon_hash_init (void);
void hash_free (clicon_hash_t *); void clicon_hash_free (clicon_hash_t *);
clicon_hash_t hash_lookup (clicon_hash_t *head, const char *key); clicon_hash_t clicon_hash_lookup (clicon_hash_t *head, const char *key);
void *hash_value (clicon_hash_t *head, const char *key, size_t *vlen); void *clicon_hash_value (clicon_hash_t *head, const char *key, size_t *vlen);
clicon_hash_t hash_add (clicon_hash_t *head, const char *key, void *val, size_t vlen); clicon_hash_t clicon_hash_add (clicon_hash_t *head, const char *key, void *val, size_t vlen);
int hash_del (clicon_hash_t *head, const char *key); int clicon_hash_del (clicon_hash_t *head, const char *key);
int hash_dump(clicon_hash_t *head, FILE *f); int clicon_hash_dump(clicon_hash_t *head, FILE *f);
int hash_keys(clicon_hash_t *hash, char ***vector, size_t *nkeys); int clicon_hash_keys(clicon_hash_t *hash, char ***vector, size_t *nkeys);
/* /*
* Macros to iterate over hash contents. * Macros to iterate over hash contents.
@ -59,24 +59,23 @@ int hash_keys(clicon_hash_t *hash, char ***vector, size_t *nkeys);
* *
* Example: * Example:
* char *k; * char *k;
* clicon_hash_t *h = hash_init(); * clicon_hash_t *h = clicon_hash_init();
* *
* hash_add(h, "colour", "red", 6); * clicon_hash_add(h, "colour", "red", 6);
* hash_add(h, "name", "rudolf" 7); * clicon_hash_add(h, "name", "rudolf" 7);
* hash_add(h, "species", "reindeer" 9); * clicon_hash_add(h, "species", "reindeer" 9);
* *
* hash_each(h, k) { * clicon_hash_each(h, k) {
* printf ("%s = %s\n", k, (char *)hash_value(h, k, NULL)); * printf ("%s = %s\n", k, (char *)clicon_hash_value(h, k, NULL));
* } hash_each_end(); * } hash_each_end();
*/ */
#define hash_each(__hash__, __key__) \ #define clicon_hash_each(__hash__, __key__) \
{ \ { \
int __i__; \ int __i__; \
size_t __n__; \ size_t __n__; \
char **__k__ = hash_keys((__hash__),&__n__); \ char **__k__ = hash_keys((__hash__),&__n__); \
if (__k__) { \ if (__k__) { \
for(__i__ = 0; __i__ < __n__ && ((__key__) = __k__[__i__]); __i__++) for(__i__ = 0; __i__ < __n__ && ((__key__) = __k__[__i__]); __i__++)
#define hash_each_end(__hash__) if (__k__) free(__k__); } } #define clicon_hash_each_end(__hash__) if (__k__) free(__k__); } }
#endif /* _CLIXON_HASH_H_ */ #endif /* _CLIXON_HASH_H_ */

View file

@ -83,7 +83,7 @@ clicon_dbspec_yang(clicon_handle h)
size_t len; size_t len;
void *p; void *p;
if ((p = hash_value(cdat, "dbspec_yang", &len)) != NULL) if ((p = clicon_hash_value(cdat, "dbspec_yang", &len)) != NULL)
return *(yang_stmt **)p; return *(yang_stmt **)p;
return NULL; return NULL;
} }
@ -100,7 +100,7 @@ clicon_dbspec_yang_set(clicon_handle h,
/* It is the pointer to ys that should be copied by hash, /* It is the pointer to ys that should be copied by hash,
so we send a ptr to the ptr to indicate what to copy. so we send a ptr to the ptr to indicate what to copy.
*/ */
if (hash_add(cdat, "dbspec_yang", &ys, sizeof(ys)) == NULL) if (clicon_hash_add(cdat, "dbspec_yang", &ys, sizeof(ys)) == NULL)
return -1; return -1;
return 0; return 0;
} }
@ -118,7 +118,7 @@ clicon_nacm_ext(clicon_handle h)
size_t len; size_t len;
void *p; void *p;
if ((p = hash_value(cdat, "nacm_xml", &len)) != NULL) if ((p = clicon_hash_value(cdat, "nacm_xml", &len)) != NULL)
return *(cxobj **)p; return *(cxobj **)p;
return NULL; return NULL;
} }
@ -141,7 +141,7 @@ clicon_nacm_ext_set(clicon_handle h,
/* It is the pointer to xn that should be copied by hash, /* It is the pointer to xn that should be copied by hash,
so we send a ptr to the ptr to indicate what to copy. so we send a ptr to the ptr to indicate what to copy.
*/ */
if (hash_add(cdat, "nacm_xml", &xn, sizeof(xn)) == NULL) if (clicon_hash_add(cdat, "nacm_xml", &xn, sizeof(xn)) == NULL)
return -1; return -1;
return 0; return 0;
} }
@ -158,7 +158,7 @@ clicon_config_yang(clicon_handle h)
size_t len; size_t len;
void *p; void *p;
if ((p = hash_value(cdat, "control_yang", &len)) != NULL) if ((p = clicon_hash_value(cdat, "control_yang", &len)) != NULL)
return *(yang_stmt **)p; return *(yang_stmt **)p;
return NULL; return NULL;
} }
@ -175,7 +175,7 @@ clicon_config_yang_set(clicon_handle h,
/* It is the pointer to ys that should be copied by hash, /* It is the pointer to ys that should be copied by hash,
so we send a ptr to the ptr to indicate what to copy. so we send a ptr to the ptr to indicate what to copy.
*/ */
if (hash_add(cdat, "control_yang", &ys, sizeof(ys)) == NULL) if (clicon_hash_add(cdat, "control_yang", &ys, sizeof(ys)) == NULL)
return -1; return -1;
return 0; return 0;
} }
@ -192,7 +192,7 @@ clicon_conf_xml(clicon_handle h)
size_t len; size_t len;
void *p; void *p;
if ((p = hash_value(cdat, "clixon_conf", &len)) != NULL) if ((p = clicon_hash_value(cdat, "clixon_conf", &len)) != NULL)
return *(cxobj **)p; return *(cxobj **)p;
return NULL; return NULL;
} }
@ -209,7 +209,7 @@ clicon_conf_xml_set(clicon_handle h,
/* It is the pointer to x that should be copied by hash, /* It is the pointer to x that should be copied by hash,
* so we send a ptr to the ptr to indicate what to copy. * so we send a ptr to the ptr to indicate what to copy.
*/ */
if (hash_add(cdat, "clixon_conf", &x, sizeof(x)) == NULL) if (clicon_hash_add(cdat, "clixon_conf", &x, sizeof(x)) == NULL)
return -1; return -1;
return 0; return 0;
} }
@ -223,7 +223,7 @@ clicon_username_get(clicon_handle h)
{ {
clicon_hash_t *cdat = clicon_data(h); clicon_hash_t *cdat = clicon_data(h);
return (char*)hash_value(cdat, "username", NULL); return (char*)clicon_hash_value(cdat, "username", NULL);
} }
/*! Set authorized user name /*! Set authorized user name
@ -238,8 +238,8 @@ clicon_username_set(clicon_handle h,
clicon_hash_t *cdat = clicon_data(h); clicon_hash_t *cdat = clicon_data(h);
if (username == NULL) if (username == NULL)
return hash_del(cdat, "username"); return clicon_hash_del(cdat, "username");
return hash_add(cdat, "username", username, strlen(username)+1)==NULL?-1:0; return clicon_hash_add(cdat, "username", username, strlen(username)+1)==NULL?-1:0;
} }
/*! Get backend daemon startup status /*! Get backend daemon startup status
@ -252,7 +252,7 @@ clicon_startup_status_get(clicon_handle h)
clicon_hash_t *cdat = clicon_data(h); clicon_hash_t *cdat = clicon_data(h);
void *p; void *p;
if ((p = hash_value(cdat, "startup_status", NULL)) != NULL) if ((p = clicon_hash_value(cdat, "startup_status", NULL)) != NULL)
return *(enum startup_status *)p; return *(enum startup_status *)p;
return STARTUP_ERR; return STARTUP_ERR;
} }
@ -268,7 +268,7 @@ clicon_startup_status_set(clicon_handle h,
enum startup_status status) enum startup_status status)
{ {
clicon_hash_t *cdat = clicon_data(h); clicon_hash_t *cdat = clicon_data(h);
if (hash_add(cdat, "startup_status", &status, sizeof(status))==NULL) if (clicon_hash_add(cdat, "startup_status", &status, sizeof(status))==NULL)
return -1; return -1;
return 0; return 0;
} }
@ -284,7 +284,7 @@ clicon_socket_get(clicon_handle h)
clicon_hash_t *cdat = clicon_data(h); clicon_hash_t *cdat = clicon_data(h);
void *p; void *p;
if ((p = hash_value(cdat, "socket", NULL)) == NULL) if ((p = clicon_hash_value(cdat, "socket", NULL)) == NULL)
return -1; return -1;
return *(int*)p; return *(int*)p;
} }
@ -302,8 +302,8 @@ clicon_socket_set(clicon_handle h,
clicon_hash_t *cdat = clicon_data(h); clicon_hash_t *cdat = clicon_data(h);
if (s == -1) if (s == -1)
return hash_del(cdat, "socket"); return clicon_hash_del(cdat, "socket");
return hash_add(cdat, "socket", &s, sizeof(int))==NULL?-1:0; return clicon_hash_add(cdat, "socket", &s, sizeof(int))==NULL?-1:0;
} }
/*! Get module state cache /*! Get module state cache
@ -319,7 +319,7 @@ clicon_modst_cache_get(clicon_handle h,
clicon_hash_t *cdat = clicon_data(h); clicon_hash_t *cdat = clicon_data(h);
void *p; void *p;
if ((p = hash_value(cdat, brief?"modst_brief":"modst_full", NULL)) != NULL) if ((p = clicon_hash_value(cdat, brief?"modst_brief":"modst_full", NULL)) != NULL)
return *(cxobj **)p; return *(cxobj **)p;
return NULL; return NULL;
} }
@ -346,7 +346,7 @@ clicon_modst_cache_set(clicon_handle h,
assert(strcmp(xml_name(xms),"modules-state")==0); assert(strcmp(xml_name(xms),"modules-state")==0);
if ((x = xml_dup(xms)) == NULL) if ((x = xml_dup(xms)) == NULL)
return -1; return -1;
if (hash_add(cdat, brief?"modst_brief":"modst_full", &x, sizeof(x))==NULL) if (clicon_hash_add(cdat, brief?"modst_brief":"modst_full", &x, sizeof(x))==NULL)
return -1; return -1;
ok: ok:
return 0; return 0;
@ -363,7 +363,7 @@ clicon_xml_changelog_get(clicon_handle h)
clicon_hash_t *cdat = clicon_data(h); clicon_hash_t *cdat = clicon_data(h);
void *p; void *p;
if ((p = hash_value(cdat, "xml-changelog", NULL)) != NULL) if ((p = clicon_hash_value(cdat, "xml-changelog", NULL)) != NULL)
return *(cxobj **)p; return *(cxobj **)p;
return NULL; return NULL;
} }
@ -381,7 +381,7 @@ clicon_xml_changelog_set(clicon_handle h,
{ {
clicon_hash_t *cdat = clicon_data(h); clicon_hash_t *cdat = clicon_data(h);
if (hash_add(cdat, "xml-changelog", &xchlog, sizeof(xchlog))==NULL) if (clicon_hash_add(cdat, "xml-changelog", &xchlog, sizeof(xchlog))==NULL)
return -1; return -1;
return 0; return 0;
} }
@ -403,12 +403,12 @@ clicon_argv_get(clicon_handle h,
void *p; void *p;
if (argc){ if (argc){
if ((p = hash_value(cdat, "argc", NULL)) == NULL) if ((p = clicon_hash_value(cdat, "argc", NULL)) == NULL)
return -1; return -1;
*argc = *(int*)p; *argc = *(int*)p;
} }
if (argv){ if (argv){
if ((p = hash_value(cdat, "argv", NULL)) == NULL) if ((p = clicon_hash_value(cdat, "argv", NULL)) == NULL)
return -1; return -1;
*argv = (char**)p; *argv = (char**)p;
} }
@ -444,10 +444,10 @@ clicon_argv_set(clicon_handle h,
memcpy(argvv+1, argv, argc*sizeof(char*)); memcpy(argvv+1, argv, argc*sizeof(char*));
argvv[0] = prgm; argvv[0] = prgm;
/* Note the value is the argv vector (which is copied) */ /* Note the value is the argv vector (which is copied) */
if (hash_add(cdat, "argv", argvv, len*sizeof(char*))==NULL) if (clicon_hash_add(cdat, "argv", argvv, len*sizeof(char*))==NULL)
goto done; goto done;
argc += 1; argc += 1;
if (hash_add(cdat, "argc", &argc, sizeof(argc))==NULL) if (clicon_hash_add(cdat, "argc", &argc, sizeof(argc))==NULL)
goto done; goto done;
retval = 0; retval = 0;
done: done:
@ -470,7 +470,7 @@ clicon_db_elmnt_get(clicon_handle h,
clicon_hash_t *cdat = clicon_db_elmnt(h); clicon_hash_t *cdat = clicon_db_elmnt(h);
void *p; void *p;
if ((p = hash_value(cdat, db, NULL)) != NULL) if ((p = clicon_hash_value(cdat, db, NULL)) != NULL)
return (db_elmnt *)p; return (db_elmnt *)p;
return NULL; return NULL;
} }
@ -491,7 +491,7 @@ clicon_db_elmnt_set(clicon_handle h,
{ {
clicon_hash_t *cdat = clicon_db_elmnt(h); clicon_hash_t *cdat = clicon_db_elmnt(h);
if (hash_add(cdat, db, de, sizeof(*de))==NULL) if (clicon_hash_add(cdat, db, de, sizeof(*de))==NULL)
return -1; return -1;
return 0; return 0;
} }

View file

@ -160,10 +160,10 @@ xmldb_disconnect(clicon_handle h)
int i; int i;
db_elmnt *de; db_elmnt *de;
if (hash_keys(clicon_db_elmnt(h), &keys, &klen) < 0) if (clicon_hash_keys(clicon_db_elmnt(h), &keys, &klen) < 0)
goto done; goto done;
for(i = 0; i < klen; i++) for(i = 0; i < klen; i++)
if ((de = hash_value(clicon_db_elmnt(h), keys[i], NULL)) != NULL){ if ((de = clicon_hash_value(clicon_db_elmnt(h), keys[i], NULL)) != NULL){
if (de->de_xml){ if (de->de_xml){
xml_free(de->de_xml); xml_free(de->de_xml);
de->de_xml = NULL; de->de_xml = NULL;
@ -310,7 +310,7 @@ xmldb_unlock_all(clicon_handle h,
int i; int i;
db_elmnt *de; db_elmnt *de;
if (hash_keys(clicon_db_elmnt(h), &keys, &klen) < 0) if (clicon_hash_keys(clicon_db_elmnt(h), &keys, &klen) < 0)
goto done; goto done;
for (i = 0; i < klen; i++) for (i = 0; i < klen; i++)
if ((de = clicon_db_elmnt_get(h, keys[i])) != NULL && if ((de = clicon_db_elmnt_get(h, keys[i])) != NULL &&

View file

@ -111,15 +111,15 @@ clicon_handle_init0(int size)
} }
memset(ch, 0, size); memset(ch, 0, size);
ch->ch_magic = CLICON_MAGIC; ch->ch_magic = CLICON_MAGIC;
if ((ch->ch_copt = hash_init()) == NULL){ if ((ch->ch_copt = clicon_hash_init()) == NULL){
clicon_handle_exit((clicon_handle)ch); clicon_handle_exit((clicon_handle)ch);
goto done; goto done;
} }
if ((ch->ch_data = hash_init()) == NULL){ if ((ch->ch_data = clicon_hash_init()) == NULL){
clicon_handle_exit((clicon_handle)ch); clicon_handle_exit((clicon_handle)ch);
goto done; goto done;
} }
if ((ch->ch_db_elmnt = hash_init()) == NULL){ if ((ch->ch_db_elmnt = clicon_hash_init()) == NULL){
clicon_handle_exit((clicon_handle)ch); clicon_handle_exit((clicon_handle)ch);
goto done; goto done;
} }
@ -154,12 +154,12 @@ clicon_handle_exit(clicon_handle h)
clicon_hash_t *ha; clicon_hash_t *ha;
if ((ha = clicon_options(h)) != NULL) if ((ha = clicon_options(h)) != NULL)
hash_free(ha); clicon_hash_free(ha);
if ((ha = clicon_data(h)) != NULL) if ((ha = clicon_data(h)) != NULL)
hash_free(ha); clicon_hash_free(ha);
if ((ha = clicon_db_elmnt(h)) != NULL) if ((ha = clicon_db_elmnt(h)) != NULL)
hash_free(ha); clicon_hash_free(ha);
stream_delete_all(h, 1); stream_delete_all(h, 1);
free(ch); free(ch);
retval = 0; retval = 0;

View file

@ -115,7 +115,7 @@ hash_bucket(const char *str)
* @see hash_free For freeing the hash-table * @see hash_free For freeing the hash-table
*/ */
clicon_hash_t * clicon_hash_t *
hash_init(void) clicon_hash_init(void)
{ {
clicon_hash_t *hash; clicon_hash_t *hash;
@ -133,7 +133,7 @@ hash_init(void)
* @retval void * @retval void
*/ */
void void
hash_free(clicon_hash_t *hash) clicon_hash_free(clicon_hash_t *hash)
{ {
int i; int i;
clicon_hash_t tmp; clicon_hash_t tmp;
@ -157,7 +157,7 @@ hash_free(clicon_hash_t *hash)
* @retval NULL Not found * @retval NULL Not found
*/ */
clicon_hash_t clicon_hash_t
hash_lookup(clicon_hash_t *hash, clicon_hash_lookup(clicon_hash_t *hash,
const char *key) const char *key)
{ {
uint32_t bkt; uint32_t bkt;
@ -183,13 +183,13 @@ hash_lookup(clicon_hash_t *hash,
* @retval NULL Key not found or value NULL * @retval NULL Key not found or value NULL
*/ */
void * void *
hash_value(clicon_hash_t *hash, clicon_hash_value(clicon_hash_t *hash,
const char *key, const char *key,
size_t *vlen) size_t *vlen)
{ {
clicon_hash_t h; clicon_hash_t h;
h = hash_lookup(hash, key); h = clicon_hash_lookup(hash, key);
if (h == NULL) if (h == NULL)
return NULL; /* OK, key not found */ return NULL; /* OK, key not found */
@ -209,7 +209,7 @@ hash_value(clicon_hash_t *hash,
* @note special case val is NULL and vlen==0 * @note special case val is NULL and vlen==0
*/ */
clicon_hash_t clicon_hash_t
hash_add(clicon_hash_t *hash, clicon_hash_add(clicon_hash_t *hash,
const char *key, const char *key,
void *val, void *val,
size_t vlen) size_t vlen)
@ -225,7 +225,7 @@ hash_add(clicon_hash_t *hash,
goto catch; goto catch;
} }
/* If variable exist, don't allocate a new. just replace value */ /* If variable exist, don't allocate a new. just replace value */
h = hash_lookup(hash, key); h = clicon_hash_lookup(hash, key);
if (h == NULL) { if (h == NULL) {
if ((new = (clicon_hash_t)malloc(sizeof(*new))) == NULL){ if ((new = (clicon_hash_t)malloc(sizeof(*new))) == NULL){
clicon_err(OE_UNIX, errno, "malloc: %s", strerror(errno)); clicon_err(OE_UNIX, errno, "malloc: %s", strerror(errno));
@ -283,12 +283,12 @@ catch:
* @retval -1 Key not found * @retval -1 Key not found
*/ */
int int
hash_del(clicon_hash_t *hash, clicon_hash_del(clicon_hash_t *hash,
const char *key) const char *key)
{ {
clicon_hash_t h; clicon_hash_t h;
h = hash_lookup(hash, key); h = clicon_hash_lookup(hash, key);
if (h == NULL) if (h == NULL)
return -1; return -1;
@ -311,7 +311,7 @@ hash_del(clicon_hash_t *hash,
* @note: vector needs to be deallocated with free * @note: vector needs to be deallocated with free
*/ */
int int
hash_keys(clicon_hash_t *hash, clicon_hash_keys(clicon_hash_t *hash,
char ***vector, char ***vector,
size_t *nkeys) size_t *nkeys)
{ {
@ -357,7 +357,7 @@ catch:
* @retval -1 Error * @retval -1 Error
*/ */
int int
hash_dump(clicon_hash_t *hash, clicon_hash_dump(clicon_hash_t *hash,
FILE *f) FILE *f)
{ {
int retval = -1; int retval = -1;
@ -369,10 +369,10 @@ hash_dump(clicon_hash_t *hash,
if (hash == NULL) if (hash == NULL)
goto ok; goto ok;
if (hash_keys(hash, &keys, &klen) < 0) if (clicon_hash_keys(hash, &keys, &klen) < 0)
goto done; goto done;
for(i = 0; i < klen; i++) { for(i = 0; i < klen; i++) {
val = hash_value(hash, keys[i], &vlen); val = clicon_hash_value(hash, keys[i], &vlen);
printf("%s =\t 0x%p , length %zu\n", keys[i], val, vlen); printf("%s =\t 0x%p , length %zu\n", keys[i], val, vlen);
} }

View file

@ -102,10 +102,10 @@ clicon_option_dump(clicon_handle h,
size_t klen; size_t klen;
size_t vlen; size_t vlen;
if (hash_keys(hash, &keys, &klen) < 0) if (clicon_hash_keys(hash, &keys, &klen) < 0)
goto done; goto done;
for(i = 0; i < klen; i++) { for(i = 0; i < klen; i++) {
val = hash_value(hash, keys[i], &vlen); val = clicon_hash_value(hash, keys[i], &vlen);
if (vlen){ if (vlen){
if (((char*)val)[vlen-1]=='\0') /* assume string */ if (((char*)val)[vlen-1]=='\0') /* assume string */
clicon_debug(dbglevel, "%s =\t \"%s\"", keys[i], (char*)val); clicon_debug(dbglevel, "%s =\t \"%s\"", keys[i], (char*)val);
@ -222,7 +222,7 @@ parse_configfile(clicon_handle h,
/* Used as an arg to this fn */ /* Used as an arg to this fn */
if (strcmp(name,"CLICON_CONFIGFILE")==0) if (strcmp(name,"CLICON_CONFIGFILE")==0)
continue; continue;
if (hash_add(copt, if (clicon_hash_add(copt,
name, name,
body, body,
strlen(body)+1) == NULL) strlen(body)+1) == NULL)
@ -267,7 +267,7 @@ clicon_option_add(clicon_handle h,
name, value, name) < 0) name, value, name) < 0)
goto done; goto done;
} }
if (hash_add(copt, if (clicon_hash_add(copt,
name, name,
value, value,
strlen(value)+1) == NULL) strlen(value)+1) == NULL)
@ -302,10 +302,10 @@ clicon_options_main(clicon_handle h,
/* /*
* Set configure file if not set by command-line above * Set configure file if not set by command-line above
*/ */
if (!hash_lookup(copt, "CLICON_CONFIGFILE")){ if (!clicon_hash_lookup(copt, "CLICON_CONFIGFILE")){
clicon_option_str_set(h, "CLICON_CONFIGFILE", CLIXON_DEFAULT_CONFIG); clicon_option_str_set(h, "CLICON_CONFIGFILE", CLIXON_DEFAULT_CONFIG);
} }
configfile = hash_value(copt, "CLICON_CONFIGFILE", NULL); configfile = clicon_hash_value(copt, "CLICON_CONFIGFILE", NULL);
clicon_debug(1, "CLICON_CONFIGFILE=%s", configfile); clicon_debug(1, "CLICON_CONFIGFILE=%s", configfile);
/* File must end with .xml */ /* File must end with .xml */
if ((suffix = rindex(configfile, '.')) != NULL){ if ((suffix = rindex(configfile, '.')) != NULL){
@ -368,7 +368,7 @@ clicon_option_exists(clicon_handle h,
{ {
clicon_hash_t *copt = clicon_options(h); clicon_hash_t *copt = clicon_options(h);
return (hash_lookup(copt, (char*)name) != NULL); return (clicon_hash_lookup(copt, (char*)name) != NULL);
} }
/*! Get a single string option string via handle /*! Get a single string option string via handle
@ -387,9 +387,9 @@ clicon_option_str(clicon_handle h,
{ {
clicon_hash_t *copt = clicon_options(h); clicon_hash_t *copt = clicon_options(h);
if (hash_lookup(copt, (char*)name) == NULL) if (clicon_hash_lookup(copt, (char*)name) == NULL)
return NULL; return NULL;
return hash_value(copt, (char*)name, NULL); return clicon_hash_value(copt, (char*)name, NULL);
} }
/*! Set a single string option via handle /*! Set a single string option via handle
@ -406,7 +406,7 @@ clicon_option_str_set(clicon_handle h,
{ {
clicon_hash_t *copt = clicon_options(h); clicon_hash_t *copt = clicon_options(h);
return hash_add(copt, (char*)name, val, strlen(val)+1)==NULL?-1:0; return clicon_hash_add(copt, (char*)name, val, strlen(val)+1)==NULL?-1:0;
} }
/*! Get options as integer but stored as string /*! Get options as integer but stored as string
@ -501,7 +501,7 @@ clicon_option_del(clicon_handle h,
{ {
clicon_hash_t *copt = clicon_options(h); clicon_hash_t *copt = clicon_options(h);
return hash_del(copt, (char*)name); return clicon_hash_del(copt, (char*)name);
} }
/*----------------------------------------------------------------- /*-----------------------------------------------------------------