Base64.h.in 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*============================================================================
  2. KWSys - Kitware System Library
  3. Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #ifndef @KWSYS_NAMESPACE@_Base64_h
  11. #define @KWSYS_NAMESPACE@_Base64_h
  12. #include <@KWSYS_NAMESPACE@/Configure.h>
  13. /* Redefine all public interface symbol names to be in the proper
  14. namespace. These macros are used internally to kwsys only, and are
  15. not visible to user code. Use kwsysHeaderDump.pl to reproduce
  16. these macros after making changes to the interface. */
  17. #if !defined(KWSYS_NAMESPACE)
  18. # define kwsys_ns(x) @KWSYS_NAMESPACE@##x
  19. # define kwsysEXPORT @KWSYS_NAMESPACE@_EXPORT
  20. #endif
  21. #if !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
  22. # define kwsysBase64 kwsys_ns(Base64)
  23. # define kwsysBase64_Decode kwsys_ns(Base64_Decode)
  24. # define kwsysBase64_Decode3 kwsys_ns(Base64_Decode3)
  25. # define kwsysBase64_Encode kwsys_ns(Base64_Encode)
  26. # define kwsysBase64_Encode1 kwsys_ns(Base64_Encode1)
  27. # define kwsysBase64_Encode2 kwsys_ns(Base64_Encode2)
  28. # define kwsysBase64_Encode3 kwsys_ns(Base64_Encode3)
  29. #endif
  30. #if defined(__cplusplus)
  31. extern "C"
  32. {
  33. #endif
  34. /**
  35. * Encode 3 bytes into a 4 byte string.
  36. */
  37. kwsysEXPORT void kwsysBase64_Encode3(const unsigned char *src,
  38. unsigned char *dest);
  39. /**
  40. * Encode 2 bytes into a 4 byte string.
  41. */
  42. kwsysEXPORT void kwsysBase64_Encode2(const unsigned char *src,
  43. unsigned char *dest);
  44. /**
  45. * Encode 1 bytes into a 4 byte string.
  46. */
  47. kwsysEXPORT void kwsysBase64_Encode1(const unsigned char *src,
  48. unsigned char *dest);
  49. /**
  50. * Encode 'length' bytes from the input buffer and store the encoded
  51. * stream into the output buffer. Return the length of the encoded
  52. * buffer (output). Note that the output buffer must be allocated by
  53. * the caller (length * 1.5 should be a safe estimate). If 'mark_end'
  54. * is true than an extra set of 4 bytes is added to the end of the
  55. * stream if the input is a multiple of 3 bytes. These bytes are
  56. * invalid chars and therefore they will stop the decoder thus
  57. * enabling the caller to decode a stream without actually knowing how
  58. * much data to expect (if the input is not a multiple of 3 bytes then
  59. * the extra padding needed to complete the encode 4 bytes will stop
  60. * the decoding anyway).
  61. */
  62. kwsysEXPORT unsigned long kwsysBase64_Encode(const unsigned char *input,
  63. unsigned long length,
  64. unsigned char *output,
  65. int mark_end);
  66. /**
  67. * Decode 4 bytes into a 3 byte string. Returns the number of bytes
  68. * actually decoded.
  69. */
  70. kwsysEXPORT int kwsysBase64_Decode3(const unsigned char *src,
  71. unsigned char *dest);
  72. /**
  73. * Decode bytes from the input buffer and store the decoded stream
  74. * into the output buffer until 'length' bytes have been decoded.
  75. * Return the real length of the decoded stream (which should be equal
  76. * to 'length'). Note that the output buffer must be allocated by the
  77. * caller. If 'max_input_length' is not null, then it specifies the
  78. * number of encoded bytes that should be at most read from the input
  79. * buffer. In that case the 'length' parameter is ignored. This
  80. * enables the caller to decode a stream without actually knowing how
  81. * much decoded data to expect (of course, the buffer must be large
  82. * enough).
  83. */
  84. kwsysEXPORT unsigned long kwsysBase64_Decode(const unsigned char *input,
  85. unsigned long length,
  86. unsigned char *output,
  87. unsigned long max_input_length);
  88. #if defined(__cplusplus)
  89. } /* extern "C" */
  90. #endif
  91. /* If we are building a kwsys .c or .cxx file, let it use these macros.
  92. Otherwise, undefine them to keep the namespace clean. */
  93. #if !defined(KWSYS_NAMESPACE)
  94. # undef kwsys_ns
  95. # undef kwsysEXPORT
  96. # if !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
  97. # undef kwsysBase64
  98. # undef kwsysBase64_Decode
  99. # undef kwsysBase64_Decode3
  100. # undef kwsysBase64_Encode
  101. # undef kwsysBase64_Encode1
  102. # undef kwsysBase64_Encode2
  103. # undef kwsysBase64_Encode3
  104. # endif
  105. #endif
  106. #endif