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. 8296341Sdelphij * 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). 15296341Sdelphij * 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. 22296341Sdelphij * 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 :-). 37296341Sdelphij * 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)" 40296341Sdelphij * 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. 52296341Sdelphij * 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 60296341Sdelphij# define HEADER_CONF_H 6155714Skris 62296341Sdelphij# include <openssl/bio.h> 63296341Sdelphij# include <openssl/lhash.h> 64296341Sdelphij# include <openssl/stack.h> 65296341Sdelphij# include <openssl/safestack.h> 66296341Sdelphij# include <openssl/e_os2.h> 6755714Skris 68296341Sdelphij# include <openssl/ossl_typ.h> 69160814Ssimon 7068651Skris#ifdef __cplusplus 7168651Skrisextern "C" { 7268651Skris#endif 7368651Skris 74296341Sdelphijtypedef struct { 75296341Sdelphij char *section; 76296341Sdelphij char *name; 77296341Sdelphij char *value; 78296341Sdelphij} CONF_VALUE; 7955714Skris 8055714SkrisDECLARE_STACK_OF(CONF_VALUE) 81238405SjkimDECLARE_LHASH_OF(CONF_VALUE); 8255714Skris 8368651Skrisstruct conf_st; 8468651Skrisstruct conf_method_st; 8568651Skristypedef struct conf_method_st CONF_METHOD; 8668651Skris 87296341Sdelphijstruct conf_method_st { 88296341Sdelphij const char *name; 89296341Sdelphij CONF *(*create) (CONF_METHOD *meth); 90296341Sdelphij int (*init) (CONF *conf); 91296341Sdelphij int (*destroy) (CONF *conf); 92296341Sdelphij int (*destroy_data) (CONF *conf); 93296341Sdelphij int (*load_bio) (CONF *conf, BIO *bp, long *eline); 94296341Sdelphij int (*dump) (const CONF *conf, BIO *bp); 95296341Sdelphij int (*is_number) (const CONF *conf, char c); 96296341Sdelphij int (*to_int) (const CONF *conf, char c); 97296341Sdelphij int (*load) (CONF *conf, const char *name, long *eline); 98296341Sdelphij}; 9968651Skris 100109998Smarkm/* Module definitions */ 101109998Smarkm 102109998Smarkmtypedef struct conf_imodule_st CONF_IMODULE; 103109998Smarkmtypedef struct conf_module_st CONF_MODULE; 104109998Smarkm 105238405SjkimDECLARE_STACK_OF(CONF_MODULE) 106238405SjkimDECLARE_STACK_OF(CONF_IMODULE) 107238405Sjkim 108109998Smarkm/* DSO module function typedefs */ 109296341Sdelphijtypedef int conf_init_func (CONF_IMODULE *md, const CONF *cnf); 110296341Sdelphijtypedef void conf_finish_func (CONF_IMODULE *md); 111109998Smarkm 112296341Sdelphij# define CONF_MFLAGS_IGNORE_ERRORS 0x1 113296341Sdelphij# define CONF_MFLAGS_IGNORE_RETURN_CODES 0x2 114296341Sdelphij# define CONF_MFLAGS_SILENT 0x4 115296341Sdelphij# define CONF_MFLAGS_NO_DSO 0x8 116296341Sdelphij# define CONF_MFLAGS_IGNORE_MISSING_FILE 0x10 117296341Sdelphij# define CONF_MFLAGS_DEFAULT_SECTION 0x20 118109998Smarkm 11968651Skrisint CONF_set_default_method(CONF_METHOD *meth); 120296341Sdelphijvoid CONF_set_nconf(CONF *conf, LHASH_OF(CONF_VALUE) *hash); 121296341SdelphijLHASH_OF(CONF_VALUE) *CONF_load(LHASH_OF(CONF_VALUE) *conf, const char *file, 122296341Sdelphij long *eline); 123296341Sdelphij# ifndef OPENSSL_NO_FP_API 124238405SjkimLHASH_OF(CONF_VALUE) *CONF_load_fp(LHASH_OF(CONF_VALUE) *conf, FILE *fp, 125296341Sdelphij long *eline); 126296341Sdelphij# endif 127296341SdelphijLHASH_OF(CONF_VALUE) *CONF_load_bio(LHASH_OF(CONF_VALUE) *conf, BIO *bp, 128296341Sdelphij long *eline); 129238405SjkimSTACK_OF(CONF_VALUE) *CONF_get_section(LHASH_OF(CONF_VALUE) *conf, 130296341Sdelphij const char *section); 131296341Sdelphijchar *CONF_get_string(LHASH_OF(CONF_VALUE) *conf, const char *group, 132296341Sdelphij const char *name); 133296341Sdelphijlong CONF_get_number(LHASH_OF(CONF_VALUE) *conf, const char *group, 134296341Sdelphij const char *name); 135238405Sjkimvoid CONF_free(LHASH_OF(CONF_VALUE) *conf); 136238405Sjkimint CONF_dump_fp(LHASH_OF(CONF_VALUE) *conf, FILE *out); 137238405Sjkimint CONF_dump_bio(LHASH_OF(CONF_VALUE) *conf, BIO *out); 13855714Skris 139109998Smarkmvoid OPENSSL_config(const char *config_name); 140109998Smarkmvoid OPENSSL_no_config(void); 141109998Smarkm 142296341Sdelphij/* 143296341Sdelphij * New conf code. The semantics are different from the functions above. If 144296341Sdelphij * that wasn't the case, the above functions would have been replaced 145296341Sdelphij */ 14655714Skris 147296341Sdelphijstruct conf_st { 148296341Sdelphij CONF_METHOD *meth; 149296341Sdelphij void *meth_data; 150296341Sdelphij LHASH_OF(CONF_VALUE) *data; 151296341Sdelphij}; 15268651Skris 15368651SkrisCONF *NCONF_new(CONF_METHOD *meth); 154109998SmarkmCONF_METHOD *NCONF_default(void); 155109998SmarkmCONF_METHOD *NCONF_WIN32(void); 156296341Sdelphij# if 0 /* Just to give you an idea of what I have in 157296341Sdelphij * mind */ 158109998SmarkmCONF_METHOD *NCONF_XML(void); 159296341Sdelphij# endif 16068651Skrisvoid NCONF_free(CONF *conf); 16168651Skrisvoid NCONF_free_data(CONF *conf); 16268651Skris 163296341Sdelphijint NCONF_load(CONF *conf, const char *file, long *eline); 164296341Sdelphij# ifndef OPENSSL_NO_FP_API 165296341Sdelphijint NCONF_load_fp(CONF *conf, FILE *fp, long *eline); 166296341Sdelphij# endif 167296341Sdelphijint NCONF_load_bio(CONF *conf, BIO *bp, long *eline); 168296341SdelphijSTACK_OF(CONF_VALUE) *NCONF_get_section(const CONF *conf, 169296341Sdelphij const char *section); 170296341Sdelphijchar *NCONF_get_string(const CONF *conf, const char *group, const char *name); 171296341Sdelphijint NCONF_get_number_e(const CONF *conf, const char *group, const char *name, 172296341Sdelphij long *result); 173109998Smarkmint NCONF_dump_fp(const CONF *conf, FILE *out); 174109998Smarkmint NCONF_dump_bio(const CONF *conf, BIO *out); 175109998Smarkm 176296341Sdelphij# if 0 /* The following function has no error 177296341Sdelphij * checking, and should therefore be avoided */ 178296341Sdelphijlong NCONF_get_number(CONF *conf, char *group, char *name); 179296341Sdelphij# else 180296341Sdelphij# define NCONF_get_number(c,g,n,r) NCONF_get_number_e(c,g,n,r) 181296341Sdelphij# endif 182296341Sdelphij 183109998Smarkm/* Module functions */ 18468651Skris 185109998Smarkmint CONF_modules_load(const CONF *cnf, const char *appname, 186296341Sdelphij unsigned long flags); 187109998Smarkmint CONF_modules_load_file(const char *filename, const char *appname, 188296341Sdelphij unsigned long flags); 189109998Smarkmvoid CONF_modules_unload(int all); 190109998Smarkmvoid CONF_modules_finish(void); 191109998Smarkmvoid CONF_modules_free(void); 192109998Smarkmint CONF_module_add(const char *name, conf_init_func *ifunc, 193296341Sdelphij conf_finish_func *ffunc); 19468651Skris 195109998Smarkmconst char *CONF_imodule_get_name(const CONF_IMODULE *md); 196109998Smarkmconst char *CONF_imodule_get_value(const CONF_IMODULE *md); 197109998Smarkmvoid *CONF_imodule_get_usr_data(const CONF_IMODULE *md); 198109998Smarkmvoid CONF_imodule_set_usr_data(CONF_IMODULE *md, void *usr_data); 199109998SmarkmCONF_MODULE *CONF_imodule_get_module(const CONF_IMODULE *md); 200109998Smarkmunsigned long CONF_imodule_get_flags(const CONF_IMODULE *md); 201109998Smarkmvoid CONF_imodule_set_flags(CONF_IMODULE *md, unsigned long flags); 202109998Smarkmvoid *CONF_module_get_usr_data(CONF_MODULE *pmod); 203109998Smarkmvoid CONF_module_set_usr_data(CONF_MODULE *pmod, void *usr_data); 204109998Smarkm 205109998Smarkmchar *CONF_get1_default_config_file(void); 206109998Smarkm 207109998Smarkmint CONF_parse_list(const char *list, int sep, int nospc, 208296341Sdelphij int (*list_cb) (const char *elem, int len, void *usr), 209296341Sdelphij void *arg); 210109998Smarkm 211109998Smarkmvoid OPENSSL_load_builtin_modules(void); 212109998Smarkm 21355714Skris/* BEGIN ERROR CODES */ 214296341Sdelphij/* 215296341Sdelphij * The following lines are auto generated by the script mkerr.pl. Any changes 21655714Skris * made after this point may be overwritten when the script is next run. 21755714Skris */ 21889837Skrisvoid ERR_load_CONF_strings(void); 21955714Skris 22055714Skris/* Error codes for the CONF functions. */ 22155714Skris 22255714Skris/* Function codes. */ 223296341Sdelphij# define CONF_F_CONF_DUMP_FP 104 224296341Sdelphij# define CONF_F_CONF_LOAD 100 225296341Sdelphij# define CONF_F_CONF_LOAD_BIO 102 226296341Sdelphij# define CONF_F_CONF_LOAD_FP 103 227296341Sdelphij# define CONF_F_CONF_MODULES_LOAD 116 228296341Sdelphij# define CONF_F_CONF_PARSE_LIST 119 229296341Sdelphij# define CONF_F_DEF_LOAD 120 230296341Sdelphij# define CONF_F_DEF_LOAD_BIO 121 231296341Sdelphij# define CONF_F_MODULE_INIT 115 232296341Sdelphij# define CONF_F_MODULE_LOAD_DSO 117 233296341Sdelphij# define CONF_F_MODULE_RUN 118 234296341Sdelphij# define CONF_F_NCONF_DUMP_BIO 105 235296341Sdelphij# define CONF_F_NCONF_DUMP_FP 106 236296341Sdelphij# define CONF_F_NCONF_GET_NUMBER 107 237296341Sdelphij# define CONF_F_NCONF_GET_NUMBER_E 112 238296341Sdelphij# define CONF_F_NCONF_GET_SECTION 108 239296341Sdelphij# define CONF_F_NCONF_GET_STRING 109 240296341Sdelphij# define CONF_F_NCONF_LOAD 113 241296341Sdelphij# define CONF_F_NCONF_LOAD_BIO 110 242296341Sdelphij# define CONF_F_NCONF_LOAD_FP 114 243296341Sdelphij# define CONF_F_NCONF_NEW 111 244296341Sdelphij# define CONF_F_STR_COPY 101 24555714Skris 24655714Skris/* Reason codes. */ 247296341Sdelphij# define CONF_R_ERROR_LOADING_DSO 110 248296341Sdelphij# define CONF_R_LIST_CANNOT_BE_NULL 115 249296341Sdelphij# define CONF_R_MISSING_CLOSE_SQUARE_BRACKET 100 250296341Sdelphij# define CONF_R_MISSING_EQUAL_SIGN 101 251296341Sdelphij# define CONF_R_MISSING_FINISH_FUNCTION 111 252296341Sdelphij# define CONF_R_MISSING_INIT_FUNCTION 112 253296341Sdelphij# define CONF_R_MODULE_INITIALIZATION_ERROR 109 254296341Sdelphij# define CONF_R_NO_CLOSE_BRACE 102 255296341Sdelphij# define CONF_R_NO_CONF 105 256296341Sdelphij# define CONF_R_NO_CONF_OR_ENVIRONMENT_VARIABLE 106 257296341Sdelphij# define CONF_R_NO_SECTION 107 258296341Sdelphij# define CONF_R_NO_SUCH_FILE 114 259296341Sdelphij# define CONF_R_NO_VALUE 108 260296341Sdelphij# define CONF_R_UNABLE_TO_CREATE_NEW_SECTION 103 261296341Sdelphij# define CONF_R_UNKNOWN_MODULE_NAME 113 262296341Sdelphij# define CONF_R_VARIABLE_HAS_NO_VALUE 104 26355714Skris 26455714Skris#ifdef __cplusplus 26555714Skris} 26655714Skris#endif 26755714Skris#endif 268