comparison src/protocols/msn/msg.c @ 6181:29fef9695c4d

[gaim-migrate @ 6667] MSN messages with newlines being sent to an MSN client had \n and not \r\n, but the official MSN client requires \r\n (wonderful, huh?) Now we send \r\n for MSN messages. Problem solved. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Thu, 17 Jul 2003 20:49:40 +0000
parents f7ddc1f6227e
children b7e113a59b51
comparison
equal deleted inserted replaced
6180:4fb902212769 6181:29fef9695c4d
405 } 405 }
406 406
407 void 407 void
408 msn_message_set_body(MsnMessage *msg, const char *body) 408 msn_message_set_body(MsnMessage *msg, const char *body)
409 { 409 {
410 const char *c;
411 char *buf, *d;
412 int newline_count = 0;
413 size_t new_len;
414
410 g_return_if_fail(msg != NULL); 415 g_return_if_fail(msg != NULL);
411 g_return_if_fail(body != NULL); 416 g_return_if_fail(body != NULL);
412 417
413 if (msg->body != NULL) { 418 if (msg->body != NULL) {
414 msg->size -= strlen(msg->body); 419 msg->size -= strlen(msg->body);
415 g_free(msg->body); 420 g_free(msg->body);
416 } 421 }
417 422
418 msg->body = g_strdup(body); 423 for (c = body; *c != '\0'; c++) {
419 424 if (*c == '\n' && (c == body || *(c - 1) != '\r'))
420 msg->size += strlen(body); 425 newline_count++;
426 }
427
428 new_len = strlen(body) + newline_count;
429
430 buf = g_new0(char, new_len + 1);
431
432 for (c = body, d = buf; *c != '\0'; c++) {
433 if (*c == '\n' && (c == body || *(c - 1) != '\r')) {
434 *d++ = '\r';
435 *d++ = '\n';
436 }
437 else
438 *d++ = *c;
439 }
440
441 msg->body = buf;
442
443 msg->size += new_len;
421 } 444 }
422 445
423 const char * 446 const char *
424 msn_message_get_body(const MsnMessage *msg) 447 msn_message_get_body(const MsnMessage *msg)
425 { 448 {