Esempio n. 1
0
void configLoad(const char *bootpath, struct ConfigContext *ctx)
{
	char cnf_path[256];
	struct ConfigFile cnf;

	memset(ctx, 0, sizeof(*ctx));
	strcpy(cnf_path, bootpath);
	strcat(cnf_path, "psplink.ini");
	printf("Config Path %s\n", cnf_path);
	if(psplinkConfigOpen(cnf_path, &cnf))
	{
		const char *name;
		const char *val;

		while((val = psplinkConfigReadNext(&cnf, &name)))
		{
			int config;

			config = 0;
			while(config_names[config].name)
			{
				if(strcmp(config_names[config].name, name) == 0)
				{
					unsigned int iVal = 0;
					if(config_names[config].isnum)
					{
						char *endp;

						iVal = strtoul(val, &endp, 0);
						if(*endp != 0)
						{
							printf("Error, line %d value should be a number\n", cnf.line); 
							break;
						}
					}

					config_names[config].handler(ctx, val, iVal);
				}
				config++;
			}

			/* Ignore anything we don't care about */
		}

		psplinkConfigClose(&cnf);
	}

	/* Always enable at least the sio shell */
	if((ctx->usbshell == 0) && (ctx->wifishell == 0))
	{
		ctx->sioshell = 1;
	}
}
Esempio n. 2
0
void configPrint(const char *bootpath)
{
	char cnf_path[256];
	struct ConfigFile cnf;

	strcpy(cnf_path, bootpath);
	strcat(cnf_path, "psplink.ini");
	SHELL_PRINT("Config Path %s\n", cnf_path);
	if(psplinkConfigOpen(cnf_path, &cnf))
	{
		const char *name;
		const char *val;

		while((val = psplinkConfigReadNext(&cnf, &name)))
		{
			SHELL_PRINT("%s=%s\n", name, val);
		}

		psplinkConfigClose(&cnf);
	}
}
Esempio n. 3
0
void configChange(const char *bootpath, const char *newname, const char *newval, int mode)
{
	char cnf_path[256];
	char new_path[256];
	int found = 0;
	struct ConfigFile cnf;
	int fd = -1;

	if((mode != CONFIG_MODE_ADD) && (mode != CONFIG_MODE_DEL))
	{
		return;
	}

	strcpy(cnf_path, bootpath);
	strcat(cnf_path, "psplink.ini");
	SHELL_PRINT("Config Path %s\n", cnf_path);

	strcpy(new_path, bootpath);
	strcat(new_path, "psplink.ini.tmp");
	fd = sceIoOpen(new_path, PSP_O_WRONLY | PSP_O_TRUNC | PSP_O_CREAT, 0777);
	if(fd >= 0)
	{
		if(psplinkConfigOpen(cnf_path, &cnf))
		{
			const char *name;
			const char *val;

			while((val = psplinkConfigReadNext(&cnf, &name)))
			{
				if(strcmp(name, newname) == 0)
				{
					if(mode == CONFIG_MODE_ADD)
					{
						fdprintf(fd, "%s=\"%s\"\n", newname, newval);
						found = 1;
					}
				}
				else
				{
					fdprintf(fd, "%s=\"%s\"\n", name, val);
				}
			}

			if((mode == CONFIG_MODE_ADD) && (!found))
			{
				fdprintf(fd, "%s=\"%s\"\n", newname, newval);
			}

			sceIoClose(fd);
			fd = -1;
			psplinkConfigClose(&cnf);

			if(sceIoRemove(cnf_path) < 0)
			{
				SHELL_PRINT("Error deleting original configuration\n");
			}
			else
			{
				if(sceIoRename(new_path, cnf_path) < 0)
				{
					SHELL_PRINT("Error renaming configuration\n");
				}
			}
		}
		else
		{
			SHELL_PRINT("Couldn't open temporary config file %s\n", new_path);
		}

		if(fd >= 0)
		{
			sceIoClose(fd);
			sceIoRemove(new_path);
		}
	}
}