|
|
1.1 ! root 1: /* ! 2: * $Header: error_message.c,v 1.1 86/11/10 21:34:34 spook Exp $ ! 3: * $Source: /mit/s/p/spook/Work/et/RCS/error_message.c,v $ ! 4: * $Locker: spook $ ! 5: * ! 6: * Copyright 1987 by the Student Information Processing Board ! 7: * of the Massachusetts Institute of Technology ! 8: * ! 9: * For copyright info, see "mit-sipb-copyright.h". ! 10: */ ! 11: ! 12: #include <stdio.h> ! 13: #include "error_table.h" ! 14: #include "mit-sipb-copyright.h" ! 15: extern char *sys_errlist[]; ! 16: extern int sys_nerr; ! 17: ! 18: static char buffer[25]; ! 19: ! 20: char * ! 21: error_message(code) ! 22: int code; ! 23: { ! 24: register int offset; ! 25: register error_table **et; ! 26: register int table_num; ! 27: register int div; ! 28: register char *cp; ! 29: ! 30: offset = code & ((1<<ERRCODE_RANGE)-1); ! 31: table_num = code - offset; ! 32: if ((_et_list == (error_table **)NULL) && table_num) ! 33: goto oops; ! 34: if (!table_num) { ! 35: if (offset < sys_nerr) ! 36: return(sys_errlist[offset]); ! 37: else ! 38: goto oops; ! 39: } ! 40: for (et = _et_list; *et != (error_table *)NULL; et++) { ! 41: if ((*et)->base == table_num) { ! 42: /* This is the right table */ ! 43: if ((*et)->n_msgs <= offset) ! 44: goto oops; ! 45: return((*et)->msgs[offset]); ! 46: } ! 47: } ! 48: oops: ! 49: cp = buffer; ! 50: { ! 51: register char *cp1; ! 52: for (cp1 = "Unknown code "; *cp1; cp1++, cp++) ! 53: *cp = *cp1; ! 54: if (table_num) { ! 55: for (cp1 = error_table_name(table_num); *cp1; cp1++, cp++) ! 56: *cp = *cp1; ! 57: *cp++ = ' '; ! 58: *cp = '\0'; ! 59: } ! 60: } ! 61: div = 1000000000; ! 62: if (offset == 0) { ! 63: *cp++ = '0'; ! 64: *cp = '\0'; ! 65: return(buffer); ! 66: } ! 67: while (div > offset) ! 68: div /= 10; ! 69: do { ! 70: register int n = offset / div; ! 71: *cp++ = '0' + n; ! 72: offset -= n * div; ! 73: div /= 10; ! 74: } while (offset && div); ! 75: while (div) { ! 76: *cp++ = '0'; ! 77: div /= 10; ! 78: } ! 79: *cp = '\0'; ! 80: return(buffer); ! 81: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.