__HEIM_OCTET_STRING__
[heimdal.git] / lib / asn1 / asn1-common.h
blob6c7f6dd501e6441d7f72728ac7fc3b9dd82bf35e
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 #ifndef __HEIM_OCTET_STRING__
17 #define __HEIM_OCTET_STRING__
18 typedef struct heim_octet_string {
19 size_t length;
20 void *data;
21 } heim_octet_string;
22 #endif
24 typedef char *heim_general_string;
25 typedef char *heim_utf8_string;
26 typedef struct heim_octet_string heim_printable_string;
27 typedef struct heim_octet_string heim_ia5_string;
29 typedef struct heim_bmp_string {
30 size_t length;
31 uint16_t *data;
32 } heim_bmp_string;
34 typedef struct heim_universal_string {
35 size_t length;
36 uint32_t *data;
37 } heim_universal_string;
39 typedef char *heim_visible_string;
41 typedef struct heim_oid {
42 size_t length;
43 unsigned *components;
44 } heim_oid;
46 typedef struct heim_bit_string {
47 size_t length;
48 void *data;
49 } heim_bit_string;
51 typedef struct heim_octet_string heim_any;
52 typedef struct heim_octet_string heim_any_set;
54 #define ASN1_MALLOC_ENCODE(T, B, BL, S, L, R) \
55 do { \
56 (BL) = length_##T((S)); \
57 (B) = malloc((BL)); \
58 if((B) == NULL) { \
59 (R) = ENOMEM; \
60 } else { \
61 (R) = encode_##T(((unsigned char*)(B)) + (BL) - 1, (BL), \
62 (S), (L)); \
63 if((R) != 0) { \
64 free((B)); \
65 (B) = NULL; \
66 } \
67 } \
68 } while (0)
70 #ifdef _WIN32
71 #ifndef ASN1_LIB
72 #define ASN1EXP __declspec(dllimport)
73 #else
74 #define ASN1EXP
75 #endif
76 #define ASN1CALL __stdcall
77 #else
78 #define ASN1EXP
79 #define ASN1CALL
80 #endif
82 #endif