| 219 if (tdt->state == STATE_PAUSE) |
219 if (tdt->state == STATE_PAUSE) |
| 220 /* TOC has given us the PAUSE message; sending could cause a disconnect |
220 /* TOC has given us the PAUSE message; sending could cause a disconnect |
| 221 * so we just return here like everything went through fine */ |
221 * so we just return here like everything went through fine */ |
| 222 return 0; |
222 return 0; |
| 223 |
223 |
| |
224 if (olen < 0) |
| |
225 len = escape_message(buf); |
| |
226 else |
| |
227 len = olen; |
| |
228 |
| 224 /* One _last_ 2048 check here! This shouldn't ever |
229 /* One _last_ 2048 check here! This shouldn't ever |
| 225 * get hit though, hopefully. If it gets hit on an IM |
230 * get hit though, hopefully. If it gets hit on an IM |
| 226 * It'll lose the last " and the message won't go through, |
231 * It'll lose the last " and the message won't go through, |
| 227 * but this'll stop a segfault. */ |
232 * but this'll stop a segfault. */ |
| 228 if (strlen(buf) > (MSG_LEN - sizeof(hdr))) { |
233 if (len > MSG_LEN) { |
| 229 debug_printf("message too long, truncating\n"); |
234 debug_printf("message too long, truncating\n"); |
| 230 buf[MSG_LEN - sizeof(hdr) - 3] = '"'; |
235 buf[MSG_LEN - 1] = '\0'; |
| 231 buf[MSG_LEN - sizeof(hdr) - 2] = '\0'; |
236 len = MSG_LEN; |
| 232 } |
237 } |
| 233 |
238 |
| 234 if (olen < 0) |
|
| 235 len = escape_message(buf); |
|
| 236 else |
|
| 237 len = olen; |
|
| 238 hdr.ast = '*'; |
239 hdr.ast = '*'; |
| 239 hdr.type = type; |
240 hdr.type = type; |
| 240 hdr.seqno = htons(tdt->seqno++ & 0xffff); |
241 hdr.seqno = htons(tdt->seqno++ & 0xffff); |
| 241 hdr.len = htons(len + (type == TYPE_SIGNON ? 0 : 1)); |
242 hdr.len = htons(len + (type == TYPE_SIGNON ? 0 : 1)); |
| 242 |
243 |
| 757 return 0; |
758 return 0; |
| 758 } |
759 } |
| 759 |
760 |
| 760 static void toc_set_config(struct gaim_connection *gc) |
761 static void toc_set_config(struct gaim_connection *gc) |
| 761 { |
762 { |
| 762 char buf[MSG_LEN], snd[BUF_LEN * 2]; |
763 char *buf = g_malloc(MSG_LEN), snd[BUF_LEN * 2]; |
| 763 toc_build_config(gc, buf, MSG_LEN, FALSE); |
764 toc_build_config(gc, buf, MSG_LEN - strlen("toc_set_config \\{\\}"), FALSE); |
| 764 g_snprintf(snd, MSG_LEN, "toc_set_config {%s}", buf); |
765 g_snprintf(snd, MSG_LEN, "toc_set_config {%s}", buf); |
| 765 sflap_send(gc, snd, -1, TYPE_DATA); |
766 sflap_send(gc, snd, -1, TYPE_DATA); |
| |
767 g_free(buf); |
| 766 } |
768 } |
| 767 |
769 |
| 768 static void toc_get_info(struct gaim_connection *g, char *name) |
770 static void toc_get_info(struct gaim_connection *g, char *name) |
| 769 { |
771 { |
| 770 char buf[BUF_LEN * 2]; |
772 char buf[BUF_LEN * 2]; |