int on_switch(char * v, void *d) { __bool ok = __false; CArgs args; PCRTK_PACKET p = (PCRTK_PACKET)d; parse_arg_ex(v, &args, " "); if(args.argc >= 2){ if(!strcmpi(args.argv[1], "primary")){ ok = switch_to_primary(); }else if(!strcmpi(args.argv[1], "backup")){ ok = switch_to_backup(); } } send_rtk_data_with_guid( vbus_system, &p->src, &p->guid, ok ? PT_System : PT_System | PF_Failed | PF_ACK, 0, 0 ); return 0; }
int main(int c, char **v) { char buf[1024]; CArgs args; char *dirName = "."; char *catagory=0; char path[F8_MAX_PATH]; BEGIN_ARGS ARG("-d:", dirName, "char *", "specify operation directory.") ARG("-c:", catagory, "char *", "specify library catagory[dir name]") END_ARGS if(process_args_1(c, v)){ print_usage_1(); return -1; } if(!SetCurrentDirectory(dirName)){ utils_error("Cannot change directory to ``%s''.\n", dirName); return -1; } GetCurrentDirectory(sizeof(buf), buf); parse_arg_ex(buf, &args, ":/\\"); if(!catagory){ catagory = args.argv[args.argc-1]; } GetCurrentDirectory(sizeof(path), path); printf( "Making library database in ``%s'', catagory ``%s''\n", path, catagory ); fdb = fopen("f8.dir", "w"); if(!fdb){ return -1; } fprintf(fdb, "[library]\n"); fprintf(fdb, "catagory=%s\n", catagory); enumerate_files( ".", "*.blk", _e_file, 0, 0); fprintf(fdb, "count=%d\n", count); fclose(fdb); printf("%d entries added.\n", count); return 0; }
void CAutoPopup::init() { __uint i; popupEntry_t * ent; nEntries = (__uint)GetPrivateProfileInt( "AutoPopup", "count", 0, get_config_file() ); if(nEntries >= maxPopups){ nEntries = maxPopups; } ent = entries; char lineBuf[1024]; char key[4]; memset(&entries, 0, sizeof(entries)); for(i=0; i<nEntries; i++){ sprintf(key, "%d", i); GetPrivateProfileString( "AutoPopup", key, "", lineBuf, sizeof(lineBuf), get_config_file() ); CArgs a; parse_arg_ex(lineBuf, &a, ","); if(a.argc != 5){ continue; } if(!tagname_by_text(&ent->tn, a.argv[0])){ continue; } if(atoi(a.argv[1])){ ent->flags |= popupWhenVariableIsOn; } if(atoi(a.argv[2])){ ent->flags |= popupOverlay; } if(atoi(a.argv[3])){ ent->flags |= popupAutoHide; } strncpy(ent->associatedPicture, a.argv[4], MAX_PATH); ent->associatedPicture[MAX_PATH - 1] = 0; ent++; } nEntries = ent - entries; }
void CSerialPortItem::ReloadContents() { char buf[32]; char setting[1024]; CArgs args; sprintf(buf, "PORT%d", m_PortNo); if(!get_config_string(&key, "ports", buf, setting, sizeof(setting), 500)){ return; } utils_debug("Port%d on %s: %s\n", m_PortNo, (char*)CNodeName(key), setting); parse_arg_ex(setting, &args, ","); if(args.argc != 4){ return; } m_baud = atoi(args.argv[0]); if( m_baud != 4800 && m_baud != 9600 && m_baud != 19200 && m_baud != 38400 && m_baud != 57600 && m_baud != 115200 ){ m_baud = 57600; } m_checkmode = *args.argv[1]; if(!strchr("mbeon", m_checkmode) ){ m_checkmode = 'm'; } m_databits = atoi(args.argv[2]); if(m_databits < 6 || m_databits>8){ m_databits = 8; } if( !strcmp(args.argv[3], "1") ){ m_stopbits = 1; }else if(!strcmp(args.argv[3], "2") ){ m_stopbits = 2; }else if(!strcmp(args.argv[3], "1.5") ){ m_stopbits = 3; }else{ m_stopbits = 1; } }
int on_mmap(char *v, void *k) { CArgs args; int i; parse_arg_ex(v, &args, FS); if(args.argc == 1){ for(i=0; i<KERN_NUM_SECTIONS; i++){ utils_trace("Dump of memory section %d\n", i); dump_map(i); } }else{ for(i=1; i<args.argc; i++){ dump_map(atoi(args.argv[i])); } } return F8_SUCCESS; }
static int on_test(char * arg, void * k) { int i; int count=10; char * cmd = "uload"; BEGIN_ARGS ARG("-c:", count, "int", "count") ARG("-a:", cmd, "char *", "command to stress") END_ARGS CArgs args; parse_arg_ex(arg, &args, FS); if(process_args_1(args.argc, args.argv) < 0){ print_usage_1(); return F8_SYNTAX; } for(i=0; i<count; i++){ kproxy_shell(cmd); } return 0; }
IOSS_DLL_EXPORT __bool address_translate(PRTK_TAG tte) { CArgs args; parse_arg_ex(tte->s.Address, & args, "."); memset(tte->d.BinaryAddress,0,sizeof(tte->d.BinaryAddress)); int add; if(utils_argc == 2){ if(0 == strcmpi(args.argv[0], "r")){ tte->d.BinaryAddress[0] = 'a'; }else if(0 == strcmpi(args.argv[0], "s")){ tte->d.BinaryAddress[0] = 'b'; }else if(0 == strcmpi(args.argv[0], "p")){ tte->d.BinaryAddress[0] = 'c'; }else if(0 == strcmpi(args.argv[0], "u")){ tte->d.BinaryAddress[0] = 'd'; }else if(0 == strcmpi(args.argv[0], "h")){ tte->d.BinaryAddress[0] = 'e'; }else if(0 == strcmpi(args.argv[0], "n1")){ tte->d.BinaryAddress[0] = 'f'; }else if(0 == strcmpi(args.argv[0], "n2")){ tte->d.BinaryAddress[0] = 'g'; }else if(0 == strcmpi(args.argv[0], "dr")){ tte->d.BinaryAddress[0] = 'h'; }else if(0 == strcmpi(args.argv[0], "ds")){ tte->d.BinaryAddress[0] = 'i'; }else if(0 == strcmpi(args.argv[0], "dp")){ tte->d.BinaryAddress[0] = 'j'; }else{ return __false; } add = atoi(args.argv[1]); memcpy(&tte->d.BinaryAddress[1], &add, 4); return __true; }else{ return __false; } }
KSERVER_API f8_status kserver_main(const char * cmdline) { CArgs a; parse_arg_ex(cmdline, &a, " \t\n"); return kserver_main2(a.argc, a.argv); }
/* in WIN32, the executive can run in two mode, i.e., the SoftPLC mode or the simulator mode. in SoftPLC mode, the executive will try to probe additional IO drivers and perform IOs during execution, while in simulator mode, no IO is performed. */ KSERVER_API int kserver_main2(int c, char **v) { int flags; char * mode = 0; int port = 0; __bool dbgMode; int leakDetect = 0; BEGIN_ARGS ARG("mode=", mode, "char *", "mode specifiers") ARG("port=", port, "int", "agent port") ARG("leak=", leakDetect, "int", "detect memory leakage") ARG("--debug", dbgMode, "tbool", "debug mode") END_ARGS if(process_args_1(c, v)<0){ print_usage_1(); return F8_SYNTAX; } if(leakDetect){ _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); _CrtSetBreakAlloc(leakDetect); } if(mode){ CArgs a; parse_arg_ex(mode, &a, "+/|-= ,;:"); int i; flags = 0; for(i=0; i<a.argc; i++){ if(!strcmp(a.argv[i], "sched")){ flags |= KERN_F_ENABLE_SCHEDULER; }else if(!strcmp(a.argv[i], "standby")){ flags |= KERN_F_ENABLE_STANDBY; }else if(!strcmp(a.argv[i], "io")){ flags |= KERN_F_ENABLE_IO; }else if(!strcmp(a.argv[i], "sio")){ flags |= KERN_F_SERIALIZED_IO; }else if(!strcmp(a.argv[i], "agent")){ flags |= KERN_F_ENABLE_AGENT; }else if(!strcmp(a.argv[i], "single")){ flags = KERN_F_ENABLE_SCHEDULER | KERN_F_ENABLE_IO | KERN_F_ENABLE_AGENT; break; }else if(!strcmp(a.argv[i], "all")){ flags = KERN_F_ENABLE_SCHEDULER | KERN_F_ENABLE_IO | KERN_F_ENABLE_AGENT | KERN_F_ENABLE_STANDBY; break; }else if(!strcmp(a.argv[i], "headless")){ flags = KERN_F_ENABLE_SCHEDULER | KERN_F_ENABLE_AGENT | KERN_F_ENABLE_STANDBY; break; } } }else{ flags = KERN_F_ENABLE_SCHEDULER | KERN_F_ENABLE_IO | KERN_F_ENABLE_AGENT | KERN_F_ENABLE_STANDBY; } ex_init(); g_kernel = ke_get_default_kernel(); ex_start(flags, port); sections = ke_get_blk(g_kernel, NULL); return F8_SUCCESS; }