Leptonica 1.68
C Image Processing Library

libversions.c

Go to the documentation of this file.
00001 /*====================================================================*
00002  -  Copyright (C) 2001 Leptonica.  All rights reserved.
00003  -  This software is distributed in the hope that it will be
00004  -  useful, but with NO WARRANTY OF ANY KIND.
00005  -  No author or distributor accepts responsibility to anyone for the
00006  -  consequences of using this software, or for whether it serves any
00007  -  particular purpose or works at all, unless he or she says so in
00008  -  writing.  Everyone is granted permission to copy, modify and
00009  -  redistribute this source code, for commercial or non-commercial
00010  -  purposes, with the following restrictions: (1) the origin of this
00011  -  source code must not be misrepresented; (2) modified versions must
00012  -  be plainly marked as such; and (3) this notice may not be removed
00013  -  or altered from any source or modified source distribution.
00014  *====================================================================*/
00015 
00016 /*
00017  *  libversions.c
00018  *
00019  *       Image library version number
00020  *           char      *getImagelibVersions()
00021  */
00022 
00023 #include "allheaders.h"
00024 
00025 #ifdef HAVE_CONFIG_H
00026 #include "config_auto.h"
00027 #endif  /* HAVE_CONFIG_H */
00028 
00029 #if HAVE_LIBGIF
00030 #include "gif_lib.h"
00031 #endif
00032 
00033 #if HAVE_LIBJPEG
00034 /* jpeglib.h includes jconfig.h, which makes the error of setting
00035  *   #define HAVE_STDLIB_H
00036  * which conflicts with config_auto.h (where it is set to 1) and results
00037  * for some gcc compiler versions in a warning.  The conflict is harmless
00038  * but we suppress it by undefining the variable. */
00039 #undef HAVE_STDLIB_H
00040 #include "jpeglib.h"
00041 #include "jerror.h"
00042 #endif
00043 
00044 #if HAVE_LIBPNG
00045 #include "png.h"
00046 #endif
00047 
00048 #if HAVE_LIBTIFF
00049 #include "tiffio.h"
00050 #endif
00051 
00052 #if HAVE_LIBZ
00053 #include "zlib.h"
00054 #endif
00055 
00056 #define stringJoinInPlace(s1, s2) \
00057     tempStrP = stringJoin(s1,s2); FREE(s1); s1 = tempStrP;
00058 
00059 
00060 /*---------------------------------------------------------------------*
00061  *                    Image Library Version number                     *
00062  *---------------------------------------------------------------------*/
00063 /*! 
00064  *  getImagelibVersions()
00065  *
00066  *      Return: string of version numbers (e.g.,
00067  *               libgif 4.1.6
00068  *               libjpeg 8b
00069  *               libpng 1.4.3
00070  *               libtiff 3.9.4
00071  *               zlib 1.2.5
00072  *
00073  *  Notes:
00074  *      (1) The caller has responsibility to free the memory.
00075  */
00076 char *
00077 getImagelibVersions()
00078 {
00079 #if HAVE_LIBJPEG
00080     struct jpeg_compress_struct cinfo;
00081     struct jpeg_error_mgr err;
00082     char buffer[JMSG_LENGTH_MAX];
00083 #endif
00084     char *tempStrP;
00085     char *versionNumP;
00086     char *nextTokenP;
00087     char *versionStrP = stringNew("");
00088 
00089 #if HAVE_LIBGIF
00090     stringJoinInPlace(versionStrP, "libgif 4.1.6 : ");
00091 #endif
00092 
00093 #if HAVE_LIBJPEG
00094     cinfo.err = jpeg_std_error(&err);
00095     err.msg_code = JMSG_VERSION;
00096     (*err.format_message) ((j_common_ptr ) &cinfo, buffer);
00097 
00098     stringJoinInPlace(versionStrP, "libjpeg ");
00099     versionNumP = strtokSafe(buffer, " ", &nextTokenP);
00100     stringJoinInPlace(versionStrP, versionNumP);
00101     stringJoinInPlace(versionStrP, " : ");
00102     FREE(versionNumP);
00103 #endif
00104 
00105 #if HAVE_LIBPNG
00106     stringJoinInPlace(versionStrP, "libpng ");
00107     stringJoinInPlace(versionStrP, png_get_libpng_ver(NULL));
00108     stringJoinInPlace(versionStrP, " : ");
00109 #endif
00110 
00111 #if HAVE_LIBTIFF
00112     stringJoinInPlace(versionStrP, "libtiff ");
00113     versionNumP = strtokSafe((char *)TIFFGetVersion(), " \n", &nextTokenP);
00114     FREE(versionNumP);
00115     versionNumP = strtokSafe(NULL, " \n", &nextTokenP);
00116     FREE(versionNumP);
00117     versionNumP = strtokSafe(NULL, " \n", &nextTokenP);
00118     stringJoinInPlace(versionStrP, versionNumP);
00119     stringJoinInPlace(versionStrP, " : ");
00120     FREE(versionNumP);
00121 #endif
00122 
00123 #if HAVE_LIBZ
00124     stringJoinInPlace(versionStrP, "zlib ");
00125     stringJoinInPlace(versionStrP, zlibVersion());
00126 #endif
00127     stringJoinInPlace(versionStrP, "\n");
00128 
00129     return versionStrP;
00130 }
00131 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines