int HDCCUNoticeHandler::DoResponse(HD8583STRUCT& req,HD8583STRUCT& resp,ACE_HANDLE peer) { int recordcnt = 0; size_t packlen; std::string filepath; char data[128] = ""; int ret; char phyid[12] = ""; ACE_OS::sprintf(phyid,"%.010d",req->TerminalSN); KSGDeviceNode* node = KsgGetGateway()->GetDeviceManager()->FindDevice(phyid); if(!node) { ACE_DEBUG((LM_ERROR,"CCU [%s] 不存在!",phyid)); return -1; } ACE_Time_Value tv = KSGGetTaskTimeoutIntval(); MYDATETIMESTRUCT now = HDDEV::HDGetDataTime(); resp.SetFieldValue(FIELD_DATEANDTIME,(char*)&now,sizeof now); resp.SetFieldValue(FIELD_TERMINALSN,req->TerminalSN); unsigned char buf[(FILEID_ARECORD+1)* RECORD_SECT_LEN]; ACE_OS::memset(buf,0x00,sizeof buf); resp.SetFieldValue(FIELD_ADDITIONALDATA2,(char*)buf,sizeof buf); packlen = PackRequestStruct(resp,MT_CCUONLINENOTICE1,data,sizeof data); if(HDSendBuffer(peer,data,packlen,&tv)) { ACE_DEBUG((LM_ERROR,"发送应答失败")); } // 主动应答 filepath = HDA_FILENAME_PRECORD1; ret = DoFile(FILEID_PRECORD1,req->AdditionalData2+FILEID_PRECORD1*RECORD_SECT_LEN ,node,req,filepath); if(ret) { // 错误 ACE_DEBUG((LM_ERROR,"处理流水记录文件1失败")); } filepath = HDA_FILENAME_PRECORD2; ret = DoFile(FILEID_PRECORD2,req->AdditionalData2+FILEID_PRECORD2*RECORD_SECT_LEN ,node,req,filepath); if(ret) { // 错误 ACE_DEBUG((LM_ERROR,"处理流水记录文件2失败")); } return 0; }
bool CConfigLog::WriteLogFile(String &sError) { CloseFile(); bool writing = true; return DoFile(writing, sError); }
void CConfigLog::ReadLogFile(const String & Filepath) { CloseFile(); bool writing = false; String sError; m_pCfgSettings = new CfgSettings; if (!ParseSettings(Filepath)) return; DoFile(writing, sError); }
LuaEnvironment::LuaEnvironment() { L_ = lua_open(); // Load the default libraries luaL_openlibs(L_); // Utility functions RegisterFunction("c_print", Utility::l_Print); RegisterFunction("c_println", Utility::l_Println); // Run the Lua init script DoFile("./lua/init.lua"); }
/* * M A I N * * Parse arguments, valid ones are: * name of file to plot (instead of STDIN) * -d for debugging statements * * Default (no arguments) action is to plot STDIN on current FB. */ int main(int argc, char **argv) { Nscanlines = Npixels = 512; if ( !get_args( argc, argv ) ) { (void)fputs(usage, stderr); bu_exit( 1, NULL ); } /* Open frame buffer, adapt to slightly smaller ones */ if ( (fbp = fb_open(framebuffer, Npixels, Nscanlines)) == FBIO_NULL ) { fprintf(stderr, "pl-fb: fb_open failed\n"); bu_exit(1, NULL); } Npixels = fb_getwidth(fbp); Nscanlines = fb_getheight(fbp); if ( immediate ) { lines_per_band = Nscanlines; if ( !over ) fb_clear( fbp, RGBPIXEL_NULL ); } else if ( Nscanlines <= 512 ) { /* make one full size band */ lines_per_band = Nscanlines; single_banded = 1; } /* * Handle image-size specific initializations */ if ( (Nscanlines % lines_per_band) != 0 ) { /* round it down - only necessary if buffered? */ Nscanlines = (Nscanlines / lines_per_band) * lines_per_band; } space.left = space.right = 0; space.right = Npixels; space.top = Nscanlines; delta = Nscanlines; deltao2 = Nscanlines/2; buffersize = lines_per_band*Npixels*sizeof(RGBpixel); if ( (buffer = (unsigned char *)malloc(buffersize)) == RGBPIXEL_NULL) { fprintf(stderr, "pl-fb: malloc error\n"); bu_exit(1, NULL); } /* Extra band protects against requeueing off the top */ band = (struct band *)malloc((BANDSLOP)*sizeof(struct band)); if ( band == (struct band *)0 ) { fprintf(stderr, "pl-fb: malloc error2\n"); bu_exit(1, NULL); } memset((char *)band, 0, (BANDSLOP)*sizeof(struct band)); bandEnd = &band[BANDS]; if ( single_banded && over ) { /* Read in initial screen */ if ( fb_read( fbp, 0, 0, buffer, buffersize/sizeof(RGBpixel) ) <= 0 ) fprintf(stderr, "pl-fb: band read error\n"); } if ( debug ) fprintf(stderr, "pl-fb output of %s\n", filename); SetSigs(); /* set signal catchers */ (void)DoFile( ); /* plot it */ bu_exit(0, NULL); }
int main( int argc, char **argv ) { char *args; int i = 0; FILE *op; char filename[MAX_PATH]; if (argc >= 2) { for(int i=1; i<argc; i++) { args = argv[i]; switch ( args[1] ) { case 'd': sprintf(gBaseDir,args + 2); break; case 'l': sprintf(gLangDir,args + 2); sprintf(gBaseDir,"D:\\falcon4\\%s\\campaign\\save",gLangDir); break; default: break; } } } else { sprintf(gBaseDir,"D:\\falcon4\\campaign\\save"); sprintf(gLangDir,"output"); printf("Working directory: %s",gBaseDir); // scanf("%s",baseDir); } ReadIndex("strings"); LoadNames("Korea"); BuildExampleNames(); sprintf(filename,"%s\\%s.txt",gBaseDir,gLangDir); op = fopen(filename,"w"); while (FilesToRead[i][0]) { ClearTokenList(); fprintf(op,"\n==============================\n"); fprintf(op,"FILENAME: %s\n",FilesToRead[i]); fprintf(op,"==============================\n"); printf("\n==============================\n"); printf("FILENAME: %s\n",FilesToRead[i]); printf("==============================\n"); AnalyseFile(FilesToRead[i]); DoFile(FilesToRead[i],op); i++; } FreeIndex(); FreeNames(); fclose(op); printf("Done! - press <return> to exit\n"); getchar(); return 1; }
int main(int argc, char **argv) { const char *savedir = "."; struct fstab *fsp; int i, ch, error; checkfor = compress = clear = force = keep = verbose = 0; nfound = nsaved = nerr = 0; openlog("savecore", LOG_PERROR, LOG_DAEMON); while ((ch = getopt(argc, argv, "Ccfkvz")) != -1) switch(ch) { case 'C': checkfor = 1; break; case 'c': clear = 1; break; case 'k': keep = 1; break; case 'v': verbose++; break; case 'f': force = 1; break; case 'z': compress = 1; break; case '?': default: usage(); } if (checkfor && (clear || force || keep)) usage(); argc -= optind; argv += optind; if (argc >= 1) { error = chdir(argv[0]); if (error) { syslog(LOG_ERR, "chdir(%s): %m", argv[0]); exit(1); } savedir = argv[0]; argc--; argv++; } if (argc == 0) { for (;;) { fsp = getfsent(); if (fsp == NULL) break; if (strcmp(fsp->fs_vfstype, "swap") && strcmp(fsp->fs_vfstype, "dump")) continue; DoFile(savedir, fsp->fs_spec); } } else { for (i = 0; i < argc; i++) DoFile(savedir, argv[i]); } /* Emit minimal output. */ if (nfound == 0) { if (checkfor) { printf("No dump exists\n"); exit(1); } syslog(LOG_WARNING, "no dumps found"); } else if (nsaved == 0) { if (nerr != 0) syslog(LOG_WARNING, "unsaved dumps found but not saved"); else syslog(LOG_WARNING, "no unsaved dumps found"); } return (0); }
// ///////////////////////////////////////////////////////////////// // // ///////////////////////////////////////////////////////////////// bool LuaStateManager::Init(char const * const pInitFileName) { // Create our global actor table. // This table will hold context for all actors created in the game world. LuaPlus::LuaObject globals = m_GlobalState->GetGlobals(); LuaPlus::LuaObject actorTable = globals.CreateTable("ActorList"); // Execute the init file and setup some useful global variables for the lua scripts to know. if(DoFile(pInitFileName)) { std::string luaCommand; // The LUA command to execute. std::string currOpVal; // The current option value retrieved. boost::shared_ptr<GameOptions> opPtr = g_appPtr->GetGameOptions(); // Write out the location of the game root directory. boost::filesystem::path gameRoot(g_appPtr->GetGameRootDir()); //if(GameHalloran::RetrieveAndConvertOption<std::string>(opPtr, std::string("GameRoot"), GameHalloran::GameOptions::PROGRAMMER, currOpVal)) //{ luaCommand = std::string("INIT_GAME_ROOT_PATH = \"") + gameRoot.generic_string() + std::string("\";"); if(!ExecuteString(luaCommand.c_str())) { return (false); } currOpVal.clear(); luaCommand.clear(); //} // Write out what type of build is running. #ifdef DEBUG luaCommand = std::string("INIT_RUNNING_DEBUG_BUILD = true;"); #else luaCommand = std::string("INIT_RUNNING_DEBUG_BUILD = false;"); #endif if(!ExecuteString(luaCommand.c_str())) { return (false); } luaCommand.clear(); // Write out the various player options so they are available to the lua UI setup scripts. luaCommand = std::string("INIT_PLAYER_OPTIONS = {};"); if(!ExecuteString(luaCommand.c_str())) { return (false); } luaCommand.clear(); // Sound options. if(GameHalloran::RetrieveAndConvertOption<std::string>(opPtr, std::string("MasterVolume"), GameHalloran::GameOptions::PLAYER, currOpVal)) { luaCommand = std::string("INIT_PLAYER_OPTIONS.MasterVolume = ") + currOpVal + std::string(";"); if(!ExecuteString(luaCommand.c_str())) { return (false); } currOpVal.clear(); luaCommand.clear(); } bool flag; if(GameHalloran::RetrieveAndConvertOption<bool>(opPtr, std::string("Music"), GameHalloran::GameOptions::PLAYER, flag)) { luaCommand = std::string("INIT_PLAYER_OPTIONS.Music = ") + (flag ? std::string("true") : std::string("false")) + std::string(";"); if(!ExecuteString(luaCommand.c_str())) { return (false); } luaCommand.clear(); } if(GameHalloran::RetrieveAndConvertOption<bool>(opPtr, std::string("SoundFx"), GameHalloran::GameOptions::PLAYER, flag)) { luaCommand = std::string("INIT_PLAYER_OPTIONS.SoundFx = ") + (flag ? std::string("true") : std::string("false")) + std::string(";"); if(!ExecuteString(luaCommand.c_str())) { return (false); } luaCommand.clear(); } // Graphics options. if(GameHalloran::RetrieveAndConvertOption<bool>(opPtr, std::string("RenderShadows"), GameHalloran::GameOptions::PLAYER, flag)) { luaCommand = std::string("INIT_PLAYER_OPTIONS.RenderShadows = ") + (flag ? std::string("true") : std::string("false")) + std::string(";"); if(!ExecuteString(luaCommand.c_str())) { return (false); } luaCommand.clear(); } if(GameHalloran::RetrieveAndConvertOption<std::string>(opPtr, std::string("ScreenWidth"), GameHalloran::GameOptions::PLAYER, currOpVal)) { luaCommand = std::string("INIT_PLAYER_OPTIONS.ScreenResolution = \"") + currOpVal + std::string("*"); boost::shared_ptr<GameOptions> opPtr = g_appPtr->GetGameOptions(); if(GameHalloran::RetrieveAndConvertOption<std::string>(opPtr, std::string("ScreenHeight"), GameHalloran::GameOptions::PLAYER, currOpVal)) { luaCommand += currOpVal + std::string("\";"); if(!ExecuteString(luaCommand.c_str())) { return (false); } } currOpVal.clear(); luaCommand.clear(); } if(GameHalloran::RetrieveAndConvertOption<std::string>(opPtr, std::string("Multisampling"), GameHalloran::GameOptions::PLAYER, currOpVal)) { currOpVal = std::string("x") + currOpVal; luaCommand = std::string("INIT_PLAYER_OPTIONS.Multisampling = \"") + currOpVal + std::string("\";"); if(!ExecuteString(luaCommand.c_str())) { return (false); } currOpVal.clear(); luaCommand.clear(); } if(GameHalloran::RetrieveAndConvertOption<std::string>(opPtr, std::string("TextureFilteringType"), GameHalloran::GameOptions::PLAYER, currOpVal)) { luaCommand = std::string("INIT_PLAYER_OPTIONS.TextureFilteringType = \"") + currOpVal + std::string("\";"); if(!ExecuteString(luaCommand.c_str())) { return (false); } currOpVal.clear(); luaCommand.clear(); } return (true); } return (false); }