Initial code commit for Toolkit 1.1.
[silc.git] / lib / silcutil / silcstream.c
diff --git a/lib/silcutil/silcstream.c b/lib/silcutil/silcstream.c
new file mode 100644 (file)
index 0000000..c32e15a
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+
+  silcstream.c
+
+  Author: Pekka Riikonen <priikone@silcnet.org>
+
+  Copyright (C) 2005 Pekka Riikonen
+
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; version 2 of the License.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+*/
+
+#include "silcincludes.h"
+
+typedef struct {
+  SilcStreamOps *ops;
+} *SilcStreamHeader;
+
+int silc_stream_read(SilcStream stream, unsigned char *buf,
+                    SilcUInt32 buf_len)
+{
+  SilcStreamHeader h = stream;
+  return h->ops->read(stream, buf, buf_len);
+}
+
+int silc_stream_write(SilcStream stream, const unsigned char *data,
+                     SilcUInt32 data_len)
+{
+  SilcStreamHeader h = stream;
+  return h->ops->write(stream, data, data_len);
+}
+
+bool silc_stream_close(SilcStream stream)
+{
+  SilcStreamHeader h = stream;
+  return h->ops->close(stream);
+}
+
+void silc_stream_destroy(SilcStream stream)
+{
+  SilcStreamHeader h = stream;
+  return h->ops->destroy(stream);
+}
+
+void silc_stream_set_notifier(SilcStream stream, SilcStreamNotifier notifier,
+                             void *context)
+{
+  SilcStreamHeader h = stream;
+  return h->ops->notifier(stream, notifier, context);
+}