This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Compress::Zlib 1.37
[perl5.git] / ext / Compress / Zlib / fallback.h
CommitLineData
f4c6fd49
RGS
1#define PERL_constant_NOTFOUND 1
2#define PERL_constant_NOTDEF 2
3#define PERL_constant_ISIV 3
4#define PERL_constant_ISNO 4
5#define PERL_constant_ISNV 5
6#define PERL_constant_ISPV 6
7#define PERL_constant_ISPVN 7
8#define PERL_constant_ISSV 8
9#define PERL_constant_ISUNDEF 9
10#define PERL_constant_ISUV 10
11#define PERL_constant_ISYES 11
12
13#ifndef NVTYPE
14typedef double NV; /* 5.6 and later define NVTYPE, and typedef NV to it. */
15#endif
16#ifndef aTHX_
17#define aTHX_ /* 5.6 or later define this for threading support. */
18#endif
19#ifndef pTHX_
20#define pTHX_ /* 5.6 or later define this for threading support. */
21#endif
22
23static int
24constant_7 (pTHX_ const char *name, IV *iv_return) {
25 /* When generated this function returned values for the list of names given
26 here. However, subsequent manual editing may have added or removed some.
27 OS_CODE Z_ASCII Z_ERRNO */
28 /* Offset 5 gives the best switch position. */
29 switch (name[5]) {
30 case 'D':
31 if (memEQ(name, "OS_CODE", 7)) {
32 /* ^ */
33#ifdef OS_CODE
34 *iv_return = OS_CODE;
35 return PERL_constant_ISIV;
36#else
37 return PERL_constant_NOTDEF;
38#endif
39 }
40 break;
41 case 'I':
42 if (memEQ(name, "Z_ASCII", 7)) {
43 /* ^ */
44#ifdef Z_ASCII
45 *iv_return = Z_ASCII;
46 return PERL_constant_ISIV;
47#else
48 return PERL_constant_NOTDEF;
49#endif
50 }
51 break;
52 case 'N':
53 if (memEQ(name, "Z_ERRNO", 7)) {
54 /* ^ */
55#ifdef Z_ERRNO
56 *iv_return = Z_ERRNO;
57 return PERL_constant_ISIV;
58#else
59 return PERL_constant_NOTDEF;
60#endif
61 }
62 break;
63 }
64 return PERL_constant_NOTFOUND;
65}
66
67static int
68constant_9 (pTHX_ const char *name, IV *iv_return) {
69 /* When generated this function returned values for the list of names given
70 here. However, subsequent manual editing may have added or removed some.
71 DEF_WBITS MAX_WBITS Z_UNKNOWN */
72 /* Offset 2 gives the best switch position. */
73 switch (name[2]) {
74 case 'F':
75 if (memEQ(name, "DEF_WBITS", 9)) {
76 /* ^ */
77#ifdef DEF_WBITS
78 *iv_return = DEF_WBITS;
79 return PERL_constant_ISIV;
80#else
81 return PERL_constant_NOTDEF;
82#endif
83 }
84 break;
85 case 'U':
86 if (memEQ(name, "Z_UNKNOWN", 9)) {
87 /* ^ */
88#ifdef Z_UNKNOWN
89 *iv_return = Z_UNKNOWN;
90 return PERL_constant_ISIV;
91#else
92 return PERL_constant_NOTDEF;
93#endif
94 }
95 break;
96 case 'X':
97 if (memEQ(name, "MAX_WBITS", 9)) {
98 /* ^ */
99#ifdef MAX_WBITS
100 *iv_return = MAX_WBITS;
101 return PERL_constant_ISIV;
102#else
103 return PERL_constant_NOTDEF;
104#endif
105 }
106 break;
107 }
108 return PERL_constant_NOTFOUND;
109}
110
111static int
112constant_10 (pTHX_ const char *name, IV *iv_return) {
113 /* When generated this function returned values for the list of names given
114 here. However, subsequent manual editing may have added or removed some.
115 Z_DEFLATED Z_FILTERED Z_NO_FLUSH */
116 /* Offset 7 gives the best switch position. */
117 switch (name[7]) {
118 case 'R':
119 if (memEQ(name, "Z_FILTERED", 10)) {
120 /* ^ */
121#ifdef Z_FILTERED
122 *iv_return = Z_FILTERED;
123 return PERL_constant_ISIV;
124#else
125 return PERL_constant_NOTDEF;
126#endif
127 }
128 break;
129 case 'T':
130 if (memEQ(name, "Z_DEFLATED", 10)) {
131 /* ^ */
132#ifdef Z_DEFLATED
133 *iv_return = Z_DEFLATED;
134 return PERL_constant_ISIV;
135#else
136 return PERL_constant_NOTDEF;
137#endif
138 }
139 break;
140 case 'U':
141 if (memEQ(name, "Z_NO_FLUSH", 10)) {
142 /* ^ */
143#ifdef Z_NO_FLUSH
144 *iv_return = Z_NO_FLUSH;
145 return PERL_constant_ISIV;
146#else
147 return PERL_constant_NOTDEF;
148#endif
149 }
150 break;
151 }
152 return PERL_constant_NOTFOUND;
153}
154
155static int
156constant_11 (pTHX_ const char *name, IV *iv_return) {
157 /* When generated this function returned values for the list of names given
158 here. However, subsequent manual editing may have added or removed some.
159 Z_BUF_ERROR Z_MEM_ERROR Z_NEED_DICT */
160 /* Offset 4 gives the best switch position. */
161 switch (name[4]) {
162 case 'E':
163 if (memEQ(name, "Z_NEED_DICT", 11)) {
164 /* ^ */
165#ifdef Z_NEED_DICT
166 *iv_return = Z_NEED_DICT;
167 return PERL_constant_ISIV;
168#else
169 return PERL_constant_NOTDEF;
170#endif
171 }
172 break;
173 case 'F':
174 if (memEQ(name, "Z_BUF_ERROR", 11)) {
175 /* ^ */
176#ifdef Z_BUF_ERROR
177 *iv_return = Z_BUF_ERROR;
178 return PERL_constant_ISIV;
179#else
180 return PERL_constant_NOTDEF;
181#endif
182 }
183 break;
184 case 'M':
185 if (memEQ(name, "Z_MEM_ERROR", 11)) {
186 /* ^ */
187#ifdef Z_MEM_ERROR
188 *iv_return = Z_MEM_ERROR;
189 return PERL_constant_ISIV;
190#else
191 return PERL_constant_NOTDEF;
192#endif
193 }
194 break;
195 }
196 return PERL_constant_NOTFOUND;
197}
198
199static int
200constant_12 (pTHX_ const char *name, IV *iv_return, const char **pv_return) {
201 /* When generated this function returned values for the list of names given
202 here. However, subsequent manual editing may have added or removed some.
203 ZLIB_VERSION Z_BEST_SPEED Z_DATA_ERROR Z_FULL_FLUSH Z_STREAM_END
204 Z_SYNC_FLUSH */
205 /* Offset 4 gives the best switch position. */
206 switch (name[4]) {
207 case 'L':
208 if (memEQ(name, "Z_FULL_FLUSH", 12)) {
209 /* ^ */
210#ifdef Z_FULL_FLUSH
211 *iv_return = Z_FULL_FLUSH;
212 return PERL_constant_ISIV;
213#else
214 return PERL_constant_NOTDEF;
215#endif
216 }
217 break;
218 case 'N':
219 if (memEQ(name, "Z_SYNC_FLUSH", 12)) {
220 /* ^ */
221#ifdef Z_SYNC_FLUSH
222 *iv_return = Z_SYNC_FLUSH;
223 return PERL_constant_ISIV;
224#else
225 return PERL_constant_NOTDEF;
226#endif
227 }
228 break;
229 case 'R':
230 if (memEQ(name, "Z_STREAM_END", 12)) {
231 /* ^ */
232#ifdef Z_STREAM_END
233 *iv_return = Z_STREAM_END;
234 return PERL_constant_ISIV;
235#else
236 return PERL_constant_NOTDEF;
237#endif
238 }
239 break;
240 case 'S':
241 if (memEQ(name, "Z_BEST_SPEED", 12)) {
242 /* ^ */
243#ifdef Z_BEST_SPEED
244 *iv_return = Z_BEST_SPEED;
245 return PERL_constant_ISIV;
246#else
247 return PERL_constant_NOTDEF;
248#endif
249 }
250 break;
251 case 'T':
252 if (memEQ(name, "Z_DATA_ERROR", 12)) {
253 /* ^ */
254#ifdef Z_DATA_ERROR
255 *iv_return = Z_DATA_ERROR;
256 return PERL_constant_ISIV;
257#else
258 return PERL_constant_NOTDEF;
259#endif
260 }
261 break;
262 case '_':
263 if (memEQ(name, "ZLIB_VERSION", 12)) {
264 /* ^ */
265#ifdef ZLIB_VERSION
266 *pv_return = ZLIB_VERSION;
267 return PERL_constant_ISPV;
268#else
269 return PERL_constant_NOTDEF;
270#endif
271 }
272 break;
273 }
274 return PERL_constant_NOTFOUND;
275}
276
277static int
278constant (pTHX_ const char *name, STRLEN len, IV *iv_return, const char **pv_return) {
279 /* Initially switch on the length of the name. */
280 /* When generated this function returned values for the list of names given
281 in this section of perl code. Rather than manually editing these functions
282 to add or remove constants, which would result in this comment and section
283 of code becoming inaccurate, we recommend that you edit this section of
284 code, and use it to regenerate a new set of constant functions which you
285 then use to replace the originals.
286
287 Regenerate these constant functions by feeding this entire source file to
288 perl -x
289
290#!/home/paul/perl/install/redhat6.1/bleed/bin/perl5.7.2 -w
291use ExtUtils::Constant qw (constant_types C_constant XS_constant);
292
293my $types = {map {($_, 1)} qw(IV PV)};
294my @names = (qw(DEF_WBITS MAX_MEM_LEVEL MAX_WBITS OS_CODE Z_ASCII
295 Z_BEST_COMPRESSION Z_BEST_SPEED Z_BINARY Z_BUF_ERROR
296 Z_DATA_ERROR Z_DEFAULT_COMPRESSION Z_DEFAULT_STRATEGY Z_DEFLATED
297 Z_ERRNO Z_FILTERED Z_FINISH Z_FULL_FLUSH Z_HUFFMAN_ONLY
298 Z_MEM_ERROR Z_NEED_DICT Z_NO_COMPRESSION Z_NO_FLUSH Z_NULL Z_OK
299 Z_PARTIAL_FLUSH Z_STREAM_END Z_STREAM_ERROR Z_SYNC_FLUSH
300 Z_UNKNOWN Z_VERSION_ERROR),
301 {name=>"ZLIB_VERSION", type=>"PV"});
302
303print constant_types(); # macro defs
304foreach (C_constant ("Zlib", 'constant', 'IV', $types, undef, 3, @names) ) {
305 print $_, "\n"; # C constant subs
306}
307print "#### XS Section:\n";
308print XS_constant ("Zlib", $types);
309__END__
310 */
311
312 switch (len) {
313 case 4:
314 if (memEQ(name, "Z_OK", 4)) {
315#ifdef Z_OK
316 *iv_return = Z_OK;
317 return PERL_constant_ISIV;
318#else
319 return PERL_constant_NOTDEF;
320#endif
321 }
322 break;
323 case 6:
324 if (memEQ(name, "Z_NULL", 6)) {
325#ifdef Z_NULL
326 *iv_return = Z_NULL;
327 return PERL_constant_ISIV;
328#else
329 return PERL_constant_NOTDEF;
330#endif
331 }
332 break;
333 case 7:
334 return constant_7 (aTHX_ name, iv_return);
335 break;
336 case 8:
337 /* Names all of length 8. */
338 /* Z_BINARY Z_FINISH */
339 /* Offset 6 gives the best switch position. */
340 switch (name[6]) {
341 case 'R':
342 if (memEQ(name, "Z_BINARY", 8)) {
343 /* ^ */
344#ifdef Z_BINARY
345 *iv_return = Z_BINARY;
346 return PERL_constant_ISIV;
347#else
348 return PERL_constant_NOTDEF;
349#endif
350 }
351 break;
352 case 'S':
353 if (memEQ(name, "Z_FINISH", 8)) {
354 /* ^ */
355#ifdef Z_FINISH
356 *iv_return = Z_FINISH;
357 return PERL_constant_ISIV;
358#else
359 return PERL_constant_NOTDEF;
360#endif
361 }
362 break;
363 }
364 break;
365 case 9:
366 return constant_9 (aTHX_ name, iv_return);
367 break;
368 case 10:
369 return constant_10 (aTHX_ name, iv_return);
370 break;
371 case 11:
372 return constant_11 (aTHX_ name, iv_return);
373 break;
374 case 12:
375 return constant_12 (aTHX_ name, iv_return, pv_return);
376 break;
377 case 13:
378 if (memEQ(name, "MAX_MEM_LEVEL", 13)) {
379#ifdef MAX_MEM_LEVEL
380 *iv_return = MAX_MEM_LEVEL;
381 return PERL_constant_ISIV;
382#else
383 return PERL_constant_NOTDEF;
384#endif
385 }
386 break;
387 case 14:
388 /* Names all of length 14. */
389 /* Z_HUFFMAN_ONLY Z_STREAM_ERROR */
390 /* Offset 3 gives the best switch position. */
391 switch (name[3]) {
392 case 'T':
393 if (memEQ(name, "Z_STREAM_ERROR", 14)) {
394 /* ^ */
395#ifdef Z_STREAM_ERROR
396 *iv_return = Z_STREAM_ERROR;
397 return PERL_constant_ISIV;
398#else
399 return PERL_constant_NOTDEF;
400#endif
401 }
402 break;
403 case 'U':
404 if (memEQ(name, "Z_HUFFMAN_ONLY", 14)) {
405 /* ^ */
406#ifdef Z_HUFFMAN_ONLY
407 *iv_return = Z_HUFFMAN_ONLY;
408 return PERL_constant_ISIV;
409#else
410 return PERL_constant_NOTDEF;
411#endif
412 }
413 break;
414 }
415 break;
416 case 15:
417 /* Names all of length 15. */
418 /* Z_PARTIAL_FLUSH Z_VERSION_ERROR */
419 /* Offset 5 gives the best switch position. */
420 switch (name[5]) {
421 case 'S':
422 if (memEQ(name, "Z_VERSION_ERROR", 15)) {
423 /* ^ */
424#ifdef Z_VERSION_ERROR
425 *iv_return = Z_VERSION_ERROR;
426 return PERL_constant_ISIV;
427#else
428 return PERL_constant_NOTDEF;
429#endif
430 }
431 break;
432 case 'T':
433 if (memEQ(name, "Z_PARTIAL_FLUSH", 15)) {
434 /* ^ */
435#ifdef Z_PARTIAL_FLUSH
436 *iv_return = Z_PARTIAL_FLUSH;
437 return PERL_constant_ISIV;
438#else
439 return PERL_constant_NOTDEF;
440#endif
441 }
442 break;
443 }
444 break;
445 case 16:
446 if (memEQ(name, "Z_NO_COMPRESSION", 16)) {
447#ifdef Z_NO_COMPRESSION
448 *iv_return = Z_NO_COMPRESSION;
449 return PERL_constant_ISIV;
450#else
451 return PERL_constant_NOTDEF;
452#endif
453 }
454 break;
455 case 18:
456 /* Names all of length 18. */
457 /* Z_BEST_COMPRESSION Z_DEFAULT_STRATEGY */
458 /* Offset 14 gives the best switch position. */
459 switch (name[14]) {
460 case 'S':
461 if (memEQ(name, "Z_BEST_COMPRESSION", 18)) {
462 /* ^ */
463#ifdef Z_BEST_COMPRESSION
464 *iv_return = Z_BEST_COMPRESSION;
465 return PERL_constant_ISIV;
466#else
467 return PERL_constant_NOTDEF;
468#endif
469 }
470 break;
471 case 'T':
472 if (memEQ(name, "Z_DEFAULT_STRATEGY", 18)) {
473 /* ^ */
474#ifdef Z_DEFAULT_STRATEGY
475 *iv_return = Z_DEFAULT_STRATEGY;
476 return PERL_constant_ISIV;
477#else
478 return PERL_constant_NOTDEF;
479#endif
480 }
481 break;
482 }
483 break;
484 case 21:
485 if (memEQ(name, "Z_DEFAULT_COMPRESSION", 21)) {
486#ifdef Z_DEFAULT_COMPRESSION
487 *iv_return = Z_DEFAULT_COMPRESSION;
488 return PERL_constant_ISIV;
489#else
490 return PERL_constant_NOTDEF;
491#endif
492 }
493 break;
494 }
495 return PERL_constant_NOTFOUND;
496}
497