>From 911f6ecccd6ae323660acc66261a5d27de3e1e12 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 26 Dec 2014 09:32:06 -0800 Subject: [PATCH 1/2] Wrap dll functions more simply * decompress.c, gnutls.c, image.c, xml.c: If WINDOWSNT, use '#define FOO fn_FOO' to wrap dll functions, rather than the inverse when not WINDOWSNT. This isolates the fn_* business into the WINDOWSNT-specific section of the code, which makes it easier to maintain the generic code. * decompress.c (DEF_ZLIB_FN, LOAD_ZLIB_FN): * gnutls.c (DEF_GNUTLS_FN, LOAD_GNUTLS_FN): * image.c (DEF_IMGLIB_FN, LOAD_IMGLIB_FN): * xml.c (DEF_XML2_FN, LOAD_XML2_FN): Remove. All uses replaced by DEF_DLL_FN. * w32.h (DEF_DLL_FN, LOAD_DLL_FN): New macros. --- src/ChangeLog | 15 + src/decompress.c | 52 ++-- src/gnutls.c | 738 ++++++++++++++++++++++--------------------- src/image.c | 932 +++++++++++++++++++++++++++++-------------------------- src/w32.h | 13 + src/xml.c | 94 +++--- 6 files changed, 950 insertions(+), 894 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 72601fe..b0e5b09 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,18 @@ +2014-12-26 Paul Eggert + + Wrap dll functions more simply + * decompress.c, gnutls.c, image.c, xml.c: + If WINDOWSNT, use '#define FOO fn_FOO' to wrap dll functions, + rather than the inverse when not WINDOWSNT. This isolates the + fn_* business into the WINDOWSNT-specific section of the code, + which makes it easier to maintain the generic code. + * decompress.c (DEF_ZLIB_FN, LOAD_ZLIB_FN): + * gnutls.c (DEF_GNUTLS_FN, LOAD_GNUTLS_FN): + * image.c (DEF_IMGLIB_FN, LOAD_IMGLIB_FN): + * xml.c (DEF_XML2_FN, LOAD_XML2_FN): + Remove. All uses replaced by DEF_DLL_FN. + * w32.h (DEF_DLL_FN, LOAD_DLL_FN): New macros. + 2014-12-26 Eli Zaretskii * w32proc.c (sys_spawnve, get_lcid_callback): Use strcpy instead diff --git a/src/decompress.c b/src/decompress.c index 24ce852..28a94bc 100644 --- a/src/decompress.c +++ b/src/decompress.c @@ -31,26 +31,14 @@ along with GNU Emacs. If not, see . */ static Lisp_Object Qzlib_dll; #ifdef WINDOWSNT -#include -#include "w32.h" +# include +# include "w32.h" -/* Macro for defining functions that will be loaded from the zlib DLL. */ -#define DEF_ZLIB_FN(rettype,func,args) static rettype (FAR CDECL *fn_##func)args - -/* Macro for loading zlib functions from the library. */ -#define LOAD_ZLIB_FN(lib,func) { \ - fn_##func = (void *) GetProcAddress (lib, #func); \ - if (!fn_##func) return false; \ - } - -DEF_ZLIB_FN (int, inflateInit2_, - (z_streamp strm, int windowBits, const char *version, int stream_size)); - -DEF_ZLIB_FN (int, inflate, - (z_streamp strm, int flush)); - -DEF_ZLIB_FN (int, inflateEnd, - (z_streamp strm)); +DEF_DLL_FN (int, inflateInit2_, + (z_streamp strm, int windowBits, const char *version, + int stream_size)); +DEF_DLL_FN (int, inflate, (z_streamp strm, int flush)); +DEF_DLL_FN (int, inflateEnd, (z_streamp strm)); static bool zlib_initialized; @@ -62,20 +50,22 @@ init_zlib_functions (void) if (!library) return false; - LOAD_ZLIB_FN (library, inflateInit2_); - LOAD_ZLIB_FN (library, inflate); - LOAD_ZLIB_FN (library, inflateEnd); + LOAD_DLL_FN (library, inflateInit2_); + LOAD_DLL_FN (library, inflate); + LOAD_DLL_FN (library, inflateEnd); return true; } -#define fn_inflateInit2(strm, windowBits) \ - fn_inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream)) +# undef inflate +# undef inflateEnd +# undef inflateInit2_ -#else /* !WINDOWSNT */ +# define inflate fn_inflate +# define inflateEnd fn_inflateEnd +# define inflateInit2_ fn_inflateInit2_ -#define fn_inflateInit2 inflateInit2 -#define fn_inflate inflate -#define fn_inflateEnd inflateEnd +# define inflateInit2(strm, windowBits) \ + inflateInit2_ (strm, windowBits, ZLIB_VERSION, sizeof (z_stream)) #endif /* WINDOWSNT */ @@ -90,7 +80,7 @@ static void unwind_decompress (void *ddata) { struct decompress_unwind_data *data = ddata; - fn_inflateEnd (data->stream); + inflateEnd (data->stream); /* Delete any uncompressed data already inserted on error. */ if (data->start) @@ -167,7 +157,7 @@ This function can be called only in unibyte buffers. */) /* The magic number 32 apparently means "autodetect both the gzip and zlib formats" according to zlib.h. */ - if (fn_inflateInit2 (&stream, MAX_WBITS + 32) != Z_OK) + if (inflateInit2 (&stream, MAX_WBITS + 32) != Z_OK) return Qnil; unwind_data.start = iend; @@ -197,7 +187,7 @@ This function can be called only in unibyte buffers. */) stream.avail_in = avail_in; stream.next_out = GPT_ADDR; stream.avail_out = avail_out; - inflate_status = fn_inflate (&stream, Z_NO_FLUSH); + inflate_status = inflate (&stream, Z_NO_FLUSH); pos_byte += avail_in - stream.avail_in; decompressed = avail_out - stream.avail_out; insert_from_gap (decompressed, decompressed, 0); diff --git a/src/gnutls.c b/src/gnutls.c index bf9f132..b14998f 100644 --- a/src/gnutls.c +++ b/src/gnutls.c @@ -71,142 +71,133 @@ enum extra_peer_verification #ifdef WINDOWSNT -/* Macro for defining functions that will be loaded from the GnuTLS DLL. */ -#define DEF_GNUTLS_FN(rettype,func,args) static rettype (FAR CDECL *fn_##func)args - -/* Macro for loading GnuTLS functions from the library. */ -#define LOAD_GNUTLS_FN(lib,func) { \ - fn_##func = (void *) GetProcAddress (lib, #func); \ - if (!fn_##func) return 0; \ - } - -DEF_GNUTLS_FN (gnutls_alert_description_t, gnutls_alert_get, - (gnutls_session_t)); -DEF_GNUTLS_FN (const char *, gnutls_alert_get_name, - (gnutls_alert_description_t)); -DEF_GNUTLS_FN (int, gnutls_alert_send_appropriate, (gnutls_session_t, int)); -DEF_GNUTLS_FN (int, gnutls_anon_allocate_client_credentials, - (gnutls_anon_client_credentials_t *)); -DEF_GNUTLS_FN (void, gnutls_anon_free_client_credentials, - (gnutls_anon_client_credentials_t)); -DEF_GNUTLS_FN (int, gnutls_bye, (gnutls_session_t, gnutls_close_request_t)); -DEF_GNUTLS_FN (int, gnutls_certificate_allocate_credentials, - (gnutls_certificate_credentials_t *)); -DEF_GNUTLS_FN (void, gnutls_certificate_free_credentials, - (gnutls_certificate_credentials_t)); -DEF_GNUTLS_FN (const gnutls_datum_t *, gnutls_certificate_get_peers, - (gnutls_session_t, unsigned int *)); -DEF_GNUTLS_FN (void, gnutls_certificate_set_verify_flags, - (gnutls_certificate_credentials_t, unsigned int)); -DEF_GNUTLS_FN (int, gnutls_certificate_set_x509_crl_file, - (gnutls_certificate_credentials_t, const char *, - gnutls_x509_crt_fmt_t)); -DEF_GNUTLS_FN (int, gnutls_certificate_set_x509_key_file, - (gnutls_certificate_credentials_t, const char *, const char *, - gnutls_x509_crt_fmt_t)); -#if GNUTLS_VERSION_MAJOR + \ - (GNUTLS_VERSION_MINOR > 0 || GNUTLS_VERSION_PATCH >= 20) > 3 -DEF_GNUTLS_FN (int, gnutls_certificate_set_x509_system_trust, - (gnutls_certificate_credentials_t)); -#endif -DEF_GNUTLS_FN (int, gnutls_certificate_set_x509_trust_file, - (gnutls_certificate_credentials_t, const char *, - gnutls_x509_crt_fmt_t)); -DEF_GNUTLS_FN (gnutls_certificate_type_t, gnutls_certificate_type_get, - (gnutls_session_t)); -DEF_GNUTLS_FN (int, gnutls_certificate_verify_peers2, - (gnutls_session_t, unsigned int *)); -DEF_GNUTLS_FN (int, gnutls_credentials_set, - (gnutls_session_t, gnutls_credentials_type_t, void *)); -DEF_GNUTLS_FN (void, gnutls_deinit, (gnutls_session_t)); -DEF_GNUTLS_FN (void, gnutls_dh_set_prime_bits, - (gnutls_session_t, unsigned int)); -DEF_GNUTLS_FN (int, gnutls_dh_get_prime_bits, (gnutls_session_t)); -DEF_GNUTLS_FN (int, gnutls_error_is_fatal, (int)); -DEF_GNUTLS_FN (int, gnutls_global_init, (void)); -DEF_GNUTLS_FN (void, gnutls_global_set_log_function, (gnutls_log_func)); -#ifdef HAVE_GNUTLS3 -DEF_GNUTLS_FN (void, gnutls_global_set_audit_log_function, (gnutls_audit_log_func)); -#endif -DEF_GNUTLS_FN (void, gnutls_global_set_log_level, (int)); -DEF_GNUTLS_FN (void, gnutls_global_set_mem_functions, - (gnutls_alloc_function, gnutls_alloc_function, - gnutls_is_secure_function, gnutls_realloc_function, - gnutls_free_function)); -DEF_GNUTLS_FN (int, gnutls_handshake, (gnutls_session_t)); -DEF_GNUTLS_FN (int, gnutls_init, (gnutls_session_t *, gnutls_connection_end_t)); -DEF_GNUTLS_FN (int, gnutls_priority_set_direct, - (gnutls_session_t, const char *, const char **)); -DEF_GNUTLS_FN (size_t, gnutls_record_check_pending, (gnutls_session_t)); -DEF_GNUTLS_FN (ssize_t, gnutls_record_recv, (gnutls_session_t, void *, size_t)); -DEF_GNUTLS_FN (ssize_t, gnutls_record_send, - (gnutls_session_t, const void *, size_t)); -DEF_GNUTLS_FN (const char *, gnutls_strerror, (int)); -DEF_GNUTLS_FN (void, gnutls_transport_set_errno, (gnutls_session_t, int)); -DEF_GNUTLS_FN (const char *, gnutls_check_version, (const char *)); -DEF_GNUTLS_FN (void, gnutls_transport_set_lowat, (gnutls_session_t, int)); -DEF_GNUTLS_FN (void, gnutls_transport_set_ptr2, - (gnutls_session_t, gnutls_transport_ptr_t, - gnutls_transport_ptr_t)); -DEF_GNUTLS_FN (void, gnutls_transport_set_pull_function, - (gnutls_session_t, gnutls_pull_func)); -DEF_GNUTLS_FN (void, gnutls_transport_set_push_function, - (gnutls_session_t, gnutls_push_func)); -DEF_GNUTLS_FN (int, gnutls_x509_crt_check_hostname, - (gnutls_x509_crt_t, const char *)); -DEF_GNUTLS_FN (void, gnutls_x509_crt_deinit, (gnutls_x509_crt_t)); -DEF_GNUTLS_FN (int, gnutls_x509_crt_import, - (gnutls_x509_crt_t, const gnutls_datum_t *, - gnutls_x509_crt_fmt_t)); -DEF_GNUTLS_FN (int, gnutls_x509_crt_init, (gnutls_x509_crt_t *)); -DEF_GNUTLS_FN (int, gnutls_x509_crt_get_fingerprint, - (gnutls_x509_crt_t, - gnutls_digest_algorithm_t, void *, size_t *)); -DEF_GNUTLS_FN (int, gnutls_x509_crt_get_version, - (gnutls_x509_crt_t)); -DEF_GNUTLS_FN (int, gnutls_x509_crt_get_serial, - (gnutls_x509_crt_t, void *, size_t *)); -DEF_GNUTLS_FN (int, gnutls_x509_crt_get_issuer_dn, - (gnutls_x509_crt_t, char *, size_t *)); -DEF_GNUTLS_FN (time_t, gnutls_x509_crt_get_activation_time, - (gnutls_x509_crt_t)); -DEF_GNUTLS_FN (time_t, gnutls_x509_crt_get_expiration_time, - (gnutls_x509_crt_t)); -DEF_GNUTLS_FN (int, gnutls_x509_crt_get_dn, - (gnutls_x509_crt_t, char *, size_t *)); -DEF_GNUTLS_FN (int, gnutls_x509_crt_get_pk_algorithm, - (gnutls_x509_crt_t, unsigned int *)); -DEF_GNUTLS_FN (const char*, gnutls_pk_algorithm_get_name, - (gnutls_pk_algorithm_t)); -DEF_GNUTLS_FN (int, gnutls_pk_bits_to_sec_param, - (gnutls_pk_algorithm_t, unsigned int)); -DEF_GNUTLS_FN (int, gnutls_x509_crt_get_issuer_unique_id, - (gnutls_x509_crt_t, char *, size_t *)); -DEF_GNUTLS_FN (int, gnutls_x509_crt_get_subject_unique_id, - (gnutls_x509_crt_t, char *, size_t *)); -DEF_GNUTLS_FN (int, gnutls_x509_crt_get_signature_algorithm, - (gnutls_x509_crt_t)); -DEF_GNUTLS_FN (int, gnutls_x509_crt_get_signature, - (gnutls_x509_crt_t, char *, size_t *)); -DEF_GNUTLS_FN (int, gnutls_x509_crt_get_key_id, - (gnutls_x509_crt_t, unsigned int, - unsigned char *, size_t *_size)); -DEF_GNUTLS_FN (const char*, gnutls_sec_param_get_name, (gnutls_sec_param_t)); -DEF_GNUTLS_FN (const char*, gnutls_sign_get_name, (gnutls_sign_algorithm_t)); -DEF_GNUTLS_FN (int, gnutls_server_name_set, (gnutls_session_t, - gnutls_server_name_type_t, - const void *, size_t)); -DEF_GNUTLS_FN (gnutls_kx_algorithm_t, gnutls_kx_get, (gnutls_session_t)); -DEF_GNUTLS_FN (const char*, gnutls_kx_get_name, (gnutls_kx_algorithm_t)); -DEF_GNUTLS_FN (gnutls_protocol_t, gnutls_protocol_get_version, - (gnutls_session_t)); -DEF_GNUTLS_FN (const char*, gnutls_protocol_get_name, (gnutls_protocol_t)); -DEF_GNUTLS_FN (gnutls_cipher_algorithm_t, gnutls_cipher_get, - (gnutls_session_t)); -DEF_GNUTLS_FN (const char*, gnutls_cipher_get_name, - (gnutls_cipher_algorithm_t)); -DEF_GNUTLS_FN (gnutls_mac_algorithm_t, gnutls_mac_get, (gnutls_session_t)); -DEF_GNUTLS_FN (const char*, gnutls_mac_get_name, (gnutls_mac_algorithm_t)); +DEF_DLL_FN (gnutls_alert_description_t, gnutls_alert_get, + (gnutls_session_t)); +DEF_DLL_FN (const char *, gnutls_alert_get_name, + (gnutls_alert_description_t)); +DEF_DLL_FN (int, gnutls_alert_send_appropriate, (gnutls_session_t, int)); +DEF_DLL_FN (int, gnutls_anon_allocate_client_credentials, + (gnutls_anon_client_credentials_t *)); +DEF_DLL_FN (void, gnutls_anon_free_client_credentials, + (gnutls_anon_client_credentials_t)); +DEF_DLL_FN (int, gnutls_bye, (gnutls_session_t, gnutls_close_request_t)); +DEF_DLL_FN (int, gnutls_certificate_allocate_credentials, + (gnutls_certificate_credentials_t *)); +DEF_DLL_FN (void, gnutls_certificate_free_credentials, + (gnutls_certificate_credentials_t)); +DEF_DLL_FN (const gnutls_datum_t *, gnutls_certificate_get_peers, + (gnutls_session_t, unsigned int *)); +DEF_DLL_FN (void, gnutls_certificate_set_verify_flags, + (gnutls_certificate_credentials_t, unsigned int)); +DEF_DLL_FN (int, gnutls_certificate_set_x509_crl_file, + (gnutls_certificate_credentials_t, const char *, + gnutls_x509_crt_fmt_t)); +DEF_DLL_FN (int, gnutls_certificate_set_x509_key_file, + (gnutls_certificate_credentials_t, const char *, const char *, + gnutls_x509_crt_fmt_t)); +# if ((GNUTLS_VERSION_MAJOR \ + + (GNUTLS_VERSION_MINOR > 0 || GNUTLS_VERSION_PATCH >= 20)) \ + > 3) +DEF_DLL_FN (int, gnutls_certificate_set_x509_system_trust, + (gnutls_certificate_credentials_t)); +# endif +DEF_DLL_FN (int, gnutls_certificate_set_x509_trust_file, + (gnutls_certificate_credentials_t, const char *, + gnutls_x509_crt_fmt_t)); +DEF_DLL_FN (gnutls_certificate_type_t, gnutls_certificate_type_get, + (gnutls_session_t)); +DEF_DLL_FN (int, gnutls_certificate_verify_peers2, + (gnutls_session_t, unsigned int *)); +DEF_DLL_FN (int, gnutls_credentials_set, + (gnutls_session_t, gnutls_credentials_type_t, void *)); +DEF_DLL_FN (void, gnutls_deinit, (gnutls_session_t)); +DEF_DLL_FN (void, gnutls_dh_set_prime_bits, + (gnutls_session_t, unsigned int)); +DEF_DLL_FN (int, gnutls_dh_get_prime_bits, (gnutls_session_t)); +DEF_DLL_FN (int, gnutls_error_is_fatal, (int)); +DEF_DLL_FN (int, gnutls_global_init, (void)); +DEF_DLL_FN (void, gnutls_global_set_log_function, (gnutls_log_func)); +# ifdef HAVE_GNUTLS3 +DEF_DLL_FN (void, gnutls_global_set_audit_log_function, (gnutls_audit_log_func)); +# endif +DEF_DLL_FN (void, gnutls_global_set_log_level, (int)); +DEF_DLL_FN (void, gnutls_global_set_mem_functions, + (gnutls_alloc_function, gnutls_alloc_function, + gnutls_is_secure_function, gnutls_realloc_function, + gnutls_free_function)); +DEF_DLL_FN (int, gnutls_handshake, (gnutls_session_t)); +DEF_DLL_FN (int, gnutls_init, (gnutls_session_t *, gnutls_connection_end_t)); +DEF_DLL_FN (int, gnutls_priority_set_direct, + (gnutls_session_t, const char *, const char **)); +DEF_DLL_FN (size_t, gnutls_record_check_pending, (gnutls_session_t)); +DEF_DLL_FN (ssize_t, gnutls_record_recv, (gnutls_session_t, void *, size_t)); +DEF_DLL_FN (ssize_t, gnutls_record_send, + (gnutls_session_t, const void *, size_t)); +DEF_DLL_FN (const char *, gnutls_strerror, (int)); +DEF_DLL_FN (void, gnutls_transport_set_errno, (gnutls_session_t, int)); +DEF_DLL_FN (const char *, gnutls_check_version, (const char *)); +DEF_DLL_FN (void, gnutls_transport_set_lowat, (gnutls_session_t, int)); +DEF_DLL_FN (void, gnutls_transport_set_ptr2, + (gnutls_session_t, gnutls_transport_ptr_t, + gnutls_transport_ptr_t)); +DEF_DLL_FN (void, gnutls_transport_set_pull_function, + (gnutls_session_t, gnutls_pull_func)); +DEF_DLL_FN (void, gnutls_transport_set_push_function, + (gnutls_session_t, gnutls_push_func)); +DEF_DLL_FN (int, gnutls_x509_crt_check_hostname, + (gnutls_x509_crt_t, const char *)); +DEF_DLL_FN (void, gnutls_x509_crt_deinit, (gnutls_x509_crt_t)); +DEF_DLL_FN (int, gnutls_x509_crt_import, + (gnutls_x509_crt_t, const gnutls_datum_t *, + gnutls_x509_crt_fmt_t)); +DEF_DLL_FN (int, gnutls_x509_crt_init, (gnutls_x509_crt_t *)); +DEF_DLL_FN (int, gnutls_x509_crt_get_fingerprint, + (gnutls_x509_crt_t, + gnutls_digest_algorithm_t, void *, size_t *)); +DEF_DLL_FN (int, gnutls_x509_crt_get_version, + (gnutls_x509_crt_t)); +DEF_DLL_FN (int, gnutls_x509_crt_get_serial, + (gnutls_x509_crt_t, void *, size_t *)); +DEF_DLL_FN (int, gnutls_x509_crt_get_issuer_dn, + (gnutls_x509_crt_t, char *, size_t *)); +DEF_DLL_FN (time_t, gnutls_x509_crt_get_activation_time, + (gnutls_x509_crt_t)); +DEF_DLL_FN (time_t, gnutls_x509_crt_get_expiration_time, + (gnutls_x509_crt_t)); +DEF_DLL_FN (int, gnutls_x509_crt_get_dn, + (gnutls_x509_crt_t, char *, size_t *)); +DEF_DLL_FN (int, gnutls_x509_crt_get_pk_algorithm, + (gnutls_x509_crt_t, unsigned int *)); +DEF_DLL_FN (const char*, gnutls_pk_algorithm_get_name, + (gnutls_pk_algorithm_t)); +DEF_DLL_FN (int, gnutls_pk_bits_to_sec_param, + (gnutls_pk_algorithm_t, unsigned int)); +DEF_DLL_FN (int, gnutls_x509_crt_get_issuer_unique_id, + (gnutls_x509_crt_t, char *, size_t *)); +DEF_DLL_FN (int, gnutls_x509_crt_get_subject_unique_id, + (gnutls_x509_crt_t, char *, size_t *)); +DEF_DLL_FN (int, gnutls_x509_crt_get_signature_algorithm, + (gnutls_x509_crt_t)); +DEF_DLL_FN (int, gnutls_x509_crt_get_signature, + (gnutls_x509_crt_t, char *, size_t *)); +DEF_DLL_FN (int, gnutls_x509_crt_get_key_id, + (gnutls_x509_crt_t, unsigned int, unsigned char *, size_t *_size)); +DEF_DLL_FN (const char*, gnutls_sec_param_get_name, (gnutls_sec_param_t)); +DEF_DLL_FN (const char*, gnutls_sign_get_name, (gnutls_sign_algorithm_t)); +DEF_DLL_FN (int, gnutls_server_name_set, + (gnutls_session_t, gnutls_server_name_type_t, + const void *, size_t)); +DEF_DLL_FN (gnutls_kx_algorithm_t, gnutls_kx_get, (gnutls_session_t)); +DEF_DLL_FN (const char*, gnutls_kx_get_name, (gnutls_kx_algorithm_t)); +DEF_DLL_FN (gnutls_protocol_t, gnutls_protocol_get_version, + (gnutls_session_t)); +DEF_DLL_FN (const char*, gnutls_protocol_get_name, (gnutls_protocol_t)); +DEF_DLL_FN (gnutls_cipher_algorithm_t, gnutls_cipher_get, + (gnutls_session_t)); +DEF_DLL_FN (const char*, gnutls_cipher_get_name, + (gnutls_cipher_algorithm_t)); +DEF_DLL_FN (gnutls_mac_algorithm_t, gnutls_mac_get, (gnutls_session_t)); +DEF_DLL_FN (const char*, gnutls_mac_get_name, (gnutls_mac_algorithm_t)); static bool @@ -221,83 +212,84 @@ init_gnutls_functions (void) return 0; } - LOAD_GNUTLS_FN (library, gnutls_alert_get); - LOAD_GNUTLS_FN (library, gnutls_alert_get_name); - LOAD_GNUTLS_FN (library, gnutls_alert_send_appropriate); - LOAD_GNUTLS_FN (library, gnutls_anon_allocate_client_credentials); - LOAD_GNUTLS_FN (library, gnutls_anon_free_client_credentials); - LOAD_GNUTLS_FN (library, gnutls_bye); - LOAD_GNUTLS_FN (library, gnutls_certificate_allocate_credentials); - LOAD_GNUTLS_FN (library, gnutls_certificate_free_credentials); - LOAD_GNUTLS_FN (library, gnutls_certificate_get_peers); - LOAD_GNUTLS_FN (library, gnutls_certificate_set_verify_flags); - LOAD_GNUTLS_FN (library, gnutls_certificate_set_x509_crl_file); - LOAD_GNUTLS_FN (library, gnutls_certificate_set_x509_key_file); -#if GNUTLS_VERSION_MAJOR + \ - (GNUTLS_VERSION_MINOR > 0 || GNUTLS_VERSION_PATCH >= 20) > 3 - LOAD_GNUTLS_FN (library, gnutls_certificate_set_x509_system_trust); -#endif - LOAD_GNUTLS_FN (library, gnutls_certificate_set_x509_trust_file); - LOAD_GNUTLS_FN (library, gnutls_certificate_type_get); - LOAD_GNUTLS_FN (library, gnutls_certificate_verify_peers2); - LOAD_GNUTLS_FN (library, gnutls_credentials_set); - LOAD_GNUTLS_FN (library, gnutls_deinit); - LOAD_GNUTLS_FN (library, gnutls_dh_set_prime_bits); - LOAD_GNUTLS_FN (library, gnutls_dh_get_prime_bits); - LOAD_GNUTLS_FN (library, gnutls_error_is_fatal); - LOAD_GNUTLS_FN (library, gnutls_global_init); - LOAD_GNUTLS_FN (library, gnutls_global_set_log_function); -#ifdef HAVE_GNUTLS3 - LOAD_GNUTLS_FN (library, gnutls_global_set_audit_log_function); -#endif - LOAD_GNUTLS_FN (library, gnutls_global_set_log_level); - LOAD_GNUTLS_FN (library, gnutls_global_set_mem_functions); - LOAD_GNUTLS_FN (library, gnutls_handshake); - LOAD_GNUTLS_FN (library, gnutls_init); - LOAD_GNUTLS_FN (library, gnutls_priority_set_direct); - LOAD_GNUTLS_FN (library, gnutls_record_check_pending); - LOAD_GNUTLS_FN (library, gnutls_record_recv); - LOAD_GNUTLS_FN (library, gnutls_record_send); - LOAD_GNUTLS_FN (library, gnutls_strerror); - LOAD_GNUTLS_FN (library, gnutls_transport_set_errno); - LOAD_GNUTLS_FN (library, gnutls_check_version); + LOAD_DLL_FN (library, gnutls_alert_get); + LOAD_DLL_FN (library, gnutls_alert_get_name); + LOAD_DLL_FN (library, gnutls_alert_send_appropriate); + LOAD_DLL_FN (library, gnutls_anon_allocate_client_credentials); + LOAD_DLL_FN (library, gnutls_anon_free_client_credentials); + LOAD_DLL_FN (library, gnutls_bye); + LOAD_DLL_FN (library, gnutls_certificate_allocate_credentials); + LOAD_DLL_FN (library, gnutls_certificate_free_credentials); + LOAD_DLL_FN (library, gnutls_certificate_get_peers); + LOAD_DLL_FN (library, gnutls_certificate_set_verify_flags); + LOAD_DLL_FN (library, gnutls_certificate_set_x509_crl_file); + LOAD_DLL_FN (library, gnutls_certificate_set_x509_key_file); +# if ((GNUTLS_VERSION_MAJOR \ + + (GNUTLS_VERSION_MINOR > 0 || GNUTLS_VERSION_PATCH >= 20)) \ + > 3) + LOAD_DLL_FN (library, gnutls_certificate_set_x509_system_trust); +# endif + LOAD_DLL_FN (library, gnutls_certificate_set_x509_trust_file); + LOAD_DLL_FN (library, gnutls_certificate_type_get); + LOAD_DLL_FN (library, gnutls_certificate_verify_peers2); + LOAD_DLL_FN (library, gnutls_credentials_set); + LOAD_DLL_FN (library, gnutls_deinit); + LOAD_DLL_FN (library, gnutls_dh_set_prime_bits); + LOAD_DLL_FN (library, gnutls_dh_get_prime_bits); + LOAD_DLL_FN (library, gnutls_error_is_fatal); + LOAD_DLL_FN (library, gnutls_global_init); + LOAD_DLL_FN (library, gnutls_global_set_log_function); +# ifdef HAVE_GNUTLS3 + LOAD_DLL_FN (library, gnutls_global_set_audit_log_function); +# endif + LOAD_DLL_FN (library, gnutls_global_set_log_level); + LOAD_DLL_FN (library, gnutls_global_set_mem_functions); + LOAD_DLL_FN (library, gnutls_handshake); + LOAD_DLL_FN (library, gnutls_init); + LOAD_DLL_FN (library, gnutls_priority_set_direct); + LOAD_DLL_FN (library, gnutls_record_check_pending); + LOAD_DLL_FN (library, gnutls_record_recv); + LOAD_DLL_FN (library, gnutls_record_send); + LOAD_DLL_FN (library, gnutls_strerror); + LOAD_DLL_FN (library, gnutls_transport_set_errno); + LOAD_DLL_FN (library, gnutls_check_version); /* We don't need to call gnutls_transport_set_lowat in GnuTLS 2.11.1 and later, and the function was removed entirely in 3.0.0. */ if (!fn_gnutls_check_version ("2.11.1")) - LOAD_GNUTLS_FN (library, gnutls_transport_set_lowat); - LOAD_GNUTLS_FN (library, gnutls_transport_set_ptr2); - LOAD_GNUTLS_FN (library, gnutls_transport_set_pull_function); - LOAD_GNUTLS_FN (library, gnutls_transport_set_push_function); - LOAD_GNUTLS_FN (library, gnutls_x509_crt_check_hostname); - LOAD_GNUTLS_FN (library, gnutls_x509_crt_deinit); - LOAD_GNUTLS_FN (library, gnutls_x509_crt_import); - LOAD_GNUTLS_FN (library, gnutls_x509_crt_init); - LOAD_GNUTLS_FN (library, gnutls_x509_crt_get_fingerprint); - LOAD_GNUTLS_FN (library, gnutls_x509_crt_get_version); - LOAD_GNUTLS_FN (library, gnutls_x509_crt_get_serial); - LOAD_GNUTLS_FN (library, gnutls_x509_crt_get_issuer_dn); - LOAD_GNUTLS_FN (library, gnutls_x509_crt_get_activation_time); - LOAD_GNUTLS_FN (library, gnutls_x509_crt_get_expiration_time); - LOAD_GNUTLS_FN (library, gnutls_x509_crt_get_dn); - LOAD_GNUTLS_FN (library, gnutls_x509_crt_get_pk_algorithm); - LOAD_GNUTLS_FN (library, gnutls_pk_algorithm_get_name); - LOAD_GNUTLS_FN (library, gnutls_pk_bits_to_sec_param); - LOAD_GNUTLS_FN (library, gnutls_x509_crt_get_issuer_unique_id); - LOAD_GNUTLS_FN (library, gnutls_x509_crt_get_subject_unique_id); - LOAD_GNUTLS_FN (library, gnutls_x509_crt_get_signature_algorithm); - LOAD_GNUTLS_FN (library, gnutls_x509_crt_get_signature); - LOAD_GNUTLS_FN (library, gnutls_x509_crt_get_key_id); - LOAD_GNUTLS_FN (library, gnutls_sec_param_get_name); - LOAD_GNUTLS_FN (library, gnutls_sign_get_name); - LOAD_GNUTLS_FN (library, gnutls_server_name_set); - LOAD_GNUTLS_FN (library, gnutls_kx_get); - LOAD_GNUTLS_FN (library, gnutls_kx_get_name); - LOAD_GNUTLS_FN (library, gnutls_protocol_get_version); - LOAD_GNUTLS_FN (library, gnutls_protocol_get_name); - LOAD_GNUTLS_FN (library, gnutls_cipher_get); - LOAD_GNUTLS_FN (library, gnutls_cipher_get_name); - LOAD_GNUTLS_FN (library, gnutls_mac_get); - LOAD_GNUTLS_FN (library, gnutls_mac_get_name); + LOAD_DLL_FN (library, gnutls_transport_set_lowat); + LOAD_DLL_FN (library, gnutls_transport_set_ptr2); + LOAD_DLL_FN (library, gnutls_transport_set_pull_function); + LOAD_DLL_FN (library, gnutls_transport_set_push_function); + LOAD_DLL_FN (library, gnutls_x509_crt_check_hostname); + LOAD_DLL_FN (library, gnutls_x509_crt_deinit); + LOAD_DLL_FN (library, gnutls_x509_crt_import); + LOAD_DLL_FN (library, gnutls_x509_crt_init); + LOAD_DLL_FN (library, gnutls_x509_crt_get_fingerprint); + LOAD_DLL_FN (library, gnutls_x509_crt_get_version); + LOAD_DLL_FN (library, gnutls_x509_crt_get_serial); + LOAD_DLL_FN (library, gnutls_x509_crt_get_issuer_dn); + LOAD_DLL_FN (library, gnutls_x509_crt_get_activation_time); + LOAD_DLL_FN (library, gnutls_x509_crt_get_expiration_time); + LOAD_DLL_FN (library, gnutls_x509_crt_get_dn); + LOAD_DLL_FN (library, gnutls_x509_crt_get_pk_algorithm); + LOAD_DLL_FN (library, gnutls_pk_algorithm_get_name); + LOAD_DLL_FN (library, gnutls_pk_bits_to_sec_param); + LOAD_DLL_FN (library, gnutls_x509_crt_get_issuer_unique_id); + LOAD_DLL_FN (library, gnutls_x509_crt_get_subject_unique_id); + LOAD_DLL_FN (library, gnutls_x509_crt_get_signature_algorithm); + LOAD_DLL_FN (library, gnutls_x509_crt_get_signature); + LOAD_DLL_FN (library, gnutls_x509_crt_get_key_id); + LOAD_DLL_FN (library, gnutls_sec_param_get_name); + LOAD_DLL_FN (library, gnutls_sign_get_name); + LOAD_DLL_FN (library, gnutls_server_name_set); + LOAD_DLL_FN (library, gnutls_kx_get); + LOAD_DLL_FN (library, gnutls_kx_get_name); + LOAD_DLL_FN (library, gnutls_protocol_get_version); + LOAD_DLL_FN (library, gnutls_protocol_get_name); + LOAD_DLL_FN (library, gnutls_cipher_get); + LOAD_DLL_FN (library, gnutls_cipher_get_name); + LOAD_DLL_FN (library, gnutls_mac_get); + LOAD_DLL_FN (library, gnutls_mac_get_name); max_log_level = global_gnutls_log_level; @@ -310,78 +302,77 @@ init_gnutls_functions (void) return 1; } -#else /* !WINDOWSNT */ - -#define fn_gnutls_alert_get gnutls_alert_get -#define fn_gnutls_alert_get_name gnutls_alert_get_name -#define fn_gnutls_alert_send_appropriate gnutls_alert_send_appropriate -#define fn_gnutls_anon_allocate_client_credentials gnutls_anon_allocate_client_credentials -#define fn_gnutls_anon_free_client_credentials gnutls_anon_free_client_credentials -#define fn_gnutls_bye gnutls_bye -#define fn_gnutls_certificate_allocate_credentials gnutls_certificate_allocate_credentials -#define fn_gnutls_certificate_free_credentials gnutls_certificate_free_credentials -#define fn_gnutls_certificate_get_peers gnutls_certificate_get_peers -#define fn_gnutls_certificate_set_verify_flags gnutls_certificate_set_verify_flags -#define fn_gnutls_certificate_set_x509_crl_file gnutls_certificate_set_x509_crl_file -#define fn_gnutls_certificate_set_x509_key_file gnutls_certificate_set_x509_key_file -#if GNUTLS_VERSION_MAJOR + \ - (GNUTLS_VERSION_MINOR > 0 || GNUTLS_VERSION_PATCH >= 20) > 3 -#define fn_gnutls_certificate_set_x509_system_trust gnutls_certificate_set_x509_system_trust -#endif -#define fn_gnutls_certificate_set_x509_trust_file gnutls_certificate_set_x509_trust_file -#define fn_gnutls_certificate_type_get gnutls_certificate_type_get -#define fn_gnutls_certificate_verify_peers2 gnutls_certificate_verify_peers2 -#define fn_gnutls_cipher_get gnutls_cipher_get -#define fn_gnutls_cipher_get_name gnutls_cipher_get_name -#define fn_gnutls_credentials_set gnutls_credentials_set -#define fn_gnutls_deinit gnutls_deinit -#define fn_gnutls_dh_get_prime_bits gnutls_dh_get_prime_bits -#define fn_gnutls_dh_set_prime_bits gnutls_dh_set_prime_bits -#define fn_gnutls_error_is_fatal gnutls_error_is_fatal -#define fn_gnutls_global_init gnutls_global_init -#ifdef HAVE_GNUTLS3 -#define fn_gnutls_global_set_audit_log_function gnutls_global_set_audit_log_function +# define gnutls_alert_get fn_gnutls_alert_get +# define gnutls_alert_get_name fn_gnutls_alert_get_name +# define gnutls_alert_send_appropriate fn_gnutls_alert_send_appropriate +# define gnutls_anon_allocate_client_credentials fn_gnutls_anon_allocate_client_credentials +# define gnutls_anon_free_client_credentials fn_gnutls_anon_free_client_credentials +# define gnutls_bye fn_gnutls_bye +# define gnutls_certificate_allocate_credentials fn_gnutls_certificate_allocate_credentials +# define gnutls_certificate_free_credentials fn_gnutls_certificate_free_credentials +# define gnutls_certificate_get_peers fn_gnutls_certificate_get_peers +# define gnutls_certificate_set_verify_flags fn_gnutls_certificate_set_verify_flags +# define gnutls_certificate_set_x509_crl_file fn_gnutls_certificate_set_x509_crl_file +# define gnutls_certificate_set_x509_key_file fn_gnutls_certificate_set_x509_key_file +# define gnutls_certificate_set_x509_system_trust fn_gnutls_certificate_set_x509_system_trust +# define gnutls_certificate_set_x509_trust_file fn_gnutls_certificate_set_x509_trust_file +# define gnutls_certificate_type_get fn_gnutls_certificate_type_get +# define gnutls_certificate_verify_peers2 fn_gnutls_certificate_verify_peers2 +# define gnutls_check_version fn_gnutls_check_version +# define gnutls_cipher_get fn_gnutls_cipher_get +# define gnutls_cipher_get_name fn_gnutls_cipher_get_name +# define gnutls_credentials_set fn_gnutls_credentials_set +# define gnutls_deinit fn_gnutls_deinit +# define gnutls_dh_get_prime_bits fn_gnutls_dh_get_prime_bits +# define gnutls_dh_set_prime_bits fn_gnutls_dh_set_prime_bits +# define gnutls_error_is_fatal fn_gnutls_error_is_fatal +# define gnutls_global_init fn_gnutls_global_init +# define gnutls_global_set_audit_log_function fn_gnutls_global_set_audit_log_function +# define gnutls_global_set_log_function fn_gnutls_global_set_log_function +# define gnutls_global_set_log_level fn_gnutls_global_set_log_level +# define gnutls_global_set_mem_functions fn_gnutls_global_set_mem_functions +# define gnutls_handshake fn_gnutls_handshake +# define gnutls_init fn_gnutls_init +# define gnutls_kx_get fn_gnutls_kx_get +# define gnutls_kx_get_name fn_gnutls_kx_get_name +# define gnutls_mac_get fn_gnutls_mac_get +# define gnutls_mac_get_name fn_gnutls_mac_get_name +# define gnutls_pk_algorithm_get_name fn_gnutls_pk_algorithm_get_name +# define gnutls_pk_bits_to_sec_param fn_gnutls_pk_bits_to_sec_param +# define gnutls_priority_set_direct fn_gnutls_priority_set_direct +# define gnutls_protocol_get_name fn_gnutls_protocol_get_name +# define gnutls_protocol_get_version fn_gnutls_protocol_get_version +# define gnutls_record_check_pending fn_gnutls_record_check_pending +# define gnutls_record_recv fn_gnutls_record_recv +# define gnutls_record_send fn_gnutls_record_send +# define gnutls_sec_param_get_name fn_gnutls_sec_param_get_name +# define gnutls_server_name_set fn_gnutls_server_name_set +# define gnutls_sign_get_name fn_gnutls_sign_get_name +# define gnutls_strerror fn_gnutls_strerror +# define gnutls_transport_set_errno fn_gnutls_transport_set_errno +# define gnutls_transport_set_lowat fn_gnutls_transport_set_lowat +# define gnutls_transport_set_ptr2 fn_gnutls_transport_set_ptr2 +# define gnutls_transport_set_pull_function fn_gnutls_transport_set_pull_function +# define gnutls_transport_set_push_function fn_gnutls_transport_set_push_function +# define gnutls_x509_crt_check_hostname fn_gnutls_x509_crt_check_hostname +# define gnutls_x509_crt_deinit fn_gnutls_x509_crt_deinit +# define gnutls_x509_crt_get_activation_time fn_gnutls_x509_crt_get_activation_time +# define gnutls_x509_crt_get_dn fn_gnutls_x509_crt_get_dn +# define gnutls_x509_crt_get_expiration_time fn_gnutls_x509_crt_get_expiration_time +# define gnutls_x509_crt_get_fingerprint fn_gnutls_x509_crt_get_fingerprint +# define gnutls_x509_crt_get_issuer_dn fn_gnutls_x509_crt_get_issuer_dn +# define gnutls_x509_crt_get_issuer_unique_id fn_gnutls_x509_crt_get_issuer_unique_id +# define gnutls_x509_crt_get_key_id fn_gnutls_x509_crt_get_key_id +# define gnutls_x509_crt_get_pk_algorithm fn_gnutls_x509_crt_get_pk_algorithm +# define gnutls_x509_crt_get_serial fn_gnutls_x509_crt_get_serial +# define gnutls_x509_crt_get_signature fn_gnutls_x509_crt_get_signature +# define gnutls_x509_crt_get_signature_algorithm fn_gnutls_x509_crt_get_signature_algorithm +# define gnutls_x509_crt_get_subject_unique_id fn_gnutls_x509_crt_get_subject_unique_id +# define gnutls_x509_crt_get_version fn_gnutls_x509_crt_get_version +# define gnutls_x509_crt_import fn_gnutls_x509_crt_import +# define gnutls_x509_crt_init fn_gnutls_x509_crt_init + #endif -#define fn_gnutls_global_set_log_function gnutls_global_set_log_function -#define fn_gnutls_global_set_log_level gnutls_global_set_log_level -#define fn_gnutls_global_set_mem_functions gnutls_global_set_mem_functions -#define fn_gnutls_handshake gnutls_handshake -#define fn_gnutls_init gnutls_init -#define fn_gnutls_kx_get gnutls_kx_get -#define fn_gnutls_kx_get_name gnutls_kx_get_name -#define fn_gnutls_mac_get gnutls_mac_get -#define fn_gnutls_mac_get_name gnutls_mac_get_name -#define fn_gnutls_pk_algorithm_get_name gnutls_pk_algorithm_get_name -#define fn_gnutls_pk_bits_to_sec_param gnutls_pk_bits_to_sec_param -#define fn_gnutls_priority_set_direct gnutls_priority_set_direct -#define fn_gnutls_protocol_get_name gnutls_protocol_get_name -#define fn_gnutls_protocol_get_version gnutls_protocol_get_version -#define fn_gnutls_record_check_pending gnutls_record_check_pending -#define fn_gnutls_record_recv gnutls_record_recv -#define fn_gnutls_record_send gnutls_record_send -#define fn_gnutls_sec_param_get_name gnutls_sec_param_get_name -#define fn_gnutls_server_name_set gnutls_server_name_set -#define fn_gnutls_sign_get_name gnutls_sign_get_name -#define fn_gnutls_strerror gnutls_strerror -#define fn_gnutls_transport_set_ptr2 gnutls_transport_set_ptr2 -#define fn_gnutls_x509_crt_check_hostname gnutls_x509_crt_check_hostname -#define fn_gnutls_x509_crt_deinit gnutls_x509_crt_deinit -#define fn_gnutls_x509_crt_get_activation_time gnutls_x509_crt_get_activation_time -#define fn_gnutls_x509_crt_get_dn gnutls_x509_crt_get_dn -#define fn_gnutls_x509_crt_get_expiration_time gnutls_x509_crt_get_expiration_time -#define fn_gnutls_x509_crt_get_fingerprint gnutls_x509_crt_get_fingerprint -#define fn_gnutls_x509_crt_get_issuer_dn gnutls_x509_crt_get_issuer_dn -#define fn_gnutls_x509_crt_get_issuer_unique_id gnutls_x509_crt_get_issuer_unique_id -#define fn_gnutls_x509_crt_get_key_id gnutls_x509_crt_get_key_id -#define fn_gnutls_x509_crt_get_pk_algorithm gnutls_x509_crt_get_pk_algorithm -#define fn_gnutls_x509_crt_get_serial gnutls_x509_crt_get_serial -#define fn_gnutls_x509_crt_get_signature_algorithm gnutls_x509_crt_get_signature_algorithm -#define fn_gnutls_x509_crt_get_subject_unique_id gnutls_x509_crt_get_subject_unique_id -#define fn_gnutls_x509_crt_get_version gnutls_x509_crt_get_version -#define fn_gnutls_x509_crt_import gnutls_x509_crt_import -#define fn_gnutls_x509_crt_init gnutls_x509_crt_init - -#endif /* !WINDOWSNT */ #ifdef HAVE_GNUTLS3 @@ -432,11 +423,11 @@ emacs_gnutls_handshake (struct Lisp_Process *proc) /* On W32 we cannot transfer socket handles between different runtime libraries, so we tell GnuTLS to use our special push/pull functions. */ - fn_gnutls_transport_set_ptr2 (state, - (gnutls_transport_ptr_t) proc, - (gnutls_transport_ptr_t) proc); - fn_gnutls_transport_set_push_function (state, &emacs_gnutls_push); - fn_gnutls_transport_set_pull_function (state, &emacs_gnutls_pull); + gnutls_transport_set_ptr2 (state, + (gnutls_transport_ptr_t) proc, + (gnutls_transport_ptr_t) proc); + gnutls_transport_set_push_function (state, &emacs_gnutls_push); + gnutls_transport_set_pull_function (state, &emacs_gnutls_pull); /* For non blocking sockets or other custom made pull/push functions the gnutls_transport_set_lowat must be called, with @@ -449,15 +440,15 @@ emacs_gnutls_handshake (struct Lisp_Process *proc) zero by default in version 2.11.1, and the function gnutls_transport_set_lowat was removed from the library in version 2.99.0. */ - if (!fn_gnutls_check_version ("2.11.1")) - fn_gnutls_transport_set_lowat (state, 0); + if (!gnutls_check_version ("2.11.1")) + gnutls_transport_set_lowat (state, 0); #else /* This is how GnuTLS takes sockets: as file descriptors passed in. For an Emacs process socket, infd and outfd are the same but we use this two-argument version for clarity. */ - fn_gnutls_transport_set_ptr2 (state, - (void *) (intptr_t) proc->infd, - (void *) (intptr_t) proc->outfd); + gnutls_transport_set_ptr2 (state, + (void *) (intptr_t) proc->infd, + (void *) (intptr_t) proc->outfd); #endif proc->gnutls_initstage = GNUTLS_STAGE_TRANSPORT_POINTERS_SET; @@ -465,11 +456,11 @@ emacs_gnutls_handshake (struct Lisp_Process *proc) do { - ret = fn_gnutls_handshake (state); + ret = gnutls_handshake (state); emacs_gnutls_handle_error (state, ret); QUIT; } - while (ret < 0 && fn_gnutls_error_is_fatal (ret) == 0); + while (ret < 0 && gnutls_error_is_fatal (ret) == 0); proc->gnutls_initstage = GNUTLS_STAGE_HANDSHAKE_TRIED; @@ -480,7 +471,7 @@ emacs_gnutls_handshake (struct Lisp_Process *proc) } else { - fn_gnutls_alert_send_appropriate (state, ret); + gnutls_alert_send_appropriate (state, ret); } return ret; } @@ -488,14 +479,14 @@ emacs_gnutls_handshake (struct Lisp_Process *proc) ptrdiff_t emacs_gnutls_record_check_pending (gnutls_session_t state) { - return fn_gnutls_record_check_pending (state); + return gnutls_record_check_pending (state); } #ifdef WINDOWSNT void emacs_gnutls_transport_set_errno (gnutls_session_t state, int err) { - fn_gnutls_transport_set_errno (state, err); + gnutls_transport_set_errno (state, err); } #endif @@ -516,7 +507,7 @@ emacs_gnutls_write (struct Lisp_Process *proc, const char *buf, ptrdiff_t nbyte) while (nbyte > 0) { - rtnval = fn_gnutls_record_send (state, buf, nbyte); + rtnval = gnutls_record_send (state, buf, nbyte); if (rtnval < 0) { @@ -568,7 +559,7 @@ emacs_gnutls_read (struct Lisp_Process *proc, char *buf, ptrdiff_t nbyte) proc->gnutls_handshakes_tried = 0; return 0; } - rtnval = fn_gnutls_record_recv (state, buf, nbyte); + rtnval = gnutls_record_recv (state, buf, nbyte); if (rtnval >= 0) return rtnval; else if (rtnval == GNUTLS_E_UNEXPECTED_PACKET_LENGTH) @@ -601,11 +592,11 @@ emacs_gnutls_handle_error (gnutls_session_t session, int err) /* TODO: use gnutls-error-fatalp and gnutls-error-string. */ - str = fn_gnutls_strerror (err); + str = gnutls_strerror (err); if (!str) str = "unknown"; - if (fn_gnutls_error_is_fatal (err)) + if (gnutls_error_is_fatal (err)) { ret = 0; GNUTLS_LOG2 (1, max_log_level, "fatal error:", str); @@ -632,9 +623,9 @@ emacs_gnutls_handle_error (gnutls_session_t session, int err) if (err == GNUTLS_E_WARNING_ALERT_RECEIVED || err == GNUTLS_E_FATAL_ALERT_RECEIVED) { - int alert = fn_gnutls_alert_get (session); + int alert = gnutls_alert_get (session); int level = (err == GNUTLS_E_FATAL_ALERT_RECEIVED) ? 0 : 1; - str = fn_gnutls_alert_get_name (alert); + str = gnutls_alert_get_name (alert); if (!str) str = "unknown"; @@ -680,20 +671,20 @@ emacs_gnutls_deinit (Lisp_Object proc) if (XPROCESS (proc)->gnutls_x509_cred) { GNUTLS_LOG (2, log_level, "Deallocating x509 credentials"); - fn_gnutls_certificate_free_credentials (XPROCESS (proc)->gnutls_x509_cred); + gnutls_certificate_free_credentials (XPROCESS (proc)->gnutls_x509_cred); XPROCESS (proc)->gnutls_x509_cred = NULL; } if (XPROCESS (proc)->gnutls_anon_cred) { GNUTLS_LOG (2, log_level, "Deallocating anon credentials"); - fn_gnutls_anon_free_client_credentials (XPROCESS (proc)->gnutls_anon_cred); + gnutls_anon_free_client_credentials (XPROCESS (proc)->gnutls_anon_cred); XPROCESS (proc)->gnutls_anon_cred = NULL; } if (XPROCESS (proc)->gnutls_state) { - fn_gnutls_deinit (XPROCESS (proc)->gnutls_state); + gnutls_deinit (XPROCESS (proc)->gnutls_state); XPROCESS (proc)->gnutls_state = NULL; if (GNUTLS_INITSTAGE (proc) >= GNUTLS_STAGE_INIT) GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_INIT - 1; @@ -750,7 +741,7 @@ Usage: (gnutls-error-fatalp ERROR) */) if (! TYPE_RANGED_INTEGERP (int, err)) error ("Not an error symbol or code"); - if (0 == fn_gnutls_error_is_fatal (XINT (err))) + if (0 == gnutls_error_is_fatal (XINT (err))) return Qnil; return Qt; @@ -782,7 +773,7 @@ usage: (gnutls-error-string ERROR) */) if (! TYPE_RANGED_INTEGERP (int, err)) return build_string ("Not an error symbol or code"); - return build_string (fn_gnutls_strerror (XINT (err))); + return build_string (gnutls_strerror (XINT (err))); } DEFUN ("gnutls-deinit", Fgnutls_deinit, Sgnutls_deinit, 1, 1, 0, @@ -821,7 +812,7 @@ gnutls_certificate_details (gnutls_x509_crt_t cert) /* Version. */ { - int version = fn_gnutls_x509_crt_get_version (cert); + int version = gnutls_x509_crt_get_version (cert); if (version >= GNUTLS_E_SUCCESS) res = nconc2 (res, list2 (intern (":version"), make_number (version))); @@ -829,11 +820,11 @@ gnutls_certificate_details (gnutls_x509_crt_t cert) /* Serial. */ buf_size = 0; - err = fn_gnutls_x509_crt_get_serial (cert, NULL, &buf_size); + err = gnutls_x509_crt_get_serial (cert, NULL, &buf_size); if (err == GNUTLS_E_SHORT_MEMORY_BUFFER) { void *serial = xmalloc (buf_size); - err = fn_gnutls_x509_crt_get_serial (cert, serial, &buf_size); + err = gnutls_x509_crt_get_serial (cert, serial, &buf_size); if (err >= GNUTLS_E_SUCCESS) res = nconc2 (res, list2 (intern (":serial-number"), gnutls_hex_string (serial, buf_size, ""))); @@ -842,11 +833,11 @@ gnutls_certificate_details (gnutls_x509_crt_t cert) /* Issuer. */ buf_size = 0; - err = fn_gnutls_x509_crt_get_issuer_dn (cert, NULL, &buf_size); + err = gnutls_x509_crt_get_issuer_dn (cert, NULL, &buf_size); if (err == GNUTLS_E_SHORT_MEMORY_BUFFER) { char *dn = xmalloc (buf_size); - err = fn_gnutls_x509_crt_get_issuer_dn (cert, dn, &buf_size); + err = gnutls_x509_crt_get_issuer_dn (cert, dn, &buf_size); if (err >= GNUTLS_E_SUCCESS) res = nconc2 (res, list2 (intern (":issuer"), make_string (dn, buf_size))); @@ -859,23 +850,23 @@ gnutls_certificate_details (gnutls_x509_crt_t cert) that might add 1 to the year length. */ char buf[INT_STRLEN_BOUND (int) + 1 + sizeof "-12-31"]; struct tm t; - time_t tim = fn_gnutls_x509_crt_get_activation_time (cert); + time_t tim = gnutls_x509_crt_get_activation_time (cert); if (gmtime_r (&tim, &t) && strftime (buf, sizeof buf, "%Y-%m-%d", &t)) res = nconc2 (res, list2 (intern (":valid-from"), build_string (buf))); - tim = fn_gnutls_x509_crt_get_expiration_time (cert); + tim = gnutls_x509_crt_get_expiration_time (cert); if (gmtime_r (&tim, &t) && strftime (buf, sizeof buf, "%Y-%m-%d", &t)) res = nconc2 (res, list2 (intern (":valid-to"), build_string (buf))); } /* Subject. */ buf_size = 0; - err = fn_gnutls_x509_crt_get_dn (cert, NULL, &buf_size); + err = gnutls_x509_crt_get_dn (cert, NULL, &buf_size); if (err == GNUTLS_E_SHORT_MEMORY_BUFFER) { char *dn = xmalloc (buf_size); - err = fn_gnutls_x509_crt_get_dn (cert, dn, &buf_size); + err = gnutls_x509_crt_get_dn (cert, dn, &buf_size); if (err >= GNUTLS_E_SUCCESS) res = nconc2 (res, list2 (intern (":subject"), make_string (dn, buf_size))); @@ -888,16 +879,16 @@ gnutls_certificate_details (gnutls_x509_crt_t cert) { unsigned int bits; - err = fn_gnutls_x509_crt_get_pk_algorithm (cert, &bits); + err = gnutls_x509_crt_get_pk_algorithm (cert, &bits); if (err >= GNUTLS_E_SUCCESS) { - const char *name = fn_gnutls_pk_algorithm_get_name (err); + const char *name = gnutls_pk_algorithm_get_name (err); if (name) res = nconc2 (res, list2 (intern (":public-key-algorithm"), build_string (name))); - name = fn_gnutls_sec_param_get_name (fn_gnutls_pk_bits_to_sec_param - (err, bits)); + name = gnutls_sec_param_get_name (gnutls_pk_bits_to_sec_param + (err, bits)); res = nconc2 (res, list2 (intern (":certificate-security-level"), build_string (name))); } @@ -905,11 +896,11 @@ gnutls_certificate_details (gnutls_x509_crt_t cert) /* Unique IDs. */ buf_size = 0; - err = fn_gnutls_x509_crt_get_issuer_unique_id (cert, NULL, &buf_size); + err = gnutls_x509_crt_get_issuer_unique_id (cert, NULL, &buf_size); if (err == GNUTLS_E_SHORT_MEMORY_BUFFER) { char *buf = xmalloc (buf_size); - err = fn_gnutls_x509_crt_get_issuer_unique_id (cert, buf, &buf_size); + err = gnutls_x509_crt_get_issuer_unique_id (cert, buf, &buf_size); if (err >= GNUTLS_E_SUCCESS) res = nconc2 (res, list2 (intern (":issuer-unique-id"), make_string (buf, buf_size))); @@ -917,11 +908,11 @@ gnutls_certificate_details (gnutls_x509_crt_t cert) } buf_size = 0; - err = fn_gnutls_x509_crt_get_subject_unique_id (cert, NULL, &buf_size); + err = gnutls_x509_crt_get_subject_unique_id (cert, NULL, &buf_size); if (err == GNUTLS_E_SHORT_MEMORY_BUFFER) { char *buf = xmalloc (buf_size); - err = fn_gnutls_x509_crt_get_subject_unique_id (cert, buf, &buf_size); + err = gnutls_x509_crt_get_subject_unique_id (cert, buf, &buf_size); if (err >= GNUTLS_E_SUCCESS) res = nconc2 (res, list2 (intern (":subject-unique-id"), make_string (buf, buf_size))); @@ -930,10 +921,10 @@ gnutls_certificate_details (gnutls_x509_crt_t cert) #endif /* Signature. */ - err = fn_gnutls_x509_crt_get_signature_algorithm (cert); + err = gnutls_x509_crt_get_signature_algorithm (cert); if (err >= GNUTLS_E_SUCCESS) { - const char *name = fn_gnutls_sign_get_name (err); + const char *name = gnutls_sign_get_name (err); if (name) res = nconc2 (res, list2 (intern (":signature-algorithm"), build_string (name))); @@ -941,11 +932,11 @@ gnutls_certificate_details (gnutls_x509_crt_t cert) /* Public key ID. */ buf_size = 0; - err = fn_gnutls_x509_crt_get_key_id (cert, 0, NULL, &buf_size); + err = gnutls_x509_crt_get_key_id (cert, 0, NULL, &buf_size); if (err == GNUTLS_E_SHORT_MEMORY_BUFFER) { void *buf = xmalloc (buf_size); - err = fn_gnutls_x509_crt_get_key_id (cert, 0, buf, &buf_size); + err = gnutls_x509_crt_get_key_id (cert, 0, buf, &buf_size); if (err >= GNUTLS_E_SUCCESS) res = nconc2 (res, list2 (intern (":public-key-id"), gnutls_hex_string (buf, buf_size, "sha1:"))); @@ -954,13 +945,13 @@ gnutls_certificate_details (gnutls_x509_crt_t cert) /* Certificate fingerprint. */ buf_size = 0; - err = fn_gnutls_x509_crt_get_fingerprint (cert, GNUTLS_DIG_SHA1, - NULL, &buf_size); + err = gnutls_x509_crt_get_fingerprint (cert, GNUTLS_DIG_SHA1, + NULL, &buf_size); if (err == GNUTLS_E_SHORT_MEMORY_BUFFER) { void *buf = xmalloc (buf_size); - err = fn_gnutls_x509_crt_get_fingerprint (cert, GNUTLS_DIG_SHA1, - buf, &buf_size); + err = gnutls_x509_crt_get_fingerprint (cert, GNUTLS_DIG_SHA1, + buf, &buf_size); if (err >= GNUTLS_E_SUCCESS) res = nconc2 (res, list2 (intern (":certificate-id"), gnutls_hex_string (buf, buf_size, "sha1:"))); @@ -1061,7 +1052,7 @@ The return value is a property list with top-level keys :warnings and /* Diffie-Hellman prime bits. */ { - int bits = fn_gnutls_dh_get_prime_bits (state); + int bits = gnutls_dh_get_prime_bits (state); if (bits > 0) result = nconc2 (result, list2 (intern (":diffie-hellman-prime-bits"), make_number (bits))); @@ -1070,26 +1061,26 @@ The return value is a property list with top-level keys :warnings and /* Key exchange. */ result = nconc2 (result, list2 (intern (":key-exchange"), - build_string (fn_gnutls_kx_get_name - (fn_gnutls_kx_get (state))))); + build_string (gnutls_kx_get_name + (gnutls_kx_get (state))))); /* Protocol name. */ result = nconc2 (result, list2 (intern (":protocol"), - build_string (fn_gnutls_protocol_get_name - (fn_gnutls_protocol_get_version (state))))); + build_string (gnutls_protocol_get_name + (gnutls_protocol_get_version (state))))); /* Cipher name. */ result = nconc2 (result, list2 (intern (":cipher"), - build_string (fn_gnutls_cipher_get_name - (fn_gnutls_cipher_get (state))))); + build_string (gnutls_cipher_get_name + (gnutls_cipher_get (state))))); /* MAC name. */ result = nconc2 (result, list2 (intern (":mac"), - build_string (fn_gnutls_mac_get_name - (fn_gnutls_mac_get (state))))); + build_string (gnutls_mac_get_name + (gnutls_mac_get (state))))); return result; @@ -1105,9 +1096,9 @@ emacs_gnutls_global_init (void) if (!gnutls_global_initialized) { - fn_gnutls_global_set_mem_functions (xmalloc, xmalloc, NULL, - xrealloc, xfree); - ret = fn_gnutls_global_init (); + gnutls_global_set_mem_functions (xmalloc, xmalloc, NULL, + xrealloc, xfree); + ret = gnutls_global_init (); } gnutls_global_initialized = 1; @@ -1257,11 +1248,11 @@ one trustfile (usually a CA bundle). */) if (TYPE_RANGED_INTEGERP (int, loglevel)) { - fn_gnutls_global_set_log_function (gnutls_log_function); + gnutls_global_set_log_function (gnutls_log_function); #ifdef HAVE_GNUTLS3 - fn_gnutls_global_set_audit_log_function (gnutls_audit_log_function); + gnutls_global_set_audit_log_function (gnutls_audit_log_function); #endif - fn_gnutls_global_set_log_level (XINT (loglevel)); + gnutls_global_set_log_level (XINT (loglevel)); max_log_level = XINT (loglevel); XPROCESS (proc)->gnutls_log_level = max_log_level; } @@ -1291,7 +1282,7 @@ one trustfile (usually a CA bundle). */) unsigned int gnutls_verify_flags = GNUTLS_VERIFY_ALLOW_X509_V1_CA_CRT; GNUTLS_LOG (2, max_log_level, "allocating x509 credentials"); - fn_gnutls_certificate_allocate_credentials (&x509_cred); + gnutls_certificate_allocate_credentials (&x509_cred); XPROCESS (proc)->gnutls_x509_cred = x509_cred; verify_flags = Fplist_get (proplist, QCgnutls_bootprop_verify_flags); @@ -1305,12 +1296,12 @@ one trustfile (usually a CA bundle). */) else GNUTLS_LOG (2, max_log_level, "ignoring invalid verify-flags"); - fn_gnutls_certificate_set_verify_flags (x509_cred, gnutls_verify_flags); + gnutls_certificate_set_verify_flags (x509_cred, gnutls_verify_flags); } else /* Qgnutls_anon: */ { GNUTLS_LOG (2, max_log_level, "allocating anon credentials"); - fn_gnutls_anon_allocate_client_credentials (&anon_cred); + gnutls_anon_allocate_client_credentials (&anon_cred); XPROCESS (proc)->gnutls_anon_cred = anon_cred; } @@ -1324,7 +1315,7 @@ one trustfile (usually a CA bundle). */) #if GNUTLS_VERSION_MAJOR + \ (GNUTLS_VERSION_MINOR > 0 || GNUTLS_VERSION_PATCH >= 20) > 3 - ret = fn_gnutls_certificate_set_x509_system_trust (x509_cred); + ret = gnutls_certificate_set_x509_system_trust (x509_cred); if (ret < GNUTLS_E_SUCCESS) GNUTLS_LOG2i (4, max_log_level, "setting system trust failed with code ", ret); @@ -1344,7 +1335,7 @@ one trustfile (usually a CA bundle). */) name using the current ANSI codepage. */ trustfile = ansi_encode_filename (trustfile); #endif - ret = fn_gnutls_certificate_set_x509_trust_file + ret = gnutls_certificate_set_x509_trust_file (x509_cred, SSDATA (trustfile), file_format); @@ -1370,7 +1361,7 @@ one trustfile (usually a CA bundle). */) #ifdef WINDOWSNT crlfile = ansi_encode_filename (crlfile); #endif - ret = fn_gnutls_certificate_set_x509_crl_file + ret = gnutls_certificate_set_x509_crl_file (x509_cred, SSDATA (crlfile), file_format); if (ret < GNUTLS_E_SUCCESS) @@ -1399,7 +1390,7 @@ one trustfile (usually a CA bundle). */) keyfile = ansi_encode_filename (keyfile); certfile = ansi_encode_filename (certfile); #endif - ret = fn_gnutls_certificate_set_x509_key_file + ret = gnutls_certificate_set_x509_key_file (x509_cred, SSDATA (certfile), SSDATA (keyfile), file_format); if (ret < GNUTLS_E_SUCCESS) @@ -1421,7 +1412,7 @@ one trustfile (usually a CA bundle). */) /* Call gnutls_init here: */ GNUTLS_LOG (1, max_log_level, "gnutls_init"); - ret = fn_gnutls_init (&state, GNUTLS_CLIENT); + ret = gnutls_init (&state, GNUTLS_CLIENT); XPROCESS (proc)->gnutls_state = state; if (ret < GNUTLS_E_SUCCESS) return gnutls_make_error (ret); @@ -1440,27 +1431,25 @@ one trustfile (usually a CA bundle). */) } GNUTLS_LOG (1, max_log_level, "setting the priority string"); - ret = fn_gnutls_priority_set_direct (state, - priority_string_ptr, - NULL); + ret = gnutls_priority_set_direct (state, priority_string_ptr, NULL); if (ret < GNUTLS_E_SUCCESS) return gnutls_make_error (ret); GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_PRIORITY; if (INTEGERP (prime_bits)) - fn_gnutls_dh_set_prime_bits (state, XUINT (prime_bits)); + gnutls_dh_set_prime_bits (state, XUINT (prime_bits)); ret = EQ (type, Qgnutls_x509pki) - ? fn_gnutls_credentials_set (state, GNUTLS_CRD_CERTIFICATE, x509_cred) - : fn_gnutls_credentials_set (state, GNUTLS_CRD_ANON, anon_cred); + ? gnutls_credentials_set (state, GNUTLS_CRD_CERTIFICATE, x509_cred) + : gnutls_credentials_set (state, GNUTLS_CRD_ANON, anon_cred); if (ret < GNUTLS_E_SUCCESS) return gnutls_make_error (ret); if (!gnutls_ip_address_p (c_hostname)) { - ret = fn_gnutls_server_name_set (state, GNUTLS_NAME_DNS, c_hostname, - strlen (c_hostname)); + ret = gnutls_server_name_set (state, GNUTLS_NAME_DNS, c_hostname, + strlen (c_hostname)); if (ret < GNUTLS_E_SUCCESS) return gnutls_make_error (ret); } @@ -1476,7 +1465,7 @@ one trustfile (usually a CA bundle). */) check of the certificate's hostname with gnutls_x509_crt_check_hostname against :hostname. */ - ret = fn_gnutls_certificate_verify_peers2 (state, &peer_verification); + ret = gnutls_certificate_verify_peers2 (state, &peer_verification); if (ret < GNUTLS_E_SUCCESS) return gnutls_make_error (ret); @@ -1514,47 +1503,47 @@ one trustfile (usually a CA bundle). */) /* Up to here the process is the same for X.509 certificates and OpenPGP keys. From now on X.509 certificates are assumed. This can be easily extended to work with openpgp keys as well. */ - if (fn_gnutls_certificate_type_get (state) == GNUTLS_CRT_X509) + if (gnutls_certificate_type_get (state) == GNUTLS_CRT_X509) { gnutls_x509_crt_t gnutls_verify_cert; const gnutls_datum_t *gnutls_verify_cert_list; unsigned int gnutls_verify_cert_list_size; - ret = fn_gnutls_x509_crt_init (&gnutls_verify_cert); + ret = gnutls_x509_crt_init (&gnutls_verify_cert); if (ret < GNUTLS_E_SUCCESS) return gnutls_make_error (ret); gnutls_verify_cert_list = - fn_gnutls_certificate_get_peers (state, &gnutls_verify_cert_list_size); + gnutls_certificate_get_peers (state, &gnutls_verify_cert_list_size); if (gnutls_verify_cert_list == NULL) { - fn_gnutls_x509_crt_deinit (gnutls_verify_cert); + gnutls_x509_crt_deinit (gnutls_verify_cert); emacs_gnutls_deinit (proc); error ("No x509 certificate was found\n"); } /* We only check the first certificate in the given chain. */ - ret = fn_gnutls_x509_crt_import (gnutls_verify_cert, + ret = gnutls_x509_crt_import (gnutls_verify_cert, &gnutls_verify_cert_list[0], GNUTLS_X509_FMT_DER); if (ret < GNUTLS_E_SUCCESS) { - fn_gnutls_x509_crt_deinit (gnutls_verify_cert); + gnutls_x509_crt_deinit (gnutls_verify_cert); return gnutls_make_error (ret); } XPROCESS (proc)->gnutls_certificate = gnutls_verify_cert; - if (!fn_gnutls_x509_crt_check_hostname (gnutls_verify_cert, c_hostname)) + if (!gnutls_x509_crt_check_hostname (gnutls_verify_cert, c_hostname)) { XPROCESS (proc)->gnutls_extra_peer_verification |= CERTIFICATE_NOT_MATCHING; if (verify_error_all || !NILP (Fmember (QCgnutls_bootprop_hostname, verify_error))) { - fn_gnutls_x509_crt_deinit (gnutls_verify_cert); + gnutls_x509_crt_deinit (gnutls_verify_cert); emacs_gnutls_deinit (proc); error ("The x509 certificate does not match \"%s\"", c_hostname); } @@ -1595,10 +1584,9 @@ This function may also return `gnutls-e-again', or state = XPROCESS (proc)->gnutls_state; - fn_gnutls_x509_crt_deinit (XPROCESS (proc)->gnutls_certificate); + gnutls_x509_crt_deinit (XPROCESS (proc)->gnutls_certificate); - ret = fn_gnutls_bye (state, - NILP (cont) ? GNUTLS_SHUT_RDWR : GNUTLS_SHUT_WR); + ret = gnutls_bye (state, NILP (cont) ? GNUTLS_SHUT_RDWR : GNUTLS_SHUT_WR); return gnutls_make_error (ret); } diff --git a/src/image.c b/src/image.c index a73a725..4cba886 100644 --- a/src/image.c +++ b/src/image.c @@ -1859,19 +1859,6 @@ mark_image_cache (struct image_cache *c) X / NS / W32 support code ***********************************************************************/ -#ifdef WINDOWSNT - -/* Macro for defining functions that will be loaded from image DLLs. */ -#define DEF_IMGLIB_FN(rettype,func,args) static rettype (FAR CDECL *fn_##func)args - -/* Macro for loading those image functions from the library. */ -#define LOAD_IMGLIB_FN(lib,func) { \ - fn_##func = (void *) GetProcAddress (lib, #func); \ - if (!fn_##func) return 0; \ - } - -#endif /* WINDOWSNT */ - /* Return true if XIMG's size WIDTH x HEIGHT doesn't break the windowing system. WIDTH and HEIGHT must both be positive. @@ -3377,12 +3364,14 @@ xpm_free_colors (Display *dpy, Colormap cmap, Pixel *pixels, int npixels, void * /* XPM library details. */ -DEF_IMGLIB_FN (void, XpmFreeAttributes, (XpmAttributes *)); -DEF_IMGLIB_FN (int, XpmCreateImageFromBuffer, (Display *, char *, xpm_XImage **, - xpm_XImage **, XpmAttributes *)); -DEF_IMGLIB_FN (int, XpmReadFileToImage, (Display *, char *, xpm_XImage **, - xpm_XImage **, XpmAttributes *)); -DEF_IMGLIB_FN (void, XImageFree, (xpm_XImage *)); +DEF_DLL_FN (void, XpmFreeAttributes, (XpmAttributes *)); +DEF_DLL_FN (int, XpmCreateImageFromBuffer, + (Display *, char *, xpm_XImage **, + xpm_XImage **, XpmAttributes *)); +DEF_DLL_FN (int, XpmReadFileToImage, + (Display *, char *, xpm_XImage **, + xpm_XImage **, XpmAttributes *)); +DEF_DLL_FN (void, XImageFree, (xpm_XImage *)); static bool init_xpm_functions (void) @@ -3392,22 +3381,24 @@ init_xpm_functions (void) if (!(library = w32_delayed_load (Qxpm))) return 0; - LOAD_IMGLIB_FN (library, XpmFreeAttributes); - LOAD_IMGLIB_FN (library, XpmCreateImageFromBuffer); - LOAD_IMGLIB_FN (library, XpmReadFileToImage); - LOAD_IMGLIB_FN (library, XImageFree); + LOAD_DLL_FN (library, XpmFreeAttributes); + LOAD_DLL_FN (library, XpmCreateImageFromBuffer); + LOAD_DLL_FN (library, XpmReadFileToImage); + LOAD_DLL_FN (library, XImageFree); return 1; } -#endif /* WINDOWSNT */ +# undef XImageFree +# undef XpmCreateImageFromBuffer +# undef XpmFreeAttributes +# undef XpmReadFileToImage -#if defined HAVE_NTGUI && !defined WINDOWSNT -/* Glue for code below */ -#define fn_XpmReadFileToImage XpmReadFileToImage -#define fn_XpmCreateImageFromBuffer XpmCreateImageFromBuffer -#define fn_XImageFree XImageFree -#define fn_XpmFreeAttributes XpmFreeAttributes -#endif /* HAVE_NTGUI && !WINDOWSNT */ +# define XImageFree fn_XImageFree +# define XpmCreateImageFromBuffer fn_XpmCreateImageFromBuffer +# define XpmFreeAttributes fn_XpmFreeAttributes +# define XpmReadFileToImage fn_XpmReadFileToImage + +#endif /* WINDOWSNT */ /* Value is true if COLOR_SYMBOLS is a valid color symbols list for XPM images. Such a list must consist of conses whose car and @@ -3624,9 +3615,9 @@ xpm_load (struct frame *f, struct image *img) #endif /* XpmReadFileToPixmap is not available in the Windows port of libxpm. But XpmReadFileToImage almost does what we want. */ - rc = fn_XpmReadFileToImage (&hdc, SDATA (file), - &xpm_image, &xpm_mask, - &attrs); + rc = XpmReadFileToImage (&hdc, SDATA (file), + &xpm_image, &xpm_mask, + &attrs); #else rc = XpmReadFileToImage (FRAME_X_DISPLAY (f), SSDATA (file), &img->ximg, &img->mask_img, @@ -3648,9 +3639,9 @@ xpm_load (struct frame *f, struct image *img) #ifdef HAVE_NTGUI /* XpmCreatePixmapFromBuffer is not available in the Windows port of libxpm. But XpmCreateImageFromBuffer almost does what we want. */ - rc = fn_XpmCreateImageFromBuffer (&hdc, SDATA (buffer), - &xpm_image, &xpm_mask, - &attrs); + rc = XpmCreateImageFromBuffer (&hdc, SDATA (buffer), + &xpm_image, &xpm_mask, + &attrs); #else rc = XpmCreateImageFromBuffer (FRAME_X_DISPLAY (f), SSDATA (buffer), &img->ximg, &img->mask_img, @@ -3699,7 +3690,7 @@ xpm_load (struct frame *f, struct image *img) img->pixmap = xpm_image->bitmap; /* XImageFree in libXpm frees XImage struct without destroying the bitmap, which is what we want. */ - fn_XImageFree (xpm_image); + XImageFree (xpm_image); } if (xpm_mask && xpm_mask->bitmap) { @@ -3713,7 +3704,7 @@ xpm_load (struct frame *f, struct image *img) SelectObject (hdc, old_obj); img->mask = xpm_mask->bitmap; - fn_XImageFree (xpm_mask); + XImageFree (xpm_mask); DeleteDC (hdc); } @@ -3737,11 +3728,7 @@ xpm_load (struct frame *f, struct image *img) eassert (img->width > 0 && img->height > 0); /* The call to XpmFreeAttributes below frees attrs.alloc_pixels. */ -#ifdef HAVE_NTGUI - fn_XpmFreeAttributes (&attrs); -#else XpmFreeAttributes (&attrs); -#endif /* HAVE_NTGUI */ #ifdef HAVE_X_WINDOWS /* Maybe fill in the background field while we have ximg handy. */ @@ -5535,39 +5522,42 @@ png_image_p (Lisp_Object object) #if defined HAVE_PNG && !defined HAVE_NS -#ifdef WINDOWSNT +# ifdef WINDOWSNT /* PNG library details. */ -DEF_IMGLIB_FN (png_voidp, png_get_io_ptr, (png_structp)); -DEF_IMGLIB_FN (int, png_sig_cmp, (png_bytep, png_size_t, png_size_t)); -DEF_IMGLIB_FN (png_structp, png_create_read_struct, (png_const_charp, png_voidp, - png_error_ptr, png_error_ptr)); -DEF_IMGLIB_FN (png_infop, png_create_info_struct, (png_structp)); -DEF_IMGLIB_FN (void, png_destroy_read_struct, (png_structpp, png_infopp, png_infopp)); -DEF_IMGLIB_FN (void, png_set_read_fn, (png_structp, png_voidp, png_rw_ptr)); -DEF_IMGLIB_FN (void, png_set_sig_bytes, (png_structp, int)); -DEF_IMGLIB_FN (void, png_read_info, (png_structp, png_infop)); -DEF_IMGLIB_FN (png_uint_32, png_get_IHDR, (png_structp, png_infop, - png_uint_32 *, png_uint_32 *, - int *, int *, int *, int *, int *)); -DEF_IMGLIB_FN (png_uint_32, png_get_valid, (png_structp, png_infop, png_uint_32)); -DEF_IMGLIB_FN (void, png_set_strip_16, (png_structp)); -DEF_IMGLIB_FN (void, png_set_expand, (png_structp)); -DEF_IMGLIB_FN (void, png_set_gray_to_rgb, (png_structp)); -DEF_IMGLIB_FN (void, png_set_background, (png_structp, png_color_16p, - int, int, double)); -DEF_IMGLIB_FN (png_uint_32, png_get_bKGD, (png_structp, png_infop, png_color_16p *)); -DEF_IMGLIB_FN (void, png_read_update_info, (png_structp, png_infop)); -DEF_IMGLIB_FN (png_byte, png_get_channels, (png_structp, png_infop)); -DEF_IMGLIB_FN (png_size_t, png_get_rowbytes, (png_structp, png_infop)); -DEF_IMGLIB_FN (void, png_read_image, (png_structp, png_bytepp)); -DEF_IMGLIB_FN (void, png_read_end, (png_structp, png_infop)); -DEF_IMGLIB_FN (void, png_error, (png_structp, png_const_charp)); - -#if (PNG_LIBPNG_VER >= 10500) -DEF_IMGLIB_FN (void, png_longjmp, (png_structp, int)) PNG_NORETURN; -DEF_IMGLIB_FN (jmp_buf *, png_set_longjmp_fn, (png_structp, png_longjmp_ptr, size_t)); -#endif /* libpng version >= 1.5 */ +DEF_DLL_FN (png_voidp, png_get_io_ptr, (png_structp)); +DEF_DLL_FN (int, png_sig_cmp, (png_bytep, png_size_t, png_size_t)); +DEF_DLL_FN (png_structp, png_create_read_struct, + (png_const_charp, png_voidp, png_error_ptr, png_error_ptr)); +DEF_DLL_FN (png_infop, png_create_info_struct, (png_structp)); +DEF_DLL_FN (void, png_destroy_read_struct, + (png_structpp, png_infopp, png_infopp)); +DEF_DLL_FN (void, png_set_read_fn, (png_structp, png_voidp, png_rw_ptr)); +DEF_DLL_FN (void, png_set_sig_bytes, (png_structp, int)); +DEF_DLL_FN (void, png_read_info, (png_structp, png_infop)); +DEF_DLL_FN (png_uint_32, png_get_IHDR, + (png_structp, png_infop, png_uint_32 *, png_uint_32 *, + int *, int *, int *, int *, int *)); +DEF_DLL_FN (png_uint_32, png_get_valid, (png_structp, png_infop, png_uint_32)); +DEF_DLL_FN (void, png_set_strip_16, (png_structp)); +DEF_DLL_FN (void, png_set_expand, (png_structp)); +DEF_DLL_FN (void, png_set_gray_to_rgb, (png_structp)); +DEF_DLL_FN (void, png_set_background, + (png_structp, png_color_16p, int, int, double)); +DEF_DLL_FN (png_uint_32, png_get_bKGD, + (png_structp, png_infop, png_color_16p *)); +DEF_DLL_FN (void, png_read_update_info, (png_structp, png_infop)); +DEF_DLL_FN (png_byte, png_get_channels, (png_structp, png_infop)); +DEF_DLL_FN (png_size_t, png_get_rowbytes, (png_structp, png_infop)); +DEF_DLL_FN (void, png_read_image, (png_structp, png_bytepp)); +DEF_DLL_FN (void, png_read_end, (png_structp, png_infop)); +DEF_DLL_FN (void, png_error, (png_structp, png_const_charp)); + +# if (PNG_LIBPNG_VER >= 10500) +DEF_DLL_FN (void, png_longjmp, (png_structp, int)) PNG_NORETURN; +DEF_DLL_FN (jmp_buf *, png_set_longjmp_fn, + (png_structp, png_longjmp_ptr, size_t)); +# endif /* libpng version >= 1.5 */ static bool init_png_functions (void) @@ -5577,87 +5567,107 @@ init_png_functions (void) if (!(library = w32_delayed_load (Qpng))) return 0; - LOAD_IMGLIB_FN (library, png_get_io_ptr); - LOAD_IMGLIB_FN (library, png_sig_cmp); - LOAD_IMGLIB_FN (library, png_create_read_struct); - LOAD_IMGLIB_FN (library, png_create_info_struct); - LOAD_IMGLIB_FN (library, png_destroy_read_struct); - LOAD_IMGLIB_FN (library, png_set_read_fn); - LOAD_IMGLIB_FN (library, png_set_sig_bytes); - LOAD_IMGLIB_FN (library, png_read_info); - LOAD_IMGLIB_FN (library, png_get_IHDR); - LOAD_IMGLIB_FN (library, png_get_valid); - LOAD_IMGLIB_FN (library, png_set_strip_16); - LOAD_IMGLIB_FN (library, png_set_expand); - LOAD_IMGLIB_FN (library, png_set_gray_to_rgb); - LOAD_IMGLIB_FN (library, png_set_background); - LOAD_IMGLIB_FN (library, png_get_bKGD); - LOAD_IMGLIB_FN (library, png_read_update_info); - LOAD_IMGLIB_FN (library, png_get_channels); - LOAD_IMGLIB_FN (library, png_get_rowbytes); - LOAD_IMGLIB_FN (library, png_read_image); - LOAD_IMGLIB_FN (library, png_read_end); - LOAD_IMGLIB_FN (library, png_error); - -#if (PNG_LIBPNG_VER >= 10500) - LOAD_IMGLIB_FN (library, png_longjmp); - LOAD_IMGLIB_FN (library, png_set_longjmp_fn); -#endif /* libpng version >= 1.5 */ + LOAD_DLL_FN (library, png_get_io_ptr); + LOAD_DLL_FN (library, png_sig_cmp); + LOAD_DLL_FN (library, png_create_read_struct); + LOAD_DLL_FN (library, png_create_info_struct); + LOAD_DLL_FN (library, png_destroy_read_struct); + LOAD_DLL_FN (library, png_set_read_fn); + LOAD_DLL_FN (library, png_set_sig_bytes); + LOAD_DLL_FN (library, png_read_info); + LOAD_DLL_FN (library, png_get_IHDR); + LOAD_DLL_FN (library, png_get_valid); + LOAD_DLL_FN (library, png_set_strip_16); + LOAD_DLL_FN (library, png_set_expand); + LOAD_DLL_FN (library, png_set_gray_to_rgb); + LOAD_DLL_FN (library, png_set_background); + LOAD_DLL_FN (library, png_get_bKGD); + LOAD_DLL_FN (library, png_read_update_info); + LOAD_DLL_FN (library, png_get_channels); + LOAD_DLL_FN (library, png_get_rowbytes); + LOAD_DLL_FN (library, png_read_image); + LOAD_DLL_FN (library, png_read_end); + LOAD_DLL_FN (library, png_error); + +# if (PNG_LIBPNG_VER >= 10500) + LOAD_DLL_FN (library, png_longjmp); + LOAD_DLL_FN (library, png_set_longjmp_fn); +# endif /* libpng version >= 1.5 */ return 1; } -#else - -#define fn_png_get_io_ptr png_get_io_ptr -#define fn_png_sig_cmp png_sig_cmp -#define fn_png_create_read_struct png_create_read_struct -#define fn_png_create_info_struct png_create_info_struct -#define fn_png_destroy_read_struct png_destroy_read_struct -#define fn_png_set_read_fn png_set_read_fn -#define fn_png_set_sig_bytes png_set_sig_bytes -#define fn_png_read_info png_read_info -#define fn_png_get_IHDR png_get_IHDR -#define fn_png_get_valid png_get_valid -#define fn_png_set_strip_16 png_set_strip_16 -#define fn_png_set_expand png_set_expand -#define fn_png_set_gray_to_rgb png_set_gray_to_rgb -#define fn_png_set_background png_set_background -#define fn_png_get_bKGD png_get_bKGD -#define fn_png_read_update_info png_read_update_info -#define fn_png_get_channels png_get_channels -#define fn_png_get_rowbytes png_get_rowbytes -#define fn_png_read_image png_read_image -#define fn_png_read_end png_read_end -#define fn_png_error png_error - -#if (PNG_LIBPNG_VER >= 10500) -#define fn_png_longjmp png_longjmp -#define fn_png_set_longjmp_fn png_set_longjmp_fn -#endif /* libpng version >= 1.5 */ -#endif /* WINDOWSNT */ +# undef png_create_info_struct +# undef png_create_read_struct +# undef png_destroy_read_struct +# undef png_error +# undef png_get_bKGD +# undef png_get_channels +# undef png_get_IHDR +# undef png_get_io_ptr +# undef png_get_rowbytes +# undef png_get_valid +# undef png_longjmp +# undef png_read_end +# undef png_read_image +# undef png_read_info +# undef png_read_update_info +# undef png_set_background +# undef png_set_expand +# undef png_set_gray_to_rgb +# undef png_set_longjmp_fn +# undef png_set_read_fn +# undef png_set_sig_bytes +# undef png_set_strip_16 +# undef png_sig_cmp + +# define png_create_info_struct fn_png_create_info_struct +# define png_create_read_struct fn_png_create_read_struct +# define png_destroy_read_struct fn_png_destroy_read_struct +# define png_error fn_png_error +# define png_get_bKGD fn_png_get_bKGD +# define png_get_channels fn_png_get_channels +# define png_get_IHDR fn_png_get_IHDR +# define png_get_io_ptr fn_png_get_io_ptr +# define png_get_rowbytes fn_png_get_rowbytes +# define png_get_valid fn_png_get_valid +# define png_longjmp fn_png_longjmp +# define png_read_end fn_png_read_end +# define png_read_image fn_png_read_image +# define png_read_info fn_png_read_info +# define png_read_update_info fn_png_read_update_info +# define png_set_background fn_png_set_background +# define png_set_expand fn_png_set_expand +# define png_set_gray_to_rgb fn_png_set_gray_to_rgb +# define png_set_longjmp_fn fn_png_set_longjmp_fn +# define png_set_read_fn fn_png_set_read_fn +# define png_set_sig_bytes fn_png_set_sig_bytes +# define png_set_strip_16 fn_png_set_strip_16 +# define png_sig_cmp fn_png_sig_cmp + +# endif /* WINDOWSNT */ /* Fast implementations of setjmp and longjmp. Although setjmp and longjmp will do, POSIX _setjmp and _longjmp (if available) are often faster. Do not use sys_setjmp, as PNG supports only jmp_buf. It's OK if the longjmp substitute restores the signal mask. */ -#ifdef HAVE__SETJMP -# define FAST_SETJMP(j) _setjmp (j) -# define FAST_LONGJMP _longjmp -#else -# define FAST_SETJMP(j) setjmp (j) -# define FAST_LONGJMP longjmp -#endif - -#if PNG_LIBPNG_VER < 10500 -#define PNG_LONGJMP(ptr) FAST_LONGJMP ((ptr)->jmpbuf, 1) -#define PNG_JMPBUF(ptr) ((ptr)->jmpbuf) -#else +# ifdef HAVE__SETJMP +# define FAST_SETJMP(j) _setjmp (j) +# define FAST_LONGJMP _longjmp +# else +# define FAST_SETJMP(j) setjmp (j) +# define FAST_LONGJMP longjmp +# endif + +# if PNG_LIBPNG_VER < 10500 +# define PNG_LONGJMP(ptr) FAST_LONGJMP ((ptr)->jmpbuf, 1) +# define PNG_JMPBUF(ptr) ((ptr)->jmpbuf) +# else /* In libpng version 1.5, the jmpbuf member is hidden. (Bug#7908) */ -#define PNG_LONGJMP(ptr) fn_png_longjmp (ptr, 1) -#define PNG_JMPBUF(ptr) \ - (*fn_png_set_longjmp_fn (ptr, FAST_LONGJMP, sizeof (jmp_buf))) -#endif +# define PNG_LONGJMP(ptr) png_longjmp (ptr, 1) +# define PNG_JMPBUF(ptr) \ + (*png_set_longjmp_fn (ptr, FAST_LONGJMP, sizeof (jmp_buf))) +# endif /* Error and warning handlers installed when the PNG library is initialized. */ @@ -5697,10 +5707,10 @@ struct png_memory_storage static void png_read_from_memory (png_structp png_ptr, png_bytep data, png_size_t length) { - struct png_memory_storage *tbr = fn_png_get_io_ptr (png_ptr); + struct png_memory_storage *tbr = png_get_io_ptr (png_ptr); if (length > tbr->len - tbr->index) - fn_png_error (png_ptr, "Read error"); + png_error (png_ptr, "Read error"); memcpy (data, tbr->bytes + tbr->index, length); tbr->index = tbr->index + length; @@ -5714,10 +5724,10 @@ png_read_from_memory (png_structp png_ptr, png_bytep data, png_size_t length) static void png_read_from_file (png_structp png_ptr, png_bytep data, png_size_t length) { - FILE *fp = fn_png_get_io_ptr (png_ptr); + FILE *fp = png_get_io_ptr (png_ptr); if (fread (data, 1, length, fp) < length) - fn_png_error (png_ptr, "Read error"); + png_error (png_ptr, "Read error"); } @@ -5779,7 +5789,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c) /* Check PNG signature. */ if (fread (sig, 1, sizeof sig, fp) != sizeof sig - || fn_png_sig_cmp (sig, 0, sizeof sig)) + || png_sig_cmp (sig, 0, sizeof sig)) { fclose (fp); image_error ("Not a PNG file: `%s'", file, Qnil); @@ -5801,7 +5811,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c) /* Check PNG signature. */ if (tbr.len < sizeof sig - || fn_png_sig_cmp (tbr.bytes, 0, sizeof sig)) + || png_sig_cmp (tbr.bytes, 0, sizeof sig)) { image_error ("Not a PNG image: `%s'", img->spec, Qnil); return 0; @@ -5812,13 +5822,13 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c) } /* Initialize read and info structs for PNG lib. */ - png_ptr = fn_png_create_read_struct (PNG_LIBPNG_VER_STRING, + png_ptr = png_create_read_struct (PNG_LIBPNG_VER_STRING, NULL, my_png_error, my_png_warning); if (png_ptr) { - info_ptr = fn_png_create_info_struct (png_ptr); - end_info = fn_png_create_info_struct (png_ptr); + info_ptr = png_create_info_struct (png_ptr); + end_info = png_create_info_struct (png_ptr); } c->png_ptr = png_ptr; @@ -5830,7 +5840,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c) if (! (info_ptr && end_info)) { - fn_png_destroy_read_struct (&c->png_ptr, &c->info_ptr, &c->end_info); + png_destroy_read_struct (&c->png_ptr, &c->info_ptr, &c->end_info); png_ptr = 0; } if (! png_ptr) @@ -5845,7 +5855,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c) { error: if (c->png_ptr) - fn_png_destroy_read_struct (&c->png_ptr, &c->info_ptr, &c->end_info); + png_destroy_read_struct (&c->png_ptr, &c->info_ptr, &c->end_info); xfree (c->pixels); xfree (c->rows); if (c->fp) @@ -5858,14 +5868,14 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c) /* Read image info. */ if (!NILP (specified_data)) - fn_png_set_read_fn (png_ptr, &tbr, png_read_from_memory); + png_set_read_fn (png_ptr, &tbr, png_read_from_memory); else - fn_png_set_read_fn (png_ptr, fp, png_read_from_file); + png_set_read_fn (png_ptr, fp, png_read_from_file); - fn_png_set_sig_bytes (png_ptr, sizeof sig); - fn_png_read_info (png_ptr, info_ptr); - fn_png_get_IHDR (png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, - &interlace_type, NULL, NULL); + png_set_sig_bytes (png_ptr, sizeof sig); + png_read_info (png_ptr, info_ptr); + png_get_IHDR (png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, + &interlace_type, NULL, NULL); if (! (width <= INT_MAX && height <= INT_MAX && check_image_size (f, width, height))) @@ -5881,7 +5891,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c) /* If image contains simply transparency data, we prefer to construct a clipping mask. */ - if (fn_png_get_valid (png_ptr, info_ptr, PNG_INFO_tRNS)) + if (png_get_valid (png_ptr, info_ptr, PNG_INFO_tRNS)) transparent_p = 1; else transparent_p = 0; @@ -5892,16 +5902,16 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c) /* Strip more than 8 bits per channel. */ if (bit_depth == 16) - fn_png_set_strip_16 (png_ptr); + png_set_strip_16 (png_ptr); /* Expand data to 24 bit RGB, or 8 bit grayscale, with alpha channel if available. */ - fn_png_set_expand (png_ptr); + png_set_expand (png_ptr); /* Convert grayscale images to RGB. */ if (color_type == PNG_COLOR_TYPE_GRAY || color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - fn_png_set_gray_to_rgb (png_ptr); + png_set_gray_to_rgb (png_ptr); /* Handle alpha channel by combining the image with a background color. Do this only if a real alpha channel is supplied. For @@ -5927,24 +5937,24 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c) bg.green = color.green >> shift; bg.blue = color.blue >> shift; - fn_png_set_background (png_ptr, &bg, - PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0); + png_set_background (png_ptr, &bg, + PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0); } } /* Update info structure. */ - fn_png_read_update_info (png_ptr, info_ptr); + png_read_update_info (png_ptr, info_ptr); /* Get number of channels. Valid values are 1 for grayscale images and images with a palette, 2 for grayscale images with transparency information (alpha channel), 3 for RGB images, and 4 for RGB images with alpha channel, i.e. RGBA. If conversions above were sufficient we should only have 3 or 4 channels here. */ - channels = fn_png_get_channels (png_ptr, info_ptr); + channels = png_get_channels (png_ptr, info_ptr); eassert (channels == 3 || channels == 4); /* Number of bytes needed for one row of the image. */ - row_bytes = fn_png_get_rowbytes (png_ptr, info_ptr); + row_bytes = png_get_rowbytes (png_ptr, info_ptr); /* Allocate memory for the image. */ if (min (PTRDIFF_MAX, SIZE_MAX) / sizeof *rows < height @@ -5956,8 +5966,8 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c) rows[i] = pixels + i * row_bytes; /* Read the entire image. */ - fn_png_read_image (png_ptr, rows); - fn_png_read_end (png_ptr, info_ptr); + png_read_image (png_ptr, rows); + png_read_end (png_ptr, info_ptr); if (fp) { fclose (fp); @@ -6021,21 +6031,21 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c) overrode it. */ { png_color_16 *bg; - if (fn_png_get_bKGD (png_ptr, info_ptr, &bg)) + if (png_get_bKGD (png_ptr, info_ptr, &bg)) { img->background = lookup_rgb_color (f, bg->red, bg->green, bg->blue); img->background_valid = 1; } } -#ifdef COLOR_TABLE_SUPPORT +# ifdef COLOR_TABLE_SUPPORT /* Remember colors allocated for this image. */ img->colors = colors_in_color_table (&img->ncolors); free_color_table (); -#endif /* COLOR_TABLE_SUPPORT */ +# endif /* COLOR_TABLE_SUPPORT */ /* Clean up. */ - fn_png_destroy_read_struct (&c->png_ptr, &c->info_ptr, &c->end_info); + png_destroy_read_struct (&c->png_ptr, &c->info_ptr, &c->end_info); xfree (rows); xfree (pixels); @@ -6170,15 +6180,15 @@ jpeg_image_p (Lisp_Object object) /* Work around a warning about HAVE_STDLIB_H being redefined in jconfig.h. */ -#ifdef HAVE_STDLIB_H -#undef HAVE_STDLIB_H -#endif /* HAVE_STLIB_H */ +# ifdef HAVE_STDLIB_H +# undef HAVE_STDLIB_H +# endif -#if defined (HAVE_NTGUI) && !defined (__WIN32__) +# if defined (HAVE_NTGUI) && !defined (__WIN32__) /* In older releases of the jpeg library, jpeglib.h will define boolean differently depending on __WIN32__, so make sure it is defined. */ -#define __WIN32__ 1 -#endif +# define __WIN32__ 1 +# endif /* rpcndr.h (via windows.h) and jpeglib.h both define boolean types. Some versions of jpeglib try to detect whether rpcndr.h is loaded, @@ -6194,23 +6204,25 @@ jpeg_image_p (Lisp_Object object) different name. This name, jpeg_boolean, remains in effect through the rest of image.c. */ -#if defined CYGWIN && defined HAVE_NTGUI -#define boolean jpeg_boolean -#endif -#include -#include +# if defined CYGWIN && defined HAVE_NTGUI +# define boolean jpeg_boolean +# endif +# include +# include -#ifdef WINDOWSNT +# ifdef WINDOWSNT /* JPEG library details. */ -DEF_IMGLIB_FN (void, jpeg_CreateDecompress, (j_decompress_ptr, int, size_t)); -DEF_IMGLIB_FN (boolean, jpeg_start_decompress, (j_decompress_ptr)); -DEF_IMGLIB_FN (boolean, jpeg_finish_decompress, (j_decompress_ptr)); -DEF_IMGLIB_FN (void, jpeg_destroy_decompress, (j_decompress_ptr)); -DEF_IMGLIB_FN (int, jpeg_read_header, (j_decompress_ptr, boolean)); -DEF_IMGLIB_FN (JDIMENSION, jpeg_read_scanlines, (j_decompress_ptr, JSAMPARRAY, JDIMENSION)); -DEF_IMGLIB_FN (struct jpeg_error_mgr *, jpeg_std_error, (struct jpeg_error_mgr *)); -DEF_IMGLIB_FN (boolean, jpeg_resync_to_restart, (j_decompress_ptr, int)); +DEF_DLL_FN (void, jpeg_CreateDecompress, (j_decompress_ptr, int, size_t)); +DEF_DLL_FN (boolean, jpeg_start_decompress, (j_decompress_ptr)); +DEF_DLL_FN (boolean, jpeg_finish_decompress, (j_decompress_ptr)); +DEF_DLL_FN (void, jpeg_destroy_decompress, (j_decompress_ptr)); +DEF_DLL_FN (int, jpeg_read_header, (j_decompress_ptr, boolean)); +DEF_DLL_FN (JDIMENSION, jpeg_read_scanlines, + (j_decompress_ptr, JSAMPARRAY, JDIMENSION)); +DEF_DLL_FN (struct jpeg_error_mgr *, jpeg_std_error, + (struct jpeg_error_mgr *)); +DEF_DLL_FN (boolean, jpeg_resync_to_restart, (j_decompress_ptr, int)); static bool init_jpeg_functions (void) @@ -6220,37 +6232,46 @@ init_jpeg_functions (void) if (!(library = w32_delayed_load (Qjpeg))) return 0; - LOAD_IMGLIB_FN (library, jpeg_finish_decompress); - LOAD_IMGLIB_FN (library, jpeg_read_scanlines); - LOAD_IMGLIB_FN (library, jpeg_start_decompress); - LOAD_IMGLIB_FN (library, jpeg_read_header); - LOAD_IMGLIB_FN (library, jpeg_CreateDecompress); - LOAD_IMGLIB_FN (library, jpeg_destroy_decompress); - LOAD_IMGLIB_FN (library, jpeg_std_error); - LOAD_IMGLIB_FN (library, jpeg_resync_to_restart); + LOAD_DLL_FN (library, jpeg_finish_decompress); + LOAD_DLL_FN (library, jpeg_read_scanlines); + LOAD_DLL_FN (library, jpeg_start_decompress); + LOAD_DLL_FN (library, jpeg_read_header); + LOAD_DLL_FN (library, jpeg_CreateDecompress); + LOAD_DLL_FN (library, jpeg_destroy_decompress); + LOAD_DLL_FN (library, jpeg_std_error); + LOAD_DLL_FN (library, jpeg_resync_to_restart); return 1; } +# undef jpeg_CreateDecompress +# undef jpeg_destroy_decompress +# undef jpeg_finish_decompress +# undef jpeg_read_header +# undef jpeg_read_scanlines +# undef jpeg_resync_to_restart +# undef jpeg_start_decompress +# undef jpeg_std_error + +# define jpeg_CreateDecompress fn_jpeg_CreateDecompress +# define jpeg_destroy_decompress fn_jpeg_destroy_decompress +# define jpeg_finish_decompress fn_jpeg_finish_decompress +# define jpeg_read_header fn_jpeg_read_header +# define jpeg_read_scanlines fn_jpeg_read_scanlines +# define jpeg_resync_to_restart fn_jpeg_resync_to_restart +# define jpeg_start_decompress fn_jpeg_start_decompress +# define jpeg_std_error fn_jpeg_std_error + /* Wrapper since we can't directly assign the function pointer to another function pointer that was declared more completely easily. */ static boolean jpeg_resync_to_restart_wrapper (j_decompress_ptr cinfo, int desired) { - return fn_jpeg_resync_to_restart (cinfo, desired); + return jpeg_resync_to_restart (cinfo, desired); } +# undef jpeg_resync_to_restart +# define jpeg_resync_to_restart jpeg_resync_to_restart_wrapper -#else - -#define fn_jpeg_CreateDecompress(a,b,c) jpeg_create_decompress (a) -#define fn_jpeg_start_decompress jpeg_start_decompress -#define fn_jpeg_finish_decompress jpeg_finish_decompress -#define fn_jpeg_destroy_decompress jpeg_destroy_decompress -#define fn_jpeg_read_header jpeg_read_header -#define fn_jpeg_read_scanlines jpeg_read_scanlines -#define fn_jpeg_std_error jpeg_std_error -#define jpeg_resync_to_restart_wrapper jpeg_resync_to_restart - -#endif /* WINDOWSNT */ +# endif /* WINDOWSNT */ struct my_jpeg_error_mgr { @@ -6358,7 +6379,7 @@ jpeg_memory_src (j_decompress_ptr cinfo, JOCTET *data, ptrdiff_t len) src->init_source = our_common_init_source; src->fill_input_buffer = our_memory_fill_input_buffer; src->skip_input_data = our_memory_skip_input_data; - src->resync_to_restart = jpeg_resync_to_restart_wrapper; /* Use default method. */ + src->resync_to_restart = jpeg_resync_to_restart; /* Use default method. */ src->term_source = our_common_term_source; src->bytes_in_buffer = len; src->next_input_byte = data; @@ -6464,7 +6485,7 @@ jpeg_file_src (j_decompress_ptr cinfo, FILE *fp) src->mgr.init_source = our_common_init_source; src->mgr.fill_input_buffer = our_stdio_fill_input_buffer; src->mgr.skip_input_data = our_stdio_skip_input_data; - src->mgr.resync_to_restart = jpeg_resync_to_restart_wrapper; /* Use default method. */ + src->mgr.resync_to_restart = jpeg_resync_to_restart; /* Use default. */ src->mgr.term_source = our_common_term_source; src->mgr.bytes_in_buffer = 0; src->mgr.next_input_byte = NULL; @@ -6515,7 +6536,7 @@ jpeg_load_body (struct frame *f, struct image *img, /* Customize libjpeg's error handling to call my_error_exit when an error is detected. This function will perform a longjmp. */ - mgr->cinfo.err = fn_jpeg_std_error (&mgr->pub); + mgr->cinfo.err = jpeg_std_error (&mgr->pub); mgr->pub.error_exit = my_error_exit; if (sys_setjmp (mgr->setjmp_buffer)) { @@ -6541,7 +6562,7 @@ jpeg_load_body (struct frame *f, struct image *img, /* Close the input file and destroy the JPEG object. */ if (fp) fclose (fp); - fn_jpeg_destroy_decompress (&mgr->cinfo); + jpeg_destroy_decompress (&mgr->cinfo); /* If we already have an XImage, free that. */ x_destroy_x_image (ximg); @@ -6553,7 +6574,7 @@ jpeg_load_body (struct frame *f, struct image *img, /* Create the JPEG decompression object. Let it read from fp. Read the JPEG image header. */ - fn_jpeg_CreateDecompress (&mgr->cinfo, JPEG_LIB_VERSION, sizeof *&mgr->cinfo); + jpeg_CreateDecompress (&mgr->cinfo, JPEG_LIB_VERSION, sizeof *&mgr->cinfo); if (NILP (specified_data)) jpeg_file_src (&mgr->cinfo, fp); @@ -6561,12 +6582,12 @@ jpeg_load_body (struct frame *f, struct image *img, jpeg_memory_src (&mgr->cinfo, SDATA (specified_data), SBYTES (specified_data)); - fn_jpeg_read_header (&mgr->cinfo, 1); + jpeg_read_header (&mgr->cinfo, 1); /* Customize decompression so that color quantization will be used. Start decompression. */ mgr->cinfo.quantize_colors = 1; - fn_jpeg_start_decompress (&mgr->cinfo); + jpeg_start_decompress (&mgr->cinfo); width = img->width = mgr->cinfo.output_width; height = img->height = mgr->cinfo.output_height; @@ -6629,14 +6650,14 @@ jpeg_load_body (struct frame *f, struct image *img, JPOOL_IMAGE, row_stride, 1); for (y = 0; y < height; ++y) { - fn_jpeg_read_scanlines (&mgr->cinfo, buffer, 1); + jpeg_read_scanlines (&mgr->cinfo, buffer, 1); for (x = 0; x < mgr->cinfo.output_width; ++x) XPutPixel (ximg, x, y, colors[buffer[0][x]]); } /* Clean up. */ - fn_jpeg_finish_decompress (&mgr->cinfo); - fn_jpeg_destroy_decompress (&mgr->cinfo); + jpeg_finish_decompress (&mgr->cinfo); + jpeg_destroy_decompress (&mgr->cinfo); if (fp) fclose (fp); @@ -6760,22 +6781,22 @@ tiff_image_p (Lisp_Object object) #ifdef HAVE_TIFF -#include +# include -#ifdef WINDOWSNT +# ifdef WINDOWSNT /* TIFF library details. */ -DEF_IMGLIB_FN (TIFFErrorHandler, TIFFSetErrorHandler, (TIFFErrorHandler)); -DEF_IMGLIB_FN (TIFFErrorHandler, TIFFSetWarningHandler, (TIFFErrorHandler)); -DEF_IMGLIB_FN (TIFF *, TIFFOpen, (const char *, const char *)); -DEF_IMGLIB_FN (TIFF *, TIFFClientOpen, (const char *, const char *, thandle_t, - TIFFReadWriteProc, TIFFReadWriteProc, - TIFFSeekProc, TIFFCloseProc, TIFFSizeProc, - TIFFMapFileProc, TIFFUnmapFileProc)); -DEF_IMGLIB_FN (int, TIFFGetField, (TIFF *, ttag_t, ...)); -DEF_IMGLIB_FN (int, TIFFReadRGBAImage, (TIFF *, uint32, uint32, uint32 *, int)); -DEF_IMGLIB_FN (void, TIFFClose, (TIFF *)); -DEF_IMGLIB_FN (int, TIFFSetDirectory, (TIFF *, tdir_t)); +DEF_DLL_FN (TIFFErrorHandler, TIFFSetErrorHandler, (TIFFErrorHandler)); +DEF_DLL_FN (TIFFErrorHandler, TIFFSetWarningHandler, (TIFFErrorHandler)); +DEF_DLL_FN (TIFF *, TIFFOpen, (const char *, const char *)); +DEF_DLL_FN (TIFF *, TIFFClientOpen, + (const char *, const char *, thandle_t, TIFFReadWriteProc, + TIFFReadWriteProc, TIFFSeekProc, TIFFCloseProc, TIFFSizeProc, + TIFFMapFileProc, TIFFUnmapFileProc)); +DEF_DLL_FN (int, TIFFGetField, (TIFF *, ttag_t, ...)); +DEF_DLL_FN (int, TIFFReadRGBAImage, (TIFF *, uint32, uint32, uint32 *, int)); +DEF_DLL_FN (void, TIFFClose, (TIFF *)); +DEF_DLL_FN (int, TIFFSetDirectory, (TIFF *, tdir_t)); static bool init_tiff_functions (void) @@ -6785,28 +6806,36 @@ init_tiff_functions (void) if (!(library = w32_delayed_load (Qtiff))) return 0; - LOAD_IMGLIB_FN (library, TIFFSetErrorHandler); - LOAD_IMGLIB_FN (library, TIFFSetWarningHandler); - LOAD_IMGLIB_FN (library, TIFFOpen); - LOAD_IMGLIB_FN (library, TIFFClientOpen); - LOAD_IMGLIB_FN (library, TIFFGetField); - LOAD_IMGLIB_FN (library, TIFFReadRGBAImage); - LOAD_IMGLIB_FN (library, TIFFClose); - LOAD_IMGLIB_FN (library, TIFFSetDirectory); + LOAD_DLL_FN (library, TIFFSetErrorHandler); + LOAD_DLL_FN (library, TIFFSetWarningHandler); + LOAD_DLL_FN (library, TIFFOpen); + LOAD_DLL_FN (library, TIFFClientOpen); + LOAD_DLL_FN (library, TIFFGetField); + LOAD_DLL_FN (library, TIFFReadRGBAImage); + LOAD_DLL_FN (library, TIFFClose); + LOAD_DLL_FN (library, TIFFSetDirectory); return 1; } -#else +# undef TIFFClientOpen +# undef TIFFClose +# undef TIFFGetField +# undef TIFFOpen +# undef TIFFReadRGBAImage +# undef TIFFSetDirectory +# undef TIFFSetErrorHandler +# undef TIFFSetWarningHandler -#define fn_TIFFSetErrorHandler TIFFSetErrorHandler -#define fn_TIFFSetWarningHandler TIFFSetWarningHandler -#define fn_TIFFOpen TIFFOpen -#define fn_TIFFClientOpen TIFFClientOpen -#define fn_TIFFGetField TIFFGetField -#define fn_TIFFReadRGBAImage TIFFReadRGBAImage -#define fn_TIFFClose TIFFClose -#define fn_TIFFSetDirectory TIFFSetDirectory -#endif /* WINDOWSNT */ +# define TIFFClientOpen fn_TIFFClientOpen +# define TIFFClose fn_TIFFClose +# define TIFFGetField fn_TIFFGetField +# define TIFFOpen fn_TIFFOpen +# define TIFFReadRGBAImage fn_TIFFReadRGBAImage +# define TIFFSetDirectory fn_TIFFSetDirectory +# define TIFFSetErrorHandler fn_TIFFSetErrorHandler +# define TIFFSetWarningHandler fn_TIFFSetWarningHandler + +# endif /* WINDOWSNT */ /* Reading from a memory buffer for TIFF images Based on the PNG @@ -6904,11 +6933,11 @@ tiff_size_of_memory (thandle_t data) compiler error compiling tiff_handler, see Bugzilla bug #17406 (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17406). Declaring this function as external works around that problem. */ -#if defined (__MINGW32__) && __GNUC__ == 3 -# define MINGW_STATIC -#else -# define MINGW_STATIC static -#endif +# if defined (__MINGW32__) && __GNUC__ == 3 +# define MINGW_STATIC +# else +# define MINGW_STATIC static +# endif MINGW_STATIC void tiff_handler (const char *, const char *, const char *, va_list) @@ -6927,7 +6956,7 @@ tiff_handler (const char *log_format, const char *title, add_to_log (log_format, build_string (title), make_string (buf, max (0, min (len, sizeof buf - 1)))); } -#undef MINGW_STATIC +# undef MINGW_STATIC static void tiff_error_handler (const char *, const char *, va_list) ATTRIBUTE_FORMAT_PRINTF (2, 0); @@ -6966,8 +6995,8 @@ tiff_load (struct frame *f, struct image *img) specified_file = image_spec_value (img->spec, QCfile, NULL); specified_data = image_spec_value (img->spec, QCdata, NULL); - fn_TIFFSetErrorHandler ((TIFFErrorHandler) tiff_error_handler); - fn_TIFFSetWarningHandler ((TIFFErrorHandler) tiff_warning_handler); + TIFFSetErrorHandler ((TIFFErrorHandler) tiff_error_handler); + TIFFSetWarningHandler ((TIFFErrorHandler) tiff_warning_handler); if (NILP (specified_data)) { @@ -6978,12 +7007,12 @@ tiff_load (struct frame *f, struct image *img) image_error ("Cannot find image file `%s'", specified_file, Qnil); return 0; } -#ifdef WINDOWSNT +# ifdef WINDOWSNT file = ansi_encode_filename (file); -#endif +# endif /* Try to open the image file. */ - tiff = fn_TIFFOpen (SSDATA (file), "r"); + tiff = TIFFOpen (SSDATA (file), "r"); if (tiff == NULL) { image_error ("Cannot open `%s'", file, Qnil); @@ -7003,14 +7032,14 @@ tiff_load (struct frame *f, struct image *img) memsrc.len = SBYTES (specified_data); memsrc.index = 0; - tiff = fn_TIFFClientOpen ("memory_source", "r", (thandle_t)&memsrc, - tiff_read_from_memory, - tiff_write_from_memory, - tiff_seek_in_memory, - tiff_close_memory, - tiff_size_of_memory, - tiff_mmap_memory, - tiff_unmap_memory); + tiff = TIFFClientOpen ("memory_source", "r", (thandle_t)&memsrc, + tiff_read_from_memory, + tiff_write_from_memory, + tiff_seek_in_memory, + tiff_close_memory, + tiff_size_of_memory, + tiff_mmap_memory, + tiff_unmap_memory); if (!tiff) { @@ -7024,24 +7053,24 @@ tiff_load (struct frame *f, struct image *img) { EMACS_INT ino = XFASTINT (image); if (! (TYPE_MINIMUM (tdir_t) <= ino && ino <= TYPE_MAXIMUM (tdir_t) - && fn_TIFFSetDirectory (tiff, ino))) + && TIFFSetDirectory (tiff, ino))) { image_error ("Invalid image number `%s' in image `%s'", image, img->spec); - fn_TIFFClose (tiff); + TIFFClose (tiff); return 0; } } /* Get width and height of the image, and allocate a raster buffer of width x height 32-bit values. */ - fn_TIFFGetField (tiff, TIFFTAG_IMAGEWIDTH, &width); - fn_TIFFGetField (tiff, TIFFTAG_IMAGELENGTH, &height); + TIFFGetField (tiff, TIFFTAG_IMAGEWIDTH, &width); + TIFFGetField (tiff, TIFFTAG_IMAGELENGTH, &height); if (!check_image_size (f, width, height)) { image_error ("Invalid image size (see `max-image-size')", Qnil, Qnil); - fn_TIFFClose (tiff); + TIFFClose (tiff); return 0; } @@ -7050,16 +7079,16 @@ tiff_load (struct frame *f, struct image *img) && image_create_x_image_and_pixmap (f, img, width, height, 0, &ximg, 0))) { - fn_TIFFClose (tiff); + TIFFClose (tiff); return 0; } buf = xmalloc (sizeof *buf * width * height); - rc = fn_TIFFReadRGBAImage (tiff, width, height, buf, 0); + rc = TIFFReadRGBAImage (tiff, width, height, buf, 0); /* Count the number of images in the file. */ - for (count = 1; fn_TIFFSetDirectory (tiff, count); count++) + for (count = 1; TIFFSetDirectory (tiff, count); count++) continue; if (count > 1) @@ -7067,7 +7096,7 @@ tiff_load (struct frame *f, struct image *img) Fcons (make_number (count), img->lisp_data)); - fn_TIFFClose (tiff); + TIFFClose (tiff); if (!rc) { image_error ("Error reading TIFF image `%s'", img->spec, Qnil); @@ -7093,11 +7122,11 @@ tiff_load (struct frame *f, struct image *img) } } -#ifdef COLOR_TABLE_SUPPORT +# ifdef COLOR_TABLE_SUPPORT /* Remember the colors allocated for the image. Free the color table. */ img->colors = colors_in_color_table (&img->ncolors); free_color_table (); -#endif /* COLOR_TABLE_SUPPORT */ +# endif /* COLOR_TABLE_SUPPORT */ img->width = width; img->height = height; @@ -7114,9 +7143,8 @@ tiff_load (struct frame *f, struct image *img) return 1; } -#else /* HAVE_TIFF */ +#elif defined HAVE_NS -#ifdef HAVE_NS static bool tiff_load (struct frame *f, struct image *img) { @@ -7124,9 +7152,8 @@ tiff_load (struct frame *f, struct image *img) image_spec_value (img->spec, QCfile, NULL), image_spec_value (img->spec, QCdata, NULL)); } -#endif /* HAVE_NS */ -#endif /* !HAVE_TIFF */ +#endif @@ -7226,54 +7253,54 @@ gif_image_p (Lisp_Object object) #ifdef HAVE_GIF -#if defined (HAVE_NTGUI) +# ifdef HAVE_NTGUI /* winuser.h might define DrawText to DrawTextA or DrawTextW. Undefine before redefining to avoid a preprocessor warning. */ -#ifdef DrawText -#undef DrawText -#endif +# ifdef DrawText +# undef DrawText +# endif /* avoid conflict with QuickdrawText.h */ -#define DrawText gif_DrawText -#include -#undef DrawText +# define DrawText gif_DrawText +# include +# undef DrawText /* Giflib before 5.0 didn't define these macros (used only if HAVE_NTGUI). */ -#ifndef GIFLIB_MINOR -#define GIFLIB_MINOR 0 -#endif -#ifndef GIFLIB_RELEASE -#define GIFLIB_RELEASE 0 -#endif +# ifndef GIFLIB_MINOR +# define GIFLIB_MINOR 0 +# endif +# ifndef GIFLIB_RELEASE +# define GIFLIB_RELEASE 0 +# endif -#else /* HAVE_NTGUI */ +# else /* HAVE_NTGUI */ -#include +# include -#endif /* HAVE_NTGUI */ +# endif /* HAVE_NTGUI */ /* Giflib before 5.0 didn't define these macros. */ -#ifndef GIFLIB_MAJOR -#define GIFLIB_MAJOR 4 -#endif +# ifndef GIFLIB_MAJOR +# define GIFLIB_MAJOR 4 +# endif -#ifdef WINDOWSNT +# ifdef WINDOWSNT /* GIF library details. */ -#if 5 < GIFLIB_MAJOR + (1 <= GIFLIB_MINOR) -DEF_IMGLIB_FN (int, DGifCloseFile, (GifFileType *, int *)); -#else -DEF_IMGLIB_FN (int, DGifCloseFile, (GifFileType *)); -#endif -DEF_IMGLIB_FN (int, DGifSlurp, (GifFileType *)); -#if GIFLIB_MAJOR < 5 -DEF_IMGLIB_FN (GifFileType *, DGifOpen, (void *, InputFunc)); -DEF_IMGLIB_FN (GifFileType *, DGifOpenFileName, (const char *)); -#else -DEF_IMGLIB_FN (GifFileType *, DGifOpen, (void *, InputFunc, int *)); -DEF_IMGLIB_FN (GifFileType *, DGifOpenFileName, (const char *, int *)); -DEF_IMGLIB_FN (char *, GifErrorString, (int)); -#endif +# if 5 < GIFLIB_MAJOR + (1 <= GIFLIB_MINOR) +DEF_DLL_FN (int, DGifCloseFile, (GifFileType *, int *)); +# else +DEF_DLL_FN (int, DGifCloseFile, (GifFileType *)); +# endif +DEF_DLL_FN (int, DGifSlurp, (GifFileType *)); +# if GIFLIB_MAJOR < 5 +DEF_DLL_FN (GifFileType *, DGifOpen, (void *, InputFunc)); +DEF_DLL_FN (GifFileType *, DGifOpenFileName, (const char *)); +# else +DEF_DLL_FN (GifFileType *, DGifOpen, (void *, InputFunc, int *)); +DEF_DLL_FN (GifFileType *, DGifOpenFileName, (const char *, int *)); +DEF_DLL_FN (char *, GifErrorString, (int)); +# endif static bool init_gif_functions (void) @@ -7283,27 +7310,29 @@ init_gif_functions (void) if (!(library = w32_delayed_load (Qgif))) return 0; - LOAD_IMGLIB_FN (library, DGifCloseFile); - LOAD_IMGLIB_FN (library, DGifSlurp); - LOAD_IMGLIB_FN (library, DGifOpen); - LOAD_IMGLIB_FN (library, DGifOpenFileName); -#if GIFLIB_MAJOR >= 5 - LOAD_IMGLIB_FN (library, GifErrorString); -#endif + LOAD_DLL_FN (library, DGifCloseFile); + LOAD_DLL_FN (library, DGifSlurp); + LOAD_DLL_FN (library, DGifOpen); + LOAD_DLL_FN (library, DGifOpenFileName); +# if GIFLIB_MAJOR >= 5 + LOAD_DLL_FN (library, GifErrorString); +# endif return 1; } -#else +# undef DGifCloseFile +# undef DGifOpen +# undef DGifOpenFileName +# undef DGifSlurp +# undef GifErrorString -#define fn_DGifCloseFile DGifCloseFile -#define fn_DGifSlurp DGifSlurp -#define fn_DGifOpen DGifOpen -#define fn_DGifOpenFileName DGifOpenFileName -#if 5 <= GIFLIB_MAJOR -# define fn_GifErrorString GifErrorString -#endif +# define DGifCloseFile fn_DGifCloseFile +# define DGifOpen fn_DGifOpen +# define DGifOpenFileName fn_DGifOpenFileName +# define DGifSlurp fn_DGifSlurp +# define GifErrorString fn_GifErrorString -#endif /* WINDOWSNT */ +# endif /* WINDOWSNT */ /* Reading a GIF image from memory Based on the PNG memory stuff to a certain extent. */ @@ -7340,9 +7369,9 @@ gif_close (GifFileType *gif, int *err) int retval; #if 5 < GIFLIB_MAJOR + (1 <= GIFLIB_MINOR) - retval = fn_DGifCloseFile (gif, err); + retval = DGifCloseFile (gif, err); #else - retval = fn_DGifCloseFile (gif); + retval = DGifCloseFile (gif); #if GIFLIB_MAJOR >= 5 if (err) *err = gif->Error; @@ -7390,18 +7419,18 @@ gif_load (struct frame *f, struct image *img) /* Open the GIF file. */ #if GIFLIB_MAJOR < 5 - gif = fn_DGifOpenFileName (SSDATA (file)); + gif = DGifOpenFileName (SSDATA (file)); if (gif == NULL) { image_error ("Cannot open `%s'", file, Qnil); return 0; } #else - gif = fn_DGifOpenFileName (SSDATA (file), &gif_err); + gif = DGifOpenFileName (SSDATA (file), &gif_err); if (gif == NULL) { image_error ("Cannot open `%s': %s", - file, build_string (fn_GifErrorString (gif_err))); + file, build_string (GifErrorString (gif_err))); return 0; } #endif @@ -7421,18 +7450,18 @@ gif_load (struct frame *f, struct image *img) memsrc.index = 0; #if GIFLIB_MAJOR < 5 - gif = fn_DGifOpen (&memsrc, gif_read_from_memory); + gif = DGifOpen (&memsrc, gif_read_from_memory); if (!gif) { image_error ("Cannot open memory source `%s'", img->spec, Qnil); return 0; } #else - gif = fn_DGifOpen (&memsrc, gif_read_from_memory, &gif_err); + gif = DGifOpen (&memsrc, gif_read_from_memory, &gif_err); if (!gif) { image_error ("Cannot open memory source `%s': %s", - img->spec, build_string (fn_GifErrorString (gif_err))); + img->spec, build_string (GifErrorString (gif_err))); return 0; } #endif @@ -7447,7 +7476,7 @@ gif_load (struct frame *f, struct image *img) } /* Read entire contents. */ - rc = fn_DGifSlurp (gif); + rc = DGifSlurp (gif); if (rc == GIF_ERROR || gif->ImageCount <= 0) { image_error ("Error reading `%s'", img->spec, Qnil); @@ -7681,7 +7710,7 @@ gif_load (struct frame *f, struct image *img) if (gif_close (gif, &gif_err) == GIF_ERROR) { #if 5 <= GIFLIB_MAJOR - char *error_text = fn_GifErrorString (gif_err); + char *error_text = GifErrorString (gif_err); if (error_text) image_error ("Error closing `%s': %s", @@ -8593,7 +8622,7 @@ and `imagemagick-types-inhibit'. */) SVG ***********************************************************************/ -#if defined (HAVE_RSVG) +#ifdef HAVE_RSVG /* Function prototypes. */ @@ -8641,11 +8670,11 @@ static const struct image_keyword svg_format[SVG_LAST] = {":background", IMAGE_STRING_OR_NIL_VALUE, 0} }; -#if defined HAVE_NTGUI && defined WINDOWSNT +# if defined HAVE_NTGUI && defined WINDOWSNT static bool init_svg_functions (void); -#else +# else #define init_svg_functions NULL -#endif +# endif /* Structure describing the image type `svg'. Its the same type of structure defined for all image formats, handled by emacs image @@ -8679,32 +8708,34 @@ svg_image_p (Lisp_Object object) return fmt[SVG_FILE].count + fmt[SVG_DATA].count == 1; } -#include +# include -#ifdef WINDOWSNT +# ifdef WINDOWSNT /* SVG library functions. */ -DEF_IMGLIB_FN (RsvgHandle *, rsvg_handle_new, (void)); -DEF_IMGLIB_FN (void, rsvg_handle_get_dimensions, (RsvgHandle *, RsvgDimensionData *)); -DEF_IMGLIB_FN (gboolean, rsvg_handle_write, (RsvgHandle *, const guchar *, gsize, GError **)); -DEF_IMGLIB_FN (gboolean, rsvg_handle_close, (RsvgHandle *, GError **)); -DEF_IMGLIB_FN (GdkPixbuf *, rsvg_handle_get_pixbuf, (RsvgHandle *)); -DEF_IMGLIB_FN (void, rsvg_handle_set_base_uri, (RsvgHandle *, const char *)); - -DEF_IMGLIB_FN (int, gdk_pixbuf_get_width, (const GdkPixbuf *)); -DEF_IMGLIB_FN (int, gdk_pixbuf_get_height, (const GdkPixbuf *)); -DEF_IMGLIB_FN (guchar *, gdk_pixbuf_get_pixels, (const GdkPixbuf *)); -DEF_IMGLIB_FN (int, gdk_pixbuf_get_rowstride, (const GdkPixbuf *)); -DEF_IMGLIB_FN (GdkColorspace, gdk_pixbuf_get_colorspace, (const GdkPixbuf *)); -DEF_IMGLIB_FN (int, gdk_pixbuf_get_n_channels, (const GdkPixbuf *)); -DEF_IMGLIB_FN (gboolean, gdk_pixbuf_get_has_alpha, (const GdkPixbuf *)); -DEF_IMGLIB_FN (int, gdk_pixbuf_get_bits_per_sample, (const GdkPixbuf *)); - -#if ! GLIB_CHECK_VERSION (2, 36, 0) -DEF_IMGLIB_FN (void, g_type_init, (void)); -#endif -DEF_IMGLIB_FN (void, g_object_unref, (gpointer)); -DEF_IMGLIB_FN (void, g_error_free, (GError *)); +DEF_DLL_FN (RsvgHandle *, rsvg_handle_new, (void)); +DEF_DLL_FN (void, rsvg_handle_get_dimensions, + (RsvgHandle *, RsvgDimensionData *)); +DEF_DLL_FN (gboolean, rsvg_handle_write, + (RsvgHandle *, const guchar *, gsize, GError **)); +DEF_DLL_FN (gboolean, rsvg_handle_close, (RsvgHandle *, GError **)); +DEF_DLL_FN (GdkPixbuf *, rsvg_handle_get_pixbuf, (RsvgHandle *)); +DEF_DLL_FN (void, rsvg_handle_set_base_uri, (RsvgHandle *, const char *)); + +DEF_DLL_FN (int, gdk_pixbuf_get_width, (const GdkPixbuf *)); +DEF_DLL_FN (int, gdk_pixbuf_get_height, (const GdkPixbuf *)); +DEF_DLL_FN (guchar *, gdk_pixbuf_get_pixels, (const GdkPixbuf *)); +DEF_DLL_FN (int, gdk_pixbuf_get_rowstride, (const GdkPixbuf *)); +DEF_DLL_FN (GdkColorspace, gdk_pixbuf_get_colorspace, (const GdkPixbuf *)); +DEF_DLL_FN (int, gdk_pixbuf_get_n_channels, (const GdkPixbuf *)); +DEF_DLL_FN (gboolean, gdk_pixbuf_get_has_alpha, (const GdkPixbuf *)); +DEF_DLL_FN (int, gdk_pixbuf_get_bits_per_sample, (const GdkPixbuf *)); + +# if ! GLIB_CHECK_VERSION (2, 36, 0) +DEF_DLL_FN (void, g_type_init, (void)); +# endif +DEF_DLL_FN (void, g_object_unref, (gpointer)); +DEF_DLL_FN (void, g_error_free, (GError *)); Lisp_Object Qgdk_pixbuf, Qglib, Qgobject; @@ -8724,56 +8755,71 @@ init_svg_functions (void) return 0; } - LOAD_IMGLIB_FN (library, rsvg_handle_new); - LOAD_IMGLIB_FN (library, rsvg_handle_get_dimensions); - LOAD_IMGLIB_FN (library, rsvg_handle_write); - LOAD_IMGLIB_FN (library, rsvg_handle_close); - LOAD_IMGLIB_FN (library, rsvg_handle_get_pixbuf); - LOAD_IMGLIB_FN (library, rsvg_handle_set_base_uri); - - LOAD_IMGLIB_FN (gdklib, gdk_pixbuf_get_width); - LOAD_IMGLIB_FN (gdklib, gdk_pixbuf_get_height); - LOAD_IMGLIB_FN (gdklib, gdk_pixbuf_get_pixels); - LOAD_IMGLIB_FN (gdklib, gdk_pixbuf_get_rowstride); - LOAD_IMGLIB_FN (gdklib, gdk_pixbuf_get_colorspace); - LOAD_IMGLIB_FN (gdklib, gdk_pixbuf_get_n_channels); - LOAD_IMGLIB_FN (gdklib, gdk_pixbuf_get_has_alpha); - LOAD_IMGLIB_FN (gdklib, gdk_pixbuf_get_bits_per_sample); - -#if ! GLIB_CHECK_VERSION (2, 36, 0) - LOAD_IMGLIB_FN (gobject, g_type_init); -#endif - LOAD_IMGLIB_FN (gobject, g_object_unref); - LOAD_IMGLIB_FN (glib, g_error_free); + LOAD_DLL_FN (library, rsvg_handle_new); + LOAD_DLL_FN (library, rsvg_handle_get_dimensions); + LOAD_DLL_FN (library, rsvg_handle_write); + LOAD_DLL_FN (library, rsvg_handle_close); + LOAD_DLL_FN (library, rsvg_handle_get_pixbuf); + LOAD_DLL_FN (library, rsvg_handle_set_base_uri); + + LOAD_DLL_FN (gdklib, gdk_pixbuf_get_width); + LOAD_DLL_FN (gdklib, gdk_pixbuf_get_height); + LOAD_DLL_FN (gdklib, gdk_pixbuf_get_pixels); + LOAD_DLL_FN (gdklib, gdk_pixbuf_get_rowstride); + LOAD_DLL_FN (gdklib, gdk_pixbuf_get_colorspace); + LOAD_DLL_FN (gdklib, gdk_pixbuf_get_n_channels); + LOAD_DLL_FN (gdklib, gdk_pixbuf_get_has_alpha); + LOAD_DLL_FN (gdklib, gdk_pixbuf_get_bits_per_sample); + +# if ! GLIB_CHECK_VERSION (2, 36, 0) + LOAD_DLL_FN (gobject, g_type_init); +# endif + LOAD_DLL_FN (gobject, g_object_unref); + LOAD_DLL_FN (glib, g_error_free); return 1; } -#else /* The following aliases for library functions allow dynamic loading to be used on some platforms. */ -#define fn_rsvg_handle_new rsvg_handle_new -#define fn_rsvg_handle_get_dimensions rsvg_handle_get_dimensions -#define fn_rsvg_handle_write rsvg_handle_write -#define fn_rsvg_handle_close rsvg_handle_close -#define fn_rsvg_handle_get_pixbuf rsvg_handle_get_pixbuf -#define fn_rsvg_handle_set_base_uri rsvg_handle_set_base_uri - -#define fn_gdk_pixbuf_get_width gdk_pixbuf_get_width -#define fn_gdk_pixbuf_get_height gdk_pixbuf_get_height -#define fn_gdk_pixbuf_get_pixels gdk_pixbuf_get_pixels -#define fn_gdk_pixbuf_get_rowstride gdk_pixbuf_get_rowstride -#define fn_gdk_pixbuf_get_colorspace gdk_pixbuf_get_colorspace -#define fn_gdk_pixbuf_get_n_channels gdk_pixbuf_get_n_channels -#define fn_gdk_pixbuf_get_has_alpha gdk_pixbuf_get_has_alpha -#define fn_gdk_pixbuf_get_bits_per_sample gdk_pixbuf_get_bits_per_sample -#if ! GLIB_CHECK_VERSION (2, 36, 0) -#define fn_g_type_init g_type_init -#endif -#define fn_g_object_unref g_object_unref -#define fn_g_error_free g_error_free -#endif /* !WINDOWSNT */ +# undef gdk_pixbuf_get_bits_per_sample +# undef gdk_pixbuf_get_colorspace +# undef gdk_pixbuf_get_has_alpha +# undef gdk_pixbuf_get_height +# undef gdk_pixbuf_get_n_channels +# undef gdk_pixbuf_get_pixels +# undef gdk_pixbuf_get_rowstride +# undef gdk_pixbuf_get_width +# undef g_error_free +# undef g_object_unref +# undef g_type_init +# undef rsvg_handle_close +# undef rsvg_handle_get_dimensions +# undef rsvg_handle_get_pixbuf +# undef rsvg_handle_new +# undef rsvg_handle_set_base_uri +# undef rsvg_handle_write + +# define gdk_pixbuf_get_bits_per_sample fn_gdk_pixbuf_get_bits_per_sample +# define gdk_pixbuf_get_colorspace fn_gdk_pixbuf_get_colorspace +# define gdk_pixbuf_get_has_alpha fn_gdk_pixbuf_get_has_alpha +# define gdk_pixbuf_get_height fn_gdk_pixbuf_get_height +# define gdk_pixbuf_get_n_channels fn_gdk_pixbuf_get_n_channels +# define gdk_pixbuf_get_pixels fn_gdk_pixbuf_get_pixels +# define gdk_pixbuf_get_rowstride fn_gdk_pixbuf_get_rowstride +# define gdk_pixbuf_get_width fn_gdk_pixbuf_get_width +# define g_error_free fn_g_error_free +# define g_object_unref fn_g_object_unref +# define g_type_init fn_g_type_init +# define rsvg_handle_close fn_rsvg_handle_close +# define rsvg_handle_get_dimensions fn_rsvg_handle_get_dimensions +# define rsvg_handle_get_pixbuf fn_rsvg_handle_get_pixbuf +# define rsvg_handle_new fn_rsvg_handle_new +# define rsvg_handle_set_base_uri fn_rsvg_handle_set_base_uri +# define rsvg_handle_write fn_rsvg_handle_write + +# endif /* !WINDOWSNT */ /* Load SVG image IMG for use on frame F. Value is true if successful. */ @@ -8862,28 +8908,28 @@ svg_load_image (struct frame *f, /* Pointer to emacs frame structure. * #if ! GLIB_CHECK_VERSION (2, 36, 0) /* g_type_init is a glib function that must be called prior to using gnome type library functions (obsolete since 2.36.0). */ - fn_g_type_init (); + g_type_init (); #endif /* Make a handle to a new rsvg object. */ - rsvg_handle = fn_rsvg_handle_new (); + rsvg_handle = rsvg_handle_new (); /* Set base_uri for properly handling referenced images (via 'href'). See rsvg bug 596114 - "image refs are relative to curdir, not .svg file" (https://bugzilla.gnome.org/show_bug.cgi?id=596114). */ if (filename) - fn_rsvg_handle_set_base_uri(rsvg_handle, filename); + rsvg_handle_set_base_uri(rsvg_handle, filename); /* Parse the contents argument and fill in the rsvg_handle. */ - fn_rsvg_handle_write (rsvg_handle, contents, size, &err); + rsvg_handle_write (rsvg_handle, contents, size, &err); if (err) goto rsvg_error; /* The parsing is complete, rsvg_handle is ready to used, close it for further writes. */ - fn_rsvg_handle_close (rsvg_handle, &err); + rsvg_handle_close (rsvg_handle, &err); if (err) goto rsvg_error; - fn_rsvg_handle_get_dimensions (rsvg_handle, &dimension_data); + rsvg_handle_get_dimensions (rsvg_handle, &dimension_data); if (! check_image_size (f, dimension_data.width, dimension_data.height)) { image_error ("Invalid image size (see `max-image-size')", Qnil, Qnil); @@ -8892,26 +8938,26 @@ svg_load_image (struct frame *f, /* Pointer to emacs frame structure. * /* We can now get a valid pixel buffer from the svg file, if all went ok. */ - pixbuf = fn_rsvg_handle_get_pixbuf (rsvg_handle); + pixbuf = rsvg_handle_get_pixbuf (rsvg_handle); if (!pixbuf) goto rsvg_error; - fn_g_object_unref (rsvg_handle); + g_object_unref (rsvg_handle); /* Extract some meta data from the svg handle. */ - width = fn_gdk_pixbuf_get_width (pixbuf); - height = fn_gdk_pixbuf_get_height (pixbuf); - pixels = fn_gdk_pixbuf_get_pixels (pixbuf); - rowstride = fn_gdk_pixbuf_get_rowstride (pixbuf); + width = gdk_pixbuf_get_width (pixbuf); + height = gdk_pixbuf_get_height (pixbuf); + pixels = gdk_pixbuf_get_pixels (pixbuf); + rowstride = gdk_pixbuf_get_rowstride (pixbuf); /* Validate the svg meta data. */ - eassert (fn_gdk_pixbuf_get_colorspace (pixbuf) == GDK_COLORSPACE_RGB); - eassert (fn_gdk_pixbuf_get_n_channels (pixbuf) == 4); - eassert (fn_gdk_pixbuf_get_has_alpha (pixbuf)); - eassert (fn_gdk_pixbuf_get_bits_per_sample (pixbuf) == 8); + eassert (gdk_pixbuf_get_colorspace (pixbuf) == GDK_COLORSPACE_RGB); + eassert (gdk_pixbuf_get_n_channels (pixbuf) == 4); + eassert (gdk_pixbuf_get_has_alpha (pixbuf)); + eassert (gdk_pixbuf_get_bits_per_sample (pixbuf) == 8); /* Try to create a x pixmap to hold the svg pixmap. */ if (!image_create_x_image_and_pixmap (f, img, width, height, 0, &ximg, 0)) { - fn_g_object_unref (pixbuf); + g_object_unref (pixbuf); return 0; } @@ -8968,7 +9014,7 @@ svg_load_image (struct frame *f, /* Pointer to emacs frame structure. * free_color_table (); #endif /* COLOR_TABLE_SUPPORT */ - fn_g_object_unref (pixbuf); + g_object_unref (pixbuf); img->width = width; img->height = height; @@ -8983,11 +9029,11 @@ svg_load_image (struct frame *f, /* Pointer to emacs frame structure. * return 1; rsvg_error: - fn_g_object_unref (rsvg_handle); + g_object_unref (rsvg_handle); /* FIXME: Use error->message so the user knows what is the actual problem with the image. */ image_error ("Error parsing SVG image `%s'", img->spec, Qnil); - fn_g_error_free (err); + g_error_free (err); return 0; } diff --git a/src/w32.h b/src/w32.h index e0aedcb..18e12b2 100644 --- a/src/w32.h +++ b/src/w32.h @@ -225,4 +225,17 @@ extern ssize_t emacs_gnutls_push (gnutls_transport_ptr_t p, const void* buf, size_t sz); #endif /* HAVE_GNUTLS */ +/* Definine a function that will be loaded from a DLL. */ +#define DEF_DLL_FN(type, func, args) static type (FAR CDECL *fn_##func) args + +/* Load a function from the DLL. */ +#define LOAD_DLL_FN(lib, func) \ + do \ + { \ + fn_##func = (void *) GetProcAddress (lib, #func); \ + if (!fn_##func) \ + return false; \ + } \ + while (false) + #endif /* EMACS_W32_H */ diff --git a/src/xml.c b/src/xml.c index d418202..2c521dd 100644 --- a/src/xml.c +++ b/src/xml.c @@ -33,26 +33,17 @@ static Lisp_Object Qlibxml2_dll; #ifdef WINDOWSNT -#include -#include "w32.h" +# include +# include "w32.h" -/* Macro for defining functions that will be loaded from the libxml2 DLL. */ -#define DEF_XML2_FN(rettype,func,args) static rettype (FAR CDECL *fn_##func)args - -/* Macro for loading libxml2 functions from the library. */ -#define LOAD_XML2_FN(lib,func) { \ - fn_##func = (void *) GetProcAddress (lib, #func); \ - if (!fn_##func) goto bad_library; \ - } - -DEF_XML2_FN (htmlDocPtr, htmlReadMemory, +DEF_DLL_FN (htmlDocPtr, htmlReadMemory, (const char *, int, const char *, const char *, int)); -DEF_XML2_FN (xmlDocPtr, xmlReadMemory, +DEF_DLL_FN (xmlDocPtr, xmlReadMemory, (const char *, int, const char *, const char *, int)); -DEF_XML2_FN (xmlNodePtr, xmlDocGetRootElement, (xmlDocPtr)); -DEF_XML2_FN (void, xmlFreeDoc, (xmlDocPtr)); -DEF_XML2_FN (void, xmlCleanupParser, (void)); -DEF_XML2_FN (void, xmlCheckVersion, (int)); +DEF_DLL_FN (xmlNodePtr, xmlDocGetRootElement, (xmlDocPtr)); +DEF_DLL_FN (void, xmlFreeDoc, (xmlDocPtr)); +DEF_DLL_FN (void, xmlCleanupParser, (void)); +DEF_DLL_FN (void, xmlCheckVersion, (int)); static int libxml2_loaded_p (void) @@ -64,14 +55,33 @@ libxml2_loaded_p (void) return 0; } -#else /* !WINDOWSNT */ +# undef htmlReadMemory +# undef xmlCheckVersion +# undef xmlCleanupParser +# undef xmlDocGetRootElement +# undef xmlFreeDoc +# undef xmlReadMemory + +# define htmlReadMemory fn_htmlReadMemory +# define xmlCheckVersion fn_xmlCheckVersion +# define xmlCleanupParser fn_xmlCleanupParser +# define xmlDocGetRootElement fn_xmlDocGetRootElement +# define xmlFreeDoc fn_xmlFreeDoc +# define xmlReadMemory fn_xmlReadMemory + +static bool +load_dll_functions (void) +{ + LOAD_DLL_FN (library, htmlReadMemory); + LOAD_DLL_FN (library, xmlReadMemory); + LOAD_DLL_FN (library, xmlDocGetRootElement); + LOAD_DLL_FN (library, xmlFreeDoc); + LOAD_DLL_FN (library, xmlCleanupParser); + LOAD_DLL_FN (library, xmlCheckVersion); + return true; +} -#define fn_htmlReadMemory htmlReadMemory -#define fn_xmlReadMemory xmlReadMemory -#define fn_xmlDocGetRootElement xmlDocGetRootElement -#define fn_xmlFreeDoc xmlFreeDoc -#define fn_xmlCleanupParser xmlCleanupParser -#define fn_xmlCheckVersion xmlCheckVersion +#else /* !WINDOWSNT */ static int libxml2_loaded_p (void) @@ -97,14 +107,8 @@ init_libxml2_functions (void) return 0; } - /* LOAD_XML2_FN jumps to bad_library if it fails to find the - named function. */ - LOAD_XML2_FN (library, htmlReadMemory); - LOAD_XML2_FN (library, xmlReadMemory); - LOAD_XML2_FN (library, xmlDocGetRootElement); - LOAD_XML2_FN (library, xmlFreeDoc); - LOAD_XML2_FN (library, xmlCleanupParser); - LOAD_XML2_FN (library, xmlCheckVersion); + if (! load_dll_functions ()) + goto bad_library; Vlibrary_cache = Fcons (Fcons (Qlibxml2_dll, Qt), Vlibrary_cache); return 1; @@ -182,7 +186,7 @@ parse_region (Lisp_Object start, Lisp_Object end, Lisp_Object base_url, Lisp_Obj const char *burl = ""; ptrdiff_t istart, iend, istart_byte, iend_byte; - fn_xmlCheckVersion (LIBXML_VERSION); + xmlCheckVersion (LIBXML_VERSION); validate_region (&start, &end); @@ -201,16 +205,16 @@ parse_region (Lisp_Object start, Lisp_Object end, Lisp_Object base_url, Lisp_Obj } if (htmlp) - doc = fn_htmlReadMemory ((char *) BYTE_POS_ADDR (istart_byte), - iend_byte - istart_byte, burl, "utf-8", - HTML_PARSE_RECOVER|HTML_PARSE_NONET| - HTML_PARSE_NOWARNING|HTML_PARSE_NOERROR| - HTML_PARSE_NOBLANKS); + doc = htmlReadMemory ((char *) BYTE_POS_ADDR (istart_byte), + iend_byte - istart_byte, burl, "utf-8", + HTML_PARSE_RECOVER|HTML_PARSE_NONET| + HTML_PARSE_NOWARNING|HTML_PARSE_NOERROR| + HTML_PARSE_NOBLANKS); else - doc = fn_xmlReadMemory ((char *) BYTE_POS_ADDR (istart_byte), - iend_byte - istart_byte, burl, "utf-8", - XML_PARSE_NONET|XML_PARSE_NOWARNING| - XML_PARSE_NOBLANKS |XML_PARSE_NOERROR); + doc = xmlReadMemory ((char *) BYTE_POS_ADDR (istart_byte), + iend_byte - istart_byte, burl, "utf-8", + XML_PARSE_NONET|XML_PARSE_NOWARNING| + XML_PARSE_NOBLANKS |XML_PARSE_NOERROR); if (doc != NULL) { @@ -232,14 +236,14 @@ parse_region (Lisp_Object start, Lisp_Object end, Lisp_Object base_url, Lisp_Obj if (NILP (result)) { /* The document doesn't have toplevel comments or we discarded them. Get the tree the proper way. */ - xmlNode *node = fn_xmlDocGetRootElement (doc); + xmlNode *node = xmlDocGetRootElement (doc); if (node != NULL) result = make_dom (node); } else result = Fcons (intern ("top"), Fcons (Qnil, Fnreverse (Fcons (r, result)))); - fn_xmlFreeDoc (doc); + xmlFreeDoc (doc); } return result; @@ -249,7 +253,7 @@ void xml_cleanup_parser (void) { if (libxml2_loaded_p ()) - fn_xmlCleanupParser (); + xmlCleanupParser (); } DEFUN ("libxml-parse-html-region", Flibxml_parse_html_region, -- 1.9.3