X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fmeta_data.c;h=6a336c4b67c734b62cf1516c3375b649fd826cac;hb=ff8390d53b08dd36f8b0c5f4e530fe7ea9f21b90;hp=3a3f5e7918b4c44ba8da80367bf0d2597f6eff15;hpb=8be9c73cc216609a54a1b997aad8a3d646a0a43f;p=collectd.git diff --git a/src/meta_data.c b/src/meta_data.c index 3a3f5e79..6a336c4b 100644 --- a/src/meta_data.c +++ b/src/meta_data.c @@ -26,15 +26,6 @@ #include /* - * Defines - */ -#define MD_TYPE_STRING 1 -#define MD_TYPE_SIGNED_INT 2 -#define MD_TYPE_UNSIGNED_INT 3 -#define MD_TYPE_DOUBLE 4 -#define MD_TYPE_BOOLEAN 5 - -/* * Data types */ union meta_value_u @@ -249,6 +240,49 @@ int meta_data_exists (meta_data_t *md, const char *key) /* {{{ */ return (0); } /* }}} int meta_data_exists */ +int meta_data_type (meta_data_t *md, const char *key) /* {{{ */ +{ + meta_entry_t *e; + + if ((md == NULL) || (key == NULL)) + return -EINVAL; + + pthread_mutex_lock (&md->lock); + + for (e = md->head; e != NULL; e = e->next) + { + if (strcasecmp (key, e->key) == 0) + { + pthread_mutex_unlock (&md->lock); + return e->type; + } + } + + pthread_mutex_unlock (&md->lock); + return 0; +} /* }}} int meta_data_type */ + +int meta_data_toc (meta_data_t *md, char ***toc) /* {{{ */ +{ + int i = 0, count = 0; + meta_entry_t *e; + + if ((md == NULL) || (toc == NULL)) + return -EINVAL; + + pthread_mutex_lock (&md->lock); + + for (e = md->head; e != NULL; e = e->next) + ++count; + + *toc = malloc(count * sizeof(**toc)); + for (e = md->head; e != NULL; e = e->next) + (*toc)[i++] = strdup(e->key); + + pthread_mutex_unlock (&md->lock); + return count; +} /* }}} int meta_data_toc */ + int meta_data_delete (meta_data_t *md, const char *key) /* {{{ */ { meta_entry_t *this;