1 /*	$NetBSD: asn1-common.h,v 1.1.1.3 2014/04/24 12:45:28 pettai Exp $	*/
2 
3 /* Id */
4 
5 #include <stddef.h>
6 #include <time.h>
7 #include <krb5/krb5-types.h>
8 
9 #ifndef __asn1_common_definitions__
10 #define __asn1_common_definitions__
11 
12 typedef struct heim_integer {
13     size_t length;
14     void *data;
15     int negative;
16 } heim_integer;
17 
18 typedef struct heim_octet_string {
19     size_t length;
20     void *data;
21 } heim_octet_string;
22 
23 typedef char *heim_general_string;
24 typedef char *heim_utf8_string;
25 typedef struct heim_octet_string heim_printable_string;
26 typedef struct heim_octet_string heim_ia5_string;
27 
28 typedef struct heim_bmp_string {
29     size_t length;
30     uint16_t *data;
31 } heim_bmp_string;
32 
33 typedef struct heim_universal_string {
34     size_t length;
35     uint32_t *data;
36 } heim_universal_string;
37 
38 typedef char *heim_visible_string;
39 
40 typedef struct heim_oid {
41     size_t length;
42     unsigned *components;
43 } heim_oid;
44 
45 typedef struct heim_bit_string {
46     size_t length;
47     void *data;
48 } heim_bit_string;
49 
50 typedef struct heim_octet_string heim_any;
51 typedef struct heim_octet_string heim_any_set;
52 
53 #define ASN1_MALLOC_ENCODE(T, B, BL, S, L, R)                  \
54   do {                                                         \
55     (BL) = length_##T((S));                                    \
56     (B) = malloc((BL));                                        \
57     if((B) == NULL) {                                          \
58       (R) = ENOMEM;                                            \
59     } else {                                                   \
60       (R) = encode_##T(((unsigned char*)(B)) + (BL) - 1, (BL), \
61                        (S), (L));                              \
62       if((R) != 0) {                                           \
63         free((B));                                             \
64         (B) = NULL;                                            \
65       }                                                        \
66     }                                                          \
67   } while (0)
68 
69 #ifdef _WIN32
70 #ifndef ASN1_LIB
71 #define ASN1EXP  __declspec(dllimport)
72 #else
73 #define ASN1EXP
74 #endif
75 #define ASN1CALL __stdcall
76 #else
77 #define ASN1EXP
78 #define ASN1CALL
79 #endif
80 
81 #endif
82