//--------------------------------------------------------------------------- bool TSharpnessForm1::Load_SP(String Fpath) { char* buffer = Load_File(Fpath); char* pch; pch = strtok (buffer,"\n\t"); int c= 0; AnsiString str[5]; str[0] = "TEXT_DET"; str[1] = "HORZ_THR"; str[2] = "VERT_THR"; str[3] = "EDGE_THR"; str[4] = "GLT_STR"; //hardwre gain while (c < 38 && pch!=NULL){ if(pch == NULL){ ShowMessage("Data Missing."); delete [] buffer; return 0; //資料中的data缺少 } if(c==0){ //TD for(int i = 0; i < OSP->SPChkBox_Nbr; i++){ if(SameText(ChkB[i]->Addr.Name(),str[0])){ ChkB[i]->Chkb->Checked = (StrToInt((AnsiString)pch)>0?1:0); ChkB[i]->Chkb->OnClick; break; } } }else if(c>=1 && c<=3){ //HORZ_THR, VERT_THR, EDGE_THR for(int i = 0; i < OSP->SPScrollBar_Nbr; i++){ if(SameText(ScrlB[i]->Addr.Name(),str[c])){ ScrlB[i]->ScrlB->Position = (StrToInt((AnsiString)pch)); ScrlB[i]->ScrlB->OnChange; break; } } }else if(c==4){ //hardware gain for(int i = 0; i < OSP->SPScrollBar_Nbr; i++){ if(SameText(ScrlB[i]->Addr.Name(),str[c])){ float tmp = (StrToFloat((AnsiString)pch)); ScrlB[i]->ScrlB->Position = int(tmp*4); ScrlB[i]->ScrlB->OnChange; break; } } }else if(c==5){ //swg sb_softgain->Position = StrToFloat((AnsiString)pch)*10; }else{ //tbl SP_lut[c-6] = StrToInt((AnsiString)pch); } pch = strtok (NULL,"\n\t"); c++; if(c>=38) break; } delete [] buffer; return 1; }
//--------------------------------------------------------------------------- void __fastcall TFMain_11011981::miEditFunctionIClick(TObject *Sender) { int refCnt; DWORD adr; char tkName[32]; if (lbUnitItems->ItemIndex < 0) return; String item = lbUnitItems->Items->Strings[lbUnitItems->ItemIndex]; //Xrefs? if (item[11] == '<' || item[11] == '?') sscanf(item.c_str() + 1, "%lX%s", &adr, tkName); else sscanf(item.c_str() + 1, "%lX%d%s", &adr, &refCnt, tkName); String name = String(tkName); if (SameText(name, "<?>") || //SameText(name, "<Imp?>") || //SameText(name, "<Emb?>") || SameText(name, "<Constructor>") || SameText(name, "<Destructor>") || SameText(name, "<Func>") || //SameText(name, "<EmbFunc>") || SameText(name, "<Proc>") //|| //SameText(name, "<EmbProc>") || //SameText(name, "<ImpFunc>") || //SameText(name, "<ImpProc>") ) { EditFunction(adr); } }
//--------------------------------------------------------------------------- void __fastcall TfrmCompactLayout::pgfPaymentTypeGetGroupImageIndex( TcxPivotGridField *Sender, const TcxPivotGridViewDataItem *AItem, int &AImageIndex, TAlignment &AImageAlignHorz, TcxAlignmentVert &AImageAlignVert) { AnsiString Card = ((TcxPivotGridViewDataItem *)AItem)->Value; if (SameText(Card, "Cash")) AImageIndex = 0; else if (SameText(Card, "AmEx")) AImageIndex = 1; else if (SameText(Card, "Master")) AImageIndex = 2; else if (SameText(Card, "Visa")) AImageIndex = 3; }
//--------------------------------------------------------------------------- void __fastcall THTMLFrame::htmlMeta(TObject *Sender, const AnsiString HttpEq, const AnsiString Name, const AnsiString Content) { if(SameText(Name,"width")) { Width = StrToInt(Content); } else if(SameText(Name,"height")) { Height = StrToInt(Content); } }
void __fastcall TSharpnessForm1::btn_sp_SaveClick(TObject *Sender) { if(!SaveDialog1->Execute()) return; String Fpath = SaveDialog1->FileName; FILE* fptr = fopen (Fpath.c_str(),"w"); AnsiString str[5]; str[0] = "TEXT_DET"; str[1] = "HORZ_THR"; str[2] = "VERT_THR"; str[3] = "EDGE_THR"; str[4] = "GLT_STR"; //hardwre gain AnsiString input_str[5]; for(int i = 0; i <= 3; i++) input_str[i] = "0"; input_str[4] = "1"; for(int i = 0; i < OSP->SPChkBox_Nbr; i++){ if(SameText(ChkB[i]->Addr.Name(),str[0])){ input_str[0] = (ChkB[i]->Chkb->Checked?"1":"0"); break; } } for(int j = 0; j <= 3; j++) for(int i = 0; i < OSP->SPScrollBar_Nbr; i++){ if(SameText(ScrlB[i]->Addr.Name(),str[j])){ input_str[j] = ScrlB[i]->ScrlB->Position; break; } } for(int i = 0; i < OSP->SPScrollBar_Nbr; i++){ if(SameText(ScrlB[i]->Addr.Name(),str[4])){ float val = (float)ScrlB[i]->ScrlB->Position*4; input_str[4] = FloatToStr(val); break; } } float input_str5 = StrToFloat(sb_softgain->Position)/10; fprintf(fptr,"%s\t%s\t%s\t%s\t%s\t%f\n",input_str[0],input_str[1],input_str[2], input_str[3],input_str[4],input_str5); for(int i = 0; i < 32; i++){ fprintf(fptr,"%d\n", SP_lut[i]); } fclose(fptr); }
//--------------------------------------------------------------------------- void __fastcall OpenBrowser(UnicodeString URL) { UnicodeString HomePageUrl = LoadStr(HOMEPAGE_URL); if (SameText(URL.SubString(1, HomePageUrl.Length()), HomePageUrl)) { URL = CampaignUrl(URL); } ShellExecute(Application->Handle, L"open", URL.c_str(), NULL, NULL, SW_SHOWNORMAL); }
void __fastcall THTMLFrame::HtmlHotSpotClick(TObject *Sender, const AnsiString SRC, bool &Handled) { TSysCharSet Delims; Delims << ':'; String Proto = ExtractWord(1,SRC,Delims); Handled=false; if(SameText(Proto,"dcm")) { String Script = SRC.c_str()+4; Evalate(Script); Handled = true; } else if(SameText(Proto,"http") || SameText(Proto,"mailto")) { ShellExecuteA(Handle, NULL, SRC.c_str(), NULL, NULL, SW_SHOWNORMAL); Handled = true; } }
//--------------------------------------------------------------------- void TConfiguration::TemporaryLogging(const UnicodeString & ALogFileName) { if (SameText(ExtractFileExt(ALogFileName), L".xml")) { TemporaryActionsLogging(ALogFileName); } else { FLogging = true; FLogFileName = ALogFileName; UpdateActualLogProtocol(); } }
//--------------------------------------------------------------------------- void __fastcall TForm2::CppWebBrowser2DocumentComplete(TObject *Sender, LPDISPATCH pDisp, Variant *URL) { Variant vObj = CppWebBrowser2->OleObject; Variant vBody; String strDocCompatMode = vObj.OlePropertyGet("document").OlePropertyGet("compatMode"); if (SameText(strDocCompatMode, "CSS1Compat")) vBody = vObj.OlePropertyGet("Document").OlePropertyGet("documentElement"); else vBody = vObj.OlePropertyGet("Document").OlePropertyGet("body"); vBody.OlePropertyGet("style").OlePropertySet("overflow", "hidden"); }
UnicodeString TConfiguration::GetProductVersionStr() const { UnicodeString Result; #ifndef __linux__ TGuard Guard(FCriticalSection); try { TVSFixedFileInfo * Info = GetFixedApplicationInfo(); /*return FMTLOAD(VERSION, HIWORD(Info->dwFileVersionMS), LOWORD(Info->dwFileVersionMS), HIWORD(Info->dwFileVersionLS), LOWORD(Info->dwFileVersionLS));*/ UnicodeString BuildStr; if (!GetIsUnofficial()) { BuildStr = LoadStr(VERSION_BUILD); } else { #ifdef _DEBUG BuildStr = LoadStr(VERSION_DEBUG_BUILD); #else BuildStr = LoadStr(VERSION_DEV_BUILD); #endif } int Build = LOWORD(Info->dwFileVersionLS); if (Build > 0) { BuildStr += L" " + ::IntToStr(Build); } #if 0 #ifndef BUILD_OFFICIAL UnicodeString BuildDate = __DATE__; UnicodeString MonthStr = CutToChar(BuildDate, L' ', true); int Month = ParseShortEngMonthName(MonthStr); int Day = StrToInt64(CutToChar(BuildDate, L' ', true)); int Year = StrToInt64(Trim(BuildDate)); UnicodeString DateStr = FORMAT("%d-%2.2d-%2.2d", Year, Month, Day); AddToList(BuildStr, DateStr, L" "); #endif #endif UnicodeString FullVersion = GetProductVersion(); UnicodeString AReleaseType = GetReleaseType(); if (DebugAlwaysTrue(!AReleaseType.IsEmpty()) && !SameText(AReleaseType, L"stable") && !SameText(AReleaseType, L"development")) { FullVersion += L" " + AReleaseType; } Result = FMTLOAD(VERSION2, GetProductVersion().c_str(), Build); #if 0 #ifndef BUILD_OFFICIAL Result += L" " + LoadStr(VERSION_DONT_DISTRIBUTE); #endif #endif } catch (Exception & E) { throw ExtException(&E, "Can't get application version"); } #endif return Result; }
//--------------------------------------------------------------------------- void __fastcall TFMain_11011981::lbUnitItemsDblClick(TObject *Sender) { int idx = -1, len, size, refCnt; WORD* uses; DWORD adr; char *tmpBuf; PInfoRec recN; MTypeInfo tInfo; String str; char tkName[32], typeName[1024]; if (lbUnitItems->ItemIndex == -1) return; String item = lbUnitItems->Items->Strings[lbUnitItems->ItemIndex]; //Xrefs? if (item[11] == '<' || item[11] == '?') sscanf(item.c_str() + 1, "%lX%s%s", &adr, tkName, typeName); else sscanf(item.c_str() + 1, "%lX%d%s%s", &adr, &refCnt, tkName, typeName); String name = String(tkName); if (SameText(name, "????")) { //Find end of unexplored Data int bytes = 1024, pos = Adr2Pos(adr); //Get first byte (use later for filtering code?data) BYTE db = *(Code + pos); FExplorer_11011981->tsCode->TabVisible = true; FExplorer_11011981->ShowCode(adr, bytes); FExplorer_11011981->tsData->TabVisible = true; FExplorer_11011981->ShowData(adr, bytes); FExplorer_11011981->tsString->TabVisible = true; FExplorer_11011981->ShowString(adr, 1024); FExplorer_11011981->tsText->TabVisible = false; FExplorer_11011981->WAlign = 0; FExplorer_11011981->btnDefCode->Enabled = true; if (IsFlagSet(cfCode, pos)) FExplorer_11011981->btnDefCode->Enabled = false; FExplorer_11011981->btnUndefCode->Enabled = false; if (IsFlagSet(cfCode | cfData, pos)) FExplorer_11011981->btnUndefCode->Enabled = true; if (IsValidCode(adr) != -1 && db >= 0xF) FExplorer_11011981->pc1->ActivePage = FExplorer_11011981->tsCode; else FExplorer_11011981->pc1->ActivePage = FExplorer_11011981->tsData; if (FExplorer_11011981->ShowModal() == mrOk) { switch (FExplorer_11011981->DefineAs) { case DEFINE_AS_CODE: recN = GetInfoRec(adr); if (!recN) recN = new InfoRec(pos, ikRefine); else if (recN->kind < ikRefine || recN->kind > ikFunc) { delete recN; recN = new InfoRec(pos, ikRefine); } //AnalyzeProcInitial(adr); AnalyzeProc1(adr, 0, 0, 0, false); AnalyzeProc2(adr, true, true); AnalyzeArguments(adr); AnalyzeProc2(adr, true, true); if (!ContainsUnexplored(GetUnit(adr))) ShowUnits(true); ShowUnitItems(GetUnit(adr), lbUnitItems->TopIndex, lbUnitItems->ItemIndex); ShowCode(adr, 0, -1, -1); break; case DEFINE_AS_STRING: break; } } return; } if (SameText(name, "<VMT>") && tsClassView->TabVisible) { ShowClassViewer(adr); return; } if (SameText(name, "<ResString>")) { FStringInfo_11011981->memStringInfo->Clear(); FStringInfo_11011981->Caption = "ResString"; recN = GetInfoRec(adr); FStringInfo_11011981->memStringInfo->Lines->Add(recN->rsInfo->value); FStringInfo_11011981->ShowModal(); return; } if (SameText(name, "<ShortString>") || SameText(name, "<AnsiString>") || SameText(name, "<WideString>") || SameText(name, "<PAnsiChar>") || SameText(name, "<PWideChar>")) { FStringInfo_11011981->memStringInfo->Clear(); FStringInfo_11011981->Caption = "String"; recN = GetInfoRec(adr); FStringInfo_11011981->memStringInfo->Lines->Add(recN->GetName()); FStringInfo_11011981->ShowModal(); return; } if (SameText(name, "<UString>")) { FStringInfo_11011981->memStringInfo->Clear(); FStringInfo_11011981->Caption = "String"; recN = GetInfoRec(adr); len = wcslen((wchar_t*)(Code + Adr2Pos(adr))); size = WideCharToMultiByte(CP_ACP, 0, (wchar_t*)(Code + Adr2Pos(adr)), len, 0, 0, 0, 0); if (size) { tmpBuf = new char[size + 1]; WideCharToMultiByte(CP_ACP, 0, (wchar_t*)(Code + Adr2Pos(adr)), len, tmpBuf, len, 0, 0); FStringInfo_11011981->memStringInfo->Lines->Add(String(tmpBuf, len)); delete[] tmpBuf; FStringInfo_11011981->ShowModal(); } return; } if (SameText(name, "<Integer>") || SameText(name, "<Char>") || SameText(name, "<Enumeration>") || SameText(name, "<Float>") || SameText(name, "<Set>") || SameText(name, "<Class>") || SameText(name, "<Method>") || SameText(name, "<WChar>") || SameText(name, "<Array>") || SameText(name, "<Record>") || SameText(name, "<Interface>") || SameText(name, "<Int64>") || SameText(name, "<DynArray>") || SameText(name, "<ClassRef>") || SameText(name, "<Pointer>") || SameText(name, "<Procedure>")) { uses = KnowledgeBase.GetTypeUses(typeName); idx = KnowledgeBase.GetTypeIdxByModuleIds(uses, typeName); if (uses) delete[] uses; if (idx != -1) { idx = KnowledgeBase.TypeOffsets[idx].NamId; if (KnowledgeBase.GetTypeInfo(idx, INFO_FIELDS | INFO_PROPS | INFO_METHODS, &tInfo)) { FTypeInfo_11011981->ShowKbInfo(&tInfo); //as delete tInfo; } } else { FTypeInfo_11011981->ShowRTTI(adr); } return; } if (SameText(name, "<Proc>") || SameText(name, "<Func>") || SameText(name, "<Constructor>") || SameText(name, "<Destructor>") || SameText(name, "<EmbProc>") || SameText(name, "<EmbFunc>") || SameText(name, "<Emb?>") || SameText(name, "<ImpProc>") || SameText(name, "<ExpProc>") || SameText(name, "<ImpFunc>") || SameText(name, "<ExpFunc>") || SameText(name, "<Imp?>") || SameText(name, "<Exp?>") || SameText(name, "<?>")) { PROCHISTORYREC rec; rec.adr = CurProcAdr; rec.itemIdx = lbCode->ItemIndex; rec.xrefIdx = lbCXrefs->ItemIndex; rec.topIdx = lbCode->TopIndex; ShowCode(adr, 0, -1, -1); CodeHistoryPush(&rec); pcWorkArea->ActivePage = tsCodeView; } }
//--------------------------------------------------------------------------- TStrings * __fastcall TGUIConfiguration::GetLocales() { UnicodeString LocalesExts; TStringList * Exts = new TStringList(); try { Exts->Sorted = true; Exts->CaseSensitive = false; int FindAttrs = faReadOnly | faArchive; TSearchRec SearchRec; bool Found; Found = (bool)(FindFirst(ChangeFileExt(ModuleFileName(), L".*"), FindAttrs, SearchRec) == 0); try { UnicodeString Ext; while (Found) { Ext = ExtractFileExt(SearchRec.Name).UpperCase(); if ((Ext.Length() >= 3) && (Ext != L".EXE") && (Ext != L".COM") && (Ext != L".DLL") && (Ext != L".INI")) { Ext = Ext.SubString(2, Ext.Length() - 1); LocalesExts += Ext; Exts->Add(Ext); } Found = (FindNextChecked(SearchRec) == 0); } } __finally { FindClose(SearchRec); } if (FLastLocalesExts != LocalesExts) { FLastLocalesExts = LocalesExts; FLocales->Clear(); TLanguages * Langs = Languages(); int Ext, Index, Count; wchar_t LocaleStr[255]; LCID Locale; Count = Langs->Count; Index = -1; while (Index < Count) { if (Index >= 0) { Locale = Langs->LocaleID[Index]; Ext = Exts->IndexOf(Langs->Ext[Index]); if (Ext < 0) { Ext = Exts->IndexOf(Langs->Ext[Index].SubString(1, 2)); if (Ext >= 0) { Locale = MAKELANGID(PRIMARYLANGID(Locale), SUBLANG_DEFAULT); } } if (Ext >= 0) { Exts->Objects[Ext] = reinterpret_cast<TObject*>(Locale); } else { Locale = 0; } } else { Locale = InternalLocale(); } if (Locale) { UnicodeString Name; GetLocaleInfo(Locale, LOCALE_SENGLANGUAGE, LocaleStr, LENOF(LocaleStr)); Name = LocaleStr; Name += L" - "; // LOCALE_SNATIVELANGNAME GetLocaleInfo(Locale, LOCALE_SLANGUAGE, LocaleStr, LENOF(LocaleStr)); Name += LocaleStr; FLocales->AddObject(Name, reinterpret_cast<TObject*>(Locale)); } Index++; } for (int Index = 0; Index < Exts->Count; Index++) { if ((Exts->Objects[Index] == NULL) && (Exts->Strings[Index].Length() == 3) && SameText(Exts->Strings[Index].SubString(1, 2), AdditionaLanguagePrefix)) { UnicodeString LangName = GetFileFileInfoString(L"LangName", ChangeFileExt(ModuleFileName(), UnicodeString(L".") + Exts->Strings[Index])); if (!LangName.IsEmpty()) { FLocales->AddObject(LangName, reinterpret_cast<TObject*>( AdditionaLanguageMask + Exts->Strings[Index][3])); } } } } } __finally { delete Exts; } return FLocales; }
//--------------------------------------------------------------------------- //go through column headings as desired by the user void __fastcall TForm3::nextImageButtonClick(TObject *Sender) { //check for blank input if (SameText(dbFieldEdit->Text,"")) { errorLabel->Visible=true; return; } //check to see if string contains only digits and decimal int numDecimals=0; string inputString=AnsiString(dbFieldEdit->Text).c_str(); for (int i = 0; i < inputString.length(); i++) { //check to see if the character is 0-9 or a decimal //if((inputString[i]<48 || inputString[i]>57) && inputString[i]!=46) if(inputString[i]<48 || inputString[i]>57) { if(inputString[i]==46) { numDecimals++; if(numDecimals>1) { dbFieldEdit->Text=""; errorLabel->Visible=true; return; } if(inputString[i+1]<48 || inputString[i+1]>57) { dbFieldEdit->Text=""; errorLabel->Visible=true; return; } } else { dbFieldEdit->Text=""; errorLabel->Visible=true; return; } } } //make sure the error label does not appear errorLabel->Visible=false; if (inputObject.currentIndex == 0 && inputObject.size == 0) { //run when displayObject is empty //strings used in if for holdling column headings String originalHeading = ""; String editedHeading = ""; //get initial column heading without formatting (i.e. removing "_") originalHeading = SQLQuery2->Fields->Fields[0]->AsString; //replace underscores with spaces and set label editedHeading = StringReplace(originalHeading, "_", " ", TReplaceFlags() << rfReplaceAll); //add data to inputObject and increase index/size vector<String> temp; temp.push_back(originalHeading); temp.push_back(editedHeading); temp.push_back(dbFieldEdit->Text); inputObject.valueMap[inputObject.currentIndex] = temp; dbFieldEdit->Text = ""; (inputObject.currentIndex)++; (inputObject.size)++; originalHeading = ""; editedHeading = ""; //advance query SQLQuery2->Next(); //get initial column heading without formatting (i.e. removing "_") originalHeading = SQLQuery2->Fields->Fields[0]->AsString; //replace underscores with spaces and set label editedHeading = StringReplace(originalHeading, "_", " ", TReplaceFlags() << rfReplaceAll); dbFieldLabel->Text = editedHeading; backImageButton->Visible = true; } else if (inputObject.currentIndex == inputObject.size) { //will run when it is time to get the next column from the db //strings used in if for holdling column headings String originalHeading = ""; String editedHeading = ""; if(!SQLQuery2->Eof) { //get initial column heading without formatting (i.e. removing "_") originalHeading = SQLQuery2->Fields->Fields[0]->AsString; //replace underscores with spaces and set label editedHeading = StringReplace(originalHeading, "_", " ", TReplaceFlags() << rfReplaceAll); //fill inputObject with data and increse index/size vector<String> temp; temp.push_back(originalHeading); temp.push_back(editedHeading); temp.push_back(dbFieldEdit->Text); inputObject.valueMap[inputObject.currentIndex] = temp; dbFieldEdit->Text = ""; (inputObject.currentIndex)++; (inputObject.size)++; originalHeading = ""; editedHeading = ""; //advance query cursor SQLQuery2->Next(); //check if now at the end of the query if(SQLQuery2->Eof) { //spawn next part that displays desired changes and asks if sure //hide all other items on form besides home button dbFieldLabel->Visible = false; dbFieldEdit->Visible = false; nextImageButton->Visible = false; nextLabelImage->Visible=false; //show and populate displayGrid displayGrid->RowCount = inputObject.valueMap.size(); for (int i = 0; i < inputObject.size; ++i) { displayGrid->Cells[0][i] = inputObject.valueMap[i][1]; displayGrid->Cells[1][i] = inputObject.valueMap[i][2]; } Image3->Visible=false; Image4->Visible=false; inputLabelImage->Visible=false; displayGrid->Visible = true; submitButton->Visible = true; Image1->Visible=true; } else { //get initial column heading without formatting (i.e. removing "_") originalHeading = SQLQuery2->Fields->Fields[0]->AsString; //replace underscores with spaces and set label editedHeading = StringReplace(originalHeading, "_", " ", TReplaceFlags() << rfReplaceAll); dbFieldLabel->Text = editedHeading; backImageButton->Visible = true; } } } else { //don't query db, only go to next item in struct, replace item before advancing inputObject.valueMap[inputObject.currentIndex].pop_back(); inputObject.valueMap[inputObject.currentIndex].push_back(dbFieldEdit->Text); dbFieldEdit->Text = ""; (inputObject.currentIndex)++; if (inputObject.currentIndex == inputObject.size) { //accounts for case when coming back after pressing previous if data not previously captured //strings used in if for holdling column headings String originalHeading = ""; String editedHeading = ""; if(!SQLQuery2->Eof) { //get initial column heading without formatting (i.e. removing "_") originalHeading = ""; editedHeading = ""; //get initial column heading without formatting (i.e. removing "_") originalHeading = SQLQuery2->Fields->Fields[0]->AsString; //replace underscores with spaces and set label editedHeading = StringReplace(originalHeading, "_", " ", TReplaceFlags() << rfReplaceAll); dbFieldLabel->Text = editedHeading; backImageButton->Visible = true; } else { //spawn next part that displays desired changes and asks if sure //hide all other items on form besides home button dbFieldLabel->Visible = false; dbFieldEdit->Visible = false; nextImageButton->Visible = false; Image3->Visible=false; Image4->Visible=false; nextLabelImage->Visible=false; //show and populate displayGrid for (int i = 0; i < inputObject.size; ++i) { displayGrid->Cells[0][i+1] = inputObject.valueMap[i][1]; displayGrid->Cells[1][i+1] = inputObject.valueMap[i][2]; } submitButton->Visible = true; Image1->Visible=true; displayGrid->Visible = true; } } else { //when next pressed and data for this index has previously been captured dbFieldEdit->Text = inputObject.valueMap[inputObject.currentIndex][2]; dbFieldLabel->Text = inputObject.valueMap[inputObject.currentIndex][1]; backImageButton->Visible = true; } } }
//--------------------------------------------------------------------------- UnicodeString __fastcall TConfiguration::GetIniFileStorageName(bool ReadingOnly) { if (FIniFileStorageName.IsEmpty()) { UnicodeString ProgramPath = ParamStr(0); UnicodeString ProgramIniPath = ChangeFileExt(ProgramPath, L".ini"); UnicodeString IniPath; if (FileExists(ProgramIniPath)) { IniPath = ProgramIniPath; } else { UnicodeString AppDataIniPath = IncludeTrailingBackslash(GetShellFolderPath(CSIDL_APPDATA)) + ExtractFileName(ProgramIniPath); if (FileExists(AppDataIniPath)) { IniPath = AppDataIniPath; } else { // avoid expensive test if we are interested in existing files only if (!ReadingOnly && (FProgramIniPathWrittable < 0)) { UnicodeString ProgramDir = ExtractFilePath(ProgramPath); FProgramIniPathWrittable = IsDirectoryWriteable(ProgramDir) ? 1 : 0; } // does not really matter what we return when < 0 IniPath = (FProgramIniPathWrittable == 0) ? AppDataIniPath : ProgramIniPath; } } // BACKWARD COMPATIBILITY with 4.x if (FVirtualIniFileStorageName.IsEmpty() && TPath::IsDriveRooted(IniPath)) { UnicodeString LocalAppDataPath = GetShellFolderPath(CSIDL_LOCAL_APPDATA); // virtual store for non-system drives have a different virtual store, // do not bother about them if (TPath::IsDriveRooted(LocalAppDataPath) && SameText(ExtractFileDrive(IniPath), ExtractFileDrive(LocalAppDataPath))) { FVirtualIniFileStorageName = IncludeTrailingBackslash(LocalAppDataPath) + L"VirtualStore\\" + IniPath.SubString(4, IniPath.Length() - 3); } } if (!FVirtualIniFileStorageName.IsEmpty() && FileExists(FVirtualIniFileStorageName)) { return FVirtualIniFileStorageName; } else { return IniPath; } } else { return FIniFileStorageName; } }
XRequestState XHttpRequest::DataIn(/*in*/void *buf,/*in*/int buf_size) { if(NULL == buf || 0 == buf_size) return m_state; m_data->Write(buf,buf_size); lblcase: switch(m_state) { case rsNotHttp: break; case rsHeadUnCompleted: { void *p = AddPtr(m_data->GetBuffer(),4); for(int i=0;i<m_data->GetSize()-4;++i) { IncPtr(&p,1); if(memcmp(p,"\r\n\r\n",4) == 0) { m_state = rsBodyUncompleted; m_body_pos = i+4; string shead((char*)(m_data->GetBuffer()),m_body_pos+1); vector<string> vhead; vector<string> vhead_1; vector<string> vhead_2; SplitString(shead,"\r\n",vhead); SplitString(vhead[0]," ",vhead_1); m_method = vhead_1[0]; SplitString(vhead_1[1],"?",vhead_2); m_path = vhead_2[0]; if (vhead_2.size() > 1) m_url_params = vhead_2[1]; else m_url_params.clear(); m_head.clear(); m_content_length = 0; if(vhead.size() > 1) { for(size_t ihead=1;ihead<vhead.size();++ihead) { string sk,sv; SplitString(vhead[ihead],":",sk,sv); sk = trim(sk); sv = trim(sv); if(SameText(sk,"Content-Length")) { m_content_length = atoi(sv.c_str()); } m_head.push_back(XHttpHeadLine(sk,sv)); } } if(m_content_length <= 0) { m_state = rsCompleted; //post packet to recv queue m_socket->m_server->m_recved_queue->P(Clone()); Clear(true); } goto lblcase; } } break; } case rsBodyUncompleted: { int iretain = m_data->GetSize() - m_body_pos - m_content_length; if(iretain >= 0) { m_state = rsCompleted; //post packet to recv queue m_socket->m_server->m_recved_queue->P(this->Clone()); if(iretain > 0) { void *p = m_data->GetBuffer(); IncPtr(&p,m_body_pos + m_content_length); memmove(m_data->GetBuffer(),p,iretain); //maybe overlap m_data->Shrink(iretain+1); m_data->Seek(MemoryStream::soEnd,1); Clear(false); } else Clear(true); goto lblcase; } break; } case rsCompleted: { if(buf_size >= 4) { string smtd((char*)buf,4); if(!SameText(smtd,"GET ") && !SameText(smtd,"POST")) { m_state = rsNotHttp; goto lblcase; } } m_state = rsHeadUnCompleted; goto lblcase; break; } } return m_state; }
//--------------------------------------------------------------------------- bool TContrastEnhanceForm1::Load_CEini(String Fpath) { long lSize; char *Buffer; FILE *fptr; if ((fptr = fopen(Fpath.c_str(), "r")) == NULL) return 0; // obtain file size: fseek(fptr, 0, SEEK_END); lSize = ftell(fptr); rewind(fptr); // allocate memory to contain the whole file: Buffer = (char *) malloc(sizeof(char) * lSize); if (Buffer == NULL) return 0; // copy the file into the buffer: fread(Buffer, 1, lSize, fptr); fclose(fptr); //------------Load CE value to interface----------------------------- AnsiString Str[29]; //CheckBox Str[0] = "SPRS_BLK1"; Str[1] = "SPRS_BLK0"; Str[2] = "PURITYWT_EN"; Str[3] = "GRAD_EN"; Str[4] = "FASTCHG_EN"; Str[5] = "MLC_EN"; //ComboBox Str[6] = "MAXLIMT_SEL"; Str[7] = "PIXHIST_SEL"; Str[8] = "LOWST_SEL"; Str[9] = "JND_SEL"; Str[10] = "ST_SEL"; //ScrollBar Str[11] = "GRAD_GMA_STEP"; Str[12] = "GRAD_FRM_STEP"; Str[13] = "GRAD_PIXDIFF_THR"; Str[14] = "STRENGTH_K"; Str[15] = "MIN_EDGE"; Str[16] = "PIX_DIFF_THR"; Str[17] = "EDG_DIFF_THR"; Str[18] = "MLC_THR"; Str[19] = "PATDET_FRM_NUM"; Str[20] = "PATDET_LINE_NUM"; Str[21] = "JND_MAX"; Str[22] = "JND_MIN"; Str[23] = "ST_MAX"; Str[24] = "ST_MIN"; //Table Str[25] = "JND_LUT"; Str[26] = "ST_LUT"; Str[27] = "MAX_LUT"; Str[28] = "MIN_LUT"; char *buffer; char *pch; bool match = false; //CheckBox for (int i = 0; i < 25; i++) { match = false; buffer = (char *) malloc(sizeof(char) * lSize); strncpy(buffer, Buffer, lSize); pch = strtok(buffer, "\n\t"); while (!SameText((AnsiString) pch, Str[i])) { if (pch == NULL) { ShowMessage("Can't Find" + Str[i]); return 0; //資料中沒有 } pch = strtok(NULL, "\n\t"); } pch = strtok(NULL, "\n\t"); for (int j = 0; j < OCE->CEChkBox_Nbr; j++) { if (SameText(Str[i], ChkB[j]->Addr.Name())) { ChkB[j]->Chkb->Checked = (StrToInt(pch) == 1 ? 1 : 0); match = true; break; } } if (!match) { for (int j = 0; j < OCE->CECboBox_Nbr; j++) { if (SameText(Str[i], CboB[j]->Addr.Name())) { CboB[j]->Cbob->ItemIndex = StrToInt(pch); match = true; break; } } } if (!match) { for (int j = 0; j < OCE->CEScrollBar_Nbr; j++) { if (SameText(Str[i], ScrlB[j]->Addr.Name())) { ScrlB[j]->ScrlB->Position = StrToInt(pch); break; } } } delete[]buffer; } //-----------------LUT------------------------------ for (int i = 0; i < 16; i++) { JND_lut[i] = 0; ST_lut[i] = 0; MAX_lut[i] = 0; MIN_lut[i] = 0; } char *str[4]; str[0] = "JND_LUT"; str[1] = "ST__LUT"; str[2] = "MAX_LUT"; str[3] = "MIN_LUT"; for (int i = 0; i < 4; i++) { buffer = (char *) malloc(sizeof(char) * lSize); strncpy(buffer, Buffer, lSize); pch = strtok(buffer, "\n\t"); while (SameText((AnsiString) pch, str[i]) != 1) { if (pch == NULL) return 0; pch = strtok(NULL, "\n\t"); } int c = 0; pch = strtok(NULL, "\n\t"); while (c < 16 && pch != NULL) { if (pch == NULL) return 0; //資料中的data缺少 if (i == 0) JND_lut[c] = StrToInt((AnsiString) pch); else if (i == 1) ST_lut[c] = StrToInt((AnsiString) pch); else if (i == 2) MAX_lut[c] = StrToInt((AnsiString) pch); else MIN_lut[c] = StrToInt((AnsiString) pch); pch = strtok(NULL, "\n\t"); c++; } delete[]buffer; } delete[]Buffer; for (int i = 0; i < 16; i++) { sg_JND_LUT->Cells[i][0] = JND_lut[i]; sg_ST_LUT->Cells[i][0] = ST_lut[i]; sg_MAX_LUT->Cells[i][0] = MAX_lut[i]; sg_MIN_LUT->Cells[i][0] = MIN_lut[i]; } return 1; }