Fix more error codes.
[openssl.git] / crypto / dso / dso_win32.c
index 4ce9a5d..e6eaa99 100644 (file)
@@ -61,7 +61,7 @@
 #include "cryptlib.h"
 #include <openssl/dso.h>
 
-#ifndef OPENSSL_SYS_WIN32
+#if !defined(DSO_WIN32)
 DSO_METHOD *DSO_METHOD_win32(void)
        {
        return NULL;
@@ -86,6 +86,8 @@ static char *win32_name_converter(DSO *dso, const char *filename);
 static char *win32_merger(DSO *dso, const char *filespec1,
        const char *filespec2);
 
+static const char *openssl_strnchr(const char *string, int c, size_t len);
+
 static DSO_METHOD dso_meth_win32 = {
        "OpenSSL 'win32' shared library method",
        win32_load,
@@ -258,7 +260,7 @@ struct file_st
        const char *predir; int predirlen;
        const char *dir; int dirlen;
        const char *file; int filelen;
-       }
+       };
 
 static struct file_st *win32_splitter(DSO *dso, const char *filename,
        int assume_last_is_dir)
@@ -269,14 +271,15 @@ static struct file_st *win32_splitter(DSO *dso, const char *filename,
 
        if (!filename)
                {
-               DSOerr(DSO_F_WIN32_MERGER,DSO_R_NO_FILENAME);
-               goto err;
+               DSOerr(DSO_F_WIN32_SPLITTER,DSO_R_NO_FILENAME);
+               /*goto err;*/
+               return(NULL);
                }
 
        result = OPENSSL_malloc(sizeof(struct file_st));
        if(result == NULL)
                {
-               DSOerr(DSO_F_WIN32_MERGER,
+               DSOerr(DSO_F_WIN32_SPLITTER,
                        ERR_R_MALLOC_FAILURE);
                return(NULL);
                }
@@ -300,9 +303,10 @@ static struct file_st *win32_splitter(DSO *dso, const char *filename,
                case ':':
                        if(position != IN_DEVICE)
                                {
-                               DSOerr(DSO_F_WIN32_MERGER,
+                               DSOerr(DSO_F_WIN32_SPLITTER,
                                        DSO_R_INCORRECT_FILE_SYNTAX);
-                               goto err;
+                               /*goto err;*/
+                               return(NULL);
                                }
                        result->device = start;
                        result->devicelen = filename - start;
@@ -354,14 +358,14 @@ static struct file_st *win32_splitter(DSO *dso, const char *filename,
        while(*filename);
 
        if(!result->nodelen) result->node = NULL;
-       if(!result->devicelen) result->devicce = NULL;
+       if(!result->devicelen) result->device = NULL;
        if(!result->dirlen) result->dir = NULL;
        if(!result->filelen) result->file = NULL;
 
        return(result);
        }
 
-static char *win32_joiner(DSO *dso, const file_st *file_split)
+static char *win32_joiner(DSO *dso, const struct file_st *file_split)
        {
        int len = 0, offset = 0;
        char *result = NULL;
@@ -369,7 +373,7 @@ static char *win32_joiner(DSO *dso, const file_st *file_split)
 
        if(!file_split)
                {
-               DSOerr(DSO_F_WIN32_MERGER,
+               DSOerr(DSO_F_WIN32_JOINER,
                                ERR_R_PASSED_NULL_PARAMETER);
                return(NULL);
                }
@@ -397,14 +401,14 @@ static char *win32_joiner(DSO *dso, const file_st *file_split)
 
        if(!len)
                {
-               DSOerr(DSO_F_WIN32_MERGER, DSO_R_EMPTY_FILE_STRUCTURE);
+               DSOerr(DSO_F_WIN32_JOINER, DSO_R_EMPTY_FILE_STRUCTURE);
                return(NULL);
                }
 
        result = OPENSSL_malloc(len + 1);
        if (!result)
                {
-               DSOerr(DSO_F_WIN32_MERGER,
+               DSOerr(DSO_F_WIN32_JOINER,
                        ERR_R_MALLOC_FAILURE);
                return(NULL);
                }
@@ -428,7 +432,7 @@ static char *win32_joiner(DSO *dso, const file_st *file_split)
        start = file_split->predir;
        while(file_split->predirlen > (start - file_split->predir))
                {
-               const char *end = strnchr(start, '/',
+               const char *end = openssl_strnchr(start, '/',
                        file_split->predirlen - (start - file_split->predir));
                if(!end)
                        end = start
@@ -446,7 +450,7 @@ static char *win32_joiner(DSO *dso, const file_st *file_split)
        start = file_split->dir;
        while(file_split->dirlen > (start - file_split->dir))
                {
-               const char *end = strnchr(start, '/',
+               const char *end = openssl_strnchr(start, '/',
                        file_split->dirlen - (start - file_split->dir));
                if(!end)
                        end = start
@@ -577,4 +581,17 @@ static char *win32_name_converter(DSO *dso, const char *filename)
        return(translated);
        }
 
+static const char *openssl_strnchr(const char *string, int c, size_t len)
+       {
+       size_t i;
+       const char *p;
+       for (i = 0, p = string; i < len && *p; i++, p++)
+               {
+               if (*p == c)
+                       return p;
+               }
+       return NULL;
+       }
+
+
 #endif /* OPENSSL_SYS_WIN32 */