24char *seek_level(
char *s,
char qs,
char qe);
26int in_charset(
char c,
char *s);
41 char *ptr0, *ptr1, *ptr;
45 while (in_charset(*s, t) && *s)
54 if (*s ==
'"' && !(s != ptr0 && *(s - 1) ==
'\\')) {
56 while (*s && !(*s ==
'"' && *(s - 1) !=
'\\'))
62 }
while (*s && !in_charset(*s, t));
64 ptr =
tmalloc(
sizeof(*ptr) * (s - ptr1 + 1));
65 strncpy(ptr, ptr1, s - ptr1);
80int in_charset(
char c,
char *set) {
112 register char *ptr0, *ptr1, *ptr;
113 register int in_quotes;
117 while (*s && in_charset(*s, ts) && !in_charset(*s, qs)) {
123 if ((in_quotes = in_charset(*s, qs)))
129 if ((ptr = seek_level(s, *(qs + in_quotes - 1), *(qe + in_quotes - 1)))) {
137 in_quotes = in_charset(*s, qs);
140 }
while (*s && (in_quotes || !in_charset(*s, te)));
142 ptr =
tmalloc((
unsigned)
sizeof(*ptr) * (s - ptr1 + 1));
143 strncpy(ptr, ptr1, s - ptr1);
165char *seek_level(
char *s,
char qs,
char qe) {
171 while (*s && qlevel) {
172 if (*s == qe && !(s != ptr0 && *(s - 1) ==
'\\'))
174 else if (*s == qs && !(s != ptr0 && *(s - 1) ==
'\\'))
197 if (*ptr ==
'\\' && *(ptr + 1) ==
'"')
void * tmalloc(uint64_t size_of_block)
Allocates a memory block of the specified size with zero initialization.
char * get_token_tq(char *s, char *ts, char *te, char *qs, char *qe)
Extracts a token from a string with support for multiple delimiter and quotation sets.
void interpret_escaped_quotes(char *s)
Processes a string to interpret and replace escaped quotation marks.
char * get_token_t(char *s, char *t)
Extracts a token from a string based on delimiter characters.
char * strcpy_ss(char *dest, const char *src)
Safely copies a string, handling memory overlap.