1 | #include "EXTERN.h" |
1 | #include "EXTERN.h" |
2 | #include "perl.h" |
2 | #include "perl.h" |
3 | #include "XSUB.h" |
3 | #include "XSUB.h" |
4 | |
4 | |
5 | // C99 required |
5 | // C99 required! |
|
|
6 | // this is not just for comments, but also for |
|
|
7 | // integer constant semantics, |
|
|
8 | // sscanf format modifiers and more. |
6 | |
9 | |
7 | enum { |
10 | enum { |
8 | // ASN_TAG |
11 | // ASN_TAG |
9 | ASN_BOOLEAN = 0x01, |
12 | ASN_BOOLEAN = 0x01, |
10 | ASN_INTEGER32 = 0x02, |
13 | ASN_INTEGER32 = 0x02, |
… | |
… | |
199 | { ASN_UNIVERSAL, ASN_UTF8_STRING , BER_TYPE_UTF8 }, |
202 | { ASN_UNIVERSAL, ASN_UTF8_STRING , BER_TYPE_UTF8 }, |
200 | { ASN_UNIVERSAL, ASN_BMP_STRING , BER_TYPE_UCS2 }, |
203 | { ASN_UNIVERSAL, ASN_BMP_STRING , BER_TYPE_UCS2 }, |
201 | { ASN_UNIVERSAL, ASN_UNIVERSAL_STRING , BER_TYPE_UCS4 }, |
204 | { ASN_UNIVERSAL, ASN_UNIVERSAL_STRING , BER_TYPE_UCS4 }, |
202 | }; |
205 | }; |
203 | |
206 | |
204 | for (celem = default_map + sizeof (default_map) / sizeof (default_map [0]); celem > default_map; celem--) |
207 | for (celem = default_map + sizeof (default_map) / sizeof (default_map [0]); celem-- > default_map; ) |
205 | profile_set ((void *)sv, celem->klass, celem->tag, celem->type); |
208 | profile_set ((profile_type *)sv, celem->klass, celem->tag, celem->type); |
206 | |
209 | |
207 | return sv_bless (newRV_noinc (sv), profile_stash); |
210 | return sv_bless (newRV_noinc (sv), profile_stash); |
208 | } |
211 | } |
209 | |
212 | |
210 | ///////////////////////////////////////////////////////////////////////////// |
213 | ///////////////////////////////////////////////////////////////////////////// |
… | |
… | |
343 | u /= 10; |
346 | u /= 10; |
344 | } |
347 | } |
345 | while (u); |
348 | while (u); |
346 | |
349 | |
347 | // reverse digits |
350 | // reverse digits |
348 | for (char *ptr = buf; --ptr != beg; ++beg) |
351 | char *ptr = buf; |
|
|
352 | while (--ptr != beg) |
349 | { |
353 | { |
350 | char c = *ptr; |
354 | char c = *ptr; |
351 | *ptr = *beg; |
355 | *ptr = *beg; |
352 | *beg = c; |
356 | *beg = c; |
|
|
357 | ++beg; |
353 | } |
358 | } |
354 | } |
359 | } |
355 | |
360 | |
356 | return buf; |
361 | return buf; |
357 | } |
362 | } |
… | |
… | |
868 | int fill = AvFILL (av); |
873 | int fill = AvFILL (av); |
869 | |
874 | |
870 | if (expect_false (SvRMAGICAL (av))) |
875 | if (expect_false (SvRMAGICAL (av))) |
871 | croak ("BER constructed data must not be tied"); |
876 | croak ("BER constructed data must not be tied"); |
872 | |
877 | |
|
|
878 | int i; |
873 | for (int i = 0; i <= fill; ++i) |
879 | for (i = 0; i <= fill; ++i) |
874 | encode_ber (AvARRAY (av)[i]); |
880 | encode_ber (AvARRAY (av)[i]); |
875 | |
881 | |
876 | len_fixup (mark); |
882 | len_fixup (mark); |
877 | } |
883 | } |
878 | else |
884 | else |