REVERT: add and use der_{malloc,free}
[heimdal.git] / lib / asn1 / asn1-common.h
blob4c6af8b45eb1717316d477b04cdc1244cacfbd5b
1 /* $Id$ */
3 #include <stddef.h>
4 #include <time.h>
6 #ifndef __asn1_common_definitions__
7 #define __asn1_common_definitions__
9 typedef struct heim_integer {
10 size_t length;
11 void *data;
12 int negative;
13 } heim_integer;
15 typedef struct heim_octet_string {
16 size_t length;
17 void *data;
18 } heim_octet_string;
20 typedef char *heim_general_string;
21 typedef char *heim_utf8_string;
22 typedef char *heim_printable_string;
23 typedef char *heim_ia5_string;
25 typedef struct heim_bmp_string {
26 size_t length;
27 uint16_t *data;
28 } heim_bmp_string;
30 typedef struct heim_universal_string {
31 size_t length;
32 uint32_t *data;
33 } heim_universal_string;
35 typedef char *heim_visible_string;
37 typedef struct heim_oid {
38 size_t length;
39 unsigned *components;
40 } heim_oid;
42 typedef struct heim_bit_string {
43 size_t length;
44 void *data;
45 } heim_bit_string;
47 typedef struct heim_octet_string heim_any;
48 typedef struct heim_octet_string heim_any_set;
50 #define ASN1_MALLOC_ENCODE(T, B, BL, S, L, R) \
51 do { \
52 (BL) = length_##T((S)); \
53 (B) = malloc((BL)); \
54 if((B) == NULL) { \
55 (R) = ENOMEM; \
56 } else { \
57 (R) = encode_##T(((unsigned char*)(B)) + (BL) - 1, (BL), \
58 (S), (L)); \
59 if((R) != 0) { \
60 free((B)); \
61 (B) = NULL; \
62 } \
63 } \
64 } while (0)
66 #endif