Esempio n. 1
0
void reset(void)
{
    view_status("booting rom");
    flushdisplay();

    view_status("loading ultra.ini");
    inifile_read(cart.title);

    boot_boot();

    // have to load a second time... boot_boot overwrites some stuff
    // should be fixed
    view_status("loading ultra.ini");
    inifile_read(cart.title);

    view.hidestuff=0; view_changed(VIEW_RESIZE); flushdisplay();

    sym_findfirstos();
    if(cart.isdocalls)
    {
        print("Creating OSCALLS list.\n");
        sym_demooscalls(); // generate oscalls
    }
    else
    {
        sym_addpatches();
    }

    inifile_patches(0);
}
Esempio n. 2
0
/* {{{ inifile_find_group
 * if found pos_grp_start points to "[group_name]"
 */
static int inifile_find_group(inifile *dba, const key_type *key, size_t *pos_grp_start)
{
	int ret = FAILURE;

	php_stream_flush(dba->fp);
	php_stream_seek(dba->fp, 0, SEEK_SET);
	inifile_line_free(&dba->curr);
	inifile_line_free(&dba->next);

	if (key->group && strlen(key->group)) {
		int res;
		line_type ln = {{NULL,NULL},{NULL}};

		res = 1;
		while(inifile_read(dba, &ln)) {
			if ((res=inifile_key_cmp(&ln.key, key)) < 2) {
				ret = SUCCESS;
				break;
			}
			*pos_grp_start = php_stream_tell(dba->fp);
		}
		inifile_line_free(&ln);
	} else {
		*pos_grp_start = 0;
		ret = SUCCESS;
	}
	if (ret == FAILURE) {
		*pos_grp_start = php_stream_tell(dba->fp);
	}
	return ret;
}
Esempio n. 3
0
/* Read parameters from the registry
 */
static int ReadInitData(void)
{
	int ok = JK_TRUE;
	const char *v;

#ifdef USE_INIFILE
// Using an INIFILE

#define GETV(key) inifile_lookup(key)

	ERRTYPE e;

	if (e = inifile_read(&cfgPool, ININAME), ERRNONE != e)
	{
		AddInLogMessageText("Error reading: %s, %s", NOERROR, ININAME, ERRTXT(e));
		return JK_FALSE;
	}

#else
// Using the registry
#define GETV(key) GetRegString(hkey, key)

	HKEY hkey;
	long rc;

	rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE, REGISTRY_LOCATION, (DWORD) 0, KEY_READ, &hkey);
	if (ERROR_SUCCESS != rc) return JK_FALSE;

#endif

#define GETVNB(tag, var) \
	var = GETV(tag); \
	if (NULL == var) \
	{ \
		AddInLogMessageText("%s not defined in %s", NOERROR, tag, ININAME); \
		ok = JK_FALSE; \
	}

	GETVNB(JK_LOG_FILE_TAG, logFile)
	GETVNB(JK_LOG_LEVEL_TAG, v);
	GETVNB(JK_WORKER_FILE_TAG, workerFile);
	GETVNB(JK_MOUNT_FILE_TAG, workerMountFile);

	logLevel = (NULL == v) ? 0 : jk_parse_log_level(v);

	tomcatStart	= GETV(TOMCAT_START);
	tomcatStop	= GETV(TOMCAT_STOP);

#ifndef USE_INIFILE
	RegCloseKey(hkey);
#endif

	return ok;
}
Esempio n. 4
0
/* {{{ inifile_nextkey
 */
int inifile_nextkey(inifile *dba) {
	line_type ln = {{NULL,NULL},{NULL}};

	/*inifile_line_free(&dba->next); ??? */
	php_stream_seek(dba->fp, dba->curr.pos, SEEK_SET);
	ln.key.group = estrdup(dba->curr.key.group ? dba->curr.key.group : "");
	inifile_read(dba, &ln);
	inifile_line_free(&dba->curr);
	dba->curr = ln;
	return ln.key.group || ln.key.name;
}
Esempio n. 5
0
/* {{{ inifile_next_group
 * only valid after a call to inifile_find_group
 * if any next group is found pos_grp_start points to "[group_name]" or whitespace before that
 */
static int inifile_next_group(inifile *dba, const key_type *key, size_t *pos_grp_start)
{
	int ret = FAILURE;
	line_type ln = {{NULL,NULL},{NULL}};

	*pos_grp_start = php_stream_tell(dba->fp);
	ln.key.group = estrdup(key->group);
	while(inifile_read(dba, &ln)) {
		if (inifile_key_cmp(&ln.key, key) == 2) {
			ret = SUCCESS;
			break;
		}
		*pos_grp_start = php_stream_tell(dba->fp);
	}
	inifile_line_free(&ln);
	return ret;
}
Esempio n. 6
0
/* {{{ inifile_filter
 * copy from to dba while ignoring key name (group must equal)
 */
