コード例 #1
0
    // バイトコードがメモリにロードされた直後のコールバック。
    // 対応するDLLがあればロードする
    static void cb4dll(const char* hybPath)
    {
        int len = HMD_STRLEN(hybPath);
        char* dllPath = (char*)HMD_ALLOCA(len + sizeof(dll_prefix)+sizeof(dll_ext));
        char* q = dllPath;
        char* q2 = q;

        const unsigned char* p = _mbsrchr((const unsigned char*)hybPath, PATH_DELIM);
        if (p == NULL) {
            p = (const unsigned char*)hybPath;
        } else {
            p += 1;
            size_t lp = p - (const unsigned char*)hybPath;
            memcpy(q, hybPath, lp);
            q += lp;
            q2 = q;
        }
        // pはhybPathのファイル名部分の先頭アドレス
        const unsigned char* p2 = _mbsstr((const unsigned char*)p, (const unsigned char*)".hyb");
        if ((p2 <= p) || (p2 >= (const unsigned char*)hybPath + len)) {
            p2 = (const unsigned char*)hybPath + len;
        }
        // p2は拡張子を抜いたファイル名部分の末尾アドレス

        memcpy(q, dll_prefix, sizeof(dll_prefix));
        q += sizeof(dll_prefix) - 1;
        size_t lp2 = p2 - p;
        memcpy(q, p, lp2);
        q += lp2;
        memcpy(q, dll_ext, sizeof(dll_ext));
        q += sizeof(dll_ext) - 1;
        *q = '\0';

#ifdef VERBOSE_LOAD_DLL
        HMD_PRINTF("try load dll: %s\n", dllPath);
#endif
		HMODULE hmod = LoadLibraryMB(dllPath);    // dllロード
#ifdef VERBOSE_LOAD_DLL
        if (hmod == NULL) printLastError();
#endif        
        if (hmod == NULL && q2 != dllPath) {
            // パス抜きのファイル名だけでロードしてみる
#ifdef VERBOSE_LOAD_DLL
            HMD_PRINTF("try load dll: %s\n", q2);
#endif        
            hmod = LoadLibraryMB(q2);
#ifdef VERBOSE_LOAD_DLL
            if (hmod == NULL) printLastError();
#endif        
        }

        if (hmod != NULL) {
            dllHandleArr.add(hmod);
#ifdef VERBOSE_LOAD_DLL
            HMD_PRINTF("DLL '%s' loaded.\n", q2);
#endif
        }
    }
