#include #include #include static void handle_err(ECPConnection *conn, unsigned char mtype, int err) { printf("ERR: CTYPE:0x%x MTYPE:0x%x ERR:%d\n", conn->type, mtype, err); } static ECPConnection *conn_new(ECPSocket *sock, ECPConnection *parent, unsigned char type) { ECPConnection *conn; conn = malloc(sizeof(ECPConnection)); if (conn) { ecp_conn_init(conn, sock, type); ecp_conn_set_flags(conn, ECP_CONN_FLAG_GC); } return conn; } static void conn_free(ECPConnection *conn) { /* outbound connections are statically allocated */ if (ecp_conn_is_inb(conn)) free(conn); } int ecp_init(ECPContext *ctx) { int rv; rv = ecp_ctx_init(ctx, NULL, conn_new, conn_free, handle_err); return rv; }