Пример #1
0
int ndn_rtt(int argc, char **argv)
{
    if (argc < 2) {
        printf("usage: %s [client|server]\n", argv[0]);
        return 1;
    }

    if (strcmp(argv[1], "client") == 0) {
	if (argc < 3) {
            printf("usage: %s client _max_count_\n", argv[0]);
            return 1;
        }

	int max_cnt = atoi(argv[2]);
	if (max_cnt == 0) {
	    printf("invalid max count number: %s\n", argv[3]);
	    return 1;
	}

	run_client(max_cnt);
    }
    else if (strcmp(argv[1], "server") == 0) {
        if (argc < 4) {
            printf("usage: %s server _sig_type_ _content_size_\n", argv[0]);
            return 1;
        }

	int content_sz = atoi(argv[3]);
	if (content_sz <= 0 || content_sz > 200) {
	    printf("invalid content size: %s; will set to 4\n", argv[3]);
	    content_sz = 4;
	}

	if (strcmp(argv[2], "hmac") == 0) {
	    run_server(NDN_SIG_TYPE_HMAC_SHA256, content_sz);
	}
	else if (strcmp(argv[2], "ecdsa") == 0) {
	    run_server(NDN_SIG_TYPE_ECDSA_SHA256, content_sz);
	}
	else {
	    printf("unknown signature type: %s\n", argv[2]);
	    return 1;
	}
    }
    else {
        puts("error: invalid command");
    }
    return 0;
}
Пример #2
0
int Argument_main(Argument *arg){
    gint port, max_connections, verbosity;
    gchar *input_path;
    gboolean preload;
    register ArgumentSet *as = ArgumentSet_create("Exonerate Server options");
    ArgumentSet_add_option(as, '\0', "port", "port",
            "Port number to run server on", "12886",
            Argument_parse_int, &port);
    ArgumentSet_add_option(as, '\0', "input", "path",
            "Path to input file (.esd or .esi)", NULL,
            Argument_parse_string, &input_path);
    ArgumentSet_add_option(as, '\0', "preload", NULL,
            "Preload index and sequence data", "TRUE",
            Argument_parse_boolean, &preload);
    ArgumentSet_add_option(as, '\0', "maxconnections", "threads",
            "Maximum concurrent server connections", "4",
            Argument_parse_int, &max_connections);
    ArgumentSet_add_option(as, 'V', "verbosity", "level",
            "Set server verbosity level", "1",
            Argument_parse_int, &verbosity);
    Argument_absorb_ArgumentSet(arg, as);
    /**/
    Match_ArgumentSet_create(arg);
    HSPset_ArgumentSet_create(arg);
    /**/
    Argument_process(arg, "exonerate-server", "Exonerate Server.\n",
                     "Guy St.C. Slater.  [email protected] June 2006\n");
    run_server(port, input_path, preload, max_connections, verbosity);
    g_message("-- server exiting");
    return 0;
    }
