From 5cdfad50e677d205e5c6fcff3c5bb465c395cf60 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Tue, 15 Feb 2011 18:07:19 -0800 Subject: [PATCH] Detect and use png_get_io_ptr if provided --- libguac/configure.in | 2 +- libguac/src/protocol.c | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/libguac/configure.in b/libguac/configure.in index c401cf1c..fce89271 100644 --- a/libguac/configure.in +++ b/libguac/configure.in @@ -24,7 +24,7 @@ AC_TYPE_SSIZE_T # Checks for library functions. AC_FUNC_MALLOC AC_FUNC_REALLOC -AC_CHECK_FUNCS([gettimeofday memmove memset select strdup]) +AC_CHECK_FUNCS([gettimeofday memmove memset select strdup png_get_io_ptr]) AC_CONFIG_FILES([Makefile]) AC_OUTPUT diff --git a/libguac/src/protocol.c b/libguac/src/protocol.c index 78cca00f..e942648b 100644 --- a/libguac/src/protocol.c +++ b/libguac/src/protocol.c @@ -248,7 +248,15 @@ void guac_send_copy(GUACIO* io, int srcl, int srcx, int srcy, int w, int h, int void __guac_write_png(png_structp png, png_bytep data, png_size_t length) { - if (guac_write_base64((GUACIO*) png->io_ptr, data, length) < 0) { +#ifdef HAVE_PNG_GET_IO_PTR + GUACIO* io = (GUACIO*) png_get_io_ptr(png); +#else + /* Direct access to io_ptr has been deprecated, but we'll + use it if we have to. */ + GUACIO* io = (GUACIO*) png->io_ptr; +#endif + + if (guac_write_base64(io, data, length) < 0) { perror("Error writing PNG"); png_error(png, "Error writing PNG"); return;