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 (pTHX_ const char *name, STRLEN len, IV *iv_return) { 25 /* Initially switch on the length of the name. */ 26 /* When generated this function returned values for the list of names given 27 in this section of perl code. Rather than manually editing these functions 28 to add or remove constants, which would result in this comment and section 29 of code becoming inaccurate, we recommend that you edit this section of 30 code, and use it to regenerate a new set of constant functions which you 31 then use to replace the originals. 32 33 Regenerate these constant functions by feeding this entire source file to 34 perl -x 35 36#!C:\perl5\bin\perl.exe -w 37use ExtUtils::Constant qw (constant_types C_constant XS_constant); 38 39my $types = {map {($_, 1)} qw(IV)}; 40my @names = (qw(CRYPT_MODE_AUTO CRYPT_MODE_DECRYPT CRYPT_MODE_DECRYPTED 41 CRYPT_MODE_ENCRYPT CRYPT_MODE_ENCRYPTED)); 42 43print constant_types(); # macro defs 44foreach (C_constant ("Filter::Crypto::CryptFile", 'constant', 'IV', $types, undef, 3, @names) ) { 45 print $_, "\n"; # C constant subs 46} 47print "#### XS Section:\n"; 48print XS_constant ("Filter::Crypto::CryptFile", $types); 49__END__ 50 */ 51 52 switch (len) { 53 case 15: 54 if (memEQ(name, "CRYPT_MODE_AUTO", 15)) { 55#ifdef CRYPT_MODE_AUTO 56 *iv_return = CRYPT_MODE_AUTO; 57 return PERL_constant_ISIV; 58#else 59 return PERL_constant_NOTDEF; 60#endif 61 } 62 break; 63 case 18: 64 /* Names all of length 18. */ 65 /* CRYPT_MODE_DECRYPT CRYPT_MODE_ENCRYPT */ 66 /* Offset 11 gives the best switch position. */ 67 switch (name[11]) { 68 case 'D': 69 if (memEQ(name, "CRYPT_MODE_DECRYPT", 18)) { 70 /* ^ */ 71#ifdef CRYPT_MODE_DECRYPT 72 *iv_return = CRYPT_MODE_DECRYPT; 73 return PERL_constant_ISIV; 74#else 75 return PERL_constant_NOTDEF; 76#endif 77 } 78 break; 79 case 'E': 80 if (memEQ(name, "CRYPT_MODE_ENCRYPT", 18)) { 81 /* ^ */ 82#ifdef CRYPT_MODE_ENCRYPT 83 *iv_return = CRYPT_MODE_ENCRYPT; 84 return PERL_constant_ISIV; 85#else 86 return PERL_constant_NOTDEF; 87#endif 88 } 89 break; 90 } 91 break; 92 case 20: 93 /* Names all of length 20. */ 94 /* CRYPT_MODE_DECRYPTED CRYPT_MODE_ENCRYPTED */ 95 /* Offset 11 gives the best switch position. */ 96 switch (name[11]) { 97 case 'D': 98 if (memEQ(name, "CRYPT_MODE_DECRYPTED", 20)) { 99 /* ^ */ 100#ifdef CRYPT_MODE_DECRYPTED 101 *iv_return = CRYPT_MODE_DECRYPTED; 102 return PERL_constant_ISIV; 103#else 104 return PERL_constant_NOTDEF; 105#endif 106 } 107 break; 108 case 'E': 109 if (memEQ(name, "CRYPT_MODE_ENCRYPTED", 20)) { 110 /* ^ */ 111#ifdef CRYPT_MODE_ENCRYPTED 112 *iv_return = CRYPT_MODE_ENCRYPTED; 113 return PERL_constant_ISIV; 114#else 115 return PERL_constant_NOTDEF; 116#endif 117 } 118 break; 119 } 120 break; 121 } 122 return PERL_constant_NOTFOUND; 123} 124 125