iPXE
Functions
stringextra.c File Reference
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_ONLY)
char * strpbrk (const char *cs, const char *ct)
 strpbrk - Find the first occurrence of a set of characters : The string to be searched : The characters to search for
char * strsep (char **s, const char *ct)
 strsep - Split a string into tokens : The string to be searched : The characters to search for

Function Documentation

FILE_LICENCE ( GPL2_ONLY  )
char* strpbrk ( const char *  cs,
const char *  ct 
)

strpbrk - Find the first occurrence of a set of characters : The string to be searched : The characters to search for

Definition at line 47 of file stringextra.c.

References NULL.

Referenced by strsep().

{
        const char *sc1,*sc2;

        for( sc1 = cs; *sc1 != '\0'; ++sc1) {
                for( sc2 = ct; *sc2 != '\0'; ++sc2) {
                        if (*sc1 == *sc2)
                                return (char *) sc1;
                }
        }
        return NULL;
}
char* strsep ( char **  s,
const char *  ct 
)

strsep - Split a string into tokens : The string to be searched : The characters to search for

strsep() updates to point after the token, ready for the next call.

It returns empty tokens, too, behaving exactly like the libc function of that name. In fact, it was stolen from glibc2 and de-fancy-fied. Same semantics, slimmer shape. ;)

Definition at line 73 of file stringextra.c.

References end, NULL, and strpbrk().

Referenced by parse_kv(), and parse_net_args().

{
        char *sbegin = *s, *end;

        if (sbegin == NULL)
                return NULL;

        end = strpbrk(sbegin, ct);
        if (end)
                *end++ = '\0';
        *s = end;

        return sbegin;
}