当前位置: 首页>>代码示例>>C++>>正文


C++ process_arguments函数代码示例

本文整理汇总了C++中process_arguments函数的典型用法代码示例。如果您正苦于以下问题:C++ process_arguments函数的具体用法?C++ process_arguments怎么用?C++ process_arguments使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了process_arguments函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char *argv[], char *envp[])
{

    if (process_arguments(argc, argv) == ERROR)
        exit(ERROR);

    pid_t pid;
    int error_code = 0;
    switch (pid = fork()) {
    case -1:
        /* Here pid is -1, the fork failed */
        /* Some possible reasons are that you're */
        /* out of process slots or virtual memory */
        perror("The fork failed!");
        error_code = -1;
        break;

    case 0:
        /* pid of zero is the child */
        signal(SIGALRM, timeout_sighandler);
        alarm(timeout);
        process_env(envp);
        _exit(0);

    default:
        /* pid greater than zero is parent getting the child's pid */
        //printf("Child's pid is %d\n",pid);
        error_code = 0;
    }
    exit(error_code);
}
开发者ID:hstraub,项目名称:nagperfdiag,代码行数:31,代码来源:pnpsender.c

示例2: main

int main(int argc, char* argv[])
{
    size_t seconds = TEST_SECONDS;

    METRIC_AZURE_INFO metric_info;
    process_arguments(argc, (const char**)argv, &metric_info);

    if (platform_init() == 0)
    {
        gballoc_init();

        if (ExecuteIotHubTest(&metric_info, seconds) != 0)
        {
            (void)printf("Mqtt run failed\r\n");
        }
        gballoc_deinit();
        platform_deinit();
    }
    else
    {
        (void)printf("Platform_Init Failed\r\n");
    }

    (void)printf("Press any key to exit: ");
    (int)getchar();
    return 0;
}
开发者ID:jebrando,项目名称:azureiot-metrics,代码行数:27,代码来源:main.cpp

示例3: main

int main(int argc, char **argv)
{
    setlocale(LC_ALL,"");

    /* what to do if we get a control-c */
    signal(SIGINT,quit);

    programInits(&properties);

    props_defaults_options(&properties,1);
    props_defaults_futures(&future_properties,1);

#if defined(HAVE_GETOPT_H) && defined(HAVE_GETTIMEOFDAY)

    process_arguments(argc, argv, &properties.data.debug);

#endif

    initscr();
    keypad(stdscr,TRUE);

    welcome_screen();

    for(;;)
    {
        /* get initial user inputs */
        if( get_user_inputs(&properties,&future_properties) == -1 )
          continue;

        curses_process(&properties,&future_properties);

    } /* for(;;) */
}
开发者ID:mmizutani,项目名称:optionmatrix,代码行数:33,代码来源:curses_main.cpp

示例4: main

int main(int argc, char **argv){
	int dhcp_socket;
	int result;

	if(process_arguments(argc,argv)!=OK){
		/*usage("Invalid command arguments supplied\n");*/
		printf("Invalid command arguments supplied\n");
		exit(STATE_UNKNOWN);
	        }


	/* create socket for DHCP communications */
	dhcp_socket=create_dhcp_socket();

	/* get hardware address of client machine */
	get_hardware_address(dhcp_socket,network_interface_name);

	/* send DHCPDISCOVER packet */
	send_dhcp_discover(dhcp_socket);

	/* wait for a DHCPOFFER packet */
	get_dhcp_offer(dhcp_socket);

	/* close socket we created */
	close_dhcp_socket(dhcp_socket);

	/* determine state/plugin output to return */
	result=get_results();

	/* free allocated memory */
	free_dhcp_offer_list();
	free_requested_server_list();

	return result;
        }
开发者ID:nomius,项目名称:kwtools,代码行数:35,代码来源:test_dhcp.c

示例5: main

