int CompileWork::DoWork(const char *recvbuf, const int recvlen, string &sendbuf, int &sendlen) { cout << "\n\n" << recvbuf << "\n\n"; MyLogInstance->WriteLog(recvbuf); responseHttp->Init(); requestHttp->Parse(recvbuf); string path = requestHttp->GetPath(); int endpos = path.rfind("/"); string cmp = string(path,endpos+1); if(cmp == "compile") { DoCompile(sendbuf); //responseHttp->SetMsgHead("Content-Type","text/html; charset=GB2312"); //responseHttp->SetMsgBody("<font color='red'>不和你玩了,我要休息了 ^_^</br>可加入 qq群讨论:233718417</font"); //sendbuf = responseHttp->ResponseContent(); return RT_OK; } else if(cmp == "tb") { responseHttp->SetStatus("302 "); responseHttp->SetMsgHead("Location", "http://www.taobao.com"); responseHttp->SetMsgBody(""); sendbuf = responseHttp->ResponseContent(); return RT_OK; } ResponseStaticPage(sendbuf); return RT_OK; }
void InvokeCompile( void ) { InitMacros(); ComRead(); // pre-read must occur here in case of null program if( ProgSw & PS_SOURCE_EOF ) { Conclude(); } else { DoCompile(); } FiniMacros(); }
int C_DECL main(int argc, char* argv[]) { { // One time init InitResources(); glslang::InitializeProcess(); spv::Parameterize(); } const char* File = ReadFileData(argv[1]); DoCompile(File); glslang::FinalizeProcess(); return 0; }
//=========================================================================== // Compile //=========================================================================== void Compile(char *fileName) { FILE *file; int length; // Try to first open the file "as is". strcpy(sourceFileName, fileName); if((file = fopen(sourceFileName, "rb")) == NULL) { // OK, what about adding an extension? strcat(sourceFileName, ".tx"); if((file = fopen(sourceFileName, "rb")) == NULL) { perror(fileName); return; } } printf("Compiling %s...\n", sourceFileName); // Load in the defs. fseek(file, 0, SEEK_END); length = ftell(file); rewind(file); sourcePos = source = new unsigned char[length + 1]; if(!fread(source, length, 1, file)) { perror(fileName); return; } source[length] = 0; fclose(file); // Let's compile it! InitCompiler(); if(!DoCompile()) { printf("Compilation of %s was aborted!\n", sourceFileName); } CloseCompiler(); // Free the buffer, we don't need it any more. delete [] source; }
int main(int argc, char* argv[]) { int l; char *s; clock_t start; start = clock(); message(0,"Nintendo NES High Level Assembler"); message(0,"Version %s, %s",SZ_VERSION,SZ_BUILD_DATE); message(0,"By Brian Provinciano :: http://www.bripro.com"); message(0,""); if(argc < 1) return 3; s = argv[0]; if(strlen(s) > 0) { strcpy(szprogdir,argv[0]); l = strlen(szprogdir)-1; s = szprogdir+l; while(l>0) { if(*s == '/' || *s == '\\') { *s = '\0'; break; } s--; } } else { if(!getcwd(szprogdir, sizeof(szprogdir)-1)) return 3; } l = strlen(szprogdir); if(l && szprogdir[l-1]!='/') { szprogdir[l] = '/'; szprogdir[l+1] = '\0'; } if(!InitConfig()) return 4; ParseCommandLine(argc, argv); sysDirList = includeDirList = libDirList = NULL; l = strlen(szoutdir); if(l && szoutdir[l-1]!='/') { szoutdir[l] = '/'; szoutdir[l+1] = '\0'; } strcpy(outDir,szoutdir); sprintf(szTemp,"%s",szprogdir); AddDirList(&sysDirList, szTemp); sprintf(szTemp,"%sinclude/",szprogdir); printf("Standard includes: %s\n", szTemp); AddDirList(&includeDirList, szTemp); sprintf(szTemp,"%slib/",szprogdir); printf("Standard libs: %s\n", szTemp); AddDirList(&libDirList, szTemp); if(InitializeCompiler()) { message(0,"Compiling file: %s ... \n", szfilename); DoCompile(szfilename); } { float fl = (float)(clock() - start) / CLOCKS_PER_SEC; printf("Compilation time: %f seconds.\n", fl); } if(COMPILE_SUCCESS) { ShutDownCompiler(); PrintTime(); message(MSG_COMPSUCCESS); //if(warnCnt) // getch(); } else // automatically shuts down fatal(FTL_COMPFAIL); message(0,""); return 0; }