New macro BIO_set_shutdown_wr().
[openssl.git] / crypto / bio / bss_sock.c
index 299787aa1dd659347d98fd203049770f6ab6962e..50c6744c0607a213fde9d0c07e0126486df14ecb 100644 (file)
 #include <errno.h>
 #define USE_SOCKETS
 #include "cryptlib.h"
-#include "bio.h"
+#include <openssl/bio.h>
 
 #ifndef BIO_FD
-#ifndef NOPROTO
-static int sock_write(BIO *h,char *buf,int num);
-static int sock_read(BIO *h,char *buf,int size);
-static int sock_puts(BIO *h,char *str);
-static long sock_ctrl(BIO *h,int cmd,long arg1,char *arg2);
+static int sock_write(BIO *h, const char *buf, int num);
+static int sock_read(BIO *h, char *buf, int size);
+static int sock_puts(BIO *h, const char *str);
+static long sock_ctrl(BIO *h, int cmd, long arg1, void *arg2);
 static int sock_new(BIO *h);
 static int sock_free(BIO *data);
 int BIO_sock_should_retry(int s);
-#else
-static int sock_write();
-static int sock_read();
-static int sock_puts();
-static long sock_ctrl();
-static int sock_new();
-static int sock_free();
-int BIO_sock_should_retry();
-#endif
-
 #else
 
-#ifndef NOPROTO
-static int fd_write(BIO *h,char *buf,int num);
-static int fd_read(BIO *h,char *buf,int size);
-static int fd_puts(BIO *h,char *str);
-static long fd_ctrl(BIO *h,int cmd,long arg1,char *arg2);
+static int fd_write(BIO *h, const char *buf, int num);
+static int fd_read(BIO *h, char *buf, int size);
+static int fd_puts(BIO *h, const char *str);
+static long fd_ctrl(BIO *h, int cmd, long arg1, void *arg2);
 static int fd_new(BIO *h);
 static int fd_free(BIO *data);
 int BIO_fd_should_retry(int s);
-#else
-static int fd_write();
-static int fd_read();
-static int fd_puts();
-static long fd_ctrl();
-static int fd_new();
-static int fd_free();
-int BIO_fd_should_retry();
-#endif
 #endif
 
 #ifndef BIO_FD
@@ -116,9 +95,10 @@ static BIO_METHOD methods_sockp=
        sock_ctrl,
        sock_new,
        sock_free,
+       NULL,
        };
 
-BIO_METHOD *BIO_s_socket()
+BIO_METHOD *BIO_s_socket(void)
        {
        return(&methods_sockp);
        }
@@ -133,21 +113,20 @@ static BIO_METHOD methods_fdp=
        fd_ctrl,
        fd_new,
        fd_free,
+       NULL,
        };
 
-BIO_METHOD *BIO_s_fd()
+BIO_METHOD *BIO_s_fd(void)
        {
        return(&methods_fdp);
        }
 #endif
 
 #ifndef BIO_FD
-BIO *BIO_new_socket(fd,close_flag)
+BIO *BIO_new_socket(int fd, int close_flag)
 #else
-BIO *BIO_new_fd(fd,close_flag)
+BIO *BIO_new_fd(int fd,int close_flag)
 #endif
-int fd;
-int close_flag;
        {
        BIO *ret;
 
@@ -162,11 +141,10 @@ int close_flag;
        }
 
 #ifndef BIO_FD
-static int sock_new(bi)
+static int sock_new(BIO *bi)
 #else
-static int fd_new(bi)
+static int fd_new(BIO *bi)
 #endif
-BIO *bi;
        {
        bi->init=0;
        bi->num=0;
@@ -176,11 +154,10 @@ BIO *bi;
        }
 
 #ifndef BIO_FD
-static int sock_free(a)
+static int sock_free(BIO *a)
 #else
-static int fd_free(a)
+static int fd_free(BIO *a)
 #endif
-BIO *a;
        {
        if (a == NULL) return(0);
        if (a->shutdown)
@@ -188,8 +165,7 @@ BIO *a;
                if (a->init)
                        {
 #ifndef BIO_FD
-                       shutdown(a->num,2);
-                       closesocket(a->num);
+                       SHUTDOWN2(a->num);
 #else                  /* BIO_FD */
                        close(a->num);
 #endif
@@ -202,13 +178,10 @@ BIO *a;
        }
        
 #ifndef BIO_FD
-static int sock_read(b,out,outl)
+static int sock_read(BIO *b, char *out, int outl)
 #else
-static int fd_read(b,out,outl)
+static int fd_read(BIO *b, char *out,int outl)
 #endif
-BIO *b;
-char *out;
-int outl;
        {
        int ret=0;
 
@@ -236,13 +209,10 @@ int outl;
        }
 
 #ifndef BIO_FD
-static int sock_write(b,in,inl)
+static int sock_write(BIO *b, const char *in, int inl)
 #else
-static int fd_write(b,in,inl)
+static int fd_write(BIO *b, const char *in, int inl)
 #endif
-BIO *b;
-char *in;
-int inl;
        {
        int ret;
        
@@ -267,14 +237,10 @@ int inl;
        }
 
 #ifndef BIO_FD
-static long sock_ctrl(b,cmd,num,ptr)
+static long sock_ctrl(BIO *b, int cmd, long num, void *ptr)
 #else
-static long fd_ctrl(b,cmd,num,ptr)
+static long fd_ctrl(BIO *b, int cmd, long num, void *ptr)
 #endif
-BIO *b;
-int cmd;
-long num;
-char *ptr;
        {
        long ret=1;
        int *ip;
@@ -340,22 +306,17 @@ char *ptr;
        }
 
 #ifdef undef
-static int sock_gets(bp,buf,size)
-BIO *bp;
-char *buf;
-int size;
+static int sock_gets(BIO *bp, char *buf,int size)
        {
        return(-1);
        }
 #endif
 
 #ifndef BIO_FD
-static int sock_puts(bp,str)
+static int sock_puts(BIO *bp, const char *str)
 #else
-static int fd_puts(bp,str)
+static int fd_puts(BIO *bp, const char *str)
 #endif
-BIO *bp;
-char *str;
        {
        int n,ret;
 
@@ -369,11 +330,10 @@ char *str;
        }
 
 #ifndef BIO_FD
-int BIO_sock_should_retry(i)
+int BIO_sock_should_retry(int i)
 #else
-int BIO_fd_should_retry(i)
+int BIO_fd_should_retry(int i)
 #endif
-int i;
        {
        int err;
 
@@ -385,7 +345,7 @@ int i;
                err=get_last_sys_error();
 #endif
 
-#if defined(WINDOWS) && 0 /* more microsoft stupidity *//* perhaps not? Ben 4/1/99 */
+#if defined(WINDOWS) && 0 /* more microsoft stupidity? perhaps not? Ben 4/1/99 */
                if ((i == -1) && (err == 0))
                        return(1);
 #endif
@@ -400,11 +360,10 @@ int i;
        }
 
 #ifndef BIO_FD
-int BIO_sock_non_fatal_error(err)
+int BIO_sock_non_fatal_error(int err)
 #else
-int BIO_fd_non_fatal_error(err)
+int BIO_fd_non_fatal_error(int err)
 #endif
-int err;
        {
        switch (err)
                {