Leptonica 1.85.0
Image processing and image analysis suite
Loading...
Searching...
No Matches
libversions.c
Go to the documentation of this file.
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
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 *---------------------------------------------------------------------*/
101char *
103{
104char buf[128];
105l_int32 first = TRUE;
106char *versionNumP;
107char *nextTokenP;
108char *versionStrP = NULL;
109
110#if HAVE_LIBGIF
111 first = FALSE;
112 stringJoinIP(&versionStrP, "libgif ");
113 #ifdef GIFLIB_MAJOR
114 snprintf(buf, sizeof(buf), "%d.%d.%d", GIFLIB_MAJOR, GIFLIB_MINOR,
115 GIFLIB_RELEASE);
116 #else
117 stringCopy(buf, "4.1.6(?)", sizeof(buf));
118 #endif
119 stringJoinIP(&versionStrP, buf);
120#endif /* HAVE_LIBGIF */
121
122#if HAVE_LIBJPEG
123 {
124 struct jpeg_compress_struct cinfo = { 0 };
125 struct jpeg_error_mgr err = { 0 };
126 char buffer[JMSG_LENGTH_MAX];
127 cinfo.err = jpeg_std_error(&err);
128 err.msg_code = JMSG_VERSION;
129 (*err.format_message) ((j_common_ptr ) &cinfo, buffer);
130
131 if (!first) stringJoinIP(&versionStrP, " : ");
132 first = FALSE;
133 stringJoinIP(&versionStrP, "libjpeg ");
134 versionNumP = strtokSafe(buffer, " ", &nextTokenP);
135 stringJoinIP(&versionStrP, versionNumP);
136 LEPT_FREE(versionNumP);
137
138 #if defined(LIBJPEG_TURBO_VERSION)
139 /* To stringify the result of expansion of a macro argument,
140 * you must use two levels of macros. See:
141 * https://gcc.gnu.org/onlinedocs/cpp/Stringification.html */
142 #define l_xstr(s) l_str(s)
143 #define l_str(s) #s
144 snprintf(buf, sizeof(buf), " (libjpeg-turbo %s)",
145 l_xstr(LIBJPEG_TURBO_VERSION));
146 stringJoinIP(&versionStrP, buf);
147 #endif /* LIBJPEG_TURBO_VERSION */
148 }
149#endif /* HAVE_LIBJPEG */
150
151#if HAVE_LIBPNG
152 if (!first) stringJoinIP(&versionStrP, " : ");
153 first = FALSE;
154 stringJoinIP(&versionStrP, "libpng ");
155 stringJoinIP(&versionStrP, png_get_libpng_ver(NULL));
156#endif /* HAVE_LIBPNG */
157
158#if HAVE_LIBTIFF
159 if (!first) stringJoinIP(&versionStrP, " : ");
160 first = FALSE;
161 stringJoinIP(&versionStrP, "libtiff ");
162 versionNumP = strtokSafe((char *)TIFFGetVersion(), " \n", &nextTokenP);
163 LEPT_FREE(versionNumP);
164 versionNumP = strtokSafe(NULL, " \n", &nextTokenP);
165 LEPT_FREE(versionNumP);
166 versionNumP = strtokSafe(NULL, " \n", &nextTokenP);
167 stringJoinIP(&versionStrP, versionNumP);
168 LEPT_FREE(versionNumP);
169#endif /* HAVE_LIBTIFF */
170
171#if HAVE_LIBZ
172 if (!first) stringJoinIP(&versionStrP, " : ");
173 first = FALSE;
174 stringJoinIP(&versionStrP, "zlib ");
175 stringJoinIP(&versionStrP, ZLIB_VERSION);
176#endif /* HAVE_LIBZ */
177
178#if HAVE_LIBWEBP
179 {
180 l_int32 val;
181 char buf[32];
182 if (!first) stringJoinIP(&versionStrP, " : ");
183 first = FALSE;
184 stringJoinIP(&versionStrP, "libwebp ");
185 val = WebPGetEncoderVersion();
186 snprintf(buf, sizeof(buf), "%d.%d.%d", val >> 16, (val >> 8) & 0xff,
187 val & 0xff);
188 stringJoinIP(&versionStrP, buf);
189 }
190#endif /* HAVE_LIBWEBP */
191
192#if HAVE_LIBJP2K
193 {
194 const char *version;
195 if (!first) stringJoinIP(&versionStrP, " : ");
196 first = FALSE;
197 stringJoinIP(&versionStrP, "libopenjp2 ");
198 version = opj_version();
199 stringJoinIP(&versionStrP, version);
200 }
201#endif /* HAVE_LIBJP2K */
202
203 return versionStrP;
204}
char * getImagelibVersions(void)
getImagelibVersions()