X-Git-Url: http://git.ozlabs.org/?p=petitboot;a=blobdiff_plain;f=discover%2Fevent-parser.c;h=289fee96bdf8da7f688b985ad66b7216985dcbd6;hp=0cfda9a027af1727a235d571c62b587d641c6304;hb=e4f5bd235894c11823ac1befe8c8c43063cad026;hpb=fbb2f7a20e5ac7b6d9f578fdb3538fad4310c472 diff --git a/discover/event-parser.c b/discover/event-parser.c index 0cfda9a..289fee9 100644 --- a/discover/event-parser.c +++ b/discover/event-parser.c @@ -6,15 +6,27 @@ #include "talloc/talloc.h" #include "event.h" #include "parser-utils.h" +#include "device-handler.h" -int parse_user_event(struct device *device, struct event *event) +/** + * parse_user_event - Parse a user event. + * + * Understands params: name, image, args. + */ + +int parse_user_event(struct discover_context *ctx, struct event *event) { + struct discover_boot_option *d_opt; struct boot_option *opt; + struct device *dev; const char *p; - opt = talloc_zero(device, struct boot_option); + dev = ctx->device->device; + + d_opt = discover_boot_option_create(ctx, ctx->device); + opt = d_opt->option; - if (!opt) + if (!d_opt) goto fail; p = event_get_param(event, "name"); @@ -24,7 +36,8 @@ int parse_user_event(struct device *device, struct event *event) goto fail; } - opt->id = talloc_asprintf(opt, "%s#%s", device->id, p); + opt->id = talloc_asprintf(opt, "%s#%s", dev->id, p); + opt->device_id = talloc_strdup(opt, dev->id); opt->name = talloc_strdup(opt, p); p = event_get_param(event, "image"); @@ -45,11 +58,11 @@ int parse_user_event(struct device *device, struct event *event) opt->description = talloc_asprintf(opt, "%s %s", opt->boot_image_file, opt->boot_args); - device_add_boot_option(device, opt); + discover_context_add_boot_option(ctx, d_opt); return 0; fail: - talloc_free(opt); + talloc_free(d_opt); return -1; }