136471Ssam # include "errno.h"
236471Ssam # include "../hdr/macros.h"
336471Ssam SCCSID(@(#)xmsg 2.1);
436471Ssam /*
536471Ssam Call fatal with an appropriate error message
636471Ssam based on errno. If no good message can be made up, it makes
736471Ssam up a simple message.
836471Ssam The second argument is a pointer to the calling functions
936471Ssam name (a string); it's used in the manufactured message.
1036471Ssam */
1136471Ssam
1236471Ssam
xmsg(file,func)1336471Ssam xmsg(file,func)
1436471Ssam char *file, *func;
1536471Ssam {
1636471Ssam register char *str;
1736471Ssam extern int errno;
1836471Ssam extern char Error[];
1936471Ssam
2036471Ssam switch (errno) {
2136471Ssam case ENFILE:
2236471Ssam str = "no file (ut3)";
2336471Ssam break;
2436471Ssam case ENOENT:
2536471Ssam sprintf(str = Error,"`%s' nonexistent (ut4)",file);
2636471Ssam break;
2736471Ssam case EACCES:
28*36472Ssam str = malloc(size(file));
2936471Ssam copy(file,str);
3036471Ssam file = str;
3136471Ssam sprintf(str = Error,"directory `%s' unwritable (ut2)",
3236471Ssam dname(file));
3336471Ssam break;
3436471Ssam case ENOSPC:
3536471Ssam str = "no space! (ut10)";
3636471Ssam break;
3736471Ssam case EFBIG:
3836471Ssam str = "write error (ut8)";
3936471Ssam break;
4036471Ssam default:
4136471Ssam sprintf(str = Error,"errno = %d, function = `%s' (ut11)",errno,
4236471Ssam func);
4336471Ssam break;
4436471Ssam }
4536471Ssam return(fatal(str));
4636471Ssam }
47