void QMplayer::sharing() { #ifdef QTOPIA if(!runClient()) { runServer(); } #else if(!runServer()) { runClient(); } #endif }
Dialog::Dialog(QWidget *parent) : QDialog(parent), ui(new Ui::Dialog) { ui->setupUi(this); closeid=0; this->setWindowFlags(Qt::WindowFullscreenButtonHint); //this->setWindowFlags(Qt::WindowCloseButtonHint); _serv = new server(this,this); encrypt=false; ctx= new BLOWFISH_CTX; slotInitPass(); connect(ui->btn_start,SIGNAL(clicked()),this,SLOT(runServer())); connect(ui->btn_send,SIGNAL(clicked()),this,SLOT(slotSendMessae())); connect(ui->tabWidget,SIGNAL(tabCloseRequested(int)),this,SLOT(closeTab(int))); connect(_serv,SIGNAL(newRoom(QString)),this,SLOT(addNewRoom(QString))); ui->ln_addr->setVisible(false); createMenuUserList(); #ifdef Q_OS_WIN32 tray = new QSystemTrayIcon(QIcon(":/icon/resource/icon/icon.ico"),this); // tray->setProperty("_sni_qt_category", "ApplicationStatus"); tray->show(); QMenu *Menu = new QMenu(this); QAction *showw = new QAction("Show", this); connect(showw, SIGNAL(triggered()), this, SLOT(showEvent())); QAction *quitAction = new QAction("Quit", this); connect(quitAction, SIGNAL(triggered()), this, SLOT(closeEvent2())); Menu->addAction(showw); Menu->addAction(quitAction); tray->setContextMenu(Menu); #endif }
int main(int argc, char **argv) { // Parse command line if(argc == 1) { printUsage(); return 0; } if(!parseCommandLine(argc, argv)) { fprintf(stderr, "Command error\n"); printUsage(); return -1; } if(g_execType == ExecServer) { runServer(); } else if(g_execType == ExecClient) { // TODO: start client module } puts("Exitting"); return 0; }
int main(int argc, char *argv[]) { int port; int c; char *strPort; if (argc != 3) { usage(argv[0]); } while ( (c = getopt(argc, argv, "p:")) != -1) { switch (c) { case 'p': strPort = optarg; break; case '?': default: usage(argv[0]); } } signal(SIGINT, sigintHandler); port = atoi(strPort); setupServer(port); runServer(); }
/*********************************************************************** * Parse and dispatch options **********************************************************************/ int main(int argc, char *argv[]) { std::cout << "######################################################" << std::endl; std::cout << "## Soapy Server -- Use any Soapy SDR remotely" << std::endl; std::cout << "######################################################" << std::endl; std::cout << std::endl; /******************************************************************* * parse command line options ******************************************************************/ static struct option long_options[] = { {"help", no_argument, 0, 'h'}, {"bind", optional_argument, 0, 'b'}, {0, 0, 0, 0} }; int long_index = 0; int option = 0; while ((option = getopt_long_only(argc, argv, "", long_options, &long_index)) != -1) { switch (option) { case 'h': return printHelp(); case 'b': return runServer(); } } //unknown or unspecified options, do help... return printHelp(); }
bool TestExtCurl::RunTests(const std::string &which) { bool ret = true; ServerPtr server = runServer(); RUN_TEST(test_curl_init); RUN_TEST(test_curl_copy_handle); RUN_TEST(test_curl_version); RUN_TEST(test_curl_setopt); RUN_TEST(test_curl_setopt_array); RUN_TEST(test_curl_exec); RUN_TEST(test_curl_getinfo); RUN_TEST(test_curl_errno); RUN_TEST(test_curl_error); RUN_TEST(test_curl_close); RUN_TEST(test_curl_multi_init); RUN_TEST(test_curl_multi_add_handle); RUN_TEST(test_curl_multi_remove_handle); RUN_TEST(test_curl_multi_exec); RUN_TEST(test_curl_multi_select); RUN_TEST(test_curl_multi_getcontent); RUN_TEST(test_curl_multi_info_read); RUN_TEST(test_curl_multi_close); RUN_TEST(test_evhttp_set_cache); RUN_TEST(test_evhttp_get); RUN_TEST(test_evhttp_post); RUN_TEST(test_evhttp_post_gzip); RUN_TEST(test_evhttp_async_get); RUN_TEST(test_evhttp_async_post); RUN_TEST(test_evhttp_recv); server->stop(); return ret; }
bool TestExtCurl::RunTests(const std::string &which) { bool ret = true; DECLARE_TEST_FUNCTIONS("function curl_write_func($s1, $s2) {" " print 'curl_write_func called with ';" " print $s2;" " return strlen($s2);" "}"); ServerPtr server = std::move(runServer()); RUN_TEST(test_curl_init); RUN_TEST(test_curl_copy_handle); RUN_TEST(test_curl_version); RUN_TEST(test_curl_setopt); RUN_TEST(test_curl_setopt_array); RUN_TEST(test_curl_exec); RUN_TEST(test_curl_getinfo); RUN_TEST(test_curl_errno); RUN_TEST(test_curl_error); RUN_TEST(test_curl_close); RUN_TEST(test_curl_multi_init); RUN_TEST(test_curl_multi_add_handle); RUN_TEST(test_curl_multi_remove_handle); RUN_TEST(test_curl_multi_exec); RUN_TEST(test_curl_multi_select); RUN_TEST(test_curl_multi_getcontent); RUN_TEST(test_curl_multi_info_read); RUN_TEST(test_curl_multi_close); server->stop(); return ret; }
int main(void) { pthread_t displayThread; pthread_create(&displayThread, NULL, runDisplayServer, (void*)NULL); runServer(); return 0; }
int main(int argc, char ** argv) { QCoreApplication app(argc, argv); #if defined(Q_OS_UNIX) catchUnixSignals({SIGQUIT, SIGINT, SIGTERM, SIGHUP}); #endif app.setApplicationName("helloworld"); app.setApplicationVersion("1.0.0"); QCommandLineParser parser; parser.setApplicationDescription("a HelloWorld example for http client and server."); parser.addHelpOption(); parser.addVersionOption(); parser.addPositionalArgument("mode", "working mode: server, client or weather. default: server"); // parser.addOption({ // {"l", "listen"}, // "listening tcp port number in server mode (default 8080)", // "portNo", "8080"}); // parser.addOption({ // {"u", "url"}, // "fetch url data in client mode", // "address", "http://www.google.com"}); // parser.addOption({ // {"g", "geolocation"}, // "a city name [,country name] in weather mode, default: Tehran", // "city", "Tehran"}); parser.process(app); QStringList posArgs = parser.positionalArguments(); if ( posArgs.size() != 1 ) { parser.showHelp(0); } else { const auto& mode = posArgs.at(0); if ( mode == QLatin1Literal("server") ) runServer(parser.value("listen")); #if defined(QHTTP_HAS_CLIENT) else if ( mode == QLatin1Literal("client") ) runClient(parser.value("url")); else if ( mode == QLatin1Literal("weather") ) runWeatherClient(parser.value("geolocation")); #else else if ( mode == QLatin1Literal("client") || mode == QLatin1Literal("weather") ) qDebug("qhttp::client has not been enabled at build time"); #endif // QHTTP_HAS_CLIENT } return 0; }
int main(int argc, char *argv[]) { if (invalidArgs(argc, argv)) exit(1); const char *port = argc == 3 ? argv[2] : "10101"; if (strcmp(argv[1], "-S") == 0) return runServer(port); if (strcmp(argv[1], "host") == 0) return runHost(port); return 0; }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); ui->gameBox->setEnabled(FALSE); connect(ui->clientButton, SIGNAL(released()), this, SLOT(connectToHost())); connect(ui->serverButton, SIGNAL(released()), this, SLOT(runServer())); moves = 0; }
/** * Name: beginServer * Description: Binds a socket and begins listening to it for the web server. * * @param ipaddress IP Address * @param port Port Number */ void beginServer(const char* ipaddress, const char * port) { //initialize the socket int sock = initializeSocket(ipaddress, port); if(sock < 0) { endServer(sock, NULL, 0); } runServer(sock); }
bool CDaemon::start(){ //get daemon pid from file char buf[640]; int masterPid; string strName = m_runPath + daemon_pid_file; strName = strName + "." + m_pName; if ( 0<read1LineFromFile(strName.c_str(), buf, 64, "r") &&(masterPid = atoi(buf)) != 0){ if(kill(masterPid, 0) == 0){ printf("Instance's running, ready to quit!\n"); return true; } } initAsDaemon(); sprintf(buf, "%d", getpid()); if(!writeBuff2File(strName.c_str(), buf, "w")){ fprintf(stderr, "Write master pid fail!\n"); } while(true){//daemon fork and son do jobs pid_t pid = fork(); if (pid == 0){ signal(SIGUSR1, sigChildHandler); signal(SIGPIPE, SIG_IGN); signal(SIGTTOU, SIG_IGN); signal(SIGTTIN, SIG_IGN); signal(SIGTERM, SIG_IGN); signal(SIGINT, SIG_IGN); signal(SIGQUIT, SIG_IGN); if(!initServer()){ fprintf(stderr, "Server init fail!\n"); return false; } fprintf(stdout, "Server init ok pid = %d\n",(int)getpid()); if(!runServer()){ fprintf(stderr, "run fail!\n"); return false; } fprintf(stdout, "Server run ok!\n"); exit(0); } m_nChildPid=pid; int status; pid = wait(&status); if(!isAbnormalExit(pid, status)){ fprintf(stdout, "Child exit!\n"); break; } } return true; }
int main(void) { Server server; if (initServer(&server) < 0) { printf("ERROR: Can`t initialize server by \"%s\"\n", FILE_NAME); return -1; } return runServer(&server); return 0; }
int main(int argc, char** argv) { key_t key = ftok("chat", 3141596); if(argc != 2) { fprintf(stderr, "Invalid arguments."); } else if(strcmp(argv[1], "-s") == 0) { runServer(key); } else if(strcmp(argv[1], "-c") == 0) { runClient(key); } return 0; }
/* Run a web server not based on a config file. */ PUBLIC int maRunSimpleWebServer(cchar *ip, int port, cchar *home, cchar *documents) { Mpr *mpr; int rc; if ((mpr = mprCreate(0, NULL, MPR_USER_EVENTS_THREAD)) == 0) { mprLog("error appweb", 0, "Cannot create the web server runtime"); return MPR_ERR_CANT_CREATE; } rc = runServer(0, ip, port, home, documents); mprDestroy(); return rc; }
/* Create a web server described by a config file. */ PUBLIC int maRunWebServer(cchar *configFile) { Mpr *mpr; int rc; if ((mpr = mprCreate(0, NULL, MPR_USER_EVENTS_THREAD)) == 0) { mprLog("error appweb", 0, "Cannot create the web server runtime"); return MPR_ERR_CANT_CREATE; } rc = runServer(configFile, 0, 0, 0, 0); mprDestroy(); return rc; }
void TestControllerParallel::run() { barrier(); if (attr->is_worker()) runWorker(); #ifdef HAVE_MPI if (attr->is_server()) runServer(); #endif barrier(); // std::cerr << "incrementing program number after run" << std::endl << std::flush; sip::JobControl::global->increment_program(); barrier(); }
virtual void SetUp() { pid_ = fork(); ASSERT_LE(0, pid_) << "failed to fork off server process"; if (pid_ == 0) { runServer(); exit(0); } else { waitForServer(); } }
int main(const int argc, const char* argv[]) { if (argc == 2) { if (argv[1] == std::string("client")) { runClient(); return 0; } else if (argv[1] == std::string("server")) { runServer(); return 0; } } printHelp(); return 1; }
int main(int argc, char* argv[]) { std::string profile; for (int i = 1; i < argc; ++i) { std::string arg(argv[i]); if (arg == "server") { profile = "server"; } } if (profile == "server") { return runServer(argc, argv); } return runClient(argc, argv); }
int main(int argc, char ** argv) { key_t key = ftok("kozel", 0); int msgId = msgget(key, IPC_CREAT | 0666); printf("key=%d\n", key); printf("msgId=%d\n", msgId); switch(getKey(argc, argv)) { case server: runServer(msgId); break; case client: runClient(msgId); break; default: printf("Error\n"); break; } return 0; }
int main (int argc, char **argv) { /* Signal * -TERM : Gracefully shutdown * -HUP : Reload configuration file */ signal (SIGPIPE, SIG_IGN); setupSignalHandlers (); initConfig (argc, argv); if (initServer () == -1) exit (EXIT_FAILURE); if (runServer () == -1) exit (EXIT_FAILURE); finalizeServer (); exit (EXIT_SUCCESS); }
int main(int argc, char **argv) { // Initialize // extractAll(); // quantizeAllData(); extractAndQuantizeAll(); if (argc > 1) { if (strcmp(argv[1], "test") == 0) { runTest(); } else if (strcmp(argv[1], "runserver")) { runServer(); } } return 0; }
/* Main code execution starts here */ int main(int argc, char **argv) { /* Writes our opening message to log file */ logMessage("Open Program"); /* Used to store the port number argument */ int port; int result; /* Used for creating and binding the socket */ int socketID; /* Initialize our global for our signal handler */ Exit = 0; /* Sets the signals */ setSignalHandler(); /* Assigns the port and checks error */ result = portAssign(&port, argc, argv); checkError(result, PORT_ASSIGN_STATUS); if(result == -1) return (1); /* Construct socket, binds and listens */ socketID = setSocket(port); checkError(result, SOCKET_ASSIGN_STATUS); if(socketID == -1) return (1); /* Accepts clients and allows communication*/ runServer(socketID); /* Close socket connection */ result = close( socketID ); checkError(result, SOCKET_CLOSE_STATUS); if(result != -1) printf("Server closed.\n"); /* Log final message and end program */ logMessage("Close Program\n"); return(0); }
int main(int argc, char *argv[]) { int port; /* Check the given parameters and report error if any then quit */ if(argc == PARAMS) { if((port = atoi(argv[1])) == 0) error_minor("Error: Invalid port.\nUsage:\t./server <port>\n"); } /* If no parameter (port) is defined, default TFTP server port is used (69) */ else if(argc == PARAMS - 1) port = TFTP_SERVER_PORT; else param_err(); printf("Server is using port: %d\n",port); /* Run the server */ if(runServer(port) != 0) error_minor("Error: starting error, unknown reason"); return 0; }
/** Entry point for command handling thread. */ void* readCommands(void *arg) { runServer(); return NULL; }
int main(int argc, char *argv[]) { if (argc < 2) { fprintf(stderr, "[gwmserver] no launcher specified\n"); return 1; }; char dispdev[1024]; uint64_t requestRes; char linebuf[1024]; if (geteuid() != 0) { fprintf(stderr, "[gwmserver] you need to be root to start the window manager\n"); return 1; }; int sockfd = socket(AF_UNIX, SOCK_SEQPACKET, 0); if (sockfd == -1) { fprintf(stderr, "[gwmserver] cannot create socket: %s\n", strerror(errno)); return 1; }; struct sockaddr_un srvaddr; srvaddr.sun_family = AF_UNIX; strcpy(srvaddr.sun_path, "/run/gwmserver"); if (bind(sockfd, (struct sockaddr*) &srvaddr, sizeof(struct sockaddr_un)) != 0) { fprintf(stderr, "[gwmserver] cannot bind to /run/gwmserver: %s\n", strerror(errno)); return 1; }; if (listen(sockfd, 5) != 0) { fprintf(stderr, "[gwmserver] cannot listen: %s\n", strerror(errno)); return 1; }; // make sure the clipboard and shared surface directories actually exist mkdir("/run/clipboard", 0777); mkdir("/run/shsurf", 01777); mkdir("/run/gwmserver-wd", 0777); mkdir("/var", 0755); mkdir("/var/log", 0755); chdir("/run/gwmserver-wd"); FILE *fp = fopen("/etc/gwm.conf", "r"); if (fp == NULL) { fprintf(stderr, "could not open /etc/gwm.conf: %s\n", strerror(errno)); return 1; }; requestRes = DDI_RES_AUTO; dispdev[0] = 0; char *line; int lineno = 0; char logdest[PATH_MAX]; strcpy(logdest, "/var/log/gwmserver.log"); while ((line = fgets(linebuf, 1024, fp)) != NULL) { lineno++; char *endline = strchr(line, '\n'); if (endline != NULL) { *endline = 0; }; if (strlen(line) >= 1023) { fprintf(stderr, "/etc/gwm.conf:%d: buffer overflow\n", lineno); return 1; }; if ((line[0] == 0) || (line[0] == '#')) { continue; } else { char *cmd = strtok(line, " \t"); if (cmd == NULL) { continue; }; if (strcmp(cmd, "display") == 0) { char *name = strtok(NULL, " \t"); if (name == NULL) { fprintf(stderr, "/etc/gwm.conf:%d: 'display' needs a parameter\n", lineno); return 1; }; strcpy(dispdev, name); } else if (strcmp(cmd, "resolution") == 0) { char *res = strtok(NULL, " \t"); if (res == NULL) { fprintf(stderr, "/etc/gwm.conf:%d: 'resolution' needs a parameter\n", lineno); return 1; }; uint64_t reqWidth, reqHeight; if (strcmp(res, "auto") == 0) { requestRes = DDI_RES_AUTO; } else if (strcmp(res, "safe") == 0) { requestRes = DDI_RES_SAFE; } else if (sscanf(res, "%lux%lu", &reqWidth, &reqHeight) == 2) { requestRes = DDI_RES_SPECIFIC(reqWidth, reqHeight); } else { fprintf(stderr, "/etc/gwm.conf:%d: invalid resolution: %s\n", lineno, res); return 1; }; } else if (strcmp(cmd, "log") == 0) { char *path = strtok(NULL, " \t"); if (path == NULL) { fprintf(stderr, "/etc/gwm.conf:%d: 'log' needs a parameter\n", lineno); return 1; }; if (strlen(path) >= PATH_MAX) { fprintf(stderr, "/etc/gwm.conf:%d: log path too long\n", lineno); return 1; }; strcpy(logdest, path); } else { fprintf(stderr, "/etc/gwm.conf:%d: invalid directive: %s\n", lineno, cmd); return 1; }; }; }; fclose(fp); int logfd = open(logdest, O_WRONLY | O_CREAT | O_APPEND, 0644); if (logfd == -1) { fprintf(stderr, "[gwmserver] could not open log file %s: %s\n", logdest, strerror(errno)); return 1; }; dup2(logfd, 1); dup2(logfd, 2); close(logfd); if (dispdev[0] == 0) { fprintf(stderr, "/etc/gwm.conf: no display device specified!\n"); return 1; }; if (ddiInit(dispdev, O_RDWR) != 0) { fprintf(stderr, "ddiInit: %s: %s\n", dispdev, strerror(errno)); return 1; }; if (symlink(dispdev, "/run/gwmdisp") != 0) { fprintf(stderr, "symlink /run/gwmdisp: %s\n", strerror(errno)); return 1; }; frontBuffer = ddiSetVideoMode(requestRes); screen = ddiCreateSurface(&frontBuffer->format, frontBuffer->width, frontBuffer->height, NULL, 0); // GWM information int fd = open("/run/gwminfo", O_RDWR | O_CREAT | O_TRUNC, 0644); if (fd == -1) { fprintf(stderr, "Failed to open /run/gwminfo! %s\n", strerror(errno)); return 1; }; DDIColor backgroundColor = {0, 0, 0x77, 0xFF}; desktopBackground = ddiCreateSurface(&screen->format, screen->width, screen->height, NULL, DDI_SHARED); ddiFillRect(desktopBackground, 0, 0, screen->width, screen->height, &backgroundColor); ddiFillRect(screen, 0, 0, screen->width, screen->height, &backgroundColor); ddiFillRect(frontBuffer, 0, 0, screen->width, screen->height, &backgroundColor); ftruncate(fd, sizeof(GWMInfo)); gwminfo = (GWMInfo*) mmap(NULL, sizeof(GWMInfo), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); gwminfo->backgroundID = desktopBackground->id; printf("[gwmserver] initialize theme info\n"); gwmGlobalThemeInit(&frontBuffer->format); imgWincap = ddiOpenSurface(gwminfo->imgWinCap); imgWinbut = ddiOpenSurface(gwminfo->imgWinButtons); if (fork() == 0) { execv(argv[1], &argv[1]); perror("exec launcher"); _exit(1); }; // now that we won't be starting any processes, we can set core dumps signal(SIGSEGV, SIG_CORE); signal(SIGILL, SIG_CORE); signal(SIGBUS, SIG_CORE); signal(SIGABRT, SIG_CORE); signal(SIGALRM, SIG_CORE); kblSet("/usr/share/kblayout/en_US/int", stderr); wndInit(); ptrInit(); inputInit(); runServer(sockfd); return 0; };
/* Main function for demonstrating the echo server. * You can remove this and simply call runServer() from your application. */ int main(int argc, char *argv[]) { return runServer(); }
int main() { runServer(); return 0; }