1 | /********************************************************************\ |
---|
2 | * BitlBee -- An IRC to other IM-networks gateway * |
---|
3 | * * |
---|
4 | * Copyright 2002-2004 Wilmer van der Gaast and others * |
---|
5 | \********************************************************************/ |
---|
6 | |
---|
7 | /* |
---|
8 | * nogaim |
---|
9 | * |
---|
10 | * Gaim without gaim - for BitlBee |
---|
11 | * |
---|
12 | * This file contains functions called by the Gaim IM-modules. It's written |
---|
13 | * from scratch for BitlBee and doesn't contain any code from Gaim anymore |
---|
14 | * (except for the function names). |
---|
15 | * |
---|
16 | * Copyright 2002-2004 Wilmer van der Gaast <lintux@lintux.cx> |
---|
17 | */ |
---|
18 | |
---|
19 | /* |
---|
20 | This program is free software; you can redistribute it and/or modify |
---|
21 | it under the terms of the GNU General Public License as published by |
---|
22 | the Free Software Foundation; either version 2 of the License, or |
---|
23 | (at your option) any later version. |
---|
24 | |
---|
25 | This program is distributed in the hope that it will be useful, |
---|
26 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
27 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
28 | GNU General Public License for more details. |
---|
29 | |
---|
30 | You should have received a copy of the GNU General Public License with |
---|
31 | the Debian GNU/Linux distribution in /usr/share/common-licenses/GPL; |
---|
32 | if not, write to the Free Software Foundation, Inc., 59 Temple Place, |
---|
33 | Suite 330, Boston, MA 02111-1307 USA |
---|
34 | */ |
---|
35 | |
---|
36 | #define BITLBEE_CORE |
---|
37 | #include "nogaim.h" |
---|
38 | #include <ctype.h> |
---|
39 | #include <iconv.h> |
---|
40 | |
---|
41 | struct prpl *proto_prpl[PROTO_MAX]; |
---|
42 | char proto_name[PROTO_MAX][8] = { "TOC", "OSCAR", "YAHOO", "ICQ", "MSN", "", "", "", "JABBER", "", "", "", "", "", "", "" }; |
---|
43 | |
---|
44 | static char *proto_away_alias[7][5] = |
---|
45 | { |
---|
46 | { "Away from computer", "Away", "Extended away", NULL }, |
---|
47 | { "NA", "N/A", "Not available", NULL }, |
---|
48 | { "Busy", "Do not disturb", "DND", "Occupied", NULL }, |
---|
49 | { "Be right back", "BRB", NULL }, |
---|
50 | { "On the phone", "Phone", "On phone", NULL }, |
---|
51 | { "Out to lunch", "Lunch", "Food", NULL }, |
---|
52 | { NULL } |
---|
53 | }; |
---|
54 | static char *proto_away_alias_find( GList *gcm, char *away ); |
---|
55 | |
---|
56 | static int remove_chat_buddy_silent( struct conversation *b, char *handle ); |
---|
57 | |
---|
58 | GSList *connections; |
---|
59 | |
---|
60 | |
---|
61 | /* nogaim.c */ |
---|
62 | |
---|
63 | void nogaim_init() |
---|
64 | { |
---|
65 | proto_prpl[PROTO_MSN] = g_new0 ( struct prpl, 1 ); |
---|
66 | #ifdef WITH_MSN |
---|
67 | msn_init( proto_prpl[PROTO_MSN] ); |
---|
68 | #endif |
---|
69 | |
---|
70 | proto_prpl[PROTO_OSCAR] = g_new0( struct prpl, 1 ); |
---|
71 | #ifdef WITH_OSCAR |
---|
72 | oscar_init( proto_prpl[PROTO_OSCAR] ); |
---|
73 | #endif |
---|
74 | |
---|
75 | proto_prpl[PROTO_YAHOO] = g_new0( struct prpl, 1 ); |
---|
76 | #ifdef WITH_YAHOO |
---|
77 | byahoo_init( proto_prpl[PROTO_YAHOO] ); |
---|
78 | #endif |
---|
79 | |
---|
80 | proto_prpl[PROTO_JABBER] = g_new0( struct prpl, 1 ); |
---|
81 | #ifdef WITH_JABBER |
---|
82 | jabber_init( proto_prpl[PROTO_JABBER] ); |
---|
83 | #endif |
---|
84 | } |
---|
85 | |
---|
86 | GSList *get_connections() { return connections; } |
---|
87 | |
---|
88 | int proto_away( struct gaim_connection *gc, char *away ) |
---|
89 | { |
---|
90 | GList *m, *ms; |
---|
91 | char *s; |
---|
92 | |
---|
93 | if( !away ) away = ""; |
---|
94 | ms = m = gc->prpl->away_states( gc ); |
---|
95 | |
---|
96 | while( m ) |
---|
97 | { |
---|
98 | if( *away ) |
---|
99 | { |
---|
100 | if( g_strncasecmp( m->data, away, strlen( m->data ) ) == 0 ) |
---|
101 | break; |
---|
102 | } |
---|
103 | else |
---|
104 | { |
---|
105 | if( g_strcasecmp( m->data, "Available" ) == 0 ) |
---|
106 | break; |
---|
107 | if( g_strcasecmp( m->data, "Online" ) == 0 ) |
---|
108 | break; |
---|
109 | } |
---|
110 | m = m->next; |
---|
111 | } |
---|
112 | |
---|
113 | if( m ) |
---|
114 | { |
---|
115 | gc->prpl->set_away( gc, m->data, *away ? away : NULL ); |
---|
116 | } |
---|
117 | else |
---|
118 | { |
---|
119 | s = proto_away_alias_find( ms, away ); |
---|
120 | if( s ) |
---|
121 | { |
---|
122 | gc->prpl->set_away( gc, s, away ); |
---|
123 | if( set_getint( gc->irc, "debug" ) ) |
---|
124 | irc_usermsg( gc->irc, "Setting away state for %s to %s", proto_name[gc->protocol], s ); |
---|
125 | } |
---|
126 | else |
---|
127 | gc->prpl->set_away( gc, GAIM_AWAY_CUSTOM, away ); |
---|
128 | } |
---|
129 | |
---|
130 | g_list_free( ms ); |
---|
131 | |
---|
132 | return( 1 ); |
---|
133 | } |
---|
134 | |
---|
135 | static char *proto_away_alias_find( GList *gcm, char *away ) |
---|
136 | { |
---|
137 | GList *m; |
---|
138 | int i, j; |
---|
139 | |
---|
140 | for( i = 0; *proto_away_alias[i]; i ++ ) |
---|
141 | { |
---|
142 | for( j = 0; proto_away_alias[i][j]; j ++ ) |
---|
143 | if( g_strncasecmp( away, proto_away_alias[i][j], strlen( proto_away_alias[i][j] ) ) == 0 ) |
---|
144 | break; |
---|
145 | |
---|
146 | if( !proto_away_alias[i][j] ) /* If we reach the end, this row */ |
---|
147 | continue; /* is not what we want. Next! */ |
---|
148 | |
---|
149 | /* Now find an entry in this row which exists in gcm */ |
---|
150 | for( j = 0; proto_away_alias[i][j]; j ++ ) |
---|
151 | { |
---|
152 | m = gcm; |
---|
153 | while( m ) |
---|
154 | { |
---|
155 | if( g_strcasecmp( proto_away_alias[i][j], m->data ) == 0 ) |
---|
156 | return( proto_away_alias[i][j] ); |
---|
157 | m = m->next; |
---|
158 | } |
---|
159 | } |
---|
160 | } |
---|
161 | |
---|
162 | return( NULL ); |
---|
163 | } |
---|
164 | |
---|
165 | /* Compare two handles for a specific protocol. For most protocols, |
---|
166 | g_strcasecmp is okay, but for AIM, for example, it's not. This really |
---|
167 | should be a compare function inside the PRPL module, but I do it this |
---|
168 | way for now because I don't want to touch the Gaim code too much since |
---|
169 | it's not going to be here for too long anymore. */ |
---|
170 | int handle_cmp( char *a, char *b, int protocol ) |
---|
171 | { |
---|
172 | if( protocol == PROTO_TOC || protocol == PROTO_ICQ ) |
---|
173 | { |
---|
174 | /* AIM, being teh evil, thinks it's cool that users can put |
---|
175 | random spaces in screennames. But "A B" and "AB" are |
---|
176 | equal. Hrmm, okay. */ |
---|
177 | while( 1 ) |
---|
178 | { |
---|
179 | while( *a == ' ' ) a ++; |
---|
180 | while( *b == ' ' ) b ++; |
---|
181 | |
---|
182 | if( *a && *b ) |
---|
183 | { |
---|
184 | if( tolower( *a ) != tolower( *b ) ) |
---|
185 | return( 1 ); |
---|
186 | } |
---|
187 | else if( *a || *b ) |
---|
188 | return( 1 ); |
---|
189 | else |
---|
190 | return( 0 ); |
---|
191 | |
---|
192 | a ++; |
---|
193 | b ++; |
---|
194 | } |
---|
195 | } |
---|
196 | else |
---|
197 | { |
---|
198 | return( g_strcasecmp( a, b ) ); |
---|
199 | } |
---|
200 | } |
---|
201 | |
---|
202 | |
---|
203 | /* multi.c */ |
---|
204 | |
---|
205 | struct gaim_connection *new_gaim_conn( struct aim_user *user ) |
---|
206 | { |
---|
207 | struct gaim_connection *gc; |
---|
208 | account_t *a; |
---|
209 | |
---|
210 | gc = g_new0( struct gaim_connection, 1 ); |
---|
211 | |
---|
212 | gc->protocol = user->protocol; |
---|
213 | gc->prpl = proto_prpl[gc->protocol]; |
---|
214 | g_snprintf( gc->username, sizeof( gc->username ), "%s", user->username ); |
---|
215 | g_snprintf( gc->password, sizeof( gc->password ), "%s", user->password ); |
---|
216 | /* [MD] BUGFIX: don't set gc->irc to the global IRC, but use the one from the struct aim_user. |
---|
217 | * This fixes daemon mode breakage where IRC doesn't point to the currently active connection. |
---|
218 | */ |
---|
219 | gc->irc=user->irc; |
---|
220 | |
---|
221 | connections = g_slist_append( connections, gc ); |
---|
222 | |
---|
223 | user->gc = gc; |
---|
224 | gc->user = user; |
---|
225 | |
---|
226 | // Find the account_t so we can set its gc pointer |
---|
227 | for( a = gc->irc->accounts; a; a = a->next ) |
---|
228 | if( ( struct aim_user * ) a->gc == user ) |
---|
229 | { |
---|
230 | a->gc = gc; |
---|
231 | break; |
---|
232 | } |
---|
233 | |
---|
234 | return( gc ); |
---|
235 | } |
---|
236 | |
---|
237 | void destroy_gaim_conn( struct gaim_connection *gc ) |
---|
238 | { |
---|
239 | account_t *a; |
---|
240 | |
---|
241 | /* Destroy the pointer to this connection from the account list */ |
---|
242 | for( a = gc->irc->accounts; a; a = a->next ) |
---|
243 | if( a->gc == gc ) |
---|
244 | { |
---|
245 | a->gc = NULL; |
---|
246 | break; |
---|
247 | } |
---|
248 | |
---|
249 | connections = g_slist_remove( connections, gc ); |
---|
250 | g_free( gc->user ); |
---|
251 | g_free( gc ); |
---|
252 | } |
---|
253 | |
---|
254 | void set_login_progress( struct gaim_connection *gc, int step, char *msg ) |
---|
255 | { |
---|
256 | irc_usermsg( gc->irc, "%s(%s) - Logging in: %s", proto_name[gc->protocol], gc->username, msg ); |
---|
257 | } |
---|
258 | |
---|
259 | /* Errors *while* logging in */ |
---|
260 | void hide_login_progress( struct gaim_connection *gc, char *msg ) |
---|
261 | { |
---|
262 | irc_usermsg( gc->irc, "%s(%s) - Login error: %s", proto_name[gc->protocol], gc->username, msg ); |
---|
263 | } |
---|
264 | |
---|
265 | /* Errors *after* logging in */ |
---|
266 | void hide_login_progress_error( struct gaim_connection *gc, char *msg ) |
---|
267 | { |
---|
268 | irc_usermsg( gc->irc, "%s(%s) - Logged out: %s", proto_name[gc->protocol], gc->username, msg ); |
---|
269 | } |
---|
270 | |
---|
271 | void serv_got_crap( struct gaim_connection *gc, char *format, ... ) |
---|
272 | { |
---|
273 | va_list params; |
---|
274 | char text[1024], buf[1024]; |
---|
275 | char *msg; |
---|
276 | |
---|
277 | va_start( params, format ); |
---|
278 | g_vsnprintf( text, sizeof( text ), format, params ); |
---|
279 | va_end( params ); |
---|
280 | |
---|
281 | if( g_strncasecmp( set_getstr( gc->irc, "charset" ), "none", 4 ) != 0 && |
---|
282 | do_iconv( "UTF8", set_getstr( gc->irc, "charset" ), text, buf, 0, 1024 ) != -1 ) |
---|
283 | msg = buf; |
---|
284 | else |
---|
285 | msg = text; |
---|
286 | |
---|
287 | /* if( g_strcasecmp( set_getstr(gc->irc, "html" ), "strip" ) == 0 ) */ |
---|
288 | if( gc->flags & OPT_CONN_HTML ) |
---|
289 | strip_html( msg ); |
---|
290 | |
---|
291 | irc_usermsg( gc->irc, "%s(%s) - %s", proto_name[gc->protocol], gc->username, msg ); |
---|
292 | } |
---|
293 | |
---|
294 | static gboolean send_keepalive( gpointer d ) |
---|
295 | { |
---|
296 | struct gaim_connection *gc = d; |
---|
297 | |
---|
298 | if( gc->prpl && gc->prpl->keepalive ) |
---|
299 | gc->prpl->keepalive( gc ); |
---|
300 | |
---|
301 | return TRUE; |
---|
302 | } |
---|
303 | |
---|
304 | void account_online( struct gaim_connection *gc ) |
---|
305 | { |
---|
306 | user_t *u; |
---|
307 | |
---|
308 | /* MSN servers sometimes redirect you to a different server and do |
---|
309 | the whole login sequence again, so subsequent calls to this |
---|
310 | function should be handled correctly. (IOW, ignored) */ |
---|
311 | if( gc->flags & OPT_LOGGED_IN ) |
---|
312 | return; |
---|
313 | |
---|
314 | u = user_find( gc->irc, gc->irc->nick ); |
---|
315 | |
---|
316 | irc_usermsg( gc->irc, "%s(%s) - Logged in", proto_name[gc->protocol], gc->username ); |
---|
317 | |
---|
318 | gc->keepalive = g_timeout_add( 60000, send_keepalive, gc ); |
---|
319 | gc->flags |= OPT_LOGGED_IN; |
---|
320 | |
---|
321 | if( u && u->away ) proto_away( gc, u->away ); |
---|
322 | |
---|
323 | if( gc->protocol == PROTO_ICQ ) |
---|
324 | { |
---|
325 | for( u = gc->irc->users; u; u = u->next ) |
---|
326 | if( u->gc == gc ) |
---|
327 | break; |
---|
328 | |
---|
329 | if( u == NULL ) |
---|
330 | irc_usermsg( gc->irc, "\x02""***\x02"" BitlBee now supports ICQ server-side contact lists. " |
---|
331 | "See \x02""help import_buddies\x02"" for more information." ); |
---|
332 | } |
---|
333 | } |
---|
334 | |
---|
335 | gboolean auto_reconnect( gpointer data ) |
---|
336 | { |
---|
337 | account_t *a = data; |
---|
338 | |
---|
339 | a->reconnect = 0; |
---|
340 | account_on( a->irc, a ); |
---|
341 | |
---|
342 | return( FALSE ); /* Only have to run the timeout once */ |
---|
343 | } |
---|
344 | |
---|
345 | void cancel_auto_reconnect( account_t *a ) |
---|
346 | { |
---|
347 | while( g_source_remove_by_user_data( (gpointer) a ) ); |
---|
348 | a->reconnect = 0; |
---|
349 | } |
---|
350 | |
---|
351 | void account_offline( struct gaim_connection *gc ) |
---|
352 | { |
---|
353 | gc->wants_to_die = TRUE; |
---|
354 | signoff( gc ); |
---|
355 | } |
---|
356 | |
---|
357 | void signoff( struct gaim_connection *gc ) |
---|
358 | { |
---|
359 | irc_t *irc = gc->irc; |
---|
360 | user_t *t, *u = irc->users; |
---|
361 | account_t *a; |
---|
362 | |
---|
363 | irc_usermsg( gc->irc, "%s(%s) - Signing off..", proto_name[gc->protocol], gc->username ); |
---|
364 | |
---|
365 | gaim_input_remove( gc->keepalive ); |
---|
366 | gc->keepalive = 0; |
---|
367 | gc->prpl->close( gc ); |
---|
368 | gaim_input_remove( gc->inpa ); |
---|
369 | |
---|
370 | while( u ) |
---|
371 | { |
---|
372 | if( u->gc == gc ) |
---|
373 | { |
---|
374 | t = u->next; |
---|
375 | user_del( irc, u->nick ); |
---|
376 | u = t; |
---|
377 | } |
---|
378 | else |
---|
379 | u = u->next; |
---|
380 | } |
---|
381 | |
---|
382 | query_del_by_gc( gc->irc, gc ); |
---|
383 | |
---|
384 | for( a = irc->accounts; a; a = a->next ) |
---|
385 | if( a->gc == gc ) |
---|
386 | break; |
---|
387 | |
---|
388 | if( !a ) |
---|
389 | { |
---|
390 | /* Uhm... This is very sick. */ |
---|
391 | } |
---|
392 | else if( !gc->wants_to_die && set_getint( irc, "auto_reconnect" ) ) |
---|
393 | { |
---|
394 | int delay = set_getint( irc, "auto_reconnect_delay" ); |
---|
395 | irc_usermsg( gc->irc, "%s(%s) - Reconnecting in %d seconds..", proto_name[gc->protocol], gc->username, delay); |
---|
396 | |
---|
397 | a->reconnect = 1; |
---|
398 | g_timeout_add( delay * 1000, auto_reconnect, a ); |
---|
399 | } |
---|
400 | |
---|
401 | destroy_gaim_conn( gc ); |
---|
402 | } |
---|
403 | |
---|
404 | |
---|
405 | /* dialogs.c */ |
---|
406 | |
---|
407 | void do_error_dialog( struct gaim_connection *gc, char *msg, char *title ) |
---|
408 | { |
---|
409 | irc_usermsg( gc->irc, "%s(%s) - Error: %s", gc->username, title, msg ); |
---|
410 | } |
---|
411 | |
---|
412 | void do_ask_dialog( struct gaim_connection *gc, char *msg, void *data, void *doit, void *dont ) |
---|
413 | { |
---|
414 | query_add( gc->irc, gc, msg, doit, dont, data ); |
---|
415 | } |
---|
416 | |
---|
417 | |
---|
418 | /* list.c */ |
---|
419 | |
---|
420 | int bud_list_cache_exists( struct gaim_connection *gc ) |
---|
421 | { |
---|
422 | return( 0 ); |
---|
423 | } |
---|
424 | |
---|
425 | void do_import( struct gaim_connection *gc, void *null ) |
---|
426 | { |
---|
427 | return; |
---|
428 | } |
---|
429 | |
---|
430 | void add_buddy( struct gaim_connection *gc, char *group, char *handle, char *realname ) |
---|
431 | { |
---|
432 | user_t *u; |
---|
433 | char nick[MAX_NICK_LENGTH+1]; |
---|
434 | char *s; |
---|
435 | irc_t *irc = gc->irc; |
---|
436 | |
---|
437 | if( set_getint( irc, "debug" ) && 0 ) /* This message is too useless */ |
---|
438 | irc_usermsg( irc, "Receiving user add from protocol: %s", handle ); |
---|
439 | |
---|
440 | if( user_findhandle( gc, handle ) ) |
---|
441 | { |
---|
442 | if( set_getint( irc, "debug" ) ) |
---|
443 | irc_usermsg( irc, "User already exists, ignoring add request: %s", handle ); |
---|
444 | |
---|
445 | return; |
---|
446 | |
---|
447 | /* Buddy seems to exist already. Let's ignore this request then... */ |
---|
448 | } |
---|
449 | |
---|
450 | memset( nick, 0, MAX_NICK_LENGTH + 1 ); |
---|
451 | strcpy( nick, nick_get( gc->irc, handle, gc->protocol, realname ) ); |
---|
452 | |
---|
453 | u = user_add( gc->irc, nick ); |
---|
454 | |
---|
455 | if( !realname || !*realname ) realname = nick; |
---|
456 | u->realname = g_strdup( realname ); |
---|
457 | |
---|
458 | if( ( s = strchr( handle, '@' ) ) ) |
---|
459 | { |
---|
460 | u->host = g_strdup( s + 1 ); |
---|
461 | u->user = g_strndup( handle, s - handle ); |
---|
462 | } |
---|
463 | else if( gc->user->proto_opt[0] && *gc->user->proto_opt[0] ) |
---|
464 | { |
---|
465 | u->host = g_strdup( gc->user->proto_opt[0] ); |
---|
466 | u->user = g_strdup( handle ); |
---|
467 | |
---|
468 | /* s/ /_/ ... important for AOL screennames */ |
---|
469 | for( s = u->user; *s; s ++ ) |
---|
470 | if( *s == ' ' ) |
---|
471 | *s = '_'; |
---|
472 | } |
---|
473 | else |
---|
474 | { |
---|
475 | u->host = g_strdup( proto_name[gc->user->protocol] ); |
---|
476 | u->user = g_strdup( handle ); |
---|
477 | } |
---|
478 | |
---|
479 | u->gc = gc; |
---|
480 | u->handle = g_strdup( handle ); |
---|
481 | u->send_handler = buddy_send_handler; |
---|
482 | u->last_typing_notice = 0; |
---|
483 | } |
---|
484 | |
---|
485 | struct buddy *find_buddy( struct gaim_connection *gc, char *handle ) |
---|
486 | { |
---|
487 | static struct buddy b[1]; |
---|
488 | user_t *u; |
---|
489 | |
---|
490 | u = user_findhandle( gc, handle ); |
---|
491 | |
---|
492 | if( !u ) |
---|
493 | return( NULL ); |
---|
494 | |
---|
495 | memset( b, 0, sizeof( b ) ); |
---|
496 | strncpy( b->name, handle, 80 ); |
---|
497 | strncpy( b->show, u->realname, BUDDY_ALIAS_MAXLEN ); |
---|
498 | b->present = u->online; |
---|
499 | b->gc = u->gc; |
---|
500 | |
---|
501 | return( b ); |
---|
502 | } |
---|
503 | |
---|
504 | void do_export( struct gaim_connection *gc ) |
---|
505 | { |
---|
506 | return; |
---|
507 | } |
---|
508 | |
---|
509 | void signoff_blocked( struct gaim_connection *gc ) |
---|
510 | { |
---|
511 | return; /* Make all blocked users look invisible (TODO?) */ |
---|
512 | } |
---|
513 | |
---|
514 | |
---|
515 | void serv_buddy_rename( struct gaim_connection *gc, char *handle, char *realname ) |
---|
516 | { |
---|
517 | user_t *u = user_findhandle( gc, handle ); |
---|
518 | char *name, buf[1024]; |
---|
519 | |
---|
520 | if( !u ) return; |
---|
521 | |
---|
522 | /* Convert all UTF-8 */ |
---|
523 | if( g_strncasecmp( set_getstr( gc->irc, "charset" ), "none", 4 ) != 0 && |
---|
524 | do_iconv( "UTF-8", set_getstr( gc->irc, "charset" ), realname, buf, 0, sizeof( buf ) ) != -1 ) |
---|
525 | name = buf; |
---|
526 | else |
---|
527 | name = realname; |
---|
528 | |
---|
529 | if( g_strcasecmp( u->realname, name ) != 0 ) |
---|
530 | { |
---|
531 | if( u->realname != u->nick ) g_free( u->realname ); |
---|
532 | |
---|
533 | u->realname = g_strdup( name ); |
---|
534 | |
---|
535 | if( ( gc->flags & OPT_LOGGED_IN ) && set_getint( gc->irc, "display_namechanges" ) ) |
---|
536 | irc_usermsg( gc->irc, "User `%s' changed name to `%s'", u->nick, u->realname ); |
---|
537 | } |
---|
538 | } |
---|
539 | |
---|
540 | |
---|
541 | /* prpl.c */ |
---|
542 | |
---|
543 | void show_got_added( struct gaim_connection *gc, char *id, char *handle, const char *realname, const char *msg ) |
---|
544 | { |
---|
545 | return; |
---|
546 | } |
---|
547 | |
---|
548 | |
---|
549 | /* server.c */ |
---|
550 | |
---|
551 | void serv_got_update( struct gaim_connection *gc, char *handle, int loggedin, int evil, time_t signon, time_t idle, int type, guint caps ) |
---|
552 | { |
---|
553 | user_t *u; |
---|
554 | int oa, oo; |
---|
555 | |
---|
556 | u = user_findhandle( gc, handle ); |
---|
557 | |
---|
558 | if( !u ) |
---|
559 | { |
---|
560 | if( g_strcasecmp( set_getstr( gc->irc, "handle_unknown" ), "add" ) == 0 ) |
---|
561 | { |
---|
562 | add_buddy( gc, NULL, handle, NULL ); |
---|
563 | u = user_findhandle( gc, handle ); |
---|
564 | } |
---|
565 | else |
---|
566 | { |
---|
567 | if( set_getint( gc->irc, "debug" ) || g_strcasecmp( set_getstr( gc->irc, "handle_unknown" ), "ignore" ) != 0 ) |
---|
568 | { |
---|
569 | irc_usermsg( gc->irc, "serv_got_update() for handle %s on connection %s(%s):", handle, proto_name[gc->protocol], gc->username ); |
---|
570 | irc_usermsg( gc->irc, "loggedin = %d, type = %d", loggedin, type ); |
---|
571 | } |
---|
572 | |
---|
573 | return; |
---|
574 | } |
---|
575 | return; |
---|
576 | } |
---|
577 | |
---|
578 | oa = u->away != NULL; |
---|
579 | oo = u->online; |
---|
580 | |
---|
581 | if( u->away ) |
---|
582 | { |
---|
583 | g_free( u->away ); |
---|
584 | u->away = NULL; |
---|
585 | } |
---|
586 | |
---|
587 | if( loggedin && !u->online ) |
---|
588 | { |
---|
589 | irc_spawn( gc->irc, u ); |
---|
590 | u->online = 1; |
---|
591 | } |
---|
592 | else if( !loggedin && u->online ) |
---|
593 | { |
---|
594 | struct conversation *c; |
---|
595 | |
---|
596 | irc_kill( gc->irc, u ); |
---|
597 | u->online = 0; |
---|
598 | |
---|
599 | /* Remove him/her from the conversations to prevent PART messages after he/she QUIT already */ |
---|
600 | for( c = gc->conversations; c; c = c->next ) |
---|
601 | remove_chat_buddy_silent( c, handle ); |
---|
602 | } |
---|
603 | |
---|
604 | if( ( type & UC_UNAVAILABLE ) && ( gc->protocol == PROTO_OSCAR || gc->protocol == PROTO_TOC ) ) |
---|
605 | { |
---|
606 | u->away = g_strdup( "Away" ); |
---|
607 | } |
---|
608 | else if( ( type & UC_UNAVAILABLE ) && ( gc->protocol == PROTO_JABBER ) ) |
---|
609 | { |
---|
610 | if( type & UC_DND ) |
---|
611 | u->away = g_strdup( "Do Not Disturb" ); |
---|
612 | else if( type & UC_XA ) |
---|
613 | u->away = g_strdup( "Extended Away" ); |
---|
614 | else // if( type & UC_AWAY ) |
---|
615 | u->away = g_strdup( "Away" ); |
---|
616 | } |
---|
617 | else if( ( type & UC_UNAVAILABLE ) && gc->prpl->get_status_string ) |
---|
618 | { |
---|
619 | u->away = g_strdup( gc->prpl->get_status_string( gc, type ) ); |
---|
620 | } |
---|
621 | else |
---|
622 | u->away = NULL; |
---|
623 | |
---|
624 | /* LISPy... */ |
---|
625 | if( ( set_getint( gc->irc, "away_devoice" ) ) && /* Don't do a thing when user doesn't want it */ |
---|
626 | ( u->online ) && /* Don't touch offline people */ |
---|
627 | ( ( ( u->online != oo ) && !u->away ) || /* Voice joining people */ |
---|
628 | ( ( u->online == oo ) && ( oa == !u->away ) ) ) ) /* (De)voice people changing state */ |
---|
629 | { |
---|
630 | irc_write( gc->irc, ":%s!%s@%s MODE %s %cv %s", gc->irc->mynick, gc->irc->mynick, gc->irc->myhost, |
---|
631 | gc->irc->channel, u->away?'-':'+', u->nick ); |
---|
632 | } |
---|
633 | } |
---|
634 | |
---|
635 | void serv_got_im( struct gaim_connection *gc, char *handle, char *msg, guint32 flags, time_t mtime, gint len ) |
---|
636 | { |
---|
637 | irc_t *irc = gc->irc; |
---|
638 | user_t *u; |
---|
639 | char buf[8192]; |
---|
640 | |
---|
641 | u = user_findhandle( gc, handle ); |
---|
642 | |
---|
643 | if( !u ) |
---|
644 | { |
---|
645 | char *h = set_getstr( irc, "handle_unknown" ); |
---|
646 | |
---|
647 | if( g_strcasecmp( h, "ignore" ) == 0 ) |
---|
648 | { |
---|
649 | if( set_getint( irc, "debug" ) ) |
---|
650 | irc_usermsg( irc, "Ignoring message from unknown handle %s on connection %s(%s)", handle, proto_name[gc->protocol], gc->username ); |
---|
651 | |
---|
652 | return; |
---|
653 | } |
---|
654 | else if( g_strncasecmp( h, "add", 3 ) == 0 ) |
---|
655 | { |
---|
656 | int private = set_getint( irc, "private" ); |
---|
657 | |
---|
658 | if( h[3] ) |
---|
659 | { |
---|
660 | if( g_strcasecmp( h + 3, "_private" ) == 0 ) |
---|
661 | private = 1; |
---|
662 | else if( g_strcasecmp( h + 3, "_channel" ) == 0 ) |
---|
663 | private = 0; |
---|
664 | } |
---|
665 | |
---|
666 | add_buddy( gc, NULL, handle, NULL ); |
---|
667 | u = user_findhandle( gc, handle ); |
---|
668 | u->is_private = private; |
---|
669 | } |
---|
670 | else |
---|
671 | { |
---|
672 | irc_usermsg( irc, "Message from unknown handle %s on connection %s(%s):", handle, proto_name[gc->protocol], gc->username ); |
---|
673 | u = user_find( irc, irc->mynick ); |
---|
674 | } |
---|
675 | } |
---|
676 | |
---|
677 | /* if( g_strcasecmp( set_getstr( irc, "html" ), "strip" ) == 0 ) */ |
---|
678 | if( gc->flags & OPT_CONN_HTML ) |
---|
679 | strip_html( msg ); |
---|
680 | |
---|
681 | if( g_strncasecmp( set_getstr( irc, "charset" ), "none", 4 ) != 0 && |
---|
682 | do_iconv( "UTF-8", set_getstr( irc, "charset" ), msg, buf, 0, 8192 ) != -1 ) |
---|
683 | msg = buf; |
---|
684 | |
---|
685 | while( strlen( msg ) > 450 ) |
---|
686 | { |
---|
687 | char tmp, *nl; |
---|
688 | |
---|
689 | tmp = msg[450]; |
---|
690 | msg[450] = 0; |
---|
691 | |
---|
692 | /* If there's a newline in this string, split up there so we're not |
---|
693 | going to split up lines. If there isn't a newline, well, too bad. */ |
---|
694 | if( ( nl = strrchr( msg, '\n' ) ) ) |
---|
695 | *nl = 0; |
---|
696 | |
---|
697 | irc_msgfrom( irc, u->nick, msg ); |
---|
698 | |
---|
699 | msg[450] = tmp; |
---|
700 | |
---|
701 | /* Move on. */ |
---|
702 | if( nl ) |
---|
703 | { |
---|
704 | *nl = '\n'; |
---|
705 | msg = nl + 1; |
---|
706 | } |
---|
707 | else |
---|
708 | { |
---|
709 | msg += 450; |
---|
710 | } |
---|
711 | } |
---|
712 | irc_msgfrom( irc, u->nick, msg ); |
---|
713 | } |
---|
714 | |
---|
715 | void serv_got_typing( struct gaim_connection *gc, char *handle, int timeout ) |
---|
716 | { |
---|
717 | user_t *u; |
---|
718 | |
---|
719 | if( !set_getint( gc->irc, "typing_notice" ) ) |
---|
720 | return; |
---|
721 | |
---|
722 | if( ( u = user_findhandle( gc, handle ) ) ) |
---|
723 | irc_noticefrom( gc->irc, u->nick, "* Typing a message *" ); |
---|
724 | } |
---|
725 | |
---|
726 | void serv_got_chat_left( struct gaim_connection *gc, int id ) |
---|
727 | { |
---|
728 | struct conversation *c, *l = NULL; |
---|
729 | GList *ir; |
---|
730 | |
---|
731 | if( set_getint( gc->irc, "debug" ) ) |
---|
732 | irc_usermsg( gc->irc, "You were removed from conversation %d", (int) id ); |
---|
733 | |
---|
734 | for( c = gc->conversations; c && c->id != id; c = (l=c)->next ); |
---|
735 | |
---|
736 | if( c ) |
---|
737 | { |
---|
738 | if( c->joined ) |
---|
739 | { |
---|
740 | user_t *u, *r; |
---|
741 | |
---|
742 | r = user_find( gc->irc, gc->irc->mynick ); |
---|
743 | irc_privmsg( gc->irc, r, "PRIVMSG", c->channel, "", "Cleaning up channel, bye!" ); |
---|
744 | |
---|
745 | u = user_find( gc->irc, gc->irc->nick ); |
---|
746 | irc_kick( gc->irc, u, c->channel, r ); |
---|
747 | /* irc_part( gc->irc, u, c->channel ); */ |
---|
748 | } |
---|
749 | |
---|
750 | if( l ) |
---|
751 | l->next = c->next; |
---|
752 | else |
---|
753 | gc->conversations = c->next; |
---|
754 | |
---|
755 | for( ir = c->in_room; ir; ir = ir->next ) |
---|
756 | g_free( ir->data ); |
---|
757 | g_list_free( c->in_room ); |
---|
758 | g_free( c->channel ); |
---|
759 | g_free( c->title ); |
---|
760 | g_free( c ); |
---|
761 | } |
---|
762 | } |
---|
763 | |
---|
764 | void serv_got_chat_in( struct gaim_connection *gc, int id, char *who, int whisper, char *msg, time_t mtime ) |
---|
765 | { |
---|
766 | struct conversation *c; |
---|
767 | user_t *u; |
---|
768 | char buf[8192]; |
---|
769 | |
---|
770 | /* Gaim sends own messages through this too. IRC doesn't want this, so kill them */ |
---|
771 | if( g_strcasecmp( who, gc->user->username ) == 0 ) |
---|
772 | return; |
---|
773 | |
---|
774 | u = user_findhandle( gc, who ); |
---|
775 | for( c = gc->conversations; c && c->id != id; c = c->next ); |
---|
776 | |
---|
777 | /* if( g_strcasecmp( set_getstr( gc->irc, "html" ), "strip" ) == 0 ) */ |
---|
778 | if( gc->flags & OPT_CONN_HTML ) |
---|
779 | strip_html( msg ); |
---|
780 | |
---|
781 | if( g_strncasecmp( set_getstr( gc->irc, "charset" ), "none", 4 ) != 0 && |
---|
782 | do_iconv( "UTF-8", set_getstr( gc->irc, "charset" ), msg, buf, 0, 8192 ) != -1 ) |
---|
783 | msg = buf; |
---|
784 | |
---|
785 | if( c && u ) |
---|
786 | irc_privmsg( gc->irc, u, "PRIVMSG", c->channel, "", msg ); |
---|
787 | else |
---|
788 | irc_usermsg( gc->irc, "Message from/to conversation %s@%d (unknown conv/user): %s", who, id, msg ); |
---|
789 | } |
---|
790 | |
---|
791 | struct conversation *serv_got_joined_chat( struct gaim_connection *gc, int id, char *handle ) |
---|
792 | { |
---|
793 | struct conversation *c; |
---|
794 | char *s; |
---|
795 | |
---|
796 | /* This one just creates the conversation structure, user won't see anything yet */ |
---|
797 | |
---|
798 | if( gc->conversations ) |
---|
799 | { |
---|
800 | for( c = gc->conversations; c->next; c = c->next ); |
---|
801 | c = c->next = g_new0( struct conversation, 1 ); |
---|
802 | } |
---|
803 | else |
---|
804 | gc->conversations = c = g_new0( struct conversation, 1); |
---|
805 | |
---|
806 | c->id = id; |
---|
807 | c->gc = gc; |
---|
808 | c->title = g_strdup( handle ); |
---|
809 | |
---|
810 | s = g_new( char, 16 ); |
---|
811 | sprintf( s, "#chat_%03d", gc->irc->c_id++ ); |
---|
812 | c->channel = g_strdup( s ); |
---|
813 | g_free( s ); |
---|
814 | |
---|
815 | if( set_getint( gc->irc, "debug" ) ) |
---|
816 | irc_usermsg( gc->irc, "Creating new conversation: (id=%d,handle=%s)", id, handle ); |
---|
817 | |
---|
818 | return( c ); |
---|
819 | } |
---|
820 | |
---|
821 | void serv_finish_login( struct gaim_connection *gc ) |
---|
822 | { |
---|
823 | return; |
---|
824 | } |
---|
825 | |
---|
826 | |
---|
827 | /* buddy_chat.c */ |
---|
828 | |
---|
829 | void add_chat_buddy( struct conversation *b, char *handle ) |
---|
830 | { |
---|
831 | user_t *u = user_findhandle( b->gc, handle ); |
---|
832 | int me = 0; |
---|
833 | |
---|
834 | if( set_getint( b->gc->irc, "debug" ) ) |
---|
835 | irc_usermsg( b->gc->irc, "User %s added to conversation %d", handle, b->id ); |
---|
836 | |
---|
837 | /* It might be yourself! */ |
---|
838 | if( handle_cmp ( handle, b->gc->user->username, b->gc->protocol ) == 0 ) |
---|
839 | { |
---|
840 | u = user_find( b->gc->irc, b->gc->irc->nick ); |
---|
841 | if( !b->joined ) |
---|
842 | irc_join( b->gc->irc, u, b->channel ); |
---|
843 | b->joined = me = 1; |
---|
844 | } |
---|
845 | |
---|
846 | /* Most protocols allow people to join, even when they're not in |
---|
847 | your contact list. Try to handle that here */ |
---|
848 | if( !u ) |
---|
849 | { |
---|
850 | add_buddy( b->gc, NULL, handle, NULL ); |
---|
851 | u = user_findhandle( b->gc, handle ); |
---|
852 | } |
---|
853 | |
---|
854 | /* Add the handle to the room userlist, if it's not 'me' */ |
---|
855 | if( !me ) |
---|
856 | { |
---|
857 | if( b->joined ) |
---|
858 | irc_join( b->gc->irc, u, b->channel ); |
---|
859 | b->in_room = g_list_append( b->in_room, g_strdup( handle ) ); |
---|
860 | } |
---|
861 | } |
---|
862 | |
---|
863 | void remove_chat_buddy( struct conversation *b, char *handle, char *reason ) |
---|
864 | { |
---|
865 | user_t *u; |
---|
866 | int me = 0; |
---|
867 | |
---|
868 | if( set_getint( b->gc->irc, "debug" ) ) |
---|
869 | irc_usermsg( b->gc->irc, "User %s removed from conversation %d (%s)", handle, b->id, reason ? reason : "" ); |
---|
870 | |
---|
871 | /* It might be yourself! */ |
---|
872 | if( g_strcasecmp( handle, b->gc->user->username ) == 0 ) |
---|
873 | { |
---|
874 | u = user_find( b->gc->irc, b->gc->irc->nick ); |
---|
875 | b->joined = 0; |
---|
876 | me = 1; |
---|
877 | } |
---|
878 | else |
---|
879 | { |
---|
880 | u = user_findhandle( b->gc, handle ); |
---|
881 | } |
---|
882 | |
---|
883 | if( remove_chat_buddy_silent( b, handle ) ) |
---|
884 | if( ( b->joined || me ) && u ) |
---|
885 | irc_part( b->gc->irc, u, b->channel ); |
---|
886 | } |
---|
887 | |
---|
888 | static int remove_chat_buddy_silent( struct conversation *b, char *handle ) |
---|
889 | { |
---|
890 | GList *i; |
---|
891 | |
---|
892 | /* Find the handle in the room userlist and shoot it */ |
---|
893 | i = b->in_room; |
---|
894 | while( i ) |
---|
895 | { |
---|
896 | if( g_strcasecmp( handle, i->data ) == 0 ) |
---|
897 | { |
---|
898 | g_free( i->data ); |
---|
899 | b->in_room = g_list_remove( b->in_room, i->data ); |
---|
900 | return( 1 ); |
---|
901 | } |
---|
902 | |
---|
903 | i = i->next; |
---|
904 | } |
---|
905 | |
---|
906 | return( 0 ); |
---|
907 | } |
---|
908 | |
---|
909 | |
---|
910 | /* prefs.c */ |
---|
911 | |
---|
912 | /* Necessary? */ |
---|
913 | void build_block_list() |
---|
914 | { |
---|
915 | return; |
---|
916 | } |
---|
917 | |
---|
918 | void build_allow_list() |
---|
919 | { |
---|
920 | return; |
---|
921 | } |
---|
922 | |
---|
923 | |
---|
924 | /* Misc. BitlBee stuff which shouldn't really be here */ |
---|
925 | |
---|
926 | struct conversation *conv_findchannel( char *channel ) |
---|
927 | { |
---|
928 | struct gaim_connection *gc; |
---|
929 | struct conversation *c; |
---|
930 | GSList *l; |
---|
931 | |
---|
932 | /* This finds the connection which has a conversation which belongs to this channel */ |
---|
933 | for( l = connections; l; l = l->next ) |
---|
934 | { |
---|
935 | gc = l->data; |
---|
936 | for( c = gc->conversations; c && g_strcasecmp( c->channel, channel ) != 0; c = c->next ); |
---|
937 | if( c ) |
---|
938 | return( c ); |
---|
939 | } |
---|
940 | |
---|
941 | return( NULL ); |
---|
942 | } |
---|
943 | |
---|
944 | char *set_eval_away_devoice( irc_t *irc, set_t *set, char *value ) |
---|
945 | { |
---|
946 | int st; |
---|
947 | |
---|
948 | if( ( g_strcasecmp( value, "true" ) == 0 ) || ( g_strcasecmp( value, "yes" ) == 0 ) || ( g_strcasecmp( value, "on" ) == 0 ) ) |
---|
949 | st = 1; |
---|
950 | else if( ( g_strcasecmp( value, "false" ) == 0 ) || ( g_strcasecmp( value, "no" ) == 0 ) || ( g_strcasecmp( value, "off" ) == 0 ) ) |
---|
951 | st = 0; |
---|
952 | else if( sscanf( value, "%d", &st ) != 1 ) |
---|
953 | return( NULL ); |
---|
954 | |
---|
955 | st = st != 0; |
---|
956 | |
---|
957 | /* Horror.... */ |
---|
958 | |
---|
959 | if( st != set_getint( irc, "away_devoice" ) ) |
---|
960 | { |
---|
961 | char list[80] = ""; |
---|
962 | user_t *u = irc->users; |
---|
963 | int i = 0, count = 0; |
---|
964 | char pm; |
---|
965 | char v[80]; |
---|
966 | |
---|
967 | if( st ) |
---|
968 | pm = '+'; |
---|
969 | else |
---|
970 | pm = '-'; |
---|
971 | |
---|
972 | while( u ) |
---|
973 | { |
---|
974 | if( u->gc && u->online && !u->away ) |
---|
975 | { |
---|
976 | if( ( strlen( list ) + strlen( u->nick ) ) >= 79 ) |
---|
977 | { |
---|
978 | for( i = 0; i < count; v[i++] = 'v' ); v[i] = 0; |
---|
979 | irc_write( irc, ":%s!%s@%s MODE %s %c%s%s", |
---|
980 | irc->mynick, irc->mynick, irc->myhost, |
---|
981 | irc->channel, pm, v, list ); |
---|
982 | |
---|
983 | *list = 0; |
---|
984 | count = 0; |
---|
985 | } |
---|
986 | |
---|
987 | sprintf( list + strlen( list ), " %s", u->nick ); |
---|
988 | count ++; |
---|
989 | } |
---|
990 | u = u->next; |
---|
991 | } |
---|
992 | |
---|
993 | /* $v = 'v' x $i */ |
---|
994 | for( i = 0; i < count; v[i++] = 'v' ); v[i] = 0; |
---|
995 | irc_write( irc, ":%s!%s@%s MODE %s %c%s%s", irc->mynick, irc->mynick, irc->myhost, |
---|
996 | irc->channel, pm, v, list ); |
---|
997 | } |
---|
998 | |
---|
999 | return( set_eval_bool( irc, set, value ) ); |
---|
1000 | } |
---|
1001 | |
---|
1002 | int serv_send_im( irc_t *irc, user_t *u, char *msg, int flags ) |
---|
1003 | { |
---|
1004 | char buf[8192]; |
---|
1005 | |
---|
1006 | if( g_strncasecmp( set_getstr( irc, "charset" ), "none", 4 ) != 0 && |
---|
1007 | do_iconv( set_getstr( irc, "charset" ), "UTF-8", msg, buf, 0, 8192 ) != -1 ) |
---|
1008 | msg = buf; |
---|
1009 | |
---|
1010 | if( u->gc->flags & OPT_CONN_HTML) { |
---|
1011 | char * html = escape_html(msg); |
---|
1012 | strncpy(buf, html, 8192); |
---|
1013 | g_free(html); |
---|
1014 | } |
---|
1015 | |
---|
1016 | return( ((struct gaim_connection *)u->gc)->prpl->send_im( u->gc, u->handle, msg, strlen( msg ), flags ) ); |
---|
1017 | } |
---|
1018 | |
---|
1019 | int serv_send_chat( irc_t *irc, struct gaim_connection *gc, int id, char *msg ) |
---|
1020 | { |
---|
1021 | char buf[8192]; |
---|
1022 | |
---|
1023 | if( g_strncasecmp( set_getstr( irc, "charset" ), "none", 4 ) != 0 && |
---|
1024 | do_iconv( set_getstr( irc, "charset" ), "UTF-8", msg, buf, 0, 8192 ) != -1 ) |
---|
1025 | msg = buf; |
---|
1026 | |
---|
1027 | if( gc->flags & OPT_CONN_HTML) { |
---|
1028 | char * html = escape_html(msg); |
---|
1029 | strncpy(buf, html, 8192); |
---|
1030 | g_free(html); |
---|
1031 | } |
---|
1032 | |
---|
1033 | return( gc->prpl->chat_send( gc, id, msg ) ); |
---|
1034 | } |
---|
1035 | |
---|
1036 | /* Convert from one charset to another. |
---|
1037 | |
---|
1038 | from_cs, to_cs: Source and destination charsets |
---|
1039 | src, dst: Source and destination strings |
---|
1040 | size: Size if src. 0 == use strlen(). strlen() is not reliable for UNICODE/UTF16 strings though. |
---|
1041 | maxbuf: Maximum number of bytes to write to dst |
---|
1042 | |
---|
1043 | Returns the number of bytes written to maxbuf or -1 on an error. |
---|
1044 | */ |
---|
1045 | signed int do_iconv( char *from_cs, char *to_cs, char *src, char *dst, size_t size, size_t maxbuf ) |
---|
1046 | { |
---|
1047 | iconv_t cd; |
---|
1048 | size_t res; |
---|
1049 | size_t inbytesleft, outbytesleft; |
---|
1050 | char *inbuf = src; |
---|
1051 | char *outbuf = dst; |
---|
1052 | |
---|
1053 | cd = iconv_open( to_cs, from_cs ); |
---|
1054 | if( cd == (iconv_t) -1 ) |
---|
1055 | return( -1 ); |
---|
1056 | |
---|
1057 | inbytesleft = size ? size : strlen( src ); |
---|
1058 | outbytesleft = maxbuf - 1; |
---|
1059 | res = iconv( cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft ); |
---|
1060 | *outbuf = '\0'; |
---|
1061 | iconv_close( cd ); |
---|
1062 | |
---|
1063 | if( res == (size_t) -1 ) |
---|
1064 | return( -1 ); |
---|
1065 | else |
---|
1066 | return( outbuf - dst ); |
---|
1067 | } |
---|
1068 | |
---|
1069 | char *set_eval_charset( irc_t *irc, set_t *set, char *value ) |
---|
1070 | { |
---|
1071 | iconv_t cd; |
---|
1072 | |
---|
1073 | if ( g_strncasecmp( value, "none", 4 ) == 0 ) |
---|
1074 | return( value ); |
---|
1075 | |
---|
1076 | cd = iconv_open( "UTF-8", value ); |
---|
1077 | if( cd == (iconv_t) -1 ) |
---|
1078 | return( NULL ); |
---|
1079 | |
---|
1080 | iconv_close( cd ); |
---|
1081 | return( value ); |
---|
1082 | } |
---|