Mercurial > hg
comparison mcabber/src/jabglue.c @ 165:b4921dbf8709
[/trunk] Changeset 177 by mikael
* Maybe fix a segfault when receiving a message.
* Try to have a less intrusive signal handler function.
* TODO update
author | mikael |
---|---|
date | Wed, 04 May 2005 09:07:49 +0000 |
parents | faf534be8ff0 |
children | 62bc2992216b |
comparison
equal
deleted
inserted
replaced
164:faf534be8ff0 | 165:b4921dbf8709 |
---|---|
95 */ | 95 */ |
96 | 96 |
97 char *jidtodisp(const char *jid) | 97 char *jidtodisp(const char *jid) |
98 { | 98 { |
99 char *ptr; | 99 char *ptr; |
100 char *alias = g_strdup(jid); | 100 char *alias; |
101 | |
102 while ((alias = g_strdup(jid)) == NULL) | |
103 usleep(100); | |
104 | |
101 if ((ptr = strchr(alias, '/')) != NULL) { | 105 if ((ptr = strchr(alias, '/')) != NULL) { |
102 *ptr = 0; | 106 *ptr = 0; |
103 } | 107 } |
104 return alias; | 108 return alias; |
105 } | 109 } |
484 | 488 |
485 void packethandler(jconn conn, jpacket packet) | 489 void packethandler(jconn conn, jpacket packet) |
486 { | 490 { |
487 char *p, *r; | 491 char *p, *r; |
488 xmlnode x, y; | 492 xmlnode x, y; |
489 // string from, type, body, enc, ns, id, u, h, s; | |
490 char *from=NULL, *type=NULL, *body=NULL, *enc=NULL; | 493 char *from=NULL, *type=NULL, *body=NULL, *enc=NULL; |
491 char *ns=NULL; | 494 char *ns=NULL; |
492 char *id=NULL; | 495 char *id=NULL; |
493 enum imstatus ust; | 496 enum imstatus ust; |
494 // int npos; | 497 // int npos; |
506 x = xmlnode_get_tag(packet->x, "body"); | 509 x = xmlnode_get_tag(packet->x, "body"); |
507 p = xmlnode_get_data(x); if (p) body = p; | 510 p = xmlnode_get_data(x); if (p) body = p; |
508 | 511 |
509 if ((x = xmlnode_get_tag(packet->x, "subject")) != NULL) | 512 if ((x = xmlnode_get_tag(packet->x, "subject")) != NULL) |
510 if ((p = xmlnode_get_data(x)) != NULL) { | 513 if ((p = xmlnode_get_data(x)) != NULL) { |
511 tmp = g_new(char, strlen(body)+strlen(p)+3); | 514 tmp = g_new(char, strlen(body)+strlen(p)+4); |
512 *tmp = '['; | 515 *tmp = '['; |
513 strcpy(tmp+1, p); | 516 strcpy(tmp+1, p); |
514 strcat(tmp, "]\n"); | 517 strcat(tmp, "]\n"); |
515 strcat(tmp, body); | 518 strcat(tmp, body); |
516 body = tmp; | 519 body = tmp; |
527 enc = p; | 530 enc = p; |
528 break; | 531 break; |
529 } | 532 } |
530 } | 533 } |
531 | 534 |
532 if (body) | 535 if (from && body) |
533 gotmessage(type, from, body, enc); | 536 gotmessage(type, from, body, enc); |
534 if (tmp) | 537 if (tmp) |
535 g_free(tmp); | 538 g_free(tmp); |
536 } | 539 } |
537 break; | 540 break; |