diff options
author | Rob Landley <rob@landley.net> | 2015-12-30 11:49:13 -0600 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2015-12-30 11:49:13 -0600 |
commit | 1b7c02a6bf83a5e2ed618b824caf33804bf8373d (patch) | |
tree | 3f71a5758b3cbb7c88d37b19bd1722c94d7ef04e /lib | |
parent | 4d3ad67ab37a25d0edfccdc34d29ec550e0802b6 (diff) | |
download | toybox-1b7c02a6bf83a5e2ed618b824caf33804bf8373d.tar.gz |
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.)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/getmountlist.c | 17 |
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) |