Adjust to recent ObjFW changes.

This commit is contained in:
Jonathan Schleifer 2011-09-23 01:28:48 +02:00
parent 0972f8ee36
commit 250d2452dd

View file

@ -59,10 +59,12 @@ static SSL_CTX *ctx;
SSL_library_init(); SSL_library_init();
if ((ctx = SSL_CTX_new(SSLv23_method())) == NULL) if ((ctx = SSL_CTX_new(SSLv23_method())) == NULL)
@throw [OFInitializationFailedException newWithClass: self]; @throw [OFInitializationFailedException
exceptionWithClass: self];
if ((SSL_CTX_set_options(ctx, SSL_OP_NO_SSLv2) & SSL_OP_NO_SSLv2) == 0) if ((SSL_CTX_set_options(ctx, SSL_OP_NO_SSLv2) & SSL_OP_NO_SSLv2) == 0)
@throw [OFInitializationFailedException newWithClass: self]; @throw [OFInitializationFailedException
exceptionWithClass: self];
} }
- initWithSocket: (OFTCPSocket*)socket - initWithSocket: (OFTCPSocket*)socket
@ -76,7 +78,7 @@ static SSL_CTX *ctx;
close(sock); close(sock);
sock = INVALID_SOCKET; sock = INVALID_SOCKET;
@throw [OFInitializationFailedException @throw [OFInitializationFailedException
newWithClass: isa]; exceptionWithClass: isa];
} }
SSL_set_connect_state(ssl); SSL_set_connect_state(ssl);
@ -91,7 +93,7 @@ static SSL_CTX *ctx;
close(sock); close(sock);
sock = INVALID_SOCKET; sock = INVALID_SOCKET;
@throw [OFInitializationFailedException @throw [OFInitializationFailedException
newWithClass: isa]; exceptionWithClass: isa];
} }
} @catch (id e) { } @catch (id e) {
[self release]; [self release];
@ -122,10 +124,10 @@ static SSL_CTX *ctx;
if ((ssl = SSL_new(ctx)) == NULL || !SSL_set_fd(ssl, sock)) { if ((ssl = SSL_new(ctx)) == NULL || !SSL_set_fd(ssl, sock)) {
[super close]; [super close];
@throw [OFConnectionFailedException newWithClass: isa @throw [OFConnectionFailedException exceptionWithClass: isa
socket: self socket: self
host: host host: host
port: port]; port: port];
} }
SSL_set_connect_state(ssl); SSL_set_connect_state(ssl);
@ -137,10 +139,10 @@ static SSL_CTX *ctx;
cStringWithEncoding: OF_STRING_ENCODING_NATIVE], cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
SSL_FILETYPE_PEM)) || SSL_connect(ssl) != 1) { SSL_FILETYPE_PEM)) || SSL_connect(ssl) != 1) {
[super close]; [super close];
@throw [OFConnectionFailedException newWithClass: isa @throw [OFConnectionFailedException exceptionWithClass: isa
socket: self socket: self
host: host host: host
port: port]; port: port];
} }
} }
@ -155,8 +157,8 @@ static SSL_CTX *ctx;
[newSocket close]; [newSocket close];
newSocket->isa = isa; newSocket->isa = isa;
@throw [OFAcceptFailedException newWithClass: isa @throw [OFAcceptFailedException exceptionWithClass: isa
socket: self]; socket: self];
} }
SSL_set_accept_state(newSocket->ssl); SSL_set_accept_state(newSocket->ssl);
@ -171,8 +173,8 @@ static SSL_CTX *ctx;
[newSocket close]; [newSocket close];
newSocket->isa = isa; newSocket->isa = isa;
@throw [OFAcceptFailedException newWithClass: isa @throw [OFAcceptFailedException exceptionWithClass: isa
socket: self]; socket: self];
} }
return newSocket; return newSocket;
@ -191,18 +193,18 @@ static SSL_CTX *ctx;
ssize_t ret; ssize_t ret;
if (length > INT_MAX) if (length > INT_MAX)
@throw [OFOutOfRangeException newWithClass: isa]; @throw [OFOutOfRangeException exceptionWithClass: isa];
if (sock == INVALID_SOCKET) if (sock == INVALID_SOCKET)
@throw [OFNotConnectedException newWithClass: isa @throw [OFNotConnectedException exceptionWithClass: isa
socket: self]; socket: self];
if (atEndOfStream) { if (atEndOfStream) {
OFReadFailedException *e; OFReadFailedException *e;
e = [OFReadFailedException newWithClass: isa e = [OFReadFailedException exceptionWithClass: isa
stream: self stream: self
requestedLength: length]; requestedLength: length];
#ifndef _WIN32 #ifndef _WIN32
e->errNo = ENOTCONN; e->errNo = ENOTCONN;
#else #else
@ -213,9 +215,9 @@ static SSL_CTX *ctx;
} }
if ((ret = SSL_read(ssl, buffer, (int)length)) < 0) if ((ret = SSL_read(ssl, buffer, (int)length)) < 0)
@throw [OFReadFailedException newWithClass: isa @throw [OFReadFailedException exceptionWithClass: isa
stream: self stream: self
requestedLength: length]; requestedLength: length];
if (ret == 0) if (ret == 0)
atEndOfStream = YES; atEndOfStream = YES;
@ -227,17 +229,17 @@ static SSL_CTX *ctx;
fromBuffer: (const void*)buffer fromBuffer: (const void*)buffer
{ {
if (length > INT_MAX) if (length > INT_MAX)
@throw [OFOutOfRangeException newWithClass: isa]; @throw [OFOutOfRangeException exceptionWithClass: isa];
if (sock == INVALID_SOCKET) if (sock == INVALID_SOCKET)
@throw [OFNotConnectedException newWithClass: isa @throw [OFNotConnectedException exceptionWithClass: isa
socket: self]; socket: self];
if (atEndOfStream) { if (atEndOfStream) {
OFWriteFailedException *e; OFWriteFailedException *e;
e = [OFWriteFailedException newWithClass: isa e = [OFWriteFailedException exceptionWithClass: isa
stream: self stream: self
requestedLength: length]; requestedLength: length];
#ifndef _WIN32 #ifndef _WIN32
@ -250,9 +252,9 @@ static SSL_CTX *ctx;
} }
if (SSL_write(ssl, buffer, (int)length) < length) if (SSL_write(ssl, buffer, (int)length) < length)
@throw [OFWriteFailedException newWithClass: isa @throw [OFWriteFailedException exceptionWithClass: isa
stream: self stream: self
requestedLength: length]; requestedLength: length];
} }
- (size_t)pendingBytes - (size_t)pendingBytes
@ -287,8 +289,8 @@ static SSL_CTX *ctx;
OFDataArray *data; OFDataArray *data;
if (![type isEqual: @"tls-unique"]) if (![type isEqual: @"tls-unique"])
@throw [OFInvalidArgumentException newWithClass: isa @throw [OFInvalidArgumentException exceptionWithClass: isa
selector: _cmd]; selector: _cmd];
if (SSL_session_reused(ssl) ^ !listening) { if (SSL_session_reused(ssl) ^ !listening) {
/* /*