comparison src/protocols/toc/toc.c @ 6061:c28dea25983c

[gaim-migrate @ 6511] Assorted fixes. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Tue, 08 Jul 2003 04:12:12 +0000
parents d8cd876e613e
children 11bedb793a44
comparison
equal deleted inserted replaced
6060:6b4a12cd4caf 6061:c28dea25983c
118 118
119 /* constants to identify proto_opts */ 119 /* constants to identify proto_opts */
120 #define USEROPT_AUTH 0 120 #define USEROPT_AUTH 0
121 #define USEROPT_AUTHPORT 1 121 #define USEROPT_AUTHPORT 1
122 122
123 #define TOC_CONNECT_STEPS 3 123 #define TOC_CONNECT_STEPS 4
124 124
125 static void toc_login_callback(gpointer, gint, GaimInputCondition); 125 static void toc_login_callback(gpointer, gint, GaimInputCondition);
126 static void toc_callback(gpointer, gint, GaimInputCondition); 126 static void toc_callback(gpointer, gint, GaimInputCondition);
127 static void accept_file_dialog(struct ft_request *); 127 static void accept_file_dialog(struct ft_request *);
128 128
351 ret = (char *)malloc((j+1) * sizeof(char)); 351 ret = (char *)malloc((j+1) * sizeof(char));
352 352
353 /* Copy the string */ 353 /* Copy the string */
354 i = 0; 354 i = 0;
355 j = 0; 355 j = 0;
356 while (msg[i++]) { 356 while (msg[i]) {
357 switch (msg[i]) { 357 switch (msg[i]) {
358 case '\n': 358 case '\n':
359 ret[j++] = '<'; 359 ret[j] = '<';
360 ret[j++] = 'B'; 360 ret[j+1] = 'B';
361 ret[j++] = 'R'; 361 ret[j+2] = 'R';
362 ret[j++] = '>'; 362 ret[j+3] = '>';
363 j += 4;
363 break; 364 break;
364 case '{': 365 case '{':
365 case '}': 366 case '}':
366 case '\\': 367 case '\\':
367 case '"': 368 case '"':
368 ret[j++] = '\\'; 369 ret[j] = '\\';
370 j++;
369 default: 371 default:
370 ret[j++] = msg[i]; 372 ret[j] = msg[i];
373 j++;
371 } 374 }
375 i++;
372 } 376 }
373 ret[j] = '\0'; 377 ret[j] = '\0';
374 378
375 return ret; 379 return ret;
376 } 380 }
1023 } 1027 }
1024 } 1028 }
1025 1029
1026 static int toc_send_im(GaimConnection *gc, const char *name, const char *message, int len, int flags) 1030 static int toc_send_im(GaimConnection *gc, const char *name, const char *message, int len, int flags)
1027 { 1031 {
1028 char buf[BUF_LEN * 2]; 1032 char *buf1, *buf2;
1029 char *tmp; 1033
1030 1034 buf1 = escape_text(message);
1031 tmp = escape_text(message); 1035 if (strlen(buf1) + 52 > MSG_LEN) {
1032 if (strlen(tmp) + 52 > MSG_LEN) { 1036 g_free(buf1);
1033 g_free(tmp);
1034 return -E2BIG; 1037 return -E2BIG;
1035 } 1038 }
1036 g_snprintf(buf, MSG_LEN - 8, "toc_send_im %s \"%s\"%s", normalize(name), 1039
1037 tmp, ((flags & IM_FLAG_AWAY) ? " auto" : "")); 1040 buf2 = g_strdup_printf("toc_send_im %s \"%s\"%s", normalize(name), buf1,
1038 sflap_send(gc, buf, -1, TYPE_DATA); 1041 ((flags & IM_FLAG_AWAY) ? " auto" : ""));
1039 1042 g_free(buf1);
1040 g_free(tmp); 1043 sflap_send(gc, buf2, -1, TYPE_DATA);
1044 g_free(buf2);
1045
1041 return 1; 1046 return 1;
1042 } 1047 }
1043 1048
1044 static void toc_set_config(GaimConnection *gc) 1049 static void toc_set_config(GaimConnection *gc)
1045 { 1050 {