Ejemplo n.º 1
0
static int cmdline_help(const char *param, void *extra_param)
{
    cmdline_show_help(NULL);

#ifndef __LIBRETRO__
//retro fix atexit in other thread
    exit(0);
#endif
    return 0;   /* OSF1 cc complains */
}
Ejemplo n.º 2
0
static int config_init(int argc, char * * argv)
{
    char const * levels;
    char *       temp;
    char const * tok;

	if (cmdline_parse(argc, argv)<0) {
		return -1;
	}
	if (cmdline_get_version()) {
		cmdline_show_version();
		return -1;
	}
	if (cmdline_get_help()) {
		cmdline_show_help();
		return -1;
	}
	if (!cmdline_get_foreground()) {
		if (setup_daemon()<0) {
			return -1;
		}
	}
	if (prefs_load(cmdline_get_prefs_file())<0) {
		log_error("error loading configuration file %s",cmdline_get_prefs_file());
		return -1;
	}

    eventlog_clear_level();
    if ((levels = prefs_get_loglevels()))
    {
        if (!(temp = strdup(levels)))
        {
         eventlog(eventlog_level_fatal,"main","could not allocate memory for temp (exiting)");
         return -1;
        }

        tok = strtok(temp,","); /* strtok modifies the string it is passed */

        while (tok)
        {
        if (eventlog_add_level(tok)<0)
            eventlog(eventlog_level_error,"main","could not add log level \"%s\"",tok);
        tok = strtok(NULL,",");
        }

        free(temp);
    }

	if (cmdline_get_logstderr()) {
		eventlog_set(stderr);
	} else if (cmdline_get_logfile()) {
		if (eventlog_open(cmdline_get_logfile())<0) {
			log_error("error open eventlog file %s",cmdline_get_logfile());
			return -1;
		}
	} else {
		if (eventlog_open(prefs_get_logfile())<0) {
			log_error("error open eventlog file %s",prefs_get_logfile());
			return -1;
		}
	}
#ifdef USE_CHECK_ALLOC
	memlog_fp=fopen(cmdline_get_memlog_file(),"a");
	if (!memlog_fp) {
		log_warn("error open file %s for memory debug logging",cmdline_get_memlog_file());
	} else {
		check_set_file(memlog_fp);
	}
#endif
	return 0;
}