static void test_read(LSMDB_env *const env) { LSMDB_txn *txn; chk( lsmdb_txn_begin(env, NULL, MDB_RDONLY, &txn) ); LSMDB_cursor *cursor; chk( lsmdb_cursor_open(txn, &cursor) ); for(int i = 0; i < WRITES; ++i) { MDB_val key, data; chk( lsmdb_cursor_next(cursor, &key, &data, +1) ); assert(KEY_SIZE == key.mv_size); chkkey(key.mv_data); assert(DATA_SIZE == data.mv_size); } lsmdb_txn_abort(txn); }
DialogDIR::DialogDIR(QWidget *parent) { setupUi(this); // this sets up GUI connect( bt_save, SIGNAL( clicked() ), this, SLOT( folder_dir_path_einlesen() ) ); connect( chk_path, SIGNAL( clicked() ), this, SLOT( treeview_show() ) ); connect( bt_end, SIGNAL( clicked() ), this, SLOT(close())); connect( chk_key, SIGNAL( clicked() ), this, SLOT(chkkey())); connect( pushButton_break, SIGNAL( clicked() ), this, SLOT( esc_end() ) ); connect( chk_hidden, SIGNAL( clicked() ), this, SLOT(chkhidden())); timer = new QTimer(this); dirModel = new QFileSystemModel; selModel = new QItemSelectionModel(dirModel); dirModel1 = new QFileSystemModel; selModel1 = new QItemSelectionModel(dirModel1); QModelIndex cwdIndex = dirModel->index(QDir::rootPath()); dirModel->setRootPath(QDir::rootPath()); treeView_dir->setModel(dirModel); treeView_dir->setSelectionModel(selModel); treeView_dir->setRootIndex(cwdIndex); QModelIndex cwdIndex1 = dirModel1->index(QDir::rootPath()); dirModel1->setRootPath(QDir::rootPath()); treeView_path->setModel(dirModel1); treeView_path->setSelectionModel(selModel1); treeView_path->setRootIndex(cwdIndex1); /* QFileSystemModel *model = new QFileSystemModel; QItemSelectionModel *selModel = new QItemSelectionModel(model); // oder : selModel = new QItemSelectionModel(model); model->setFilter(QDir::AllDirs | QDir::Files | QDir::NoSymLinks | QDir::NoDotAndDotDot); model->setRootPath(QDir::currentPath()); treeView_dir->setModel(model); treeView_dir->setRootIndex(model->index(QDir::rootPath())); */ items_dir_kerne << "1" << "2" << "3" << "4" << "5" << "6" << "7" << "8" ; cmb_kerne->addItems (items_dir_kerne); items_dir_kerne.clear(); items << "lzo" << tr("gzip fast") << tr("gzip standard") << tr("qzip best") << tr("bzip2 fast"); cmb_zip->addItems (items); items.clear(); items << tr("bzip2 good") << tr("lzma fast") << tr("lzma medium") << tr("lzma best"); cmb_zip->addItems (items); items.clear(); // Ini-Datei auslesen QString homepath = QDir::homePath(); QFile file(homepath + "/.config/qt5-fsarchiver/qt5-fsarchiver.conf"); if (file.exists()) { QSettings setting("qt5-fsarchiver", "qt5-fsarchiver"); setting.beginGroup("Basiseinstellungen"); int auswertung = setting.value("Kompression").toInt(); cmb_zip -> setCurrentIndex(auswertung); auswertung = setting.value("Kerne").toInt(); cmb_kerne -> setCurrentIndex(auswertung-1); auswertung = setting.value("overwrite").toInt(); if (auswertung ==1) chk_overwrite->setChecked(Qt::Checked); auswertung = setting.value("place").toInt(); if (auswertung ==1) chk_path->setChecked(Qt::Checked); auswertung = setting.value("key").toInt(); if (auswertung ==1) chk_key->setChecked(Qt::Checked); auswertung = setting.value("hidden").toInt(); if (auswertung ==1) chk_hidden->setChecked(Qt::Checked); setting.endGroup(); } else { cmb_kerne -> setCurrentIndex(0); chk_path->setChecked(Qt::Checked); chk_overwrite->setChecked(Qt::Checked); cmb_zip -> setCurrentIndex(2); } chkkey(); pid_ermitteln(); state = chk_key->checkState(); if (state == Qt::Checked) lineKey->setEnabled(true); state = chk_path->checkState(); if (dialog_auswertung == 4){ chk_key->setText (tr("Encrypt\nbackup. key:", "Sicherung\nverschlüsseln. Schlüssel:")); bt_save->setText (tr("Directory save", "Verzeichnis sichern")); label->setText (tr("to saved Directory", "zu sicherndes Verzeichnis")); label_2->setText (tr("Location (path) of the backup", "Ort (Pfad) der Sicherung")); chk_path->setEnabled(false); chk_overwrite->setEnabled(true); cmb_zip->setEnabled(true); cmb_zip -> setCurrentIndex(2); label_4->setEnabled(true); label_5->setEnabled(true); AnzahlsaveFile->setEnabled(true); AnzahlgesicherteFile->setEnabled(true); filters << "*.*"; } if (dialog_auswertung == 5){ chk_key->setText (tr("Decrypt\nbackup. key:", "Sicherung\nentschlüsseln. Schlüssel:")); bt_save->setText (tr("Directory restore", "Verzeichnis zurückschreiben")); label->setText (tr("back to write backup file", "zurück zu schreibende Sicherungsdatei")); label_2->setText (tr("Location (path) of the restore", "Ort (Pfad) der Wiederherstellung")); state = chk_path->checkState(); if (state == Qt::Checked) treeView_path->setEnabled(false); chk_overwrite->setEnabled(false); cmb_zip->setEnabled(false); label_4->setEnabled(false); label_5->setEnabled(false); AnzahlsaveFile->setEnabled(false); AnzahlgesicherteFile->setEnabled(false); filters << "*.fsa"; } chkhidden(); }
int main(int argc, char *argv[]) { extern int optind; extern char *optarg; enum S command = COMMAND, state; DB *dbp; DBT data, key, keydata; size_t len; int ch, oflags, sflag; char *fname, *infoarg, *p, *t, buf[8 * 1024]; bool unlink_dbfile; infoarg = NULL; fname = NULL; unlink_dbfile = false; oflags = O_CREAT | O_RDWR; sflag = 0; while ((ch = getopt(argc, argv, "f:i:lo:s")) != -1) switch (ch) { case 'f': fname = optarg; break; case 'i': infoarg = optarg; break; case 'l': oflags |= DB_LOCK; break; case 'o': if ((ofd = open(optarg, O_WRONLY|O_CREAT|O_TRUNC, 0666)) < 0) err(1, "Cannot create `%s'", optarg); break; case 's': sflag = 1; break; case '?': default: usage(); } argc -= optind; argv += optind; if (argc != 2) usage(); /* Set the type. */ type = dbtype(*argv++); /* Open the descriptor file. */ if (strcmp(*argv, "-") && freopen(*argv, "r", stdin) == NULL) err(1, "Cannot reopen `%s'", *argv); /* Set up the db structure as necessary. */ if (infoarg == NULL) infop = NULL; else for (p = strtok(infoarg, ",\t "); p != NULL; p = strtok(0, ",\t ")) if (*p != '\0') infop = setinfo(type, p); /* * Open the DB. Delete any preexisting copy, you almost never * want it around, and it often screws up tests. */ if (fname == NULL) { const char *q = getenv("TMPDIR"); if (q == NULL) q = "/var/tmp"; (void)snprintf(buf, sizeof(buf), "%s/__dbtest", q); fname = buf; (void)unlink(buf); unlink_dbfile = true; } else if (!sflag) (void)unlink(fname); if ((dbp = dbopen(fname, oflags, S_IRUSR | S_IWUSR, type, infop)) == NULL) err(1, "Cannot dbopen `%s'", fname); XXdbp = dbp; if (unlink_dbfile) (void)unlink(fname); state = COMMAND; for (lineno = 1; (p = fgets(buf, sizeof(buf), stdin)) != NULL; ++lineno) { /* Delete the newline, displaying the key/data is easier. */ if (ofd == STDOUT_FILENO && (t = strchr(p, '\n')) != NULL) *t = '\0'; if ((len = strlen(buf)) == 0 || isspace((unsigned char)*p) || *p == '#') continue; /* Convenient gdb break point. */ if (XXlineno == lineno) XXlineno = 1; switch (*p) { case 'c': /* compare */ chkcmd(state); state = KEY; command = COMPARE; break; case 'e': /* echo */ chkcmd(state); /* Don't display the newline, if CR at EOL. */ if (p[len - 2] == '\r') --len; if (write(ofd, p + 1, len - 1) != (ssize_t)len - 1 || write(ofd, "\n", 1) != 1) err(1, "write failed"); break; case 'g': /* get */ chkcmd(state); state = KEY; command = GET; break; case 'p': /* put */ chkcmd(state); state = KEY; command = PUT; break; case 'r': /* remove */ chkcmd(state); if (flags == R_CURSOR) { rem(dbp, &key); state = COMMAND; } else { state = KEY; command = REMOVE; } break; case 'S': /* sync */ chkcmd(state); synk(dbp); state = COMMAND; break; case 's': /* seq */ chkcmd(state); if (flags == R_CURSOR) { state = KEY; command = SEQ; } else seq(dbp, &key); break; case 'f': flags = setflags(p + 1); break; case 'D': /* data file */ chkdata(state); data.data = rfile(p + 1, &data.size); goto ldata; case 'd': /* data */ chkdata(state); data.data = xcopy(p + 1, len - 1); data.size = len - 1; ldata: switch (command) { case COMPARE: compare(&keydata, &data); break; case PUT: put(dbp, &key, &data); break; default: errx(1, "line %zu: command doesn't take data", lineno); } if (type != DB_RECNO) free(key.data); free(data.data); state = COMMAND; break; case 'K': /* key file */ chkkey(state); if (type == DB_RECNO) errx(1, "line %zu: 'K' not available for recno", lineno); key.data = rfile(p + 1, &key.size); goto lkey; case 'k': /* key */ chkkey(state); if (type == DB_RECNO) { static recno_t recno; recno = atoi(p + 1); key.data = &recno; key.size = sizeof(recno); } else { key.data = xcopy(p + 1, len - 1); key.size = len - 1; } lkey: switch (command) { case COMPARE: getdata(dbp, &key, &keydata); state = DATA; break; case GET: get(dbp, &key); if (type != DB_RECNO) free(key.data); state = COMMAND; break; case PUT: state = DATA; break; case REMOVE: rem(dbp, &key); if ((type != DB_RECNO) && (flags != R_CURSOR)) free(key.data); state = COMMAND; break; case SEQ: seq(dbp, &key); if ((type != DB_RECNO) && (flags != R_CURSOR)) free(key.data); state = COMMAND; break; default: errx(1, "line %zu: command doesn't take a key", lineno); } break; case 'o': dump(dbp, p[1] == 'r', 0); break; #ifdef __NetBSD__ case 'O': dump(dbp, p[1] == 'r', 1); break; case 'u': unlinkpg(dbp); break; #endif default: errx(1, "line %zu: %s: unknown command character", lineno, p); } } #ifdef STATISTICS /* * -l must be used (DB_LOCK must be set) for this to be * used, otherwise a page will be locked and it will fail. */ if (type == DB_BTREE && oflags & DB_LOCK) __bt_stat(dbp); #endif if ((*dbp->close)(dbp)) err(1, "db->close failed"); (void)close(ofd); return 0; }