bool -> SilcBool.
[silc.git] / lib / silcutil / silcfdstream.h
1 /*
2
3   silcfdstream.h
4
5   Author: Pekka Riikonen <priikone@silcnet.org>
6
7   Copyright (C) 2005 Pekka Riikonen
8
9   This program is free software; you can redistribute it and/or modify
10   it under the terms of the GNU General Public License as published by
11   the Free Software Foundation; version 2 of the License.
12
13   This program is distributed in the hope that it will be useful,
14   but WITHOUT ANY WARRANTY; without even the implied warranty of
15   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16   GNU General Public License for more details.
17
18 */
19
20 /****h* silcutil/SILC File Descriptor Stream Interface
21  *
22  * DESCRIPTION
23  *
24  * Implementation of SILC File Descriptor Stream.  The file descriptor
25  * stream can be used read from and write to a file descriptor.  This
26  * interface should be used only with real file descriptors, not with
27  * sockets.  Use the SILC Socket Stream for sockets.
28  *
29  ***/
30
31 #ifndef SILCFDSTREAM_H
32 #define SILCFDSTREAM_H
33
34 /****f* silcutil/SilcFDStreamAPI/silc_fd_stream_create
35  *
36  * SYNOPSIS
37  *
38  *    SilcStream silc_fd_stream_create(int fd, SilcSchedule schedule);
39  *
40  * DESCRIPTION
41  *
42  *    Creates file descriptor stream for the open file descriptor indicated
43  *    by `fd'.  The stream is closed with the silc_stream_close and destroyed
44  *    with the silc_stream_destroy.
45  *
46  ***/
47 SilcStream silc_fd_stream_create(int fd, SilcSchedule schedule);
48
49 /****f* silcutil/SilcFDStreamAPI/silc_fd_stream_create2
50  *
51  * SYNOPSIS
52  *
53  *    SilcStream silc_fd_stream_create2(int read_fd, int write_fd,
54  *                                      SilcSchedule schedule);
55  *
56  * DESCRIPTION
57  *
58  *    Creates file descriptor stream for the open file descriptors indicated
59  *    by `read_fd' and `write_fd'.  The `read_fd' must be opened for reading
60  *    and `write_fd' opened for writing.  The stream is closed with the
61  *    silc_stream_close and destroyed with the silc_stream_destroy.
62  *
63  ***/
64 SilcStream silc_fd_stream_create2(int read_fd, int write_fd,
65                                   SilcSchedule schedule);
66
67 /****f* silcutil/SilcFDStreamAPI/silc_fd_stream_get_info
68  *
69  * SYNOPSIS
70  *
71  *    SilcBool
72  *    silc_fd_stream_get_info(SilcStream stream, int *read_fd, int *write_fd);
73  *
74  * DESCRIPTION
75  *
76  *    Returns the file descriptors associated with the stream.  The 'write_fd'
77  *    is available only if the stream was created with silc_fd_stream_create2
78  *    function.
79  *
80  ***/
81 SilcBool silc_fd_stream_get_info(SilcStream stream, int *read_fd, int *write_fd);
82
83 /****f* silcutil/SilcFDStreamAPI/silc_fd_stream_get_error
84  *
85  * SYNOPSIS
86  *
87  *    int silc_fd_stream_get_error(SilcStream stream);
88  *
89  * DESCRIPTION
90  *
91  *    If error occurred during file descriptor stream operations, this
92  *    function can be used to retrieve the error number that occurred.
93  *
94  ***/
95 int silc_fd_stream_get_error(SilcStream stream);
96
97 #endif /* SILCFDSTREAM_H */