19#include "apr_private.h"
22#if APR_HAVE_SYS_TYPES_H
97#define SKIP_WHITESPACE(cp) \
98 for ( ; *cp == ' ' || *cp == '\t'; ) { \
102#define CHECK_QUOTATION(cp,isquoted) \
108 else if (*cp == '\'') { \
113/* DETERMINE_NEXTSTRING:
114 * At exit, cp will point to one of the following: NULL, SPACE, TAB or QUOTE.
115 * NULL implies the argument string has been fully traversed.
117#define DETERMINE_NEXTSTRING(cp,isquoted) \
118 for ( ; *cp != '\0'; cp++) { \
119 if ( (*cp == '\\' && (*(cp+1) == ' ' || *(cp+1) == '\t' || \
120 *(cp+1) == '"' || *(cp+1) == '\''))) { \
124 if ( (!isquoted && (*cp == ' ' || *cp == '\t')) \
125 || (isquoted == 1 && *cp == '"') \
126 || (isquoted == 2 && *cp == '\'') ) { \
131/* REMOVE_ESCAPE_CHARS:
132 * Compresses the arg string to remove all of the '\' escape chars.
133 * The final argv strings should not have any extra escape chars in it.
135#define REMOVE_ESCAPE_CHARS(cleaned, dirty, escaped) \
138 if (!escaped && *dirty == '\\') { \
143 *cleaned++ = *dirty; \
147 *cleaned = 0; /* last line of macro... */
153 /* This is ugly and expensive, but if anyone wants to figure a
154 * way to support any number of args without counting and
155 * allocating, please go ahead and change the code.
157 * Must account for the trailing NULL arg.
160 while (*ct != '\0') {
161 CHECK_QUOTATION(ct, isquoted);
162 DETERMINE_NEXTSTRING(ct, isquoted);
169 *argv_out = apr_palloc(token_context, numargs * sizeof(char*));
171 /* determine first argument */
172 for (argnum = 0; argnum < (numargs-1); argnum++) {
174 CHECK_QUOTATION(cp, isquoted);
176 DETERMINE_NEXTSTRING(cp, isquoted);
178 (*argv_out)[argnum] = apr_palloc(token_context, cp - ct);
179 apr_cpystrn((*argv_out)[argnum], ct, cp - ct);
180 cleaned = dirty = (*argv_out)[argnum];
181 REMOVE_ESCAPE_CHARS(cleaned, dirty, escaped);
183 (*argv_out)[argnum] = NULL;
188/* Filepath_name_get returns the final element of the pathname.
189 * Using the current platform's filename syntax.
190 * "/foo/bar/gum" -> "gum"
191 * "/foo/bar/gum/" -> ""
193 * "wi\\n32\\stuff" -> "stuff
235 size_t len = strlen(
str) + 1;
247#if (!APR_HAVE_STRCASECMP && !APR_HAVE_STRICMP)
252 for (
p =
a, q =
b; *
p && *q;
p++, q++) {
266#if (!APR_HAVE_STRNCASECMP && !APR_HAVE_STRNICMP)
272 for (
p =
a, q =
b; ;
p++, q++) {
287#if (!APR_HAVE_STRSTR)
299 while (*++
p1 == *++
p2) {
const char apr_size_t len
char * strstr(char *s1, char *s2)
char * strdup(const char *str)
APR general purpose library routines.
apr_size_t const unsigned char unsigned int unsigned int d
apr_bucket apr_bucket_brigade * a
const char const char * pathname
const void apr_status_t(*) apr_status_t(* APR_DECLARE)(void) apr_pool_pre_cleanup_register(apr_pool_t *p
int strcasecmp(const char *a, const char *b)
int strncasecmp(const char *a, const char *b, size_t n)
const char apr_size_t dst_size
char apr_pool_t * token_context