summaryrefslogtreecommitdiff
path: root/ecp/test/init.c
diff options
context:
space:
mode:
authorUros Majstorovic <majstor@majstor.org>2022-03-15 04:34:50 +0100
committerUros Majstorovic <majstor@majstor.org>2022-03-15 04:34:50 +0100
commitfbb5a477eaed7a4dc0a8adf2785c20653f064af7 (patch)
treee1137fadf5735e8c5b90a3ca25ef5e516f352639 /ecp/test/init.c
parent620c0560567b1143afb0477c6c2ec9f44ab63a77 (diff)
basic test passed
Diffstat (limited to 'ecp/test/init.c')
-rw-r--r--ecp/test/init.c29
1 files changed, 8 insertions, 21 deletions
diff --git a/ecp/test/init.c b/ecp/test/init.c
index 7b59578..f4b033a 100644
--- a/ecp/test/init.c
+++ b/ecp/test/init.c
@@ -1,17 +1,10 @@
#include <stdlib.h>
-#include <fcntl.h>
-#include <unistd.h>
+#include <stdio.h>
-#include "core.h"
+#include <core.h>
-static int v_rng(void *buf, size_t bufsize) {
- int fd;
-
- if((fd = open("/dev/urandom", O_RDONLY)) < 0) return -1;
- size_t nb = read(fd, buf, bufsize);
- close(fd);
- if (nb != bufsize) return -1;
- return 0;
+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) {
@@ -21,7 +14,7 @@ static ECPConnection *conn_alloc(ECPSocket *sock, unsigned char type) {
conn = malloc(sizeof(ECPConnection));
if (conn == NULL) return NULL;
- rv = ecp_conn_init(conn, sock, type);
+ rv = ecp_conn_create_inb(conn, sock, type);
if (rv) {
free(conn);
return NULL;
@@ -36,12 +29,6 @@ static void conn_free(ECPConnection *conn) {
int ecp_init(ECPContext *ctx) {
int rv;
- rv = ecp_ctx_init(ctx);
- if (rv) return rv;
-
- ctx->rng = v_rng;
- ctx->conn_alloc = conn_alloc;
- ctx->conn_free = conn_free;
-
- return ECP_OK;
-} \ No newline at end of file
+ rv = ecp_ctx_init(ctx, handle_err, NULL, conn_alloc, conn_free);
+ return rv;
+}