0adda45dd3e044aebf28c0c5cea9b08da0ed18a7
[openssl.git] / crypto / conf / conf.h
1 /* crypto/conf/conf.h */
2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3  * All rights reserved.
4  *
5  * This package is an SSL implementation written
6  * by Eric Young (eay@cryptsoft.com).
7  * The implementation was written so as to conform with Netscapes SSL.
8  * 
9  * This library is free for commercial and non-commercial use as long as
10  * the following conditions are aheared to.  The following conditions
11  * apply to all code found in this distribution, be it the RC4, RSA,
12  * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
13  * included with this distribution is covered by the same copyright terms
14  * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15  * 
16  * Copyright remains Eric Young's, and as such any Copyright notices in
17  * the code are not to be removed.
18  * If this package is used in a product, Eric Young should be given attribution
19  * as the author of the parts of the library used.
20  * This can be in the form of a textual message at program startup or
21  * in documentation (online or textual) provided with the package.
22  * 
23  * Redistribution and use in source and binary forms, with or without
24  * modification, are permitted provided that the following conditions
25  * are met:
26  * 1. Redistributions of source code must retain the copyright
27  *    notice, this list of conditions and the following disclaimer.
28  * 2. Redistributions in binary form must reproduce the above copyright
29  *    notice, this list of conditions and the following disclaimer in the
30  *    documentation and/or other materials provided with the distribution.
31  * 3. All advertising materials mentioning features or use of this software
32  *    must display the following acknowledgement:
33  *    "This product includes cryptographic software written by
34  *     Eric Young (eay@cryptsoft.com)"
35  *    The word 'cryptographic' can be left out if the rouines from the library
36  *    being used are not cryptographic related :-).
37  * 4. If you include any Windows specific code (or a derivative thereof) from 
38  *    the apps directory (application code) you must include an acknowledgement:
39  *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40  * 
41  * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51  * SUCH DAMAGE.
52  * 
53  * The licence and distribution terms for any publically available version or
54  * derivative of this code cannot be changed.  i.e. this code cannot simply be
55  * copied and put under another distribution licence
56  * [including the GNU Public Licence.]
57  */
58
59 #ifndef  HEADER_CONF_H
60 #define HEADER_CONF_H
61
62 #include <openssl/bio.h>
63 #include <openssl/lhash.h>
64 #include <openssl/stack.h>
65 #include <openssl/safestack.h>
66 #include <openssl/e_os.h>
67
68 #ifdef  __cplusplus
69 extern "C" {
70 #endif
71
72 typedef struct
73         {
74         char *section;
75         char *name;
76         char *value;
77         } CONF_VALUE;
78
79 DECLARE_STACK_OF(CONF_VALUE)
80 /* This block of defines is updated by a perl script, please do not touch! */
81 #ifndef DEBUG_SAFESTACK
82         #define sk_CONF_VALUE_new(a) sk_new((int (*) \
83                 (const char * const *, const char * const *))(a))
84         #define sk_CONF_VALUE_new_null() sk_new_null()
85         #define sk_CONF_VALUE_free(a) sk_free(a)
86         #define sk_CONF_VALUE_num(a) sk_num(a)
87         #define sk_CONF_VALUE_value(a,b) ((CONF_VALUE *) \
88                 sk_value((a),(b)))
89         #define sk_CONF_VALUE_set(a,b,c) ((CONF_VALUE *) \
90                 sk_set((a),(b),(char *)(c)))
91         #define sk_CONF_VALUE_zero(a) sk_zero(a)
92         #define sk_CONF_VALUE_push(a,b) sk_push((a),(char *)(b))
93         #define sk_CONF_VALUE_unshift(a,b) sk_unshift((a),(b))
94         #define sk_CONF_VALUE_find(a,b) sk_find((a), (char *)(b))
95         #define sk_CONF_VALUE_delete(a,b) ((CONF_VALUE *) \
96                 sk_delete((a),(b)))
97         #define sk_CONF_VALUE_delete_ptr(a,b) ((CONF_VALUE *) \
98                 sk_delete_ptr((a),(char *)(b)))
99         #define sk_CONF_VALUE_insert(a,b,c) sk_insert((a),(char *)(b),(c))
100         #define sk_CONF_VALUE_set_cmp_func(a,b) ((int (*) \
101                 (const CONF_VALUE * const *,const CONF_VALUE * const *)) \
102                 sk_set_cmp_func((a),(int (*) \
103                 (const char * const *, const char * const *))(b)))
104         #define sk_CONF_VALUE_dup(a) sk_dup(a)
105         #define sk_CONF_VALUE_pop_free(a,b) sk_pop_free((a),(void (*)(void *))(b))
106         #define sk_CONF_VALUE_shift(a) ((CONF_VALUE *)sk_shift(a))
107         #define sk_CONF_VALUE_pop(a) ((CONF_VALUE *)sk_pop(a))
108         #define sk_CONF_VALUE_sort(a) sk_sort(a)
109 #endif /* !DEBUG_SAFESTACK */
110 /* End of perl script block, you may now edit :-) */
111
112 struct conf_st;
113 typedef struct conf_st CONF;
114 struct conf_method_st;
115 typedef struct conf_method_st CONF_METHOD;
116
117 struct conf_method_st
118         {
119         const char *name;
120         CONF *(MS_FAR *create)(CONF_METHOD *meth);
121         int (MS_FAR *init)(CONF *conf);
122         int (MS_FAR *destroy)(CONF *conf);
123         int (MS_FAR *destroy_data)(CONF *conf);
124         int (MS_FAR *load)(CONF *conf, BIO *bp, long *eline);
125         int (MS_FAR *dump)(CONF *conf, BIO *bp);
126         int (MS_FAR *is_number)(CONF *conf, char c);
127         int (MS_FAR *to_int)(CONF *conf, char c);
128         };
129
130 int CONF_set_default_method(CONF_METHOD *meth);
131 LHASH *CONF_load(LHASH *conf,const char *file,long *eline);
132 #ifndef NO_FP_API
133 LHASH *CONF_load_fp(LHASH *conf, FILE *fp,long *eline);
134 #endif
135 LHASH *CONF_load_bio(LHASH *conf, BIO *bp,long *eline);
136 STACK_OF(CONF_VALUE) *CONF_get_section(LHASH *conf,char *section);
137 char *CONF_get_string(LHASH *conf,char *group,char *name);
138 long CONF_get_number(LHASH *conf,char *group,char *name);
139 void CONF_free(LHASH *conf);
140 int CONF_dump_fp(LHASH *conf, FILE *out);
141 int CONF_dump_bio(LHASH *conf, BIO *out);
142 void ERR_load_CONF_strings(void );
143
144 /* New conf code.  The semantics are different from the functions above.
145    If that wasn't the case, the above functions would have been replaced */
146
147 struct conf_st
148         {
149         CONF_METHOD *meth;
150         void *meth_data;
151         LHASH *data;
152         };
153
154 CONF *NCONF_new(CONF_METHOD *meth);
155 CONF_METHOD *NCONF_default();
156 CONF_METHOD *NCONF_WIN32();
157 #if 0 /* Just to give you an idea of what I have in mind */
158 CONF_METHOD *NCONF_XML();
159 #endif
160 void NCONF_free(CONF *conf);
161 void NCONF_free_data(CONF *conf);
162
163 int NCONF_load(CONF *conf,const char *file,long *eline);
164 #ifndef NO_FP_API
165 int NCONF_load_fp(CONF *conf, FILE *fp,long *eline);
166 #endif
167 int NCONF_load_bio(CONF *conf, BIO *bp,long *eline);
168 STACK_OF(CONF_VALUE) *NCONF_get_section(CONF *conf,char *section);
169 char *NCONF_get_string(CONF *conf,char *group,char *name);
170 long NCONF_get_number(CONF *conf,char *group,char *name);
171 int NCONF_dump_fp(CONF *conf, FILE *out);
172 int NCONF_dump_bio(CONF *conf, BIO *out);
173
174
175 /* BEGIN ERROR CODES */
176 /* The following lines are auto generated by the script mkerr.pl. Any changes
177  * made after this point may be overwritten when the script is next run.
178  */
179
180 /* Error codes for the CONF functions. */
181
182 /* Function codes. */
183 #define CONF_F_CONF_DUMP_FP                              104
184 #define CONF_F_CONF_LOAD                                 100
185 #define CONF_F_CONF_LOAD_BIO                             102
186 #define CONF_F_CONF_LOAD_FP                              103
187 #define CONF_F_NCONF_DUMP_BIO                            105
188 #define CONF_F_NCONF_DUMP_FP                             106
189 #define CONF_F_NCONF_GET_NUMBER                          107
190 #define CONF_F_NCONF_GET_SECTION                         108
191 #define CONF_F_NCONF_GET_STRING                          109
192 #define CONF_F_NCONF_LOAD_BIO                            110
193 #define CONF_F_NCONF_NEW                                 111
194 #define CONF_F_STR_COPY                                  101
195
196 /* Reason codes. */
197 #define CONF_R_MISSING_CLOSE_SQUARE_BRACKET              100
198 #define CONF_R_MISSING_EQUAL_SIGN                        101
199 #define CONF_R_NO_CLOSE_BRACE                            102
200 #define CONF_R_NO_CONF                                   105
201 #define CONF_R_UNABLE_TO_CREATE_NEW_SECTION              103
202 #define CONF_R_VARIABLE_HAS_NO_VALUE                     104
203
204 #ifdef  __cplusplus
205 }
206 #endif
207 #endif
208