Base64.h.in 4.5 KB

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