1: /* 2: ** SYSERR -- SYStem ERRor message print and abort 3: ** 4: ** Syserr acts like a printf with up to five arguments. 5: ** 6: ** If the first argument to syserr is not zero, 7: ** the message "SYSERR:" is prepended. 8: ** 9: ** If the extern variable `Proc_name' is assigned to a 10: ** string, that string is prepended to the message. 11: ** 12: ** All arguments must be null-terminated. 13: ** 14: ** The function pointed to by `Exitfn' is then called. 15: ** It is initialized to be `exit'. 16: */ 17: 18: char *Proc_name; 19: int Accerror; 20: extern exit(); 21: int (*Exitfn)() = &exit; 22: 23: syserr(pv) 24: char *pv; 25: { 26: int pid; 27: register char **p; 28: extern int errno; 29: register int usererr; 30: register int exitvalue; 31: 32: p = &pv; 33: printf("\n"); 34: usererr = pv == 0; 35: 36: if (!usererr) 37: { 38: if (Proc_name) 39: printf("%s ", Proc_name); 40: printf("\007SYSERR: "); 41: } 42: else 43: p++; 44: printf(p[0], p[1], p[2], p[3], p[4], p[5]); 45: printf("\007\n"); 46: exitvalue = -1; 47: if (!usererr) 48: { 49: if (errno) 50: { 51: exitvalue = errno; 52: printf("\tUNIX error %d\n", exitvalue); 53: } 54: if (Accerror != 0) 55: { 56: printf("\taccess method error %d\n", Accerror); 57: } 58: } 59: flush(); 60: (*Exitfn)(exitvalue); 61: }