//--------------------------------------------------------------------------- int askappend(void * /*frontend*/, Filename * /*filename*/, void (* /*callback*/)(void * ctx, int result), void * /*ctx*/) { // this is called from logging.c of putty, which is never used with WinSCP DebugFail(); return 0; }
long reg_query_winscp_value_ex(HKEY Key, const char * ValueName, unsigned long * /*Reserved*/, unsigned long * Type, uint8_t * Data, unsigned long * DataSize) { long R; DebugAssert(GetConfiguration() != nullptr); THierarchicalStorage * Storage = reinterpret_cast<THierarchicalStorage *>(Key); AnsiString Value; if (Storage == nullptr) { if (UnicodeString(ValueName) == L"RandSeedFile") { Value = AnsiString(GetConfiguration()->GetRandomSeedFileName()); R = ERROR_SUCCESS; } else { DebugFail(); R = ERROR_READ_FAULT; } } else { if (Storage->ValueExists(ValueName)) { Value = AnsiString(Storage->ReadStringRaw(ValueName, L"")); R = ERROR_SUCCESS; } else { R = ERROR_READ_FAULT; } } if (R == ERROR_SUCCESS) { DebugAssert(Type != nullptr); *Type = REG_SZ; char * DataStr = reinterpret_cast<char *>(Data); int sz = static_cast<int>(*DataSize); if (sz > 0) { strncpy(DataStr, Value.c_str(), sz); DataStr[sz - 1] = '\0'; } *DataSize = static_cast<uint32_t>(strlen(DataStr)); } return R; }
bool TCopyParamType::AllowResume(int64_t Size) const { switch (GetResumeSupport()) { case rsOn: return true; case rsOff: return false; case rsSmart: return (Size >= GetResumeThreshold()); default: DebugFail(); return false; } }
bool TCopyParamType::UseAsciiTransfer(const UnicodeString & AFileName, TOperationSide Side, const TFileMasks::TParams & Params) const { switch (GetTransferMode()) { case tmBinary: return false; case tmAscii: return true; case tmAutomatic: return GetAsciiFileMask().Matches(AFileName, (Side == osLocal), false, &Params); default: DebugFail(); return false; } }
UnicodeString TSessionLog::GetTlsVersionName(TTlsVersion TlsVersion) const { switch (TlsVersion) { default: DebugFail(); case ssl2: return "SSLv2"; case ssl3: return "SSLv3"; case tls10: return "TLSv1.0"; case tls11: return "TLSv1.1"; case tls12: return "TLSv1.2"; } }
TPrivateKey * LoadKey(TKeyType KeyType, const UnicodeString & FileName, const UnicodeString & Passphrase) { UTF8String UtfFileName = UTF8String(::ExpandEnvironmentVariables(FileName)); Filename * KeyFile = filename_from_str(UtfFileName.c_str()); AnsiString AnsiPassphrase = AnsiString(Passphrase); struct ssh2_userkey * Ssh2Key = nullptr; const char * ErrorStr = nullptr; switch (KeyType) { case ktSSH2: Ssh2Key = ssh2_load_userkey(KeyFile, (char *)AnsiPassphrase.c_str(), &ErrorStr); break; case ktOpenSSHPEM: case ktOpenSSHNew: case ktSSHCom: Ssh2Key = import_ssh2(KeyFile, KeyType, (char *)AnsiPassphrase.c_str(), &ErrorStr); break; default: DebugFail(); break; } Shred(AnsiPassphrase); if (Ssh2Key == nullptr) { UnicodeString Error = UnicodeString(ErrorStr); // While theoretically we may get "unable to open key file" and // so we should check system error code, // we actully never get here unless we call KeyType previously // and handle ktUnopenable accordingly. throw Exception(Error); } else if (Ssh2Key == SSH2_WRONG_PASSPHRASE) { throw Exception(LoadStr(AUTH_TRANSL_WRONG_PASSPHRASE)); } return reinterpret_cast<TPrivateKey *>(Ssh2Key); }
//--------------------------------------------------------------------------- void __fastcall TKeyGenerator::SaveKey(const AnsiString FileName, const AnsiString Passphrase, TKeyFormat Format) { DebugAssert(FSSH2Key); DebugAssert(FState == kgComplete); DebugAssert((Format != kfOpenSSH && Format != kfSSHCom) || IsSSH2); int Result; if (IsSSH2) { switch (Format) { case kfPutty: Result = ssh2_save_userkey(FileName.c_str(), FSSH2Key, (char*)Passphrase.data()); break; case kfOpenSSH: Result = export_ssh2(FileName.c_str(), SSH_KEYTYPE_OPENSSH, FSSH2Key, (char*)Passphrase.data()); break; case kfSSHCom: Result = export_ssh2(FileName.c_str(), SSH_KEYTYPE_SSHCOM, FSSH2Key, (char*)Passphrase.data()); break; default: DebugFail(); } } else { DebugAssert(Format == kfPutty); Result = saversakey(FileName.c_str(), FRSAKey, (char*)Passphrase.data()); } if (Result <= 0) throw Exception(FMTLOAD(SAVE_KEY_ERROR, (FileName))); }
T_void DebugAddRoutine( T_byte8 *p_routineName, T_byte8 *p_filename, T_word16 lineNum) { /* We will place the routine's name on the call stack. */ DebugCheck(p_routineName != NULL) ; /* First, determine if there is room on the stack for the name. */ if (G_StackPosition == DEBUG_MAX_STACK_DEPTH) { /* Error! Too many calls */ DebugFail("Call stack too deep!", __FILE__, __LINE__) ; } else { /* OK, just add to the stack. */ G_CallStackFile[G_StackPosition] = p_filename ; G_CallStackLine[G_StackPosition] = lineNum ; G_CallStack[G_StackPosition++] = p_routineName ; } }
const wchar_t *ActionName() const { switch (FAction) { case laUpload: return L"upload"; case laDownload: return L"download"; case laTouch: return L"touch"; case laChmod: return L"chmod"; case laMkdir: return L"mkdir"; case laRm: return L"rm"; case laMv: return L"mv"; case laCall: return L"call"; case laLs: return L"ls"; case laStat: return L"stat"; case laChecksum: return L"checksum"; case laCwd: return L"cwd"; default: DebugFail(); return L""; } }
void SaveKey(TKeyType KeyType, const UnicodeString & FileName, const UnicodeString & Passphrase, TPrivateKey * PrivateKey) { UTF8String UtfFileName = UTF8String(::ExpandEnvironmentVariables(FileName)); Filename * KeyFile = filename_from_str(UtfFileName.c_str()); struct ssh2_userkey * Ssh2Key = reinterpret_cast<struct ssh2_userkey *>(PrivateKey); AnsiString AnsiPassphrase = AnsiString(Passphrase); const char * PassphrasePtr = (AnsiPassphrase.IsEmpty() ? nullptr : AnsiPassphrase.c_str()); switch (KeyType) { case ktSSH2: if (!ssh2_save_userkey(KeyFile, Ssh2Key, (char *)PassphrasePtr)) { int Error = errno; throw EOSExtException(FMTLOAD(KEY_SAVE_ERROR, FileName.c_str()), Error); } break; default: DebugFail(); break; } }
bool IsKeyEncrypted(TKeyType KeyType, const UnicodeString & FileName, UnicodeString & Comment) { UTF8String UtfFileName = UTF8String(::ExpandEnvironmentVariables(FileName)); Filename * KeyFile = filename_from_str(UtfFileName.c_str()); bool Result; char * CommentStr = nullptr; switch (KeyType) { case ktSSH2: Result = (ssh2_userkey_encrypted(KeyFile, &CommentStr) != 0); break; case ktOpenSSHPEM: case ktOpenSSHNew: case ktSSHCom: Result = (import_encrypted(KeyFile, KeyType, &CommentStr) != 0); break; default: DebugFail(); Result = false; break; } if (CommentStr != nullptr) { Comment = UnicodeString(AnsiString(CommentStr)); // ktOpenSSH has no comment, PuTTY defaults to file path if (Comment == FileName) { Comment = base::ExtractFileName(FileName, false); } sfree(CommentStr); } return Result; }
//--------------------------------------------------------------------------- bool __fastcall TQueueController::AllowOperation( TQueueOperation Operation, void ** Param) { TQueueItemProxy * QueueItem = NULL; if (FListView->ItemFocused != NULL) { QueueItem = QueueViewItemToQueueItem(FListView->ItemFocused); } switch (Operation) { case qoItemUserAction: return (QueueItem != NULL) && TQueueItem::IsUserActionStatus(QueueItem->Status); case qoItemQuery: return (QueueItem != NULL) && (QueueItem->Status == TQueueItem::qsQuery); case qoItemError: return (QueueItem != NULL) && (QueueItem->Status == TQueueItem::qsError); case qoItemPrompt: return (QueueItem != NULL) && (QueueItem->Status == TQueueItem::qsPrompt); case qoItemDelete: return (QueueItem != NULL); case qoItemExecute: return (QueueItem != NULL) && (QueueItem->Status == TQueueItem::qsPending); case qoItemUp: return (QueueItem != NULL) && (QueueItem->Status == TQueueItem::qsPending) && // it's not first pending item, // this is based on assumption that pending items occupy single line always (FListView->ItemFocused->Index > 0) && (QueueViewItemToQueueItem(FListView->Items->Item[FListView->ItemFocused->Index - 1])->Status == TQueueItem::qsPending); case qoItemDown: return (QueueItem != NULL) && (QueueItem->Status == TQueueItem::qsPending) && (FListView->ItemFocused->Index < (FListView->Items->Count - 1)); case qoItemPause: return (QueueItem != NULL) && (QueueItem->Status == TQueueItem::qsProcessing); case qoItemResume: return (QueueItem != NULL) && (QueueItem->Status == TQueueItem::qsPaused); case qoItemSpeed: { bool Result = (QueueItem != NULL) && (QueueItem->Status != TQueueItem::qsDone); if (Result && (Param != NULL)) { Result = QueueItem->GetCPSLimit(*reinterpret_cast<unsigned long *>(Param)); } return Result; } case qoPauseAll: case qoResumeAll: { TQueueItem::TStatus Status = (Operation == qoPauseAll) ? TQueueItem::qsProcessing : TQueueItem::qsPaused; bool Result = false; // can be NULL when action update is triggered while disconnecting if (FQueueStatus != NULL) { for (int i = FQueueStatus->DoneCount; !Result && (i < FQueueStatus->DoneAndActiveCount); i++) { QueueItem = FQueueStatus->Items[i]; Result = (QueueItem->Status == Status); } } return Result; } case qoDeleteAllDone: return (FQueueStatus != NULL) && (FQueueStatus->DoneCount > 0); case qoDeleteAll: return (FQueueStatus != NULL) && (FQueueStatus->Count > 0); default: DebugFail(); return false; } }
//--------------------------------------------------------------------------- void __fastcall TQueueController::ExecuteOperation(TQueueOperation Operation, void * Param) { TQueueItemProxy * QueueItem = NULL; if (FListView->ItemFocused != NULL) { QueueItem = QueueViewItemToQueueItem(FListView->ItemFocused); } switch (Operation) { case qoItemUserAction: case qoItemQuery: case qoItemError: case qoItemPrompt: if (QueueItem != NULL) { QueueItem->ProcessUserAction(); } break; case qoItemExecute: if (QueueItem != NULL) { QueueItem->ExecuteNow(); } break; case qoItemUp: case qoItemDown: if (QueueItem != NULL) { QueueItem->Move(Operation == qoItemUp); } break; case qoItemDelete: if (QueueItem != NULL) { QueueItem->Delete(); } break; case qoItemPause: if (QueueItem != NULL) { QueueItem->Pause(); } break; case qoItemResume: if (QueueItem != NULL) { QueueItem->Resume(); } break; case qoItemSpeed: if (QueueItem != NULL) { QueueItem->SetCPSLimit(reinterpret_cast<unsigned long>(Param)); } break; case qoPauseAll: case qoResumeAll: { for (int i = FQueueStatus->DoneCount; i < FQueueStatus->DoneAndActiveCount; i++) { QueueItem = FQueueStatus->Items[i]; if ((Operation == qoPauseAll) && (QueueItem->Status == TQueueItem::qsProcessing)) { QueueItem->Pause(); } else if ((Operation == qoResumeAll) && (QueueItem->Status == TQueueItem::qsPaused)) { QueueItem->Resume(); } } } break; case qoDeleteAllDone: case qoDeleteAll: { int Count = (Operation == qoDeleteAll) ? FQueueStatus->Count : FQueueStatus->DoneCount; for (int i = 0; i < Count; i++) { QueueItem = FQueueStatus->Items[i]; QueueItem->Delete(); } } break; default: DebugFail(); break; } }
void TCopyParamType::DoGetInfoStr( const UnicodeString & Separator, intptr_t Options, UnicodeString & Result, bool & SomeAttrIncluded, const UnicodeString & Link, UnicodeString & ScriptArgs, bool & NoScriptArgs, /*TAssemblyLanguage Language, UnicodeString & AssemblyCode,*/ bool & NoCodeProperties) const { TCopyParamType Defaults; bool SomeAttrExcluded = false; NoScriptArgs = false; NoCodeProperties = false; SomeAttrIncluded = false; #define ADD(STR, EXCEPT) \ if (FLAGCLEAR(Options, EXCEPT)) \ { \ AddToList(Result, (STR), Separator); \ SomeAttrIncluded = true; \ } \ else \ { \ SomeAttrExcluded = true; \ } bool AsciiFileMaskDiffers = (GetTransferMode() == tmAutomatic) && !(GetAsciiFileMask() == Defaults.GetAsciiFileMask()); bool TransferModeDiffers = ((GetTransferMode() != Defaults.GetTransferMode()) || AsciiFileMaskDiffers); if (FLAGCLEAR(Options, cpaIncludeMaskOnly | cpaNoTransferMode)) { // Adding Transfer type unconditionally bool FormatMask; int Ident; switch (GetTransferMode()) { case tmBinary: FormatMask = false; Ident = 2; break; case tmAscii: FormatMask = false; Ident = 3; break; case tmAutomatic: default: FormatMask = !(GetAsciiFileMask() == Defaults.GetAsciiFileMask()); Ident = FormatMask ? 4 : 5; break; } UnicodeString S = FORMAT(LoadStrPart(COPY_INFO_TRANSFER_TYPE2, 1).c_str(), LoadStrPart(COPY_INFO_TRANSFER_TYPE2, Ident).c_str()); if (FormatMask) { S = FORMAT(S.c_str(), GetAsciiFileMask().GetMasks().c_str()); } AddToList(Result, S, Separator); if (TransferModeDiffers) { ADD("", cpaIncludeMaskOnly | cpaNoTransferMode); /*ScriptArgs += RtfSwitchValue(TRANSFER_SWITCH, Link, TransferModeNames[TransferMode]); const wchar_t * TransferModeMembers[] = { L"Binary", L"Ascii", L"Automatic" }; AssemblyCode += AssemblyProperty( Language, TransferOptionsClassName, L"TransferMode", L"TransferMode", TransferModeMembers[TransferMode], false); if (AsciiFileMaskDiffers) { NoScriptArgs = true; NoCodeProperties = true; }*/ } } else { if (TransferModeDiffers) { SomeAttrExcluded = true; NoScriptArgs = true; NoCodeProperties = true; } } if (GetFileNameCase() != Defaults.GetFileNameCase()) { ADD(FORMAT(LoadStrPart(COPY_INFO_FILENAME, 1).c_str(), LoadStrPart(COPY_INFO_FILENAME, GetFileNameCase() + 2).c_str()), cpaIncludeMaskOnly); NoScriptArgs = true; NoCodeProperties = true; } if ((GetInvalidCharsReplacement() == NoReplacement) != (Defaults.GetInvalidCharsReplacement() == NoReplacement)) { DebugAssert(GetInvalidCharsReplacement() == NoReplacement); if (GetInvalidCharsReplacement() == NoReplacement) { ADD(LoadStr(COPY_INFO_DONT_REPLACE_INV_CHARS).c_str(), cpaIncludeMaskOnly); } NoScriptArgs = true; NoCodeProperties = true; } if ((GetPreserveRights() != Defaults.GetPreserveRights()) || (GetPreserveRights() && ((GetRights() != Defaults.GetRights()) || (GetAddXToDirectories() != Defaults.GetAddXToDirectories())))) { const int Except = cpaIncludeMaskOnly | cpaNoRights; if (DebugAlwaysTrue(GetPreserveRights())) { UnicodeString RightsStr = GetRights().GetText(); if (GetAddXToDirectories()) { RightsStr += L", " + LoadStr(COPY_INFO_ADD_X_TO_DIRS); } ADD(FORMAT(LoadStr(COPY_INFO_PERMISSIONS).c_str(), RightsStr.c_str()), Except); if (FLAGCLEAR(Options, Except)) { // ScriptArgs += RtfSwitchValue(PERMISSIONS_SWITCH, Link, Rights.Octal); // const UnicodeString FilePermissionsClassName = L"FilePermissions"; // const bool Inline = true; // UnicodeString FilePermissions = // AssemblyNewClassInstanceStart(Language, FilePermissionsClassName, Inline) + // AssemblyProperty(Language, FilePermissionsClassName, L"Octal", Rights.Octal, Inline) + // AssemblyNewClassInstanceEnd(Language, Inline); // AssemblyCode += AssemblyPropertyRaw(Language, TransferOptionsClassName, L"FilePermissions", FilePermissions, false); } } if ((GetAddXToDirectories() != Defaults.GetAddXToDirectories()) && FLAGCLEAR(Options, Except)) { NoScriptArgs = true; NoCodeProperties = true; } } bool APreserveTimeDirs = GetPreserveTime() && GetPreserveTimeDirs(); if ((GetPreserveTime() != Defaults.GetPreserveTime()) || (APreserveTimeDirs != Defaults.GetPreserveTimeDirs())) { bool AddPreserveTime = false; UnicodeString Str = LoadStr(GetPreserveTime() ? COPY_INFO_TIMESTAMP : COPY_INFO_DONT_PRESERVE_TIME); const int ExceptDirs = cpaNoPreserveTimeDirs; if (APreserveTimeDirs != Defaults.GetPreserveTimeDirs()) { if (DebugAlwaysTrue(GetPreserveTimeDirs())) { if (FLAGCLEAR(Options, ExceptDirs)) { Str = FMTLOAD(COPY_INFO_PRESERVE_TIME_DIRS, (Str)); AddPreserveTime = true; } } ADD("", ExceptDirs); } const int Except = cpaIncludeMaskOnly | cpaNoPreserveTime; if (GetPreserveTime() != Defaults.GetPreserveTime()) { if (FLAGCLEAR(Options, Except)) { AddPreserveTime = true; } ADD(L"", Except); } if (AddPreserveTime) { AddToList(Result, Str, Separator); } if (FLAGCLEAR(Options, Except)) { if (GetPreserveTime()) { if (GetPreserveTimeDirs() && FLAGCLEAR(Options, ExceptDirs)) { //ScriptArgs += RtfSwitchValue(PRESERVETIME_SWITCH, Link, PRESERVETIMEDIRS_SWITCH_VALUE); NoCodeProperties = true; } else { DebugFail(); // should never get here //ScriptArgs += RtfSwitch(PRESERVETIME_SWITCH, Link); } } else { // ScriptArgs += RtfSwitch(NOPRESERVETIME_SWITCH, Link); // AssemblyCode += AssemblyProperty(Language, TransferOptionsClassName, L"PreserveTimestamp", false, false); } } } if ((GetPreserveRights() || GetPreserveTime()) && (GetIgnorePermErrors() != Defaults.GetIgnorePermErrors())) { if (DebugAlwaysTrue(GetIgnorePermErrors())) { const int Except = cpaIncludeMaskOnly | cpaNoIgnorePermErrors; ADD(LoadStr(COPY_INFO_IGNORE_PERM_ERRORS), Except); if (FLAGCLEAR(Options, Except)) { NoScriptArgs = true; NoCodeProperties = true; } } } if (GetPreserveReadOnly() != Defaults.GetPreserveReadOnly()) { if (DebugAlwaysTrue(GetPreserveReadOnly())) { const int Except = cpaIncludeMaskOnly | cpaNoPreserveReadOnly; ADD(LoadStr(COPY_INFO_PRESERVE_READONLY), Except); if (FLAGCLEAR(Options, Except)) { NoScriptArgs = true; NoCodeProperties = true; } } } if (GetCalculateSize() != Defaults.GetCalculateSize()) { if (DebugAlwaysTrue(!GetCalculateSize())) { ADD(LoadStr(COPY_INFO_DONT_CALCULATE_SIZE), cpaIncludeMaskOnly); // Always false in scripting, in assembly controlled by use of FileTransferProgress } } if (GetClearArchive() != Defaults.GetClearArchive()) { if (DebugAlwaysTrue(GetClearArchive())) { const int Except = cpaIncludeMaskOnly | cpaNoClearArchive; ADD(LoadStr(COPY_INFO_CLEAR_ARCHIVE), Except); if (FLAGCLEAR(Options, Except)) { NoScriptArgs = true; NoCodeProperties = true; } } } if ((GetTransferMode() == tmAscii) || (GetTransferMode() == tmAutomatic)) { if (GetRemoveBOM() != Defaults.GetRemoveBOM()) { if (DebugAlwaysTrue(GetRemoveBOM())) { const int Except = cpaIncludeMaskOnly | cpaNoRemoveBOM | cpaNoTransferMode; ADD(LoadStr(COPY_INFO_REMOVE_BOM), Except); if (FLAGCLEAR(Options, Except)) { NoScriptArgs = true; NoCodeProperties = true; } } } if (GetRemoveCtrlZ() != Defaults.GetRemoveCtrlZ()) { if (DebugAlwaysTrue(GetRemoveCtrlZ())) { const int Except = cpaIncludeMaskOnly | cpaNoRemoveCtrlZ | cpaNoTransferMode; ADD(LoadStr(COPY_INFO_REMOVE_CTRLZ),Except); if (FLAGCLEAR(Options, Except)) { NoScriptArgs = true; NoCodeProperties = true; } } } } if (!(GetIncludeFileMask() == Defaults.GetIncludeFileMask())) { ADD(FORMAT(LoadStr(COPY_INFO_FILE_MASK).c_str(), GetIncludeFileMask().GetMasks().c_str()), cpaNoIncludeMask); // ScriptArgs += RtfSwitch(FILEMASK_SWITCH, Link, IncludeFileMask.Masks); // AssemblyCode += AssemblyProperty(Language, TransferOptionsClassName, L"FileMask", IncludeFileMask.Masks, false); } DebugAssert(FTransferSkipList.get() == nullptr); DebugAssert(FTransferResumeFile.IsEmpty()); if (GetCPSLimit() > 0) { intptr_t LimitKB = intptr_t(GetCPSLimit() / 1024); ADD(FMTLOAD(COPY_INFO_CPS_LIMIT2, (LimitKB)), cpaIncludeMaskOnly); // ScriptArgs += RtfSwitch(SPEED_SWITCH, Link, LimitKB); // AssemblyCode += AssemblyProperty(Language, TransferOptionsClassName, L"Speed", LimitKB, false); } if (GetNewerOnly() != Defaults.GetNewerOnly()) { if (DebugAlwaysTrue(GetNewerOnly())) { const int Except = cpaIncludeMaskOnly | cpaNoNewerOnly; ADD(StripHotkey(LoadStr(COPY_PARAM_NEWER_ONLY)), Except); if (FLAGCLEAR(Options, Except)) { // ScriptArgs += RtfSwitch(NEWERONLY_SWICH, Link); NoCodeProperties = true; } } } bool ResumeThresholdDiffers = ((GetResumeSupport() == rsSmart) && (GetResumeThreshold() != Defaults.GetResumeThreshold())); if (((GetResumeSupport() != Defaults.GetResumeSupport()) || ResumeThresholdDiffers) && (GetTransferMode() != tmAscii) && FLAGCLEAR(Options, cpaNoResumeSupport)) { UnicodeString Value; UnicodeString CodeState; intptr_t ResumeThresholdKB = (GetResumeThreshold() / 1024); switch (GetResumeSupport()) { case rsOff: Value = ToggleNames[ToggleOff]; CodeState = L"Off"; break; case rsOn: Value = ToggleNames[ToggleOn]; CodeState = L"On"; break; case rsSmart: Value = IntToStr(ResumeThresholdKB); break; } // ScriptArgs += RtfSwitchValue(RESUMESUPPORT_SWITCH, Link, Value); const UnicodeString ResumeSupportClassName = L"TransferResumeSupport"; // const bool Inline = true; // UnicodeString ResumeSupportCode = // AssemblyNewClassInstanceStart(Language, ResumeSupportClassName, Inline); if (GetResumeSupport() == rsSmart) { // ResumeSupportCode += AssemblyProperty(Language, ResumeSupportClassName, L"Threshold", ResumeThresholdKB, Inline); } else { // ResumeSupportCode += AssemblyProperty(Language, ResumeSupportClassName, L"State", L"TransferResumeSupportState", CodeState, Inline); } // ResumeSupportCode += AssemblyNewClassInstanceEnd(Language, Inline); // AssemblyCode += AssemblyPropertyRaw(Language, TransferOptionsClassName, L"ResumeSupport", ResumeSupportCode, false); } if (SomeAttrExcluded) { Result += (Result.IsEmpty() ? UnicodeString() : Separator) + FORMAT(LoadStrPart(COPY_INFO_NOT_USABLE, 1).c_str(), LoadStrPart(COPY_INFO_NOT_USABLE, (SomeAttrIncluded ? 2 : 3)).c_str()); } else if (Result.IsEmpty()) { Result = LoadStr(COPY_INFO_DEFAULT); } #undef ADD }
//--------------------------------------------------------------------------- bool __fastcall TFileZillaIntf::HandleMessage(WPARAM wParam, LPARAM lParam) { bool Result; CString a; unsigned int MessageID = FZ_MSG_ID(wParam); switch (MessageID) { case FZ_MSG_STATUS: { DebugAssert(FZ_MSG_PARAM(wParam) == 0); t_ffam_statusmessage * Status = (t_ffam_statusmessage *)lParam; DebugAssert(Status->post); Result = HandleStatus(Status->status, Status->type); delete Status; } break; case FZ_MSG_ASYNCREQUEST: if (FZ_MSG_PARAM(wParam) == FZ_ASYNCREQUEST_OVERWRITE) { int RequestResult; wchar_t FileName1[MAX_PATH]; COverwriteRequestData * Data = (COverwriteRequestData *)lParam; try { DebugAssert(Data != NULL); wcsncpy(FileName1, Data->FileName1, LENOF(FileName1)); FileName1[LENOF(FileName1) - 1] = L'\0'; TRemoteFileTime RemoteTime; CopyFileTime(RemoteTime, Data->remotetime); Result = HandleAsynchRequestOverwrite( FileName1, LENOF(FileName1), Data->FileName2, Data->path1, Data->path2, Data->size1, Data->size2, (Data->localtime != NULL) ? Data->localtime->GetTime() : 0, (Data->localtime != NULL) && ((Data->localtime->GetHour() != 0) || (Data->localtime->GetMinute() != 0)), RemoteTime, reinterpret_cast<void*>(Data->pTransferFile->nUserData), RequestResult); } catch(...) { FFileZillaApi->SetAsyncRequestResult(FILEEXISTS_SKIP, Data); throw; } if (Result) { Data->FileName1 = FileName1; Result = Check(FFileZillaApi->SetAsyncRequestResult(RequestResult, Data), L"setasyncrequestresult"); } } else if (FZ_MSG_PARAM(wParam) == FZ_ASYNCREQUEST_VERIFYCERT) { int RequestResult; CVerifyCertRequestData * AData = (CVerifyCertRequestData *)lParam; try { DebugAssert(AData != NULL); TFtpsCertificateData Data; CopyContact(Data.Subject, AData->pCertData->subject); CopyContact(Data.Issuer, AData->pCertData->issuer); CopyValidityTime(Data.ValidFrom, AData->pCertData->validFrom); CopyValidityTime(Data.ValidUntil, AData->pCertData->validUntil); Data.SubjectAltName = AData->pCertData->subjectAltName; Data.Hash = AData->pCertData->hash; Data.Certificate = AData->pCertData->certificate; Data.CertificateLen = AData->pCertData->certificateLen; Data.VerificationResult = AData->pCertData->verificationResult; Data.VerificationDepth = AData->pCertData->verificationDepth; Result = HandleAsynchRequestVerifyCertificate(Data, RequestResult); } catch(...) { FFileZillaApi->SetAsyncRequestResult(0, AData); throw; } if (Result) { Result = Check(FFileZillaApi->SetAsyncRequestResult(RequestResult, AData), L"setasyncrequestresult"); } } else if (FZ_MSG_PARAM(wParam) == FZ_ASYNCREQUEST_NEEDPASS) { int RequestResult = 0; CNeedPassRequestData * AData = (CNeedPassRequestData *)lParam; try { TNeedPassRequestData Data; Data.Password = AData->Password.GetBuffer(AData->Password.GetLength()); Result = HandleAsynchRequestNeedPass(Data, RequestResult); AData->Password.ReleaseBuffer(AData->Password.GetLength()); if (Result && (RequestResult == TFileZillaIntf::REPLY_OK)) { AData->Password = Data.Password; free(Data.Password); Data.Password = NULL; } } catch(...) { FFileZillaApi->SetAsyncRequestResult(0, AData); throw; } if (Result) { Result = Check(FFileZillaApi->SetAsyncRequestResult(RequestResult, AData), L"setasyncrequestresult"); } } else { // FZ_ASYNCREQUEST_GSS_AUTHFAILED // FZ_ASYNCREQUEST_GSS_NEEDUSER // FZ_ASYNCREQUEST_GSS_NEEDPASS DebugFail(); Result = false; } break; case FZ_MSG_LISTDATA: { DebugAssert(FZ_MSG_PARAM(wParam) == 0); t_directory * Directory = (t_directory *)lParam; CString Path = Directory->path.GetPath(); std::vector<TListDataEntry> Entries(Directory->num); for (int Index = 0; Index < Directory->num; Index++) { t_directory::t_direntry & Source = Directory->direntry[Index]; TListDataEntry & Dest = Entries[Index]; Dest.Name = Source.name; Dest.Permissions = Source.permissionstr; Dest.HumanPerm = Source.humanpermstr; Dest.OwnerGroup = Source.ownergroup; Dest.Size = Source.size; Dest.Dir = Source.dir; Dest.Link = Source.bLink; CopyFileTime(Dest.Time, Source.date); Dest.LinkTarget = Source.linkTarget; } int Num = Directory->num; TListDataEntry * pEntries = Num > 0 ? &Entries[0] : NULL; Result = HandleListData(Path, pEntries, Num); delete Directory; } break; case FZ_MSG_TRANSFERSTATUS: { DebugAssert(FZ_MSG_PARAM(wParam) == 0); t_ffam_transferstatus * Status = (t_ffam_transferstatus *)lParam; if (Status != NULL) { Result = HandleTransferStatus( true, Status->transfersize, Status->bytes, Status->bFileTransfer); delete Status; } else { Result = HandleTransferStatus(false, -1, -1, false); } } break; case FZ_MSG_REPLY: Result = HandleReply(FZ_MSG_PARAM(wParam), lParam); break; case FZ_MSG_CAPABILITIES: Result = HandleCapabilities((TFTPServerCapabilities *)lParam); break; default: DebugFail(); Result = false; break; } return Result; }
char * get_ttymode(void * /*frontend*/, const char * /*mode*/) { // should never happen when Config.nopty == TRUE DebugFail(); return nullptr; }
void TestMemory::RecvMsg(const BaseMsg* msg, int connectionID) { DebugAssert(msg); TimeDelta replyTime = 0; BaseMsg* reply = NULL; switch(msg->Type()) { case(mt_Read): { readsReceived++; ReadMsg* rm = (ReadMsg*)msg; replyTime = readTime; ReadResponseMsg* m = EM().CreateReadResponseMsg(GetDeviceID(),msg->GeneratingPC()); m->addr = rm->addr; m->size = rm->size; m->blockAttached = true; m->directoryLookup = rm->directoryLookup; m->exclusiveOwnership = true; m->satisfied = true; m->solicitingMessage = rm->MsgID(); rm->SignalComplete(); reply = m; break; } case(mt_Write): { writesReceived++; WriteMsg* wm = (WriteMsg*)msg; replyTime = writeTime; WriteResponseMsg* m = EM().CreateWriteResponseMsg(GetDeviceID(),msg->GeneratingPC()); m->addr = wm->addr; m->size = wm->size; m->solicitingMessage = wm->MsgID(); wm->SignalComplete(); reply = m; break; } case(mt_Eviction): { evictionsReceived++; EvictionMsg* em = (EvictionMsg*)msg; EvictionResponseMsg* m = EM().CreateEvictionResponseMsg(GetDeviceID(),msg->GeneratingPC()); m->addr = em->addr; m->size = em->size; m->solicitingMessage = em->MsgID(); reply = m; break; } case(mt_Invalidate): { DebugFail("TestMemory::RecvMsg: Main memory being told to invalidate"); break; } case(mt_EvictionResponse): { DebugFail("TestMemory::RecvMsg: Main memory received eviction response message"); break; } case(mt_InvalidateResponse): { DebugFail("TestMemory::RecvMsg: Main memory received invalidate response message"); break; } case(mt_Network): { DebugFail("TestMemory::RecvMsg: Main memory received network message"); break; } case(mt_ReadResponse): { DebugFail("TestMemory::RecvMsg: Main memory received read response message"); break; } case(mt_WriteResponse): { DebugFail("TestMemory::RecvMsg: Main memory received write response message"); break; } default: { DebugFail("TestMemory::RecvMsg: Main memory received message with unknown message type"); break; } } // end switch(msg->Type()) if(reply) { DebugAssert(reply->IsResponse()); GetConnection(connectionID).SendMsg(reply,replyTime); } EM().DisposeMsg(msg); }
void agent_schedule_callback(void (* /*callback*/)(void *, void *, int), void * /*callback_ctx*/, void * /*data*/, int /*len*/) { DebugFail(); }
void ldisc_echoedit_update(void * /*handle*/) { DebugFail(); }