ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Convert-BER-XS/XS.xs
(Generate patch)

Comparing Convert-BER-XS/XS.xs (file contents):
Revision 1.7 by root, Sat Apr 20 01:31:07 2019 UTC vs.
Revision 1.10 by root, Sat Apr 20 11:12:47 2019 UTC

10 ASN_INTEGER32 = 0x02, 10 ASN_INTEGER32 = 0x02,
11 ASN_BIT_STRING = 0x03, 11 ASN_BIT_STRING = 0x03,
12 ASN_OCTET_STRING = 0x04, 12 ASN_OCTET_STRING = 0x04,
13 ASN_NULL = 0x05, 13 ASN_NULL = 0x05,
14 ASN_OBJECT_IDENTIFIER = 0x06, 14 ASN_OBJECT_IDENTIFIER = 0x06,
15 ASN_OID = 0x06, //X 15 ASN_OID = 0x06,
16 ASN_OBJECT_DESCRIPTOR = 0x07, //X 16 ASN_OBJECT_DESCRIPTOR = 0x07,
17 ASN_EXTERNAL = 0x08, //X 17 ASN_EXTERNAL = 0x08,
18 ASN_REAL = 0x09, //X 18 ASN_REAL = 0x09,
19 ASN_ENUMERATED = 0x0a, //X 19 ASN_ENUMERATED = 0x0a,
20 ASN_EMBEDDED_PDV = 0x0b, //X 20 ASN_EMBEDDED_PDV = 0x0b,
21 ASN_UTF8_STRING = 0x0c, //X 21 ASN_UTF8_STRING = 0x0c,
22 ASN_RELATIVE_OID = 0x0d, //X 22 ASN_RELATIVE_OID = 0x0d,
23 ASN_SEQUENCE = 0x10, 23 ASN_SEQUENCE = 0x10,
24 ASN_SET = 0x11, //X 24 ASN_SET = 0x11,
25 ASN_NUMERIC_STRING = 0x12, //X 25 ASN_NUMERIC_STRING = 0x12,
26 ASN_PRINTABLE_STRING = 0x13, //X 26 ASN_PRINTABLE_STRING = 0x13,
27 ASN_TELETEX_STRING = 0x14, //X 27 ASN_TELETEX_STRING = 0x14,
28 ASN_T61_STRING = 0x14, //X 28 ASN_T61_STRING = 0x14,
29 ASN_VIDEOTEX_STRING = 0x15, //X 29 ASN_VIDEOTEX_STRING = 0x15,
30 ASN_IA5_STRING = 0x16, //X 30 ASN_IA5_STRING = 0x16,
31 ASN_ASCII_STRING = 0x16, //X 31 ASN_ASCII_STRING = 0x16,
32 ASN_UTC_TIME = 0x17, //X 32 ASN_UTC_TIME = 0x17,
33 ASN_GENERALIZED_TIME = 0x18, //X 33 ASN_GENERALIZED_TIME = 0x18,
34 ASN_GRAPHIC_STRING = 0x19, //X 34 ASN_GRAPHIC_STRING = 0x19,
35 ASN_VISIBLE_STRING = 0x1a, //X 35 ASN_VISIBLE_STRING = 0x1a,
36 ASN_ISO646_STRING = 0x1a, //X 36 ASN_ISO646_STRING = 0x1a,
37 ASN_GENERAL_STRING = 0x1b, //X 37 ASN_GENERAL_STRING = 0x1b,
38 ASN_UNIVERSAL_STRING = 0x1c, //X 38 ASN_UNIVERSAL_STRING = 0x1c,
39 ASN_CHARACTER_STRING = 0x1d, //X 39 ASN_CHARACTER_STRING = 0x1d,
40 ASN_BMP_STRING = 0x1e, //X 40 ASN_BMP_STRING = 0x1e,
41 41
42 ASN_TAG_BER = 0x1f, 42 ASN_TAG_BER = 0x1f,
43 ASN_TAG_MASK = 0x1f, 43 ASN_TAG_MASK = 0x1f,
44 44
45 // primitive/constructed 45 // primitive/constructed
92 92
93static profile_type *cur_profile, *default_profile; 93static profile_type *cur_profile, *default_profile;
94static SV *buf_sv; // encoding buffer 94static SV *buf_sv; // encoding buffer
95static U8 *buf, *cur, *end; // buffer start, current, end 95static U8 *buf, *cur, *end; // buffer start, current, end
96 96
97#if PERL_VERSION < 18
98# define utf8_to_uvchr_buf(s,e,l) utf8_to_uvchr (s, l)
99#endif
100
97#if __GNUC__ >= 3 101#if __GNUC__ >= 3
98# define expect(expr,value) __builtin_expect ((expr), (value)) 102# define expect(expr,value) __builtin_expect ((expr), (value))
99# define INLINE static inline 103# define INLINE static inline
100#else 104#else
101# define expect(expr,value) (expr) 105# define expect(expr,value) (expr)
155 return BER_TYPE_BYTES; 159 return BER_TYPE_BYTES;
156 160
157 return SvPVX (sv)[idx]; 161 return SvPVX (sv)[idx];
158} 162}
159 163
160static int 164static void
161profile_set (profile_type *profile, int klass, int tag, int type) 165profile_set (profile_type *profile, int klass, int tag, int type)
162{ 166{
163 SV *sv = (SV *)profile; 167 SV *sv = (SV *)profile;
164 U32 idx = (tag << 2) + klass; 168 U32 idx = (tag << 2) + klass;
165 STRLEN oldlen = SvCUR (sv); 169 STRLEN oldlen = SvCUR (sv);
553static void 557static void
554set_buf (SV *sv) 558set_buf (SV *sv)
555{ 559{
556 STRLEN len; 560 STRLEN len;
557 buf_sv = sv; 561 buf_sv = sv;
558 buf = SvPVbyte (buf_sv, len); 562 buf = (U8 *)SvPVbyte (buf_sv, len);
559 cur = buf; 563 cur = buf;
560 end = buf + len; 564 end = buf + len;
561} 565}
562 566
563/* similar to SvGROW, but somewhat safer and guarantees exponential realloc strategy */ 567/* similar to SvGROW, but somewhat safer and guarantees exponential realloc strategy */
577need (STRLEN len) 581need (STRLEN len)
578{ 582{
579 if (expect_false ((uintptr_t)(end - cur) < len)) 583 if (expect_false ((uintptr_t)(end - cur) < len))
580 { 584 {
581 STRLEN pos = cur - buf; 585 STRLEN pos = cur - buf;
582 buf = my_sv_grow (buf_sv, pos, len); 586 buf = (U8 *)my_sv_grow (buf_sv, pos, len);
583 cur = buf + pos; 587 cur = buf + pos;
584 end = buf + SvLEN (buf_sv) - 1; 588 end = buf + SvLEN (buf_sv) - 1;
585 } 589 }
586} 590}
587 591
813 put_length (uchars * chrsize); 817 put_length (uchars * chrsize);
814 818
815 while (uchars--) 819 while (uchars--)
816 { 820 {
817 STRLEN uclen; 821 STRLEN uclen;
818 UV uchr = utf8_to_uvchr_buf (ptr, ptr + len, &uclen); 822 UV uchr = utf8_to_uvchr_buf ((U8 *)ptr, (U8 *)ptr + len, &uclen);
819 823
820 ptr += uclen; 824 ptr += uclen;
821 len -= uclen; 825 len -= uclen;
822 826
823 if (chrsize == 4) 827 if (chrsize == 4)
1024ber_decode (SV *ber, SV *profile = &PL_sv_undef) 1028ber_decode (SV *ber, SV *profile = &PL_sv_undef)
1025 CODE: 1029 CODE:
1026{ 1030{
1027 cur_profile = SvPROFILE (profile); 1031 cur_profile = SvPROFILE (profile);
1028 STRLEN len; 1032 STRLEN len;
1029 buf = SvPVbyte (ber, len); 1033 buf = (U8 *)SvPVbyte (ber, len);
1030 cur = buf; 1034 cur = buf;
1031 end = buf + len; 1035 end = buf + len;
1032 1036
1033 RETVAL = decode_ber (); 1037 RETVAL = decode_ber ();
1034} 1038}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines