X-Git-Url: http://git.silcnet.org/gitweb/?a=blobdiff_plain;f=lib%2Fsilcutil%2Fsilcfdstream.h;h=285c796d07dcd6bfeaf06100e4349a11c0c845a8;hb=e7b6c157b80152bf9fb9266e6bdd93f9fb0db776;hp=f5a95e3a6f50b6a7b60b7e2ef2f46c162b51fb76;hpb=00607b678dedef3396c9d9ec48797ec50e4724a5;p=silc.git diff --git a/lib/silcutil/silcfdstream.h b/lib/silcutil/silcfdstream.h index f5a95e3a..285c796d 100644 --- a/lib/silcutil/silcfdstream.h +++ b/lib/silcutil/silcfdstream.h @@ -38,92 +38,113 @@ * * SYNOPSIS * - * SilcStream silc_fd_stream_create(int fd); + * SilcStream silc_fd_stream_create(int fd, SilcStack stack); * * DESCRIPTION * * Creates file descriptor stream for the open file descriptor indicated * by `fd'. The stream is closed with the silc_stream_close and destroyed - * with the silc_stream_destroy. + * with the silc_stream_destroy. Returns NULL if system is out of memory. * - * The silc_stream_set_notifier must be called in order to be able to read - * from and write to this file descriptor stream if the `fd' is in + * If the silc_stream_set_notifier is called the stream is set to * non-blocking mode. * + * If `stack' is non-NULL all memory is allocated from the `stack' and + * will be released back to `stack' after the stream is destroyed. + * ***/ -SilcStream silc_fd_stream_create(int fd); +SilcStream silc_fd_stream_create(int fd, SilcStack stack); /****f* silcutil/SilcFDStreamAPI/silc_fd_stream_create2 * * SYNOPSIS * - * SilcStream silc_fd_stream_create2(int read_fd, int write_fd); + * SilcStream silc_fd_stream_create2(int read_fd, int write_fd, + * SilcStack stack); * * DESCRIPTION * * Creates file descriptor stream for the open file descriptors indicated * by `read_fd' and `write_fd'. The `read_fd' must be opened for reading * and `write_fd' opened for writing. The stream is closed with the - * silc_stream_close and destroyed with the silc_stream_destroy. + * silc_stream_close and destroyed with the silc_stream_destroy. Returns + * NULL if system is out of memory. * - * The silc_stream_set_notifier must be called in order to be able to read - * from and write to this file descriptor stream if the `fd' is in + * If the silc_stream_set_notifier is called the stream is set to * non-blocking mode. * + * If `stack' is non-NULL all memory is allocated from the `stack' and + * will be released back to `stack' after the stream is destroyed. + * ***/ -SilcStream silc_fd_stream_create2(int read_fd, int write_fd); +SilcStream silc_fd_stream_create2(int read_fd, int write_fd, SilcStack stack); /****f* silcutil/SilcFDStreamAPI/silc_fd_stream_file * * SYNOPSIS * * SilcStream silc_fd_stream_file(const char *filename, SilcBool reading, - * SilcBool writing); + * SilcBool writing, SilcStack stack); * * DESCRIPTION * * Same as silc_fd_stream_create but creates the stream by opening the * file indicated by `filename'. If the `reading' is TRUE the file is * opened for reading. If the `writing' is TRUE the file is opened - * for writing. + * for writing. Returns NULL if system is out of memory. * - * The silc_stream_set_notifier must be called in order to be able to read - * from and write to this file descriptor stream if the `fd' is in + * If the silc_stream_set_notifier is called the stream is set to * non-blocking mode. * + * If `stack' is non-NULL all memory is allocated from the `stack' and + * will be released back to `stack' after the stream is destroyed. + * ***/ SilcStream silc_fd_stream_file(const char *filename, SilcBool reading, - SilcBool writing); + SilcBool writing, SilcStack stack); -/****f* silcutil/SilcFDStreamAPI/silc_fd_stream_get_info +/****f* silcutil/SilcFDStreamAPI/silc_fd_stream_file2 * * SYNOPSIS * - * SilcBool - * silc_fd_stream_get_info(SilcStream stream, int *read_fd, int *write_fd); + * SilcStream silc_fd_stream_file2(const char *read_file, + * const char *write_file, + * SilcStack stack); * * DESCRIPTION * - * Returns the file descriptors associated with the stream. The 'write_fd' - * is available only if the stream was created with silc_fd_stream_create2 - * function. + * Same as silc_fd_stream_file but creates the stream by opening `read_file' + * for reading and `write_file' for writing. Returns NULL if system is + * out of memory. + * + * If the silc_stream_set_notifier is called the stream is set to + * non-blocking mode. + * + * If `stack' is non-NULL all memory is allocated from the `stack' and + * will be released back to `stack' after the stream is destroyed. * ***/ -SilcBool silc_fd_stream_get_info(SilcStream stream, - int *read_fd, int *write_fd); +SilcStream silc_fd_stream_file2(const char *read_file, const char *write_file, + SilcStack stack); -/****f* silcutil/SilcFDStreamAPI/silc_fd_stream_get_error +/****f* silcutil/SilcFDStreamAPI/silc_fd_stream_get_info * * SYNOPSIS * - * int silc_fd_stream_get_error(SilcStream stream); + * SilcBool + * silc_fd_stream_get_info(SilcStream stream, int *read_fd, int *write_fd); * * DESCRIPTION * - * If error occurred during file descriptor stream operations, this - * function can be used to retrieve the error number that occurred. + * Returns the file descriptors associated with the stream. The 'write_fd' + * is available only if the stream was created with silc_fd_stream_create2 + * function. Returns FALSE if the information is not available. * ***/ -int silc_fd_stream_get_error(SilcStream stream); +SilcBool silc_fd_stream_get_info(SilcStream stream, + int *read_fd, int *write_fd); + +/* Backwards support */ +#define silc_fd_stream_get_error(stream) silc_errno #endif /* SILCFDSTREAM_H */