comparison src/gaimrc.c @ 1881:a02584b98823

[gaim-migrate @ 1891] C:) committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Wed, 23 May 2001 07:59:05 +0000
parents 75643b9f4261
children 318d6240ffe3
comparison
equal deleted inserted replaced
1880:b8245bcce7e6 1881:a02584b98823
32 #include <stdio.h> 32 #include <stdio.h>
33 #include <stdlib.h> 33 #include <stdlib.h>
34 #include <gtk/gtk.h> 34 #include <gtk/gtk.h>
35 #include "gaim.h" 35 #include "gaim.h"
36 #include "prpl.h" 36 #include "prpl.h"
37 #include "proxy.h"
37 38
38 /* for people like myself, who are too lazy to add an away msg :) */ 39 /* for people like myself, who are too lazy to add an away msg :) */
39 #define BORING_DEFAULT_AWAY_MSG "sorry, i ran out for a while. bbl" 40 #define BORING_DEFAULT_AWAY_MSG "sorry, i ran out for a while. bbl"
40 #define MAX_VALUES 10 41 #define MAX_VALUES 10
41 42
154 return 4; 155 return 4;
155 } else if (!strcmp(tag, "chat")) { 156 } else if (!strcmp(tag, "chat")) {
156 return 5; 157 return 5;
157 } else if (!strcmp(tag, "sound_files")) { 158 } else if (!strcmp(tag, "sound_files")) {
158 return 6; 159 return 6;
160 } else if (!strcmp(tag, "proxy")) {
161 return 7;
159 } 162 }
160 163
161 return -1; 164 return -1;
162 } 165 }
163 166
766 fprintf(f, "\tsound%c { }\n", i + 'A'); 769 fprintf(f, "\tsound%c { }\n", i + 'A');
767 fprintf(f, "\tsound_cmd { %s }\n", sound_cmd); 770 fprintf(f, "\tsound_cmd { %s }\n", sound_cmd);
768 fprintf(f, "}\n"); 771 fprintf(f, "}\n");
769 } 772 }
770 773
774 static void gaimrc_read_proxy(FILE *f)
775 {
776 char buf[2048];
777 struct parse *p;
778
779 buf[0] = 0;
780
781 while (buf[0] != '}') {
782 if (buf[0] == '#')
783 continue;
784
785 if (!fgets(buf, sizeof(buf), f))
786 return;
787
788 p = parse_line(buf);
789
790 if (!strcmp(p->option, "host")) {
791 g_snprintf(proxyhost, sizeof(proxyhost), "%s", p->value[0]);
792 } else if (!strcmp(p->option, "port")) {
793 proxyport = atoi(p->value[0]);
794 } else if (!strcmp(p->option, "type")) {
795 proxyport = atoi(p->value[0]);
796 } else if (!strcmp(p->option, "user")) {
797 g_snprintf(proxyuser, sizeof(proxyuser), "%s", p->value[0]);
798 } else if (!strcmp(p->option, "pass")) {
799 g_snprintf(proxypass, sizeof(proxypass), "%s", p->value[0]);
800 }
801 }
802 }
803
804 static void gaimrc_write_proxy(FILE *f)
805 {
806 fprintf(f, "proxy {\n");
807 fprintf(f, "\thost { %s }\n", proxyhost);
808 fprintf(f, "\tport { %d }\n", proxyport);
809 fprintf(f, "\ttype { %d }\n", proxytype);
810 fprintf(f, "\tuser { %s }\n", proxyuser);
811 fprintf(f, "\tport { %s }\n", proxypass);
812 fprintf(f, "}\n");
813 }
814
771 815
772 void set_defaults(int saveinfo) 816 void set_defaults(int saveinfo)
773 { 817 {
774 if (!saveinfo) { 818 if (!saveinfo) {
775 if (aim_users) { 819 if (aim_users) {
889 gaimrc_read_chat(f); 933 gaimrc_read_chat(f);
890 break; 934 break;
891 case 6: 935 case 6:
892 gaimrc_read_sounds(f); 936 gaimrc_read_sounds(f);
893 break; 937 break;
938 case 7:
939 gaimrc_read_proxy(f);
940 break;
894 default: 941 default:
895 /* NOOP */ 942 /* NOOP */
896 break; 943 break;
897 } 944 }
898 } 945 }
928 gaimrc_write_pounce(f); 975 gaimrc_write_pounce(f);
929 gaimrc_write_chat(f); 976 gaimrc_write_chat(f);
930 #ifdef GAIM_PLUGINS 977 #ifdef GAIM_PLUGINS
931 gaimrc_write_plugins(f); 978 gaimrc_write_plugins(f);
932 #endif 979 #endif
980 gaimrc_write_proxy(f);
933 fclose(f); 981 fclose(f);
934 chmod(buf, S_IRUSR | S_IWUSR); 982 chmod(buf, S_IRUSR | S_IWUSR);
935 } 983 }
936 } 984 }
937 985