xf.li | 6c8fc1e | 2023-08-12 00:11:09 -0700 | [diff] [blame] | 1 | #ifndef HEADER_CURL_TOOL_URLGLOB_H |
| 2 | #define HEADER_CURL_TOOL_URLGLOB_H |
| 3 | /*************************************************************************** |
| 4 | * _ _ ____ _ |
| 5 | * Project ___| | | | _ \| | |
| 6 | * / __| | | | |_) | | |
| 7 | * | (__| |_| | _ <| |___ |
| 8 | * \___|\___/|_| \_\_____| |
| 9 | * |
| 10 | * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. |
| 11 | * |
| 12 | * This software is licensed as described in the file COPYING, which |
| 13 | * you should have received as part of this distribution. The terms |
| 14 | * are also available at https://curl.se/docs/copyright.html. |
| 15 | * |
| 16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell |
| 17 | * copies of the Software, and permit persons to whom the Software is |
| 18 | * furnished to do so, under the terms of the COPYING file. |
| 19 | * |
| 20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
| 21 | * KIND, either express or implied. |
| 22 | * |
| 23 | * SPDX-License-Identifier: curl |
| 24 | * |
| 25 | ***************************************************************************/ |
| 26 | #include "tool_setup.h" |
| 27 | |
| 28 | typedef enum { |
| 29 | UPTSet = 1, |
| 30 | UPTCharRange, |
| 31 | UPTNumRange |
| 32 | } URLPatternType; |
| 33 | |
| 34 | struct URLPattern { |
| 35 | URLPatternType type; |
| 36 | int globindex; /* the number of this particular glob or -1 if not used |
| 37 | within {} or [] */ |
| 38 | union { |
| 39 | struct { |
| 40 | char **elements; |
| 41 | int size; |
| 42 | int ptr_s; |
| 43 | } Set; |
| 44 | struct { |
| 45 | char min_c; |
| 46 | char max_c; |
| 47 | char ptr_c; |
| 48 | int step; |
| 49 | } CharRange; |
| 50 | struct { |
| 51 | unsigned long min_n; |
| 52 | unsigned long max_n; |
| 53 | int padlength; |
| 54 | unsigned long ptr_n; |
| 55 | unsigned long step; |
| 56 | } NumRange; |
| 57 | } content; |
| 58 | }; |
| 59 | |
| 60 | /* the total number of globs supported */ |
| 61 | #define GLOB_PATTERN_NUM 100 |
| 62 | |
| 63 | struct URLGlob { |
| 64 | struct URLPattern pattern[GLOB_PATTERN_NUM]; |
| 65 | size_t size; |
| 66 | size_t urllen; |
| 67 | char *glob_buffer; |
| 68 | char beenhere; |
| 69 | const char *error; /* error message */ |
| 70 | size_t pos; /* column position of error or 0 */ |
| 71 | }; |
| 72 | |
| 73 | CURLcode glob_url(struct URLGlob**, char *, unsigned long *, FILE *); |
| 74 | CURLcode glob_next_url(char **, struct URLGlob *); |
| 75 | CURLcode glob_match_url(char **, char *, struct URLGlob *); |
| 76 | void glob_cleanup(struct URLGlob *glob); |
| 77 | |
| 78 | #endif /* HEADER_CURL_TOOL_URLGLOB_H */ |