diff --git a/configure.ac b/configure.ac index f0f6962a..e8316158 100644 --- a/configure.ac +++ b/configure.ac @@ -461,6 +461,16 @@ AC_CHECK_LIB(m,atan2,[AC_DEFINE(HAVE_ATAN2,1,[have atan2() in libm.])]) PKG_CHECK_MODULES(REQUIRED, glib-2.0 >= 2.6 gmodule-2.0 gobject-2.0) PACKAGES_USED="$PACKAGES_USED glib-2.0 gmodule-2.0 gobject-2.0" +# from 2.12 we have g_base64_encode() +PKG_CHECK_MODULES(BASE64_ENCODE, glib-2.0 >= 2.12, + [AC_DEFINE(HAVE_BASE64_ENCODE,1, + [define if your glib has g_base64_encode().] + ) + ], + [: + ] +) + # from 2.14 we have g_option_context_get_help() PKG_CHECK_MODULES(CONTEXT_GET_HELP, glib-2.0 >= 2.14, [AC_DEFINE(HAVE_CONTEXT_GET_HELP,1, diff --git a/libvips/iofuncs/base64.c b/libvips/iofuncs/base64.c index 8398ff30..fe9dc2cf 100644 --- a/libvips/iofuncs/base64.c +++ b/libvips/iofuncs/base64.c @@ -90,6 +90,24 @@ Modified on: #include #include +#ifdef HAVE_BASE64_ENCODE + +/* glib 2.12 adds these. + */ +char * +vips__b64_encode( const unsigned char *data, size_t data_length ) +{ + return( g_base64_encode( data, data_length ) ); +} + +unsigned char * +vips__b64_decode( const char *buffer, size_t *data_length ) +{ + return( g_base64_decode( buffer, data_length ) ); +} + +#else /*!HAVE_BASE64_ENCODE*/ + static unsigned char b64_list[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; @@ -295,3 +313,5 @@ vips__b64_decode( const char *buffer, size_t *data_length ) return( data ); } + +#endif /*HAVE_BASE64_ENCODE*/