コード例 #2
0
// ---------------------------------------------------------------------
SInt32 WinMBCString::Find(const WinMBCString& other, SInt32 startIndex /* = 0 */) const
{
	const unsigned char* target = reinterpret_cast<const unsigned char*>(innerString.c_str() + startIndex);
	const unsigned char* found = _mbsstr(target, reinterpret_cast<const unsigned char*>(other.innerString.c_str()));
	if (NULL == found)
	{
		return -1;
	}
	else
	{
		return found - target + startIndex;
	}
}
コード例 #3
0
ファイル: bookmark.c プロジェクト: umorigu/ffftp-mirror
static int GetBothPath(char *Str, char **Path1, char **Path2)
{
	char *Pos;
	int Ret;

	Ret = 1;
	*Path1 = Str + BMARK_MARK_LEN;

	Pos = _mbsstr(Str, BMARK_SEP);
	if(Pos != NULL)
	{
		Ret = 2;
		*Pos = NUL;
		*Path2 = Pos + BMARK_SEP_LEN;
	}
	return(Ret);
}
コード例 #4
0
char io() {
	char str[9];
	char st[10];
	char get[500];
	char* end;
	int hant, i = 0, l = 0;
	char* p;
	char key = NULL;
	FILE * save;

	while (1) {
		puts("名前を8文字以内で入力してください");
		*str = '\0';
		fgets(str, sizeof(8), stdin);
		p = strchr(str, '\n');
		if (p != NULL) { *p = '\0'; }

		while (str[i] != '\0') {
			l = _ismbblead(str[i]);
			i++;
			if (l != 0)break;
		}

		if (l != 0) {
			puts("全角文字が含まれています。半角で入力してください");
			continue;
		}

		sprintf(st, "%s:", str);
		if ((save = fopen("save.txt", "r")) == NULL) {
			save = fopen("save.txt", "w");
			fprintf(save, "%s:", str);
			break;
		}
		else {
			save = fopen("save.txt", "a+");
			end = fgets(get, sizeof(get), save);
			while (end != NULL) {
				end = fgets(get, sizeof(get), save);
				if (_mbsstr(get, st) == NULL) {
					hant = 0;
				}
				else {
					hant = 1;
					break;
				}
			}
			if (hant == 0) {
				fprintf(save, "\n%s:", str);
				break;
			}
			else {
				puts("同じ名前の人がいます。もう一度入力してください\n");
			}
		}
	}
	fclose(save);

	printf("名前は%sです。Enterを押してね!\n", str);

	scanf("%c", &key);
	if (key != NULL) {
		system("cls");
		key = NULL;
	}
	return 0;
}
コード例 #5
0
ファイル: CKey.cpp プロジェクト: Cartman0/Winny-p2p
bool CKey::mf_CKey_0040(const char * arg_0,const char * arg_1,bool arg_2)
{
	int local_00;
	int local_01;
	int local_02;
	int local_03;
	bool local_04;
	unsigned char local_05[16];
	char local_06[120];

	if (! (arg_2||!m_bln_unk304) ) {
		return m_bln_unk303;
	}
	if (!arg_2) {
		m_bln_unk304=true;
	}

	local_00=strlen(arg_0);
	if (local_00==0) {
		if (!arg_2) {
			m_bln_unk303=true;
		}
		return true;
	}
	if (! (m_bln_unk308||local_00>=2) ) {
		return false;
	}
	m_bln_unk303=false;
	if (! ((int)*arg_0!='%'||local_00!=33) ) {
		ny_aschash2binhash(arg_0+1,local_05);
		if (memcmp((unsigned char *)m_hash_tabun,local_05,16)==0) {
			m_bln_unk303=true;
			return true;
		}
		return false;
	}

	if (*arg_1!=0) {
		if ((int)*arg_1=='#') {
			ny_htmlproc_5(arg_1+1,gbuf400_004);
			if (strcmp(m_char11_nazo2,gbuf400_004)!=0) {
				return false;
			}
			bool dummy;	//orphan jumpの再現用。これをしなくても、制御構造を変えれば出ると思われ
		} else {
			if (strcmp(m_char11_nazo2,arg_1)!=0) {
				return false;
			}
		}
	}

	strcpy(gbuf400_002,mf_CKey_0260());
	if ((unsigned char)gbuf400_002[0]=='@') {
		return false;
	}
	strcpy(gbuf400_003,arg_0);
	local_02=0;
	local_03=0;
	_mbslwr(gbuf400_002);
	_mbslwr(gbuf400_003);
	for (local_01=0; local_01<30; local_01++) {
		gbuf7800_200[local_01*1024]=0;
		*((int *)(local_06+local_01*4))=0;
	}
	local_04=false;
	for (local_01=0; local_01<local_00; local_01++) {
		if (! ((*(gbuf400_003+local_01)==0||(unsigned char)*(gbuf400_003+local_01)==' ')||!((unsigned char)*(gbuf400_003+local_01)!=129)&&(unsigned char)*((gbuf400_003+1)+local_01)=='@') ) {
			*((gbuf7800_200+local_02*1024)+local_03)=*(gbuf400_003+local_01);
			local_03=local_03+1;
			continue;
		}
		if (local_03<2) {
			local_03=0;
		}
		*((int *)(local_06+local_02*4))=local_03;
		*((gbuf7800_200+local_02*1024)+local_03)=0;
		if (local_03>=2) {
			if (*(gbuf7800_200+local_02*1024)!='-') {
				local_04=true;
			}
			if (local_02>=29) break;
			local_02=local_02+1;
		}
		local_03=0;
		if (*(gbuf400_003+local_01)==' ') continue;
		local_01=local_01+1;
	}
	if (! (!(!(local_02!=0)&&(local_03<2||(unsigned char)*(((struct_charptrd *)gbuf7800_200)->d1)=='-'))&&(local_02<=0||local_04)) ) {
		return false;
	}
	if (local_03<2) {
		local_03=0;
	}
	*((int *)(local_06+local_02*4))=local_03;
	*((gbuf7800_200+local_02*1024)+local_03)=0;
	for (local_03=0; local_03<=local_02; local_03++) {
		if (*(gbuf7800_200+local_03*1024)==0||!(gbuf7800_200[local_03*1024]!='-')&&*(gbuf7800_200+local_03*1024+1)==0) continue;
		if (gbuf7800_200[local_03*1024]=='-') {
			if (_mbsstr(gbuf400_002,&gbuf7800_200[local_03*1024+1])==0) continue;
			return false;
		}
		if (_mbsstr(gbuf400_002,&gbuf7800_200[local_03*1024])!=0) continue;
		return false;
	}
	if (!arg_2) {
		m_bln_unk303=true;
	}
	return true;

}