Mercurial > pidgin
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 |
rev | line source |
---|---|
2086 | 1 /* |
2 * Copyright 1987 by MIT Student Information Processing Board | |
3 * | |
4 * For copyright info, see mit-sipb-copyright.h. | |
5 */ | |
6 | |
7 #include <sysdep.h> | |
8 | |
8354 | 9 |
10 #define ERRCODE_RANGE 8 /* # of bits to shift table number */ | |
11 #define BITS_PER_CHAR 6 /* # bits to shift per character in name */ | |
12 | |
13 | |
2086 | 14 static const char char_set[] = |
15 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_"; | |
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 | 22 { |
23 int ch; | |
24 int i; | |
25 char *p; | |
26 | |
27 /* num = aa aaa abb bbb bcc ccc cdd ddd d?? ??? ??? */ | |
28 p = buf; | |
29 num >>= ERRCODE_RANGE; | |
30 /* num = ?? ??? ??? aaa aaa bbb bbb ccc ccc ddd ddd */ | |
31 num &= 077777777; | |
32 /* num = 00 000 000 aaa aaa bbb bbb ccc ccc ddd ddd */ | |
33 for (i = 4; i >= 0; i--) { | |
34 ch = (num >> BITS_PER_CHAR * i) & ((1 << BITS_PER_CHAR) - 1); | |
35 if (ch != 0) | |
36 *p++ = char_set[ch-1]; | |
37 } | |
38 *p = '\0'; | |
39 return(buf); | |
40 } | |
41 | |
12424
7c2e2c4d45a4
[gaim-migrate @ 14731]
Richard Laager <rlaager@wiktel.com>
parents:
11105
diff
changeset
|
42 const char * error_table_name(int num) |
2086 | 43 { |
44 static char buf[6]; | |
45 | |
46 return(error_table_name_r(num, buf)); | |
47 } | |
48 |