C99 macro
[libtasn1.git] / lib / int.h
blob3219ec2c69ce47f963daf1a43359fa4dff49276b
1 /*
2 * Copyright (C) 2002 Fabio Fiorina
4 * This file is part of LIBASN1.
6 * GNUTLS is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * GNUTLS is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
21 #ifndef INT_H
23 #define INT_H
25 #include <defines.h>
28 #define LIBTASN1_DEBUG
29 #define LIBTASN1_DEBUG_PARSER
30 #define LIBTASN1_DEBUG_INTEGER
34 #define MAX32 4294967295
35 #define MAX24 16777215
36 #define MAX16 65535
38 #define MAX_LOG_SIZE 1024 /* maximum number of characters of a log message */
39 #define MAX_NAME_SIZE 128 /* maximum number of characters of a name inside an ASN1 file definitons */
40 #define MAX_ERROR_DESCRIPTION_SIZE 1024 /* maximum number of characters of a description message */
43 /* define used for visiting trees */
44 #define UP 1
45 #define RIGHT 2
46 #define DOWN 3
49 typedef int asn1_retCode; /* type returned by libasn1 functions */
52 /******************************************************/
53 /* Structure definition used for the node of the tree */
54 /* that rappresent an ASN.1 DEFINITION. */
55 /******************************************************/
56 typedef struct node_asn_struct{
57 char *name; /* Node name */
58 unsigned int type; /* Node type */
59 unsigned char *value; /* Node value */
60 struct node_asn_struct *down; /* Pointer to the son node */
61 struct node_asn_struct *right; /* Pointer to the brother node */
62 struct node_asn_struct *left; /* Pointer to the next list element */
63 } node_asn;
65 typedef node_asn* ASN1_TYPE;
67 #define ASN1_TYPE_EMPTY NULL
69 struct static_struct_asn{
70 char *name; /* Node name */
71 unsigned int type; /* Node type */
72 unsigned char *value; /* Node value */
75 typedef struct static_struct_asn ASN1_ARRAY_TYPE;
78 /****************************************/
79 /* Returns the first 8 bits. */
80 /* Used with the field type of node_asn */
81 /****************************************/
82 #define type_field(x) (x&0xFF)
85 /* List of constants for field type of typedef node_asn */
86 #define TYPE_CONSTANT 1
87 #define TYPE_IDENTIFIER 2
88 #define TYPE_INTEGER 3
89 #define TYPE_BOOLEAN 4
90 #define TYPE_SEQUENCE 5
91 #define TYPE_BIT_STRING 6
92 #define TYPE_OCTET_STRING 7
93 #define TYPE_TAG 8
94 #define TYPE_DEFAULT 9
95 #define TYPE_SIZE 10
96 #define TYPE_SEQUENCE_OF 11
97 #define TYPE_OBJECT_ID 12
98 #define TYPE_ANY 13
99 #define TYPE_SET 14
100 #define TYPE_SET_OF 15
101 #define TYPE_DEFINITIONS 16
102 #define TYPE_TIME 17
103 #define TYPE_CHOICE 18
104 #define TYPE_IMPORTS 19
105 #define TYPE_NULL 20
106 #define TYPE_ENUMERATED 21
107 #define TYPE_GENERALSTRING 27
110 /***********************************************************************/
111 /* List of constants for specify better the type of typedef node_asn. */
112 /***********************************************************************/
113 /* Used with TYPE_TAG */
114 #define CONST_UNIVERSAL (1<<8)
115 #define CONST_PRIVATE (1<<9)
116 #define CONST_APPLICATION (1<<10)
117 #define CONST_EXPLICIT (1<<11)
118 #define CONST_IMPLICIT (1<<12)
120 #define CONST_TAG (1<<13) /* Used in ASN.1 assignement */
121 #define CONST_OPTION (1<<14)
122 #define CONST_DEFAULT (1<<15)
123 #define CONST_TRUE (1<<16)
124 #define CONST_FALSE (1<<17)
126 #define CONST_LIST (1<<18) /* Used with TYPE_INTEGER and TYPE_BIT_STRING */
127 #define CONST_MIN_MAX (1<<19)
129 #define CONST_1_PARAM (1<<20)
131 #define CONST_SIZE (1<<21)
133 #define CONST_DEFINED_BY (1<<22)
135 #define CONST_GENERALIZED (1<<23)
136 #define CONST_UTC (1<<24)
138 // #define CONST_IMPORTS (1<<25)
140 #define CONST_NOT_USED (1<<26)
141 #define CONST_SET (1<<27)
142 #define CONST_ASSIGN (1<<28)
144 #define CONST_DOWN (1<<29)
145 #define CONST_RIGHT (1<<30)
148 /* functions */
149 asn1_retCode asn1_delete_structure(ASN1_TYPE *structure);
151 asn1_retCode asn1_create_element(ASN1_TYPE definitions,const char *source_name,
152 ASN1_TYPE *element,const char *dest_name);
154 asn1_retCode asn1_read_value(ASN1_TYPE element,const char *name,
155 unsigned char *value,int *len);
157 asn1_retCode
158 asn1_expand_octet_string(ASN1_TYPE definitions,ASN1_TYPE *element,
159 const char *octetName,const char *objectName);
162 #endif /* INT_H */