summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 89bc58e)
raw | patch | inline | side by side (parent: 89bc58e)
author | Florian Forster <ff@octo.it> | |
Wed, 23 Jun 2010 06:37:36 +0000 (08:37 +0200) | ||
committer | Florian Forster <octo@verplant.org> | |
Wed, 23 Jun 2010 06:37:36 +0000 (08:37 +0200) |
src/graph_instance.c | patch | blob | history | |
src/graph_instance.h | patch | blob | history |
diff --git a/src/graph_instance.c b/src/graph_instance.c
index e560527026c989b39a52d6b0e9f0c8b95d1dac85..109316fb992ef2284ec2f31267c42e4dc6a91ab1 100644 (file)
--- a/src/graph_instance.c
+++ b/src/graph_instance.c
return (1);
} /* }}} _Bool inst_matches_string */
+_Bool inst_matches_field (graph_instance_t *inst, /* {{{ */
+ graph_ident_field_t field, const char *field_value)
+{
+ const char *selector_field;
+ size_t i;
+
+ if ((inst == NULL) || (field_value == NULL))
+ return (0);
+
+ selector_field = ident_get_field (inst->select, field);
+ if (selector_field == NULL)
+ return (0);
+
+ assert (!IS_ANY (selector_field));
+ if (!IS_ALL (selector_field))
+ {
+ if (strcasecmp (selector_field, field_value) == 0)
+ return (1);
+ else
+ return (0);
+ }
+
+ /* The selector field is an ALL selector
+ * => we need to check the files to see if the instance matches. */
+ for (i = 0; i < inst->files_num; i++)
+ {
+ selector_field = ident_get_field (inst->files[i], field);
+ if (selector_field == NULL)
+ continue;
+
+ assert (!IS_ANY (selector_field));
+ assert (!IS_ALL (selector_field));
+
+ if (strcasecmp (selector_field, field_value) == 0)
+ return (1);
+ } /* for files */
+
+ return (0);
+} /* }}} _Bool inst_matches_field */
+
int inst_describe (graph_config_t *cfg, graph_instance_t *inst, /* {{{ */
char *buffer, size_t buffer_size)
{
diff --git a/src/graph_instance.h b/src/graph_instance.h
index f0425d21a5dda3f945cf64bdfe5fc9c9805f314d..1baccc6aad5c25cb61368123b804bfcd52e4601a 100644 (file)
--- a/src/graph_instance.h
+++ b/src/graph_instance.h
#include <time.h>
#include "graph_types.h"
+#include "graph_ident.h"
#include "utils_array.h"
/*
_Bool inst_matches_string (graph_config_t *cfg, graph_instance_t *inst,
const char *term);
+_Bool inst_matches_field (graph_instance_t *inst,
+ graph_ident_field_t field, const char *field_value);
+
int inst_describe (graph_config_t *cfg, graph_instance_t *inst,
char *buffer, size_t buffer_size);