Mercurial > pidgin
annotate plugins/icq/icqbyteorder.h @ 1840:00aef397a1fe
[gaim-migrate @ 1850]
reworked some of the proxy stuff so that it's non-blocking now. next thing to do is to get IRC, MSN, Napster, and Jabber to use the new proxy_connect code. After that, Oscar and Yahoo (maybe Zephyr too? not likely)
committer: Tailor Script <tailor@pidgin.im>
| author | Eric Warmenhoven <eric@warmenhoven.org> |
|---|---|
| date | Sat, 12 May 2001 01:38:04 +0000 |
| parents | 7f7857c5036e |
| children | 8ed70631ed15 |
| rev | line source |
|---|---|
| 1152 | 1 /* |
|
1467
7f7857c5036e
[gaim-migrate @ 1477]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1432
diff
changeset
|
2 * $Id: icqbyteorder.h 1477 2001-02-04 07:34:46Z 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 | |
|
1432
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1375
diff
changeset
|
57 /* hpux way */ |
|
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1375
diff
changeset
|
58 #ifdef hpux |
|
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1375
diff
changeset
|
59 #include <arpa/nameser.h> |
|
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1375
diff
changeset
|
60 #endif |
|
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1375
diff
changeset
|
61 |
| 1152 | 62 /* |
| 63 * Kind of portable way. this common header, at least I found it on BSD and Solaris. | |
| 64 * On Solaris this is only place where endiannes is defined. | |
| 65 */ | |
| 66 #ifdef HAVE_ARPA_NAMESER_COMPAT_H | |
| 67 # include <arpa/nameser_compat.h> | |
| 68 #endif | |
| 69 | |
| 70 /* | |
| 71 * I am really trying to use builtin optimized byte swap routines. | |
| 72 * they are highly optimised on some platforms. | |
| 73 * But as last resort this simple code is used. | |
| 74 */ | |
| 75 #ifndef HAVE_BYTESWAP_H | |
| 76 # ifndef bswap_32 | |
| 77 extern unsigned long bswap_32(unsigned long v); | |
| 78 # endif | |
| 79 # ifndef bswap_16 | |
| 80 extern unsigned short bswap_16(unsigned short v); | |
| 81 # endif | |
| 82 #endif | |
| 83 | |
| 84 #ifdef BYTE_ORDER_LITTLE_ENDIAN | |
| 85 # define htoicql(x) (x) | |
| 86 # define icqtohl(x) (x) | |
| 87 # define htoicqs(x) (x) | |
| 88 # define icqtohs(x) (x) | |
| 89 #else | |
| 90 | |
| 91 #ifndef BYTE_ORDER | |
|
1467
7f7857c5036e
[gaim-migrate @ 1477]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1432
diff
changeset
|
92 /*# error "Unknown byte order!"*/ |
|
7f7857c5036e
[gaim-migrate @ 1477]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1432
diff
changeset
|
93 /* I probably shouldn't be doing this, but eh. -EWarmenhoven */ |
|
7f7857c5036e
[gaim-migrate @ 1477]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1432
diff
changeset
|
94 # warning "Unknown byte order! Using GLib defines" |
|
7f7857c5036e
[gaim-migrate @ 1477]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1432
diff
changeset
|
95 # include <glib.h> |
|
7f7857c5036e
[gaim-migrate @ 1477]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1432
diff
changeset
|
96 # define BYTE_ORDER G_BYTE_ORDER |
|
7f7857c5036e
[gaim-migrate @ 1477]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1432
diff
changeset
|
97 # define BIG_ENDIAN G_BIG_ENDIAN |
|
7f7857c5036e
[gaim-migrate @ 1477]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1432
diff
changeset
|
98 # define LITTLE_ENDIAN G_LITTLE_ENDIAN |
| 1152 | 99 #endif |
| 100 | |
| 101 #if BYTE_ORDER == BIG_ENDIAN | |
| 102 /* host is different from ICQ byte order */ | |
| 103 # define htoicql(x) bswap_32(x) | |
| 104 # define icqtohl(x) bswap_32(x) | |
| 105 # define htoicqs(x) bswap_16(x) | |
| 106 # define icqtohs(x) bswap_16(x) | |
| 107 #else | |
| 108 # if BYTE_ORDER == LITTLE_ENDIAN | |
| 109 /* host byte order match ICQ byte order */ | |
| 110 # define htoicql(x) (x) | |
| 111 # define icqtohl(x) (x) | |
| 112 # define htoicqs(x) (x) | |
| 113 # define icqtohs(x) (x) | |
| 114 # else | |
| 115 # error "Unsupported byte order!" | |
| 116 # endif | |
| 117 #endif | |
| 118 | |
| 119 #endif | |
| 120 | |
| 121 /* ICQ byte order is always different from network byte order. */ | |
| 122 # define ntoicql(x) bswap_32(x) | |
| 123 # define icqtonl(x) bswap_32(x) | |
| 124 # define ntoicqs(x) bswap_16(x) | |
| 125 # define icqtons(x) bswap_16(x) | |
| 126 | |
| 127 #endif |
