/* decrypt path */ int decrypt(const char *path) { /* validate path argument */ switch(validation(path, TYPE_ARGUMENT)) { case ARG_DIR: if (is_mounted(path)) { return 1; } if (!(directory_is_encrypted(path))) { printf("%s: %s: directory %s is not encrypted\n", NAME, "ERROR", path); return 1; } decrypt_directory(path); break; case ARG_PART: printf("%s: %s: decrypt partition %s is not implemented yet\n", NAME, "TODO", path); break; case ARG_DISK: printf("%s: %s: decrypt disk %s is not implemented yet\n", NAME, "TODO", path); break; default: printf("%s: %s: file type of %s doesn't support\n", NAME, "ERROR", path); break; } /* exit */ return 0; }
/** * Constructeur. * Construit l'interface du widget */ Selecteur::Selecteur(QWidget *parent) : QDialog(parent) { setWindowTitle(tr("Entrez les détails du héros")); //On construit tout d'abord le layout QVBoxLayout *layout = new QVBoxLayout; setLayout(layout); QLabel *label = new QLabel(tr("Entrez les détails du héros")); layout->addWidget(label); QFormLayout *form = new QFormLayout; layout->addLayout(form); //On crée et on ajoute les widget du nom et du prenom _nom = new QLineEdit; _prenom = new QLineEdit; form->addRow(tr("Prénom:"),_prenom); form->addRow(tr("Nom:"),_nom); _age = new QSpinBox; form->addRow(tr("Age:"),_age); //On ajoute le bouton valider _valider = new QPushButton(tr("Valider")); layout->addWidget(_valider); connect(_valider,SIGNAL(clicked()),this,SLOT(validation())); }
// Handle client connection void* client_handler(void *arg) { int fd = *((int*)arg); // User validation validation(fd); int str_len; char message[BUFFER_SIZE] = {0,}; while((str_len = read(fd, message, BUFFER_SIZE-1)) != 0) SendMessage(message, str_len, fd); // Run when disconnect pthread_mutex_lock(&mutex); for(int i = 0; i < client_num; ++i) { if(socks[i] == fd) { while(i < client_num-1) { socks[i] = socks[i+1]; ++i; } break; } } --client_num; pthread_mutex_unlock(&mutex); close(fd); return NULL; }
AjoutCategorie::AjoutCategorie(QWidget *parent) : QDialog(parent), ui(new Ui::AjoutCategorie) { ui->setupUi(this); connect( ui->boutonAnnuler, SIGNAL(clicked()), this, SLOT(close()) ); connect( ui->boutonOK, SIGNAL(clicked()), this, SLOT(validation()) ); connect( ui->pushButton, SIGNAL(clicked()), this, SLOT( parcourir() ) ); }
int main() { struct date d; int N; printf("Enter a date: "); scanf("%d-%d-%d", &d.year, &d.month, &d.day); if (!validation(d)) { printf("\nInvalid date"); return 0; } printf("\nThe Year: %d", currentYear(d)); printf("\nThe Previous year: %d", previousYear(d)); printf("\nThe Month In Number: %d", monthinnumber(d)); printf("\nThe Month name: %s", monthName(d)); printf("\nThe Previous month: %s", prevMonthName(d)); printf("\nThe Day in Number: %d", currentDay(d)); printf("\nThe Day name: %s", dayOfWeek(d)); printf("\nThe Day index of the year: %d", dayIndex(d)); printf("\nEnter value for N: "); scanf("%d", &N); if (N < 0) { return 0; } struct date before = dateBeforeNDays(d, N); printf("\nDate before N days: %04d-%02d-%02d", before.year, before.month, before.day); printf("\n\nDAYS BETWEEN DATES: "); printf("\nEnter another date: "); struct date d1; scanf("%d-%d-%d", &d1.year, &d1.month, &d1.day); if (!validation(d1)) { printf("\nInvalid date"); return 0; } printf("\nDifference in dates between 2 dates: %d days", daysBetweenDates(d, d1)); printf("\n"); return 0; }
void WorksheetTest::testWriteDataValidations() { QXlsx::Worksheet sheet("", 1, 0); QXlsx::DataValidation validation(QXlsx::DataValidation::Whole); validation.setFormula1("10"); validation.setFormula2("100"); validation.addCell("A1"); validation.addCell("C2:C4"); sheet.addDataValidation(validation); QByteArray xmldata = sheet.saveToXmlData(); QVERIFY(xmldata.contains("<dataValidation type=\"whole\" showInputMessage=\"1\" showErrorMessage=\"1\" sqref=\"A1 C2:C4\"><formula1>10</formula1><formula2>100</formula2></dataValidation>")); }
FenetreSetDette::FenetreSetDette(int index, QWidget *parent) : QDialog(parent), ui(new Ui::FenetreSetDette) { ui->setupUi(this); client = CGestionBDD::getClient( index ); ancienneValeur = client.getDette(); ui->doubleSpinBox->setValue( ancienneValeur ); ui->doubleSpinBox->setFocus(); connect( ui->boutonOK, SIGNAL(clicked()), this, SLOT( validation() ) ); connect( ui->boutonAnnuler, SIGNAL(clicked()), this, SLOT(close() ) ); }
void MainWindow::on_NImages_Input_editingFinished() { QRegExp validation("\\d*"); if (validation.exactMatch(ui->NImages_Input->text())) { NImage=ui->NImages_Input->text(); QString url = "http://10.0.27.67/cgi-bin/omr.cgi?opmode=7&aqcount="; url.append(NImage+"&write"); nam->get(QNetworkRequest(QUrl(url))); } else { ui->textBrowser->setText("Invalid Value Dude!!!<br/>from 1 to 100 please!!!"); ui->NImages_Input->setText(NImage); } }
void MainWindow::on_TH7_Input_editingFinished() { QRegExp validation("\\d*"); if (validation.exactMatch(ui->TH7_Input->text())) { th7=ui->TH7_Input->text().rightJustified(3,'0'); QString url = "http://10.0.27.67/cgi-bin/dacs.cgi?&threshold_7="; url.append(th7+"&write"); nam->get(QNetworkRequest(QUrl(url))); } else { ui->textBrowser->setText("Invalid Value Dude!!!<br/>from 0 to 511 please!!!"); ui->TH7_Input->setText(th7); } }
void MainWindow::on_IPREAMP_Input_editingFinished() { QRegExp validation("\\d*"); if (validation.exactMatch(ui->IPREAMP_Input->text())) { preamp=ui->IPREAMP_Input->text().rightJustified(3,'0'); QString url = "http://10.0.27.67/cgi-bin/dacs.cgi?&preamp="; url.append(preamp+"&write"); nam->get(QNetworkRequest(QUrl(url))); } else { ui->textBrowser->setText("Invalid Value Dude!!!<br/>from 0 to 255 please!!!"); ui->IPREAMP_Input->setText(preamp); } }
bool nano::uint256_union::decode_account (std::string const & source_a) { auto error (source_a.size () < 5); if (!error) { auto xrb_prefix (source_a[0] == 'x' && source_a[1] == 'r' && source_a[2] == 'b' && (source_a[3] == '_' || source_a[3] == '-')); auto nano_prefix (source_a[0] == 'n' && source_a[1] == 'a' && source_a[2] == 'n' && source_a[3] == 'o' && (source_a[4] == '_' || source_a[4] == '-')); error = (xrb_prefix && source_a.size () != 64) || (nano_prefix && source_a.size () != 65); if (!error) { if (xrb_prefix || nano_prefix) { auto i (source_a.begin () + (xrb_prefix ? 4 : 5)); if (*i == '1' || *i == '3') { nano::uint512_t number_l; for (auto j (source_a.end ()); !error && i != j; ++i) { uint8_t character (*i); error = character < 0x30 || character >= 0x80; if (!error) { uint8_t byte (account_decode (character)); error = byte == '~'; if (!error) { number_l <<= 5; number_l += byte; } } } if (!error) { *this = (number_l >> 40).convert_to<nano::uint256_t> (); uint64_t check (number_l & static_cast<uint64_t> (0xffffffffff)); uint64_t validation (0); blake2b_state hash; blake2b_init (&hash, 5); blake2b_update (&hash, bytes.data (), bytes.size ()); blake2b_final (&hash, reinterpret_cast<uint8_t *> (&validation), 5); error = check != validation; } }
void Cholesky<Matrix>::doCompute( const Matrix& mat ) { if (!validation(mat)) { std::cerr<<"Warning in cholesky solver: the input matrix is not symmetric. Please confirm that!"<<std::endl; return; } clear(); __a = new scalar[mat.size()]; this->setRowNum(mat.rows()); this->setColNum(mat.cols()); this->setLDA(mat.lda()); blas::copt_blas_copy(mat.size(),mat.dataPtr(),1,__a,1); copt_lapack_potrf('U',this->rowNum(),__a,this->lda(),&__info); if( __info != 0 ) { std::cout<<__info<<std::endl; std::cerr<<"Warning in Cholesky solver: something computation is wrong!"<<std::endl; } }
int ParamDialog(tParam *p, tComplex *c){ //if failure: 0 //else 1 DisplayParam(p, c); printf("Sollen Parameter geändert werden?\n(j) Ja, bitte.\n(n) Nein, danke.\n(e) Programm beenden!"); switch (InputChar()){ case 'j': do { ChangeParam(p, c); //Vllt sollte man eine maxAnzahl an Versuchen in Erwähgung ziehen? } while(validation(p,c) == 0); //Schleife wird erst verlassen, wenn Werte Sinn machen. return 1; break; case 'n': return 1; break; case 'e': return 0; break; } return 0; }
// date in english function void dateEnglish(char* date) { // for numbers from 1 to 19 char *digit[] = { "", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen" }; // all tens char *tens[] = { "", "", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety" }; int day = (date[0] - '0') * 10 + (date[1] - '0'); int month = (date[3] - '0') * 10 + (date[4] - '0'); int year = (date[6] - '0') * 1000 + (date[7] - '0') * 100 + ((date[8] - '0') * 10 + date[9] - '0'); if (validation(day,month,year)) { days(day, digit, tens); months(month); printf(" of "); years(year, digit, tens); } else printf("Its not a valid date"); }
bool isValidBST(TreeNode *root) { // Start typing your C/C++ solution below // DO NOT write int main() function return validation(root, INT_MIN, INT_MAX); }
int main(int argc, char *argv[]) { ApplicationsLib::LogogSetup logog_setup; TCLAP::CmdLine cmd( "Checks mesh properties.\n\n" "OpenGeoSys-6 software, version " + BaseLib::BuildInfo::ogs_version + ".\n" "Copyright (c) 2012-2019, OpenGeoSys Community " "(http://www.opengeosys.org)", ' ', BaseLib::BuildInfo::ogs_version); TCLAP::UnlabeledValueArg<std::string> mesh_arg("mesh-file","input mesh file",true,"","string"); cmd.add( mesh_arg ); TCLAP::SwitchArg valid_arg("v","validation","validate the mesh"); cmd.add( valid_arg ); TCLAP::SwitchArg print_properties_arg("p","print_properties","print properties stored in the mesh"); cmd.add( print_properties_arg ); cmd.parse( argc, argv ); // read the mesh file BaseLib::MemWatch mem_watch; const unsigned long mem_without_mesh (mem_watch.getVirtMemUsage()); BaseLib::RunTime run_time; run_time.start(); std::unique_ptr<MeshLib::Mesh> mesh( MeshLib::IO::readMeshFromFile(mesh_arg.getValue())); if (!mesh) { return EXIT_FAILURE; } const unsigned long mem_with_mesh (mem_watch.getVirtMemUsage()); if (mem_with_mesh>0) { INFO ("Memory size: %i MB", (mem_with_mesh - mem_without_mesh)/(1024*1024)); (void)mem_with_mesh; } INFO ("Time for reading: %g s", run_time.elapsed()); // Geometric information const GeoLib::AABB aabb(MeshLib::MeshInformation::getBoundingBox(*mesh)); auto minPt(aabb.getMinPoint()); auto maxPt(aabb.getMaxPoint()); INFO("Node coordinates:"); INFO("\tx [%g, %g] (extent %g)", minPt[0], maxPt[0], maxPt[0]-minPt[0]); INFO("\ty [%g, %g] (extent %g)", minPt[1], maxPt[1], maxPt[1]-minPt[1]); INFO("\tz [%g, %g] (extent %g)", minPt[2], maxPt[2], maxPt[2]-minPt[2]); INFO("Edge length: [%g, %g]", mesh->getMinEdgeLength(), mesh->getMaxEdgeLength()); // Element information const std::array<unsigned, 7> nr_ele_types(MeshLib::MeshInformation::getNumberOfElementTypes(*mesh)); INFO("Element types:"); unsigned etype = 0; if (nr_ele_types[etype] > 0) { INFO("\t%d lines", nr_ele_types[etype]); } if (nr_ele_types[++etype] > 0) { INFO("\t%d triangles", nr_ele_types[etype]); } if (nr_ele_types[++etype] > 0) { INFO("\t%d quads", nr_ele_types[etype]); } if (nr_ele_types[++etype] > 0) { INFO("\t%d tetrahedra", nr_ele_types[etype]); } if (nr_ele_types[++etype] > 0) { INFO("\t%d hexahedra", nr_ele_types[etype]); } if (nr_ele_types[++etype] > 0) { INFO("\t%d pyramids", nr_ele_types[etype]); } if (nr_ele_types[++etype] > 0) { INFO("\t%d prisms", nr_ele_types[etype]); } std::vector<std::string> const& vec_names (mesh->getProperties().getPropertyVectorNames()); INFO("There are %d properties in the mesh:", vec_names.size()); for (const auto & vec_name : vec_names) { auto vec_bounds (MeshLib::MeshInformation::getValueBounds<int>(*mesh, vec_name)); if (vec_bounds.second != std::numeric_limits<int>::max()) { INFO("\t%s: [%d, %d]", vec_name.c_str(), vec_bounds.first, vec_bounds.second); } else { auto vec_bounds (MeshLib::MeshInformation::getValueBounds<double>(*mesh, vec_name)); if (vec_bounds.second != std::numeric_limits<double>::max()) { INFO("\t%s: [%g, %g]", vec_name.c_str(), vec_bounds.first, vec_bounds.second); } else { INFO("\t%s: Unknown properties", vec_name.c_str()); } } } if (valid_arg.isSet()) { // MeshValidation outputs error messages // Remark: MeshValidation can modify the original mesh MeshLib::MeshValidation validation(*mesh); unsigned const n_holes (MeshLib::MeshValidation::detectHoles(*mesh)); if (n_holes > 0) { INFO("%d hole(s) detected within the mesh", n_holes); } else { INFO ("No holes found within the mesh."); } } }
void Key::set( const std::string &k ) { this->append( k ); validation(); }
void Key::set( const char *k, const size_t len ) { this->append( k, len ); validation(); }
Key::Key( const std::string &k ): std::string(k), hashCalc(false), _hash(0) { validation(); }
bool validation(TreeNode *node, int left, int right) { if(!node) return true; return (node->val > left) && (node->val < right) && validation(node->left, left, node->val) && validation(node->right, node->val, right); // node->val is greater than left, smaller than right. then recurse left and right, just a DLR }
/*! * \brief Slot für OK-Button */ void HardwareKonfiguration::on_okButton_released(){ // Validierung if(!validation()) return; // Speichern der Informationen in eine config.ini file QString fileName = QFileDialog::getSaveFileName(this, tr("Speichere konfiguration"), "config.ini", tr("Configurations Datei (*.ini)")); // relevante Daten aus der Datenbank lesen QSqlQuery query; QStringList list; QString sql = "SELECT funktion, sim_pin, sim_puk, sms_center, wapapn, server_ip, " "server_port, gprs_username, gprs_pwd, ftp_server, " "ftp_username, ftp_pwd FROM stationen WHERE StationenKey='" + QString::number(ui.stationComboBox->currentIndex()+1) + "'"; qDebug() << sql; query.exec(sql); query.next(); funktion=query.value(0).toString(); for(int i=1;i<=11;++i) list.append(query.value(i).toString()); // Konfiguration in Datei speichern if(!fileName.isEmpty()){ QFile file(fileName); if(!file.open(QIODevice::WriteOnly)){ QMessageBox::warning(this, tr("Exportieren nach CSV"), tr("Kann die Datei %1 nicht schreiben;\n%2") .arg(file.fileName()).arg(file.errorString())); return; } QTextStream out(&file); // Daten in Datei schreiben QStringList timechange = getSommertime(); if(funktion.compare("start")==0){ out << "STARTorFINISH=0" << "\r\n"; }else{ out << "STARTorFINISH=1" << "\r\n"; } out << "WINTERTIME_DAY=" << timechange.at(1) << "\r\n"; out << "SUMMERTIME_DAY=" << timechange.at(0) << "\r\n"; out << "SIM_PIN=" << list.at(0) << "\r\n"; out << "SIM_PUK=" << list.at(1) << "\r\n"; out << "SMS_NR=" << ui.smsLineEdit->text() << "\r\n"; out << "SMS_CENTER=" << list.at(2) << "\r\n"; out << "WAPAPN=" << list.at(3) << "\r\n"; out << "SERVER_IP=" << list.at(4) << "\r\n"; out << "SERVER_PORT=" << list.at(5) << "\r\n"; out << "GPRS_USERNAME="******"\r\n"; out << "GPRS_PWD=" << list.at(7) << "\r\n"; out << "FTP_SERVER=" << list.at(8) << "\r\n"; out << "FTP_USERNAME="******"\r\n"; out << "FTP_PWD=" << list.at(10) << "\r\n"; out << "GOODNIGHT_TIME=" << ui.ausSpinBox->value() << "\r\n"; out << "WAKEUP_TIME=" << ui.einSpinBox->value() << "\r\n"; if(ui.gprsCheckBox->isChecked()) out << "USE_GPRS=1" << "\r\n"; else out << "USE_GPRS=0" << "\r\n"; QStringList strecken = getSelectedRennen(); qDebug() << strecken.count(); out << "STRECKENKEY_1=" << strecken.at(0) << "\r\n"; out << "STRECKENSTRING_1=" << strecken.at(1) << "\r\n"; if(strecken.count()>2){ out << "STRECKENKEY_2=" << strecken.at(2) << "\r\n"; out << "STRECKENSTRING_2=" << strecken.at(3) << "\r\n"; }else{ out << "STRECKENKEY_2=0" << "\r\n"; out << "STRECKENSTRING_2=0" << "\r\n"; } if(strecken.count()>4){ out << "STRECKENKEY_3=" << strecken.at(4) << "\r\n"; out << "STRECKENSTRING_3=" << strecken.at(5) << "\r\n"; }else{ out << "STRECKENKEY_3=0" << "\r\n"; out << "STRECKENSTRING_3=0" << "\r\n"; } file.flush(); file.close(); } this->close(); }
int main(int argc, char **argv){ /* char *testFolder; if(argc > 1){ testFolder = argv[1]; }else{ testFolder = TEST_FOLDER; } */ std::vector<cv::Mat> type1s; std::vector<cv::Mat> type2s; std::vector<std::string> listFile; //read images of type 1 in folder and get list descriptors listFile = IO::getFilesInFolder(TYPE1_FOLDER); std::random_shuffle(listFile.begin(), listFile.end()); for(unsigned int i = 0; i < listFile.size(); i++){ std::string fileName = TYPE1_FOLDER + listFile[i]; cv::Mat image = cv::imread(fileName, CV_LOAD_IMAGE_GRAYSCALE); //cv::threshold(image, image, THRESHOLD_GRAY_LEVEL, 255, CV_THRESH_TRUNC); //cv::GaussianBlur(image, image, cv::Size(3, 3), 0, 0, cv::BORDER_DEFAULT); type1s.push_back(Utils::getHeader(image, RATIO)); } std::vector<std::string> listFile2 = IO::getFilesInFolder(TYPE2_FOLDER); std::random_shuffle(listFile2.begin(), listFile2.end()); for(unsigned int i = 0; i < listFile2.size(); i++){ std::string fileName = TYPE2_FOLDER + listFile2[i]; cv::Mat image = cv::imread(fileName, CV_LOAD_IMAGE_GRAYSCALE); // cv::GaussianBlur(image, image, cv::Size(3, 3), 0, 0, cv::BORDER_DEFAULT); type2s.push_back(Utils::getHeader(image, RATIO)); } std::vector<cv::Mat> others; std::vector<std::string> listFileAutre = IO::getFilesInFolder(AUTRE_FOLDER); std::random_shuffle(listFileAutre.begin(), listFileAutre.end()); for(unsigned int i = 0; i < listFileAutre.size(); i++){ std::string fileName = AUTRE_FOLDER + listFileAutre[i]; cv::Mat image = cv::imread(fileName, CV_LOAD_IMAGE_GRAYSCALE); //cv::GaussianBlur(image, image, cv::Size(3, 3), 0, 0, cv::BORDER_DEFAULT); others.push_back(Utils::getHeader(image, RATIO)); } //shuffle vectors //std::random_shuffle(type1s.begin(), type1s.end()); //std::random_shuffle(type2s.begin(), type2s.end()); //std::random_shuffle(others.begin(), others.end()); unsigned int s1 = type1s.size()/3; unsigned int s2 = type2s.size()/3; unsigned int s3 = others.size()/3; for(int i = 0; i < 3; i++){ if(i != 2){ std::vector<cv::Mat> validation(type1s.begin() + s1 * i, type1s.begin() + s1 * (i + 1) ); std::vector<cv::Mat> type1Train(type1s); type1Train.erase(type1Train.begin() + s1 * i, type1Train.begin() + s1 * (i + 1)); std::vector<std::string> validationFileNames(listFile.begin() + s1 * i, listFile.begin() + s1 * (i + 1) ); validation.insert(validation.end(), type2s.begin() + s2 * i, type2s.begin() + s2 * (i + 1) ); std::vector<cv::Mat> type2Train(type2s); type2Train.erase(type2Train.begin() + s2 * i, type2Train.begin() + s2 * (i + 1)); validationFileNames.insert(validationFileNames.end(), listFile2.begin() + s2 * i, listFile2.begin() + s2 * (i + 1)); validation.insert(validation.end(), others.begin() + s3 * i, others.begin() + s3 * (i + 1) ); std::vector<cv::Mat> type3Train(others); type3Train.erase(type3Train.begin() + s3 * i, type3Train.begin() + s3 * (i + 1)); validationFileNames.insert(validationFileNames.end(), listFileAutre.begin() + s3 * i, listFileAutre.begin() + s3 * (i + 1)); //debug(validation.size()); //debug(validationFileNames.size()); //debug(type1Train.size()); //debug(type2Train.size()); experiment(type1Train, type2Train, type3Train, validation, validationFileNames); }else{ std::vector<cv::Mat> validation(type1s.begin() + s1 * i, type1s.end() ); std::vector<cv::Mat> type1Train(type1s); type1Train.erase(type1Train.begin() + s1 * i, type1Train.end()); std::vector<std::string> validationFileNames (listFile.begin() + s1 * i, listFile.end() ); validation.insert(validation.end(), type2s.begin() + s2 * i, type2s.end() ); std::vector<cv::Mat> type2Train(type2s); type2Train.erase(type2Train.begin() + s2 * i, type2Train.end()); validationFileNames.insert(validationFileNames.end(), listFile2.begin() + s2 * i, listFile2.end()); validation.insert(validation.end(), others.begin() + s3 * i, others.end() ); std::vector<cv::Mat> type3Train(others); type3Train.erase(type3Train.begin() + s3 * i, type3Train.end()); validationFileNames.insert(validationFileNames.end(), listFileAutre.begin() + s3 * i, listFileAutre.end()); experiment(type1Train, type2Train, type3Train, validation, validationFileNames); } } return 0; }