예제 #1
0
static int ndisk_lua_push(lua_State *l, NDisk *disk) {
    char *tmp = NULL;
    wchar_t sTmp[40];
    lua_newtable(l);
    tmp = wtoc(disk->nickname);
    lua_pushstring(l, tmp);
    free(tmp);
    tmp = NULL;
    lua_setfield(l, -2, "nickname");
    tmp = wtoc(disk->username);
    lua_pushstring(l, tmp);
    free(tmp);
    tmp = NULL;
    lua_setfield(l, -2, "username");
    if(disk->token) {
        tmp = wtoc(disk->token);
        lua_pushstring(l, tmp);
        free(tmp);
        tmp = NULL;
        lua_setfield(l, -2, "token");
    }
    if(disk->secret) {
        tmp = wtoc(disk->secret);
        lua_pushstring(l, tmp);
        free(tmp);
        tmp = NULL;
        lua_setfield(l, -2, "secret");
    }
    return NDISK_OK;
}
예제 #2
0
int _tmain(int argc, _TCHAR* argv[])
{
	CWDB wdb;
	LoadDefinitions();


	char* file = (char*)malloc(0xff);

	if( !argv[1] )
		file = "itemcache.wdb";
	else
		wtoc(file,argv[1],256);

	if (!wdb.loadWDB(file))
		return 0;

	if(memcmp(wdb.getDef()->getSignature(),"BDIW",4))
		return 0;

	wdb.parseWDB();
	makeCSV(&wdb);
	
	return 0;
}
예제 #3
0
int main(int argc, char **argv) {
		
#if defined(__APPLE__) && defined(__MACH__)
	char path[2049];
	_NSGetExecutablePath(path, 2048);

	String basePath = path;
	vector<String> cpts = basePath.split("/");
	String installPath = "";
	for(int i=0; i < cpts.size() - 2; i++) {
		installPath = installPath + cpts[i];
		installPath += String("/");
	}
#else
	char path[2049];
	TCHAR tpath[2049];
	GetModuleFileName(NULL, (LPWSTR)tpath, 2048);
	wtoc(path, tpath, 2048);
	
	String basePath = path;
	vector<String> cpts = basePath.split("\\");
	String installPath = "";
	for(int i=0; i < cpts.size() - 2; i++) {
		installPath = installPath + cpts[i];
		installPath += String("\\");
	}

#endif

	printf("Polycode build tool v0.1.1\n");

	for(int i=0; i < argc; i++) {
		String argString = String(argv[i]);
		vector<String> bits = argString.split("=");
		if(bits.size() == 2) {
			BuildArg arg;
			arg.name = bits[0];
			arg.value = bits[1];
			args.push_back(arg);
		}
		
	}
	
	if(getArg("--config") == "") {
		printf("\n\nInput config XML missing. Use --config=path to specify.\n\n");
		return 1;
	}

	
	if(getArg("--out") == "") {
		printf("\n\nOutput file not specified. Use --out=outfile.polyapp to specify.\n\n");
		return 1;		
	}

	char dirPath[4099];
#if defined(__APPLE__) && defined(__MACH__)
	_getcwd(dirPath, sizeof(dirPath));
#else	
	TCHAR tdirpath[4099];
	GetCurrentDirectory(4098, (LPWSTR)tdirpath);
	wtoc(dirPath, tdirpath, 4098);

#endif
	String currentPath = String(dirPath);

	String configPath = getArg("--config");

	String finalPath = configPath;
	if(configPath[0] != '/') {

#ifdef _WINDOWS
		finalPath = currentPath+"\\"+configPath;
#else
		finalPath = currentPath+"/"+configPath;
#endif
	}

	finalPath = finalPath.replace(":", "");
	finalPath = finalPath.replace("\\", "/");
	finalPath = finalPath.substr(1, finalPath.length() - 1);

	printf("Reading config file from %s\n", finalPath.c_str());

	Object configFile;
	if(!configFile.loadFromXML(finalPath)) {
		printf("Specified config file doesn't exist!\n");
		return 1;
	}
	printf("OK!\n");
	// start required params

	String entryPoint;
	int defaultWidth;
	int defaultHeight;
	int frameRate = 60;
	int antiAliasingLevel = 0;
	bool fullScreen = false;
	float backgroundColorR = 0.2;
	float backgroundColorG = 0.2;
	float backgroundColorB = 0.2;

	if(configFile.root["entryPoint"]) {
		printf("Entry point: %s\n", configFile.root["entryPoint"]->stringVal.c_str());
		entryPoint = configFile.root["entryPoint"]->stringVal;
	} else {
		printf("Required parameter: \"entryPoint\" is missing from config file!\n");
		return 1;		
	}

	if(configFile.root["defaultWidth"]) {
		printf("Width: %d\n", configFile.root["defaultWidth"]->intVal);
		defaultWidth = configFile.root["defaultWidth"]->intVal;
	} else {
		printf("Required parameter: \"defaultWidth\" is missing from config file!\n");
		return 1;		
	}

	if(configFile.root["defaultHeight"]) {
		printf("Height: %d\n", configFile.root["defaultHeight"]->intVal);
		defaultHeight = configFile.root["defaultHeight"]->intVal;
	} else {
		printf("Required parameter: \"defaultHeight\" is missing from config file!\n");
		return 1;		
	}

	// start optional params

	if(configFile.root["frameRate"]) {
		printf("Frame rate: %d\n", configFile.root["frameRate"]->intVal);
		frameRate = configFile.root["frameRate"]->intVal;
	}

	if(configFile.root["antiAliasingLevel"]) {
		printf("Anti-aliasing level: %d\n", configFile.root["antiAliasingLevel"]->intVal);
		antiAliasingLevel = configFile.root["antiAliasingLevel"]->intVal;
	}

	if(configFile.root["fullScreen"]) {
		fullScreen = configFile.root["fullScreen"]->boolVal;
		if(fullScreen) {
			printf("Full-screen: true\n");
		} else {
			printf("Full-screen: false\n");
		}
	}

	if(configFile.root["backgroundColor"]) {
		ObjectEntry *color = configFile.root["backgroundColor"];
		if((*color)["red"] && (*color)["green"] && (*color)["blue"]) {
			backgroundColorR = (*color)["red"]->NumberVal;
			backgroundColorG = (*color)["green"]->NumberVal;
			backgroundColorB = (*color)["blue"]->NumberVal;
			printf("Background color: %f %f %f\n", backgroundColorR, backgroundColorG, backgroundColorB);

		} else {
			printf("backgroundColor node specified, but missing all three color attributes (red,green,blue). Ignoring.\n");
		}
	}

	zipFile z = zipOpen(getArg("--out").c_str(), 0);
	

	Object runInfo;
	runInfo.root.name = "PolycodeApp";
	runInfo.root.addChild("entryPoint", entryPoint);
	runInfo.root.addChild("defaultHeight", defaultHeight);
	runInfo.root.addChild("defaultWidth", defaultWidth);
	runInfo.root.addChild("frameRate", frameRate);
	runInfo.root.addChild("antiAliasingLevel", antiAliasingLevel);
	runInfo.root.addChild("fullScreen", fullScreen);
	
	ObjectEntry *color = runInfo.root.addChild("backgroundColor");
	color->addChild("red", backgroundColorR);
	color->addChild("green", backgroundColorG);
	color->addChild("blue", backgroundColorB);

	addFileToZip(z, entryPoint, entryPoint, false);

	if(configFile.root["modules"]) {
#ifdef _WINDOWS
		String modulesPath = installPath + "Modules\\";
#else
		String modulesPath = installPath + "Modules/";
#endif

		ObjectEntry *modules = configFile.root["modules"];
		if(modules) {		
			for(int i=0; i < modules->length; i++) {
				printf("Adding module: %s\n", (*modules)[i]->stringVal.c_str());
				String modulePath = modulesPath + (*modules)[i]->stringVal;
#ifdef _WINDOWS
				String moduleAPIPath = modulePath + "\\API";
				String moduleLibPath = modulePath + "\\Lib";
				moduleAPIPath = moduleAPIPath.replace("\\", "/");
				moduleAPIPath = moduleAPIPath.substr(2, moduleAPIPath.length() - 2);	
				moduleLibPath = moduleLibPath.replace("\\", "/");
				moduleLibPath = moduleLibPath.substr(2, moduleLibPath.length() - 2);	

#else
				String moduleAPIPath = modulePath + "/API";
				String moduleLibPath = modulePath + "/Lib";
#endif
				printf("Path:%s\n", moduleAPIPath.c_str());		


				addFolderToZip(z, moduleAPIPath, "", false);
				addFolderToZip(z, moduleLibPath, "__lib", false);

				//String module = configFile.root["entryPoint"]->stringVal;
			}
			runInfo.root.addChild(configFile.root["modules"]);
		}
	}

	if(configFile.root["packedItems"]) {
		ObjectEntry *packed = configFile.root["packedItems"];
		if(packed) {
			for(int i=0; i < packed->length; i++) {
				ObjectEntry *entryPath = (*(*packed)[i])["path"];
				ObjectEntry *entryType = (*(*packed)[i])["type"];
				if(entryPath && entryType) {
					if(entryType->stringVal == "folder") {
						addFolderToZip(z, entryPath->stringVal, entryPath->stringVal, false);
					} else {
						addFileToZip(z, entryPath->stringVal, entryPath->stringVal, false);
					}
				}
			}
			runInfo.root.addChild(configFile.root["packedItems"]);
		}
	}


	runInfo.saveToXML("runinfo_tmp_zzzz.polyrun");
	addFileToZip(z, "runinfo_tmp_zzzz.polyrun", "runinfo.polyrun", true);

	//addFolderToZip(z, getArg("--project"), "");
	
	zipClose(z, "");	

	OSBasics::removeItem("runinfo_tmp_zzzz.polyrun");

	return 0;
}
예제 #4
0
   void VTune_RegisterMethod(AvmCore* core, JITCodeInfo* inf) 
   {       
		// assume no method inlining so start/end of JIT code gen = method start/end
       uintptr startAt = inf->startAddr;
       uintptr endAt = inf->endAddr;
		uint32 methodSize = endAt - startAt;

       Stringp name = inf->method->format(core);
       int idx[4];
       bool hasClass = locateNames(core, name, idx);

		// register the method
		iJIT_Method_Load ML;
       Stringp mname = name->substring(idx[2],idx[3]);
		VMPI_memset(&ML, 0, sizeof(iJIT_Method_Load));
       ML.method_id = (inf->vtune) ? inf->vtune->method_id : iJIT_GetNewMethodID();
       ML.method_name = string2char(core, mname);
		ML.method_load_address = (void *)startAt;	// virtual address of that method  - This determines the method range for the iJVM_EVENT_TYPE_ENTER/LEAVE_METHOD_ADDR events
		ML.method_size = methodSize;	// Size in memory - Must be exact

		// md position / line number table
       SortedIntMap<LineNumberRecord*>* tbl = &inf->lineNumTable;
		int size = tbl->size();
		LineNumberInfo* lines = 0;
		if (size)
		{
			int bsz = size*sizeof(LineNumberInfo);
			lines = (LineNumberInfo*) malloc(bsz);
			VMPI_memset(lines, 0, bsz);
		}

       String* fileName = 0;
       int at = 0;
       for(int i=0; i<size; i++) 
		{
			sintptr mdPos = tbl->keyAt(i);
			LineNumberRecord* entry = tbl->at(i);
           if (entry->filename && entry->lineno)
           {
               if (!fileName) fileName = entry->filename;

               // @todo file name should be part of the lines[] record, no?
               lines[at].LineNumber = entry->lineno;
               lines[at].Offset = mdPos - startAt;
               at++;
           }
       }

       // @todo hack for vtune since it can't process multiple records with the same method name 
       if (inf->sid>0 && at>0) {
           mname = core->concatStrings(mname,core->newString("_L"));
           mname = core->concatStrings(mname,core->intToString(lines[0].LineNumber));
           mname = core->concatStrings(mname,core->newString("_"));
           mname = core->concatStrings(mname,core->intToString(inf->sid));
           if (ML.method_name) free(ML.method_name);
           ML.method_name = string2char(core,mname);
       }

       ML.line_number_table = lines;   // Pointer to the begining of the line numbers info array
       ML.line_number_size = at;       // Line Table size in number of entries - Zero if none

       UTF8String* utf = ( fileName ) ? fileName->toUTF8String() : core->kEmptyString->toUTF8String();
		
		ML.class_id = 0;                // uniq class ID
       ML.class_file_name = (hasClass) ? string2char(core,name->substring(idx[0],idx[1])) : 0;     // class file name 
		ML.source_file_name = (char *)(malloc((utf->length()+3)*sizeof(char)));   // +1 for \0 and +2 for wtoc's ()
		wtoc(ML.source_file_name, utf->c_str(), 0);	// source file name 

		ML.user_data = NULL;            // bits supplied by the user for saving in the JIT file...
		ML.user_data_size = 0;          // the size of the user data buffer
		ML.env = iJDE_JittingAPI;

		// DumpVTuneMethodInfo(core, &ML); // Uncommented to debug VTune
		iJIT_NotifyEvent(iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED, &ML);

       if (inf->vtune && core->VTuneStatus == iJIT_CALLGRAPH_ON) 
		{
			MMgc::GCHeap* heap = core->GetGC()->GetGCHeap();
           heap->SetPageProtection(inf->vtune, sizeof (iJIT_Method_NIDS), false, true);   
       }

		// free everything we alloc'd  ( @todo did vtune really copy all the strings?!? )
		if (ML.line_number_table) free(ML.line_number_table);
       if (ML.class_file_name && hasClass) free(ML.class_file_name);
		if (ML.method_name) free(ML.method_name);
		if (ML.source_file_name) free(ML.source_file_name);
	}	
