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,7 +124,7 @@ 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];
@ -137,7 +139,7 @@ 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,7 +157,7 @@ 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];
} }
@ -171,7 +173,7 @@ 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];
} }
@ -191,16 +193,16 @@ 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
@ -213,7 +215,7 @@ 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];
@ -227,16 +229,16 @@ 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];
@ -250,7 +252,7 @@ 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];
} }
@ -287,7 +289,7 @@ 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) {