| 1 |
#include "ppport.h" |
| 2 |
void |
| 3 |
constant(sv) |
| 4 |
PREINIT: |
| 5 |
#ifdef dXSTARG |
| 6 |
dXSTARG; /* Faster if we have it. */ |
| 7 |
#else |
| 8 |
dTARGET; |
| 9 |
#endif |
| 10 |
STRLEN len; |
| 11 |
int type; |
| 12 |
IV iv; |
| 13 |
/* NV nv; Uncomment this if you need to return NVs */ |
| 14 |
/* const char *pv; Uncomment this if you need to return PVs */ |
| 15 |
INPUT: |
| 16 |
SV * sv; |
| 17 |
const char * s = SvPV(sv, len); |
| 18 |
PPCODE: |
| 19 |
/* Change this to constant(aTHX_ s, len, &iv, &nv); |
| 20 |
if you need to return both NVs and IVs */ |
| 21 |
type = constant(aTHX_ s, len, &iv); |
| 22 |
/* Return 1 or 2 items. First is error message, or undef if no error. |
| 23 |
Second, if present, is found value */ |
| 24 |
switch (type) { |
| 25 |
case PERL_constant_NOTFOUND: |
| 26 |
sv = |
| 27 |
sv_2mortal(newSVpvf("%s is not a valid Crypt::OpenSSL::EC macro", s)); |
| 28 |
PUSHs(sv); |
| 29 |
break; |
| 30 |
case PERL_constant_NOTDEF: |
| 31 |
sv = sv_2mortal(newSVpvf( |
| 32 |
"Your vendor has not defined Crypt::OpenSSL::EC macro %s, used", |
| 33 |
s)); |
| 34 |
PUSHs(sv); |
| 35 |
break; |
| 36 |
case PERL_constant_ISIV: |
| 37 |
EXTEND(SP, 1); |
| 38 |
PUSHs(&PL_sv_undef); |
| 39 |
PUSHi(iv); |
| 40 |
break; |
| 41 |
/* Uncomment this if you need to return NOs |
| 42 |
case PERL_constant_ISNO: |
| 43 |
EXTEND(SP, 1); |
| 44 |
PUSHs(&PL_sv_undef); |
| 45 |
PUSHs(&PL_sv_no); |
| 46 |
break; */ |
| 47 |
/* Uncomment this if you need to return NVs |
| 48 |
case PERL_constant_ISNV: |
| 49 |
EXTEND(SP, 1); |
| 50 |
PUSHs(&PL_sv_undef); |
| 51 |
PUSHn(nv); |
| 52 |
break; */ |
| 53 |
/* Uncomment this if you need to return PVs |
| 54 |
case PERL_constant_ISPV: |
| 55 |
EXTEND(SP, 1); |
| 56 |
PUSHs(&PL_sv_undef); |
| 57 |
PUSHp(pv, strlen(pv)); |
| 58 |
break; */ |
| 59 |
/* Uncomment this if you need to return PVNs |
| 60 |
case PERL_constant_ISPVN: |
| 61 |
EXTEND(SP, 1); |
| 62 |
PUSHs(&PL_sv_undef); |
| 63 |
PUSHp(pv, iv); |
| 64 |
break; */ |
| 65 |
/* Uncomment this if you need to return SVs |
| 66 |
case PERL_constant_ISSV: |
| 67 |
EXTEND(SP, 1); |
| 68 |
PUSHs(&PL_sv_undef); |
| 69 |
PUSHs(sv); |
| 70 |
break; */ |
| 71 |
/* Uncomment this if you need to return UNDEFs |
| 72 |
case PERL_constant_ISUNDEF: |
| 73 |
break; */ |
| 74 |
/* Uncomment this if you need to return UVs |
| 75 |
case PERL_constant_ISUV: |
| 76 |
EXTEND(SP, 1); |
| 77 |
PUSHs(&PL_sv_undef); |
| 78 |
PUSHu((UV)iv); |
| 79 |
break; */ |
| 80 |
/* Uncomment this if you need to return YESs |
| 81 |
case PERL_constant_ISYES: |
| 82 |
EXTEND(SP, 1); |
| 83 |
PUSHs(&PL_sv_undef); |
| 84 |
PUSHs(&PL_sv_yes); |
| 85 |
break; */ |
| 86 |
default: |
| 87 |
sv = sv_2mortal(newSVpvf( |
| 88 |
"Unexpected return type %d while processing Crypt::OpenSSL::EC macro %s, used", |
| 89 |
type, s)); |
| 90 |
PUSHs(sv); |
| 91 |
} |