void InitConfig (char *arg0) { #if defined (OS_WIN32_MINGW) // the progdir is always the current dir param.config_dir = "config"; param.data_dir = "data"; param.configfile = param.config_dir + SEP + "options.txt"; #else char buff[256]; if (strcmp (arg0, "./etr") == 0) { // start from work directory char *s = getcwd (buff, 256); if (s==NULL) {}; } else { // start with full path strcpy (buff, arg0); if (strlen (buff) > 5) buff[strlen(buff)-3] = 0; } param.prog_dir = buff; struct passwd *pwent = getpwuid (getuid ()); param.config_dir = pwent->pw_dir; param.config_dir += SEP; param.config_dir += CONFIG_DIR; // or: param.config_dir = param.prog_dir + SEP + "config"; if (!DirExists (param.config_dir.c_str())) mkdir (param.config_dir.c_str(), 0775); param.data_dir = param.prog_dir + SEP + "data"; param.configfile = param.config_dir + SEP + "options"; #endif param.screenshot_dir = param.data_dir + SEP + "screenshots"; param.obj_dir = param.data_dir + SEP + "objects"; param.env_dir2 = param.data_dir + SEP + "env"; param.char_dir = param.data_dir + SEP + "char"; param.keyframe_dir = param.char_dir + SEP + "keyframes"; param.terr_dir = param.data_dir + SEP + "terrains"; param.tex_dir = param.data_dir + SEP + "textures"; param.common_course_dir = param.data_dir + SEP + "courses"; param.common_cup_dir = param.data_dir + SEP + "cups"; param.sounds_dir = param.data_dir + SEP + "sounds"; param.music_dir = param.data_dir + SEP + "music"; param.font_dir = param.data_dir + SEP + "fonts"; param.trans_dir = param.data_dir + SEP + "translations"; param.player_dir = param.data_dir + SEP + "players"; param.ui_snow = true; param.view_mode = 1; param.display_fps = false; param.show_hud = true; if (FileExists (param.configfile.c_str())) { // SetConfigDefaults (); LoadConfigFile (); } else { SetConfigDefaults (); SaveConfigFile (); } string playerfile = param.config_dir + SEP + PLAYER_FILE; if (FileExists (playerfile.c_str())) { } else { } }
/** * Initialize logging configuration. Schedules a work thread to * load the configuration file once the file system is readable. **/ void BCMLOG_InitConfig(void *h) { int value; struct device * dev = (struct device *)h; /* * disable all AP logging (CP logging is * handled by CP) [MobC00126731] */ memset(&g_config, 0x00, sizeof(g_config)); /* * set default configuration */ SetConfigDefaults(); /* * create the procfs entry */ g_proc_dir_entry = create_proc_entry(BCMLOG_CONFIG_PROC_FILE, S_IRWXU | S_IRWXG | S_IRWXO, NULL); if (g_proc_dir_entry == NULL) { remove_proc_entry(BCMLOG_CONFIG_PROC_FILE, NULL); } else { g_proc_dir_entry->read_proc = proc_read; g_proc_dir_entry->write_proc = proc_write; } strncpy(g_config.file_base, BCMLOG_DEFAULT_FILE_BASE, MAX_STR_NAME); strncpy(g_config.uart_dev, BCMLOG_DEFAULT_UART_DEV, MAX_STR_NAME); strncpy(g_config.acm_dev, BCMLOG_DEFAULT_ACM_DEV, MAX_STR_NAME); value = device_create_file(dev, &dev_attr_log); if (value < 0) pr_err("BCMLOG Init failed to create bcmlog log attribute\n"); value = device_create_file(dev, &dev_attr_log_lock); if (value < 0) pr_err ("BCMLOG Init failed to create bcmlog log_lock attribute\n"); value = device_create_file(dev, &dev_attr_cp_crash); if (value < 0) pr_err ("BCMLOG Init failed to create bcmlog cp crash log attribute\n"); value = device_create_file(dev, &dev_attr_cp_crash_lock); if (value < 0) pr_err ("BCMLOG Init failed to create bcmlog cp crash log lock attribute\n"); value = device_create_file(dev, &dev_attr_ap_crash); if (value < 0) pr_err ("BCMLOG Init failed to create bcmlog ap crash log attribute\n"); value = device_create_file(dev, &dev_attr_ap_crash_lock); if (value < 0) pr_err ("BCMLOG Init failed to create bcmlog ap crash log lock attribute\n"); value = device_create_file(dev, &dev_attr_file_base); if (value < 0) pr_err ("BCMLOG Init failed to create bcmlog file_base attribute\n"); value = device_create_file(dev, &dev_attr_file_max); if (value < 0) pr_err ("BCMLOG Init failed to create bcmlog file max attribute\n"); value = device_create_file(dev, &dev_attr_uart_dev); if (value < 0) pr_err ("BCMLOG Init failed to create bcmlog uart_dev attribute\n"); value = device_create_file(dev, &dev_attr_acm_dev); if (value < 0) pr_err ("BCMLOG Init failed to create bcmlog acm_dev attribute\n"); }