1
0
mirror of https://github.com/deadw00d/AROS.git synced 2025-12-06 05:00:25 +00:00
Files
AROS-v0/workbench/devs/netinfo/misc.c
2025-10-17 08:30:10 +02:00

49 lines
1.2 KiB
C

/*
* misc.c
*
* Author: ppessi <Pekka.Pessi@hut.fi>
*
* Copyright © 1993 AmiTCP/IP Group, <AmiTCP-group@hut.fi>
* Helsinki University of Technology, Finland.
*/
#include <proto/exec.h>
#include "base.h"
/*
* Get next token from string *stringp, where tokens are nonempty
* strings separated by characters from delim.
*
* Writes NULs into the string at *stringp to end tokens.
* delim need not remain constant from call to call.
* On return, *stringp points past the last NUL written (if there might
* be further tokens), or is NULL (if there are definitely no more tokens).
*
* If *stringp is NULL, strtoken returns NULL.
*/
char *strsep(register char **stringp, register const char *delim)
{
register char *s;
register const char *spanp;
register int c, sc;
char *tok;
if ((s = *stringp) == NULL)
return (NULL);
for (tok = s;;) {
c = *s++;
spanp = delim;
do {
if ((sc = *spanp++) == c) {
if (c == 0)
s = NULL;
else
s[-1] = 0;
*stringp = s;
return (tok);
}
} while (sc != 0);
}
}