2
0

apr_base64.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /* Copyright 2000-2005 The Apache Software Foundation or its licensors, as
  2. * applicable.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. * The apr_vsnprintf/apr_snprintf functions are based on, and used with the
  16. * permission of, the SIO stdio-replacement strx_* functions by Panos
  17. * Tsirigotis <panos@alumni.cs.colorado.edu> for xinetd.
  18. */
  19. /**
  20. * @file apr_base64.h
  21. * @brief APR-UTIL Base64 Encoding
  22. */
  23. #ifndef APR_BASE64_H
  24. #define APR_BASE64_H
  25. #include "apu.h"
  26. #include "apr_general.h"
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. /**
  31. * @defgroup APR_Util_Base64 Base64 Encoding
  32. * @ingroup APR_Util
  33. * @{
  34. */
  35. /* Simple BASE64 encode/decode functions.
  36. *
  37. * As we might encode binary strings, hence we require the length of
  38. * the incoming plain source. And return the length of what we decoded.
  39. *
  40. * The decoding function takes any non valid char (i.e. whitespace, \0
  41. * or anything non A-Z,0-9 etc as terminal.
  42. *
  43. * plain strings/binary sequences are not assumed '\0' terminated. Encoded
  44. * strings are neither. But probably should.
  45. *
  46. */
  47. /**
  48. * Given the length of an un-encrypted string, get the length of the
  49. * encrypted string.
  50. * @param len the length of an unencrypted string.
  51. * @return the length of the string after it is encrypted
  52. */
  53. APU_DECLARE(int) apr_base64_encode_len(int len);
  54. /**
  55. * Encode a text string using base64encoding.
  56. * @param coded_dst The destination string for the encoded string.
  57. * @param plain_src The original string in plain text
  58. * @param len_plain_src The length of the plain text string
  59. * @return the length of the encoded string
  60. */
  61. APU_DECLARE(int) apr_base64_encode(char * coded_dst, const char *plain_src,
  62. int len_plain_src);
  63. /**
  64. * Encode an EBCDIC string using base64encoding.
  65. * @param coded_dst The destination string for the encoded string.
  66. * @param plain_src The original string in plain text
  67. * @param len_plain_src The length of the plain text string
  68. * @return the length of the encoded string
  69. */
  70. APU_DECLARE(int) apr_base64_encode_binary(char * coded_dst,
  71. const unsigned char *plain_src,
  72. int len_plain_src);
  73. /**
  74. * Determine the length of a plain text string given the encoded version
  75. * @param coded_src The encoded string
  76. * @return the length of the plain text string
  77. */
  78. APU_DECLARE(int) apr_base64_decode_len(const char * coded_src);
  79. /**
  80. * Decode a string to plain text
  81. * @param plain_dst The destination string for the plain text
  82. * @param coded_src The encoded string
  83. * @return the length of the plain text string
  84. */
  85. APU_DECLARE(int) apr_base64_decode(char * plain_dst, const char *coded_src);
  86. /**
  87. * Decode an EBCDIC string to plain text
  88. * @param plain_dst The destination string for the plain text
  89. * @param coded_src The encoded string
  90. * @return the length of the plain text string
  91. */
  92. APU_DECLARE(int) apr_base64_decode_binary(unsigned char * plain_dst,
  93. const char *coded_src);
  94. /** @} */
  95. #ifdef __cplusplus
  96. }
  97. #endif
  98. #endif /* !APR_BASE64_H */