Changed SILC Stream API implementation static inline functions.
authorPekka Riikonen <priikone@silcnet.org>
Mon, 3 Mar 2008 19:09:59 +0000 (21:09 +0200)
committerPekka Riikonen <priikone@silcnet.org>
Mon, 3 Mar 2008 19:09:59 +0000 (21:09 +0200)
lib/silcutil/Makefile.ad
lib/silcutil/silcstream.c [deleted file]
lib/silcutil/silcstream.h

index 60ca63fd231595c83c00ebf00eb930c7c2ac0392..ef7efb9c7270ebef541049be0ac80db167c512a1 100644 (file)
@@ -48,7 +48,6 @@ libsilcutil_la_SOURCES = \
        silchashtable.c \
        silcutf8.c      \
        silcstringprep.c \
-       silcstream.c    \
        silcfdstream.c  \
        silcsocketstream.c \
        silcfsm.c       \
diff --git a/lib/silcutil/silcstream.c b/lib/silcutil/silcstream.c
deleted file mode 100644 (file)
index 5e01ad3..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
-
-  silcstream.c
-
-  Author: Pekka Riikonen <priikone@silcnet.org>
-
-  Copyright (C) 2005 - 2008 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 "silcruntime.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);
-}
-
-SilcBool silc_stream_close(SilcStream stream)
-{
-  SilcStreamHeader h = stream;
-  return h->ops->close(stream);
-}
-
-void silc_stream_destroy(SilcStream stream)
-{
-  SilcStreamHeader h = stream;
-  h->ops->destroy(stream);
-}
-
-SilcBool silc_stream_set_notifier(SilcStream stream, SilcSchedule schedule,
-                                 SilcStreamNotifier notifier, void *context)
-{
-  SilcStreamHeader h = stream;
-  return h->ops->notifier(stream, schedule, notifier, context);
-}
-
-SilcSchedule silc_stream_get_schedule(SilcStream stream)
-{
-  SilcStreamHeader h = stream;
-  return h->ops->get_schedule(stream);
-}
index 4440fa5dce8ade00314586cbb56ae41fca1b0826..b6d82d90009489e0b050ba1beaafa3c47a4a2bd5 100644 (file)
@@ -157,6 +157,11 @@ typedef struct {
 } SilcStreamOps;
 /***/
 
+/* Stream header */
+typedef struct SilcStreamHeaderObject {
+  SilcStreamOps *ops;
+} *SilcStreamHeader, SilcStreamHeaderStruct;
+
 /****f* silcutil/silc_stream_read
  *
  * SYNOPSIS
@@ -176,8 +181,13 @@ typedef struct {
  *    If error occurred the error code can be retrieved with silc_errno.
  *
  ***/
+static inline
 int silc_stream_read(SilcStream stream, unsigned char *buf,
-                    SilcUInt32 buf_len);
+                    SilcUInt32 buf_len)
+{
+  SilcStreamHeader h = stream;
+  return h->ops->read(stream, buf, buf_len);
+}
 
 /****f* silcutil/silc_stream_write
  *
@@ -198,8 +208,13 @@ int silc_stream_read(SilcStream stream, unsigned char *buf,
  *    If error occurred the error code can be retrieved with silc_errno.
  *
  ***/
+static inline
 int silc_stream_write(SilcStream stream, const unsigned char *data,
-                     SilcUInt32 data_len);
+                     SilcUInt32 data_len)
+{
+  SilcStreamHeader h = stream;
+  return h->ops->write(stream, data, data_len);
+}
 
 /****f* silcutil/silc_stream_close
  *
@@ -215,7 +230,12 @@ int silc_stream_write(SilcStream stream, const unsigned char *data,
  *    callback may be called with an error status.
  *
  ***/
-SilcBool silc_stream_close(SilcStream stream);
+static inline
+SilcBool silc_stream_close(SilcStream stream)
+{
+  SilcStreamHeader h = stream;
+  return h->ops->close(stream);
+}
 
 /****f* silcutil/silc_stream_destroy
  *
@@ -232,7 +252,12 @@ SilcBool silc_stream_close(SilcStream stream);
  *    function will call it.
  *
  ***/
-void silc_stream_destroy(SilcStream stream);
+static inline
+void silc_stream_destroy(SilcStream stream)
+{
+  SilcStreamHeader h = stream;
+  h->ops->destroy(stream);
+}
 
 /****f* silcutil/silc_stream_set_notifier
  *
@@ -259,8 +284,13 @@ void silc_stream_destroy(SilcStream stream);
  *    Returns TRUE on success.  The `schedule' must always be non-NULL.
  *
  ***/
+static inline
 SilcBool silc_stream_set_notifier(SilcStream stream, SilcSchedule schedule,
-                                 SilcStreamNotifier notifier, void *context);
+                                 SilcStreamNotifier notifier, void *context)
+{
+  SilcStreamHeader h = stream;
+  return h->ops->notifier(stream, schedule, notifier, context);
+}
 
 /****f* silcutil/silc_stream_get_schedule
  *
@@ -274,6 +304,11 @@ SilcBool silc_stream_set_notifier(SilcStream stream, SilcSchedule schedule,
  *    NULL if one has not been set for the `stream'.
  *
  ***/
-SilcSchedule silc_stream_get_schedule(SilcStream stream);
+static inline
+SilcSchedule silc_stream_get_schedule(SilcStream stream)
+{
+  SilcStreamHeader h = stream;
+  return h->ops->get_schedule(stream);
+}
 
 #endif /* SILCSTREAM_H */