Beispiel #1
0
hydra_post_t *
hydra_post_load (const char *filename)
{
    assert (filename);
    zconfig_t *root = zconfig_loadf ("posts/%s", filename);
    if (!root)
        return NULL;            //  No such file

    hydra_post_t *self = NULL;
    char *ident = zconfig_resolve (root, "/post/ident", "");
    char *subject = zconfig_resolve (root, "/post/subject", NULL);
    char *timestamp = zconfig_resolve (root, "/post/timestamp", NULL);
    char *parent_id = zconfig_resolve (root, "/post/parent-id", "");
    char *mime_type = zconfig_resolve (root, "/post/mime-type", NULL);
    char *digest = zconfig_resolve (root, "/post/digest", NULL);
    char *location = zconfig_resolve (root, "/post/location", NULL);
    
    if (subject && timestamp && mime_type && digest && location
    && (strlen (ident) == ID_SIZE)
    && (strlen (parent_id) == 0 || strlen (parent_id) == ID_SIZE)
    && (strlen (timestamp) == 20)
    && (strlen (digest) == ID_SIZE)) {
        self = hydra_post_new (subject);
        strcpy (self->ident, ident);
        strcpy (self->timestamp, timestamp);
        strcpy (self->parent_id, parent_id);
        self->mime_type = strdup (mime_type);
        self->location = strdup (location);
        strcpy (self->digest, digest);
        self->content_size = atoll (zconfig_resolve (root, "/post/content-size", "0"));
        zchunk_destroy (&self->content);
    }
    zconfig_destroy (&root);
    return self;
}
Beispiel #2
0
JNIEXPORT jlong JNICALL
Java_zconfig__1_1loadf (JNIEnv *env, jclass c, jstring format)
{
    char *format_ = (char *) (*env)->GetStringUTFChars (env, format, NULL);
    jlong loadf_ = (jlong) zconfig_loadf ("%s", format_);
    (*env)->ReleaseStringUTFChars (env, format, format_);
    return loadf_;
}
///
//  Equivalent to zconfig_load, taking a format string instead of a fixed
//  filename.                                                            
QmlZconfig *QmlZconfigAttached::loadf (const QString &format) {
    QmlZconfig *qmlSelf = new QmlZconfig ();
    qmlSelf->self = zconfig_loadf ("%s", format.toUtf8().data());
    return qmlSelf;
};