summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 251889c)
raw | patch | inline | side by side (parent: 251889c)
author | Sven Trenkel <collectd@semidefinite.de> | |
Wed, 9 Dec 2009 12:18:49 +0000 (13:18 +0100) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Thu, 10 Dec 2009 09:17:18 +0000 (10:17 +0100) |
src/meta_data.c | patch | blob | history | |
src/meta_data.h | patch | blob | history |
diff --git a/src/meta_data.c b/src/meta_data.c
index 3a3f5e7918b4c44ba8da80367bf0d2597f6eff15..a7c11c10607352d9cbf0a938a185a54895bfd970 100644 (file)
--- a/src/meta_data.c
+++ b/src/meta_data.c
#include <pthread.h>
-/*
- * 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
*/
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 0;
+
+ 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_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 8e5a7852544a43e235919250ccf464de973b05e0..7a9afee589db5945a9800662fb0d85ba004fa304 100644 (file)
--- a/src/meta_data.h
+++ b/src/meta_data.h
#include "collectd.h"
+/*
+ * 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
+
struct meta_data_s;
typedef struct meta_data_s meta_data_t;
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_delete (meta_data_t *md, const char *key);
int meta_data_add_string (meta_data_t *md,