X-Git-Url: http://git.marmaro.de/?p=mmh;a=blobdiff_plain;f=uip%2Fvmhsbr.c;h=a504220a1e53c22bce32e7a9f2952d1d9f27262a;hp=664c388e8ce513e78f3b0d0aab533b9d30e63733;hb=d2da15ecabb03fb2de72863abdf5f21e52fdf329;hpb=1691e80890e5d8ba258c51c214a3e91880e1db2b diff --git a/uip/vmhsbr.c b/uip/vmhsbr.c index 664c388..a504220 100644 --- a/uip/vmhsbr.c +++ b/uip/vmhsbr.c @@ -3,6 +3,10 @@ * vmhsbr.c -- routines to help vmh along * * $Id$ + * + * This code is Copyright (c) 2002, by the authors of nmh. See the + * COPYRIGHT file in the root directory of the nmh distribution for + * complete copyright information. */ /* @@ -12,6 +16,8 @@ #include #include +#include +#include static char *types[] = { "OK", @@ -24,8 +30,6 @@ static FILE *fp = NULL; static int PEERrfd = NOTOK; static int PEERwfd = NOTOK; -extern int errno; - /* * static prototypes */ @@ -95,8 +99,7 @@ peer2rc (struct record *rc) if (read (PEERrfd, (char *) rc_head (rc), RHSIZE (rc)) != RHSIZE (rc)) return rclose (rc, "read from peer lost(1)"); if (rc->rc_len) { - if ((rc->rc_data = malloc ((unsigned) rc->rc_len + 1)) == NULL) - return rclose (rc, "malloc of %d lost", rc->rc_len + 1); + rc->rc_data = mh_xmalloc ((unsigned) rc->rc_len + 1); if (read (PEERrfd, rc->rc_data, rc->rc_len) != rc->rc_len) return rclose (rc, "read from peer lost(2)"); rc->rc_data[rc->rc_len] = 0; @@ -107,7 +110,7 @@ peer2rc (struct record *rc) if (fp) { fseek (fp, 0L, SEEK_END); fprintf (fp, "%d: <--- %s %d: \"%*.*s\"\n", (int) getpid(), - types[rc->rc_type], rc->rc_len, + types[(unsigned char)rc->rc_type], rc->rc_len, rc->rc_len, rc->rc_len, rc->rc_data); fflush (fp); } @@ -128,7 +131,7 @@ rc2peer (char code, int len, char *data) if (fp) { fseek (fp, 0L, SEEK_END); fprintf (fp, "%d: ---> %s %d: \"%*.*s\"\n", (int) getpid(), - types[rc->rc_type], rc->rc_len, + types[(unsigned char)rc->rc_type], rc->rc_len, rc->rc_len, rc->rc_len, data); fflush (fp); } @@ -165,11 +168,13 @@ fmt2peer (char code, char *fmt, ...) int err2peer (char code, char *what, char *fmt, ...) { + int return_value; va_list ap; va_start(ap, fmt); - verr2peer(code, what, fmt, ap); + return_value = verr2peer(code, what, fmt, ap); va_end(ap); + return return_value; /* This routine returned garbage before 1999-07-15. */ }