[gaim-migrate @ 3063]
[pidgin-git.git] / src / protocols / zephyr / error_message.c
blobdaeb02c410f9e8ba2964d0264676ffab7ba87e44
1 /*
2 * $Header$
3 * $Source$
4 * $Locker$
6 * Copyright 1987 by the Student Information Processing Board
7 * of the Massachusetts Institute of Technology
9 * For copyright info, see "mit-sipb-copyright.h".
12 #include <sysdep.h>
13 #include "error_table.h"
14 #include "mit-sipb-copyright.h"
15 #include "com_err.h"
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";
22 char *error_table_name_r __P((int, char *));
24 struct et_list * _et_list = (struct et_list *) NULL;
26 const char * error_message (code)
27 long code;
29 static char buf[COM_ERR_BUF_LEN];
31 return(error_message_r(code, buf));
34 const char * error_message_r (code, buf)
35 long code;
36 char *buf;
38 int offset;
39 struct et_list *et;
40 int table_num;
41 int started = 0;
42 char *cp, namebuf[6];
44 offset = code & ((1<<ERRCODE_RANGE)-1);
45 table_num = code - offset;
46 if (!table_num)
47 return strerror(offset);
48 for (et = _et_list; et; et = et->next) {
49 if (et->table->base == table_num) {
50 /* This is the right table */
51 if (et->table->n_msgs <= offset)
52 break;
53 return(et->table->msgs[offset]);
57 strcpy (buf, "Unknown code ");
58 if (table_num) {
59 strcat (buf, error_table_name_r (table_num, namebuf));
60 strcat (buf, " ");
62 for (cp = buf; *cp; cp++)
64 if (offset >= 100) {
65 *cp++ = '0' + offset / 100;
66 offset %= 100;
67 started++;
69 if (started || offset >= 10) {
70 *cp++ = '0' + offset / 10;
71 offset %= 10;
73 *cp++ = '0' + offset;
74 *cp = '\0';
75 return(buf);