void execute_drag(int fd, uint32_t device_flags, int start_x, int start_y, int end_x, int end_y, int num_steps, int duration_msec) { int delta[] = {(end_x-start_x)/num_steps, (end_y-start_y)/num_steps}; int sleeptime = duration_msec / num_steps; int i; print_action(ACTION_START, "drag", "\"start_x\": %d, \"start_y\": %d, " "\"end_x\": %d, \"end_y\": %d, \"num_steps\": %d, " "\"duration_msec\": %d", start_x, start_y, end_x, end_y, num_steps, duration_msec); // press execute_press(fd, device_flags, start_x, start_y); // drag for (i=0; i<num_steps; i++) { execute_sleep(sleeptime); execute_move(fd, device_flags, start_x+delta[0]*i, start_y+delta[1]*i); } // release execute_release(fd, device_flags); // wait execute_sleep(100); print_action(ACTION_END, "drag", NULL); }
void execute_pinch(int fd, uint32_t device_flags, int touch1_x1, int touch1_y1, int touch1_x2, int touch1_y2, int touch2_x1, int touch2_y1, int touch2_x2, int touch2_y2, int num_steps, int duration_msec) { int delta1[] = {(touch1_x2-touch1_x1)/num_steps, (touch1_y2-touch1_y1)/num_steps}; int delta2[] = {(touch2_x2-touch2_x1)/num_steps, (touch2_y2-touch2_y1)/num_steps}; int sleeptime = duration_msec / num_steps; int i; print_action(ACTION_START, "pinch", "\"touch1_x1\": %d, \"touch1_y1\": %d, \"touch1_x2\": %d, " "\"touch1_y2\": %d, \"touch2_x1\": %d, \"touch2_y1\": %d, " "\"touch2_x2\": %d, \"touch2_y2\": %d, \"num_steps\": %d, " "\"duration_msec\": %d", touch1_x1, touch1_y1, touch1_x2, touch1_y2, touch2_x1, touch2_y1, touch2_x2, touch2_y2, num_steps, duration_msec); // press change_mt_slot(fd, device_flags, 0); add_mt_tracking_id(fd, device_flags, global_tracking_id++); execute_press(fd, device_flags, touch1_x1, touch1_y1); change_mt_slot(fd, device_flags, 1); add_mt_tracking_id(fd, device_flags, global_tracking_id++); execute_press(fd, device_flags, touch2_x1, touch2_y1); // drag for (i=0; i<num_steps; i++) { execute_sleep(sleeptime); change_mt_slot(fd, device_flags, 0); execute_move(fd, device_flags, touch1_x1+delta1[0]*i, touch1_y1+delta1[1]*i); change_mt_slot(fd, device_flags, 1); execute_move(fd, device_flags, touch2_x1+delta2[0]*i, touch2_y1+delta2[1]*i); //write_event(fd, EV_SYN, SYN_REPORT, 0); } // release change_mt_slot(fd, device_flags, 0); execute_release(fd, device_flags); change_mt_slot(fd, device_flags, 1); execute_release(fd, device_flags); remove_mt_tracking_id(fd, device_flags, 0); remove_mt_tracking_id(fd, device_flags, 1); // wait execute_sleep(100); print_action(ACTION_END, "pinch", NULL); }
void print_actions(t_list *list, t_list *list_b, char *str) { if (list_b->first == NULL && check_sorted_list(list, list->first) == 1) { if (list->flags->last == 1) str = ft_strjoin(ft_strjoin("\x1b[32m", str), "\x1b[0m"); print_action(str, list, list_b); } else { print_action(ft_strjoin(str, " "), list, list_b); } }
void execute_reset(int fd, uint32_t device_flags) { print_action(ACTION_START, "reset", NULL); if (device_flags & INPUT_DEVICE_CLASS_TOUCH_MT) { write_event(fd, EV_ABS, ABS_MT_POSITION_X, 0); write_event(fd, EV_ABS, ABS_MT_POSITION_Y, 0); write_event(fd, EV_ABS, ABS_MT_PRESSURE, 0); write_event(fd, EV_ABS, ABS_MT_TOUCH_MAJOR, 0); write_event(fd, EV_ABS, ABS_MT_WIDTH_MAJOR, 0); } else if (device_flags & INPUT_DEVICE_CLASS_TOUCH) { write_event(fd, EV_ABS, ABS_X, 0); write_event(fd, EV_ABS, ABS_Y, 0); } print_action(ACTION_END, "reset", NULL); }
void execute_release(int fd, uint32_t device_flags) { print_action(ACTION_START, "release", NULL); if (device_flags & INPUT_DEVICE_CLASS_TOUCH_MT) { write_event(fd, EV_ABS, ABS_MT_TRACKING_ID, -1); if (device_flags & INPUT_DEVICE_CLASS_TOUCH_MT_SYNC) write_event(fd, EV_SYN, SYN_MT_REPORT, 0); write_event(fd, EV_KEY, BTN_TOUCH, 0); write_event(fd, EV_SYN, SYN_REPORT, 0); } else if (device_flags & INPUT_DEVICE_CLASS_TOUCH) { write_event(fd, EV_KEY, BTN_TOUCH, 0); write_event(fd, EV_SYN, SYN_REPORT, 0); } print_action(ACTION_END, "release", NULL); }
size_t actions_list(const char *case_num) { size_t count = 0; if ( query_select_count_from_actions_for( case_num, &count ) ) { clear_line(20, 10); mvprintw( 20, 10, db_get_error_msg() ); move( 6, 25 ); } else { if ( count ) { if ( query_select_all_from_actions_for( case_num ) ) { clear_line(20, 10); mvprintw( 20, 10, db_get_error_msg() ); move( 6, 25 ); } else { Action_t *act_ptr; size_t idx = 0; mvprintw( 20, 10, "Actions:" ); while ( ( act_ptr = get_action_from_result() ) != NULL ) print_action( act_ptr, ++idx ); } } } return count; }
void print_actions(struct action* a) { while(a) { print_action(a); a = a->next; } }
int accept_tcmsg(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg) { FILE *fp = (FILE*)arg; if (n->nlmsg_type == RTM_NEWTFILTER || n->nlmsg_type == RTM_DELTFILTER) { print_filter(who, n, arg); return 0; } if (n->nlmsg_type == RTM_NEWTCLASS || n->nlmsg_type == RTM_DELTCLASS) { print_class(who, n, arg); return 0; } if (n->nlmsg_type == RTM_NEWQDISC || n->nlmsg_type == RTM_DELQDISC) { print_qdisc(who, n, arg); return 0; } if (n->nlmsg_type == RTM_GETACTION || n->nlmsg_type == RTM_NEWACTION || n->nlmsg_type == RTM_DELACTION) { print_action(who, n, arg); return 0; } if (n->nlmsg_type != NLMSG_ERROR && n->nlmsg_type != NLMSG_NOOP && n->nlmsg_type != NLMSG_DONE) { fprintf(fp, "Unknown message: length %08d type %08x flags %08x\n", n->nlmsg_len, n->nlmsg_type, n->nlmsg_flags); } return 0; }
/* debug function, prints main routing table */ void print_rl() { struct action* t; int i,j; for(j=0; j<RT_NO; j++){ if (rlist[j]==0){ if (j==0) DBG("WARNING: the main routing table is empty\n"); continue; } DBG("routing table %d:\n",j); for (t=rlist[j],i=0; t; i++, t=t->next){ print_action(t); } DBG("\n"); } for(j=0; j<ONREPLY_RT_NO; j++){ if (onreply_rlist[j]==0){ continue; } DBG("onreply routing table %d:\n",j); for (t=onreply_rlist[j],i=0; t; i++, t=t->next){ print_action(t); } DBG("\n"); } for(j=0; j<FAILURE_RT_NO; j++){ if (failure_rlist[j]==0){ continue; } DBG("failure routing table %d:\n",j); for (t=failure_rlist[j],i=0; t; i++, t=t->next){ print_action(t); } DBG("\n"); } for(j=0; j<BRANCH_RT_NO; j++){ if (branch_rlist[j]==0){ continue; } DBG("T-branch routing table %d:\n",j); for (t=branch_rlist[j],i=0; t; i++, t=t->next){ print_action(t); } DBG("\n"); } }
void execute_drag(int fd, uint32_t device_flags, int start_x, int start_y, int end_x, int end_y, int num_steps, int duration_msec) { int delta[] = {(end_x-start_x)/num_steps, (end_y-start_y)/num_steps}; double desired_interval_msec, avg_event_dispatch_time_msec; struct timespec start_time, current_time, time_before_last_move; int i; clock_gettime(CLOCK_MONOTONIC, &start_time); double start_nsecs = (double) (start_time.tv_sec * (1000*1000)) + start_time.tv_nsec; print_action(ACTION_START, "drag", "\"start_x\": %d, \"start_y\": %d, " "\"end_x\": %d, \"end_y\": %d, \"num_steps\": %d, " "\"duration_msec\": %d", start_x, start_y, end_x, end_y, num_steps, duration_msec); // press clock_gettime(CLOCK_MONOTONIC, &time_before_last_move); execute_press(fd, device_flags, start_x, start_y); // drag desired_interval_msec = duration_msec / num_steps; for (i=0; i<num_steps; i++) { clock_gettime(CLOCK_MONOTONIC, ¤t_time); avg_event_dispatch_time_msec = ((avg_event_dispatch_time_msec * i) + timediff_msec(&time_before_last_move, ¤t_time)) / i; if (desired_interval_msec > 0 && avg_event_dispatch_time_msec < desired_interval_msec) { execute_sleep(desired_interval_msec - avg_event_dispatch_time_msec); } memcpy(&time_before_last_move, ¤t_time, sizeof(struct timespec)); execute_move(fd, device_flags, start_x+delta[0]*i, start_y+delta[1]*i); } // release execute_release(fd, device_flags); // wait execute_sleep(100); print_action(ACTION_END, "drag", NULL); }
void execute_move(int fd, uint32_t device_flags, int x, int y) { print_action(ACTION_START, "move", "\"x\": %d, \"y\": %d", x, y); if (device_flags & INPUT_DEVICE_CLASS_TOUCH_MT) { write_event(fd, EV_ABS, ABS_MT_POSITION_X, x); write_event(fd, EV_ABS, ABS_MT_POSITION_Y, y); write_event(fd, EV_ABS, ABS_MT_PRESSURE, 127); write_event(fd, EV_ABS, ABS_MT_TOUCH_MAJOR, 127); write_event(fd, EV_ABS, ABS_MT_WIDTH_MAJOR, 4); if (device_flags & INPUT_DEVICE_CLASS_TOUCH_MT_SYNC) write_event(fd, EV_SYN, SYN_MT_REPORT, 0); write_event(fd, EV_SYN, SYN_REPORT, 0); } else if (device_flags & INPUT_DEVICE_CLASS_TOUCH) { write_event(fd, EV_ABS, ABS_X, x); write_event(fd, EV_ABS, ABS_Y, y); write_event(fd, EV_SYN, SYN_REPORT, 0); } print_action(ACTION_END, "move", NULL); }
void execute_press(int fd, uint32_t device_flags, int x, int y) { print_action(ACTION_START, "press", "\"x\": %d, \"y\": %d", x, y); if (device_flags & INPUT_DEVICE_CLASS_TOUCH_MT) { write_event(fd, EV_ABS, ABS_MT_TRACKING_ID, global_tracking_id++); write_event(fd, EV_ABS, ABS_MT_POSITION_X, x); write_event(fd, EV_ABS, ABS_MT_POSITION_Y, y); write_event(fd, EV_ABS, ABS_MT_PRESSURE, 127); write_event(fd, EV_ABS, ABS_MT_TOUCH_MAJOR, 127); write_event(fd, EV_ABS, ABS_MT_WIDTH_MAJOR, 4); if (device_flags & INPUT_DEVICE_CLASS_TOUCH_MT_SYNC) write_event(fd, EV_SYN, SYN_MT_REPORT, 0); write_event(fd, EV_KEY, BTN_TOUCH, 1); write_event(fd, EV_SYN, SYN_REPORT, 0); } else if (device_flags & INPUT_DEVICE_CLASS_TOUCH) { write_event(fd, EV_ABS, ABS_X, x); write_event(fd, EV_ABS, ABS_Y, y); write_event(fd, EV_KEY, BTN_TOUCH, 1); write_event(fd, EV_SYN, SYN_REPORT, 0); } print_action(ACTION_END, "press", NULL); }
/*! * \brief Handle a timeout in node-to-node communication * * \param[in] data Pointer to action timer * * \return FALSE (indicating that source should be not be re-added) */ gboolean action_timer_callback(gpointer data) { crm_action_timer_t *timer = NULL; const char *task = NULL; const char *on_node = NULL; const char *via_node = NULL; CRM_CHECK(data != NULL, return FALSE); timer = (crm_action_timer_t *) data; stop_te_timer(timer); CRM_CHECK(timer->action != NULL, return FALSE); task = crm_element_value(timer->action->xml, XML_LRM_ATTR_TASK); on_node = crm_element_value(timer->action->xml, XML_LRM_ATTR_TARGET); via_node = crm_element_value(timer->action->xml, XML_LRM_ATTR_ROUTER_NODE); if (transition_graph->complete) { crm_notice("Node %s did not send %s result (via %s) within %dms " "(ignoring because transition not in progress)", (on_node? on_node : ""), (task? task : "unknown action"), (via_node? via_node : "controller"), timer->timeout); } else { /* fail the action */ crm_err("Node %s did not send %s result (via %s) within %dms " "(action timeout plus cluster-delay)", (on_node? on_node : ""), (task? task : "unknown action"), (via_node? via_node : "controller"), timer->timeout); print_action(LOG_ERR, "Aborting transition, action lost: ", timer->action); timer->action->failed = TRUE; te_action_confirmed(timer->action); abort_transition(INFINITY, tg_restart, "Action lost", NULL); update_graph(transition_graph, timer->action); trigger_graph(); // Record timeout in the CIB if appropriate if ((timer->action->type == action_type_rsc) && controld_action_is_recordable(task)) { controld_record_action_timeout(timer->action); } } return FALSE; }
void execute_tap(int fd, uint32_t device_flags, int x, int y, int num_times, int duration_msec) { int i; print_action(ACTION_START, "tap", "\"x\": %d, \"y\": %d, " "\"num_times\": %d, \"duration_msec\": %d", x, y, num_times, duration_msec); for (i=0; i<num_times; i++) { // press execute_press(fd, device_flags, x, y); execute_sleep(duration_msec); // release execute_release(fd, device_flags); execute_sleep(100); // wait execute_sleep(50); } print_action(ACTION_END, "tap", NULL); }
/*----------------------------------------------------------------------------*/ void print_entry(entry_t* e) { window_t *w; action_t *a; PRINTF("IF ("); for(w = list_head(e->windows); w != NULL; w = w->next) { print_window(w); PRINTF(";"); } PRINTF("){"); for(a = list_head(e->actions); a != NULL; a = a->next) { print_action(a); PRINTF(";"); } PRINTF("}[%d %d]", e->stats.ttl, e->stats.count); }
void execute_sleep(int duration_msec) { print_action(ACTION_START, "sleep", "\"duration\": %d", duration_msec); usleep(duration_msec*1000); print_action(ACTION_END, "sleep", NULL); }
void print_action(struct action* a) { struct action* t; for(t=a; t!=0; t=t->next) { switch(t->type) { case FORWARD_T: DBG("forward("); break; case FORWARD_TCP_T: DBG("forward_tcp("); break; case FORWARD_UDP_T: DBG("forward_udp("); break; case SEND_T: DBG("send("); break; case SEND_TCP_T: DBG("send_tcp("); break; case DROP_T: DBG("drop("); break; case LOG_T: DBG("log("); break; case ERROR_T: DBG("error("); break; case ROUTE_T: DBG("route("); break; case EXEC_T: DBG("exec("); break; case REVERT_URI_T: DBG("revert_uri("); break; case STRIP_T: DBG("strip("); break; case APPEND_BRANCH_T: DBG("append_branch("); break; case PREFIX_T: DBG("prefix("); break; case LEN_GT_T: DBG("len_gt("); break; case SETFLAG_T: DBG("setflag("); break; case RESETFLAG_T: DBG("resetflag("); break; case ISFLAGSET_T: DBG("isflagset("); break; case SET_HOST_T: DBG("sethost("); break; case SET_HOSTPORT_T: DBG("sethostport("); break; case SET_USER_T: DBG("setuser("); break; case SET_USERPASS_T: DBG("setuserpass("); break; case SET_PORT_T: DBG("setport("); break; case SET_URI_T: DBG("seturi("); break; case IF_T: DBG("if ("); break; case MODULE_T: DBG(" external_module_call("); break; case FORCE_RPORT_T: DBG("force_rport("); break; case SET_ADV_ADDR_T: DBG("set_advertised_address("); break; case SET_ADV_PORT_T: DBG("set_advertised_port("); break; default: DBG("UNKNOWN("); } switch(t->p1_type) { case STRING_ST: DBG("\"%s\"", t->p1.string); break; case NUMBER_ST: DBG("%lu",t->p1.number); break; case IP_ST: print_ip("", (struct ip_addr*)t->p1.data, ""); break; case EXPR_ST: print_expr((struct expr*)t->p1.data); break; case ACTIONS_ST: print_action((struct action*)t->p1.data); break; case CMDF_ST: DBG("f_ptr<%p>",t->p1.data); break; default: DBG("type<%d>", t->p1_type); } if (t->type==IF_T) DBG(") {"); switch(t->p2_type) { case NOSUBTYPE: break; case STRING_ST: DBG(", \"%s\"", t->p2.string); break; case NUMBER_ST: DBG(", %lu",t->p2.number); break; case EXPR_ST: print_expr((struct expr*)t->p2.data); break; case ACTIONS_ST: print_action((struct action*)t->p2.data); break; default: DBG(", type<%d>", t->p2_type); } if (t->type==IF_T) DBG("} else {"); switch(t->p3_type) { case NOSUBTYPE: break; case STRING_ST: DBG(", \"%s\"", t->p3.string); break; case NUMBER_ST: DBG(", %lu",t->p3.number); break; case EXPR_ST: print_expr((struct expr*)t->p3.data); break; case ACTIONS_ST: print_action((struct action*)t->p3.data); break; default: DBG(", type<%d>", t->p3_type); } if (t->type==IF_T) DBG("}; "); else DBG("); "); } }
void print_expr(struct expr* exp) { if (exp==0) { LOG(L_CRIT, "ERROR: print_expr: null expression!\n"); return; } if (exp->type==ELEM_T) { switch(exp->l.operand) { case METHOD_O: DBG("method"); break; case URI_O: DBG("uri"); break; case SRCIP_O: DBG("srcip"); break; case SRCPORT_O: DBG("srcport"); break; case DSTIP_O: DBG("dstip"); break; case NUMBER_O: break; case ACTION_O: print_action((struct action*) exp->r.param); break; default: DBG("UNKNOWN"); } switch(exp->op) { case EQUAL_OP: DBG("=="); break; case MATCH_OP: DBG("=~"); break; case NO_OP: break; default: DBG("<UNKNOWN>"); } switch(exp->subtype) { case NOSUBTYPE: DBG("N/A"); break; case STRING_ST: DBG("\"%s\"", (char*)exp->r.param); break; case NET_ST: print_net((struct net*)exp->r.param); break; case IP_ST: print_ip("", (struct ip_addr*)exp->r.param, ""); break; case ACTIONS_ST: print_action((struct action*)exp->r.param); break; case NUMBER_ST: DBG("%d",exp->r.intval); break; case MYSELF_ST: DBG("_myself_"); break; default: DBG("type<%d>", exp->subtype); } } else if (exp->type==EXP_T) { switch(exp->op) { case AND_OP: DBG("AND( "); print_expr(exp->l.expr); DBG(", "); print_expr(exp->r.expr); DBG(" )"); break; case OR_OP: DBG("OR( "); print_expr(exp->l.expr); DBG(", "); print_expr(exp->r.expr); DBG(" )"); break; case NOT_OP: DBG("NOT( "); print_expr(exp->l.expr); DBG(" )"); break; default: DBG("UNKNOWN_EXP "); } } else { DBG("ERROR:print_expr: unknown type\n"); } }
void actions_dataentry_scr(const char *curr_path, const char *case_num) { const size_t n_fields = 4; const size_t starty = 6; const size_t startx = 25; FIELD *field[n_fields]; FORM *my_form; Action_t record; int width[] = { MAX_ACT_DATE - 1, MAX_ACT_TYPE, MAX_ACT_NOTE - 200 }; int height[] = { 1, 1, 4 }; for ( size_t i = 0; i < n_fields - 1; ++i ) field[i] = new_field(height[i], width[i], starty + i * 2, startx, 0, 0); field[n_fields - 1] = NULL; set_field_back( field[0], A_UNDERLINE ); field_opts_off( field[0], O_AUTOSKIP ); set_field_back( field[1], A_UNDERLINE ); field_opts_off( field[1], O_AUTOSKIP ); set_field_back( field[2], A_UNDERLINE ); field_opts_off( field[2], O_AUTOSKIP ); field_opts_off( field[2], O_STATIC ); set_max_field( field[2], MAX_ACT_NOTE ); my_form = new_form(field); post_form(my_form); refresh(); int note_count = MAX_ACT_NOTE; char note_msg[4]; char date_str[MAX_ACT_DATE]; get_curr_date( date_str ); mvprintw( 0, 0, curr_path ); mvprintw( 4, 10, "Case Number: %s", case_num ); mvprintw( 6, 10, "Entry Date: " ); mvprintw( 8, 10, "Type: " ); mvprintw( 10, 10, "Note: " ); mvprintw( 15, 77, "%d", note_count ); mvprintw( 16, 10, "(F2) = Add | (ESC) = Previous Screen" ); set_visible_fields( field, 1, 3 ); size_t actions_count = actions_list( case_num ); move( 6, 25 ); set_field_buffer( field[0], 0, date_str ); set_current_field( my_form, field[0] ); record.id = 0; int ch; do { ch = getch(); switch ( ch ) { case KEY_UP: form_driver(my_form, REQ_PREV_FIELD); form_driver(my_form, REQ_END_LINE); break; case KEY_LEFT: form_driver(my_form, REQ_LEFT_CHAR); break; case KEY_RIGHT: form_driver(my_form, REQ_RIGHT_CHAR); break; case KEY_BACKSPACE: { FIELD * curr_fld = current_field( my_form ); if ( curr_fld == field[2] ) { snprintf( note_msg, 4, "%d", ++note_count ); display_msg( 15, 77, my_form, curr_fld, note_msg ); } } form_driver(my_form, REQ_PREV_CHAR); form_driver(my_form, REQ_DEL_CHAR); break; case DEL: { FIELD * curr_fld = current_field( my_form ); if ( curr_fld == field[2] ) { snprintf( note_msg, 4, "%d", ++note_count ); display_msg( 15, 77, my_form, curr_fld, note_msg ); } } form_driver( my_form, REQ_DEL_CHAR ); break; case ENTER: form_driver( my_form, REQ_NEXT_FIELD ); form_driver( my_form, REQ_END_LINE ); break; case KEY_F(1): { FIELD * curr_fld = current_field( my_form ); if ( curr_fld == field[1] ) { if ( query_select_all_codes_from_action_types() ) { clear_line(18, 10); mvprintw( 18, 10, db_get_error_msg() ); } else { const Code_t const * code_ptr; size_t count = 0; mvprintw( 8, 75, "Type Options:" ); while ( ( code_ptr = get_code_from_result() ) != NULL ) mvprintw( 9 + count++, 81, "[%d] %s", code_ptr->code, code_ptr->desc ); free_code_result(); int row, col; get_cursor_pos( curr_fld, &row, &col ); move( row, col ); set_current_field( my_form, curr_fld ); } } } break; case KEY_F(2): { clear_line( 18, 10 ); strncpy( record.case_num, case_num, MAX_CANUM ); strncpy( record.entry_date, compress_str( field_buffer(field[0], 0) ), MAX_ACT_DATE ); record.type = atoi( compress_str( field_buffer(field[1], 0) ) ); strncpy( record.note, field_buffer(field[2], 0), MAX_ACT_NOTE ); if ( is_empty_str( record.note, MAX_ACT_NOTE ) ) { mvprintw( 18, 10, "[!] Action must at least have a note." ); move( 10, 25 ); set_current_field( my_form, field[2] ); break; } if ( query_add_action( &record ) ) { mvprintw( 18, 10, db_get_error_msg() ); } else { clear_fields( field, 0, 2 ); actions_count++; print_action( &record, actions_count ); note_count = MAX_ACT_NOTE; mvprintw( 15, 77, "%d", note_count ); } move( 6, 25 ); set_current_field( my_form, field[0] ); } break; default: { FIELD * curr_fld = current_field( my_form ); if ( ch == '\'' ) break; if ( curr_fld == field[1] ) { if ( !isdigit( ch ) ) break; } else if ( curr_fld == field[2] ) { snprintf( note_msg, 4, "%d", --note_count ); display_msg( 15, 77, my_form, curr_fld, note_msg ); } } form_driver( my_form, ch ); break; } } while ( ch != ESC ); unpost_form( my_form ); free_form( my_form ); for ( size_t i = 0; i < n_fields - 1; ++i ) free_field( field[i] ); return; }
void ast_print(node * ast) { print_action(ast); node_next(ast, &ast_print); }
int tc_action_gd(int cmd, unsigned flags, int *argc_p, char ***argv_p) { char k[16]; struct action_util *a = NULL; int argc = *argc_p; char **argv = *argv_p; int prio = 0; int ret = 0; __u32 i; struct sockaddr_nl nladdr; struct rtattr *tail; struct rtattr *tail2; struct nlmsghdr *ans = NULL; struct { struct nlmsghdr n; struct tcamsg t; char buf[MAX_MSG]; } req; req.t.tca_family = AF_UNSPEC; memset(&req, 0, sizeof(req)); memset(&nladdr, 0, sizeof(nladdr)); nladdr.nl_family = AF_NETLINK; req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct tcamsg)); req.n.nlmsg_flags = NLM_F_REQUEST|flags; req.n.nlmsg_type = cmd; argc -=1; argv +=1; tail = NLMSG_TAIL(&req.n); addattr_l(&req.n, MAX_MSG, TCA_ACT_TAB, NULL, 0); while (argc > 0) { if (strcmp(*argv, "action") == 0 ) { argc--; argv++; continue; } else if (strcmp(*argv, "help") == 0) { return -1; } strncpy(k, *argv, sizeof (k) - 1); a = get_action_kind(k); if (NULL == a) { fprintf(stderr, "Error: non existent action: %s\n",k); ret = -1; goto bad_val; } if (strcmp(a->id, k) != 0) { fprintf(stderr, "Error: non existent action: %s\n",k); ret = -1; goto bad_val; } argc -=1; argv +=1; if (argc <= 0) { fprintf(stderr, "Error: no index specified action: %s\n",k); ret = -1; goto bad_val; } if (matches(*argv, "index") == 0) { NEXT_ARG(); if (get_u32(&i, *argv, 10)) { fprintf(stderr, "Illegal \"index\"\n"); ret = -1; goto bad_val; } argc -=1; argv +=1; } else { fprintf(stderr, "Error: no index specified action: %s\n",k); ret = -1; goto bad_val; } tail2 = NLMSG_TAIL(&req.n); addattr_l(&req.n, MAX_MSG, ++prio, NULL, 0); addattr_l(&req.n, MAX_MSG, TCA_ACT_KIND, k, strlen(k) + 1); addattr32(&req.n, MAX_MSG, TCA_ACT_INDEX, i); tail2->rta_len = (void *) NLMSG_TAIL(&req.n) - (void *) tail2; } tail->rta_len = (void *) NLMSG_TAIL(&req.n) - (void *) tail; req.n.nlmsg_seq = rth.dump = ++rth.seq; if (cmd == RTM_GETACTION) ans = &req.n; if (rtnl_talk(&rth, &req.n, 0, 0, ans) < 0) { fprintf(stderr, "We have an error talking to the kernel\n"); return 1; } if (ans && print_action(NULL, &req.n, (void*)stdout) < 0) { fprintf(stderr, "Dump terminated\n"); return 1; } *argc_p = argc; *argv_p = argv; bad_val: return ret; }