1 /*
2 * Copyright (c) 1988-1997 Sam Leffler
3 * Copyright (c) 1991-1997 Silicon Graphics, Inc.
4 *
5 * Permission to use, copy, modify, distribute, and sell this software and
6 * its documentation for any purpose is hereby granted without fee, provided
7 * that (i) the above copyright notices and this permission notice appear in
8 * all copies of the software and related documentation, and (ii) the names of
9 * Sam Leffler and Silicon Graphics may not be used in any advertising or
10 * publicity relating to the software without the specific, prior written
11 * permission of Sam Leffler and Silicon Graphics.
12 *
13 * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
14 * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
15 * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
16 *
17 * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
18 * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
19 * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
20 * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
21 * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
22 * OF THIS SOFTWARE.
23 */
24
25 /*
26 * TIFF Library
27 *
28 * Builtin Compression Scheme Configuration Support.
29 */
30 #include "tiffiop.h"
31
32 static int NotConfigured(TIFF*, int);
33
34 #ifndef LZW_SUPPORT
35 #define TIFFInitLZW NotConfigured
36 #endif
37 #ifndef PACKBITS_SUPPORT
38 #define TIFFInitPackBits NotConfigured
39 #endif
40 #ifndef THUNDER_SUPPORT
41 #define TIFFInitThunderScan NotConfigured
42 #endif
43 #ifndef NEXT_SUPPORT
44 #define TIFFInitNeXT NotConfigured
45 #endif
46 #ifndef JPEG_SUPPORT
47 #define TIFFInitJPEG NotConfigured
48 #endif
49 #ifndef OJPEG_SUPPORT
50 #define TIFFInitOJPEG NotConfigured
51 #endif
52 #ifndef CCITT_SUPPORT
53 #define TIFFInitCCITTRLE NotConfigured
54 #define TIFFInitCCITTRLEW NotConfigured
55 #define TIFFInitCCITTFax3 NotConfigured
56 #define TIFFInitCCITTFax4 NotConfigured
57 #endif
58 #ifndef JBIG_SUPPORT
59 #define TIFFInitJBIG NotConfigured
60 #endif
61 #ifndef ZIP_SUPPORT
62 #define TIFFInitZIP NotConfigured
63 #endif
64 #ifndef PIXARLOG_SUPPORT
65 #define TIFFInitPixarLog NotConfigured
66 #endif
67 #ifndef LOGLUV_SUPPORT
68 #define TIFFInitSGILog NotConfigured
69 #endif
70 #ifndef LZMA_SUPPORT
71 #define TIFFInitLZMA NotConfigured
72 #endif
73 #ifndef ZSTD_SUPPORT
74 #define TIFFInitZSTD NotConfigured
75 #endif
76
77 /*
78 * Compression schemes statically built into the library.
79 */
80 #ifdef VMS
81 const TIFFCodec _TIFFBuiltinCODECS[] = {
82 #else
83 TIFFCodec _TIFFBuiltinCODECS[] = {
84 #endif
85 { "None", COMPRESSION_NONE, TIFFInitDumpMode },
86 { "LZW", COMPRESSION_LZW, TIFFInitLZW },
87 { "PackBits", COMPRESSION_PACKBITS, TIFFInitPackBits },
88 { "ThunderScan", COMPRESSION_THUNDERSCAN,TIFFInitThunderScan },
89 { "NeXT", COMPRESSION_NEXT, TIFFInitNeXT },
90 { "JPEG", COMPRESSION_JPEG, TIFFInitJPEG },
91 { "Old-style JPEG", COMPRESSION_OJPEG, TIFFInitOJPEG },
92 { "CCITT RLE", COMPRESSION_CCITTRLE, TIFFInitCCITTRLE },
93 { "CCITT RLE/W", COMPRESSION_CCITTRLEW, TIFFInitCCITTRLEW },
94 { "CCITT Group 3", COMPRESSION_CCITTFAX3, TIFFInitCCITTFax3 },
95 { "CCITT Group 4", COMPRESSION_CCITTFAX4, TIFFInitCCITTFax4 },
96 { "ISO JBIG", COMPRESSION_JBIG, TIFFInitJBIG },
97 { "Deflate", COMPRESSION_DEFLATE, TIFFInitZIP },
98 { "AdobeDeflate", COMPRESSION_ADOBE_DEFLATE , TIFFInitZIP },
99 { "PixarLog", COMPRESSION_PIXARLOG, TIFFInitPixarLog },
100 { "SGILog", COMPRESSION_SGILOG, TIFFInitSGILog },
101 { "SGILog24", COMPRESSION_SGILOG24, TIFFInitSGILog },
102 { "LZMA", COMPRESSION_LZMA, TIFFInitLZMA },
103 { "ZSTD", COMPRESSION_ZSTD, TIFFInitZSTD },
104 { NULL, 0, NULL }
105 };
106
107 static int
_notConfigured(TIFF * tif)108 _notConfigured(TIFF* tif)
109 {
110 const TIFFCodec* c = TIFFFindCODEC(tif->tif_dir.td_compression);
111 char compression_code[20];
112
113 sprintf(compression_code, "%d",tif->tif_dir.td_compression );
114 TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
115 "%s compression support is not configured",
116 c ? c->name : compression_code );
117 return (0);
118 }
119
120 static int
NotConfigured(TIFF * tif,int scheme)121 NotConfigured(TIFF* tif, int scheme)
122 {
123 (void) scheme;
124
125 tif->tif_fixuptags = _notConfigured;
126 tif->tif_decodestatus = FALSE;
127 tif->tif_setupdecode = _notConfigured;
128 tif->tif_encodestatus = FALSE;
129 tif->tif_setupencode = _notConfigured;
130 return (1);
131 }
132
133 /************************************************************************/
134 /* TIFFIsCODECConfigured() */
135 /************************************************************************/
136
137 /**
138 * Check whether we have working codec for the specific coding scheme.
139 *
140 * @return returns 1 if the codec is configured and working. Otherwise
141 * 0 will be returned.
142 */
143
144 int
TIFFIsCODECConfigured(uint16 scheme)145 TIFFIsCODECConfigured(uint16 scheme)
146 {
147 const TIFFCodec* codec = TIFFFindCODEC(scheme);
148
149 if(codec == NULL) {
150 return 0;
151 }
152 if(codec->init == NULL) {
153 return 0;
154 }
155 if(codec->init != NotConfigured){
156 return 1;
157 }
158 return 0;
159 }
160
161 /*
162 * Local Variables:
163 * mode: c
164 * c-basic-offset: 8
165 * fill-column: 78
166 * End:
167 */
168