예제 #1
0
파일: plugins.c 프로젝트: jd3nn1s/nerdobd2
bool load_output_plugins(void) {
    bool error;
    printf("Loading output plugins...\n");
    error = (ini_parse(INI_CONFIG, output_ini_handler, NULL) < 0);
    if (error)
        fprintf(stderr, "Unable to load output plugins!\n");
    return !error;
}
예제 #2
0
void Configuration::DumpInitialIni(const char* fileName)
{
	// print speed stages
	FILE* f = fopen(fileName, "w");
	fprintf(f, "[speedStages]\nspeed_low = 0.000075\nspeed_med = 0.000125\nspeed_high = 0.000175\n");
	fclose(f);
	ini_parse(fileName, handler, this);
}
예제 #3
0
/* Actual function that parsed the file into a configuration structure */
int parse_config_file(const char *path, rpiwd_config *confstrct) {
	/* A static variable should be reset just in case */
	temp_count = 0;

	int parse_flag = ini_parse(path, inih_callback, confstrct);
	confstrct->config_count = temp_count;

	return parse_flag;
}
예제 #4
0
void config_handler_init(void)
{
  config_handler_set_defaults();
  if (ini_parse("/etc/Xmotion/config.ini", config_handler, &config) < 0) {
      printf("Can't load '/etc/Xmotion/config.ini'\n");
      return;
  }
  printf("Config loaded from '/etc/Xmotion/config.ini'\n");
}
예제 #5
0
void input_config_read() {
	// Read the input config file
	snprintf(inputconfpath, sizeof(inputconfpath), "%sinput.conf", nstpaths.nstdir);
	
	if (ini_parse(inputconfpath, input_config_match, &inputconf) < 0) {
		fprintf(stderr, "Failed to load input config file %s: Using defaults.\n", inputconfpath);
	}
	else {
		// Map the input settings from the config file
		
		// Player 1
		player[0].u = SDL_GetScancodeFromName(inputconf.kb_p1u);
		player[0].d = SDL_GetScancodeFromName(inputconf.kb_p1d);
		player[0].l = SDL_GetScancodeFromName(inputconf.kb_p1l);
		player[0].r = SDL_GetScancodeFromName(inputconf.kb_p1r);
		player[0].select = SDL_GetScancodeFromName(inputconf.kb_p1select);
		player[0].start = SDL_GetScancodeFromName(inputconf.kb_p1start);
		player[0].a = SDL_GetScancodeFromName(inputconf.kb_p1a);
		player[0].b = SDL_GetScancodeFromName(inputconf.kb_p1b);
		player[0].ta = SDL_GetScancodeFromName(inputconf.kb_p1ta);
		player[0].tb = SDL_GetScancodeFromName(inputconf.kb_p1tb);
		
		player[0].ju = input_translate_string(inputconf.js_p1u);
		player[0].jd = input_translate_string(inputconf.js_p1d);
		player[0].jl = input_translate_string(inputconf.js_p1l);
		player[0].jr = input_translate_string(inputconf.js_p1r);
		player[0].jselect = input_translate_string(inputconf.js_p1select);
		player[0].jstart = input_translate_string(inputconf.js_p1start);
		player[0].ja = input_translate_string(inputconf.js_p1a);
		player[0].jb = input_translate_string(inputconf.js_p1b);
		player[0].jta = input_translate_string(inputconf.js_p1ta);
		player[0].jtb = input_translate_string(inputconf.js_p1tb);
		
		// Player 2
		player[1].u = SDL_GetScancodeFromName(inputconf.kb_p2u);
		player[1].d = SDL_GetScancodeFromName(inputconf.kb_p2d);
		player[1].l = SDL_GetScancodeFromName(inputconf.kb_p2l);
		player[1].r = SDL_GetScancodeFromName(inputconf.kb_p2r);
		player[1].select = SDL_GetScancodeFromName(inputconf.kb_p2select);
		player[1].start = SDL_GetScancodeFromName(inputconf.kb_p2start);
		player[1].a = SDL_GetScancodeFromName(inputconf.kb_p2a);
		player[1].b = SDL_GetScancodeFromName(inputconf.kb_p2b);
		player[1].ta = SDL_GetScancodeFromName(inputconf.kb_p2ta);
		player[1].tb = SDL_GetScancodeFromName(inputconf.kb_p2tb);
		
		player[1].ju = input_translate_string(inputconf.js_p2u);
		player[1].jd = input_translate_string(inputconf.js_p2d);
		player[1].jl = input_translate_string(inputconf.js_p2l);
		player[1].jr = input_translate_string(inputconf.js_p2r);
		player[1].jselect = input_translate_string(inputconf.js_p2select);
		player[1].jstart = input_translate_string(inputconf.js_p2start);
		player[1].ja = input_translate_string(inputconf.js_p2a);
		player[1].jb = input_translate_string(inputconf.js_p2b);
		player[1].jta = input_translate_string(inputconf.js_p2ta);
		player[1].jtb = input_translate_string(inputconf.js_p2tb);
	}
}
예제 #6
0
파일: wif.cpp 프로젝트: vidarn/cloth-shader
WeaveData *wif_read(const char *filename)
{
    WeaveData *data;
    data = (WeaveData*)calloc(1,sizeof(WeaveData));
    if (ini_parse(filename, handler, data) < 0) {
        printf("Could not read \"%s\"\n",filename);
    }
    return data;
}
void parse_settings() {
	settings config;

	/* If we have an internal emmc check for sdcard, if it's not present
	 * default COTSETTINGS to the emmc otherwise check the sdcard for a
	 * settings file, if it's not present check the emmc (this sets the
	 * file to be created to the emmc as well). */
	if(OTHER_SD_CARD && OTHER_SD_CARD == EMMC) {
		if(ensure_path_mounted("/sdcard") != 0) {
			ensure_path_mounted("/emmc");
			COTSETTINGS = "/emmc/0/cotrecovery/settings.ini";
		} else if(ini_parse(COTSETTINGS, settings_handler, &config) < 0)
			COTSETTINGS = "/emmc/0/cotrecovery/settings.ini";
	} else if(ensure_path_mounted("/sdcard") != 0) {
		load_fallback_settings();
		parse_language();
		handle_theme(currenttheme);
		return;
	}

    if (ini_parse(COTSETTINGS, settings_handler, &config) < 0) {
        create_default_settings();
        ini_parse(COTSETTINGS, settings_handler, &config);
    }
    LOGI("COT Settings loaded!\n");
    orsreboot = config.orsreboot;
    orswipeprompt = config.orswipeprompt;
    backupprompt = config.backupprompt;
    signature_check_enabled = config.signaturecheckenabled;
    backupfmt = config.backupfmt;
    if (backupfmt == 0) {
		nandroid_switch_backup_handler(0);
	} else {
		nandroid_switch_backup_handler(1);
	}
	currenttheme = config.theme;
	is_sd_theme = config.is_sd_theme;
	maxX = config.ts_x;
	maxY = config.ts_y;
	touchY = config.ts_touchY;
    language = config.language;
	parse_language();
    handle_theme(config.theme);
}
예제 #8
0
int get_config_param(configuration *conf)
{
    if (ini_parse("config.ini", handler, conf) < 0) {
        printf("Can't load 'test.ini'\n");
        return 1;
    }
    printf("Config loaded from 'test.ini': max_life=%d, max_renewable_life=%d, timeout=%d  retries=%d    ticket_lifetime=%d\n",
        conf->max_life, conf->max_renewable_life, conf->timeout,conf->retries,conf->ticket_lifetime);
    return 0;
}
예제 #9
0
파일: plugins.c 프로젝트: jd3nn1s/nerdobd2
bool load_query_plugin(void)
{
    bool error;
    printf("Loading query plugin...\n");
    error = (ini_parse(INI_CONFIG, query_ini_handler, NULL) < 0);
    if (error || loaded_query_plugin_struct == NULL) {
        fprintf(stderr, "Unable to load query plugin!\n");
        return false;
    }
    return true;
}
예제 #10
0
int
config_init(void) {
    config = calloc(1, sizeof(Config));

    config->greeter.start_user = "******";
    config->greeter.cmd = NULL;

    ini_parse(PACKAGE_CONFIG, _config_parse, NULL);

    return 1;
}
예제 #11
0
/**
 * Loads a configuration file and parses it.
 */
