@@ -23,10 +23,11 @@ #include #import "OFObject.h" #import "OFString.h" +#import "OFKernelEventObserver.h" /*! @file */ @class OFStream; @class OFDataArray; @@ -73,11 +74,12 @@ * 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 lowlevel prefix, you *will* break * caching and get broken results! */ -@interface OFStream: OFObject +@interface OFStream: OFObject { char *_readBuffer, *_writeBuffer; size_t _readBufferLength, _writeBufferLength; bool _writeBufferEnabled, _blocking, _waitingForDelimiter; } @@ -138,10 +140,13 @@ * 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 * @ref asyncReadIntoBuffer:exactLength:block:. Note that a read can even * return 0 bytes - this does not necessarily mean that the stream ended, so * you still need to check @ref isAtEndOfStream. + * + * @note The stream must implement @ref fileDescriptorForReading and return a + * valid file descriptor in order for this to work! * * @param buffer The buffer into which the data is read. * The buffer must not be free'd before the async read completed! * @param length The length of the data that should be read at most. * The buffer *must* be *at least* this big! @@ -166,10 +171,13 @@ * * Unlike @ref asyncReadIntoBuffer:length:target:selector:, this method does * not call the method when less than the specified length has been read - * instead, it waits until it got exactly the specified length, the stream has * ended or an exception occurred. + * + * @note The stream must implement @ref fileDescriptorForReading and return a + * valid file descriptor in order for this to work! * * @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 *at least* this big! * @param target The target on which the selector should be called when the @@ -195,10 +203,13 @@ * 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 * @ref asyncReadIntoBuffer:exactLength:block:. Note that a read can even * return 0 bytes - this does not necessarily mean that the stream ended, so * you still need to check @ref isAtEndOfStream. + * + * @note The stream must implement @ref fileDescriptorForReading and return a + * valid file descriptor in order for this to work! * * @param buffer The buffer into which the data is read. * The buffer must not be free'd before the async read completed! * @param length The length of the data that should be read at most. * The buffer *must* be *at least* this big! @@ -218,10 +229,13 @@ * * Unlike @ref asyncReadIntoBuffer:length:block:, this method does not invoke * the block when less than the specified length has been read - instead, it * waits until it got exactly the specified length, the stream has ended or an * exception occurred. + * + * @note The stream must implement @ref fileDescriptorForReading and return a + * valid file descriptor in order for this to work! * * @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 *at least* this big! * @param block The block to call when the data has been received. @@ -584,10 +598,13 @@ #ifdef OF_HAVE_SOCKETS /*! * @brief Asyncronously reads until a newline, \\0, end of stream or an * exception occurs. + * + * @note The stream must implement @ref fileDescriptorForReading and return a + * valid file descriptor in order for this to work! * * @param target The target on which to call the selector when the data has * been received. If the method returns true, it will be called * again when the next line has been received. If you want the * next method in the queue to handle the next line, you need to @@ -600,10 +617,13 @@ selector: (SEL)selector; /*! * @brief Asyncronously reads with the specified encoding until a newline, \\0, * end of stream or an exception occurs. + * + * @note The stream must implement @ref fileDescriptorForReading and return a + * valid file descriptor in order for this to work! * * @param encoding The encoding used by the stream * @param target The target on which to call the selector when the data has * been received. If the method returns true, it will be called * again when the next line has been received. If you want the @@ -619,10 +639,13 @@ # ifdef OF_HAVE_BLOCKS /*! * @brief Asyncronously reads until a newline, \\0, end of stream or an * exception occurs. + * + * @note The stream must implement @ref fileDescriptorForReading and return a + * valid file descriptor in order for this to work! * * @param block The block to call when the data has been received. * If the block returns true, it will be called again when the next * line has been received. If you want the next block in the queue * to handle the next line, you need to return false from the @@ -631,10 +654,13 @@ - (void)asyncReadLineWithBlock: (of_stream_async_read_line_block_t)block; /*! * @brief Asyncronously reads with the specified encoding until a newline, \\0, * end of stream or an exception occurs. + * + * @note The stream must implement @ref fileDescriptorForReading and return a + * valid file descriptor in order for this to work! * * @param encoding The encoding used by the stream * @param block The block to call when the data has been received. * If the block returns true, it will be called again when the next * line has been received. If you want the next block in the queue