- char * homedir;
- char * configfile;
- size_t len;
- char buf[MAXLINE];
- char * tmp;
- char * value;
- char * default_browser = NULL;
- FILE * fp;
-
- set_config_defaults(&ctx);
-
- if (!(homedir = getenv("HOME")))
- homedir = DEFAULT_HOMEDIR;
- len = strlen(homedir) + strlen(CONFIGFILE_LOC) + 1;
- if (!(configfile = calloc(len, sizeof(char))))
- goto out_noopen;
- strncpy(configfile, homedir, strlen(homedir));
- strncat(configfile, CONFIGFILE_LOC, strlen(CONFIGFILE_LOC));
-
- if (!(fp = fopen(configfile, "r")))
- goto out_noopen;
-
- /* Read in the config file one line at a time and parse it
- XXX doesn't deal with lines longer than MAXLINE */
- while (fgets(buf, MAXLINE, fp)) {
- /* skip comments */
- if (buf[0] == '#')
- continue;
- /* look for the = in the line */
- if (!(tmp = strchr(buf, '=')))
- continue;
-
- /* split the line into parameter (before =, in buf) and
- value (after =, in value) */
- if (!(value = calloc(strlen(tmp+1)+1, sizeof(char))))
- goto out;
- strncpy(value, tmp+1, strlen(tmp+1));
- value[strlen(tmp+1)] = '\0';
- /* scribble over the = in buf with a \0 -- that makes buf
- just the parameter name */
- *tmp = '\0';
- /* if we find a newline in value, replace that with a \0 too */
- if ((tmp = strchr(value, '\n')))
- *tmp = '\0';
-
- if (!strcmp(buf, "continuous_mode")) {
- ctx.continuous_mode = atoi(value);
- free(value);
- } else if (!strcmp(buf, "default_browser")) {
- if (!default_browser)
- default_browser = value;
- } else if (!strcmp(buf, "other_browser_cmd")) {
- if (!ctx.other_browser_cmd)
- ctx.other_browser_cmd = value;
- } else {
- /* Don't need this line's contents */
- free(value);
+ struct swb_config cfg;
+
+ swb_config_init(&cfg);
+
+ swb_config_load(&cfg);
+
+ log_config(cfg.logging);
+#ifdef FREMANTLE
+ /* continuous mode is required on Fremantle */
+ ctx.continuous_mode = 1;
+ if (!cfg.continuous_mode)
+ log_msg("continuous_mode = 0 operation no longer supported, ignoring config setting\n");
+#else
+ ctx.continuous_mode = cfg.continuous_mode;
+#endif
+ free(ctx.other_browser_cmd);
+ if (cfg.other_browser_cmd) {
+ if (!(ctx.other_browser_cmd = strdup(cfg.other_browser_cmd))) {
+ log_perror(errno, "Failed to set other_browser_cmd");
+ exit(1);