1 |
– |
/* Copyright (c) 1991 Regents of the University of California */ |
2 |
– |
|
1 |
|
#ifndef lint |
2 |
< |
static char SCCSid[] = "$SunId$ LBL"; |
2 |
> |
static const char RCSid[] = "$Id$"; |
3 |
|
#endif |
6 |
– |
|
4 |
|
/* |
5 |
|
* error.c - standard error reporting function |
6 |
+ |
* |
7 |
+ |
* External symbols declared in standard.h |
8 |
|
*/ |
9 |
|
|
10 |
< |
#include "standard.h" |
10 |
> |
#include "copyright.h" |
11 |
|
|
12 |
< |
#ifndef linux |
13 |
< |
extern char *sys_errlist[]; /* system error list */ |
14 |
< |
extern int sys_nerr; /* number of system errors */ |
15 |
< |
#endif |
12 |
> |
#include <stdio.h> |
13 |
> |
|
14 |
> |
#include "rterror.h" |
15 |
> |
|
16 |
> |
extern char *strerror(); |
17 |
|
/* global list of error actions */ |
18 |
|
struct erract erract[NERRS] = ERRACT_INIT; |
19 |
|
|
20 |
|
char errmsg[512]; /* global error message buffer */ |
21 |
|
|
22 |
|
|
23 |
+ |
void |
24 |
|
error(etype, emsg) /* report error, quit if necessary */ |
25 |
|
int etype; |
26 |
|
char *emsg; |
35 |
|
if (emsg != NULL && emsg[0]) (*ep->pf)(emsg); |
36 |
|
if (etype == SYSTEM && errno > 0) { |
37 |
|
(*ep->pf)(": "); |
38 |
< |
if (errno <= sys_nerr) |
38 |
< |
(*ep->pf)(sys_errlist[errno]); |
39 |
< |
else |
40 |
< |
(*ep->pf)("Unknown error"); |
38 |
> |
(*ep->pf)(strerror(errno)); |
39 |
|
} |
40 |
|
(*ep->pf)("\n"); |
41 |
|
} |