static int inifile_filter(inifile *dba, inifile *from, const key_type *key, zend_bool *found)
{
	size_t pos_start = 0, pos_next = 0, pos_curr;
	int ret = SUCCESS;
	line_type ln = {{NULL,NULL},{NULL}};

	php_stream_seek(from->fp, 0, SEEK_SET);
	php_stream_seek(dba->fp, 0, SEEK_END);
	while(inifile_read(from, &ln)) {
		switch(inifile_key_cmp(&ln.key, key)) {
		case 0:
			if (found) {
				*found = (zend_bool) 1;
			}
			pos_curr = php_stream_tell(from->fp);
			if (pos_start != pos_next) {
				php_stream_seek(from->fp, pos_start, SEEK_SET);
				if (SUCCESS != php_stream_copy_to_stream_ex(from->fp, dba->fp, pos_next - pos_start, NULL)) {
					php_error_docref(NULL, E_WARNING, "Could not copy [%zu - %zu] from temporary stream", pos_next, pos_start);
					ret = FAILURE;
				}
				php_stream_seek(from->fp, pos_curr, SEEK_SET);
			}
			pos_next = pos_start = pos_curr;
			break;
		case 1:
			pos_next = php_stream_tell(from->fp);
			break;
		case 2:
			/* the function is meant to process only entries from same group */
			assert(0);
			break;
		}
	}
	if (pos_start != pos_next) {
		php_stream_seek(from->fp, pos_start, SEEK_SET);
		if (SUCCESS != php_stream_copy_to_stream_ex(from->fp, dba->fp, pos_next - pos_start, NULL)) {
			php_error_docref(NULL, E_WARNING, "Could not copy [%zu - %zu] from temporary stream", pos_next, pos_start);
			ret = FAILURE;
		}
	}
	inifile_line_free(&ln);
	return ret;
}
Esempio n. 7
0
/* {{{ inifile_fetch
 */
val_type inifile_fetch(inifile *dba, const key_type *key, int skip) {
	line_type ln = {{NULL,NULL},{NULL}};
	val_type val;
	int res, grp_eq = 0;

	if (skip == -1 && dba->next.key.group && dba->next.key.name && !inifile_key_cmp(&dba->next.key, key)) {
		/* we got position already from last fetch */
		php_stream_seek(dba->fp, dba->next.pos, SEEK_SET);
		ln.key.group = estrdup(dba->next.key.group);
	} else {
		/* specific instance or not same key -> restart search */
		/* the slow way: restart and seacrch */
		php_stream_rewind(dba->fp);
		inifile_line_free(&dba->next);
	}
	if (skip == -1) {
		skip = 0;
	}
	while(inifile_read(dba, &ln)) {
		if (!(res=inifile_key_cmp(&ln.key, key))) {
			if (!skip) {
				val.value = estrdup(ln.val.value ? ln.val.value : "");
				/* allow faster access by updating key read into next */
				inifile_line_free(&dba->next);
				dba->next = ln;
				dba->next.pos = php_stream_tell(dba->fp);
				return val;
			}
			skip--;
		} else if (res == 1) {
			grp_eq = 1;
		} else if (grp_eq) {
			/* we are leaving group now: that means we cannot find the key */
			break;
		}
	}
	inifile_line_free(&ln);
	dba->next.pos = php_stream_tell(dba->fp);
	return ln.val;
}
Esempio n. 8
0
static bool_t playlist_load_pls (const char * filename, VFSFile * file,
                                 char * * title, Index * filenames, Index * tuples)
{
    INIFile * inifile = inifile_read (file);
    if (! inifile)
        return FALSE;

    * title = NULL;

    const char * val = inifile_lookup (inifile, "playlist", "numberofentries");
    if (! val)
    {
        inifile_destroy (inifile);
        return FALSE;
    }

    int count = atoi (val);

    for (int i = 1; i <= count; i ++)
    {
        SPRINTF (key, "file%d", i);

        if (! (val = inifile_lookup (inifile, "playlist", key)))
            continue;

        char * uri = aud_construct_uri (val, filename);
        if (! uri)
            continue;

        index_append (filenames, str_get (uri));
        free (uri);
    }

    inifile_destroy (inifile);
    return TRUE;
}
Esempio n. 9
0
bool settings_init(int argc, char** argv)
{
	char* ininame;
	uint len;
	
	atexit(settings_uninit);
	
	if (!(ininame = platform_locdup(false, configfile)))
	{
		FILE* fp;
		
		len = strlen(config_local_dir);
		ininame = malloc(len + configfile_len + 2);
		memcpy(ininame, config_local_dir, len);
		memcpy(ininame + len, pathsep_str configfile, 2 + configfile_len);
		if (!platform_mkpdir(ininame))
		{
			trace("Error: Couldn't create config directory.");
			free(ininame);
			return false;
		}
		trace("Creating new blank config file.");
		if (!(fp = fopen(ininame, "w")))
		{
			trace("Error: Couldn't create config file.");
			free(ininame);
			return false;
		}
		fputs("[Data]\n", fp);
		fclose(fp);
	}
	
	if (!inifile_read(ininame, settings_callback))
		trace("Error reading config file, check your syntax :)");
	{
		int i;
		char* section;
		char* option;
		bool falseoption;
		for (i = 1; i < argc; i ++)
		{
			if (argv[i][0] == '-')
			{
				section = argv[i] + 1;
				if ((option = strchr(argv[i], '.')))
				{
					*option = '\0';
					falseoption = (option[1] == 'n' || option[1] == 'N') && (option[2] = 'o' || option[2] == 'O');
					if (i < (argc - 1) && argv[i + 1][0] != '-')
						settings_callback(section, true, option + 1, argv[++i]);
					else
						settings_callback(section, true, option + (falseoption ? 3 : 1), (falseoption ? "false" : "true"));
					*option = '.';
				}
				else
				{
					falseoption = (section[0] == 'n' || section[0] == 'N') && (section[1] = 'o' || section[1] == 'O');
					ini_section = s_options;
					if (i < (argc - 1) && argv[i + 1][0] != '-')
						settings_callback(NULL, false, section, argv[++i]);
					else
						settings_callback(NULL, false, section + (falseoption ? 2 : 0), (falseoption ? "false" : "true"));
				}
			}
			else
			{
				tracef("Parse error \"%s\"", argv[i]);
				break;
			}
		}
	}
	free(ininame);
	return true;
}