remove -Werror from automake
[platform/upstream/libtasn1.git] / lib / parser_aux.h
1 /*
2  * Copyright (C) 2000-2014 Free Software Foundation, Inc.
3  *
4  * This file is part of LIBTASN1.
5  *
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.
10  *
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.
15  *
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
19  * 02110-1301, USA
20  */
21
22 #ifndef _PARSER_AUX_H
23 #define _PARSER_AUX_H
24
25 /***************************************/
26 /*  Functions used by ASN.1 parser     */
27 /***************************************/
28 asn1_node _asn1_add_static_node (unsigned int type);
29
30 asn1_node
31 _asn1_set_value (asn1_node node, const void *value, unsigned int len);
32
33 asn1_node _asn1_set_value_m (asn1_node node, void *value, unsigned int len);
34
35 asn1_node
36 _asn1_set_value_lv (asn1_node node, const void *value, unsigned int len);
37
38 asn1_node
39 _asn1_append_value (asn1_node node, const void *value, unsigned int len);
40
41 asn1_node _asn1_set_name (asn1_node node, const char *name);
42
43 asn1_node _asn1_cpy_name (asn1_node dst, asn1_node src);
44
45 asn1_node _asn1_set_right (asn1_node node, asn1_node right);
46
47 asn1_node _asn1_get_last_right (asn1_node node);
48
49 void _asn1_remove_node (asn1_node node, unsigned int flags);
50
51 void _asn1_delete_list (void);
52
53 void _asn1_delete_list_and_nodes (void);
54
55 #define LTOSTR_MAX_SIZE 20
56 char *_asn1_ltostr (long v, char *str);
57
58 asn1_node _asn1_find_up (asn1_node node);
59
60 inline static asn1_node _asn1_get_up(asn1_node node)
61 {
62         if (node && node->up)
63                 return node->up;
64         else
65                 return _asn1_find_up(node);
66 }
67
68 int _asn1_change_integer_value (asn1_node node);
69
70 int _asn1_expand_object_id (asn1_node node);
71
72 int _asn1_type_set_config (asn1_node node);
73
74 int _asn1_check_identifier (asn1_node node);
75
76 int _asn1_set_default_tag (asn1_node node);
77
78 /******************************************************************/
79 /* Function : _asn1_get_right                                     */
80 /* Description: returns the element pointed by the RIGHT field of */
81 /*              a NODE_ASN element.                               */
82 /* Parameters:                                                    */
83 /*   node: NODE_ASN element pointer.                              */
84 /* Return: field RIGHT of NODE.                                   */
85 /******************************************************************/
86 inline static asn1_node
87 _asn1_get_right (asn1_node node)
88 {
89   if (node == NULL)
90     return NULL;
91   return node->right;
92 }
93
94 /******************************************************************/
95 /* Function : _asn1_set_down                                      */
96 /* Description: sets the field DOWN in a NODE_ASN element.        */
97 /* Parameters:                                                    */
98 /*   node: element pointer.                                       */
99 /*   down: pointer to a NODE_ASN element that you want be pointed */
100 /*          by NODE.                                              */
101 /* Return: pointer to *NODE.                                      */
102 /******************************************************************/
103 inline static asn1_node
104 _asn1_set_down (asn1_node node, asn1_node down)
105 {
106   if (node == NULL)
107     return node;
108   node->down = down;
109   if (down)
110     {
111       down->left = node;
112       down->up = node;
113     }
114   return node;
115 }
116
117 /******************************************************************/
118 /* Function : _asn1_get_down                                      */
119 /* Description: returns the element pointed by the DOWN field of  */
120 /*              a NODE_ASN element.                               */
121 /* Parameters:                                                    */
122 /*   node: NODE_ASN element pointer.                              */
123 /* Return: field DOWN of NODE.                                    */
124 /******************************************************************/
125 inline static asn1_node
126 _asn1_get_down (asn1_node node)
127 {
128   if (node == NULL)
129     return NULL;
130   return node->down;
131 }
132
133 /******************************************************************/
134 /* Function : _asn1_get_name                                      */
135 /* Description: returns the name of a NODE_ASN element.           */
136 /* Parameters:                                                    */
137 /*   node: NODE_ASN element pointer.                              */
138 /* Return: a null terminated string.                              */
139 /******************************************************************/
140 inline static char *
141 _asn1_get_name (asn1_node node)
142 {
143   if (node == NULL)
144     return NULL;
145   return node->name;
146 }
147
148 /******************************************************************/
149 /* Function : _asn1_mod_type                                      */
150 /* Description: change the field TYPE of an NODE_ASN element.     */
151 /*              The new value is the old one | (bitwise or) the   */
152 /*              paramener VALUE.                                  */
153 /* Parameters:                                                    */
154 /*   node: NODE_ASN element pointer.                              */
155 /*   value: the integer value that must be or-ed with the current */
156 /*          value of field TYPE.                                  */
157 /* Return: NODE pointer.                                          */
158 /******************************************************************/
159 inline static asn1_node
160 _asn1_mod_type (asn1_node node, unsigned int value)
161 {
162   if (node == NULL)
163     return node;
164   node->type |= value;
165   return node;
166 }
167
168 #endif