src/sock.c
changeset 9 4c4c906cc649
parent 8 be88e543c8ff
child 10 9fe218576d13
equal deleted inserted replaced
8:be88e543c8ff 9:4c4c906cc649
     2 #include "sock_internal.h"
     2 #include "sock_internal.h"
     3 #include "sock_gnutls.h"
     3 #include "sock_gnutls.h"
     4 
     4 
     5 #include <assert.h>
     5 #include <assert.h>
     6 
     6 
     7 err_t sock_init (struct error_info *err)
     7 // global sock_stream_ctx instance
       
     8 struct sock_stream_ctx _sock_stream_ctx;
       
     9 
       
    10 err_t sock_init (struct event_base *ev_base, struct error_info *err)
     8 {
    11 {
       
    12     // store ev_base
       
    13     _sock_stream_ctx.ev_base = ev_base;
       
    14 
     9     // XXX: just call these all directly for now
    15     // XXX: just call these all directly for now
    10     if (sock_gnutls_global_init(err))
    16     if (sock_gnutls_global_init(err))
    11         return ERROR_CODE(err);
    17         return ERROR_CODE(err);
    12 
    18 
    13     // done
    19     // done
    19     // be strict
    25     // be strict
    20     assert(sock->type == NULL);
    26     assert(sock->type == NULL);
    21 
    27 
    22     // store type
    28     // store type
    23     sock->type = type;
    29     sock->type = type;
       
    30 }
       
    31 
       
    32 void sock_stream_set_callbacks (struct sock_stream *sock, const struct sock_stream_callbacks *callbacks, void *arg)
       
    33 {
       
    34     // store
       
    35     sock->cb_info = callbacks;
       
    36     sock->cb_arg = arg;
    24 }
    37 }
    25 
    38 
    26 err_t sock_stream_read (struct sock_stream *sock, void *buf, size_t len)
    39 err_t sock_stream_read (struct sock_stream *sock, void *buf, size_t len)
    27 {
    40 {
    28     // proxy off to method handler
    41     // proxy off to method handler