Base64.h.in 4.5 KB

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