#include #define _(s) dgettext (PACKAGE, s) void init_webidoidc_base64 (void); SCM_DEFINE (webidoidc_base64_encode_g, "base64-encode", 1, 0, 0, (SCM data), "Encode @var{data} as base64. If @var{data} is a string, first encode it to UTF-8.") { size_t c_size; uint8_t *c_data; if (scm_is_string (data)) { return webidoidc_base64_encode_g (scm_string_to_utf8 (data)); } c_size = scm_c_bytevector_length (data); c_data = scm_gc_malloc_pointerless (c_size, "data"); memcpy (c_data, SCM_BYTEVECTOR_CONTENTS (data), c_size); return wrap_bytevector (c_size, c_data); } SCM_DEFINE (webidoidc_base64_decode_g, "base64-decode", 1, 0, 0, (SCM data), "Decode @var{data} from base64.") { size_t c_size; uint8_t *c_data = get_as_bytevector (data, &c_size, 1); SCM ret = scm_c_make_bytevector (c_size); memcpy (SCM_BYTEVECTOR_CONTENTS (ret), c_data, c_size); return ret; } void init_webidoidc_base64 (void) { #ifndef SCM_MAGIC_SNARFER #include "libwebidoidc-base64.x" #endif /* not SCM_MAGIC_SNARFER */ }