diff options
author | Uros Majstorovic <majstor@majstor.org> | 2022-08-09 21:54:45 +0200 |
---|---|---|
committer | Uros Majstorovic <majstor@majstor.org> | 2022-08-09 21:54:45 +0200 |
commit | 810dde21ee65653c15606917b19566cfbaaf165e (patch) | |
tree | 4cd84b109e06660a9c59f2487822905e5672681e /ecp/test/init.c | |
parent | aee853a208d6abec53ec81dc4ef110b63e13342f (diff) |
ecp server added
Diffstat (limited to 'ecp/test/init.c')
-rw-r--r-- | ecp/test/init.c | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/ecp/test/init.c b/ecp/test/init.c index f4b033a..b75b2ee 100644 --- a/ecp/test/init.c +++ b/ecp/test/init.c @@ -1,34 +1,27 @@ #include <stdlib.h> #include <stdio.h> -#include <core.h> +#include <ecp/core.h> -void handle_err(ECPConnection *conn, unsigned char mtype, int err) { +static void handle_err(ECPConnection *conn, unsigned char mtype, int err) { printf("ERR: CTYPE:%d MTYPE:%x ERR:%d\n", conn->type, mtype, err); } -static ECPConnection *conn_alloc(ECPSocket *sock, unsigned char type) { +static ECPConnection *conn_new(ECPSocket *sock, unsigned char type) { ECPConnection *conn; - int rv; conn = malloc(sizeof(ECPConnection)); - if (conn == NULL) return NULL; - - rv = ecp_conn_create_inb(conn, sock, type); - if (rv) { - free(conn); - return NULL; - } + if (conn) ecp_conn_init(conn, sock, type); return conn; } static void conn_free(ECPConnection *conn) { - free(conn); + if (ecp_conn_is_gc(conn)) free(conn); } int ecp_init(ECPContext *ctx) { int rv; - rv = ecp_ctx_init(ctx, handle_err, NULL, conn_alloc, conn_free); + rv = ecp_ctx_init(ctx, handle_err, conn_new, conn_free); return rv; } |