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