X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=crypto%2Fconf%2Fconf_lib.c;h=54046defca8b2db4852cc386cec2686730126582;hb=3c075bf07f2d57c0272260409bf38fb6f438b016;hp=8e4d673fb877c6a372a9105024b134e6f0762fea;hpb=bc36ee6227517edae802bcb0da68d4f04fe1fb5e;p=oweals%2Fopenssl.git diff --git a/crypto/conf/conf_lib.c b/crypto/conf/conf_lib.c index 8e4d673fb8..54046defca 100644 --- a/crypto/conf/conf_lib.c +++ b/crypto/conf/conf_lib.c @@ -63,10 +63,21 @@ #include #include -const char *CONF_version="CONF" OPENSSL_VERSION_PTEXT; +const char CONF_version[]="CONF" OPENSSL_VERSION_PTEXT; static CONF_METHOD *default_CONF_method=NULL; +/* Init a 'CONF' structure from an old LHASH */ + +void CONF_set_nconf(CONF *conf, LHASH_OF(CONF_VALUE) *hash) + { + if (default_CONF_method == NULL) + default_CONF_method = NCONF_default(); + + default_CONF_method->init(conf); + conf->data = hash; + } + /* The following section contains the "CONF classic" functions, rewritten in terms of the new CONF interface. */ @@ -76,9 +87,10 @@ int CONF_set_default_method(CONF_METHOD *meth) return 1; } -LHASH *CONF_load(LHASH *conf, const char *file, long *eline) +LHASH_OF(CONF_VALUE) *CONF_load(LHASH_OF(CONF_VALUE) *conf, const char *file, + long *eline) { - LHASH *ltmp; + LHASH_OF(CONF_VALUE) *ltmp; BIO *in=NULL; #ifdef OPENSSL_SYS_VMS @@ -99,10 +111,11 @@ LHASH *CONF_load(LHASH *conf, const char *file, long *eline) } #ifndef OPENSSL_NO_FP_API -LHASH *CONF_load_fp(LHASH *conf, FILE *fp,long *eline) +LHASH_OF(CONF_VALUE) *CONF_load_fp(LHASH_OF(CONF_VALUE) *conf, FILE *fp, + long *eline) { BIO *btmp; - LHASH *ltmp; + LHASH_OF(CONF_VALUE) *ltmp; if(!(btmp = BIO_new_fp(fp, BIO_NOCLOSE))) { CONFerr(CONF_F_CONF_LOAD_FP,ERR_R_BUF_LIB); return NULL; @@ -113,23 +126,22 @@ LHASH *CONF_load_fp(LHASH *conf, FILE *fp,long *eline) } #endif -LHASH *CONF_load_bio(LHASH *conf, BIO *bp,long *eline) +LHASH_OF(CONF_VALUE) *CONF_load_bio(LHASH_OF(CONF_VALUE) *conf, BIO *bp, + long *eline) { CONF ctmp; int ret; - if (default_CONF_method == NULL) - default_CONF_method = NCONF_default(); + CONF_set_nconf(&ctmp, conf); - default_CONF_method->init(&ctmp); - ctmp.data = conf; ret = NCONF_load_bio(&ctmp, bp, eline); if (ret) return ctmp.data; return NULL; } -STACK_OF(CONF_VALUE) *CONF_get_section(LHASH *conf,char *section) +STACK_OF(CONF_VALUE) *CONF_get_section(LHASH_OF(CONF_VALUE) *conf, + const char *section) { if (conf == NULL) { @@ -138,17 +150,13 @@ STACK_OF(CONF_VALUE) *CONF_get_section(LHASH *conf,char *section) else { CONF ctmp; - - if (default_CONF_method == NULL) - default_CONF_method = NCONF_default(); - - default_CONF_method->init(&ctmp); - ctmp.data = conf; + CONF_set_nconf(&ctmp, conf); return NCONF_get_section(&ctmp, section); } } -char *CONF_get_string(LHASH *conf,char *group,char *name) +char *CONF_get_string(LHASH_OF(CONF_VALUE) *conf,const char *group, + const char *name) { if (conf == NULL) { @@ -157,17 +165,13 @@ char *CONF_get_string(LHASH *conf,char *group,char *name) else { CONF ctmp; - - if (default_CONF_method == NULL) - default_CONF_method = NCONF_default(); - - default_CONF_method->init(&ctmp); - ctmp.data = conf; + CONF_set_nconf(&ctmp, conf); return NCONF_get_string(&ctmp, group, name); } } -long CONF_get_number(LHASH *conf,char *group,char *name) +long CONF_get_number(LHASH_OF(CONF_VALUE) *conf,const char *group, + const char *name) { int status; long result = 0; @@ -179,37 +183,27 @@ long CONF_get_number(LHASH *conf,char *group,char *name) else { CONF ctmp; - - if (default_CONF_method == NULL) - default_CONF_method = NCONF_default(); - - default_CONF_method->init(&ctmp); - ctmp.data = conf; + CONF_set_nconf(&ctmp, conf); status = NCONF_get_number_e(&ctmp, group, name, &result); } if (status == 0) { /* This function does not believe in errors... */ - ERR_get_error(); + ERR_clear_error(); } return result; } -void CONF_free(LHASH *conf) +void CONF_free(LHASH_OF(CONF_VALUE) *conf) { CONF ctmp; - - if (default_CONF_method == NULL) - default_CONF_method = NCONF_default(); - - default_CONF_method->init(&ctmp); - ctmp.data = conf; + CONF_set_nconf(&ctmp, conf); NCONF_free_data(&ctmp); } #ifndef OPENSSL_NO_FP_API -int CONF_dump_fp(LHASH *conf, FILE *out) +int CONF_dump_fp(LHASH_OF(CONF_VALUE) *conf, FILE *out) { BIO *btmp; int ret; @@ -224,15 +218,10 @@ int CONF_dump_fp(LHASH *conf, FILE *out) } #endif -int CONF_dump_bio(LHASH *conf, BIO *out) +int CONF_dump_bio(LHASH_OF(CONF_VALUE) *conf, BIO *out) { CONF ctmp; - - if (default_CONF_method == NULL) - default_CONF_method = NCONF_default(); - - default_CONF_method->init(&ctmp); - ctmp.data = conf; + CONF_set_nconf(&ctmp, conf); return NCONF_dump_bio(&ctmp, out); } @@ -311,7 +300,7 @@ int NCONF_load_bio(CONF *conf, BIO *bp,long *eline) return conf->meth->load_bio(conf, bp, eline); } -STACK_OF(CONF_VALUE) *NCONF_get_section(CONF *conf,char *section) +STACK_OF(CONF_VALUE) *NCONF_get_section(const CONF *conf,const char *section) { if (conf == NULL) { @@ -328,7 +317,7 @@ STACK_OF(CONF_VALUE) *NCONF_get_section(CONF *conf,char *section) return _CONF_get_section_values(conf, section); } -char *NCONF_get_string(CONF *conf,char *group,char *name) +char *NCONF_get_string(const CONF *conf,const char *group,const char *name) { char *s = _CONF_get_string(conf, group, name); @@ -344,10 +333,12 @@ char *NCONF_get_string(CONF *conf,char *group,char *name) } CONFerr(CONF_F_NCONF_GET_STRING, CONF_R_NO_VALUE); + ERR_add_error_data(4,"group=",group," name=",name); return NULL; } -int NCONF_get_number_e(CONF *conf,char *group,char *name,long *result) +int NCONF_get_number_e(const CONF *conf,const char *group,const char *name, + long *result) { char *str; @@ -362,7 +353,7 @@ int NCONF_get_number_e(CONF *conf,char *group,char *name,long *result) if (str == NULL) return 0; - for (;conf->meth->is_number(conf, *str);) + for (*result = 0;conf->meth->is_number(conf, *str);) { *result = (*result)*10 + conf->meth->to_int(conf, *str); str++; @@ -372,7 +363,7 @@ int NCONF_get_number_e(CONF *conf,char *group,char *name,long *result) } #ifndef OPENSSL_NO_FP_API -int NCONF_dump_fp(CONF *conf, FILE *out) +int NCONF_dump_fp(const CONF *conf, FILE *out) { BIO *btmp; int ret; @@ -386,7 +377,7 @@ int NCONF_dump_fp(CONF *conf, FILE *out) } #endif -int NCONF_dump_bio(CONF *conf, BIO *out) +int NCONF_dump_bio(const CONF *conf, BIO *out) { if (conf == NULL) { @@ -397,8 +388,9 @@ int NCONF_dump_bio(CONF *conf, BIO *out) return conf->meth->dump(conf, out); } + /* This function should be avoided */ -#undef NCONF_get_number +#if 0 long NCONF_get_number(CONF *conf,char *group,char *name) { int status; @@ -412,4 +404,4 @@ long NCONF_get_number(CONF *conf,char *group,char *name) } return ret; } - +#endif