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