annotate src/protocols/zephyr/et_name.c @ 19802:4a832e480178

[gaim-migrate @ 16771] add README file comitted by Ma Yuan<mayuan2006@gmail.com> committer: Ethan Blanton <elb@pidgin.im>
author Ma Yuan <mayuan2006@gmail.com>
date Tue, 15 Aug 2006 15:57:07 +0000
parents 7c2e2c4d45a4
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1 /*
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2 * Copyright 1987 by MIT Student Information Processing Board
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3 *
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
4 * For copyright info, see mit-sipb-copyright.h.
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
5 */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
6
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
7 #include <sysdep.h>
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
8
8354
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 2086
diff changeset
9
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 2086
diff changeset
10 #define ERRCODE_RANGE 8 /* # of bits to shift table number */
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 2086
diff changeset
11 #define BITS_PER_CHAR 6 /* # bits to shift per character in name */
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 2086
diff changeset
12
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 2086
diff changeset
13
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
14 static const char char_set[] =
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
15 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
16
12424
7c2e2c4d45a4 [gaim-migrate @ 14731]
Richard Laager <rlaager@wiktel.com>
parents: 11105
diff changeset
17 /* Prototypes for -Wmissing-prototypes */
7c2e2c4d45a4 [gaim-migrate @ 14731]
Richard Laager <rlaager@wiktel.com>
parents: 11105
diff changeset
18 const char * error_table_name(int num);
7c2e2c4d45a4 [gaim-migrate @ 14731]
Richard Laager <rlaager@wiktel.com>
parents: 11105
diff changeset
19 const char * error_table_name_r(int num, char *buf);
7c2e2c4d45a4 [gaim-migrate @ 14731]
Richard Laager <rlaager@wiktel.com>
parents: 11105
diff changeset
20
7c2e2c4d45a4 [gaim-migrate @ 14731]
Richard Laager <rlaager@wiktel.com>
parents: 11105
diff changeset
21 const char * error_table_name_r(int num, char *buf)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
22 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
23 int ch;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
24 int i;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
25 char *p;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
26
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
27 /* num = aa aaa abb bbb bcc ccc cdd ddd d?? ??? ??? */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
28 p = buf;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
29 num >>= ERRCODE_RANGE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
30 /* num = ?? ??? ??? aaa aaa bbb bbb ccc ccc ddd ddd */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
31 num &= 077777777;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
32 /* num = 00 000 000 aaa aaa bbb bbb ccc ccc ddd ddd */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
33 for (i = 4; i >= 0; i--) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
34 ch = (num >> BITS_PER_CHAR * i) & ((1 << BITS_PER_CHAR) - 1);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
35 if (ch != 0)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
36 *p++ = char_set[ch-1];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
37 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
38 *p = '\0';
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
39 return(buf);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
40 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
41
12424
7c2e2c4d45a4 [gaim-migrate @ 14731]
Richard Laager <rlaager@wiktel.com>
parents: 11105
diff changeset
42 const char * error_table_name(int num)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
43 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
44 static char buf[6];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
45
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
46 return(error_table_name_r(num, buf));
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
47 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
48