summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--discover/event.c24
-rw-r--r--discover/event.h5
2 files changed, 27 insertions, 2 deletions
diff --git a/discover/event.c b/discover/event.c
index a05ce27..7cb128f 100644
--- a/discover/event.c
+++ b/discover/event.c
@@ -134,3 +134,27 @@ const char *event_get_param(const struct event *event, const char *name)
return NULL;
}
+
+void event_set_param(struct event *event, const char *name, const char *value)
+{
+ struct param *param;
+ int i;
+
+ /* if it's already present, replace the value of the old param */
+ for (i = 0; i < event->n_params; i++) {
+ param = &event->params[i];
+ if (!strcasecmp(param->name, name)) {
+ talloc_free(param->value);
+ param->value = talloc_strdup(event, value);
+ return;
+ }
+ }
+
+ /* not found - create a new param */
+ event->params = talloc_realloc(event, event->params,
+ struct param, ++event->n_params);
+ param = &event->params[event->n_params - 1];
+
+ param->name = talloc_strdup(event, name);
+ param->value = talloc_strdup(event, value);
+}
diff --git a/discover/event.h b/discover/event.h
index 70cc8fc..adba336 100644
--- a/discover/event.h
+++ b/discover/event.h
@@ -20,13 +20,14 @@ struct event {
const char *device;
struct param {
- const char *name;
- const char *value;
+ char *name;
+ char *value;
} *params;
int n_params;
};
int event_parse_ad_message(struct event *event, char *buf, int len);
const char *event_get_param(const struct event *event, const char *name);
+void event_set_param(struct event *event, const char *name, const char *value);
#endif /* _PB_EVENT_H */
OpenPOWER on IntegriCloud