/* * tscanserver implementation * * Copyright (C) Thomas Escher, Kai Lingemann * * Released under the GPL version 3. * */ /** * @file * @brief Dynamic management of scans. * @author Thomas Escher */ #include using std::cout; using std::cerr; using std::endl; #include using std::string; // for signals #include // for getopt #ifndef _MSC_VER #include #else #include "XGetopt.h" #endif #include "scanserver/serverInterface.h" #include "scanserver/cacheIO.h" #include "scanserver/scanHandler.h" bool keep_temp_files = false; void signal_segv(int v) { static sig_atomic_t signal_once = false; if(!signal_once) { signal_once = true; cout << endl << "# Scanserver closed due to segmentation fault #" << endl; // remove server and memory ServerInterface::destroy(); // clean up temporary files if(!keep_temp_files) CacheIO::removeTemporaryDirectory(); } exit(-1); } void signal_interrupt(int v) { static sig_atomic_t signal_once = false; if(!signal_once) { signal_once = true; cout << endl << "# Scanserver closed #" << endl; // remove server and memory ServerInterface::destroy(); // clean up temporary files if(!keep_temp_files) CacheIO::removeTemporaryDirectory(); } exit(-1); } void usage(const char* name) { #ifndef _MSC_VER const string bold("\033[1m"); const string normal("\033[m"); #else const string bold(""); const string normal(""); #endif cout <run(); // end of line! cout << "Stopping scanserver." << endl; ServerInterface::destroy(); // clean up temporary files if(!keep_temp_files) CacheIO::removeTemporaryDirectory(); }