0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-05-19 19:33:45 +02:00

ircd::png: Exclude dependent functions when build missing libpng.

This commit is contained in:
Jason Volk 2022-06-21 20:28:46 -07:00
parent 67d9bff870
commit 7b2af2cf1c

View file

@ -12,11 +12,13 @@
namespace ircd::png namespace ircd::png
{ {
#ifdef HAVE_PNG_H
static void handle_error(png_structp, const char *) noexcept(false); static void handle_error(png_structp, const char *) noexcept(false);
static void handle_warn(png_structp, const char *) noexcept; static void handle_warn(png_structp, const char *) noexcept;
static void *handle_alloc(png_structp, size_t) noexcept; static void *handle_alloc(png_structp, size_t) noexcept;
static void handle_free(png_structp, void *) noexcept; static void handle_free(png_structp, void *) noexcept;
static void handle_read(png_structp, uint8_t *, size_t) noexcept; static void handle_read(png_structp, uint8_t *, size_t) noexcept;
#endif
extern log::log log; extern log::log log;
} }
@ -53,7 +55,7 @@ ircd::png::version_abi
bool bool
ircd::png::is_animated(const const_buffer &buf) ircd::png::is_animated(const const_buffer &buf)
#ifdef PNG_APNG_SUPPORTED #if defined(HAVE_PNG_H) && defined(PNG_APNG_SUPPORTED)
{ {
// Cannot be a PNG // Cannot be a PNG
if(unlikely(size(buf) < 8)) if(unlikely(size(buf) < 8))
@ -100,13 +102,12 @@ ircd::png::is_animated(const const_buffer &buf)
} }
#else #else
{ {
// If there's no libpng there's no reason to decide APNG's right now #warning "An upgraded version of libpng is required for animation detection."
// because they won't be thumbnailed by magick anyway.
#warning "Upgrade your libpng version for animation detection."
return false; return false;
} }
#endif #endif
#ifdef HAVE_PNG_H
void void
ircd::png::handle_read(png_structp handle, ircd::png::handle_read(png_structp handle,
uint8_t *const ptr, uint8_t *const ptr,
@ -139,7 +140,9 @@ noexcept
assert(copied == consumed); assert(copied == consumed);
} }
#endif
#ifdef HAVE_PNG_H
void * void *
ircd::png::handle_alloc(png_structp handle, ircd::png::handle_alloc(png_structp handle,
size_t size) size_t size)
@ -147,7 +150,9 @@ noexcept
{ {
return std::malloc(size); return std::malloc(size);
} }
#endif
#ifdef HAVE_PNG_H
void void
ircd::png::handle_free(png_structp handle, ircd::png::handle_free(png_structp handle,
void *const ptr) void *const ptr)
@ -155,7 +160,9 @@ noexcept
{ {
std::free(ptr); std::free(ptr);
} }
#endif
#ifdef HAVE_PNG_H
void void
ircd::png::handle_warn(png_structp handle, ircd::png::handle_warn(png_structp handle,
const char *const msg) const char *const msg)
@ -168,7 +175,9 @@ noexcept
msg, msg,
}; };
} }
#endif
#ifdef HAVE_PNG_H
void void
ircd::png::handle_error(png_structp handle, ircd::png::handle_error(png_structp handle,
const char *const msg) const char *const msg)
@ -186,3 +195,4 @@ noexcept(false)
"%s", msg "%s", msg
}; };
} }
#endif