iPXE
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 @cs: The string to be searched @ct: The characters to search for
char * strsep (char **s, const char *ct)
 strsep - Split a string into tokens @s: The string to be searched @ct: The characters to search for

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_ONLY )

◆ strpbrk()

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

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

Definition at line 47 of file stringextra.c.

48{
49 const char *sc1,*sc2;
50
51 for( sc1 = cs; *sc1 != '\0'; ++sc1) {
52 for( sc2 = ct; *sc2 != '\0'; ++sc2) {
53 if (*sc1 == *sc2)
54 return (char *) sc1;
55 }
56 }
57 return NULL;
58}
#define NULL
NULL pointer (VOID *)
Definition Base.h:322
uint32_t cs
Definition librm.h:14

References cs, and NULL.

Referenced by strsep().

◆ strsep()

char * strsep ( char ** s,
const char * ct )

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

strsep() updates @s 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.

74{
75 char *sbegin = *s, *end;
76
77 if (sbegin == NULL)
78 return NULL;
79
80 end = strpbrk(sbegin, ct);
81 if (end)
82 *end++ = '\0';
83 *s = end;
84
85 return sbegin;
86}
uint32_t end
Ending offset.
Definition netvsc.h:7
char * strpbrk(const char *cs, const char *ct)
strpbrk - Find the first occurrence of a set of characters @cs: The string to be searched @ct: The ch...
Definition stringextra.c:47

References end, NULL, and strpbrk().

Referenced by parse_kv(), and parse_net_args().