From a9b99916301a6299d81f20e194df83826e0dfdb6 Mon Sep 17 00:00:00 2001 From: Alejandro Mery Date: Mon, 1 Oct 2012 10:34:56 +0200 Subject: [PATCH] fexc: script: add script_find_entry() helper --- script.c | 20 ++++++++++++++++++++ script.h | 5 ++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/script.c b/script.c index b48ab48..3a9c7e7 100644 --- a/script.c +++ b/script.c @@ -246,3 +246,23 @@ struct script_gpio_entry *script_gpio_entry_new(struct script_section *section, return entry; } + +struct script_entry *script_find_entry(struct script_section *section, + const char *name) +{ + struct list_entry *o; + struct script_entry *ep; + + assert(section); + assert(name); + + for (o = list_first(§ion->entries); o; + o = list_next(§ion->entries, o)) { + ep = container_of(o, struct script_entry, entries); + + if (strcmp(ep->name, name) == 0) + return ep; + } + + return NULL; +} diff --git a/script.h b/script.h index aa14ecf..0fa2134 100644 --- a/script.h +++ b/script.h @@ -87,7 +87,7 @@ struct script_section *script_section_new(struct script *script, void script_section_delete(struct script_section *section); /** find existing section */ -struct script_section *script_find_section(struct script *section, +struct script_section *script_find_section(struct script *script, const char *name); /** deletes an entry and removes it from the section */ @@ -110,4 +110,7 @@ struct script_gpio_entry *script_gpio_entry_new(struct script_section *script, unsigned port, unsigned num, int32_t data[4]); +/** find existing entry in a giving section */ +struct script_entry *script_find_entry(struct script_section *section, + const char *name); #endif