@@ -139,39 +139,39 @@ static OF_INLINE OFString* normalized_key(OFString *key) { char *cString = strdup([key UTF8String]); uint8_t *tmp = (uint8_t*)cString; - BOOL firstLetter = YES; + bool firstLetter = true; if (cString == NULL) @throw [OFOutOfMemoryException exceptionWithClass: nil requestedSize: strlen([key UTF8String])]; while (*tmp != '\0') { if (!isalnum(*tmp)) { - firstLetter = YES; + firstLetter = true; tmp++; continue; } *tmp = (firstLetter ? toupper(*tmp) : tolower(*tmp)); - firstLetter = NO; + firstLetter = false; tmp++; } return [OFString stringWithUTF8StringNoCopy: cString - freeWhenDone: YES]; + freeWhenDone: true]; } @interface OFHTTPServerReply: OFHTTPRequestReply { OFTCPSocket *_socket; OFHTTPServer *_server; - BOOL _chunked, _headersSent, _closed; + bool _chunked, _headersSent, _closed; } - initWithSocket: (OFTCPSocket*)socket server: (OFHTTPServer*)server; @end @@ -222,11 +222,11 @@ if (![key isEqual: @"Server"] && ![key isEqual: @"Date"]) [_socket writeFormat: @"%@: %@\r\n", key, value]; [_socket writeString: @"\r\n"]; - _headersSent = YES; + _headersSent = true; _chunked = [[_headers objectForKey: @"Transfer-Encoding"] isEqual: @"chunked"]; objc_autoreleasePoolPop(pool); } @@ -264,11 +264,11 @@ [_socket writeBuffer: "0\r\n\r\n" length: 5]; [_socket close]; - _closed = YES; + _closed = true; } - (int)fileDescriptorForWriting { return [_socket fileDescriptorForWriting]; @@ -294,20 +294,20 @@ OFDataArray *_POSTData; } - initWithSocket: (OFTCPSocket*)socket server: (OFHTTPServer*)server; -- (BOOL)socket: (OFTCPSocket*)socket +- (bool)socket: (OFTCPSocket*)socket didReadLine: (OFString*)line exception: (OFException*)exception; -- (BOOL)parseProlog: (OFString*)line; -- (BOOL)parseHeaders: (OFString*)line; -- (BOOL)socket: (OFTCPSocket*)socket +- (bool)parseProlog: (OFString*)line; +- (bool)parseHeaders: (OFString*)line; +- (bool)socket: (OFTCPSocket*)socket didReadIntoBuffer: (const char*)buffer length: (size_t)length exception: (OFException*)exception; -- (BOOL)sendErrorAndClose: (short)statusCode; +- (bool)sendErrorAndClose: (short)statusCode; - (void)createReply; @end @implementation OFHTTPServer_Connection - initWithSocket: (OFTCPSocket*)socket @@ -321,11 +321,11 @@ _timer = [[OFTimer scheduledTimerWithTimeInterval: 10 target: socket selector: @selector( cancelAsyncRequests) - repeats: NO] retain]; + repeats: false] retain]; _state = AWAITING_PROLOG; } @catch (id e) { [self release]; @throw e; } @@ -347,42 +347,42 @@ [_POSTData release]; [super dealloc]; } -- (BOOL)socket: (OFTCPSocket*)socket +- (bool)socket: (OFTCPSocket*)socket didReadLine: (OFString*)line exception: (OFException*)exception { if (line == nil || exception != nil) - return NO; + return false; @try { switch (_state) { case AWAITING_PROLOG: return [self parseProlog: line]; case PARSING_HEADERS: if (![self parseHeaders: line]) - return NO; + return false; if (_state == SEND_REPLY) { [self createReply]; - return NO; + return false; } - return YES; + return true; default: - return NO; + return false; } } @catch (OFWriteFailedException *e) { - return NO; + return false; } abort(); } -- (BOOL)parseProlog: (OFString*)line +- (bool)parseProlog: (OFString*)line { OFString *type; size_t pos; @try { @@ -428,14 +428,14 @@ return [self sendErrorAndClose: 400]; _headers = [[OFMutableDictionary alloc] init]; _state = PARSING_HEADERS; - return YES; + return true; } -- (BOOL)parseHeaders: (OFString*)line +- (bool)parseHeaders: (OFString*)line { OFString *key, *value; size_t pos; if ([line length] == 0) { @@ -468,14 +468,14 @@ didReadIntoBuffer: length:exception:)]; [_timer setFireDate: [OFDate dateWithTimeIntervalSinceNow: 5]]; - return NO; + return false; } - return YES; + return true; } pos = [line rangeOfString: @":"].location; if (pos == OF_NOT_FOUND) return [self sendErrorAndClose: 400]; @@ -518,40 +518,40 @@ _host = [value retain]; _port = 80; } } - return YES; + return true; } -- (BOOL)socket: (OFTCPSocket*)socket +- (bool)socket: (OFTCPSocket*)socket didReadIntoBuffer: (const char*)buffer length: (size_t)length exception: (OFException*)exception { if ([socket isAtEndOfStream] || exception != nil) - return NO; + return false; [_POSTData addItems: buffer count: length]; if ([_POSTData count] >= _contentLength) { @try { [self createReply]; } @catch (OFWriteFailedException *e) { - return NO; + return false; } - return NO; + return false; } [_timer setFireDate: [OFDate dateWithTimeIntervalSinceNow: 5]]; - return YES; + return true; } -- (BOOL)sendErrorAndClose: (short)statusCode +- (bool)sendErrorAndClose: (short)statusCode { OFString *date = [[OFDate date] dateStringWithFormat: @"%a, %d %b %Y %H:%M:%S GMT"]; [_socket writeFormat: @"HTTP/1.1 %d %s\r\n" @@ -560,11 +560,11 @@ @"\r\n", statusCode, status_code_to_string(statusCode), date, [_server name]]; [_socket close]; - return NO; + return false; } - (void)createReply { OFURL *URL; @@ -647,16 +647,16 @@ [super dealloc]; } - (void)setHost: (OFString*)host { - OF_SETTER(_host, host, YES, 1) + OF_SETTER(_host, host, true, 1) } - (OFString*)host { - OF_GETTER(_host, YES) + OF_GETTER(_host, true) } - (void)setPort: (uint16_t)port { _port = port; @@ -677,16 +677,16 @@ return _delegate; } - (void)setName: (OFString*)name { - OF_SETTER(_name, name, YES, 1) + OF_SETTER(_name, name, true, 1) } - (OFString*)name { - OF_GETTER(_name, YES) + OF_GETTER(_name, true) } - (void)start { if (_host == nil || _port == 0) @@ -715,11 +715,11 @@ [_listeningSocket cancelAsyncRequests]; [_listeningSocket release]; _listeningSocket = nil; } -- (BOOL)OF_socket: (OFTCPSocket*)socket +- (bool)OF_socket: (OFTCPSocket*)socket didAcceptSocket: (OFTCPSocket*)clientSocket exception: (OFException*)exception { OFHTTPServer_Connection *connection; @@ -727,11 +727,11 @@ if ([_delegate respondsToSelector: @selector(server:didReceiveExceptionOnListeningSocket:)]) return [_delegate server: self didReceiveExceptionOnListeningSocket: exception]; - return NO; + return false; } connection = [[[OFHTTPServer_Connection alloc] initWithSocket: clientSocket server: self] autorelease]; @@ -738,8 +738,8 @@ [clientSocket asyncReadLineWithTarget: connection selector: @selector(socket:didReadLine: exception:)]; - return YES; + return true; } @end