STACK_OF(CONF_VALUE) *CONF_get_section(LHASH *conf,char *section)
{
- CONF ctmp;
+ if (conf == NULL)
+ {
+ return NULL;
+ }
+ else
+ {
+ CONF ctmp;
- if (default_CONF_method == NULL)
- default_CONF_method = NCONF_default();
+ if (default_CONF_method == NULL)
+ default_CONF_method = NCONF_default();
- default_CONF_method->init(&ctmp);
- ctmp.data = conf;
- return NCONF_get_section(&ctmp, section);
+ default_CONF_method->init(&ctmp);
+ ctmp.data = conf;
+ return NCONF_get_section(&ctmp, section);
+ }
}
char *CONF_get_string(LHASH *conf,char *group,char *name)
{
- CONF ctmp;
+ if (conf == NULL)
+ {
+ return NCONF_get_string(NULL, group, name);
+ }
+ else
+ {
+ CONF ctmp;
- if (default_CONF_method == NULL)
- default_CONF_method = NCONF_default();
+ if (default_CONF_method == NULL)
+ default_CONF_method = NCONF_default();
- default_CONF_method->init(&ctmp);
- ctmp.data = conf;
- return NCONF_get_string(&ctmp, group, name);
+ default_CONF_method->init(&ctmp);
+ ctmp.data = conf;
+ return NCONF_get_string(&ctmp, group, name);
+ }
}
long CONF_get_number(LHASH *conf,char *group,char *name)
{
- CONF ctmp;
- int status;
- long result = 0;
+ if (conf == NULL)
+ {
+ return NCONF_get_number(NULL, group, name);
+ }
+ else
+ {
+ CONF ctmp;
- if (default_CONF_method == NULL)
- default_CONF_method = NCONF_default();
+ if (default_CONF_method == NULL)
+ default_CONF_method = NCONF_default();
- default_CONF_method->init(&ctmp);
- ctmp.data = conf;
- status = NCONF_get_number_e(&ctmp, group, name, &result);
- if (status == 0)
- {
- /* This function does not believe in errors... */
- ERR_get_error();
+ default_CONF_method->init(&ctmp);
+ ctmp.data = conf;
+ return NCONF_get_number(&ctmp, group, name);
}
- return result;
}
void CONF_free(LHASH *conf)
int NCONF_load(CONF *conf, const char *file, long *eline)
{
- if (conf == NULL)
+ int ret;
+ BIO *in=NULL;
+
+#ifdef VMS
+ in=BIO_new_file(file, "r");
+#else
+ in=BIO_new_file(file, "rb");
+#endif
+ if (in == NULL)
{
- CONFerr(CONF_F_NCONF_LOAD,CONF_R_NO_CONF);
+ CONFerr(CONF_F_CONF_LOAD,ERR_R_SYS_LIB);
return 0;
}
- return conf->meth->load(conf, file, eline);
+ ret = NCONF_load_bio(conf, in, eline);
+ BIO_free(in);
+
+ return ret;
}
#ifndef NO_FP_API
int ret;
if(!(btmp = BIO_new_fp(fp, BIO_NOCLOSE)))
{
- CONFerr(CONF_F_NCONF_LOAD_FP,ERR_R_BUF_LIB);
+ CONFerr(CONF_F_CONF_LOAD_FP,ERR_R_BUF_LIB);
return 0;
}
ret = NCONF_load_bio(conf, btmp, eline);
return 0;
}
- return conf->meth->load_bio(conf, bp, eline);
+ return conf->meth->load(conf, bp, eline);
}
STACK_OF(CONF_VALUE) *NCONF_get_section(CONF *conf,char *section)
CONF_R_NO_CONF_OR_ENVIRONMENT_VARIABLE);
return NULL;
}
- CONFerr(CONF_F_NCONF_GET_STRING,
- CONF_R_NO_VALUE);
return NULL;
}
-int NCONF_get_number_e(CONF *conf,char *group,char *name,long *result)
+long NCONF_get_number(CONF *conf,char *group,char *name)
{
- char *str;
-
- if (result == NULL)
+#if 0 /* As with _CONF_get_string(), we rely on the possibility of finding
+ an environment variable with a suitable name. Unfortunately, there's
+ no way with the current API to see if we found one or not...
+ The meaning of this is that if a number is not found anywhere, it
+ will always default to 0. */
+ if (conf == NULL)
{
- CONFerr(CONF_F_NCONF_GET_NUMBER_E,ERR_R_PASSED_NULL_PARAMETER);
- return 0;
- }
-
- str = NCONF_get_string(conf,group,name);
-
- if (str == NULL)
+ CONFerr(CONF_F_NCONF_GET_NUMBER,
+ CONF_R_NO_CONF_OR_ENVIRONMENT_VARIABLE);
return 0;
-
- for (;conf->meth->is_number(conf, *str);)
- {
- *result = (*result)*10 + conf->meth->to_int(conf, *str);
- str++;
}
-
- return 1;
+#endif
+
+ return _CONF_get_number(conf, group, name);
}
#ifndef NO_FP_API
return conf->meth->dump(conf, out);
}
-/* This function should be avoided */
-#undef NCONF_get_number
-long NCONF_get_number(CONF *conf,char *group,char *name)
- {
- int status;
- long ret=0;
-
- status = NCONF_get_number_e(conf, group, name, &ret);
- if (status == 0)
- {
- /* This function does not believe in errors... */
- ERR_get_error();
- }
- return ret;
- }
-