fixing compilation for openssl-1.1.0 (part 11)

This commit is contained in:
csoler 2017-02-18 23:47:53 +01:00
parent 01e89bb0d8
commit 0c77a10224

View File

@ -90,7 +90,13 @@ static int clear_tou_socket_error(int s);
#include "tou.h" #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= static BIO_METHOD methods_tou_sockp=
{ {
@ -132,10 +138,10 @@ static int tou_socket_new(BIO *bi)
#ifdef DEBUG_TOU_BIO #ifdef DEBUG_TOU_BIO
fprintf(stderr, "tou_socket_new()\n"); fprintf(stderr, "tou_socket_new()\n");
#endif #endif
bi->init=0; BIO_set_init(bi,0) ;
bi->num=0; BIO_set_data(bi,NULL) ; // sets bi->ptr
bi->ptr=NULL; BIO_set_flags(bi,0) ;
bi->flags=0; BIO_set_fd(bi,0,0) ;
return(1); return(1);
} }
@ -145,14 +151,15 @@ static int tou_socket_free(BIO *a)
fprintf(stderr, "tou_socket_free()\n"); fprintf(stderr, "tou_socket_free()\n");
#endif #endif
if (a == NULL) return(0); 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; BIO_set_init(a,0) ;
a->flags=0; BIO_set_flags(a,0) ;
} }
return(1); return(1);
} }
@ -166,13 +173,13 @@ static int tou_socket_read(BIO *b, char *out, int outl)
if (out != NULL) if (out != NULL)
{ {
clear_tou_socket_error(b->num); clear_tou_socket_error(BIO_get_fd(b,NULL));
/* call tou library */ /* 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); BIO_clear_retry_flags(b);
if (ret <= 0) 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); 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); fprintf(stderr, "tou_socket_write(%p,%p,%d)\n",b,in,inl);
#endif #endif
clear_tou_socket_error(b->num); clear_tou_socket_error(BIO_get_fd(b,NULL));
/* call tou library */ /* 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); BIO_clear_retry_flags(b);
if (ret <= 0) 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); BIO_set_retry_write(b);
#ifdef DEBUG_TOU_BIO #ifdef DEBUG_TOU_BIO
@ -230,34 +237,34 @@ static long tou_socket_ctrl(BIO *b, int cmd, long num, void *ptr)
break; break;
case BIO_C_SET_FD: case BIO_C_SET_FD:
tou_socket_free(b); tou_socket_free(b);
b->num= *((int *)ptr); BIO_set_fd(b,*((int *)ptr),0);
b->shutdown=(int)num; BIO_set_shutdown(b,(int)num) ;
b->init=1; BIO_set_init(b,1) ;
break; break;
case BIO_C_GET_FD: case BIO_C_GET_FD:
if (b->init) if (BIO_get_init(b))
{ {
ip=(int *)ptr; ip=(int *)ptr;
if (ip != NULL) *ip=b->num; if (ip != NULL) *ip=BIO_get_fd(b,NULL);
ret=b->num; ret=BIO_get_fd(b,NULL);
} }
else else
ret= -1; ret= -1;
break; break;
case BIO_CTRL_GET_CLOSE: case BIO_CTRL_GET_CLOSE:
ret=b->shutdown; ret=BIO_get_shutdown(b);
break; break;
case BIO_CTRL_SET_CLOSE: case BIO_CTRL_SET_CLOSE:
b->shutdown=(int)num; BIO_set_shutdown(b,(int)num) ;
break; break;
case BIO_CTRL_PENDING: case BIO_CTRL_PENDING:
ret = tou_maxread(b->num); ret = tou_maxread(BIO_get_fd(b,NULL));
#ifdef DEBUG_TOU_BIO #ifdef DEBUG_TOU_BIO
fprintf(stderr, "tou_pending = %ld\n", ret); fprintf(stderr, "tou_pending = %ld\n", ret);
#endif #endif
break; break;
case BIO_CTRL_WPENDING: case BIO_CTRL_WPENDING:
ret = tou_maxwrite(b->num); ret = tou_maxwrite(BIO_get_fd(b,NULL));
#ifdef DEBUG_TOU_BIO #ifdef DEBUG_TOU_BIO
fprintf(stderr, "tou_wpending = %ld\n", ret); fprintf(stderr, "tou_wpending = %ld\n", ret);
#endif #endif