9
3

service_sha1.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #ifndef MYSQL_SERVICE_SHA1_INCLUDED
  2. /* Copyright (c) 2013, 2014, Monty Program Ab
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; version 2 of the License.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. GNU General Public License for more details.
  10. You should have received a copy of the GNU General Public License
  11. along with this program; if not, write to the Free Software
  12. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
  13. /**
  14. @file
  15. my sha1 service
  16. Functions to calculate SHA1 hash from a memory buffer
  17. */
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. #ifndef MYSQL_ABI_CHECK
  22. #include <stdlib.h>
  23. #endif
  24. #define MY_SHA1_HASH_SIZE 20 /* Hash size in bytes */
  25. extern struct my_sha1_service_st {
  26. void (*my_sha1_type)(unsigned char*, const char*, size_t);
  27. void (*my_sha1_multi_type)(unsigned char*, ...);
  28. size_t (*my_sha1_context_size_type)();
  29. void (*my_sha1_init_type)(void *);
  30. void (*my_sha1_input_type)(void *, const unsigned char *, size_t);
  31. void (*my_sha1_result_type)(void *, unsigned char *);
  32. } *my_sha1_service;
  33. #ifdef MYSQL_DYNAMIC_PLUGIN
  34. #define my_sha1(A,B,C) my_sha1_service->my_sha1_type(A,B,C)
  35. #define my_sha1_multi my_sha1_service->my_sha1_multi_type
  36. #define my_sha1_context_size() my_sha1_service->my_sha1_context_size_type()
  37. #define my_sha1_init(A) my_sha1_service->my_sha1_init_type(A)
  38. #define my_sha1_input(A,B,C) my_sha1_service->my_sha1_input_type(A,B,C)
  39. #define my_sha1_result(A,B) my_sha1_service->my_sha1_result_type(A,B)
  40. #else
  41. void my_sha1(unsigned char*, const char*, size_t);
  42. void my_sha1_multi(unsigned char*, ...);
  43. size_t my_sha1_context_size();
  44. void my_sha1_init(void *context);
  45. void my_sha1_input(void *context, const unsigned char *buf, size_t len);
  46. void my_sha1_result(void *context, unsigned char *digest);
  47. #endif
  48. #ifdef __cplusplus
  49. }
  50. #endif
  51. #define MYSQL_SERVICE_SHA1_INCLUDED
  52. #endif