1: /* 2: * Copyright (c) 1980 Regents of the University of California. 3: * All rights reserved. The Berkeley software License Agreement 4: * specifies the terms and conditions for redistribution. 5: * 6: * @(#)perror_.c 5.1.1 1996/3/22 7: */ 8: 9: /* 10: * write a standard error message to the standard error output 11: * 12: * calling sequence: 13: * call perror(string) 14: * where: 15: * string will be written preceeding the standard error message 16: */ 17: 18: #include <stdio.h> 19: #include "../libI77/fiodefs.h" 20: #include "../libI77/f_errno.h" 21: #include <string.h> 22: 23: extern char *f_errlist[]; 24: extern int f_nerr; 25: extern unit units[]; 26: 27: perror_(s, len) 28: char *s; long len; 29: { 30: register unit *lu; 31: register char *mesg = s + len; 32: 33: while (len > 0 && *--mesg == ' ') 34: len--; 35: if (errno >= F_ER && errno < (F_ER + f_nerr)) 36: mesg = f_errlist[errno - F_ER]; 37: else 38: mesg = strerror(errno); 39: lu = &units[STDERR]; 40: if (!lu->uwrt) 41: nowwriting(lu); 42: while (len-- > 0) 43: fputc(*s++, lu->ufd); 44: fprintf(lu->ufd, ": %s\n", mesg); 45: }