]> andersk Git - moira.git/blob - util/et/error_message.c
sync'ing files for RCS->CVS migration
[moira.git] / util / et / error_message.c
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>
13 #include "error_table.h"
14 #include "mit-sipb-copyright.h"
15 #include "internal.h"
16
17 static const char rcsid[] =
18     "$Header$";
19 static const char copyright[] =
20     "Copyright 1986, 1987, 1988 by the Student Information Processing Board\nand the department of Information Systems\nof the Massachusetts Institute of Technology";
21
22 static char buffer[25];
23
24 struct et_list * _et_list = (struct et_list *) NULL;
25
26 const char * error_message (code)
27 long    code;
28 {
29     int offset;
30     struct et_list *et;
31     int table_num;
32     int started = 0;
33     char *cp;
34
35     offset = code & ((1<<ERRCODE_RANGE)-1);
36     table_num = code - offset;
37     if (!table_num) {
38         if (offset < sys_nerr)
39             return(sys_errlist[offset]);
40         else
41             goto oops;
42     }
43     for (et = _et_list; et; et = et->next) {
44         if (et->table->base == table_num) {
45             /* This is the right table */
46             if (et->table->n_msgs <= offset)
47                 goto oops;
48             return(et->table->msgs[offset]);
49         }
50     }
51 oops:
52     strcpy (buffer, "Unknown code ");
53     if (table_num) {
54         strcat (buffer, error_table_name (table_num));
55         strcat (buffer, " ");
56     }
57     for (cp = buffer; *cp; cp++)
58         ;
59     if (offset >= 100) {
60         *cp++ = '0' + offset / 100;
61         offset %= 100;
62         started++;
63     }
64     if (started || offset >= 10) {
65         *cp++ = '0' + offset / 10;
66         offset %= 10;
67     }
68     *cp++ = '0' + offset;
69     *cp = '\0';
70     return(buffer);
71 }
This page took 0.045868 seconds and 5 git commands to generate.