From 0c77a102248c237d97b1845201b09ab2a853d821 Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 18 Feb 2017 23:47:53 +0100 Subject: [PATCH] fixing compilation for openssl-1.1.0 (part 11) --- libretroshare/src/tcponudp/bss_tou.c | 59 ++++++++++++++++------------ 1 file changed, 33 insertions(+), 26 deletions(-) diff --git a/libretroshare/src/tcponudp/bss_tou.c b/libretroshare/src/tcponudp/bss_tou.c index f96abb19d..1637b4c65 100644 --- a/libretroshare/src/tcponudp/bss_tou.c +++ b/libretroshare/src/tcponudp/bss_tou.c @@ -90,7 +90,13 @@ static int clear_tou_socket_error(int s); #include "tou.h" - +#if OPENSSL_VERSION_NUMBER < 0x10100000L +static int BIO_get_shutdown(BIO *a) { return a->shutdown; } +static void BIO_set_shutdown(BIO *a,int s) { a->shutdown=s; } +static int BIO_get_init(BIO *a) { return a->init; } +static void BIO_set_init(BIO *a,int i) { a->init=i; } +static void BIO_set_data(BIO *a,void *p) { a->ptr = p; } +#endif static BIO_METHOD methods_tou_sockp= { @@ -132,10 +138,10 @@ static int tou_socket_new(BIO *bi) #ifdef DEBUG_TOU_BIO fprintf(stderr, "tou_socket_new()\n"); #endif - bi->init=0; - bi->num=0; - bi->ptr=NULL; - bi->flags=0; + BIO_set_init(bi,0) ; + BIO_set_data(bi,NULL) ; // sets bi->ptr + BIO_set_flags(bi,0) ; + BIO_set_fd(bi,0,0) ; return(1); } @@ -145,14 +151,15 @@ static int tou_socket_free(BIO *a) fprintf(stderr, "tou_socket_free()\n"); #endif if (a == NULL) return(0); - if (a->shutdown) + + if(BIO_get_shutdown(a)) { - if (a->init) + if(BIO_get_init(a)) { - tou_close(a->num); + tou_close(BIO_get_fd(a,NULL)); } - a->init=0; - a->flags=0; + BIO_set_init(a,0) ; + BIO_set_flags(a,0) ; } return(1); } @@ -166,13 +173,13 @@ static int tou_socket_read(BIO *b, char *out, int outl) if (out != NULL) { - clear_tou_socket_error(b->num); + clear_tou_socket_error(BIO_get_fd(b,NULL)); /* call tou library */ - ret=tou_read(b->num,out,outl); + ret=tou_read(BIO_get_fd(b,NULL),out,outl); BIO_clear_retry_flags(b); if (ret <= 0) { - if (BIO_tou_socket_should_retry(b->num, ret)) + if (BIO_tou_socket_should_retry(BIO_get_fd(b,NULL), ret)) BIO_set_retry_read(b); } } @@ -189,13 +196,13 @@ static int tou_socket_write(BIO *b, const char *in, int inl) fprintf(stderr, "tou_socket_write(%p,%p,%d)\n",b,in,inl); #endif - clear_tou_socket_error(b->num); + clear_tou_socket_error(BIO_get_fd(b,NULL)); /* call tou library */ - ret=tou_write(b->num,in,inl); + ret=tou_write(BIO_get_fd(b,NULL),in,inl); BIO_clear_retry_flags(b); if (ret <= 0) { - if (BIO_tou_socket_should_retry(b->num,ret)) + if (BIO_tou_socket_should_retry(BIO_get_fd(b,NULL),ret)) { BIO_set_retry_write(b); #ifdef DEBUG_TOU_BIO @@ -230,34 +237,34 @@ static long tou_socket_ctrl(BIO *b, int cmd, long num, void *ptr) break; case BIO_C_SET_FD: tou_socket_free(b); - b->num= *((int *)ptr); - b->shutdown=(int)num; - b->init=1; + BIO_set_fd(b,*((int *)ptr),0); + BIO_set_shutdown(b,(int)num) ; + BIO_set_init(b,1) ; break; case BIO_C_GET_FD: - if (b->init) + if (BIO_get_init(b)) { ip=(int *)ptr; - if (ip != NULL) *ip=b->num; - ret=b->num; + if (ip != NULL) *ip=BIO_get_fd(b,NULL); + ret=BIO_get_fd(b,NULL); } else ret= -1; break; case BIO_CTRL_GET_CLOSE: - ret=b->shutdown; + ret=BIO_get_shutdown(b); break; case BIO_CTRL_SET_CLOSE: - b->shutdown=(int)num; + BIO_set_shutdown(b,(int)num) ; break; case BIO_CTRL_PENDING: - ret = tou_maxread(b->num); + ret = tou_maxread(BIO_get_fd(b,NULL)); #ifdef DEBUG_TOU_BIO fprintf(stderr, "tou_pending = %ld\n", ret); #endif break; case BIO_CTRL_WPENDING: - ret = tou_maxwrite(b->num); + ret = tou_maxwrite(BIO_get_fd(b,NULL)); #ifdef DEBUG_TOU_BIO fprintf(stderr, "tou_wpending = %ld\n", ret); #endif