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