discover: Send options to client in order
[petitboot] / discover / event.c
index 1314561c9eda23e19cfc016604ae71d207d9ae09..7cb128f6dfb45afbea395d4f49649433b0775712 100644 (file)
@@ -42,6 +42,8 @@ static int event_parse_ad_header(char *buf, int len, enum event_action *action,
                *action = EVENT_ACTION_ADD;
        else if (streq(buf, "remove"))
                *action = EVENT_ACTION_REMOVE;
+       else if (streq(buf, "conf"))
+               *action = EVENT_ACTION_CONF;
        else {
                pb_log("%s: unknown action: %s\n", __func__, buf);
                return -1;
@@ -132,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);
+}