xref: /onnv-gate/usr/src/common/openssl/crypto/conf/conf_lib.c (revision 2139:6243c3338933)
10Sstevel@tonic-gate /* conf_lib.c */
20Sstevel@tonic-gate /* Written by Richard Levitte (richard@levitte.org) for the OpenSSL
30Sstevel@tonic-gate  * project 2000.
40Sstevel@tonic-gate  */
50Sstevel@tonic-gate /* ====================================================================
60Sstevel@tonic-gate  * Copyright (c) 2000 The OpenSSL Project.  All rights reserved.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * Redistribution and use in source and binary forms, with or without
90Sstevel@tonic-gate  * modification, are permitted provided that the following conditions
100Sstevel@tonic-gate  * are met:
110Sstevel@tonic-gate  *
120Sstevel@tonic-gate  * 1. Redistributions of source code must retain the above copyright
130Sstevel@tonic-gate  *    notice, this list of conditions and the following disclaimer.
140Sstevel@tonic-gate  *
150Sstevel@tonic-gate  * 2. Redistributions in binary form must reproduce the above copyright
160Sstevel@tonic-gate  *    notice, this list of conditions and the following disclaimer in
170Sstevel@tonic-gate  *    the documentation and/or other materials provided with the
180Sstevel@tonic-gate  *    distribution.
190Sstevel@tonic-gate  *
200Sstevel@tonic-gate  * 3. All advertising materials mentioning features or use of this
210Sstevel@tonic-gate  *    software must display the following acknowledgment:
220Sstevel@tonic-gate  *    "This product includes software developed by the OpenSSL Project
230Sstevel@tonic-gate  *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
240Sstevel@tonic-gate  *
250Sstevel@tonic-gate  * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
260Sstevel@tonic-gate  *    endorse or promote products derived from this software without
270Sstevel@tonic-gate  *    prior written permission. For written permission, please contact
280Sstevel@tonic-gate  *    licensing@OpenSSL.org.
290Sstevel@tonic-gate  *
300Sstevel@tonic-gate  * 5. Products derived from this software may not be called "OpenSSL"
310Sstevel@tonic-gate  *    nor may "OpenSSL" appear in their names without prior written
320Sstevel@tonic-gate  *    permission of the OpenSSL Project.
330Sstevel@tonic-gate  *
340Sstevel@tonic-gate  * 6. Redistributions of any form whatsoever must retain the following
350Sstevel@tonic-gate  *    acknowledgment:
360Sstevel@tonic-gate  *    "This product includes software developed by the OpenSSL Project
370Sstevel@tonic-gate  *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
380Sstevel@tonic-gate  *
390Sstevel@tonic-gate  * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
400Sstevel@tonic-gate  * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
410Sstevel@tonic-gate  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
420Sstevel@tonic-gate  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
430Sstevel@tonic-gate  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
440Sstevel@tonic-gate  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
450Sstevel@tonic-gate  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
460Sstevel@tonic-gate  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
470Sstevel@tonic-gate  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
480Sstevel@tonic-gate  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
490Sstevel@tonic-gate  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
500Sstevel@tonic-gate  * OF THE POSSIBILITY OF SUCH DAMAGE.
510Sstevel@tonic-gate  * ====================================================================
520Sstevel@tonic-gate  *
530Sstevel@tonic-gate  * This product includes cryptographic software written by Eric Young
540Sstevel@tonic-gate  * (eay@cryptsoft.com).  This product includes software written by Tim
550Sstevel@tonic-gate  * Hudson (tjh@cryptsoft.com).
560Sstevel@tonic-gate  *
570Sstevel@tonic-gate  */
580Sstevel@tonic-gate 
590Sstevel@tonic-gate #include <stdio.h>
600Sstevel@tonic-gate #include <openssl/crypto.h>
610Sstevel@tonic-gate #include <openssl/err.h>
620Sstevel@tonic-gate #include <openssl/conf.h>
630Sstevel@tonic-gate #include <openssl/conf_api.h>
640Sstevel@tonic-gate #include <openssl/lhash.h>
650Sstevel@tonic-gate 
660Sstevel@tonic-gate const char *CONF_version="CONF" OPENSSL_VERSION_PTEXT;
670Sstevel@tonic-gate 
680Sstevel@tonic-gate static CONF_METHOD *default_CONF_method=NULL;
690Sstevel@tonic-gate 
700Sstevel@tonic-gate /* Init a 'CONF' structure from an old LHASH */
710Sstevel@tonic-gate 
CONF_set_nconf(CONF * conf,LHASH * hash)720Sstevel@tonic-gate void CONF_set_nconf(CONF *conf, LHASH *hash)
730Sstevel@tonic-gate 	{
740Sstevel@tonic-gate 	if (default_CONF_method == NULL)
750Sstevel@tonic-gate 		default_CONF_method = NCONF_default();
760Sstevel@tonic-gate 
770Sstevel@tonic-gate 	default_CONF_method->init(conf);
780Sstevel@tonic-gate 	conf->data = hash;
790Sstevel@tonic-gate 	}
800Sstevel@tonic-gate 
810Sstevel@tonic-gate /* The following section contains the "CONF classic" functions,
820Sstevel@tonic-gate    rewritten in terms of the new CONF interface. */
830Sstevel@tonic-gate 
CONF_set_default_method(CONF_METHOD * meth)840Sstevel@tonic-gate int CONF_set_default_method(CONF_METHOD *meth)
850Sstevel@tonic-gate 	{
860Sstevel@tonic-gate 	default_CONF_method = meth;
870Sstevel@tonic-gate 	return 1;
880Sstevel@tonic-gate 	}
890Sstevel@tonic-gate 
CONF_load(LHASH * conf,const char * file,long * eline)900Sstevel@tonic-gate LHASH *CONF_load(LHASH *conf, const char *file, long *eline)
910Sstevel@tonic-gate 	{
920Sstevel@tonic-gate 	LHASH *ltmp;
930Sstevel@tonic-gate 	BIO *in=NULL;
940Sstevel@tonic-gate 
950Sstevel@tonic-gate #ifdef OPENSSL_SYS_VMS
960Sstevel@tonic-gate 	in=BIO_new_file(file, "r");
970Sstevel@tonic-gate #else
980Sstevel@tonic-gate 	in=BIO_new_file(file, "rb");
990Sstevel@tonic-gate #endif
1000Sstevel@tonic-gate 	if (in == NULL)
1010Sstevel@tonic-gate 		{
1020Sstevel@tonic-gate 		CONFerr(CONF_F_CONF_LOAD,ERR_R_SYS_LIB);
1030Sstevel@tonic-gate 		return NULL;
1040Sstevel@tonic-gate 		}
1050Sstevel@tonic-gate 
1060Sstevel@tonic-gate 	ltmp = CONF_load_bio(conf, in, eline);
1070Sstevel@tonic-gate 	BIO_free(in);
1080Sstevel@tonic-gate 
1090Sstevel@tonic-gate 	return ltmp;
1100Sstevel@tonic-gate 	}
1110Sstevel@tonic-gate 
1120Sstevel@tonic-gate #ifndef OPENSSL_NO_FP_API
CONF_load_fp(LHASH * conf,FILE * fp,long * eline)1130Sstevel@tonic-gate LHASH *CONF_load_fp(LHASH *conf, FILE *fp,long *eline)
1140Sstevel@tonic-gate 	{
1150Sstevel@tonic-gate 	BIO *btmp;
1160Sstevel@tonic-gate 	LHASH *ltmp;
1170Sstevel@tonic-gate 	if(!(btmp = BIO_new_fp(fp, BIO_NOCLOSE))) {
1180Sstevel@tonic-gate 		CONFerr(CONF_F_CONF_LOAD_FP,ERR_R_BUF_LIB);
1190Sstevel@tonic-gate 		return NULL;
1200Sstevel@tonic-gate 	}
1210Sstevel@tonic-gate 	ltmp = CONF_load_bio(conf, btmp, eline);
1220Sstevel@tonic-gate 	BIO_free(btmp);
1230Sstevel@tonic-gate 	return ltmp;
1240Sstevel@tonic-gate 	}
1250Sstevel@tonic-gate #endif
1260Sstevel@tonic-gate 
CONF_load_bio(LHASH * conf,BIO * bp,long * eline)1270Sstevel@tonic-gate LHASH *CONF_load_bio(LHASH *conf, BIO *bp,long *eline)
1280Sstevel@tonic-gate 	{
1290Sstevel@tonic-gate 	CONF ctmp;
1300Sstevel@tonic-gate 	int ret;
1310Sstevel@tonic-gate 
1320Sstevel@tonic-gate 	CONF_set_nconf(&ctmp, conf);
1330Sstevel@tonic-gate 
1340Sstevel@tonic-gate 	ret = NCONF_load_bio(&ctmp, bp, eline);
1350Sstevel@tonic-gate 	if (ret)
1360Sstevel@tonic-gate 		return ctmp.data;
1370Sstevel@tonic-gate 	return NULL;
1380Sstevel@tonic-gate 	}
1390Sstevel@tonic-gate 
STACK_OF(CONF_VALUE)1400Sstevel@tonic-gate STACK_OF(CONF_VALUE) *CONF_get_section(LHASH *conf,const char *section)
1410Sstevel@tonic-gate 	{
1420Sstevel@tonic-gate 	if (conf == NULL)
1430Sstevel@tonic-gate 		{
1440Sstevel@tonic-gate 		return NULL;
1450Sstevel@tonic-gate 		}
1460Sstevel@tonic-gate 	else
1470Sstevel@tonic-gate 		{
1480Sstevel@tonic-gate 		CONF ctmp;
1490Sstevel@tonic-gate 		CONF_set_nconf(&ctmp, conf);
1500Sstevel@tonic-gate 		return NCONF_get_section(&ctmp, section);
1510Sstevel@tonic-gate 		}
1520Sstevel@tonic-gate 	}
1530Sstevel@tonic-gate 
CONF_get_string(LHASH * conf,const char * group,const char * name)1540Sstevel@tonic-gate char *CONF_get_string(LHASH *conf,const char *group,const char *name)
1550Sstevel@tonic-gate 	{
1560Sstevel@tonic-gate 	if (conf == NULL)
1570Sstevel@tonic-gate 		{
1580Sstevel@tonic-gate 		return NCONF_get_string(NULL, group, name);
1590Sstevel@tonic-gate 		}
1600Sstevel@tonic-gate 	else
1610Sstevel@tonic-gate 		{
1620Sstevel@tonic-gate 		CONF ctmp;
1630Sstevel@tonic-gate 		CONF_set_nconf(&ctmp, conf);
1640Sstevel@tonic-gate 		return NCONF_get_string(&ctmp, group, name);
1650Sstevel@tonic-gate 		}
1660Sstevel@tonic-gate 	}
1670Sstevel@tonic-gate 
CONF_get_number(LHASH * conf,const char * group,const char * name)1680Sstevel@tonic-gate long CONF_get_number(LHASH *conf,const char *group,const char *name)
1690Sstevel@tonic-gate 	{
1700Sstevel@tonic-gate 	int status;
1710Sstevel@tonic-gate 	long result = 0;
1720Sstevel@tonic-gate 
1730Sstevel@tonic-gate 	if (conf == NULL)
1740Sstevel@tonic-gate 		{
1750Sstevel@tonic-gate 		status = NCONF_get_number_e(NULL, group, name, &result);
1760Sstevel@tonic-gate 		}
1770Sstevel@tonic-gate 	else
1780Sstevel@tonic-gate 		{
1790Sstevel@tonic-gate 		CONF ctmp;
1800Sstevel@tonic-gate 		CONF_set_nconf(&ctmp, conf);
1810Sstevel@tonic-gate 		status = NCONF_get_number_e(&ctmp, group, name, &result);
1820Sstevel@tonic-gate 		}
1830Sstevel@tonic-gate 
1840Sstevel@tonic-gate 	if (status == 0)
1850Sstevel@tonic-gate 		{
1860Sstevel@tonic-gate 		/* This function does not believe in errors... */
187*2139Sjp161948 		ERR_clear_error();
1880Sstevel@tonic-gate 		}
1890Sstevel@tonic-gate 	return result;
1900Sstevel@tonic-gate 	}
1910Sstevel@tonic-gate 
CONF_free(LHASH * conf)1920Sstevel@tonic-gate void CONF_free(LHASH *conf)
1930Sstevel@tonic-gate 	{
1940Sstevel@tonic-gate 	CONF ctmp;
1950Sstevel@tonic-gate 	CONF_set_nconf(&ctmp, conf);
1960Sstevel@tonic-gate 	NCONF_free_data(&ctmp);
1970Sstevel@tonic-gate 	}
1980Sstevel@tonic-gate 
1990Sstevel@tonic-gate #ifndef OPENSSL_NO_FP_API
CONF_dump_fp(LHASH * conf,FILE * out)2000Sstevel@tonic-gate int CONF_dump_fp(LHASH *conf, FILE *out)
2010Sstevel@tonic-gate 	{
2020Sstevel@tonic-gate 	BIO *btmp;
2030Sstevel@tonic-gate 	int ret;
2040Sstevel@tonic-gate 
2050Sstevel@tonic-gate 	if(!(btmp = BIO_new_fp(out, BIO_NOCLOSE))) {
2060Sstevel@tonic-gate 		CONFerr(CONF_F_CONF_DUMP_FP,ERR_R_BUF_LIB);
2070Sstevel@tonic-gate 		return 0;
2080Sstevel@tonic-gate 	}
2090Sstevel@tonic-gate 	ret = CONF_dump_bio(conf, btmp);
2100Sstevel@tonic-gate 	BIO_free(btmp);
2110Sstevel@tonic-gate 	return ret;
2120Sstevel@tonic-gate 	}
2130Sstevel@tonic-gate #endif
2140Sstevel@tonic-gate 
CONF_dump_bio(LHASH * conf,BIO * out)2150Sstevel@tonic-gate int CONF_dump_bio(LHASH *conf, BIO *out)
2160Sstevel@tonic-gate 	{
2170Sstevel@tonic-gate 	CONF ctmp;
2180Sstevel@tonic-gate 	CONF_set_nconf(&ctmp, conf);
2190Sstevel@tonic-gate 	return NCONF_dump_bio(&ctmp, out);
2200Sstevel@tonic-gate 	}
2210Sstevel@tonic-gate 
2220Sstevel@tonic-gate /* The following section contains the "New CONF" functions.  They are
2230Sstevel@tonic-gate    completely centralised around a new CONF structure that may contain
2240Sstevel@tonic-gate    basically anything, but at least a method pointer and a table of data.
2250Sstevel@tonic-gate    These functions are also written in terms of the bridge functions used
2260Sstevel@tonic-gate    by the "CONF classic" functions, for consistency.  */
2270Sstevel@tonic-gate 
NCONF_new(CONF_METHOD * meth)2280Sstevel@tonic-gate CONF *NCONF_new(CONF_METHOD *meth)
2290Sstevel@tonic-gate 	{
2300Sstevel@tonic-gate 	CONF *ret;
2310Sstevel@tonic-gate 
2320Sstevel@tonic-gate 	if (meth == NULL)
2330Sstevel@tonic-gate 		meth = NCONF_default();
2340Sstevel@tonic-gate 
2350Sstevel@tonic-gate 	ret = meth->create(meth);
2360Sstevel@tonic-gate 	if (ret == NULL)
2370Sstevel@tonic-gate 		{
2380Sstevel@tonic-gate 		CONFerr(CONF_F_NCONF_NEW,ERR_R_MALLOC_FAILURE);
2390Sstevel@tonic-gate 		return(NULL);
2400Sstevel@tonic-gate 		}
2410Sstevel@tonic-gate 
2420Sstevel@tonic-gate 	return ret;
2430Sstevel@tonic-gate 	}
2440Sstevel@tonic-gate 
NCONF_free(CONF * conf)2450Sstevel@tonic-gate void NCONF_free(CONF *conf)
2460Sstevel@tonic-gate 	{
2470Sstevel@tonic-gate 	if (conf == NULL)
2480Sstevel@tonic-gate 		return;
2490Sstevel@tonic-gate 	conf->meth->destroy(conf);
2500Sstevel@tonic-gate 	}
2510Sstevel@tonic-gate 
NCONF_free_data(CONF * conf)2520Sstevel@tonic-gate void NCONF_free_data(CONF *conf)
2530Sstevel@tonic-gate 	{
2540Sstevel@tonic-gate 	if (conf == NULL)
2550Sstevel@tonic-gate 		return;
2560Sstevel@tonic-gate 	conf->meth->destroy_data(conf);
2570Sstevel@tonic-gate 	}
2580Sstevel@tonic-gate 
NCONF_load(CONF * conf,const char * file,long * eline)2590Sstevel@tonic-gate int NCONF_load(CONF *conf, const char *file, long *eline)
2600Sstevel@tonic-gate 	{
2610Sstevel@tonic-gate 	if (conf == NULL)
2620Sstevel@tonic-gate 		{
2630Sstevel@tonic-gate 		CONFerr(CONF_F_NCONF_LOAD,CONF_R_NO_CONF);
2640Sstevel@tonic-gate 		return 0;
2650Sstevel@tonic-gate 		}
2660Sstevel@tonic-gate 
2670Sstevel@tonic-gate 	return conf->meth->load(conf, file, eline);
2680Sstevel@tonic-gate 	}
2690Sstevel@tonic-gate 
2700Sstevel@tonic-gate #ifndef OPENSSL_NO_FP_API
NCONF_load_fp(CONF * conf,FILE * fp,long * eline)2710Sstevel@tonic-gate int NCONF_load_fp(CONF *conf, FILE *fp,long *eline)
2720Sstevel@tonic-gate 	{
2730Sstevel@tonic-gate 	BIO *btmp;
2740Sstevel@tonic-gate 	int ret;
2750Sstevel@tonic-gate 	if(!(btmp = BIO_new_fp(fp, BIO_NOCLOSE)))
2760Sstevel@tonic-gate 		{
2770Sstevel@tonic-gate 		CONFerr(CONF_F_NCONF_LOAD_FP,ERR_R_BUF_LIB);
2780Sstevel@tonic-gate 		return 0;
2790Sstevel@tonic-gate 		}
2800Sstevel@tonic-gate 	ret = NCONF_load_bio(conf, btmp, eline);
2810Sstevel@tonic-gate 	BIO_free(btmp);
2820Sstevel@tonic-gate 	return ret;
2830Sstevel@tonic-gate 	}
2840Sstevel@tonic-gate #endif
2850Sstevel@tonic-gate 
NCONF_load_bio(CONF * conf,BIO * bp,long * eline)2860Sstevel@tonic-gate int NCONF_load_bio(CONF *conf, BIO *bp,long *eline)
2870Sstevel@tonic-gate 	{
2880Sstevel@tonic-gate 	if (conf == NULL)
2890Sstevel@tonic-gate 		{
2900Sstevel@tonic-gate 		CONFerr(CONF_F_NCONF_LOAD_BIO,CONF_R_NO_CONF);
2910Sstevel@tonic-gate 		return 0;
2920Sstevel@tonic-gate 		}
2930Sstevel@tonic-gate 
2940Sstevel@tonic-gate 	return conf->meth->load_bio(conf, bp, eline);
2950Sstevel@tonic-gate 	}
2960Sstevel@tonic-gate 
STACK_OF(CONF_VALUE)2970Sstevel@tonic-gate STACK_OF(CONF_VALUE) *NCONF_get_section(const CONF *conf,const char *section)
2980Sstevel@tonic-gate 	{
2990Sstevel@tonic-gate 	if (conf == NULL)
3000Sstevel@tonic-gate 		{
3010Sstevel@tonic-gate 		CONFerr(CONF_F_NCONF_GET_SECTION,CONF_R_NO_CONF);
3020Sstevel@tonic-gate 		return NULL;
3030Sstevel@tonic-gate 		}
3040Sstevel@tonic-gate 
3050Sstevel@tonic-gate 	if (section == NULL)
3060Sstevel@tonic-gate 		{
3070Sstevel@tonic-gate 		CONFerr(CONF_F_NCONF_GET_SECTION,CONF_R_NO_SECTION);
3080Sstevel@tonic-gate 		return NULL;
3090Sstevel@tonic-gate 		}
3100Sstevel@tonic-gate 
3110Sstevel@tonic-gate 	return _CONF_get_section_values(conf, section);
3120Sstevel@tonic-gate 	}
3130Sstevel@tonic-gate 
NCONF_get_string(const CONF * conf,const char * group,const char * name)3140Sstevel@tonic-gate char *NCONF_get_string(const CONF *conf,const char *group,const char *name)
3150Sstevel@tonic-gate 	{
3160Sstevel@tonic-gate 	char *s = _CONF_get_string(conf, group, name);
3170Sstevel@tonic-gate 
3180Sstevel@tonic-gate         /* Since we may get a value from an environment variable even
3190Sstevel@tonic-gate            if conf is NULL, let's check the value first */
3200Sstevel@tonic-gate         if (s) return s;
3210Sstevel@tonic-gate 
3220Sstevel@tonic-gate 	if (conf == NULL)
3230Sstevel@tonic-gate 		{
3240Sstevel@tonic-gate 		CONFerr(CONF_F_NCONF_GET_STRING,
3250Sstevel@tonic-gate                         CONF_R_NO_CONF_OR_ENVIRONMENT_VARIABLE);
3260Sstevel@tonic-gate 		return NULL;
3270Sstevel@tonic-gate 		}
3280Sstevel@tonic-gate 	CONFerr(CONF_F_NCONF_GET_STRING,
3290Sstevel@tonic-gate 		CONF_R_NO_VALUE);
3300Sstevel@tonic-gate 	ERR_add_error_data(4,"group=",group," name=",name);
3310Sstevel@tonic-gate 	return NULL;
3320Sstevel@tonic-gate 	}
3330Sstevel@tonic-gate 
NCONF_get_number_e(const CONF * conf,const char * group,const char * name,long * result)3340Sstevel@tonic-gate int NCONF_get_number_e(const CONF *conf,const char *group,const char *name,
3350Sstevel@tonic-gate 		       long *result)
3360Sstevel@tonic-gate 	{
3370Sstevel@tonic-gate 	char *str;
3380Sstevel@tonic-gate 
3390Sstevel@tonic-gate 	if (result == NULL)
3400Sstevel@tonic-gate 		{
3410Sstevel@tonic-gate 		CONFerr(CONF_F_NCONF_GET_NUMBER_E,ERR_R_PASSED_NULL_PARAMETER);
3420Sstevel@tonic-gate 		return 0;
3430Sstevel@tonic-gate 		}
3440Sstevel@tonic-gate 
3450Sstevel@tonic-gate 	str = NCONF_get_string(conf,group,name);
3460Sstevel@tonic-gate 
3470Sstevel@tonic-gate 	if (str == NULL)
3480Sstevel@tonic-gate 		return 0;
3490Sstevel@tonic-gate 
3500Sstevel@tonic-gate 	for (*result = 0;conf->meth->is_number(conf, *str);)
3510Sstevel@tonic-gate 		{
3520Sstevel@tonic-gate 		*result = (*result)*10 + conf->meth->to_int(conf, *str);
3530Sstevel@tonic-gate 		str++;
3540Sstevel@tonic-gate 		}
3550Sstevel@tonic-gate 
3560Sstevel@tonic-gate 	return 1;
3570Sstevel@tonic-gate 	}
3580Sstevel@tonic-gate 
3590Sstevel@tonic-gate #ifndef OPENSSL_NO_FP_API
NCONF_dump_fp(const CONF * conf,FILE * out)3600Sstevel@tonic-gate int NCONF_dump_fp(const CONF *conf, FILE *out)
3610Sstevel@tonic-gate 	{
3620Sstevel@tonic-gate 	BIO *btmp;
3630Sstevel@tonic-gate 	int ret;
3640Sstevel@tonic-gate 	if(!(btmp = BIO_new_fp(out, BIO_NOCLOSE))) {
3650Sstevel@tonic-gate 		CONFerr(CONF_F_NCONF_DUMP_FP,ERR_R_BUF_LIB);
3660Sstevel@tonic-gate 		return 0;
3670Sstevel@tonic-gate 	}
3680Sstevel@tonic-gate 	ret = NCONF_dump_bio(conf, btmp);
3690Sstevel@tonic-gate 	BIO_free(btmp);
3700Sstevel@tonic-gate 	return ret;
3710Sstevel@tonic-gate 	}
3720Sstevel@tonic-gate #endif
3730Sstevel@tonic-gate 
NCONF_dump_bio(const CONF * conf,BIO * out)3740Sstevel@tonic-gate int NCONF_dump_bio(const CONF *conf, BIO *out)
3750Sstevel@tonic-gate 	{
3760Sstevel@tonic-gate 	if (conf == NULL)
3770Sstevel@tonic-gate 		{
3780Sstevel@tonic-gate 		CONFerr(CONF_F_NCONF_DUMP_BIO,CONF_R_NO_CONF);
3790Sstevel@tonic-gate 		return 0;
3800Sstevel@tonic-gate 		}
3810Sstevel@tonic-gate 
3820Sstevel@tonic-gate 	return conf->meth->dump(conf, out);
3830Sstevel@tonic-gate 	}
3840Sstevel@tonic-gate 
3850Sstevel@tonic-gate 
3860Sstevel@tonic-gate /* This function should be avoided */
3870Sstevel@tonic-gate #if 0
3880Sstevel@tonic-gate long NCONF_get_number(CONF *conf,char *group,char *name)
3890Sstevel@tonic-gate 	{
3900Sstevel@tonic-gate 	int status;
3910Sstevel@tonic-gate 	long ret=0;
3920Sstevel@tonic-gate 
3930Sstevel@tonic-gate 	status = NCONF_get_number_e(conf, group, name, &ret);
3940Sstevel@tonic-gate 	if (status == 0)
3950Sstevel@tonic-gate 		{
3960Sstevel@tonic-gate 		/* This function does not believe in errors... */
3970Sstevel@tonic-gate 		ERR_get_error();
3980Sstevel@tonic-gate 		}
3990Sstevel@tonic-gate 	return ret;
4000Sstevel@tonic-gate 	}
4010Sstevel@tonic-gate #endif
402