tool_urlglob.h 2.3 KB

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