]> git.notmuchmail.org Git - notmuch/blob - util/string-util.h
util: add string-util.[ch]
[notmuch] / util / string-util.h
1 #ifndef _STRING_UTIL_H
2 #define _STRING_UTIL_H
3
4 #include <string.h>
5
6 /* like strtok(3), but without state, and doesn't modify s.  Return
7  * value is indicated by pointer and length, not null terminator.
8  *
9  * Usage pattern:
10  *
11  * const char *tok = input;
12  * const char *delim = " \t";
13  * size_t tok_len = 0;
14  *
15  * while ((tok = strtok_len (tok + tok_len, delim, &tok_len)) != NULL) {
16  *     // do stuff with string tok of length tok_len
17  * }
18  */
19
20 char *strtok_len (char *s, const char *delim, size_t *len);
21
22 #endif