diff options
author | Lennart Poettering <lennart@poettering.net> | 2010-02-12 02:00:49 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2010-02-12 02:00:49 +0100 |
commit | 82919e3d3172c85acb80b0e206ae1731863eee6d (patch) | |
tree | 95b9a8527d290d07b4f14819fccaafe4a18a65ab /util.c | |
parent | 451a074fd589fd90aff91fcf89b2e599b20ae6a0 (diff) |
util: add api for iterating through components of a path string
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -284,6 +284,22 @@ char *split_spaces(const char *c, size_t *l, char **state) { return (char*) current; } +/* Split a path into filenames. */ +char *split_slash(const char *c, size_t *l, char **state) { + char *current; + + current = *state ? *state : (char*) c; + + if (!*current || *c == 0) + return NULL; + + current += strspn(current, "/"); + *l = strcspn(current, "/"); + *state = current+*l; + + return (char*) current; +} + /* Split a string into words, but consider strings enclosed in '' and * "" as words even if they include spaces. */ char *split_quoted(const char *c, size_t *l, char **state) { |