From f8b8027ae63c957557ed6bdc7e5a30ef1bdd8e77 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Thu, 23 Jun 2016 09:48:54 +0200 Subject: core: Add a base 64 decoder. * src/b64dec.c: New. Taken from gnupg. Prefix function names with _gpgme_ and change to use standard C malloc functions. * src/util.h.h (struct b64state): New. * src/Makefile.am (main_sources): Add file. -- The file b64dec.c has been taken from gnupg commit e430ff6ad0b7dcfcebd92b825dd5168205447ff3 Signed-off-by: Werner Koch --- src/util.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/util.h') diff --git a/src/util.h b/src/util.h index 9c62f57d..5a0f7906 100644 --- a/src/util.h +++ b/src/util.h @@ -146,6 +146,26 @@ gpgme_error_t _gpgme_map_gnupg_error (char *err); int _gpgme_map_pk_algo (int algo, gpgme_protocol_t protocol); + +/*-- b64dec.c --*/ + +struct b64state +{ + int idx; + int quad_count; + char *title; + unsigned char radbuf[4]; + int stop_seen:1; + int invalid_encoding:1; + gpg_error_t lasterr; +}; + +gpg_error_t _gpgme_b64dec_start (struct b64state *state, const char *title); +gpg_error_t _gpgme_b64dec_proc (struct b64state *state, + void *buffer, size_t length, size_t *r_nbytes); +gpg_error_t _gpgme_b64dec_finish (struct b64state *state); + + /* Retrieve the environment variable NAME and return a copy of it in a malloc()'ed buffer in *VALUE. If the environment variable is not -- cgit v1.2.3