void parse_header (header the_header, register char *where) { register header old = the_header; do { char *field; register char *keyword = get_keyword (the_header->text->string, &field); if (strcmp (keyword, "TO") == 0) where = add_field (the_header->text->continuation, field, where); else if (strcmp (keyword, "CC") == 0) where = add_field (the_header->text->continuation, field, where); else if (strcmp (keyword, "BCC") == 0) { where = add_field (the_header->text->continuation, field, where); the_header->previous->next = the_header->next; the_header->next->previous = the_header->previous; } else if (strcmp (keyword, "FCC") == 0) setup_files (the_header->text->continuation, field); the_header = the_header->next; } while (the_header != old); *where = '\0'; return; }
void init_vc( int argc, char *argv[] ) /* The first part of initialisation involves sorting out the arguments, and assigning standard input and standard output files as explained in decode_args and setup_files below. The rest involves setting various system wide variables to sensible values and clearing down the symbol table. Small constants are so common we put them in the symbol table first and record their addresses in a table. We do this for the integers 0 to COUNT_MAX - 1. This will permit us efficient access to them throughout the compiler. We record the entry labels for the library routines. We happen to know from inspection of the library code that the entry point to PRINTN is L2 and to PRINTS is L4. If we rewrite the library then we may have to change these. This is really rather clumsy, and at the very least ought to be put in a single table somewhere. Note that earlier we set the first label to be used to L10, permitting the use of labels up to L9 for library use. */ { int i ; /* General counter */ char *ifile ; /* Input file */ char *ofile ; /* Output file */ /* Decode the arguments, and setup stdin and stdout accordingly */ ofile = decode_args( argc, argv ) ; ifile = argv[1] ; /* Do after decode has checked argument is OK */ setup_files( ifile, ofile ) ; /* Give values to global variables */ symb_list = NULL ; /* Freelists */ enode_list = NULL ; errors_found = FALSE ; /* No errors found yet */ next_tmp = 0 ; /* No temporaries used */ next_label = LAB_MIN ; /* 10 labels reserved */ for( i = 0 ; i < HASHSIZE ; i++ ) /* Clear symbol table */ symbtab[i] = NULL ; for( i = 0 ; i < CONST_MAX ; i++ ) /* Make constants */ { SYMB *c = get_symb() ; /* Node for the constant */ c->type = T_INT ; c->VAL1 = i ; const_tab[i] = c ; } library[LIB_PRINTN] = mktac( TAC_LABEL, mklabel( 2 ), NULL, NULL ) ; library[LIB_PRINTS] = mktac( TAC_LABEL, mklabel( 4 ), NULL, NULL ) ; } /* void init_vc( void ) */
void Console::after_exec(STATE) { setup_files(state); start_threads(state); }
void Console::start(STATE) { initialize(state); setup_files(state); start_threads(state); }
void baseline_catalog(char *sensor, char *beam_mode, char *input_dir, char *output_dir) { struct dirent *dp; DIR *dir; FILE *fpTxt, *fpKml, *fpShape, *fpDB; int track, nOrbits, nFrames, nPairs, nTracks, orbit=0; report_level_t report = REPORT_LEVEL_STATUS; struct base_pair *base_pairs=NULL; struct srf_orbit *srf_orbit=NULL; char cmd[255], tmp_dir[1024], track_list[1024]; // Some more error checking on beam modes if (strcmp_case(sensor, "R1") == 0) { if (strcmp_case(beam_mode, "FN1") != 0 && strcmp_case(beam_mode, "FN2") != 0 && strcmp_case(beam_mode, "FN3") != 0 && strcmp_case(beam_mode, "FN4") != 0 && strcmp_case(beam_mode, "FN5") != 0 && strcmp_case(beam_mode, "ST1") != 0 && strcmp_case(beam_mode, "ST2") != 0 && strcmp_case(beam_mode, "ST3") != 0 && strcmp_case(beam_mode, "ST4") != 0 && strcmp_case(beam_mode, "ST5") != 0 && strcmp_case(beam_mode, "ST6") != 0 && strcmp_case(beam_mode, "ST7") != 0) asfPrintError("Unknown beam mode '%s' for sensor '%s'.\n", beam_mode, sensor); } else if ((strcmp_case(sensor, "E1") == 0 || strcmp_case(sensor, "E2") == 0) && strcmp_case(beam_mode, "STD") != 0) asfPrintError("Unknown beam mode '%s' for sensor '%s'.\n", beam_mode, sensor); else if (strcmp_case(sensor, "J1") == 0 && strcmp_case(beam_mode, "STD") != 0) asfPrintError("Unknown beam mode '%s' for sensor '%s'.\n", beam_mode, sensor); else if (strcmp_case(sensor, "PALSAR") == 0 && strcmp_case(beam_mode, "PLR") != 0) asfPrintError("Unknown beam mode '%s' for sensor '%s'.\n", beam_mode, sensor); // Report what is going on asfReport(report, "Calculating baseline catalog for satellite '%s' in " "beam mode '%s'\n\n", sensor, beam_mode); // Create temporary directory for list files sprintf(tmp_dir, "%s/%s", output_dir, time_stamp_dir()); create_clean_dir(tmp_dir); // Setup the baseline calculation setup_files(sensor, beam_mode, input_dir, tmp_dir, &nTracks, &nFrames); // Step through the archive track by track - save plenty of memory for (track=0; track<nTracks; track++) { asfPrintStatus("\nTrack: %d (out of %d)\n", track+1, nTracks); nOrbits = 0; nPairs = 0; // Get a list of recent SRFs if (strcmp(sensor, "PSR") == 0) asfPrintStatus("Reading metadata file ...\n"); else asfPrintStatus("Reading SRFs ...\n"); sprintf(track_list, "%s/%s_track%d.lst", tmp_dir, sensor, track); if (fileExists(track_list)) { if (strcmp(sensor, "PSR") == 0) read_palsar(track_list, &srf_orbit, &nOrbits); else read_srf(input_dir, track_list, &srf_orbit, &nOrbits); } else continue; // Determine baselines if (nOrbits) { asfPrintStatus("Determining baselines ...\n"); determine_baseline(sensor, sensor, beam_mode, track, orbit, srf_orbit, nOrbits, &base_pairs, &nPairs); } // Generate products if (nPairs) { asfPrintStatus("Generate products ...\n"); generate_products(output_dir, base_pairs, nPairs); } // Clean up before last track if (srf_orbit) FREE(srf_orbit); if (base_pairs) FREE(base_pairs); srf_orbit = NULL; base_pairs = NULL; //exit(0); } // Pack text, KML and shape files for entire mode chdir(output_dir); fpTxt = FOPEN("txt.lst", "w"); fpKml = FOPEN("kml.lst", "w"); fpShape = FOPEN("shape.lst", "w"); fpDB = FOPEN("db.lst", "w"); dir = opendir(output_dir); while ((dp = readdir(dir)) != NULL) { if (strstr(dp->d_name, ".txt")) fprintf(fpTxt, "%s\n", dp->d_name); if (strstr(dp->d_name, ".kml")) fprintf(fpKml, "%s\n", dp->d_name); if (strstr(dp->d_name, ".tgz")) fprintf(fpShape, "%s\n", dp->d_name); if (strstr(dp->d_name, ".db") && !strstr(dp->d_name, ".dbf")) fprintf(fpDB, "%s\n", dp->d_name); } closedir(dir); FCLOSE(fpTxt); FCLOSE(fpKml); FCLOSE(fpShape); FCLOSE(fpDB); printf("\nZipping text files ...\n"); sprintf(cmd, "tar czf %s_%s_txt.tgz -T txt.lst", sensor, beam_mode); asfSystem(cmd); printf("\nZipping KML files ...\n"); sprintf(cmd, "tar czf %s_%s_kml.tgz -T kml.lst", sensor, beam_mode); asfSystem(cmd); printf("\nZipping shape files ...\n"); sprintf(cmd, "tar czf %s_%s_shape.tgz -T shape.lst", sensor, beam_mode); asfSystem(cmd); printf("\nZipping database files ...\n"); sprintf(cmd, "tar czf %s_%s_db.tgz -T db.lst", sensor, beam_mode); asfSystem(cmd); sprintf(cmd, "rm txt.lst kml.lst shape.lst db.lst"); asfSystem(cmd); printf("\n\n"); }
//! Die Hauptfunktion zum Testen // int main(int argc, char *argv[]) { int res; rlimit rlp; res = getrlimit(RLIMIT_CORE, &rlp); std::cout<<"max core size: "<<rlp.rlim_cur<<std::endl; std::cout<<"current core size: "<<rlp.rlim_max<<std::endl; rlp.rlim_cur = 20000; res = getrlimit(RLIMIT_CORE, &rlp); if (res < 0) { std::cout<<"err: "<<errno<<std::endl; perror("setrlimit: RLIMIT_CORE"); exit(-2); } importmaps = false; //di::postgres::enable_trace_query = true; // get more info for unspecified exceptions std::set_terminate(__gnu_cxx::__verbose_terminate_handler); // save starting time time_t starttime; time(&starttime); std::stringstream ss; ss << starttime; configOptions["starttime"] = ss.str(); //Initialize Logging Options InitLogOptions(); Logger::writeMessage("basic", "\nStarte Illarion !"); // initialize randomizer initRandom(); // initialize signalhandlers if (! init_sighandlers()) { return 1; } // deactivate savethread // unsigned long int thisonlinetime = 0; checkArguments(argc, argv); // set up logfiles etc. and check if everything works if (! setup_files()) { return 1; } Logger::writeMessage("basic", "main: server requires clientversion: " + configOptions["clientversion"], false); Logger::writeMessage("basic", "main: listen port: " + configOptions["port"], false); Logger::writeMessage("basic", "main: data directory: " + configOptions["datadir"], false); // initialise DB Manager Database::ConnectionManager::Login login; Database::ConnectionManager::Server server; login.database = configOptions["postgres_db"]; login.user = configOptions["postgres_user"]; login.password = configOptions["postgres_pwd"]; server.host = configOptions["postgres_host"]; server.port = configOptions["postgres_port"]; Database::ConnectionManager::getInstance().setupManager(login, server); Database::SchemaHelper::setSchemata(configOptions["postgres_schema_server"], configOptions["postgres_schema_account"]); //Welt anlegen World *world = World::create(configOptions["datadir"] , starttime); //Laden der Daten fr die Welt (Items, Scripte, Tabellen etc.) loadData(); if (!importmaps) { world->Load("Illarion"); } else { configOptions["disable_login"] = "******"; world->load_from_editor(configOptions["datadir"] + std::string("map/import/oberwelt_0")); } std::cout<<"Creation the PlayerManager"<<std::endl; PlayerManager::get()->activate(); std::cout<<"PlayerManager activated"<<std::endl; PlayerManager::TPLAYERVECTOR &newplayers = PlayerManager::get()->getLogInPlayers(); timespec stime; stime.tv_sec = 0; stime.tv_nsec = 25000000; //25ms //NPC's erschaffen world->initNPC(); //run both reload scripts to initialize semi-dynamic data try { boost::shared_ptr<LuaReloadScript> tmpScript(new LuaReloadScript("server.reload_defs")); if (!tmpScript->onReload()) { std::cerr << "server.reload_defs.onReload returned false" << std::endl; } } catch (ScriptException &e) { std::cerr << "reload_defs: " << e.what() << std::endl; } try { boost::shared_ptr<LuaReloadScript> tmpScript(new LuaReloadScript("server.reload_tables")); if (!tmpScript->onReload()) { std::cerr << "server.reload_tables.onReload returned false" << std::endl; }; } catch (ScriptException &e) { std::cerr << "reload_tables: " << e.what() << std::endl; } Logger::writeMessage("basic","Scheduler wird Initialisiert \n",false); //Scheduler Initialisieren world->initScheduler(); int new_players_processed; running = true; // die OnlinePlayer-Liste aktualisieren (-> auf 0) world->saveAllPlayerNamesToFile(configOptions["datadir"] + std::string(ONLINEPLFILE)); while (running) { // Ausgaben auf std::cout in die Datei schreiben std::cout.flush(); // make sure we don't block the server with processing new players... new_players_processed = 0; // process new players from connection thread while (!newplayers.empty() && new_players_processed < MAXPLAYERSPROCESSED) { new_players_processed++; Player *newPlayer = newplayers.non_block_pop_front(); if (newPlayer) { login_save(newPlayer); if (newPlayer->isMonitoringClient()) { world->monitoringClientList->clientConnect(newPlayer); } else { try { std::cout<<"login sucessully from: "<<newPlayer->name<<" "<<newPlayer->id<<std::endl; world->Players.push_back(newPlayer); newPlayer->login(); try { std::cout<<"calling onlogin"<<std::endl; loginScript->onLogin(newPlayer); } catch (ScriptException &e) { std::cerr<<"Login Script: Failed to load scripts/login.lua !"<<std::endl; } world->updatePlayerList(); } catch (Player::LogoutException &e) { std::cout<<"got logout Exception during login!"<<std::endl; boost::shared_ptr<BasicServerCommand> cmd(new LogOutTC(e.getReason())); newPlayer->Connection->shutdownSend(cmd); //newPlayer->Connection->closeConnection(); PlayerManager::get()->getLogOutPlayers().non_block_push_back(newPlayer); } } } else { std::cout<<"try to get new player but was NULL!"<<std::endl; } } // get new players // Eingaben der Player abarbeiten und die Karte altern world->turntheworld(); nanosleep(&stime, NULL); } Logger::writeMessage("basic","Beende Illarion!"); std::cout<<"Server Shutdown:"<<std::endl; scriptVariables->save(); std::cout<<"Scriptvariables saved!"<<std::endl; world->forceLogoutOfAllPlayers(); //saving all players which where forced logged out. PlayerManager::get()->saveAll(); world->takeMonsterAndNPCFromMap(); Logger::writeMessage("basic","Statistik aktualisieren"); Logger::writeMessage("basic","OnlinePlayer-Liste aktualisieren (-> auf 0)"); world->saveAllPlayerNamesToFile(configOptions["datadir"] + std::string(ONLINEPLFILE)); Logger::writeMessage("basic","Karten speichern"); world->Save("Illarion"); Logger::writeMessage("basic","InitialConnection beenden"); Logger::writeMessage("basic", "Die in loadItems(..) angelegten Tabellen loeschen"); delete CommonItems; CommonItems = NULL; delete ItemNames; ItemNames = NULL; delete WeaponItems; WeaponItems = NULL; delete ArmorItems; ArmorItems = NULL; delete ContainerItems; ContainerItems = NULL; delete TilesModItems; TilesModItems = NULL; delete Tiles; Tiles = NULL; delete world; world = NULL; reset_sighandlers(); time(&starttime); Logger::writeMessage("basic","main: Ende "); return EXIT_SUCCESS; }