Lev Walkin | 75809e8 | 2004-06-28 21:25:18 +0000 | [diff] [blame] | 1 | #undef NDEBUG |
| 2 | #include <stdio.h> |
| 3 | #include <stdlib.h> |
| 4 | #include <sys/types.h> |
| 5 | #include <string.h> |
| 6 | #include <assert.h> |
| 7 | |
| 8 | #include <T.h> |
| 9 | |
| 10 | uint8_t buf1[] = { |
| 11 | 32 | ((2 << 6) + 3), /* [3], constructed */ |
| 12 | 5, |
| 13 | ((2 << 6) + 5), /* [5], primitive */ |
| 14 | 3, /* L */ |
| 15 | 'a', |
| 16 | 'b', |
| 17 | 'c', |
| 18 | }; |
| 19 | |
| 20 | static void |
Lev Walkin | 1715b32 | 2013-03-28 04:02:13 -0700 | [diff] [blame] | 21 | check(uint8_t *buf, size_t size, size_t consumed) { |
Lev Walkin | 75809e8 | 2004-06-28 21:25:18 +0000 | [diff] [blame] | 22 | T_t t, *tp; |
Lev Walkin | 90bf7ae | 2004-10-20 15:46:56 +0000 | [diff] [blame] | 23 | asn_dec_rval_t rval; |
Lev Walkin | 75809e8 | 2004-06-28 21:25:18 +0000 | [diff] [blame] | 24 | |
| 25 | tp = memset(&t, 0, sizeof(t)); |
| 26 | |
| 27 | fprintf(stderr, "Buf %p\n", buf); |
Lev Walkin | c7400c5 | 2004-09-29 13:14:36 +0000 | [diff] [blame] | 28 | rval = ber_decode(0, &asn_DEF_T, (void **)&tp, buf, size); |
Lev Walkin | 1715b32 | 2013-03-28 04:02:13 -0700 | [diff] [blame] | 29 | fprintf(stderr, "Returned code %d, consumed %zd\n", |
| 30 | (int)rval.code, rval.consumed); |
Lev Walkin | 75809e8 | 2004-06-28 21:25:18 +0000 | [diff] [blame] | 31 | |
| 32 | assert(rval.code == RC_OK); |
| 33 | assert(rval.consumed == consumed); |
Vasil Velichkov | cef21e0 | 2017-10-09 23:40:17 +0300 | [diff] [blame] | 34 | ASN_STRUCT_RESET(asn_DEF_T, tp); |
Lev Walkin | 75809e8 | 2004-06-28 21:25:18 +0000 | [diff] [blame] | 35 | } |
| 36 | |
| 37 | int |
| 38 | main(int ac, char **av) { |
| 39 | |
| 40 | (void)ac; /* Unused argument */ |
| 41 | (void)av; /* Unused argument */ |
| 42 | |
| 43 | check(buf1, sizeof(buf1), sizeof(buf1)); |
| 44 | |
| 45 | return 0; |
| 46 | } |
| 47 | |