68 #include <lal/LALStdlib.h>
69 #include <lal/AVFactories.h>
70 #include <lal/StringInput.h>
78 const CHAR *
string,
const CHAR * delimiters)
97 sLength = strlen(
string) + 1;
101 for (i = 0; i < sLength; i++) {
103 if (strchr(delimiters, c)) {
121 if (!((*list)->tokens =
128 (*list)->nTokens = nTokens;
129 (*list)->list = NULL;
144 listData = (*list)->list->data;
146 while (i < sLength) {
148 tLength = strlen(copy + i) + 1;
149 memcpy(listData, copy + i, tLength *
sizeof(
CHAR));
150 (*list)->tokens[j++] = listData;
157 (*list)->tokens[j] = NULL;
170 const CHAR * delimiters
181 size_t stringLen = strlen(
string);
190 const char *endPtr = ptr + stringLen;
193 UINT4 nTokensAlloc = 0;
195 while ((ptr != NULL) && (ptr < endPtr)) {
197 size_t skip = strspn(ptr, delimiters);
198 memset(ptr, 0, skip);
208 if (nTokens > nTokensAlloc) {
209 nTokensAlloc = 2 * nTokens;
217 ret->
tokens[nTokens - 1] = ptr;
220 ptr = strpbrk(ptr, delimiters);
#define ABORT(statusptr, code, mesg)
#define ENDFAIL(statusptr)
#define TRY(func, statusptr)
#define ATTATCHSTATUSPTR(statusptr)
#define ASSERT(assertion, statusptr, code, mesg)
#define DETATCHSTATUSPTR(statusptr)
#define INITSTATUS(statusptr)
#define RETURN(statusptr)
#define BEGINFAIL(statusptr)
void XLALDestroyTokenList(TokenList *list)
See StringToken.c for documentation.
void LALDestroyTokenList(LALStatus *stat, TokenList **list)
void LALCreateTokenList(LALStatus *stat, TokenList **list, const CHAR *string, const CHAR *delimiters)
int XLALCreateTokenList(TokenList **list, const CHAR *string, const CHAR *delimiters)
Split given input string into a list of 'tokens' separated by any of the characters given in 'delimit...
unsigned char BOOLEAN
Boolean logical type, see Headers LAL(Atomic)Datatypes.h for more details.
char CHAR
One-byte signed integer, see Headers LAL(Atomic)Datatypes.h for more details.
uint32_t UINT4
Four-byte unsigned integer.
#define XLALRealloc(p, n)
void LALCHARCreateVector(LALStatus *, CHARVector **, UINT4)
void LALCHARDestroyVector(LALStatus *, CHARVector **)
CHARVector * XLALCreateCHARVector(UINT4 length)
void XLALDestroyCHARVector(CHARVector *vector)
#define XLAL_ERROR(...)
Macro to invoke a failure from a XLAL routine returning an integer.
#define XLAL_CHECK(assertion,...)
Macro to test an assertion and invoke a failure if it is not true in a function that returns an integ...
@ XLAL_ENOMEM
Memory allocation error.
@ XLAL_SUCCESS
Success return value (not an error number)
@ XLAL_EINVAL
Invalid argument.
CHAR * data
Pointer to the data array.
LAL status structure, see The LALStatus structure for more details.
struct tagLALStatus * statusPtr
Pointer to the next node in the list; NULL if this function is not reporting a subroutine error.
This structure stores a number of null-terminated strings of arbitrary length.
CHAR ** tokens
A list of pointers to the individual tokens; the elements tokens[0..nTokens-1] point to tokens,...
CHARVector * list
The flattened list of tokens, separated by (and terminated with) '\0' characters.
UINT4 nTokens
The number of tokens in the list.