/src/openssl/include/openssl/conf.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved. |
3 | | * |
4 | | * Licensed under the Apache License 2.0 (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 OPENSSL_CONF_H |
11 | | # define OPENSSL_CONF_H |
12 | | # pragma once |
13 | | |
14 | | # include <openssl/macros.h> |
15 | | # ifndef OPENSSL_NO_DEPRECATED_3_0 |
16 | | # define HEADER_CONF_H |
17 | | # endif |
18 | | |
19 | | # include <openssl/bio.h> |
20 | | # include <openssl/lhash.h> |
21 | | # include <openssl/safestack.h> |
22 | | # include <openssl/e_os2.h> |
23 | | # include <openssl/types.h> |
24 | | # include <openssl/conferr.h> |
25 | | |
26 | | #ifdef __cplusplus |
27 | | extern "C" { |
28 | | #endif |
29 | | |
30 | | typedef struct { |
31 | | char *section; |
32 | | char *name; |
33 | | char *value; |
34 | | } CONF_VALUE; |
35 | | |
36 | | DEFINE_STACK_OF(CONF_VALUE) |
37 | | DEFINE_LHASH_OF(CONF_VALUE); |
38 | | |
39 | | struct conf_st; |
40 | | struct conf_method_st; |
41 | | typedef struct conf_method_st CONF_METHOD; |
42 | | |
43 | | struct conf_method_st { |
44 | | const char *name; |
45 | | CONF *(*create) (CONF_METHOD *meth); |
46 | | int (*init) (CONF *conf); |
47 | | int (*destroy) (CONF *conf); |
48 | | int (*destroy_data) (CONF *conf); |
49 | | int (*load_bio) (CONF *conf, BIO *bp, long *eline); |
50 | | int (*dump) (const CONF *conf, BIO *bp); |
51 | | int (*is_number) (const CONF *conf, char c); |
52 | | int (*to_int) (const CONF *conf, char c); |
53 | | int (*load) (CONF *conf, const char *name, long *eline); |
54 | | }; |
55 | | |
56 | | /* Module definitions */ |
57 | | |
58 | | typedef struct conf_imodule_st CONF_IMODULE; |
59 | | typedef struct conf_module_st CONF_MODULE; |
60 | | |
61 | | DEFINE_STACK_OF(CONF_MODULE) |
62 | | DEFINE_STACK_OF(CONF_IMODULE) |
63 | | |
64 | | /* DSO module function typedefs */ |
65 | | typedef int conf_init_func (CONF_IMODULE *md, const CONF *cnf); |
66 | | typedef void conf_finish_func (CONF_IMODULE *md); |
67 | | |
68 | 0 | # define CONF_MFLAGS_IGNORE_ERRORS 0x1 |
69 | 1.95k | # define CONF_MFLAGS_IGNORE_RETURN_CODES 0x2 |
70 | 0 | # define CONF_MFLAGS_SILENT 0x4 |
71 | 0 | # define CONF_MFLAGS_NO_DSO 0x8 |
72 | 1.95k | # define CONF_MFLAGS_IGNORE_MISSING_FILE 0x10 |
73 | 976 | # define CONF_MFLAGS_DEFAULT_SECTION 0x20 |
74 | | |
75 | | int CONF_set_default_method(CONF_METHOD *meth); |
76 | | void CONF_set_nconf(CONF *conf, LHASH_OF(CONF_VALUE) *hash); |
77 | | LHASH_OF(CONF_VALUE) *CONF_load(LHASH_OF(CONF_VALUE) *conf, const char *file, |
78 | | long *eline); |
79 | | # ifndef OPENSSL_NO_STDIO |
80 | | LHASH_OF(CONF_VALUE) *CONF_load_fp(LHASH_OF(CONF_VALUE) *conf, FILE *fp, |
81 | | long *eline); |
82 | | # endif |
83 | | LHASH_OF(CONF_VALUE) *CONF_load_bio(LHASH_OF(CONF_VALUE) *conf, BIO *bp, |
84 | | long *eline); |
85 | | STACK_OF(CONF_VALUE) *CONF_get_section(LHASH_OF(CONF_VALUE) *conf, |
86 | | const char *section); |
87 | | char *CONF_get_string(LHASH_OF(CONF_VALUE) *conf, const char *group, |
88 | | const char *name); |
89 | | long CONF_get_number(LHASH_OF(CONF_VALUE) *conf, const char *group, |
90 | | const char *name); |
91 | | void CONF_free(LHASH_OF(CONF_VALUE) *conf); |
92 | | #ifndef OPENSSL_NO_STDIO |
93 | | int CONF_dump_fp(LHASH_OF(CONF_VALUE) *conf, FILE *out); |
94 | | #endif |
95 | | int CONF_dump_bio(LHASH_OF(CONF_VALUE) *conf, BIO *out); |
96 | | |
97 | | DEPRECATEDIN_1_1_0(void OPENSSL_config(const char *config_name)) |
98 | | |
99 | | #ifndef OPENSSL_NO_DEPRECATED_1_1_0 |
100 | | # define OPENSSL_no_config() \ |
101 | | OPENSSL_init_crypto(OPENSSL_INIT_NO_LOAD_CONFIG, NULL) |
102 | | #endif |
103 | | |
104 | | /* |
105 | | * New conf code. The semantics are different from the functions above. If |
106 | | * that wasn't the case, the above functions would have been replaced |
107 | | */ |
108 | | |
109 | | struct conf_st { |
110 | | CONF_METHOD *meth; |
111 | | void *meth_data; |
112 | | LHASH_OF(CONF_VALUE) *data; |
113 | | unsigned int flag_dollarid:1; |
114 | | }; |
115 | | |
116 | | CONF *NCONF_new(CONF_METHOD *meth); |
117 | | CONF_METHOD *NCONF_default(void); |
118 | | DEPRECATEDIN_3_0(CONF_METHOD *NCONF_WIN32(void)) |
119 | | void NCONF_free(CONF *conf); |
120 | | void NCONF_free_data(CONF *conf); |
121 | | |
122 | | int NCONF_load(CONF *conf, const char *file, long *eline); |
123 | | # ifndef OPENSSL_NO_STDIO |
124 | | int NCONF_load_fp(CONF *conf, FILE *fp, long *eline); |
125 | | # endif |
126 | | int NCONF_load_bio(CONF *conf, BIO *bp, long *eline); |
127 | | STACK_OF(CONF_VALUE) *NCONF_get_section(const CONF *conf, |
128 | | const char *section); |
129 | | char *NCONF_get_string(const CONF *conf, const char *group, const char *name); |
130 | | int NCONF_get_number_e(const CONF *conf, const char *group, const char *name, |
131 | | long *result); |
132 | | #ifndef OPENSSL_NO_STDIO |
133 | | int NCONF_dump_fp(const CONF *conf, FILE *out); |
134 | | #endif |
135 | | int NCONF_dump_bio(const CONF *conf, BIO *out); |
136 | | |
137 | | #define NCONF_get_number(c,g,n,r) NCONF_get_number_e(c,g,n,r) |
138 | | |
139 | | /* Module functions */ |
140 | | |
141 | | int CONF_modules_load(const CONF *cnf, const char *appname, |
142 | | unsigned long flags); |
143 | | int CONF_modules_load_file(const char *filename, const char *appname, |
144 | | unsigned long flags); |
145 | | void CONF_modules_unload(int all); |
146 | | void CONF_modules_finish(void); |
147 | | #ifndef OPENSSL_NO_DEPRECATED_1_1_0 |
148 | | # define CONF_modules_free() while(0) continue |
149 | | #endif |
150 | | int CONF_module_add(const char *name, conf_init_func *ifunc, |
151 | | conf_finish_func *ffunc); |
152 | | |
153 | | const char *CONF_imodule_get_name(const CONF_IMODULE *md); |
154 | | const char *CONF_imodule_get_value(const CONF_IMODULE *md); |
155 | | void *CONF_imodule_get_usr_data(const CONF_IMODULE *md); |
156 | | void CONF_imodule_set_usr_data(CONF_IMODULE *md, void *usr_data); |
157 | | CONF_MODULE *CONF_imodule_get_module(const CONF_IMODULE *md); |
158 | | unsigned long CONF_imodule_get_flags(const CONF_IMODULE *md); |
159 | | void CONF_imodule_set_flags(CONF_IMODULE *md, unsigned long flags); |
160 | | void *CONF_module_get_usr_data(CONF_MODULE *pmod); |
161 | | void CONF_module_set_usr_data(CONF_MODULE *pmod, void *usr_data); |
162 | | |
163 | | char *CONF_get1_default_config_file(void); |
164 | | |
165 | | int CONF_parse_list(const char *list, int sep, int nospc, |
166 | | int (*list_cb) (const char *elem, int len, void *usr), |
167 | | void *arg); |
168 | | |
169 | | void OPENSSL_load_builtin_modules(void); |
170 | | |
171 | | |
172 | | # ifdef __cplusplus |
173 | | } |
174 | | # endif |
175 | | #endif |