本文整理汇总了C++中read_args函数的典型用法代码示例。如果您正苦于以下问题:C++ read_args函数的具体用法?C++ read_args怎么用?C++ read_args使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了read_args函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: calloc
struct token *expand(struct token *original)
{
const struct token *list;
struct token *res;
/* Do nothing if there is nothing to expand. */
if (!needs_expansion(original))
return original;
list = original;
res = calloc(1, sizeof(*res));
res[0] = token_end;
while (list->token != END) {
const struct macro *def = definition(*list);
struct token **args;
/* Only expand function-like macros if they appear as function
* invocations, beginning with an open paranthesis. */
if (def && !is_macro_expanded(def) &&
(def->type != FUNCTION_LIKE || peek_next(list + 1) == '('))
{
args = read_args(list + 1, &list, def);
res = concat(res, expand_macro(def, args));
} else {
res = append(res, *list++);
}
}
free(original);
return res;
}
示例2: main
/****************************************************************************
* Function implementations
****************************************************************************/
int
main(int argc, char *argv[])
{
/* Read program arguments */
program_name = argv[0];
read_args(argc, argv);
/* Try and read the problem file and its info */
arrow_problem problem;
if(!arrow_problem_read(input_file, &problem))
{
arrow_print_error("Could not read input file.\n");
}
/* Solve TSP */
arrow_tsp_result result;
if(!arrow_tsp_result_init(&problem, &result))
arrow_print_error("Could not initialize result structure.\n");
if(!arrow_tsp_cc_exact_solve(&problem, NULL, &result))
arrow_print_error("Could not solve TSP on file.\n");
printf("\nFound Tour: %d\n", result.found_tour);
printf("Tour length: %5.0f\n", result.obj_value);
printf("Total Time: %5.2f\n", result.total_time);
/* Free up the structures */
arrow_tsp_result_destruct(&result);
arrow_problem_destruct(&problem);
return EXIT_SUCCESS;
}
示例3: main
int
main(int argc, char **argv)
{
int ret;
settings_init();
if (set_signal_handler(signals) == -1) {
return -1;
}
tc_time_init();
if (read_args(argc, argv) == -1) {
return -1;
}
if (srv_settings.log_path == NULL) {
srv_settings.log_path = "error_intercept.log";
}
if (tc_log_init(srv_settings.log_path) == -1) {
return -1;
}
ret = tc_event_loop_init(&s_event_loop, MAX_FD_NUM);
if (ret == TC_EVENT_ERROR) {
tc_log_info(LOG_ERR, 0, "event loop init failed");
return -1;
}
/* output debug info */
output_for_debug();
if (set_details() == -1) {
return -1;
}
if (interception_init(&s_event_loop, srv_settings.binded_ip,
srv_settings.port) == TC_ERROR)
{
return -1;
}
if (set_timer() == -1) {
return -1;
}
#if (INTERCEPT_COMBINED)
tc_event_timer_add(&s_event_loop, CHECK_INTERVAL, interception_push);
#endif
tc_event_timer_add(&s_event_loop, OUTPUT_INTERVAL,
interception_output_stat);
/* run now */
tc_event_process_cycle(&s_event_loop);
server_release_resources();
return 0;
}
示例4: op_sum
void op_sum(const char *p) {
Mesg request, response;
request.mesg_type = pid;
request.op = SUM_GET;
read_args(p, &request);
send_request(&request, &response);
sleep(op_time);
request.op = SUM_SET;
int sum = 0;
size_t i;
for (i = 1; i < request.args_count; i++) {
sum += response.args[i];
}
request.args[request.args_count++] = sum;
send_request(&request, &response);
printf("s %d", request.args[0]);
for (i = 1; i < request.args_count; i++) {
printf(" %d", request.args[i]);
}
printf("\n");
}
示例5: main
/*
* Main entry point
*/
int
main(int argc ,char **argv)
{
int ret;
/* first, init time */
tc_time_update();
/* Set defaults */
settings_init();
read_args(argc, argv);
/* Init log for outputing debug info */
log_init(clt_settings.log_path);
/* Output debug info */
output_for_debug(argc, argv);
/* Set details for running */
set_details();
ret = tc_event_loop_init(&event_loop, MAX_FD_NUM);
if (ret == TC_EVENT_ERROR) {
log_info(LOG_ERR, "event loop init failed");
return -1;
}
/* Initiate tcpcopy client*/
ret = tcp_copy_init(&event_loop);
if (SUCCESS != ret) {
exit(EXIT_FAILURE);
}
/* Run now */
tc_event_process_cycle(&event_loop);
return 0;
}
示例6: b_cmd
void b_cmd(int pid){
char *cmds[10], s[100], *endptr;
long unsigned int address;
int i = 0;
while(1){
printf("->");
read_args(s, cmds, " \n");
if(strcmp(cmds[0], "get") == 0){
address = strtol(cmds[1], &endptr, 16);
int data = ptrace(PTRACE_PEEKDATA, pid, address, 0);
printf("Value at %x = %lu\n", address, data);
}
else if(strcmp(cmds[0], "set") == 0){
address = strtol(cmds[1], &endptr, 16);
int dat = strtol(cmds[2], &endptr, 10);
ptrace(PTRACE_POKEDATA, pid, address, dat);
}
else if(strcmp(cmds[0], "continue") == 0)
break;
else if(strcmp(cmds[0], "exit") == 0)
return 0;
else if(strcmp(cmds[0], "help") == 0){
printf("get address : to get data at given address, address should be in hexadecimal format\n");
printf("set address data : to set data at given address, data should be in intiger format and address should be in hexadecimal format\n");
printf("continue : to continue running the program\n");
printf("exit : to exit mygdb\n");
}
else
printf("invalid command\n");
}
}
示例7: C_arg
// constructors
explicit C_arg(int argc, char** argv, C_time& c_inst_time) :
random_seed(0),
target_false_positive_prob(DEFAULT_FPR),
kmer_length(0),
kmer_middle_index(0),
kmer_occurrence_threshold(0),
num_clusters(NUM_PARTITIONS_FOR_COUNT),
num_clusters_digit(0),
residue_kmer(0),
remainder_kmer(0),
num_bytes_per_kmer(0),
extend(MAX_EXTENSION),
paired_read(true),
nowrite(false),
debug(false),
verify(true),
set_kmer_occurrence_threshold(false),
num_args(argc),
args(argv)
{
time_t rawtime;
time(&rawtime);
c_inst_time.start_parse_args = asctime(localtime(&rawtime));
read_args();
time(&rawtime);
c_inst_time.end_parse_args = asctime(localtime(&rawtime));
};
示例8: main
int main(int argc, char *argv[]) {
enum timerec_type t = TIMEREC_SQLITE;
enum timerec_action action = TIMEREC_NUMACTIONS;
struct buffer *conn = NULL;
struct timerec_data *tr;
char *opt = NULL;
int ret = EXIT_SUCCESS;
size_t id = 0;
if(read_args(argc, argv, &t, &conn, &action, &opt, &id) < 0)
return EXIT_FAILURE;
if(conn == NULL)
default_dbpath(&conn);
if(action == TIMEREC_NUMACTIONS) {
usage();
goto error;
}
if(conn == NULL)
return EXIT_FAILURE;
if(timerec_init(t, buffer_cstr(conn), &tr) < 0) {
ret = EXIT_FAILURE;
goto error;
}
timerec_do(tr, action, opt, id);
timerec_end(tr);
error:
buffer_end(conn);
return ret;
(void)argc;
(void)argv;
}
示例9: main
int main(int ac, char **av)
{
t_env e;
e.inf.h = 0.2;
e.div = 2;
if (ac >= 2 && ac <= 7)
{
if (ft_strcmp(av[1], "-help") == 0)
aff_help();
e.mlx = mlx_init();
init_env(&e);
read_args(&e, ac, av);
parsing(&e, av[1]);
e.inf.scale = (((e.arg.winx + e.arg.winy) / (e.p.lenx + e.p.leny)) / 2);
e.inf.scale = e.inf.scale <= 0 ? 0.8 : e.inf.scale;
e.orix = e.arg.winx / 2;
e.oriy = e.arg.winy / e.p.leny;
backup(&e);
draw(&e);
}
else
aff_help();
return (0);
}
示例10: read_cpp_token
/*
* Reads a token from a given preprocessing context, expands it if macro, and
* returns it.
*/
static Token *expand_one(CppContext *ctx) {
Token *tok = read_cpp_token(ctx);
if (!tok) return NULL;
if (tok->toktype != TOKTYPE_IDENT)
return tok;
String *name = tok->val.str;
Macro *macro = dict_get(ctx->defs, name);
if (!macro)
return tok;
if (list_in(tok->hideset, name))
return tok;
switch (macro->type) {
case MACRO_OBJ: {
List *ts = subst(ctx, macro, make_list(), list_union1(tok->hideset, name));
pushback(ctx, ts);
return expand_one(ctx);
}
case MACRO_FUNC: {
List *args = read_args(ctx, macro);
Token *rparen = read_cpp_token(ctx);
List *hideset = list_union1(list_intersect(tok->hideset, rparen->hideset), name);
List *ts = subst(ctx, macro, args, hideset);
pushback(ctx, ts);
return expand_one(ctx);
}
case MACRO_SPECIAL:
macro->fn(ctx, tok);
return expand_one(ctx);
}
panic("should not reach here");
}
示例11: main
int main(int argc, char *argv[]) {
char *args_help = "Enter number of signals.\n";
if (read_args(argc, argv, &signal_num) != 0) {
printf(args_help);
return 1;
}
struct sigaction act_sigusr;
act_sigusr.sa_sigaction = sigusr_handler;
act_sigusr.sa_flags = SA_SIGINFO;
sigset_t mask_set;
sigfillset(&mask_set);
act_sigusr.sa_mask = mask_set;
sigaction(SIGRTMIN, &act_sigusr, NULL);
sigaction(SIGRTMIN + 1, &act_sigusr, NULL);
FILE * catcher_ps = popen("pidof catcher", "r");
if (catcher_ps == NULL) {
printf("Error while searching for catcher process occurred.\n");
return 1;
}
if (fscanf(catcher_ps, "%d", &catcher_pid) == EOF) {
printf("Catcher process not found.\n");
return 1;
}
pclose(catcher_ps);
send_signals();
while (1)
pause();
}
示例12: main
//program to implement the game of minesweeper
//user enters the name of the executable, the row and column dimensions, number of mines, and optionally a seed for random number generator
int main(int argc, char** argv){
Board board; //intitialize the board with struct type Board
int row = 0; //intialize the number of rows
int column = 0; //initialize the number of columns
int mine = 0; //intiialize the number of mines
read_args(argc, argv, &row, &column, &mine);
board.row = row;
board.col = column;
board.mine = mine;
board.seed = generate_seed(argv);
board.tile = create_board(board); //create the board
mine_location_generator(board);
print_board(board);
play_is_valid(board);
destroy_board(board); //when the game is over destroy the board
return 0;
}
示例13: main
int
main ( int argc, char **argv )
{
read_args ( argc, argv );
yyparse ();
#ifdef DUMPTREES
FILE *pre = fopen ( "pre.tree", "w" ),
*post = fopen ( "post.tree", "w" );
print_node ( pre, root, 0 );
#endif
root = simplify_tree ( root );
#ifdef DUMPTREES
print_node ( post, root, 0 );
fclose ( pre );
fclose ( post );
#endif
init_scopes ( 256 );
find_symbols ( root );
destroy_scopes ();
destroy_subtree ( root );
exit ( EXIT_SUCCESS );
}
示例14: main
int main(int argc, char **argv) {
read_args(argc, argv);
counters timer;
start_measure(timer);
// declarations
Complex ioB(1.0, 1.0);
ioBuffer = cl::sycl::buffer<Complex,2>(cl::sycl::range<2> {M, N});
ioABuffer = cl::sycl::buffer<Complex,2>(cl::sycl::range<2> {M, N});
ioBBuffer = cl::sycl::buffer<Complex,1>(&ioB, cl::sycl::range<1> {1});
// initialization
for (size_t i = 0; i < M; ++i){
for (size_t j = 0; j < N; ++j){
float tmp = (float) (i*(j+2) + 10) / N;
Complex value(tmp, tmp);
cl::sycl::id<2> id = {i, j};
ioBuffer.get_access<cl::sycl::access::mode::write>()[id] = value;
ioABuffer.get_access<cl::sycl::access::mode::write>()[id] = value;
}
}
// our work
coef_var2D<0, 0> c1;
coef_var2D<1, 0> c2;
coef_var2D<0, 1> c3;
coef_var2D<-1, 0> c4;
coef_var2D<0, -1> c5;
auto st = c1+c2+c3+c4+c5;
input_var2D<Complex, &ioABuffer, &ioBBuffer, &fdl_in, &fac> work_in;
output_2D<Complex, &ioBuffer, &fdl_out> work_out;
auto op_work = work_out << st << work_in;
auto st_id = c1.toStencil();
input_var2D<Complex, &ioBuffer, &ioBBuffer, &fdl_in, &fac_id> copy_in;
output_2D<Complex, &ioABuffer, &fdl_out> copy_out;
auto op_copy = copy_out << st_id << copy_in;
end_init(timer);
auto begin_op = counters::clock_type::now();
// compute result with "gpu"
{
cl::sycl::queue myQueue;
for (unsigned int i = 0; i < NB_ITER; ++i){
//op_work.doComputation(myQueue);
op_work.doLocalComputation(myQueue);
op_copy.doComputation(myQueue);
}
}
auto end_op = counters::clock_type::now();
timer.stencil_time = std::chrono::duration_cast<counters::duration_type>(end_op - begin_op);
// loading time is not watched
end_measure(timer);
return 0;
}
示例15: main
/*
* Function: main
* Parameter(s): built in parameters that has command line arguments stored in it.
* Returns: exit status of the program
* Description: The main controller of the whole program,
* connects with other functions and accomplishes the given task.
*/
int main(int argc, char* argv[]) {
read_args(argc, argv);
read_jobs();
start_scheduler();
return EXIT_SUCCESS;
}