X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/mLib/blobdiff_plain/db2bf4111cde36048ac66bbac58547d105bc7e80..67b5031ec6d160b5cae425466a34d1be3b211dd4:/test/tvec-remote.c?ds=sidebyside diff --git a/test/tvec-remote.c b/test/tvec-remote.c index e03297e..a00f046 100644 --- a/test/tvec-remote.c +++ b/test/tvec-remote.c @@ -114,7 +114,7 @@ static int recv_all(struct tvec_state *tv, struct tvec_remote *r, #undef f_any } -int tvec_send(struct tvec_state *tv, struct tvec_reomte *r) +int tvec_send(struct tvec_state *tv, struct tvec_remote *r) { kludge64 k; unsigned char lenbuf[8]; const char *p; size_t sz; @@ -131,7 +131,7 @@ int tvec_send(struct tvec_state *tv, struct tvec_reomte *r) return (0); } -int tvec_recv(struct tvec_state *tv, struct tvec_reomte *r, buf *b_out) +int tvec_recv(struct tvec_state *tv, struct tvec_remote *r, buf *b_out) { kludge64 k, szmax; unsigned char lenbuf[8]; unsigned char *p; @@ -176,6 +176,7 @@ int tvec_recv(struct tvec_state *tv, struct tvec_reomte *r, buf *b_out) /*----- The output driver -------------------------------------------------*/ #define SENDPK(ro, pk) \ + if ((ro)->r.f&TVRF_BROKEN) /* do nothing */; else \ MC_BEFORE(setpk, \ { buf_reset(&(ro)->r.bout); \ buf_putu16l(&(ro)->r.bout.b, (pk)); }) \ @@ -187,29 +188,26 @@ static int sendstr(struct tvec_output *o, unsigned pk, { struct remote_output *ro = (struct remote_output *)o; - if (ro->r.f&TVRF_BROKEN) return (-1); - dbuf_reset(&ro->r.bout); - buf_putu16l(&ro->r.bout.b, TVPK_ERROR); - buf_vputstrf16l(&ro->r.bout.b, msg, ap); - return (tvec_send(ro->_o.tv, &ro->r)); + SENDPK(ro, pk) buf_vputstrf16l(&ro->r.bout.b, msg, ap); + return (ro->r.f&TVRF_BROKEN ? -1 : 0); } -static void report(struct tvec_output *o, unsigned pk, +static void report(struct tvec_output *o, unsigned pk, const char *what, const char *msg, va_list *ap) { if (sendstr(o, pk, msg, ap)) { - fprintf(stderr, "%s: ", QUIS); + fprintf(stderr, "%s %s: ", QUIS, what); vfprintf(stderr, msg, *ap); fputc('\n', stderr); } } static void remote_error(struct tvec_output *o, const char *msg, va_list *ap) - { report(o, TVPK_ERROR, msg, ap); } + { report(o, TVPK_ERROR, "ERROR", msg, ap); } static void remote_notice(struct tvec_output *o, const char *msg, va_list *ap) - { report(o, TVPK_NOTICE, msg, ap); } + { report(o, TVPK_NOTICE, "notice", msg, ap); } static void remote_setstatus(struct tvec_ouptut *o, int st) {