Have all tests use EXIT() to exit rather than exit(), since the latter doesn't
[openssl.git] / crypto / dso / dso_lib.c
index 364ddbdb37179e7c22acb2f65bca7eeff7be4993..1045d1dd19baecba24eb218cb49c5f460323c7f8 100644 (file)
@@ -1,4 +1,4 @@
-/* dso_lib.c */
+/* dso_lib.c -*- mode:C; c-file-style: "eay" -*- */
 /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL
  * project 2000.
  */
@@ -108,7 +108,7 @@ DSO *DSO_new_method(DSO_METHOD *meth)
                }
        memset(ret, 0, sizeof(DSO));
        ret->meth_data = sk_new_null();
-       if((ret->meth_data = sk_new_null()) == NULL)
+       if(ret->meth_data == NULL)
                {
                /* sk_new doesn't generate any errors so we do */
                DSOerr(DSO_F_DSO_NEW_METHOD,ERR_R_MALLOC_FAILURE);
@@ -179,11 +179,11 @@ int DSO_flags(DSO *dso)
        }
 
 
-int DSO_up(DSO *dso)
+int DSO_up_ref(DSO *dso)
        {
        if (dso == NULL)
                {
-               DSOerr(DSO_F_DSO_UP,ERR_R_PASSED_NULL_PARAMETER);
+               DSOerr(DSO_F_DSO_UP_REF,ERR_R_PASSED_NULL_PARAMETER);
                return(0);
                }
 
@@ -205,6 +205,12 @@ DSO *DSO_load(DSO *dso, const char *filename, DSO_METHOD *meth, int flags)
                        goto err;
                        }
                allocated = 1;
+               /* Pass the provided flags to the new DSO object */
+               if(DSO_ctrl(ret, DSO_CTRL_SET_FLAGS, flags, NULL) < 0)
+                       {
+                       DSOerr(DSO_F_DSO_LOAD,DSO_R_CTRL_FAILED);
+                       goto err;
+                       }
                }
        else
                ret = dso;
@@ -228,13 +234,6 @@ DSO *DSO_load(DSO *dso, const char *filename, DSO_METHOD *meth, int flags)
                DSOerr(DSO_F_DSO_LOAD,DSO_R_NO_FILENAME);
                goto err;
                }
-       /* Bleurgh ... have to check for negative return values for
-        * errors. <grimace> */
-       if(DSO_ctrl(ret, DSO_CTRL_SET_FLAGS, flags, NULL) < 0)
-               {
-               DSOerr(DSO_F_DSO_LOAD,DSO_R_CTRL_FAILED);
-               goto err;
-               }
        if(ret->meth->dso_load == NULL)
                {
                DSOerr(DSO_F_DSO_LOAD,DSO_R_UNSUPPORTED);
@@ -391,6 +390,33 @@ int DSO_set_filename(DSO *dso, const char *filename)
        return(1);
        }
 
+char *DSO_merge(DSO *dso, const char *filespec1, const char *filespec2)
+       {
+       char *result = NULL;
+
+       if(dso == NULL || filespec1 == NULL)
+               {
+               DSOerr(DSO_F_DSO_MERGE,ERR_R_PASSED_NULL_PARAMETER);
+               return(NULL);
+               }
+       if(filespec1 == NULL)
+               filespec1 = dso->filename;
+       if(filespec1 == NULL)
+               {
+               DSOerr(DSO_F_DSO_MERGE,DSO_R_NO_FILE_SPECIFICATION);
+               return(NULL);
+               }
+       if((dso->flags & DSO_FLAG_NO_NAME_TRANSLATION) == 0)
+               {
+               if(dso->merger != NULL)
+                       result = dso->merger(dso, filespec1, filespec2);
+               else if(dso->meth->dso_merger != NULL)
+                       result = dso->meth->dso_merger(dso,
+                               filespec1, filespec2);
+               }
+       return(result);
+       }
+
 char *DSO_convert_filename(DSO *dso, const char *filename)
        {
        char *result = NULL;