int main() { FILE *fin, *fout; int a = 0, i = 0, ar; char c; char arr[STR] = {}; if (!(fin = fopen("test.asem", "r"))) { printf ("can't open a file for read\n"); return -1; } //================================================================== while(1) { c = fgetc(fin); if(c == EOF) break; if(c == '\n') a++; if(c == ' ') a++; } fclose(fin); //================================================================== if ((fin = fopen("test.asem", "r")) == NULL) { printf ("can't open a file for read\n"); return -1; } if ((fout = fopen("my.forcpu", "wb")) == NULL) { printf ("can't open a file for writing\n"); return -1; } //================================================================== while(a) { i = 0; c = fgetc(fin); while(c != ' ' && c != '\n' && c != EOF) { arr[i] = c; i++; c = fgetc(fin); } for(i = 0; i < NumberFunction; i++) DEF_CMD(i); a--; clear(arr); } return 0; }
DSMAction* MonitoringModule::getAction(const string& from_str) { string cmd; string params; splitCmd(from_str, cmd, params); #define DEF_CMD(cmd_name, class_name) \ \ if (cmd == cmd_name) { \ class_name * a = \ new class_name(params); \ a->name = from_str; \ return a; \ } DEF_CMD("monitoring.log", MonLogAction); DEF_CMD("monitoring.logAdd", MonLogAddAction); DEF_CMD("monitoring.logVars", MonLogVarsAction); return NULL; }
DSMAction* CurlModule::getAction(const string& from_str) { string cmd; string params; splitCmd(from_str, cmd, params); DEF_CMD("curl.get", SCJCurlGetAction); DEF_CMD("curl.getDiscardResult", SCJCurlGetNoresultAction); DEF_CMD("curl.getFile", SCJCurlGetFileAction); DEF_CMD("curl.getForm", SCJCurlGetFormAction); DEF_CMD("curl.post", SCJCurlPOSTGetResultAction); DEF_CMD("curl.postDiscardResult", SCJCurlPOSTAction); return NULL; }
bzero((char *)&vreq.vlr_parent, sizeof(vreq.vlr_parent)); vreq.vlr_tag = 0; if (ioctl(s, SIOCSETVLAN, (caddr_t)&ifr) == -1) err(1, "SIOCSETVLAN"); } static struct cmd vlan_cmds[] = { DEF_CLONE_CMD_ARG("vlan", setvlantag), DEF_CLONE_CMD_ARG("vlandev", setvlandev), /* NB: non-clone cmds */ DEF_CMD_ARG("vlan", setvlantag), DEF_CMD_ARG("vlandev", setvlandev), /* XXX For compatibility. Should become DEF_CMD() some day. */ DEF_CMD_OPTARG("-vlandev", unsetvlandev), DEF_CMD("vlanmtu", IFCAP_VLAN_MTU, setifcap), DEF_CMD("-vlanmtu", -IFCAP_VLAN_MTU, setifcap), DEF_CMD("vlanhwtag", IFCAP_VLAN_HWTAGGING, setifcap), DEF_CMD("-vlanhwtag", -IFCAP_VLAN_HWTAGGING, setifcap), DEF_CMD("vlanhwfilter", IFCAP_VLAN_HWFILTER, setifcap), DEF_CMD("-vlanhwfilter", -IFCAP_VLAN_HWFILTER, setifcap), DEF_CMD("-vlanhwtso", -IFCAP_VLAN_HWTSO, setifcap), DEF_CMD("vlanhwtso", IFCAP_VLAN_HWTSO, setifcap), DEF_CMD("vlanhwcsum", IFCAP_VLAN_HWCSUM, setifcap), DEF_CMD("-vlanhwcsum", -IFCAP_VLAN_HWCSUM, setifcap), }; static struct afswtch af_vlan = { .af_name = "af_vlan", .af_af = AF_UNSPEC, .af_other_status = vlan_status, };
DEF_CLONE_CMD_ARG("vxlanttl", setvxlan_ttl), DEF_CLONE_CMD("vxlanlearn", 1, setvxlan_learn), DEF_CLONE_CMD("-vxlanlearn", 0, setvxlan_learn), DEF_CMD_ARG("vxlanvni", setvxlan_vni), DEF_CMD_ARG("vxlanlocal", setvxlan_local), DEF_CMD_ARG("vxlanremote", setvxlan_remote), DEF_CMD_ARG("vxlangroup", setvxlan_group), DEF_CMD_ARG("vxlanlocalport", setvxlan_local_port), DEF_CMD_ARG("vxlanremoteport", setvxlan_remote_port), DEF_CMD_ARG2("vxlanportrange", setvxlan_port_range), DEF_CMD_ARG("vxlantimeout", setvxlan_timeout), DEF_CMD_ARG("vxlanmaxaddr", setvxlan_maxaddr), DEF_CMD_ARG("vxlandev", setvxlan_dev), DEF_CMD_ARG("vxlanttl", setvxlan_ttl), DEF_CMD("vxlanlearn", 1, setvxlan_learn), DEF_CMD("-vxlanlearn", 0, setvxlan_learn), DEF_CMD("vxlanflush", 0, setvxlan_flush), DEF_CMD("vxlanflushall", 1, setvxlan_flush), }; static struct afswtch af_vxlan = { .af_name = "af_vxlan", .af_af = AF_UNSPEC, .af_other_status = vxlan_status, }; static __constructor void vxlan_ctor(void) {
printf(VHADDR_PFMT, inet_ntoa(carpa[i].carpa_addr.sin_addr), baddr, flags); } if (carpa != NULL) free(carpa); #undef VHADDR_PFMT } static struct cmd carp_cmds[] = { DEF_CMD_ARG("advbase", setcarp_advbase), DEF_CMD_ARG("advskew", setcarp_advskew), DEF_CMD_ARG("pass", setcarp_passwd), DEF_CMD_ARG("vhid", setcarp_vhid), DEF_CMD("vhaddr", 1, getcarp_vhaddr) }; static struct afswtch af_carp = { .af_name = "af_carp", .af_af = AF_UNSPEC, .af_other_status = carp_status, }; static __constructor(101) void carp_ctor(void) { #define N(a) (sizeof(a) / sizeof(a[0])) int i; for (i = 0; i < N(carp_cmds); i++) cmd_register(&carp_cmds[i]);
callback_register(callback_func *func, void *arg) { struct callback *cb; cb = malloc(sizeof(struct callback)); if (cb == NULL) errx(1, "unable to allocate memory for callback"); cb->cb_func = func; cb->cb_arg = arg; cb->cb_next = callbacks; callbacks = cb; } /* specially-handled commands */ static void setifaddr(const char *, int, int, const struct afswtch *); static const struct cmd setifaddr_cmd = DEF_CMD("ifaddr", 0, setifaddr); static void setifdstaddr(const char *, int, int, const struct afswtch *); static const struct cmd setifdstaddr_cmd = DEF_CMD("ifdstaddr", 0, setifdstaddr); static int ifconfig(int argc, char *const *argv, int iscreate, const struct afswtch *uafp) { const struct afswtch *afp, *nafp; const struct cmd *p; struct callback *cb; int s; strncpy(ifr.ifr_name, name, sizeof ifr.ifr_name); afp = uafp != NULL ? uafp : af_getbyname("inet");
callback_register(callback_func *func, void *arg) { struct callback *cb; cb = malloc(sizeof(struct callback)); if (cb == NULL) errx(1, "unable to allocate memory for callback"); cb->cb_func = func; cb->cb_arg = arg; cb->cb_next = callbacks; callbacks = cb; } /* specially-handled commands */ static void setifaddr(const char *, int, int, const struct afswtch *); static const struct cmd setifaddr_cmd = DEF_CMD("ifaddr", 0, setifaddr); static void setifdstaddr(const char *, int, int, const struct afswtch *); static const struct cmd setifdstaddr_cmd = DEF_CMD("ifdstaddr", 0, setifdstaddr); static int ifconfig(int argc, char *const *argv, int iscreate, const struct afswtch *uafp) { const struct afswtch *afp, *nafp; struct callback *cb; int s; strncpy(ifr.ifr_name, name, sizeof ifr.ifr_name); afp = uafp != NULL ? uafp : af_getbyname("inet"); top:
DSMAction* DSMCoreModule::getAction(const string& from_str) { string cmd; string params; splitCmd(from_str, cmd, params); DEF_CMD("repost", SCRepostAction); DEF_CMD("jumpFSM", SCJumpFSMAction); DEF_CMD("callFSM", SCCallFSMAction); DEF_CMD("returnFSM", SCReturnFSMAction); DEF_CMD("throw", SCThrowAction); DEF_CMD("throwOnError", SCThrowOnErrorAction); DEF_CMD("stop", SCStopAction); DEF_CMD("playPrompt", SCPlayPromptAction); DEF_CMD("playPromptLooped", SCPlayPromptLoopedAction); DEF_CMD("playFile", SCPlayFileAction); DEF_CMD("playFileFront", SCPlayFileFrontAction); DEF_CMD("recordFile", SCRecordFileAction); DEF_CMD("stopRecord", SCStopRecordAction); DEF_CMD("getRecordLength", SCGetRecordLengthAction); DEF_CMD("getRecordDataSize", SCGetRecordDataSizeAction); DEF_CMD("closePlaylist", SCClosePlaylistAction); DEF_CMD("setInOutPlaylist", SCSetInOutPlaylistAction); DEF_CMD("addSeparator", SCAddSeparatorAction); DEF_CMD("connectMedia", SCConnectMediaAction); DEF_CMD("disconnectMedia", SCDisconnectMediaAction); DEF_CMD("mute", SCMuteAction); DEF_CMD("unmute", SCUnmuteAction); DEF_CMD("enableDTMFDetection", SCEnableDTMFDetection); DEF_CMD("disableDTMFDetection", SCDisableDTMFDetection); DEF_CMD("set", SCSetAction); DEF_CMD("sets", SCSetSAction); DEF_CMD("eval", SCEvalAction); DEF_CMD("setVar", SCSetVarAction); DEF_CMD("var", SCGetVarAction); DEF_CMD("append", SCAppendAction); DEF_CMD("substr", SCSubStrAction); DEF_CMD("inc", SCIncAction); DEF_CMD("log", SCLogAction); DEF_CMD("clear", SCClearAction); DEF_CMD("logVars", SCLogVarsAction); DEF_CMD("logParams", SCLogParamsAction); DEF_CMD("logSelects", SCLogSelectsAction); DEF_CMD("logAll", SCLogAllAction); DEF_CMD("setTimer", SCSetTimerAction); DEF_CMD("removeTimer", SCRemoveTimerAction); DEF_CMD("removeTimers", SCRemoveTimersAction); DEF_CMD("setPrompts", SCSetPromptsAction); DEF_CMD("postEvent", SCPostEventAction); if (cmd == "DI") { SCDIAction * a = new SCDIAction(params, false); a->name = from_str; return a; } if (cmd == "DIgetResult") { SCDIAction * a = new SCDIAction(params, true); a->name = from_str; return a; } DEF_CMD("B2B.connectCallee", SCB2BConnectCalleeAction); DEF_CMD("B2B.terminateOtherLeg", SCB2BTerminateOtherLegAction); DEF_CMD("B2B.sendReinvite", SCB2BReinviteAction); DEF_CMD("B2B.addHeader", SCB2BAddHeaderAction); DEF_CMD("B2B.clearHeaders", SCB2BClearHeadersAction); DEF_CMD("B2B.setHeaders", SCB2BSetHeadersAction); return NULL; }
} if (0 /* XXX */) { printf("\tsupported aggregation protocols:\n"); for (i = 0; i < (sizeof(lpr) / sizeof(lpr[0])); i++) printf("\t\tlaggproto %s\n", lpr[i].lpr_name); } } } static struct cmd lagg_cmds[] = { DEF_CMD_ARG("laggport", setlaggport), DEF_CMD_ARG("-laggport", unsetlaggport), DEF_CMD_ARG("laggproto", setlaggproto), DEF_CMD_ARG("lagghash", setlagghash), DEF_CMD("use_flowid", LAGG_OPT_USE_FLOWID, setlaggsetopt), DEF_CMD("-use_flowid", -LAGG_OPT_USE_FLOWID, setlaggsetopt), DEF_CMD("lacp_strict", LAGG_OPT_LACP_STRICT, setlaggsetopt), DEF_CMD("-lacp_strict", -LAGG_OPT_LACP_STRICT, setlaggsetopt), DEF_CMD("lacp_txtest", LAGG_OPT_LACP_TXTEST, setlaggsetopt), DEF_CMD("-lacp_txtest", -LAGG_OPT_LACP_TXTEST, setlaggsetopt), DEF_CMD("lacp_rxtest", LAGG_OPT_LACP_RXTEST, setlaggsetopt), DEF_CMD("-lacp_rxtest", -LAGG_OPT_LACP_RXTEST, setlaggsetopt), DEF_CMD("lacp_fast_timeout", LAGG_OPT_LACP_TIMEOUT, setlaggsetopt), DEF_CMD("-lacp_fast_timeout", -LAGG_OPT_LACP_TIMEOUT, setlaggsetopt), DEF_CMD_ARG("flowid_shift", setlaggflowidshift), DEF_CMD_ARG("rr_limit", setlaggrr_limit), }; static struct afswtch af_lagg = { .af_name = "af_lagg", .af_af = AF_UNSPEC,
DEF_CMD_ARG("-learn", unsetbridge_learn), DEF_CMD_ARG("sticky", setbridge_sticky), DEF_CMD_ARG("-sticky", unsetbridge_sticky), DEF_CMD_ARG("span", setbridge_span), DEF_CMD_ARG("-span", unsetbridge_span), DEF_CMD_ARG("stp", setbridge_stp), DEF_CMD_ARG("-stp", unsetbridge_stp), DEF_CMD_ARG("edge", setbridge_edge), DEF_CMD_ARG("-edge", unsetbridge_edge), DEF_CMD_ARG("autoedge", setbridge_autoedge), DEF_CMD_ARG("-autoedge", unsetbridge_autoedge), DEF_CMD_ARG("ptp", setbridge_ptp), DEF_CMD_ARG("-ptp", unsetbridge_ptp), DEF_CMD_ARG("autoptp", setbridge_autoptp), DEF_CMD_ARG("-autoptp", unsetbridge_autoptp), DEF_CMD("flush", 0, setbridge_flush), DEF_CMD("flushall", 0, setbridge_flushall), DEF_CMD_ARG2("static", setbridge_static), DEF_CMD_ARG("deladdr", setbridge_deladdr), DEF_CMD("addr", 1, setbridge_addr), DEF_CMD_ARG("maxaddr", setbridge_maxaddr), DEF_CMD_ARG("hellotime", setbridge_hellotime), DEF_CMD_ARG("fwddelay", setbridge_fwddelay), DEF_CMD_ARG("maxage", setbridge_maxage), DEF_CMD_ARG("priority", setbridge_priority), DEF_CMD_ARG("proto", setbridge_protocol), DEF_CMD_ARG("holdcnt", setbridge_holdcount), DEF_CMD_ARG2("ifpriority", setbridge_ifpriority), DEF_CMD_ARG2("ifpathcost", setbridge_ifpathcost), DEF_CMD_ARG2("ifmaxaddr", setbridge_ifmaxaddr), DEF_CMD_ARG("timeout", setbridge_timeout),
CommandProc CmdAutofillTimetable; CommandProc CmdSetTimetableStart; CommandProc CmdOpenCloseAirport; #define DEF_CMD(proc, flags, type) {proc, #proc, (CommandFlags)flags, type} /** * The master command table * * This table contains all possible CommandProc functions with * the flags which belongs to it. The indices are the same * as the value from the CMD_* enums. */ static const Command _command_proc_table[] = { DEF_CMD(CmdBuildRailroadTrack, CMD_NO_WATER | CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_BUILD_RAILROAD_TRACK DEF_CMD(CmdRemoveRailroadTrack, CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_REMOVE_RAILROAD_TRACK DEF_CMD(CmdBuildSingleRail, CMD_NO_WATER | CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_BUILD_SINGLE_RAIL DEF_CMD(CmdRemoveSingleRail, CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_REMOVE_SINGLE_RAIL DEF_CMD(CmdLandscapeClear, 0, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_LANDSCAPE_CLEAR DEF_CMD(CmdBuildBridge, CMD_DEITY | CMD_NO_WATER | CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_BUILD_BRIDGE DEF_CMD(CmdBuildRailStation, CMD_NO_WATER | CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_BUILD_RAIL_STATION DEF_CMD(CmdBuildTrainDepot, CMD_NO_WATER | CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_BUILD_TRAIN_DEPOT DEF_CMD(CmdBuildSingleSignal, CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_BUILD_SIGNALS DEF_CMD(CmdRemoveSingleSignal, CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_REMOVE_SIGNALS DEF_CMD(CmdTerraformLand, CMD_ALL_TILES | CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_TERRAFORM_LAND DEF_CMD(CmdBuildObject, CMD_NO_WATER | CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_BUILD_OBJECT DEF_CMD(CmdBuildTunnel, CMD_DEITY | CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_BUILD_TUNNEL DEF_CMD(CmdRemoveFromRailStation, 0, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_REMOVE_FROM_RAIL_STATION DEF_CMD(CmdConvertRail, 0, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_CONVERT_RAILD DEF_CMD(CmdBuildRailWaypoint, 0, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_BUILD_RAIL_WAYPOINT
if (d < 0) opts &= ~(-d); else opts |= d; if (ioctl(s, GRESOPTS, &ifr) == -1) { warn("ioctl(GIFSOPTS)"); return; } } static struct cmd gre_cmds[] = { DEF_CMD_ARG("grekey", setifgrekey), DEF_CMD("enable_csum", GRE_ENABLE_CSUM, setifgreopts), DEF_CMD("-enable_csum",-GRE_ENABLE_CSUM,setifgreopts), DEF_CMD("enable_seq", GRE_ENABLE_SEQ, setifgreopts), DEF_CMD("-enable_seq",-GRE_ENABLE_SEQ, setifgreopts), }; static struct afswtch af_gre = { .af_name = "af_gre", .af_af = AF_UNSPEC, .af_other_status = gre_status, }; static __constructor void gre_ctor(void) { #define N(a) (sizeof(a) / sizeof(a[0])) size_t i;
DSMAction* DSMCoreModule::getAction(const string& from_str) { string cmd; string params; splitCmd(from_str, cmd, params); #define DEF_CMD(cmd_name, class_name) \ \ if (cmd == cmd_name) { \ class_name * a = \ new class_name(params); \ a->name = from_str; \ return a; \ } DEF_CMD("repost", SCRepostAction); DEF_CMD("jumpFSM", SCJumpFSMAction); DEF_CMD("callFSM", SCCallFSMAction); DEF_CMD("returnFSM", SCReturnFSMAction); DEF_CMD("stop", SCStopAction); DEF_CMD("playPrompt", SCPlayPromptAction); DEF_CMD("playFile", SCPlayFileAction); DEF_CMD("recordFile", SCRecordFileAction); DEF_CMD("stopRecord", SCStopRecordAction); DEF_CMD("closePlaylist", SCClosePlaylistAction); DEF_CMD("set", SCSetAction); DEF_CMD("append", SCAppendAction); DEF_CMD("log", SCLogAction); DEF_CMD("setTimer", SCSetTimerAction); if (cmd == "DI") { SCDIAction * a = new SCDIAction(params, false); a->name = from_str; return a; } if (cmd == "DIgetResult") { SCDIAction * a = new SCDIAction(params, true); a->name = from_str; return a; } ERROR("could not find action named '%s'\n", cmd.c_str()); return NULL; }
if (__have_tag ^ __have_dev) errx(1, "both vlan and vlandev must be specified"); if (__have_tag && __have_dev) { ifr.ifr_data = (caddr_t)&__vreq; if (ioctl(s, SIOCSETVLAN, (caddr_t)&ifr) == -1) err(1, "SIOCSETVLAN"); } } static struct cmd vlan_cmds[] = { DEF_CMD_ARG("vlan", setvlantag), DEF_CMD_ARG("vlandev", setvlandev), /* XXX For compatibility. Should become DEF_CMD() some day. */ DEF_CMD_OPTARG("-vlandev", unsetvlandev), DEF_CMD("vlanmtu", IFCAP_VLAN_MTU, setifcap), DEF_CMD("-vlanmtu", -IFCAP_VLAN_MTU, setifcap), DEF_CMD("vlanhwtag", IFCAP_VLAN_HWTAGGING, setifcap), DEF_CMD("-vlanhwtag", -IFCAP_VLAN_HWTAGGING, setifcap), }; static struct afswtch af_vlan = { .af_name = "af_vlan", .af_af = AF_UNSPEC, .af_other_status = vlan_status, }; static __constructor(101) void vlan_ctor(void) { #define N(a) (sizeof(a) / sizeof(a[0])) int i;