[PATCH 02/12] file_list: Add function to get entry by its name

Sascha Hauer s.hauer at pengutronix.de
Wed Sep 27 05:09:00 PDT 2017


Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 common/file-list.c  | 12 ++++++++++++
 include/file-list.h |  2 ++
 2 files changed, 14 insertions(+)

diff --git a/common/file-list.c b/common/file-list.c
index 010f8f0617..0b760c1aec 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 ccdc2b5efd..1e02539d4d 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)
 
-- 
2.11.0




More information about the barebox mailing list