Make build on windows
[heimdal.git] / lib / asn1 / asn1-common.h
blob8ab97761dbf8e193b44f8018bd24a12ea9a1b2de
1 /* $Id$ */
3 #include <stddef.h>
4 #include <time.h>
5 #include <krb5-types.h>
7 #ifndef __asn1_common_definitions__
8 #define __asn1_common_definitions__
10 typedef struct heim_integer {
11 size_t length;
12 void *data;
13 int negative;
14 } heim_integer;
16 typedef struct heim_octet_string {
17 size_t length;
18 void *data;
19 } heim_octet_string;
21 typedef char *heim_general_string;
22 typedef char *heim_utf8_string;
23 typedef char *heim_printable_string;
24 typedef char *heim_ia5_string;
26 typedef struct heim_bmp_string {
27 size_t length;
28 uint16_t *data;
29 } heim_bmp_string;
31 typedef struct heim_universal_string {
32 size_t length;
33 uint32_t *data;
34 } heim_universal_string;
36 typedef char *heim_visible_string;
38 typedef struct heim_oid {
39 size_t length;
40 unsigned *components;
41 } heim_oid;
43 typedef struct heim_bit_string {
44 size_t length;
45 void *data;
46 } heim_bit_string;
48 typedef struct heim_octet_string heim_any;
49 typedef struct heim_octet_string heim_any_set;
51 #define ASN1_MALLOC_ENCODE(T, B, BL, S, L, R) \
52 do { \
53 (BL) = length_##T((S)); \
54 (B) = malloc((BL)); \
55 if((B) == NULL) { \
56 (R) = ENOMEM; \
57 } else { \
58 (R) = encode_##T(((unsigned char*)(B)) + (BL) - 1, (BL), \
59 (S), (L)); \
60 if((R) != 0) { \
61 free((B)); \
62 (B) = NULL; \
63 } \
64 } \
65 } while (0)
67 #endif