DragonFly On-Line Manual Pages
cstrc(l) BEGEMOT Library cstrc(l)
NAME
cstrc, cstrd - convert between ANSI C-strings and strings
SYNOPSIS
# include <begemot.h>
char * cstrc(char **pstr, char delim, size_t *plen);
char * cstrd(const char *str, char delim, size_t len);
int cstrwarn;
DESCRIPTION
The cstrc function converts a string as specified in the ANSI C-
standard to the usual internal representation. All escape sequences are
(hopefully) recognized. Setting cstrwarn to any non-zero value enables
some warning messages, which are emitted via warn(l). Pstr is the
address of a pointer to the string to be parsed. Delim is the
character at which the parsing should stop. It should be a single or a
double quote character. Parsing stops also if a NUL character is found.
* pstr is left pointing to the terminating character. At entry to the
function * pstr should point behind the initial delimiter. * plen will
hold the number of bytes in the output string. The string will be NUL
termninated, but note, that it may contain embedded NULs.
Cstrd prints a string with non-printable characters converted to escape
sequences. delim is escaped in the output string (usually '\'' or
'"').
The user is responsible the deallocate the memory returned by cstrc and
cstrd. Both functions call xalloc(l) and xrealloc(l) and therefor end
in panic(l) if not enough memory is available.
RETURN VALUE
Both functions return allocated memory that must be freed by the
caller. They may never return NULL.
SEE ALSO
panic(l), xalloc(l), xrealloc(3b)
BUGS
Certainly.
BEGEMOT 9 Oct 1996 cstrc(l)