Example #1
0
// Generate the MAC address
void NsGenMacAddress(void *dest, char *mac_address_seed, char *device_name)
{
	char tmp[MAX_SIZE];
	UCHAR mac[6];
	UCHAR hash[SHA1_SIZE];

	Zero(tmp, sizeof(tmp));

	StrCat(tmp, sizeof(tmp), mac_address_seed);
	StrCat(tmp, sizeof(tmp), "@");
	StrCat(tmp, sizeof(tmp), device_name);

	Trim(tmp);

	StrLower(tmp);

	HashSha1(hash, tmp, StrLen(tmp));

	mac[0] = NS_MAC_ADDRESS_BYTE_1;
	mac[1] = hash[1];
	mac[2] = hash[2];
	mac[3] = hash[3];
	mac[4] = hash[4];
	mac[5] = hash[5];

	NsGenMacAddressSignatureForMachine(mac + 4, mac);

	Copy(dest, mac, 6);
}
Example #2
0
int CmdProcessing(void)
{
	_fputts(_T("Best command prompt>> "), stdout);
	_getts(cmdString);

	TCHAR * token = _tcstok(cmdString, seps);

	int tokenNum = 0;
	while (token != NULL)
	{
		_tcscpy(
			cmdTokenList[tokenNum++], StrLower(token)
			);
		token = _tcstok(NULL, seps);
	}

	if (!_tcscmp(cmdTokenList[0], _T("exit")))
	{
		return TRUE;
	}
	else if (!_tcscmp(cmdTokenList[0], _T("추가 되는 명령어 1")))
	{
	}
	else if (!_tcscmp(cmdTokenList[0], _T("추가 되는 명령어 2")))
	{
	}
	else
	{
		_tprintf(ERROR_CMD, cmdTokenList[0]);
	}

	return 0;
}
Example #3
0
bool Tokenize()
{
	TCHAR cDIR[MAX_STR_LEN];
	GetCurrentDirectory(MAX_STR_LEN, cDIR);

	_tprintf(_T("%s>>"), cDIR);
	_getts_s(cmdString);
	_tcscpy_s(cmdHistory[historyNum++], cmdString);

	int nowNum = historyNum - 1;
	while (cmdString[0] == '!')
	{
		if (cmdString[1] == '!')
		{
			if (_tcslen(cmdString) == 2 && nowNum >= 1)
			{
				_tcscpy(cmdString, cmdHistory[nowNum - 1]);
				nowNum = nowNum - 1;
			}
			else
			{
				_tprintf(_T("이전 명령어가 존재하지 않습니다.\n"));
				return false;
			}
		}
		else
		{
			int num = SearchToken();
			if (num != -1)
			{
				_tcscpy(cmdString, cmdHistory[num]);
				nowNum = num;
			}
			else
			{
				_tprintf(_T("이전 명령어가 존재하지 않습니다.\n"));
				return false;
			}
		}
	}
	_tcscpy_s(cmdCopy, cmdString);
	



	TCHAR * token = _tcstok(cmdString, seps);


	while (token != NULL){
		_tcscpy(
			cmdTokenList[tokenNum++], StrLower(token)
			);
		token = _tcstok(NULL, seps);
	}

	return true;
}
Example #4
0
void	Blitters_Init()
{
    ConsolePrint(Msg_Get(MSG_Blitters_Loading));

    Blitters.list = NULL;
    Blitters.current = NULL;

    // Open and read file
    t_tfile * tf;
    if ((tf = tfile_read (Blitters.filename)) == NULL)
        Quit_Msg("%s", meka_strerror());
    ConsolePrint("\n");

    // Parse each line
    int line_cnt = 0;
    for (t_list* lines = tf->data_lines; lines; lines = lines->next)
    {
        const char* line = (char*)lines->elem;
        line_cnt += 1;

		int i, j;
        char s1 [256], s2 [256];
        for (i = 0, j = 0; line [i] != 0 && line [i] != ';'; i ++)
            if ((line [0] == '[') || (line [i] != ' ' && line [i] != '\t'))
                s2 [j ++] = line [i];
        s2 [j] = 0;
        if (StrIsNull (s2))
            continue;

        strcpy(s1, s2);
        StrLower(s1);

        switch (Blitters_Parse_Line (s1, s2))
        {
        case MEKA_ERR_UNKNOWN:          tfile_free(tf); Quit_Msg(Msg_Get(MSG_Blitters_Error_Unrecognized), line_cnt);
        case MEKA_ERR_MISSING:          tfile_free(tf); Quit_Msg(Msg_Get(MSG_Blitters_Error_Missing), line_cnt);
        case MEKA_ERR_VALUE_INCORRECT:  tfile_free(tf); Quit_Msg(Msg_Get(MSG_Blitters_Error_Incorrect_Value), line_cnt);
        }
    }

    // Free file data
    tfile_free(tf);

    // Requires at least 1 blitter
    if (Blitters.count == 0)
        Quit_Msg("%s", Msg_Get(MSG_Blitters_Error_Not_Enough));

    // Current blitter
    if (Blitters.blitter_configuration_name != NULL)
        Blitters.current = Blitters_FindBlitterByName(Blitters.blitter_configuration_name);
    if (Blitters.current == NULL)
        Blitters.current = (t_blitter*)Blitters.list->elem; // first
}
Example #5
0
File: Database.cpp Project: wkcn/HR
string Database::GetSourceName(string s){
	//得到原名并转为小写
	if (alias.count(StrLower(s)))return alias[s];
	return StrLower(s);
}
Example #6
0
File: Database.cpp Project: wkcn/HR
Exp* Database::Build(const string filter){

	vector<string> vs;
	string buf;
	//分词

	static const int symsSize = 18;
	static string syms[symsSize] = {"(",")",">","<",">=","<=","==","=","!=","<>","+","-","*","/","+=","-=","*=","/="};
	static string checkstr = "()><=!+-*/";
	bool quote = false;

	for(size_t i = 0;i < filter.size(); ++i){
		if (filter[i] == ' '){
			if(!(buf.empty()))vs.push_back(buf);
			buf.clear();
		}else if (filter[i] == '\'' || filter[i] == '\"'){
			quote = true;
			char q = filter[i];
			if(!(buf.empty()))vs.push_back(buf);
			buf.clear();
			buf += q;
			++i;
			for(;i < filter.size(); ++i){
				if (filter[i] == q){
					buf += q;
					quote = false;
					break;
				}else{
					buf += filter[i];
				}
			}
			vs.push_back(buf);
			buf.clear();
		}else if (checkstr.find(filter[i]) != string::npos){
			if(!(buf.empty()))vs.push_back(buf);
			buf.clear();
			buf = filter[i];
			if (i+1 < filter.size()){
				string temp(buf);
				temp += filter[i + 1]; 
				bool ex = false;
				for (auto &s : syms){
					if (s == temp){
						ex = true;
						++i;
						break;
					}
				}
				if (ex)buf = temp;
			}
			vs.push_back(buf);
			buf.clear();	
		}else{
			buf += filter[i];
		}
	}

	if(quote)throw "引号不匹配";

	if(!buf.empty())vs.push_back(buf);

	stack<string> op;
	vector<string> bac;
	vector<bool> kinds;//0为一般表达式,1为逻辑符号
	for(size_t i = 0;i < vs.size(); ++i){
		//cout << vs[i] << endl;
		if (vs[i] == ")"){
			bool can = false;
			while (!op.empty()){
				string q = op.top();
				op.pop();
				if (q == "("){
					can = true;
					break;
				}else{
					bac.push_back(q);
					kinds.push_back(1);
				}
			}
			if (!can){
				throw "括号不匹配";
			}
		}else{
			if (checkstr.find(vs[i][0]) != string::npos || vs[i][0] == '(' || vs[i] == "and" || vs[i] == "or"){
				while (!op.empty() && ISP(op.top()) >= ICP(vs[i])){
					string q = op.top();
					op.pop();
					bac.push_back(q);
					//cout <<q<<endl;
					kinds.push_back(1);
				}
				op.push(vs[i]);
			}else{
				bac.push_back(vs[i]);
				kinds.push_back(0);
			}
		}
	}
	while (!op.empty()){
		string q = op.top();
		op.pop();
		bac.push_back(q);
		kinds.push_back(1);
	}
/*
	for(auto v:bac){
		cout << v <<endl;
	}
*/
	stack<Exp*> es;
	for (size_t i = 0; i < bac.size();++i){
		if (kinds[i]){
			//符号(这里都是二元操作符)
			Exp *t = new Exp();
			if(es.empty())throw "缺少右操作数";
			t -> rv = es.top();es.pop();
			if(es.empty())throw "缺少左操作数";
			t -> lv = es.top();es.pop();
			t -> name = bac[i];
			t -> kind = EXP_OP;
			es.push(t);
		}else{
			Exp *t = new Exp();
			if (bac[i][0] == '-' || (bac[i][0] >= '0' && bac[i][0] <= '9')){
				t -> kind = EXP_NUM;
				t -> name = bac[i];
			}else{
				if (bac[i][0] == '\'' || bac[i][0] == '\"'){
					t -> kind = EXP_STR;
					t -> name = bac[i].substr(1,bac[i].size()-2);
				}else{
					t -> kind = EXP_VAR;
					t -> name = StrLower(bac[i]);
				}
			}
			es.push(t);
		}
	}
	Exp *root = es.top();es.pop();
	if (es.empty())return root;
	throw "您输入的表达式有误,不能完全解析";
	return 0;
}
int LeArquivo(char * entrada, int tabelaAsc[256], TipoLista * palavras){
    FILE *fpEntrada;
    int i, ascAux, numPalavras;
    char aux[2], confere[MAXTAM], palavraCorrigida[MAXTAM];
    TipoItem item;

    fpEntrada=fopen(entrada, "r");
    fscanf(fpEntrada, "%s", confere);

    if(strcasecmp(confere, "ORDEM")==0){
        for(i=0;i<26;i++){
            fscanf(fpEntrada, "%s", aux);
            StrLower(aux);
            ascAux=ConverteCharAsc(aux);
            tabelaAsc[ascAux]=i+97;//POSICAO CORERETA NA TABELA AUX PASSADA
        }

        fscanf(fpEntrada, "%s", confere);// LE "TEXTO" E GUARDA EM CONFERE
        numPalavras=0;
        while (fscanf(fpEntrada, "%s", confere) != EOF){
                strcpy(palavraCorrigida,"");//ESVAZIA PALAVRACORRIGIDA
                Tokeniza(confere, palavraCorrigida);
                if(palavraCorrigida[strlen(palavraCorrigida)-1]=='-' && strlen(palavraCorrigida)>1){//Se o último caracter for hífen e a palavra não for "-"
                    if(fscanf(fpEntrada, "%s", confere) != EOF){
                        Tokeniza(confere, palavraCorrigida);
                    }
                }
                StrLower(palavraCorrigida);
                strcpy(item.palavra, palavraCorrigida);//item.palavra=confere
                item.numVezes=1;
                Insere(item, palavras);//Cria celula para a palavra;
                numPalavras++;//NUMERO DE PALAVRAS INSERIDAS NA LISTA
        }//WHILE
    } else {//LOGO A PRIMEIRA PALAVRA SERÁ TEXTO
        fscanf(fpEntrada, "%s", confere);
        numPalavras=0;//Ja foi inserida a primeira palavra
        while(strcasecmp(confere, "ORDEM")!=0){
            strcpy(palavraCorrigida,"");//ESVAZIA PALAVRACORRIGIDA
                Tokeniza(confere, palavraCorrigida);
                if(palavraCorrigida[strlen(palavraCorrigida)-1]=='-' && strlen(palavraCorrigida)>1){//Se o último caracter for hífen e a palavra não for "-"
                    fscanf(fpEntrada, "%s", confere);//Le a prox palavra
                    if(strcasecmp(confere, "ORDEM")!=0){
                        Tokeniza(confere, palavraCorrigida);
                    }
                }
                StrLower(palavraCorrigida);
                strcpy(item.palavra, palavraCorrigida);//item.palavra=confere
                item.numVezes=1;
                Insere(item, palavras);//Cria celula para a palavra;
                numPalavras++;//NUMERO DE PALAVRAS INSERIDAS NA LISTA

            if(strcmp(confere, "ORDEM")!=0)
                fscanf(fpEntrada, "%s", confere);
        }//WHILE
        for(i=0;i<26;i++){
            fscanf(fpEntrada, "%s", aux);
            StrLower(aux);
            ascAux=ConverteCharAsc(aux);
            tabelaAsc[ascAux]=i+97;//POSICAO CORERETA NA TABELA AUX PASSADA
        }
    }//ELSE
    return numPalavras;
    fclose(fpEntrada);
}
Example #8
0
// Execution of registration
UINT DCRegister(DDNS_CLIENT *c, bool ipv6, DDNS_REGISTER_PARAM *p, char *replace_v6)
{
	char *url;
	char url2[MAX_SIZE];
	char url3[MAX_SIZE];
	PACK *req, *ret;
	char key_str[MAX_SIZE];
	UCHAR machine_key[SHA1_SIZE];
	char machine_key_str[MAX_SIZE];
	char machine_name[MAX_SIZE];
	BUF *cert_hash;
	UINT err = ERR_INTERNAL_ERROR;
	UCHAR key_hash[SHA1_SIZE];
	char key_hash_str[MAX_SIZE];
	bool use_azure = false;
	char current_azure_ip[MAX_SIZE];
	INTERNET_SETTING t;
	UINT build = 0;
	bool use_https = false;
	bool use_vgs = false;
	// Validate arguments
	if (c == NULL)
	{
		return ERR_INTERNAL_ERROR;
	}

	Zero(current_azure_ip, sizeof(current_azure_ip));

	GetCurrentMachineIpProcessHash(machine_key);
	BinToStr(machine_key_str, sizeof(machine_key_str), machine_key, sizeof(machine_key));

	GetMachineHostName(machine_name, sizeof(machine_name));
	StrLower(machine_name);

	if (ipv6 == false)
	{
		url = DDNS_URL_V4_GLOBAL;

		if (IsUseAlternativeHostname())
		{
			url = DDNS_URL_V4_ALT;
		}
	}
	else
	{
		url = DDNS_URL_V6_GLOBAL;

		if (IsUseAlternativeHostname())
		{
			url = DDNS_URL_V6_ALT;
		}

		if (replace_v6)
		{
			url = replace_v6;
		}
	}

	Zero(&t, sizeof(t));
	if (ipv6 == false)
	{
		// Proxy Setting
		Copy(&t, &c->InternetSetting, sizeof(INTERNET_SETTING));
	}

	if (ipv6 == false)
	{
		// Get the current status of the VPN Azure Client
		if (c->Cedar->Server != NULL)
		{
			AZURE_CLIENT *ac = c->Cedar->Server->AzureClient;

			if (ac != NULL)
			{
				use_azure = SiIsAzureEnabled(c->Cedar->Server);

				if (use_azure)
				{
					Lock(ac->Lock);
					{
						StrCpy(current_azure_ip, sizeof(current_azure_ip), ac->ConnectingAzureIp);
					}
					Unlock(ac->Lock);
				}
			}
		}
	}

	req = NewPack();
	BinToStr(key_str, sizeof(key_str), c->Key, sizeof(c->Key));
	StrUpper(key_str);
	PackAddStr(req, "key", key_str);

	// Build Number
	build = c->Cedar->Build;


	PackAddInt(req, "build", build);
	PackAddInt(req, "osinfo", GetOsInfo()->OsType);
	PackAddInt(req, "is_64bit", Is64());
#ifdef	OS_WIN32
	PackAddInt(req, "is_windows_64bit", MsIs64BitWindows());
#endif	// OS_WIN32
	PackAddBool(req, "is_softether", true);
	PackAddBool(req, "is_packetix", false);
	PackAddStr(req, "machine_key", machine_key_str);
	PackAddStr(req, "machine_name", machine_name);
	PackAddInt(req, "lasterror_ipv4", c->Err_IPv4_GetMyIp);
	PackAddInt(req, "lasterror_ipv6", c->Err_IPv6_GetMyIp);
	PackAddBool(req, "use_azure", use_azure);
	PackAddStr(req, "product_str", CEDAR_PRODUCT_STR);
	PackAddInt(req, "ddns_protocol_version", DDNS_VERSION);


	if (use_azure)
	{
		Debug("current_azure_ip = %s\n", current_azure_ip);
		PackAddStr(req, "current_azure_ip", current_azure_ip);
	}

	HashSha1(key_hash, key_str, StrLen(key_str));
	BinToStr(key_hash_str, sizeof(key_hash_str), key_hash, sizeof(key_hash));
	StrLower(key_hash_str);

	if (p != NULL)
	{
		if (IsEmptyStr(p->NewHostname) == false)
		{
			PackAddStr(req, "new_hostname", p->NewHostname);
		}
	}



	cert_hash = StrToBin(DDNS_CERT_HASH);

	Format(url2, sizeof(url2), "%s?v=%I64u", url, Rand64());
	Format(url3, sizeof(url3), url2, key_hash_str[0], key_hash_str[1], key_hash_str[2], key_hash_str[3]);

	if (use_https == false)
	{
		ReplaceStr(url3, sizeof(url3), url3, "https://", "http://");
	}

	ReplaceStr(url3, sizeof(url3), url3, ".servers", ".open.servers");

	Debug("WpcCall: %s\n", url3);
	ret = WpcCallEx(url3, &t, DDNS_CONNECT_TIMEOUT, DDNS_COMM_TIMEOUT, "register", req,
		NULL, NULL, ((cert_hash != NULL && cert_hash->Size == SHA1_SIZE) ? cert_hash->Buf : NULL), NULL, DDNS_RPC_MAX_RECV_SIZE);
	Debug("WpcCall Ret: %u\n", ret);

	FreeBuf(cert_hash);

	FreePack(req);

	err = GetErrorFromPack(ret);

	ExtractAndApplyDynList(ret);

	// Status update
	Lock(c->Lock);
	{
		if (err == ERR_NO_ERROR)
		{
			char snat_t[MAX_SIZE];
			char current_region[128];

			// Current host name
			PackGetStr(ret, "current_hostname", c->CurrentHostName, sizeof(c->CurrentHostName));
			PackGetStr(ret, "current_fqdn", c->CurrentFqdn, sizeof(c->CurrentFqdn));
			PackGetStr(ret, "current_ipv4", c->CurrentIPv4, sizeof(c->CurrentIPv4));
			PackGetStr(ret, "current_ipv6", c->CurrentIPv6, sizeof(c->CurrentIPv6));
			PackGetStr(ret, "dns_suffix", c->DnsSuffix, sizeof(c->DnsSuffix));
			PackGetStr(ret, "current_region", current_region, sizeof(current_region));

			// SecureNAT connectivity check parameters
			Zero(snat_t, sizeof(snat_t));
			PackGetStr(ret, "snat_t", snat_t, sizeof(snat_t));
			NnSetSecureNatTargetHostname(snat_t);

			if (ipv6 == false)
			{
				char cert_hash[MAX_SIZE];

				PackGetStr(ret, "current_azure_ip", c->CurrentAzureIp, sizeof(c->CurrentAzureIp));
				c->CurrentAzureTimestamp = PackGetInt64(ret, "current_azure_timestamp");
				PackGetStr(ret, "current_azure_signature", c->CurrentAzureSignature, sizeof(c->CurrentAzureSignature));

				Zero(cert_hash, sizeof(cert_hash));
				PackGetStr(ret, "azure_cert_hash", cert_hash, sizeof(cert_hash));

				if (IsEmptyStr(cert_hash) == false)
				{
					StrCpy(c->AzureCertHash, sizeof(c->AzureCertHash), cert_hash);
				}
			}

			StrCpy(c->Cedar->CurrentDDnsFqdn, sizeof(c->Cedar->CurrentDDnsFqdn), c->CurrentFqdn);

			Debug("current_hostname=%s, current_fqdn=%s, current_ipv4=%s, current_ipv6=%s, current_azure_ip=%s, CurrentAzureTimestamp=%I64u, CurrentAzureSignature=%s, CertHash=%s\n",
				c->CurrentHostName, c->CurrentFqdn,
				c->CurrentIPv4, c->CurrentIPv6,
				c->CurrentAzureIp, c->CurrentAzureTimestamp, c->CurrentAzureSignature, c->AzureCertHash);

			if (IsEmptyStr(current_region) == false)
			{
				// Update the current region
				SiUpdateCurrentRegion(c->Cedar, current_region, false);
			}
		}
	}
	Unlock(c->Lock);

	if (IsEmptyStr(c->CurrentFqdn) == false)
	{
		SetCurrentDDnsFqdn(c->CurrentFqdn);
	}


	FreePack(ret);

	UniDebug(L"DCRegister Error: %s\n", _E(err));

	if (err == ERR_DUPLICATE_DDNS_KEY)
	{
		// Key duplication
		DCGenNewKey(c->Key);
		c->KeyChanged = true;
	}

	if (err == ERR_DISCONNECTED)
	{
		err = ERR_DDNS_DISCONNECTED;
	}

	if (IsUseAlternativeHostname() == false)
	{
		if (err == ERR_CONNECT_FAILED)
		{
			if (ipv6 && replace_v6 == NULL)
			{
				UINT type = DetectFletsType();

				if (type & FLETS_DETECT_TYPE_EAST_BFLETS_PRIVATE && err != ERR_NO_ERROR)
				{
					err = DCRegister(c, ipv6, p, DDNS_REPLACE_URL_FOR_EAST_BFLETS);
				}

				if (type & FLETS_DETECT_TYPE_EAST_NGN_PRIVATE && err != ERR_NO_ERROR)
				{
					err = DCRegister(c, ipv6, p, DDNS_REPLACE_URL_FOR_EAST_NGN);
				}

				if (type & FLETS_DETECT_TYPE_WEST_NGN_PRIVATE && err != ERR_NO_ERROR)
				{
					err = DCRegister(c, ipv6, p, DDNS_REPLACE_URL_FOR_WEST_NGN);
				}
			}
		}
	}

	return err;
}
Example #9
0
//-----------------------------------------------------------------------------
// DB_Load_EntryOldFormat (char *line)
// Load DB entry in old format from given line
//-----------------------------------------------------------------------------
static int      DB_Load_EntryOldFormat(char *line)
{
    t_db_entry *entry;
    t_meka_crc  mekacrc;
    char *      w;
    char        buf[1024+1];

    // Get MekaCRC
    sscanf (line, "%08X%08X", &mekacrc.v[0], &mekacrc.v[1]);
    line += 16 + 1;

    // Get name
    if (!(w = parse_getword(NULL, 0, &line, ",", ';')))
        return (0);

    // Create and add entry to global list
    // Note that the old format doesn't store system nor crc32
    entry = DB_Entry_New (-1, 0, &mekacrc);
    list_add (&DB.entries, entry);
    DB.entries_counter_format_old++;

    // Add default name
    DB_Name_New (entry, w, 0, FALSE);

    // Parse optional parameters
    while ((w = parse_getword(buf, 1024, &line, "=,", ';')) != NULL)
    {
        StrUpper(w);
        // printf ("field '%s'\n", w);
        if (!strcmp(w, "JAPNAME"))
        {
            if (!(w = parse_getword(NULL, 0, &line, ",", ';')))
                return (0);
            DB_Name_New (entry, w, DB_COUNTRY_JP, FALSE);
        }
        else if (!strcmp(w, "VER"))
        {
            // In the old format, the 'VER' field holds both COUNTRY and VERSION
            char *wp;
            if (!(w = parse_getword(buf, 1024, &line, ",", ';')))
                return (0);

            wp = buf;
            // printf("VER = %s\n", wp);

            // Get COUNTRY part
            if      (!strnicmp (wp, "Brazilian", 9))
            {   wp += 9; entry->country |= DB_COUNTRY_BR; }
            else if (!strnicmp (wp, "English",   7))
            {   wp += 7; entry->country |= DB_COUNTRY_EU | DB_COUNTRY_US; }
            else if (!strnicmp (wp, "European",  8))
            {   wp += 8; entry->country |= DB_COUNTRY_EU; }
            else if (!strnicmp (wp, "Export",    6))
            {   wp += 6; entry->country |= DB_COUNTRY_EU | DB_COUNTRY_US; }
            else if (!strnicmp (wp, "French",    6))
            {   wp += 6; entry->country |= DB_COUNTRY_FR; }
            else if (!strnicmp (wp, "Hong-Kong", 9))
            {   wp += 9; entry->country |= DB_COUNTRY_HK; }
            else if (!strnicmp (wp, "International", 13))
            {   wp += 13;   }
            else if (!strnicmp (wp, "Japanese",  8))
            {   wp += 8; entry->country |= DB_COUNTRY_JP; }
            else if (!strnicmp (wp, "Korean",    6))
            {   wp += 6; entry->country |= DB_COUNTRY_KR; }
            else if (!strnicmp (wp, "USA",       3))
            {   wp += 3; entry->country |= DB_COUNTRY_US; }
            // else
            //    printf("Unknown country in version!");
            
            // If there's anything left after known countries, it goes to VERSION
            if (*wp != EOSTR)
            {
                parse_skip_spaces (&wp);
                entry->version = strdup (wp);
                // printf("--> NEW VERSION = '%s'\n", entry->version);
            }
        }
        else if (!strcmp(w, "BAD"))
            entry->flags |= DB_FLAG_BAD;
        else if (!strcmp(w, "HACK"))
            entry->flags |= DB_FLAG_HACK;
        else if (!strcmp(w, "BIOS"))
            entry->flags |= DB_FLAG_BIOS;
        else if (!strcmp(w, "PROTO"))
            entry->flags |= DB_FLAG_PROTO;
        else if (!strcmp(w, "3D"))
            entry->flags |= DB_FLAG_EMU_3D;
        else if (!strcmp(w, "FLICKER"))
            entry->flags |= DB_FLAG_EMU_SPRITE_FLICKER;
        else if (!strcmp(w, "COMMENT"))
        {
            if (!(w = parse_getword(NULL, 0, &line, ",", ';')))
                return (0);
            entry->comments = w;
        }
        else if (!strcmp(w, "ID"))
        {
            if (!(w = parse_getword(NULL, 0, &line, ",", ';')))
                return (0);
            entry->product_no = w;
        }
        else if (!strcmp(w, "MAPPER"))
        {
            if (!(w = parse_getword(buf, 1024, &line, ",", ';')))
                return (0);
            entry->emu_mapper = atoi(w);
        }
        else if (!strcmp(w, "TRANS"))
        {
            int value;
            if (!(w = parse_getword(buf, 1024, &line, ",", ';')))
                return (0);
            // In TRANS field only, 'EN' can be specified. It currently gets the UK flag.
            if (!strcmp(w, "EN"))
                value = DB_COUNTRY_UK;
            else
                if ((value = DB_FindCountryFlagByName(w)) == -1)
                    return (0);
            entry->trans_country = value;
            entry->flags |= DB_FLAG_TRANS;
        }
        else if (!strcmp(w, "TVTYPE"))
        {
            if (!(w = parse_getword(buf, 1024, &line, ",", ';')))
                return (0);
            StrLower(w);
            if (!strcmp(w, "pal") || !strcmp(w, "secam") || !strcmp(w, "pal/secam"))
                entry->emu_tvtype = TVTYPE_PAL_SECAM;
            else if (!strcmp(w, "ntsc"))
                entry->emu_tvtype = TVTYPE_NTSC;
            else
                return (0);
        }
        else if (!strcmp(w, "AUTHORS"))
        {
            if (!(w = parse_getword(NULL, 0, &line, ",", ';')))
                return (0);
            entry->authors = w;
        }
        else if (!strcmp(w, "DATE"))
        {
            if (!(w = parse_getword(buf, 1024, &line, ",", ';')))
                return (0);
            // FIXME: yet ignored
        }
        else
            return (0); // Unknown field
    }

    // Ok
    return (1);
}
Example #10
0
//-----------------------------------------------------------------------------
// DB_Load_Entry (char *line)
// Load DB entry from given line
//-----------------------------------------------------------------------------
static int      DB_Load_Entry (char *line)
{
    t_db_entry *entry;
    int         value;
    u32         crc_crc32;
    t_meka_crc  crc_mekacrc;
    char *      w;
    char        buf[1024+1];

    // Get system
    // FIXME: linear research with strcmp. Could be int compared, or even hashed.
    parse_getword(buf, 4, &line, " \t", ';');
    value = DB_FindDriverIdByName(buf);
    if (value == -1)
        return (1); // Silent return if there's anything else than a system

    parse_skip_spaces (&line);
    // printf("line: %s\n", line);

    // Get CRC32 & MekaCRC
    if (sscanf (line, "%08x %08X%08X", &crc_crc32, &crc_mekacrc.v[0], &crc_mekacrc.v[1]) != 3)
        return (0);
    line += 8 + 1 + 16;
    parse_skip_spaces (&line);

    // Create and add entry to global list
    entry = DB_Entry_New (value, crc_crc32, &crc_mekacrc); // value hold system
    list_add (&DB.entries, entry);
    DB.entries_counter_format_new++;

    // Get and add default name
    if (!(w = parse_getword(NULL, 0, &line, "/", ';')))
        return (0);
    DB_Name_New (entry, w, 0, FALSE);

    // Parse optional parameters
    while ((w = parse_getword(buf, 1024, &line, "=/", ';')) != NULL)
    {
        StrUpper(w);
        // printf ("field '%s'\n", w);

        if (!strncmp (w, "NAME_", 5))
        {
            w += 5;
            if ((value = DB_FindCountryFlagByName(w)) == -1)
                return (0);
            if (!(w = parse_getword(NULL, 0, &line, "/", ';')))
                break;
            DB_Name_New (entry, w, value, FALSE);
            // printf("adding country %d name %s", value, w);
        }
        else if (!strcmp(w, "COUNTRY"))
        {
            while (line[-1] == ',' || line[-1] == '=')
            {
                if (!(w = parse_getword(buf, 3, &line, ",/", ';')))
                    return (0);
                if ((value = DB_FindCountryFlagByName(w)) == -1)
                    return (0);
                entry->country |= value;
            }
        }
        else if (!strcmp(w, "PRODUCT_NO"))
        {
            if (!(w = parse_getword(NULL, 0, &line, "/", ';')))
                return (0);
            entry->product_no = w;
        }
        else if (!strcmp(w, "EMU_COUNTRY"))
        {
            if (!(w = parse_getword(buf, 1024, &line, ",/", ';')))
                return (0);
            entry->emu_country = atoi(w);
        }
        else if (!strcmp(w, "EMU_INPUTS"))
        {
            if (!(w = parse_getword(buf, 1024, &line, "/", ';')))
                return (0);
            StrLower(w);
            if (!strcmp(w, "joypad"))
                entry->emu_inputs = INPUT_JOYPAD;
            else if (!strcmp(w, "lightphaser"))
                entry->emu_inputs = INPUT_LIGHTPHASER;
            else if (!strcmp(w, "paddle"))
                entry->emu_inputs = INPUT_PADDLECONTROL;
            else if (!strcmp(w, "sportspad"))
                entry->emu_inputs = INPUT_SPORTSPAD;
            else if (!strcmp(w, "tvoekaki"))
                entry->emu_inputs = INPUT_GRAPHICBOARD;
            else if (!strcmp(w, "graphicboardv2"))
                entry->emu_inputs = INPUT_GRAPHICBOARD_V2;
            else
                return (0);
        }
        else if (!strcmp(w, "EMU_IPERIOD"))
        {
            if (!(w = parse_getword(buf, 1024, &line, "/", ';')))
                return (0);
            entry->emu_iperiod = atoi(w);
        }
        else if (!strcmp(w, "EMU_MAPPER"))
        {
            if (!(w = parse_getword(buf, 1024, &line, "/", ';')))
                return (0);
            entry->emu_mapper = atoi(w);
        }
        else if (!strcmp(w, "EMU_VDP"))
        {
            if (!(w = parse_getword(buf, 1024, &line, "/", ';')))
                return (0);
            if ((entry->emu_vdp_model = VDP_Model_FindByName(w)) == -1)
                return (0);
        }
        else if (!strcmp(w, "EMU_TVTYPE"))
        {
            if (!(w = parse_getword(buf, 1024, &line, "/", ';')))
                return (0);
            StrLower(w);
            if (!strcmp(w, "pal"))
                entry->emu_tvtype = TVTYPE_PAL_SECAM;
            else if (!strcmp(w, "ntsc"))
                entry->emu_tvtype = TVTYPE_NTSC;
            else
                return (0);
        }
        else if (!strcmp(w, "EMU_3D"))
            entry->flags |= DB_FLAG_EMU_3D;
        else if (!strcmp(w, "EMU_SPRITE_FLICKER"))
            entry->flags |= DB_FLAG_EMU_SPRITE_FLICKER;
        else if (!strcmp(w, "COMMENT"))
        {
            if (!(w = parse_getword(NULL, 0, &line, "/", ';')))
                return (0);
            entry->comments = w;
        }
        else if (!strcmp(w, "FLAGS"))
        {
            while (line[-1] == ',' || line[-1] == '=')
            {
                if (!(w = parse_getword(buf, 16, &line, ",/", ';')))
                    return (0);
                if      (!strcmp(w, "BAD"))        entry->flags |= DB_FLAG_BAD;
                else if (!strcmp(w, "BIOS"))       entry->flags |= DB_FLAG_BIOS;
                else if (!strcmp(w, "SMSGG_MODE")) entry->flags |= DB_FLAG_SMSGG_MODE;
                else if (!strcmp(w, "HACK"))       entry->flags |= DB_FLAG_HACK;
                else if (!strcmp(w, "TRANS"))      entry->flags |= DB_FLAG_TRANS;
                else if (!strcmp(w, "PROTO"))      entry->flags |= DB_FLAG_PROTO;
                else if (!strcmp(w, "HOMEBREW"))   entry->flags |= DB_FLAG_HOMEBREW;
                else return (0);
            }
        }
        else if (!strcmp(w, "TRANS"))
        {
            if (!(w = parse_getword(buf, 1024, &line, "/", ';')))
                return (0);
            // In TRANS field only, 'EN' can be specified. It currently gets the UK flag.
            if (!strcmp(w, "EN"))
                value = DB_COUNTRY_UK;
            else if ((value = DB_FindCountryFlagByName(w)) == -1)
                return (0);
            entry->trans_country = value;
        }
        else if (!strcmp(w, "AUTHORS"))
        {
            if (!(w = parse_getword(NULL, 0, &line, "/", ';')))
                return (0);
            entry->authors = w;
        }
        else if (!strcmp(w, "VERSION"))
        {
            if (!(w = parse_getword(NULL, 0, &line, "/", ';')))
                return (0);
            entry->version = w;
        }
        else
        {
            // No error for empty fields (",,")
            // This is mainly to handle end of line comments ("FIELD=heh    ; comment")
            if (strlen(w) > 0)
                return (0);
        }
    }

    // Ok
    return (1);
}
Example #11
0
int     Z80_Disassemble(char *S, word A, bool display_symbols, bool display_symbols_for_current_index_registers, bool resolve_indirect_offsets)
{
    char  R[256], H[256], C;
    byte  Offset = 0;
	bool  has_offset = false;
    word  B;
    int   relative_offset_base = 0;  // 0 : from PC, 1 : from IX, 2 : from IY

    B = A;
    C = '\0';
    
	const char *T_const = NULL;
    switch (RdZ80_NoHook(B))
    {
    case 0xCB: B++;T_const=MnemonicsCB[RdZ80_NoHook(B++&0xFFFF)];break;
    case 0xED: B++;T_const=MnemonicsED[RdZ80_NoHook(B++&0xFFFF)];break;
    case 0xDD: B++;C='x';
        if (RdZ80_NoHook(B&0xFFFF)!=0xCB) 
            T_const=MnemonicsXX[RdZ80_NoHook(B++&0xFFFF)];
        else
        { B++;Offset=RdZ80_NoHook(B++&0xFFFF);has_offset=true;T_const=MnemonicsXCB[RdZ80_NoHook(B++&0xFFFF)]; }
        break;
    case 0xFD: B++;C='y';
        if(RdZ80_NoHook(B&0xFFFF)!=0xCB) 
            T_const=MnemonicsXX[RdZ80_NoHook(B++&0xFFFF)];
        else
        { B++;Offset=RdZ80_NoHook(B++&0xFFFF);has_offset=true;T_const=MnemonicsXCB[RdZ80_NoHook(B++&0xFFFF)]; }
        break;
    default:   
        T_const=Mnemonics[RdZ80_NoHook(B++&0xFFFF)];
        break;
    }
	char T[32];
	strcpy(T, T_const);
	StrLower(T);

	char *P;
    if ((P=strchr(T,'^')) != NULL)
    {
		assert(!has_offset);	// Should never get a ^ in the DD CB and FD CB paths
		if (S != NULL)
		{
			Offset = RdZ80_NoHook(B&0xFFFF);

			// convert 0xFF to -0x01 for nicer display
			const char offset_sign = (Offset & 0x80) ? '-' : '+';
			const byte offset_abs = (Offset & 0x80) ? 256 - Offset : Offset;

			if (resolve_indirect_offsets)
			{
				if (display_symbols_for_current_index_registers)
				{
					// P+2: skip the 'h' in the instruction
					const u16 addr = ((C == 'x') ? sms.R.IX.W : sms.R.IY.W) + (signed char)Offset;
					Z80_Disassemble_GetDecoratedSymbolFromAddress(R, addr, H, 256, display_symbols, false);		// Don't display full address because it is obvious (for IX/IY being typically stable)
					snprintf(R, 256, "%.*s%c%d=%s%s", (int)(P-T), T, offset_sign, offset_abs, H, P+2);
				}
				else
				{
					// P+2: skip the 'h' in the instruction
					snprintf(R, 256, "%.*s%c%d%s", (int)(P-T), T, offset_sign, offset_abs, P+2);
				}
			}
			else
			{
				snprintf(R, 256, "%.*s%c%d", (int)(P-T), T, offset_sign, offset_abs);
			}
		}
		else
		{
			strcpy(R,T);
		}
		B++;
	}
    else 
	{
        strcpy(R,T);
	}

    if ((P=strchr(R,'%')) != NULL) 
    {
        *P=C;
        if (C == 'x')
            relative_offset_base = 1;
        else if (C == 'y')
            relative_offset_base = 2;
    }

    if ((P=strchr(R,'*')) != NULL)
    {
        if (S != NULL)
        {
            strncpy(S,R,P-R);S[P-R]='\0';
            sprintf(H,"%02Xh",RdZ80_NoHook(B&0xFFFF));
            strcat(S,H);strcat(S,P+2);
        }
        B++;
    }
    else
	{
        if ((P=strchr(R,'@')) != NULL)
        {
            if (S != NULL)
            {
                if(!has_offset) 
                    Offset=RdZ80_NoHook(B&0xFFFF);

				// convert 0xFF to -0x01 for nicer display
				const char offset_sign = (Offset & 0x80) ? '-' : '+';
				const byte offset_abs = (Offset & 0x80) ? 256 - Offset : Offset;

                if (resolve_indirect_offsets)
                {
					// P+2: skip the 'h' in the instruction
					if (relative_offset_base == 0)
					{
						const u16 addr = (B+1) + (signed char)Offset;
						Z80_Disassemble_GetDecoratedSymbolFromAddress(R, addr, H, 256, display_symbols, true);
						snprintf(S, 255, "%.*s%c%02Xh (%s)%s", (int)(P-R), R, offset_sign, offset_abs, H, P+2);
					}
					else
					{
						const u16 addr = ((relative_offset_base == 1) ? sms.R.IX.W : sms.R.IY.W) + (signed char)Offset;
						Z80_Disassemble_GetDecoratedSymbolFromAddress(R, addr, H, 256, display_symbols, false);	// Don't display full address because it is obvious (for IX/IY being typically stable)
						snprintf(S, 255, "%.*s%c%d=%s%s", (int)(P-R), R, offset_sign, offset_abs, H, P+2);
					}
                }
                else
                {
					// P+2: skip the 'h' in the instruction
					snprintf(S, 256, "%.*s%c%02Xh%s", (int)(P-R), R, offset_sign, offset_abs, P+2);
                }
            }
			if(!has_offset)
				B++;
        }
		else if((P=strchr(R,'#')) != NULL)
		{
			if (S != NULL)
			{
				const u16 addr = RdZ80_NoHook(B&0xFFFF)+256*RdZ80_NoHook((B+1)&0xFFFF);
				Z80_Disassemble_GetDecoratedSymbolFromAddress(R, addr, H, 256, display_symbols, true);
				snprintf(S, 256, "%.*s%s%s", (int)(P-R), R, H, P+2);
			}
			B += 2;
		}
		else if(strncmp(R,"rst ",4)==0)
		{
			if (S != NULL)
			{
				const u16 addr = (u16)Debugger_Eval_ParseIntegerHex(R+4);
				const t_debugger_symbol* symbol = display_symbols ? Debugger_Symbols_GetLastByAddr(addr) : NULL;
				if (symbol != NULL)
				{
					sprintf(S,"rst %s/%02Xh", symbol->name, addr);
				}
				else
				{
					strcpy(S, R);
				}
			}
		}
		else
		{
			if (S != NULL)
				strcpy(S, R);
		}
	}

    // MEKA-START: needed so it works properly when the instruction wrap at 0xffff
    if (B < A)
        return ((int)B+0x10000 - (int)A);
    // MEKA-END

    return (B-A);
}
Example #12
0
// Create a tap device
int UnixCreateTapDeviceEx(char *name, char *prefix, UCHAR *mac_address)
{
	int fd;
	struct ifreq ifr;
	char eth_name[MAX_SIZE];
	char instance_name_lower[MAX_SIZE];
	struct sockaddr sa;
	char *tap_name = TAP_FILENAME_1;
	int s;
	// Validate arguments
	if (name == NULL)
	{
		return -1;
	}

	// Generate the device name
	StrCpy(instance_name_lower, sizeof(instance_name_lower), name);
	Trim(instance_name_lower);
	StrLower(instance_name_lower);
	Format(eth_name, sizeof(eth_name), "%s_%s", prefix, instance_name_lower);

	eth_name[15] = 0;

	// Open the tun / tap
#ifndef	UNIX_MACOS
	if (GetOsInfo()->OsType == OSTYPE_LINUX)
	{
		// Linux
		if (IsFile(TAP_FILENAME_1) == false)
		{
			char tmp[MAX_SIZE];

			Format(tmp, sizeof(tmp), "%s c 10 200", TAP_FILENAME_1);
			Run("mknod", tmp, true, true);

			Format(tmp, sizeof(tmp), "600 %s", TAP_FILENAME_1);
			Run("chmod", tmp, true, true);
		}
	}
	// Other than MacOS X
	fd = open(TAP_FILENAME_1, O_RDWR);
	if (fd == -1)
	{
		// Failure
		fd = open(TAP_FILENAME_2, O_RDWR);
		if (fd == -1)
		{
			return -1;
		}
		tap_name = TAP_FILENAME_2;
	}
#else	// UNIX_MACOS
	// MacOS X
	fd = open(TAP_MACOS_FILENAME, O_RDWR);
	if (fd == -1)
	{
		return -1;
	}
	tap_name = TAP_MACOS_FILENAME;
#endif	// UNIX_MACOS

#ifdef	UNIX_LINUX
	// Create a tap for Linux

	// Set the device name
	Zero(&ifr, sizeof(ifr));

	ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
	StrCpy(ifr.ifr_name, sizeof(ifr.ifr_name), eth_name);

	if (ioctl(fd, TUNSETIFF, &ifr) == -1)
	{
		// Failure
		close(fd);
		return -1;
	}

	// MAC address setting
	s = socket(AF_INET, SOCK_DGRAM, 0);
	if (s != -1)
	{
		if (mac_address != NULL)
		{
			Zero(&ifr, sizeof(ifr));
			StrCpy(ifr.ifr_name, sizeof(ifr.ifr_name), eth_name);
			ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER;
			Copy(&ifr.ifr_hwaddr.sa_data, mac_address, 6);
			ioctl(s, SIOCSIFHWADDR, &ifr);
		}

		Zero(&ifr, sizeof(ifr));
		StrCpy(ifr.ifr_name, sizeof(ifr.ifr_name), eth_name);
		ioctl(s, SIOCGIFFLAGS, &ifr);

		ifr.ifr_flags |= IFF_UP;
		ioctl(s, SIOCSIFFLAGS, &ifr);

		close(s);
	}

#else	// UNIX_LINUX
#ifdef	UNIX_SOLARIS
	// Create a tap for Solaris
	{
		int ip_fd;
		int tun_fd;
		int ppa;

		tun_fd = open(tap_name, O_RDWR);
		if (tun_fd == -1)
		{
			// Failure
			close(fd);
			return -1;
		}

		ip_fd = open("/dev/ip", O_RDWR);
		if (ip_fd == -1)
		{
			// Failure
			close(tun_fd);
			close(fd);
			return -1;
		}

		ppa = -1;
		ppa = ioctl(tun_fd, TUNNEWPPA, ppa);
		if (ppa == -1)
		{
			// Failure
			close(tun_fd);
			close(fd);
			close(ip_fd);
			return -1;
		}

		if (ioctl(fd, I_PUSH, "ip") < 0)
		{
			// Failure
			close(tun_fd);
			close(fd);
			close(ip_fd);
			return -1;
		}

		if (ioctl(fd, IF_UNITSEL, (char *)&ppa) < 0)
		{
			// Failure
			close(tun_fd);
			close(fd);
			close(ip_fd);
			return -1;
		}

		if (ioctl(ip_fd, I_LINK, fd) < 0)
		{
			// Failure
			close(tun_fd);
			close(fd);
			close(ip_fd);
			return -1;
		}

		close(tun_fd);
		close(ip_fd);
	}

#endif	// UNIX_SOLARIS
#endif	// UNIX_LINUX

	return fd;
}
Example #13
0
NLM_EXTERN char * LIBCALL Nlm_StringLower (char *string)
{
	return (string == NULL) ? 0 : StrLower(string);
}
Example #14
0
TModel3d *__fastcall TModelsManager::GetModel(const char *Name, bool dynamic)
{ // model mo¿e byæ we wpisie "node...model" albo "node...dynamic", a tak¿e byæ dodatkowym w dynamic
    // (kabina, wnêtrze, ³adunek)
    // dla "node...dynamic" mamy podan¹ œcie¿kê w "\dynamic\" i musi byæ co najmniej 1 poziom, zwkle
    // s¹ 2
    // dla "node...model" mo¿e byæ typowy model statyczny ze œcie¿k¹, domyœlnie w "\scenery\" albo
    // "\models"
    // albo mo¿e byæ model z "\dynamic\", jeœli potrzebujemy wstawiæ auto czy wagon nieruchomo
    // - ze œcie¿ki z której jest wywo³any, np. dir="scenery\bud\" albo dir="dynamic\pkp\st44_v1\"
    // plus name="model.t3d"
    // - z domyœlnej œcie¿ki dla modeli, np. "scenery\" albo "models\" plus name="bud\dombale.t3d"
    // (dir="")
    // - konkretnie podanej œcie¿ki np. name="\scenery\bud\dombale.t3d" (dir="")
    // wywo³ania:
    // - konwersja wszystkiego do E3D, podawana dok³adna œcie¿ka, tekstury tam, gdzie plik
    // - wczytanie kabiny, dok³adna œcie¿ka, tekstury z katalogu modelu
    // - wczytanie ³adunku, œcie¿ka dok³adna, tekstury z katalogu modelu
    // - wczytanie modelu, œcie¿ka dok³adna, tekstury z katalogu modelu
    // - wczytanie przedsionków, œcie¿ka dok³adna, tekstury z katalogu modelu
    // - wczytanie uproszczonego wnêtrza, œcie¿ka dok³adna, tekstury z katalogu modelu
    // - niebo animowane, œcie¿ka brana ze wpisu, tekstury nieokreœlone
    // - wczytanie modelu animowanego - Init() - sprawdziæ
    char buf[255];
    AnsiString buftp = Global::asCurrentTexturePath; // zapamiêtanie aktualnej œcie¿ki do tekstur,
    // bo bêdzie tyczmasowo zmieniana
    /*
    // Ra: niby tak jest lepiej, ale dzia³a gorzej, wiêc przywrócone jest oryginalne
     //nawet jeœli model bêdzie pobrany z tablicy, to trzeba ustaliæ œcie¿kê dla tekstur
     if (dynamic) //na razie tak, bo nie wiadomo, jaki mo¿e mieæ wp³yw na pozosta³e modele
     {//dla pojazdów podana jest zawsze pe³na œcie¿ka do modelu
      strcpy(buf,Name);
      if (strchr(Name,'/')!=NULL)
      {//pobieranie tekstur z katalogu, w którym jest model
       Global::asCurrentTexturePath=Global::asCurrentTexturePath+AnsiString(Name);
       Global::asCurrentTexturePath.Delete(Global::asCurrentTexturePath.Pos("/")+1,Global::asCurrentTexturePath.Length());
      }
     }
     else
     {//dla modeli scenerii trzeba ustaliæ œcie¿kê
      if (strchr(Name,'\\')==NULL)
      {//jeœli nie ma lewego ukoœnika w œcie¿ce, a jest prawy, to zmieniæ œcie¿kê dla tekstur na tê
    z modelem
       strcpy(buf,"models\\"); //Ra: by³o by lepiej katalog dodaæ w parserze
       //strcpy(buf,"scenery\\"); //Ra: by³o by lepiej katalog dodaæ w parserze
       strcat(buf,Name);
       if (strchr(Name,'/')!=NULL)
       {//jeszcze musi byæ prawy ukoœnik
        Global::asCurrentTexturePath=Global::asCurrentTexturePath+AnsiString(Name);
        Global::asCurrentTexturePath.Delete(Global::asCurrentTexturePath.Pos("/")+1,Global::asCurrentTexturePath.Length());
       }
      }
      else
      {//jeœli jest lewy ukoœnik, to œcie¿kê do tekstur zmieniæ tylko dla pojazdów
       strcpy(buf,Name);
      }
     }
     StrLower(buf);
     for (int i=0;i<Count;i++)
     {//bezsensowne przeszukanie tabeli na okolicznoœæ wyst¹pienia modelu
      if (strcmp(buf,Models[i].Name)==0)
      {
       Global::asCurrentTexturePath=buftp; //odtworzenie œcie¿ki do tekstur
       return (Models[i].Model); //model znaleziony
      }
     };
    */
    if (strchr(Name, '\\') == NULL)
    {
        strcpy(buf, "models\\"); // Ra: by³o by lepiej katalog dodaæ w parserze
        strcat(buf, Name);
        if (strchr(Name, '/') != NULL)
        {
            Global::asCurrentTexturePath = Global::asCurrentTexturePath + AnsiString(Name);
            Global::asCurrentTexturePath.Delete(Global::asCurrentTexturePath.Pos("/") + 1,
                                                Global::asCurrentTexturePath.Length());
        }
    }
    else
    {
        strcpy(buf, Name);
        if (dynamic) // na razie tak, bo nie wiadomo, jaki mo¿e mieæ wp³yw na pozosta³e modele
            if (strchr(Name, '/') != NULL)
            { // pobieranie tekstur z katalogu, w którym jest model
                Global::asCurrentTexturePath = Global::asCurrentTexturePath + AnsiString(Name);
                Global::asCurrentTexturePath.Delete(Global::asCurrentTexturePath.Pos("/") + 1,
                                                    Global::asCurrentTexturePath.Length());
            }
    }
    StrLower(buf);
    for (int i = 0; i < Count; i++)
    {
        if (strcmp(buf, Models[i].Name) == 0)
        {
            Global::asCurrentTexturePath = buftp;
            return (Models[i].Model);
        }
    };
    TModel3d *tmpModel = LoadModel(buf, dynamic); // model nie znaleziony, to wczytaæ
    Global::asCurrentTexturePath = buftp; // odtworzenie œcie¿ki do tekstur
    return (tmpModel); // NULL jeœli b³¹d
};