aboutsummaryrefslogtreecommitdiff
path: root/lib/getmountlist.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/getmountlist.c')
-rw-r--r--lib/getmountlist.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/getmountlist.c b/lib/getmountlist.c
index 4fec41b7..8fb43dc9 100644
--- a/lib/getmountlist.c
+++ b/lib/getmountlist.c
@@ -6,6 +6,23 @@
#include "toys.h"
#include <mntent.h>
+// Traverse arg_list of csv, calling callback on each value
+void comma_args(struct arg_list *al, void *data, char *err,
+ char *(*callback)(void *data, char *str, int len))
+{
+ char *next, *arg;
+ int len;
+
+ while (al) {
+ arg = al->arg;
+ while ((next = comma_iterate(&arg, &len)))
+ if ((next = callback(data, next, len)))
+ perror_exit("%s '%s'\n%*c", err, al->arg,
+ (int)(5+strlen(toys.which->name)+strlen(err)+next-al->arg), '^');
+ al = al->next;
+ }
+}
+
// Realloc *old with oldstring,newstring
void comma_collate(char **old, char *new)