1 # include "errno.h"
2 # include "../hdr/macros.h"
3 SCCSID(@(#)xmsg 2.1);
4 /*
5 Call fatal with an appropriate error message
6 based on errno. If no good message can be made up, it makes
7 up a simple message.
8 The second argument is a pointer to the calling functions
9 name (a string); it's used in the manufactured message.
10 */
11
12
xmsg(file,func)13 xmsg(file,func)
14 char *file, *func;
15 {
16 register char *str;
17 extern int errno;
18 extern char Error[];
19
20 switch (errno) {
21 case ENFILE:
22 str = "no file (ut3)";
23 break;
24 case ENOENT:
25 sprintf(str = Error,"`%s' nonexistent (ut4)",file);
26 break;
27 case EACCES:
28 str = malloc(size(file));
29 copy(file,str);
30 file = str;
31 sprintf(str = Error,"directory `%s' unwritable (ut2)",
32 dname(file));
33 break;
34 case ENOSPC:
35 str = "no space! (ut10)";
36 break;
37 case EFBIG:
38 str = "write error (ut8)";
39 break;
40 default:
41 sprintf(str = Error,"errno = %d, function = `%s' (ut11)",errno,
42 func);
43 break;
44 }
45 return(fatal(str));
46 }
47