tool_urlglob.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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 - 2020, 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. ***************************************************************************/
  24. #include "tool_setup.h"
  25. typedef enum {
  26. UPTSet = 1,
  27. UPTCharRange,
  28. UPTNumRange
  29. } URLPatternType;
  30. struct URLPattern {
  31. URLPatternType type;
  32. int globindex; /* the number of this particular glob or -1 if not used
  33. within {} or [] */
  34. union {
  35. struct {
  36. char **elements;
  37. int size;
  38. int ptr_s;
  39. } Set;
  40. struct {
  41. char min_c;
  42. char max_c;
  43. char ptr_c;
  44. int step;
  45. } CharRange;
  46. struct {
  47. unsigned long min_n;
  48. unsigned long max_n;
  49. int padlength;
  50. unsigned long ptr_n;
  51. unsigned long step;
  52. } NumRange;
  53. } content;
  54. };
  55. /* the total number of globs supported */
  56. #define GLOB_PATTERN_NUM 100
  57. struct URLGlob {
  58. struct URLPattern pattern[GLOB_PATTERN_NUM];
  59. size_t size;
  60. size_t urllen;
  61. char *glob_buffer;
  62. char beenhere;
  63. const char *error; /* error message */
  64. size_t pos; /* column position of error or 0 */
  65. };
  66. CURLcode glob_url(struct URLGlob**, char *, unsigned long *, FILE *);
  67. CURLcode glob_next_url(char **, struct URLGlob *);
  68. CURLcode glob_match_url(char **, char *, struct URLGlob *);
  69. void glob_cleanup(struct URLGlob *glob);
  70. #endif /* HEADER_CURL_TOOL_URLGLOB_H */