void UserInterface::DisplayVolumeProperties (const VolumeInfoList &volumes) const { if (volumes.size() < 1) throw_err (LangString["NO_VOLUMES_MOUNTED"]); wxString prop; foreach_ref (const VolumeInfo &volume, volumes) { prop << _("Slot") << L": " << StringConverter::FromNumber (volume.SlotNumber) << L'\n'; prop << LangString["VOLUME"] << L": " << wstring (volume.Path) << L'\n'; #ifndef TC_WINDOWS prop << LangString["VIRTUAL_DEVICE"] << L": " << wstring (volume.VirtualDevice) << L'\n'; #endif prop << LangString["MOUNT_POINT"] << L": " << wstring (volume.MountPoint) << L'\n'; prop << LangString["SIZE"] << L": " << SizeToString (volume.Size) << L'\n'; prop << LangString["TYPE"] << L": " << VolumeTypeToString (volume.Type, volume.Protection) << L'\n'; prop << LangString["READ_ONLY"] << L": " << LangString [volume.Protection == VolumeProtection::ReadOnly ? "UISTR_YES" : "UISTR_NO"] << L'\n'; wxString protection; if (volume.Type == VolumeType::Hidden) protection = LangString["NOT_APPLICABLE_OR_NOT_AVAILABLE"]; else if (volume.HiddenVolumeProtectionTriggered) protection = LangString["HID_VOL_DAMAGE_PREVENTED"]; else protection = LangString [volume.Protection == VolumeProtection::HiddenVolumeReadOnly ? "UISTR_YES" : "UISTR_NO"]; prop << LangString["HIDDEN_VOL_PROTECTION"] << L": " << protection << L'\n'; prop << LangString["ENCRYPTION_ALGORITHM"] << L": " << volume.EncryptionAlgorithmName << L'\n'; prop << LangString["KEY_SIZE"] << L": " << StringFormatter (L"{0} {1}", volume.EncryptionAlgorithmKeySize * 8, LangString ["BITS"]) << L'\n'; if (volume.EncryptionModeName == L"XTS") prop << LangString["SECONDARY_KEY_SIZE_XTS"] << L": " << StringFormatter (L"{0} {1}", volume.EncryptionAlgorithmKeySize * 8, LangString ["BITS"]) << L'\n';; wstringstream blockSize; blockSize << volume.EncryptionAlgorithmBlockSize * 8; if (volume.EncryptionAlgorithmBlockSize != volume.EncryptionAlgorithmMinBlockSize) blockSize << L"/" << volume.EncryptionAlgorithmMinBlockSize * 8; prop << LangString["BLOCK_SIZE"] << L": " << blockSize.str() + L" " + LangString ["BITS"] << L'\n'; prop << LangString["MODE_OF_OPERATION"] << L": " << volume.EncryptionModeName << L'\n'; prop << LangString["PKCS5_PRF"] << L": " << volume.Pkcs5PrfName << L'\n'; prop << LangString["VOLUME_FORMAT_VERSION"] << L": " << (volume.MinRequiredProgramVersion < 0x600 ? 1 : 2) << L'\n'; prop << LangString["BACKUP_HEADER"] << L": " << LangString[volume.MinRequiredProgramVersion >= 0x600 ? "UISTR_YES" : "UISTR_NO"] << L'\n'; #ifdef TC_LINUX if (string (volume.VirtualDevice).find ("/dev/mapper/truecrypt") != 0) { #endif prop << LangString["TOTAL_DATA_READ"] << L": " << SizeToString (volume.TotalDataRead) << L'\n'; prop << LangString["TOTAL_DATA_WRITTEN"] << L": " << SizeToString (volume.TotalDataWritten) << L'\n'; #ifdef TC_LINUX } #endif prop << L'\n'; }
VolumeSizeWizardPage::VolumeSizeWizardPage (wxPanel* parent, const VolumePath &volumePath, uint32 sectorSize, const wxString &freeSpaceText) : VolumeSizeWizardPageBase (parent), MaxVolumeSize (0), MaxVolumeSizeValid (false), MinVolumeSize (1), SectorSize (sectorSize) { VolumeSizePrefixChoice->Append (LangString["KB"], reinterpret_cast <void *> (1024)); VolumeSizePrefixChoice->Append (LangString["MB"], reinterpret_cast <void *> (1024 * 1024)); VolumeSizePrefixChoice->Append (LangString["GB"], reinterpret_cast <void *> (1024 * 1024 * 1024)); VolumeSizePrefixChoice->Select (Prefix::MB); wxLongLong diskSpace = 0; if (!wxGetDiskSpace (wxFileName (wstring (volumePath)).GetPath(), nullptr, &diskSpace)) { VolumeSizeTextCtrl->Disable(); VolumeSizeTextCtrl->SetValue (L""); } FreeSpaceStaticText->SetFont (Gui->GetDefaultBoldFont (this)); if (!freeSpaceText.empty()) { FreeSpaceStaticText->SetLabel (freeSpaceText); } else { #ifdef TC_WINDOWS wxString drive = wxFileName (wstring (volumePath)).GetVolume(); if (!drive.empty()) { FreeSpaceStaticText->SetLabel (StringFormatter (_("Free space on drive {0}: is {1}."), drive, Gui->SizeToString (diskSpace.GetValue()))); } else #endif { FreeSpaceStaticText->SetLabel (StringFormatter (_("Free space available: {0}"), Gui->SizeToString (diskSpace.GetValue()))); } } VolumeSizeTextCtrl->SetMinSize (wxSize (Gui->GetCharWidth (VolumeSizeTextCtrl) * 20, -1)); wxTextValidator validator (wxFILTER_INCLUDE_CHAR_LIST); // wxFILTER_NUMERIC does not exclude - . , etc. const wxChar *valArr[] = { L"0", L"1", L"2", L"3", L"4", L"5", L"6", L"7", L"8", L"9" }; validator.SetIncludes (wxArrayString (array_capacity (valArr), (const wxChar **) &valArr)); VolumeSizeTextCtrl->SetValidator (validator); }
std::string makeGpuIdString(const std::vector<int> &gpuIds, int totalNumberOfTasks) { auto resultGpuIds = makeGpuIds(gpuIds, totalNumberOfTasks); return formatAndJoin(resultGpuIds, ",", StringFormatter("%d")); }
void EncryptionTestDialog::OnEncryptionAlgorithmSelected () { shared_ptr <EncryptionAlgorithm> ea = GetSelectedEncryptionAlgorithm(); KeySizeStaticText->SetLabel (StringFormatter (L"{0} {1}", (uint32) ea->GetKeySize() * 8, LangString["BITS"])); Buffer key (ea->GetKeySize()); key.Zero(); SetTextCtrlData (KeyTextCtrl, key); SetTextCtrlData (SecondaryKeyTextCtrl, key); Buffer block (ea->GetMaxBlockSize()); block.Zero(); SetTextCtrlData (PlainTextTextCtrl, block); SetTextCtrlData (CipherTextTextCtrl, block); if (ea->GetCiphers().size() > 1) { XtsModeCheckBox->Disable(); XtsModeCheckBox->SetValue (true); SecondaryKeyTextCtrl->Enable (true); DataUnitNumberTextCtrl->Enable (true); BlockNumberTextCtrl->Enable (true); } else XtsModeCheckBox->Enable(); }
int main(int argc, char *argv[]){ if (argc != 2){ printf("usage: %s filename\n",argv[0]); } else{ FILE *file = fopen(argv[1],"r"); FILE *outfile = fopen("out.txt","w"); if(file == 0){ printf("Could not open file\n"); } else{ printf("Reading file"); char x; while( (x = fgetc(file)) != EOF ){ int i = 0; char Buffer[BigArray]; while( x !=';'){ Buffer[i] = x; printf("%c\n",Buffer[i]); if (x == '\n'){ continue; } i++; x = fgetc(file); } Buffer[i] = '\0'; char *form = StringFormatter(Buffer); char formattedString[BigArray]; for(int i =0; i<strlen(form);i++){ formattedString[i]=form[i]; } printf("%s\n",formattedString); char printArr[BigArray]; strcpy(printArr,formattedString); Node_t *tokenList = NULL; tokenList = tokenizer(formattedString); printList(tokenList); double mini_results = Parser(tokenList); printf("%s\n",printArr); fprintf(outfile, "%s %s %f\n", printArr, "=", mini_results); x = fgetc(file); } fclose(file); fclose(outfile); } } }
void EncryptionOptionsWizardPage::OnEncryptionAlgorithmSelected () { FreezeScope freeze (this); shared_ptr <EncryptionAlgorithm> ea = GetEncryptionAlgorithm(); CipherList ciphers = ea->GetCiphers(); if (ciphers.size() == 1) { EncryptionAlgorithmHyperlink->SetLabel (StringFormatter (LangString["MORE_INFO_ABOUT"], ea->GetName())); if (typeid (*ea) == typeid (AES)) EncryptionAlgorithmStaticText->SetLabel (LangString["AES_HELP"]); else if (typeid (*ea) == typeid (Serpent)) EncryptionAlgorithmStaticText->SetLabel (LangString["SERPENT_HELP"]); else if (typeid (*ea) == typeid (Twofish)) EncryptionAlgorithmStaticText->SetLabel (LangString["TWOFISH_HELP"]); else EncryptionAlgorithmStaticText->SetLabel (L""); } else { if (ciphers.size() == 2) { EncryptionAlgorithmStaticText->SetLabel (StringFormatter (LangString["TWO_LAYER_CASCADE_HELP"], ciphers[0]->GetName(), (int) ciphers[0]->GetKeySize() * 8, ciphers[1]->GetName(), (int) ciphers[1]->GetKeySize() * 8)); } else if (ciphers.size() == 3) { EncryptionAlgorithmStaticText->SetLabel (StringFormatter (LangString["THREE_LAYER_CASCADE_HELP"], ciphers[0]->GetName(), (int) ciphers[0]->GetKeySize() * 8, ciphers[1]->GetName(), (int) ciphers[1]->GetKeySize() * 8, ciphers[2]->GetName(), (int) ciphers[2]->GetKeySize() * 8)); } else EncryptionAlgorithmStaticText->SetLabel (L""); EncryptionAlgorithmHyperlink->SetLabel (_("More information")); } Layout(); }
MountOptionsDialog::MountOptionsDialog (wxWindow *parent, MountOptions &options, const wxString &title, bool disableMountOptions) : MountOptionsDialogBase (parent, wxID_ANY, wxString() #ifdef __WXGTK__ // GTK apparently needs wxRESIZE_BORDER to support dynamic resizing , wxDefaultPosition, wxSize (-1,-1), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER #endif ), Options (options) { if (!title.empty()) this->SetTitle (title); else if (options.Path && !options.Path->IsEmpty()) this->SetTitle (StringFormatter (LangString["ENTER_PASSWORD_FOR"], wstring (*options.Path))); else this->SetTitle (LangString["ENTER_TC_VOL_PASSWORD"]); if (disableMountOptions) OptionsButton->Show (false); PasswordPanel = new VolumePasswordPanel (this, &options, options.Password, disableMountOptions, options.Keyfiles, !disableMountOptions, true, true, false, true, true); PasswordPanel->SetCacheCheckBoxValidator (wxGenericValidator (&Options.CachePassword)); PasswordSizer->Add (PasswordPanel, 1, wxALL | wxEXPAND); #ifdef __WXGTK__ FilesystemOptionsSizer->Remove (FilesystemSpacer); OptionsPanel->Show (false); Fit(); Layout(); SetMinSize (GetSize()); #endif NoFilesystemCheckBox->SetValidator (wxGenericValidator (&Options.NoFilesystem)); RemovableCheckBox->SetValidator (wxGenericValidator (&Options.Removable)); PartitionInSystemEncryptionScopeCheckBox->SetValidator (wxGenericValidator (&Options.PartitionInSystemEncryptionScope)); TransferDataToWindow(); if (Options.MountPoint && !Options.MountPoint->IsEmpty()) MountPointTextCtrl->SetValue (wstring (*Options.MountPoint)); FilesystemOptionsTextCtrl->SetValue (Options.FilesystemOptions); ReadOnlyCheckBox->SetValue (Options.Protection == VolumeProtection::ReadOnly); ProtectionCheckBox->SetValue (Options.Protection == VolumeProtection::HiddenVolumeReadOnly); OptionsButtonLabel = OptionsButton->GetLabel(); OptionsButton->SetLabel (OptionsButtonLabel + L" >"); OptionsPanel->Show (false); ProtectionPasswordPanel = new VolumePasswordPanel (OptionsPanel, &options, options.ProtectionPassword, true, options.ProtectionKeyfiles, false, true, true, false, true, true, _("P&assword to hidden volume:")); ProtectionPasswordSizer->Add (ProtectionPasswordPanel, 1, wxALL | wxEXPAND); UpdateDialog(); Center(); }
VolumePropertiesDialog::VolumePropertiesDialog (wxWindow* parent, const VolumeInfo &volumeInfo) : VolumePropertiesDialogBase (parent) { list <int> colPermilles; PropertiesListCtrl->InsertColumn (0, LangString["PROPERTY"], wxLIST_FORMAT_LEFT, 208); colPermilles.push_back (500); PropertiesListCtrl->InsertColumn (1, LangString["VALUE"], wxLIST_FORMAT_LEFT, 192); colPermilles.push_back (500); Gui->SetListCtrlWidth (PropertiesListCtrl, 70, false); Gui->SetListCtrlHeight (PropertiesListCtrl, 17); Gui->SetListCtrlColumnWidths (PropertiesListCtrl, colPermilles, false); AppendToList ("LOCATION", wstring (volumeInfo.Path)); #ifndef TC_WINDOWS AppendToList ("VIRTUAL_DEVICE", wstring (volumeInfo.VirtualDevice)); #endif AppendToList ("SIZE", Gui->SizeToString (volumeInfo.Size)); AppendToList ("TYPE", Gui->VolumeTypeToString (volumeInfo.Type, volumeInfo.TrueCryptMode, volumeInfo.Protection)); AppendToList ("READ_ONLY", LangString [volumeInfo.Protection == VolumeProtection::ReadOnly ? "UISTR_YES" : "UISTR_NO"]); wxString protection; if (volumeInfo.Type == VolumeType::Hidden) protection = LangString["NOT_APPLICABLE_OR_NOT_AVAILABLE"]; else if (volumeInfo.HiddenVolumeProtectionTriggered) protection = LangString["HID_VOL_DAMAGE_PREVENTED"]; else protection = LangString [volumeInfo.Protection == VolumeProtection::HiddenVolumeReadOnly ? "UISTR_YES" : "UISTR_NO"]; AppendToList ("HIDDEN_VOL_PROTECTION", protection); AppendToList ("ENCRYPTION_ALGORITHM", volumeInfo.EncryptionAlgorithmName); AppendToList ("KEY_SIZE", StringFormatter (L"{0} {1}", volumeInfo.EncryptionAlgorithmKeySize * 8, LangString ["BITS"])); if (volumeInfo.EncryptionModeName == L"XTS") AppendToList ("SECONDARY_KEY_SIZE_XTS", StringFormatter (L"{0} {1}", volumeInfo.EncryptionAlgorithmKeySize * 8, LangString ["BITS"])); wstringstream blockSize; blockSize << volumeInfo.EncryptionAlgorithmBlockSize * 8; if (volumeInfo.EncryptionAlgorithmBlockSize != volumeInfo.EncryptionAlgorithmMinBlockSize) blockSize << L"/" << volumeInfo.EncryptionAlgorithmMinBlockSize * 8; AppendToList ("BLOCK_SIZE", blockSize.str() + L" " + LangString ["BITS"]); AppendToList ("MODE_OF_OPERATION", volumeInfo.EncryptionModeName); if (volumeInfo.Pim <= 0) AppendToList ("PKCS5_PRF", volumeInfo.Pkcs5PrfName); else AppendToList ("PKCS5_PRF", StringFormatter (L"{0} (Dynamic)", volumeInfo.Pkcs5PrfName)); #if 0 AppendToList ("PKCS5_ITERATIONS", StringConverter::FromNumber (volumeInfo.Pkcs5IterationCount)); AppendToList ("VOLUME_CREATE_DATE", Gui->VolumeTimeToString (volumeInfo.VolumeCreationTime)); AppendToList ("VOLUME_HEADER_DATE", Gui->VolumeTimeToString (volumeInfo.HeaderCreationTime)); #endif AppendToList ("VOLUME_FORMAT_VERSION", StringConverter::ToWide (volumeInfo.MinRequiredProgramVersion < 0x10b ? 1 : 2)); AppendToList ("BACKUP_HEADER", LangString[volumeInfo.MinRequiredProgramVersion >= 0x10b ? "UISTR_YES" : "UISTR_NO"]); #ifdef TC_LINUX if (string (volumeInfo.VirtualDevice).find ("/dev/mapper/veracrypt") != 0) { #endif AppendToList ("TOTAL_DATA_READ", Gui->SizeToString (volumeInfo.TotalDataRead)); AppendToList ("TOTAL_DATA_WRITTEN", Gui->SizeToString (volumeInfo.TotalDataWritten)); #ifdef TC_LINUX } #endif Layout(); Fit(); Center(); StdButtonsOK->SetDefault(); }
void UserInterface::DismountVolumes (VolumeInfoList volumes, bool ignoreOpenFiles, bool interactive) const { BusyScope busy (this); volumes.sort (VolumeInfo::FirstVolumeMountedAfterSecond); wxString message; bool twoPassMode = volumes.size() > 1; bool volumesInUse = false; bool firstPass = true; #ifdef TC_WINDOWS if (Preferences.CloseExplorerWindowsOnDismount) { foreach (shared_ptr <VolumeInfo> volume, volumes) CloseExplorerWindows (volume); } #endif while (!volumes.empty()) { VolumeInfoList volumesLeft; foreach (shared_ptr <VolumeInfo> volume, volumes) { try { BusyScope busy (this); volume = Core->DismountVolume (volume, ignoreOpenFiles); } catch (MountedVolumeInUse&) { if (!firstPass) throw; if (twoPassMode || !interactive) { volumesInUse = true; volumesLeft.push_back (volume); continue; } else { if (AskYesNo (StringFormatter (LangString["UNMOUNT_LOCK_FAILED"], wstring (volume->Path)), true, true)) { BusyScope busy (this); volume = Core->DismountVolume (volume, true); } else throw UserAbort (SRC_POS); } } catch (...) { if (twoPassMode && firstPass) volumesLeft.push_back (volume); else throw; } if (volume->HiddenVolumeProtectionTriggered) ShowWarning (StringFormatter (LangString["DAMAGE_TO_HIDDEN_VOLUME_PREVENTED"], wstring (volume->Path))); if (Preferences.Verbose) { if (!message.IsEmpty()) message += L'\n'; message += StringFormatter (_("Volume \"{0}\" has been dismounted."), wstring (volume->Path)); } } if (twoPassMode && firstPass) { volumes = volumesLeft; if (volumesInUse && interactive) { if (AskYesNo (LangString["UNMOUNTALL_LOCK_FAILED"], true, true)) ignoreOpenFiles = true; else throw UserAbort (SRC_POS); } } else break; firstPass = false; } if (Preferences.Verbose && !message.IsEmpty()) ShowInfo (message); }
String Value::format() const { return StringFormatter().toString(*this); }