base64.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /* -*- buffer-read-only: t -*- vi: set ro: */
  2. /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
  3. /* base64.h -- Encode binary data using printable characters.
  4. Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
  5. Written by Simon Josefsson.
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2, or (at your option)
  9. any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software Foundation,
  16. Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
  17. #ifndef BASE64_H
  18. # define BASE64_H
  19. /* Get size_t. */
  20. # include <stddef.h>
  21. /* Get bool. */
  22. # include <stdbool.h>
  23. /* This uses that the expression (n+(k-1))/k means the smallest
  24. integer >= n/k, i.e., the ceiling of n/k. */
  25. # define BASE64_LENGTH(inlen) ((((inlen) + 2) / 3) * 4)
  26. struct base64_decode_context
  27. {
  28. unsigned int i;
  29. char buf[4];
  30. };
  31. bool isbase64 (char ch);
  32. void base64_encode (const char * in, size_t inlen,
  33. char * out, size_t outlen);
  34. extern size_t base64_encode_alloc (const char *in, size_t inlen, char **out);
  35. void base64_decode_ctx_init (struct base64_decode_context *ctx);
  36. bool base64_decode (struct base64_decode_context *ctx,
  37. const char * in, size_t inlen,
  38. char * out, size_t *outlen);
  39. bool base64_decode_alloc (struct base64_decode_context *ctx,
  40. const char *in, size_t inlen,
  41. char **out, size_t *outlen);
  42. #endif /* BASE64_H */