source: trunk/third/moira/util/et/error_message.c @ 24319

Revision 24319, 1.6 KB checked in by broder, 14 years ago (diff)
New Moira snapshot from SVN.
Line 
1/* $Id: error_message.c 3956 2010-01-05 20:56:56Z zacheiss $
2 *
3 * Copyright 1987 by the Student Information Processing Board
4 * of the Massachusetts Institute of Technology
5 *
6 * For copyright info, see "mit-sipb-copyright.h".
7 */
8
9#include <stdio.h>
10#include <string.h>
11#include "error_table.h"
12#include "mit-sipb-copyright.h"
13
14static const char rcsid[] = "$HeadURL: svn+ssh://svn.mit.edu/moira/trunk/moira/util/et/error_message.c $ $Id: error_message.c 3956 2010-01-05 20:56:56Z zacheiss $";
15static const char copyright[] =
16    "Copyright 1986, 1987, 1988 by the Student Information Processing Board\nand the department of Information Systems\nof the Massachusetts Institute of Technology";
17
18static char buffer[25];
19
20struct et_list *_et_list = NULL;
21
22const char *error_message(long code)
23{
24    int offset;
25    struct et_list *et;
26    int table_num;
27    int started = 0;
28    char *cp;
29
30    offset = code & ((1<<ERRCODE_RANGE)-1);
31    table_num = code - offset;
32    if (!table_num)
33        return strerror(offset);
34    for (et = _et_list; et; et = et->next) {
35        if (et->table->base == table_num) {
36            /* This is the right table */
37            if (et->table->n_msgs <= offset)
38                goto oops;
39            return(et->table->msgs[offset]);
40        }
41    }
42oops:
43    strcpy (buffer, "Unknown code ");
44    if (table_num) {
45        strcat (buffer, error_table_name (table_num));
46        strcat (buffer, " ");
47    }
48    for (cp = buffer; *cp; cp++)
49        ;
50    if (offset >= 100) {
51        *cp++ = '0' + offset / 100;
52        offset %= 100;
53        started++;
54    }
55    if (started || offset >= 10) {
56        *cp++ = '0' + offset / 10;
57        offset %= 10;
58    }
59    *cp++ = '0' + offset;
60    *cp = '\0';
61    return(buffer);
62}
Note: See TracBrowser for help on using the repository browser.