2 * Copyright (C) 2000-2014 Free Software Foundation, Inc.
4 * This file is part of LIBTASN1.
6 * The LIBTASN1 library is free software; you can redistribute it
7 * and/or modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25 /***********************************************/
27 /* Description: type used in the list during */
28 /* the structure creation. */
29 /***********************************************/
30 typedef struct list_struct
33 struct list_struct *next;
36 /***************************************/
37 /* Functions used by ASN.1 parser */
38 /***************************************/
39 asn1_node _asn1_add_static_node (list_type **e_list, unsigned int type);
41 void _asn1_delete_list (list_type *e_list);
43 void _asn1_delete_list_and_nodes (list_type *e_list);
47 _asn1_set_value (asn1_node node, const void *value, unsigned int len);
49 asn1_node _asn1_set_value_m (asn1_node node, void *value, unsigned int len);
52 _asn1_set_value_lv (asn1_node node, const void *value, unsigned int len);
55 _asn1_append_value (asn1_node node, const void *value, unsigned int len);
57 asn1_node _asn1_set_name (asn1_node node, const char *name);
59 asn1_node _asn1_cpy_name (asn1_node dst, asn1_node_const src);
61 asn1_node _asn1_set_right (asn1_node node, asn1_node right);
63 asn1_node _asn1_get_last_right (asn1_node_const node);
65 void _asn1_remove_node (asn1_node node, unsigned int flags);
67 /* Max 64-bit integer length is 20 chars + 1 for sign + 1 for null termination */
68 #define LTOSTR_MAX_SIZE 22
69 char *_asn1_ltostr (int64_t v, char str[LTOSTR_MAX_SIZE]);
71 asn1_node _asn1_find_up (asn1_node_const node);
73 int _asn1_change_integer_value (asn1_node node);
75 #define EXPAND_OBJECT_ID_MAX_RECURSION 16
76 int _asn1_expand_object_id (list_type *list, asn1_node node);
78 int _asn1_type_set_config (asn1_node node);
80 int _asn1_check_identifier (asn1_node_const node);
82 int _asn1_set_default_tag (asn1_node node);
84 /******************************************************************/
85 /* Function : _asn1_get_right */
86 /* Description: returns the element pointed by the RIGHT field of */
87 /* a NODE_ASN element. */
89 /* node: NODE_ASN element pointer. */
90 /* Return: field RIGHT of NODE. */
91 /******************************************************************/
92 inline static asn1_node
93 _asn1_get_right (asn1_node_const node)
100 /******************************************************************/
101 /* Function : _asn1_set_down */
102 /* Description: sets the field DOWN in a NODE_ASN element. */
104 /* node: element pointer. */
105 /* down: pointer to a NODE_ASN element that you want be pointed */
107 /* Return: pointer to *NODE. */
108 /******************************************************************/
109 inline static asn1_node
110 _asn1_set_down (asn1_node node, asn1_node down)
120 /******************************************************************/
121 /* Function : _asn1_get_down */
122 /* Description: returns the element pointed by the DOWN field of */
123 /* a NODE_ASN element. */
125 /* node: NODE_ASN element pointer. */
126 /* Return: field DOWN of NODE. */
127 /******************************************************************/
128 inline static asn1_node
129 _asn1_get_down (asn1_node_const node)
136 /******************************************************************/
137 /* Function : _asn1_get_name */
138 /* Description: returns the name of a NODE_ASN element. */
140 /* node: NODE_ASN element pointer. */
141 /* Return: a null terminated string. */
142 /******************************************************************/
144 _asn1_get_name (asn1_node_const node)
148 return (char *) node->name;
151 /******************************************************************/
152 /* Function : _asn1_mod_type */
153 /* Description: change the field TYPE of an NODE_ASN element. */
154 /* The new value is the old one | (bitwise or) the */
155 /* paramener VALUE. */
157 /* node: NODE_ASN element pointer. */
158 /* value: the integer value that must be or-ed with the current */
159 /* value of field TYPE. */
160 /* Return: NODE pointer. */
161 /******************************************************************/
162 inline static asn1_node
163 _asn1_mod_type (asn1_node node, unsigned int value)