Mercurial > hg
comparison mcabber/src/main.c @ 188:7604e3cdbb86
[/trunk] Changeset 200 by mikael
* Add a cfg_read_int() function...
author | mikael |
---|---|
date | Fri, 06 May 2005 09:58:44 +0000 |
parents | a51ce78a0e2a |
children | 200ea7c89d9a |
comparison
equal
deleted
inserted
replaced
187:4ce9ff808baa | 188:7604e3cdbb86 |
---|---|
85 } | 85 } |
86 | 86 |
87 int main(int argc, char **argv) | 87 int main(int argc, char **argv) |
88 { | 88 { |
89 char *configFile = NULL; | 89 char *configFile = NULL; |
90 char *username, *password, *resource; | 90 char *username, *password, *resource, *servername; |
91 char *servername, *portstring; | |
92 char *jid; | 91 char *jid; |
93 char *optstring, *optstring2; | 92 char *optstring; |
94 int optval, optval2; | 93 int optval, optval2; |
94 int ssl; | |
95 int key; | 95 int key; |
96 unsigned int port; | 96 unsigned int port; |
97 unsigned int ping; | 97 unsigned int ping; |
98 int ssl; | |
99 int ret = 0; | 98 int ret = 0; |
100 unsigned int refresh = 0; | 99 unsigned int refresh = 0; |
101 | 100 |
102 credits(); | 101 credits(); |
103 | 102 |
132 ut_WriteLog("Parsing config file...\n"); | 131 ut_WriteLog("Parsing config file...\n"); |
133 cfg_file(configFile); | 132 cfg_file(configFile); |
134 if (configFile) g_free(configFile); | 133 if (configFile) g_free(configFile); |
135 | 134 |
136 optstring = cfg_read("debug"); | 135 optstring = cfg_read("debug"); |
137 if (optstring) | 136 if (optval) ut_InitDebug(1, optstring); |
138 ut_InitDebug(1, optstring); | |
139 | 137 |
140 servername = cfg_read("server"); | 138 servername = cfg_read("server"); |
141 username = cfg_read("username"); | 139 username = cfg_read("username"); |
142 password = cfg_read("password"); | 140 password = cfg_read("password"); |
143 resource = cfg_read("resource"); | 141 resource = cfg_read("resource"); |
144 | 142 |
145 if (!servername) { | 143 if (!servername) { |
146 printf("Server name has not been specified in the config file!\n"); | 144 printf("Server name has not been specified in the config file!\n"); |
147 return -1; | 145 return -1; |
148 } | 146 } |
166 scr_InitCurses(); | 164 scr_InitCurses(); |
167 | 165 |
168 ut_WriteLog("Drawing main window...\n"); | 166 ut_WriteLog("Drawing main window...\n"); |
169 scr_DrawMainWindow(TRUE); | 167 scr_DrawMainWindow(TRUE); |
170 | 168 |
171 optstring = cfg_read("logging"); | 169 optval = (cfg_read_int("logging") > 0); |
172 optstring2 = cfg_read("load_logs"); | 170 optval2 = (cfg_read_int("load_logs") > 0); |
173 optval = (optstring && (atoi(optstring) > 0)); | |
174 optval2 = (optstring2 && (atoi(optstring2) > 0)); | |
175 if (optval || optval2) | 171 if (optval || optval2) |
176 hlog_enable(optval, cfg_read("logging_dir"), optval2); | 172 hlog_enable(optval, cfg_read("logging_dir"), optval2); |
177 | 173 |
178 if ((optstring = cfg_read("events_command")) != NULL) | 174 if ((optstring = cfg_read("events_command")) != NULL) |
179 hk_ext_cmd_init(optstring); | 175 hk_ext_cmd_init(optstring); |
180 | 176 |
181 ssl = 0; | 177 ssl = (cfg_read_int("ssl") > 0); |
182 optstring = cfg_read("ssl"); | 178 port = (unsigned int) cfg_read_int("port"); |
183 if (optstring && (atoi(optstring) > 0)) | |
184 ssl = 1; | |
185 portstring = cfg_read("port"); | |
186 port = (portstring != NULL) ? (unsigned int) atoi(portstring) : 0; | |
187 | 179 |
188 /* Connect to server */ | 180 /* Connect to server */ |
189 ut_WriteLog("Connecting to server: %s:%d\n", servername, port); | 181 ut_WriteLog("Connecting to server: %s:%d\n", servername, port); |
190 scr_LogPrint("Connecting to server: %s:%d", servername, port); | 182 scr_LogPrint("Connecting to server: %s:%d", servername, port); |
191 | 183 |
203 if (cfg_read("pinginterval")) | 195 if (cfg_read("pinginterval")) |
204 ping = (unsigned int) atoi(cfg_read("pinginterval")); | 196 ping = (unsigned int) atoi(cfg_read("pinginterval")); |
205 jb_set_keepalive_delay(ping); | 197 jb_set_keepalive_delay(ping); |
206 ut_WriteLog("Ping interval stablished: %d secs\n", ping); | 198 ut_WriteLog("Ping interval stablished: %d secs\n", ping); |
207 | 199 |
208 optstring = cfg_read("hide_offline_buddies"); | 200 if (cfg_read_int("hide_offline_buddies") > 0) |
209 if (optstring && (atoi(optstring) > 0)) | |
210 buddylist_set_hide_offline_buddies(TRUE); | 201 buddylist_set_hide_offline_buddies(TRUE); |
211 | 202 |
212 /* Initialize commands system */ | 203 /* Initialize commands system */ |
213 cmd_init(); | 204 cmd_init(); |
214 | 205 |