X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=util.c;h=4bec220f7a1dbfad1c1868d8228d973bb77863df;hp=bcb608480f7d54cc0dc6c80f0a36b392d0e21340;hb=a41e8209be729cd8de34d715135fe84920e8016c;hpb=ed5bcfbe3c3b68e59242c03649eea03a9707d318 diff --git a/util.c b/util.c index bcb608480..4bec220f7 100644 --- a/util.c +++ b/util.c @@ -145,3 +145,22 @@ int safe_atoi(const char *s, int *ret_i) { *ret_i = (unsigned) l; return 0; } + +/* What is interpreted as whitespace? */ +#define WHITESPACE " \t\n" + +/* Split a string into words. */ +char *split_spaces(const char *c, size_t *l, char **state) { + char *current; + + current = *state ? *state : (char*) c; + + if (!*current || *c == 0) + return NULL; + + current += strspn(current, WHITESPACE); + *l = strcspn(current, WHITESPACE); + *state = current+*l; + + return (char*) current; +}