--- a/src/sock.c Sun Feb 22 08:48:21 2009 +0200
+++ b/src/sock.c Sun Feb 22 10:16:28 2009 +0200
@@ -29,23 +29,44 @@
sock->type = type;
}
-void sock_stream_set_callbacks (struct sock_stream *sock, const struct sock_stream_callbacks *callbacks, void *arg)
+int sock_stream_read (struct sock_stream *sock, void *buf, size_t len)
+{
+ err_t err;
+
+ // proxy off to method handler
+ if ((err = sock->type->methods.read(sock, buf, &len)))
+ return err;
+
+ // return updated bytes-read len
+ return len;
+}
+
+int sock_stream_write (struct sock_stream *sock, const void *buf, size_t len)
+{
+ err_t err;
+
+ // proxy off to method handler
+ if ((err = sock->type->methods.write(sock, buf, &len)))
+ return err;
+
+ // return updated bytes-written len
+ return len;
+}
+
+err_t sock_stream_event_init (struct sock_stream *sock, const struct sock_stream_callbacks *callbacks, void *arg)
{
// store
sock->cb_info = callbacks;
sock->cb_arg = arg;
+
+ // run method
+ return sock->type->methods.event_init(sock);
}
-err_t sock_stream_read (struct sock_stream *sock, void *buf, size_t len)
+err_t sock_stream_event_enable (struct sock_stream *sock, short mask)
{
- // proxy off to method handler
- return sock->type->methods.read(sock, buf, len);
-}
-
-err_t sock_stream_write (struct sock_stream *sock, const void *buf, size_t len)
-{
- // proxy off to method handler
- return sock->type->methods.write(sock, buf, len);
+ // run method
+ return sock->type->methods.event_enable(sock, mask);
}
const struct error_info* sock_stream_error (struct sock_stream *sock)