|
@@ -9,56 +9,84 @@
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
|
+UA_Int32 UA_encode(void* const data, UA_Int32 *pos, UA_Int32 type, char* dst) {
|
|
|
+ return UA_[type].encode(data,pos,dst);
|
|
|
+}
|
|
|
+
|
|
|
+UA_Int32 UA_decode(char* const data, UA_Int32* pos, UA_Int32 type, void* dst){
|
|
|
+ return UA_[type].decode(data,pos,dst);
|
|
|
+}
|
|
|
|
|
|
-Int32 UA_calcSize(void* const data, UInt32 type) {
|
|
|
+UA_Int32 UA_calcSize(void* const data, UInt32 type) {
|
|
|
return (UA_[type].calcSize)(data);
|
|
|
}
|
|
|
|
|
|
-Int32 UA_Array_calcSize(Int32 nElements, Int32 type, void const ** data) {
|
|
|
+UA_Int32 UA_Array_calcSize(UA_Int32 nElements, UA_Int32 type, void const ** data) {
|
|
|
+
|
|
|
int length = sizeof(UA_Int32);
|
|
|
int i;
|
|
|
|
|
|
+ char** ptr = (char**)data;
|
|
|
+
|
|
|
if (nElements > 0) {
|
|
|
- for(i=0; i<nElements;i++,data++) {
|
|
|
- length += UA_calcSize(data,type);
|
|
|
+ for(i=0; i<nElements;i++) {
|
|
|
+ length += UA_calcSize((void*)ptr[i],type);
|
|
|
}
|
|
|
}
|
|
|
return length;
|
|
|
}
|
|
|
-Int32 UA_Array_encode(void const **src, Int32 noElements, Int32 type, Int32* pos, char * dst) {
|
|
|
- //TODO: Implement
|
|
|
- return UA_ERR_NOT_IMPLEMENTED;
|
|
|
+UA_Int32 UA_Array_encode(void const **src, UA_Int32 noElements, UA_Int32 type, UA_Int32* pos, char * dst) {
|
|
|
+ UA_Int32 length = sizeof(UA_Int32);
|
|
|
+ UA_Int32 retVal = 0;
|
|
|
+ UA_Int32 i = 0;
|
|
|
+
|
|
|
+ char** ptr = (char**)src;
|
|
|
+
|
|
|
+ UA_Int32_encode(&noElements, pos, dst);
|
|
|
+ for(i=0; i<noElements; i++) {
|
|
|
+ retVal |= UA_[type].encode((void*)src[i], pos, dst);
|
|
|
+ }
|
|
|
+
|
|
|
+ return retVal;
|
|
|
}
|
|
|
|
|
|
-Int32 UA_Array_decode(char const * src, Int32 noElements, Int32 type, Int32* pos, void const **dst) {
|
|
|
- //TODO: Implement
|
|
|
- return UA_ERR_NOT_IMPLEMENTED;
|
|
|
+UA_Int32 UA_Array_decode(char const * src,UA_Int32 noElements, UA_Int32 type, UA_Int32* pos, void const **dst) {
|
|
|
+ UA_Int32 length = sizeof(UA_Int32);
|
|
|
+ UA_Int32 retval = 0;
|
|
|
+ UA_Int32 i = 0;
|
|
|
+
|
|
|
+ char** ptr = (char**)src;
|
|
|
+
|
|
|
+ for(i=0; i<noElements; i++) {
|
|
|
+ retval |= UA_[type].decode(src, pos, (void*)dst[i]);
|
|
|
+ }
|
|
|
+ return retval;
|
|
|
}
|
|
|
|
|
|
-Int32 UA_free(void * ptr){
|
|
|
+UA_Int32 UA_free(void * ptr){
|
|
|
free(ptr);
|
|
|
return UA_SUCCESS;
|
|
|
}
|
|
|
|
|
|
-Int32 UA_alloc(void ** ptr, int size){
|
|
|
+UA_Int32 UA_alloc(void ** ptr, int size){
|
|
|
*ptr = malloc(size);
|
|
|
if(*ptr == UA_NULL) return UA_ERR_NO_MEMORY;
|
|
|
return UA_SUCCESS;
|
|
|
}
|
|
|
|
|
|
-Int32 UA_memcpy(void * dst, void const * src, int size){
|
|
|
+UA_Int32 UA_memcpy(void * dst, void const * src, int size){
|
|
|
memcpy(dst, src, size);
|
|
|
return UA_SUCCESS;
|
|
|
}
|
|
|
|
|
|
|
|
|
UA_TYPE_METHOD_CALCSIZE_SIZEOF(UA_Boolean)
|
|
|
-Int32 UA_Boolean_encode(UA_Boolean const * src, Int32* pos, char * dst) {
|
|
|
+UA_Int32 UA_Boolean_encode(UA_Boolean const * src, UA_Int32* pos, char * dst) {
|
|
|
UA_Boolean tmpBool = ((*src > 0) ? UA_TRUE : UA_FALSE);
|
|
|
memcpy(&(dst[(*pos)++]), &tmpBool, sizeof(UA_Boolean));
|
|
|
return UA_SUCCESS;
|
|
|
}
|
|
|
-Int32 UA_Boolean_decode(char const * src, Int32* pos, UA_Boolean * dst) {
|
|
|
+UA_Int32 UA_Boolean_decode(char const * src, UA_Int32* pos, UA_Boolean * dst) {
|
|
|
*dst = ((UA_Boolean) (src[(*pos)++]) > 0) ? UA_TRUE : UA_FALSE;
|
|
|
return UA_SUCCESS;
|
|
|
}
|
|
@@ -66,13 +94,12 @@ UA_TYPE_METHOD_DELETE_FREE(UA_Boolean)
|
|
|
UA_TYPE_METHOD_DELETEMEMBERS_NOACTION(UA_Boolean)
|
|
|
|
|
|
|
|
|
-
|
|
|
UA_TYPE_METHOD_CALCSIZE_SIZEOF(UA_Byte)
|
|
|
-Int32 UA_Byte_encode(UA_Byte const * src, Int32* pos, char * dst) {
|
|
|
+UA_Int32 UA_Byte_encode(UA_Byte const * src, UA_Int32* pos, char * dst) {
|
|
|
*dst = src[(*pos)++];
|
|
|
return UA_SUCCESS;
|
|
|
}
|
|
|
-Int32 UA_Byte_decode(char const * src, Int32* pos, UA_Byte * dst) {
|
|
|
+UA_Int32 UA_Byte_decode(char const * src, UA_Int32* pos, UA_Byte * dst) {
|
|
|
memcpy(&(dst[(*pos)++]), src, sizeof(UA_Byte));
|
|
|
return UA_SUCCESS;
|
|
|
}
|
|
@@ -80,11 +107,11 @@ UA_TYPE_METHOD_DELETE_FREE(UA_Byte)
|
|
|
UA_TYPE_METHOD_DELETEMEMBERS_NOACTION(UA_Byte)
|
|
|
|
|
|
UA_TYPE_METHOD_CALCSIZE_SIZEOF(UA_SByte)
|
|
|
-Int32 UA_SByte_encode(UA_SByte const * src, Int32* pos, char * dst) {
|
|
|
+UA_Int32 UA_SByte_encode(UA_SByte const * src, UA_Int32* pos, char * dst) {
|
|
|
dst[(*pos)++] = *src;
|
|
|
return UA_SUCCESS;
|
|
|
}
|
|
|
-Int32 UA_SByte_decode(char const * src, Int32* pos, UA_SByte * dst) {
|
|
|
+UA_Int32 UA_SByte_decode(char const * src, UA_Int32* pos, UA_SByte * dst) {
|
|
|
*dst = src[(*pos)++];
|
|
|
return 1;
|
|
|
}
|
|
@@ -92,12 +119,12 @@ UA_TYPE_METHOD_DELETE_FREE(UA_SByte)
|
|
|
UA_TYPE_METHOD_DELETEMEMBERS_NOACTION(UA_SByte)
|
|
|
|
|
|
UA_TYPE_METHOD_CALCSIZE_SIZEOF(UA_UInt16)
|
|
|
-Int32 UA_UInt16_encode(UA_UInt16 const *src, Int32* pos, char * dst) {
|
|
|
+UA_Int32 UA_UInt16_encode(UA_UInt16 const *src, UA_Int32* pos, char * dst) {
|
|
|
memcpy(&(dst[*pos]), src, sizeof(UA_UInt16));
|
|
|
*pos += sizeof(UA_UInt16);
|
|
|
return UA_SUCCESS;
|
|
|
}
|
|
|
-Int32 UA_UInt16_decode(char const * src, Int32* pos, UA_UInt16* dst) {
|
|
|
+UA_Int32 UA_UInt16_decode(char const * src, UA_Int32* pos, UA_UInt16* dst) {
|
|
|
Byte t1 = src[(*pos)++];
|
|
|
UInt16 t2 = (UInt16) (src[(*pos)++] << 8);
|
|
|
*dst = t1 + t2;
|
|
@@ -107,12 +134,12 @@ UA_TYPE_METHOD_DELETE_FREE(UA_UInt16)
|
|
|
UA_TYPE_METHOD_DELETEMEMBERS_NOACTION(UA_UInt16)
|
|
|
|
|
|
UA_TYPE_METHOD_CALCSIZE_SIZEOF(UA_Int16)
|
|
|
-Int32 UA_Int16_encode(UA_Int16 const * src, Int32* pos, char* dst) {
|
|
|
+UA_Int32 UA_Int16_encode(UA_Int16 const * src, UA_Int32* pos, char* dst) {
|
|
|
memcpy(&(dst[*pos]), src, sizeof(UA_Int16));
|
|
|
*pos += sizeof(UA_Int16);
|
|
|
return UA_SUCCESS;
|
|
|
}
|
|
|
-Int32 UA_Int16_decode(char const * src, Int32* pos, UA_Int16 *dst) {
|
|
|
+UA_Int32 UA_Int16_decode(char const * src, UA_Int32* pos, UA_Int16 *dst) {
|
|
|
Int16 t1 = (Int16) (((SByte) (src[(*pos)++]) & 0xFF));
|
|
|
Int16 t2 = (Int16) (((SByte) (src[(*pos)++]) & 0xFF) << 8);
|
|
|
*dst = t1 + t2;
|
|
@@ -122,16 +149,16 @@ UA_TYPE_METHOD_DELETE_FREE(UA_Int16)
|
|
|
UA_TYPE_METHOD_DELETEMEMBERS_NOACTION(UA_Int16)
|
|
|
|
|
|
UA_TYPE_METHOD_CALCSIZE_SIZEOF(UA_Int32)
|
|
|
-Int32 UA_Int32_encode(UA_Int32 const * src, Int32* pos, char *dst) {
|
|
|
+UA_Int32 UA_Int32_encode(UA_Int32 const * src, UA_Int32* pos, char *dst) {
|
|
|
memcpy(&(dst[*pos]), src, sizeof(UA_Int32));
|
|
|
*pos += sizeof(UA_Int32);
|
|
|
return UA_SUCCESS;
|
|
|
}
|
|
|
-Int32 UA_Int32_decode(char const * src, Int32* pos, UA_Int32* dst) {
|
|
|
- Int32 t1 = (Int32) (((SByte) (src[(*pos)++]) & 0xFF));
|
|
|
- Int32 t2 = (Int32) (((SByte) (src[(*pos)++]) & 0xFF) << 8);
|
|
|
- Int32 t3 = (Int32) (((SByte) (src[(*pos)++]) & 0xFF) << 16);
|
|
|
- Int32 t4 = (Int32) (((SByte) (src[(*pos)++]) & 0xFF) << 24);
|
|
|
+UA_Int32 UA_Int32_decode(char const * src, UA_Int32* pos, UA_Int32* dst) {
|
|
|
+ UA_Int32 t1 = (UA_Int32) (((SByte) (src[(*pos)++]) & 0xFF));
|
|
|
+ UA_Int32 t2 = (UA_Int32) (((SByte) (src[(*pos)++]) & 0xFF) << 8);
|
|
|
+ UA_Int32 t3 = (UA_Int32) (((SByte) (src[(*pos)++]) & 0xFF) << 16);
|
|
|
+ UA_Int32 t4 = (UA_Int32) (((SByte) (src[(*pos)++]) & 0xFF) << 24);
|
|
|
*dst = t1 + t2 + t3 + t4;
|
|
|
return UA_SUCCESS;
|
|
|
}
|
|
@@ -139,12 +166,12 @@ UA_TYPE_METHOD_DELETE_FREE(UA_Int32)
|
|
|
UA_TYPE_METHOD_DELETEMEMBERS_NOACTION(UA_Int32)
|
|
|
|
|
|
UA_TYPE_METHOD_CALCSIZE_SIZEOF(UA_UInt32)
|
|
|
-Int32 UA_UInt32_encode(UA_UInt32 const * src, Int32* pos, char *dst) {
|
|
|
+UA_Int32 UA_UInt32_encode(UA_UInt32 const * src, UA_Int32* pos, char *dst) {
|
|
|
memcpy(&(dst[*pos]), src, sizeof(UA_UInt32));
|
|
|
*pos += sizeof(UA_UInt32);
|
|
|
return UA_SUCCESS;
|
|
|
}
|
|
|
-Int32 UA_UInt32_decode(char const * src, Int32* pos, UA_UInt32 *dst) {
|
|
|
+UA_Int32 UA_UInt32_decode(char const * src, UA_Int32* pos, UA_UInt32 *dst) {
|
|
|
UInt32 t1 = (UInt32) src[(*pos)++];
|
|
|
UInt32 t2 = (UInt32) src[(*pos)++] << 8;
|
|
|
UInt32 t3 = (UInt32) src[(*pos)++] << 16;
|
|
@@ -156,12 +183,12 @@ UA_TYPE_METHOD_DELETE_FREE(UA_UInt32)
|
|
|
UA_TYPE_METHOD_DELETEMEMBERS_NOACTION(UA_UInt32)
|
|
|
|
|
|
UA_TYPE_METHOD_CALCSIZE_SIZEOF(UA_Int64)
|
|
|
-Int32 UA_Int64_encode(UA_Int64 const * src, Int32* pos, char *dst) {
|
|
|
+UA_Int32 UA_Int64_encode(UA_Int64 const * src, UA_Int32* pos, char *dst) {
|
|
|
memcpy(&(dst[*pos]), src, sizeof(UA_Int64));
|
|
|
*pos += sizeof(UA_Int64);
|
|
|
return UA_SUCCESS;
|
|
|
}
|
|
|
-Int32 UA_Int64_decode(char const * src, Int32* pos, UA_Int64* dst) {
|
|
|
+UA_Int32 UA_Int64_decode(char const * src, UA_Int32* pos, UA_Int64* dst) {
|
|
|
Int64 t1 = (Int64) src[(*pos)++];
|
|
|
Int64 t2 = (Int64) src[(*pos)++] << 8;
|
|
|
Int64 t3 = (Int64) src[(*pos)++] << 16;
|
|
@@ -177,12 +204,12 @@ UA_TYPE_METHOD_DELETE_FREE(UA_Int64)
|
|
|
UA_TYPE_METHOD_DELETEMEMBERS_NOACTION(UA_Int64)
|
|
|
|
|
|
UA_TYPE_METHOD_CALCSIZE_SIZEOF(UA_UInt64)
|
|
|
-Int32 UA_UInt64_encode(UA_UInt64 const * src , Int32* pos, char * dst) {
|
|
|
+UA_Int32 UA_UInt64_encode(UA_UInt64 const * src , UA_Int32* pos, char * dst) {
|
|
|
memcpy(&(dst[*pos]), src, sizeof(UA_UInt64));
|
|
|
*pos += sizeof(UInt64);
|
|
|
return UA_SUCCESS;
|
|
|
}
|
|
|
-Int32 UA_UInt64_decode(char const * src, Int32* pos, UA_UInt64* dst) {
|
|
|
+UA_Int32 UA_UInt64_decode(char const * src, UA_Int32* pos, UA_UInt64* dst) {
|
|
|
UInt64 t1 = (UInt64) src[(*pos)++];
|
|
|
UInt64 t2 = (UInt64) src[(*pos)++] << 8;
|
|
|
UInt64 t3 = (UInt64) src[(*pos)++] << 16;
|
|
@@ -198,13 +225,13 @@ UA_TYPE_METHOD_DELETE_FREE(UA_UInt64)
|
|
|
UA_TYPE_METHOD_DELETEMEMBERS_NOACTION(UA_UInt64)
|
|
|
|
|
|
UA_TYPE_METHOD_CALCSIZE_SIZEOF(UA_Float)
|
|
|
-Int32 UA_Float_decode(char const * src, Int32* pos, UA_Float* dst) {
|
|
|
+UA_Int32 UA_Float_decode(char const * src, UA_Int32* pos, UA_Float* dst) {
|
|
|
// TODO: not yet implemented
|
|
|
memcpy(dst, &(src[*pos]), sizeof(UA_Float));
|
|
|
*pos += sizeof(UA_Float);
|
|
|
return UA_SUCCESS;
|
|
|
}
|
|
|
-Int32 UA_Float_encode(UA_Float const * src, Int32* pos, char *dst) {
|
|
|
+UA_Int32 UA_Float_encode(UA_Float const * src, UA_Int32* pos, char *dst) {
|
|
|
// TODO: not yet implemented
|
|
|
memcpy(&(dst[*pos]), src, sizeof(UA_Float));
|
|
|
*pos += sizeof(UA_Float);
|
|
@@ -214,7 +241,7 @@ UA_TYPE_METHOD_DELETE_FREE(UA_Float)
|
|
|
UA_TYPE_METHOD_DELETEMEMBERS_NOACTION(UA_Float)
|
|
|
|
|
|
UA_TYPE_METHOD_CALCSIZE_SIZEOF(UA_Double)
|
|
|
-Int32 UA_Double_decode(char const * src, Int32* pos, UA_Double * dst) {
|
|
|
+UA_Int32 UA_Double_decode(char const * src, UA_Int32* pos, UA_Double * dst) {
|
|
|
// TODO: not yet implemented
|
|
|
Double tmpDouble;
|
|
|
tmpDouble = (Double) (src[*pos]);
|
|
@@ -222,7 +249,7 @@ Int32 UA_Double_decode(char const * src, Int32* pos, UA_Double * dst) {
|
|
|
*dst = tmpDouble;
|
|
|
return UA_SUCCESS;
|
|
|
}
|
|
|
-Int32 UA_Double_encode(UA_Double const * src, Int32 *pos, char * dst) {
|
|
|
+UA_Int32 UA_Double_encode(UA_Double const * src, UA_Int32 *pos, char * dst) {
|
|
|
// TODO: not yet implemented
|
|
|
memcpy(&(dst[*pos]), src, sizeof(UA_Double));
|
|
|
*pos *= sizeof(UA_Double);
|
|
@@ -231,7 +258,7 @@ Int32 UA_Double_encode(UA_Double const * src, Int32 *pos, char * dst) {
|
|
|
UA_TYPE_METHOD_DELETE_FREE(UA_Double)
|
|
|
UA_TYPE_METHOD_DELETEMEMBERS_NOACTION(UA_Double)
|
|
|
|
|
|
-Int32 UA_String_calcSize(UA_String const * string) {
|
|
|
+UA_Int32 UA_String_calcSize(UA_String const * string) {
|
|
|
if (string == UA_NULL) {
|
|
|
// internal size for UA_memalloc
|
|
|
return sizeof(UA_String);
|
|
@@ -244,7 +271,7 @@ Int32 UA_String_calcSize(UA_String const * string) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-Int32 UA_String_encode(UA_String const * src, Int32* pos, char *dst) {
|
|
|
+UA_Int32 UA_String_encode(UA_String const * src, UA_Int32* pos, char *dst) {
|
|
|
UA_Int32_encode(&(src->length),pos,dst);
|
|
|
|
|
|
if (src->length > 0) {
|
|
@@ -253,11 +280,11 @@ Int32 UA_String_encode(UA_String const * src, Int32* pos, char *dst) {
|
|
|
}
|
|
|
return UA_SUCCESS;
|
|
|
}
|
|
|
-Int32 UA_String_decode(char const * src, Int32* pos, UA_String * dst) {
|
|
|
- Int32 retval = UA_SUCCESS;
|
|
|
+UA_Int32 UA_String_decode(char const * src, UA_Int32* pos, UA_String * dst) {
|
|
|
+ UA_Int32 retval = UA_SUCCESS;
|
|
|
retval |= UA_Int32_decode(src,pos,&(dst->length));
|
|
|
if (dst->length > 0) {
|
|
|
- retval |= UA_alloc(&(dst->data),dst->length);
|
|
|
+ retval |= UA_alloc((void*)&(dst->data),dst->length);
|
|
|
retval |= UA_memcpy((void*)&(src[*pos]),dst->data,dst->length);
|
|
|
*pos += dst->length;
|
|
|
} else {
|
|
@@ -266,13 +293,14 @@ Int32 UA_String_decode(char const * src, Int32* pos, UA_String * dst) {
|
|
|
return retval;
|
|
|
}
|
|
|
UA_TYPE_METHOD_DELETE_STRUCT(UA_String)
|
|
|
-Int32 UA_String_deleteMembers(UA_String* p) { return UA_free(p->data); };
|
|
|
-Int32 UA_String_copy(UA_String const * src, UA_String* dst) {
|
|
|
- Int32 retval = UA_SUCCESS;
|
|
|
+UA_Int32 UA_String_deleteMembers(UA_String* p) { return UA_free(p->data); };
|
|
|
+UA_Int32 UA_String_copy(UA_String const * src, UA_String* dst) {
|
|
|
+ UA_Int32 retval = UA_SUCCESS;
|
|
|
dst->length = src->length;
|
|
|
dst->data = UA_NULL;
|
|
|
if (src->length > 0) {
|
|
|
- retval |= UA_alloc(&(dst->data), src->length);
|
|
|
+
|
|
|
+ retval |= UA_alloc((void*)&(dst->data), src->length);
|
|
|
if (retval == UA_SUCCESS) {
|
|
|
retval |= UA_memcpy((void*)dst->data, src->data, src->length);
|
|
|
}
|
|
@@ -290,7 +318,7 @@ UA_TYPE_METHOD_DECODE_AS(UA_ByteString, UA_String)
|
|
|
UA_TYPE_METHOD_DELETE_AS(UA_ByteString, UA_String)
|
|
|
UA_TYPE_METHOD_DELETEMEMBERS_AS(UA_ByteString, UA_String)
|
|
|
|
|
|
-Int32 UA_Guid_calcSize(UA_Guid const * p) {
|
|
|
+UA_Int32 UA_Guid_calcSize(UA_Guid const * p) {
|
|
|
if (p == UA_NULL) {
|
|
|
return sizeof(UA_Guid);
|
|
|
} else {
|
|
@@ -302,16 +330,16 @@ Int32 UA_Guid_calcSize(UA_Guid const * p) {
|
|
|
;
|
|
|
}
|
|
|
}
|
|
|
-Int32 UA_Guid_encode(UA_Guid const *src, Int32* pos, char *dst) {
|
|
|
- Int32 retval = UA_SUCCESS;
|
|
|
+UA_Int32 UA_Guid_encode(UA_Guid const *src, UA_Int32* pos, char *dst) {
|
|
|
+ UA_Int32 retval = UA_SUCCESS;
|
|
|
retval |= UA_UInt32_encode(&(src->data1), pos, dst);
|
|
|
retval |= UA_UInt16_encode(&(src->data2), pos, dst);
|
|
|
retval |= UA_UInt16_encode(&(src->data3), pos, dst);
|
|
|
retval |= UA_ByteString_encode(&(src->data4), pos, dst);
|
|
|
return UA_SUCCESS;
|
|
|
}
|
|
|
-Int32 UA_Guid_decode(char const * src, Int32* pos, UA_Guid *dst) {
|
|
|
- Int32 retval = UA_SUCCESS;
|
|
|
+UA_Int32 UA_Guid_decode(char const * src, UA_Int32* pos, UA_Guid *dst) {
|
|
|
+ UA_Int32 retval = UA_SUCCESS;
|
|
|
retval |= UA_Int32_decode(src,pos,&(dst->data1));
|
|
|
retval |= UA_Int16_decode(src,pos,&(dst->data2));
|
|
|
retval |= UA_Int16_decode(src,pos,&(dst->data3));
|
|
@@ -319,10 +347,10 @@ Int32 UA_Guid_decode(char const * src, Int32* pos, UA_Guid *dst) {
|
|
|
return retval;
|
|
|
}
|
|
|
UA_TYPE_METHOD_DELETE_STRUCT(UA_Guid)
|
|
|
-Int32 UA_Guid_deleteMembers(UA_Guid* p) { return UA_ByteString_delete(&(p->data4)); };
|
|
|
+UA_Int32 UA_Guid_deleteMembers(UA_Guid* p) { return UA_ByteString_delete(&(p->data4)); };
|
|
|
|
|
|
-Int32 UA_LocalizedText_calcSize(UA_LocalizedText const * p) {
|
|
|
- Int32 length = 0;
|
|
|
+UA_Int32 UA_LocalizedText_calcSize(UA_LocalizedText const * p) {
|
|
|
+ UA_Int32 length = 0;
|
|
|
if (p==UA_NULL) {
|
|
|
// size for UA_memalloc
|
|
|
length = sizeof(UA_LocalizedText);
|
|
@@ -338,9 +366,9 @@ Int32 UA_LocalizedText_calcSize(UA_LocalizedText const * p) {
|
|
|
}
|
|
|
return length;
|
|
|
}
|
|
|
-Int32 UA_LocalizedText_encode(UA_LocalizedText const * src, Int32 *pos,
|
|
|
+UA_Int32 UA_LocalizedText_encode(UA_LocalizedText const * src, UA_Int32 *pos,
|
|
|
char * dst) {
|
|
|
- Int32 retval = UA_SUCCESS;
|
|
|
+ UA_Int32 retval = UA_SUCCESS;
|
|
|
retval |= UA_Byte_encode(&(src->encodingMask),pos,dst);
|
|
|
if (src->encodingMask & 0x01) {
|
|
|
UA_String_encode(&(src->locale),pos,dst);
|
|
@@ -350,9 +378,9 @@ Int32 UA_LocalizedText_encode(UA_LocalizedText const * src, Int32 *pos,
|
|
|
}
|
|
|
return retval;
|
|
|
}
|
|
|
-Int32 UA_LocalizedText_decode(char const * src, Int32 *pos,
|
|
|
+UA_Int32 UA_LocalizedText_decode(char const * src, UA_Int32 *pos,
|
|
|
UA_LocalizedText *dst) {
|
|
|
- Int32 retval = UA_SUCCESS;
|
|
|
+ UA_Int32 retval = UA_SUCCESS;
|
|
|
retval |= UA_String_copy(&UA_String_null,&(dst->locale));
|
|
|
retval |= UA_String_copy(&UA_String_null,&(dst->text));
|
|
|
|
|
@@ -366,7 +394,7 @@ Int32 UA_LocalizedText_decode(char const * src, Int32 *pos,
|
|
|
return retval;
|
|
|
}
|
|
|
UA_TYPE_METHOD_DELETE_STRUCT(UA_LocalizedText)
|
|
|
-Int32 UA_LocalizedText_deleteMembers(UA_LocalizedText* p) {
|
|
|
+UA_Int32 UA_LocalizedText_deleteMembers(UA_LocalizedText* p) {
|
|
|
return UA_SUCCESS
|
|
|
|| UA_String_deleteMembers(&(p->locale))
|
|
|
|| UA_String_deleteMembers(&(p->text))
|
|
@@ -374,8 +402,8 @@ Int32 UA_LocalizedText_deleteMembers(UA_LocalizedText* p) {
|
|
|
};
|
|
|
|
|
|
/* Serialization of UA_NodeID is specified in 62541-6, §5.2.2.9 */
|
|
|
-Int32 UA_NodeId_calcSize(UA_NodeId const *p) {
|
|
|
- Int32 length = 0;
|
|
|
+UA_Int32 UA_NodeId_calcSize(UA_NodeId const *p) {
|
|
|
+ UA_Int32 length = 0;
|
|
|
if (p == UA_NULL) {
|
|
|
length = sizeof(UA_NodeId);
|
|
|
} else {
|
|
@@ -404,7 +432,7 @@ Int32 UA_NodeId_calcSize(UA_NodeId const *p) {
|
|
|
}
|
|
|
return length;
|
|
|
}
|
|
|
-Int32 UA_NodeId_encode(UA_NodeId const * src, Int32* pos, char *dst) {
|
|
|
+UA_Int32 UA_NodeId_encode(UA_NodeId const * src, UA_Int32* pos, char *dst) {
|
|
|
// temporary variables for endian-save code
|
|
|
UA_Byte srcByte;
|
|
|
UA_UInt16 srcUInt16;
|
|
@@ -441,7 +469,7 @@ Int32 UA_NodeId_encode(UA_NodeId const * src, Int32* pos, char *dst) {
|
|
|
}
|
|
|
return retval;
|
|
|
}
|
|
|
-Int32 UA_NodeId_decode(char const * src, Int32* pos, UA_NodeId *dst) {
|
|
|
+UA_Int32 UA_NodeId_decode(char const * src, UA_Int32* pos, UA_NodeId *dst) {
|
|
|
int retval = UA_SUCCESS;
|
|
|
// temporary variables to overcome decoder's non-endian-saveness for datatypes
|
|
|
Byte dstByte;
|
|
@@ -480,7 +508,7 @@ Int32 UA_NodeId_decode(char const * src, Int32* pos, UA_NodeId *dst) {
|
|
|
return retval;
|
|
|
}
|
|
|
UA_TYPE_METHOD_DELETE_STRUCT(UA_NodeId)
|
|
|
-Int32 UA_NodeId_deleteMembers(UA_NodeId* p) {
|
|
|
+UA_Int32 UA_NodeId_deleteMembers(UA_NodeId* p) {
|
|
|
int retval = UA_SUCCESS;
|
|
|
switch (p->encodingByte) {
|
|
|
case UA_NodeIdType_TwoByte:
|
|
@@ -503,8 +531,8 @@ Int32 UA_NodeId_deleteMembers(UA_NodeId* p) {
|
|
|
//FIXME: Sten Where do these two flags come from?
|
|
|
#define NIEVT_NAMESPACE_URI_FLAG 0x80 //Is only for ExpandedNodeId required
|
|
|
#define NIEVT_SERVERINDEX_FLAG 0x40 //Is only for ExpandedNodeId required
|
|
|
-Int32 UA_ExpandedNodeId_calcSize(UA_ExpandedNodeId const * p) {
|
|
|
- Int32 length = 0;
|
|
|
+UA_Int32 UA_ExpandedNodeId_calcSize(UA_ExpandedNodeId const * p) {
|
|
|
+ UA_Int32 length = 0;
|
|
|
if (p == UA_NULL) {
|
|
|
length = sizeof(UA_ExpandedNodeId);
|
|
|
} else {
|
|
@@ -518,7 +546,7 @@ Int32 UA_ExpandedNodeId_calcSize(UA_ExpandedNodeId const * p) {
|
|
|
}
|
|
|
return length;
|
|
|
}
|
|
|
-Int32 UA_ExpandedNodeId_encode(UA_ExpandedNodeId const * src, Int32* pos, char *dst) {
|
|
|
+UA_Int32 UA_ExpandedNodeId_encode(UA_ExpandedNodeId const * src, UA_Int32* pos, char *dst) {
|
|
|
UInt32 retval = UA_SUCCESS;
|
|
|
retval |= UA_NodeId_encode(&(src->nodeId),pos,dst);
|
|
|
if (src->nodeId.encodingByte & NIEVT_NAMESPACE_URI_FLAG) {
|
|
@@ -529,7 +557,7 @@ Int32 UA_ExpandedNodeId_encode(UA_ExpandedNodeId const * src, Int32* pos, char *
|
|
|
}
|
|
|
return retval;
|
|
|
}
|
|
|
-Int32 UA_ExpandedNodeId_decode(char const * src, Int32* pos,
|
|
|
+UA_Int32 UA_ExpandedNodeId_decode(char const * src, UA_Int32* pos,
|
|
|
UA_ExpandedNodeId *dst) {
|
|
|
UInt32 retval = UA_SUCCESS;
|
|
|
retval |= UA_NodeId_decode(src,pos,&(dst->nodeId));
|
|
@@ -546,15 +574,15 @@ Int32 UA_ExpandedNodeId_decode(char const * src, Int32* pos,
|
|
|
return retval;
|
|
|
}
|
|
|
UA_TYPE_METHOD_DELETE_STRUCT(UA_ExpandedNodeId)
|
|
|
-Int32 UA_ExpandedNodeId_deleteMembers(UA_ExpandedNodeId* p) {
|
|
|
- Int32 retval = UA_SUCCESS;
|
|
|
+UA_Int32 UA_ExpandedNodeId_deleteMembers(UA_ExpandedNodeId* p) {
|
|
|
+ UA_Int32 retval = UA_SUCCESS;
|
|
|
retval |= UA_NodeId_deleteMembers(&(p->nodeId));
|
|
|
retval |= UA_String_deleteMembers(&(p->namespaceUri));
|
|
|
return retval;
|
|
|
}
|
|
|
|
|
|
-Int32 UA_ExtensionObject_calcSize(UA_ExtensionObject const * p) {
|
|
|
- Int32 length = 0;
|
|
|
+UA_Int32 UA_ExtensionObject_calcSize(UA_ExtensionObject const * p) {
|
|
|
+ UA_Int32 length = 0;
|
|
|
if (p == UA_NULL) {
|
|
|
length = sizeof(UA_ExtensionObject);
|
|
|
} else {
|
|
@@ -574,31 +602,31 @@ Int32 UA_ExtensionObject_calcSize(UA_ExtensionObject const * p) {
|
|
|
}
|
|
|
return length;
|
|
|
}
|
|
|
-Int32 UA_ExtensionObject_encode(UA_ExtensionObject const *src, Int32* pos, char * dst) {
|
|
|
- Int32 retval = UA_SUCCESS;
|
|
|
+UA_Int32 UA_ExtensionObject_encode(UA_ExtensionObject const *src, UA_Int32* pos, char * dst) {
|
|
|
+ UA_Int32 retval = UA_SUCCESS;
|
|
|
retval |= UA_NodeId_encode(&(src->typeId),pos,dst);
|
|
|
retval |= UA_Byte_encode(&(src->encoding),pos,dst);
|
|
|
switch (src->encoding) {
|
|
|
- case NO_BODY_IS_ENCODED:
|
|
|
+ case UA_ExtensionObject_NoBodyIsEncoded:
|
|
|
break;
|
|
|
- case BODY_IS_BYTE_STRING:
|
|
|
- case BODY_IS_XML_ELEMENT:
|
|
|
+ case UA_ExtensionObject_BodyIsByteString:
|
|
|
+ case UA_ExtensionObject_BodyIsXml:
|
|
|
retval |= UA_ByteString_encode(&(src->body),pos,dst);
|
|
|
break;
|
|
|
}
|
|
|
return retval;
|
|
|
}
|
|
|
-Int32 UA_ExtensionObject_decode(char const * src, Int32 *pos,
|
|
|
+UA_Int32 UA_ExtensionObject_decode(char const * src, UA_Int32 *pos,
|
|
|
UA_ExtensionObject *dst) {
|
|
|
- Int32 retval = UA_SUCCESS;
|
|
|
+ UA_Int32 retval = UA_SUCCESS;
|
|
|
retval |= UA_NodeId_decode(src,pos,&(dst->typeId));
|
|
|
retval |= UA_Byte_decode(src,pos,&(dst->encoding));
|
|
|
retval |= UA_String_copy(&UA_String_null, (UA_String*) &(dst->body));
|
|
|
switch (dst->encoding) {
|
|
|
- case NO_BODY_IS_ENCODED:
|
|
|
+ case UA_ExtensionObject_NoBodyIsEncoded:
|
|
|
break;
|
|
|
- case BODY_IS_BYTE_STRING:
|
|
|
- case BODY_IS_XML_ELEMENT:
|
|
|
+ case UA_ExtensionObject_BodyIsByteString:
|
|
|
+ case UA_ExtensionObject_BodyIsXml:
|
|
|
retval |= UA_ByteString_decode(src,pos,&(dst->body));
|
|
|
break;
|
|
|
}
|
|
@@ -606,8 +634,8 @@ Int32 UA_ExtensionObject_decode(char const * src, Int32 *pos,
|
|
|
}
|
|
|
|
|
|
UA_TYPE_METHOD_DELETE_STRUCT(UA_ExtensionObject)
|
|
|
-Int32 UA_ExtensionObject_deleteMembers(UA_ExtensionObject *p) {
|
|
|
- Int32 retval = UA_SUCCESS;
|
|
|
+UA_Int32 UA_ExtensionObject_deleteMembers(UA_ExtensionObject *p) {
|
|
|
+ UA_Int32 retval = UA_SUCCESS;
|
|
|
retval |= UA_NodeId_deleteMembers(&(p->typeId));
|
|
|
retval |= UA_ByteString_deleteMembers(&(p->body));
|
|
|
return retval;
|
|
@@ -619,33 +647,34 @@ Int32 UA_ExtensionObject_deleteMembers(UA_ExtensionObject *p) {
|
|
|
// TODO: UA_DataValue_deleteMembers
|
|
|
|
|
|
/** DiagnosticInfo - Part: 4, Chapter: 7.9, Page: 116 */
|
|
|
-Int32 UA_DiagnosticInfo_decode(char const * src, Int32 *pos, UA_DiagnosticInfo *dst) {
|
|
|
- Int32 retval = UA_SUCCESS;
|
|
|
+UA_Int32 UA_DiagnosticInfo_decode(char const * src, UA_Int32 *pos, UA_DiagnosticInfo *dst) {
|
|
|
+ UA_Int32 retval = UA_SUCCESS;
|
|
|
int i;
|
|
|
|
|
|
retval |= UA_Byte_decode(src, pos, &(dst->encodingMask));
|
|
|
|
|
|
for (i = 0; i < 7; i++) {
|
|
|
switch ( (0x01 << i) & dst->encodingMask) {
|
|
|
- case DIEMT_SYMBOLIC_ID:
|
|
|
+
|
|
|
+ case UA_DiagnosticInfoEncodingMaskType_SymbolicId:
|
|
|
retval |= UA_Int32_decode(src, pos, &(dst->symbolicId));
|
|
|
break;
|
|
|
- case DIEMT_NAMESPACE:
|
|
|
+ case UA_DiagnosticInfoEncodingMaskType_Namespace:
|
|
|
retval |= UA_Int32_decode(src, pos, &(dst->namespaceUri));
|
|
|
break;
|
|
|
- case DIEMT_LOCALIZED_TEXT:
|
|
|
+ case UA_DiagnosticInfoEncodingMaskType_LocalizedText:
|
|
|
retval |= UA_Int32_decode(src, pos, &(dst->localizedText));
|
|
|
break;
|
|
|
- case DIEMT_LOCALE:
|
|
|
+ case UA_DiagnosticInfoEncodingMaskType_Locale:
|
|
|
retval |= UA_Int32_decode(src, pos, &(dst->locale));
|
|
|
break;
|
|
|
- case DIEMT_ADDITIONAL_INFO:
|
|
|
+ case UA_DiagnosticInfoEncodingMaskType_AdditionalInfo:
|
|
|
retval |= UA_String_decode(src, pos, &(dst->additionalInfo));
|
|
|
break;
|
|
|
- case DIEMT_INNER_STATUS_CODE:
|
|
|
+ case UA_DiagnosticInfoEncodingMaskType_InnerStatusCode:
|
|
|
retval |= UA_StatusCode_decode(src, pos, &(dst->innerStatusCode));
|
|
|
break;
|
|
|
- case DIEMT_INNER_DIAGNOSTIC_INFO:
|
|
|
+ case UA_DiagnosticInfoEncodingMaskType_InnerDiagnosticInfo:
|
|
|
// innerDiagnosticInfo is a pointer to struct, therefore allocate
|
|
|
retval |= UA_alloc((void **) &(dst->innerDiagnosticInfo),UA_DiagnosticInfo_calcSize(UA_NULL));
|
|
|
retval |= UA_DiagnosticInfo_decode(src, pos, dst->innerDiagnosticInfo);
|
|
@@ -654,41 +683,41 @@ Int32 UA_DiagnosticInfo_decode(char const * src, Int32 *pos, UA_DiagnosticInfo *
|
|
|
}
|
|
|
return retval;
|
|
|
}
|
|
|
-Int32 UA_DiagnosticInfo_encode(UA_DiagnosticInfo const *src, Int32 *pos, char *dst) {
|
|
|
- Int32 retval = UA_SUCCESS;
|
|
|
+UA_Int32 UA_DiagnosticInfo_encode(UA_DiagnosticInfo const *src, UA_Int32 *pos, char *dst) {
|
|
|
+ UA_Int32 retval = UA_SUCCESS;
|
|
|
Byte mask;
|
|
|
int i;
|
|
|
|
|
|
UA_Byte_encode(&(src->encodingMask), pos, dst);
|
|
|
for (i = 0; i < 7; i++) {
|
|
|
switch ( (0x01 << i) & src->encodingMask) {
|
|
|
- case DIEMT_SYMBOLIC_ID:
|
|
|
+ case UA_DiagnosticInfoEncodingMaskType_SymbolicId:
|
|
|
retval |= UA_Int32_encode(&(src->symbolicId), pos, dst);
|
|
|
break;
|
|
|
- case DIEMT_NAMESPACE:
|
|
|
+ case UA_DiagnosticInfoEncodingMaskType_Namespace:
|
|
|
retval |= UA_Int32_encode( &(src->namespaceUri), pos, dst);
|
|
|
break;
|
|
|
- case DIEMT_LOCALIZED_TEXT:
|
|
|
+ case UA_DiagnosticInfoEncodingMaskType_LocalizedText:
|
|
|
retval |= UA_Int32_encode(&(src->localizedText), pos, dst);
|
|
|
break;
|
|
|
- case DIEMT_LOCALE:
|
|
|
+ case UA_DiagnosticInfoEncodingMaskType_Locale:
|
|
|
retval |= UA_Int32_encode(&(src->locale), pos, dst);
|
|
|
break;
|
|
|
- case DIEMT_ADDITIONAL_INFO:
|
|
|
+ case UA_DiagnosticInfoEncodingMaskType_AdditionalInfo:
|
|
|
retval |= UA_String_encode(&(src->additionalInfo), pos, dst);
|
|
|
break;
|
|
|
- case DIEMT_INNER_STATUS_CODE:
|
|
|
+ case UA_DiagnosticInfoEncodingMaskType_InnerStatusCode:
|
|
|
retval |= UA_StatusCode_encode(&(src->innerStatusCode), pos, dst);
|
|
|
break;
|
|
|
- case DIEMT_INNER_DIAGNOSTIC_INFO:
|
|
|
+ case UA_DiagnosticInfoEncodingMaskType_InnerDiagnosticInfo:
|
|
|
retval |= UA_DiagnosticInfo_encode(src->innerDiagnosticInfo, pos, dst);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
return retval;
|
|
|
}
|
|
|
-Int32 UA_DiagnosticInfo_calcSize(UA_DiagnosticInfo const * ptr) {
|
|
|
- Int32 length = 0;
|
|
|
+UA_Int32 UA_DiagnosticInfo_calcSize(UA_DiagnosticInfo const * ptr) {
|
|
|
+ UA_Int32 length = 0;
|
|
|
if (ptr == UA_NULL) {
|
|
|
length = sizeof(UA_DiagnosticInfo);
|
|
|
} else {
|
|
@@ -698,26 +727,26 @@ Int32 UA_DiagnosticInfo_calcSize(UA_DiagnosticInfo const * ptr) {
|
|
|
for (mask = 0x01; mask <= 0x40; mask *= 2) {
|
|
|
switch (mask & (ptr->encodingMask)) {
|
|
|
|
|
|
- case DIEMT_SYMBOLIC_ID:
|
|
|
+ case UA_DiagnosticInfoEncodingMaskType_SymbolicId:
|
|
|
// puts("diagnosticInfo symbolic id");
|
|
|
length += sizeof(UA_Int32);
|
|
|
break;
|
|
|
- case DIEMT_NAMESPACE:
|
|
|
+ case UA_DiagnosticInfoEncodingMaskType_Namespace:
|
|
|
length += sizeof(UA_Int32);
|
|
|
break;
|
|
|
- case DIEMT_LOCALIZED_TEXT:
|
|
|
+ case UA_DiagnosticInfoEncodingMaskType_LocalizedText:
|
|
|
length += sizeof(UA_Int32);
|
|
|
break;
|
|
|
- case DIEMT_LOCALE:
|
|
|
+ case UA_DiagnosticInfoEncodingMaskType_Locale:
|
|
|
length += sizeof(UA_Int32);
|
|
|
break;
|
|
|
- case DIEMT_ADDITIONAL_INFO:
|
|
|
+ case UA_DiagnosticInfoEncodingMaskType_AdditionalInfo:
|
|
|
length += UA_String_calcSize(&(ptr->additionalInfo));
|
|
|
break;
|
|
|
- case DIEMT_INNER_STATUS_CODE:
|
|
|
+ case UA_DiagnosticInfoEncodingMaskType_InnerStatusCode:
|
|
|
length += sizeof(UA_StatusCode);
|
|
|
break;
|
|
|
- case DIEMT_INNER_DIAGNOSTIC_INFO:
|
|
|
+ case UA_DiagnosticInfoEncodingMaskType_InnerDiagnosticInfo:
|
|
|
length += UA_DiagnosticInfo_calcSize(ptr->innerDiagnosticInfo);
|
|
|
break;
|
|
|
}
|
|
@@ -726,9 +755,9 @@ Int32 UA_DiagnosticInfo_calcSize(UA_DiagnosticInfo const * ptr) {
|
|
|
return length;
|
|
|
}
|
|
|
UA_TYPE_METHOD_DELETE_STRUCT(UA_DiagnosticInfo)
|
|
|
-Int32 UA_DiagnosticInfo_deleteMembers(UA_DiagnosticInfo *p) {
|
|
|
- Int32 retval = UA_SUCCESS;
|
|
|
- if (p->encodingMask & DIEMT_INNER_DIAGNOSTIC_INFO) {
|
|
|
+UA_Int32 UA_DiagnosticInfo_deleteMembers(UA_DiagnosticInfo *p) {
|
|
|
+ UA_Int32 retval = UA_SUCCESS;
|
|
|
+ if (p->encodingMask & UA_DiagnosticInfoEncodingMaskType_InnerDiagnosticInfo) {
|
|
|
retval |= UA_DiagnosticInfo_deleteMembers(p->innerDiagnosticInfo);
|
|
|
retval |= UA_free(p->innerDiagnosticInfo);
|
|
|
}
|
|
@@ -761,24 +790,24 @@ UA_TYPE_METHOD_DECODE_AS(UA_StatusCode, UA_UInt32)
|
|
|
UA_TYPE_METHOD_DELETE_AS(UA_StatusCode, UA_UInt32)
|
|
|
UA_TYPE_METHOD_DELETEMEMBERS_AS(UA_StatusCode, UA_UInt32)
|
|
|
|
|
|
-Int32 UA_QualifiedName_calcSize(UA_QualifiedName const * p) {
|
|
|
- Int32 length = 0;
|
|
|
+UA_Int32 UA_QualifiedName_calcSize(UA_QualifiedName const * p) {
|
|
|
+ UA_Int32 length = 0;
|
|
|
length += sizeof(UInt16); //qualifiedName->namespaceIndex
|
|
|
length += sizeof(UInt16); //qualifiedName->reserved
|
|
|
length += UA_String_calcSize(&(p->name)); //qualifiedName->name
|
|
|
return length;
|
|
|
}
|
|
|
-Int32 UA_QualifiedName_decode(char const * src, Int32 *pos,
|
|
|
+UA_Int32 UA_QualifiedName_decode(char const * src, UA_Int32 *pos,
|
|
|
UA_QualifiedName *dst) {
|
|
|
- Int32 retval = UA_SUCCESS;
|
|
|
+ UA_Int32 retval = UA_SUCCESS;
|
|
|
retval |= UA_UInt16_decode(src,pos,&(dst->namespaceIndex));
|
|
|
retval |= UA_UInt16_decode(src,pos,&(dst->reserved));
|
|
|
retval |= UA_String_decode(src,pos,&(dst->name));
|
|
|
return retval;
|
|
|
}
|
|
|
-Int32 UA_QualifiedName_encode(UA_QualifiedName const *src, Int32* pos,
|
|
|
+UA_Int32 UA_QualifiedName_encode(UA_QualifiedName const *src, UA_Int32* pos,
|
|
|
char *dst) {
|
|
|
- Int32 retval = UA_SUCCESS;
|
|
|
+ UA_Int32 retval = UA_SUCCESS;
|
|
|
retval |= UA_UInt16_encode(&(src->namespaceIndex),pos,dst);
|
|
|
retval |= UA_UInt16_encode(&(src->reserved),pos,dst);
|
|
|
retval |= UA_String_encode(&(src->name),pos,dst);
|
|
@@ -786,9 +815,9 @@ Int32 UA_QualifiedName_encode(UA_QualifiedName const *src, Int32* pos,
|
|
|
}
|
|
|
|
|
|
|
|
|
-Int32 UA_Variant_calcSize(UA_Variant const * p) {
|
|
|
- Int32 length = 0;
|
|
|
- Int32 ns0Id = p->encodingMask & 0x1F; // Bits 1-5
|
|
|
+UA_Int32 UA_Variant_calcSize(UA_Variant const * p) {
|
|
|
+ UA_Int32 length = 0;
|
|
|
+ UA_Int32 ns0Id = p->encodingMask & 0x1F; // Bits 1-5
|
|
|
Boolean isArray = p->encodingMask & (0x01 << 7); // Bit 7
|
|
|
Boolean hasDimensions = p->encodingMask & (0x01 << 6); // Bit 6
|
|
|
int i;
|
|
@@ -798,7 +827,7 @@ Int32 UA_Variant_calcSize(UA_Variant const * p) {
|
|
|
}
|
|
|
length += sizeof(Byte); //p->encodingMask
|
|
|
if (isArray) { // array length is encoded
|
|
|
- length += sizeof(Int32); //p->arrayLength
|
|
|
+ length += sizeof(UA_Int32); //p->arrayLength
|
|
|
if (p->arrayLength > 0) {
|
|
|
// TODO: add suggestions of @jfpr to not iterate over arrays with fixed len elements
|
|
|
for (i=0;i<p->arrayLength;i++) {
|
|
@@ -813,8 +842,8 @@ Int32 UA_Variant_calcSize(UA_Variant const * p) {
|
|
|
}
|
|
|
return length;
|
|
|
}
|
|
|
-Int32 UA_Variant_encode(UA_Variant const *src, Int32* pos, char *dst) {
|
|
|
- Int32 retval = UA_SUCCESS;
|
|
|
+UA_Int32 UA_Variant_encode(UA_Variant const *src, UA_Int32* pos, char *dst) {
|
|
|
+ UA_Int32 retval = UA_SUCCESS;
|
|
|
int i;
|
|
|
|
|
|
if (src->vt == UA_NULL || src->encodingMask != src->vt->Id) {
|
|
@@ -839,9 +868,9 @@ Int32 UA_Variant_encode(UA_Variant const *src, Int32* pos, char *dst) {
|
|
|
return retval;
|
|
|
}
|
|
|
|
|
|
-Int32 UA_Variant_decode(char const * src, Int32 *pos, UA_Variant *dst) {
|
|
|
- Int32 retval = UA_SUCCESS;
|
|
|
- Int32 ns0Id;
|
|
|
+UA_Int32 UA_Variant_decode(char const * src, UA_Int32 *pos, UA_Variant *dst) {
|
|
|
+ UA_Int32 retval = UA_SUCCESS;
|
|
|
+ UA_Int32 ns0Id;
|
|
|
int i;
|
|
|
|
|
|
retval |= UA_Byte_decode(src,pos,&(dst->encodingMask));
|
|
@@ -881,8 +910,8 @@ Int32 UA_Variant_decode(char const * src, Int32 *pos, UA_Variant *dst) {
|
|
|
|
|
|
//TODO: place this define at the server configuration
|
|
|
#define MAX_PICO_SECONDS 1000
|
|
|
-Int32 UA_DataValue_decode(char const * src, Int32* pos, UA_DataValue* dst) {
|
|
|
- Int32 retval = UA_SUCCESS;
|
|
|
+UA_Int32 UA_DataValue_decode(char const * src, UA_Int32* pos, UA_DataValue* dst) {
|
|
|
+ UA_Int32 retval = UA_SUCCESS;
|
|
|
retval |= UA_Byte_decode(src,pos,&(dst->encodingMask));
|
|
|
if (dst->encodingMask & 0x01) {
|
|
|
retval |= UA_Variant_decode(src,pos,&(dst->value));
|
|
@@ -910,8 +939,8 @@ Int32 UA_DataValue_decode(char const * src, Int32* pos, UA_DataValue* dst) {
|
|
|
}
|
|
|
return retval;
|
|
|
}
|
|
|
-Int32 UA_DataValue_encode(UA_DataValue const * src, Int32* pos, char *dst) {
|
|
|
- Int32 retval = UA_SUCCESS;
|
|
|
+UA_Int32 UA_DataValue_encode(UA_DataValue const * src, UA_Int32* pos, char *dst) {
|
|
|
+ UA_Int32 retval = UA_SUCCESS;
|
|
|
retval |= UA_Byte_encode(&(src->encodingMask),pos,dst);
|
|
|
if (src->encodingMask & 0x01) {
|
|
|
retval |= UA_Variant_encode(&(src->value),pos,dst);
|
|
@@ -934,8 +963,8 @@ Int32 UA_DataValue_encode(UA_DataValue const * src, Int32* pos, char *dst) {
|
|
|
return retval;
|
|
|
}
|
|
|
|
|
|
-Int32 UA_DataValue_calcSize(UA_DataValue const * p) {
|
|
|
- Int32 length = 0;
|
|
|
+UA_Int32 UA_DataValue_calcSize(UA_DataValue const * p) {
|
|
|
+ UA_Int32 length = 0;
|
|
|
|
|
|
if (p == UA_NULL) { // get static storage size
|
|
|
length = sizeof(UA_DataValue);
|
|
@@ -963,112 +992,3 @@ Int32 UA_DataValue_calcSize(UA_DataValue const * p) {
|
|
|
return length;
|
|
|
}
|
|
|
|
|
|
-/**
|
|
|
- * RequestHeader
|
|
|
- * Part: 4
|
|
|
- * Chapter: 7.26
|
|
|
- * Page: 132
|
|
|
- */
|
|
|
-/** \copydoc decodeRequestHeader */
|
|
|
-/*** Sten: removed to compile
|
|
|
-Int32 decodeRequestHeader(const AD_RawMessage *srcRaw, Int32 *pos,
|
|
|
- UA_AD_RequestHeader *dstRequestHeader) {
|
|
|
- return decoder_decodeRequestHeader(srcRaw->message, pos, dstRequestHeader);
|
|
|
-}
|
|
|
-***/
|
|
|
-
|
|
|
-/*** Sten: removed to compile
|
|
|
-Int32 decoder_decodeRequestHeader(char const * message, Int32 *pos,
|
|
|
- UA_AD_RequestHeader *dstRequestHeader) {
|
|
|
- // 62541-4 §5.5.2.2 OpenSecureChannelServiceParameters
|
|
|
- // requestHeader - common request parameters. The authenticationToken is always omitted
|
|
|
- decoder_decodeBuiltInDatatype(message, NODE_ID, pos,
|
|
|
- &(dstRequestHeader->authenticationToken));
|
|
|
- decoder_decodeBuiltInDatatype(message, DATE_TIME, pos,
|
|
|
- &(dstRequestHeader->timestamp));
|
|
|
- decoder_decodeBuiltInDatatype(message, UINT32, pos,
|
|
|
- &(dstRequestHeader->requestHandle));
|
|
|
- decoder_decodeBuiltInDatatype(message, UINT32, pos,
|
|
|
- &(dstRequestHeader->returnDiagnostics));
|
|
|
- decoder_decodeBuiltInDatatype(message, STRING, pos,
|
|
|
- &(dstRequestHeader->auditEntryId));
|
|
|
- decoder_decodeBuiltInDatatype(message, UINT32, pos,
|
|
|
- &(dstRequestHeader->timeoutHint));
|
|
|
- decoder_decodeBuiltInDatatype(message, EXTENSION_OBJECT, pos,
|
|
|
- &(dstRequestHeader->additionalHeader));
|
|
|
- // AdditionalHeader will stay empty, need to be changed if there is relevant information
|
|
|
-
|
|
|
- return 0;
|
|
|
-}
|
|
|
-***/
|
|
|
-
|
|
|
-/**
|
|
|
- * ResponseHeader
|
|
|
- * Part: 4
|
|
|
- * Chapter: 7.27
|
|
|
- * Page: 133
|
|
|
- */
|
|
|
-/** \copydoc encodeResponseHeader */
|
|
|
-/*** Sten: removed to compile
|
|
|
-Int32 encodeResponseHeader(UA_AD_ResponseHeader const * responseHeader,
|
|
|
- Int32 *pos, UA_ByteString *dstBuf) {
|
|
|
- encodeUADateTime(responseHeader->timestamp, pos, dstBuf->data);
|
|
|
- encodeIntegerId(responseHeader->requestHandle, pos, dstBuf->data);
|
|
|
- encodeUInt32(responseHeader->serviceResult, pos, dstBuf->data);
|
|
|
- encodeDiagnosticInfo(responseHeader->serviceDiagnostics, pos, dstBuf->data);
|
|
|
-
|
|
|
- encoder_encodeBuiltInDatatypeArray(responseHeader->stringTable,
|
|
|
- responseHeader->noOfStringTable, STRING_ARRAY, pos, dstBuf->data);
|
|
|
-
|
|
|
- encodeExtensionObject(responseHeader->additionalHeader, pos, dstBuf->data);
|
|
|
-
|
|
|
- //Kodieren von String Datentypen
|
|
|
-
|
|
|
- return 0;
|
|
|
-}
|
|
|
-***/
|
|
|
-/*** Sten: removed to compile
|
|
|
-Int32 extensionObject_calcSize(UA_ExtensionObject *extensionObject) {
|
|
|
- Int32 length = 0;
|
|
|
-
|
|
|
- length += nodeId_calcSize(&(extensionObject->typeId));
|
|
|
- length += sizeof(Byte); //The EncodingMask Byte
|
|
|
-
|
|
|
- if (extensionObject->encoding == BODY_IS_BYTE_STRING
|
|
|
- || extensionObject->encoding == BODY_IS_XML_ELEMENT) {
|
|
|
- length += UAByteString_calcSize(&(extensionObject->body));
|
|
|
- }
|
|
|
- return length;
|
|
|
-}
|
|
|
-***/
|
|
|
-
|
|
|
-/*** Sten: removed to compile
|
|
|
-Int32 responseHeader_calcSize(UA_AD_ResponseHeader *responseHeader) {
|
|
|
- Int32 i;
|
|
|
- Int32 length = 0;
|
|
|
-
|
|
|
- // UtcTime timestamp 8
|
|
|
- length += sizeof(UA_DateTime);
|
|
|
-
|
|
|
- // IntegerId requestHandle 4
|
|
|
- length += sizeof(UA_AD_IntegerId);
|
|
|
-
|
|
|
- // StatusCode serviceResult 4
|
|
|
- length += sizeof(UA_StatusCode);
|
|
|
-
|
|
|
- // DiagnosticInfo serviceDiagnostics
|
|
|
- length += diagnosticInfo_calcSize(responseHeader->serviceDiagnostics);
|
|
|
-
|
|
|
- // String stringTable[], see 62541-6 § 5.2.4
|
|
|
- length += sizeof(Int32); // Length of Stringtable always
|
|
|
- if (responseHeader->noOfStringTable > 0) {
|
|
|
- for (i = 0; i < responseHeader->noOfStringTable; i++) {
|
|
|
- length += UAString_calcSize(responseHeader->stringTable[i]);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // ExtensibleObject additionalHeader
|
|
|
- length += extensionObject_calcSize(responseHeader->additionalHeader);
|
|
|
- return length;
|
|
|
-}
|
|
|
-***/
|