comparison src/gaimrc.c @ 3493:4b204c262376

[gaim-migrate @ 3553] Rob committed some bug fixes to gtk1-stable, but not to HEAD. now his computer is acting up again, so i'm making the corresponding commits to HEAD. this should help with yahoo i18n, segfaults on jabber, a problem in gaimrc, and word wrapping on new mail notification. Modified Files: ChangeLog src/gaim.h src/gaimrc.c src/prpl.c src/protocols/msn/msn.c src/protocols/yahoo/yahoo.c ---------------------------------------------------------------------- committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Tue, 10 Sep 2002 15:31:34 +0000
parents 0073a014e55b
children 593567405d48
comparison
equal deleted inserted replaced
3492:3b9b5e06c2e0 3493:4b204c262376
61 struct parse { 61 struct parse {
62 char option[256]; 62 char option[256];
63 char value[MAX_VALUES][4096]; 63 char value[MAX_VALUES][4096];
64 }; 64 };
65 65
66 static struct parse *parse_line(char *line) 66 static struct parse *parse_line(char *line, struct parse *p)
67 { 67 {
68 char *c = line; 68 char *c = line;
69 int inopt = 1, inval = 0, curval = -1; 69 int inopt = 1, inval = 0, curval = -1;
70 int optlen = 0, vallen = 0; 70 int optlen = 0, vallen = 0;
71 static struct parse p;
72 int x; 71 int x;
73 72
74 for (x = 0; x < MAX_VALUES; x++) { 73 for (x = 0; x < MAX_VALUES; x++) {
75 p.value[x][0] = 0; 74 p->value[x][0] = 0;
76 } 75 }
77 76
78 77
79 while (*c) { 78 while (*c) {
80 if (*c == '\t') { 79 if (*c == '\t') {
83 } 82 }
84 if (inopt) { 83 if (inopt) {
85 /* if ((*c < 'a' || *c > 'z') && *c != '_') { */ 84 /* if ((*c < 'a' || *c > 'z') && *c != '_') { */
86 if ((*c < 'a' || *c > 'z') && *c != '_' && (*c < 'A' || *c > 'Z')) { 85 if ((*c < 'a' || *c > 'z') && *c != '_' && (*c < 'A' || *c > 'Z')) {
87 inopt = 0; 86 inopt = 0;
88 p.option[optlen] = 0; 87 p->option[optlen] = 0;
89 c++; 88 c++;
90 continue; 89 continue;
91 } 90 }
92 91
93 p.option[optlen] = *c; 92 p->option[optlen] = *c;
94 optlen++; 93 optlen++;
95 c++; 94 c++;
96 continue; 95 continue;
97 } else if (inval) { 96 } else if (inval) {
98 if ((*c == '}')) { 97 if ((*c == '}')) {
99 if (*(c - 1) == '\\') { 98 if (*(c - 1) == '\\') {
100 p.value[curval][vallen - 1] = *c; 99 p->value[curval][vallen - 1] = *c;
101 c++; 100 c++;
102 continue; 101 continue;
103 } else { 102 } else {
104 p.value[curval][vallen - 1] = 0; 103 p->value[curval][vallen - 1] = 0;
105 inval = 0; 104 inval = 0;
106 c++; 105 c++;
107 continue; 106 continue;
108 } 107 }
109 } else { 108 } else {
110 p.value[curval][vallen] = *c; 109 p->value[curval][vallen] = *c;
111 vallen++; 110 vallen++;
112 c++; 111 c++;
113 continue; 112 continue;
114 } 113 }
115 } else if (*c == '{') { 114 } else if (*c == '{') {
116 if (*(c - 1) == '\\') { 115 if (*(c - 1) == '\\') {
117 p.value[curval][vallen - 1] = *c; 116 p->value[curval][vallen - 1] = *c;
118 c++; 117 c++;
119 continue; 118 continue;
120 } else { 119 } else {
121 curval++; 120 curval++;
122 vallen = 0; 121 vallen = 0;
127 } 126 }
128 } 127 }
129 c++; 128 c++;
130 } 129 }
131 130
132 return &p; 131 return p;
133 } 132 }
134 133
135 134
136 static int gaimrc_parse_tag(FILE *f) 135 static int gaimrc_parse_tag(FILE *f)
137 { 136 {
226 return woo; 225 return woo;
227 } 226 }
228 227
229 static void gaimrc_read_away(FILE *f) 228 static void gaimrc_read_away(FILE *f)
230 { 229 {
230 struct parse parse_buffer;
231 struct parse *p; 231 struct parse *p;
232 char buf[4096]; 232 char buf[4096];
233 struct away_message *a; 233 struct away_message *a;
234 234
235 buf[0] = 0; 235 buf[0] = 0;
239 return; 239 return;
240 240
241 if (buf[0] == '}') 241 if (buf[0] == '}')
242 return; 242 return;
243 243
244 p = parse_line(buf); 244 p = parse_line(buf, &parse_buffer);
245 if (!strcmp(p->option, "message")) { 245 if (!strcmp(p->option, "message")) {
246 a = g_new0(struct away_message, 1); 246 a = g_new0(struct away_message, 1);
247 247
248 g_snprintf(a->name, sizeof(a->name), "%s", p->value[0]); 248 g_snprintf(a->name, sizeof(a->name), "%s", p->value[0]);
249 g_snprintf(a->message, sizeof(a->message), "%s", p->value[1]); 249 g_snprintf(a->message, sizeof(a->message), "%s", p->value[1]);
299 fprintf(f, "}\n"); 299 fprintf(f, "}\n");
300 } 300 }
301 301
302 static void gaimrc_read_pounce(FILE *f) 302 static void gaimrc_read_pounce(FILE *f)
303 { 303 {
304 struct parse parse_buffer;
304 struct parse *p; 305 struct parse *p;
305 char buf[4096]; 306 char buf[4096];
306 struct buddy_pounce *b; 307 struct buddy_pounce *b;
307 308
308 buf[0] = 0; 309 buf[0] = 0;
312 return; 313 return;
313 314
314 if (buf[0] == '}') 315 if (buf[0] == '}')
315 return; 316 return;
316 317
317 p = parse_line(buf); 318 p = parse_line(buf, &parse_buffer);
318 if (!strcmp(p->option, "entry")) { 319 if (!strcmp(p->option, "entry")) {
319 b = g_new0(struct buddy_pounce, 1); 320 b = g_new0(struct buddy_pounce, 1);
320 321
321 g_snprintf(b->name, sizeof(b->name), "%s", p->value[0]); 322 g_snprintf(b->name, sizeof(b->name), "%s", p->value[0]);
322 filter_break(b->name); 323 filter_break(b->name);
411 fprintf(f, "}\n"); 412 fprintf(f, "}\n");
412 } 413 }
413 414
414 static void gaimrc_read_plugins(FILE *f) 415 static void gaimrc_read_plugins(FILE *f)
415 { 416 {
417 struct parse parse_buffer;
416 struct parse *p; 418 struct parse *p;
417 char buf[4096]; 419 char buf[4096];
418 GSList *load = NULL; 420 GSList *load = NULL;
419 421
420 buf[0] = 0; 422 buf[0] = 0;
424 break; 426 break;
425 427
426 if (buf[0] == '}') 428 if (buf[0] == '}')
427 break; 429 break;
428 430
429 p = parse_line(buf); 431 p = parse_line(buf, &parse_buffer);
430 if (!strcmp(p->option, "plugin")) { 432 if (!strcmp(p->option, "plugin")) {
431 filter_break(p->value[0]); 433 filter_break(p->value[0]);
432 load = g_slist_append(load, g_strdup(p->value[0])); 434 load = g_slist_append(load, g_strdup(p->value[0]));
433 } 435 }
434 } 436 }
444 } 446 }
445 #endif /* GAIM_PLUGINS */ 447 #endif /* GAIM_PLUGINS */
446 448
447 static struct aim_user *gaimrc_read_user(FILE *f) 449 static struct aim_user *gaimrc_read_user(FILE *f)
448 { 450 {
451 struct parse parse_buffer;
449 struct parse *p; 452 struct parse *p;
450 struct aim_user *u; 453 struct aim_user *u;
451 int i; 454 int i;
452 char buf[4096]; 455 char buf[4096];
453 456
454 if (!fgets(buf, sizeof(buf), f)) 457 if (!fgets(buf, sizeof(buf), f))
455 return NULL; 458 return NULL;
456 459
457 p = parse_line(buf); 460 p = parse_line(buf, &parse_buffer);
458 461
459 if (strcmp(p->option, "ident")) 462 if (strcmp(p->option, "ident"))
460 return NULL; 463 return NULL;
461 464
462 u = g_new0(struct aim_user, 1); 465 u = g_new0(struct aim_user, 1);
497 500
498 if (!strcmp(buf, "\t}")) { 501 if (!strcmp(buf, "\t}")) {
499 return u; 502 return u;
500 } 503 }
501 504
502 p = parse_line(buf); 505 p = parse_line(buf, &parse_buffer);
503 506
504 if (strcmp(p->option, "user_opts")) 507 if (strcmp(p->option, "user_opts"))
505 return u; 508 return u;
506 509
507 u->options = atoi(p->value[0]); 510 u->options = atoi(p->value[0]);
511 return u; 514 return u;
512 515
513 if (!strcmp(buf, "\t}")) 516 if (!strcmp(buf, "\t}"))
514 return u; 517 return u;
515 518
516 p = parse_line(buf); 519 p = parse_line(buf, &parse_buffer);
517 520
518 if (strcmp(p->option, "proto_opts")) 521 if (strcmp(p->option, "proto_opts"))
519 return u; 522 return u;
520 523
521 for (i = 0; i < 7; i++) 524 for (i = 0; i < 7; i++)
525 return u; 528 return u;
526 529
527 if (!strcmp(buf, "\t}")) 530 if (!strcmp(buf, "\t}"))
528 return u; 531 return u;
529 532
530 p = parse_line(buf); 533 p = parse_line(buf, &parse_buffer);
531 534
532 if (strcmp(p->option, "iconfile")) 535 if (strcmp(p->option, "iconfile"))
533 return u; 536 return u;
534 537
535 g_snprintf(u->iconfile, sizeof(u->iconfile), "%s", p->value[0]); 538 g_snprintf(u->iconfile, sizeof(u->iconfile), "%s", p->value[0]);
538 return u; 541 return u;
539 542
540 if (!strcmp(buf, "\t}")) 543 if (!strcmp(buf, "\t}"))
541 return u; 544 return u;
542 545
543 p = parse_line(buf); 546 p = parse_line(buf, &parse_buffer);
544 547
545 if (strcmp(p->option, "alias")) 548 if (strcmp(p->option, "alias"))
546 return u; 549 return u;
547 550
548 g_snprintf(u->alias, sizeof(u->alias), "%s", p->value[0]); 551 g_snprintf(u->alias, sizeof(u->alias), "%s", p->value[0]);
591 594
592 static void gaimrc_read_users(FILE *f) 595 static void gaimrc_read_users(FILE *f)
593 { 596 {
594 char buf[2048]; 597 char buf[2048];
595 struct aim_user *u; 598 struct aim_user *u;
599 struct parse parse_buffer;
596 struct parse *p; 600 struct parse *p;
597 601
598 buf[0] = 0; 602 buf[0] = 0;
599 603
600 while (buf[0] != '}') { 604 while (buf[0] != '}') {
604 if (!fgets(buf, sizeof(buf), f)) 608 if (!fgets(buf, sizeof(buf), f))
605 return; 609 return;
606 610
607 611
608 612
609 p = parse_line(buf); 613 p = parse_line(buf, &parse_buffer);
610 614
611 if (!strcmp(p->option, "current_user")) { 615 if (!strcmp(p->option, "current_user")) {
612 } else if (strcmp(p->option, "user")) { 616 } else if (strcmp(p->option, "user")) {
613 continue; 617 continue;
614 } else { 618 } else {
704 }; 708 };
705 709
706 static void gaimrc_read_options(FILE *f) 710 static void gaimrc_read_options(FILE *f)
707 { 711 {
708 char buf[2048]; 712 char buf[2048];
713 struct parse parse_buffer;
709 struct parse *p; 714 struct parse *p;
710 gboolean read_logging = FALSE, read_general = FALSE, read_display = FALSE; 715 gboolean read_logging = FALSE, read_general = FALSE, read_display = FALSE;
711 int general_options = 0, display_options = 0; 716 int general_options = 0, display_options = 0;
712 int i; 717 int i;
713 718
718 continue; 723 continue;
719 724
720 if (!fgets(buf, sizeof(buf), f)) 725 if (!fgets(buf, sizeof(buf), f))
721 return; 726 return;
722 727
723 p = parse_line(buf); 728 p = parse_line(buf, &parse_buffer);
724 729
725 if (!strcmp(p->option, "general_options")) { 730 if (!strcmp(p->option, "general_options")) {
726 general_options = atoi(p->value[0]); 731 general_options = atoi(p->value[0]);
727 read_general = TRUE; 732 read_general = TRUE;
728 } else if (!strcmp(p->option, "display_options")) { 733 } else if (!strcmp(p->option, "display_options")) {
870 875
871 static void gaimrc_read_sounds(FILE *f) 876 static void gaimrc_read_sounds(FILE *f)
872 { 877 {
873 int i; 878 int i;
874 char buf[2048]; 879 char buf[2048];
880 struct parse parse_buffer;
875 struct parse *p; 881 struct parse *p;
876 882
877 buf[0] = 0; 883 buf[0] = 0;
878 884
879 for (i = 0; i < NUM_SOUNDS; i++) 885 for (i = 0; i < NUM_SOUNDS; i++)
885 continue; 891 continue;
886 892
887 if (!fgets(buf, sizeof(buf), f)) 893 if (!fgets(buf, sizeof(buf), f))
888 return; 894 return;
889 895
890 p = parse_line(buf); 896 p = parse_line(buf, &parse_buffer);
891 897
892 if (!strcmp(p->option, "sound_cmd")) { 898 if (!strcmp(p->option, "sound_cmd")) {
893 g_snprintf(sound_cmd, sizeof(sound_cmd), "%s", p->value[0]); 899 g_snprintf(sound_cmd, sizeof(sound_cmd), "%s", p->value[0]);
894 } else if (!strncmp(p->option, "sound", strlen("sound"))) { 900 } else if (!strncmp(p->option, "sound", strlen("sound"))) {
895 i = p->option[strlen("sound")] - 'A'; 901 i = p->option[strlen("sound")] - 'A';
1004 } 1010 }
1005 1011
1006 static void gaimrc_read_proxy(FILE *f) 1012 static void gaimrc_read_proxy(FILE *f)
1007 { 1013 {
1008 char buf[2048]; 1014 char buf[2048];
1015 struct parse parse_buffer;
1009 struct parse *p; 1016 struct parse *p;
1010 1017
1011 buf[0] = 0; 1018 buf[0] = 0;
1012 proxyhost[0] = 0; 1019 proxyhost[0] = 0;
1013 1020
1016 continue; 1023 continue;
1017 1024
1018 if (!fgets(buf, sizeof(buf), f)) 1025 if (!fgets(buf, sizeof(buf), f))
1019 return; 1026 return;
1020 1027
1021 p = parse_line(buf); 1028 p = parse_line(buf, &parse_buffer);
1022 1029
1023 if (!strcmp(p->option, "host")) { 1030 if (!strcmp(p->option, "host")) {
1024 g_snprintf(proxyhost, sizeof(proxyhost), "%s", p->value[0]); 1031 g_snprintf(proxyhost, sizeof(proxyhost), "%s", p->value[0]);
1025 } else if (!strcmp(p->option, "port")) { 1032 } else if (!strcmp(p->option, "port")) {
1026 proxyport = atoi(p->value[0]); 1033 proxyport = atoi(p->value[0]);
1133 font_options = 0; 1140 font_options = 0;
1134 1141
1135 away_options = 1142 away_options =
1136 OPT_AWAY_BACK_ON_IM; 1143 OPT_AWAY_BACK_ON_IM;
1137 1144
1138 for (i = 0; i < 7; i++) 1145 for (i = 0; i < NUM_SOUNDS; i++)
1139 sound_file[i] = NULL; 1146 sound_file[i] = NULL;
1140 font_options = 0; 1147 font_options = 0;
1141 /* Enable all of the sound players that might be available. The first 1148 /* Enable all of the sound players that might be available. The first
1142 available one will be used. */ 1149 available one will be used. */
1143 sound_options = 1150 sound_options =