Пример #3
0
static Suite *
souphttpsrc_suite (void)
{
    Suite *s;

    TCase *tc_chain, *tc_internet;

    s = suite_create ("souphttpsrc");
    tc_chain = tcase_create ("general");
    tc_internet = tcase_create ("internet");

    suite_add_tcase (s, tc_chain);
    run_server (&http_port, &https_port);
    atexit (stop_server);
    tcase_add_test (tc_chain, test_first_buffer_has_offset);
    tcase_add_test (tc_chain, test_redirect_yes);
    tcase_add_test (tc_chain, test_redirect_no);
    tcase_add_test (tc_chain, test_not_found);
    tcase_add_test (tc_chain, test_forbidden);
    tcase_add_test (tc_chain, test_cookies);
    tcase_add_test (tc_chain, test_good_user_basic_auth);
    tcase_add_test (tc_chain, test_bad_user_basic_auth);
    tcase_add_test (tc_chain, test_bad_password_basic_auth);
    tcase_add_test (tc_chain, test_good_user_digest_auth);
    tcase_add_test (tc_chain, test_bad_user_digest_auth);
    tcase_add_test (tc_chain, test_bad_password_digest_auth);
    if (soup_ssl_supported)
        tcase_add_test (tc_chain, test_https);

    suite_add_tcase (s, tc_internet);
    tcase_set_timeout (tc_internet, 250);
    tcase_add_test (tc_internet, test_icy_stream);

    return s;
}
Пример #4
0
int main(int argc, char **argv)
{
  if (argc > 1 && strcmp(argv[1], "test") == 0)
    return run_tests(argc, argv);

  return run_server(argc, argv);
}
Пример #5
0
int main()
{
	int * pipe_req = pipe_create();
	int * pipe_ans = pipe_create();
	pid_t fork_res = fork();
	
	switch(fork_res)
	{
		case -1:	printf("Stopped. Fork error.\n");
				break;
		case 0:		close(pipe_req[1]);
				close(pipe_ans[0]);
				run_server(pipe_req[0], pipe_ans[1]);
				close(pipe_req[0]);
				close(pipe_ans[1]);				
				break;
		default:	close(pipe_req[0]);
				close(pipe_ans[1]);
				run_client(pipe_req[1], pipe_ans[0]);
				close(pipe_req[1]);
				close(pipe_ans[0]);
				break;
	};

	pipe_delete(pipe_req);
	pipe_delete(pipe_ans);

	return 0;
}
Пример #6
0
void run_server_or_cgi::run()
{
  bool server=false;
  for (int i=1; i<argc; i++)
    if (argv[i]==string("-s")||
        argv[i]==string("--server"))
      server=true;

  if (server){
    run_server(c, argc, argv).run();
  }
  else{
    bool help=false;
    for (int i=1; i<argc; i++)
      if (argv[i]==string("-h")||
          argv[i]==string("--help"))
        help=true;

    if (help){
      cerr<<"usage: "<<argv[0]<<" [-s] [-h] [server-options]"<<endl;
      exit(0);
    }

    run_cgi(c).run();
  }
}
Пример #7
0
void* wait_thread(void* args)
{
	int status;

	while(running_flag) {
		//Start server
		pthread_mutex_lock(&fd_mutex);
		server_pid = run_server();

		if(server_pid == -1) {
			pthread_mutex_unlock(&fd_mutex);
			printlog(LOG_SERVER, "Failed to run server!\n");
			continue;
		}

		pthread_mutex_unlock(&fd_mutex);
		printlog(LOG_SERVER, "Server started.\n");

		//Wait
		waitpid(server_pid, &status, 0);
	}

	UNREFERRED_PARAMETER(args);
	return NULL;
}
Пример #8
0
int 
main(int argc, char **argv)
{    
    int loop_number = 0; 

    startup_win_network();

    parse_parameters(argc, argv);

    init_network();

    signal(SIGINT, sig_handler);

    if (!quiet)
    {
        fprintf(stderr, "listening on port %d for packets .... \n", port_num);
        if (continuous)
            fprintf(stderr, "looping tests.\n");
        fprintf(stderr, "\n");
    }

    fprintf(stdout, "# run no., loss rate in %%, packets_sent, packets_received, payload_size\n");
    do
    {
        loop_number++;
        fprintf(stdout, "%2d.   ", loop_number);
        run_server();
    }
    while (continuous);

    return 1;
}
Пример #9
0
int main(int argc, char *argv[]){
  
  int server;
  int port = DEFAULT_PORT;
  int c;
  
  opterr = 0;
  while ((c = getopt (argc, argv, "sp:")) != -1){
    switch (c){
    case 's':
      server = 1;
      break;
    case 'p':
      port = atoi(optarg);
      break;
    default:
      fprintf(stderr, "undefined argument\n");
      exit(1);
    }
  }

  if (server){
    run_server(port);

  } else {
    run_client(port);

  }


  return 0; 
}
Пример #10
0
int _tmain(int argc, TCHAR *argv[])
{
	int res = 0;
	program_state_t state;

	if (argc != 4) {
		_tprintf(_T("Usage: %s <port> <in folder> <num of threads>\n"), argv[0]);
		return -1;
	}
	state.port = _tstoi(argv[1]);
	_tcscpy_s(state.in_dir, argv[2]);
	state.num_of_threads = _tstoi(argv[3]);

	if (!init_state(&state)) {
		res = -1;
		goto cleanup;
	}
	if (!run_server(&state)) {
		res = -1;
	}

cleanup:
	if (!fini_state(&state)) {
		res = -1;
	}
	return res;
}
Пример #11
0
int server(struct conf *conf, const char *conffile,
	struct lock *lock, int generate_ca_only)
{
	int ret=0;
	int rfd=-1; // normal client port
	// Only close and reopen listening sockets if the ports changed.
	// Otherwise you get an "unable to bind listening socket on port X"
	// error, and the server stops.
	char *oldport=NULL;
	char *oldstatusport=NULL;

