Example #1
0
int main(int argc, const char **argv)
{
    qeo_factory_t *factory;
    qeocore_type_t *type;
    qeocore_reader_t *reader;
    qeocore_reader_listener_t listener = { .on_data = on_data_available };
    qeocore_writer_t *writer;
    pthread_t th = 0;


    /* initialize */
    sem_init(&_sync, 0, 0);
    assert(NULL != (factory = qeocore_factory_new(QEO_IDENTITY_DEFAULT)));
    init_factory(factory);
    assert(NULL != (type = qeocore_type_register_tsm(factory, _tsm, _tsm[0].name)));
    assert(NULL != (reader = qeocore_reader_open(factory, type, NULL, QEOCORE_EFLAG_STATE_DATA | QEOCORE_EFLAG_ENABLE,
                                                 &listener, NULL)));
    assert(NULL != (writer = qeocore_writer_open(factory, type, NULL, QEOCORE_EFLAG_STATE_DATA | QEOCORE_EFLAG_ENABLE,
                                                 NULL, NULL)));
    /* start writer thread */
    assert(0 == pthread_create(&th, NULL, run, writer));
    /* make sure writing has started */
    sem_wait(&_sync);
    /* shutdown reader */
    qeocore_reader_close(reader);
    _closed = 1;
    /* shutdown writer */
    _done = 1;
    pthread_join(th, NULL);
    qeocore_writer_close(writer);
    qeocore_type_free(type);
    qeocore_factory_close(factory);
}
Example #2
0
static void run_writer(pid_t peer)
{
    // writer is a type_nest_i writer
    qeo_factory_t *factory;
    qeocore_type_t *type_nest_i;
    qeocore_writer_t *writer;
    qeocore_data_t *outer=NULL;
    qeocore_data_t *inner=NULL;

    int status;

    /* initialize */
    assert(NULL != (factory = qeocore_factory_new(QEO_IDENTITY_DEFAULT)));
    init_factory(factory);
    assert(NULL != (type_nest_i = type_nest_i_register(factory)));
    assert(NULL != (writer = qeocore_writer_open(factory, type_nest_i, NULL,
                                                 QEOCORE_EFLAG_STATE_DATA | QEOCORE_EFLAG_ENABLE,
                                                 NULL, NULL)));
    log_pid("=================================== writer initialized");
    assert(NULL != (outer = qeocore_writer_data_new(writer)));
    /* fill outer struct */
    assert(QEO_OK == qeocore_data_set_member(outer, _outer_int32_id, &_outer_int32_value));
    assert(QEO_OK == qeocore_data_set_member(outer, _outer_int8_id, &_outer_int8_value));
    assert(QEO_OK == qeocore_data_set_member(outer, _outer_string_id, &_outer_string_value));
    assert(QEO_OK == qeocore_data_set_member(outer, _outer_int16_id, &_outer_int16_value));
    assert(QEO_OK == qeocore_data_set_member(outer, _outer_int64_id, &_outer_int64_value));

    /* fill inner struct */
    assert(QEO_OK == qeocore_data_get_member(outer, _inner_id, &inner));
    assert(QEO_OK == qeocore_data_set_member(inner, _inner_int32_id, &_inner_int32_value));
    assert(QEO_OK == qeocore_data_set_member(inner, _inner_int8_id, &_inner_int8_value));
    assert(QEO_OK == qeocore_data_set_member(inner, _inner_string_id, &_inner_string_value));
    assert(QEO_OK == qeocore_data_set_member(inner, _inner_int16_id, &_inner_int16_value));
    assert(QEO_OK == qeocore_data_set_member(inner, _inner_int64_id, &_inner_int64_value));
    assert(QEO_OK == qeocore_data_set_member(outer, _inner_id, &inner));
    log_verbose(" =================== _outer_int32_value = %u \n", _outer_int32_value );
    log_verbose(" =================== _outer_int8_value = %u \n", _outer_int8_value );
    log_verbose(" =================== _outer_int16_value = %u \n", _outer_int16_value );
    log_verbose(" =================== _outer_int64_value = %"PRIu64" \n", _outer_int64_value );
    log_verbose(" =================== _inner_int32_value = %u \n", _inner_int32_value );
    log_verbose(" =================== _inner_int8_value = %u \n", _inner_int8_value );
    log_verbose(" =================== _inner_int16_value = %u \n", _inner_int16_value );
    log_verbose(" =================== _inner_int64_value = %"PRIu64" \n", _inner_int64_value );
    /* write */
    assert(QEO_OK == qeocore_writer_write(writer, outer));
    log_pid("===================================== writer wrote outer data");
    assert(peer == waitpid(peer, &status, 0));
    assert(0 == status);
    log_pid("===================================== writer done");
    /* clean up */
    qeocore_data_free(inner);
    qeocore_data_free(outer);
    qeocore_writer_close(writer);
    qeocore_type_free(type_nest_i);
    qeocore_factory_close(factory);
}
Example #3
0
qeo_retcode_t fwd_init_post_auth(qeo_factory_t *factory)
{
    qeo_retcode_t rc = QEO_EFAIL;
    qeocore_type_t *type = NULL;

    /* this will eventually also take the factory lock, so postponing our lock */
    type = qeocore_type_register_tsm(factory, org_qeo_system_Forwarder_type, org_qeo_system_Forwarder_type->name);
    if (NULL != type) {
        lock(&factory->mutex);
        if (factory->flags.is_forwarder) {
            factory->fwd.listener.on_data = fwd_server_on_data;
            factory->fwd.reader = qeocore_reader_open(factory, type, org_qeo_system_Forwarder_type->name,
                                                      QEOCORE_EFLAG_STATE_UPDATE, &factory->fwd.listener, NULL);
            if (NULL != factory->fwd.reader) {
                factory->fwd.u.server.writer = qeocore_writer_open(factory, type, org_qeo_system_Forwarder_type->name,
                                                                   QEOCORE_EFLAG_STATE_DATA | QEOCORE_EFLAG_ENABLE,
                                                                   NULL, NULL);
                if (NULL != factory->fwd.u.server.writer) {
                    factory->fwd.u.server.state = FWD_STATE_INIT;
                    rc = fwd_server_state_machine_eval_ul(factory, -1, false, false);
                }
            }
        } else {
            factory->fwd.listener.on_data = fwd_client_on_data;
            factory->fwd.listener.userdata = (uintptr_t)factory;
            factory->fwd.reader = qeocore_reader_open(factory, type, org_qeo_system_Forwarder_type->name,
                                                      QEOCORE_EFLAG_STATE_DATA, &factory->fwd.listener, NULL);
            /* note: reader construction failure is not fatal */
            if (qeocore_parameter_get_number("FWD_DISABLE_FORWARDING")) {
                qeo_log_i("Disable forwarding");
                factory->fwd.u.client.state = FWD_CLIENT_STATE_READY;
            }
            else {
                factory->fwd.u.client.state = FWD_CLIENT_STATE_INIT;
                client_state_machine_eval_ul(factory, CLIENT_EVENT_START, NULL, -1);
            }
            rc = QEO_OK;
        }
        unlock(&factory->mutex);
        qeocore_type_free(type);
    }
    return rc;
}
Example #4
0
static void run_writer(pid_t peer)
{
    qeo_factory_t *factory;
    qeocore_type_t *type;
    qeocore_writer_t *writer;
    qeocore_data_t *data, *seqdata;
    byte_array_t array;
    int status, i;

    /* initialize */
    assert(NULL != (factory = qeocore_factory_new(QEO_IDENTITY_DEFAULT)));
    init_factory(factory);
    assert(NULL != (type = type_register(factory)));
    assert(NULL != (writer = qeocore_writer_open(factory, type, NULL,
                                                 QEOCORE_EFLAG_STATE_DATA | QEOCORE_EFLAG_ENABLE,
                                                 NULL, NULL)));
    log_pid("writer initialized");
    assert(NULL != (data = qeocore_writer_data_new(writer)));
    assert(QEO_OK == qeocore_data_set_member(data, _size_id, &_test_size));
    /* init sequence */
    DDS_SEQ_INIT(array);
    assert(NULL != (DDS_SEQ_DATA(array) = malloc(_test_size * sizeof(char))));
    DDS_SEQ_LENGTH(array) = DDS_SEQ_MAXIMUM(array) = _test_size;
    for (i = 0; i < _test_size; i++) {
        DDS_SEQ_ITEM(array, i) = i & 0xff;
    }
    assert(QEO_OK == qeocore_data_get_member(data, _buf_id, &seqdata));
    assert(QEO_OK == qeocore_data_sequence_set(seqdata, (const qeo_sequence_t *)&array, 0));
    assert(QEO_OK == qeocore_data_set_member(data, _buf_id, &seqdata));
    /* write */
    assert(QEO_OK == qeocore_writer_write(writer, data));
    log_pid("writer wrote data");
    assert(peer == waitpid(peer, &status, 0));
    assert(0 == status);
    log_pid("writer done");
    /* clean up */
    free(DDS_SEQ_DATA(array));
    qeocore_data_free(seqdata);
    qeocore_data_free(data);
    qeocore_writer_close(writer);
    qeocore_type_free(type);
    qeocore_factory_close(factory);
}
Example #5
0
qeo_state_writer_t *qeo_factory_create_state_writer(const qeo_factory_t *factory,
                                                    const DDS_TypeSupport_meta *type,
                                                    const qeo_state_writer_listener_t *listener,
                                                    uintptr_t userdata)
{
    qeo_state_writer_t *writer = NULL;

    if ((NULL != factory) && (NULL != type) && ((NULL == listener) || (NULL != listener->on_policy_update))) {
        qeocore_writer_listener_t l = { 0 }, *pl = NULL;
        writer_dispatcher_cookie *dc = NULL;
        qeo_retcode_t rc = QEO_OK;
        qeocore_type_t *t = NULL;

        if (NULL != listener) {
            dc = calloc(1, sizeof(*dc));
            if (NULL != dc) {
                dc->etype = QEO_ETYPE_STATE_DATA;
                dc->listener.state = *listener;
                dc->userdata = userdata;
                l.on_policy_update = core_writer_policy_update_callback_dispatcher;
                l.userdata = (uintptr_t)dc;
                pl = &l;
            }
            else {
                rc = QEO_ENOMEM;
            }
        }
        if (QEO_OK == rc) {
            t = qeocore_type_register_tsm(factory, type, type->name);
            if (NULL != t) {
                writer = (qeo_state_writer_t *)qeocore_writer_open(factory, t, NULL,
                                                                   QEOCORE_EFLAG_STATE_DATA | QEOCORE_EFLAG_ENABLE,
                                                                   pl, NULL);
                qeocore_type_free(t);
            }
            if (NULL == writer) {
                free(dc);
            }
        }
    }
    return writer;
}
Example #6
0
int main(int argc, const char **argv)
{
    qeo_factory_t *factory;
    qeocore_reader_t *reader;
    qeocore_writer_t *writer;
    qeocore_type_t *type;
    qeocore_data_t *rdata, *wdata;
    int i;

    for (i = 0; i < 2; i++) {
        /* initialize */
        assert(NULL != (factory = qeocore_factory_new(QEO_IDENTITY_DEFAULT)));
        init_factory(factory);
        assert(NULL != (type = nested_type_get(1, 0, 0)));
        assert(QEO_OK == qeocore_type_register(factory, type, "nested"));
        assert(NULL != (reader = qeocore_reader_open(factory,  type, NULL,
                                                     QEOCORE_EFLAG_STATE_UPDATE | QEOCORE_EFLAG_ENABLE, NULL, NULL)));
        assert(NULL != (writer = qeocore_writer_open(factory, type, NULL,
                                                     QEOCORE_EFLAG_STATE_UPDATE | QEOCORE_EFLAG_ENABLE, NULL, NULL)));
        /* write */
        assert(NULL != (wdata = qeocore_writer_data_new(writer)));
        fill_data(wdata);
        assert(QEO_OK == qeocore_writer_write(writer, wdata));
        /* check data */
        assert(NULL != (rdata = qeocore_reader_data_new(reader)));
        assert(QEO_OK == qeocore_reader_read(reader, NULL, rdata));
        expected_status = QEOCORE_DATA;
        validate_data(rdata);
        /* remove */
        assert(QEO_OK == qeocore_writer_remove(writer, wdata));
        /* clean up */
        qeocore_data_free(wdata);
        qeocore_data_free(rdata);
        qeocore_writer_close(writer);
        qeocore_reader_close(reader);
        qeocore_type_free(type);
        qeocore_factory_close(factory);
    }
}
Example #7
0
int main(int argc, const char **argv)
{
    qeo_factory_t *factory;
    qeocore_type_t *type;
    qeocore_reader_t *reader;
    qeocore_reader_listener_t listener = { .on_data = on_data_available };
    qeocore_writer_t *writer;
    int i = 0;

    /* initialize */
    sem_init(&_sync, 0, 0);
    sem_init(&_sync_nodata, 0, 0);
    assert(NULL != (factory = qeocore_factory_new(QEO_IDENTITY_DEFAULT)));
    init_factory(factory);
    assert(NULL != (type = qeocore_type_register_tsm(factory, org_qeo_dynamic_qdm_test_TypeWithStructs_type, org_qeo_dynamic_qdm_test_TypeWithStructs_type[0].name)));
    assert(NULL != (reader = qeocore_reader_open(factory, type, NULL, QEOCORE_EFLAG_EVENT_DATA, &listener, NULL)));
    assert(NULL != (writer = qeocore_writer_open(factory, type, NULL, QEOCORE_EFLAG_EVENT_DATA, NULL, NULL)));
    /* test late enabling of readers/writers */
    assert(QEO_OK == qeocore_reader_enable(reader));
    assert(QEO_OK == qeocore_writer_enable(writer));
    /* send structure */
    for(i = 0; i < 20; i++){
        log_verbose("testing with %d", i);
        assert(QEO_OK == write_generated_data(writer, i));
        log_verbose("waiting for data");
        /* wait for reception */
        sem_wait(&_sync);
        sem_wait(&_sync_nodata);
    }

    /* clean up */
    qeocore_writer_close(writer);
    qeocore_reader_close(reader);
    qeocore_type_free(type);
    qeocore_factory_close(factory);
    sem_destroy(&_sync);
}
Example #8
0
    DDS_SEQ_INIT(chat_msg.colorlist);
    dds_seq_from_array(&chat_msg.colorlist, enum_array, sizeof(enum_array) / sizeof(enum_array[0]));

    /* reading */
    qeocore_reader_t *event_reader = qeocore_reader_open(_factory,
            type,
            org_qeo_sample_simplechat_ChatMessage_type[0].name,
            QEOCORE_EFLAG_EVENT_DATA | QEOCORE_EFLAG_ENABLE,
            &_sc_rlistener,
            &ret);
    ck_assert_int_ne(event_reader, NULL);

    /* writing */
    qeocore_writer_t *event_writer = qeocore_writer_open(_factory,
            type,
            org_qeo_sample_simplechat_ChatMessage_type[0].name,
            QEOCORE_EFLAG_EVENT_DATA | QEOCORE_EFLAG_ENABLE,
            NULL, /* FIX ME */
            &ret);
    qeocore_type_free(type);
    ck_assert_int_ne(event_writer, NULL);
    ck_assert_int_eq(ret, QEO_OK);

    qeocore_data_t *sample = qeocore_writer_data_new(event_writer);
    ck_assert_int_eq(qeo_walk_tsm_for_marshal(_types, org_qeo_sample_simplechat_ChatMessage_type, (uintptr_t)&chat_msg, sample, QEO_T2D_FLAGS_ALL, &_sc_mcbs), QEO_OK); 

    ck_assert_int_eq(qeocore_writer_write(event_writer, sample), QEO_OK);
    qeocore_data_free(sample);


    sleep(1);
    org_qeo_wifi_ScanListEntry_t *entry;