void WMConfig::load()
{
    // This is meant to help out the unit tests, which would otherwise have 
    // 'reset()' calls sprinkled about
    reset();

    std::string config_path = get_config_path();
    const char *c_filename = const_cast<const char*>(config_path.c_str());

    ini_parse(c_filename, &WMConfig::config_parser, this);
}
예제 #12
0
struct map_t* create_inimap(const char* inifile)
{
    struct map_t* inimap = new_map();
    map_set_free_func(inimap, free_ini_value);

    if (ini_parse(inifile, handler, inimap) < 0) {
        destroy_map(&inimap);
        inimap = NULL;
    }

    return inimap;
}
예제 #13
0
파일: test_ini.c 프로젝트: kazuyamamoto/ini
/* 空行でもコメントでもないが、無効な行がある場合 */
static void test_ini_get_unknown_line_before_first_section(void)
{
	Ini *ini;
	const char *value;

	ini = ini_parse("abc");

	value = ini_get(ini, "section", "name");
	PCU_ASSERT_PTR_NULL(value);

	ini_delete(ini);
}
예제 #14
0
void
enna_config_load (void)
{
    Eina_List *l;
    Enna_Config_Section_Parser *p;

    ini_parse(cfg_ini);

    EINA_LIST_FOREACH(cfg_parsers, l, p)
    {
        if (p->load)
            p->load(p->section);
    }
}
예제 #15
0
파일: test_ini.c 프로젝트: kazuyamamoto/ini
static void test_ini_get(void)
{
	Ini *ini;
	const char *value;

	ini = ini_parse("[section]\nname=value");
	PCU_ASSERT_PTR_NOT_NULL(ini);

	value = ini_get(ini, "section", "name");
	PCU_ASSERT_PTR_NOT_NULL(value);
	PCU_ASSERT_STRING_EQUAL("value", value);

	ini_delete(ini);
}
예제 #16
0
int _tmain(int argc, char* argv[])
{
//1cmd_file.txt 2config_file.txt 3mem_init.txt 4regs_dump.txt 5mem_dump.txt 6time.txt 7committed.txt 8hitrate.txt 9L1i.txt 10L1d.txt 11L2i.txt 12L2d.txt
//1cmd_file1.txt 2cmd_file2.txt 3config_file.txt 4mem_init.txt 5regs_dump.txt 6mem_dump.txt 7time.txt 8committed.txt 9hitrate.txt 10trace1.txt 11trace2.txt

	if(argc!=12)
	{
		printf("Wrong number of command line arguments!\n");
		exit(1);
	}

	if (ini_parse(argv[3], handler, &configuration) < 0) {
		printf("Can't load '%s' file\n",argv[1]);
		exit(1);
	}

	ram = new int[MEMORY_SIZE/4];
	if (ram == NULL)
		exit(1);

	ReadMemInitFile(argv[4]);

	ParseCMDfile(argv[1]);

	InitCaches(&configuration);

	StartSimulator();

	printf("simulation done!\n");

	WriteMemoryDumpToFile(argv[6]);

	WriteRegisterDumpToFile(argv[5]);

	WriteExceutionTime(argv[7]);

	WriteInstructionCount(argv[8]);

	WriteHitRatioAndAMAT(argv[9]);

	
	printf("all results written to files!\n");

//	DestroyCaches();

	free(ram);

	return 0;
}
void parse_settings() {
    if(ensure_path_mounted("/sdcard") != 0) {
		load_fallback_settings();
		parse_language();
		handle_theme(currenttheme);
		return;
	}
    settings config;

    if (ini_parse(COTSETTINGS, settings_handler, &config) < 0) {
        ui_print("Can't load COT settings!\nSetting defaults...\n");
        create_default_settings();
        ini_parse(COTSETTINGS, settings_handler, &config);
    }
    LOGI("COT Settings loaded!\n");
    orsreboot = config.orsreboot;
    orswipeprompt = config.orswipeprompt;
    backupprompt = config.backupprompt;
    signature_check_enabled = config.signature_check_enabled;
	currenttheme = config.theme;
    language = config.language;
	parse_language();
    handle_theme(config.theme);
}
예제 #18
0
파일: ini.c 프로젝트: macosunity/rengine
/*
 *	Reads an INI file and returns it as a ini_file object.
 *	If filename is NULL, an empty ini_file object is created and returned.
 */
