src/sock.c
branchnew-transport
changeset 155 c59d3eaff0fb
parent 139 55b9dcc2b73a
child 180 22967b165692
--- a/src/sock.c	Tue Apr 28 17:52:48 2009 +0300
+++ b/src/sock.c	Tue Apr 28 20:27:45 2009 +0300
@@ -20,98 +20,3 @@
     return SUCCESS;
 }
 
-void sock_stream_init (struct sock_stream *sock, struct sock_stream_type *type, sock_stream_connect_cb cb_func, void *cb_arg)
-{
-    // be strict
-    assert(sock->type == NULL);
-
-    // store 
-    sock->type = type;
-    sock->conn_cb_func = cb_func;
-    sock->conn_cb_arg = cb_arg;
-}
-
-int sock_stream_read (struct sock_stream *sock, void *buf, size_t len)
-{
-    struct error_info *err = SOCK_ERR(sock);
-
-    // XXX: not readable
-    if (!sock->type->methods.read)
-        return -1;
-
-    // proxy off to method handler
-    if (sock->type->methods.read(sock, buf, &len, err))
-        return -ERROR_CODE(err);
-    
-    // return updated bytes-read len
-    return len;
-}
-
-int sock_stream_write (struct sock_stream *sock, const void *buf, size_t len)
-{
-    struct error_info *err = SOCK_ERR(sock);
-
-    // XXX: not writeable
-    if (!sock->type->methods.write)
-        return -1;
-
-    // proxy off to method handler
-    if (sock->type->methods.write(sock, buf, &len, err))
-        return -ERROR_CODE(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_event_enable (struct sock_stream *sock, short mask)
-{
-    // run method
-    return sock->type->methods.event_enable(sock, mask);
-}
-
-const struct error_info* sock_stream_error (struct sock_stream *sock)
-{
-    // return pointer
-    return SOCK_ERR(sock);
-}
-
-void sock_stream_invoke_callbacks (struct sock_stream *sock, short what)
-{
-    if (what & EV_READ && sock->cb_info->on_read)
-        sock->cb_info->on_read(sock, sock->cb_arg);
-
-    if (what & EV_WRITE && sock->cb_info->on_write)
-        sock->cb_info->on_read(sock, sock->cb_arg);
-}
-
-void sock_stream_invoke_conn_cb (struct sock_stream *sock, struct error_info *err, bool direct)
-{
-    if (!direct && sock->type->methods._conn_cb) {
-        // invoke indirectly
-        sock->type->methods._conn_cb(sock, err);
-
-    } else {
-        sock_stream_connect_cb cb_func = sock->conn_cb_func;
-
-        // invoke directly
-        sock->conn_cb_func = NULL;
-        cb_func(sock, err, sock->conn_cb_arg);
-        sock->conn_cb_arg = NULL;
-    }
-}
-
-void sock_stream_release (struct sock_stream *sock)
-{
-    sock->type->methods.release(sock);
-}
-