Index: src/SSLSocket.m ================================================================== --- src/SSLSocket.m +++ src/SSLSocket.m @@ -11,10 +11,11 @@ #import #import #import #import #import +#import #ifndef INVALID_SOCKET # define INVALID_SOCKET -1 #endif @@ -111,104 +112,104 @@ } } - (SSLSocket*)accept { - SSLSocket *newsock = (SSLSocket*)[super accept]; + SSLSocket *newSocket = (SSLSocket*)[super accept]; - if ((newsock->ssl = SSL_new(ctx)) == NULL || - !SSL_set_fd(newsock->ssl, newsock->sock)) { + if ((newSocket->ssl = SSL_new(ctx)) == NULL || + !SSL_set_fd(newSocket->ssl, newSocket->sock)) { /* We only want to close the OFTCPSocket */ - newsock->isa = [OFTCPSocket class]; - [newsock close]; - newsock->isa = isa; + newSocket->isa = [OFTCPSocket class]; + [newSocket close]; + newSocket->isa = isa; @throw [OFAcceptFailedException newWithClass: isa socket: self]; } - SSL_set_accept_state(newsock->ssl); + SSL_set_accept_state(newSocket->ssl); - if (!SSL_use_PrivateKey_file(newsock->ssl, [privateKeyFile cString], - SSL_FILETYPE_PEM) || !SSL_use_certificate_file(newsock->ssl, + if (!SSL_use_PrivateKey_file(newSocket->ssl, [privateKeyFile cString], + SSL_FILETYPE_PEM) || !SSL_use_certificate_file(newSocket->ssl, [certificateFile cString], SSL_FILETYPE_PEM) || - SSL_accept(newsock->ssl) != 1) { + SSL_accept(newSocket->ssl) != 1) { /* We only want to close the OFTCPSocket */ - newsock->isa = [OFTCPSocket class]; - [newsock close]; - newsock->isa = isa; + newSocket->isa = [OFTCPSocket class]; + [newSocket close]; + newSocket->isa = isa; @throw [OFAcceptFailedException newWithClass: isa socket: self]; } - return newsock; + return newSocket; } - (void)close { SSL_shutdown(ssl); [super close]; } -- (size_t)_readNBytes: (size_t)size - intoBuffer: (char*)buf +- (size_t)_readNBytes: (size_t)length + intoBuffer: (char*)buffer { ssize_t ret; - if (size > INT_MAX) + if (length > INT_MAX) @throw [OFOutOfRangeException newWithClass: isa]; if (sock == INVALID_SOCKET) @throw [OFNotConnectedException newWithClass: isa socket: self]; - if (eos) { + if (isAtEndOfStream) { OFReadFailedException *e; e = [OFReadFailedException newWithClass: isa stream: self - requestedSize: size]; + requestedLength: length]; #ifndef _WIN32 e->errNo = ENOTCONN; #else e->errNo = WSAENOTCONN; #endif @throw e; } - if ((ret = SSL_read(ssl, buf, (int)size)) < 0) + if ((ret = SSL_read(ssl, buffer, (int)length)) < 0) @throw [OFReadFailedException newWithClass: isa stream: self - requestedSize: size]; + requestedLength: length]; if (ret == 0) - eos = YES; + isAtEndOfStream = YES; return ret; } -- (size_t)_writeNBytes: (size_t)size - fromBuffer: (const char*)buf +- (size_t)_writeNBytes: (size_t)length + fromBuffer: (const char*)buffer { ssize_t ret; - if (size > INT_MAX) + if (length > INT_MAX) @throw [OFOutOfRangeException newWithClass: isa]; if (sock == INVALID_SOCKET) @throw [OFNotConnectedException newWithClass: isa socket: self]; - if (eos) { + if (isAtEndOfStream) { OFWriteFailedException *e; e = [OFWriteFailedException newWithClass: isa stream: self - requestedSize: size]; + requestedLength: length]; #ifndef _WIN32 e->errNo = ENOTCONN; #else e->errNo = WSAENOTCONN; @@ -215,14 +216,14 @@ #endif @throw e; } - if ((ret = SSL_write(ssl, buf, (int)size)) < 1) + if ((ret = SSL_write(ssl, buffer, (int)length)) < 1) @throw [OFWriteFailedException newWithClass: isa stream: self - requestedSize: size]; + requestedLength: length]; return ret; } - (size_t)pendingBytes @@ -230,27 +231,23 @@ return [super pendingBytes] + SSL_pending(ssl); } - (void)setPrivateKeyFile: (OFString*)file { - OFString *old = privateKeyFile; - privateKeyFile = [file copy]; - [old release]; + OF_SETTER(privateKeyFile, file, YES, YES) } - (OFString*)privateKeyFile { - return [[privateKeyFile copy] autorelease]; + OF_GETTER(privateKeyFile, YES) } - (void)setCertificateFile: (OFString*)file { - OFString *old = certificateFile; - certificateFile = [file copy]; - [old release]; + OF_SETTER(certificateFile, file, YES, YES) } - (OFString*)certificateFile { - return [[certificateFile copy] autorelease]; + OF_GETTER(certificateFile, YES) } @end