33 #define _MPRINTF_REPLACE
40 #include "../lib/memdebug.h"
79 "unmatched brace at pos %d\n", pos);
85 "nested braces not supported at pos %d\n", pos);
102 if (*pattern ==
'}') {
107 if(
GLOB_ERROR == glob_word(glob, ++pattern, ++pos, &wordamount))
121 "illegal pattern at pos %d\n", pos);
125 if (*(buf+1) ==
'\0') {
127 "illegal pattern at pos %d\n", pos);
141 static GlobCode glob_range(
URLGlob *glob,
char *pattern,
int pos,
int *amount)
157 if (isalpha((
int)*pattern)) {
165 "illegal pattern or range specification after pos %d\n", pos);
171 if(
GLOB_ERROR == glob_word(glob, pattern + 4, pos + 4, &wordamount))
181 if (isdigit((
int)*pattern)) {
185 if (sscanf(pattern,
"%d-%d]",
191 "error: illegal pattern or range specification after pos %d\n",
195 if (*pattern ==
'0') {
197 while (isdigit((
int)*c++))
202 c = (
char*)strchr(pattern,
']');
212 if(
GLOB_ERROR == glob_word(glob, c, pos + (c - pattern), &wordamount))
222 "illegal character in range specification at pos %d\n", pos);
226 static GlobCode glob_word(
URLGlob *glob,
char *pattern,
int pos,
int *amount)
237 while (*pattern !=
'\0' && *pattern !=
'{' && *pattern !=
'[') {
238 if (*pattern ==
'}' || *pattern ==
']')
242 if (*pattern ==
'\\' &&
243 (*(pattern+1) ==
'{' || *(pattern+1) ==
'[' ||
244 *(pattern+1) ==
'}' || *(pattern+1) ==
']') ) {
249 if (*pattern ==
'\0')
256 litindex = glob->
size / 2;
269 res = glob_set(glob, ++pattern, ++pos, amount);
274 res= glob_range(glob, ++pattern, ++pos, amount);
293 char *glob_buffer=(
char *)malloc(strlen(url)+1);
296 if(
NULL == glob_buffer)
300 if(
NULL == glob_expand) {
304 glob_expand->
size = 0;
305 glob_expand->
urllen = strlen(url);
308 if(
GLOB_OK == glob_word(glob_expand, url, 1, &amount))
311 if(error && glob_expand->
errormsg[0]) {
313 fprintf(error,
"curl: (%d) [globbing] %s\n",
332 for (i = glob->
size - 1; i >= 0; --i) {
366 for (i = glob->
size / 2 - 1; carry && i >= 0; --i) {
389 printf(
"internal error: invalid pattern type (%d)\n", pat->
type);
397 for (i = 0; i < glob->
size; ++
i) {
419 printf(
"internal error: invalid pattern type (%d)\n", pat->
type);
434 char *appendthis =
NULL;
441 allocsize=strlen(filename);
442 target = malloc(allocsize);
447 if (*filename ==
'#' && isdigit((
int)filename[1])) {
450 unsigned long num = strtoul(&filename[1], &filename, 10);
454 if (num && (i <= glob->
size / 2)) {
473 appendlen = (
int)strlen(numbuf);
476 printf(
"internal error: invalid pattern type (%d)\n",
484 appendthis=filename++;
487 if(appendlen + stringlen >= allocsize) {
489 allocsize = (appendlen + stringlen)*2;
490 newstr=realloc(target, allocsize);
497 memcpy(&target[stringlen], appendthis, appendlen);
498 stringlen += appendlen;
500 target[stringlen]=
'\0';
char * glob_match_url(char *filename, URLGlob *glob)
void glob_cleanup(URLGlob *glob)
char * glob_next_url(URLGlob *glob)
struct URLPattern::@13::@14 Set
struct URLPattern::@13::@16 NumRange
int glob_url(URLGlob **glob, char *url, int *urlnum, FILE *error)
if(!ValidDisplayID(prefInfo.prefDisplayID)) prefInfo.prefDisplayID
struct URLPattern::@13::@15 CharRange
int sprintf(idStr &string, const char *fmt,...)
union URLPattern::@13 content