summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2017-09-27 12:21:51 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2017-09-27 14:02:20 +0200
commitdc8c2c4b942f499fedb284b096eff3b2b9970b9c (patch)
treef98c42a4bd13e8158af5ae7f77b9edb4f82ad89a
parent9f36f6d615ab6eca2e37823213c0f6f3ead25921 (diff)
downloadbarebox-dc8c2c4b942f499fedb284b096eff3b2b9970b9c.tar.gz
file_list: Add function to get entry by its name
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--common/file-list.c12
-rw-r--r--include/file-list.h2
2 files changed, 14 insertions, 0 deletions
diff --git a/common/file-list.c b/common/file-list.c
index 010f8f0..0b760c1 100644
--- a/common/file-list.c
+++ b/common/file-list.c
@@ -8,6 +8,18 @@
#define PARSE_NAME 1
#define PARSE_FLAGS 2
+struct file_list_entry *file_list_entry_by_name(struct file_list *files, const char *name)
+{
+ struct file_list_entry *entry;
+
+ file_list_for_each_entry(files, entry) {
+ if (!strcmp(entry->name, name))
+ return entry;
+ }
+
+ return NULL;
+}
+
int file_list_add_entry(struct file_list *files, const char *name, const char *filename,
unsigned long flags)
{
diff --git a/include/file-list.h b/include/file-list.h
index ccdc2b5..1e02539 100644
--- a/include/file-list.h
+++ b/include/file-list.h
@@ -23,6 +23,8 @@ void file_list_free(struct file_list *);
int file_list_add_entry(struct file_list *files, const char *name, const char *filename,
unsigned long flags);
+struct file_list_entry *file_list_entry_by_name(struct file_list *files, const char *name);
+
#define file_list_for_each_entry(files, entry) \
list_for_each_entry(entry, &files->list, list)