155714Skris/* crypto/conf/conf.h */ 255714Skris/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 355714Skris * All rights reserved. 455714Skris * 555714Skris * This package is an SSL implementation written 655714Skris * by Eric Young (eay@cryptsoft.com). 755714Skris * The implementation was written so as to conform with Netscapes SSL. 8296465Sdelphij * 955714Skris * This library is free for commercial and non-commercial use as long as 1055714Skris * the following conditions are aheared to. The following conditions 1155714Skris * apply to all code found in this distribution, be it the RC4, RSA, 1255714Skris * lhash, DES, etc., code; not just the SSL code. The SSL documentation 1355714Skris * included with this distribution is covered by the same copyright terms 1455714Skris * except that the holder is Tim Hudson (tjh@cryptsoft.com). 15296465Sdelphij * 1655714Skris * Copyright remains Eric Young's, and as such any Copyright notices in 1755714Skris * the code are not to be removed. 1855714Skris * If this package is used in a product, Eric Young should be given attribution 1955714Skris * as the author of the parts of the library used. 2055714Skris * This can be in the form of a textual message at program startup or 2155714Skris * in documentation (online or textual) provided with the package. 22296465Sdelphij * 2355714Skris * Redistribution and use in source and binary forms, with or without 2455714Skris * modification, are permitted provided that the following conditions 2555714Skris * are met: 2655714Skris * 1. Redistributions of source code must retain the copyright 2755714Skris * notice, this list of conditions and the following disclaimer. 2855714Skris * 2. Redistributions in binary form must reproduce the above copyright 2955714Skris * notice, this list of conditions and the following disclaimer in the 3055714Skris * documentation and/or other materials provided with the distribution. 3155714Skris * 3. All advertising materials mentioning features or use of this software 3255714Skris * must display the following acknowledgement: 3355714Skris * "This product includes cryptographic software written by 3455714Skris * Eric Young (eay@cryptsoft.com)" 3555714Skris * The word 'cryptographic' can be left out if the rouines from the library 3655714Skris * being used are not cryptographic related :-). 37296465Sdelphij * 4. If you include any Windows specific code (or a derivative thereof) from 3855714Skris * the apps directory (application code) you must include an acknowledgement: 3955714Skris * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" 40296465Sdelphij * 4155714Skris * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 4255714Skris * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 4355714Skris * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 4455714Skris * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 4555714Skris * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 4655714Skris * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 4755714Skris * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 4855714Skris * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 4955714Skris * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 5055714Skris * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 5155714Skris * SUCH DAMAGE. 52296465Sdelphij * 5355714Skris * The licence and distribution terms for any publically available version or 5455714Skris * derivative of this code cannot be changed. i.e. this code cannot simply be 5555714Skris * copied and put under another distribution licence 5655714Skris * [including the GNU Public Licence.] 5755714Skris */ 5855714Skris 59109998Smarkm#ifndef HEADER_CONF_H 60296465Sdelphij# define HEADER_CONF_H 6155714Skris 62296465Sdelphij# include <openssl/bio.h> 63296465Sdelphij# include <openssl/lhash.h> 64296465Sdelphij# include <openssl/stack.h> 65296465Sdelphij# include <openssl/safestack.h> 66296465Sdelphij# include <openssl/e_os2.h> 6755714Skris 68296465Sdelphij# include <openssl/ossl_typ.h> 69160814Ssimon 7068651Skris#ifdef __cplusplus 7168651Skrisextern "C" { 7268651Skris#endif 7368651Skris 74296465Sdelphijtypedef struct { 75296465Sdelphij char *section; 76296465Sdelphij char *name; 77296465Sdelphij char *value; 78296465Sdelphij} CONF_VALUE; 7955714Skris 8055714SkrisDECLARE_STACK_OF(CONF_VALUE) 81109998SmarkmDECLARE_STACK_OF(CONF_MODULE) 82109998SmarkmDECLARE_STACK_OF(CONF_IMODULE) 8355714Skris 8468651Skrisstruct conf_st; 8568651Skrisstruct conf_method_st; 8668651Skristypedef struct conf_method_st CONF_METHOD; 8768651Skris 88296465Sdelphijstruct conf_method_st { 89296465Sdelphij const char *name; 90296465Sdelphij CONF *(*create) (CONF_METHOD *meth); 91296465Sdelphij int (*init) (CONF *conf); 92296465Sdelphij int (*destroy) (CONF *conf); 93296465Sdelphij int (*destroy_data) (CONF *conf); 94296465Sdelphij int (*load_bio) (CONF *conf, BIO *bp, long *eline); 95296465Sdelphij int (*dump) (const CONF *conf, BIO *bp); 96296465Sdelphij int (*is_number) (const CONF *conf, char c); 97296465Sdelphij int (*to_int) (const CONF *conf, char c); 98296465Sdelphij int (*load) (CONF *conf, const char *name, long *eline); 99296465Sdelphij}; 10068651Skris 101109998Smarkm/* Module definitions */ 102109998Smarkm 103109998Smarkmtypedef struct conf_imodule_st CONF_IMODULE; 104109998Smarkmtypedef struct conf_module_st CONF_MODULE; 105109998Smarkm 106109998Smarkm/* DSO module function typedefs */ 107296465Sdelphijtypedef int conf_init_func (CONF_IMODULE *md, const CONF *cnf); 108296465Sdelphijtypedef void conf_finish_func (CONF_IMODULE *md); 109109998Smarkm 110296465Sdelphij# define CONF_MFLAGS_IGNORE_ERRORS 0x1 111296465Sdelphij# define CONF_MFLAGS_IGNORE_RETURN_CODES 0x2 112296465Sdelphij# define CONF_MFLAGS_SILENT 0x4 113296465Sdelphij# define CONF_MFLAGS_NO_DSO 0x8 114296465Sdelphij# define CONF_MFLAGS_IGNORE_MISSING_FILE 0x10 115296465Sdelphij# define CONF_MFLAGS_DEFAULT_SECTION 0x20 116109998Smarkm 11768651Skrisint CONF_set_default_method(CONF_METHOD *meth); 118296465Sdelphijvoid CONF_set_nconf(CONF *conf, LHASH *hash); 119296465SdelphijLHASH *CONF_load(LHASH *conf, const char *file, long *eline); 120296465Sdelphij# ifndef OPENSSL_NO_FP_API 121296465SdelphijLHASH *CONF_load_fp(LHASH *conf, FILE *fp, long *eline); 122296465Sdelphij# endif 123296465SdelphijLHASH *CONF_load_bio(LHASH *conf, BIO *bp, long *eline); 124296465SdelphijSTACK_OF(CONF_VALUE) *CONF_get_section(LHASH *conf, const char *section); 125296465Sdelphijchar *CONF_get_string(LHASH *conf, const char *group, const char *name); 126296465Sdelphijlong CONF_get_number(LHASH *conf, const char *group, const char *name); 12755714Skrisvoid CONF_free(LHASH *conf); 12868651Skrisint CONF_dump_fp(LHASH *conf, FILE *out); 12968651Skrisint CONF_dump_bio(LHASH *conf, BIO *out); 13055714Skris 131109998Smarkmvoid OPENSSL_config(const char *config_name); 132109998Smarkmvoid OPENSSL_no_config(void); 133109998Smarkm 134296465Sdelphij/* 135296465Sdelphij * New conf code. The semantics are different from the functions above. If 136296465Sdelphij * that wasn't the case, the above functions would have been replaced 137296465Sdelphij */ 13855714Skris 139296465Sdelphijstruct conf_st { 140296465Sdelphij CONF_METHOD *meth; 141296465Sdelphij void *meth_data; 142296465Sdelphij LHASH *data; 143296465Sdelphij}; 14468651Skris 14568651SkrisCONF *NCONF_new(CONF_METHOD *meth); 146109998SmarkmCONF_METHOD *NCONF_default(void); 147109998SmarkmCONF_METHOD *NCONF_WIN32(void); 148296465Sdelphij# if 0 /* Just to give you an idea of what I have in 149296465Sdelphij * mind */ 150109998SmarkmCONF_METHOD *NCONF_XML(void); 151296465Sdelphij# endif 15268651Skrisvoid NCONF_free(CONF *conf); 15368651Skrisvoid NCONF_free_data(CONF *conf); 15468651Skris 155296465Sdelphijint NCONF_load(CONF *conf, const char *file, long *eline); 156296465Sdelphij# ifndef OPENSSL_NO_FP_API 157296465Sdelphijint NCONF_load_fp(CONF *conf, FILE *fp, long *eline); 158296465Sdelphij# endif 159296465Sdelphijint NCONF_load_bio(CONF *conf, BIO *bp, long *eline); 160296465SdelphijSTACK_OF(CONF_VALUE) *NCONF_get_section(const CONF *conf, 161296465Sdelphij const char *section); 162296465Sdelphijchar *NCONF_get_string(const CONF *conf, const char *group, const char *name); 163296465Sdelphijint NCONF_get_number_e(const CONF *conf, const char *group, const char *name, 164296465Sdelphij long *result); 165109998Smarkmint NCONF_dump_fp(const CONF *conf, FILE *out); 166109998Smarkmint NCONF_dump_bio(const CONF *conf, BIO *out); 167109998Smarkm 168296465Sdelphij# if 0 /* The following function has no error 169296465Sdelphij * checking, and should therefore be avoided */ 170296465Sdelphijlong NCONF_get_number(CONF *conf, char *group, char *name); 171296465Sdelphij# else 172296465Sdelphij# define NCONF_get_number(c,g,n,r) NCONF_get_number_e(c,g,n,r) 173296465Sdelphij# endif 174296465Sdelphij 175109998Smarkm/* Module functions */ 17668651Skris 177109998Smarkmint CONF_modules_load(const CONF *cnf, const char *appname, 178296465Sdelphij unsigned long flags); 179109998Smarkmint CONF_modules_load_file(const char *filename, const char *appname, 180296465Sdelphij unsigned long flags); 181109998Smarkmvoid CONF_modules_unload(int all); 182109998Smarkmvoid CONF_modules_finish(void); 183109998Smarkmvoid CONF_modules_free(void); 184109998Smarkmint CONF_module_add(const char *name, conf_init_func *ifunc, 185296465Sdelphij conf_finish_func *ffunc); 18668651Skris 187109998Smarkmconst char *CONF_imodule_get_name(const CONF_IMODULE *md); 188109998Smarkmconst char *CONF_imodule_get_value(const CONF_IMODULE *md); 189109998Smarkmvoid *CONF_imodule_get_usr_data(const CONF_IMODULE *md); 190109998Smarkmvoid CONF_imodule_set_usr_data(CONF_IMODULE *md, void *usr_data); 191109998SmarkmCONF_MODULE *CONF_imodule_get_module(const CONF_IMODULE *md); 192109998Smarkmunsigned long CONF_imodule_get_flags(const CONF_IMODULE *md); 193109998Smarkmvoid CONF_imodule_set_flags(CONF_IMODULE *md, unsigned long flags); 194109998Smarkmvoid *CONF_module_get_usr_data(CONF_MODULE *pmod); 195109998Smarkmvoid CONF_module_set_usr_data(CONF_MODULE *pmod, void *usr_data); 196109998Smarkm 197109998Smarkmchar *CONF_get1_default_config_file(void); 198109998Smarkm 199109998Smarkmint CONF_parse_list(const char *list, int sep, int nospc, 200296465Sdelphij int (*list_cb) (const char *elem, int len, void *usr), 201296465Sdelphij void *arg); 202109998Smarkm 203109998Smarkmvoid OPENSSL_load_builtin_modules(void); 204109998Smarkm 20555714Skris/* BEGIN ERROR CODES */ 206296465Sdelphij/* 207296465Sdelphij * The following lines are auto generated by the script mkerr.pl. Any changes 20855714Skris * made after this point may be overwritten when the script is next run. 20955714Skris */ 21089837Skrisvoid ERR_load_CONF_strings(void); 21155714Skris 21255714Skris/* Error codes for the CONF functions. */ 21355714Skris 21455714Skris/* Function codes. */ 215296465Sdelphij# define CONF_F_CONF_DUMP_FP 104 216296465Sdelphij# define CONF_F_CONF_LOAD 100 217296465Sdelphij# define CONF_F_CONF_LOAD_BIO 102 218296465Sdelphij# define CONF_F_CONF_LOAD_FP 103 219296465Sdelphij# define CONF_F_CONF_MODULES_LOAD 116 220296465Sdelphij# define CONF_F_DEF_LOAD 120 221296465Sdelphij# define CONF_F_DEF_LOAD_BIO 121 222296465Sdelphij# define CONF_F_MODULE_INIT 115 223296465Sdelphij# define CONF_F_MODULE_LOAD_DSO 117 224296465Sdelphij# define CONF_F_MODULE_RUN 118 225296465Sdelphij# define CONF_F_NCONF_DUMP_BIO 105 226296465Sdelphij# define CONF_F_NCONF_DUMP_FP 106 227296465Sdelphij# define CONF_F_NCONF_GET_NUMBER 107 228296465Sdelphij# define CONF_F_NCONF_GET_NUMBER_E 112 229296465Sdelphij# define CONF_F_NCONF_GET_SECTION 108 230296465Sdelphij# define CONF_F_NCONF_GET_STRING 109 231296465Sdelphij# define CONF_F_NCONF_LOAD 113 232296465Sdelphij# define CONF_F_NCONF_LOAD_BIO 110 233296465Sdelphij# define CONF_F_NCONF_LOAD_FP 114 234296465Sdelphij# define CONF_F_NCONF_NEW 111 235296465Sdelphij# define CONF_F_STR_COPY 101 23655714Skris 23755714Skris/* Reason codes. */ 238296465Sdelphij# define CONF_R_ERROR_LOADING_DSO 110 239296465Sdelphij# define CONF_R_MISSING_CLOSE_SQUARE_BRACKET 100 240296465Sdelphij# define CONF_R_MISSING_EQUAL_SIGN 101 241296465Sdelphij# define CONF_R_MISSING_FINISH_FUNCTION 111 242296465Sdelphij# define CONF_R_MISSING_INIT_FUNCTION 112 243296465Sdelphij# define CONF_R_MODULE_INITIALIZATION_ERROR 109 244296465Sdelphij# define CONF_R_NO_CLOSE_BRACE 102 245296465Sdelphij# define CONF_R_NO_CONF 105 246296465Sdelphij# define CONF_R_NO_CONF_OR_ENVIRONMENT_VARIABLE 106 247296465Sdelphij# define CONF_R_NO_SECTION 107 248296465Sdelphij# define CONF_R_NO_SUCH_FILE 114 249296465Sdelphij# define CONF_R_NO_VALUE 108 250296465Sdelphij# define CONF_R_UNABLE_TO_CREATE_NEW_SECTION 103 251296465Sdelphij# define CONF_R_UNKNOWN_MODULE_NAME 113 252296465Sdelphij# define CONF_R_VARIABLE_HAS_NO_VALUE 104 25355714Skris 25455714Skris#ifdef __cplusplus 25555714Skris} 25655714Skris#endif 25755714Skris#endif 258