	//return champ_test(conf);

	if(ca_server_setup(conf)) return 1;
	if(generate_ca_only)
	{
		logp("The '-g' command line option was given. Exiting now.\n");
		return 0;
	}

	if(conf->forking && conf->daemon)
	{
		if(daemonise() || relock(lock)) return 1;
	}

	ssl_load_globals();

	while(!ret && !gentleshutdown)
	{
		ret=run_server(conf, conffile,
			&rfd, oldport, oldstatusport);
		if(ret) break;
		if(hupreload && !gentleshutdown)
		{
			if(oldport) free(oldport);
			if(oldstatusport) free(oldstatusport);
			oldport=strdup(conf->port);
			oldstatusport=conf->status_port?
				strdup(conf->status_port):NULL;
			if(reload(conf, conffile,
				0, // Not first time.
				conf->max_children,
				conf->max_status_children,
				0)) // Not JSON output.
					ret=1;
		}
		hupreload=0;
	}
	close_fd(&rfd);
	close_fd(&sfd);
	if(oldport) free(oldport);
	if(oldstatusport) free(oldstatusport);

	// The signal handler stuff sets up chlds. Need to free them.
	chlds_free();

// FIX THIS: Have an enum for a return value, so that it is more obvious what
// is happening, like client.c does.
	return ret;
}
Пример #12
0
int
main(int argc, char *argv[])
{
    in_port_t port;
    uint8_t page_count;

    if (argc > 3) {
        printf("Too many arguments\n");
        return -1;
    }

    if (argc < 3) {
        printf("Not enough arguments (port, pages)\n");
        return -1;
    }

    if (sscanf(argv[1], "%"SCNu16, &port) != 1) {
        printf("Bad port\n");
        return -1;
    }

    if (sscanf(argv[2], "%"SCNu8, &page_count) != 1) {
        printf("Bad page number\n");
        return -1;
    }

    return run_server(port, page_count, xen_shm_handler_ping_server, NULL);
}
Пример #13
0
int main(int argc, const char **argv)
{
  clioptions opts;
  parse_commandline(argc, argv, &opts);
  run_server(&opts);
  return 0;
}
Пример #14
0
int main(char argc, char *argv[]){
	
	if( args_handle(argc,argv) != -1 ){
		run_server(OPTION_PORT);
	}

	return 0;
}
Пример #15
0
void CALLBACK ServiceMain(DWORD dwArgc, LPTSTR *lpszArgv)
{
	int seq=1;
	HKEY hk;
	DWORD dwTmp,dwType;
	char szTmp[1024];

	HANDLE hSem = CreateSemaphore(NULL,0,1,"CVSNT_ControlPanel");

	if(dwArgc!=999)
	{
		if (!(g_hService = RegisterServiceCtrlHandler(SERVICE_NAME,ServiceHandler))) { ReportError(TRUE,"Unable to start "SERVICE_NAME" - RegisterServiceCtrlHandler failed"); return; }
		NotifySCM(SERVICE_START_PENDING, 0, seq++);
	}
	else
	{
		g_bTestMode=TRUE;
		printf(SERVICE_NAME" " CVSNT_PRODUCTVERSION_STRING " ("__DATE__") starting in test mode.\n");
	}

// Initialisation
    WSADATA data;

    if(WSAStartup (MAKEWORD (1, 1), &data))
	{
		ReportError(TRUE,"WSAStartup failed... aborting - Error %d\n",WSAGetLastError());
		if(!g_bTestMode)
			NotifySCM(SERVICE_STOPPED,0,0);
		return;
	}

	if(!RegOpenKeyEx(HKEY_LOCAL_MACHINE,"Software\\CVS\\Pserver",NULL,KEY_QUERY_VALUE,&hk))
	{
		dwTmp=sizeof(szTmp);
		if(!RegQueryValueEx(hk,"ControlPanel",NULL,&dwType,(BYTE*)szTmp,&dwTmp))
		{
			char *p = strchr(szTmp,':');
			if(p)
				controlserver_port=atoi(p+1);
		}
		dwTmp=sizeof(szTmp);
		if(!RegQueryValueEx(hk,"ControlPanelLocal",NULL,&dwType,(BYTE*)szTmp,&dwTmp))
		{
			if(dwType==REG_DWORD)
				local_only = *(DWORD*)szTmp;
		}
		RegCloseKey(hk);
	}

    run_server(controlserver_port, seq, local_only);

	CloseHandle(hSem);

	if(!g_bTestMode)
		NotifySCM(SERVICE_STOPPED, 0, 0);
	ReportError(FALSE,SERVICE_NAME" stopped successfully");

}
Пример #16
0
/*---------------------------------------------------------------------------------------
-- FUNCTION: main
--
-- DATE: February 11, 2016
--
-- DESIGNERS: Rizwan Ahmed, Vishav Singh
--
-- PROGRAMMERS: Rizwan Ahmed, Vishav Singh
--
-- RETURNS: 0 on exit
--
-- NOTES: Main entry point of the program. Merely gets rid of the need to flush
-- everytime something is printed to standard output and calls the server loop.
---------------------------------------------------------------------------------------*/
int main(int argc, char *argv[])
{
	(void)signal(SIGINT, kill_server);
	setbuf(stdout, NULL);
	run_server(SERVER_PORT);

	return 0;

}
Пример #17
0
Файл: main.c Проект: bpa/gamed
int main(int argc, char *argv[]) {
    char **p_ptr = NULL;
    char *config_file = NULL;
    int port = GAMED_PORT;
	int c, fork = 1;
    long requested_port = 0;
	struct rlimit limit;

	while ((c = getopt (argc, argv, "Xp:f:")) != -1) {
		switch(c) {
			case 'X':
				fork = 0;
				break;
			case 'p':
				requested_port = strtol(optarg, p_ptr, 10);
				if (p_ptr != NULL || requested_port > 65535) {
					printf("%s is not a valid port\n", optarg);
					return 1;
				}
				port = requested_port;
				break;
            case 'f':
			case '?':
				if (optopt == 'p') {
					/* getopt is printing errors for me, so this isn't needed
					fprintf(stderr, "No port specified with -p\n");
					*/
				}
				else {
					fprintf(stderr, "Usage: [-X] [-p port] [-f /path/to/config]\n");
				}
				return 1;
			default:
				abort();
		}
	}

	limit.rlim_cur = RLIM_INFINITY;
	limit.rlim_max = RLIM_INFINITY;
	setrlimit(RLIMIT_CORE, &limit);
    if (fork) {
        if (daemon(1, 0) == -1) {
            perror("daemonize");
            return 1;
        }
    }
    if (config_file == NULL) {
	    init_server(port, DEFAULT_CONFIG);
    }
    else {
	    init_server(port, config_file);
    }
    free(config_file);
	run_server();
	return 0;
}
Пример #18
0
static void *thread_start(void *arg)
{
        struct thread *t = arg;
        reset_port(t->ai, atoi(t->opts->port), t->cb);
        if (t->opts->client)
                run_client(t);
        else
                run_server(t);
        return NULL;
}
Пример #19
0
int main(int argc, char const* argv[])
{
    if (argc > 2) {
        run_client(atoi(argv[1]));
    } else {
        run_server(atoi(argv[1]));
    }

    return 0;
}
Пример #20
0
int main(int argc, char *argv[]) {

	int sock_fd;

	bind_serv(&sock_fd);
	start_listen(&sock_fd);
	run_server(&sock_fd);

	return EXIT_SUCCESS;
}
Пример #21
0
int main(int argc, char **argv)
{ const char *tmp = getenv("TMPDIR");
  if (tmp)
    TMPDIR = tmp;
  if (argc < 2)
    return cgi_server();
  if (argc < 3)
    return run_server(atoi(argv[1]));
  return run_client(argc, argv);
}
Пример #22
0
int main(int argc, char**argv)
{
	TmsiAmplifier driver;
	AmplifierServer server(&driver);
	try{
	run_server(argc,argv,&server);
	}
	catch (exception &e){
		cerr << "Exception: "<<e.what();
	}
}
Пример #23
0
int main(int argc, char **argv) {
    if (argc == 3 && strcmp(argv[1], "-server") == 0) {
        return run_server((unsigned short) atoi(argv[2]));
    } else if (argc == 4 && strcmp(argv[1], "-client") == 0) {
        return run_client(argv[2], (unsigned short) atoi(argv[3]));
    }

    printf("Usage: echoz [-server [port] or -client [host] [port]\n");

    return 0;
}
Пример #24
0
static void case1(struct zco_context_t *context, int *stage)
{
    pthread_mutex_lock(&port_lock);

    run_server(context, (ZBindHandler) on_new_client1, last_port, stage);
    run_client(context, (ZBindHandler) on_client_ready1, last_port, stage);

    ++last_port;

    pthread_mutex_unlock(&port_lock);
}
Пример #25
0
Файл: main.c Проект: EmisFR/burp
int server(struct conf **confs, const char *conffile,
	struct lock *lock, int generate_ca_only)
{
	enum serret ret=SERVER_ERROR;
	int rfds[LISTEN_SOCKETS]; // Sockets for clients to connect to.
	int sfds[LISTEN_SOCKETS]; // Status server sockets.

