void Manager(FILE *file, int count) { char MenuNum; while (1) { MenuView(); MenuNum = getch(); puts(""); switch (MenuNum) { case '1': InputStudent(file, count); break; case '2': ModifyStudent(file, count); break; case '3': DeleteStudent(file, count); break; case '4': PrintStudent(file, count); break; case '5': FilePrint(file, count); break; case '6': exit(1); default: printf("잘못된 입력 입니다!\n"); printf("다시 입력해주세요\n"); } } }
void Log::LogPrint(LogType type, const char* msg) { if (config.logConsole) ConsolePrint(type, msg); if (config.logSyslog) SyslogPrint(type, msg); if (config.logFile) FilePrint(type, msg); }
static bool pcl_verify_otter(ClauseSet_p problem,char *executable, long time_limit) { bool res; DStr_p command = DStrAlloc(); char* name=TempFileName(); FILE* problemfile; if(!executable) { executable=OTTER_EXEC_DEFAULT; } problemfile = OutOpen(name); fprintf(problemfile, "set(prolog_style_variables).\n" "clear(print_kept).\n" "clear(print_new_demod).\n" "clear(print_back_demod).\n" "clear(print_back_sub).\n" "set(auto).\n" "set(input_sos_first).\n" /* "set(para_from_vars).\n" */ "assign(max_seconds, %ld).\n\n" "assign(max_mem, 100000).\n\n" "list(usable).\n\n" "equal(X,X).\n",time_limit); clause_set_print_otter(problemfile, problem); fprintf(problemfile, "end_of_list.\n"); OutClose(problemfile); DStrAppendStr(command, executable); DStrAppendStr(command, " < "); DStrAppendStr(command, name); DStrAppendStr(command, " 2> /dev/null"); res = pcl_run_prover(DStrView(command), "-------- PROOF --------"); if(!res) { fprintf(GlobalOut, "# ------------Problem begin--------------\n"); FilePrint(GlobalOut, name); fprintf(GlobalOut, "# ------------Problem end----------------\n"); } TempFileRemove(name); FREE(name); DStrFree(command); return res; }
void main(){ char * SearchMsg[] = { "찾기성공", "삭제 등록된 데이터가 없습니다.", "찾으려는 데이터가 존재하지 않습니다." }; char * ChangeMsg[] = { "수정성공", "등록된 데이터가 없습니다.", "찾으려는 데이터가 존재하지 않습니다." }; char * DeleteMsg[] = { "삭제성공", "삭제 등록된 데이터가 없습니다.", "찾으려는 데이터가 존재하지 않습니다." }; ISBN * BookArray = {}; char mode = '1'; int TotalBook=10; int BookNum = 0; BookArray = (ISBN *)malloc(sizeof(ISBN)* 1); while (mode != '0'){ printf("\nmode 선택 ( 1 = 입력 , 2 = 출력 , 3 = 단일검색, 4 = 수정(정확한 이름), 5 = 단일삭제(정확한 이름), 6 = 파일저장, 7 = 파일로드 0 = 종료) \n"); mode = getchar(); fflush(stdin); switch (mode) { case '1': AddBook(BookArray, &BookNum, TotalBook); break; case '2': PrintBookList(BookArray, BookNum); break; case '3': SearchBook(BookArray, BookNum, SearchMsg); break; case '4': ChangeBook(BookArray, BookNum, SearchMsg, ChangeMsg); break; case '5': DeleteBook(BookArray, &BookNum, DeleteMsg); break; case '6': FilePrint(BookArray, TotalBook, BookNum); break; case '7': FileScan(BookArray, &TotalBook, &BookNum); break; default: mode = '0'; for (int i= 0; i < TotalBook;i++) KillData(&BookArray[i]); break; } } }
static bool pcl_verify_spass(ClauseSet_p problem,char *executable, long time_limit, Sig_p sig) { bool res; DStr_p command = DStrAlloc(); char* name=TempFileName(); FILE* problemfile; if(!executable) { executable=SPASS_EXEC_DEFAULT; } problemfile = OutOpen(name); fprintf(problemfile, "begin_problem(Unknown).\n"); sig_print_dfg(problemfile, problem, sig); fprintf(problemfile, "list_of_clauses(axioms,cnf).\n"); clause_set_print_dfg(problemfile, problem); fprintf(problemfile, "end_of_list.\n" "list_of_settings(SPASS).\n" "set_flag(TimeLimit, %ld).\n" "end_of_list.\n" "end_problem.\n", time_limit); OutClose(problemfile); DStrAppendStr(command, executable); DStrAppendStr(command, " "); DStrAppendStr(command, name); res = pcl_run_prover(DStrView(command), "Proof found."); if(!res) { fprintf(GlobalOut, "# ------------Problem begin--------------\n"); FilePrint(GlobalOut, name); fprintf(GlobalOut, "# ------------Problem end----------------\n"); } TempFileRemove(name); FREE(name); DStrFree(command); return res; }
static bool pcl_verify_eprover(ClauseSet_p problem,char *executable, long time_limit) { bool res; DStr_p command = DStrAlloc(); char* name=TempFileName(); FILE* problemfile; assert(OutputFormat == TPTPFormat); if(!executable) { executable=E_EXEC_DEFAULT; } problemfile = OutOpen(name); ClauseSetPrint(problemfile, problem, true); OutClose(problemfile); DStrAppendStr(command, executable); DStrAppendStr(command, " --tptp-in --prefer-initial-clauses --ac-handling=None" " --cpu-limit="); DStrAppendInt(command, time_limit); DStrAppendChar(command, ' '); DStrAppendStr(command, name); res = pcl_run_prover(DStrView(command),"# Proof found!"); if(!res) { fprintf(GlobalOut, "# ------------Problem begin--------------\n"); FilePrint(GlobalOut, name); fprintf(GlobalOut, "# ------------Problem end----------------\n"); } TempFileRemove(name); FREE(name); DStrFree(command); return res; }
int main(int argc, char** argv) { #ifdef _DEBUG _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); // _crtBreakAlloc = 2025; #endif srand(time(NULL)); for (int logs = 0; logs < EQEMuLog::MaxLogID; logs++) { LogFile->write((EQEMuLog::LogIDs)logs, "CURRENT_ZONE_VERSION: %s", CURRENT_ZONE_VERSION); } if (argc != 5) { cerr << "Usage: zone zone_name address port worldaddress" << endl; exit(0); } char* filename = argv[0]; char* zone_name = argv[1]; char* address = argv[2]; int32 port = atoi(argv[3]); char* worldaddress = argv[4]; if (strlen(address) <= 0) { cerr << "Invalid address" << endl; exit(0); } if (port <= 0) { cerr << "Bad port specified" << endl; exit(0); } if (strlen(worldaddress) <= 0) { cerr << "Invalid worldaddress" << endl; exit(0); } if (signal(SIGINT, CatchSignal) == SIG_ERR) { cerr << "Could not set signal handler" << endl; return 0; } #ifndef WIN32 if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) { cerr << "Could not set signal handler" << endl; return 0; } #endif net.SaveInfo(address, port, worldaddress,filename); LogFile->write(EQEMuLog::Status, "Loading Variables"); database.LoadVariables(); LogFile->write(EQEMuLog::Status, "Loading zone names"); database.LoadZoneNames(); LogFile->write(EQEMuLog::Status, "Loading items"); if (!database.LoadItems()) { LogFile->write(EQEMuLog::Error, "Loading items FAILED!"); cout << "Failed. But ignoring error and going on..." << endl; } LogFile->write(EQEMuLog::Status, "Loading npcs"); if (!database.LoadNPCTypes()) { LogFile->write(EQEMuLog::Error, "Loading npcs FAILED!"); CheckEQEMuErrorAndPause(); return 0; } #ifdef SHAREMEM LogFile->write(EQEMuLog::Status, "Loading npc faction lists"); if (!database.LoadNPCFactionLists()) { LogFile->write(EQEMuLog::Error, "Loading npcs faction lists FAILED!"); CheckEQEMuErrorAndPause(); return 0; } #endif LogFile->write(EQEMuLog::Status, "Loading loot tables"); if (!database.LoadLoot()) { LogFile->write(EQEMuLog::Error, "Loading loot FAILED!"); CheckEQEMuErrorAndPause(); return 0; } #ifdef SHAREMEM LogFile->write(EQEMuLog::Status, "Loading doors"); database.LoadDoors(); #endif LoadSPDat(); #ifdef GUILDWARS LogFile->write(EQEMuLog::Status, "Loading guild alliances"); //database.LoadGuildAlliances(); #endif // New Load function. keeping it commented till I figure out why its not working correctly in linux. Trump. // NewLoadSPDat(); LogFile->write(EQEMuLog::Status, "Loading guilds"); database.LoadGuilds(guilds); LogFile->write(EQEMuLog::Status, "Loading factions"); database.LoadFactionData(); LogFile->write(EQEMuLog::Status, "Loading corpse timers"); database.GetDecayTimes(npcCorpseDecayTimes); LogFile->write(EQEMuLog::Status, "Loading what ever is left"); database.ExtraOptions(); AutoDelete<Parser> ADparse(&parse, new Parser); #ifdef ADDONCMD LogFile->write(EQEMuLog::Status, "Looding addon commands from dll"); if ( !addonCmd.openLib() ) { LogFile->write(EQEMuLog::Error, "Loading addons failed =("); } #endif if (!worldserver.Connect()) { LogFile->write(EQEMuLog::Error, "worldserver.Connect() FAILED!"); } if (strcmp(zone_name, ".") == 0 || strcasecmp(zone_name, "sleep") == 0) { LogFile->write(EQEMuLog::Status, "Entering sleep mode"); } else if (!Zone::Bootup(database.GetZoneID(zone_name), true)) { LogFile->write(EQEMuLog::Error, "Zone bootup FAILED!"); zone = 0; } Timer InterserverTimer(INTERSERVER_TIMER); // does MySQL pings and auto-reconnect UpdateWindowTitle(); bool worldwasconnected = worldserver.Connected(); EQNetworkConnection* eqnc; while(RunLoops) { Timer::SetCurrentTime(); while ((eqnc = eqns.NewQueuePop())) { struct in_addr in; in.s_addr = eqnc->GetrIP(); LogFile->write(EQEMuLog::Status, "%i New client from ip:%s port:%i", Timer::GetCurrentTime(), inet_ntoa(in), ntohs(eqnc->GetrPort())); Client* client = new Client(eqnc); entity_list.AddClient(client); } #ifdef CATCH_CRASH try{ #endif worldserver.Process(); #ifdef CATCH_CRASH } catch(...){ error = 1; adverrornum = worldserver.GetErrorNumber(); worldserver.Disconnect(); worldwasconnected = false; } #endif if (worldserver.Connected()) { worldwasconnected = true; } else { if (worldwasconnected && ZoneLoaded) entity_list.ChannelMessageFromWorld(0, 0, 6, 0, 0, "WARNING: World server connection lost"); worldwasconnected = false; } if (ZoneLoaded) { { #ifdef CATCH_CRASH try{ #endif entity_list.Process(); #ifdef CATCH_CRASH } catch(...){ error = 4; } try{ #endif zoneprocess= zone->Process(); if (!zoneprocess) { Zone::Shutdown(); } #ifdef CATCH_CRASH } catch(...){ error = 2; } #endif } } DBAsyncWork* dbaw = 0; while ((dbaw = MTdbafq->Pop())) { DispatchFinishedDBAsync(dbaw); } if (InterserverTimer.Check() #ifdef CATCH_CRASH && !error #endif ) { #ifdef CATCH_CRASH try{ #endif InterserverTimer.Start(); database.ping(); AsyncLoadVariables(); // NPC::GetAILevel(true); entity_list.UpdateWho(); if (worldserver.TryReconnect() && (!worldserver.Connected())) worldserver.AsyncConnect(); #ifdef CATCH_CRASH } catch(...) { error = 16; RunLoops = false; } #endif } #ifdef CATCH_CRASH if (error){ RunLoops = false; } #endif #if defined(_DEBUG) && defined(DEBUG_PC) QueryPerformanceCounter(&tmp3); mainloop_time += tmp3.QuadPart - tmp2.QuadPart; if (!--tmp0) { tmp0 = 200; printf("Elapsed Tics : %9.0f (%1.4f sec)\n", (double)mainloop_time, ((double)mainloop_time/tmp.QuadPart)); printf("NPCAI Tics : %9.0f (%1.2f%%)\n", (double)npcai_time, ((double)npcai_time/mainloop_time)*100); printf("FindSpell Tics: %9.0f (%1.2f%%)\n", (double)findspell_time, ((double)findspell_time/mainloop_time)*100); printf("AtkAllowd Tics: %9.0f (%1.2f%%)\n", (double)IsAttackAllowed_time, ((double)IsAttackAllowed_time/mainloop_time)*100); printf("ClientPro Tics: %9.0f (%1.2f%%)\n", (double)clientprocess_time, ((double)clientprocess_time/mainloop_time)*100); printf("ClientAtk Tics: %9.0f (%1.2f%%)\n", (double)clientattack_time, ((double)clientattack_time/mainloop_time)*100); mainloop_time = 0; npcai_time = 0; findspell_time = 0; IsAttackAllowed_time = 0; clientprocess_time = 0; clientattack_time = 0; } #endif Sleep(1); } #ifdef CATCH_CRASH if (error) FilePrint("eqemudebug.log",true,true,"Zone %i crashed. Errorcode: %i/%i. Current zone loaded:%s. Current clients:%i. Caused by: %s",net.GetZonePort(), error,adverrornum, zone->GetShortName(), numclients,errorname); try{ entity_list.Message(0, 15, "ZONEWIDE_MESSAGE: This zone caused a fatal error and will shut down now. Your character will be restored to the last saved status. We are sorry for any inconvenience!"); } catch(...){} if (error){ #ifdef WIN32 ExitProcess(error); #else entity_list.Clear(); safe_delete(zone); #endif } #endif entity_list.Clear(); if (zone != 0 #ifdef CATCH_CRASH & !error #endif ) Zone::Shutdown(true); //Fix for Linux world server problem. eqns.Close(); worldserver.Disconnect(); dbasync->CommitWrites(); dbasync->StopThread(); #ifdef NEW_LoadSPDat safe_delete(spells_delete); #endif CheckEQEMuErrorAndPause(); return 0; }