1 /*
2 
3   silcstream.c
4 
5   Author: Pekka Riikonen <priikone@silcnet.org>
6 
7   Copyright (C) 2005 - 2006 Pekka Riikonen
8 
9   The contents of this file are subject to one of the Licenses specified
10   in the COPYING file;  You may not use this file except in compliance
11   with the License.
12 
13   The software distributed under the License is distributed on an "AS IS"
14   basis, in the hope that it will be useful, but WITHOUT WARRANTY OF ANY
15   KIND, either expressed or implied.  See the COPYING file for more
16   information.
17 
18 */
19 
20 #include "silc.h"
21 
22 typedef struct {
23   SilcStreamOps *ops;
24 } *SilcStreamHeader;
25 
silc_stream_read(SilcStream stream,unsigned char * buf,SilcUInt32 buf_len)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 
silc_stream_write(SilcStream stream,const unsigned char * data,SilcUInt32 data_len)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 
silc_stream_close(SilcStream stream)40 SilcBool silc_stream_close(SilcStream stream)
41 {
42   SilcStreamHeader h = stream;
43   return h->ops->close(stream);
44 }
45 
silc_stream_destroy(SilcStream stream)46 void silc_stream_destroy(SilcStream stream)
47 {
48   SilcStreamHeader h = stream;
49   h->ops->destroy(stream);
50 }
51 
silc_stream_set_notifier(SilcStream stream,SilcSchedule schedule,SilcStreamNotifier notifier,void * context)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 
silc_stream_get_schedule(SilcStream stream)59 SilcSchedule silc_stream_get_schedule(SilcStream stream)
60 {
61   SilcStreamHeader h = stream;
62   return h->ops->get_schedule(stream);
63 }
64