comparison mcabber/src/main.c @ 333:db5bebe96c89

New config. file parsing The "set", "alias" and "bind" keywords can now be used in config files.
author Mikael Berthe <mikael@lilotux.net>
date Mon, 18 Jul 2005 20:02:38 +0100
parents da138cdebf04
children eb994ee40029
comparison
equal deleted inserted replaced
332:a1901741890e 333:db5bebe96c89
176 char *configFile = NULL; 176 char *configFile = NULL;
177 const char *optstring; 177 const char *optstring;
178 int optval, optval2; 178 int optval, optval2;
179 int key; 179 int key;
180 unsigned int ping; 180 unsigned int ping;
181 int ret = 0; 181 int ret;
182 unsigned int refresh = 0; 182 unsigned int refresh = 0;
183 183
184 credits(); 184 credits();
185 185
186 /* Set this >0 to enable log */ 186 /* Set this >0 to enable log */
207 configFile = g_strdup(optarg); 207 configFile = g_strdup(optarg);
208 break; 208 break;
209 } 209 }
210 } 210 }
211 211
212 /* Initialize commands system */
213 cmd_init();
214
212 if (configFile) 215 if (configFile)
213 ut_WriteLog("Setting config file: %s\n", configFile); 216 ut_WriteLog("Setting config file: %s\n", configFile);
214 217
215 /* Parsing config file... */ 218 /* Parsing config file... */
216 ut_WriteLog("Parsing config file...\n"); 219 ut_WriteLog("Parsing config file...\n");
217 cfg_file(configFile); 220 ret = cfg_file(configFile);
218 if (configFile) g_free(configFile); 221 if (configFile) g_free(configFile);
222 /* Leave if there was an error in the config. file */
223 if (ret)
224 exit(EXIT_FAILURE);
219 225
220 optstring = settings_opt_get("debug"); 226 optstring = settings_opt_get("debug");
221 if (optstring) ut_InitDebug(1, optstring); 227 if (optstring) ut_InitDebug(1, optstring);
222 228
223 /* If no password is stored, we ask for it before entering 229 /* If no password is stored, we ask for it before entering
254 if (settings_opt_get("password")) 260 if (settings_opt_get("password"))
255 mcabber_connect(); 261 mcabber_connect();
256 else 262 else
257 scr_LogPrint("Can't connect: no password supplied"); 263 scr_LogPrint("Can't connect: no password supplied");
258 264
259 /* Initialize commands system */
260 cmd_init();
261
262 ut_WriteLog("Entering into main loop...\n\n"); 265 ut_WriteLog("Entering into main loop...\n\n");
263 ut_WriteLog("Ready to send/receive messages...\n"); 266 ut_WriteLog("Ready to send/receive messages...\n");
264 267
265 while (ret != 255) { 268 for (ret = 0 ; ret != 255 ; ) {
266 key = scr_Getch(); 269 key = scr_Getch();
267 270
268 /* The refresh is really an ugly hack, but we need to call doupdate() 271 /* The refresh is really an ugly hack, but we need to call doupdate()
269 from time to time to catch the RESIZE events, because getch keep 272 from time to time to catch the RESIZE events, because getch keep
270 returning ERR until a real key is pressed :-( 273 returning ERR until a real key is pressed :-(