本文整理汇总了C++中parse_arguments函数的典型用法代码示例。如果您正苦于以下问题:C++ parse_arguments函数的具体用法?C++ parse_arguments怎么用?C++ parse_arguments使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parse_arguments函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: THD_FUNCTION
/**
* @brief Shell thread function.
*
* @param[in] p pointer to a @p BaseSequentialStream object
*/
THD_FUNCTION(shellThread, p) {
int n;
BaseSequentialStream *chp = ((ShellConfig *)p)->sc_channel;
const ShellCommand *scp = ((ShellConfig *)p)->sc_commands;
char *lp, *cmd, *tokp, line[SHELL_MAX_LINE_LENGTH];
char *args[SHELL_MAX_ARGUMENTS + 1];
chprintf(chp, "\r\nChibiOS/RT Shell\r\n");
while (true) {
chprintf(chp, "ch> ");
if (shellGetLine(chp, line, sizeof(line))) {
#if (SHELL_CMD_EXIT_ENABLED == TRUE) && !defined(_CHIBIOS_NIL_)
chprintf(chp, "\r\nlogout");
break;
#else
/* Putting a delay in order to avoid an endless loop trying to read
an unavailable stream.*/
osalThreadSleepMilliseconds(100);
#endif
}
lp = parse_arguments(line, &tokp);
cmd = lp;
n = 0;
while ((lp = parse_arguments(NULL, &tokp)) != NULL) {
if (n >= SHELL_MAX_ARGUMENTS) {
chprintf(chp, "too many arguments\r\n");
cmd = NULL;
break;
}
args[n++] = lp;
}
args[n] = NULL;
if (cmd != NULL) {
if (strcmp(cmd, "exit") == 0) {
if (n > 0) {
usage(chp, "exit");
continue;
}
break;
}
else if (strcmp(cmd, "help") == 0) {
if (n > 0) {
usage(chp, "help");
continue;
}
chprintf(chp, "Commands: help exit ");
list_commands(chp, shell_local_commands);
if (scp != NULL)
list_commands(chp, scp);
chprintf(chp, "\r\n");
}
else if (cmdexec(shell_local_commands, chp, cmd, n, args) &&
((scp == NULL) || cmdexec(scp, chp, cmd, n, args))) {
chprintf(chp, "%s", cmd);
chprintf(chp, " ?\r\n");
}
}
}
shellExit(MSG_OK);
}
开发者ID:AlexShiLucky,项目名称:ChibiOS,代码行数:65,代码来源:shell.c
示例2: THD_FUNCTION
/**
* @brief Shell thread function.
*
* @param[in] p pointer to a @p BaseSequentialStream object
*/
THD_FUNCTION(shellThread, p) {
int n;
BaseSequentialStream *chp = ((ShellConfig *)p)->sc_channel;
const ShellCommand *scp = ((ShellConfig *)p)->sc_commands;
char *lp, *cmd, *tokp, line[SHELL_MAX_LINE_LENGTH];
char *args[SHELL_MAX_ARGUMENTS + 1];
chprintf(chp, "\r\nChibiOS/RT Shell\r\n");
while (true) {
chprintf(chp, "ch> ");
if (shellGetLine(chp, line, sizeof(line))) {
chprintf(chp, "\r\nlogout");
break;
}
lp = parse_arguments(line, &tokp);
cmd = lp;
n = 0;
while ((lp = parse_arguments(NULL, &tokp)) != NULL) {
if (n >= SHELL_MAX_ARGUMENTS) {
chprintf(chp, "too many arguments\r\n");
cmd = NULL;
break;
}
args[n++] = lp;
}
args[n] = NULL;
if (cmd != NULL) {
if (strcmp(cmd, "exit") == 0) {
if (n > 0) {
usage(chp, "exit");
continue;
}
break;
}
else if (strcmp(cmd, "help") == 0) {
if (n > 0) {
usage(chp, "help");
continue;
}
chprintf(chp, "Commands: help exit ");
list_commands(chp, shell_local_commands);
if (scp != NULL)
list_commands(chp, scp);
chprintf(chp, "\r\n");
}
else if (cmdexec(shell_local_commands, chp, cmd, n, args) &&
((scp == NULL) || cmdexec(scp, chp, cmd, n, args))) {
chprintf(chp, "%s", cmd);
chprintf(chp, " ?\r\n");
}
}
}
shellExit(MSG_OK);
}
开发者ID:krtkr,项目名称:ChibiOS,代码行数:59,代码来源:shell.c
示例3: test_invalid_color
void test_invalid_color(){
Arguments* parsed = NULL;
char* test[] = {"test", "-p", "regex1", "invalid_color"};
int result = parse_arguments(4, test, &parsed);
assert(result == ERR_UNKNOWN_COLOR);
assert(parsed == NULL);
}
开发者ID:damjanv90,项目名称:highlight,代码行数:7,代码来源:test_arg_parser.c
示例4: main
int
main (int argc, char *argv[])
{
parse_arguments (argc, argv);
/* become a JACK client */
if ((client = jack_client_open ("freewheel", JackNullOption, NULL)) == 0) {
fprintf (stderr, "JACK server not running?\n");
exit(1);
}
signal (SIGQUIT, signal_handler);
signal (SIGTERM, signal_handler);
signal (SIGHUP, signal_handler);
signal (SIGINT, signal_handler);
jack_on_shutdown (client, jack_shutdown, 0);
if (jack_set_freewheel (client, onoff)) {
fprintf (stderr, "failed to reset freewheel mode\n");
}
jack_client_close(client);
return 0;
}
开发者ID:johnsen,项目名称:jack2,代码行数:25,代码来源:freewheel.c
示例5: main
int main(int argc, char **argv)
{
char* pw, *crypted_pw;
crypt_mechs_root = (crypt_mechs_t*)MyMalloc(sizeof(crypt_mechs_t));
crypt_mechs_root->mech = NULL;
crypt_mechs_root->next = crypt_mechs_root->prev = NULL;
if (argc < 2)
{
show_help();
exit(0);
}
pw = parse_arguments(argc, argv);
load_mechs();
if (NULL == umkpasswd_conf->mech)
{
fprintf(stderr, "No mechanism specified.\n");
abort();
}
if (NULL == pw)
{
pw = getpass("Password: ");
}
crypted_pw = crypt_pass(pw, umkpasswd_conf->mech);
printf("Crypted Pass: %s\n", crypted_pw);
memset(pw, 0, strlen(pw));
return 0;
}
开发者ID:NX-Andro,项目名称:nefarious,代码行数:34,代码来源:umkpasswd.c
示例6: main
int main(int argc, char *argv[]) {
iParams p;
int i;
/* set defaults for parameters */
p.a = 0.0;
p.b = 1.0;
p.n = 10;
parse_arguments(argc, argv, &p);
fprintf(stdout,"Initializing integration of f(x) = sqrt(x) + sin(x^(3/2)), from %f to %f with %d segments\n",p.a, p.b, p.n);
p.h = (double)(p.b - p.a)/(double)p.n;
double trapezoid_sum = 0;
for (i = 0; i < p.n; ++i) {
trapezoid_sum += trapezoid(p.a + (double)i * p.h, p.a + (double)(i+1) * p.h);
}
fprintf(stdout, "Integrated value: %20.15f\n",trapezoid_sum);
return 0;
}
开发者ID:paulsoper,项目名称:area-under-a-curve,代码行数:25,代码来源:trapezoid.c
示例7: main
int main(int argc, char* argv[]) {
try {
parse_arguments(argc, argv);
FLM_Conf flm_conf(flmparamfile);
GA_Conf ga_conf(flm_conf, gaparamfile, seedfile);
GA ga(ga_conf, flm_conf);
// TODO: set a fixed random seed with a command-line argument for reproducibility
unsigned random_seed = chrono::system_clock::now().time_since_epoch().count();
GA_Operator::set_random_seed(random_seed);
float best_fitness, best_perplexity;
Chromosome best = ga.search(best_fitness, best_perplexity);
cerr << "Best fitness: " << best_fitness << endl;
cerr << "Best best_perplexity: " << best_perplexity << endl;
// backup_best(ga_conf.ga_path, to_string(best));
} catch (char const* s) {
cerr << "ERROR: " << s << endl;
return 1;
} catch (string s) {
cerr << "ERROR: " << s << endl;
return 1;
}
return 0;
}
开发者ID:zahlenteufel,项目名称:GA-FLM,代码行数:27,代码来源:main.cpp
示例8: sef_cb_init_fresh
/*===========================================================================*
* sef_cb_init_fresh *
*===========================================================================*/
PRIVATE int sef_cb_init_fresh(int type, sef_init_info_t *info)
{
/* Initialize the filter driver. */
int r;
r = parse_arguments(env_argc, env_argv);
if(r != OK) {
printf("Filter: wrong argument!\n");
return 1;
}
if ((buf_array = flt_malloc(BUF_SIZE, NULL, 0)) == NULL)
panic("no memory available");
sum_init();
driver_init();
/* Subscribe to driver events for VFS drivers. */
r = ds_subscribe("drv\\.vfs\\..*", DSF_INITIAL | DSF_OVERWRITE);
if(r != OK) {
panic("Filter: can't subscribe to driver events");
}
/* Announce we are up! */
driver_announce();
return(OK);
}
开发者ID:Spenser309,项目名称:CS551,代码行数:32,代码来源:main.c
示例9: main
int main(int argc, char *argv[])
{
int rc;
parse_arguments(argc, argv);
/* become a JACK client */
if ((client = jack_client_open(package, JackNullOption, NULL)) == 0) {
fprintf(stderr, "JACK server not running?\n");
exit(1);
}
#ifndef WIN32
signal(SIGQUIT, signal_handler);
signal(SIGHUP, signal_handler);
#endif
signal(SIGTERM, signal_handler);
signal(SIGINT, signal_handler);
jack_on_shutdown(client, jack_shutdown, 0);
if (just_print_bufsize) {
fprintf(stdout, "buffer size = %d sample rate = %d\n", jack_get_buffer_size(client), jack_get_sample_rate(client));
rc=0;
}
else
{
rc = jack_set_buffer_size(client, nframes);
if (rc)
fprintf(stderr, "jack_set_buffer_size(): %s\n", strerror(rc));
}
jack_client_close(client);
return rc;
}
开发者ID:HI-CARL,项目名称:jack2,代码行数:35,代码来源:bufsize.c
示例10: test_all_options_long
void test_all_options_long(){
Arguments* parsed = NULL;
char* test[] = {"test", "--selection-only", "--background", "--help", "--ignore-case"};
int result = parse_arguments(5, test, &parsed);
assert(result == SUCCESS);
assert(parsed->input_file == NULL);
assert(parsed->options.first != NULL);
OptionListItem* first = (OptionListItem*)(parsed->options.first);
assert(first->item.next != NULL);
OptionListItem* second = (OptionListItem*)(first->item.next);
assert(second->item.next != NULL);
OptionListItem* third = (OptionListItem*)(second->item.next);
assert(third->item.next != NULL);
OptionListItem* fourth = (OptionListItem*)(third->item.next);
assert(first->opt == SELECTION_ONLY);
assert(second->opt == BACKGROUND);
assert(third->opt == PRINT_HELP);
assert(fourth->opt == IGNORE_CASE);
}
开发者ID:damjanv90,项目名称:highlight,代码行数:25,代码来源:test_arg_parser.c
示例11: main
int main (int argc, char** argv) {
// parse the program arguments
options in_options = options();
CHECK(parse_arguments(argc, argv, in_options));
// parse the input graph
std::unordered_map<uint64_t,cell> graph;
CHECK(parse_graph(in_options, graph));
//CHECK(validate_parser(in_options, graph));
// factor the number of partitions
std::vector<uint64_t> factors(0);
CHECK(factor(in_options, factors));
CHECK(validate_factors(in_options, factors));
// partition!
CHECK(partition(in_options, graph, factors));
// write partitions
CHECK(write_partitions(in_options, graph));
CHECK(do_cleanup(graph));
return 0;
}
开发者ID:khuck,项目名称:hindsight2,代码行数:26,代码来源:main.cpp
示例12: test_all_options_short
void test_all_options_short(){
Arguments* parsed = NULL;
char* test[] = {"test", "-s", "-b", "-h", "-i"};
int result = parse_arguments(5, test, &parsed);
assert(result == SUCCESS);
assert(parsed->input_file == NULL);
assert(parsed->options.first != NULL);
OptionListItem* first = (OptionListItem*)(parsed->options.first);
assert(first->item.next != NULL);
OptionListItem* second = (OptionListItem*)(first->item.next);
assert(second->item.next != NULL);
OptionListItem* third = (OptionListItem*)(second->item.next);
assert(third->item.next != NULL);
OptionListItem* fourth = (OptionListItem*)(third->item.next);
assert(first->opt == SELECTION_ONLY);
assert(second->opt == BACKGROUND);
assert(third->opt == PRINT_HELP);
assert(fourth->opt == IGNORE_CASE);
}
开发者ID:damjanv90,项目名称:highlight,代码行数:25,代码来源:test_arg_parser.c
示例13: test_invalid_option
void test_invalid_option(){
Arguments* parsed = NULL;
char* test[] = {"test", "--invalid_option"};
int result = parse_arguments(2, test, &parsed);
assert(result == ERR_UNKNOWN_OPTION);
assert(parsed == NULL);
}
开发者ID:damjanv90,项目名称:highlight,代码行数:7,代码来源:test_arg_parser.c
示例14: test_invalid_pattern
void test_invalid_pattern(){
Arguments* parsed = NULL;
char* test[] = {"test", "-p", "regex"};
int result = parse_arguments(3, test, &parsed);
assert(result == ERR_INVALID_PATTERN);
assert(parsed == NULL);
}
开发者ID:damjanv90,项目名称:highlight,代码行数:7,代码来源:test_arg_parser.c
示例15: main
int main(int argc, char **argv)
{
int result;
struct email *email;
email = alloc_email();
result = parse_arguments(argc, argv, email);
if (result != 0)
{
free_email(email);
return 1;
}
result = send_email(email);
if (result != 0)
{
free_email(email);
return 1;
}
free_email(email);
return 0;
}
开发者ID:johndistasio,项目名称:mailer,代码行数:26,代码来源:mailer.c
示例16: main
int main(int argc, char * argv[])
{
struct arguments args;
parse_arguments(argc, argv, &args);
struct jpeg_compress_struct outputinfo;
JBLOCKARRAY coef_buffers[MAX_COMPONENTS];
FILE *output = setup_output(args.outputname, &outputinfo);
read_DCT(args.inputname, coef_buffers, &outputinfo);
unsigned int seed = (unsigned) strtoul(args.userPassword, NULL, 10);
node *root;
size_t usable_size = make_linked_list(coef_buffers, seed, &root);
if (args.embedFlag) {
embed(coef_buffers, args.embedMessage, root, usable_size);
write_DCT(args.outputname, coef_buffers, &outputinfo);
}
else if (args.extractFlag) {
extract(args.message_size, root, usable_size);
}
fclose(output);
return 0;
}
开发者ID:gwengrid,项目名称:C-Steganography-Framework,代码行数:29,代码来源:main.c
示例17: modsecurity_request_body_end_urlencoded
static apr_status_t modsecurity_request_body_end_urlencoded(modsec_rec *msr, char **error_msg) {
int invalid_count = 0;
*error_msg = NULL;
/* Create the raw buffer */
if (modsecurity_request_body_end_raw(msr, error_msg) != 1) {
return -1;
}
/* Parse URL-encoded arguments in the request body. */
if (parse_arguments(msr, msr->msc_reqbody_buffer, msr->msc_reqbody_length,
msr->txcfg->argument_separator, "BODY", msr->arguments, &invalid_count) < 0)
{
*error_msg = apr_pstrdup(msr->mp, "Initialisation: Error occurred while parsing BODY arguments.");
return -1;
}
if (invalid_count) {
msr->urlencoded_error = 1;
}
return 1;
}
开发者ID:MHMDhub,项目名称:ModSecurity,代码行数:25,代码来源:msc_reqbody.c
示例18: main
int main(const int argc, char * const * argv)
{
parse_arguments(argc, argv);
if (is_server) {
run_as_server();
}
if (is_client) {
run_as_client();
}
if (stdin_file_descriptor)
fclose(stdin_file_descriptor);
if (stdout_file_descriptor)
fclose(stdout_file_descriptor);
if (stderr_file_descriptor)
fclose(stderr_file_descriptor);
if (server_hostname) {
free (server_hostname);
}
if (connection_type) {
free (connection_type);
}
return 0;
}
开发者ID:shrenikjain38,项目名称:ftutil,代码行数:26,代码来源:main.c
示例19: fork
pid_t GraphBuilder::start_child(const char* pathfile)
{
char **argv;
char *envp[] = { NULL };
pid_t pid;
int ret;
pid = fork();
switch(pid) {
/* child process */
case 0:
/* sleep 1 second to have enough time to setup
* the scid driver */
ret = sem_wait(child_sem);
DIE(ret < 0, "error waiting for semaphore");
argv = parse_arguments(pathfile);
DIE(argv == NULL, "error parsing arguments");
ret = execve(argv[0], argv, envp);
DIE(ret < 0, "error running execve");
break;
/* father process */
default:
DIE(pid < 0, "fork failed");
/* else just return the child process's pid */
break;
}
return pid;
}
开发者ID:nikopo1,项目名称:malware-sharpshooter,代码行数:27,代码来源:graphbuilder.cpp
示例20: main
int main(int argc, char *argv[]) {
log_open("./core_log.txt"); //或许写成参数更好,懒得写了
atexit(output_result); //退出程序时的回调函数,用于输出判题结果
//为了构建沙盒,必须要有root权限
if (geteuid() != 0) {
FM_LOG_FATAL("You must run this program as root.");
exit(JUDGE_CONF::EXIT_UNPRIVILEGED);
}
parse_arguments(argc, argv);
JUDGE_CONF::JUDGE_TIME_LIMIT += PROBLEM::time_limit;
if (EXIT_SUCCESS != malarm(ITIMER_REAL, JUDGE_CONF::JUDGE_TIME_LIMIT)) {
FM_LOG_WARNING("Set the alarm for this judge program failed, %d: %s", errno, strerror(errno));
exit(JUDGE_CONF::EXIT_VERY_FIRST);
}
signal(SIGALRM, timeout);
compiler_source_code();
judge();
if (PROBLEM::spj) {
run_spj();
} else {
if (PROBLEM::result == JUDGE_CONF::SE)
PROBLEM::result = compare_output(PROBLEM::output_file, PROBLEM::exec_output);
}
return 0;
}
开发者ID:NJUST-FishTeam,项目名称:OnlineJudgeCore,代码行数:35,代码来源:core.cpp
注:本文中的parse_arguments函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论