default access mode is sequential. DLW
[unix-history] / usr / src / usr.bin / f77 / libU77 / perror_.c
CommitLineData
7f4368a6 1/*
70d9135d 2char id_perror[] = "@(#)perror_.c 1.2";
7f4368a6
DW
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 <stdio.h>
13#include "../libI77/fiodefs.h"
14#include "../libI77/f_errno.h"
15
16extern char *sys_errlist[];
17extern int sys_nerr;
18extern char *f_errlist[];
19extern int f_nerr;
20extern unit units[];
21
22perror_(s, len)
23char *s; long len;
24{
70d9135d
DW
25 unit *lu;
26 char buf[40];
27 char *mesg = s + len;
7f4368a6
DW
28
29 while (len > 0 && *--mesg == ' ')
30 len--;
31 if (errno >=0 && errno < sys_nerr)
32 mesg = sys_errlist[errno];
33 else if (errno >= F_ER && errno < (F_ER + f_nerr))
34 mesg = f_errlist[errno - F_ER];
35 else
36 {
37 sprintf(buf, "%d: unknown error number", errno);
38 mesg = buf;
39 }
70d9135d
DW
40 lu = &units[STDERR];
41 if (!lu->uwrt)
42 nowwriting(lu);
7f4368a6 43 while (len-- > 0)
70d9135d
DW
44 putc(*s++, lu->ufd);
45 fprintf(lu->ufd, ": %s\n", mesg);
7f4368a6 46}