From 1b7c02a6bf83a5e2ed618b824caf33804bf8373d Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Wed, 30 Dec 2015 11:49:13 -0600 Subject: I didn't add comma_args() to lib.c, I added it with the other comma functions. (Oops. Missed a file checkin, build break, my bad.) --- lib/getmountlist.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'lib/getmountlist.c') 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 +// 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) -- cgit v1.2.3