Additionally, rename des_encrypt to des_encrypt1 in files that are
[oweals/openssl.git] / crypto / conf / conf_lib.c
index 48803bc186364cbaf64c09721497c5f620ccfab2..11ec6397324db82875174a9a21f6d83ae9555d8b 100644 (file)
@@ -98,7 +98,7 @@ LHASH *CONF_load(LHASH *conf, const char *file, long *eline)
        return ltmp;
        }
 
-#ifndef OPENSSL_NO_FP_API
+#ifndef NO_FP_API
 LHASH *CONF_load_fp(LHASH *conf, FILE *fp,long *eline)
        {
        BIO *btmp;
@@ -169,12 +169,9 @@ char *CONF_get_string(LHASH *conf,char *group,char *name)
 
 long CONF_get_number(LHASH *conf,char *group,char *name)
        {
-       int status;
-       long result = 0;
-
        if (conf == NULL)
                {
-               status = NCONF_get_number_e(NULL, group, name, &result);
+               return NCONF_get_number(NULL, group, name);
                }
        else
                {
@@ -185,15 +182,8 @@ long CONF_get_number(LHASH *conf,char *group,char *name)
 
                default_CONF_method->init(&ctmp);
                ctmp.data = conf;
-               status = NCONF_get_number_e(&ctmp, group, name, &result);
+               return NCONF_get_number(&ctmp, group, name);
                }
-
-       if (status == 0)
-               {
-               /* This function does not believe in errors... */
-               ERR_get_error();
-               }
-       return result;
        }
 
 void CONF_free(LHASH *conf)
@@ -208,7 +198,7 @@ void CONF_free(LHASH *conf)
        NCONF_free_data(&ctmp);
        }
 
-#ifndef OPENSSL_NO_FP_API
+#ifndef NO_FP_API
 int CONF_dump_fp(LHASH *conf, FILE *out)
        {
        BIO *btmp;
@@ -275,23 +265,34 @@ void NCONF_free_data(CONF *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 OPENSSL_NO_FP_API
+#ifndef NO_FP_API
 int NCONF_load_fp(CONF *conf, FILE *fp,long *eline)
        {
        BIO *btmp;
        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);
@@ -308,7 +309,7 @@ int NCONF_load_bio(CONF *conf, BIO *bp,long *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)
@@ -342,36 +343,28 @@ char *NCONF_get_string(CONF *conf,char *group,char *name)
                         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 OPENSSL_NO_FP_API
+#ifndef NO_FP_API
 int NCONF_dump_fp(CONF *conf, FILE *out)
        {
        BIO *btmp;
@@ -397,19 +390,3 @@ int NCONF_dump_bio(CONF *conf, BIO *out)
        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;
-       }
-