#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <sys/stat.h>
#include <sys/types.h>
#include "libdali.h"
Functions | |
int | dl_strparse (const char *string, const char *delim, DLstrlist **list) |
Parse/split a string on a specified delimiter. | |
int | dl_strncpclean (char *dest, const char *source, int length) |
Copy a string while removing space charaters. | |
int | dl_addtostring (char **string, char *add, char *delim, int maxlen) |
Concatinate one string to another growing the destination as needed. |
modified: 2008.193
int dl_addtostring | ( | char ** | string, | |
char * | add, | |||
char * | delim, | |||
int | maxlen | |||
) |
Concatinate one string to another growing the destination as needed.
Concatinate one string to another with a delimiter in-between growing the destination string as needed up to a maximum length.
string | Destination string to be added to | |
add | String to add to string | |
delim | Optional delimiter between added strings (cannot be NULL, but can be an empty string) | |
maxlen | Maximum number of bytes to grow string |
int dl_strncpclean | ( | char * | dest, | |
const char * | source, | |||
int | length | |||
) |
Copy a string while removing space charaters.
Copy length characters from source to dest while removing all spaces. The result is left justified and always null terminated. The source string must have at least length characters and the destination string must have enough room needed for the non-space characters within length and the null terminator.
dest | Destination string | |
source | String to copy | |
length | Copy up to a maximum of this many characters to dest |
int dl_strparse | ( | const char * | string, | |
const char * | delim, | |||
DLstrlist ** | list | |||
) |
Parse/split a string on a specified delimiter.
Splits a 'string' on 'delim' and puts each part into a linked list pointed to by 'list' (a pointer to a pointer). The last entry has it's 'next' set to 0. All elements are NULL terminated strings.
It is up to the caller to free the memory associated with the returned list. To facilitate freeing this special string list dl_strparse() can be called with both 'string' and 'delim' set to NULL and then the linked list is traversed and the memory used is free'd and the list pointer is set to NULL.
string | String to parse/split | |
delim | Delimiter to split string on | |
list | Returned list of sub-strings. |