Parcourir la source

Merge branch 'master' of https://github.com/acplt/open62541

Florian Palm il y a 10 ans
Parent
commit
b518a55d29

+ 2 - 3
CMakeLists.txt

@@ -1,7 +1,7 @@
 cmake_minimum_required(VERSION 2.6)
 # set(CMAKE_VERBOSE_MAKEFILE on )
 
-project(open62541)
+project(open62541 C)
 set(open62541_VERSION_MAJOR 0)
 set(open62541_VERSION_MINOR 1)
 
@@ -21,8 +21,7 @@ set(lib_sources src/ua_types.c
 				src/ua_connection.c
                 src/ua_securechannel.c
                 src/ua_session.c
-                src/util/ua_util.c
-                src/util/ua_list.c
+                src/ua_util.c
                 #src/util/ua_base64.c
                 src/server/ua_server.c
                 src/server/ua_securechannel_manager.c

+ 8 - 14
include/ua_types.h

@@ -240,7 +240,7 @@ typedef struct UA_VariantDataSource {
  * Variants store (arrays of) built-in types. If you want to store a more
  * complex (or self-defined) type, you have to use an UA_ExtensionObject.*/
 typedef struct UA_Variant {
-    UA_VTable_Entry *vt; // internal entry into vTable
+    const UA_VTable_Entry *vt; // internal entry into vTable
     enum {
         UA_VARIANT_DATA,
         UA_VARIANT_DATA_NODELETE, // do not free the data (e.g. because it is "borrowed" and points into a larger structure)
@@ -425,18 +425,18 @@ void UA_LIBEXPORT UA_QualifiedName_printf(char const *label, const UA_QualifiedN
 UA_Int32 UA_LIBEXPORT UA_LocalizedText_copycstring(char const *src, UA_LocalizedText *dst);
 
 /* Variant */
-UA_Int32 UA_LIBEXPORT UA_Variant_copySetValue(UA_Variant *v, UA_VTable_Entry *vt, const void *value);
-UA_Int32 UA_LIBEXPORT UA_Variant_copySetArray(UA_Variant *v, UA_VTable_Entry *vt, UA_Int32 arrayLength, const void *array);
+UA_Int32 UA_LIBEXPORT UA_Variant_copySetValue(UA_Variant *v, const UA_VTable_Entry *vt, const void *value);
+UA_Int32 UA_LIBEXPORT UA_Variant_copySetArray(UA_Variant *v, const UA_VTable_Entry *vt, UA_Int32 arrayLength, const void *array);
 
 /* Array operations */
-UA_Int32 UA_LIBEXPORT UA_Array_new(void **p, UA_Int32 noElements, UA_VTable_Entry *vt);
-void UA_LIBEXPORT UA_Array_init(void *p, UA_Int32 noElements, UA_VTable_Entry *vt);
-void UA_LIBEXPORT UA_Array_delete(void *p, UA_Int32 noElements, UA_VTable_Entry *vt);
+UA_Int32 UA_LIBEXPORT UA_Array_new(void **p, UA_Int32 noElements, const UA_VTable_Entry *vt);
+void UA_LIBEXPORT UA_Array_init(void *p, UA_Int32 noElements, const UA_VTable_Entry *vt);
+void UA_LIBEXPORT UA_Array_delete(void *p, UA_Int32 noElements, const UA_VTable_Entry *vt);
 
 /* @brief The destination array is allocated according to noElements. */
-UA_Int32 UA_LIBEXPORT UA_Array_copy(const void *src, UA_Int32 noElements, UA_VTable_Entry *vt, void **dst);
+UA_Int32 UA_LIBEXPORT UA_Array_copy(const void *src, UA_Int32 noElements, const UA_VTable_Entry *vt, void **dst);
 #ifdef DEBUG
-void UA_LIBEXPORT UA_Array_print(const void *p, UA_Int32 noElements, UA_VTable_Entry *vt, FILE *stream);
+void UA_LIBEXPORT UA_Array_print(const void *p, UA_Int32 noElements, const UA_VTable_Entry *vt, FILE *stream);
 #endif
 
 /**********/
@@ -472,12 +472,6 @@ struct UA_VTable_Entry {
     UA_Encoding encodings[UA_ENCODING_AMOUNT]; // binary, xml, ... UA_ENCODING_AMOUNT is set by the build script
 };
 
-typedef UA_Int32 (*UA_nodeIdToVTableIndex)(const UA_NodeId *id);
-typedef struct UA_VTable {
-    UA_nodeIdToVTableIndex getTypeIndex;
-    UA_VTable_Entry       *types;
-} UA_VTable;
-
 /***********************************/
 /* Macros for type implementations */
 /***********************************/

src/util/ua_base64.c → src/ongoing/ua_base64.c


src/util/ua_base64.h → src/ongoing/ua_base64.h


+ 1 - 1
src/server/ua_nodestore.c

@@ -1,5 +1,5 @@
 #include "ua_nodestore.h"
-#include "util/ua_util.h"
+#include "ua_util.h"
 
 struct UA_NodeStore {
     const UA_Node **entries;

+ 1 - 1
src/server/ua_nodestore_concurrent.c

@@ -1,5 +1,5 @@
 #include "ua_nodestore.h"
-#include "util/ua_util.h"
+#include "ua_util.h"
 
 #include <urcu.h>
 #include <urcu/compiler.h> // for caa_container_of

+ 1 - 1
src/server/ua_securechannel_manager.c

@@ -1,5 +1,5 @@
 #include "ua_securechannel_manager.h"
-#include "util/ua_util.h"
+#include "ua_util.h"
 
 struct channel_list_entry {
     UA_SecureChannel channel;

+ 5 - 5
src/server/ua_server.c

@@ -3,7 +3,7 @@
 #include "ua_namespace_0.h"
 #include "ua_securechannel_manager.h"
 #include "ua_session_manager.h"
-#include "util/ua_util.h"
+#include "ua_util.h"
 
 UA_Int32 UA_Server_deleteMembers(UA_Server *server) {
     UA_ApplicationDescription_deleteMembers(&server->description);
@@ -461,8 +461,8 @@ void UA_Server_init(UA_Server *server, UA_String *endpointUrl) {
     UA_QualifiedName_copycstring("NodeStoreArray", &namespaceArray->browseName);
     UA_LocalizedText_copycstring("NodeStoreArray", &namespaceArray->displayName);
     UA_LocalizedText_copycstring("NodeStoreArray", &namespaceArray->description);
-    UA_Array_new((void **)&namespaceArray->value.storage.data.dataPtr, 2, &UA_.types[UA_STRING]);
-    namespaceArray->value.vt = &UA_.types[UA_STRING];
+    UA_Array_new((void **)&namespaceArray->value.storage.data.dataPtr, 2, &UA_[UA_STRING]);
+    namespaceArray->value.vt = &UA_[UA_STRING];
     namespaceArray->value.storage.data.arrayLength = 2;
     UA_String_copycstring("http://opcfoundation.org/UA/", &((UA_String *)(namespaceArray->value.storage.data.dataPtr))[0]);
     UA_String_copycstring("http://localhost:16664/open62541/", &((UA_String *)(namespaceArray->value.storage.data.dataPtr))[1]);
@@ -498,7 +498,7 @@ void UA_Server_init(UA_Server *server, UA_String *endpointUrl) {
     status->buildInfo.buildDate     = UA_DateTime_now();
     status->secondsTillShutdown     = 99999999;
     UA_LocalizedText_copycstring("because", &status->shutdownReason);
-    serverstatus->value.vt          = &UA_.types[UA_SERVERSTATUSDATATYPE]; // gets encoded as an extensionobject
+    serverstatus->value.vt          = &UA_[UA_SERVERSTATUSDATATYPE]; // gets encoded as an extensionobject
     serverstatus->value.storage.data.arrayLength = 1;
     serverstatus->value.storage.data.dataPtr        = status;
     UA_NodeStore_insert(server->nodestore, (UA_Node**)&serverstatus, UA_NODESTORE_INSERT_UNIQUE);
@@ -511,7 +511,7 @@ void UA_Server_init(UA_Server *server, UA_String *endpointUrl) {
     UA_QualifiedName_copycstring("State", &state->browseName);
     UA_LocalizedText_copycstring("State", &state->displayName);
     UA_LocalizedText_copycstring("State", &state->description);
-    state->value.vt = &UA_.types[UA_SERVERSTATE];
+    state->value.vt = &UA_[UA_SERVERSTATE];
     state->value.storage.data.arrayDimensionsLength = 1; // added to ensure encoding in readreponse
     state->value.storage.data.arrayLength = 1;
     state->value.storage.data.dataPtr = &status->state; // points into the other object.

+ 1 - 1
src/server/ua_server_binary.c

@@ -4,7 +4,7 @@
 #include "ua_namespace_0.h"
 #include "ua_securechannel_manager.h"
 #include "ua_session_manager.h"
-#include "util/ua_util.h"
+#include "ua_util.h"
 
 static UA_Int32 UA_ByteStringArray_init(UA_ByteStringArray *stringarray, UA_UInt32 length) {
     if(!stringarray || length == 0)

+ 23 - 23
src/server/ua_services_attribute.c

@@ -2,7 +2,7 @@
 #include "ua_statuscodes.h"
 #include "ua_nodestore.h"
 #include "ua_namespace_0.h"
-#include "util/ua_util.h"
+#include "ua_util.h"
 
 enum UA_AttributeId {
     UA_ATTRIBUTEID_NODEID = 1,
@@ -52,39 +52,39 @@ static UA_DataValue service_read_node(UA_Server *server, const UA_ReadValueId *i
     switch(id->attributeId) {
     case UA_ATTRIBUTEID_NODEID:
         v.encodingMask = UA_DATAVALUE_ENCODINGMASK_VARIANT;
-        retval |= UA_Variant_copySetValue(&v.value, &UA_.types[UA_NODEID], &node->nodeId);
+        retval |= UA_Variant_copySetValue(&v.value, &UA_[UA_NODEID], &node->nodeId);
         break;
 
     case UA_ATTRIBUTEID_NODECLASS:
         v.encodingMask = UA_DATAVALUE_ENCODINGMASK_VARIANT;
-        retval |= UA_Variant_copySetValue(&v.value, &UA_.types[UA_INT32], &node->nodeClass);
+        retval |= UA_Variant_copySetValue(&v.value, &UA_[UA_INT32], &node->nodeClass);
         break;
 
     case UA_ATTRIBUTEID_BROWSENAME:
         v.encodingMask = UA_DATAVALUE_ENCODINGMASK_VARIANT;
-        retval |= UA_Variant_copySetValue(&v.value, &UA_.types[UA_QUALIFIEDNAME], &node->browseName);
+        retval |= UA_Variant_copySetValue(&v.value, &UA_[UA_QUALIFIEDNAME], &node->browseName);
         break;
 
     case UA_ATTRIBUTEID_DISPLAYNAME:
         v.encodingMask = UA_DATAVALUE_ENCODINGMASK_VARIANT;
-        retval |= UA_Variant_copySetValue(&v.value, &UA_.types[UA_LOCALIZEDTEXT],
+        retval |= UA_Variant_copySetValue(&v.value, &UA_[UA_LOCALIZEDTEXT],
                                           &node->displayName);
         break;
 
     case UA_ATTRIBUTEID_DESCRIPTION:
         v.encodingMask = UA_DATAVALUE_ENCODINGMASK_VARIANT;
-        retval |= UA_Variant_copySetValue(&v.value, &UA_.types[UA_LOCALIZEDTEXT],
+        retval |= UA_Variant_copySetValue(&v.value, &UA_[UA_LOCALIZEDTEXT],
                                           &node->description);
         break;
 
     case UA_ATTRIBUTEID_WRITEMASK:
         v.encodingMask = UA_DATAVALUE_ENCODINGMASK_VARIANT;
-        retval |= UA_Variant_copySetValue(&v.value, &UA_.types[UA_UINT32], &node->writeMask);
+        retval |= UA_Variant_copySetValue(&v.value, &UA_[UA_UINT32], &node->writeMask);
         break;
 
     case UA_ATTRIBUTEID_USERWRITEMASK:
         v.encodingMask = UA_DATAVALUE_ENCODINGMASK_VARIANT;
-        retval |= UA_Variant_copySetValue(&v.value, &UA_.types[UA_UINT32], &node->userWriteMask);
+        retval |= UA_Variant_copySetValue(&v.value, &UA_[UA_UINT32], &node->userWriteMask);
         break;
 
     case UA_ATTRIBUTEID_ISABSTRACT:
@@ -93,35 +93,35 @@ static UA_DataValue service_read_node(UA_Server *server, const UA_ReadValueId *i
             UA_NODECLASS_DATATYPE);
         v.encodingMask = UA_DATAVALUE_ENCODINGMASK_VARIANT;
         retval |=
-            UA_Variant_copySetValue(&v.value, &UA_.types[UA_BOOLEAN],
+            UA_Variant_copySetValue(&v.value, &UA_[UA_BOOLEAN],
                                     &((UA_ReferenceTypeNode *)node)->isAbstract);
         break;
 
     case UA_ATTRIBUTEID_SYMMETRIC:
         CHECK_NODECLASS(UA_NODECLASS_REFERENCETYPE);
         v.encodingMask = UA_DATAVALUE_ENCODINGMASK_VARIANT;
-        retval |= UA_Variant_copySetValue(&v.value, &UA_.types[UA_BOOLEAN],
+        retval |= UA_Variant_copySetValue(&v.value, &UA_[UA_BOOLEAN],
                                           &((UA_ReferenceTypeNode *)node)->symmetric);
         break;
 
     case UA_ATTRIBUTEID_INVERSENAME:
         CHECK_NODECLASS(UA_NODECLASS_REFERENCETYPE);
         v.encodingMask = UA_DATAVALUE_ENCODINGMASK_VARIANT;
-        retval |= UA_Variant_copySetValue(&v.value, &UA_.types[UA_LOCALIZEDTEXT],
+        retval |= UA_Variant_copySetValue(&v.value, &UA_[UA_LOCALIZEDTEXT],
                                           &((UA_ReferenceTypeNode *)node)->inverseName);
         break;
 
     case UA_ATTRIBUTEID_CONTAINSNOLOOPS:
         CHECK_NODECLASS(UA_NODECLASS_VIEW);
         v.encodingMask = UA_DATAVALUE_ENCODINGMASK_VARIANT;
-        retval |= UA_Variant_copySetValue(&v.value, &UA_.types[UA_BOOLEAN],
+        retval |= UA_Variant_copySetValue(&v.value, &UA_[UA_BOOLEAN],
                                           &((UA_ViewNode *)node)->containsNoLoops);
         break;
 
     case UA_ATTRIBUTEID_EVENTNOTIFIER:
         CHECK_NODECLASS(UA_NODECLASS_VIEW | UA_NODECLASS_OBJECT);
         v.encodingMask = UA_DATAVALUE_ENCODINGMASK_VARIANT;
-        retval |= UA_Variant_copySetValue(&v.value, &UA_.types[UA_BYTE],
+        retval |= UA_Variant_copySetValue(&v.value, &UA_[UA_BYTE],
                                           &((UA_ViewNode *)node)->eventNotifier);
         break;
 
@@ -134,21 +134,21 @@ static UA_DataValue service_read_node(UA_Server *server, const UA_ReadValueId *i
     case UA_ATTRIBUTEID_DATATYPE:
         CHECK_NODECLASS(UA_NODECLASS_VARIABLE | UA_NODECLASS_VARIABLETYPE);
         v.encodingMask = UA_DATAVALUE_ENCODINGMASK_VARIANT;
-        retval |= UA_Variant_copySetValue(&v.value, &UA_.types[UA_NODEID],
+        retval |= UA_Variant_copySetValue(&v.value, &UA_[UA_NODEID],
                                           &((UA_VariableTypeNode *)node)->dataType);
         break;
 
     case UA_ATTRIBUTEID_VALUERANK:
         CHECK_NODECLASS(UA_NODECLASS_VARIABLE | UA_NODECLASS_VARIABLETYPE);
         v.encodingMask = UA_DATAVALUE_ENCODINGMASK_VARIANT;
-        retval |= UA_Variant_copySetValue(&v.value, &UA_.types[UA_INT32],
+        retval |= UA_Variant_copySetValue(&v.value, &UA_[UA_INT32],
                                           &((UA_VariableTypeNode *)node)->valueRank);
         break;
 
     case UA_ATTRIBUTEID_ARRAYDIMENSIONS:
         CHECK_NODECLASS(UA_NODECLASS_VARIABLE | UA_NODECLASS_VARIABLETYPE);
         v.encodingMask = UA_DATAVALUE_ENCODINGMASK_VARIANT;
-        UA_Variant_copySetArray(&v.value, &UA_.types[UA_UINT32],
+        UA_Variant_copySetArray(&v.value, &UA_[UA_UINT32],
                                 ((UA_VariableTypeNode *)node)->arrayDimensionsSize,
                                 &((UA_VariableTypeNode *)node)->arrayDimensions);
         break;
@@ -156,42 +156,42 @@ static UA_DataValue service_read_node(UA_Server *server, const UA_ReadValueId *i
     case UA_ATTRIBUTEID_ACCESSLEVEL:
         CHECK_NODECLASS(UA_NODECLASS_VARIABLE);
         v.encodingMask = UA_DATAVALUE_ENCODINGMASK_VARIANT;
-        retval |= UA_Variant_copySetValue(&v.value, &UA_.types[UA_BYTE],
+        retval |= UA_Variant_copySetValue(&v.value, &UA_[UA_BYTE],
                                           &((UA_VariableNode *)node)->accessLevel);
         break;
 
     case UA_ATTRIBUTEID_USERACCESSLEVEL:
         CHECK_NODECLASS(UA_NODECLASS_VARIABLE);
         v.encodingMask = UA_DATAVALUE_ENCODINGMASK_VARIANT;
-        retval |= UA_Variant_copySetValue(&v.value, &UA_.types[UA_BYTE],
+        retval |= UA_Variant_copySetValue(&v.value, &UA_[UA_BYTE],
                                           &((UA_VariableNode *)node)->userAccessLevel);
         break;
 
     case UA_ATTRIBUTEID_MINIMUMSAMPLINGINTERVAL:
         CHECK_NODECLASS(UA_NODECLASS_VARIABLE);
         v.encodingMask = UA_DATAVALUE_ENCODINGMASK_VARIANT;
-        retval |= UA_Variant_copySetValue(&v.value, &UA_.types[UA_DOUBLE],
+        retval |= UA_Variant_copySetValue(&v.value, &UA_[UA_DOUBLE],
                                           &((UA_VariableNode *)node)->minimumSamplingInterval);
         break;
 
     case UA_ATTRIBUTEID_HISTORIZING:
         CHECK_NODECLASS(UA_NODECLASS_VARIABLE);
         v.encodingMask = UA_DATAVALUE_ENCODINGMASK_VARIANT;
-        retval |= UA_Variant_copySetValue(&v.value, &UA_.types[UA_BOOLEAN],
+        retval |= UA_Variant_copySetValue(&v.value, &UA_[UA_BOOLEAN],
                                           &((UA_VariableNode *)node)->historizing);
         break;
 
     case UA_ATTRIBUTEID_EXECUTABLE:
         CHECK_NODECLASS(UA_NODECLASS_METHOD);
         v.encodingMask = UA_DATAVALUE_ENCODINGMASK_VARIANT;
-        retval |= UA_Variant_copySetValue(&v.value, &UA_.types[UA_BOOLEAN],
+        retval |= UA_Variant_copySetValue(&v.value, &UA_[UA_BOOLEAN],
                                           &((UA_MethodNode *)node)->executable);
         break;
 
     case UA_ATTRIBUTEID_USEREXECUTABLE:
         CHECK_NODECLASS(UA_NODECLASS_METHOD);
         v.encodingMask = UA_DATAVALUE_ENCODINGMASK_VARIANT;
-        retval |= UA_Variant_copySetValue(&v.value, &UA_.types[UA_BOOLEAN],
+        retval |= UA_Variant_copySetValue(&v.value, &UA_[UA_BOOLEAN],
                                           &((UA_MethodNode *)node)->userExecutable);
         break;
 
@@ -387,7 +387,7 @@ UA_Int32 Service_Write(UA_Server *server, UA_Session *session, const UA_WriteReq
         return UA_ERROR;    // TODO: Return error message
     response->resultsSize = request->nodesToWriteSize;
     //TODO evalutate diagnostic info within the request
-    UA_Array_new((void **)&response->results, response->resultsSize, &UA_.types[UA_STATUSCODE]);
+    UA_Array_new((void **)&response->results, response->resultsSize, &UA_[UA_STATUSCODE]);
     for(i = 0;i < request->nodesToWriteSize;i++)
         retval |= Service_Write_writeNode(server, &request->nodesToWrite[i], &response->results[i]);
 

+ 2 - 2
src/server/ua_services_discovery.c

@@ -6,7 +6,7 @@ UA_Int32 Service_GetEndpoints(UA_Server                    *server,
                               UA_GetEndpointsResponse      *response) {
     UA_GetEndpointsResponse_init(response);
     response->endpointsSize = 1;
-    UA_Array_new((void **)&response->endpoints, response->endpointsSize, &UA_.types[UA_ENDPOINTDESCRIPTION]);
+    UA_Array_new((void **)&response->endpoints, response->endpointsSize, &UA_[UA_ENDPOINTDESCRIPTION]);
 
     // security policy
     response->endpoints[0].securityMode = UA_MESSAGESECURITYMODE_NONE;
@@ -18,7 +18,7 @@ UA_Int32 Service_GetEndpoints(UA_Server                    *server,
     // usertoken policy
     response->endpoints[0].userIdentityTokensSize = 1;
     UA_Array_new((void **)&response->endpoints[0].userIdentityTokens,
-                 response->endpoints[0].userIdentityTokensSize, &UA_.types[UA_USERTOKENPOLICY]);
+                 response->endpoints[0].userIdentityTokensSize, &UA_[UA_USERTOKENPOLICY]);
     UA_UserTokenPolicy *token = &response->endpoints[0].userIdentityTokens[0];
     UA_UserTokenPolicy_init(token);
     UA_String_copycstring("my-anonymous-policy", &token->policyId); // defined per server

+ 16 - 28
src/server/ua_services_monitoreditems.c

@@ -2,39 +2,27 @@
 #include "ua_namespace_0.h"
 #include "ua_statuscodes.h"
 
-//#if 0
-/* Activate once the infrastructure for pushing events is in place. */
-
 UA_Int32 Service_CreateMonitoredItems(UA_Server *server, UA_Session *session,
                                       const UA_CreateMonitoredItemsRequest *request,
                                       UA_CreateMonitoredItemsResponse *response) {
-    if(request->itemsToCreateSize > 0) {
-        response->resultsSize = request->itemsToCreateSize;
-
-        UA_Array_new((void **)&(response->results), response->resultsSize,
-                     &UA_.types[UA_MONITOREDITEMCREATERESULT]);
-        for(int i = 0;request->itemsToCreateSize > 0 && i < request->itemsToCreateSize;i++) {
-#ifdef DEBUG
-            UA_NodeId_printf("CreateMonitoredItems - itemToCreate=",
-                             &(request->itemsToCreate[i].itemToMonitor.nodeId));
-#endif
-            //FIXME: search the object in the namespace
-
-            if(request->itemsToCreate[i].itemToMonitor.nodeId.identifier.numeric == 2253) {  // server
-
-                response->results[i].statusCode       = UA_STATUSCODE_GOOD;
-                response->results[i].monitoredItemId  = 1;
-                response->results[i].revisedSamplingInterval = 4294967295;
-                response->results[i].revisedQueueSize = 0;
-            } else {
-                // response->results[i]->statusCode = UA_STATUSCODE_BAD_NODEIDUNKNOWN;
+    if(request->itemsToCreateSize <= 0)
+        return UA_SUCCESS;
 
-                response->results[i].statusCode = -1;
-            }
+    //mock up
+    response->resultsSize = request->itemsToCreateSize;
+    UA_Array_new((void**)&response->results, response->resultsSize, &UA_[UA_MONITOREDITEMCREATERESULT]);
+    for(int i = 0;request->itemsToCreateSize > 0 && i < request->itemsToCreateSize;i++) {
+        //FIXME: search the object in the namespace
+        if(request->itemsToCreate[i].itemToMonitor.nodeId.identifier.numeric == 2253) {  // server
+            response->results[i].statusCode       = UA_STATUSCODE_GOOD;
+            response->results[i].monitoredItemId  = 1;
+            response->results[i].revisedSamplingInterval = 4294967295;
+            response->results[i].revisedQueueSize = 0;
+            continue;
+        } else {
+            // response->results[i]->statusCode = UA_STATUSCODE_BAD_NODEIDUNKNOWN;
+            response->results[i].statusCode = -1;
         }
     }
-    //mock up
     return UA_SUCCESS;
 }
-
-//#endif

+ 1 - 1
src/server/ua_services_nodemanagement.c

@@ -3,7 +3,7 @@
 #include "ua_nodestore.h"
 #include "ua_services_internal.h"
 #include "ua_session.h"
-#include "util/ua_util.h"
+#include "ua_util.h"
 
 #define CHECKED_ACTION(ACTION, CLEAN_UP, GOTO) do { \
         status |= ACTION;                           \

+ 2 - 5
src/server/ua_services_subscription.c

@@ -1,11 +1,10 @@
 #include "ua_services.h"
 #include "ua_statuscodes.h"
-#include "util/ua_util.h"
+#include "ua_util.h"
 
 UA_Int32 Service_CreateSubscription(UA_Server *server, UA_Session *session,
                                     const UA_CreateSubscriptionRequest *request,
                                     UA_CreateSubscriptionResponse *response) {
-
     response->subscriptionId            = 42;
     response->revisedPublishingInterval = 100000;
     response->revisedLifetimeCount      = 120000;
@@ -13,10 +12,8 @@ UA_Int32 Service_CreateSubscription(UA_Server *server, UA_Session *session,
     return UA_SUCCESS;
 }
 
-UA_Int32 Service_Publish(UA_Server *server, UA_Session *session,
-                         const UA_PublishRequest *request,
+UA_Int32 Service_Publish(UA_Server *server, UA_Session *session, const UA_PublishRequest *request,
                          UA_PublishResponse *response) {
-
     response->subscriptionId = 42;
     response->notificationMessage.sequenceNumber = 1;
     response->notificationMessage.publishTime    = UA_DateTime_now();

+ 5 - 5
src/server/ua_services_view.c

@@ -2,7 +2,7 @@
 #include "ua_statuscodes.h"
 #include "ua_nodestore.h"
 #include "ua_namespace_0.h"
-#include "util/ua_util.h"
+#include "ua_util.h"
 
 UA_Int32 Service_Browse_getReferenceDescription(UA_NodeStore *ns, UA_ReferenceNode *reference,
                                                 UA_UInt32 nodeClassMask, UA_UInt32 resultMask,
@@ -183,7 +183,7 @@ static void Service_Browse_getBrowseResult(UA_NodeStore         *ns,
     }
 
     browseResult->referencesSize = refs;
-    UA_Array_new((void **)&browseResult->references, refs, &UA_.types[UA_REFERENCEDESCRIPTION]);
+    UA_Array_new((void **)&browseResult->references, refs, &UA_[UA_REFERENCEDESCRIPTION]);
 
     for(UA_UInt32 i = 0, j = 0;j < refs;i++) {
         if(!Service_Browse_returnReference(browseDescription, &node->references[i], relevantReferenceTypes,
@@ -202,7 +202,7 @@ static void Service_Browse_getBrowseResult(UA_NodeStore         *ns,
     }
 
     UA_NodeStore_releaseManagedNode(node);
-    UA_Array_delete(relevantReferenceTypes, relevantReferenceTypesCount, &UA_.types[UA_NODEID]);
+    UA_Array_delete(relevantReferenceTypes, relevantReferenceTypesCount, &UA_[UA_NODEID]);
 }
 
 UA_Int32 Service_Browse(UA_Server *server, UA_Session *session,
@@ -212,7 +212,7 @@ UA_Int32 Service_Browse(UA_Server *server, UA_Session *session,
         return UA_ERROR;
 
     //TODO request->view not used atm
-    UA_Array_new((void **)&(response->results), request->nodesToBrowseSize, &UA_.types[UA_BROWSERESULT]);
+    UA_Array_new((void **)&(response->results), request->nodesToBrowseSize, &UA_[UA_BROWSERESULT]);
     response->resultsSize = request->nodesToBrowseSize;
 
     for(UA_Int32 i = 0;i < request->nodesToBrowseSize;i++) {
@@ -238,7 +238,7 @@ UA_Int32 Service_TranslateBrowsePathsToNodeIds(UA_Server *server, UA_Session *se
     // Allocate space for a correct answer
     response->resultsSize = request->browsePathsSize;
     // _init of the elements is done in Array_new
-    UA_Array_new((void **)&response->results, request->browsePathsSize, &UA_.types[UA_BROWSEPATHRESULT]);
+    UA_Array_new((void **)&response->results, request->browsePathsSize, &UA_[UA_BROWSEPATHRESULT]);
 
     for(UA_Int32 i = 0;i < request->browsePathsSize;i++) {
         //FIXME: implement

+ 72 - 94
src/server/ua_session_manager.c

@@ -1,9 +1,19 @@
 #include "ua_session_manager.h"
-#include "util/ua_util.h"
-#include "util/ua_list.h"
+#include "ua_util.h"
+
+/**
+ The functions in this file are not thread-safe. For multi-threaded access, a
+ second implementation should be provided. See for example, how a nodestore
+ implementation is choosen based on whether multithreading is enabled or not.
+ */
+
+struct session_list_entry {
+    UA_Session session;
+    LIST_ENTRY(session_list_entry) pointers;
+};
 
 struct UA_SessionManager {
-    UA_list_List sessions;
+    LIST_HEAD(session_list, session_list_entry) sessions;
     UA_UInt32    maxSessionCount;
     UA_Int32     lastSessionId;
     UA_UInt32    currentSessionCount;
@@ -17,7 +27,7 @@ UA_Int32 UA_SessionManager_new(UA_SessionManager **sessionManager, UA_UInt32 max
     retval |= UA_alloc((void **)sessionManager, sizeof(UA_SessionManager));
     if(retval != UA_SUCCESS)
         return UA_ERROR;
-    retval |= UA_list_init(&(*sessionManager)->sessions);
+    LIST_INIT(&(*sessionManager)->sessions);
     (*sessionManager)->maxSessionCount = maxSessionCount;
     (*sessionManager)->lastSessionId   = startSessionId;
     (*sessionManager)->sessionTimeout  = sessionTimeout;
@@ -29,119 +39,87 @@ UA_Int32 UA_SessionManager_delete(UA_SessionManager *sessionManager) {
     return UA_SUCCESS;
 }
 
-UA_Boolean UA_SessionManager_sessionExists(UA_SessionManager *sessionManager,
-                                           UA_Session        *session) {
-    if(sessionManager == UA_NULL)
-        return UA_FALSE;
-
-    if(UA_list_search(&sessionManager->sessions,
-                      (UA_list_PayloadComparer)UA_Session_compare, (void *)session)) {
-        UA_Double pendingLifetime;
-        UA_Session_getPendingLifetime(session, &pendingLifetime);
+UA_Int32 UA_SessionManager_getSessionById(UA_SessionManager *sessionManager, UA_NodeId *sessionId, UA_Session **session) {
+    if(sessionManager == UA_NULL) {
+        *session = UA_NULL;
+        return UA_ERROR;
+    }
 
-        if(pendingLifetime > 0)
-            return UA_TRUE;
+    struct session_list_entry *current = UA_NULL;
+    LIST_FOREACH(current, &sessionManager->sessions, pointers) {
+        if(UA_NodeId_equal(&current->session.sessionId, sessionId) == UA_EQUAL)
+            break;
+    }
 
-        //timeout of session reached so remove it
-        UA_NodeId *sessionId = &session->sessionId;
-        UA_SessionManager_removeSession(sessionManager, sessionId);
+    if(!current) {
+        *session = UA_NULL;
+        return UA_ERROR;
     }
-    return UA_FALSE;
+
+    // Lifetime handling is not done here, but in a regular cleanup by the
+    // server. If the session still exists, then it is valid.
+    *session = &current->session;
+    return UA_SUCCESS;
 }
 
-UA_Int32 UA_SessionManager_getSessionById(UA_SessionManager *sessionManager,
-                                          UA_NodeId *sessionId, UA_Session **session) {
+UA_Int32 UA_SessionManager_getSessionByToken(UA_SessionManager *sessionManager, UA_NodeId *token, UA_Session **session) {
     if(sessionManager == UA_NULL) {
         *session = UA_NULL;
         return UA_ERROR;
     }
 
-    UA_list_Element *current = sessionManager->sessions.first;
-    while(current) {
-        if(current->payload) {
-            UA_list_Element *elem = (UA_list_Element *)current;
-            *session = ((UA_Session *)(elem->payload));
-            if(UA_NodeId_equal(&(*session)->sessionId, sessionId) == UA_EQUAL) {
-                UA_Double pendingLifetime;
-                UA_Session_getPendingLifetime(*session, &pendingLifetime);
-
-                if(pendingLifetime > 0)
-                    return UA_SUCCESS;
-
-                //session not valid anymore -> remove it
-                UA_list_removeElement(elem, (UA_list_PayloadVisitor)UA_Session_delete);
-                *session = UA_NULL;
-                return UA_ERROR;
-            }
-        }
-        current = current->next;
+    struct session_list_entry *current = UA_NULL;
+    LIST_FOREACH(current, &sessionManager->sessions, pointers) {
+        if(UA_NodeId_equal(&current->session.authenticationToken, token) == UA_EQUAL)
+            break;
     }
-    *session = UA_NULL;
-    return UA_ERROR;
-}
 
-UA_Int32 UA_SessionManager_getSessionByToken(UA_SessionManager *sessionManager,
-                                             UA_NodeId *token, UA_Session **session) {
-    if(sessionManager == UA_NULL) {
+    if(!current) {
         *session = UA_NULL;
         return UA_ERROR;
     }
 
-    UA_list_Element *current = sessionManager->sessions.first;
-    while(current) {
-        if(current->payload) {
-            UA_list_Element *elem = (UA_list_Element *)current;
-            *session = ((UA_Session *)(elem->payload));
-
-            if(UA_NodeId_equal(&(*session)->authenticationToken, token) == UA_EQUAL) {
-                UA_Double pendingLifetime;
-                UA_Session_getPendingLifetime(*session, &pendingLifetime);
-
-                if(pendingLifetime > 0)
-                    return UA_SUCCESS;
-
-                //session not valid anymore -> remove it
-                UA_list_removeElement(elem, (UA_list_PayloadVisitor)UA_Session_delete);
-                *session = UA_NULL;
-                return UA_ERROR;
-            }
-        }
-        current = current->next;
-    }
-    *session = UA_NULL;
-    return UA_ERROR;
+    // Lifetime handling is not done here, but in a regular cleanup by the
+    // server. If the session still exists, then it is valid.
+    *session = &current->session;
+    return UA_SUCCESS;
 }
 
 /** Creates and adds a session. */
-UA_Int32 UA_SessionManager_createSession(UA_SessionManager *sessionManager,
-                                         UA_SecureChannel *channel, UA_Session **session) {
-    UA_Int32 retval = UA_SUCCESS;
+UA_Int32 UA_SessionManager_createSession(UA_SessionManager *sessionManager, UA_SecureChannel *channel, UA_Session **session) {
     if(sessionManager->currentSessionCount >= sessionManager->maxSessionCount)
         return UA_ERROR;
-    UA_Session_new(session);
-    (*session)->sessionId = (UA_NodeId) {.namespaceIndex     = 1, .identifierType = UA_NODEIDTYPE_NUMERIC,
-                                         .identifier.numeric = sessionManager->lastSessionId++ };
-    (*session)->authenticationToken = (UA_NodeId) {.namespaceIndex = 1,
-                                                   .identifierType = UA_NODEIDTYPE_NUMERIC,
-                                                   .identifier.numeric = sessionManager->lastSessionId };
-    (*session)->channel   = channel;
-    (*session)->timeout = 3600 * 1000; // 1h
-    UA_Session_setExpirationDate((*session));
+
+    struct session_list_entry *newentry;
+    if(UA_alloc((void **)&newentry, sizeof(struct session_list_entry)) != UA_SUCCESS)
+        return UA_ERROR;
+
+    UA_Session_init(&newentry->session);
+    newentry->session.sessionId = (UA_NodeId) {.namespaceIndex = 1, .identifierType = UA_NODEIDTYPE_NUMERIC,
+                                               .identifier.numeric = sessionManager->lastSessionId++ };
+    newentry->session.authenticationToken = (UA_NodeId) {.namespaceIndex = 1, .identifierType = UA_NODEIDTYPE_NUMERIC,
+                                                         .identifier.numeric = sessionManager->lastSessionId };
+    newentry->session.channel = channel;
+    newentry->session.timeout = 3600 * 1000; // 1h
+    UA_Session_setExpirationDate(&newentry->session);
+
     sessionManager->currentSessionCount++;
-    UA_list_addPayloadToFront(&sessionManager->sessions, *session);
-    return retval;
+    LIST_INSERT_HEAD(&sessionManager->sessions, newentry, pointers);
+    *session = &newentry->session;
+    return UA_SUCCESS;
 }
 
-UA_Int32 UA_SessionManager_removeSession(UA_SessionManager *sessionManager,
-                                         UA_NodeId         *sessionId) {
-    UA_Int32 retval = UA_SUCCESS;
-    UA_list_Element *element =
-        UA_list_search(&sessionManager->sessions, (UA_list_PayloadComparer)UA_Session_compare,
-                       sessionId);
-    if(element) {
-        retval |= UA_list_removeElement(element, (UA_list_PayloadVisitor)UA_Session_delete);
-        printf("UA_SessionManager_removeSession - session removed, current count: %i \n",
-               sessionManager->sessions.size);
+UA_Int32 UA_SessionManager_removeSession(UA_SessionManager *sessionManager, UA_NodeId  *sessionId) {
+    struct session_list_entry *current = UA_NULL;
+    LIST_FOREACH(current, &sessionManager->sessions, pointers) {
+        if(UA_NodeId_equal(&current->session.sessionId, sessionId) == UA_EQUAL)
+            break;
     }
-    return retval;
+
+    if(!current)
+        return UA_ERROR;
+
+    LIST_REMOVE(current, pointers);
+    UA_free(current);
+    return UA_SUCCESS;
 }

+ 0 - 1
src/server/ua_session_manager.h

@@ -25,7 +25,6 @@ UA_Int32 UA_SessionManager_getSessionById(UA_SessionManager *sessionManager,
                                           UA_NodeId *sessionId, UA_Session **session);
 
 /**
- * @brief
  * @param token authentication token which is used to get the session object
  * @param session output, session object which is identified by the authentication token
  * @return error code

+ 1 - 1
src/ua_connection.c

@@ -1,5 +1,5 @@
 #include "ua_connection.h"
-#include "util/ua_util.h"
+#include "ua_util.h"
 
 UA_ConnectionConfig UA_ConnectionConfig_standard = { .protocolVersion = 0,    .sendBufferSize = 8192,
                                                      .recvBufferSize  = 8192, .maxMessageSize = 8192,

+ 1 - 1
src/ua_securechannel.c

@@ -1,7 +1,7 @@
 #include <time.h>
 #include <stdlib.h>
 #include "ua_securechannel.h"
-#include "util/ua_util.h"
+#include "ua_util.h"
 
 void UA_SecureChannel_init(UA_SecureChannel *channel) {
     UA_AsymmetricAlgorithmSecurityHeader_init(&channel->clientAsymAlgSettings);

+ 1 - 1
src/ua_session.c

@@ -2,7 +2,7 @@
 #include <stdlib.h>
 
 #include "ua_session.h"
-#include "util/ua_util.h"
+#include "ua_util.h"
 
 UA_Int32 UA_Session_new(UA_Session **session) {
     UA_Int32 retval = UA_SUCCESS;

+ 1 - 1
src/ua_transport.c

@@ -2,7 +2,7 @@
 #include <stdio.h>
 #endif
 #include "ua_transport.h"
-#include "util/ua_util.h"
+#include "ua_util.h"
 
 UA_TYPE_DEFAULT(UA_MessageType)
 UA_Int32 UA_MessageType_calcSizeBinary(UA_MessageType const *ptr) {

+ 13 - 13
src/ua_types.c

@@ -11,7 +11,7 @@
 #include <stdio.h>
 #endif
 
-#include "util/ua_util.h"
+#include "ua_util.h"
 #include "ua_types.h"
 #include "ua_types_encoding_binary.h"
 #include "ua_namespace_0.h"
@@ -829,7 +829,7 @@ void UA_Variant_init(UA_Variant *p) {
     p->storage.data.dataPtr        = UA_NULL;
     p->storage.data.arrayDimensions       = UA_NULL;
     p->storage.data.arrayDimensionsLength = -1;
-    p->vt = &UA_.types[UA_INVALIDTYPE];
+    p->vt = &UA_[UA_INVALIDTYPE];
 }
 
 /** It is not allowed to copy into a variant that points to an external data source. */
@@ -854,7 +854,7 @@ UA_Int32 UA_Variant_copy(UA_Variant const *src, UA_Variant *dst) {
         goto clean_up;
     dstdata->arrayLength = srcdata->arrayLength;
     if(srcdata->arrayDimensions != UA_NULL) {
-        retval |= UA_Array_copy(srcdata->arrayDimensions, srcdata->arrayDimensionsLength, &UA_.types[UA_INT32], (void **)&dstdata->arrayDimensions);
+        retval |= UA_Array_copy(srcdata->arrayDimensions, srcdata->arrayDimensionsLength, &UA_[UA_INT32], (void **)&dstdata->arrayDimensions);
         if(retval != UA_SUCCESS)
             goto clean_up2;
         dstdata->arrayDimensionsLength = srcdata->arrayDimensionsLength;
@@ -879,7 +879,7 @@ UA_Int32 UA_Variant_copy(UA_Variant const *src, UA_Variant *dst) {
 }
 
 /** Copies data into a variant. The target variant has always a storagetype UA_VARIANT_DATA */
-UA_Int32 UA_Variant_copySetValue(UA_Variant *v, UA_VTable_Entry *vt, const void *value) {
+UA_Int32 UA_Variant_copySetValue(UA_Variant *v, const UA_VTable_Entry *vt, const void *value) {
     if(v == UA_NULL || vt == UA_NULL || value == UA_NULL)
         return UA_ERROR;
     UA_Variant_init(v);
@@ -891,7 +891,7 @@ UA_Int32 UA_Variant_copySetValue(UA_Variant *v, UA_VTable_Entry *vt, const void
         retval |= vt->copy(value, v->storage.data.dataPtr);
     return retval;
 }
-UA_Int32 UA_Variant_copySetArray(UA_Variant *v, UA_VTable_Entry *vt, UA_Int32 arrayLength,
+UA_Int32 UA_Variant_copySetArray(UA_Variant *v, const UA_VTable_Entry *vt, UA_Int32 arrayLength,
                                  const void *array) {
     if(v == UA_NULL || vt == UA_NULL || array == UA_NULL)
         return UA_ERROR;
@@ -906,8 +906,8 @@ void UA_Variant_print(const UA_Variant *p, FILE *stream) {
     if(p == UA_NULL || stream == UA_NULL) return;
     UA_UInt32 ns0id = UA_ns0ToVTableIndex(&p->vt->typeId);
     fprintf(stream, "(UA_Variant){/*%s*/", p->vt->name);
-    if(p->vt == &UA_.types[ns0id])
-        fprintf(stream, "UA_.types[%d]", ns0id);
+    if(p->vt == &UA_[ns0id])
+        fprintf(stream, "UA_[%d]", ns0id);
     else
         fprintf(stream, "ERROR (not a builtin type)");
     UA_Int32_print(&p->arrayLength, stream);
@@ -916,7 +916,7 @@ void UA_Variant_print(const UA_Variant *p, FILE *stream) {
     fprintf(stream, ",");
     UA_Int32_print(&p->arrayDimensionsLength, stream);
     fprintf(stream, ",");
-    UA_Array_print(p->arrayDimensions, p->arrayDimensionsLength, &UA_.types[UA_INT32], stream);
+    UA_Array_print(p->arrayDimensions, p->arrayDimensionsLength, &UA_[UA_INT32], stream);
     fprintf(stream, "}");
 }
 #endif
@@ -1024,7 +1024,7 @@ void UA_InvalidType_print(const UA_InvalidType *p, FILE *stream) {
 /* Array */
 /*********/
 
-UA_Int32 UA_Array_new(void **p, UA_Int32 noElements, UA_VTable_Entry *vt) {
+UA_Int32 UA_Array_new(void **p, UA_Int32 noElements, const UA_VTable_Entry *vt) {
     if(vt == UA_NULL)
         return UA_ERROR;
 
@@ -1049,7 +1049,7 @@ UA_Int32 UA_Array_new(void **p, UA_Int32 noElements, UA_VTable_Entry *vt) {
     return UA_SUCCESS;
 }
 
-void UA_Array_init(void *p, UA_Int32 noElements, UA_VTable_Entry *vt) {
+void UA_Array_init(void *p, UA_Int32 noElements, const UA_VTable_Entry *vt) {
     if(!p || !vt) return;
     char *cp = (char *)p; // so compilers allow pointer arithmetic
     UA_UInt32 memSize = vt->memSize;
@@ -1059,7 +1059,7 @@ void UA_Array_init(void *p, UA_Int32 noElements, UA_VTable_Entry *vt) {
     }
 }
 
-void UA_Array_delete(void *p, UA_Int32 noElements, UA_VTable_Entry *vt) {
+void UA_Array_delete(void *p, UA_Int32 noElements, const UA_VTable_Entry *vt) {
     if(!p || !vt || noElements <= 0) return;
     char     *cp      = (char *)p; // so compilers allow pointer arithmetic
     UA_UInt32 memSize = vt->memSize;
@@ -1070,7 +1070,7 @@ void UA_Array_delete(void *p, UA_Int32 noElements, UA_VTable_Entry *vt) {
     UA_free(p);
 }
 
-UA_Int32 UA_Array_copy(const void *src, UA_Int32 noElements, UA_VTable_Entry *vt, void **dst) {
+UA_Int32 UA_Array_copy(const void *src, UA_Int32 noElements, const UA_VTable_Entry *vt, void **dst) {
     UA_Int32 retval;
     if(src == UA_NULL || dst == UA_NULL || vt == UA_NULL)
         return UA_ERROR;
@@ -1101,7 +1101,7 @@ UA_Int32 UA_Array_copy(const void *src, UA_Int32 noElements, UA_VTable_Entry *vt
 }
 
 #ifdef DEBUG
-void UA_Array_print(const void *p, UA_Int32 noElements, UA_VTable_Entry *vt, FILE *stream) {
+void UA_Array_print(const void *p, UA_Int32 noElements, const UA_VTable_Entry *vt, FILE *stream) {
     if(p == UA_NULL || vt == UA_NULL || stream == UA_NULL) return;
     fprintf(stream, "(%s){", vt->name);
     char     *cp      = (char *)p; // so compilers allow pointer arithmetic

+ 15 - 19
src/ua_types_encoding_binary.c

@@ -1,8 +1,8 @@
 #include "ua_types_encoding_binary.h"
-#include "util/ua_util.h"
+#include "ua_util.h"
 #include "ua_namespace_0.h"
 
-static INLINE UA_Boolean is_builtin(UA_NodeId *typeid ) {
+static INLINE UA_Boolean is_builtin(const UA_NodeId *typeid ) {
     return typeid ->namespaceIndex == 0 && 1 <= typeid ->identifier.numeric && typeid ->identifier.numeric <=
            25;
 }
@@ -11,7 +11,7 @@ static INLINE UA_Boolean is_builtin(UA_NodeId *typeid ) {
 /* Array */
 /*********/
 
-UA_Int32 UA_Array_calcSizeBinary(UA_Int32 nElements, UA_VTable_Entry *vt, const void *data) {
+UA_Int32 UA_Array_calcSizeBinary(UA_Int32 nElements, const UA_VTable_Entry *vt, const void *data) {
     if(vt == UA_NULL)
         return 0;  // do not return error as the result will be used to allocate memory
 
@@ -28,7 +28,7 @@ UA_Int32 UA_Array_calcSizeBinary(UA_Int32 nElements, UA_VTable_Entry *vt, const
     return length;
 }
 
-static UA_Int32 UA_Array_calcSizeBinary_asExtensionObject(UA_Int32 nElements, UA_VTable_Entry *vt,
+static UA_Int32 UA_Array_calcSizeBinary_asExtensionObject(UA_Int32 nElements, const UA_VTable_Entry *vt,
                                                           const void *data) {
     if(vt == UA_NULL)
         return 0;  // do not return error as the result will be used to allocate memory
@@ -49,8 +49,8 @@ static UA_Int32 UA_Array_calcSizeBinary_asExtensionObject(UA_Int32 nElements, UA
     return length;
 }
 
-UA_Int32 UA_Array_encodeBinary(const void *src, UA_Int32 noElements, UA_VTable_Entry *vt, UA_ByteString *dst,
-                               UA_UInt32 *offset) {
+UA_Int32 UA_Array_encodeBinary(const void *src, UA_Int32 noElements, const UA_VTable_Entry *vt,
+                               UA_ByteString *dst, UA_UInt32 *offset) {
     UA_Int32 retval = UA_SUCCESS;
     if(vt == UA_NULL || dst == UA_NULL || offset == UA_NULL || ((src == UA_NULL) && (noElements > 0)))
         return UA_ERROR;
@@ -70,7 +70,7 @@ UA_Int32 UA_Array_encodeBinary(const void *src, UA_Int32 noElements, UA_VTable_E
 }
 
 static UA_Int32 UA_Array_encodeBinary_asExtensionObject(const void *src, UA_Int32 noElements,
-                                                        UA_VTable_Entry *vt,
+                                                        const UA_VTable_Entry *vt,
                                                         UA_ByteString *dst,
                                                         UA_UInt32 *offset) {
     UA_Int32 retval = UA_SUCCESS;
@@ -101,7 +101,7 @@ static UA_Int32 UA_Array_encodeBinary_asExtensionObject(const void *src, UA_Int3
 }
 
 UA_Int32 UA_Array_decodeBinary(const UA_ByteString *src, UA_UInt32 *offset, UA_Int32 noElements,
-                               UA_VTable_Entry *vt,
+                               const UA_VTable_Entry *vt,
                                void **dst) {
     UA_Int32 retval = UA_SUCCESS;
     if(vt == UA_NULL || src == UA_NULL || dst == UA_NULL || offset == UA_NULL)
@@ -697,11 +697,7 @@ UA_TYPE_ENCODEBINARY(UA_ExtensionObject,
 
                      case UA_EXTENSIONOBJECT_ENCODINGMASK_BODYISBYTESTRING:
                          // FIXME: This code is valid for numeric nodeIds in ns0 only!
-                         retval |= UA_.types[UA_ns0ToVTableIndex(
-                                                 &src->typeId)].encodings[UA_ENCODING_BINARY].encode(src->
-                                                                                                     body.
-                                                                                                     data,
-                                                                                                     dst, offset);
+                         retval |= UA_[UA_ns0ToVTableIndex(&src->typeId)].encodings[UA_ENCODING_BINARY].encode(src-> body. data, dst, offset);
                          break;
 
                      case UA_EXTENSIONOBJECT_ENCODINGMASK_BODYISXML:
@@ -852,9 +848,9 @@ UA_Int32 UA_Variant_calcSizeBinary(UA_Variant const *p) {
 
     if(arrayLength != 1 && data->arrayDimensions != UA_NULL) {
         if(is_builtin(&p->vt->typeId))
-            length += UA_Array_calcSizeBinary(data->arrayDimensionsLength, &UA_.types[UA_INT32], data->arrayDimensions);
+            length += UA_Array_calcSizeBinary(data->arrayDimensionsLength, &UA_[UA_INT32], data->arrayDimensions);
         else
-            length += UA_Array_calcSizeBinary_asExtensionObject(data->arrayDimensionsLength, &UA_.types[UA_INT32], data->arrayDimensions);
+            length += UA_Array_calcSizeBinary_asExtensionObject(data->arrayDimensionsLength, &UA_[UA_INT32], data->arrayDimensions);
     }
     
     if(p->storageType == UA_VARIANT_DATASOURCE)
@@ -916,9 +912,9 @@ UA_TYPE_ENCODEBINARY(UA_Variant,
 
                      if(hasDimensions) {
                          if(isBuiltin)
-                             retval |= UA_Array_encodeBinary(data->arrayDimensions, data->arrayDimensionsLength, &UA_.types[UA_INT32], dst, offset);
+                             retval |= UA_Array_encodeBinary(data->arrayDimensions, data->arrayDimensionsLength, &UA_[UA_INT32], dst, offset);
                          else
-                             retval |= UA_Array_encodeBinary_asExtensionObject(data->arrayDimensions, data->arrayDimensionsLength, &UA_.types[UA_INT32], dst, offset);
+                             retval |= UA_Array_encodeBinary_asExtensionObject(data->arrayDimensions, data->arrayDimensionsLength, &UA_[UA_INT32], dst, offset);
                      }
 
                      if(src->storageType == UA_VARIANT_DATASOURCE)
@@ -942,7 +938,7 @@ UA_Int32 UA_Variant_decodeBinary(UA_ByteString const *src, UA_UInt32 *offset, UA
     UA_NodeId typeid = { .namespaceIndex = 0, .identifierType = UA_NODEIDTYPE_NUMERIC,
                          .identifier.numeric = encodingByte & UA_VARIANT_ENCODINGMASKTYPE_TYPEID_MASK };
     UA_Int32 typeNs0Id = UA_ns0ToVTableIndex(&typeid );
-    dst->vt = &UA_.types[typeNs0Id];
+    dst->vt = &UA_[typeNs0Id];
 
     if(!isArray) {
         if(UA_alloc(&data->dataPtr, dst->vt->memSize) != UA_SUCCESS) return UA_ERROR;
@@ -963,7 +959,7 @@ UA_Int32 UA_Variant_decodeBinary(UA_ByteString const *src, UA_UInt32 *offset, UA
     if(hasDimensions && retval == UA_SUCCESS) {
         retval |= UA_Int32_decodeBinary(src, offset, &data->arrayDimensionsLength);
         if(retval == UA_SUCCESS)
-            retval |= UA_Array_decodeBinary(src, offset, data->arrayDimensionsLength, &UA_.types[UA_INT32], &data->dataPtr);
+            retval |= UA_Array_decodeBinary(src, offset, data->arrayDimensionsLength, &UA_[UA_INT32], &data->dataPtr);
         if(retval != UA_SUCCESS)
             data->arrayLength = -1; // for deleteMembers
     }

+ 4 - 5
src/ua_types_encoding_binary.h

@@ -98,16 +98,15 @@ UA_TYPE_BINARY_ENCODING(UA_InvalidType)
 /*********/
 
 /* Computes the size of an array (incl. length field) in a binary blob. */
-UA_Int32 UA_Array_calcSizeBinary(UA_Int32 nElements, UA_VTable_Entry *vt, const void *data);
+UA_Int32 UA_Array_calcSizeBinary(UA_Int32 nElements, const UA_VTable_Entry *vt, const void *data);
 
 /* @brief Encodes an array into a binary blob. The array size is printed as well. */
-UA_Int32 UA_Array_encodeBinary(const void *src, UA_Int32 noElements, UA_VTable_Entry *vt, UA_ByteString *dst,
-                               UA_UInt32 *offset);
+UA_Int32 UA_Array_encodeBinary(const void *src, UA_Int32 noElements, const UA_VTable_Entry *vt,
+                               UA_ByteString *dst, UA_UInt32 *offset);
 
 /* @brief Decodes an array from a binary blob. The array is allocated automatically before decoding. */
 UA_Int32 UA_Array_decodeBinary(const UA_ByteString *src, UA_UInt32 *offset, UA_Int32 noElements,
-                               UA_VTable_Entry *vt,
-                               void **dst);
+                               const UA_VTable_Entry *vt, void **dst);
 
 /// @} /* end of group */
 

src/util/ua_util.c → src/ua_util.c


src/util/ua_util.h → src/ua_util.h


+ 0 - 236
src/util/ua_list.c

@@ -1,236 +0,0 @@
-#include "ua_list.h"
-#include "ua_util.h"
-
-void UA_list_defaultFreer(void *payload) {
-    if(payload)
-        UA_free(payload);
-}
-
-UA_Int32 UA_list_initElement(UA_list_Element *element) {
-    if(element == UA_NULL) return UA_ERROR;
-    element->next    = UA_NULL;
-    element->prev    = UA_NULL;
-    element->father  = UA_NULL;
-    element->payload = UA_NULL;
-    return UA_NO_ERROR;
-}
-
-UA_Int32 UA_list_init(UA_list_List *list) {
-    if(list == UA_NULL) return UA_ERROR;
-    list->first = UA_NULL;
-    list->last  = UA_NULL;
-    list->size  = 0;
-    return UA_NO_ERROR;
-}
-
-UA_Int32 UA_list_addElementToFront(UA_list_List *list, UA_list_Element *element) {
-    UA_list_Element *second = UA_NULL;
-    if(list == UA_NULL || element == UA_NULL) return UA_ERROR;
-    second          = list->first;
-    list->first     = element;
-    element->prev   = UA_NULL;
-    element->next   = second;
-    element->father = list;
-    if(second)
-        second->prev = element;
-    list->size++;
-    if(list->size == 1)
-        list->last = element;
-    return UA_NO_ERROR;
-}
-
-UA_Int32 UA_list_addPayloadToFront(UA_list_List *list, void *const payload) {
-    UA_list_Element *elem;
-    if(list == UA_NULL)
-        return UA_ERROR;
-    UA_alloc((void **)&elem, sizeof(*elem));
-    UA_list_initElement(elem);
-    elem->payload = payload;
-    UA_list_addElementToFront(list, elem);
-    return UA_NO_ERROR;
-}
-
-UA_Int32 UA_list_addElementToBack(UA_list_List *list, UA_list_Element *element) {
-    UA_list_Element *secondLast = UA_NULL;
-    if(list == UA_NULL || element == UA_NULL)
-        return UA_ERROR;
-    secondLast      = list->last;
-    list->last      = element;
-    element->prev   = secondLast;
-    element->next   = UA_NULL;
-    element->father = list;
-    if(secondLast)
-        secondLast->next = element;
-    list->size++;
-    if(list->size == 1)
-        list->first = element;
-    return UA_NO_ERROR;
-}
-
-UA_Int32 UA_list_addPayloadToBack(UA_list_List *list, void *const payload) {
-    UA_list_Element *elem;
-    if(list == UA_NULL)
-        return UA_ERROR;
-    UA_alloc((void **)&elem, sizeof(*elem));
-    UA_list_initElement(elem);
-    elem->payload = payload;
-    UA_list_addElementToBack(list, elem);
-    return UA_NO_ERROR;
-}
-
-UA_Int32 UA_list_removeFirst(UA_list_List *list, UA_list_PayloadVisitor visitor) {
-    UA_list_Element *temp = UA_NULL;
-    if(list == UA_NULL)
-        return UA_ERROR;
-    if(list->first) {
-        temp = list->first->next;
-        if(visitor)
-            (*visitor)(list->first->payload);
-        UA_free(list->first);
-        list->first = temp;
-        if(temp)
-            temp->prev = UA_NULL;
-        list->size--;
-        if(list->size == 1)
-            list->last = temp;
-        else if(list->size == 0)
-            list->last = UA_NULL;
-    }
-    return UA_NO_ERROR;
-}
-
-UA_Int32 UA_list_removeLast(UA_list_List *list, UA_list_PayloadVisitor visitor) {
-    UA_list_Element *temp = UA_NULL;
-    if(list == UA_NULL)
-        return UA_ERROR;
-    if(list->last) {
-        temp = list->last->prev;
-        if(visitor)
-            (*visitor)(list->last->payload);
-        UA_free(list->last);
-        list->last = temp;
-        if(temp)
-            temp->next = UA_NULL;
-        list->size--;
-        if(list->size == 1)
-            list->first = temp;
-        else if(list->size == 0)
-            list->first = UA_NULL;
-    }
-    return UA_NO_ERROR;
-}
-
-UA_Int32 UA_list_removeElement(UA_list_Element *const elem, UA_list_PayloadVisitor visitor) {
-    if(elem == UA_NULL)
-        return UA_ERROR;
-    if(elem == elem->father->first)
-        return UA_list_removeFirst(elem->father, visitor);
-    else if(elem == elem->father->last)
-        return UA_list_removeLast(elem->father, visitor);
-    else{
-        UA_list_Element *prev = elem->prev;
-        UA_list_Element *next = elem->next;
-        prev->next = next;
-        next->prev = prev;
-        if(visitor)
-            (*visitor)(elem->payload);
-        (elem->father)->size--;
-        UA_free(elem);
-    }
-    return UA_NO_ERROR;
-}
-
-UA_Int32 UA_list_destroy(UA_list_List *list, UA_list_PayloadVisitor visitor) {
-    UA_list_Element *current = UA_NULL;
-    if(list == UA_NULL)
-        return UA_ERROR;
-    current = list->first;
-    while(current) {
-        UA_list_Element *next = current->next;
-        if(visitor)
-            (*visitor)(current->payload);
-        UA_free(current);
-        current = next;
-    }
-    UA_list_init(list);
-    return UA_NO_ERROR;
-}
-
-UA_Int32 UA_list_iterateElement(UA_list_List *const list, UA_list_ElementVisitor visitor) {
-    UA_list_Element *current;
-    UA_list_Element *next = UA_NULL;
-    if(list == UA_NULL)
-        return UA_ERROR;
-    current = list->first;
-    while(current) {
-        next = current->next;
-        if(visitor)
-            (*visitor)(current);
-        current = next;
-    }
-    return UA_NO_ERROR;
-}
-
-/*Int32 UA_list_iteratePayload(UA_list_list* const list, UA_payloadVisitor visitor){
-    void visitorTemp(UA_list_element* element){
-        if(visitor){
-            (*visitor)(element->payload);
-        }
-    }
-    if(list==NULL)return UA_ERROR;
-    UA_list_iterateElement(list, visitorTemp);
-    return UA_NO_ERROR;
-   }*/
-/** ANSI C forbids function nesting - reworked ugly version **/
-UA_Int32 UA_list_iteratePayload(UA_list_List *const list, UA_list_PayloadVisitor visitor) {
-    UA_list_Element *current;
-    UA_list_Element *next = UA_NULL;
-    if(list == UA_NULL)
-        return UA_ERROR;
-    current = list->first;
-    while(current) {
-        next = current->next;
-        if(visitor)
-            (*visitor)(current->payload);
-        current = next;
-    }
-    return UA_NO_ERROR;
-}
-
-UA_list_Element *UA_list_find(UA_list_List *const list, UA_list_PayloadMatcher matcher) {
-    if(list == UA_NULL) return UA_NULL;
-    if(matcher) {
-        UA_list_Element *current = list->first;
-        while(current) {
-            if(matcher && (*matcher)(current->payload) == UA_TRUE)
-                return current;
-            current = current->next;
-        }
-    }
-    /* nothing found */
-    return UA_NULL;
-}
-
-UA_list_Element *UA_list_search(UA_list_List *const list, UA_list_PayloadComparer compare, void *payload) {
-    if(list == UA_NULL) return UA_NULL;
-    if(compare) {
-        UA_list_Element *current = list->first;
-        while(current) {
-            if(compare && (*compare)(current->payload, payload) == UA_TRUE)
-                return current;
-            current = current->next;
-        }
-    }
-    /* nothing found */
-    return UA_NULL;
-}
-
-UA_list_Element *UA_list_getFirst(UA_list_List *const list) {
-    if(list == UA_NULL) return UA_NULL;
-    return list->first;
-}
-
-UA_list_Element *UA_list_getLast(UA_list_List *const list) {
-    if(list == UA_NULL) return UA_NULL;
-    return list->last;
-}

+ 0 - 65
src/util/ua_list.h

@@ -1,65 +0,0 @@
-#ifndef UA_LIST_H_
-#define UA_LIST_H_
-
-#include "ua_types.h"
-
-/**********************/
-/* Doubly Linked List */
-/**********************/
-
-typedef void (*UA_list_PayloadVisitor)(void *payload);
-
-typedef struct UA_list_Element {
-    struct UA_list_List    *father;
-    void *payload;
-    struct UA_list_Element *next;
-    struct UA_list_Element *prev;
-}UA_list_Element;
-
-typedef struct UA_list_List {
-    struct UA_list_Element *first;
-    struct UA_list_Element *last;
-    UA_Int32 size;
-}UA_list_List;
-
-typedef void (*UA_list_ElementVisitor)(UA_list_Element *payload);
-
-//typedef Boolean (*UA_list_PayloadMatcher)(void* payload);
-typedef _Bool (*UA_list_PayloadMatcher)(void *payload);
-typedef _Bool (*UA_list_PayloadComparer)(void *payload, void *otherPayload);
-
-void UA_list_defaultFreer(void *payload);
-
-UA_Int32 UA_list_initElement(UA_list_Element *element);
-
-UA_Int32 UA_list_init(UA_list_List *list);
-
-UA_Int32 UA_list_addElementToFront(UA_list_List *list, UA_list_Element *element);
-
-UA_Int32 UA_list_addPayloadToFront(UA_list_List *list, void *const payload);
-
-UA_Int32 UA_list_addElementToBack(UA_list_List *list, UA_list_Element *element);
-
-UA_Int32 UA_list_addPayloadToBack(UA_list_List *list, void *const payload);
-
-UA_Int32 UA_list_removeFirst(UA_list_List *list, UA_list_PayloadVisitor visitor);
-
-UA_Int32 UA_list_removeLast(UA_list_List *list, UA_list_PayloadVisitor visitor);
-
-UA_Int32 UA_list_removeElement(UA_list_Element *const elem, UA_list_PayloadVisitor visitor);
-
-UA_Int32 UA_list_destroy(UA_list_List *list, UA_list_PayloadVisitor visitor);
-
-UA_Int32 UA_list_iterateElement(UA_list_List *const list, UA_list_ElementVisitor visitor);
-
-UA_Int32 UA_list_iteratePayload(UA_list_List *const list, UA_list_PayloadVisitor visitor);
-
-UA_list_Element *UA_list_find(UA_list_List *const list, UA_list_PayloadMatcher matcher);
-
-UA_list_Element *UA_list_search(UA_list_List *const list, UA_list_PayloadComparer compare, void *payload);
-
-UA_list_Element *UA_list_getFirst(UA_list_List *const list);
-
-UA_list_Element *UA_list_getLast(UA_list_List *const list);
-
-#endif /* UA_LIST_H_ */

+ 0 - 4
tests/CMakeLists.txt

@@ -21,10 +21,6 @@ add_test(memory ${CMAKE_CURRENT_BINARY_DIR}/check_memory)
 # target_link_libraries(check_stack ${LIBS})
 # add_test(stack ${CMAKE_CURRENT_BINARY_DIR}/check_stack)
 
-add_executable(check_list check_list.c)
-target_link_libraries(check_list ${LIBS})
-add_test(list ${CMAKE_CURRENT_BINARY_DIR}/check_list)
-
 # add_executable(check_base64 check_base64.c)
 # target_link_libraries(check_base64 ${LIBS})
 # add_test(base64 ${CMAKE_CURRENT_BINARY_DIR}/check_base64)

+ 17 - 17
tests/check_builtin.c

@@ -4,7 +4,7 @@
 #include "ua_types_encoding_binary.h"
 #include "ua_namespace_0.h"
 #include "ua_transport.h"
-#include "util/ua_util.h"
+#include "ua_util.h"
 #include "check.h"
 
 /* copied here from encoding_binary.c */
@@ -473,7 +473,7 @@ START_TEST(UA_Variant_calcSizeFixedSizeArrayShallReturnEncodingSize) {
 	// given
 	UA_Variant arg;
 	UA_Variant_init(&arg);
-	arg.vt = &UA_.types[UA_INT32];
+	arg.vt = &UA_[UA_INT32];
 #define ARRAY_LEN 8
 	arg.storage.data.arrayLength = ARRAY_LEN;
 	UA_Int32 *data[ARRAY_LEN];
@@ -491,7 +491,7 @@ START_TEST(UA_Variant_calcSizeVariableSizeArrayShallReturnEncodingSize) {
 	// given
 	UA_Variant arg;
 	UA_Variant_init(&arg);
-	arg.vt = &UA_.types[UA_STRING];
+	arg.vt = &UA_[UA_STRING];
 #define ARRAY_LEN 3
 	arg.storage.data.arrayLength = ARRAY_LEN;
 	UA_String strings[3];
@@ -862,7 +862,7 @@ START_TEST(UA_Variant_decodeWithOutArrayFlagSetShallSetVTAndAllocateMemoryForArr
 	// then
 	ck_assert_int_eq(retval, UA_SUCCESS);
 	ck_assert_int_eq(pos, 5);
-	ck_assert_ptr_eq(dst.vt, &UA_.types[UA_INT32]);
+	ck_assert_ptr_eq(dst.vt, &UA_[UA_INT32]);
 	ck_assert_int_eq(dst.storage.data.arrayLength, 1);
 	ck_assert_int_eq(*(UA_Int32 *)dst.storage.data.dataPtr, 255);
 	// finally
@@ -884,7 +884,7 @@ START_TEST(UA_Variant_decodeWithArrayFlagSetShallSetVTAndAllocateMemoryForArray)
 	// then
 	ck_assert_int_eq(retval, UA_SUCCESS);
 	ck_assert_int_eq(pos, 1+4+2*4);
-	ck_assert_ptr_eq(dst.vt, &UA_.types[UA_INT32]);
+	ck_assert_ptr_eq(dst.vt, &UA_[UA_INT32]);
 	ck_assert_int_eq(dst.storage.data.arrayLength, 2);
 	ck_assert_int_eq(((UA_Int32 *)dst.storage.data.dataPtr)[0], 255);
 	ck_assert_int_eq(((UA_Int32 *)dst.storage.data.dataPtr)[1], -1);
@@ -1307,7 +1307,7 @@ START_TEST(UA_DataValue_encodeShallWorkOnExampleWithVariant) {
 	src.serverTimestamp    = 80;
 	src.encodingMask       = UA_DATAVALUE_ENCODINGMASK_VARIANT | UA_DATAVALUE_ENCODINGMASK_SERVERTIMESTAMP; //Variant & SourvePicoseconds
 	UA_Variant_init(&src.value);
-	src.value.vt           = &UA_.types[UA_INT32];
+	src.value.vt           = &UA_[UA_INT32];
 	src.value.storage.data.arrayLength  = 1; // one element (encoded as not an array)
 	UA_Int32  vdata  = 45;
 	src.value.storage.data.dataPtr = (void *)&vdata;
@@ -1426,7 +1426,7 @@ START_TEST(UA_Array_copyByteArrayShallWorkOnExample) {
 	testString.length  = 5;
 
 	//when
-	UA_Array_copy((const void *)testString.data, 5, &UA_.types[UA_BYTE], (void **)&dstArray);
+	UA_Array_copy((const void *)testString.data, 5, &UA_[UA_BYTE], (void **)&dstArray);
 	//then
 	for(i = 0;i < size;i++)
 		ck_assert_int_eq(testString.data[i], dstArray[i]);
@@ -1442,14 +1442,14 @@ START_TEST(UA_Array_copyUA_StringShallWorkOnExample) {
 	// given
 	UA_Int32   i, j;
 	UA_String *srcArray;
-	UA_Array_new((void **)&srcArray, 3, &UA_.types[UA_STRING]);
+	UA_Array_new((void **)&srcArray, 3, &UA_[UA_STRING]);
 	UA_String *dstArray;
 
 	UA_String_copycstring("open", &srcArray[0]);
 	UA_String_copycstring("62541", &srcArray[1]);
 	UA_String_copycstring("opc ua", &srcArray[2]);
 	//when
-	UA_Array_copy((const void *)srcArray, 3, &UA_.types[UA_STRING], (void **)&dstArray);
+	UA_Array_copy((const void *)srcArray, 3, &UA_[UA_STRING], (void **)&dstArray);
 	//then
 	for(i = 0;i < 3;i++) {
 		for(j = 0;j < 3;j++)
@@ -1457,8 +1457,8 @@ START_TEST(UA_Array_copyUA_StringShallWorkOnExample) {
 		ck_assert_int_eq(srcArray[i].length, dstArray[i].length);
 	}
 	//finally
-	UA_Array_delete(srcArray, 3, &UA_.types[UA_STRING]);
-	UA_Array_delete(dstArray, 3, &UA_.types[UA_STRING]);
+	UA_Array_delete(srcArray, 3, &UA_[UA_STRING]);
+	UA_Array_delete(dstArray, 3, &UA_[UA_STRING]);
 }
 END_TEST
 
@@ -1675,7 +1675,7 @@ START_TEST(UA_Variant_copyShallWorkOnSingleValueExample) {
 	UA_Variant_init(&copiedValue);
 	UA_alloc((void**)&value.storage.data.dataPtr, sizeof(UA_String));
 	*((UA_String*)value.storage.data.dataPtr) = testString;
-	value.vt = &UA_.types[UA_STRING];
+	value.vt = &UA_[UA_STRING];
 	value.storage.data.arrayLength = 1;
 
 	//when
@@ -1699,7 +1699,7 @@ END_TEST
 START_TEST(UA_Variant_copyShallWorkOn1DArrayExample) {
 	// given
 	UA_String *srcArray;
-	UA_Array_new((void **)&srcArray, 3, &UA_.types[UA_STRING]);
+	UA_Array_new((void **)&srcArray, 3, &UA_[UA_STRING]);
 	UA_String_copycstring("__open", &srcArray[0]);
 	UA_String_copycstring("_62541", &srcArray[1]);
 	UA_String_copycstring("opc ua", &srcArray[2]);
@@ -1716,7 +1716,7 @@ START_TEST(UA_Variant_copyShallWorkOn1DArrayExample) {
 	value.storage.data.dataPtr        = (void **)srcArray;
 	value.storage.data.arrayDimensionsLength = 1;
 	value.storage.data.arrayDimensions       = dimensions;
-	value.vt = &UA_.types[UA_STRING];
+	value.vt = &UA_[UA_STRING];
 
 	//when
 	UA_Variant_copy(&value, &copiedValue);
@@ -1745,7 +1745,7 @@ END_TEST
 START_TEST(UA_Variant_copyShallWorkOn2DArrayExample) {
 	// given
 	UA_Int32 *srcArray;
-	UA_Array_new((void **)&srcArray, 6, &UA_.types[UA_INT32]);
+	UA_Array_new((void **)&srcArray, 6, &UA_[UA_INT32]);
 	srcArray[0] = 0;
 	srcArray[1] = 1;
 	srcArray[2] = 2;
@@ -1754,7 +1754,7 @@ START_TEST(UA_Variant_copyShallWorkOn2DArrayExample) {
 	srcArray[5] = 5;
 
 	UA_Int32 *dimensions;
-	UA_Array_new((void **)&dimensions, 2, &UA_.types[UA_INT32]);
+	UA_Array_new((void **)&dimensions, 2, &UA_[UA_INT32]);
 	UA_Int32  dim1 = 3;
 	UA_Int32  dim2 = 2;
 	dimensions[0] = dim1;
@@ -1768,7 +1768,7 @@ START_TEST(UA_Variant_copyShallWorkOn2DArrayExample) {
 	value.storage.data.dataPtr        = (void **)srcArray;
 	value.storage.data.arrayDimensionsLength = 2;
 	value.storage.data.arrayDimensions       = dimensions;
-	value.vt = &UA_.types[UA_INT32];
+	value.vt = &UA_[UA_INT32];
 
 	//when
 	UA_Variant_copy(&value, &copiedValue);

+ 0 - 295
tests/check_list.c

@@ -1,295 +0,0 @@
-#include <stdlib.h> // EXIT_SUCCESS
-#include "util/ua_util.h"
-#include "util/ua_list.h"
-#include "check.h"
-
-/* global test counters */
-UA_Int32 visit_count = 0;
-UA_Int32 free_count = 0;
-
-void elementVisitor(UA_list_Element* payload){
-	visit_count++;
-}
-
-void visitor(void* payload){
-	visit_count++;
-}
-
-void freer(void* payload){
-	if(payload){
-		free_count++;
-		UA_free(payload);
-	}
-}
-
-_Bool matcher(void* payload){
-	if(payload == UA_NULL){
-		return UA_FALSE;
-	}
-	if(*((UA_Int32*)payload) == 42){
-		return UA_TRUE;
-	}
-	return UA_FALSE;
-}
-
-_Bool matcher2(void* payload){
-	if(payload == UA_NULL){
-		return UA_FALSE;
-	}
-	if(*((UA_Int32*)payload) == 43){
-		return UA_TRUE;
-	}
-	return UA_FALSE;
-}
-
-_Bool comparer(void* payload, void* otherPayload) {
-	if(payload == UA_NULL || otherPayload == UA_NULL){
-		return UA_FALSE;
-	} else {
-		return ( *((UA_Int32*)payload) == *((UA_Int32*)otherPayload) );
-	}
-}
-
-START_TEST(list_test_basic)
-{
-
-	UA_list_List list;
-	UA_list_init(&list);
-
-
-	ck_assert_int_eq(UA_list_addPayloadToFront(UA_NULL, UA_NULL), UA_ERROR);
-	ck_assert_int_eq(UA_list_addElementToBack(UA_NULL, UA_NULL), UA_ERROR);
-	ck_assert_int_eq(UA_list_addElementToFront(UA_NULL, UA_NULL), UA_ERROR);
-	ck_assert_int_eq(UA_list_addPayloadToBack(UA_NULL, UA_NULL), UA_ERROR);
-	ck_assert_int_eq(UA_list_removeFirst(UA_NULL, UA_NULL), UA_ERROR);
-	ck_assert_int_eq(UA_list_removeLast(UA_NULL, UA_NULL), UA_ERROR);
-	ck_assert_int_eq(UA_list_removeElement(UA_NULL, UA_NULL), UA_ERROR);
-	ck_assert_int_eq(UA_list_destroy(UA_NULL, UA_NULL), UA_ERROR);
-	ck_assert_int_eq(UA_list_iterateElement(UA_NULL, UA_NULL), UA_ERROR);
-	ck_assert_int_eq(UA_list_iteratePayload(UA_NULL, UA_NULL), UA_ERROR);
-
-	ck_assert_int_eq(list.size, 0);
-
-	UA_Int32* payload;
-	UA_alloc((void**)&payload, sizeof(*payload));
-	*payload = 42;
-	UA_list_addPayloadToFront(&list, payload);
-	UA_alloc((void**)&payload, sizeof(*payload));
-	*payload = 24;
-	UA_list_addPayloadToFront(&list, payload);
-	UA_alloc((void**)&payload, sizeof(*payload));
-	*payload = 1;
-	UA_list_addPayloadToBack(&list, payload);
-
-	ck_assert_int_eq(*(UA_Int32*)UA_list_getFirst(&list)->payload, 24);
-	ck_assert_int_eq(*(UA_Int32*)UA_list_getLast(&list)->payload, 1);
-
-	ck_assert_int_eq(list.size, 3);
-
-	visit_count = 0;
-	UA_list_iteratePayload(&list, visitor);
-	ck_assert_int_eq(visit_count, 3);
-
-	visit_count = 0;
-	UA_list_iterateElement(&list, elementVisitor);
-	ck_assert_int_eq(visit_count, 3);
-
-	UA_list_Element* elem = NULL;
-	elem = UA_list_find(&list, matcher);
-	if(elem){
-		ck_assert_int_eq((*((UA_Int32*)elem->payload)), 42);
-		UA_list_removeElement(elem, freer);
-		ck_assert_int_eq(free_count, 1);
-		free_count = 0; //reset free counter
-		ck_assert_int_eq(list.size, 2);
-	}else{
-		fail("Element 42 not found");
-	}
-
-	//search for a non-existent element
-	ck_assert_ptr_eq((UA_list_find(&list, matcher2)), UA_NULL);
-
-	UA_list_destroy(&list, freer);
-
-	ck_assert_int_eq(free_count, 2);
-
-	ck_assert_int_eq(list.size, 0);
-
-}
-END_TEST
-
-void myAddPayloadValueToFront(UA_list_List *list, UA_Int32 payloadValue) {
-	UA_Int32* payload;
-	UA_alloc((void**)&payload, sizeof(*payload));
-	*payload = payloadValue;
-	UA_list_addPayloadToFront(list, payload);
-}
-void myAddPayloadVectorToFront(UA_list_List *list, UA_Int32 payloadValues[], UA_Int32 n) {
-	UA_Int32 i = 0;
-	for (;i<n;i++) {
-		myAddPayloadValueToFront(list,payloadValues[i]);
-	}
-}
-
-START_TEST(addElementsShallResultInRespectiveSize)
-{
-	// given
-	UA_list_List list;
-	UA_list_init(&list);
-	// when
-	UA_Int32 plv[] = {42,24,1};
-	myAddPayloadVectorToFront(&list,plv,sizeof(plv)/sizeof(UA_Int32));
-	// then
-	ck_assert_int_eq(list.size, 3);
-	// finally
-	UA_list_destroy(&list, freer);
-}
-END_TEST
-
-START_TEST(findElementShallFind42)
-{
-	// given
-	UA_list_List list;
-	UA_list_init(&list);
-	UA_Int32 plv[] = {42,24,1};
-	myAddPayloadVectorToFront(&list,plv,sizeof(plv)/sizeof(UA_Int32));
-	// when
-	UA_list_Element* e = UA_list_find(&list,matcher);
-	// then
-	ck_assert_ptr_ne(e, UA_NULL);
-	ck_assert_int_eq(*(UA_Int32*)(e->payload), 42);
-	// finally
-	UA_list_destroy(&list, freer);
-}
-END_TEST
-
-START_TEST(searchElementShallFind24)
-{
-	// given
-	UA_list_List list;
-	UA_list_init(&list);
-	UA_Int32 plv[] = {42,24,1};
-	myAddPayloadVectorToFront(&list,plv,sizeof(plv)/sizeof(UA_Int32));
-	UA_Int32 payload = 24;
-	// when
-	UA_list_Element* e = UA_list_search(&list,comparer,(void*)&payload);
-	// then
-	ck_assert_ptr_ne(e, UA_NULL);
-	ck_assert_int_eq(*(UA_Int32*)(e->payload), 24);
-	// finally
-	UA_list_destroy(&list, freer);
-}
-END_TEST
-
-START_TEST(addAndRemoveShallYieldEmptyList)
-{
-	// given
-	UA_list_List list;
-	UA_list_init(&list);
-	UA_Int32 plv[] = {42};
-	myAddPayloadVectorToFront(&list,plv,sizeof(plv)/sizeof(UA_Int32));
-	// when
-	UA_list_Element* e = UA_list_search(&list,comparer,(void*)&plv[0]);
-	UA_list_removeElement(e,visitor);
-	ck_assert_int_eq(visit_count,1);
-	visit_count = 0;
-	UA_list_iteratePayload(&list,visitor);
-	// then
-	ck_assert_int_eq(list.size,0);
-	ck_assert_int_eq(visit_count,0);
-	// finally
-	UA_list_destroy(&list, freer);
-}
-END_TEST
-
-START_TEST(addAndRemoveShallYieldEmptyList2)
-{
-	// given
-	UA_list_List list;
-	UA_list_init(&list);
-	UA_Int32 plv[] = {42};
-	myAddPayloadVectorToFront(&list,plv,sizeof(plv)/sizeof(UA_Int32));
-	// when
-	UA_list_search(&list,comparer,(void*)&plv[0]);
-	UA_list_removeLast(&list,visitor);  //additionally testing removeLast explicitly
-	ck_assert_int_eq(visit_count,1);
-	visit_count = 0;
-	UA_list_iterateElement(&list,elementVisitor); //additionally testing iterateElement
-	// then
-	ck_assert_int_eq(list.size,0);
-	ck_assert_int_eq(visit_count,0);
-	// finally
-	UA_list_destroy(&list, freer);
-}
-END_TEST
-
-START_TEST(addTwiceAndRemoveFirstShallYieldListWithOneElement)
-{
-	// given
-	UA_list_List list;
-	UA_list_init(&list);
-	UA_Int32 plv[] = {42,24};
-	myAddPayloadVectorToFront(&list,plv,sizeof(plv)/sizeof(UA_Int32));
-	// when
-	UA_list_Element* e = UA_list_search(&list,comparer,(void*)&plv[0]);
-	UA_list_removeElement(e,UA_NULL);
-	visit_count = 0;
-	UA_list_iteratePayload(&list,visitor);
-	// then
-	ck_assert_int_eq(list.size,1);
-	ck_assert_int_eq(visit_count,1);
-	// finally
-	UA_list_destroy(&list, freer);
-}
-END_TEST
-
-START_TEST(addTwiceAndRemoveLastShallYieldListWithOneElement)
-{
-	// given
-	UA_list_List list;
-	UA_list_init(&list);
-	UA_Int32 plv[] = {42,24};
-	myAddPayloadVectorToFront(&list,plv,sizeof(plv)/sizeof(UA_Int32));
-	// when
-	UA_list_Element* e = UA_list_search(&list,comparer,(void*)&plv[1]);
-	UA_list_removeElement(e,UA_NULL);
-	visit_count = 0;
-	UA_list_iteratePayload(&list,visitor);
-	// then
-	ck_assert_int_eq(list.size,1);
-	ck_assert_int_eq(visit_count,1);
-	// finally
-	UA_list_destroy(&list, freer);
-}
-END_TEST
-
-Suite*list_testSuite(void)
-{
-	Suite *s = suite_create("list_test");
-	TCase *tc_core = tcase_create("Core");
-	tcase_add_test(tc_core, list_test_basic);
-	tcase_add_test(tc_core, addElementsShallResultInRespectiveSize);
-	tcase_add_test(tc_core, findElementShallFind42);
-	tcase_add_test(tc_core, searchElementShallFind24);
-	tcase_add_test(tc_core, addAndRemoveShallYieldEmptyList);
-	tcase_add_test(tc_core, addAndRemoveShallYieldEmptyList2);
-	tcase_add_test(tc_core, addTwiceAndRemoveFirstShallYieldListWithOneElement);
-	tcase_add_test(tc_core, addTwiceAndRemoveLastShallYieldListWithOneElement);
-	suite_add_tcase(s,tc_core);
-	return s;
-}
-
-int main (void)
-{
-	int number_failed = 0;
-
-	Suite* s = list_testSuite();
-	SRunner* sr = srunner_create(s);
-	srunner_run_all(sr,CK_NORMAL);
-	number_failed += srunner_ntests_failed(sr);
-	srunner_free(sr);
-
-	return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
-
-}
-

+ 34 - 34
tests/check_memory.c

@@ -3,7 +3,7 @@
 #include <stdlib.h>
 
 #include "ua_types.h"
-#include "util/ua_util.h"
+#include "ua_util.h"
 #include "ua_namespace_0.h"
 #include "check.h"
 
@@ -12,11 +12,11 @@ START_TEST(newAndEmptyObjectShallBeDeleted) {
 	UA_Int32 retval;
 	void    *obj;
 	// when
-	retval  = UA_.types[_i].new(&obj);
+	retval  = UA_[_i].new(&obj);
 #ifdef DEBUG //no print functions if not in debug mode
-	UA_.types[_i].print(obj, stdout);
+	UA_[_i].print(obj, stdout);
 #endif
-	UA_.types[_i].delete(obj);
+	UA_[_i].delete(obj);
 	// then
 	ck_assert_int_eq(retval, UA_SUCCESS);
 }
@@ -30,7 +30,7 @@ START_TEST(arrayCopyShallMakeADeepCopy) {
 	a1[2] = (UA_String){3, (UA_Byte*)"ccc"};
 	// when
 	UA_String *a2;
-	UA_Int32   retval = UA_Array_copy((const void *)a1, 3, &UA_.types[UA_STRING], (void **)&a2);
+	UA_Int32   retval = UA_Array_copy((const void *)a1, 3, &UA_[UA_STRING], (void **)&a2);
 	// then
 	ck_assert_int_eq(retval, UA_SUCCESS);
 	ck_assert_int_eq(a1[0].length, 1);
@@ -46,7 +46,7 @@ START_TEST(arrayCopyShallMakeADeepCopy) {
 	ck_assert_int_eq(a1[1].data[0], a2[1].data[0]);
 	ck_assert_int_eq(a1[2].data[0], a2[2].data[0]);
 	// finally
-	UA_Array_delete((void *)a2, 3, &UA_.types[UA_STRING]);
+	UA_Array_delete((void *)a2, 3, &UA_[UA_STRING]);
 }
 END_TEST
 
@@ -56,31 +56,31 @@ START_TEST(encodeShallYieldDecode) {
 	UA_ByteString msg1, msg2;
 	UA_Int32      retval;
 	UA_UInt32     pos = 0;
-	retval = UA_.types[_i].new(&obj1);
-	UA_ByteString_newMembers(&msg1, UA_.types[_i].encodings[UA_ENCODING_BINARY].calcSize(obj1));
-	retval |= UA_.types[_i].encodings[UA_ENCODING_BINARY].encode(obj1, &msg1, &pos);
+	retval = UA_[_i].new(&obj1);
+	UA_ByteString_newMembers(&msg1, UA_[_i].encodings[UA_ENCODING_BINARY].calcSize(obj1));
+	retval |= UA_[_i].encodings[UA_ENCODING_BINARY].encode(obj1, &msg1, &pos);
 	if(retval != UA_SUCCESS) {
-		// this happens, e.g. when we encode a variant (with UA_.types[UA_INVALIDTYPE] in the vtable)
-		UA_.types[_i].delete(obj1);
+		// this happens, e.g. when we encode a variant (with UA_[UA_INVALIDTYPE] in the vtable)
+		UA_[_i].delete(obj1);
 		UA_ByteString_deleteMembers(&msg1);
 		return;	
 	}
 
 	// when
-	UA_.types[_i].new(&obj2);
-	pos = 0; retval = UA_.types[_i].encodings[UA_ENCODING_BINARY].decode(&msg1, &pos, obj2);
-	ck_assert_msg(retval == UA_SUCCESS, "messages differ idx=%d,name=%s", _i, UA_.types[_i].name);
-	retval = UA_ByteString_newMembers(&msg2, UA_.types[_i].encodings[UA_ENCODING_BINARY].calcSize(obj2));
+	UA_[_i].new(&obj2);
+	pos = 0; retval = UA_[_i].encodings[UA_ENCODING_BINARY].decode(&msg1, &pos, obj2);
+	ck_assert_msg(retval == UA_SUCCESS, "messages differ idx=%d,name=%s", _i, UA_[_i].name);
+	retval = UA_ByteString_newMembers(&msg2, UA_[_i].encodings[UA_ENCODING_BINARY].calcSize(obj2));
 	ck_assert_int_eq(retval, UA_SUCCESS);
-	pos = 0; retval = UA_.types[_i].encodings[UA_ENCODING_BINARY].encode(obj2, &msg2, &pos);
+	pos = 0; retval = UA_[_i].encodings[UA_ENCODING_BINARY].encode(obj2, &msg2, &pos);
 	ck_assert_int_eq(retval, UA_SUCCESS);
 
 	// then
-	ck_assert_msg(UA_ByteString_equal(&msg1, &msg2) == 0, "messages differ idx=%d,name=%s", _i, UA_.types[_i].name);
+	ck_assert_msg(UA_ByteString_equal(&msg1, &msg2) == 0, "messages differ idx=%d,name=%s", _i, UA_[_i].name);
 
 	// finally
-	UA_.types[_i].delete(obj1);
-	UA_.types[_i].delete(obj2);
+	UA_[_i].delete(obj1);
+	UA_[_i].delete(obj2);
 	UA_ByteString_deleteMembers(&msg1);
 	UA_ByteString_deleteMembers(&msg2);
 }
@@ -91,20 +91,20 @@ START_TEST(decodeShallFailWithTruncatedBufferButSurvive) {
 	void *obj1 = UA_NULL, *obj2 = UA_NULL;
 	UA_ByteString msg1;
 	UA_UInt32 pos;
-	UA_.types[_i].new(&obj1);
-	UA_ByteString_newMembers(&msg1, UA_.types[_i].encodings[0].calcSize(obj1));
-	pos = 0; UA_.types[_i].encodings[0].encode(obj1, &msg1, &pos);
-	UA_.types[_i].delete(obj1);
+	UA_[_i].new(&obj1);
+	UA_ByteString_newMembers(&msg1, UA_[_i].encodings[0].calcSize(obj1));
+	pos = 0; UA_[_i].encodings[0].encode(obj1, &msg1, &pos);
+	UA_[_i].delete(obj1);
 	// when
-	UA_.types[_i].new(&obj2);
+	UA_[_i].new(&obj2);
 	pos = 0;
 	msg1.length = msg1.length / 2;
 	//fprintf(stderr,"testing %s with half buffer\n",UA_[_i].name);
-	UA_.types[_i].encodings[0].decode(&msg1, &pos, obj2);
+	UA_[_i].encodings[0].decode(&msg1, &pos, obj2);
 	//then
 	// finally
 	//fprintf(stderr,"delete %s with half buffer\n",UA_[_i].name);
-	UA_.types[_i].delete(obj2);
+	UA_[_i].delete(obj2);
 	UA_ByteString_deleteMembers(&msg1);
 }
 END_TEST
@@ -132,12 +132,12 @@ START_TEST(decodeScalarBasicTypeFromRandomBufferShallSucceed) {
 #endif
 		}
 		UA_UInt32 pos = 0;
-		retval |= UA_.types[_i].new(&obj1);
-		retval |= UA_.types[_i].encodings[0].decode(&msg1, &pos, obj1);
+		retval |= UA_[_i].new(&obj1);
+		retval |= UA_[_i].encodings[0].decode(&msg1, &pos, obj1);
 		//then
-		ck_assert_msg(retval == UA_SUCCESS, "Decoding %s from random buffer", UA_.types[_i].name);
+		ck_assert_msg(retval == UA_SUCCESS, "Decoding %s from random buffer", UA_[_i].name);
 		// finally
-		UA_.types[_i].delete(obj1);
+		UA_[_i].delete(obj1);
 	}
 	UA_ByteString_deleteMembers(&msg1);
 }
@@ -167,13 +167,13 @@ START_TEST(decodeComplexTypeFromRandomBufferShallSurvive) {
 #endif
 		}
 		UA_UInt32 pos = 0;
-		retval |= UA_.types[_i].new(&obj1);
-		retval |= UA_.types[_i].encodings[0].decode(&msg1, &pos, obj1);
+		retval |= UA_[_i].new(&obj1);
+		retval |= UA_[_i].encodings[0].decode(&msg1, &pos, obj1);
 
 		//this is allowed to fail and return UA_ERROR
-		//ck_assert_msg(retval == UA_SUCCESS, "Decoding %s from random buffer", UA_.types[_i].name);
+		//ck_assert_msg(retval == UA_SUCCESS, "Decoding %s from random buffer", UA_[_i].name);
 		
-		UA_.types[_i].delete(obj1);
+		UA_[_i].delete(obj1);
 	}
 
 	// finally

+ 1 - 1
tests/check_nodestore.c

@@ -4,7 +4,7 @@
 
 #include "ua_types.h"
 #include "server/ua_nodestore.h"
-#include "util/ua_util.h"
+#include "ua_util.h"
 #include "check.h"
 
 #ifdef MULTITHREADING

+ 7 - 7
tools/generate_builtin.py

@@ -170,7 +170,7 @@ def createStructured(element):
         if t in fixed_size:
             printc('\t + sizeof(%(t)s) // %(n)s')
         elif t.find("*") != -1:
-            printc('\t + UA_Array_calcSizeBinary(ptr->%(n)sSize,&UA_.types['+ t[0:t.find("*")].upper() +
+            printc('\t + UA_Array_calcSizeBinary(ptr->%(n)sSize,&UA_['+ t[0:t.find("*")].upper() +
                    "],ptr->%(n)s)")
             has_fixed_size = False
         else:
@@ -185,7 +185,7 @@ def createStructured(element):
     UA_Int32 retval = UA_SUCCESS;''')
     for n,t in membermap.iteritems():
         if t.find("*") != -1:
-            printc("\tretval |= UA_Array_encodeBinary(src->%(n)s,src->%(n)sSize,&UA_.types[" +
+            printc("\tretval |= UA_Array_encodeBinary(src->%(n)s,src->%(n)sSize,&UA_[" +
                    t[0:t.find("*")].upper() + "],dst,offset);")
         else:
             printc('\tretval |= %(t)s_encodeBinary(&src->%(n)s,dst,offset);')
@@ -198,7 +198,7 @@ def createStructured(element):
     for n,t in membermap.iteritems():
         if t.find("*") != -1:
             printc('\tretval |= UA_Int32_decodeBinary(src,offset,&dst->%(n)sSize);')
-            printc('\tretval |= UA_Array_decodeBinary(src,offset,dst->%(n)sSize,&UA_.types[' +
+            printc('\tretval |= UA_Array_decodeBinary(src,offset,dst->%(n)sSize,&UA_[' +
                    t[0:t.find("*")].upper() + '],(void**)&dst->%(n)s);')
             printc('\tif(retval != UA_SUCCESS) { dst->%(n)sSize = -1; %(name)s_deleteMembers(dst); return retval;}') # arrays clean up internally. But the size needs to be set here for the eventual deleteMembers.
         else:
@@ -222,7 +222,7 @@ UA_TYPE_METHOD_DECODEXML_NOTIMPL(%(name)s)''')
     for n,t in membermap.iteritems():
         if not t in fixed_size: # dynamic size on the wire
             if t.find("*") != -1:
-		printc("\tUA_Array_delete((void*)p->%(n)s,p->%(n)sSize,&UA_.types[" +
+		printc("\tUA_Array_delete((void*)p->%(n)s,p->%(n)sSize,&UA_[" +
                        t[0:t.find("*")].upper()+"]);")
             else:
 		printc('\t%(t)s_deleteMembers(&p->%(n)s);')
@@ -250,7 +250,7 @@ UA_TYPE_METHOD_DECODEXML_NOTIMPL(%(name)s)''')
     for n,t in membermap.iteritems():
         if t.find("*") != -1:
             printc('\tdst->%(n)sSize = src->%(n)sSize;')
-            printc("\tretval |= UA_Array_copy(src->%(n)s, src->%(n)sSize,&UA_.types[" + t[0:t.find("*")].upper() + "],(void**)&dst->%(n)s);")
+            printc("\tretval |= UA_Array_copy(src->%(n)s, src->%(n)sSize,&UA_[" + t[0:t.find("*")].upper() + "],(void**)&dst->%(n)s);")
             continue
         if not t in fixed_size: # there are members of variable size    
             printc('\tretval |= %(t)s_copy(&src->%(n)s,&dst->%(n)s);')
@@ -267,7 +267,7 @@ UA_TYPE_METHOD_DECODEXML_NOTIMPL(%(name)s)''')
     for i,(n,t) in enumerate(membermap.iteritems()):
         if t.find("*") != -1:
             printc('\tUA_Int32_print(&p->%(n)sSize, stream);')
-            printc("\tUA_Array_print(p->%(n)s, p->%(n)sSize, &UA_.types[" + t[0:t.find("*")].upper()+"], stream);")
+            printc("\tUA_Array_print(p->%(n)s, p->%(n)sSize, &UA_[" + t[0:t.find("*")].upper()+"], stream);")
         else:
             printc('\t%(t)s_print(&p->%(n)s,stream);')
         if i == len(membermap)-1:
@@ -320,7 +320,7 @@ printc('''/**
  
 #include "''' + args.outfile.split("/")[-1] + '''.h"
 #include "ua_namespace_0.h"
-#include "util/ua_util.h"\n''')
+#include "ua_util.h"\n''')
 
 # types for which we create a vector type
 arraytypes = set()

+ 6 - 8
tools/generate_namespace.py

@@ -103,9 +103,10 @@ printh('''/**********************************************************
  *
  * @retval UA_ERR_INVALID_VALUE whenever ns0Id could not be mapped
  * @retval the corresponding index into UA_VTable
- */\n
+ */
+
 UA_Int32 UA_ns0ToVTableIndex(const UA_NodeId *id);\n
-extern const UA_VTable UA_;
+extern const UA_VTable_Entry *UA_;
 
 /**
  * @brief the set of possible indices into UA_VTable
@@ -122,7 +123,7 @@ printc('''/**********************************************************
        ''' at '''+ time.strftime("%Y-%m-%d %I:%M:%S")+'''
  **********************************************************/\n
 #include "''' + args.outfile.split("/")[-1] + '''.h"\n
-#include "util/ua_util.h"
+#include "ua_util.h"
 UA_Int32 UA_ns0ToVTableIndex(const UA_NodeId *id) {
 	UA_Int32 retval = 0; // InvalidType
         if(id->namespaceIndex != 0) return retval;
@@ -146,10 +147,7 @@ for row in rows:
 printh("};\n")
 printc('''\n}\nreturn retval;\n}\n''');
 
-printc('''const UA_VTable UA_ = {
-\t.getTypeIndex = UA_ns0ToVTableIndex,
-\t.types = (UA_VTable_Entry[]){''')
-
+printc('''const UA_VTable_Entry *UA_ = (UA_VTable_Entry[]){''')
 i = 0
 for row in rows:
     if skipType(row):
@@ -183,7 +181,7 @@ for row in rows:
             ",\n.decode=(UA_Int32(*)(const UA_ByteString*,UA_UInt32*,void*))%(name)s_decodeXml}" if (args.with_xml) else "") +
           "}},")
 
-printc('''}};''')
+printc('};')
 
 printh('\n#define SIZE_UA_VTABLE '+str(i));