summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4732be3)
raw | patch | inline | side by side (parent: 4732be3)
author | Florian Forster <ff@octo.it> | |
Mon, 14 Jun 2010 21:19:13 +0000 (23:19 +0200) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Mon, 14 Jun 2010 21:19:13 +0000 (23:19 +0200) |
graph_ident.c | patch | blob | history | |
graph_ident.h | patch | blob | history |
diff --git a/graph_ident.c b/graph_ident.c
index 7b57f5d2c6828ea25ee2b74d7f1ed859d0be621c..fb6e206f46c01eb8856cfad5c9fbba76ce634064 100644 (file)
--- a/graph_ident.c
+++ b/graph_ident.c
#include <stdlib.h>
#include <string.h>
#include <strings.h>
+#include <errno.h>
#include <limits.h> /* PATH_MAX */
#include "graph_ident.h"
#include "common.h"
-#define ANY_TOKEN "/any/"
-#define ALL_TOKEN "/all/"
-
#define IS_ANY(str) (((str) != NULL) && (strcasecmp (ANY_TOKEN, (str)) == 0))
#define IS_ALL(str) (((str) != NULL) && (strcasecmp (ALL_TOKEN, (str)) == 0))
free (ident);
} /* }}} void ident_destroy */
+/* ident_get_* methods {{{ */
const char *ident_get_host (graph_ident_t *ident) /* {{{ */
{
if (ident == NULL)
return (ident->type_instance);
} /* }}} char *ident_get_type_instance */
+/* }}} ident_get_* methods */
+
+/* ident_set_* methods {{{ */
+int ident_set_host (graph_ident_t *ident, const char *host) /* {{{ */
+{
+ char *tmp;
+
+ if ((ident == NULL) || (host == NULL))
+ return (EINVAL);
+
+ tmp = strdup (host);
+ if (tmp == NULL)
+ return (ENOMEM);
+
+ free (ident->host);
+ ident->host = tmp;
+
+ return (0);
+} /* }}} int ident_set_host */
+
+int ident_set_plugin (graph_ident_t *ident, const char *plugin) /* {{{ */
+{
+ char *tmp;
+
+ if ((ident == NULL) || (plugin == NULL))
+ return (EINVAL);
+
+ tmp = strdup (plugin);
+ if (tmp == NULL)
+ return (ENOMEM);
+
+ free (ident->plugin);
+ ident->plugin = tmp;
+
+ return (0);
+} /* }}} int ident_set_plugin */
+
+int ident_set_plugin_instance (graph_ident_t *ident, const char *plugin_instance) /* {{{ */
+{
+ char *tmp;
+
+ if ((ident == NULL) || (plugin_instance == NULL))
+ return (EINVAL);
+
+ tmp = strdup (plugin_instance);
+ if (tmp == NULL)
+ return (ENOMEM);
+
+ free (ident->plugin_instance);
+ ident->plugin_instance = tmp;
+
+ return (0);
+} /* }}} int ident_set_plugin_instance */
+
+int ident_set_type (graph_ident_t *ident, const char *type) /* {{{ */
+{
+ char *tmp;
+
+ if ((ident == NULL) || (type == NULL))
+ return (EINVAL);
+
+ tmp = strdup (type);
+ if (tmp == NULL)
+ return (ENOMEM);
+
+ free (ident->type);
+ ident->type = tmp;
+
+ return (0);
+} /* }}} int ident_set_type */
+
+int ident_set_type_instance (graph_ident_t *ident, const char *type_instance) /* {{{ */
+{
+ char *tmp;
+
+ if ((ident == NULL) || (type_instance == NULL))
+ return (EINVAL);
+
+ tmp = strdup (type_instance);
+ if (tmp == NULL)
+ return (ENOMEM);
+
+ free (ident->type_instance);
+ ident->type_instance = tmp;
+
+ return (0);
+} /* }}} int ident_set_type_instance */
+
+/* }}} ident_set_* methods */
int ident_compare (const graph_ident_t *i0, /* {{{ */
const graph_ident_t *i1)
diff --git a/graph_ident.h b/graph_ident.h
index abc451db0edc95ee005f11fe93e7b2ef8b2dcbcd..442bcfeba499e6cd3402da090574b2d6ee63230e 100644 (file)
--- a/graph_ident.h
+++ b/graph_ident.h
#ifndef GRAPH_IDENT_H
#define GRAPH_IDENT_H 1
+#define ANY_TOKEN "/any/"
+#define ALL_TOKEN "/all/"
+
struct graph_ident_s;
typedef struct graph_ident_s graph_ident_t;
const char *ident_get_type (graph_ident_t *ident);
const char *ident_get_type_instance (graph_ident_t *ident);
+int ident_set_host (graph_ident_t *ident, const char *host);
+int ident_set_plugin (graph_ident_t *ident, const char *plugin);
+int ident_set_plugin_instance (graph_ident_t *ident,
+ const char *plugin_instance);
+int ident_set_type (graph_ident_t *ident, const char *type);
+int ident_set_type_instance (graph_ident_t *ident,
+ const char *type_instance);
+
int ident_compare (const graph_ident_t *i0,
const graph_ident_t *i1);