/* -------------------------------------------------------------
// ------   MAIN - replace this by your own aplication! 
// ------------------------------------------------------------- */
int main(int argn, char *argv[]) {
  int multipnm=1;
  job_t job;

  JOB = &job;
  setvbuf(stdout, (char *) NULL, _IONBF, 0);	/* not buffered */
  
  while (multipnm==1) {

    job_init(&job);
  
    process_arguments(&job, argn, argv);

    mark_start(&job);

    multipnm = read_picture(&job);
    /* separation of main and rest for using as lib
       this will be changed later => introduction of set_option()
       for better communication to the engine  */
    if (multipnm<0) break; /* read error */
  
    /* call main loop */
    pgm2asc(&job);

    mark_end(&job);
  
    print_output(&job);

    job_free(&job);
  
  }
  
  return 0;
}
开发者ID:cyb3727,项目名称:annrecognition,代码行数:37,代码来源:gocr.c

示例6: main

int
main (int argc, char **argv)
{
	int result = STATE_UNKNOWN;

	setlocale (LC_ALL, "");
	bindtextdomain (PACKAGE, LOCALEDIR);
	textdomain (PACKAGE);

	/* Parse extra opts if any */
	argv=np_extra_opts (&argc, argv, progname);

	if (process_arguments (argc, argv) == ERROR)
		usage4 (_("Could not parse arguments"));

	/* initialize alarm signal handling */
	signal (SIGALRM, socket_timeout_alarm_handler);

	alarm (socket_timeout);

	/* ssh_connect exits if error is found */
	result = ssh_connect (server_name, port, remote_version);

	alarm (0);

	return (result);
}
开发者ID:dermoth,项目名称:monitoring-plugins,代码行数:27,代码来源:check_ssh.c

示例7: main

