void dr_on_statistic_data_available(DDS_DataReaderListener *self, DDS_DataReader dataReader) { acceptance_high_end_StatisticPtrSeq samples; DDS_SampleInfoSeq sampleInfos; DDS_ReturnCode_t retCode; int i; DDS_SEQ_INIT(samples); DDS_SEQ_INIT(sampleInfos); retCode = DDS_DataReader_take(dataReader, (DDS_DataSeq *)&samples, &sampleInfos, -1, DDS_ANY_SAMPLE_STATE, DDS_ANY_VIEW_STATE, DDS_ANY_INSTANCE_STATE); if (retCode == DDS_RETCODE_NO_DATA) { return; } else if (retCode != DDS_RETCODE_OK) { fprintf(stderr, "Error taking sample (%s).\r\n", DDS_error(retCode)); return; } for (i = 0; i < DDS_SEQ_LENGTH (samples); i++) if (DDS_SEQ_ITEM (sampleInfos, i)->valid_data) nofConfigSamples++; retCode = DDS_DataReader_return_loan(dataReader, (DDS_DataSeq *)&samples, &sampleInfos); if (retCode != DDS_RETCODE_OK) { fprintf(stderr, "Error returning loan (%s).\r\n", DDS_error(retCode)); return; } }
void DDS_SubscriptionBuiltinTopicData__init (DDS_SubscriptionBuiltinTopicData *data) { memset (data, 0, sizeof (DDS_SubscriptionBuiltinTopicData)); DDS_SEQ_INIT (data->user_data.value); DDS_SEQ_INIT (data->partition.name); DDS_SEQ_INIT (data->topic_data.value); DDS_SEQ_INIT (data->group_data.value); }
DDS_ReturnCode_t DDS_ContentFilteredTopic_get_expression_parameters ( DDS_ContentFilteredTopic ftp, DDS_StringSeq *expr_pars) { DDS_ReturnCode_t rc; ctrc_begind (DCPS_ID, DCPS_FT_G_PARS, &ftp, sizeof (ftp)); ctrc_contd (&expr_pars, sizeof (expr_pars)); ctrc_endd (); if (!topic_ptr (ftp, 1, NULL)) return (DDS_RETCODE_ALREADY_DELETED); if ((ftp->topic.entity.flags & EF_FILTERED) == 0) { lock_release (ftp->topic.lock); return (DDS_RETCODE_ALREADY_DELETED); } if (!expr_pars) { lock_release (ftp->topic.lock); return (DDS_RETCODE_BAD_PARAMETER); } DDS_SEQ_INIT (*expr_pars); rc = dcps_get_str_pars (expr_pars, ftp->data.filter.expression_pars); lock_release (ftp->topic.lock); return (rc); }
AuthState_t validate_peer_identity (Identity_t id, void *token, unsigned char *identity, size_t identity_length, unsigned char *challenge, size_t *challenge_length) { Identity_t h; AuthState_t r; DDS_IdentityToken rem_idt, *list; DDS_OctetSeq seq; DDS_ReturnCode_t err; ARG_NOT_USED (token) ARG_NOT_USED (challenge) DDS_DataHolder__init (&rem_idt, DDS_DTLS_ID_TOKEN_CLASS); rem_idt.binary_value1 = &seq; DDS_SEQ_INIT (seq); seq._buffer = identity; seq._maximum = seq._length = identity_length; rem_idt.nusers = ~0; list = &rem_idt; r = sec_validate_remote_id (id, &list, NULL, NULL, &h, &err); *challenge_length = 0; if (err) return (AS_FAILED); return (r); }
DDS_ReturnCode_t DDS_DomainParticipant_get_discovered_topics (DDS_DomainParticipant dp, DDS_InstanceHandleSeq *handles) { DDS_ReturnCode_t ret; ctrc_begind (DCPS_ID, DCPS_DP_G_DISC_T_S, &dp, sizeof (dp)); ctrc_contd (&handles, sizeof (handles)); ctrc_endd (); if (!handles) return (DDS_RETCODE_BAD_PARAMETER); if (!domain_ptr (dp, 1, &ret)) return (ret); DDS_SEQ_INIT (*handles); if ((dp->participant.p_flags & EF_ENABLED) == 0) { lock_release (dp->lock); return (DDS_RETCODE_NOT_ENABLED); } sl_walk (&dp->participant.p_topics, topic_add_handle, handles); lock_release (dp->lock); return (ret); }
DDS_ReturnCode_t DDS_DataWriter_get_matched_subscriptions( DDS_DataWriter wp, DDS_InstanceHandleSeq *handles) { Topic_t *tp; Endpoint_t *ep; FilteredTopic_t *ftp; DDS_ReturnCode_t ret; ctrc_begind (DCPS_ID, DCPS_DW_G_MATCH_S, &wp, sizeof (wp)); ctrc_contd (&handles, sizeof (handles)); ctrc_endd (); if (!handles) return (DDS_RETCODE_BAD_PARAMETER); DDS_SEQ_INIT (*handles); if (!writer_ptr (wp, 0, &ret)) return (ret); tp = wp->w_topic; if (lock_take (tp->lock)) return (DDS_RETCODE_ALREADY_DELETED); #ifndef RW_TOPIC_LOCK if (lock_take (wp->w_lock)) { lock_release (tp->lock); return (DDS_RETCODE_ALREADY_DELETED); } #endif for (ep = tp->writers; ep && ep != &wp->w_ep; ep = ep->next) ; if (!ep) { ret = DDS_RETCODE_ALREADY_DELETED; goto done; } for (ep = tp->readers; ep; ep = ep->next) if (check_matched_subscription (wp, ep, handles, NULL)) { ret = DDS_RETCODE_OUT_OF_RESOURCES; goto done; } for (ftp = tp->filters; ftp; ftp = ftp->next) for (ep = ftp->topic.readers; ep; ep = ep->next) if (check_matched_subscription (wp, ep, handles, NULL)) { ret = DDS_RETCODE_OUT_OF_RESOURCES; goto done; } done: #ifndef RW_TOPIC_LOCK lock_release (wp->w_lock); #endif lock_release (tp->lock); return (ret); }
static qeo_retcode_t write_generated_data(qeocore_writer_t *writer, int arraysize){ org_qeo_dynamic_qdm_test_TypeWithStructs_t t = {}; size_t i, j; qeo_retcode_t rc = QEO_EFAIL; int stringsize = 10; t.mfloat32 = 32; t.mstring = "asdfdfasdfqwreqwrqwdfadfadsfadfd"; DDS_SEQ_INIT(t.msubstruct3); org_qeo_dynamic_qdm_test_Substruct3_t ss3[arraysize]; char strings[arraysize][arraysize+2][stringsize]; for (i = 0; i < arraysize; ++i) { ss3[i].msubfloat = i; ss3[i].msubstring = str_random(strings[i][0], stringsize); DDS_SEQ_INIT(ss3[i].msubstruct2); org_qeo_dynamic_qdm_test_Substruct2_t ss2[arraysize]; for (j = 0; j < arraysize; ++j) { ss2[j].msubshort = j*i; ss2[j].msubstring = str_random(strings[i][j+2], stringsize); } dds_seq_from_array(&ss3[i].msubstruct2, ss2, arraysize); } dds_seq_from_array(&t.msubstruct3, ss3, arraysize); DDS_SEQ_INIT(t.msubstruct1); org_qeo_dynamic_qdm_test_Substruct1_t ss1[arraysize]; for (i = 0; i < arraysize; ++i) { ss1[i].msubint32 = i; ss1[i].msubstring = str_random(strings[i][1], stringsize); } dds_seq_from_array(&t.msubstruct1, ss1, arraysize); rc = qeocore_writer_write(writer, &t); for(i = 0; i < DDS_SEQ_LENGTH(t.msubstruct3); ++i) { dds_seq_cleanup(&(DDS_SEQ_ITEM(t.msubstruct3, i).msubstruct2)); } dds_seq_cleanup(&t.msubstruct3); dds_seq_cleanup(&t.msubstruct1); return rc; }
static bool simplechat_ChatMessage_set_val_cb(uintptr_t out_data, const char *name, CDR_TypeCode_t type, qeo_t2d_types_t *value /* cast me */){ org_qeo_sample_simplechat_ChatMessage_t *chat_msg = (org_qeo_sample_simplechat_ChatMessage_t *)out_data; if (strcmp(name, "from") == 0){ chat_msg->from = strdup(value->string_val); } else if (strcmp(name, "fromExtra") == 0){ ck_assert_str_eq(value->typeref.name, org_qeo_UUID_type[0].name); value->typeref.ref = (uintptr_t)&chat_msg->fromExtra; value->typeref.ucbs = &_uuid_ucbs; } else if (strcmp(name, "message") == 0){ chat_msg->message = strdup(value->string_val); } else if (strcmp(name, "extraInfo") == 0){ value->seq.seq_ref = (uintptr_t)&chat_msg->extraInfo; value->seq.ucbs = &_sc_extraInfo_ucbs; DDS_SEQ_INIT(chat_msg->extraInfo); ck_assert_int_eq(dds_seq_require(&chat_msg->extraInfo,value->seq.seq_size), DDS_RETCODE_OK); printf("allocating extraInfo sequence with size %zu\n", value->seq.seq_size); } else if (strcmp(name, "list") == 0){ value->seq.seq_ref = (uintptr_t)&chat_msg->list; value->seq.ucbs = &_sc_list_ucbs; DDS_SEQ_INIT(chat_msg->list); ck_assert_int_eq(dds_seq_require(&chat_msg->list,value->seq.seq_size), DDS_RETCODE_OK); printf("allocating list sequence with size %zu\n", value->seq.seq_size); } else if (strcmp(name, "maincolor") == 0){ chat_msg->maincolor = value->enum_val; } else if (strcmp(name, "colorlist") == 0){ value->seq.seq_ref = (uintptr_t)&chat_msg->colorlist; value->seq.ucbs = &_sc_colorlist_ucbs; DDS_SEQ_INIT(chat_msg->colorlist); ck_assert_int_eq(dds_seq_require(&chat_msg->colorlist,value->seq.seq_size), DDS_RETCODE_OK); printf("allocating colorlist sequence with size %zu\n", value->seq.seq_size); } else { qeo_log_e("unknown field %s", name); return false; } return true; }
void ctt_send (Domain_t *dp, Participant_t *pp, Endpoint_t *sep, Endpoint_t *dep, DDS_ParticipantVolatileSecureMessage *msg) { Writer_t *wp; DDS_Time_t time; DDS_InstanceHandleSeq handles; DDS_InstanceHandle_t h; int error; CTT_ASSERT (dp); memcpy (msg->message_identity.source_guid, dp->participant.p_guid_prefix.prefix, 12); msg->message_identity.sequence_number = psmp_seqnr++; if (pp) memcpy (msg->destination_participant_key, pp->p_guid_prefix.prefix, 12); if (dep) { memcpy (msg->destination_endpoint_key, pp->p_guid_prefix.prefix, 12); memcpy (msg->destination_endpoint_key + 12, dep->entity_id.id, 4); memcpy (msg->source_endpoint_key, dp->participant.p_guid_prefix.prefix, 12); memcpy (msg->source_endpoint_key + 12, sep->entity_id.id, 4); } CTT_TRACE ('T', msg); wp = (Writer_t *) dp->participant.p_builtin_ep [EPB_PARTICIPANT_VOL_SEC_W]; /* Send participant data. */ if (pp) { DDS_SEQ_INIT (handles); h = pp->p_builtin_ep [EPB_PARTICIPANT_VOL_SEC_R]->entity.handle; DDS_SEQ_LENGTH (handles) = DDS_SEQ_MAXIMUM (handles) = 1; DDS_SEQ_DATA (handles) = &h; sys_gettime ((Time_t *) &time); error = DDS_DataWriter_write_w_timestamp_directed (wp, msg, 0, &time, &handles); if (error) fatal_printf ("ctt_send: error sending crypto tokens message!"); } else { sys_gettime ((Time_t *) &time); error = DDS_DataWriter_write_w_timestamp (wp, msg, 0, &time); if (error) fatal_printf ("ctt_send: error sending crypto tokens message!"); } CTT_ASSERT (dp); }
void DDS_Security_write_volatile_data (Domain_t *dp, DDS_DataHolder *dh) { DDS_ParticipantVolatileSecureMessage msg; DDS_ReturnCode_t error; memset (&msg, 0, sizeof (msg)); msg.message_class_id = GMCLASSID_SECURITY_VOL_DATA; DDS_SEQ_INIT (msg.message_data); error = dds_seq_require (&msg.message_data, 1); if (error) return; DDS_SEQ_ITEM (msg.message_data, 0) = *dh; ctt_send (dp, NULL, NULL, NULL, &msg); }
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); }
void introspect_annotation (DDS_AnnotationDescriptor *adp, int after) { unsigned i; DDS_ReturnCode_t ret; DDS_TypeDescriptor desc; DDS_Parameters pars; MapEntry_DDS_ObjectName_DDS_ObjectName *p; if (after) dbg_printf (" //"); DDS_TypeDescriptor__init (&desc); ret = DDS_DynamicType_get_descriptor (adp->type, &desc); fail_unless (ret == DDS_RETCODE_OK); dbg_printf ("@%s", desc.name); DDS_SEQ_INIT (pars); ret = DDS_AnnotationDescriptor_get_all_value (adp, &pars); fail_unless (ret == DDS_RETCODE_OK); if (DDS_SEQ_LENGTH (pars) == 1 && !strcmp (DDS_SEQ_ITEM (pars, 0).key, "value")) { /* Shorthand notation! */ if (strcmp (DDS_SEQ_ITEM (pars, 0).value, "true")) dbg_printf ("(%s)", DDS_SEQ_ITEM (pars, 0).value); } else { dbg_printf ("("); for (i = 0; i < DDS_SEQ_LENGTH (pars); i++) { if (i) dbg_printf (", "); p = DDS_SEQ_ITEM_PTR (pars, i); dbg_printf ("%s=\"%s\"", p->key, p->value); } dbg_printf (")"); } if (!after) dbg_printf (" "); DDS_Parameters__clear (&pars); DDS_TypeDescriptor__clear (&desc); }
DDS_ReturnCode_t DDS_Subscriber_get_datareaders (DDS_Subscriber sp, DDS_DataReaderSeq *readers, DDS_SampleStateMask sample_states, DDS_ViewStateMask view_states, DDS_InstanceStateMask instance_states) { Domain_t *dp; SubGReaders_t srd; DDS_ReturnCode_t ret; ctrc_begind (DCPS_ID, DCPS_S_G_DR_S, &sp, sizeof (sp)); ctrc_contd (&readers, sizeof (readers)); ctrc_contd (&sample_states, sizeof (sample_states)); ctrc_contd (&view_states, sizeof (view_states)); ctrc_contd (&instance_states, sizeof (instance_states)); ctrc_endd (); if (!readers) return (DDS_RETCODE_BAD_PARAMETER); srd.sp = subscriber_ptr (sp, &ret); if (!srd.sp) return (ret); DDS_SEQ_INIT (*readers); srd.rseq = readers; srd.skip = dcps_skip_mask (sample_states, view_states, instance_states); srd.ret = DDS_RETCODE_OK; dp = srd.sp->domain; if (!dp || lock_take (dp->lock)) return (DDS_RETCODE_ALREADY_DELETED); sl_walk (&dp->participant.p_endpoints, subscriber_get_reader, &srd); lock_release (dp->lock); return (srd.ret); }
void test_dyn_array1 (void) { DDS_DynamicTypeSupport ts; DDS_DynamicTypeBuilder sb, abc20; DDS_TypeDescriptor *desc; DDS_MemberDescriptor *md; DDS_DynamicType s, ac20; DDS_BoundSeq bounds; DDS_DynamicData dd, dda, dd2; DDS_ReturnCode_t rc; unsigned i; v_printf ("test_dyn_array1 - "); /* 1. Create the type. */ desc = DDS_TypeDescriptor__alloc (); fail_unless (desc != NULL); desc->kind = DDS_STRUCTURE_TYPE; desc->name = "dstruct1"; sb = DDS_DynamicTypeBuilderFactory_create_type (desc); fail_unless (sb != NULL); md = DDS_MemberDescriptor__alloc (); fail_unless (md != NULL); DDS_SEQ_INIT (bounds); dds_seq_require (&bounds, 1); DDS_SEQ_LENGTH (bounds) = 1; DDS_SEQ_ITEM (bounds, 0) = 20; abc20 = DDS_DynamicTypeBuilderFactory_create_array_type ( DDS_DynamicTypeBuilderFactory_get_primitive_type (DDS_CHAR_8_TYPE), &bounds); fail_unless (abc20 != NULL); dds_seq_cleanup (&bounds); ac20 = DDS_DynamicTypeBuilder_build (abc20); fail_unless (ac20 != NULL); DDS_DynamicTypeBuilderFactory_delete_type (abc20); md->name = "char_a"; md->index = md->id = 0; md->type = ac20; rc = DDS_DynamicTypeBuilder_add_member (sb, md); fail_unless (rc == DDS_RETCODE_OK); s = DDS_DynamicTypeBuilder_build (sb); fail_unless (s != NULL); DDS_DynamicTypeBuilderFactory_delete_type (sb); ts = DDS_DynamicTypeSupport_create_type_support (s); fail_unless (ts != NULL); DDS_TypeDescriptor__free (desc); DDS_MemberDescriptor__free (md); /* 2. Create a Dynamic Data item for this type. */ dd = DDS_DynamicDataFactory_create_data (s); fail_unless (dd != NULL); dda = DDS_DynamicDataFactory_create_data (ac20); fail_unless (dda != NULL); for (i = 0; i < 20; i++) { SET_FIELD (dda, i, char8, i + '0'); } SET_FIELD (dd, 0, complex, dda); marshallDynamic (dd, &dd2, ts); DDS_DynamicDataFactory_delete_data (dd); DDS_DynamicDataFactory_delete_data (dda); DDS_DynamicTypeBuilderFactory_delete_type (ac20); DDS_DynamicTypeBuilderFactory_delete_type (s); DDS_DynamicTypeSupport_delete_type_support (ts); v_printf ("success!\r\n"); }
void test_dyn_oseq (void) { DDS_DynamicTypeSupport ts; DDS_DynamicTypeBuilder sb, oseqb; DDS_TypeDescriptor *desc; DDS_MemberDescriptor *md; DDS_DynamicType s, oseq; DDS_DynamicData dd, dda, dd2; DDS_ReturnCode_t rc; DDS_ByteSeq values; unsigned i; v_printf ("test_dyn_oseq - "); /* 1. Create the type. */ desc = DDS_TypeDescriptor__alloc (); fail_unless (desc != NULL); desc->kind = DDS_STRUCTURE_TYPE; desc->name = "dstruct3"; sb = DDS_DynamicTypeBuilderFactory_create_type (desc); fail_unless (sb != NULL); md = DDS_MemberDescriptor__alloc (); fail_unless (md != NULL); ADD_FIELD (sb, md, "anuint", 0, 0, DDS_UINT_32_TYPE); oseqb = DDS_DynamicTypeBuilderFactory_create_sequence_type ( DDS_DynamicTypeBuilderFactory_get_primitive_type (DDS_BYTE_TYPE), 0); fail_unless (oseqb != NULL); oseq = DDS_DynamicTypeBuilder_build (oseqb); fail_unless (oseq != NULL); DDS_DynamicTypeBuilderFactory_delete_type (oseqb); md->name = "oseq"; md->index = md->id = 1; md->type = oseq; rc = DDS_DynamicTypeBuilder_add_member (sb, md); fail_unless (rc == DDS_RETCODE_OK); ADD_FIELD (sb, md, "ch", 2, 2, DDS_CHAR_8_TYPE); s = DDS_DynamicTypeBuilder_build (sb); fail_unless (s != NULL); DDS_DynamicTypeBuilderFactory_delete_type (sb); ts = DDS_DynamicTypeSupport_create_type_support (s); fail_unless (ts != NULL); DDS_TypeDescriptor__free (desc); DDS_MemberDescriptor__free (md); /* 2. Create a Dynamic Data item for this type. */ dd = DDS_DynamicDataFactory_create_data (s); fail_unless (dd != NULL); dda = DDS_DynamicDataFactory_create_data (oseq); fail_unless (dda != NULL); SET_FIELD (dd, 0, uint32, 1000); DDS_SEQ_INIT (values); rc = dds_seq_require (&values, 21); fail_unless (rc == DDS_RETCODE_OK); for (i = 0; i < 21; i++) DDS_SEQ_ITEM (values, i) = i + '0'; rc = DDS_DynamicData_set_byte_values (dda, 0, &values); fail_unless (rc == DDS_RETCODE_OK); SET_FIELD (dd, 1, complex, dda); SET_FIELD (dd, 2, char8, 'X'); marshallDynamic (dd, &dd2, ts); DDS_DynamicDataFactory_delete_data (dd); DDS_DynamicDataFactory_delete_data (dda); DDS_DynamicTypeBuilderFactory_delete_type (oseq); DDS_DynamicTypeBuilderFactory_delete_type (s); DDS_DynamicTypeSupport_delete_type_support (ts); v_printf ("success!\r\n"); }
void test_dyn_array2 (void) { DDS_DynamicTypeSupport ts; DDS_DynamicTypeBuilder sb1, sb1a, abi64, abs1a; DDS_DynamicType s1, s1a, ai64, as1a; DDS_TypeDescriptor *desc; DDS_MemberDescriptor *md; DDS_DynamicData dd, dds, dda, ddas, dd2; DDS_ReturnCode_t rc; DDS_BoundSeq bounds; unsigned i, j; v_printf ("test_dyn_array2 - "); /* 1. Create the type. */ desc = DDS_TypeDescriptor__alloc (); fail_unless (desc != NULL); desc->kind = DDS_STRUCTURE_TYPE; desc->name = "dstruct2a"; sb1a = DDS_DynamicTypeBuilderFactory_create_type (desc); fail_unless (sb1a != NULL); md = DDS_MemberDescriptor__alloc (); fail_unless (md != NULL); DDS_SEQ_INIT (bounds); dds_seq_require (&bounds, 1); DDS_SEQ_LENGTH (bounds) = 1; DDS_SEQ_ITEM (bounds, 0) = 5; abi64 = DDS_DynamicTypeBuilderFactory_create_array_type ( DDS_DynamicTypeBuilderFactory_get_primitive_type (DDS_INT_64_TYPE), &bounds); fail_unless (abi64 != NULL); ai64 = DDS_DynamicTypeBuilder_build (abi64); fail_unless (ai64 != NULL); DDS_DynamicTypeBuilderFactory_delete_type (abi64); md->name = "i64"; md->index = md->id = 0; md->type = ai64; rc = DDS_DynamicTypeBuilder_add_member (sb1a, md); fail_unless (rc == DDS_RETCODE_OK); ADD_FIELD (sb1a, md, "ch", 1, 1, DDS_CHAR_8_TYPE); s1a = DDS_DynamicTypeBuilder_build (sb1a); fail_unless (s1a != NULL); DDS_DynamicTypeBuilderFactory_delete_type (sb1a); DDS_SEQ_ITEM (bounds, 0) = 7; abs1a = DDS_DynamicTypeBuilderFactory_create_array_type (s1a, &bounds); fail_unless (abs1a != NULL); dds_seq_cleanup (&bounds); as1a = DDS_DynamicTypeBuilder_build (abs1a); fail_unless (as1a != NULL); DDS_DynamicTypeBuilderFactory_delete_type (abs1a); desc->kind = DDS_STRUCTURE_TYPE; desc->name = "dstruct2"; sb1 = DDS_DynamicTypeBuilderFactory_create_type (desc); fail_unless (sb1 != NULL); ADD_FIELD (sb1, md, "c", 0, 0, DDS_CHAR_8_TYPE); md->name = "str2"; md->index = md->id = 1; md->type = as1a; rc = DDS_DynamicTypeBuilder_add_member (sb1, md); fail_unless (rc == DDS_RETCODE_OK); ADD_FIELD (sb1, md, "u16", 2, 2, DDS_UINT_16_TYPE); s1 = DDS_DynamicTypeBuilder_build (sb1); fail_unless (s1 != NULL); DDS_DynamicTypeBuilderFactory_delete_type (sb1); ts = DDS_DynamicTypeSupport_create_type_support (s1); fail_unless (ts != NULL); DDS_TypeDescriptor__free (desc); DDS_MemberDescriptor__free (md); /* 2. Create a Dynamic Data item for this type. */ dd = DDS_DynamicDataFactory_create_data (s1); fail_unless (dd != NULL); ddas = DDS_DynamicDataFactory_create_data (as1a); fail_unless (ddas != NULL); SET_FIELD (dd, 0, char8, 'A'); for (i = 0; i < 7; i++) { dds = DDS_DynamicDataFactory_create_data (s1a); fail_unless (dds != NULL); dda = DDS_DynamicDataFactory_create_data (ai64); fail_unless (dda != NULL); for (j = 0; j < 5; j++) { SET_FIELD (dda, j, int64, ((i + 6) * j) << i); } SET_FIELD (dds, 0, complex, dda); DDS_DynamicDataFactory_delete_data (dda); SET_FIELD (dds, 1, char8, i + 0x30); SET_FIELD (ddas, i, complex, dds); DDS_DynamicDataFactory_delete_data (dds); } SET_FIELD (dd, 1, complex, ddas); DDS_DynamicDataFactory_delete_data (ddas); SET_FIELD (dd, 2, uint16, 1366); marshallDynamic (dd, &dd2, ts); DDS_DynamicDataFactory_delete_data (dd); DDS_DynamicTypeBuilderFactory_delete_type (s1); DDS_DynamicTypeBuilderFactory_delete_type (as1a); DDS_DynamicTypeBuilderFactory_delete_type (s1a); DDS_DynamicTypeBuilderFactory_delete_type (ai64); DDS_DynamicTypeSupport_delete_type_support (ts); v_printf ("success!\r\n"); }
DDS_ReturnCode_t DDS_DataWriter_get_reply_subscriptions( DDS_DataWriter wp, DDS_InstanceHandle_t publication_handle, DDS_InstanceHandleSeq *handles) { Endpoint_t *rwp; Participant_t *pp; Entity_t *p; Topic_t *tp; Endpoint_t *ep; FilteredTopic_t *ftp; DDS_ReturnCode_t ret; ctrc_begind (DCPS_ID, DCPS_DW_G_REPLY_S, &wp, sizeof (wp)); ctrc_contd (&handles, sizeof (handles)); ctrc_endd (); p = entity_ptr (publication_handle); if (!p || p->type != ET_WRITER || !handles) return (DDS_RETCODE_BAD_PARAMETER); rwp = (Endpoint_t *) p; if ((rwp->entity.flags & EF_LOCAL) != 0) pp = &rwp->u.publisher->domain->participant; else pp = rwp->u.participant; DDS_SEQ_INIT (*handles); if (!writer_ptr (wp, 0, &ret)) return (ret); tp = wp->w_topic; if (lock_take (tp->lock)) return (DDS_RETCODE_ALREADY_DELETED); #ifndef RW_TOPIC_LOCK if (lock_take (wp->w_lock)) { lock_release (tp->lock); return (DDS_RETCODE_ALREADY_DELETED); } #endif for (ep = tp->writers; ep && ep != &wp->w_ep; ep = ep->next) ; if (!ep) { ret = DDS_RETCODE_ALREADY_DELETED; goto done; } for (ep = tp->readers; ep; ep = ep->next) if (check_matched_subscription (wp, ep, handles, pp)) { ret = DDS_RETCODE_OUT_OF_RESOURCES; goto done; } for (ftp = tp->filters; ftp; ftp = ftp->next) for (ep = ftp->topic.readers; ep; ep = ep->next) if (check_matched_subscription (wp, ep, handles, pp)) { ret = DDS_RETCODE_OUT_OF_RESOURCES; goto done; } done: #ifndef RW_TOPIC_LOCK lock_release (wp->w_lock); #endif lock_release (tp->lock); return (ret); }
void test_dyn_mutable1 (void) { DDS_DynamicTypeSupport ts; DDS_DynamicTypeBuilder sb2, ostb; DDS_DynamicType s2, ot, ost; DDS_TypeDescriptor *desc; DDS_MemberDescriptor *md; DDS_DynamicData dd, dd2, dds; DDS_ReturnCode_t rc; DDS_ByteSeq bseq; unsigned char values [] = { 0x22, 0x33, 0x4f, 0x5e, 0x6d, 0x7c, 0x8b }; v_printf ("test_mutable1 - "); /* 1. Create the type. */ desc = DDS_TypeDescriptor__alloc (); fail_unless (desc != NULL); desc->kind = DDS_STRUCTURE_TYPE; desc->name = "dstruct1m"; sb2 = DDS_DynamicTypeBuilderFactory_create_type (desc); fail_unless (sb2 != NULL); md = DDS_MemberDescriptor__alloc (); fail_unless (md != NULL); ADD_FIELD (sb2, md, "i16", 0, 99, DDS_INT_16_TYPE); set_id_annotation (sb2, "i16", 20); ADD_FIELD (sb2, md, "u32", 1, 2, DDS_UINT_32_TYPE); set_key_annotation (sb2, "u32"); ADD_FIELD (sb2, md, "i32", 2, 100, DDS_INT_32_TYPE); set_id_annotation (sb2, "i32", 50); ADD_FIELD (sb2, md, "u16", 0, DDS_MEMBER_ID_INVALID, DDS_UINT_16_TYPE); set_id_annotation (sb2, "u16", 10); set_key_annotation (sb2, "u16"); ADD_FIELD (sb2, md, "u64", 5, 51, DDS_UINT_64_TYPE); ADD_FIELD (sb2, md, "i64", 5, DDS_MEMBER_ID_INVALID, DDS_INT_64_TYPE); ADD_FIELD (sb2, md, "fl", 6, 53, DDS_FLOAT_32_TYPE); ADD_FIELD (sb2, md, "d", 7, 54, DDS_FLOAT_64_TYPE); ADD_FIELD (sb2, md, "ch", 8, 55, DDS_CHAR_8_TYPE); set_id_annotation (sb2, "ch", 5); set_key_annotation (sb2, "ch"); set_id_annotation (sb2, "fl", 4); ot = DDS_DynamicTypeBuilderFactory_get_primitive_type (DDS_BYTE_TYPE); fail_unless (ot != NULL); ostb = DDS_DynamicTypeBuilderFactory_create_sequence_type (ot, DDS_UNBOUNDED_COLLECTION); fail_unless (ostb != NULL); ost = DDS_DynamicTypeBuilder_build (ostb); fail_unless (ost != NULL); DDS_DynamicTypeBuilderFactory_delete_type (ostb); md->name = "s"; md->index = 9; md->id = 9; md->type = ost; rc = DDS_DynamicTypeBuilder_add_member (sb2, md); fail_unless (rc == DDS_RETCODE_OK); set_ext_annotation (sb2, "MUTABLE_EXTENSIBILITY"); s2 = DDS_DynamicTypeBuilder_build (sb2); fail_unless (s2 != NULL); DDS_DynamicTypeBuilderFactory_delete_type (sb2); ts = DDS_DynamicTypeSupport_create_type_support (s2); fail_unless (ts != NULL); DDS_TypeDescriptor__free (desc); DDS_MemberDescriptor__free (md); /* 2. Create a Dynamic data item for this type. */ dd = DDS_DynamicDataFactory_create_data (s2); fail_unless (dd != NULL); SET_FIELD (dd, 50, int32, -5); SET_FIELD (dd, 10, uint16, 0xDEAD); SET_FIELD (dd, 20, int16, INT16_MIN); SET_FIELD (dd, 2, uint32, UINT32_MAX); SET_FIELD (dd, 52, int64, 100); SET_FIELD (dd, 4, float32, 0.5f); SET_FIELD (dd, 54, float64, 100e-5); SET_FIELD (dd, 5, char8, 'd'); SET_FIELD (dd, 51, uint64, 5010000); dds = DDS_DynamicDataFactory_create_data (ost); fail_unless (dds != NULL); DDS_SEQ_INIT (bseq); dds_seq_from_array (&bseq, values, sizeof (values)); rc = DDS_DynamicData_set_byte_values (dds, 0, &bseq); dds_seq_cleanup (&bseq); fail_unless (rc == DDS_RETCODE_OK); SET_FIELD (dd, 9, complex, dds); marshallDynamic (dd, &dd2, ts); DDS_DynamicDataFactory_delete_data (dd); DDS_DynamicDataFactory_delete_data (dds); DDS_DynamicTypeBuilderFactory_delete_type (s2); DDS_DynamicTypeBuilderFactory_delete_type (ost); DDS_DynamicTypeSupport_delete_type_support (ts); set_id_annotation (NULL, NULL, 0); set_key_annotation (NULL, NULL); set_ext_annotation (NULL, NULL); v_printf ("success!\r\n"); }
void DDS_TopicBuiltinTopicData__init (DDS_TopicBuiltinTopicData *data) { memset (data, 0, sizeof (DDS_TopicBuiltinTopicData)); DDS_SEQ_INIT (data->topic_data.value); }
void test_dyn_mutable2 (void) { DDS_DynamicTypeSupport ts; DDS_DynamicTypeBuilder sb2, stb, sstb; DDS_DynamicType s2, st, sst; DDS_TypeDescriptor *desc; DDS_MemberDescriptor *md; DDS_DynamicData dd, dd2, dds; DDS_ReturnCode_t rc; DDS_StringSeq ss; unsigned n; char *strings [] = { "Hi there", "blabla", "\0", NULL, "got here", "not yet done", "", "num8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "done :)" }; v_printf ("test_mutable2 - "); /* 1. Create the type. */ desc = DDS_TypeDescriptor__alloc (); fail_unless (desc != NULL); desc->kind = DDS_STRUCTURE_TYPE; desc->name = "dstruct2m"; sb2 = DDS_DynamicTypeBuilderFactory_create_type (desc); fail_unless (sb2 != NULL); md = DDS_MemberDescriptor__alloc (); fail_unless (md != NULL); ADD_FIELD (sb2, md, "u16", 0, 5, DDS_UINT_16_TYPE); set_key_annotation (sb2, "u16"); stb = DDS_DynamicTypeBuilderFactory_create_string_type (DDS_UNBOUNDED_COLLECTION); fail_unless (stb != NULL); st = DDS_DynamicTypeBuilder_build (stb); fail_unless (st != NULL); DDS_DynamicTypeBuilderFactory_delete_type (stb); sstb = DDS_DynamicTypeBuilderFactory_create_sequence_type (st, DDS_UNBOUNDED_COLLECTION); fail_unless (sstb != NULL); sst = DDS_DynamicTypeBuilder_build (sstb); fail_unless (sst != NULL); DDS_DynamicTypeBuilderFactory_delete_type (sstb); md->name = "s"; md->index = 1; md->id = 6; md->type = sst; rc = DDS_DynamicTypeBuilder_add_member (sb2, md); fail_unless (rc == DDS_RETCODE_OK); set_ext_annotation (sb2, "MUTABLE_EXTENSIBILITY"); s2 = DDS_DynamicTypeBuilder_build (sb2); fail_unless (s2 != NULL); DDS_DynamicTypeBuilderFactory_delete_type (sb2); ts = DDS_DynamicTypeSupport_create_type_support (s2); fail_unless (ts != NULL); DDS_TypeDescriptor__free (desc); DDS_MemberDescriptor__free (md); /* 2. Create a Dynamic data item for this type. */ DDS_SEQ_INIT (ss); dds_seq_from_array (&ss, strings, sizeof (strings) / sizeof (char *)); for (n = 0; n <= DDS_SEQ_MAXIMUM (ss); n++) { dd = DDS_DynamicDataFactory_create_data (s2); fail_unless (dd != NULL); SET_FIELD (dd, 5, uint16, n); dds = DDS_DynamicDataFactory_create_data (sst); fail_unless (dds != NULL); DDS_SEQ_LENGTH (ss) = n; rc = DDS_DynamicData_set_string_values (dds, 0, &ss); fail_unless (rc == DDS_RETCODE_OK); SET_FIELD (dd, 6, complex, dds); marshallDynamic (dd, &dd2, ts); DDS_DynamicDataFactory_delete_data (dd); DDS_DynamicDataFactory_delete_data (dds); if (n > 2) { n += 3; if (n == 18) n++; } } dds_seq_cleanup (&ss); DDS_DynamicTypeBuilderFactory_delete_type (s2); DDS_DynamicTypeBuilderFactory_delete_type (sst); DDS_DynamicTypeBuilderFactory_delete_type (st); DDS_DynamicTypeSupport_delete_type_support (ts); set_key_annotation (NULL, NULL); set_ext_annotation (NULL, NULL); v_printf ("success!\r\n"); }
void DDS_ParticipantBuiltinTopicData__init (DDS_ParticipantBuiltinTopicData *data) { DDS_SEQ_INIT (data->user_data.value); }
void DDS_OctetSeq__init (DDS_OctetSeq *octets) { DDS_SEQ_INIT (*octets); }
void DDS_StringSeq__init (DDS_StringSeq *strings) { DDS_SEQ_INIT (*strings); }