12522Sdlw /* 2*3892Sdlw char id_perror[] = "@(#)perror_.c 1.2"; 32522Sdlw * 42522Sdlw * write a standard error message to the standard error output 52522Sdlw * 62522Sdlw * calling sequence: 72522Sdlw * call perror(string) 82522Sdlw * where: 92522Sdlw * string will be written preceeding the standard error message 102522Sdlw */ 112522Sdlw 122522Sdlw #include <stdio.h> 132522Sdlw #include "../libI77/fiodefs.h" 142522Sdlw #include "../libI77/f_errno.h" 152522Sdlw 162522Sdlw extern char *sys_errlist[]; 172522Sdlw extern int sys_nerr; 182522Sdlw extern char *f_errlist[]; 192522Sdlw extern int f_nerr; 202522Sdlw extern unit units[]; 212522Sdlw 222522Sdlw perror_(s, len) 232522Sdlw char *s; long len; 242522Sdlw { 25*3892Sdlw unit *lu; 26*3892Sdlw char buf[40]; 27*3892Sdlw char *mesg = s + len; 282522Sdlw 292522Sdlw while (len > 0 && *--mesg == ' ') 302522Sdlw len--; 312522Sdlw if (errno >=0 && errno < sys_nerr) 322522Sdlw mesg = sys_errlist[errno]; 332522Sdlw else if (errno >= F_ER && errno < (F_ER + f_nerr)) 342522Sdlw mesg = f_errlist[errno - F_ER]; 352522Sdlw else 362522Sdlw { 372522Sdlw sprintf(buf, "%d: unknown error number", errno); 382522Sdlw mesg = buf; 392522Sdlw } 40*3892Sdlw lu = &units[STDERR]; 41*3892Sdlw if (!lu->uwrt) 42*3892Sdlw nowwriting(lu); 432522Sdlw while (len-- > 0) 44*3892Sdlw putc(*s++, lu->ufd); 45*3892Sdlw fprintf(lu->ufd, ": %s\n", mesg); 462522Sdlw } 47