void __declspec(dllexport) PasteSerial(PLUGINDATA *pd) { pd->dwSupport|=PDS_SUPPORTALL; if (pd->dwSupport & PDS_GETSUPPORT) return; if (!bInitCommon) InitCommon(pd); else if (!bInitPasteSerial) ReadOptions(OF_PASTESERIAL); if (bInitPasteSerial) { UninitMain(); UninitPasteSerial(); //If any function still loaded, stay in memory and show as non-active if (nInitMain) pd->nUnload=UD_NONUNLOAD_NONACTIVE; } else { InitMain(); InitPasteSerial(); //Stay in memory, and show as active pd->nUnload=UD_NONUNLOAD_ACTIVE; } }
bool CLemmatizer::LoadDictionariesRegistry() { try { string load_path = GetPath(); m_bLoaded = Load(load_path+MORPH_MAIN_FILES); if (!m_bLoaded) return false; // implicity load homonyms statistic for literature m_Statistic.Load(load_path + "l"); m_bUseStatistic = true; m_Predict.Load(load_path + PREDICT_BIN_PATH); ReadOptions(load_path + OPTIONS_FILE); m_PrefixesSet.clear(); m_PrefixesSet.insert(m_Prefixes.begin(), m_Prefixes.end() ); return m_bLoaded; } catch(...) { return false; } }
//Plugin extern function void __declspec(dllexport) Capture(PLUGINDATA *pd) { pd->dwSupport|=PDS_SUPPORTALL; if (pd->dwSupport & PDS_GETSUPPORT) return; if (!bInitCommon) InitCommon(pd); else if (!bInitCapture) ReadOptions(OF_CAPTURE); if (bInitCapture) { DestroyDock(hWndCaptureDlg, DKT_KEEPAUTOLOAD); //Stay in memory and show as non-active pd->nUnload=UD_NONUNLOAD_NONACTIVE; } else { InitMain(); InitCapture(); pfCapture=pd->lpPluginFunction; bCaptureDockWaitResize=pd->bOnStart; CreateDock(&hWndCaptureDlg, &dkCaptureDlg, !bCaptureDockWaitResize); //Stay in memory, and show as active pd->nUnload=UD_NONUNLOAD_ACTIVE; } }
void InitCommon(PLUGINDATA *pd) { bInitCommon=TRUE; hInstanceDLL=pd->hInstanceDLL; hMainWnd=pd->hMainWnd; hWndEdit=pd->hWndEdit; bOldWindows=pd->bOldWindows; bAkelEdit=pd->bAkelEdit; nMDI=pd->nMDI; wLangModule=PRIMARYLANGID(pd->wLangModule); hPopupEdit=GetSubMenu(pd->hPopupMenu, MENU_POPUP_EDIT); //Initialize WideFunc.h header WideInitialize(); //Plugin name { int i; for (i=0; pd->wszFunction[i] != L':'; ++i) wszPluginName[i]=pd->wszFunction[i]; wszPluginName[i]=L'\0'; } xprintfW(wszPluginTitle, GetLangStringW(wLangModule, STRID_PLUGIN), wszPluginName); xstrcpynW(wszCaptureSeparator, L"\n------------------------------------------------------------\n", MAX_PATH); ReadOptions(OF_ALL); }
/***************************************************************************** INT WINAPI WinMain (HINSTANCE hInst, HINSTANCE hPrevInstance, LPSTR szCmdLine, int iCmdShow) hInst : (IN) Instance handle hPrevInstance : not used szCmdLine : not used iCmdShow : (IN) the state the user wants the window to be in Return Value: returns value of the main window *****************************************************************************/ INT WINAPI WinMain (HINSTANCE hInst, HINSTANCE /*hPrevInstance*/, LPSTR /*szCmdLine*/, int iCmdShow) { MSG msg; HWND mainHwnd; BOOL bPipeNecessary; lFILEINFO *fileList; HANDLE hMutex; g_hInstance = hInst; g_pstatus.bHaveComCtrlv6=CheckOsVersion(5,1); //are the common controls v6 available? (os>=winxp) g_pstatus.bIsVista=CheckOsVersion(6,0); g_pstatus.bHideVerified = false; InitializeCriticalSection(&thread_fileinfo_crit); hMutex = CreateMutex(NULL,FALSE,TEXT("Local\\RapidCRCUMutex")); if(!hMutex) { return 0; } WaitForSingleObject(hMutex,INFINITE); ReadOptions(); fileList = ParseCommandLine(&bPipeNecessary); if(fileList==NULL) { return 0; } RegisterMainWindowClass(); if (!(mainHwnd = InitInstance(iCmdShow))) { MessageBox(NULL, TEXT("Program uses Unicode and requires Windows NT or higher"), TEXT("Error"), MB_ICONERROR); return 0; } if(bPipeNecessary) { PostMessage(mainHwnd,WM_ACCEPT_PIPE,(WPARAM)fileList->uiCmdOpts,NULL); delete fileList; } else { PostMessage(mainHwnd,WM_THREAD_FILEINFO_START,(WPARAM)fileList,NULL); fileList=NULL; } ReleaseMutex(hMutex); while(GetMessage(&msg, NULL, 0, 0)) { if (!IsDialogMessage(mainHwnd, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } } DeleteCriticalSection(&thread_fileinfo_crit); return (INT) msg.wParam; }
FFMS_ResampleOptions *FFMS_AudioSource::CreateResampleOptions() const { #ifdef WITH_AVRESAMPLE FFMS_ResampleOptions *ret = ReadOptions(ResampleContext, resample_options); #else FFMS_ResampleOptions *ret = new FFMS_ResampleOptions; memset(ret, 0, sizeof(FFMS_ResampleOptions)); #endif ret->SampleRate = AP.SampleRate; ret->SampleFormat = static_cast<FFMS_SampleFormat>(AP.SampleFormat); ret->ChannelLayout = AP.ChannelLayout; return ret; }
std::unique_ptr<FFMS_ResampleOptions> FFMS_AudioSource::CreateResampleOptions() const { #ifdef FFMS_RESAMPLING_ENABLED auto ret = ReadOptions(ResampleContext, resample_options); #else auto ret = make_unique<FFMS_ResampleOptions>(); memset(ret.get(), 0, sizeof(FFMS_ResampleOptions)); #endif ret->SampleRate = AP.SampleRate; ret->SampleFormat = static_cast<FFMS_SampleFormat>(AP.SampleFormat); ret->ChannelLayout = AP.ChannelLayout; return ret; }
void FFMS_AudioSource::SetOutputFormat(const FFMS_ResampleOptions *opt) { if (!Cache.empty()) throw FFMS_Exception(FFMS_ERROR_RESAMPLING, FFMS_ERROR_USER, "Cannot change the output format after audio decoding has begun"); if (opt->SampleRate != AP.SampleRate) throw FFMS_Exception(FFMS_ERROR_RESAMPLING, FFMS_ERROR_UNSUPPORTED, "Sample rate changes are currently unsupported."); #ifndef WITH_AVRESAMPLE if (opt->SampleFormat != AP.SampleFormat || opt->SampleRate != AP.SampleRate || opt->ChannelLayout != AP.ChannelLayout) throw FFMS_Exception(FFMS_ERROR_RESAMPLING, FFMS_ERROR_UNSUPPORTED, "FFMS was not built with resampling enabled. The only supported conversion is interleaving planar audio."); #endif BytesPerSample = av_get_bytes_per_sample(static_cast<AVSampleFormat>(opt->SampleFormat)) * av_get_channel_layout_nb_channels(opt->ChannelLayout); NeedsResample = opt->SampleFormat != (int)CodecContext->sample_fmt || opt->SampleRate != AP.SampleRate || opt->ChannelLayout != AP.ChannelLayout || opt->ForceResample; #ifdef WITH_AVRESAMPLE if (!NeedsResample) return; std::auto_ptr<FFMS_ResampleOptions> oldOptions(ReadOptions(ResampleContext, resample_options)); SetOptions(opt, ResampleContext, resample_options); av_opt_set_int(ResampleContext, "in_sample_rate", AP.SampleRate, 0); av_opt_set_int(ResampleContext, "in_sample_fmt", CodecContext->sample_fmt, 0); av_opt_set_int(ResampleContext, "in_channel_layout", AP.ChannelLayout, 0); if (avresample_open(ResampleContext)) { SetOptions(oldOptions.get(), ResampleContext, resample_options); if (avresample_open(ResampleContext) < 0) throw FFMS_Exception(FFMS_ERROR_RESAMPLING, FFMS_ERROR_UNKNOWN, "Could not re-open old avresample context"); else throw FFMS_Exception(FFMS_ERROR_RESAMPLING, FFMS_ERROR_UNKNOWN, "Could not open avresample context"); } #endif }
Parser::Parser(wxEvtHandler* parent, cbProject* project) : m_Parent(parent), m_Project(project), m_UsingCache(false), m_Pool(this, wxNewId(), 1, 2 * 1024 * 1024), // in the meanwhile it'll have to be forced to 1 m_IsParsing(false), m_NeedsReparse(false), m_IsFirstBatch(false), m_ReparseTimer(this, wxNewId()), m_BatchTimer(this, wxNewId()), m_StopWatchRunning(false), m_LastStopWatchTime(0), m_IgnoreThreadEvents(true), m_IsBatchParseDone(false), m_ParserState(ParserCommon::ptCreateParser), m_NeedMarkFileAsLocal(true) { ReadOptions(); ConnectEvents(); }
int main(int argc, char **argv) { FastDup dupi; int pi = ReadOptions(argc, argv, dupi.opt); for (int i = pi; i < argc; ++i) dupi.AddDirectoryTree(argv[i]); /* Initial scan - this step will recurse through the directory tree(s) * and find each file we will be working with. These files are mapped * by their size as this process runs through, so we will be provided * with a list of files with the same sizes at the end. Those files * are what we select for the deep comparison, which is where the magic * really shows ;) */ if (Interactive) { printf("Scanning for files... \E[s"); fflush(stdout); } else
/* ========================================================================= */ int main(int argc, char *argv[]) { struct optbase *ob; char mode[MAX_VALUE_SIZE]; /* Read in options */ if(NULL == (ob = ReadOptions(argc, argv))) return(1); /* Validate that MODE is set (to something) */ if ( IsInvalidOption(ob, "MODE", IVO_EXISTS) ) { ErrorMessage("ERROR: MODE option is missing or invalid.\n"); return(1); } /* Read the MODE value */ if ( GetSTRValue(ob, mode, "MODE", 4, 8) ) { ErrorMessage("ERROR: Problems parsing MODE value.\n"); return(1); } /* Run as sender (and optionally (start) the sink) */ if ( ( strcmp(mode, "SENDER") == 0 ) || ( strcmp(mode, "SINK") == 0 ) ) return(run_as_sender(ob)); /* Run the receiver */ if ( ( strcmp(mode, "RECEIVER") == 0 ) || ( strcmp(mode, "MIRROR") == 0 ) ) return(run_as_receiver(ob)); /* Well... This is a problem. */ ErrorMessage("ERROR: MODE value not understood.\n"); return(1); }
int main(int argc, char **argv) { int simSize = 14; int xx; simResults = (double *) malloc(simSize*sizeof(double)); simCounts = (unsigned long *) malloc(simSize*sizeof(unsigned long)); simIndex = 0; for(xx = 0; xx < simSize ; xx++) { simResults[xx] = 0.0; simCounts[xx] = 0; } t_options Options; t_arch Arch = { 0 }; enum e_operation Operation; struct s_placer_opts PlacerOpts; struct s_annealing_sched AnnealSched; struct s_router_opts RouterOpts; struct s_det_routing_arch RoutingArch; t_segment_inf *Segments; t_timing_inf Timing; t_subblock_data Subblocks; boolean ShowGraphics; boolean TimingEnabled; int GraphPause; /* Print title message */ PrintTitle(); /* Print usage message if no args */ if(argc < 2) { PrintUsage(); exit(1); } /* Read in available inputs */ ReadOptions(argc, argv, &Options); /* Determine whether timing is on or off */ TimingEnabled = IsTimingEnabled(Options); /* Use inputs to configure VPR */ SetupVPR(Options, TimingEnabled, &Arch, &Operation, &PlacerOpts, &AnnealSched, &RouterOpts, &RoutingArch, &Segments, &Timing, &Subblocks, &ShowGraphics, &GraphPause); /* Check inputs are reasonable */ CheckOptions(Options, TimingEnabled); CheckArch(Arch, TimingEnabled); /* Verify settings don't conflict or otherwise not make sense */ CheckSetup(Operation, PlacerOpts, AnnealSched, RouterOpts, RoutingArch, Segments, Timing, Subblocks, Arch.Chans); /* Output the current settings to console. */ ShowSetup(Options, Arch, TimingEnabled, Operation, PlacerOpts, AnnealSched, RouterOpts, RoutingArch, Segments, Timing, Subblocks); if(Operation == TIMING_ANALYSIS_ONLY) { do_constant_net_delay_timing_analysis( Timing, Subblocks, Options.constant_net_delay); return 0; } /* Startup X graphics */ set_graphics_state(ShowGraphics, GraphPause, RouterOpts.route_type); if(ShowGraphics) { init_graphics("VPR: Versatile Place and Route for FPGAs"); alloc_draw_structs(); } /* Do the actual operation */ place_and_route(Operation, PlacerOpts, Options.PlaceFile, Options.NetFile, Options.ArchFile, Options.RouteFile, AnnealSched, RouterOpts, RoutingArch, Segments, Timing, &Subblocks, Arch.Chans); /* Close down X Display */ if(ShowGraphics) close_graphics(); /* free data structures */ free(Options.PlaceFile); free(Options.NetFile); free(Options.ArchFile); free(Options.RouteFile); freeArch(&Arch); printf("\nTiming Results\n"); for(xx = 0; xx < simSize ; xx++) { if(simCounts[xx] != 0) { simResults[xx] /= (double) simCounts[xx]; } printf("Index: %d\tAverage Clock: %f\n", xx, simResults[xx]); } free(simResults); free(simCounts); /* Return 0 to single success to scripts */ return 0; }
/** Allows to return a pointer to another buffer where the data is * available instead of copying the data into the buffer */ static constexpr ReadOptions lazy() { return ReadOptions(1); }
/** Copy the data to the given buffer */ static constexpr ReadOptions none() { return ReadOptions(0); }
constexpr ReadOptions operator~() const { return ReadOptions(~value_); }
constexpr ReadOptions operator^(ReadOptions const& that) const { return ReadOptions(value_ ^ that.value_); }
/** * @brief Function initializes options structure using data from EEPROM. * @brief Options are initialized to default values if version invalid. * @param void * @retval void */ void InitOptions(void) { ReadOptions(); if (options.version != OPTIONS_VER) { ResetOptions(); WriteOptions(); } }
bool DialogInstall::ReadPackage() { const WCHAR* fileName = m_PackageFileName.c_str(); const WCHAR* fileExtension = PathFindExtension(fileName); if (_wcsicmp(fileExtension, L".rmskin") == 0) { // Check if the footer is present (for new .rmskin format) PackageFooter footer = {0}; FILE* file = _wfopen(fileName, L"rb"); __int64 fileSize = 0; if (file) { fseek(file, -(long)sizeof(footer), SEEK_END); fileSize = _ftelli64(file); fread(&footer, sizeof(footer), 1, file); fclose(file); } if (strcmp(footer.key, "RMSKIN") == 0) { m_PackageFormat = PackageFormat::New; if (footer.size != fileSize) { return false; } if (footer.flags) { m_BackupPackage = !(footer.flags & PackageFlag::Backup); } } } else if (_wcsicmp(fileExtension, L".zip") != 0) { return false; } m_PackageUnzFile = unzOpen(ConvertToAscii(fileName).c_str()); if (!m_PackageUnzFile) { return false; } WCHAR buffer[MAX_PATH]; // Get temporary file to extract the options file and header bitmap GetTempPath(MAX_PATH, buffer); GetTempFileName(buffer, L"dat", 0, buffer); std::wstring tempFile = buffer; const WCHAR* tempFileSz = tempFile.c_str(); // Helper to sets buffer with current file name auto getFileInfo = [&]()->bool { char cBuffer[MAX_PATH * 3]; unz_file_info ufi; if (unzGetCurrentFileInfo( m_PackageUnzFile, &ufi, cBuffer, _countof(cBuffer), nullptr, 0, nullptr, 0) == UNZ_OK) { const uLong ZIP_UTF8_FLAG = 1 << 11; const DWORD codePage = (ufi.flag & ZIP_UTF8_FLAG) ? CP_UTF8 : CP_ACP; MultiByteToWideChar(codePage, 0, cBuffer, strlen(cBuffer) + 1, buffer, MAX_PATH); while (WCHAR* pos = wcschr(buffer, L'/')) *pos = L'\\'; return true; } return false; }; // Loop through the contents of the archive until the settings file is found WCHAR* path; bool optionsFound = false; do { if (!getFileInfo()) { return false; } path = wcsrchr(buffer, L'\\'); if (!path) { path = buffer; } else { if (m_PackageFormat == PackageFormat::New) { // New package files must be in root of archive continue; } ++path; // Skip slash } if (_wcsicmp(path, m_PackageFormat == PackageFormat::New ? L"RMSKIN.ini" : L"Rainstaller.cfg") == 0) { if (ExtractCurrentFile(tempFile)) { optionsFound = ReadOptions(tempFileSz); DeleteFile(tempFileSz); } break; } } while (unzGoToNextFile(m_PackageUnzFile) == UNZ_OK); if (!optionsFound) { return false; } // Loop through the archive a second time and find included components unzGoToFirstFile(m_PackageUnzFile); m_PackageRoot.assign(buffer, path - buffer); const WCHAR* root = m_PackageRoot.c_str(); do { if (!getFileInfo()) { return false; } if (wcsncmp(buffer, root, m_PackageRoot.length()) != 0) { // Ignore everything that isn't in the root directory continue; } WCHAR* component = buffer + m_PackageRoot.length(); path = wcschr(component, L'\\'); if (path) { *path = L'\0'; ++path; } else { if (_wcsicmp(component, m_PackageFormat == PackageFormat::New ? L"RMSKIN.bmp" : L"Rainstaller.bmp") == 0) { if (!ExtractCurrentFile(tempFile)) { return false; } m_HeaderBitmap = (HBITMAP)LoadImage(nullptr, tempFileSz, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); DeleteFile(tempFileSz); } continue; } const WCHAR* pos = wcschr(path, L'\\'); const WCHAR* extension = PathFindExtension(pos ? pos : path); if (pos) { // Component with subfolders const std::wstring item(path, pos - path); const WCHAR* itemSz = item.c_str(); if (_wcsicmp(component, L"Skins") == 0 && !IsIgnoredSkin(itemSz)) { m_PackageSkins.insert(item); } else if (_wcsicmp(component, m_PackageFormat == PackageFormat::New ? L"Layouts" : L"Themes") == 0 && _wcsicmp(extension, m_PackageFormat == PackageFormat::New ? L".ini" : L".thm") == 0 && !IsIgnoredLayout(itemSz)) { m_PackageLayouts.insert(item); } else if (_wcsicmp(component, L"Addons") == 0 && m_PackageFormat == PackageFormat::Old && !IsIgnoredAddon(itemSz)) { m_PackageAddons.insert(item); } else if (_wcsicmp(component, L"Plugins") == 0 && _wcsicmp(itemSz, IsWin32Build() ? L"32bit" : L"64bit") == 0 && _wcsicmp(extension, L".dll") == 0 && !wcschr(pos + 1, L'\\')) { const std::wstring plugin(pos + 1); if (!IsIgnoredPlugin(plugin.c_str())) { m_PackagePlugins.insert(plugin); } } } else { // Component with subfiles const std::wstring item = path; const WCHAR* itemSz = item.c_str(); if (_wcsicmp(component, L"Fonts") == 0 && m_PackageFormat == PackageFormat::Old && _wcsicmp(extension, L".ttf") == 0) { m_PackageFonts.insert(item); } } } while (unzGoToNextFile(m_PackageUnzFile) == UNZ_OK); if (m_PackageSkins.empty()) { // Fonts can be installed only with skins m_PackageFonts.clear(); } return !(m_PackageSkins.empty() && m_PackageLayouts.empty() && m_PackageAddons.empty() && m_PackageFonts.empty() && m_PackagePlugins.empty()); }
ParserBase::ParserBase() { m_TokenTree = new TokenTree; m_TempTokenTree = new TokenTree; ReadOptions(); }
/* Initialize VPR 1. Read Options 2. Read Arch 3. Read Circuit 4. Sanity check all three */ void vpr_init(INP int argc, INP char **argv, OUTP t_options *options, OUTP t_vpr_setup *vpr_setup, OUTP t_arch *arch) { char* pszLogFileName = "vpr_stdout.log"; unsigned char enableTimeStamps = 1; unsigned long maxWarningCount = 100000; unsigned long maxErrorCount = 1000; if (PrintHandlerExists() == 1) { has_printhandler_pre_vpr = TRUE; } else { has_printhandler_pre_vpr = FALSE; } if (has_printhandler_pre_vpr == FALSE) { PrintHandlerNew(pszLogFileName); PrintHandlerInit(enableTimeStamps, maxWarningCount, maxErrorCount); } /* Print title message */ vpr_print_title(); /* Print usage message if no args */ if (argc < 3) { vpr_print_usage(); exit(1); } memset(options, 0, sizeof(t_options)); memset(vpr_setup, 0, sizeof(t_vpr_setup)); memset(arch, 0, sizeof(t_arch)); /* Read in user options */ ReadOptions(argc, argv, options); /* Timing option priorities */ vpr_setup->TimingEnabled = IsTimingEnabled(options); /* Determine whether echo is on or off */ setEchoEnabled(IsEchoEnabled(options)); setDumpVtbEnabled(IsDumpVtbEnabled(options)); SetPostSynthesisOption(IsPostSynthesisEnabled(options)); vpr_setup->constant_net_delay = options->constant_net_delay; /* Read in arch and circuit */ SetupVPR(options, vpr_setup->TimingEnabled, TRUE, &vpr_setup->FileNameOpts, arch, &vpr_setup->Operation, &vpr_setup->user_models, &vpr_setup->library_models, &vpr_setup->PackerOpts, &vpr_setup->PlacerOpts, &vpr_setup->AnnealSched, &vpr_setup->RouterOpts, &vpr_setup->RoutingArch, &vpr_setup->Segments, &vpr_setup->Timing, &vpr_setup->ShowGraphics, &vpr_setup->GraphPause, &vpr_setup->PowerOpts); /* Check inputs are reasonable */ CheckOptions(*options, vpr_setup->TimingEnabled); CheckArch(*arch, vpr_setup->TimingEnabled); /* Verify settings don't conflict or otherwise not make sense */ CheckSetup(vpr_setup->Operation, vpr_setup->PlacerOpts, vpr_setup->AnnealSched, vpr_setup->RouterOpts, vpr_setup->RoutingArch, vpr_setup->Segments, vpr_setup->Timing, arch->Chans); /* flush any messages to user still in stdout that hasn't gotten displayed */ fflush(stdout); /* Read blif file and sweep unused components */ read_and_process_blif(vpr_setup->PackerOpts.blif_file_name, vpr_setup->PackerOpts.sweep_hanging_nets_and_inputs, vpr_setup->user_models, vpr_setup->library_models, vpr_setup->PowerOpts.do_power, vpr_setup->FileNameOpts.ActFile); fflush(stdout); ShowSetup(*options, *vpr_setup); }
// 设置当前账号 void SetCurrentUser(LPCTSTR userName) { // 保存当前账号配置 if (g_currentUser != _T("")) SaveCurrentUserProfile(); // 设置配置路径 g_currentUser = userName; CURRENT_USER_PATH = USERS_PATH + userName; USER_PROFILE_PATH = CURRENT_USER_PATH + _T("\\options.tb"); COOKIE_PATH = CURRENT_USER_PATH + _T("\\ck.tb"); CACHE_PATH = CURRENT_USER_PATH + _T("\\cache.tb"); // 读取设置 TCHAR buffer[260]; // 方案 GetPrivateProfileString(_T("Setting"), _T("Option"), _T("默认"), g_currentOption.GetBuffer(MAX_PATH), MAX_PATH, USER_PROFILE_PATH); g_currentOption.ReleaseBuffer(); ReadOptions(OPTIONS_PATH + g_currentOption + _T(".tb")); // 贴吧名 GetPrivateProfileString(_T("Setting"), _T("ForumName"), _T(""), buffer, _countof(buffer), USER_PROFILE_PATH); ((CTiebaManagerDlg*)AfxGetApp()->m_pMainWnd)->m_forumNameEdit.SetWindowText(buffer); // Cookie gzFile f = gzopen_w(COOKIE_PATH, "rb"); if (f != NULL) { ReadText(f, g_cookie); gzclose(f); } // 历史回复、忽略ID等 f = gzopen_w(CACHE_PATH, "rb"); if (f != NULL) { int size; // 历史回复 if (gzread(f, &size, sizeof(int)) == sizeof(int) && 0 < size && size < 100000) // 长度 { __int64 tid; int reply; for (int i = 0; i < size; i++) { gzread(f, &tid, sizeof(__int64)); gzread(f, &reply, sizeof(int)); g_reply[tid] = reply; } } // 忽略ID ReadIDSet(f, g_initIgnoredTID); g_ignoredTID = g_initIgnoredTID; ReadIDSet(f, g_initIgnoredPID); g_ignoredPID = g_initIgnoredPID; ReadIDSet(f, g_initIgnoredLZLID); g_ignoredLZLID = g_initIgnoredLZLID; // 违规次数 if (gzread(f, &size, sizeof(int)) == sizeof(int) && 0 < size && size < 100000) // 长度 { CString userName; int count; for (int i = 0; i < size; i++) { ReadText(f, userName); gzread(f, &count, sizeof(int)); g_userTrigCount[userName] = count; } } // 拉黑用户 ReadTextSet(f, g_defriendedUser); gzclose(f); } }
/* Main program. */ void main(int argc, const char* argv[]) { FILE* sdfile = NULL; FILE* outfile = NULL; char* buffer = NULL; long index=0, nerr=0, nboom_rtrip=0, nmismatch_rtrip=0; IXA_BOOL key; IXA_BOOL generate_auxinfo = IXA_TRUE; IXA_BOOL verbose = IXA_FALSE; const char* inchi; const char* auxinfo; const char* inchikey; IXA_BOOL round_trip; char options[256]; char* saved_inchi = NULL; IXA_STATUS_HANDLE status = NULL; IXA_MOL_HANDLE molecule = NULL; IXA_INCHIBUILDER_HANDLE inchi_builder = NULL; IXA_INCHIKEYBUILDER_HANDLE key_builder = NULL; #if defined(_WIN32) const char *platform="Windows"; #else const char *platform="Linux"; #endif char banner[255]; sprintf( banner, "%s\n%-s Build of %-s %-s%s", APP_DESCRIPTION, platform, __DATE__, __TIME__, RELEASE_IS_FINAL?"":" *** pre-release, for evaluation only ***"); fprintf( stderr, "%-s\n", banner); #ifdef IXA_USES_NON_EX_CORE_API fprintf( stderr, "Note: IXA API in current build uses non-extended core API calls\n"); #else fprintf( stderr, "Note: IXA API in current build uses extended core API calls\n"); #endif if (argc < 3) { /* Not enough command line arguments have been provided. Output some help information, then exit. */ print_help(); return; } /* Open input and output files. */ sdfile = fopen(argv[1],"rb"); /* fopen_s(&sdfile, argv[1], "r"); */ if (!sdfile) { fprintf(stderr, "Failed to open \"%s\" for reading\n", argv[1]); goto cleanup; } outfile = fopen( argv[2], "w"); /* fopen_s(&outfile, argv[2], "w"); */ if (!outfile) { fprintf(stderr, "Failed to open \"%s\" for writing\n", argv[2]); goto cleanup; } /* Create status, molecule and InChI builder objects. */ status = IXA_STATUS_Create(); molecule = IXA_MOL_Create(status); if (!CheckStatus(status, index)) goto cleanup; inchi_builder = IXA_INCHIBUILDER_Create(status); if (!CheckStatus(status, index)) goto cleanup; /* Read any command line options that may have been given and set up the InChI builder accordingly. */ if (!ReadOptions(argc, argv, &key, &round_trip, &generate_auxinfo, &verbose, options, status, inchi_builder)) goto cleanup; /* If InChI keys have been requested, create an InChI key builder object. */ if (key) { key_builder = IXA_INCHIKEYBUILDER_Create(status); if (!CheckStatus(status, index)) goto cleanup; } /* Warning: in this demo, we just assume that molfile's size does not */ /* exceed some (large) MOLBUFSIZE; no further checks are performed. */ buffer = (char *) calloc( MOLBUFSIZE, sizeof(char) ); if ( !buffer ) { fprintf(stderr, "Out of memory\n"); goto cleanup; } /* Iterate the molecules in the input SD file and create an InChI for each one. */ index = 0; while ( get_next_molfile_as_text( sdfile, buffer, MOLBUFSIZE ) > 0 && !is_empty_text( buffer ) ) { /* Set up the molecule object with atoms and bonds to represent the data that has just been read from the input file. */ IXA_MOL_ReadMolfile(status, molecule, buffer); if (!CheckStatus(status,index+1)) { nerr++; goto endloop; } fprintf(outfile, "%-ld\t", index+1); /* Bind the molecule object to the InChI builder object. */ IXA_INCHIBUILDER_SetMolecule(status, inchi_builder, molecule); if (!CheckStatus(status,index+1)) { nerr++; goto endloop; } /* Retrieve the molecule's InChI and write it to the output file. */ inchi = IXA_INCHIBUILDER_GetInChI(status, inchi_builder); if (!CheckStatus(status,index+1)) { nerr++; goto endloop; } fprintf(outfile, "%s\t", inchi); if (generate_auxinfo) { /* AuxInfo has been requested. Retrieve the molecule's AuxInfo and write it to the output file. */ auxinfo = IXA_INCHIBUILDER_GetAuxInfo(status, inchi_builder); if (!CheckStatus(status,index+1)) { nerr++; goto endloop; } fprintf(outfile, "%s\t", auxinfo); } if (key_builder) { /* InChI keys have been requested. Retrieve the molecule's InChI key and write it to the output file. */ IXA_INCHIKEYBUILDER_SetInChI(status, key_builder, inchi); if (!CheckStatus(status,index+1)) { nerr++; goto endloop; } inchikey = IXA_INCHIKEYBUILDER_GetInChIKey(status, key_builder); if (!CheckStatus(status,index+1)) { nerr++; goto endloop; } fprintf(outfile, "InChIKey=%s\t", inchikey); } if (round_trip) { /* Round trip tests have been requested. Turn the InChI that has just been generated into a molecule and use that molecule as the basis for a new InChI. The two InChIs should be identical. */ saved_inchi = (char *) realloc(saved_inchi, strlen(inchi) + 1); strcpy(saved_inchi, inchi); IXA_MOL_ReadInChI(status, molecule, saved_inchi); if (!CheckStatus(status,index+1)) { fprintf(stderr, "\n!!! Round trip failed: could not read InChI : structure %-ld\n", index+1); { nboom_rtrip++; goto endloop; } } IXA_INCHIBUILDER_SetMolecule(status, inchi_builder, molecule); if (!CheckStatus(status,index+1)) { fprintf(stderr, "\n!!! Round trip failed: could not set IXA mol from read InChI string : structure %-ld\n", index+1); { nboom_rtrip++; goto endloop; } } /* strcpy(inchi,"NOTHING"); */ inchi = IXA_INCHIBUILDER_GetInChI(status, inchi_builder); if (!CheckStatus(status,index+1)) { fprintf(stderr, "\n!!! Round trip failed: could not generate InChI from IXA mol obtained from read InChI : structure %-ld\n", index+1); { nboom_rtrip++; goto endloop; } } if (strcmp(inchi, saved_inchi) != 0) { fprintf(stderr, "\n!!! Round trip failed : structure %-ld\n", index+1); fprintf(stderr, " OLD: %s\n", saved_inchi); fprintf(stderr, " NEW: %s", inchi); nmismatch_rtrip++; } else if ( verbose ) { fprintf(stderr, "\nRound trip OK : structure %-ld\n", index+1); fprintf(stderr, " OLD: %s\n", saved_inchi); fprintf(stderr, " NEW: %s", inchi); } } endloop: /* Every so often write a dot to stdout so the user knows that this program has not frozen. */ fprintf( outfile, "\n" ); if (index % 100 == 0) { fprintf(stderr, "."); } index++; fflush(NULL); } /* Main loop */ fprintf(stderr, "\n"); cleanup: fprintf(stderr, "\nFinished processing %-ld molecules.\nGeneration (struct->InChI) errors: %-ld", index, nerr); if (round_trip) { fprintf( stderr, "\nRound trip (struct->InChI->struct->InChI) problems: %-ld (%-ld failures, %-ld mismatches)", nboom_rtrip + nmismatch_rtrip, nboom_rtrip, nmismatch_rtrip); } fprintf(stderr, ".\n"); /* Release resources prior to program exit. */ if ( saved_inchi ) free(saved_inchi); if ( buffer ) free(buffer); if (sdfile) fclose(sdfile); if (outfile) fclose(outfile); IXA_INCHIKEYBUILDER_Destroy(NULL, key_builder); IXA_INCHIBUILDER_Destroy(NULL, inchi_builder); IXA_MOL_Destroy(NULL, molecule); IXA_STATUS_Destroy(status); }
void game_sv_GameState::Create (shared_str &options) { string_path fn_game; m_item_respawner.clear_respawns(); if (FS.exist(fn_game, "$level$", "level.game")) { IReader *F = FS.r_open (fn_game); IReader *O = 0; // Load RPoints if (0!=(O = F->open_chunk (RPOINT_CHUNK))) { for (int id=0; O->find_chunk(id); ++id) { RPoint R; u8 team; u8 type; u16 GameType; shared_str rp_profile; O->r_fvector3 (R.P); O->r_fvector3 (R.A); team = O->r_u8 (); type = O->r_u8 (); GameType = O->r_u16 (); if(type==rptItemSpawn) O->r_stringZ (rp_profile); if (GameType != EGameIDs(u16(-1))) { if ((Type() == eGameIDCaptureTheArtefact) && (GameType & eGameIDCaptureTheArtefact)) { team = team - 1; R_ASSERT2( ((team >= 0) && (team < 4)) || (type != rptActorSpawn), "Problem with CTA Team indexes. Propably you have added rpoint of team 0 for cta game type."); } if ((!(GameType & eGameIDDeathmatch) && (Type() == eGameIDDeathmatch)) || (!(GameType & eGameIDTeamDeathmatch) && (Type() == eGameIDTeamDeathmatch)) || (!(GameType & eGameIDArtefactHunt) && (Type() == eGameIDArtefactHunt)) || (!(GameType & eGameIDCaptureTheArtefact) && (Type() == eGameIDCaptureTheArtefact)) ) { continue; }; }; switch (type) { case rptActorSpawn: { rpoints[team].push_back (R); for (int i=0; i<int(rpoints[team].size())-1; i++) { RPoint rp = rpoints[team][i]; float dist = R.P.distance_to_xz(rp.P)/2; if (dist<rpoints_MinDist[team]) rpoints_MinDist[team] = dist; dist = R.P.distance_to(rp.P)/2; if (dist<rpoints_Dist[team]) rpoints_Dist[team] = dist; }; }break; case rptItemSpawn: { m_item_respawner.add_new_rpoint(rp_profile, R); } }; }; O->close(); } FS.r_close (F); } if (!g_dedicated_server) { // loading scripts ai().script_engine().remove_script_process(ScriptEngine::eScriptProcessorGame); string_path S; FS.update_path (S,"$game_config$","script.ltx"); CInifile *l_tpIniFile = xr_new<CInifile>(S); R_ASSERT (l_tpIniFile); if( l_tpIniFile->section_exist( type_name() ) ) if (l_tpIniFile->r_string(type_name(),"script")) ai().script_engine().add_script_process(ScriptEngine::eScriptProcessorGame,xr_new<CScriptProcess>("game",l_tpIniFile->r_string(type_name(),"script"))); else ai().script_engine().add_script_process(ScriptEngine::eScriptProcessorGame,xr_new<CScriptProcess>("game","")); xr_delete (l_tpIniFile); } //--------------------------------------------------------------------- ConsoleCommands_Create(); //--------------------------------------------------------------------- // CCC_LoadCFG_custom* pTmp = xr_new<CCC_LoadCFG_custom>("sv_"); // pTmp->Execute (Console->ConfigFile); // xr_delete (pTmp); //--------------------------------------------------------------------- LPCSTR svcfg_ltx_name = "-svcfg "; if (strstr(Core.Params, svcfg_ltx_name)) { string_path svcfg_name = ""; int sz = xr_strlen(svcfg_ltx_name); sscanf (strstr(Core.Params,svcfg_ltx_name)+sz,"%[^ ] ",svcfg_name); // if (FS.exist(svcfg_name)) { Console->ExecuteScript(svcfg_name); } }; //--------------------------------------------------------------------- ReadOptions(options); }
Status DB::getSessionUserCount(int& userCount) { return getSessionUserCount(userCount, ReadOptions()); }
/* Read in user options */ void vpr_read_options(INP int argc, INP char **argv, OUTP t_options * options) { ReadOptions(argc, argv, options); }
Status DB::getSongs(ResultSet<Song>& rs) { return getSongs(rs, ReadOptions()); }
BOOL PluginOILFilter::BuildCapabilityTree(wxString strXmlFilename, CapabilityTree* pCapTree) { // First we need to load the XML into an XML DOM object // Set Parser flags here? // hRes = pDoc->setProperty(CComBSTR(_T("SelectionLanguage")), CComVariant(_T("XPath"))); // hRes = pDoc->put_async(VARIANT_FALSE); // hRes = pDoc->put_preserveWhiteSpace(VARIANT_TRUE); // hRes = pDoc->put_validateOnParse(VARIANT_FALSE); // hRes = pDoc->put_resolveExternals(VARIANT_FALSE); BOOL bOK = TRUE; xmlDocPtr doc; // If string param contains xml (like original Windows version) // wxCharBuffer buf = strXML.mb_str(wxConvUTF8); // doc = xmlParseDoc((const xmlChar*)buf.data()); // buf will be deallocated when it goes out of scope // If string param gives xml filename (like new LX version) wxCharBuffer buf = strXmlFilename.ToAscii(); doc = xmlParseFile(buf.data()); // buf will be deallocated when it goes out of scope #if _DEBUG if (doc==NULL) doc = xmlParseFile("/tmp/XaraLX/capstest.xml"); #endif ERROR1IF(doc==NULL, FALSE, _R(IDE_XPF_BADXML)); // The name of the root element should be XPFilterConfig xmlNodePtr node = xmlDocGetRootElement(doc); wxString strName = CXMLUtils::ConvertToWXString(node->name); if (strName!=_T("XPFilterConfig")) ERROR1(FALSE, _R(IDE_XPF_BADXML)); xmlNodePtr pChild = node->children; INT32 Phase =0; // There are 7 phases to the parsing // We will loop round until we run out of child elements // After parsing a node the phase counter will be set to the phase just parsed // If an element should have already been parsed (using the phase counter) // then an error will be indicated while (pChild && bOK) { wxString strChildName = CXMLUtils::ConvertToWXString(pChild->name); if (strChildName == _T("#text") || xmlNodeIsText(pChild)) { // ignore it } else if (strChildName == _T("Private")) { if (Phase > 0) { ERROR1(FALSE, _R(IDE_XPF_BADXML_PHASE0)); } // Ignore the entire element Phase = 1; } else if (strChildName == _T("Options")) { if (Phase > 1) { ERROR1(FALSE, _R(IDE_XPF_BADXML_PHASE1)); } bOK = ReadOptions(pChild, pCapTree); // Read the options attributes Phase = 2; } else if (strChildName == _T("Rasterise")) { if (Phase > 2) { ERROR1(FALSE, _R(IDE_XPF_BADXML_PHASE2)); } bOK = ReadRasterise(pChild, pCapTree); // Read the dpi and alpha attributes Phase = 3; } else if (strChildName == _T("Spread")) { if (Phase > 3) { ERROR1(FALSE, _R(IDE_XPF_BADXML_PHASE3)); } bOK = ReadSpread(pChild, pCapTree); // Read the as attribute Phase = 4; } else if (strChildName == _T("Objects")) { if (Phase > 4) { ERROR1(FALSE, _R(IDE_XPF_BADXML_PHASE4)); } bOK = ReadObjects(pChild, pCapTree); // Build the tree of XPFCapability derived objects Phase = 5; } else if (strChildName == _T("Attributes")) { if (Phase > 5) { ERROR1(FALSE, _R(IDE_XPF_BADXML_PHASE5)); } bOK = ReadAttributes(pChild, pCapTree); // Build the tree of XPFCapability derived objects Phase = 6; } else if (strChildName == _T("Colour")) { if (Phase > 6) { ERROR1(FALSE, _R(IDE_XPF_BADXML_PHASE6)); } bOK = ReadColour(pChild, pCapTree); // Build the tree of XPFColour objects Phase = 7; } else { ERROR1(FALSE, _R(IDE_XPF_BADXML_UNEXPECTED_PHASE)); } pChild = pChild->next; } xmlFreeDoc(doc); return bOK; }
Status DB::getArtists(ResultSet<Artist>& rs) { return getArtists(rs, ReadOptions()); }
bool Measure::Update(bool rereadOptions) { if (rereadOptions) { ReadOptions(m_Skin->GetParser()); } // Don't do anything if paused if (m_Paused) return false; if (!m_Disabled) { // Only update the counter if the divider if (!UpdateCounter()) return false; // Call derived method to update value UpdateValue(); if (m_AverageSize > 0) { size_t averageValuesSize = m_AverageValues.size(); if (m_AverageSize != averageValuesSize) { m_AverageValues.resize(m_AverageSize, m_Value); averageValuesSize = m_AverageValues.size(); if (m_AveragePos >= averageValuesSize) m_AveragePos = 0; } m_AverageValues[m_AveragePos] = m_Value; ++m_AveragePos; m_AveragePos %= averageValuesSize; // Calculate the average value double value = 0; for (size_t i = 0; i < averageValuesSize; ++i) { value += m_AverageValues[i]; } m_Value = value / (double)averageValuesSize; } // If we're logging the maximum value of the measure, check if // the new value is greater than the old one, and update if necessary. if (m_LogMaxValue) { if (m_MedianValues.empty()) { m_MedianValues.resize(MEDIAN_SIZE, 0); } m_MedianValues[m_MedianPos] = m_Value; ++m_MedianPos; m_MedianPos %= MEDIAN_SIZE; auto medianArray = m_MedianValues; std::sort(&medianArray.data()[0], &medianArray.data()[MEDIAN_SIZE]); // Workaround for "Debug" build mode double medianValue = medianArray[MEDIAN_SIZE / 2]; m_MaxValue = max(m_MaxValue, medianValue); m_MinValue = min(m_MinValue, medianValue); } m_ValueAssigned = true; // For the conditional options to work with the current measure value when using // [MeasureName], we need to read the options after m_Value has been changed. if (rereadOptions) { m_IfActions.ReadConditionOptions(m_Skin->GetParser(), GetName()); } if (m_Skin) { m_IfActions.DoIfActions(*this, m_Value); } return true; } else { // Disabled measures have 0 as value m_Value = 0.0; m_IfActions.SetState(m_Value); return false; } }
Status DB::getGenres(ResultSet<Genre>& rs) { return getGenres(rs, ReadOptions()); }