int main(int argc, const char **argv)
{

    pid_t pid;

    pid = fork();

    if (pid == -1) {
       perror("fork failed");
       exit(EXIT_FAILURE);
    }
    else if (pid == 0) {
       log_verbose("=================== WRITER of type 1 \n");

       qeo_factory_t *factory;
       qeocore_type_t *type1;
       qeocore_writer_t *writer;

       /* initialize */
       assert(NULL != (factory = qeocore_factory_new(QEO_IDENTITY_DEFAULT)));
       init_factory(factory);
       log_verbose(" =================== c qeocore_type_register_tsm(factory, _tsm_type_qdm_version1, _tsm_type_qdm_version1[0].name) \n");
       assert(NULL != (type1 = qeocore_type_register_tsm(factory, _tsm_type_qdm_version1, _tsm_type_qdm_version1[0].name)));
       log_verbose(" =================== c qeocore_writer_open(factory, type1, NULL, QEOCORE_EFLAG_EVENT_DATA, NULL, NULL) \n");
       assert(NULL != (writer = qeocore_writer_open(factory, type1, NULL, QEOCORE_EFLAG_EVENT_DATA, NULL, NULL)));
       /* test late enabling of readers/writers */
       log_verbose(" =================== c qeocore_writer_enable(writer) \n");
       assert(QEO_OK == qeocore_writer_enable(writer));
       /* send structure */
       sleep(2);
       log_verbose(" =================== c qeocore_writer_write(writer, &_type_qdm_version1) \n");
       assert(QEO_OK == qeocore_writer_write(writer, &_type_qdm_version1));
       sleep(2);
       /* clean up */
       qeocore_writer_close(writer);
       qeocore_type_free(type1);
       qeocore_factory_close(factory);
       _exit(EXIT_SUCCESS);
    }
    else {
       log_verbose("=================== READER of type 2 \n");

       qeo_factory_t *factory;
       qeocore_type_t *type2;
       qeocore_reader_t *reader;
       qeocore_reader_listener_t listener = { .on_data = on_data_available };

       /* initialize */
       sem_init(&_sync, 0, 0);
       sem_init(&_sync_nodata, 0, 0);
       assert(NULL != (factory = qeocore_factory_new(QEO_IDENTITY_DEFAULT)));
       init_factory(factory);
       log_verbose(" =================== p qeocore_type_register_tsm(factory, _tsm_type_qdm_version2, _tsm_type_qdm_version2[0].name) \n");
       assert(NULL != (type2 = qeocore_type_register_tsm(factory, _tsm_type_qdm_version2, _tsm_type_qdm_version2[0].name)));
       log_verbose(" =================== p qeocore_reader_open(factory, type2, NULL, QEOCORE_EFLAG_EVENT_DATA, &listener, NULL)  \n");
       assert(NULL != (reader = qeocore_reader_open(factory, type2, NULL, QEOCORE_EFLAG_EVENT_DATA, &listener, NULL)));
       /* test late enabling of readers/writers */
       log_verbose(" =================== p qeocore_reader_enable(reader) \n");
       assert(QEO_OK == qeocore_reader_enable(reader));
       /* wait for reception */
       log_verbose(" =================== p sem_wait(&_sync) \n");
       sem_wait(&_sync);
       log_verbose(" =================== p sem_wait(&_sync_nodata) \n");
       sem_wait(&_sync_nodata);
       /* clean up */
       qeocore_reader_close(reader);
       qeocore_type_free(type2);
       qeocore_factory_close(factory);
       sem_destroy(&_sync);

       int status;
       (void)waitpid(pid, &status, 0);
    }
    return EXIT_SUCCESS;



}
    qeocore_type_t *type[2];
    qeocore_reader_t *reader[2];
    qeocore_reader_t *change[2];
    qeocore_reader_listener_t listener[2] = { {.on_data = on_regreq_available }, {.on_data = on_regcred_available } };
    qeocore_writer_t *writer[2];

    /* initialize */
    log_verbose("initialization start");
    sem_init(&_sync, 0, 0);
    sem_init(&_notify_sync, 0, 0);
    assert(NULL != (factory = qeocore_factory_new(QEO_IDENTITY_OPEN)));
    init_factory(factory);


    assert(NULL != (type[0] = qeocore_type_register_tsm(factory, org_qeo_system_RegistrationRequest_type, org_qeo_system_RegistrationRequest_type[0].name)));
    assert(NULL != (writer[0] = qeocore_writer_open(factory, type[0], NULL,
                                                    QEOCORE_EFLAG_STATE_DATA | QEOCORE_EFLAG_ENABLE, NULL, NULL)));
        /* send registration request */
    log_verbose("send registration request 1");
    _current_regreq = &_regreq[0];
    /* Already write before creating the readers. (see DE2772) */
    qeocore_writer_write(writer[0], _current_regreq);

    assert(NULL != (reader[0] = qeocore_reader_open(factory, type[0], NULL,
                                                    QEOCORE_EFLAG_STATE_UPDATE | QEOCORE_EFLAG_ENABLE, &listener[0],
                                                    NULL)));
    assert(NULL != (change[0] = qeocore_reader_open(factory, type[0], NULL,
                                                    QEOCORE_EFLAG_STATE_DATA | QEOCORE_EFLAG_ENABLE, &listener[0],
                                                    NULL)));
    assert(NULL != (type[1] = qeocore_type_register_tsm(factory, org_qeo_system_RegistrationCredentials_type, org_qeo_system_RegistrationCredentials_type[0].name)));
    assert(NULL != (reader[1] = qeocore_reader_open(factory, type[1], NULL,
                                                    QEOCORE_EFLAG_STATE_UPDATE | QEOCORE_EFLAG_ENABLE, &listener[1],
Example #11
0
static qeojson_writer_t *qeojson_writer_open(const qeo_factory_t    *factory,
                                             qeojson_writer_type_t  writer_type,
                                             void                   *listener,
                                             const char             *json_type,
                                             uintptr_t              userdata)
{
    qeo_retcode_t                   ret                 = QEO_EFAIL;
    qeojson_writer_t                *jsonwriter         = NULL;
    qeocore_type_t                  *typedesc           = NULL;
    json_writer_dispatcher_cookie_t *dc                 = NULL;
    json_t                          *jsonTypeDesc       = NULL;
    json_t                          *behavior           = NULL;
    const char                      *expected_behaviour = NULL;
    int                             flags               = QEOCORE_EFLAG_NONE;
    qeocore_writer_listener_t       l = { 0 };

    if ((NULL == factory) || (NULL == json_type)) {
        return NULL;
    }


    do {
        dc = calloc(1, sizeof(json_writer_dispatcher_cookie_t));
        if (NULL == dc) {
            break;
        }

        dc->userdata = userdata;

        switch (writer_type) {
            case QEOJSON_WRITER_TYPE_EVENT_WRITER:
                flags = QEOCORE_EFLAG_EVENT_DATA;
                expected_behaviour = "event";
                qeo_json_event_writer_listener_t *event_listener = (qeo_json_event_writer_listener_t *) listener;
                dc->etype           = QEO_ETYPE_EVENT_DATA;
                dc->listener.event  = *event_listener;
                if (NULL != event_listener->on_policy_update) {
                    l.on_policy_update = qeojson_core_writer_policy_update_callback_dispatcher;
                }
                break;

            case QEOJSON_WRITER_TYPE_STATE_WRITER:
                flags = QEOCORE_EFLAG_STATE_DATA;
                expected_behaviour = "state";
                qeo_json_state_writer_listener_t *state_listener = (qeo_json_state_writer_listener_t *)listener;
                dc->etype           = QEO_ETYPE_STATE_DATA;
                dc->listener.state  = *state_listener;
                if (NULL != state_listener->on_policy_update) {
                    l.on_policy_update = qeojson_core_writer_policy_update_callback_dispatcher;
                }

                break;
        }

        jsonTypeDesc = json_loads(json_type, 0, NULL);
        if (NULL == jsonTypeDesc) {
            break;
        }

        if (!json_is_object(jsonTypeDesc)) {
            break;
        }

        behavior = json_object_get(jsonTypeDesc, KEY_BEHAVIOR);

        if (!json_is_string(behavior)) {
            break;
        }


        if (0 != strcmp(json_string_value(behavior), expected_behaviour)) {
            qeo_log_e("not matching expected behaviour %s", expected_behaviour);
            break;
        }

        jsonwriter = calloc(1, sizeof(qeojson_writer_t));
        if (jsonwriter == NULL) {
            break;
        }

        jsonwriter->policy_cache = json_object();
        json_object_set_new(jsonwriter->policy_cache, "users", json_array());

        jsonwriter->policy = json_object();
        json_object_set_new(jsonwriter->policy, "users", json_array());

#ifdef __USE_GNU
        /* compile with -D_GNU_SOURCE */
#ifndef NDEBUG
        jsonwriter->policy_mutex = (pthread_mutex_t)PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;
#else
        jsonwriter->policy_mutex = (pthread_mutex_t)PTHREAD_MUTEX_INITIALIZER;
#endif
#else
        jsonwriter->policy_mutex = (pthread_mutex_t)PTHREAD_MUTEX_INITIALIZER;
#endif

        typedesc = types_from_json(factory, jsonTypeDesc);
        if (NULL == typedesc) {
            qeo_log_e("typedesc == NULL");
            break;
        }

        dc->typedesc        = jsonTypeDesc;
        l.userdata          = (uintptr_t)dc;
        dc->jsonwriter      = jsonwriter;
        jsonwriter->writer  = qeocore_writer_open(factory,                          // factory
                                                  typedesc,                         // type
                                                  NULL,                             // callback dispatcher
                                                  flags,                            // flags
                                                  &l,                               // callback cookie
                                                  NULL);                            // return code
        qeocore_type_free(typedesc);
        if (NULL == jsonwriter->writer) {
            break;
        }


        ret = QEO_OK;
    } while (0);


    if (QEO_OK != ret) {
        json_decref(jsonTypeDesc);
        qeojson_writer_close(jsonwriter);
        jsonwriter = NULL;
        free(dc);
    }


    return jsonwriter;
}