]>
Commit | Line | Data |
---|---|---|
d1b2a10e | 1 | /* |
2 | * $Header$ | |
3 | * $Source$ | |
4 | * $Locker$ | |
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> | |
a91a6d50 | 13 | #include <string.h> |
d1b2a10e | 14 | #include "error_table.h" |
15 | #include "mit-sipb-copyright.h" | |
d1b2a10e | 16 | |
a91a6d50 | 17 | static const char rcsid[] = "$Id$"; |
d1b2a10e | 18 | static const char copyright[] = |
19 | "Copyright 1986, 1987, 1988 by the Student Information Processing Board\nand the department of Information Systems\nof the Massachusetts Institute of Technology"; | |
20 | ||
21 | static char buffer[25]; | |
22 | ||
a91a6d50 | 23 | struct et_list *_et_list = NULL; |
d1b2a10e | 24 | |
a91a6d50 | 25 | const char *error_message(long code) |
d1b2a10e | 26 | { |
27 | int offset; | |
28 | struct et_list *et; | |
29 | int table_num; | |
30 | int started = 0; | |
31 | char *cp; | |
32 | ||
33 | offset = code & ((1<<ERRCODE_RANGE)-1); | |
34 | table_num = code - offset; | |
a91a6d50 | 35 | if (!table_num) |
36 | return strerror(offset); | |
d1b2a10e | 37 | for (et = _et_list; et; et = et->next) { |
38 | if (et->table->base == table_num) { | |
39 | /* This is the right table */ | |
40 | if (et->table->n_msgs <= offset) | |
41 | goto oops; | |
42 | return(et->table->msgs[offset]); | |
43 | } | |
44 | } | |
45 | oops: | |
46 | strcpy (buffer, "Unknown code "); | |
47 | if (table_num) { | |
48 | strcat (buffer, error_table_name (table_num)); | |
49 | strcat (buffer, " "); | |
50 | } | |
51 | for (cp = buffer; *cp; cp++) | |
52 | ; | |
53 | if (offset >= 100) { | |
54 | *cp++ = '0' + offset / 100; | |
55 | offset %= 100; | |
56 | started++; | |
57 | } | |
58 | if (started || offset >= 10) { | |
59 | *cp++ = '0' + offset / 10; | |
60 | offset %= 10; | |
61 | } | |
62 | *cp++ = '0' + offset; | |
63 | *cp = '\0'; | |
64 | return(buffer); | |
65 | } |