1231990Smp/* crypto/conf/conf.h */ 259243Sobrien/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 359243Sobrien * All rights reserved. 459243Sobrien * 559243Sobrien * This package is an SSL implementation written 659243Sobrien * by Eric Young (eay@cryptsoft.com). 759243Sobrien * The implementation was written so as to conform with Netscapes SSL. 859243Sobrien * 959243Sobrien * This library is free for commercial and non-commercial use as long as 1059243Sobrien * the following conditions are aheared to. The following conditions 1159243Sobrien * apply to all code found in this distribution, be it the RC4, RSA, 1259243Sobrien * lhash, DES, etc., code; not just the SSL code. The SSL documentation 1359243Sobrien * included with this distribution is covered by the same copyright terms 1459243Sobrien * except that the holder is Tim Hudson (tjh@cryptsoft.com). 1559243Sobrien * 1659243Sobrien * Copyright remains Eric Young's, and as such any Copyright notices in 1759243Sobrien * the code are not to be removed. 18100616Smp * If this package is used in a product, Eric Young should be given attribution 1959243Sobrien * as the author of the parts of the library used. 2059243Sobrien * This can be in the form of a textual message at program startup or 2159243Sobrien * in documentation (online or textual) provided with the package. 2259243Sobrien * 2359243Sobrien * Redistribution and use in source and binary forms, with or without 2459243Sobrien * modification, are permitted provided that the following conditions 2559243Sobrien * are met: 2659243Sobrien * 1. Redistributions of source code must retain the copyright 2759243Sobrien * notice, this list of conditions and the following disclaimer. 2859243Sobrien * 2. Redistributions in binary form must reproduce the above copyright 2959243Sobrien * notice, this list of conditions and the following disclaimer in the 3059243Sobrien * documentation and/or other materials provided with the distribution. 3159243Sobrien * 3. All advertising materials mentioning features or use of this software 3259243Sobrien * must display the following acknowledgement: 3359243Sobrien * "This product includes cryptographic software written by 3459243Sobrien * Eric Young (eay@cryptsoft.com)" 3559243Sobrien * The word 'cryptographic' can be left out if the rouines from the library 36231990Smp * being used are not cryptographic related :-). 37145479Smp * 4. If you include any Windows specific code (or a derivative thereof) from 3859243Sobrien * the apps directory (application code) you must include an acknowledgement: 39231990Smp * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" 40145479Smp * 4159243Sobrien * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 42145479Smp * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 43145479Smp * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 44145479Smp * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 45145479Smp * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 46145479Smp * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 4759243Sobrien * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 48145479Smp * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 49145479Smp * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 50231990Smp * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 51145479Smp * SUCH DAMAGE. 52145479Smp * 53145479Smp * The licence and distribution terms for any publically available version or 54145479Smp * derivative of this code cannot be changed. i.e. this code cannot simply be 55145479Smp * copied and put under another distribution licence 56195609Smp * [including the GNU Public Licence.] 57145479Smp */ 58145479Smp 59145479Smp#ifndef HEADER_CONF_H 60145479Smp#define HEADER_CONF_H 61145479Smp 62145479Smp#include <openssl/bio.h> 63145479Smp#include <openssl/lhash.h> 64145479Smp#include <openssl/stack.h> 65231990Smp#include <openssl/safestack.h> 66145479Smp#include <openssl/e_os2.h> 67145479Smp 68145479Smp#include <openssl/ossl_typ.h> 69145479Smp 70145479Smp#ifdef __cplusplus 71145479Smpextern "C" { 72145479Smp#endif 73231990Smp 74231990Smptypedef struct 75231990Smp { 76231990Smp char *section; 77231990Smp char *name; 78231990Smp char *value; 79231990Smp } CONF_VALUE; 80231990Smp 81231990SmpDECLARE_STACK_OF(CONF_VALUE) 82231990SmpDECLARE_LHASH_OF(CONF_VALUE); 83231990Smp 84231990Smpstruct conf_st; 85231990Smpstruct conf_method_st; 86231990Smptypedef struct conf_method_st CONF_METHOD; 87231990Smp 88231990Smpstruct conf_method_st 89231990Smp { 90145479Smp const char *name; 91145479Smp CONF *(*create)(CONF_METHOD *meth); 92145479Smp int (*init)(CONF *conf); 93145479Smp int (*destroy)(CONF *conf); 94145479Smp int (*destroy_data)(CONF *conf); 95145479Smp int (*load_bio)(CONF *conf, BIO *bp, long *eline); 96145479Smp int (*dump)(const CONF *conf, BIO *bp); 97167465Smp int (*is_number)(const CONF *conf, char c); 98145479Smp int (*to_int)(const CONF *conf, char c); 99231990Smp int (*load)(CONF *conf, const char *name, long *eline); 100145479Smp }; 101145479Smp 102145479Smp/* Module definitions */ 103231990Smp 104231990Smptypedef struct conf_imodule_st CONF_IMODULE; 105231990Smptypedef struct conf_module_st CONF_MODULE; 106231990Smp 107231990SmpDECLARE_STACK_OF(CONF_MODULE) 108231990SmpDECLARE_STACK_OF(CONF_IMODULE) 109231990Smp 110231990Smp/* DSO module function typedefs */ 111231990Smptypedef int conf_init_func(CONF_IMODULE *md, const CONF *cnf); 112231990Smptypedef void conf_finish_func(CONF_IMODULE *md); 113231990Smp 114231990Smp#define CONF_MFLAGS_IGNORE_ERRORS 0x1 115231990Smp#define CONF_MFLAGS_IGNORE_RETURN_CODES 0x2 116231990Smp#define CONF_MFLAGS_SILENT 0x4 117231990Smp#define CONF_MFLAGS_NO_DSO 0x8 118231990Smp#define CONF_MFLAGS_IGNORE_MISSING_FILE 0x10 119145479Smp#define CONF_MFLAGS_DEFAULT_SECTION 0x20 120231990Smp 121231990Smpint CONF_set_default_method(CONF_METHOD *meth); 122231990Smpvoid CONF_set_nconf(CONF *conf,LHASH_OF(CONF_VALUE) *hash); 123231990SmpLHASH_OF(CONF_VALUE) *CONF_load(LHASH_OF(CONF_VALUE) *conf,const char *file, 124231990Smp long *eline); 125231990Smp#ifndef OPENSSL_NO_FP_API 126231990SmpLHASH_OF(CONF_VALUE) *CONF_load_fp(LHASH_OF(CONF_VALUE) *conf, FILE *fp, 127231990Smp long *eline); 128231990Smp#endif 129231990SmpLHASH_OF(CONF_VALUE) *CONF_load_bio(LHASH_OF(CONF_VALUE) *conf, BIO *bp,long *eline); 130231990SmpSTACK_OF(CONF_VALUE) *CONF_get_section(LHASH_OF(CONF_VALUE) *conf, 131231990Smp const char *section); 132231990Smpchar *CONF_get_string(LHASH_OF(CONF_VALUE) *conf,const char *group, 133231990Smp const char *name); 134231990Smplong CONF_get_number(LHASH_OF(CONF_VALUE) *conf,const char *group, 135231990Smp const char *name); 136231990Smpvoid CONF_free(LHASH_OF(CONF_VALUE) *conf); 137231990Smpint CONF_dump_fp(LHASH_OF(CONF_VALUE) *conf, FILE *out); 138231990Smpint CONF_dump_bio(LHASH_OF(CONF_VALUE) *conf, BIO *out); 139231990Smp 140231990Smpvoid OPENSSL_config(const char *config_name); 141231990Smpvoid OPENSSL_no_config(void); 142231990Smp 143231990Smp/* New conf code. The semantics are different from the functions above. 144145479Smp If that wasn't the case, the above functions would have been replaced */ 145231990Smp 146231990Smpstruct conf_st 147231990Smp { 148145479Smp CONF_METHOD *meth; 149145479Smp void *meth_data; 150167465Smp LHASH_OF(CONF_VALUE) *data; 151145479Smp }; 152167465Smp 15359243SobrienCONF *NCONF_new(CONF_METHOD *meth); 154167465SmpCONF_METHOD *NCONF_default(void); 15559243SobrienCONF_METHOD *NCONF_WIN32(void); 15659243Sobrien#if 0 /* Just to give you an idea of what I have in mind */ 157145479SmpCONF_METHOD *NCONF_XML(void); 15859243Sobrien#endif 15959243Sobrienvoid NCONF_free(CONF *conf); 16059243Sobrienvoid NCONF_free_data(CONF *conf); 16159243Sobrien 16259243Sobrienint NCONF_load(CONF *conf,const char *file,long *eline); 16359243Sobrien#ifndef OPENSSL_NO_FP_API 164167465Smpint NCONF_load_fp(CONF *conf, FILE *fp,long *eline); 16559243Sobrien#endif 16659243Sobrienint NCONF_load_bio(CONF *conf, BIO *bp,long *eline); 16759243SobrienSTACK_OF(CONF_VALUE) *NCONF_get_section(const CONF *conf,const char *section); 16859243Sobrienchar *NCONF_get_string(const CONF *conf,const char *group,const char *name); 16959243Sobrienint NCONF_get_number_e(const CONF *conf,const char *group,const char *name, 17059243Sobrien long *result); 17159243Sobrienint NCONF_dump_fp(const CONF *conf, FILE *out); 17259243Sobrienint NCONF_dump_bio(const CONF *conf, BIO *out); 173167465Smp 17459243Sobrien#if 0 /* The following function has no error checking, 17559243Sobrien and should therefore be avoided */ 176145479Smplong NCONF_get_number(CONF *conf,char *group,char *name); 17759243Sobrien#else 17859243Sobrien#define NCONF_get_number(c,g,n,r) NCONF_get_number_e(c,g,n,r) 17959243Sobrien#endif 18059243Sobrien 18159243Sobrien/* Module functions */ 18259243Sobrien 183167465Smpint CONF_modules_load(const CONF *cnf, const char *appname, 18459243Sobrien unsigned long flags); 18559243Sobrienint CONF_modules_load_file(const char *filename, const char *appname, 18659243Sobrien unsigned long flags); 18759243Sobrienvoid CONF_modules_unload(int all); 18859243Sobrienvoid CONF_modules_finish(void); 18959243Sobrienvoid CONF_modules_free(void); 19059243Sobrienint CONF_module_add(const char *name, conf_init_func *ifunc, 19159243Sobrien conf_finish_func *ffunc); 192167465Smp 19359243Sobrienconst char *CONF_imodule_get_name(const CONF_IMODULE *md); 194167465Smpconst char *CONF_imodule_get_value(const CONF_IMODULE *md); 19559243Sobrienvoid *CONF_imodule_get_usr_data(const CONF_IMODULE *md); 19659243Sobrienvoid CONF_imodule_set_usr_data(CONF_IMODULE *md, void *usr_data); 19759243SobrienCONF_MODULE *CONF_imodule_get_module(const CONF_IMODULE *md); 19859243Sobrienunsigned long CONF_imodule_get_flags(const CONF_IMODULE *md); 199167465Smpvoid CONF_imodule_set_flags(CONF_IMODULE *md, unsigned long flags); 200167465Smpvoid *CONF_module_get_usr_data(CONF_MODULE *pmod); 201167465Smpvoid CONF_module_set_usr_data(CONF_MODULE *pmod, void *usr_data); 20259243Sobrien 203167465Smpchar *CONF_get1_default_config_file(void); 204167465Smp 20559243Sobrienint CONF_parse_list(const char *list, int sep, int nospc, 206167465Smp int (*list_cb)(const char *elem, int len, void *usr), void *arg); 207167465Smp 20859243Sobrienvoid OPENSSL_load_builtin_modules(void); 20959243Sobrien 21059243Sobrien/* BEGIN ERROR CODES */ 211167465Smp/* The following lines are auto generated by the script mkerr.pl. Any changes 21259243Sobrien * made after this point may be overwritten when the script is next run. 21359243Sobrien */ 21459243Sobrienvoid ERR_load_CONF_strings(void); 215145479Smp 21659243Sobrien/* Error codes for the CONF functions. */ 21759243Sobrien 21859243Sobrien/* Function codes. */ 21959243Sobrien#define CONF_F_CONF_DUMP_FP 104 22059243Sobrien#define CONF_F_CONF_LOAD 100 22159243Sobrien#define CONF_F_CONF_LOAD_BIO 102 222167465Smp#define CONF_F_CONF_LOAD_FP 103 22359243Sobrien#define CONF_F_CONF_MODULES_LOAD 116 22459243Sobrien#define CONF_F_CONF_PARSE_LIST 119 22559243Sobrien#define CONF_F_DEF_LOAD 120 22659243Sobrien#define CONF_F_DEF_LOAD_BIO 121 227145479Smp#define CONF_F_MODULE_INIT 115 228145479Smp#define CONF_F_MODULE_LOAD_DSO 117 229145479Smp#define CONF_F_MODULE_RUN 118 230195609Smp#define CONF_F_NCONF_DUMP_BIO 105 231195609Smp#define CONF_F_NCONF_DUMP_FP 106 232195609Smp#define CONF_F_NCONF_GET_NUMBER 107 23359243Sobrien#define CONF_F_NCONF_GET_NUMBER_E 112 234167465Smp#define CONF_F_NCONF_GET_SECTION 108 23559243Sobrien#define CONF_F_NCONF_GET_STRING 109 23659243Sobrien#define CONF_F_NCONF_LOAD 113 237195609Smp#define CONF_F_NCONF_LOAD_BIO 110 238195609Smp#define CONF_F_NCONF_LOAD_FP 114 239195609Smp#define CONF_F_NCONF_NEW 111 240195609Smp#define CONF_F_STR_COPY 101 24159243Sobrien 24259243Sobrien/* Reason codes. */ 24359243Sobrien#define CONF_R_ERROR_LOADING_DSO 110 24459243Sobrien#define CONF_R_LIST_CANNOT_BE_NULL 115 24559243Sobrien#define CONF_R_MISSING_CLOSE_SQUARE_BRACKET 100 24659243Sobrien#define CONF_R_MISSING_EQUAL_SIGN 101 247231990Smp#define CONF_R_MISSING_FINISH_FUNCTION 111 24859243Sobrien#define CONF_R_MISSING_INIT_FUNCTION 112 249167465Smp#define CONF_R_MODULE_INITIALIZATION_ERROR 109 25059243Sobrien#define CONF_R_NO_CLOSE_BRACE 102 251145479Smp#define CONF_R_NO_CONF 105 25259243Sobrien#define CONF_R_NO_CONF_OR_ENVIRONMENT_VARIABLE 106 25359243Sobrien#define CONF_R_NO_SECTION 107 25459243Sobrien#define CONF_R_NO_SUCH_FILE 114 25559243Sobrien#define CONF_R_NO_VALUE 108 25659243Sobrien#define CONF_R_UNABLE_TO_CREATE_NEW_SECTION 103 25759243Sobrien#define CONF_R_UNKNOWN_MODULE_NAME 113 25859243Sobrien#define CONF_R_VARIABLE_HAS_NO_VALUE 104 25959243Sobrien 260167465Smp#ifdef __cplusplus 26159243Sobrien} 262145479Smp#endif 26359243Sobrien#endif 26459243Sobrien