X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=daemon%2Ffnet-adc.c;h=459ef9abd108dfe8e8e808d7f91b37a8af31f81f;hb=049aedb6ec90e163d2e0cc51ab66f65d18700a86;hp=2fb9de8918888105627783ab51fa518e3c73e238;hpb=3ad44ea78a56fe28eee03e23bfc15fe3d03ea431;p=doldaconnect.git diff --git a/daemon/fnet-adc.c b/daemon/fnet-adc.c index 2fb9de8..459ef9a 100644 --- a/daemon/fnet-adc.c +++ b/daemon/fnet-adc.c @@ -38,7 +38,7 @@ #include "transfer.h" #include "sysevents.h" #include "net.h" -#include "tiger.h" +#include /* Protocol states */ #define ADC_PROTOCOL 0 @@ -67,6 +67,7 @@ struct adchub { wchar_t **sup; iconv_t ich; int state; + struct wcspair *hubinf; struct qcmd *queue; }; @@ -215,6 +216,7 @@ ADC_CMDFN(cmd_sup) } else if(!wcsncmp(argv[i], L"RM", 2)) { if(!f) continue; + free(hub->sup[o]); memmove(hub->sup[o], hub->sup[o + 1], parrlen(hub->sup) - o); } } @@ -232,9 +234,19 @@ ADC_CMDFN(cmd_sid) } } +ADC_CMDFN(cmd_inf) +{ + ADC_CMDCOM; + + if(sender == NULL) { + + } +} + static struct command hubcmds[] = { {L"SUP", 1, 0, cmd_sup}, {L"SID", 2, 0, cmd_sid}, + {L"INF", 0, 0, cmd_inf}, {NULL, 0, 0, NULL} }; @@ -274,7 +286,7 @@ static void dispatch(struct qcmd *qcmd, struct fnetnode *fn) flog(LOG_DEBUG, "unknown adc command: %ls", qcmd->args[0]); } -static void hubread(struct socket *sk, struct fnetnode *fn) +static int hubread(struct socket *sk, struct fnetnode *fn) { int ret; struct adchub *hub; @@ -284,7 +296,7 @@ static void hubread(struct socket *sk, struct fnetnode *fn) hub = fn->data; if((newbuf = sockgetinbuf(sk, &datalen)) == NULL) - return; + return(0); if(hub->inbufdata > 1024) hub->inbufdata = 0; bufcat(hub->inbuf, newbuf, datalen); @@ -309,14 +321,14 @@ static void hubread(struct socket *sk, struct fnetnode *fn) if(errno == EILSEQ) { flog(LOG_DEBUG, "adc fnetnode %i sent illegal utf-8 sequence", fn->id); killfnetnode(fn); - return; + return(0); } else if(errno == EINVAL) { break; } else if(errno == E2BIG) { /* continue; */ } else { flog(LOG_WARNING, "bug? iconv returned unexpected error: %s", strerror(errno)); - return; + return(0); } } } @@ -325,21 +337,21 @@ static void hubread(struct socket *sk, struct fnetnode *fn) newqcmd(&hub->queue, parseadc(hub->cb)); memmove(hub->cb, p, (hub->cbdata -= (p - hub->cb)) * sizeof(*(hub->cb))); } + return(0); } -static void huberr(struct socket *sk, int err, struct fnetnode *fn) +static int huberr(struct socket *sk, int err, struct fnetnode *fn) { killfnetnode(fn); + return(0); } static void hubconnect(struct fnetnode *fn) { struct adchub *hub; - fn->sk->readcb = (void (*)(struct socket *, void *))hubread; - fn->sk->errcb = (void (*)(struct socket *, int, void *))huberr; - fn->sk->data = fn; - getfnetnode(fn); + CBREG(fn->sk, socket_read, (int (*)(struct socket *, void *))hubread, (void (*)(void *))putfnetnode, fn); + CBREG(fn->sk, socket_err, (int (*)(struct socket *, int, void *))huberr, (void (*)(void *))putfnetnode, fn); hub = smalloc(sizeof(*hub)); memset(hub, 0, sizeof(*hub));