예제 #5
0
vector<OSFileEntry> OSBasics::parseFolder(String pathString, bool showHidden) {
	vector<OSFileEntry> returnVector;
	
	if(pathString.size() < 128) {
		if(PHYSFS_exists(pathString.c_str())) {
			if(PHYSFS_isDirectory(pathString.c_str())) {
				return parsePhysFSFolder(pathString, showHidden);
			}
		}
	}
	
	
#ifdef _WINDOWS

	WIN32_FIND_DATA findFileData;

	WCHAR curDir[4096];
	GetCurrentDirectory(4096, curDir);

	WCHAR tmp[4096];
	memset(tmp, 0, sizeof(WCHAR)*4096);
	ctow(tmp, pathString.c_str());
	SetCurrentDirectory(tmp);

	HANDLE hFind = FindFirstFile((LPCWSTR)"*", &findFileData);
	if(hFind  == INVALID_HANDLE_VALUE) {
		SetCurrentDirectory(curDir);
		return returnVector;
	}

	char fileName[260];
	do {		
		memset(fileName, 0, 260);
		wtoc(fileName, findFileData.cFileName);
		String fname = string(fileName);
		
		if((fname.c_str()[0] != '.' || (fname.c_str()[0] == '.'  && showHidden)) && fname != "..") {
			if( findFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) {
				returnVector.push_back(OSFileEntry(pathString, fname, OSFileEntry::TYPE_FOLDER));
			} else {
				returnVector.push_back(OSFileEntry(pathString, fname, OSFileEntry::TYPE_FILE));
			}
		}
    } while(FindNextFile(hFind, &findFileData));	
	FindClose(hFind);
	SetCurrentDirectory(curDir);
#else
	DIR           *d;
	struct dirent *dir;
	
	d = opendir(pathString.c_str());
	if(d) {
		while ((dir = readdir(d)) != NULL) {
			if(dir->d_name[0] != '.' || (dir->d_name[0] == '.'  && showHidden)) {
				if(dir->d_type == DT_DIR) {
					returnVector.push_back(OSFileEntry(pathString, dir->d_name, OSFileEntry::TYPE_FOLDER));
				} else {
					returnVector.push_back(OSFileEntry(pathString, dir->d_name, OSFileEntry::TYPE_FILE));
				}
			}
		}
		closedir(d);
	}
	
#endif
		
	return returnVector;
}
예제 #6
0
int ndisk_dir(Dictionary *dict, const NDiskEntry *entry, NDisk *disk, const wchar_t *path) {
    WIN32_FIND_DATAW fData;
    char *tmp = NULL, *sTmp = NULL;
    wchar_t *pTmp = NULL;
    unsigned long size = 0;
    int i = 0;
    SYSTEMTIME time;
    lua_reset();
    lua_getglobal(script, "entries");
    tmp = wtoc(entry->name);
    lua_getfield(script, -1, tmp);
    free(tmp);
    tmp = NULL;
    i = lua_gettop(script);
    if(lua_pcall(script, 0, 0, 0)) {
        OutputDebugStringA("Error Msg is: ");
        OutputDebugStringA(lua_tostring(script, -1));
    }
    lua_pop(script, 1);
    lua_getglobal(script, "dir");
    if(!lua_isfunction(script, -1)) {
        RequestProcW(PluginNumber, RT_MsgOK, L"ÅäÖôíÎó", L"ÍøÅ̽ű¾´íÎó, ²»ÄܶÁÈ¡µ±Ç°Ä¿Â¼µÄÄÚÈÝ. ", NULL, 0);
        return NDISK_FATAL;
    }
    if(ndisk_lua_push(script, disk) == NDISK_FATAL) {
        lua_settop(script, 0);
        return NDISK_FATAL;
    }
    tmp = wtoc(path);
    lua_pushstring(script, tmp);
    free(tmp);
    tmp = NULL;
    lua_setfield(script, -2, "path");
    if(lua_pcall(script, 1, 1, 0)) {
        OutputDebugStringA("Error Msg is: ");
        OutputDebugStringA(lua_tostring(script, -1));
    }

    if(lua_istable(script, -1)) {
        lua_pushnil(script);
        while (lua_next(script, -2)) {
            if(lua_istable(script, -1)) {
                memset(&fData, 0, sizeof(WIN32_FIND_DATAW));
                lua_pushnil(script);
                while(lua_next(script, -2)) {
                    tmp = (char *)lua_tostring(script, -2);
                    if(strcmp(tmp, "attribute") == 0) {
                        sTmp = (char *)lua_tostring(script, -1);
                        if(strcmp(sTmp, "file") == 0) {
                            fData.dwFileAttributes = FILE_ATTRIBUTE_NORMAL;
                        }
                        if(strcmp(sTmp, "directory") == 0) {
                            fData.dwFileAttributes = FILE_ATTRIBUTE_DIRECTORY;
                        }
                    }
                    if(strcmp(tmp, "filename") == 0) {
                        sTmp = (char *)lua_tostring(script, -1);
                        pTmp = ctow(sTmp);
                        wcslcpy(fData.cFileName, pTmp, PATH_MAX);
                        free(pTmp);
                        pTmp = NULL;
                    }
                    if(strcmp(tmp, "size") == 0) {
                        size = (unsigned long)lua_tonumber(script, -1);
                        fData.nFileSizeHigh = HIWORD(size);
                        fData.nFileSizeLow = LOWORD(size);
                    }
                    if(strcmp(tmp, "create") == 0) {
                        sTmp = (char *)lua_tostring(script, -1);
                        pTmp = ctow(sTmp);
                        memset(&time, 0, sizeof(SYSTEMTIME));
                        if(strtotime(pTmp, &time)) {
                            SystemTimeToFileTime(&time, &fData.ftCreationTime);
                        }
                        free(pTmp);
                        pTmp = NULL;
                    }
                    if(strcmp(tmp, "access") == 0) {
                        sTmp = (char *)lua_tostring(script, -1);
                        pTmp = ctow(sTmp);
                        memset(&time, 0, sizeof(SYSTEMTIME));
                        if(strtotime(pTmp, &time)) {
                            SystemTimeToFileTime(&time, &fData.ftLastAccessTime);
                        }
                        free(pTmp);
                        pTmp = NULL;
                    }
                    if(strcmp(tmp, "write") == 0) {
                        sTmp = (char *)lua_tostring(script, -1);
                        pTmp = ctow(sTmp);
                        memset(&time, 0, sizeof(SYSTEMTIME));
                        if(strtotime(pTmp, &time)) {
                            SystemTimeToFileTime(&time, &fData.ftLastWriteTime);
                        }
                        free(pTmp);
                        pTmp = NULL;
                    }
                    lua_pop(script, 1);
                }
                if(fData.cFileName) {
                    dict_set_element(dict, fData.cFileName, &fData, sizeof(WIN32_FIND_DATAW));
                }
            }
            lua_pop(script, 1);
        }
    }
    lua_pop(script, 1);
    return NDISK_OK;
}
예제 #7
0
BOOL APIENTRY DllMain(HANDLE hModule, DWORD  ul_reason_for_call, LPVOID lpReserved) {
    int i = 0;
    WIN32_FIND_DATAW fData;
    wchar_t tmp[PATH_MAX];
    char *sTmp;
    HANDLE fHandle = NULL;
    lua_State *lua = NULL;
    NDiskEntry *pEntry = NULL;
    
    if (ul_reason_for_call == DLL_PROCESS_ATTACH) {
        hInst = hModule;
        // init
        GetModuleFileNameW((HMODULE)hInst, my_dir, MAX_PATH);
        i = MAX_PATH;
        while (my_dir[--i] != '\\') {
            my_dir[i] = '\0';
        }
        wcslcpy(tmp, my_dir, PATH_MAX);
        wcscat_s(tmp, PATH_MAX, L"entries\\*.lua");
        fHandle = FindFirstFileW(tmp, &fData);
        i = 0;

        script = luaL_newstate();
        luaL_openlibs(script);
        wcslcpy(tmp, my_dir, PATH_MAX);
        wcscat_s(tmp, PATH_MAX, L"?.lua");
        sTmp = wtoc(tmp);
        lua_getglobal(script, "package");
        lua_pushstring(script, sTmp);
        lua_setfield(script, -2, "path");
        lua_pop(script, 1);
        free(sTmp);
        sTmp = NULL;
        lua_getglobal(script, "require");
        lua_pushstring(script, "Json");
        lua_call(script, 1, 1);
        lua_setglobal(script, "json");
        lua_register(script, "http", wp_http);
        lua_register(script, "expl", wp_explorer);
        lua_register(script, "savt", wp_savt);
        //lua_register(script, "utoc", wp_utoc);
        lua_newtable(script);

        if(fHandle != INVALID_HANDLE_VALUE) {
            do {
                lua_reset();
                wcslcpy(tmp, my_dir, PATH_MAX);
                wcscat_s(tmp, PATH_MAX, L"entries\\");
                wcscat_s(tmp, PATH_MAX, fData.cFileName);
                sTmp = wtoc(tmp);
                if(luaL_loadfile(script, sTmp)) {
                    free(sTmp);
                    sTmp = NULL;
                    OutputDebugStringA("Error Msg is: ");
                    OutputDebugStringA(lua_tostring(script,-1));
                    continue;
                }
                free(sTmp);
                sTmp = NULL;
                _wsplitpath_s(fData.cFileName, NULL, 0, NULL, 0, (wchar_t *)&tmp, PATH_MAX, NULL, 0);
                sTmp = wtoc(tmp);
                lua_setfield(script, -2, sTmp);
                lua_getfield(script, -1, sTmp);
                free(sTmp);
                sTmp = NULL;
                if(lua_pcall(script, 0, 0, 0)) {
                    OutputDebugStringA("Error Msg is: ");
                    OutputDebugStringA(lua_tostring(script,-1));
                    continue;
                }
                lua_getglobal(script, "signin");
                if(!lua_isstring(script, -1)) {
                    lua_pop(script, 1);
                    continue;
                }
                lua_getglobal(script, "description");
                if(!lua_isstring(script, -1)) {
                    lua_pop(script, 1);
                    continue;
                }

                if(available_disk_entries == NULL) {
                    available_disk_entries = (NDiskEntry *)malloc(sizeof(NDiskEntry));
                } else {
                    pEntry = (NDiskEntry *)realloc(available_disk_entries, (i + 1) * sizeof(NDiskEntry));
                    if(pEntry != available_disk_entries) {
                        available_disk_entries = pEntry;
                    }
                }
                available_disk_entries[i].name = _wcsdup(tmp);
                available_disk_entries[i].signin = ctow(lua_tostring(script, -2));
                available_disk_entries[i].description = ctow(lua_tostring(script, -1));
                lua_pop(script, 2);

                i++;
            } while (FindNextFileW(fHandle, &fData));
        }
        lua_setglobal(script, "entries");
        available_disk_entries_length = i;
        available_disks = dict_initialize();
        ndisks_load();
        OleInitialize(0);
    }
    if(ul_reason_for_call == DLL_PROCESS_DETACH) {
        // destory
        lua_close(script);
        script = NULL;
        if(available_disk_entries != NULL) {
            for(i = 0; i < available_disk_entries_length; i++) {
                free(available_disk_entries[i].name);
                free(available_disk_entries[i].description);
                free(available_disk_entries[i].signin);
            }
        }
        if(available_disks != NULL) {
            dict_destroy(&available_disks);
        }
        OleUninitialize();
    }
    return TRUE;
}
예제 #8
0
파일: ENLang.cpp 프로젝트: vova98/Isengreem
int _tmain(int argc, _TCHAR* argv[])
{
	if (!strcmp(wtoc(argv[1]), "-help"))
	{
		PrintHelp();
		system("pause");
		return 0;
	}
	//char* buffer = ReadFile(L"tempLang.txt");
	char* buffer = ReadFile(argv[1]);
	if (buffer == NULL) { printf("NO FILE!!"); return 1; }
	int countOfLexem = 0;
	lex* lexic = Lexer(buffer, &countOfLexem);

	errno_t err1 = fopen_s(&Fdotty, "E:\\C++\\Derivative\\Derivative\\dumpTree.gv", "w");
	fprintf(Fdotty, "graph graphname {");

	errno_t err2 = fopen_s(&ftrans, "FileForASM.txt", "w");

	for (int i = 0; i < countOfLexem; i++)
	{
		printf("lexem number %d :\n"
			"value <%s>\n"
			"type <%d>\n"
			"current pos <%s>\n\n", i, lexic[i].val, lexic[i].type, lexic[i].pos);
	}

	Var.vars = new char*[COUNTOFREGISTER];

	node* top = GetG0(lexic);
	if (!top) printf("SYNTAX ERROR!!!\n"
		"at this symbol %s \n", s->pos);
	s++;
	node* funcTop = GetG0(s);
	node* Main = new node;
	NODECTOR(Main, "main", T_op, top, funcTop);
	if (!top) printf("SYNTAX ERROR!!!\n"
		"at this symbol %s \n", s->pos);
	int count = 0;
	PrintTree(Main, &count);

	FILE* fout = NULL;
	errno_t err = fopen_s(&fout, "Expression.txt", "w");
	Print(Main, fout);
	DottyTree(Main);
	int countOfJump = 0, pop = 0, flag = 0;
	Translate(Main, countOfJump, &pop, flag);
	//fprintf(ftrans, "end");
	//reg regis = {};

	fprintf(Fdotty,"}");
	fclose(Fdotty);
	fclose(ftrans);
	/////////////////////////////////////////////////
	//char* FROM = "C:\\Users\\Vladimir\\Documents\\Visual Studio 2013\\Projects\\ENLang\Debug"

	/////////////////////////////////////////////////
	system("E:\\C++\\Graphviz2.38\\bin\\dotty.exe E:\\C++\\Derivative\\Derivative\\dumpTree.gv");
	system("pause");

	return 0;
}