struct ini_file *ini_read(const char *filename, int *err, int *line) {
	if(line) *line = 0;
	if(!filename) {
		if(err) *err = FILE_CREATED;
		return make_ini();
	} else {	
		char *text = my_readfile(filename);
		if(!text) {
			if(err) *err = NO_SUCH_FILE;
			return NULL;
		}
		struct ini_file * ini = ini_parse(text, err, line);
		free(text);
		return ini;
	}
}
예제 #19
0
/**
 * Initializes the configuration from a filename.
 * Reads the file as an INI configuration, and sets up the
 * config object.
 * @arg filename The name of the file to read. NULL for defaults.
 * @arg config Output. The config object to initialize.
 * @return 0 on success, negative on error.
 */
int config_from_filename(char *filename, statsite_config *config) {
    // Initialize to the default values
    memcpy(config, &DEFAULT_CONFIG, sizeof(statsite_config));

    // If there is no filename, return now
    if (filename == NULL)
        return 0;

    // Try to open the file
    int res = ini_parse(filename, config_callback, config);
    if (res == -1) {
        return -ENOENT;
    }

    return 0;
}
예제 #20
0
파일: test_ini.c 프로젝트: kazuyamamoto/ini
static void test_ini_get_unknown_line_after_first_section_crlf(void)
{
	Ini *ini;
	const char *value1, *value2;

	ini = ini_parse("[section]\r\nname1=value1\r\nabc\r\nname2=value2");

	value1 = ini_get(ini, "section", "name1");
	PCU_ASSERT_PTR_NOT_NULL(value1);
	PCU_ASSERT_STRING_EQUAL("value1", value1);

	value2 = ini_get(ini, "section", "name2");
	PCU_ASSERT_PTR_NULL(value2);

	ini_delete(ini);
}
예제 #21
0
파일: test_ini.c 프로젝트: kazuyamamoto/ini
static void test_ini_get_ignore_comment_line_crlf(void)
{
	Ini *ini;
	const char *value1, *value2;

	ini = ini_parse(" ;comment1\r\n[section]\r\n\t;comment2\r\nname1=value1\r\n;comment3\r\nname2=value2\r\n;comment4");

	value1 = ini_get(ini, "section", "name1");
	PCU_ASSERT_PTR_NOT_NULL(value1);
	PCU_ASSERT_STRING_EQUAL("value1", value1);

	value2 = ini_get(ini, "section", "name2");
	PCU_ASSERT_PTR_NOT_NULL(value2);
	PCU_ASSERT_STRING_EQUAL("value2", value2);

	ini_delete(ini);
}
예제 #22
0
파일: test_ini.c 프로젝트: kazuyamamoto/ini
static void test_ini_get_ignore_empty_line(void)
{
	Ini *ini;
	const char *value1, *value2;

	ini = ini_parse("\n[section]\n\nname1=value1\n\nname2=value2");

	value1 = ini_get(ini, "section", "name1");
	PCU_ASSERT_PTR_NOT_NULL(value1);
	PCU_ASSERT_STRING_EQUAL("value1", value1);

	value2 = ini_get(ini, "section", "name2");
	PCU_ASSERT_PTR_NOT_NULL(value2);
	PCU_ASSERT_STRING_EQUAL("value2", value2);

	ini_delete(ini);
}
예제 #23
0
파일: test_ini.c 프로젝트: kazuyamamoto/ini
static void test_ini_get_ignore_spacetab_line_cr(void)
{
	Ini *ini;
	const char *value1, *value2;

	ini = ini_parse(" \t\r[section]\r \t\rname1=value1\r \t\rname2=value2 \t\r");

	value1 = ini_get(ini, "section", "name1");
	PCU_ASSERT_PTR_NOT_NULL(value1);
	PCU_ASSERT_STRING_EQUAL("value1", value1);

	value2 = ini_get(ini, "section", "name2");
	PCU_ASSERT_PTR_NOT_NULL(value2);
	PCU_ASSERT_STRING_EQUAL("value2", value2);

	ini_delete(ini);
}
예제 #24
0
static int do_ini(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
	const char *section;
	char *file_address;
	size_t file_size;

	if (argc == 1)
		return CMD_RET_USAGE;

	section = argv[1];
	file_address = (char *)simple_strtoul(
		argc < 3 ? getenv("loadaddr") : argv[2], NULL, 16);
	file_size = (size_t)simple_strtoul(
		argc < 4 ? getenv("filesize") : argv[3], NULL, 16);

	return ini_parse(file_address, file_size, ini_handler, (void *)section);
}
예제 #25
0
파일: nsmp.c 프로젝트: audiokit/AudioKit
int nano_create(nanosamp **smp, const char *ini, int sr)
{
    *smp = malloc(sizeof(nanosamp));
    nanosamp *psmp = *smp;
    strcpy(psmp->ini, ini);
    psmp->dict.last = &psmp->dict.root;
    psmp->dict.nval = 0;
    psmp->dict.init = 1;
    psmp->selected = 0;
    psmp->curpos = 0;
    psmp->sr = sr;
    if(ini_parse(psmp->ini, nano_ini_handler, psmp) < 0) {
        printf("Can't load file %s\n", psmp->ini);
        return SP_NOT_OK;
    }

    return SP_OK;
}
예제 #26
0
파일: test_ini.c 프로젝트: kazuyamamoto/ini
static void test_ini_get_two_keys_crlf(void)
{
	Ini *ini;
	const char *value1, *value2;

	ini = ini_parse("[section]\r\nname1=value1\r\nname2=value2");
	PCU_ASSERT_PTR_NOT_NULL(ini);

	value1 = ini_get(ini, "section", "name1");
	PCU_ASSERT_PTR_NOT_NULL(value1);
	PCU_ASSERT_STRING_EQUAL("value1", value1);

	value2 = ini_get(ini, "section", "name2");
	PCU_ASSERT_PTR_NOT_NULL(value2);
	PCU_ASSERT_STRING_EQUAL("value2", value2);

	ini_delete(ini);
}
예제 #27
0
int main(int argc,char **argv){

	if(argc<2){
		printf("Usage %s <options_file.ini>\n",*argv);
		exit(1);
	}

	sys_options options;

	if(ini_parse(argv[1],handler,&options)<0){
		perror("Options file not found");
		exit(1);
	}

	print_options(&options);

	return 0;
}
예제 #28
0
/*---------------------------------------------------------------------------*/
void native_config_load(config_level_t config_level)
{
  int result;

  if (config_file_name) {
    LOG6LBR_INFO("Loading configuration : %s\n",config_file_name);
    result = ini_parse(config_file_name, native_config_handler, &config_level);
    if (result < 0) {
      LOG6LBR_WARN("Can not open %s : %s\n", config_file_name, strerror(errno));
    }
    else if (result) {
      LOG6LBR_FATAL("Syntax error in %s at line %d\n", config_file_name, result);
      exit(1);
    }
  } else {
    LOG6LBR_WARN("No configuration file specified\n");
  }
}
예제 #29
0
static void select_cb(guiObject_t *obj, u16 sel, void *data)
{
    (void)obj;
    (void)data;
    const char *ico;
    mp->selected = sel + 1;
    if(! OBJ_IS_USED(&gui->image))
        return;
    if ((long)data == LOAD_ICON) {
        ico = CONFIG_GetIcon(mp->modeltype);
        if (sel > 0 && FS_OpenDir("modelico")) {
            char filename[13];
            int count = 0;
            int type;
            while((type = FS_ReadDir(filename)) != 0) {
                if (type == 1 && strncasecmp(filename + strlen(filename) - 4, ".bmp", 4) == 0) {
                    count++;
                    if (sel == count) {
                        CONFIG_ParseIconName(mp->iconstr, filename);
                        ico = mp->iconstr;
                        break;
                    }
                }
            }
            FS_CloseDir();
        }
    } else {
        sprintf(tempstring, "models/model%d.ini", mp->selected);
        mp->modeltype = 0;
        mp->iconstr[0] = 0;
        ini_parse(tempstring, ini_handle_icon, NULL);
        if (mp->selected == CONFIG_GetCurrentModel() && Model.icon[0])
            ico = Model.icon;
        else {
            if (mp->iconstr[0])
                ico = mp->iconstr;
            else
                ico = CONFIG_GetIcon(mp->modeltype);
        }
        if (! fexists(ico))
            ico = UNKNOWN_ICON;
    }
    GUI_ReplaceImage(&gui->image, ico, 0, 0);
}
예제 #30
0
파일: struct_ini.c 프로젝트: TNick/aitown
int struct_ini_get (struct_ini_t **sini, const char *p_file)
{
    // allocate memory
    struct_ini_t *tr = malloc(sizeof(struct_ini_t));
    *sini = NULL;
    if (tr == NULL)
        return INIH_ERR_MALLOC;
    struct_ini_init (tr);

    // parse the file
    int i_parse = ini_parse (p_file, struct_handler, tr);
    if (INIH_IS_OK(i_parse)) {
        *sini = tr;
    } else {
        struct_ini_end (tr);
        free (tr);
    }
    return i_parse;
}