Netware-specific changes,
[openssl.git] / crypto / bio / b_sock.c
index c5010080281a408e3eb3ccf4ee84e5bf767c09c5..d619bcf995610681e852607a7b6b23992fb03b54 100644 (file)
@@ -79,7 +79,7 @@
 #define MAX_LISTEN  32
 #endif
 
-#ifdef OPENSSL_SYS_WINDOWS
+#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_NETWARE)
 static int wsa_init_done=0;
 #endif
 
@@ -473,6 +473,31 @@ int BIO_sock_init(void)
        if (sock_init())
                return (-1);
 #endif
+
+#if defined(OPENSSL_SYS_NETWARE)
+    WORD wVerReq;
+    WSADATA wsaData;
+    int err;
+
+    if (!wsa_init_done)
+    {
+   
+# ifdef SIGINT
+        signal(SIGINT,(void (*)(int))BIO_sock_cleanup);
+# endif
+
+        wsa_init_done=1;
+        wVerReq = MAKEWORD( 2, 0 );
+        err = WSAStartup(wVerReq,&wsaData);
+        if (err != 0)
+        {
+            SYSerr(SYS_F_WSASTARTUP,err);
+            BIOerr(BIO_F_BIO_SOCK_INIT,BIO_R_WSASTARTUP);
+            return(-1);
+                       }
+               }
+#endif
+
        return(1);
        }
 
@@ -487,6 +512,12 @@ void BIO_sock_cleanup(void)
 #endif
                WSACleanup();
                }
+#elif defined(OPENSSL_SYS_NETWARE)
+   if (wsa_init_done)
+        {
+        wsa_init_done=0;
+        WSACleanup();
+               }
 #endif
        }