Last change
on this file since 0170798 was 3ae31e9, checked in by Thomas Lopatic <thomas@…>, 7 years ago |
Imported original source code.
|
-
Property mode
set to
100755
|
File size:
744 bytes
|
Rev | Line | |
---|
[3ae31e9] | 1 | /*
|
---|
| 2 | perror.c -- print a system error message
|
---|
| 3 | Version 1 -- 1988-05-02
|
---|
| 4 | */
|
---|
| 5 |
|
---|
| 6 | #define CII
|
---|
| 7 |
|
---|
| 8 | /*
|
---|
| 9 | * Print the error indicated
|
---|
| 10 | * in the cerror cell.
|
---|
| 11 | */
|
---|
| 12 |
|
---|
| 13 | #ifdef CII
|
---|
| 14 | #define void int
|
---|
| 15 | extern int errno, s_nerr, strlen(), write();
|
---|
| 16 | extern char *s_errl[];
|
---|
| 17 | #else
|
---|
| 18 | extern int errno, sys_nerr, strlen(), write();
|
---|
| 19 | extern char *sys_errlist[];
|
---|
| 20 | #endif
|
---|
| 21 |
|
---|
| 22 | void
|
---|
| 23 | perror(s)
|
---|
| 24 | char *s;
|
---|
| 25 | {
|
---|
| 26 | register char *c;
|
---|
| 27 | register int n;
|
---|
| 28 |
|
---|
| 29 | c = "Unknown error";
|
---|
| 30 |
|
---|
| 31 | #ifdef CII
|
---|
| 32 | if(errno < s_nerr)
|
---|
| 33 | c = s_errl[errno];
|
---|
| 34 | #else
|
---|
| 35 | if(errno < sys_nerr)
|
---|
| 36 | c = sys_errlist[errno];
|
---|
| 37 | #endif
|
---|
| 38 |
|
---|
| 39 | n = strlen(s);
|
---|
| 40 |
|
---|
| 41 | if(n) {
|
---|
| 42 | (void) write(2, s, (unsigned)n);
|
---|
| 43 | (void) write(2, ": ", 2);
|
---|
| 44 | }
|
---|
| 45 |
|
---|
| 46 | (void) write(2, c, (unsigned)strlen(c));
|
---|
| 47 | (void) write(2, "\n", 1);
|
---|
| 48 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.