	//return champ_test(confs);

	init_fds(rfds);
	init_fds(sfds);

	if(ca_server_setup(confs)) goto error;
	if(generate_ca_only)
	{
		logp("The '-g' command line option was given. Exiting now.\n");
		goto end;
	}

	if(get_int(confs[OPT_FORK]) && get_int(confs[OPT_DAEMON]))
	{
		if(daemonise() || relock(lock)) goto error;
	}

	ssl_load_globals();

	while(!gentleshutdown)
	{
		if(run_server(confs, conffile, rfds, sfds))
			goto error;

		if(hupreload && !gentleshutdown)
		{
			if(reload(confs, conffile,
				0, // Not first time.
				get_int(confs[OPT_MAX_CHILDREN]),
				get_int(confs[OPT_MAX_STATUS_CHILDREN])))
					goto error;
		}
		hupreload=0;
	}

end:
	ret=SERVER_OK;
error:
	close_fds(rfds);
	close_fds(sfds);

// FIX THIS: Have an enum for a return value, so that it is more obvious what
// is happening, like client.c does.
	return ret;
}
Пример #26
0
//entry point
int main(int argc, char **argv){

    printf("fakenav!\n");
    printf("waiting for google earth to open %s...\n", DEV_NAME);

    fd = open(DEV_NAME, O_WRONLY);
        
    printf("opened pipe!\n");
    
    signal(SIGINT, on_sigint);
        
    run_server();
}
Пример #27
0
int main() {
    struct sockaddr sa;

    unlink(SOCKETNAME);
    strcpy(sa.sa_data, SOCKETNAME);
    sa.sa_family = AF_UNIX;
    for (int client = 1; client <= 4; client++) {
        assert(run_client(&sa));
    }
    assert(run_server(&sa));

    return 0;
}
Пример #28
0
int main( int argc, char *argv[] )
{
    int size;
    char filename[100];

    MPI_Init(&argc, &argv);
    MPI_Comm_size(MPI_COMM_WORLD, &size);
    MPI_Comm_rank(MPI_COMM_WORLD, &rank);
    sprintf(filename, "log%d.txt", rank);
    logfid = fopen(filename,"a");
    rankprintf("rank %d of %d\n", rank, size);
    if (1 == size) {
      //Run just one degrid 
      // For testing
      memset(token_list, 0, sizeof(token*)*256);
      int data[3];
      data[0] = TASK_GENVIS;
      data[1] = 45;
      data[2] = NPOINTS;
      exec_task(data);
      data[0] = TASK_GENIMG;
      data[1] = 46;
      data[2] = IMG_SIZE;
      exec_task(data);
      data[0] = TASK_DEGRID;
      data[1] = 45;
      data[2] = 46;
      exec_task(data);
      rankprintf("All tasks complete\n");
      return 0;
    }
    if (size < 3)
    {
        rankprintf("Three processes needed to run this test.\n");fflush(stdout);
        MPI_Finalize();
        return 0;
    }

    if (rank == 0)
    {
       run_client(size);
    }
    else 
    {
       run_server(size);
    }
    fclose(logfid);
    MPI_Barrier(MPI_COMM_WORLD);
    MPI_Finalize();
    return 0;
}
Пример #29
0
int main (int argc, char ** argv) {
#if defined(_PARENT_SUPERVISION)
    pid_t pid, status, err;
#if defined(_DAEMONIZE)
    daemon(1, 0);
#endif
    do {
        pid = fork();
        if (pid) {
            /* Parent */
            DEBUG_OUT("Waiting for child\n");
            err = waitpid(pid, &status, 0);
        } else {
            /* Child */
            run_server(argc, argv);
            exit(0);
        }
    } while (1);
    return 0;
#else
    return run_server(argc, argv);
#endif
}
Пример #30
0
int main(int argc, char **argv)
{

	if (argc == 1) {
		printf("Usage: ./conn_sock [-s] [host]\n");
		exit(0);
	}

	if (strcmp(argv[1], "-s") == 0)
		run_server();
	else
		run_client();

	return 0;
}