Ejemplo n.º 1
0
bool LinkedNotebookTable::update(LinkedNotebook &notebook, bool isDirty) {
    LinkedNotebook oldBook;
    qint32 lid = getLid(notebook.guid);
    get(oldBook, lid);
    if (lid <= 0)
        return false;
    expunge(lid);
    add(lid, notebook, isDirty);
    // Rename anything in the note list
    QString oldname = "";
    QString newname = "";
    if (notebook.shareName.isSet())
        newname = notebook.shareName;
    if (oldBook.shareName.isSet())
        oldname = oldBook.shareName;
    if (oldname != newname) {
        NSqlQuery query(*db);
        query.prepare("Update notetable set notebook=:name where notebooklid=:lid");
        query.bindValue(":name", newname);
        query.bindValue(":lid", lid);
        query.exec();
        query.finish();
    }
    return true;
}
Ejemplo n.º 2
0
// Add a new record
qint32 FavoritesTable::add(const FavoritesRecord &record) {
    NSqlQuery query(db);
    db->lockForWrite();
    query.prepare("Insert into datastore (lid, key, data) values (:lid, :key, :data)");

    qint32 lid = record.lid;
    ConfigStore cs(db);
    if (lid <= 0)
        lid = cs.incrementLidCounter();
    else
        expunge(lid);
    qint32 tempLid = getLidByTarget(record.target);
    if (tempLid>0)
        expunge(tempLid);

    query.bindValue(":lid", lid);
    query.bindValue(":key", FAVORITES_TYPE);
    query.bindValue(":data", record.type);
    query.exec();

    query.bindValue(":lid", lid);
    query.bindValue(":key", FAVORITES_TARGET);
    query.bindValue(":data", record.target);
    query.exec();

    query.bindValue(":lid", lid);
    query.bindValue(":key", FAVORITES_ORDER);
    query.bindValue(":data", record.order);
    query.exec();

    query.bindValue(":lid", lid);
    query.bindValue(":key", FAVORITES_PARENT);
    query.bindValue(":data", record.parent);
    query.exec();

    query.finish();
    db->unlock();

    return lid;
}
Ejemplo n.º 3
0
Archivo: run.c Proyecto: 8l/cmm
void
killchildren(char *msg)
{
	Process *p;

	kflag = 1;	/* to make sure waitup doesn't exit */
	jobs = 0;	/* make sure no more get scheduled */
	for(p = phead; p; p = p->f)
		expunge(p->pid, msg);
	while(waitup(1, (int *)0) == 0)
		;
	Bprint(&bout, "mk: %s\n", msg);
	Exit();
}
Ejemplo n.º 4
0
bool LinkedNotebookTable::update(LinkedNotebook &notebook, bool isDirty) {
    LinkedNotebook oldBook;
    qint32 lid = getLid(notebook.guid);
    get(oldBook, lid);
    if (lid <= 0)
        return false;
    expunge(lid);
    add(lid, notebook, isDirty);
    // Rename anything in the note list
    if (notebook.shareName != oldBook.shareName) {
        QSqlQuery query;
        query.prepare("Update notetable set notebook=:name where notebooklid=:lid");
        query.bindValue(":name", QString::fromStdString(notebook.shareName));
        query.bindValue(":lid", lid);
        query.exec();
    }
    return true;
}
Ejemplo n.º 5
0
int
main(int argc, char **argv)
{
    krb5_context ctx;
    krb5_error_code retval;
    const char *progname;

    retval = krb5_init_context(&ctx);
    if (retval) {
        fprintf(stderr, "krb5_init_context returned error %ld\n",
                (long) retval);
        exit(1);
    }
    progname = argv[0];

    /* Parse arguments. */
    argc--; argv++;
    while (argc) {
        if (strcmp(*argv, "dump") == 0) {
            /*
             * Without going through the rcache interface, dump a
             * named dfl-format rcache file to stdout.  Takes a full
             * pathname argument.
             */
            const char *filename;

            argc--; argv++;
            if (!argc) usage(progname);
            filename = *argv;
            dump_rcache(filename);
        } else if (strcmp(*argv, "store") == 0) {
            /*
             * Using the rcache interface, store a replay record.
             * Takes an rcache spec like dfl:host as the first
             * argument.  If non-empty, the "msg" argument will be
             * hashed and provided in the replay record.  The
             * now-timestamp argument can be 0 to use the current
             * time.
             */
            char *rcspec, *client, *server, *msg;
            krb5_timestamp timestamp, now_timestamp;
            krb5_int32 usec, now_usec;

            argc--; argv++;
            if (!argc) usage(progname);
            rcspec = *argv;
            argc--; argv++;
            if (!argc) usage(progname);
            client = *argv;
            argc--; argv++;
            if (!argc) usage(progname);
            server = *argv;
            argc--; argv++;
            if (!argc) usage(progname);
            msg = (**argv) ? *argv : NULL;
            argc--; argv++;
            if (!argc) usage(progname);
            timestamp = (krb5_timestamp) atoll(*argv);
            argc--; argv++;
            if (!argc) usage(progname);
            usec = (krb5_int32) atol(*argv);
            argc--; argv++;
            if (!argc) usage(progname);
            now_timestamp = (krb5_timestamp) atoll(*argv);
            argc--; argv++;
            if (!argc) usage(progname);
            now_usec = (krb5_int32) atol(*argv);

            store(ctx, rcspec, client, server, msg, timestamp, usec,
                  now_timestamp, now_usec);
        } else if (strcmp(*argv, "expunge") == 0) {
            /*
             * Using the rcache interface, expunge a replay cache.
             * The now-timestamp argument can be 0 to use the current
             * time.
             */
            char *rcspec;
            krb5_timestamp now_timestamp;
            krb5_int32 now_usec;

            argc--; argv++;
            if (!argc) usage(progname);
            rcspec = *argv;
            argc--; argv++;
            if (!argc) usage(progname);
            now_timestamp = (krb5_timestamp) atoll(*argv);
            argc--; argv++;
            if (!argc) usage(progname);
            now_usec = (krb5_int32) atol(*argv);
            expunge(ctx, rcspec, now_timestamp, now_usec);
        } else
            usage(progname);
        argc--; argv++;
    }

    krb5_free_context(ctx);

    return 0;
}