int main (int argc, char **argv) {
    /* Local Vars */
    FILE        *fp;
    mp_subprocess_t *subp;
    char        line[128];
    int         failed = 0;
    int         lines = 0;
    uid_t       uid;

    /* Set signal handling and alarm */
    if (signal(SIGALRM, timeout_alarm_handler) == SIG_ERR)
        critical("Setup SIGALRM trap failed!");

    /* Process check arguments */
    if (process_arguments(argc, argv) != OK)
        unknown("Parsing arguments failed!");

    /* Start plugin timeout */
    alarm(mp_timeout);

    // Need to be root
    if (nonroot == 0)
        mp_noneroot_die();

    alarm(mp_timeout);

    // Parse clustat
    if (nonroot == 0) {
        uid = getuid();
        if (setuid(0) != 0)
            unknown("setuid failed");
        subp = mp_subprocess((char *[]) {"/sbin/multipath","-l", NULL});
开发者ID:MonitoringPlug,项目名称:monitoringplug,代码行数:32,代码来源:check_multipath.c

示例8: main

int main (int argc, char **argv) {
    /* Local Vars */
    virConnectPtr   conn;
    const char      *hvType;
    unsigned long libVer, libMajor, libMinor, libRelease;
    unsigned long hvVer, hvMajor, hvMinor, hvRelease;

    /* Set signal handling and alarm */
    if (signal(SIGALRM, timeout_alarm_handler) == SIG_ERR)
        critical("Setup SIGALRM trap failed!");

    /* Process check arguments */
    if (process_arguments(argc, argv) != OK)
        unknown("Parsing arguments failed!");

    /* Start plugin timeout */
    alarm(mp_timeout);

    // PLUGIN CODE
    conn = virt_connect();

    hvType = virConnectGetType(conn);
    if (hvType == NULL) {
        if (mp_verbose > 0) {
            virt_showError(conn);
        }
        critical("Failed to get hypervisor type.");
    }

    if (virConnectGetVersion(conn, &hvVer) != 0) {
        if (mp_verbose > 0) {
            virt_showError(conn);
        }
        critical("Failed to get hypervisor version.");
    }

    if (virConnectGetLibVersion(conn, &libVer) != 0) {
        if (mp_verbose > 0) {
            virt_showError(conn);
        }
        critical("Failed to get library version.");
    }

    virConnectClose(conn);

    hvMajor = hvVer / 1000000;
    hvVer %= 1000000;
    hvMinor = hvVer / 1000;
    hvRelease = hvVer % 1000;

    libMajor = libVer / 1000000;
    libVer %= 1000000;
    libMinor = libVer / 1000;
    libRelease = libVer % 1000;

    /* Output and return */
    ok("libvirtd: v.%lu.%lu.%lu Hypervisor: %s (v.%lu.%lu.%lu)", 
            libMajor, libMinor, libRelease,
            hvType, hvMajor, hvMinor, hvRelease);
}
开发者ID:rjuju,项目名称:monitoringplug,代码行数:60,代码来源:check_libvirtd.c

示例9: main

int main(int argc, char ** argv)
{
	int err;

	if (!process_arguments(argc, argv))
		goto could_not_process_arguments;

	err = pe_as_lit_kw_map_rd_open(&keywords, keywords_file);
	if (err)
		goto could_not_open_keywords;

	err = pe_lexer_open(&lexer, input_file_name, output_prefix, &keywords.map);
	if (err)
		goto could_not_open_lexer;

	if (!lex(&lexer))
		goto could_not_lex;

	err = pe_lexer_close(&lexer);
	if (err)
		goto could_not_close_lexer;

	pe_as_lit_kw_map_rd_close(&keywords);
	return EXIT_SUCCESS;

could_not_lex:
	(void)pe_lexer_close(&lexer);
could_not_close_lexer:
could_not_open_lexer:
	(void)pe_as_lit_kw_map_rd_close(&keywords);
could_not_open_keywords:
could_not_process_arguments:
	return EXIT_FAILURE;
}
开发者ID:nineties-retro,项目名称:pep,代码行数:34,代码来源:pe_lexer_cl.c

示例10: process_options

static void
process_options(int argc, char **argv)
{
  if (tpd == 1) fprintf(stderr,"sman:process_options entered\n");
  set_up_defaults();
  process_arguments(argc, argv);
  if (tpd == 1) fprintf(stderr,"sman:process_options exit\n");
}
开发者ID:EmmanuelCharpentier,项目名称:fricas,代码行数:8,代码来源:sman.c

示例11: main

int main(int argc, char *argv[]) {
    int result, offset_result;
    double offset=0;
    char *result_line, *perfdata_line;

    setlocale (LC_ALL, "");
    bindtextdomain (PACKAGE, LOCALEDIR);
    textdomain (PACKAGE);

    result = offset_result = STATE_OK;

    /* Parse extra opts if any */
    argv=np_extra_opts (&argc, argv, progname);

    if (process_arguments (argc, argv) == ERROR)
        usage4 (_("Could not parse arguments"));

    set_thresholds(&offset_thresholds, owarn, ocrit);

    /* initialize alarm signal handling */
    signal (SIGALRM, socket_timeout_alarm_handler);

    /* set socket timeout */
    alarm (socket_timeout);

    offset = offset_request(server_address, &offset_result);
    if (offset_result == STATE_UNKNOWN) {
        result = (quiet == 1 ? STATE_UNKNOWN : STATE_CRITICAL);
    } else {
        result = get_status(fabs(offset), offset_thresholds);
    }

    switch (result) {
    case STATE_CRITICAL :
        xasprintf(&result_line, _("NTP CRITICAL:"));
        break;
    case STATE_WARNING :
        xasprintf(&result_line, _("NTP WARNING:"));
        break;
    case STATE_OK :
        xasprintf(&result_line, _("NTP OK:"));
        break;
    default :
        xasprintf(&result_line, _("NTP UNKNOWN:"));
        break;
    }
    if(offset_result == STATE_UNKNOWN) {
        xasprintf(&result_line, "%s %s", result_line, _("Offset unknown"));
        xasprintf(&perfdata_line, "");
    } else {
        xasprintf(&result_line, "%s %s %.10g secs", result_line, _("Offset"), offset);
        xasprintf(&perfdata_line, "%s", perfd_offset(offset));
    }
    printf("%s|%s\n", result_line, perfdata_line);

    if(server_address!=NULL) free(server_address);
    return result;
}
开发者ID:hjanuschka,项目名称:nagios-plugins,代码行数:58,代码来源:check_ntp_time.c

示例12: main

int main (int argc, char **argv) {

	// base values
	int status, intvalue;
	int upminutes, uphours, updays;
	double value, uptime;
	char* perf;
	char* output_message;

	/* Parse extra opts if any */
	argv = np_extra_opts (&argc, argv, progname);

	if (process_arguments (argc, argv) == ERROR)
		usage4 (_("Could not parse arguments"));

	value = getuptime();
	if (verbose >= 3) {
		printf("Uptime in seconds returned from timespec struct: %f\n", value);
	}
	intvalue = (int)value;
	
	updays = intvalue / 86400;
	uphours = (intvalue % 86400) / 3600;
	upminutes = ((intvalue % 86400) % 3600) / 60;

	if (!strncmp(timeunit, "minutes", strlen("minutes"))) {
		uptime = intvalue / 60;
	} else if (!strncmp(timeunit, "hours", strlen("hours"))) {
		uptime = intvalue / 3600;
	} else if (!strncmp(timeunit, "days", strlen("days"))) {
		uptime = intvalue / 86400;
	} else {
		uptime = intvalue;
	}	
	
	xasprintf(&output_message,_("%u day(s) %u hour(s) %u minute(s)"), updays, uphours, upminutes);
	
	xasprintf(&perf,_("%s"), 
	 fperfdata("uptime", uptime, "",
	 my_thresholds->warning?TRUE:FALSE, my_thresholds->warning?my_thresholds->warning->end:0,
	 my_thresholds->critical?TRUE:FALSE, my_thresholds->critical?my_thresholds->critical->end:0,
	 FALSE, 0,
	 FALSE, 0)
	);
	
	status = get_status(uptime, my_thresholds);
	
	if (status == STATE_OK) {
		printf("Uptime %s: %s | %s\n", _("OK"), output_message, perf);
	} else if (status == STATE_WARNING) {
		printf("Uptime %s: %s | %s\n", _("WARNING"), output_message, perf);
	} else if (status == STATE_CRITICAL) {
		printf("Uptime %s: %s | %s\n", _("CRITICAL"), output_message, perf);
	}

	return status;

} // end main
开发者ID:tankinger,项目名称:nagios_script,代码行数:58,代码来源:check_uptime.c

示例13: main

int
main (int argc, char **argv)
{
	int elapsed_time;
	int status = STATE_UNKNOWN;

	/* begin, by setting the parameters for a backend connection if the
	 * parameters are null, then the system will try to use reasonable
	 * defaults by looking up environment variables or, failing that,
	 * using hardwired constants */

	pgoptions = NULL;  /* special options to start up the backend server */
	pgtty = NULL;      /* debugging tty for the backend server */

	setlocale (LC_ALL, "");
	bindtextdomain (PACKAGE, LOCALEDIR);
	textdomain (PACKAGE);

	if (process_arguments (argc, argv) == ERROR)
		usage4 (_("Could not parse arguments"));

	/* Set signal handling and alarm */
	if (signal (SIGALRM, timeout_alarm_handler) == SIG_ERR) {
		usage4 (_("Cannot catch SIGALRM"));
	}
	alarm (timeout_interval);

	/* make a connection to the database */
	time (&start_time);
	conn =
		PQsetdbLogin (pghost, pgport, pgoptions, pgtty, dbName, pguser, pgpasswd);
	time (&end_time);
	elapsed_time = (int) (end_time - start_time);

	/* check to see that the backend connection was successfully made */
	if (PQstatus (conn) == CONNECTION_BAD) {
		printf (_("CRITICAL - no connection to '%s' (%s).\n"),
		        dbName,	PQerrorMessage (conn));
		PQfinish (conn);
		return STATE_CRITICAL;
	}
	else if (elapsed_time > tcrit) {
		status = STATE_CRITICAL;
	}
	else if (elapsed_time > twarn) {
		status = STATE_WARNING;
	}
	else {
		status = STATE_OK;
	}
	PQfinish (conn);
	printf (_(" %s - database %s (%d sec.)|%s\n"), 
	        state_text(status), dbName, elapsed_time,
	        fperfdata("time", elapsed_time, "s",
	                 (int)twarn, twarn, (int)tcrit, tcrit, TRUE, 0, FALSE,0));
	return status;
}
开发者ID:rmoorman,项目名称:build,代码行数:57,代码来源:check_pgsql.c

示例14: main

// Entry point
int
main(int argc, char **argv)
{
	GTH_api api;
	int data_socket = -1;
	int result;
	int monitoring = 0;
	int verbose = 0;
	Channel_t channels[MAX_MTP2_CHANNELS];
	int i;
	int n_channels = 0;
	int n_sus_per_file = 0;
	int duration_per_file = 0;
	int stop_after_interval = 0;
	int output_filename_format = 0;
	int drop_fisus = 0;
	int esnf = 0;
	int listen_port = 0;
	int listen_socket = -1;
	enum PCap_format format = PCAP_NG;
	char *hostname;
	char *base_filename;

	// Check a couple of assumptions about type size.
	assert(sizeof(u32) == 4);
	assert(sizeof(u16) == 2);

	win32_specific_startup();

	process_arguments(argv, argc,
		&monitoring, &verbose, &n_sus_per_file, &duration_per_file, &stop_after_interval, &output_filename_format,
		&drop_fisus, &esnf, &hostname, channels, &n_channels,
		&base_filename, &format);
	result = gth_connect(&api, hostname, verbose);
	if (result != 0) {
		die("Unable to connect to the GTH. Giving up.");
	}

	read_hw_description(&api, hostname);
	enable_l1(&api, channels, n_channels, monitoring);

	listen_socket = gth_make_listen_socket(&listen_port);
	for (i = 0; i < n_channels; i++){
		monitor_mtp2(&api, channels + i,
			i, drop_fisus, esnf, listen_port, listen_socket);
		if (i == 0) {
			data_socket = gth_wait_for_accept(listen_socket);
		}
	}

	fprintf(stderr, "capturing packets, press ^C to abort\n");
	convert_to_pcap(&api, data_socket, base_filename,
		n_sus_per_file, duration_per_file, stop_after_interval, output_filename_format,
		channels, n_channels, format);

	return 0; // not reached
}
开发者ID:GemikGmbH,项目名称:Corelatus-GTH-example-code,代码行数:58,代码来源:save_to_pcap.c

示例15: main

int main (int argc, char **argv) {
    /* Local Vars */
    MYSQL *conn;
    MYSQL_RES *result;
    MYSQL_ROW row;
    int ret;
    int i;
    const char *server_version;
    struct timeval  start_time;
    double          time_delta;

    /* Set signal handling and alarm */
    if (signal(SIGALRM, timeout_alarm_handler) == SIG_ERR)
        critical("Setup SIGALRM trap failed!");

    /* Process check arguments */
    if (process_arguments(argc, argv) != OK)
        unknown("Parsing arguments failed!");

    /* Start plugin timeout */
    alarm(mp_timeout);
    gettimeofday(&start_time, NULL);

    /* Connectiong to mysqld */
    conn = mp_mysql_init();

    /* Get server version */
    server_version = mysql_get_server_info(conn);

    /* Get status info */
    if (mp_showperfdata) {
        ret = mysql_query(conn, "SHOW /*!50002 GLOBAL */ STATUS;");
        if (ret != 0)
            critical("Query 'SHOW GLOBAL STATUS' failed: %s", mysql_error(conn));

        result = mysql_store_result(conn);

        while ((row = mysql_fetch_row(result))) {
            for (i=0; i < variables; i++) {
                if (strcmp(variable[i], row[0]) == 0) {
                    mp_perfdata_int(row[0], strtol(row[1], NULL, 10), unit[i], NULL);
                }
            }
        }

        mysql_free_result(result);
    }

    mp_mysql_deinit(conn);

    time_delta = mp_time_delta(start_time);
    mp_perfdata_float("time", (float)time_delta, "s", NULL);

    ok("MySQL v%s", server_version);

    critical("You should never reach this point.");
}
开发者ID:MonitoringPlug,项目名称:monitoringplug,代码行数:57,代码来源:check_mysql.c


注:本文中的process_arguments函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。