|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - downloadIndex: ┃ T e ┃
Length: 1741 (0x6cd) Types: TextFile Names: »errmsg.c«
└─⟦a0efdde77⟧ Bits:30001252 EUUGD11 Tape, 1987 Spring Conference Helsinki └─ ⟦this⟧ »EUUGD11/euug-87hel/sec8/mcp/src/errmsg.c«
/**********************************************************************\ * * * errmsg.c * * * * Mcp eschews stderr and instead dumps things not wanted on stdout to * * /dev/tty. These routines should not be used while in cbreak mode * * because they change the mode without regard to its previous state. * * * \**********************************************************************/ #include <stdio.h> #include <strings.h> #include "mem.h" extern int errno, DevTty; extern char *sys_errlist[]; char *sprintf(); char_scr(c) char c; { (void) write(DevTty, &c, 1); return; } str_scr(s) register char *s; { (void) write(DevTty, s, strlen(s)); } msg(ss) char *ss; { static int old_length; int i, new_length, hadnewline = 0; char s[LONG_BUF]; (void) strcpy(s, ss); new_length = strlen(s); cbreak(); char_scr('\r'); if (s[new_length-1] == '\n') { s[new_length-1] = '\0'; hadnewline++; new_length--; } str_scr(s); if (new_length < old_length) { for (i=new_length; i<old_length; i++) char_scr(' '); for (i=new_length; i<old_length; i++) char_scr('\b'); } if (hadnewline) str_scr("\r\n"); nocbreak(); old_length = (hadnewline ? 0 : new_length); return; } err(s) char *s; { char errmsg[LONG_BUF]; (void) sprintf(errmsg, "%s\n", s); msg(errmsg); return; } err1(fmt, s1) char *fmt, *s1; { char errmsg[LONG_BUF]; (void) sprintf(errmsg, fmt, s1); (void) strcat(errmsg, "\n"); msg(errmsg); return; } err2(fmt, s1, s2) char *fmt, *s1, *s2; { char errmsg[LONG_BUF]; (void) sprintf(errmsg, fmt, s1, s2); (void) strcat(errmsg, "\n"); msg(errmsg); return; } perr(s) char *s; { err2("%s: %s", s, sys_errlist[errno]); return; }