1 | /* |
2 | * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. |
3 | * |
4 | * Licensed under the OpenSSL license (the "License"). You may not use |
5 | * this file except in compliance with the License. You can obtain a copy |
6 | * in the file LICENSE in the source distribution or at |
7 | * https://www.openssl.org/source/license.html |
8 | */ |
9 | |
10 | #ifndef HEADER_CONF_H |
11 | # define |
12 | |
13 | # include <openssl/bio.h> |
14 | # include <openssl/lhash.h> |
15 | # include <openssl/stack.h> |
16 | # include <openssl/safestack.h> |
17 | # include <openssl/e_os2.h> |
18 | |
19 | # include <openssl/ossl_typ.h> |
20 | |
21 | #ifdef __cplusplus |
22 | extern "C" { |
23 | #endif |
24 | |
25 | typedef struct { |
26 | char *section; |
27 | char *name; |
28 | char *value; |
29 | } CONF_VALUE; |
30 | |
31 | DEFINE_STACK_OF(CONF_VALUE) |
32 | DEFINE_LHASH_OF(CONF_VALUE); |
33 | |
34 | struct conf_st; |
35 | struct conf_method_st; |
36 | typedef struct conf_method_st CONF_METHOD; |
37 | |
38 | struct conf_method_st { |
39 | const char *name; |
40 | CONF *(*create) (CONF_METHOD *meth); |
41 | int (*init) (CONF *conf); |
42 | int (*destroy) (CONF *conf); |
43 | int (*destroy_data) (CONF *conf); |
44 | int (*load_bio) (CONF *conf, BIO *bp, long *eline); |
45 | int (*dump) (const CONF *conf, BIO *bp); |
46 | int (*is_number) (const CONF *conf, char c); |
47 | int (*to_int) (const CONF *conf, char c); |
48 | int (*load) (CONF *conf, const char *name, long *eline); |
49 | }; |
50 | |
51 | /* Module definitions */ |
52 | |
53 | typedef struct conf_imodule_st CONF_IMODULE; |
54 | typedef struct conf_module_st CONF_MODULE; |
55 | |
56 | DEFINE_STACK_OF(CONF_MODULE) |
57 | DEFINE_STACK_OF(CONF_IMODULE) |
58 | |
59 | /* DSO module function typedefs */ |
60 | typedef int conf_init_func (CONF_IMODULE *md, const CONF *cnf); |
61 | typedef void conf_finish_func (CONF_IMODULE *md); |
62 | |
63 | # define CONF_MFLAGS_IGNORE_ERRORS 0x1 |
64 | # define CONF_MFLAGS_IGNORE_RETURN_CODES 0x2 |
65 | # define CONF_MFLAGS_SILENT 0x4 |
66 | # define CONF_MFLAGS_NO_DSO 0x8 |
67 | # define CONF_MFLAGS_IGNORE_MISSING_FILE 0x10 |
68 | # define CONF_MFLAGS_DEFAULT_SECTION 0x20 |
69 | |
70 | int CONF_set_default_method(CONF_METHOD *meth); |
71 | void CONF_set_nconf(CONF *conf, LHASH_OF(CONF_VALUE) *hash); |
72 | LHASH_OF(CONF_VALUE) *CONF_load(LHASH_OF(CONF_VALUE) *conf, const char *file, |
73 | long *eline); |
74 | # ifndef OPENSSL_NO_STDIO |
75 | LHASH_OF(CONF_VALUE) *CONF_load_fp(LHASH_OF(CONF_VALUE) *conf, FILE *fp, |
76 | long *eline); |
77 | # endif |
78 | LHASH_OF(CONF_VALUE) *CONF_load_bio(LHASH_OF(CONF_VALUE) *conf, BIO *bp, |
79 | long *eline); |
80 | STACK_OF(CONF_VALUE) *CONF_get_section(LHASH_OF(CONF_VALUE) *conf, |
81 | const char *section); |
82 | char *CONF_get_string(LHASH_OF(CONF_VALUE) *conf, const char *group, |
83 | const char *name); |
84 | long CONF_get_number(LHASH_OF(CONF_VALUE) *conf, const char *group, |
85 | const char *name); |
86 | void CONF_free(LHASH_OF(CONF_VALUE) *conf); |
87 | #ifndef OPENSSL_NO_STDIO |
88 | int CONF_dump_fp(LHASH_OF(CONF_VALUE) *conf, FILE *out); |
89 | #endif |
90 | int CONF_dump_bio(LHASH_OF(CONF_VALUE) *conf, BIO *out); |
91 | |
92 | DEPRECATEDIN_1_1_0(void OPENSSL_config(const char *config_name)) |
93 | |
94 | #if OPENSSL_API_COMPAT < 0x10100000L |
95 | # define OPENSSL_no_config() \ |
96 | OPENSSL_init_crypto(OPENSSL_INIT_NO_LOAD_CONFIG, NULL) |
97 | #endif |
98 | |
99 | /* |
100 | * New conf code. The semantics are different from the functions above. If |
101 | * that wasn't the case, the above functions would have been replaced |
102 | */ |
103 | |
104 | struct conf_st { |
105 | CONF_METHOD *meth; |
106 | void *meth_data; |
107 | LHASH_OF(CONF_VALUE) *data; |
108 | }; |
109 | |
110 | CONF *NCONF_new(CONF_METHOD *meth); |
111 | CONF_METHOD *NCONF_default(void); |
112 | CONF_METHOD *NCONF_WIN32(void); |
113 | void NCONF_free(CONF *conf); |
114 | void NCONF_free_data(CONF *conf); |
115 | |
116 | int NCONF_load(CONF *conf, const char *file, long *eline); |
117 | # ifndef OPENSSL_NO_STDIO |
118 | int NCONF_load_fp(CONF *conf, FILE *fp, long *eline); |
119 | # endif |
120 | int NCONF_load_bio(CONF *conf, BIO *bp, long *eline); |
121 | STACK_OF(CONF_VALUE) *NCONF_get_section(const CONF *conf, |
122 | const char *section); |
123 | char *NCONF_get_string(const CONF *conf, const char *group, const char *name); |
124 | int NCONF_get_number_e(const CONF *conf, const char *group, const char *name, |
125 | long *result); |
126 | #ifndef OPENSSL_NO_STDIO |
127 | int NCONF_dump_fp(const CONF *conf, FILE *out); |
128 | #endif |
129 | int NCONF_dump_bio(const CONF *conf, BIO *out); |
130 | |
131 | #define NCONF_get_number(c,g,n,r) NCONF_get_number_e(c,g,n,r) |
132 | |
133 | /* Module functions */ |
134 | |
135 | int CONF_modules_load(const CONF *cnf, const char *appname, |
136 | unsigned long flags); |
137 | int CONF_modules_load_file(const char *filename, const char *appname, |
138 | unsigned long flags); |
139 | void CONF_modules_unload(int all); |
140 | void CONF_modules_finish(void); |
141 | #if OPENSSL_API_COMPAT < 0x10100000L |
142 | # define CONF_modules_free() while(0) continue |
143 | #endif |
144 | int CONF_module_add(const char *name, conf_init_func *ifunc, |
145 | conf_finish_func *ffunc); |
146 | |
147 | const char *CONF_imodule_get_name(const CONF_IMODULE *md); |
148 | const char *CONF_imodule_get_value(const CONF_IMODULE *md); |
149 | void *CONF_imodule_get_usr_data(const CONF_IMODULE *md); |
150 | void CONF_imodule_set_usr_data(CONF_IMODULE *md, void *usr_data); |
151 | CONF_MODULE *CONF_imodule_get_module(const CONF_IMODULE *md); |
152 | unsigned long CONF_imodule_get_flags(const CONF_IMODULE *md); |
153 | void CONF_imodule_set_flags(CONF_IMODULE *md, unsigned long flags); |
154 | void *CONF_module_get_usr_data(CONF_MODULE *pmod); |
155 | void CONF_module_set_usr_data(CONF_MODULE *pmod, void *usr_data); |
156 | |
157 | char *CONF_get1_default_config_file(void); |
158 | |
159 | int CONF_parse_list(const char *list, int sep, int nospc, |
160 | int (*list_cb) (const char *elem, int len, void *usr), |
161 | void *arg); |
162 | |
163 | void OPENSSL_load_builtin_modules(void); |
164 | |
165 | /* BEGIN ERROR CODES */ |
166 | /* |
167 | * The following lines are auto generated by the script mkerr.pl. Any changes |
168 | * made after this point may be overwritten when the script is next run. |
169 | */ |
170 | |
171 | int ERR_load_CONF_strings(void); |
172 | |
173 | /* Error codes for the CONF functions. */ |
174 | |
175 | /* Function codes. */ |
176 | # define CONF_F_CONF_DUMP_FP 104 |
177 | # define CONF_F_CONF_LOAD 100 |
178 | # define CONF_F_CONF_LOAD_FP 103 |
179 | # define CONF_F_CONF_PARSE_LIST 119 |
180 | # define CONF_F_DEF_LOAD 120 |
181 | # define CONF_F_DEF_LOAD_BIO 121 |
182 | # define CONF_F_MODULE_INIT 115 |
183 | # define CONF_F_MODULE_LOAD_DSO 117 |
184 | # define CONF_F_MODULE_RUN 118 |
185 | # define CONF_F_NCONF_DUMP_BIO 105 |
186 | # define CONF_F_NCONF_DUMP_FP 106 |
187 | # define CONF_F_NCONF_GET_NUMBER_E 112 |
188 | # define CONF_F_NCONF_GET_SECTION 108 |
189 | # define CONF_F_NCONF_GET_STRING 109 |
190 | # define CONF_F_NCONF_LOAD 113 |
191 | # define CONF_F_NCONF_LOAD_BIO 110 |
192 | # define CONF_F_NCONF_LOAD_FP 114 |
193 | # define CONF_F_NCONF_NEW 111 |
194 | # define CONF_F_STR_COPY 101 |
195 | |
196 | /* Reason codes. */ |
197 | # define CONF_R_ERROR_LOADING_DSO 110 |
198 | # define CONF_R_LIST_CANNOT_BE_NULL 115 |
199 | # define CONF_R_MISSING_CLOSE_SQUARE_BRACKET 100 |
200 | # define CONF_R_MISSING_EQUAL_SIGN 101 |
201 | # define CONF_R_MISSING_INIT_FUNCTION 112 |
202 | # define CONF_R_MODULE_INITIALIZATION_ERROR 109 |
203 | # define CONF_R_NO_CLOSE_BRACE 102 |
204 | # define CONF_R_NO_CONF 105 |
205 | # define CONF_R_NO_CONF_OR_ENVIRONMENT_VARIABLE 106 |
206 | # define CONF_R_NO_SECTION 107 |
207 | # define CONF_R_NO_SUCH_FILE 114 |
208 | # define CONF_R_NO_VALUE 108 |
209 | # define CONF_R_UNABLE_TO_CREATE_NEW_SECTION 103 |
210 | # define CONF_R_UNKNOWN_MODULE_NAME 113 |
211 | # define CONF_R_VARIABLE_EXPANSION_TOO_LONG 116 |
212 | # define CONF_R_VARIABLE_HAS_NO_VALUE 104 |
213 | |
214 | # ifdef __cplusplus |
215 | } |
216 | # endif |
217 | #endif |
218 | |