base64.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /* Copyright (c) 2003-2006 MySQL AB
  2. Use is subject to license terms
  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 Street, Fifth Floor, Boston, MA 02110-1301, USA */
  13. #ifndef __BASE64_H_INCLUDED__
  14. #define __BASE64_H_INCLUDED__
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. /*
  19. Calculate how much memory needed for dst of base64_encode()
  20. */
  21. int base64_needed_encoded_length(int length_of_data);
  22. /*
  23. Maximum length base64_encode_needed_length() can accept with no overflow.
  24. */
  25. int base64_encode_max_arg_length(void);
  26. /*
  27. Calculate how much memory needed for dst of base64_decode()
  28. */
  29. int base64_needed_decoded_length(int length_of_encoded_data);
  30. /*
  31. Maximum length base64_decode_needed_length() can accept with no overflow.
  32. */
  33. int base64_decode_max_arg_length();
  34. /*
  35. Encode data as a base64 string
  36. */
  37. int base64_encode(const void *src, size_t src_len, char *dst);
  38. /*
  39. Decode a base64 string into data
  40. */
  41. int base64_decode(const char *src, size_t src_len,
  42. void *dst, const char **end_ptr, int flags);
  43. /* Allow multuple chunks 'AAA= AA== AA==', binlog uses this */
  44. #define MY_BASE64_DECODE_ALLOW_MULTIPLE_CHUNKS 1
  45. #ifdef __cplusplus
  46. }
  47. #endif
  48. #endif /* !__BASE64_H_INCLUDED__ */