1: /* 2: char id_perror[] = "@(#)perror_.c 1.2"; 3: * 4: * write a standard error message to the standard error output 5: * 6: * calling sequence: 7: * call perror(string) 8: * where: 9: * string will be written preceeding the standard error message 10: */ 11: 12: #include "../libI77/fiodefs.h" 13: 14: extern char *sys_errlist[]; 15: extern int sys_nerr; 16: extern char *f_errlist[]; 17: extern int f_nerr; 18: extern unit units[]; 19: 20: perror_(s, len) 21: char *s; ftnlen len; 22: { 23: unit *lu; 24: char buf[40]; 25: char *mesg = s + len; 26: 27: while (len > 0 && *--mesg == ' ') 28: len--; 29: if (errno >=0 && errno < sys_nerr) 30: mesg = sys_errlist[errno]; 31: else if (errno >= F_ER && errno < (F_ER + f_nerr)) 32: mesg = f_errlist[errno - F_ER]; 33: else 34: { 35: sprintf(buf, "%d: unknown error number", errno); 36: mesg = buf; 37: } 38: lu = &units[STDERR]; 39: if (!lu->uwrt) 40: nowwriting(lu); 41: while (len-- > 0) 42: putc(*s++, lu->ufd); 43: fprintf(lu->ufd, ": %s\n", mesg); 44: }