#include #include #include #include #include #include #include #include using namespace std; static string homepath (const char *path) { string ret; if (path[0] != '/'){ ret = string(getenv("HOME")) + "/" + path; }else{ ret = path; } return ret; } int main (int argc, char *argv[]) { glocal int ret = -1; glocal const char *unixport = ".cfshell/cfshell_local.sock"; glocal bool daemon = false; glocal const char *pidfile = ".cfshell/cfshell_local.pid"; glocal.ret = (argc,argv); setarg ('p',"unixport","Socket unix",glocal.unixport,false); setarg ('d',"daemon","Execute en arriere plan",glocal.daemon,false); setarg (' ',"pidfile","Fichier PID",glocal.pidfile,false); int ret = -1; signal (SIGPIPE,SIG_IGN); signal (SIGCHLD,SIG_IGN); string unixport = homepath (glocal.unixport); string pidfile = homepath (glocal.pidfile); string tmp = string("unix:") + unixport; (tmp.c_str(),1); if (o.is_ok()){ if (glocal.daemon){ daemon_init(pidfile.c_str(),NULL); } o.loop(); ret = 0; }else{ tlmp_error ("Ne peut installer le socket %s (%s)\n",unixport.c_str(),strerror(errno)); } return ret; return glocal.ret; }