|
|
1.1 root 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 6/7/85
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:
22: extern char *sys_errlist[];
23: extern int sys_nerr;
24: extern char *f_errlist[];
25: extern int f_nerr;
26: extern unit units[];
27:
28: perror_(s, len)
29: char *s; long len;
30: {
31: unit *lu;
32: char buf[40];
33: char *mesg = s + len;
34:
35: while (len > 0 && *--mesg == ' ')
36: len--;
37: if (errno >=0 && errno < sys_nerr)
38: mesg = sys_errlist[errno];
39: else if (errno >= F_ER && errno < (F_ER + f_nerr))
40: mesg = f_errlist[errno - F_ER];
41: else
42: {
43: sprintf(buf, "%d: unknown error number", errno);
44: mesg = buf;
45: }
46: lu = &units[STDERR];
47: if (!lu->uwrt)
48: nowwriting(lu);
49: while (len-- > 0)
50: putc(*s++, lu->ufd);
51: fprintf(lu->ufd, ": %s\n", mesg);
52: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.