Further BUILDENV refinement, further fool-proofing of Makefiles and
[openssl.git] / crypto / bio / b_sock.c
index c5010080281a408e3eb3ccf4ee84e5bf767c09c5..268517fdc3d79d8b8ab35b9e706033c49fa3e262 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
        }
 
@@ -709,12 +740,12 @@ int BIO_accept(int sock, char **addr)
                        }
                *addr=p;
                }
-       sprintf(*addr,"%d.%d.%d.%d:%d",
-               (unsigned char)(l>>24L)&0xff,
-               (unsigned char)(l>>16L)&0xff,
-               (unsigned char)(l>> 8L)&0xff,
-               (unsigned char)(l     )&0xff,
-               port);
+       BIO_snprintf(*addr,24,"%d.%d.%d.%d:%d",
+                    (unsigned char)(l>>24L)&0xff,
+                    (unsigned char)(l>>16L)&0xff,
+                    (unsigned char)(l>> 8L)&0xff,
+                    (unsigned char)(l     )&0xff,
+                    port);
 end:
        return(ret);
        }