示例#1
0
static int serial_json_cfg(serial_cfg_t* cfg, const char* js, size_t js_len, jsmntok_t* tk)
{
	char str[32];
	u32_t u32_tmp;

	if(STATE_OK != jsmn.key2val_uint(js, tk, "baud", &cfg->baudrate)){
		LOG_WARN("Default baudrate.\r\n");
		cfg->baudrate = 115200;	//default
	}

	if(STATE_OK != jsmn.key2val_str(js, tk, "bits", str,  sizeof(str), (size_t*)&u32_tmp)){
		LOG_WARN("Default bits.\r\n");
		cfg->bits = 0;
	}
	else{
		if(str[0] == '9')cfg->bits = 1; else cfg->bits = 0;
	}

	if(STATE_OK != jsmn.key2val_str(js, tk, "sbits", str,  sizeof(str), (size_t*)&u32_tmp)){
		LOG_WARN("Default sbits.\r\n");
		cfg->sbits = 1;
	}
	else{
		 //"0.5bit" "1bit" "1.5bit" "2bit"
		if(0 == _strncmp(str, "0.5bit", u32_tmp))
			cfg->sbits = 0;
		else if(0 == _strncmp(str, "1.5bit", u32_tmp))
			cfg->sbits = 2;
		else if(0 == _strncmp(str, "2bit", u32_tmp))
			cfg->sbits = 3;
		else 	cfg->sbits = 1;
	}

	if(STATE_OK != jsmn.key2val_str(js, tk, "parity", str,  sizeof(str), (size_t*)&u32_tmp)){
		LOG_WARN("Default parity.\r\n");
		cfg->Parity = 0;
	}
	else{
		 //"none" "even" "odd"
		if(0 == _strncmp(str, "odd", u32_tmp))
			cfg->Parity = 1;
		else if(0 == _strncmp(str, "even", u32_tmp))
			cfg->Parity = 2;
		else 	cfg->Parity = 0;
	}

	if(STATE_OK != jsmn.key2val_bool(js, tk, "rs485", (u8_t*)&u32_tmp)){
		LOG_WARN("Default rs485.\r\n");
		cfg->option = 0;
	}
	else{
		if(TRUE == u32_tmp)cfg->option = 1; else cfg->option = 0;
	}

	return STATE_OK;
}
示例#2
0
文件: wrappers.c 项目: emlyn/chdk
char *_strstr (const char *s1, const char *s2)
{
  const char *p = s1;
  const int len = _strlen (s2);

  for (; (p = _strchr (p, *s2)) != 0; p++)
    {
      if (_strncmp (p, s2, len) == 0)
	return (char *)p;
    }
  return (0);
}
示例#3
0
文件: vfs.c 项目: dakk/Misc
mountpoint_t *vfs_get_mountpoint(char *path)
{
	mountpoint_t *tmp = mountlist;
	mountpoint_t *l = mountlist;

	while(l != NULL)
	{
		if(	(_strncmp(l->path, path, _strlen(path)) == 0) &&
			(_strlen(tmp->path) < _strlen(l->path)))
				tmp = l;
		l = l->next;
	}

	return tmp;
}
示例#4
0
int main(int argc, char **argv){
	char ElfPath[32];

	DINIT();
	DPRINTF("OPL EE core start!\n");

	SifInitRpc(0);

	int i = 0;

	if (!_strncmp(argv[i], "USB_MODE", 8))
		GameMode = USB_MODE;
	else if (!_strncmp(argv[i], "ETH_MODE", 8))
		GameMode = ETH_MODE;
	else if (!_strncmp(argv[i], "HDD_MODE", 8))
		GameMode = HDD_MODE;
	DPRINTF("Game Mode = %d\n", GameMode);

	DisableDebug = 0;
	if (!_strncmp(&argv[i][9], "1", 1)) {
		DisableDebug = 1;
		DPRINTF("Debug Colors disabled\n");
	}

	PS2Logo = 0;
	if (!_strncmp(&argv[i][11], "1", 1)) {
		PS2Logo = 1;
		DPRINTF("PS2 Logo enabled\n");
	}

	char *p = _strtok(&argv[i][13], " ");
	if (!_strncmp(p, "Browser", 7))
		ExitPath[0] = '\0';
	else
		_strcpy(ExitPath, p);
	DPRINTF("Exit Path = (%s)\n", ExitPath);

	p = _strtok(NULL, " ");
	HDDSpindown = _strtoui(p);
	DPRINTF("HDD Spindown = %d\n", HDDSpindown);

	p = _strtok(NULL, " ");
	_strcpy(g_ps2_ip, p);
	p = _strtok(NULL, " ");
	_strcpy(g_ps2_netmask, p);
	p = _strtok(NULL, " ");
	_strcpy(g_ps2_gateway, p);
	g_ps2_ETHOpMode=_strtoui(_strtok(NULL, " "));
	DPRINTF("IP=%s NM=%s GW=%s mode: %d\n", g_ps2_ip, g_ps2_netmask, g_ps2_gateway, g_ps2_ETHOpMode);

#ifdef CHEAT
	EnableCheatOp = (gCheatList = (void*)_strtoui(_strtok(NULL, " "))) != NULL;
	DPRINTF("PS2RD Cheat Engine = %s\n", EnableCheatOp==0?"Disabled":"Enabled");
#endif

#ifdef GSM
	EnableGSMOp = _strtoi(_strtok(NULL, " "));
	DPRINTF("GSM = %s\n", EnableGSMOp==0?"Disabled":"Enabled");
#endif

	i++;

	ModStorageStart = (void*)_strtoui(_strtok(argv[i], " "));
	ModStorageEnd = (void*)_strtoui(_strtok(NULL, " "));
	i++;

	argv[i][11]=0x00; // fix for 8+3 filename.
	_strcpy(ElfPath, "cdrom0:\\");
	_strcat(ElfPath, argv[i]);
	_strcat(ElfPath, ";1");
	strncpy(GameID, argv[i], sizeof(GameID) - 1);
	GameID[sizeof(GameID) - 1] = '\0';
	DPRINTF("Elf path = '%s'\n", ElfPath);
	DPRINTF("Game ID = '%s'\n", GameID);

	i++;

	// bitmask of the compat. settings
	g_compat_mask = _strtoui(argv[i]);
	DPRINTF("Compat Mask = 0x%02x\n", g_compat_mask);

	i++;

#ifdef CHEAT
	if(EnableCheatOp){
		EnableCheats();
	}
#endif

#ifdef GSM
	if(EnableGSMOp){
		u32 interlace, mode, ffmd, dx_offset, dy_offset, skip_videos_fix;
		u64 display, syncv, smode2;

		interlace=_strtoui(_strtok(argv[i], " "));
		mode=_strtoui(_strtok(NULL, " "));
		ffmd=_strtoui(_strtok(NULL, " "));
		display=_strtoul(_strtok(NULL, " "));
		syncv=_strtoul(_strtok(NULL, " "));
		smode2=_strtoui(_strtok(NULL, " "));
		dx_offset=_strtoui(_strtok(NULL, " "));
		dy_offset=_strtoui(_strtok(NULL, " "));
		skip_videos_fix=_strtoui(_strtok(NULL, " "));

		UpdateGSMParams(interlace, mode, ffmd, display, syncv, smode2, dx_offset, dy_offset, skip_videos_fix);
		EnableGSM();
	}
#endif

	set_ipconfig();

	/* installing kernel hooks */
	DPRINTF("Installing Kernel Hooks...\n");
	Install_Kernel_Hooks();

	if(!DisableDebug)
		GS_BGCOLOUR = 0xff0000;	//Blue

	SifExitRpc();

	DPRINTF("Executing '%s'...\n", ElfPath);

	//PS2LOGO Caller, based on l_oliveira & SP193 tips
	if (PS2Logo) {
		char *argvs[1];
		argvs[0] = ElfPath;
		argvs[1] = NULL;
		LoadExecPS2("rom0:PS2LOGO", 1, argvs);
	} else {
		LoadExecPS2(ElfPath, 0, NULL);
	}

	if(!DisableDebug)
		GS_BGCOLOUR = 0x0000ff;	//Red
	DPRINTF("LoadExecPS2 failed!\n");

	SleepThread();

	return 0;
}
示例#5
0
文件: wrappers.c 项目: emlyn/chdk
int strncmp(const char *s1, const char *s2, long n) {
    return _strncmp(s1, s2, n);
}