#include "sock_internal.h"
#include "sock_gnutls.h"
#include <assert.h>
err_t sock_init (void)
{
err_t err;
// XXX: just call these all directly for now
if ((err = sock_gnutls_init()))
return err;
}
void sock_stream_init (struct sock_stream *sock, struct sock_stream_type *type)
{
// be strict
assert(sock->type == NULL);
// store type
sock->type = type;
}
err_t sock_stream_read (struct sock_stream *sock, void *buf, size_t len)
{
// 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);
}
void sock_stream_error (struct sock_stream *sock, struct error_info *err)
{
// copy from SOCK_ER
*err = SOCK_ERR(sock);
}