/* strictmain.cpp * * Copyright (c) 1998-2000 Alexander Neundorf * neundorf@kde.org * * You may distribute under the terms of the GNU General Public * License as specified in the COPYING file. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * */ #include "lisadefines.h" #include "netmanager.h" #include #include #include #include #include #include #include // detect linux/glibc for the gnu style --args #if defined(__linux__) || defined(__linux) || defined(linux) # include # ifdef __GLIBC__ // only gnu libc has getopt.h... getopt(3) is defined to be in unistd.h // by POSIX.2 # ifndef _GNU_SOURCE # define _GNU_SOURCE # endif # include # endif // __GLIBC__ # define GNU_GETOPT #endif // linux #ifdef LISA_DEBUG #undef LISA_DEBUG #endif #define LISA_DEBUG 0 #ifdef dcerr #undef dcerr #endif #define dcerr if (LISA_DEBUG==1) std::cerr<<"strictmain " void printVersion() { const char * versionInfo=\ "\r\nThis is the restricted LAN Information Server resLISa "MYVERSION"\r\n"\ "It is free software according the GNU General Public License\r\n"\ "Copyright (c) 2000-2003 by Alexander Neundorf\r\n"\ "email: neundorf@kde.org\r\n"; std::cout<readConfig(); signal(SIGHUP,&readConfig); } void printState(int sigNumber) { std::cout<<"printState(): signal caught: "<printState(); signal(SIGUSR1,&printState); } void setSignalHandler() { signal(SIGHUP,&readConfig); signal(SIGUSR1,&printState); signal(SIGINT,&destruct); signal(SIGQUIT,&destruct); signal(SIGILL,&destruct); signal(SIGTRAP,&destruct); signal(SIGABRT,&destruct); signal(SIGBUS,&destruct); signal(SIGSEGV,&destruct); signal(SIGUSR2,&destruct); signal(SIGPIPE,&destruct); signal(SIGALRM,&destruct); signal(SIGTERM,&destruct); signal(SIGFPE,&destruct); #ifdef SIGPOLL signal(SIGPOLL, &destruct); #endif #ifdef SIGSYS signal(SIGSYS, &destruct); #endif #ifdef SIGVTALRM signal(SIGVTALRM, &destruct); #endif #ifdef SIGXCPU signal(SIGXCPU, &destruct); #endif #ifdef SIGXFSZ signal(SIGXFSZ, &destruct); #endif } #ifdef GNU_GETOPT static struct option const long_opts[] = { {"version", no_argument, 0, 'v'}, {"quiet", no_argument, 0, 'q'}, {"unix", no_argument, 0, 'u'}, {"kde1", no_argument, 0, 'k'}, {"kde2", no_argument, 0, 'K'}, {"config", required_argument, 0, 'c'}, {"help", no_argument, 0, 'h'}, {0, 0, 0, 0} }; #endif int main(int argc, char** argv) { int quiet(0); int c(0); int configStyle(UNIXCONFIGSTYLE); MyString configFile; int portToUse(MYPORT); //I thought this would be the way to check wether long options are supported... #ifdef GNU_GETOPT while ((c=getopt_long(argc, argv, "vqukKc:h", long_opts, 0))!=-1) #else while ((c=getopt(argc, argv, "vqukKc:h"))!=-1) #endif { switch (c) { case 0: break; case 'v': printVersion(); exit(0); break; case 'q': quiet=1; break; case 'u': case 'k': case 'K': std::cerr<<"\a\nThe command line switches -k, -K, -u and \ntheir long versions "\ "--kde1, --kde2 and --unix are not supported anymore.\n"\ "ResLisa will always first look for $(HOME)/.reslisarc , then for /etc/reslisarc.\n"\ "If your lisa configuration file was created using an older version of \n"\ "the KDE control center, copy the $(HOME)/.trinity/share/config/reslisarc to $(HOME)/.reslisarc.\n"<0) { //this is the parent exit(0); } else if (pid<0) { dcerr<<"could not fork()"<