summaryrefslogtreecommitdiffstats
path: root/include/stringlist.h
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2008-03-11 21:38:22 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2008-03-11 21:38:22 +0100
commit8f35e16333c98737c034ab1c0b060a577387255e (patch)
tree7eb2d00753be5b86ae582cb3f05cd9b1dc7359e2 /include/stringlist.h
parent8759e68de2e2b4ce1793d36d668359eb80278c2c (diff)
downloadbarebox-8f35e16333c98737c034ab1c0b060a577387255e.tar.gz
barebox-8f35e16333c98737c034ab1c0b060a577387255e.tar.xz
add stringlist function. They can be used to build a list
of strings. For now mainly useful to print the resulting list in columns which is used in tab completion and ls.
Diffstat (limited to 'include/stringlist.h')
-rw-r--r--include/stringlist.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/include/stringlist.h b/include/stringlist.h
new file mode 100644
index 0000000000..87380cb5d5
--- /dev/null
+++ b/include/stringlist.h
@@ -0,0 +1,27 @@
+#ifndef __STRING_H
+#define __STRING_H
+
+#include <list.h>
+
+struct string_list {
+ struct list_head list;
+ char str[0];
+};
+
+int string_list_add(struct string_list *sl, char *str);
+void string_list_print_by_column(struct string_list *sl);
+
+static inline void string_list_init(struct string_list *sl)
+{
+ INIT_LIST_HEAD(&sl->list);
+}
+
+static inline void string_list_free(struct string_list *sl)
+{
+ struct string_list *entry, *safe;
+
+ list_for_each_entry_safe(entry, safe, &sl->list, list)
+ free(entry);
+}
+
+#endif /* __STRING_H */