Mercurial > pidgin
comparison src/protocols/gg/gg.c @ 2541:8229710b343b
[gaim-migrate @ 2554]
fun stuff.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Thu, 18 Oct 2001 20:56:59 +0000 |
parents | e7478176e760 |
children | 221e1c8e2410 |
comparison
equal
deleted
inserted
replaced
2540:42e8c40247f5 | 2541:8229710b343b |
---|---|
1 /* | 1 /* |
2 * gaim - Gadu-Gadu Protocol Plugin | 2 * gaim - Gadu-Gadu Protocol Plugin |
3 * $Id: gg.c 2531 2001-10-16 23:24:35Z warmenhoven $ | 3 * $Id: gg.c 2554 2001-10-18 20:56:59Z warmenhoven $ |
4 * | 4 * |
5 * Copyright (C) 2001, Arkadiusz Mi¶kiewicz <misiek@pld.ORG.PL> | 5 * Copyright (C) 2001, Arkadiusz Mi¶kiewicz <misiek@pld.ORG.PL> |
6 * | 6 * |
7 * This program is free software; you can redistribute it and/or modify | 7 * This program is free software; you can redistribute it and/or modify |
8 * it under the terms of the GNU General Public License as published by | 8 * it under the terms of the GNU General Public License as published by |
18 * along with this program; if not, write to the Free Software | 18 * along with this program; if not, write to the Free Software |
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
20 * | 20 * |
21 */ | 21 */ |
22 | 22 |
23 #ifdef HAVE_CONFIG_H | |
23 #include <config.h> | 24 #include <config.h> |
25 #endif | |
24 | 26 |
25 #include <netdb.h> | 27 #include <netdb.h> |
26 #include <unistd.h> | 28 #include <unistd.h> |
27 #include <errno.h> | 29 #include <errno.h> |
28 #include <netinet/in.h> | 30 #include <netinet/in.h> |
38 #ifdef HAVE_LANGINFO_CODESET | 40 #ifdef HAVE_LANGINFO_CODESET |
39 #include <langinfo.h> | 41 #include <langinfo.h> |
40 #endif | 42 #endif |
41 #ifdef HAVE_ICONV | 43 #ifdef HAVE_ICONV |
42 #include <iconv.h> | 44 #include <iconv.h> |
45 #include "iconv_string.h" | |
43 #endif | 46 #endif |
44 /* Library from EKG (Eksperymentalny Klient Gadu-Gadu) */ | 47 /* Library from EKG (Eksperymentalny Klient Gadu-Gadu) */ |
45 #include "libgg.h" | 48 #include "libgg.h" |
46 #include "multi.h" | 49 #include "multi.h" |
47 #include "prpl.h" | 50 #include "prpl.h" |
87 return "Gadu-Gadu"; | 90 return "Gadu-Gadu"; |
88 } | 91 } |
89 | 92 |
90 static gchar *charset_convert(const gchar *locstr, char *encsrc, char *encdst) | 93 static gchar *charset_convert(const gchar *locstr, char *encsrc, char *encdst) |
91 { | 94 { |
95 gchar *result = NULL; | |
92 #ifdef HAVE_ICONV | 96 #ifdef HAVE_ICONV |
93 gchar *dststr; | 97 if (iconv_string(encdst, encsrc, locstr, locstr+strlen(locstr)+1, &result, NULL) < 0) |
94 size_t loclen, dstlen; | 98 #endif |
95 gchar *fsave, *tsave; | |
96 size_t count; | |
97 static iconv_t cd = (iconv_t)(-1); | |
98 | |
99 if (cd == (iconv_t)(-1)) { | |
100 cd = iconv_open(encdst, encsrc); | |
101 if (cd == (iconv_t)(-1)) { | |
102 return g_strdup(locstr); | |
103 } | |
104 } | |
105 | |
106 loclen = strlen(locstr); | |
107 /* we are ready for multibyte conversions */ | |
108 dstlen = MB_LEN_MAX * loclen; | |
109 dststr = g_new0(gchar, dstlen + 1); | |
110 fsave = (gchar *)locstr; | |
111 tsave = dststr; | |
112 count = iconv(cd, &fsave, &loclen, &tsave, &dstlen); | |
113 if (count == -1) { | |
114 g_free(dststr); | |
115 return g_strdup(locstr); | |
116 } | |
117 return dststr; | |
118 #else | |
119 return g_strdup(locstr); | 99 return g_strdup(locstr); |
120 #endif | 100 return result; |
121 } | 101 } |
122 | 102 |
123 static gboolean invalid_uin(char *uin) | 103 static gboolean invalid_uin(char *uin) |
124 { | 104 { |
125 unsigned long int res = strtol(uin, (char **)NULL, 10); | 105 unsigned long int res = strtol(uin, (char **)NULL, 10); |