EVP constification.
[openssl.git] / crypto / dso / dso_lib.c
index acaac278471d2aa0726e75e7bbab7a5b2606c15a..861f5fb84e906267c60cf6f00d304c55576ae1c5 100644 (file)
@@ -100,7 +100,7 @@ DSO *DSO_new_method(DSO_METHOD *meth)
                 * to stealing the "best available" method. Will fallback
                 * to DSO_METH_null() in the worst case. */
                default_DSO_meth = DSO_METHOD_openssl();
-       ret = (DSO *)Malloc(sizeof(DSO));
+       ret = (DSO *)OPENSSL_malloc(sizeof(DSO));
        if(ret == NULL)
                {
                DSOerr(DSO_F_DSO_NEW_METHOD,ERR_R_MALLOC_FAILURE);
@@ -112,7 +112,7 @@ DSO *DSO_new_method(DSO_METHOD *meth)
                {
                /* sk_new doesn't generate any errors so we do */
                DSOerr(DSO_F_DSO_NEW_METHOD,ERR_R_MALLOC_FAILURE);
-               Free(ret);
+               OPENSSL_free(ret);
                return(NULL);
                }
        if(meth == NULL)
@@ -122,7 +122,7 @@ DSO *DSO_new_method(DSO_METHOD *meth)
        ret->references = 1;
        if((ret->meth->init != NULL) && !ret->meth->init(ret))
                {
-               Free(ret);
+               OPENSSL_free(ret);
                ret=NULL;
                }
        return(ret);
@@ -165,7 +165,7 @@ int DSO_free(DSO *dso)
        
        sk_free(dso->meth_data);
  
-       Free(dso);
+       OPENSSL_free(dso);
        return(1);
        }
 
@@ -187,7 +187,7 @@ int DSO_up(DSO *dso)
        return(1);
        }
 
-DSO *DSO_load(DSO *dso, char *filename, DSO_METHOD *meth)
+DSO *DSO_load(DSO *dso, const char *filename, DSO_METHOD *meth, int flags)
        {
        DSO *ret;
        int allocated = 0;
@@ -209,6 +209,15 @@ DSO *DSO_load(DSO *dso, char *filename, DSO_METHOD *meth)
                }
        else
                ret = dso;
+       /* 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);
+               if(allocated)
+                       DSO_free(ret);
+               return(NULL);
+               }
        if(ret->meth->dso_load == NULL)
                {
                DSOerr(DSO_F_DSO_LOAD,DSO_R_UNSUPPORTED);
@@ -227,7 +236,7 @@ DSO *DSO_load(DSO *dso, char *filename, DSO_METHOD *meth)
        return(ret);
        }
 
-void *DSO_bind(DSO *dso, char *symname)
+void *DSO_bind(DSO *dso, const char *symname)
        {
        void *ret = NULL;
 
@@ -249,3 +258,26 @@ void *DSO_bind(DSO *dso, char *symname)
        /* Success */
        return(ret);
        }
+
+/* I don't really like these *_ctrl functions very much to be perfectly
+ * honest. For one thing, I think I have to return a negative value for
+ * any error because possible DSO_ctrl() commands may return values
+ * such as "size"s that can legitimately be zero (making the standard
+ * "if(DSO_cmd(...))" form that works almost everywhere else fail at
+ * odd times. I'd prefer "output" values to be passed by reference and
+ * the return value as success/failure like usual ... but we conform
+ * when we must... :-) */
+long DSO_ctrl(DSO *dso, int cmd, long larg, void *parg)
+       {
+       if(dso == NULL)
+               {
+               DSOerr(DSO_F_DSO_CTRL,ERR_R_PASSED_NULL_PARAMETER);
+               return(-1);
+               }
+       if((dso->meth == NULL) || (dso->meth->dso_ctrl == NULL))
+               {
+               DSOerr(DSO_F_DSO_CTRL,DSO_R_UNSUPPORTED);
+               return(-1);
+               }
+       return(dso->meth->dso_ctrl(dso,cmd,larg,parg));
+       }