Mercurial > hgrepos > Python2 > PyMuPDF
comparison mupdf-source/thirdparty/leptonica/src/libversions.c @ 2:b50eed0cc0ef upstream
ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4.
The directory name has changed: no version number in the expanded directory now.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Mon, 15 Sep 2025 11:43:07 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 1:1d09e1dec1d9 | 2:b50eed0cc0ef |
|---|---|
| 1 /*====================================================================* | |
| 2 - Copyright (C) 2001 Leptonica. All rights reserved. | |
| 3 - | |
| 4 - Redistribution and use in source and binary forms, with or without | |
| 5 - modification, are permitted provided that the following conditions | |
| 6 - are met: | |
| 7 - 1. Redistributions of source code must retain the above copyright | |
| 8 - notice, this list of conditions and the following disclaimer. | |
| 9 - 2. Redistributions in binary form must reproduce the above | |
| 10 - copyright notice, this list of conditions and the following | |
| 11 - disclaimer in the documentation and/or other materials | |
| 12 - provided with the distribution. | |
| 13 - | |
| 14 - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 15 - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 16 - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
| 17 - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY | |
| 18 - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
| 19 - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
| 20 - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
| 21 - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | |
| 22 - OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | |
| 23 - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
| 24 - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 25 *====================================================================*/ | |
| 26 | |
| 27 /*! | |
| 28 * \file libversions.c | |
| 29 * <pre> | |
| 30 * | |
| 31 * Image library version number | |
| 32 * char *getImagelibVersions() | |
| 33 * </pre> | |
| 34 */ | |
| 35 | |
| 36 #ifdef HAVE_CONFIG_H | |
| 37 #include <config_auto.h> | |
| 38 #endif /* HAVE_CONFIG_H */ | |
| 39 | |
| 40 #include "allheaders.h" | |
| 41 | |
| 42 #if HAVE_LIBGIF | |
| 43 #include "gif_lib.h" | |
| 44 #endif | |
| 45 | |
| 46 #if HAVE_LIBJPEG | |
| 47 /* jpeglib.h includes jconfig.h, which makes the error of setting | |
| 48 * #define HAVE_STDLIB_H | |
| 49 * which conflicts with config_auto.h (where it is set to 1) and results | |
| 50 * for some gcc compiler versions in a warning. The conflict is harmless | |
| 51 * but we suppress it by undefining the variable. */ | |
| 52 #undef HAVE_STDLIB_H | |
| 53 #include "jpeglib.h" | |
| 54 #include "jerror.h" | |
| 55 #endif | |
| 56 | |
| 57 #if HAVE_LIBPNG | |
| 58 #include "png.h" | |
| 59 #endif | |
| 60 | |
| 61 #if HAVE_LIBTIFF | |
| 62 #include "tiffio.h" | |
| 63 #endif | |
| 64 | |
| 65 #if HAVE_LIBZ | |
| 66 #include "zlib.h" | |
| 67 #endif | |
| 68 | |
| 69 #if HAVE_LIBWEBP | |
| 70 #include "webp/encode.h" | |
| 71 #endif | |
| 72 | |
| 73 #if HAVE_LIBJP2K | |
| 74 #ifdef LIBJP2K_HEADER | |
| 75 #include LIBJP2K_HEADER | |
| 76 #else | |
| 77 #include <openjpeg.h> | |
| 78 #endif | |
| 79 #endif | |
| 80 | |
| 81 | |
| 82 /*---------------------------------------------------------------------* | |
| 83 * Image Library Version number * | |
| 84 *---------------------------------------------------------------------*/ | |
| 85 /*! | |
| 86 * \brief getImagelibVersions() | |
| 87 * | |
| 88 * <pre> | |
| 89 * Notes: | |
| 90 * (1) This returns a string of version numbers; e.g., | |
| 91 * libgif 5.1.4 | |
| 92 * libjpeg 8b (libjpeg-turbo 2.0.3) | |
| 93 * libpng 1.6.37 | |
| 94 * libtiff 4.1.0 | |
| 95 * zlib 1.2.11 | |
| 96 * libwebp 0.6.1 | |
| 97 * libopenjp2 2.5.0 | |
| 98 * (2) The caller must free the memory. | |
| 99 * </pre> | |
| 100 */ | |
| 101 char * | |
| 102 getImagelibVersions(void) | |
| 103 { | |
| 104 #if HAVE_LIBGIF || HAVE_LIBJPEG | |
| 105 char buf[128]; | |
| 106 #endif | |
| 107 l_int32 first = TRUE; | |
| 108 #if HAVE_LIBJPEG || HAVE_LIBTIFF | |
| 109 char *versionNumP; | |
| 110 char *nextTokenP; | |
| 111 #endif | |
| 112 char *versionStrP = NULL; | |
| 113 | |
| 114 #if HAVE_LIBGIF | |
| 115 first = FALSE; | |
| 116 stringJoinIP(&versionStrP, "libgif "); | |
| 117 #ifdef GIFLIB_MAJOR | |
| 118 snprintf(buf, sizeof(buf), "%d.%d.%d", GIFLIB_MAJOR, GIFLIB_MINOR, | |
| 119 GIFLIB_RELEASE); | |
| 120 #else | |
| 121 stringCopy(buf, "4.1.6(?)", sizeof(buf)); | |
| 122 #endif | |
| 123 stringJoinIP(&versionStrP, buf); | |
| 124 #endif /* HAVE_LIBGIF */ | |
| 125 | |
| 126 #if HAVE_LIBJPEG | |
| 127 { | |
| 128 struct jpeg_compress_struct cinfo = { 0 }; | |
| 129 struct jpeg_error_mgr err = { 0 }; | |
| 130 char buffer[JMSG_LENGTH_MAX]; | |
| 131 cinfo.err = jpeg_std_error(&err); | |
| 132 err.msg_code = JMSG_VERSION; | |
| 133 (*err.format_message) ((j_common_ptr ) &cinfo, buffer); | |
| 134 | |
| 135 if (!first) stringJoinIP(&versionStrP, " : "); | |
| 136 first = FALSE; | |
| 137 stringJoinIP(&versionStrP, "libjpeg "); | |
| 138 versionNumP = strtokSafe(buffer, " ", &nextTokenP); | |
| 139 stringJoinIP(&versionStrP, versionNumP); | |
| 140 LEPT_FREE(versionNumP); | |
| 141 | |
| 142 #if defined(LIBJPEG_TURBO_VERSION) | |
| 143 /* To stringify the result of expansion of a macro argument, | |
| 144 * you must use two levels of macros. See: | |
| 145 * https://gcc.gnu.org/onlinedocs/cpp/Stringification.html */ | |
| 146 #define l_xstr(s) l_str(s) | |
| 147 #define l_str(s) #s | |
| 148 snprintf(buf, sizeof(buf), " (libjpeg-turbo %s)", | |
| 149 l_xstr(LIBJPEG_TURBO_VERSION)); | |
| 150 stringJoinIP(&versionStrP, buf); | |
| 151 #endif /* LIBJPEG_TURBO_VERSION */ | |
| 152 } | |
| 153 #endif /* HAVE_LIBJPEG */ | |
| 154 | |
| 155 #if HAVE_LIBPNG | |
| 156 if (!first) stringJoinIP(&versionStrP, " : "); | |
| 157 first = FALSE; | |
| 158 stringJoinIP(&versionStrP, "libpng "); | |
| 159 stringJoinIP(&versionStrP, png_get_libpng_ver(NULL)); | |
| 160 #endif /* HAVE_LIBPNG */ | |
| 161 | |
| 162 #if HAVE_LIBTIFF | |
| 163 if (!first) stringJoinIP(&versionStrP, " : "); | |
| 164 first = FALSE; | |
| 165 stringJoinIP(&versionStrP, "libtiff "); | |
| 166 versionNumP = strtokSafe((char *)TIFFGetVersion(), " \n", &nextTokenP); | |
| 167 LEPT_FREE(versionNumP); | |
| 168 versionNumP = strtokSafe(NULL, " \n", &nextTokenP); | |
| 169 LEPT_FREE(versionNumP); | |
| 170 versionNumP = strtokSafe(NULL, " \n", &nextTokenP); | |
| 171 stringJoinIP(&versionStrP, versionNumP); | |
| 172 LEPT_FREE(versionNumP); | |
| 173 #endif /* HAVE_LIBTIFF */ | |
| 174 | |
| 175 #if HAVE_LIBZ | |
| 176 if (!first) stringJoinIP(&versionStrP, " : "); | |
| 177 first = FALSE; | |
| 178 stringJoinIP(&versionStrP, "zlib "); | |
| 179 stringJoinIP(&versionStrP, ZLIB_VERSION); | |
| 180 #endif /* HAVE_LIBZ */ | |
| 181 | |
| 182 #if HAVE_LIBWEBP | |
| 183 { | |
| 184 l_int32 val; | |
| 185 char buf[32]; | |
| 186 if (!first) stringJoinIP(&versionStrP, " : "); | |
| 187 first = FALSE; | |
| 188 stringJoinIP(&versionStrP, "libwebp "); | |
| 189 val = WebPGetEncoderVersion(); | |
| 190 snprintf(buf, sizeof(buf), "%d.%d.%d", val >> 16, (val >> 8) & 0xff, | |
| 191 val & 0xff); | |
| 192 stringJoinIP(&versionStrP, buf); | |
| 193 } | |
| 194 #endif /* HAVE_LIBWEBP */ | |
| 195 | |
| 196 #if HAVE_LIBJP2K | |
| 197 { | |
| 198 const char *version; | |
| 199 if (!first) stringJoinIP(&versionStrP, " : "); | |
| 200 first = FALSE; | |
| 201 stringJoinIP(&versionStrP, "libopenjp2 "); | |
| 202 version = opj_version(); | |
| 203 stringJoinIP(&versionStrP, version); | |
| 204 } | |
| 205 #endif /* HAVE_LIBJP2K */ | |
| 206 | |
| 207 return versionStrP; | |
| 208 } |
