UA_Client * UA_Client_new(void) { UA_Client *client = UA_malloc(sizeof(UA_Client)); if(!client) return UA_NULL; UA_String_init(&client->endpointUrl); client->connection.state = UA_CONNECTION_OPENING; client->sequenceNumber = 0; client->requestId = 0; /* Secure Channel */ UA_ChannelSecurityToken_deleteMembers(&client->securityToken); UA_ByteString_init(&client->clientNonce); UA_ByteString_init(&client->serverNonce); UA_NodeId_init(&client->authenticationToken); return client; }
static void variables_basic(void) { /* Int32 */ UA_Int32 i = 5; UA_Int32 j; UA_Int32_copy(&i, &j); UA_Int32 *ip = UA_Int32_new(); UA_Int32_copy(&i, ip); UA_Int32_delete(ip); /* String */ UA_String s; UA_String_init(&s); /* _init zeroes out the entire memory of the datatype */ char *test = "test"; s.length = strlen(test); s.data = (UA_Byte*)test; UA_String s2; UA_String_copy(&s, &s2); UA_String_deleteMembers(&s2); /* Copying heap-allocated the dynamic content */ UA_String s3 = UA_STRING("test2"); UA_String s4 = UA_STRING_ALLOC("test2"); /* Copies the content to the heap */ UA_Boolean eq = UA_String_equal(&s3, &s4); UA_String_deleteMembers(&s4); if(!eq) return; /* Structured Type */ UA_ReadRequest rr; UA_init(&rr, &UA_TYPES[UA_TYPES_READREQUEST]); /* Generic method */ UA_ReadRequest_init(&rr); /* Shorthand for the previous line */ rr.requestHeader.timestamp = UA_DateTime_now(); /* Members of a structure */ rr.nodesToRead = (UA_ReadValueId *)UA_Array_new(5, &UA_TYPES[UA_TYPES_READVALUEID]); rr.nodesToReadSize = 5; /* Array size needs to be made known */ UA_ReadRequest *rr2 = UA_ReadRequest_new(); UA_copy(&rr, rr2, &UA_TYPES[UA_TYPES_READREQUEST]); UA_ReadRequest_deleteMembers(&rr); UA_ReadRequest_delete(rr2); }
static void UA_Client_init(UA_Client* client, UA_ClientConfig config, UA_Logger logger) { client->state = UA_CLIENTSTATE_READY; UA_Connection_init(&client->connection); UA_SecureChannel_init(&client->channel); client->channel.connection = &client->connection; UA_String_init(&client->endpointUrl); client->requestId = 0; UA_NodeId_init(&client->authenticationToken); client->requestHandle = 0; client->logger = logger; client->config = config; client->scExpiresAt = 0; #ifdef ENABLE_SUBSCRIPTIONS client->monitoredItemHandles = 0; LIST_INIT(&client->pendingNotificationsAcks); LIST_INIT(&client->subscriptions); #endif }
UA_Int32 UA_NodeSetAlias_init(UA_NodeSetAlias *p) { UA_String_init(&(p->alias)); UA_String_init(&(p->value)); return UA_SUCCESS; }