mf_wcomp.h 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
  2. This program is free software; you can redistribute it and/or modify
  3. it under the terms of the GNU General Public License, version 2.0,
  4. as published by the Free Software Foundation.
  5. This program is also distributed with certain software (including
  6. but not limited to OpenSSL) that is licensed under separate terms,
  7. as designated in a particular file or component or in included license
  8. documentation. The authors of MySQL hereby grant you an additional
  9. permission to link the program and your derivative works with the
  10. separately licensed software that they have included with MySQL.
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. GNU General Public License, version 2.0, for more details.
  15. You should have received a copy of the GNU General Public License
  16. along with this program; if not, write to the Free Software
  17. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
  18. #ifndef MF_WCOMP_INCLUDED
  19. #define MF_WCOMP_INCLUDED
  20. /**
  21. Character constant for the escape character in a wildcard pattern
  22. (SQL style).
  23. */
  24. const char wild_prefix = '\\';
  25. /**
  26. Character constant for wildcard representing any one character
  27. (SQL style).
  28. */
  29. const char wild_one = '_';
  30. /**
  31. Character constant for wildcard representing zero or more
  32. characters (SQL style).
  33. */
  34. const char wild_many = '%';
  35. /**
  36. Performs wildcard matching, aka globbing, on the input string with
  37. the given wildcard pattern, and the specified wildcard characters.
  38. Note that when str_is_pattern is true, an escaped wildcard in the
  39. pattern will only match an escaped wildcard in the string, e.g the
  40. string "my_1" will *not* be matched by the pattern "my\\_1".
  41. @deprecated This function is not charset-aware, and should not be
  42. used in new code.
  43. @param str input which should be matched against pattern
  44. @param strlen length of str in bytes
  45. @param wildstr pattern with wildcards
  46. @param wildlen length of wildstr in bytes
  47. @param str_is_pattern if true the input string is considered to be a
  48. pattern, meaning that escape sequences in the input are processed as
  49. if they appeared in the pattern
  50. @param w_one wildcard character matching any single character
  51. @param w_many wildcard character matching 0 or more characters
  52. @param w_prefix escape character for the pattern
  53. @return 0 if match, 1 otherwise
  54. */
  55. int wild_compare_full(const char *str, int strlen, const char *wildstr,
  56. int wildlen, bool str_is_pattern, char w_prefix,
  57. char w_one, char w_many);
  58. /**
  59. Performs wildcard matching, aka globbing, on the input string with
  60. the given wildcard pattern, using the standard SQL wildcard ('_',
  61. '%' and '\\') notation.
  62. @deprecated This function is not charset-aware, and should not be
  63. used in new code.
  64. @param str input which should be matched against pattern
  65. @param strlen length of str in bytes
  66. @param wildstr pattern with wildcards
  67. @param wildlen length of wildstr in bytes
  68. @param str_is_pattern if true the input string is considered to be a
  69. pattern, meaning that escape sequences in the input are processed as
  70. if they appeared in the pattern.
  71. @return 0 if match, 1 otherwise
  72. */
  73. int wild_compare(const char *str, int strlen, const char *wildstr, int wildlen,
  74. bool str_is_pattern);
  75. #endif /* !MF_WCOMP_INCLUDED */