/** * Bind a number of texture objects to different image units and check * that the image unit state was updated correctly. */ static bool run_test_binding(void) { const struct image_unit_action *action; bool ret = true; int i; for (action = actions; action->action; ++action) ret &= exec_action(*action); for (i = 0; i < max_image_units(); ++i) ret &= check_action(get_last_unit_action(i)); return ret; }
void exec_action_context_services(int ch) { ITEM *item; switch (ch) { case KEY_DOWN: menu_driver(my_menu, REQ_DOWN_ITEM); break; case KEY_UP: menu_driver(my_menu, REQ_UP_ITEM); break; case KEY_ENTER: case 10: item = current_item(my_menu); exec_action(item_userptr(item)); break; } }
int exec_instr(op_rec *oprec) /* This routine is responsible for executing all conditions and action tokens. Remember action tokens are numbered from 1000. */ /* Return codes: 0 to continue running commands 1 for a failed conditional token 100 Next metacommand 101 Stop running metacommands 102 End turn 103 Redirection */ { rbool r; if (oprec->op<1000) { r=exec_cond(oprec->op,oprec->arg1,oprec->arg2); return (oprec->negate ? r : !r); /* Is it prefixed by NOT? */ } switch(oprec->op) { case 1151: /* EndDisambig <num> */ if (do_disambig) { disambig_score=oprec->arg1; return 102; /* "End turn" if disambiguating */ } return 0; /* ... otherwise do nothing */ case 1062: case 1152: return 103; /* Redirect */ case WIN_ACT: winflag=1; return 0; /* win game */ case (WIN_ACT+1): endflag=1; return 102; /* end game */ case (WIN_ACT+2): return 100; /* end this command */ case (WIN_ACT+3): return 101; /* end all commands */ case (WIN_ACT+4): return 102; /* end turn */ default: exec_action(oprec->op,oprec->arg1,oprec->arg2); if (oprec->failmsg) return 102; else return 0; } }
static void grab_key_event_cb (XPointer user_data, XRecordInterceptData *hook) { if ( hook->category != XRecordFromServer ) { XRecordFreeData(hook); g_warning ("Data not from X server..."); return; } int event_type = hook->data[0]; KeyCode keycode = hook->data[1]; /*g_debug ("event type: %d, code: %d\n", (int)event_type, (int)keycode);*/ switch (event_type) { case KeyPress: key_press_cnt++; break; case KeyRelease: /*g_debug ("key_press_cnt: %d\n", key_press_cnt);*/ if (key_press_cnt == 1) { exec_action (keycode); } key_press_cnt = 0; break; default: key_press_cnt = 0; break; } XRecordFreeData(hook); }
void event_handler_handle_event() { ievent_queue_t *iq_node_p = ievent_queue_head; while(iq_node_p != NULL) { // 事件指针 struct inotify_event *p_ievent = NULL; // absolute path and relative path char path[PATH_MAX]; // 事件掩码 uint32_t mask; // 事件cookie char cookie[12]; int i; // 取出当前事件指针 p_ievent = iq_node_p->event; // 根据当前事件wd获得事件发生目录 strcpy(path, wd_path_map[p_ievent->wd]); // 事件掩码 mask = p_ievent->mask; // 获得事件cookie sprintf(cookie, "%d", p_ievent->cookie); // 如不为IN_DELETE_SELF或IN_MOVE_SELF事件 // 则绝对路径为:事件发生目录 + 文件名 if(!(mask & IN_DELETE_SELF) && !(mask & IN_MOVE_SELF)) { strcat(path, "/"); strncat(path, p_ievent->name, p_ievent->len); } // 对创建目录事件,初始化监控目录 if((mask & IN_CREATE) && (mask & IN_ISDIR)) { event_watcher_init_dir(path); } // 对删除目录事件,撤销监控目录 if((mask & IN_DELETE) && (mask & IN_ISDIR)) { event_watcher_destory_dir(path); } // 对移入目录事件,初始化监控目录 if((mask & IN_MOVED_TO) && (mask & IN_ISDIR)) { event_watcher_init_dir(path); } // 对移出目录事件,初始化监控目录 if((mask & IN_MOVED_FROM) && (mask & IN_ISDIR)) { event_watcher_destory_dir(path); } for(i = 0; i < NACTIONS; i++) { if(!(mask & actions[i].event)) { continue; } if(!strcmp(log_enable, "YES")) { log_event(&actions[i], path, p_ievent->cookie); } exec_action(&actions[i], path, cookie); } iq_node_p = iq_node_p->next; } }
static void parse_options(int argc, char *argv[]) { int c; /* who am i, some -e option? */ if (argc > 1 && almost_equals(argv[1], "-e$xecute")) exit(exec_action(argc - 2, argv + 2)); /* no, we're plain gstat. Parse the command line: */ opterr = 0; while ((c = getopt(argc, argv, "Ccd:ehil:mo:p:sSvWxV")) != EOF) { switch (c) { case 'd': if (read_int(optarg, &debug_level) || debug_level < 0) { debug_level = 1; message(DEBUG_OPTIONS); ErrMsg(ER_ARGOPT, "d"); } break; case 'e': ErrMsg(ER_ARGOPT, "option -e only allowed as first option"); case 'i': case 'm': set_method(UIF); break; case 'l': set_gstat_log_file(efopen(logfile_name = optarg, "w")); break; case 'o': o_filename = optarg; break; case 'p': gl_plotfile = optarg; break; case 'S': gl_secure = 1; break; case 's': debug_level = 0; break; case 'c': check_only = 1; break; case 'x': gl_xvalid = 1; break; case 'C': printlog("%s\n", COPYRIGHT); break; case 'W': printlog("%s\n", NOWARRANTY); break; case 'V': case 'v': printlog("compiled on: %s\n", __DATE__); printlog("with libraries: "); #ifdef HAVE_LIBCSF printlog("csf "); #endif #ifdef HAVE_LIBCURSES printlog("curses "); #endif #ifdef HAVE_LIBGD printlog("gd "); # ifdef HAVE_GDIMAGEGIF printlog("(gif) "); # else printlog("(png) "); # endif #endif #ifdef HAVE_LIBGIS printlog("grass "); #endif #ifdef HAVE_LIBGSL printlog("gsl "); #endif #ifdef HAVE_LIBNCURSES printlog("ncurses "); #endif #ifdef HAVE_LIBNETCDF printlog("netcdf "); #endif #ifdef LIBGSTAT printlog("qt "); #endif #ifdef HAVE_LIBREADLINE printlog("readline "); #endif printlog("\n"); printlog("last modified on: %s\n", LASTMOD); printlog("gstat home page: %s\n", GSTAT_HOME); printlog("questions, bugs etc. mailto:%s\n\n", GSTAT_INFO); break; case 'h': printlog("%s\n\n%s\n", USAGE, HELP); break; case '?': default: ErrClo(optopt); } } return; }