Added SILC Thread Queue API
[silc.git] / lib / silcutil / silcstream.c
1 /*
2
3   silcstream.c
4
5   Author: Pekka Riikonen <priikone@silcnet.org>
6
7   Copyright (C) 2005 - 2006 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 #include "silc.h"
21
22 typedef struct {
23   SilcStreamOps *ops;
24 } *SilcStreamHeader;
25
26 int silc_stream_read(SilcStream stream, unsigned char *buf,
27                      SilcUInt32 buf_len)
28 {
29   SilcStreamHeader h = stream;
30   return h->ops->read(stream, buf, buf_len);
31 }
32
33 int silc_stream_write(SilcStream stream, const unsigned char *data,
34                       SilcUInt32 data_len)
35 {
36   SilcStreamHeader h = stream;
37   return h->ops->write(stream, data, data_len);
38 }
39
40 SilcBool silc_stream_close(SilcStream stream)
41 {
42   SilcStreamHeader h = stream;
43   return h->ops->close(stream);
44 }
45
46 void silc_stream_destroy(SilcStream stream)
47 {
48   SilcStreamHeader h = stream;
49   h->ops->destroy(stream);
50 }
51
52 SilcBool silc_stream_set_notifier(SilcStream stream, SilcSchedule schedule,
53                                   SilcStreamNotifier notifier, void *context)
54 {
55   SilcStreamHeader h = stream;
56   return h->ops->notifier(stream, schedule, notifier, context);
57 }
58
59 SilcSchedule silc_stream_get_schedule(SilcStream stream)
60 {
61   SilcStreamHeader h = stream;
62   return h->ops->get_schedule(stream);
63 }