/src/wrappers/glib/library/utilities/glib_base64_encoding.e

http://github.com/tybor/Liberty · Specman e · 161 lines · 2 code · 45 blank · 114 comment · 0 complexity · 457b2e5cd45a9c7a2a6fd8d1f2784186 MD5 · raw file

  1. deferred class GLIB_BASE64_ENCODING
  2. -- Base64 Encoding
  3. -- Base64 Encoding -- encodes and decodes data in Base64 format
  4. -- Synopsis
  5. -- #include <glib.h>
  6. -- gsize g_base64_encode_step (const guchar *in,
  7. -- gsize len,
  8. -- gboolean break_lines,
  9. -- gchar *out,
  10. -- gint *state,
  11. -- gint *save);
  12. -- gsize g_base64_encode_close (gboolean break_lines,
  13. -- gchar *out,
  14. -- gint *state,
  15. -- gint *save);
  16. -- gchar* g_base64_encode (const guchar *data,
  17. -- gsize len);
  18. -- gsize g_base64_decode_step (const gchar *in,
  19. -- gsize len,
  20. -- guchar *out,
  21. -- gint *state,
  22. -- guint *save);
  23. -- guchar* g_base64_decode (const gchar *text,
  24. -- gsize *out_len);
  25. -- Description
  26. -- Base64 is an encoding that allows to encode a sequence of arbitrary bytes as a
  27. -- sequence of printable ASCII characters. For the definition of Base64, see RFC
  28. -- 1421 or RFC 2045. Base64 is most commonly used as a MIME transfer encoding for
  29. -- email.
  30. -- GLib supports incremental encoding using g_base64_encode_step() and
  31. -- g_base64_encode_close(). Incremental decoding can be done with
  32. -- g_base64_decode_step(). To encode or decode data in one go, use g_base64_encode()
  33. -- or g_base64_decode().
  34. -- Support for Base64 encoding has been added in GLib 2.12.
  35. -- Details
  36. -- g_base64_encode_step ()
  37. -- gsize g_base64_encode_step (const guchar *in,
  38. -- gsize len,
  39. -- gboolean break_lines,
  40. -- gchar *out,
  41. -- gint *state,
  42. -- gint *save);
  43. -- Incrementally encode a sequence of binary data into it's Base-64 stringified
  44. -- representation. By calling this function multiple times you can convert data in
  45. -- chunks to avoid having to have the full encoded data in memory.
  46. -- When all of the data has been converted you must call g_base64_encode_close() to
  47. -- flush the saved state.
  48. -- The output buffer must be large enough to fit all the data that will be written
  49. -- to it. Due to the way base64 encodes you will need at least: len * 4 / 3 + 6
  50. -- bytes. If you enable line-breaking you will need at least: len * 4 / 3 + len * 4
  51. -- / (3 * 72) + 7 bytes.
  52. -- break_lines is typically used when putting base64-encoded data in emails. It
  53. -- breaks the lines at 72 columns instead of putting all of the text on the same
  54. -- line. This avoids problems with long lines in the email system.
  55. -- in : the binary data to encode.
  56. -- len : the length of in.
  57. -- break_lines : whether to break long lines
  58. -- out : pointer to destination buffer
  59. -- state : Saved state between steps, initialize to 0
  60. -- save : Saved state between steps, initialize to 0
  61. -- Returns : The number of bytes of output that was written
  62. -- Since 2.12
  63. -- ---------------------------------------------------------------------------------
  64. -- g_base64_encode_close ()
  65. -- gsize g_base64_encode_close (gboolean break_lines,
  66. -- gchar *out,
  67. -- gint *state,
  68. -- gint *save);
  69. -- Flush the status from a sequence of calls to g_base64_encode_step().
  70. -- break_lines : whether to break long lines
  71. -- out : pointer to destination buffer
  72. -- state : Saved state from g_base64_encode_step()
  73. -- save : Saved state from g_base64_encode_step()
  74. -- Returns : The number of bytes of output that was written
  75. -- Since 2.12
  76. -- ---------------------------------------------------------------------------------
  77. -- g_base64_encode ()
  78. -- gchar* g_base64_encode (const guchar *data,
  79. -- gsize len);
  80. -- Encode a sequence of binary data into its Base-64 stringified representation.
  81. -- data : the binary data to encode.
  82. -- len : the length of data.
  83. -- Returns : a newly allocated, zero-terminated Base-64 encoded string representing
  84. -- data.
  85. -- Since 2.12
  86. -- ---------------------------------------------------------------------------------
  87. -- g_base64_decode_step ()
  88. -- gsize g_base64_decode_step (const gchar *in,
  89. -- gsize len,
  90. -- guchar *out,
  91. -- gint *state,
  92. -- guint *save);
  93. -- Incrementally decode a sequence of binary data from its Base-64 stringified
  94. -- representation. By calling this function multiple times you can convert data in
  95. -- chunks to avoid having to have the full encoded data in memory.
  96. -- The output buffer must be large enough to fit all the data that will be written
  97. -- to it. Since base64 encodes 3 bytes in 4 chars you need at least: len * 3 / 4
  98. -- bytes.
  99. -- in : binary input data
  100. -- len : max length of in data to decode
  101. -- out : output buffer
  102. -- state : Saved state between steps, initialize to 0
  103. -- save : Saved state between steps, initialize to 0
  104. -- Returns : The number of bytes of output that was written
  105. -- Since 2.12
  106. -- ---------------------------------------------------------------------------------
  107. -- g_base64_decode ()
  108. -- guchar* g_base64_decode (const gchar *text,
  109. -- gsize *out_len);
  110. -- Decode a sequence of Base-64 encoded text into binary data
  111. -- text : zero-terminated string with base64 text to decode.
  112. -- out_len : The length of the decoded data is written here.
  113. -- Returns : a newly allocated buffer containing the binary data that text
  114. -- represents
  115. -- Since 2.12
  116. end -- class GLIB_BASE64_ENCODING