xref: /onnv-gate/usr/src/common/openssl/crypto/conf/conf_lib.c (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /* conf_lib.c */
2*0Sstevel@tonic-gate /* Written by Richard Levitte (richard@levitte.org) for the OpenSSL
3*0Sstevel@tonic-gate  * project 2000.
4*0Sstevel@tonic-gate  */
5*0Sstevel@tonic-gate /* ====================================================================
6*0Sstevel@tonic-gate  * Copyright (c) 2000 The OpenSSL Project.  All rights reserved.
7*0Sstevel@tonic-gate  *
8*0Sstevel@tonic-gate  * Redistribution and use in source and binary forms, with or without
9*0Sstevel@tonic-gate  * modification, are permitted provided that the following conditions
10*0Sstevel@tonic-gate  * are met:
11*0Sstevel@tonic-gate  *
12*0Sstevel@tonic-gate  * 1. Redistributions of source code must retain the above copyright
13*0Sstevel@tonic-gate  *    notice, this list of conditions and the following disclaimer.
14*0Sstevel@tonic-gate  *
15*0Sstevel@tonic-gate  * 2. Redistributions in binary form must reproduce the above copyright
16*0Sstevel@tonic-gate  *    notice, this list of conditions and the following disclaimer in
17*0Sstevel@tonic-gate  *    the documentation and/or other materials provided with the
18*0Sstevel@tonic-gate  *    distribution.
19*0Sstevel@tonic-gate  *
20*0Sstevel@tonic-gate  * 3. All advertising materials mentioning features or use of this
21*0Sstevel@tonic-gate  *    software must display the following acknowledgment:
22*0Sstevel@tonic-gate  *    "This product includes software developed by the OpenSSL Project
23*0Sstevel@tonic-gate  *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
24*0Sstevel@tonic-gate  *
25*0Sstevel@tonic-gate  * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26*0Sstevel@tonic-gate  *    endorse or promote products derived from this software without
27*0Sstevel@tonic-gate  *    prior written permission. For written permission, please contact
28*0Sstevel@tonic-gate  *    licensing@OpenSSL.org.
29*0Sstevel@tonic-gate  *
30*0Sstevel@tonic-gate  * 5. Products derived from this software may not be called "OpenSSL"
31*0Sstevel@tonic-gate  *    nor may "OpenSSL" appear in their names without prior written
32*0Sstevel@tonic-gate  *    permission of the OpenSSL Project.
33*0Sstevel@tonic-gate  *
34*0Sstevel@tonic-gate  * 6. Redistributions of any form whatsoever must retain the following
35*0Sstevel@tonic-gate  *    acknowledgment:
36*0Sstevel@tonic-gate  *    "This product includes software developed by the OpenSSL Project
37*0Sstevel@tonic-gate  *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
38*0Sstevel@tonic-gate  *
39*0Sstevel@tonic-gate  * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40*0Sstevel@tonic-gate  * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41*0Sstevel@tonic-gate  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42*0Sstevel@tonic-gate  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
43*0Sstevel@tonic-gate  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44*0Sstevel@tonic-gate  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45*0Sstevel@tonic-gate  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46*0Sstevel@tonic-gate  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47*0Sstevel@tonic-gate  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48*0Sstevel@tonic-gate  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49*0Sstevel@tonic-gate  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50*0Sstevel@tonic-gate  * OF THE POSSIBILITY OF SUCH DAMAGE.
51*0Sstevel@tonic-gate  * ====================================================================
52*0Sstevel@tonic-gate  *
53*0Sstevel@tonic-gate  * This product includes cryptographic software written by Eric Young
54*0Sstevel@tonic-gate  * (eay@cryptsoft.com).  This product includes software written by Tim
55*0Sstevel@tonic-gate  * Hudson (tjh@cryptsoft.com).
56*0Sstevel@tonic-gate  *
57*0Sstevel@tonic-gate  */
58*0Sstevel@tonic-gate 
59*0Sstevel@tonic-gate #include <stdio.h>
60*0Sstevel@tonic-gate #include <openssl/crypto.h>
61*0Sstevel@tonic-gate #include <openssl/err.h>
62*0Sstevel@tonic-gate #include <openssl/conf.h>
63*0Sstevel@tonic-gate #include <openssl/conf_api.h>
64*0Sstevel@tonic-gate #include <openssl/lhash.h>
65*0Sstevel@tonic-gate 
66*0Sstevel@tonic-gate const char *CONF_version="CONF" OPENSSL_VERSION_PTEXT;
67*0Sstevel@tonic-gate 
68*0Sstevel@tonic-gate static CONF_METHOD *default_CONF_method=NULL;
69*0Sstevel@tonic-gate 
70*0Sstevel@tonic-gate /* Init a 'CONF' structure from an old LHASH */
71*0Sstevel@tonic-gate 
72*0Sstevel@tonic-gate void CONF_set_nconf(CONF *conf, LHASH *hash)
73*0Sstevel@tonic-gate 	{
74*0Sstevel@tonic-gate 	if (default_CONF_method == NULL)
75*0Sstevel@tonic-gate 		default_CONF_method = NCONF_default();
76*0Sstevel@tonic-gate 
77*0Sstevel@tonic-gate 	default_CONF_method->init(conf);
78*0Sstevel@tonic-gate 	conf->data = hash;
79*0Sstevel@tonic-gate 	}
80*0Sstevel@tonic-gate 
81*0Sstevel@tonic-gate /* The following section contains the "CONF classic" functions,
82*0Sstevel@tonic-gate    rewritten in terms of the new CONF interface. */
83*0Sstevel@tonic-gate 
84*0Sstevel@tonic-gate int CONF_set_default_method(CONF_METHOD *meth)
85*0Sstevel@tonic-gate 	{
86*0Sstevel@tonic-gate 	default_CONF_method = meth;
87*0Sstevel@tonic-gate 	return 1;
88*0Sstevel@tonic-gate 	}
89*0Sstevel@tonic-gate 
90*0Sstevel@tonic-gate LHASH *CONF_load(LHASH *conf, const char *file, long *eline)
91*0Sstevel@tonic-gate 	{
92*0Sstevel@tonic-gate 	LHASH *ltmp;
93*0Sstevel@tonic-gate 	BIO *in=NULL;
94*0Sstevel@tonic-gate 
95*0Sstevel@tonic-gate #ifdef OPENSSL_SYS_VMS
96*0Sstevel@tonic-gate 	in=BIO_new_file(file, "r");
97*0Sstevel@tonic-gate #else
98*0Sstevel@tonic-gate 	in=BIO_new_file(file, "rb");
99*0Sstevel@tonic-gate #endif
100*0Sstevel@tonic-gate 	if (in == NULL)
101*0Sstevel@tonic-gate 		{
102*0Sstevel@tonic-gate 		CONFerr(CONF_F_CONF_LOAD,ERR_R_SYS_LIB);
103*0Sstevel@tonic-gate 		return NULL;
104*0Sstevel@tonic-gate 		}
105*0Sstevel@tonic-gate 
106*0Sstevel@tonic-gate 	ltmp = CONF_load_bio(conf, in, eline);
107*0Sstevel@tonic-gate 	BIO_free(in);
108*0Sstevel@tonic-gate 
109*0Sstevel@tonic-gate 	return ltmp;
110*0Sstevel@tonic-gate 	}
111*0Sstevel@tonic-gate 
112*0Sstevel@tonic-gate #ifndef OPENSSL_NO_FP_API
113*0Sstevel@tonic-gate LHASH *CONF_load_fp(LHASH *conf, FILE *fp,long *eline)
114*0Sstevel@tonic-gate 	{
115*0Sstevel@tonic-gate 	BIO *btmp;
116*0Sstevel@tonic-gate 	LHASH *ltmp;
117*0Sstevel@tonic-gate 	if(!(btmp = BIO_new_fp(fp, BIO_NOCLOSE))) {
118*0Sstevel@tonic-gate 		CONFerr(CONF_F_CONF_LOAD_FP,ERR_R_BUF_LIB);
119*0Sstevel@tonic-gate 		return NULL;
120*0Sstevel@tonic-gate 	}
121*0Sstevel@tonic-gate 	ltmp = CONF_load_bio(conf, btmp, eline);
122*0Sstevel@tonic-gate 	BIO_free(btmp);
123*0Sstevel@tonic-gate 	return ltmp;
124*0Sstevel@tonic-gate 	}
125*0Sstevel@tonic-gate #endif
126*0Sstevel@tonic-gate 
127*0Sstevel@tonic-gate LHASH *CONF_load_bio(LHASH *conf, BIO *bp,long *eline)
128*0Sstevel@tonic-gate 	{
129*0Sstevel@tonic-gate 	CONF ctmp;
130*0Sstevel@tonic-gate 	int ret;
131*0Sstevel@tonic-gate 
132*0Sstevel@tonic-gate 	CONF_set_nconf(&ctmp, conf);
133*0Sstevel@tonic-gate 
134*0Sstevel@tonic-gate 	ret = NCONF_load_bio(&ctmp, bp, eline);
135*0Sstevel@tonic-gate 	if (ret)
136*0Sstevel@tonic-gate 		return ctmp.data;
137*0Sstevel@tonic-gate 	return NULL;
138*0Sstevel@tonic-gate 	}
139*0Sstevel@tonic-gate 
140*0Sstevel@tonic-gate STACK_OF(CONF_VALUE) *CONF_get_section(LHASH *conf,const char *section)
141*0Sstevel@tonic-gate 	{
142*0Sstevel@tonic-gate 	if (conf == NULL)
143*0Sstevel@tonic-gate 		{
144*0Sstevel@tonic-gate 		return NULL;
145*0Sstevel@tonic-gate 		}
146*0Sstevel@tonic-gate 	else
147*0Sstevel@tonic-gate 		{
148*0Sstevel@tonic-gate 		CONF ctmp;
149*0Sstevel@tonic-gate 		CONF_set_nconf(&ctmp, conf);
150*0Sstevel@tonic-gate 		return NCONF_get_section(&ctmp, section);
151*0Sstevel@tonic-gate 		}
152*0Sstevel@tonic-gate 	}
153*0Sstevel@tonic-gate 
154*0Sstevel@tonic-gate char *CONF_get_string(LHASH *conf,const char *group,const char *name)
155*0Sstevel@tonic-gate 	{
156*0Sstevel@tonic-gate 	if (conf == NULL)
157*0Sstevel@tonic-gate 		{
158*0Sstevel@tonic-gate 		return NCONF_get_string(NULL, group, name);
159*0Sstevel@tonic-gate 		}
160*0Sstevel@tonic-gate 	else
161*0Sstevel@tonic-gate 		{
162*0Sstevel@tonic-gate 		CONF ctmp;
163*0Sstevel@tonic-gate 		CONF_set_nconf(&ctmp, conf);
164*0Sstevel@tonic-gate 		return NCONF_get_string(&ctmp, group, name);
165*0Sstevel@tonic-gate 		}
166*0Sstevel@tonic-gate 	}
167*0Sstevel@tonic-gate 
168*0Sstevel@tonic-gate long CONF_get_number(LHASH *conf,const char *group,const char *name)
169*0Sstevel@tonic-gate 	{
170*0Sstevel@tonic-gate 	int status;
171*0Sstevel@tonic-gate 	long result = 0;
172*0Sstevel@tonic-gate 
173*0Sstevel@tonic-gate 	if (conf == NULL)
174*0Sstevel@tonic-gate 		{
175*0Sstevel@tonic-gate 		status = NCONF_get_number_e(NULL, group, name, &result);
176*0Sstevel@tonic-gate 		}
177*0Sstevel@tonic-gate 	else
178*0Sstevel@tonic-gate 		{
179*0Sstevel@tonic-gate 		CONF ctmp;
180*0Sstevel@tonic-gate 		CONF_set_nconf(&ctmp, conf);
181*0Sstevel@tonic-gate 		status = NCONF_get_number_e(&ctmp, group, name, &result);
182*0Sstevel@tonic-gate 		}
183*0Sstevel@tonic-gate 
184*0Sstevel@tonic-gate 	if (status == 0)
185*0Sstevel@tonic-gate 		{
186*0Sstevel@tonic-gate 		/* This function does not believe in errors... */
187*0Sstevel@tonic-gate 		ERR_get_error();
188*0Sstevel@tonic-gate 		}
189*0Sstevel@tonic-gate 	return result;
190*0Sstevel@tonic-gate 	}
191*0Sstevel@tonic-gate 
192*0Sstevel@tonic-gate void CONF_free(LHASH *conf)
193*0Sstevel@tonic-gate 	{
194*0Sstevel@tonic-gate 	CONF ctmp;
195*0Sstevel@tonic-gate 	CONF_set_nconf(&ctmp, conf);
196*0Sstevel@tonic-gate 	NCONF_free_data(&ctmp);
197*0Sstevel@tonic-gate 	}
198*0Sstevel@tonic-gate 
199*0Sstevel@tonic-gate #ifndef OPENSSL_NO_FP_API
200*0Sstevel@tonic-gate int CONF_dump_fp(LHASH *conf, FILE *out)
201*0Sstevel@tonic-gate 	{
202*0Sstevel@tonic-gate 	BIO *btmp;
203*0Sstevel@tonic-gate 	int ret;
204*0Sstevel@tonic-gate 
205*0Sstevel@tonic-gate 	if(!(btmp = BIO_new_fp(out, BIO_NOCLOSE))) {
206*0Sstevel@tonic-gate 		CONFerr(CONF_F_CONF_DUMP_FP,ERR_R_BUF_LIB);
207*0Sstevel@tonic-gate 		return 0;
208*0Sstevel@tonic-gate 	}
209*0Sstevel@tonic-gate 	ret = CONF_dump_bio(conf, btmp);
210*0Sstevel@tonic-gate 	BIO_free(btmp);
211*0Sstevel@tonic-gate 	return ret;
212*0Sstevel@tonic-gate 	}
213*0Sstevel@tonic-gate #endif
214*0Sstevel@tonic-gate 
215*0Sstevel@tonic-gate int CONF_dump_bio(LHASH *conf, BIO *out)
216*0Sstevel@tonic-gate 	{
217*0Sstevel@tonic-gate 	CONF ctmp;
218*0Sstevel@tonic-gate 	CONF_set_nconf(&ctmp, conf);
219*0Sstevel@tonic-gate 	return NCONF_dump_bio(&ctmp, out);
220*0Sstevel@tonic-gate 	}
221*0Sstevel@tonic-gate 
222*0Sstevel@tonic-gate /* The following section contains the "New CONF" functions.  They are
223*0Sstevel@tonic-gate    completely centralised around a new CONF structure that may contain
224*0Sstevel@tonic-gate    basically anything, but at least a method pointer and a table of data.
225*0Sstevel@tonic-gate    These functions are also written in terms of the bridge functions used
226*0Sstevel@tonic-gate    by the "CONF classic" functions, for consistency.  */
227*0Sstevel@tonic-gate 
228*0Sstevel@tonic-gate CONF *NCONF_new(CONF_METHOD *meth)
229*0Sstevel@tonic-gate 	{
230*0Sstevel@tonic-gate 	CONF *ret;
231*0Sstevel@tonic-gate 
232*0Sstevel@tonic-gate 	if (meth == NULL)
233*0Sstevel@tonic-gate 		meth = NCONF_default();
234*0Sstevel@tonic-gate 
235*0Sstevel@tonic-gate 	ret = meth->create(meth);
236*0Sstevel@tonic-gate 	if (ret == NULL)
237*0Sstevel@tonic-gate 		{
238*0Sstevel@tonic-gate 		CONFerr(CONF_F_NCONF_NEW,ERR_R_MALLOC_FAILURE);
239*0Sstevel@tonic-gate 		return(NULL);
240*0Sstevel@tonic-gate 		}
241*0Sstevel@tonic-gate 
242*0Sstevel@tonic-gate 	return ret;
243*0Sstevel@tonic-gate 	}
244*0Sstevel@tonic-gate 
245*0Sstevel@tonic-gate void NCONF_free(CONF *conf)
246*0Sstevel@tonic-gate 	{
247*0Sstevel@tonic-gate 	if (conf == NULL)
248*0Sstevel@tonic-gate 		return;
249*0Sstevel@tonic-gate 	conf->meth->destroy(conf);
250*0Sstevel@tonic-gate 	}
251*0Sstevel@tonic-gate 
252*0Sstevel@tonic-gate void NCONF_free_data(CONF *conf)
253*0Sstevel@tonic-gate 	{
254*0Sstevel@tonic-gate 	if (conf == NULL)
255*0Sstevel@tonic-gate 		return;
256*0Sstevel@tonic-gate 	conf->meth->destroy_data(conf);
257*0Sstevel@tonic-gate 	}
258*0Sstevel@tonic-gate 
259*0Sstevel@tonic-gate int NCONF_load(CONF *conf, const char *file, long *eline)
260*0Sstevel@tonic-gate 	{
261*0Sstevel@tonic-gate 	if (conf == NULL)
262*0Sstevel@tonic-gate 		{
263*0Sstevel@tonic-gate 		CONFerr(CONF_F_NCONF_LOAD,CONF_R_NO_CONF);
264*0Sstevel@tonic-gate 		return 0;
265*0Sstevel@tonic-gate 		}
266*0Sstevel@tonic-gate 
267*0Sstevel@tonic-gate 	return conf->meth->load(conf, file, eline);
268*0Sstevel@tonic-gate 	}
269*0Sstevel@tonic-gate 
270*0Sstevel@tonic-gate #ifndef OPENSSL_NO_FP_API
271*0Sstevel@tonic-gate int NCONF_load_fp(CONF *conf, FILE *fp,long *eline)
272*0Sstevel@tonic-gate 	{
273*0Sstevel@tonic-gate 	BIO *btmp;
274*0Sstevel@tonic-gate 	int ret;
275*0Sstevel@tonic-gate 	if(!(btmp = BIO_new_fp(fp, BIO_NOCLOSE)))
276*0Sstevel@tonic-gate 		{
277*0Sstevel@tonic-gate 		CONFerr(CONF_F_NCONF_LOAD_FP,ERR_R_BUF_LIB);
278*0Sstevel@tonic-gate 		return 0;
279*0Sstevel@tonic-gate 		}
280*0Sstevel@tonic-gate 	ret = NCONF_load_bio(conf, btmp, eline);
281*0Sstevel@tonic-gate 	BIO_free(btmp);
282*0Sstevel@tonic-gate 	return ret;
283*0Sstevel@tonic-gate 	}
284*0Sstevel@tonic-gate #endif
285*0Sstevel@tonic-gate 
286*0Sstevel@tonic-gate int NCONF_load_bio(CONF *conf, BIO *bp,long *eline)
287*0Sstevel@tonic-gate 	{
288*0Sstevel@tonic-gate 	if (conf == NULL)
289*0Sstevel@tonic-gate 		{
290*0Sstevel@tonic-gate 		CONFerr(CONF_F_NCONF_LOAD_BIO,CONF_R_NO_CONF);
291*0Sstevel@tonic-gate 		return 0;
292*0Sstevel@tonic-gate 		}
293*0Sstevel@tonic-gate 
294*0Sstevel@tonic-gate 	return conf->meth->load_bio(conf, bp, eline);
295*0Sstevel@tonic-gate 	}
296*0Sstevel@tonic-gate 
297*0Sstevel@tonic-gate STACK_OF(CONF_VALUE) *NCONF_get_section(const CONF *conf,const char *section)
298*0Sstevel@tonic-gate 	{
299*0Sstevel@tonic-gate 	if (conf == NULL)
300*0Sstevel@tonic-gate 		{
301*0Sstevel@tonic-gate 		CONFerr(CONF_F_NCONF_GET_SECTION,CONF_R_NO_CONF);
302*0Sstevel@tonic-gate 		return NULL;
303*0Sstevel@tonic-gate 		}
304*0Sstevel@tonic-gate 
305*0Sstevel@tonic-gate 	if (section == NULL)
306*0Sstevel@tonic-gate 		{
307*0Sstevel@tonic-gate 		CONFerr(CONF_F_NCONF_GET_SECTION,CONF_R_NO_SECTION);
308*0Sstevel@tonic-gate 		return NULL;
309*0Sstevel@tonic-gate 		}
310*0Sstevel@tonic-gate 
311*0Sstevel@tonic-gate 	return _CONF_get_section_values(conf, section);
312*0Sstevel@tonic-gate 	}
313*0Sstevel@tonic-gate 
314*0Sstevel@tonic-gate char *NCONF_get_string(const CONF *conf,const char *group,const char *name)
315*0Sstevel@tonic-gate 	{
316*0Sstevel@tonic-gate 	char *s = _CONF_get_string(conf, group, name);
317*0Sstevel@tonic-gate 
318*0Sstevel@tonic-gate         /* Since we may get a value from an environment variable even
319*0Sstevel@tonic-gate            if conf is NULL, let's check the value first */
320*0Sstevel@tonic-gate         if (s) return s;
321*0Sstevel@tonic-gate 
322*0Sstevel@tonic-gate 	if (conf == NULL)
323*0Sstevel@tonic-gate 		{
324*0Sstevel@tonic-gate 		CONFerr(CONF_F_NCONF_GET_STRING,
325*0Sstevel@tonic-gate                         CONF_R_NO_CONF_OR_ENVIRONMENT_VARIABLE);
326*0Sstevel@tonic-gate 		return NULL;
327*0Sstevel@tonic-gate 		}
328*0Sstevel@tonic-gate 	CONFerr(CONF_F_NCONF_GET_STRING,
329*0Sstevel@tonic-gate 		CONF_R_NO_VALUE);
330*0Sstevel@tonic-gate 	ERR_add_error_data(4,"group=",group," name=",name);
331*0Sstevel@tonic-gate 	return NULL;
332*0Sstevel@tonic-gate 	}
333*0Sstevel@tonic-gate 
334*0Sstevel@tonic-gate int NCONF_get_number_e(const CONF *conf,const char *group,const char *name,
335*0Sstevel@tonic-gate 		       long *result)
336*0Sstevel@tonic-gate 	{
337*0Sstevel@tonic-gate 	char *str;
338*0Sstevel@tonic-gate 
339*0Sstevel@tonic-gate 	if (result == NULL)
340*0Sstevel@tonic-gate 		{
341*0Sstevel@tonic-gate 		CONFerr(CONF_F_NCONF_GET_NUMBER_E,ERR_R_PASSED_NULL_PARAMETER);
342*0Sstevel@tonic-gate 		return 0;
343*0Sstevel@tonic-gate 		}
344*0Sstevel@tonic-gate 
345*0Sstevel@tonic-gate 	str = NCONF_get_string(conf,group,name);
346*0Sstevel@tonic-gate 
347*0Sstevel@tonic-gate 	if (str == NULL)
348*0Sstevel@tonic-gate 		return 0;
349*0Sstevel@tonic-gate 
350*0Sstevel@tonic-gate 	for (*result = 0;conf->meth->is_number(conf, *str);)
351*0Sstevel@tonic-gate 		{
352*0Sstevel@tonic-gate 		*result = (*result)*10 + conf->meth->to_int(conf, *str);
353*0Sstevel@tonic-gate 		str++;
354*0Sstevel@tonic-gate 		}
355*0Sstevel@tonic-gate 
356*0Sstevel@tonic-gate 	return 1;
357*0Sstevel@tonic-gate 	}
358*0Sstevel@tonic-gate 
359*0Sstevel@tonic-gate #ifndef OPENSSL_NO_FP_API
360*0Sstevel@tonic-gate int NCONF_dump_fp(const CONF *conf, FILE *out)
361*0Sstevel@tonic-gate 	{
362*0Sstevel@tonic-gate 	BIO *btmp;
363*0Sstevel@tonic-gate 	int ret;
364*0Sstevel@tonic-gate 	if(!(btmp = BIO_new_fp(out, BIO_NOCLOSE))) {
365*0Sstevel@tonic-gate 		CONFerr(CONF_F_NCONF_DUMP_FP,ERR_R_BUF_LIB);
366*0Sstevel@tonic-gate 		return 0;
367*0Sstevel@tonic-gate 	}
368*0Sstevel@tonic-gate 	ret = NCONF_dump_bio(conf, btmp);
369*0Sstevel@tonic-gate 	BIO_free(btmp);
370*0Sstevel@tonic-gate 	return ret;
371*0Sstevel@tonic-gate 	}
372*0Sstevel@tonic-gate #endif
373*0Sstevel@tonic-gate 
374*0Sstevel@tonic-gate int NCONF_dump_bio(const CONF *conf, BIO *out)
375*0Sstevel@tonic-gate 	{
376*0Sstevel@tonic-gate 	if (conf == NULL)
377*0Sstevel@tonic-gate 		{
378*0Sstevel@tonic-gate 		CONFerr(CONF_F_NCONF_DUMP_BIO,CONF_R_NO_CONF);
379*0Sstevel@tonic-gate 		return 0;
380*0Sstevel@tonic-gate 		}
381*0Sstevel@tonic-gate 
382*0Sstevel@tonic-gate 	return conf->meth->dump(conf, out);
383*0Sstevel@tonic-gate 	}
384*0Sstevel@tonic-gate 
385*0Sstevel@tonic-gate 
386*0Sstevel@tonic-gate /* This function should be avoided */
387*0Sstevel@tonic-gate #if 0
388*0Sstevel@tonic-gate long NCONF_get_number(CONF *conf,char *group,char *name)
389*0Sstevel@tonic-gate 	{
390*0Sstevel@tonic-gate 	int status;
391*0Sstevel@tonic-gate 	long ret=0;
392*0Sstevel@tonic-gate 
393*0Sstevel@tonic-gate 	status = NCONF_get_number_e(conf, group, name, &ret);
394*0Sstevel@tonic-gate 	if (status == 0)
395*0Sstevel@tonic-gate 		{
396*0Sstevel@tonic-gate 		/* This function does not believe in errors... */
397*0Sstevel@tonic-gate 		ERR_get_error();
398*0Sstevel@tonic-gate 		}
399*0Sstevel@tonic-gate 	return ret;
400*0Sstevel@tonic-gate 	}
401*0Sstevel@tonic-gate #endif
402