xref: /openbsd-src/gnu/usr.bin/perl/cpan/Compress-Raw-Bzip2/fallback/constants.h (revision b39c515898423c8d899e35282f4b395f7cad3298)
1*b39c5158Smillert #define PERL_constant_NOTFOUND	1
2*b39c5158Smillert #define PERL_constant_NOTDEF	2
3*b39c5158Smillert #define PERL_constant_ISIV	3
4*b39c5158Smillert #define PERL_constant_ISNO	4
5*b39c5158Smillert #define PERL_constant_ISNV	5
6*b39c5158Smillert #define PERL_constant_ISPV	6
7*b39c5158Smillert #define PERL_constant_ISPVN	7
8*b39c5158Smillert #define PERL_constant_ISSV	8
9*b39c5158Smillert #define PERL_constant_ISUNDEF	9
10*b39c5158Smillert #define PERL_constant_ISUV	10
11*b39c5158Smillert #define PERL_constant_ISYES	11
12*b39c5158Smillert 
13*b39c5158Smillert #ifndef NVTYPE
14*b39c5158Smillert typedef double NV; /* 5.6 and later define NVTYPE, and typedef NV to it.  */
15*b39c5158Smillert #endif
16*b39c5158Smillert #ifndef aTHX_
17*b39c5158Smillert #define aTHX_ /* 5.6 or later define this for threading support.  */
18*b39c5158Smillert #endif
19*b39c5158Smillert #ifndef pTHX_
20*b39c5158Smillert #define pTHX_ /* 5.6 or later define this for threading support.  */
21*b39c5158Smillert #endif
22*b39c5158Smillert 
23*b39c5158Smillert static int
constant(pTHX_ const char * name,STRLEN len,IV * iv_return)24*b39c5158Smillert constant (pTHX_ const char *name, STRLEN len, IV *iv_return) {
25*b39c5158Smillert   /* Initially switch on the length of the name.  */
26*b39c5158Smillert   /* When generated this function returned values for the list of names given
27*b39c5158Smillert      in this section of perl code.  Rather than manually editing these functions
28*b39c5158Smillert      to add or remove constants, which would result in this comment and section
29*b39c5158Smillert      of code becoming inaccurate, we recommend that you edit this section of
30*b39c5158Smillert      code, and use it to regenerate a new set of constant functions which you
31*b39c5158Smillert      then use to replace the originals.
32*b39c5158Smillert 
33*b39c5158Smillert      Regenerate these constant functions by feeding this entire source file to
34*b39c5158Smillert      perl -x
35*b39c5158Smillert 
36*b39c5158Smillert #!/spare/local/perls/5.8.6/bin/perl5.8.6 -w
37*b39c5158Smillert use ExtUtils::Constant qw (constant_types C_constant XS_constant);
38*b39c5158Smillert 
39*b39c5158Smillert my $types = {map {($_, 1)} qw(IV)};
40*b39c5158Smillert my @names = (qw(BZ_CONFIG_ERROR BZ_DATA_ERROR BZ_DATA_ERROR_MAGIC BZ_FINISH
41*b39c5158Smillert 	       BZ_FINISH_OK BZ_FLUSH BZ_FLUSH_OK BZ_IO_ERROR BZ_MEM_ERROR BZ_OK
42*b39c5158Smillert 	       BZ_OUTBUFF_FULL BZ_PARAM_ERROR BZ_RUN BZ_RUN_OK
43*b39c5158Smillert 	       BZ_SEQUENCE_ERROR BZ_STREAM_END BZ_UNEXPECTED_EOF));
44*b39c5158Smillert 
45*b39c5158Smillert print constant_types(); # macro defs
46*b39c5158Smillert foreach (C_constant ("Bzip2", 'constant', 'IV', $types, undef, 3, @names) ) {
47*b39c5158Smillert     print $_, "\n"; # C constant subs
48*b39c5158Smillert }
49*b39c5158Smillert print "#### XS Section:\n";
50*b39c5158Smillert print XS_constant ("Bzip2", $types);
51*b39c5158Smillert __END__
52*b39c5158Smillert    */
53*b39c5158Smillert 
54*b39c5158Smillert   switch (len) {
55*b39c5158Smillert   case 5:
56*b39c5158Smillert     if (memEQ(name, "BZ_OK", 5)) {
57*b39c5158Smillert #ifdef BZ_OK
58*b39c5158Smillert       *iv_return = BZ_OK;
59*b39c5158Smillert       return PERL_constant_ISIV;
60*b39c5158Smillert #else
61*b39c5158Smillert       return PERL_constant_NOTDEF;
62*b39c5158Smillert #endif
63*b39c5158Smillert     }
64*b39c5158Smillert     break;
65*b39c5158Smillert   case 6:
66*b39c5158Smillert     if (memEQ(name, "BZ_RUN", 6)) {
67*b39c5158Smillert #ifdef BZ_RUN
68*b39c5158Smillert       *iv_return = BZ_RUN;
69*b39c5158Smillert       return PERL_constant_ISIV;
70*b39c5158Smillert #else
71*b39c5158Smillert       return PERL_constant_NOTDEF;
72*b39c5158Smillert #endif
73*b39c5158Smillert     }
74*b39c5158Smillert     break;
75*b39c5158Smillert   case 8:
76*b39c5158Smillert     if (memEQ(name, "BZ_FLUSH", 8)) {
77*b39c5158Smillert #ifdef BZ_FLUSH
78*b39c5158Smillert       *iv_return = BZ_FLUSH;
79*b39c5158Smillert       return PERL_constant_ISIV;
80*b39c5158Smillert #else
81*b39c5158Smillert       return PERL_constant_NOTDEF;
82*b39c5158Smillert #endif
83*b39c5158Smillert     }
84*b39c5158Smillert     break;
85*b39c5158Smillert   case 9:
86*b39c5158Smillert     /* Names all of length 9.  */
87*b39c5158Smillert     /* BZ_FINISH BZ_RUN_OK */
88*b39c5158Smillert     /* Offset 8 gives the best switch position.  */
89*b39c5158Smillert     switch (name[8]) {
90*b39c5158Smillert     case 'H':
91*b39c5158Smillert       if (memEQ(name, "BZ_FINIS", 8)) {
92*b39c5158Smillert       /*                       H     */
93*b39c5158Smillert #ifdef BZ_FINISH
94*b39c5158Smillert         *iv_return = BZ_FINISH;
95*b39c5158Smillert         return PERL_constant_ISIV;
96*b39c5158Smillert #else
97*b39c5158Smillert         return PERL_constant_NOTDEF;
98*b39c5158Smillert #endif
99*b39c5158Smillert       }
100*b39c5158Smillert       break;
101*b39c5158Smillert     case 'K':
102*b39c5158Smillert       if (memEQ(name, "BZ_RUN_O", 8)) {
103*b39c5158Smillert       /*                       K     */
104*b39c5158Smillert #ifdef BZ_RUN_OK
105*b39c5158Smillert         *iv_return = BZ_RUN_OK;
106*b39c5158Smillert         return PERL_constant_ISIV;
107*b39c5158Smillert #else
108*b39c5158Smillert         return PERL_constant_NOTDEF;
109*b39c5158Smillert #endif
110*b39c5158Smillert       }
111*b39c5158Smillert       break;
112*b39c5158Smillert     }
113*b39c5158Smillert     break;
114*b39c5158Smillert   case 11:
115*b39c5158Smillert     /* Names all of length 11.  */
116*b39c5158Smillert     /* BZ_FLUSH_OK BZ_IO_ERROR */
117*b39c5158Smillert     /* Offset 3 gives the best switch position.  */
118*b39c5158Smillert     switch (name[3]) {
119*b39c5158Smillert     case 'F':
120*b39c5158Smillert       if (memEQ(name, "BZ_FLUSH_OK", 11)) {
121*b39c5158Smillert       /*                  ^              */
122*b39c5158Smillert #ifdef BZ_FLUSH_OK
123*b39c5158Smillert         *iv_return = BZ_FLUSH_OK;
124*b39c5158Smillert         return PERL_constant_ISIV;
125*b39c5158Smillert #else
126*b39c5158Smillert         return PERL_constant_NOTDEF;
127*b39c5158Smillert #endif
128*b39c5158Smillert       }
129*b39c5158Smillert       break;
130*b39c5158Smillert     case 'I':
131*b39c5158Smillert       if (memEQ(name, "BZ_IO_ERROR", 11)) {
132*b39c5158Smillert       /*                  ^              */
133*b39c5158Smillert #ifdef BZ_IO_ERROR
134*b39c5158Smillert         *iv_return = BZ_IO_ERROR;
135*b39c5158Smillert         return PERL_constant_ISIV;
136*b39c5158Smillert #else
137*b39c5158Smillert         return PERL_constant_NOTDEF;
138*b39c5158Smillert #endif
139*b39c5158Smillert       }
140*b39c5158Smillert       break;
141*b39c5158Smillert     }
142*b39c5158Smillert     break;
143*b39c5158Smillert   case 12:
144*b39c5158Smillert     /* Names all of length 12.  */
145*b39c5158Smillert     /* BZ_FINISH_OK BZ_MEM_ERROR */
146*b39c5158Smillert     /* Offset 5 gives the best switch position.  */
147*b39c5158Smillert     switch (name[5]) {
148*b39c5158Smillert     case 'M':
149*b39c5158Smillert       if (memEQ(name, "BZ_MEM_ERROR", 12)) {
150*b39c5158Smillert       /*                    ^             */
151*b39c5158Smillert #ifdef BZ_MEM_ERROR
152*b39c5158Smillert         *iv_return = BZ_MEM_ERROR;
153*b39c5158Smillert         return PERL_constant_ISIV;
154*b39c5158Smillert #else
155*b39c5158Smillert         return PERL_constant_NOTDEF;
156*b39c5158Smillert #endif
157*b39c5158Smillert       }
158*b39c5158Smillert       break;
159*b39c5158Smillert     case 'N':
160*b39c5158Smillert       if (memEQ(name, "BZ_FINISH_OK", 12)) {
161*b39c5158Smillert       /*                    ^             */
162*b39c5158Smillert #ifdef BZ_FINISH_OK
163*b39c5158Smillert         *iv_return = BZ_FINISH_OK;
164*b39c5158Smillert         return PERL_constant_ISIV;
165*b39c5158Smillert #else
166*b39c5158Smillert         return PERL_constant_NOTDEF;
167*b39c5158Smillert #endif
168*b39c5158Smillert       }
169*b39c5158Smillert       break;
170*b39c5158Smillert     }
171*b39c5158Smillert     break;
172*b39c5158Smillert   case 13:
173*b39c5158Smillert     /* Names all of length 13.  */
174*b39c5158Smillert     /* BZ_DATA_ERROR BZ_STREAM_END */
175*b39c5158Smillert     /* Offset 11 gives the best switch position.  */
176*b39c5158Smillert     switch (name[11]) {
177*b39c5158Smillert     case 'N':
178*b39c5158Smillert       if (memEQ(name, "BZ_STREAM_END", 13)) {
179*b39c5158Smillert       /*                          ^        */
180*b39c5158Smillert #ifdef BZ_STREAM_END
181*b39c5158Smillert         *iv_return = BZ_STREAM_END;
182*b39c5158Smillert         return PERL_constant_ISIV;
183*b39c5158Smillert #else
184*b39c5158Smillert         return PERL_constant_NOTDEF;
185*b39c5158Smillert #endif
186*b39c5158Smillert       }
187*b39c5158Smillert       break;
188*b39c5158Smillert     case 'O':
189*b39c5158Smillert       if (memEQ(name, "BZ_DATA_ERROR", 13)) {
190*b39c5158Smillert       /*                          ^        */
191*b39c5158Smillert #ifdef BZ_DATA_ERROR
192*b39c5158Smillert         *iv_return = BZ_DATA_ERROR;
193*b39c5158Smillert         return PERL_constant_ISIV;
194*b39c5158Smillert #else
195*b39c5158Smillert         return PERL_constant_NOTDEF;
196*b39c5158Smillert #endif
197*b39c5158Smillert       }
198*b39c5158Smillert       break;
199*b39c5158Smillert     }
200*b39c5158Smillert     break;
201*b39c5158Smillert   case 14:
202*b39c5158Smillert     if (memEQ(name, "BZ_PARAM_ERROR", 14)) {
203*b39c5158Smillert #ifdef BZ_PARAM_ERROR
204*b39c5158Smillert       *iv_return = BZ_PARAM_ERROR;
205*b39c5158Smillert       return PERL_constant_ISIV;
206*b39c5158Smillert #else
207*b39c5158Smillert       return PERL_constant_NOTDEF;
208*b39c5158Smillert #endif
209*b39c5158Smillert     }
210*b39c5158Smillert     break;
211*b39c5158Smillert   case 15:
212*b39c5158Smillert     /* Names all of length 15.  */
213*b39c5158Smillert     /* BZ_CONFIG_ERROR BZ_OUTBUFF_FULL */
214*b39c5158Smillert     /* Offset 8 gives the best switch position.  */
215*b39c5158Smillert     switch (name[8]) {
216*b39c5158Smillert     case 'F':
217*b39c5158Smillert       if (memEQ(name, "BZ_OUTBUFF_FULL", 15)) {
218*b39c5158Smillert       /*                       ^             */
219*b39c5158Smillert #ifdef BZ_OUTBUFF_FULL
220*b39c5158Smillert         *iv_return = BZ_OUTBUFF_FULL;
221*b39c5158Smillert         return PERL_constant_ISIV;
222*b39c5158Smillert #else
223*b39c5158Smillert         return PERL_constant_NOTDEF;
224*b39c5158Smillert #endif
225*b39c5158Smillert       }
226*b39c5158Smillert       break;
227*b39c5158Smillert     case 'G':
228*b39c5158Smillert       if (memEQ(name, "BZ_CONFIG_ERROR", 15)) {
229*b39c5158Smillert       /*                       ^             */
230*b39c5158Smillert #ifdef BZ_CONFIG_ERROR
231*b39c5158Smillert         *iv_return = BZ_CONFIG_ERROR;
232*b39c5158Smillert         return PERL_constant_ISIV;
233*b39c5158Smillert #else
234*b39c5158Smillert         return PERL_constant_NOTDEF;
235*b39c5158Smillert #endif
236*b39c5158Smillert       }
237*b39c5158Smillert       break;
238*b39c5158Smillert     }
239*b39c5158Smillert     break;
240*b39c5158Smillert   case 17:
241*b39c5158Smillert     /* Names all of length 17.  */
242*b39c5158Smillert     /* BZ_SEQUENCE_ERROR BZ_UNEXPECTED_EOF */
243*b39c5158Smillert     /* Offset 12 gives the best switch position.  */
244*b39c5158Smillert     switch (name[12]) {
245*b39c5158Smillert     case 'D':
246*b39c5158Smillert       if (memEQ(name, "BZ_UNEXPECTED_EOF", 17)) {
247*b39c5158Smillert       /*                           ^           */
248*b39c5158Smillert #ifdef BZ_UNEXPECTED_EOF
249*b39c5158Smillert         *iv_return = BZ_UNEXPECTED_EOF;
250*b39c5158Smillert         return PERL_constant_ISIV;
251*b39c5158Smillert #else
252*b39c5158Smillert         return PERL_constant_NOTDEF;
253*b39c5158Smillert #endif
254*b39c5158Smillert       }
255*b39c5158Smillert       break;
256*b39c5158Smillert     case 'E':
257*b39c5158Smillert       if (memEQ(name, "BZ_SEQUENCE_ERROR", 17)) {
258*b39c5158Smillert       /*                           ^           */
259*b39c5158Smillert #ifdef BZ_SEQUENCE_ERROR
260*b39c5158Smillert         *iv_return = BZ_SEQUENCE_ERROR;
261*b39c5158Smillert         return PERL_constant_ISIV;
262*b39c5158Smillert #else
263*b39c5158Smillert         return PERL_constant_NOTDEF;
264*b39c5158Smillert #endif
265*b39c5158Smillert       }
266*b39c5158Smillert       break;
267*b39c5158Smillert     }
268*b39c5158Smillert     break;
269*b39c5158Smillert   case 19:
270*b39c5158Smillert     if (memEQ(name, "BZ_DATA_ERROR_MAGIC", 19)) {
271*b39c5158Smillert #ifdef BZ_DATA_ERROR_MAGIC
272*b39c5158Smillert       *iv_return = BZ_DATA_ERROR_MAGIC;
273*b39c5158Smillert       return PERL_constant_ISIV;
274*b39c5158Smillert #else
275*b39c5158Smillert       return PERL_constant_NOTDEF;
276*b39c5158Smillert #endif
277*b39c5158Smillert     }
278*b39c5158Smillert     break;
279*b39c5158Smillert   }
280*b39c5158Smillert   return PERL_constant_NOTFOUND;
281*b39c5158Smillert }
282*b39c5158Smillert 
283