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