annotate plugins/zephyr/error_message.c @ 2003:ffae8228d63a

[gaim-migrate @ 2013] small fixes committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Tue, 12 Jun 2001 22:59:05 +0000
parents 1e0fa7e130d0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1700
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1 /*
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2 * $Header$
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3 * $Source$
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
4 * $Locker$
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
5 *
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
6 * Copyright 1987 by the Student Information Processing Board
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
7 * of the Massachusetts Institute of Technology
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
8 *
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
9 * For copyright info, see "mit-sipb-copyright.h".
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
10 */
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
11
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
12 #include <sysdep.h>
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
13 #include "error_table.h"
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
14 #include "mit-sipb-copyright.h"
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
15 #include "com_err.h"
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
16
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
17 static const char rcsid[] =
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
18 "$Header$";
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
19 static const char copyright[] =
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
20 "Copyright 1986, 1987, 1988 by the Student Information Processing Board\nand the department of Information Systems\nof the Massachusetts Institute of Technology";
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
21
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
22 char *error_table_name_r __P((int, char *));
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
23
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
24 struct et_list * _et_list = (struct et_list *) NULL;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
25
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
26 const char * error_message (code)
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
27 long code;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
28 {
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
29 static char buf[COM_ERR_BUF_LEN];
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
30
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
31 return(error_message_r(code, buf));
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
32 }
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
33
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
34 const char * error_message_r (code, buf)
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
35 long code;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
36 char *buf;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
37 {
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
38 int offset;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
39 struct et_list *et;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
40 int table_num;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
41 int started = 0;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
42 char *cp, namebuf[6];
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
43
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
44 offset = code & ((1<<ERRCODE_RANGE)-1);
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
45 table_num = code - offset;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
46 if (!table_num)
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
47 return strerror(offset);
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
48 for (et = _et_list; et; et = et->next) {
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
49 if (et->table->base == table_num) {
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
50 /* This is the right table */
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
51 if (et->table->n_msgs <= offset)
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
52 break;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
53 return(et->table->msgs[offset]);
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
54 }
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
55 }
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
56
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
57 strcpy (buf, "Unknown code ");
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
58 if (table_num) {
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
59 strcat (buf, error_table_name_r (table_num, namebuf));
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
60 strcat (buf, " ");
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
61 }
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
62 for (cp = buf; *cp; cp++)
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
63 ;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
64 if (offset >= 100) {
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
65 *cp++ = '0' + offset / 100;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
66 offset %= 100;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
67 started++;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
68 }
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
69 if (started || offset >= 10) {
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
70 *cp++ = '0' + offset / 10;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
71 offset %= 10;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
72 }
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
73 *cp++ = '0' + offset;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
74 *cp = '\0';
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
75 return(buf);
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
76 }