Index: src/OFDataArray.m ================================================================== --- src/OFDataArray.m +++ src/OFDataArray.m @@ -109,12 +109,12 @@ char *buffer = [self allocMemoryWithSize: of_pagesize]; while (![file isAtEndOfStream]) { size_t length; - length = [file readNBytes: of_pagesize - intoBuffer: buffer]; + length = [file readIntoBuffer: buffer + length: of_pagesize]; [self addItemsFromCArray: buffer count: length]; } [self freeMemory: buffer]; @@ -435,12 +435,12 @@ { OFFile *file = [[OFFile alloc] initWithPath: path mode: @"wb"]; @try { - [file writeNBytes: count * itemSize - fromBuffer: data]; + [file writeBuffer: data + length: count * itemSize]; } @finally { [file release]; } } Index: src/OFFile.m ================================================================== --- src/OFFile.m +++ src/OFFile.m @@ -523,14 +523,16 @@ mode: @"rb"]; destinationFile = [OFFile fileWithPath: destination mode: @"wb"]; while (![sourceFile isAtEndOfStream]) { - size_t len = [sourceFile readNBytes: of_pagesize - intoBuffer: buffer]; - [destinationFile writeNBytes: len - fromBuffer: buffer]; + size_t length; + + length = [sourceFile readIntoBuffer: buffer + length: of_pagesize]; + [destinationFile writeBuffer: buffer + length: length]; } #if !defined(_WIN32) && !defined(_PSP) if (!override) { struct stat s; @@ -694,12 +696,12 @@ return YES; return atEndOfStream; } -- (size_t)_readNBytes: (size_t)length - intoBuffer: (void*)buffer +- (size_t)_readIntoBuffer: (void*)buffer + length: (size_t)length { ssize_t ret; if (fileDescriptor == -1 || atEndOfStream || (ret = read(fileDescriptor, buffer, length)) < 0) @@ -711,12 +713,12 @@ atEndOfStream = YES; return ret; } -- (void)_writeNBytes: (size_t)length - fromBuffer: (const void*)buffer +- (void)_writeBuffer: (const void*)buffer + length: (size_t)length { if (fileDescriptor == -1 || atEndOfStream || write(fileDescriptor, buffer, length) < length) @throw [OFWriteFailedException exceptionWithClass: isa stream: self Index: src/OFHTTPRequest.m ================================================================== --- src/OFHTTPRequest.m +++ src/OFHTTPRequest.m @@ -226,11 +226,11 @@ /* * Work around a bug with packet bisection in lighttpd when using * HTTPS. */ - [sock setBuffersWrites: YES]; + [sock setWriteBufferEnabled: YES]; if (requestType == OF_HTTP_REQUEST_TYPE_GET) type = "GET"; if (requestType == OF_HTTP_REQUEST_TYPE_HEAD) type = "HEAD"; @@ -272,11 +272,11 @@ [sock writeString: @"\r\n"]; /* Work around a bug in lighttpd, see above */ [sock flushWriteBuffer]; - [sock setBuffersWrites: NO]; + [sock setWriteBufferEnabled: NO]; if (requestType == OF_HTTP_REQUEST_TYPE_POST) [sock writeString: queryString]; @try { @@ -420,12 +420,12 @@ while (toRead > 0) { size_t length = (toRead < of_pagesize ? toRead : of_pagesize); - length = [sock readNBytes: length - intoBuffer: buffer]; + length = [sock readIntoBuffer: buffer + length: length]; [delegate request: self didReceiveData: buffer withLength: length]; [pool2 releaseObjects]; @@ -451,12 +451,13 @@ [pool2 releaseObjects]; } } else { size_t length; - while ((length = [sock readNBytes: of_pagesize - intoBuffer: buffer]) > 0) { + while ((length = [sock + readIntoBuffer: buffer + length: of_pagesize]) > 0) { [delegate request: self didReceiveData: buffer withLength: length]; [pool2 releaseObjects]; Index: src/OFProcess.m ================================================================== --- src/OFProcess.m +++ src/OFProcess.m @@ -234,12 +234,12 @@ return YES; return atEndOfStream; } -- (size_t)_readNBytes: (size_t)length - intoBuffer: (void*)buffer +- (size_t)_readIntoBuffer: (void*)buffer + length: (size_t)length { #ifndef _WIN32 ssize_t ret; #else DWORD ret; @@ -266,12 +266,12 @@ atEndOfStream = YES; return ret; } -- (void)_writeNBytes: (size_t)length - fromBuffer: (const void*)buffer +- (void)_writeBuffer: (const void*)buffer + length: (size_t)length { #ifndef _WIN32 if (writePipe[1] == -1 || atEndOfStream || write(writePipe[1], buffer, length) < length) #else Index: src/OFStream.h ================================================================== --- src/OFStream.h +++ src/OFStream.h @@ -30,29 +30,29 @@ /** * \brief A base class for different types of streams. * * \warning Even though the OFCopying protocol is implemented, it does - * not return an independant copy of the stream but instead + * not return an independent copy of the stream but instead * retains it. This is so that the stream can be used as a key for a - * dictionary so context can be associated with a stream. Using a + * dictionary, so context can be associated with a stream. Using a * stream in more than one thread at the same time is not thread-safe, - * even if copy was called! - * - * \warning If you want to subclass this, override _readNBytes:intoBuffer:, - * _writeNBytes:fromBuffer: and _isAtEndOfStream, but nothing else. - * Those are not defined in the headers, but do the actual work. - * OFStream uses those and does all the caching and other stuff. If - * you override these methods without the _ prefix, you *WILL* break - * caching and get broken results! + * even if copy was called to create one "instance" for every thread! + * + * \warning If you want to subclass this, override _readIntoBuffer:length:, + * _writeBuffer:length: and _isAtEndOfStream, but nothing else, as + * those are are the methods that do the actual work. OFStream uses + * those for all other methods and does all the caching and other + * stuff for you. If you override these methods without the _ prefix, + * you will break caching and get broken results! */ @interface OFStream: OFObject { char *cache; char *writeBuffer; size_t cacheLength, writeBufferLength; - BOOL buffersWrites; + BOOL writeBufferEnabled; BOOL blocking; BOOL waitingForDelimiter; } #ifdef OF_HAVE_PROPERTIES @@ -70,37 +70,37 @@ /** * \brief Reads at most size bytes from the stream into a buffer. * * On network streams, this might read less than the specified number of bytes. * If you want to read exactly the specified number of bytes, use - * -[readExactlyNBytes:intoBuffer:]. + * -[readIntoBuffer:exactLength:]. * * \param buffer The buffer into which the data is read * \param length The length of the data that should be read at most. - * The buffer MUST be at least this big! + * The buffer must be at least this big! * \return The number of bytes read */ -- (size_t)readNBytes: (size_t)size - intoBuffer: (void*)buffer; +- (size_t)readIntoBuffer: (void*)buffer + length: (size_t)size; /** * \brief Reads exactly the specified length bytes from the stream into a * buffer. * - * Unlike readNBytes:intoBuffer:, this method does not return when less than the + * Unlike readIntoBuffer:length:, this method does not return when less than the * specified length has been read - instead, it waits until it got exactly the * specified length. * * \warning Only call this when you know that specified amount of data is * available! Otherwise you will get an exception! * * \param buffer The buffer into which the data is read * \param length The length of the data that should be read. - * The buffer MUST be EXACTLY this big! + * The buffer must be exactly this big! */ -- (void)readExactlyNBytes: (size_t)length - intoBuffer: (void*)buffer; + - (void)readIntoBuffer: (void*)buffer + exactLength: (size_t)length; /** * \brief Reads a uint8_t from the stream. * * \warning Only call this when you know that enough data is available! @@ -170,12 +170,12 @@ * \param nInt16s The number of uint16_ts to read * \param buffer A buffer of sufficient size to store the specified number of * uint16_ts * \return The number of bytes read */ -- (size_t)readNBigEndianInt16s: (size_t)nInt16s - intoBuffer: (uint16_t*)buffer; +- (size_t)readBigEndianInt16sIntoBuffer: (uint16_t*)buffer + count: (size_t)nInt16s; /** * \brief Reads the specified number of uint32_ts from the stream which are * encoded in big endian. * @@ -185,12 +185,12 @@ * \param nInt32s The number of uint32_ts to read * \param buffer A buffer of sufficient size to store the specified number of * uint32_ts * \return The number of bytes read */ -- (size_t)readNBigEndianInt32s: (size_t)nInt32s - intoBuffer: (uint32_t*)buffer; +- (size_t)readBigEndianInt32sIntoBuffer: (uint32_t*)buffer + count: (size_t)nInt32s; /** * \brief Reads the specified number of uint64_ts from the stream which are * encoded in big endian. * @@ -200,12 +200,12 @@ * \param nInt64s The number of uint64_ts to read * \param buffer A buffer of sufficient size to store the specified number of * uint64_ts * \return The number of bytes read */ -- (size_t)readNBigEndianInt64s: (size_t)nInt64s - intoBuffer: (uint64_t*)buffer; +- (size_t)readBigEndianInt64sIntoBuffer: (uint64_t*)buffer + count: (size_t)nInt64s; /** * \brief Reads the specified number of floats from the stream which are encoded * in big endian. * @@ -215,12 +215,12 @@ * \param nFloatss The number of floats to read * \param buffer A buffer of sufficient size to store the specified number of * floats * \return The number of bytes read */ -- (size_t)readNBigEndianFloats: (size_t)nFloats - intoBuffer: (float*)buffer; +- (size_t)readBigEndianFloatsIntoBuffer: (float*)buffer + count: (size_t)nFloats; /** * \brief Reads the specified number of doubles from the stream which are * encoded in big endian. * @@ -230,12 +230,12 @@ * \param nDoubles The number of doubles to read * \param buffer A buffer of sufficient size to store the specified number of * doubles * \return The number of bytes read */ -- (size_t)readNBigEndianDoubles: (size_t)nDoubles - intoBuffer: (double*)buffer; +- (size_t)readBigEndianDoublesIntoBuffer: (double*)buffer + count: (size_t)nDoubles; /** * \brief Reads a uint16_t from the stream which is encoded in little endian. * * \warning Only call this when you know that enough data is available! @@ -295,12 +295,12 @@ * \param nInt16s The number of uint16_ts to read * \param buffer A buffer of sufficient size to store the specified number of * uint16_ts * \return The number of bytes read */ -- (size_t)readNLittleEndianInt16s: (size_t)nInt16s - intoBuffer: (uint16_t*)buffer; +- (size_t)readLittleEndianInt16sIntoBuffer: (uint16_t*)buffer + count: (size_t)nInt16s; /** * \brief Reads the specified number of uint32_ts from the stream which are * encoded in little endian. * @@ -310,12 +310,12 @@ * \param nInt32s The number of uint32_ts to read * \param buffer A buffer of sufficient size to store the specified number of * uint32_ts * \return The number of bytes read */ -- (size_t)readNLittleEndianInt32s: (size_t)nInt32s - intoBuffer: (uint32_t*)buffer; +- (size_t)readLittleEndianInt32sIntoBuffer: (uint32_t*)buffer + count: (size_t)nInt32s; /** * \brief Reads the specified number of uint64_ts from the stream which are * encoded in little endian. * @@ -325,12 +325,12 @@ * \param nInt64s The number of uint64_ts to read * \param buffer A buffer of sufficient size to store the specified number of * uint64_ts * \return The number of bytes read */ -- (size_t)readNLittleEndianInt64s: (size_t)nInt64s - intoBuffer: (uint64_t*)buffer; +- (size_t)readLittleEndianInt64sIntoBuffer: (uint64_t*)buffer + count: (size_t)nInt64s; /** * \brief Reads the specified number of floats from the stream which are * encoded in little endian. * @@ -340,12 +340,12 @@ * \param nFloats The number of floats to read * \param buffer A buffer of sufficient size to store the specified number of * floats * \return The number of bytes read */ -- (size_t)readNLittleEndianFloats: (size_t)nFloats - intoBuffer: (float*)buffer; +- (size_t)readLittleEndianFloatsIntoBuffer: (float*)buffer + count: (size_t)nFloats; /** * \brief Reads the specified number of doubles from the stream which are * encoded in little endian. * @@ -355,12 +355,12 @@ * \param nDoubles The number of doubles to read * \param buffer A buffer of sufficient size to store the specified number of * doubles * \return The number of bytes read */ -- (size_t)readNLittleEndianDoubles: (size_t)nDoubles - intoBuffer: (double*)buffer; +- (size_t)readLittleEndianDoublesIntoBuffer: (double*)buffer + count: (size_t)nDoubles; /** * \brief Reads the specified number of items with an item size of 1 from the * stream and returns them in an OFDataArray. * @@ -368,11 +368,11 @@ * Otherwise you will get an exception! * * \param nItems The number of items to read * \return An OFDataArray with at nItems items. */ -- (OFDataArray*)readDataArrayWithNItems: (size_t)nItems; +- (OFDataArray*)readDataArrayWithSize: (size_t)size; /** * \brief Reads the specified number of items with the specified item size from * the stream and returns them in an OFDataArray. * @@ -382,11 +382,11 @@ * \param itemSize The size of each item * \param nItems The number of items to read * \return An OFDataArray with at nItems items. */ - (OFDataArray*)readDataArrayWithItemSize: (size_t)itemSize - andNItems: (size_t)nItems; + count: (size_t)nItems; /** * \brief Returns an OFDataArray with all the remaining data of the stream. * * \return An OFDataArray with an item size of 1 with all the data of the @@ -423,12 +423,12 @@ * * \param encoding The encoding of the string to read from the stream * \param length The length (in bytes) of the string to read from the stream * \return A string with the specified length */ -- (OFString*)readStringWithEncoding: (of_string_encoding_t)encoding - length: (size_t)length; +- (OFString*)readStringWithLength: (size_t)length + encoding: (of_string_encoding_t)encoding; /** * \brief Reads until a newline, \\0 or end of stream occurs. * * \return The line that was read, autoreleased, or nil if the end of the @@ -484,11 +484,11 @@ * \param encoding The encoding used by the stream * \return The line that was read, autoreleased, or nil if the end of the * stream has been reached. */ - (OFString*)readTillDelimiter: (OFString*)delimiter - withEncoding: (of_string_encoding_t)encoding; + encoding: (of_string_encoding_t)encoding; /** * \brief Tries to reads until the specified string or \\0 is found or the end * of stream (see readTillDelimiter:) and returns nil if not enough data * has been received yet. @@ -508,25 +508,25 @@ * \param encoding The encoding used by the stream * \return The line that was read, autoreleased, or nil if the end of the * stream has been reached. */ - (OFString*)tryReadTillDelimiter: (OFString*)delimiter - withEncoding: (of_string_encoding_t)encoding; + encoding: (of_string_encoding_t)encoding; /** * \brief Returns a boolen whether writes are buffered. * * \return A boolean whether writes are buffered */ -- (BOOL)buffersWrites; +- (BOOL)writeBufferEnabled; /** * \brief Enables or disables the write buffer. * * \param enable Whether the write buffer should be enabled or disabled */ -- (void)setBuffersWrites: (BOOL)enable; +- (void)setWriteBufferEnabled: (BOOL)enable; /** * \brief Writes everythig in the write buffer to the stream. */ - (void)flushWriteBuffer; @@ -535,12 +535,12 @@ * \brief Writes from a buffer into the stream. * * \param buffer The buffer from which the data is written to the stream * \param length The length of the data that should be written */ -- (void)writeNBytes: (size_t)length - fromBuffer: (const void*)buffer; +- (void)writeBuffer: (const void*)buffer + length: (size_t)length; /** * \brief Writes a uint8_t into the stream. * * \param int8 A uint8_t @@ -589,12 +589,12 @@ * \param nInt16 The number of uint16_ts to write * \param buffer The buffer from which the data is written to the stream after * it has been byte swapped if necessary * \return The number of bytes written to the stream */ -- (size_t)writeNBigEndianInt16s: (size_t)nInt16s - fromBuffer: (const uint16_t*)buffer; +- (size_t)writeBigEndianInt16s: (const uint16_t*)buffer + count: (size_t)nInt16s; /** * \brief Writes the specified number of uint32_ts into the stream, encoded in * big endian. * @@ -601,12 +601,12 @@ * \param nInt32 The number of uint32_ts to write * \param buffer The buffer from which the data is written to the stream after * it has been byte swapped if necessary * \return The number of bytes written to the stream */ -- (size_t)writeNBigEndianInt32s: (size_t)nInt32s - fromBuffer: (const uint32_t*)buffer; +- (size_t)writeBigEndianInt32s: (const uint32_t*)buffer + count: (size_t)nInt32s; /** * \brief Writes the specified number of uint64_ts into the stream, encoded in * big endian. * @@ -613,12 +613,12 @@ * \param nInt64 The number of uint64_ts to write * \param buffer The buffer from which the data is written to the stream after * it has been byte swapped if necessary * \return The number of bytes written to the stream */ -- (size_t)writeNBigEndianInt64s: (size_t)nInt64s - fromBuffer: (const uint64_t*)buffer; +- (size_t)writeBigEndianInt64s: (const uint64_t*)buffer + count: (size_t)nInt64s; /** * \brief Writes the specified number of floats into the stream, encoded in big * endian. * @@ -625,12 +625,12 @@ * \param nFloats The number of floats to write * \param buffer The buffer from which the data is written to the stream after * it has been byte swapped if necessary * \return The number of bytes written to the stream */ -- (size_t)writeNBigEndianFloats: (size_t)nFloats - fromBuffer: (const float*)buffer; +- (size_t)writeBigEndianFloats: (const float*)buffer + count: (size_t)nFloats; /** * \brief Writes the specified number of doubles into the stream, encoded in * big endian. * @@ -637,12 +637,12 @@ * \param nDoubles The number of doubles to write * \param buffer The buffer from which the data is written to the stream after * it has been byte swapped if necessary * \return The number of bytes written to the stream */ -- (size_t)writeNBigEndianDoubles: (size_t)nDoubles - fromBuffer: (const double*)buffer; +- (size_t)writeBigEndianDoubles: (const double*)buffer + count: (size_t)nDoubles; /** * \brief Writes a uint16_t into the stream, encoded in little endian. * * \param int16 A uint16_t @@ -684,12 +684,12 @@ * \param nInt16 The number of uint16_ts to write * \param buffer The buffer from which the data is written to the stream after * it has been byte swapped if necessary * \return The number of bytes written to the stream */ -- (size_t)writeNLittleEndianInt16s: (size_t)nInt16s - fromBuffer: (const uint16_t*)buffer; +- (size_t)writeLittleEndianInt16s: (const uint16_t*)buffer + count: (size_t)nInt16s; /** * \brief Writes the specified number of uint32_ts into the stream, encoded in * little endian. * @@ -696,12 +696,12 @@ * \param nInt32 The number of uint32_ts to write * \param buffer The buffer from which the data is written to the stream after * it has been byte swapped if necessary * \return The number of bytes written to the stream */ -- (size_t)writeNLittleEndianInt32s: (size_t)nInt32s - fromBuffer: (const uint32_t*)buffer; +- (size_t)writeLittleEndianInt32s: (const uint32_t*)buffer + count: (size_t)nInt32s; /** * \brief Writes the specified number of uint64_ts into the stream, encoded in * little endian. * @@ -708,12 +708,12 @@ * \param nInt64 The number of uint64_ts to write * \param buffer The buffer from which the data is written to the stream after * it has been byte swapped if necessary * \return The number of bytes written to the stream */ -- (size_t)writeNLittleEndianInt64s: (size_t)nInt64s - fromBuffer: (const uint64_t*)buffer; +- (size_t)writeLittleEndianInt64s: (const uint64_t*)buffer + count: (size_t)nInt64s; /** * \brief Writes the specified number of floats into the stream, encoded in * little endian. * @@ -720,12 +720,12 @@ * \param nFloats The number of floats to write * \param buffer The buffer from which the data is written to the stream after * it has been byte swapped if necessary * \return The number of bytes written to the stream */ -- (size_t)writeNLittleEndianFloats: (size_t)nFloats - fromBuffer: (const float*)buffer; +- (size_t)writeLittleEndianFloats: (const float*)buffer + count: (size_t)nFloats; /** * \brief Writes the specified number of doubles into the stream, encoded in * little endian. * @@ -732,12 +732,12 @@ * \param nDoubles The number of doubles to write * \param buffer The buffer from which the data is written to the stream after * it has been byte swapped if necessary * \return The number of bytes written to the stream */ -- (size_t)writeNLittleEndianDoubles: (size_t)nDoubles - fromBuffer: (const double*)buffer; +- (size_t)writeLittleEndianDoubles: (const double*)buffer + count: (size_t)nDoubles; /** * \brief Writes from an OFDataArray into the stream. * * \param dataArray The OFDataArray to write into the stream @@ -781,16 +781,16 @@ * \param format A string used as format * \param arguments The arguments used in the format string * \return The number of bytes written */ - (size_t)writeFormat: (OFConstantString*)format - withArguments: (va_list)arguments; + arguments: (va_list)arguments; /** - * \brief Returns the number of bytes still present in the internal cache. + * \brief Returns the number of bytes still present in the internal read cache. * - * \return The number of bytes still present in the internal cache. + * \return The number of bytes still present in the internal read cache. */ - (size_t)pendingBytes; /** * \brief Returns whether the stream is in blocking mode. @@ -819,11 +819,11 @@ /** * \brief Closes the stream. */ - (void)close; -- (size_t)_readNBytes: (size_t)length - intoBuffer: (void*)buffer; -- (void)_writeNBytes: (size_t)length - fromBuffer: (const void*)buffer; +- (size_t)_readIntoBuffer: (void*)buffer + length: (size_t)length; +- (void)_writeBuffer: (const void*)buffer + length: (size_t)length; - (BOOL)_isWaitingForDelimiter; @end Index: src/OFStream.m ================================================================== --- src/OFStream.m +++ src/OFStream.m @@ -74,19 +74,19 @@ { @throw [OFNotImplementedException exceptionWithClass: isa selector: _cmd]; } -- (size_t)_readNBytes: (size_t)length - intoBuffer: (void*)buffer +- (size_t)_readIntoBuffer: (void*)buffer + length: (size_t)length { @throw [OFNotImplementedException exceptionWithClass: isa selector: _cmd]; } -- (void)_writeNBytes: (size_t)length - fromBuffer: (const void*)buffer +- (void)_writeBuffer: (const void*)buffer + length: (size_t)length { @throw [OFNotImplementedException exceptionWithClass: isa selector: _cmd]; } @@ -101,16 +101,16 @@ return NO; return [self _isAtEndOfStream]; } -- (size_t)readNBytes: (size_t)length - intoBuffer: (void*)buffer +- (size_t)readIntoBuffer: (void*)buffer + length: (size_t)length { if (cache == NULL) - return [self _readNBytes: length - intoBuffer: buffer]; + return [self _readIntoBuffer: buffer + length: length]; if (length >= cacheLength) { size_t ret = cacheLength; memcpy(buffer, cache, cacheLength); @@ -131,87 +131,87 @@ return length; } } -- (void)readExactlyNBytes: (size_t)length - intoBuffer: (void*)buffer +- (void)readIntoBuffer: (void*)buffer + exactLength: (size_t)length { size_t readLength = 0; while (readLength < length) - readLength += [self readNBytes: length - readLength - intoBuffer: (char*)buffer + readLength]; + readLength += [self readIntoBuffer: (char*)buffer + readLength + length: length - readLength]; } - (uint8_t)readInt8 { uint8_t ret; - [self readExactlyNBytes: 1 - intoBuffer: (char*)&ret]; + [self readIntoBuffer: (char*)&ret + exactLength: 1]; return ret; } - (uint16_t)readBigEndianInt16 { uint16_t ret; - [self readExactlyNBytes: 2 - intoBuffer: (char*)&ret]; + [self readIntoBuffer: (char*)&ret + exactLength: 2]; return of_bswap16_if_le(ret); } - (uint32_t)readBigEndianInt32 { uint32_t ret; - [self readExactlyNBytes: 4 - intoBuffer: (char*)&ret]; + [self readIntoBuffer: (char*)&ret + exactLength: 4]; return of_bswap32_if_le(ret); } - (uint64_t)readBigEndianInt64 { uint64_t ret; - [self readExactlyNBytes: 8 - intoBuffer: (char*)&ret]; + [self readIntoBuffer: (char*)&ret + exactLength: 8]; return of_bswap64_if_le(ret); } - (float)readBigEndianFloat { float ret; - [self readExactlyNBytes: 4 - intoBuffer: (char*)&ret]; + [self readIntoBuffer: (char*)&ret + exactLength: 4]; return of_bswap_float_if_le(ret); } - (double)readBigEndianDouble { double ret; - [self readExactlyNBytes: 8 - intoBuffer: (char*)&ret]; + [self readIntoBuffer: (char*)&ret + exactLength: 8]; return of_bswap_double_if_le(ret); } -- (size_t)readNBigEndianInt16s: (size_t)nInt16s - intoBuffer: (uint16_t*)buffer +- (size_t)readBigEndianInt16sIntoBuffer: (uint16_t*)buffer + count: (size_t)nInt16s { size_t size = nInt16s * sizeof(uint16_t); - [self readExactlyNBytes: size - intoBuffer: buffer]; + [self readIntoBuffer: buffer + exactLength: size]; #ifndef OF_BIG_ENDIAN size_t i; for (i = 0; i < nInt16s; i++) @@ -219,17 +219,17 @@ #endif return size; } -- (size_t)readNBigEndianInt32s: (size_t)nInt32s - intoBuffer: (uint32_t*)buffer +- (size_t)readBigEndianInt32sIntoBuffer: (uint32_t*)buffer + count: (size_t)nInt32s { size_t size = nInt32s * sizeof(uint32_t); - [self readExactlyNBytes: size - intoBuffer: buffer]; + [self readIntoBuffer: buffer + exactLength: size]; #ifndef OF_BIG_ENDIAN size_t i; for (i = 0; i < nInt32s; i++) @@ -237,17 +237,17 @@ #endif return size; } -- (size_t)readNBigEndianInt64s: (size_t)nInt64s - intoBuffer: (uint64_t*)buffer +- (size_t)readBigEndianInt64sIntoBuffer: (uint64_t*)buffer + count: (size_t)nInt64s { size_t size = nInt64s * sizeof(uint64_t); - [self readExactlyNBytes: size - intoBuffer: buffer]; + [self readIntoBuffer: buffer + exactLength: size]; #ifndef OF_BIG_ENDIAN size_t i; for (i = 0; i < nInt64s; i++) @@ -255,17 +255,17 @@ #endif return size; } -- (size_t)readNBigEndianFloats: (size_t)nFloats - intoBuffer: (float*)buffer +- (size_t)readBigEndianFloatsIntoBuffer: (float*)buffer + count: (size_t)nFloats { size_t size = nFloats * sizeof(float); - [self readExactlyNBytes: size - intoBuffer: buffer]; + [self readIntoBuffer: buffer + exactLength: size]; #ifndef OF_FLOAT_BIG_ENDIAN size_t i; for (i = 0; i < nFloats; i++) @@ -273,17 +273,17 @@ #endif return size; } -- (size_t)readNBigEndianDoubles: (size_t)nDoubles - intoBuffer: (double*)buffer +- (size_t)readBigEndianDoublesIntoBuffer: (double*)buffer + count: (size_t)nDoubles { size_t size = nDoubles * sizeof(double); - [self readExactlyNBytes: size - intoBuffer: buffer]; + [self readIntoBuffer: buffer + exactLength: size]; #ifndef OF_FLOAT_BIG_ENDIAN size_t i; for (i = 0; i < nDoubles; i++) @@ -295,63 +295,63 @@ - (uint16_t)readLittleEndianInt16 { uint16_t ret; - [self readExactlyNBytes: 2 - intoBuffer: (char*)&ret]; + [self readIntoBuffer: (char*)&ret + exactLength: 2]; return of_bswap16_if_be(ret); } - (uint32_t)readLittleEndianInt32 { uint32_t ret; - [self readExactlyNBytes: 4 - intoBuffer: (char*)&ret]; + [self readIntoBuffer: (char*)&ret + exactLength: 4]; return of_bswap32_if_be(ret); } - (uint64_t)readLittleEndianInt64 { uint64_t ret; - [self readExactlyNBytes: 8 - intoBuffer: (char*)&ret]; + [self readIntoBuffer: (char*)&ret + exactLength: 8]; return of_bswap64_if_be(ret); } - (float)readLittleEndianFloat { float ret; - [self readExactlyNBytes: 4 - intoBuffer: (char*)&ret]; + [self readIntoBuffer: (char*)&ret + exactLength: 4]; return of_bswap_float_if_be(ret); } - (double)readLittleEndianDouble { double ret; - [self readExactlyNBytes: 8 - intoBuffer: (char*)&ret]; + [self readIntoBuffer: (char*)&ret + exactLength: 8]; return of_bswap_double_if_be(ret); } -- (size_t)readNLittleEndianInt16s: (size_t)nInt16s - intoBuffer: (uint16_t*)buffer +- (size_t)readLittleEndianInt16sIntoBuffer: (uint16_t*)buffer + count: (size_t)nInt16s { size_t size = nInt16s * sizeof(uint16_t); - [self readExactlyNBytes: size - intoBuffer: buffer]; + [self readIntoBuffer: buffer + exactLength: size]; #ifdef OF_BIG_ENDIAN size_t i; for (i = 0; i < nInt16s; i++) @@ -359,17 +359,17 @@ #endif return size; } -- (size_t)readNLittleEndianInt32s: (size_t)nInt32s - intoBuffer: (uint32_t*)buffer +- (size_t)readLittleEndianInt32sIntoBuffer: (uint32_t*)buffer + count: (size_t)nInt32s { size_t size = nInt32s * sizeof(uint32_t); - [self readExactlyNBytes: size - intoBuffer: buffer]; + [self readIntoBuffer: buffer + exactLength: size]; #ifdef OF_BIG_ENDIAN size_t i; for (i = 0; i < nInt32s; i++) @@ -377,17 +377,17 @@ #endif return size; } -- (size_t)readNLittleEndianInt64s: (size_t)nInt64s - intoBuffer: (uint64_t*)buffer +- (size_t)readLittleEndianInt64sIntoBuffer: (uint64_t*)buffer + count: (size_t)nInt64s { size_t size = nInt64s * sizeof(uint64_t); - [self readExactlyNBytes: size - intoBuffer: buffer]; + [self readIntoBuffer: buffer + exactLength: size]; #ifdef OF_BIG_ENDIAN size_t i; for (i = 0; i < nInt64s; i++) @@ -395,17 +395,17 @@ #endif return size; } -- (size_t)readNLittleEndianFloats: (size_t)nFloats - intoBuffer: (float*)buffer +- (size_t)readLittleEndianFloatsIntoBuffer: (float*)buffer + count: (size_t)nFloats { size_t size = nFloats * sizeof(float); - [self readExactlyNBytes: size - intoBuffer: buffer]; + [self readIntoBuffer: buffer + exactLength: size]; #ifdef OF_FLOAT_BIG_ENDIAN size_t i; for (i = 0; i < nFloats; i++) @@ -413,17 +413,17 @@ #endif return size; } -- (size_t)readNLittleEndianDoubles: (size_t)nDoubles - intoBuffer: (double*)buffer +- (size_t)readLittleEndianDoublesIntoBuffer: (double*)buffer + count: (size_t)nDoubles { size_t size = nDoubles * sizeof(double); - [self readExactlyNBytes: size - intoBuffer: buffer]; + [self readIntoBuffer: buffer + exactLength: size]; #ifdef OF_FLOAT_BIG_ENDIAN size_t i; for (i = 0; i < nDoubles; i++) @@ -431,29 +431,29 @@ #endif return size; } -- (OFDataArray*)readDataArrayWithNItems: (size_t)nItems +- (OFDataArray*)readDataArrayWithSize: (size_t)nItems { return [self readDataArrayWithItemSize: 1 - andNItems: nItems]; + count: nItems]; } - (OFDataArray*)readDataArrayWithItemSize: (size_t)itemSize - andNItems: (size_t)nItems + count: (size_t)nItems { OFDataArray *dataArray; char *tmp; dataArray = [OFDataArray dataArrayWithItemSize: itemSize]; tmp = [self allocMemoryWithItemSize: itemSize count: nItems]; @try { - [self readExactlyNBytes: nItems * itemSize - intoBuffer: tmp]; + [self readIntoBuffer: tmp + exactLength: nItems * itemSize]; [dataArray addItemsFromCArray: tmp count: nItems]; } @finally { [self freeMemory: tmp]; @@ -472,12 +472,12 @@ @try { while (![self isAtEndOfStream]) { size_t length; - length = [self readNBytes: of_pagesize - intoBuffer: buffer]; + length = [self readIntoBuffer: buffer + length: of_pagesize]; [dataArray addItemsFromCArray: buffer count: length]; } } @finally { [self freeMemory: buffer]; @@ -486,24 +486,24 @@ return dataArray; } - (OFString*)readStringWithLength: (size_t)length { - return [self readStringWithEncoding: OF_STRING_ENCODING_UTF_8 - length: length]; + return [self readStringWithLength: length + encoding: OF_STRING_ENCODING_UTF_8]; } -- (OFString*)readStringWithEncoding: (of_string_encoding_t)encoding - length: (size_t)length +- (OFString*)readStringWithLength: (size_t)length + encoding: (of_string_encoding_t)encoding { OFString *ret; char *buffer = [self allocMemoryWithSize: length + 1]; buffer[length] = 0; @try { - [self readExactlyNBytes: length - intoBuffer: buffer]; + [self readIntoBuffer: buffer + exactLength: length]; ret = [OFString stringWithCString: buffer encoding: encoding]; } @finally { [self freeMemory: buffer]; @@ -573,12 +573,12 @@ waitingForDelimiter = NO; return ret; } - bufferLength = [self _readNBytes: of_pagesize - intoBuffer: buffer]; + bufferLength = [self _readIntoBuffer: buffer + length: of_pagesize]; /* Look if there's a newline or \0 */ for (i = 0; i < bufferLength; i++) { if (OF_UNLIKELY(buffer[i] == '\n' || buffer[i] == '\0')) { @@ -678,11 +678,11 @@ { return [self tryReadLineWithEncoding: OF_STRING_ENCODING_UTF_8]; } - (OFString*)tryReadTillDelimiter: (OFString*)delimiter - withEncoding: (of_string_encoding_t)encoding + encoding: (of_string_encoding_t)encoding { const char *delimiterUTF8String; size_t i, j, delimiterLength, bufferLength, retLength; char *retCString, *buffer, *newCache; OFString *ret; @@ -747,12 +747,12 @@ waitingForDelimiter = NO; return ret; } - bufferLength = [self _readNBytes: of_pagesize - intoBuffer: buffer]; + bufferLength = [self _readIntoBuffer: buffer + length: of_pagesize]; /* Look if there's a delimiter or \0 */ for (i = 0; i < bufferLength; i++) { if (buffer[i] != delimiterUTF8String[j++]) j = 0; @@ -824,62 +824,62 @@ - (OFString*)readTillDelimiter: (OFString*)delimiter { return [self readTillDelimiter: delimiter - withEncoding: OF_STRING_ENCODING_UTF_8]; + encoding: OF_STRING_ENCODING_UTF_8]; } - (OFString*)readTillDelimiter: (OFString*)delimiter - withEncoding: (of_string_encoding_t)encoding + encoding: (of_string_encoding_t)encoding { OFString *ret = nil; while ((ret = [self tryReadTillDelimiter: delimiter - withEncoding: encoding]) == nil) + encoding: encoding]) == nil) if ([self isAtEndOfStream]) return nil; return ret; } - (OFString*)tryReadTillDelimiter: (OFString*)delimiter { return [self tryReadTillDelimiter: delimiter - withEncoding: OF_STRING_ENCODING_UTF_8]; + encoding: OF_STRING_ENCODING_UTF_8]; } -- (BOOL)buffersWrites +- (BOOL)writeBufferEnabled { - return buffersWrites; + return writeBufferEnabled; } -- (void)setBuffersWrites: (BOOL)enable +- (void)setWriteBufferEnabled: (BOOL)enable { - buffersWrites = enable; + writeBufferEnabled = enable; } - (void)flushWriteBuffer { if (writeBuffer == NULL) return; - [self _writeNBytes: writeBufferLength - fromBuffer: writeBuffer]; + [self _writeBuffer: writeBuffer + length: writeBufferLength]; [self freeMemory: writeBuffer]; writeBuffer = NULL; writeBufferLength = 0; } -- (void)writeNBytes: (size_t)length - fromBuffer: (const void*)buffer +- (void)writeBuffer: (const void*)buffer + length: (size_t)length { - if (!buffersWrites) - [self _writeNBytes: length - fromBuffer: buffer]; + if (!writeBufferEnabled) + [self _writeBuffer: buffer + length: length]; else { writeBuffer = [self resizeMemory: writeBuffer toSize: writeBufferLength + length]; memcpy(writeBuffer + writeBufferLength, buffer, length); writeBufferLength += length; @@ -886,62 +886,62 @@ } } - (void)writeInt8: (uint8_t)int8 { - [self writeNBytes: 1 - fromBuffer: (char*)&int8]; + [self writeBuffer: (char*)&int8 + length: 1]; } - (void)writeBigEndianInt16: (uint16_t)int16 { int16 = of_bswap16_if_le(int16); - [self writeNBytes: 2 - fromBuffer: (char*)&int16]; + [self writeBuffer: (char*)&int16 + length: 2]; } - (void)writeBigEndianInt32: (uint32_t)int32 { int32 = of_bswap32_if_le(int32); - [self writeNBytes: 4 - fromBuffer: (char*)&int32]; + [self writeBuffer: (char*)&int32 + length: 4]; } - (void)writeBigEndianInt64: (uint64_t)int64 { int64 = of_bswap64_if_le(int64); - [self writeNBytes: 8 - fromBuffer: (char*)&int64]; + [self writeBuffer: (char*)&int64 + length: 8]; } - (void)writeBigEndianFloat: (float)float_ { float_ = of_bswap_float_if_le(float_); - [self writeNBytes: 4 - fromBuffer: (char*)&float_]; + [self writeBuffer: (char*)&float_ + length: 4]; } - (void)writeBigEndianDouble: (double)double_ { double_ = of_bswap_double_if_le(double_); - [self writeNBytes: 8 - fromBuffer: (char*)&double_]; + [self writeBuffer: (char*)&double_ + length: 8]; } -- (size_t)writeNBigEndianInt16s: (size_t)nInt16s - fromBuffer: (const uint16_t*)buffer +- (size_t)writeBigEndianInt16s: (const uint16_t*)buffer + count: (size_t)nInt16s { size_t size = nInt16s * sizeof(uint16_t); #ifdef OF_BIG_ENDIAN - [self writeNBytes: size - fromBuffer: buffer]; + [self writeBuffer: buffer + length: size]; #else uint16_t *tmp; tmp = [self allocMemoryWithItemSize: sizeof(uint16_t) count: nInt16s]; @@ -950,28 +950,28 @@ size_t i; for (i = 0; i < nInt16s; i++) tmp[i] = of_bswap16(buffer[i]); - [self writeNBytes: size - fromBuffer: tmp]; + [self writeBuffer: tmp + length: size]; } @finally { [self freeMemory: tmp]; } #endif return size; } -- (size_t)writeNBigEndianInt32s: (size_t)nInt32s - fromBuffer: (const uint32_t*)buffer +- (size_t)writeBigEndianInt32s: (const uint32_t*)buffer + count: (size_t)nInt32s { size_t size = nInt32s * sizeof(uint32_t); #ifdef OF_BIG_ENDIAN - [self writeNBytes: size - fromBuffer: buffer]; + [self writeBuffer: buffer + length: size]; #else uint32_t *tmp; tmp = [self allocMemoryWithItemSize: sizeof(uint32_t) count: nInt32s]; @@ -980,28 +980,28 @@ size_t i; for (i = 0; i < nInt32s; i++) tmp[i] = of_bswap32(buffer[i]); - [self writeNBytes: size - fromBuffer: tmp]; + [self writeBuffer: tmp + length: size]; } @finally { [self freeMemory: tmp]; } #endif return size; } -- (size_t)writeNBigEndianInt64s: (size_t)nInt64s - fromBuffer: (const uint64_t*)buffer +- (size_t)writeBigEndianInt64s: (const uint64_t*)buffer + count: (size_t)nInt64s { size_t size = nInt64s * sizeof(uint64_t); #ifdef OF_BIG_ENDIAN - [self writeNBytes: size - fromBuffer: buffer]; + [self writeBuffer: buffer + length: size]; #else uint64_t *tmp; tmp = [self allocMemoryWithItemSize: sizeof(uint64_t) count: nInt64s]; @@ -1010,28 +1010,28 @@ size_t i; for (i = 0; i < nInt64s; i++) tmp[i] = of_bswap64(buffer[i]); - [self writeNBytes: size - fromBuffer: tmp]; + [self writeBuffer: tmp + length: size]; } @finally { [self freeMemory: tmp]; } #endif return size; } -- (size_t)writeNBigEndianFloats: (size_t)nFloats - fromBuffer: (const float*)buffer +- (size_t)writeBigEndianFloats: (const float*)buffer + count: (size_t)nFloats { size_t size = nFloats * sizeof(float); #ifdef OF_FLOAT_BIG_ENDIAN - [self writeNBytes: size - fromBuffer: buffer]; + [self writeBuffer: buffer + length: size]; #else float *tmp; tmp = [self allocMemoryWithItemSize: sizeof(float) count: nFloats]; @@ -1040,28 +1040,28 @@ size_t i; for (i = 0; i < nFloats; i++) tmp[i] = of_bswap_float(buffer[i]); - [self writeNBytes: size - fromBuffer: tmp]; + [self writeBuffer: tmp + length: size]; } @finally { [self freeMemory: tmp]; } #endif return size; } -- (size_t)writeNBigEndianDoubles: (size_t)nDoubles - fromBuffer: (const double*)buffer +- (size_t)writeBigEndianDoubles: (const double*)buffer + count: (size_t)nDoubles { size_t size = nDoubles * sizeof(double); #ifdef OF_FLOAT_BIG_ENDIAN - [self writeNBytes: size - fromBuffer: buffer]; + [self writeBuffer: buffer + length: size]; #else double *tmp; tmp = [self allocMemoryWithItemSize: sizeof(double) count: nDoubles]; @@ -1070,12 +1070,12 @@ size_t i; for (i = 0; i < nDoubles; i++) tmp[i] = of_bswap_double(buffer[i]); - [self writeNBytes: size - fromBuffer: tmp]; + [self writeBuffer: tmp + length: size]; } @finally { [self freeMemory: tmp]; } #endif @@ -1084,54 +1084,54 @@ - (void)writeLittleEndianInt16: (uint16_t)int16 { int16 = of_bswap16_if_be(int16); - [self writeNBytes: 2 - fromBuffer: (char*)&int16]; + [self writeBuffer: (char*)&int16 + length: 2]; } - (void)writeLittleEndianInt32: (uint32_t)int32 { int32 = of_bswap32_if_be(int32); - [self writeNBytes: 4 - fromBuffer: (char*)&int32]; + [self writeBuffer: (char*)&int32 + length: 4]; } - (void)writeLittleEndianInt64: (uint64_t)int64 { int64 = of_bswap64_if_be(int64); - [self writeNBytes: 8 - fromBuffer: (char*)&int64]; + [self writeBuffer: (char*)&int64 + length: 8]; } - (void)writeLittleEndianFloat: (float)float_ { float_ = of_bswap_float_if_be(float_); - [self writeNBytes: 4 - fromBuffer: (char*)&float_]; + [self writeBuffer: (char*)&float_ + length: 4]; } - (void)writeLittleEndianDouble: (double)double_ { double_ = of_bswap_double_if_be(double_); - [self writeNBytes: 8 - fromBuffer: (char*)&double_]; + [self writeBuffer: (char*)&double_ + length: 8]; } -- (size_t)writeNLittleEndianInt16s: (size_t)nInt16s - fromBuffer: (const uint16_t*)buffer +- (size_t)writeLittleEndianInt16s: (const uint16_t*)buffer + count: (size_t)nInt16s { size_t size = nInt16s * sizeof(uint16_t); #ifndef OF_BIG_ENDIAN - [self writeNBytes: size - fromBuffer: buffer]; + [self writeBuffer: buffer + length: size]; #else uint16_t *tmp; tmp = [self allocMemoryWithItemSize: sizeof(uint16_t) count: nInt16s]; @@ -1140,28 +1140,28 @@ size_t i; for (i = 0; i < nInt16s; i++) tmp[i] = of_bswap16(buffer[i]); - [self writeNBytes: size - fromBuffer: tmp]; + [self writeBuffer: tmp + length: size]; } @finally { [self freeMemory: tmp]; } #endif return size; } -- (size_t)writeNLittleEndianInt32s: (size_t)nInt32s - fromBuffer: (const uint32_t*)buffer +- (size_t)writeLittleEndianInt32s: (const uint32_t*)buffer + count: (size_t)nInt32s { size_t size = nInt32s * sizeof(uint32_t); #ifndef OF_BIG_ENDIAN - [self writeNBytes: size - fromBuffer: buffer]; + [self writeBuffer: buffer + length: size]; #else uint32_t *tmp; tmp = [self allocMemoryWithItemSize: sizeof(uint32_t) count: nInt32s]; @@ -1170,28 +1170,28 @@ size_t i; for (i = 0; i < nInt32s; i++) tmp[i] = of_bswap32(buffer[i]); - [self writeNBytes: size - fromBuffer: tmp]; + [self writeBuffer: tmp + length: size]; } @finally { [self freeMemory: tmp]; } #endif return size; } -- (size_t)writeNLittleEndianInt64s: (size_t)nInt64s - fromBuffer: (const uint64_t*)buffer +- (size_t)writeLittleEndianInt64s: (const uint64_t*)buffer + count: (size_t)nInt64s { size_t size = nInt64s * sizeof(uint64_t); #ifndef OF_BIG_ENDIAN - [self writeNBytes: size - fromBuffer: buffer]; + [self writeBuffer: buffer + length: size]; #else uint64_t *tmp; tmp = [self allocMemoryWithItemSize: sizeof(uint64_t) count: nInt64s]; @@ -1200,28 +1200,28 @@ size_t i; for (i = 0; i < nInt64s; i++) tmp[i] = of_bswap64(buffer[i]); - [self writeNBytes: size - fromBuffer: tmp]; + [self writeBuffer: tmp + length: size]; } @finally { [self freeMemory: tmp]; } #endif return size; } -- (size_t)writeNLittleEndianFloats: (size_t)nFloats - fromBuffer: (const float*)buffer +- (size_t)writeLittleEndianFloats: (const float*)buffer + count: (size_t)nFloats { size_t size = nFloats * sizeof(float); #ifndef OF_FLOAT_BIG_ENDIAN - [self writeNBytes: size - fromBuffer: buffer]; + [self writeBuffer: buffer + length: size]; #else float *tmp; tmp = [self allocMemoryWithItemSize: sizeof(float) count: nFloats]; @@ -1230,28 +1230,28 @@ size_t i; for (i = 0; i < nFloats; i++) tmp[i] = of_bswap_float(buffer[i]); - [self writeNBytes: size - fromBuffer: tmp]; + [self writeBuffer: tmp + length: size]; } @finally { [self freeMemory: tmp]; } #endif return size; } -- (size_t)writeNLittleEndianDoubles: (size_t)nDoubles - fromBuffer: (const double*)buffer +- (size_t)writeLittleEndianDoubles: (const double*)buffer + count: (size_t)nDoubles { size_t size = nDoubles * sizeof(double); #ifndef OF_FLOAT_BIG_ENDIAN - [self writeNBytes: size - fromBuffer: buffer]; + [self writeBuffer: buffer + length: size]; #else double *tmp; tmp = [self allocMemoryWithItemSize: sizeof(double) count: nDoubles]; @@ -1260,12 +1260,12 @@ size_t i; for (i = 0; i < nDoubles; i++) tmp[i] = of_bswap_double(buffer[i]); - [self writeNBytes: size - fromBuffer: tmp]; + [self writeBuffer: tmp + length: size]; } @finally { [self freeMemory: tmp]; } #endif @@ -1274,22 +1274,22 @@ - (size_t)writeDataArray: (OFDataArray*)dataArray { size_t length = [dataArray count] * [dataArray itemSize]; - [self writeNBytes: length - fromBuffer: [dataArray cArray]]; + [self writeBuffer: [dataArray cArray] + length: length]; return [dataArray count] * [dataArray itemSize]; } - (size_t)writeString: (OFString*)string { size_t length = [string UTF8StringLength]; - [self writeNBytes: length - fromBuffer: [string UTF8String]]; + [self writeBuffer: [string UTF8String] + length: length]; return length; } - (size_t)writeLine: (OFString*)string @@ -1301,12 +1301,12 @@ @try { memcpy(buffer, [string UTF8String], stringLength); buffer[stringLength] = '\n'; - [self writeNBytes: stringLength + 1 - fromBuffer: buffer]; + [self writeBuffer: buffer + length: stringLength + 1]; } @finally { [self freeMemory: buffer]; } return stringLength + 1; @@ -1317,18 +1317,18 @@ va_list arguments; size_t ret; va_start(arguments, format); ret = [self writeFormat: format - withArguments: arguments]; + arguments: arguments]; va_end(arguments); return ret; } - (size_t)writeFormat: (OFConstantString*)format - withArguments: (va_list)arguments + arguments: (va_list)arguments { char *UTF8String; int length; if (format == nil) @@ -1338,12 +1338,12 @@ if ((length = of_vasprintf(&UTF8String, [format UTF8String], arguments)) == -1) @throw [OFInvalidFormatException exceptionWithClass: isa]; @try { - [self writeNBytes: length - fromBuffer: UTF8String]; + [self writeBuffer: UTF8String + length: length]; } @finally { free(UTF8String); } return length; Index: src/OFStreamSocket.m ================================================================== --- src/OFStreamSocket.m +++ src/OFStreamSocket.m @@ -68,12 +68,12 @@ - (BOOL)_isAtEndOfStream { return atEndOfStream; } -- (size_t)_readNBytes: (size_t)length - intoBuffer: (void*)buffer +- (size_t)_readIntoBuffer: (void*)buffer + length: (size_t)length { ssize_t ret; if (sock == INVALID_SOCKET) @throw [OFNotConnectedException exceptionWithClass: isa @@ -103,12 +103,12 @@ atEndOfStream = YES; return ret; } -- (void)_writeNBytes: (size_t)length - fromBuffer: (const void*)buffer +- (void)_writeBuffer: (const void*)buffer + length: (size_t)length { if (sock == INVALID_SOCKET) @throw [OFNotConnectedException exceptionWithClass: isa socket: self]; Index: src/OFString.m ================================================================== --- src/OFString.m +++ src/OFString.m @@ -830,12 +830,12 @@ mode: @"rb"]; @try { tmp = [self allocMemoryWithSize: (size_t)st.st_size]; - [file readExactlyNBytes: (size_t)st.st_size - intoBuffer: tmp]; + [file readIntoBuffer: tmp + exactLength: (size_t)st.st_size]; } @finally { [file release]; } } @catch (id e) { [self release]; Index: src/OFTCPSocket+SOCKS5.m ================================================================== --- src/OFTCPSocket+SOCKS5.m +++ src/OFTCPSocket+SOCKS5.m @@ -27,18 +27,18 @@ - (void)_SOCKS5ConnectToHost: (OFString*)host port: (uint16_t)port { const char request[] = { 5, 1, 0, 3 }; char reply[256]; - BOOL oldBuffersWrites; + BOOL oldWriteBufferEnabled; /* 5 1 0 -> no authentication */ - [self writeNBytes: 3 - fromBuffer: request]; + [self writeBuffer: request + length: 3]; - [self readExactlyNBytes: 2 - intoBuffer: reply]; + [self readIntoBuffer: reply + exactLength: 2]; if (reply[0] != 5 || reply[1] != 0) { [self close]; @throw [OFConnectionFailedException exceptionWithClass: isa @@ -45,29 +45,29 @@ socket: self host: host port: port]; } - oldBuffersWrites = [self buffersWrites]; - [self setBuffersWrites: YES]; + oldWriteBufferEnabled = [self writeBufferEnabled]; + [self setWriteBufferEnabled: YES]; /* CONNECT request */ - [self writeNBytes: 4 - fromBuffer: request]; + [self writeBuffer: request + length: 4]; [self writeInt8: [host cStringLengthWithEncoding: OF_STRING_ENCODING_NATIVE]]; - [self writeNBytes: [host cStringLengthWithEncoding: + [self writeBuffer: [host cStringWithEncoding: OF_STRING_ENCODING_NATIVE] - fromBuffer: [host cStringWithEncoding: + length: [host cStringLengthWithEncoding: OF_STRING_ENCODING_NATIVE]]; [self writeBigEndianInt16: port]; [self flushWriteBuffer]; - [self setBuffersWrites: oldBuffersWrites]; + [self setWriteBufferEnabled: oldWriteBufferEnabled]; - [self readExactlyNBytes: 4 - intoBuffer: reply]; + [self readIntoBuffer: reply + exactLength: 4]; if (reply[0] != 5 || reply[1] != 0 || reply[2] != 0) { [self close]; @throw [OFConnectionFailedException exceptionWithClass: isa socket: self @@ -76,20 +76,20 @@ } /* Skip the rest of the reply */ switch (reply[3]) { case 1: /* IPv4 */ - [self readExactlyNBytes: 4 - intoBuffer: reply]; + [self readIntoBuffer: reply + exactLength: 4]; break; case 3: /* Domainname */ - [self readExactlyNBytes: [self readInt8] - intoBuffer: reply]; + [self readIntoBuffer: reply + exactLength: [self readInt8]]; break; case 4: /* IPv6 */ - [self readExactlyNBytes: 16 - intoBuffer: reply]; + [self readIntoBuffer: reply + exactLength: 16]; break; default: [self close]; @throw [OFConnectionFailedException exceptionWithClass: isa socket: self Index: src/OFXMLParser.m ================================================================== --- src/OFXMLParser.m +++ src/OFXMLParser.m @@ -270,12 +270,12 @@ { char *buffer = [self allocMemoryWithSize: of_pagesize]; @try { while (![stream isAtEndOfStream]) { - size_t length = [stream readNBytes: of_pagesize - intoBuffer: buffer]; + size_t length = [stream readIntoBuffer: buffer + length: of_pagesize]; [self parseBuffer: buffer length: length]; } } @finally { Index: tests/OFMD5HashTests.m ================================================================== --- tests/OFMD5HashTests.m +++ tests/OFMD5HashTests.m @@ -42,12 +42,12 @@ TEST(@"+[MD5Hash]", (md5 = [OFMD5Hash MD5Hash])) while (![f isAtEndOfStream]) { char buf[64]; - size_t len = [f readNBytes: 64 - intoBuffer: buf]; + size_t len = [f readIntoBuffer: buf + length: 64]; [md5 updateWithBuffer: buf length: len]; } [f close]; Index: tests/OFSHA1HashTests.m ================================================================== --- tests/OFSHA1HashTests.m +++ tests/OFSHA1HashTests.m @@ -43,12 +43,12 @@ TEST(@"+[SHA1Hash]", (sha1 = [OFSHA1Hash SHA1Hash])) while (![f isAtEndOfStream]) { char buf[64]; - size_t len = [f readNBytes: 64 - intoBuffer: buf]; + size_t len = [f readIntoBuffer: buf + length: 64]; [sha1 updateWithBuffer: buf length: len]; } [f close]; Index: tests/OFStreamTests.m ================================================================== --- tests/OFStreamTests.m +++ tests/OFStreamTests.m @@ -36,12 +36,12 @@ - (BOOL)_isAtEndOfStream { return (state > 1 ? YES : NO); } -- (size_t)_readNBytes: (size_t)size - intoBuffer: (void*)buffer +- (size_t)_readIntoBuffer: (void*)buffer + length: (size_t)size { switch (state) { case 0: if (size < 1) return 0; Index: tests/OFTCPSocketTests.m ================================================================== --- tests/OFTCPSocketTests.m +++ tests/OFTCPSocketTests.m @@ -54,12 +54,12 @@ TEST(@"-[remoteAddress]", [[accepted remoteAddress] isEqual: @"127.0.0.1"]) TEST(@"-[writeString:]", [client writeString: @"Hello!"]) - TEST(@"-[readNBytes:intoBuffer:]", [accepted readNBytes: 6 - intoBuffer: buf] && + TEST(@"-[readIntoBuffer:length:]", [accepted readIntoBuffer: buf + length: 6] && !memcmp(buf, "Hello!", 6)) [pool drain]; } @end