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