1ebfedea0SLionel Sambuc /* crypto/conf/conf.h */ 2ebfedea0SLionel Sambuc /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 3ebfedea0SLionel Sambuc * All rights reserved. 4ebfedea0SLionel Sambuc * 5ebfedea0SLionel Sambuc * This package is an SSL implementation written 6ebfedea0SLionel Sambuc * by Eric Young (eay@cryptsoft.com). 7ebfedea0SLionel Sambuc * The implementation was written so as to conform with Netscapes SSL. 8ebfedea0SLionel Sambuc * 9ebfedea0SLionel Sambuc * This library is free for commercial and non-commercial use as long as 10ebfedea0SLionel Sambuc * the following conditions are aheared to. The following conditions 11ebfedea0SLionel Sambuc * apply to all code found in this distribution, be it the RC4, RSA, 12ebfedea0SLionel Sambuc * lhash, DES, etc., code; not just the SSL code. The SSL documentation 13ebfedea0SLionel Sambuc * included with this distribution is covered by the same copyright terms 14ebfedea0SLionel Sambuc * except that the holder is Tim Hudson (tjh@cryptsoft.com). 15ebfedea0SLionel Sambuc * 16ebfedea0SLionel Sambuc * Copyright remains Eric Young's, and as such any Copyright notices in 17ebfedea0SLionel Sambuc * the code are not to be removed. 18ebfedea0SLionel Sambuc * If this package is used in a product, Eric Young should be given attribution 19ebfedea0SLionel Sambuc * as the author of the parts of the library used. 20ebfedea0SLionel Sambuc * This can be in the form of a textual message at program startup or 21ebfedea0SLionel Sambuc * in documentation (online or textual) provided with the package. 22ebfedea0SLionel Sambuc * 23ebfedea0SLionel Sambuc * Redistribution and use in source and binary forms, with or without 24ebfedea0SLionel Sambuc * modification, are permitted provided that the following conditions 25ebfedea0SLionel Sambuc * are met: 26ebfedea0SLionel Sambuc * 1. Redistributions of source code must retain the copyright 27ebfedea0SLionel Sambuc * notice, this list of conditions and the following disclaimer. 28ebfedea0SLionel Sambuc * 2. Redistributions in binary form must reproduce the above copyright 29ebfedea0SLionel Sambuc * notice, this list of conditions and the following disclaimer in the 30ebfedea0SLionel Sambuc * documentation and/or other materials provided with the distribution. 31ebfedea0SLionel Sambuc * 3. All advertising materials mentioning features or use of this software 32ebfedea0SLionel Sambuc * must display the following acknowledgement: 33ebfedea0SLionel Sambuc * "This product includes cryptographic software written by 34ebfedea0SLionel Sambuc * Eric Young (eay@cryptsoft.com)" 35ebfedea0SLionel Sambuc * The word 'cryptographic' can be left out if the rouines from the library 36ebfedea0SLionel Sambuc * being used are not cryptographic related :-). 37ebfedea0SLionel Sambuc * 4. If you include any Windows specific code (or a derivative thereof) from 38ebfedea0SLionel Sambuc * the apps directory (application code) you must include an acknowledgement: 39ebfedea0SLionel Sambuc * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" 40ebfedea0SLionel Sambuc * 41ebfedea0SLionel Sambuc * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 42ebfedea0SLionel Sambuc * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 43ebfedea0SLionel Sambuc * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 44ebfedea0SLionel Sambuc * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 45ebfedea0SLionel Sambuc * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 46ebfedea0SLionel Sambuc * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 47ebfedea0SLionel Sambuc * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 48ebfedea0SLionel Sambuc * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 49ebfedea0SLionel Sambuc * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 50ebfedea0SLionel Sambuc * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 51ebfedea0SLionel Sambuc * SUCH DAMAGE. 52ebfedea0SLionel Sambuc * 53ebfedea0SLionel Sambuc * The licence and distribution terms for any publically available version or 54ebfedea0SLionel Sambuc * derivative of this code cannot be changed. i.e. this code cannot simply be 55ebfedea0SLionel Sambuc * copied and put under another distribution licence 56ebfedea0SLionel Sambuc * [including the GNU Public Licence.] 57ebfedea0SLionel Sambuc */ 58ebfedea0SLionel Sambuc 59ebfedea0SLionel Sambuc #ifndef HEADER_CONF_H 60ebfedea0SLionel Sambuc # define HEADER_CONF_H 61ebfedea0SLionel Sambuc 62ebfedea0SLionel Sambuc # include <openssl/bio.h> 63ebfedea0SLionel Sambuc # include <openssl/lhash.h> 64ebfedea0SLionel Sambuc # include <openssl/stack.h> 65ebfedea0SLionel Sambuc # include <openssl/safestack.h> 66ebfedea0SLionel Sambuc # include <openssl/e_os2.h> 67ebfedea0SLionel Sambuc 68ebfedea0SLionel Sambuc # include <openssl/ossl_typ.h> 69ebfedea0SLionel Sambuc 70ebfedea0SLionel Sambuc #ifdef __cplusplus 71ebfedea0SLionel Sambuc extern "C" { 72ebfedea0SLionel Sambuc #endif 73ebfedea0SLionel Sambuc 74*0a6a1f1dSLionel Sambuc typedef struct { 75ebfedea0SLionel Sambuc char *section; 76ebfedea0SLionel Sambuc char *name; 77ebfedea0SLionel Sambuc char *value; 78ebfedea0SLionel Sambuc } CONF_VALUE; 79ebfedea0SLionel Sambuc 80ebfedea0SLionel Sambuc DECLARE_STACK_OF(CONF_VALUE) 81ebfedea0SLionel Sambuc DECLARE_LHASH_OF(CONF_VALUE); 82ebfedea0SLionel Sambuc 83ebfedea0SLionel Sambuc struct conf_st; 84ebfedea0SLionel Sambuc struct conf_method_st; 85ebfedea0SLionel Sambuc typedef struct conf_method_st CONF_METHOD; 86ebfedea0SLionel Sambuc 87*0a6a1f1dSLionel Sambuc struct conf_method_st { 88ebfedea0SLionel Sambuc const char *name; 89ebfedea0SLionel Sambuc CONF *(*create) (CONF_METHOD *meth); 90ebfedea0SLionel Sambuc int (*init) (CONF *conf); 91ebfedea0SLionel Sambuc int (*destroy) (CONF *conf); 92ebfedea0SLionel Sambuc int (*destroy_data) (CONF *conf); 93ebfedea0SLionel Sambuc int (*load_bio) (CONF *conf, BIO *bp, long *eline); 94ebfedea0SLionel Sambuc int (*dump) (const CONF *conf, BIO *bp); 95ebfedea0SLionel Sambuc int (*is_number) (const CONF *conf, char c); 96ebfedea0SLionel Sambuc int (*to_int) (const CONF *conf, char c); 97ebfedea0SLionel Sambuc int (*load) (CONF *conf, const char *name, long *eline); 98ebfedea0SLionel Sambuc }; 99ebfedea0SLionel Sambuc 100ebfedea0SLionel Sambuc /* Module definitions */ 101ebfedea0SLionel Sambuc 102ebfedea0SLionel Sambuc typedef struct conf_imodule_st CONF_IMODULE; 103ebfedea0SLionel Sambuc typedef struct conf_module_st CONF_MODULE; 104ebfedea0SLionel Sambuc 105ebfedea0SLionel Sambuc DECLARE_STACK_OF(CONF_MODULE) 106ebfedea0SLionel Sambuc DECLARE_STACK_OF(CONF_IMODULE) 107ebfedea0SLionel Sambuc 108ebfedea0SLionel Sambuc /* DSO module function typedefs */ 109ebfedea0SLionel Sambuc typedef int conf_init_func (CONF_IMODULE *md, const CONF *cnf); 110ebfedea0SLionel Sambuc typedef void conf_finish_func (CONF_IMODULE *md); 111ebfedea0SLionel Sambuc 112ebfedea0SLionel Sambuc # define CONF_MFLAGS_IGNORE_ERRORS 0x1 113ebfedea0SLionel Sambuc # define CONF_MFLAGS_IGNORE_RETURN_CODES 0x2 114ebfedea0SLionel Sambuc # define CONF_MFLAGS_SILENT 0x4 115ebfedea0SLionel Sambuc # define CONF_MFLAGS_NO_DSO 0x8 116ebfedea0SLionel Sambuc # define CONF_MFLAGS_IGNORE_MISSING_FILE 0x10 117ebfedea0SLionel Sambuc # define CONF_MFLAGS_DEFAULT_SECTION 0x20 118ebfedea0SLionel Sambuc 119ebfedea0SLionel Sambuc int CONF_set_default_method(CONF_METHOD *meth); 120ebfedea0SLionel Sambuc void CONF_set_nconf(CONF *conf, LHASH_OF(CONF_VALUE) *hash); 121ebfedea0SLionel Sambuc LHASH_OF(CONF_VALUE) *CONF_load(LHASH_OF(CONF_VALUE) *conf, const char *file, 122ebfedea0SLionel Sambuc long *eline); 123ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_FP_API 124ebfedea0SLionel Sambuc LHASH_OF(CONF_VALUE) *CONF_load_fp(LHASH_OF(CONF_VALUE) *conf, FILE *fp, 125ebfedea0SLionel Sambuc long *eline); 126ebfedea0SLionel Sambuc # endif 127*0a6a1f1dSLionel Sambuc LHASH_OF(CONF_VALUE) *CONF_load_bio(LHASH_OF(CONF_VALUE) *conf, BIO *bp, 128*0a6a1f1dSLionel Sambuc long *eline); 129ebfedea0SLionel Sambuc STACK_OF(CONF_VALUE) *CONF_get_section(LHASH_OF(CONF_VALUE) *conf, 130ebfedea0SLionel Sambuc const char *section); 131ebfedea0SLionel Sambuc char *CONF_get_string(LHASH_OF(CONF_VALUE) *conf, const char *group, 132ebfedea0SLionel Sambuc const char *name); 133ebfedea0SLionel Sambuc long CONF_get_number(LHASH_OF(CONF_VALUE) *conf, const char *group, 134ebfedea0SLionel Sambuc const char *name); 135ebfedea0SLionel Sambuc void CONF_free(LHASH_OF(CONF_VALUE) *conf); 136ebfedea0SLionel Sambuc int CONF_dump_fp(LHASH_OF(CONF_VALUE) *conf, FILE *out); 137ebfedea0SLionel Sambuc int CONF_dump_bio(LHASH_OF(CONF_VALUE) *conf, BIO *out); 138ebfedea0SLionel Sambuc 139ebfedea0SLionel Sambuc void OPENSSL_config(const char *config_name); 140ebfedea0SLionel Sambuc void OPENSSL_no_config(void); 141ebfedea0SLionel Sambuc 142*0a6a1f1dSLionel Sambuc /* 143*0a6a1f1dSLionel Sambuc * New conf code. The semantics are different from the functions above. If 144*0a6a1f1dSLionel Sambuc * that wasn't the case, the above functions would have been replaced 145*0a6a1f1dSLionel Sambuc */ 146ebfedea0SLionel Sambuc 147*0a6a1f1dSLionel Sambuc struct conf_st { 148ebfedea0SLionel Sambuc CONF_METHOD *meth; 149ebfedea0SLionel Sambuc void *meth_data; 150ebfedea0SLionel Sambuc LHASH_OF(CONF_VALUE) *data; 151ebfedea0SLionel Sambuc }; 152ebfedea0SLionel Sambuc 153ebfedea0SLionel Sambuc CONF *NCONF_new(CONF_METHOD *meth); 154ebfedea0SLionel Sambuc CONF_METHOD *NCONF_default(void); 155ebfedea0SLionel Sambuc CONF_METHOD *NCONF_WIN32(void); 156*0a6a1f1dSLionel Sambuc # if 0 /* Just to give you an idea of what I have in 157*0a6a1f1dSLionel Sambuc * mind */ 158ebfedea0SLionel Sambuc CONF_METHOD *NCONF_XML(void); 159ebfedea0SLionel Sambuc # endif 160ebfedea0SLionel Sambuc void NCONF_free(CONF *conf); 161ebfedea0SLionel Sambuc void NCONF_free_data(CONF *conf); 162ebfedea0SLionel Sambuc 163ebfedea0SLionel Sambuc int NCONF_load(CONF *conf, const char *file, long *eline); 164ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_FP_API 165ebfedea0SLionel Sambuc int NCONF_load_fp(CONF *conf, FILE *fp, long *eline); 166ebfedea0SLionel Sambuc # endif 167ebfedea0SLionel Sambuc int NCONF_load_bio(CONF *conf, BIO *bp, long *eline); 168*0a6a1f1dSLionel Sambuc STACK_OF(CONF_VALUE) *NCONF_get_section(const CONF *conf, 169*0a6a1f1dSLionel Sambuc const char *section); 170ebfedea0SLionel Sambuc char *NCONF_get_string(const CONF *conf, const char *group, const char *name); 171ebfedea0SLionel Sambuc int NCONF_get_number_e(const CONF *conf, const char *group, const char *name, 172ebfedea0SLionel Sambuc long *result); 173ebfedea0SLionel Sambuc int NCONF_dump_fp(const CONF *conf, FILE *out); 174ebfedea0SLionel Sambuc int NCONF_dump_bio(const CONF *conf, BIO *out); 175ebfedea0SLionel Sambuc 176*0a6a1f1dSLionel Sambuc # if 0 /* The following function has no error 177*0a6a1f1dSLionel Sambuc * checking, and should therefore be avoided */ 178ebfedea0SLionel Sambuc long NCONF_get_number(CONF *conf, char *group, char *name); 179ebfedea0SLionel Sambuc # else 180ebfedea0SLionel Sambuc # define NCONF_get_number(c,g,n,r) NCONF_get_number_e(c,g,n,r) 181ebfedea0SLionel Sambuc # endif 182ebfedea0SLionel Sambuc 183ebfedea0SLionel Sambuc /* Module functions */ 184ebfedea0SLionel Sambuc 185ebfedea0SLionel Sambuc int CONF_modules_load(const CONF *cnf, const char *appname, 186ebfedea0SLionel Sambuc unsigned long flags); 187ebfedea0SLionel Sambuc int CONF_modules_load_file(const char *filename, const char *appname, 188ebfedea0SLionel Sambuc unsigned long flags); 189ebfedea0SLionel Sambuc void CONF_modules_unload(int all); 190ebfedea0SLionel Sambuc void CONF_modules_finish(void); 191ebfedea0SLionel Sambuc void CONF_modules_free(void); 192ebfedea0SLionel Sambuc int CONF_module_add(const char *name, conf_init_func *ifunc, 193ebfedea0SLionel Sambuc conf_finish_func *ffunc); 194ebfedea0SLionel Sambuc 195ebfedea0SLionel Sambuc const char *CONF_imodule_get_name(const CONF_IMODULE *md); 196ebfedea0SLionel Sambuc const char *CONF_imodule_get_value(const CONF_IMODULE *md); 197ebfedea0SLionel Sambuc void *CONF_imodule_get_usr_data(const CONF_IMODULE *md); 198ebfedea0SLionel Sambuc void CONF_imodule_set_usr_data(CONF_IMODULE *md, void *usr_data); 199ebfedea0SLionel Sambuc CONF_MODULE *CONF_imodule_get_module(const CONF_IMODULE *md); 200ebfedea0SLionel Sambuc unsigned long CONF_imodule_get_flags(const CONF_IMODULE *md); 201ebfedea0SLionel Sambuc void CONF_imodule_set_flags(CONF_IMODULE *md, unsigned long flags); 202ebfedea0SLionel Sambuc void *CONF_module_get_usr_data(CONF_MODULE *pmod); 203ebfedea0SLionel Sambuc void CONF_module_set_usr_data(CONF_MODULE *pmod, void *usr_data); 204ebfedea0SLionel Sambuc 205ebfedea0SLionel Sambuc char *CONF_get1_default_config_file(void); 206ebfedea0SLionel Sambuc 207ebfedea0SLionel Sambuc int CONF_parse_list(const char *list, int sep, int nospc, 208*0a6a1f1dSLionel Sambuc int (*list_cb) (const char *elem, int len, void *usr), 209*0a6a1f1dSLionel Sambuc void *arg); 210ebfedea0SLionel Sambuc 211ebfedea0SLionel Sambuc void OPENSSL_load_builtin_modules(void); 212ebfedea0SLionel Sambuc 213ebfedea0SLionel Sambuc /* BEGIN ERROR CODES */ 214*0a6a1f1dSLionel Sambuc /* 215*0a6a1f1dSLionel Sambuc * The following lines are auto generated by the script mkerr.pl. Any changes 216ebfedea0SLionel Sambuc * made after this point may be overwritten when the script is next run. 217ebfedea0SLionel Sambuc */ 218ebfedea0SLionel Sambuc void ERR_load_CONF_strings(void); 219ebfedea0SLionel Sambuc 220ebfedea0SLionel Sambuc /* Error codes for the CONF functions. */ 221ebfedea0SLionel Sambuc 222ebfedea0SLionel Sambuc /* Function codes. */ 223ebfedea0SLionel Sambuc # define CONF_F_CONF_DUMP_FP 104 224ebfedea0SLionel Sambuc # define CONF_F_CONF_LOAD 100 225ebfedea0SLionel Sambuc # define CONF_F_CONF_LOAD_BIO 102 226ebfedea0SLionel Sambuc # define CONF_F_CONF_LOAD_FP 103 227ebfedea0SLionel Sambuc # define CONF_F_CONF_MODULES_LOAD 116 228ebfedea0SLionel Sambuc # define CONF_F_CONF_PARSE_LIST 119 229ebfedea0SLionel Sambuc # define CONF_F_DEF_LOAD 120 230ebfedea0SLionel Sambuc # define CONF_F_DEF_LOAD_BIO 121 231ebfedea0SLionel Sambuc # define CONF_F_MODULE_INIT 115 232ebfedea0SLionel Sambuc # define CONF_F_MODULE_LOAD_DSO 117 233ebfedea0SLionel Sambuc # define CONF_F_MODULE_RUN 118 234ebfedea0SLionel Sambuc # define CONF_F_NCONF_DUMP_BIO 105 235ebfedea0SLionel Sambuc # define CONF_F_NCONF_DUMP_FP 106 236ebfedea0SLionel Sambuc # define CONF_F_NCONF_GET_NUMBER 107 237ebfedea0SLionel Sambuc # define CONF_F_NCONF_GET_NUMBER_E 112 238ebfedea0SLionel Sambuc # define CONF_F_NCONF_GET_SECTION 108 239ebfedea0SLionel Sambuc # define CONF_F_NCONF_GET_STRING 109 240ebfedea0SLionel Sambuc # define CONF_F_NCONF_LOAD 113 241ebfedea0SLionel Sambuc # define CONF_F_NCONF_LOAD_BIO 110 242ebfedea0SLionel Sambuc # define CONF_F_NCONF_LOAD_FP 114 243ebfedea0SLionel Sambuc # define CONF_F_NCONF_NEW 111 244ebfedea0SLionel Sambuc # define CONF_F_STR_COPY 101 245ebfedea0SLionel Sambuc 246ebfedea0SLionel Sambuc /* Reason codes. */ 247ebfedea0SLionel Sambuc # define CONF_R_ERROR_LOADING_DSO 110 248ebfedea0SLionel Sambuc # define CONF_R_LIST_CANNOT_BE_NULL 115 249ebfedea0SLionel Sambuc # define CONF_R_MISSING_CLOSE_SQUARE_BRACKET 100 250ebfedea0SLionel Sambuc # define CONF_R_MISSING_EQUAL_SIGN 101 251ebfedea0SLionel Sambuc # define CONF_R_MISSING_FINISH_FUNCTION 111 252ebfedea0SLionel Sambuc # define CONF_R_MISSING_INIT_FUNCTION 112 253ebfedea0SLionel Sambuc # define CONF_R_MODULE_INITIALIZATION_ERROR 109 254ebfedea0SLionel Sambuc # define CONF_R_NO_CLOSE_BRACE 102 255ebfedea0SLionel Sambuc # define CONF_R_NO_CONF 105 256ebfedea0SLionel Sambuc # define CONF_R_NO_CONF_OR_ENVIRONMENT_VARIABLE 106 257ebfedea0SLionel Sambuc # define CONF_R_NO_SECTION 107 258ebfedea0SLionel Sambuc # define CONF_R_NO_SUCH_FILE 114 259ebfedea0SLionel Sambuc # define CONF_R_NO_VALUE 108 260ebfedea0SLionel Sambuc # define CONF_R_UNABLE_TO_CREATE_NEW_SECTION 103 261ebfedea0SLionel Sambuc # define CONF_R_UNKNOWN_MODULE_NAME 113 262ebfedea0SLionel Sambuc # define CONF_R_VARIABLE_HAS_NO_VALUE 104 263ebfedea0SLionel Sambuc 264ebfedea0SLionel Sambuc #ifdef __cplusplus 265ebfedea0SLionel Sambuc } 266ebfedea0SLionel Sambuc #endif 267ebfedea0SLionel Sambuc #endif 268