Lines Matching +full:ipv6 +full:- +full:single +full:- +full:target
8 * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
35 glob->error = string, glob->pos = column, code
39 URLPattern *pat = &glob->pattern[glob->size]; in glob_fixed()
40 pat->type = UPTSet; in glob_fixed()
41 pat->content.Set.size = 1; in glob_fixed()
42 pat->content.Set.ptr_s = 0; in glob_fixed()
43 pat->globindex = -1; in glob_fixed()
45 pat->content.Set.elements = malloc(sizeof(char *)); in glob_fixed()
47 if(!pat->content.Set.elements) in glob_fixed()
50 pat->content.Set.elements[0] = malloc(len + 1); in glob_fixed()
51 if(!pat->content.Set.elements[0]) in glob_fixed()
54 memcpy(pat->content.Set.elements[0], fixed, len); in glob_fixed()
55 pat->content.Set.elements[0][len] = 0; in glob_fixed()
82 ','-separated elements are collected until the next closing '}' in glob_set()
86 char *buf = glob->glob_buffer; in glob_set()
89 size_t opos = *posp-1; in glob_set()
91 pat = &glob->pattern[glob->size]; in glob_set()
93 pat->type = UPTSet; in glob_set()
94 pat->content.Set.size = 0; in glob_set()
95 pat->content.Set.ptr_s = 0; in glob_set()
96 pat->content.Set.elements = NULL; in glob_set()
97 pat->globindex = globindex; in glob_set()
114 if(multiply(amount, pat->content.Set.size + 1)) in glob_set()
121 if(pat->content.Set.elements) { in glob_set()
122 char **new_arr = realloc(pat->content.Set.elements, in glob_set()
123 (pat->content.Set.size + 1) * sizeof(char *)); in glob_set()
127 pat->content.Set.elements = new_arr; in glob_set()
130 pat->content.Set.elements = malloc(sizeof(char *)); in glob_set()
132 if(!pat->content.Set.elements) in glob_set()
135 pat->content.Set.elements[pat->content.Set.size] = in glob_set()
136 strdup(glob->glob_buffer); in glob_set()
137 if(!pat->content.Set.elements[pat->content.Set.size]) in glob_set()
139 ++pat->content.Set.size; in glob_set()
147 buf = glob->glob_buffer; in glob_set()
176 - char range: e.g. "a-z]", "B-Q]" in glob_range()
177 - num range: e.g. "0-9]", "17-2000]" in glob_range()
178 - num range with leading zeros: e.g. "001-999]" in glob_range()
179 expression is checked for well-formedness and collected until the next ']' in glob_range()
186 pat = &glob->pattern[glob->size]; in glob_range()
187 pat->globindex = globindex; in glob_range()
196 pat->type = UPTCharRange; in glob_range()
198 rc = sscanf(pattern, "%c-%c%c", &min_c, &max_c, &end_c); in glob_range()
218 *posp += (pattern - *patternp); in glob_range()
222 (min_c != max_c && (min_c > max_c || step > (unsigned)(max_c - min_c) || in glob_range()
223 (max_c - min_c) > ('z' - 'a')))) in glob_range()
224 /* the pattern is not well-formed */ in glob_range()
228 pat->content.CharRange.step = (int)step; in glob_range()
229 pat->content.CharRange.ptr_c = pat->content.CharRange.min_c = min_c; in glob_range()
230 pat->content.CharRange.max_c = max_c; in glob_range()
232 if(multiply(amount, ((pat->content.CharRange.max_c - in glob_range()
233 pat->content.CharRange.min_c) / in glob_range()
234 pat->content.CharRange.step + 1))) in glob_range()
244 pat->type = UPTNumRange; in glob_range()
245 pat->content.NumRange.padlength = 0; in glob_range()
252 ++pat->content.NumRange.padlength; /* padding length is set for all in glob_range()
262 if(*endp != '-') in glob_range()
296 *posp += (pattern - *patternp); in glob_range()
300 (min_n != max_n && (min_n > max_n || step_n > (max_n - min_n)))) in glob_range()
301 /* the pattern is not well-formed */ in glob_range()
306 pat->content.NumRange.ptr_n = pat->content.NumRange.min_n = min_n; in glob_range()
307 pat->content.NumRange.max_n = max_n; in glob_range()
308 pat->content.NumRange.step = step_n; in glob_range()
310 if(multiply(amount, ((pat->content.NumRange.max_n - in glob_range()
311 pat->content.NumRange.min_n) / in glob_range()
312 pat->content.NumRange.step + 1))) in glob_range()
325 * Scan for a potential IPv6 literal. in peek_ipv6()
326 * - Valid globs contain a hyphen and <= 1 colon. in peek_ipv6()
327 * - IPv6 literals contain no hyphens and >= 2 colons. in peek_ipv6()
364 char *buf = glob->glob_buffer; in glob_parse()
368 /* skip over IPv6 literals and [] */ in glob_parse()
399 /* we got a literal string, add it as a single-item list */ in glob_parse()
401 res = glob_fixed(glob, glob->glob_buffer, sublen); in glob_parse()
424 if(++glob->size >= GLOB_PATTERN_NUM) in glob_parse()
434 * We can deal with any-size, just make a buffer with the same length in glob_url()
454 glob_expand->urllen = strlen(url); in glob_url()
455 glob_expand->glob_buffer = glob_buffer; in glob_url()
461 if(error && glob_expand->error) { in glob_url()
464 if(glob_expand->pos) { in glob_url()
466 glob_expand->error, in glob_url()
467 glob_expand->pos, url, glob_expand->pos - 1, " "); in glob_url()
471 t = glob_expand->error; in glob_url()
473 /* send error description to the error-stream */ in glob_url()
491 for(i = 0; i < glob->size; i++) { in glob_cleanup()
492 if((glob->pattern[i].type == UPTSet) && in glob_cleanup()
493 (glob->pattern[i].content.Set.elements)) { in glob_cleanup()
494 for(elem = glob->pattern[i].content.Set.size - 1; in glob_cleanup()
496 --elem) { in glob_cleanup()
497 Curl_safefree(glob->pattern[i].content.Set.elements[elem]); in glob_cleanup()
499 Curl_safefree(glob->pattern[i].content.Set.elements); in glob_cleanup()
502 Curl_safefree(glob->glob_buffer); in glob_cleanup()
511 size_t buflen = glob->urllen + 1; in glob_next_url()
512 char *buf = glob->glob_buffer; in glob_next_url()
516 if(!glob->beenhere) in glob_next_url()
517 glob->beenhere = 1; in glob_next_url()
523 for(i = 0; carry && (i < glob->size); i++) { in glob_next_url()
525 pat = &glob->pattern[glob->size - 1 - i]; in glob_next_url()
526 switch(pat->type) { in glob_next_url()
528 if((pat->content.Set.elements) && in glob_next_url()
529 (++pat->content.Set.ptr_s == pat->content.Set.size)) { in glob_next_url()
530 pat->content.Set.ptr_s = 0; in glob_next_url()
535 pat->content.CharRange.ptr_c = in glob_next_url()
536 (char)(pat->content.CharRange.step + in glob_next_url()
537 (int)((unsigned char)pat->content.CharRange.ptr_c)); in glob_next_url()
538 if(pat->content.CharRange.ptr_c > pat->content.CharRange.max_c) { in glob_next_url()
539 pat->content.CharRange.ptr_c = pat->content.CharRange.min_c; in glob_next_url()
544 pat->content.NumRange.ptr_n += pat->content.NumRange.step; in glob_next_url()
545 if(pat->content.NumRange.ptr_n > pat->content.NumRange.max_n) { in glob_next_url()
546 pat->content.NumRange.ptr_n = pat->content.NumRange.min_n; in glob_next_url()
551 printf("internal error: invalid pattern type (%d)\n", (int)pat->type); in glob_next_url()
561 for(i = 0; i < glob->size; ++i) { in glob_next_url()
562 pat = &glob->pattern[i]; in glob_next_url()
563 switch(pat->type) { in glob_next_url()
565 if(pat->content.Set.elements) { in glob_next_url()
567 pat->content.Set.elements[pat->content.Set.ptr_s]); in glob_next_url()
570 buflen -= len; in glob_next_url()
575 *buf++ = pat->content.CharRange.ptr_c; in glob_next_url()
577 buflen--; in glob_next_url()
582 pat->content.NumRange.padlength, in glob_next_url()
583 pat->content.NumRange.ptr_n); in glob_next_url()
586 buflen -= len; in glob_next_url()
589 printf("internal error: invalid pattern type (%d)\n", (int)pat->type); in glob_next_url()
594 *globbed = strdup(glob->glob_buffer); in glob_next_url()
603 char *target; in glob_match_url() local
618 target = malloc(allocsize); in glob_match_url()
619 if(!target) in glob_match_url()
628 if(num < glob->size) { in glob_match_url()
630 num--; /* make it zero based */ in glob_match_url()
632 for(i = 0; i<glob->size; i++) { in glob_match_url()
633 if(glob->pattern[i].globindex == (int)num) { in glob_match_url()
634 pat = &glob->pattern[i]; in glob_match_url()
641 switch(pat->type) { in glob_match_url()
643 if(pat->content.Set.elements) { in glob_match_url()
644 appendthis = pat->content.Set.elements[pat->content.Set.ptr_s]; in glob_match_url()
646 strlen(pat->content.Set.elements[pat->content.Set.ptr_s]); in glob_match_url()
650 numbuf[0] = pat->content.CharRange.ptr_c; in glob_match_url()
657 pat->content.NumRange.padlength, in glob_match_url()
658 pat->content.NumRange.ptr_n); in glob_match_url()
664 (int)pat->type); in glob_match_url()
665 Curl_safefree(target); in glob_match_url()
682 /* we append a single byte to allow for the trailing byte to be appended in glob_match_url()
685 newstr = realloc(target, allocsize + 1); in glob_match_url()
687 Curl_safefree(target); in glob_match_url()
690 target = newstr; in glob_match_url()
692 memcpy(&target[stringlen], appendthis, appendlen); in glob_match_url()
695 target[stringlen]= '\0'; in glob_match_url()
700 SANITIZEcode sc = sanitize_file_name(&sanitized, target, in glob_match_url()
703 Curl_safefree(target); in glob_match_url()
706 target = sanitized; in glob_match_url()
710 *result = target; in glob_match_url()