service_mysql_string.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /* Copyright (c) 2012, 2014, 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. /* This service provides functions to parse mysql String */
  19. #ifndef MYSQL_SERVICE_MYSQL_STRING_INCLUDED
  20. #define MYSQL_SERVICE_MYSQL_STRING_INCLUDED
  21. #ifndef MYSQL_ABI_CHECK
  22. #include <stdlib.h>
  23. #endif
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. typedef void *mysql_string_iterator_handle;
  28. typedef void *mysql_string_handle;
  29. extern struct mysql_string_service_st {
  30. int (*mysql_string_convert_to_char_ptr_type)
  31. (mysql_string_handle, const char *, char *, unsigned int, int *);
  32. mysql_string_iterator_handle (*mysql_string_get_iterator_type)
  33. (mysql_string_handle);
  34. int (*mysql_string_iterator_next_type)(mysql_string_iterator_handle);
  35. int (*mysql_string_iterator_isupper_type)(mysql_string_iterator_handle);
  36. int (*mysql_string_iterator_islower_type)(mysql_string_iterator_handle);
  37. int (*mysql_string_iterator_isdigit_type)(mysql_string_iterator_handle);
  38. mysql_string_handle (*mysql_string_to_lowercase_type)(mysql_string_handle);
  39. void (*mysql_string_free_type)(mysql_string_handle);
  40. void (*mysql_string_iterator_free_type)(mysql_string_iterator_handle);
  41. } *mysql_string_service;
  42. #ifdef MYSQL_DYNAMIC_PLUGIN
  43. #define mysql_string_convert_to_char_ptr(string_handle, charset_name, \
  44. buffer, buffer_size, error) \
  45. mysql_string_service->mysql_string_convert_to_char_ptr_type \
  46. (string_handle, charset_name, buffer, \
  47. buffer_size, error)
  48. #define mysql_string_get_iterator(string_handle) \
  49. mysql_string_service->mysql_string_get_iterator_type(string_handle)
  50. #define mysql_string_iterator_next(iterator_handle) \
  51. mysql_string_service->mysql_string_iterator_next_type(iterator_handle)
  52. #define mysql_string_iterator_isupper(iterator_handle) \
  53. mysql_string_service->mysql_string_iterator_isupper_type \
  54. (iterator_handle)
  55. #define mysql_string_iterator_islower(iterator_handle) \
  56. mysql_string_service->mysql_string_iterator_islower_type \
  57. (iterator_handle)
  58. #define mysql_string_iterator_isdigit(iterator_handle) \
  59. mysql_string_service->mysql_string_iterator_isdigit_type \
  60. (iterator_handle)
  61. #define mysql_string_to_lowercase(string_handle) \
  62. mysql_string_service->mysql_string_to_lowercase_type(string_handle)
  63. #define mysql_string_free(mysql_string_handle) \
  64. mysql_string_service->mysql_string_free_type(mysql_string_handle)
  65. #define mysql_string_iterator_free(mysql_string_iterator_handle) \
  66. mysql_string_service->mysql_string_iterator_free_type \
  67. (mysql_string_iterator_handle)
  68. #else
  69. /* This service function convert string into given character set */
  70. int mysql_string_convert_to_char_ptr(mysql_string_handle string_handle,
  71. const char *charset_name, char *buffer,
  72. unsigned int buffer_size, int *error);
  73. /* This service function returns the beginning of the iterator handle */
  74. mysql_string_iterator_handle mysql_string_get_iterator(mysql_string_handle
  75. string_handle);
  76. /*
  77. This service function gets the next iterator handle
  78. returns 0 if reached the end else return 1
  79. */
  80. int mysql_string_iterator_next(mysql_string_iterator_handle iterator_handle);
  81. /*
  82. This service function return 1 if current iterator handle points to a
  83. uppercase character else return 0 for client character set.
  84. */
  85. int mysql_string_iterator_isupper(mysql_string_iterator_handle iterator_handle);
  86. /*
  87. This service function return 1 if current iterator handle points to a
  88. lowercase character else return 0 for client character set.
  89. */
  90. int mysql_string_iterator_islower(mysql_string_iterator_handle iterator_handle);
  91. /*
  92. This service function return 1 if current iterator handle points to a digit
  93. else return 0 for client character sets.
  94. */
  95. int mysql_string_iterator_isdigit(mysql_string_iterator_handle iterator_handle);
  96. /* convert string_handle into lowercase */
  97. mysql_string_handle mysql_string_to_lowercase(mysql_string_handle
  98. string_handle);
  99. /* It deallocates the string created on server side during plugin operations */
  100. void mysql_string_free(mysql_string_handle);
  101. /*
  102. It deallocates the string iterator created on server side
  103. during plugin operations
  104. */
  105. void mysql_string_iterator_free(mysql_string_iterator_handle);
  106. #endif
  107. #ifdef __cplusplus
  108. }
  109. #endif
  110. #endif