From: Sven Trenkel Date: Wed, 9 Dec 2009 12:53:14 +0000 (+0100) Subject: Added function to get a list of meta data entries. X-Git-Tag: collectd-4.10.0~92 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=20508b861ea3d1b72d19c92c4b3261713336e89f;p=collectd.git Added function to get a list of meta data entries. --- diff --git a/src/meta_data.c b/src/meta_data.c index a7c11c10..80b6dd1e 100644 --- a/src/meta_data.c +++ b/src/meta_data.c @@ -262,6 +262,27 @@ int meta_data_type (meta_data_t *md, const char *key) /* {{{ */ 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 -1; + + 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; diff --git a/src/meta_data.h b/src/meta_data.h index 7a9afee5..9ef7b0a8 100644 --- a/src/meta_data.h +++ b/src/meta_data.h @@ -41,6 +41,7 @@ void meta_data_destroy (meta_data_t *md); int meta_data_exists (meta_data_t *md, const char *key); int meta_data_type (meta_data_t *md, const char *key); +int meta_data_toc (meta_data_t *md, char ***toc); int meta_data_delete (meta_data_t *md, const char *key); int meta_data_add_string (meta_data_t *md,