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