home *** CD-ROM | disk | FTP | other *** search
- /*
- * STRTOKP.C
- *
- * This function will return a pointer to a token from an input string.
- * The first argument is a pointer to a pointer to an input string.
- * After the call is made, the pointer to the string will be advanced
- * past the extracted token. The second argument is a pointer to a string
- * of characters, any of which may be used to delimit a token.
- *
- * date = strtokp(&input, delims);
- * time = strtokp(&input, delims);
- * place = strtokp(&input, delims);
- *
- * Note: This function modifies the input string by inserting a null
- * character to delimit the token.
- *
- * This function is very much like strtok(), but it does not retain any
- * internal state, elminating the problem of not being able to scan more
- * than one input string at a time.
- *
- * History:
- * Chris Hind Genly 7/10/90 Original Version
- */
-
- #include <stdio.h>
- #include <string.h>
- #include "config.h"
-
- Prototype char *strtokp (char **, char *);
-
- char *
- strtokp (char **inp, char *brk)
- {
- char
- *token,
- *in,
- c;
-
- if (inp == NULL || *inp == NULL)
- return NULL;
-
- in = *inp;
-
- for (in; (c = *in) && strchr (brk, *in); ++in)
- continue;
-
- if (c == 0)
- return NULL;
-
- token = in;
-
- for (in; (c = *in) && !stpchr (brk, *in); ++in)
- continue;
-
- if (c != 0)
- *in++ = 0;
-
- *inp = in;
-
- return token;
- }
-