Mercurial > pidgin
annotate plugins/icq/icqbyteorder.h @ 1375:b167222b5c93
[gaim-migrate @ 1385]
updates to libyahoo, and jlsantiago told me how to get icq to work on hpux
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Thu, 04 Jan 2001 22:46:19 +0000 |
parents | 0a766047b4fd |
children | 4c510ca3563f |
rev | line source |
---|---|
1152 | 1 /* |
1375
b167222b5c93
[gaim-migrate @ 1385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1309
diff
changeset
|
2 * $Id: icqbyteorder.h 1385 2001-01-04 22:46:19Z warmenhoven $ |
1152 | 3 * |
4 * This header defines macros to handle ICQ protocol byte order conversion. | |
5 * | |
6 * Vadim Zaliva <lord@crocodile.org> | |
7 * http://www.crocodile.org/ | |
8 * | |
9 * Copyright (C) 1999 Vadim Zaliva | |
10 * | |
11 * This program is free software; you can redistribute it and/or modify | |
12 * it under the terms of the GNU General Public License as published by | |
13 * the Free Software Foundation; either version 2 of the License, or | |
14 * (at your option) any later version. | |
15 * | |
16 * This program is distributed in the hope that it will be useful, | |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 * GNU General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU General Public License | |
22 * along with this program; if not, write to the Free Software | |
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
24 * | |
25 */ | |
26 | |
27 /* | |
28 * From ICQ protocol description: | |
29 * "Integers consisting of more than one byte is stored | |
30 * with the least significant byte first, and the most significant byte last | |
31 * (as is usual on the PC/Intel architecture)". | |
32 * | |
33 * whereas the network byte order, as used on the | |
34 * Internet, is Most Significant Byte first. (aka. Big Endian) | |
35 */ | |
36 | |
37 #ifndef ICQ_BYTEORDER_H_FLAG | |
38 #define ICQ_BYTEORDER_H_FLAG | |
39 | |
40 #ifdef HAVE_CONFIG_H | |
41 #include <config.h> | |
42 #endif | |
43 | |
44 /* linux way */ | |
45 #ifdef HAVE_ENDIAN_H | |
46 # include <endian.h> | |
47 #endif | |
48 #ifdef HAVE_BYTESWAP_H | |
49 # include <byteswap.h> | |
50 #endif | |
51 | |
52 /* bsd way */ | |
53 #ifdef HAVE_MACHINE_ENDIAN_H | |
54 # include <machine/endian.h> | |
55 #endif | |
56 | |
57 /* | |
58 * Kind of portable way. this common header, at least I found it on BSD and Solaris. | |
59 * On Solaris this is only place where endiannes is defined. | |
60 */ | |
61 #ifdef HAVE_ARPA_NAMESER_COMPAT_H | |
62 # include <arpa/nameser_compat.h> | |
63 #endif | |
64 | |
1375
b167222b5c93
[gaim-migrate @ 1385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1309
diff
changeset
|
65 /* put in by EWarmenhoven; jlsantiago told me what to do. I should send this on to the |
b167222b5c93
[gaim-migrate @ 1385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1309
diff
changeset
|
66 * icqlib guys. */ |
b167222b5c93
[gaim-migrate @ 1385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1309
diff
changeset
|
67 #ifdef hpux |
b167222b5c93
[gaim-migrate @ 1385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1309
diff
changeset
|
68 #include <arpa/nameser.h> |
b167222b5c93
[gaim-migrate @ 1385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1309
diff
changeset
|
69 #endif |
b167222b5c93
[gaim-migrate @ 1385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1309
diff
changeset
|
70 |
1152 | 71 /* |
72 * I am really trying to use builtin optimized byte swap routines. | |
73 * they are highly optimised on some platforms. | |
74 * But as last resort this simple code is used. | |
75 */ | |
76 #ifndef HAVE_BYTESWAP_H | |
77 # ifndef bswap_32 | |
78 extern unsigned long bswap_32(unsigned long v); | |
79 # endif | |
80 # ifndef bswap_16 | |
81 extern unsigned short bswap_16(unsigned short v); | |
82 # endif | |
83 #endif | |
84 | |
85 #ifdef BYTE_ORDER_LITTLE_ENDIAN | |
86 # define htoicql(x) (x) | |
87 # define icqtohl(x) (x) | |
88 # define htoicqs(x) (x) | |
89 # define icqtohs(x) (x) | |
90 #else | |
91 | |
92 #ifndef BYTE_ORDER | |
93 # error "Unknown byte order!" | |
94 #endif | |
95 | |
96 #if BYTE_ORDER == BIG_ENDIAN | |
97 /* host is different from ICQ byte order */ | |
98 # define htoicql(x) bswap_32(x) | |
99 # define icqtohl(x) bswap_32(x) | |
100 # define htoicqs(x) bswap_16(x) | |
101 # define icqtohs(x) bswap_16(x) | |
102 #else | |
103 # if BYTE_ORDER == LITTLE_ENDIAN | |
104 /* host byte order match ICQ byte order */ | |
105 # define htoicql(x) (x) | |
106 # define icqtohl(x) (x) | |
107 # define htoicqs(x) (x) | |
108 # define icqtohs(x) (x) | |
109 # else | |
110 # error "Unsupported byte order!" | |
111 # endif | |
112 #endif | |
113 | |
114 #endif | |
115 | |
116 /* ICQ byte order is always different from network byte order. */ | |
117 # define ntoicql(x) bswap_32(x) | |
118 # define icqtonl(x) bswap_32(x) | |
119 # define ntoicqs(x) bswap_16(x) | |
120 # define icqtons(x) bswap_16(x) | |
121 | |
122 #endif |