Browse Source

Merge branch 'master' into statuscode

Conflicts:
	src/ua_connection.c
	src/ua_types.c
Julius Pfrommer 10 years ago
parent
commit
5edfcba3f6
5 changed files with 20 additions and 18 deletions
  1. 7 3
      CMakeLists.txt
  2. 7 12
      examples/opcuaClient.c
  3. 1 2
      src/ua_securechannel.c
  4. 4 0
      src/ua_types.c
  5. 1 1
      src/ua_util.h

+ 7 - 3
CMakeLists.txt

@@ -6,7 +6,7 @@ set(open62541_VERSION_MAJOR 0)
 set(open62541_VERSION_MINOR 1)
 
 set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
-set(CMAKE_C_FLAGS_DEBUG "-g -DDEBUG")
+set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG")
 
 # main sources of libopen62541
 include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include")
@@ -39,14 +39,14 @@ set(lib_sources src/ua_types.c
 
 # compiler flags
 if(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
-add_definitions(-std=c99 -pedantic -pipe -fvisibility=hidden -fPIC -Wall -Wextra -Werror -Wformat
+add_definitions(-std=c99 -pedantic -pipe -Wall -Wextra -Werror -Wformat
                 -Wno-unused-parameter -Wno-unused-function -Wno-unused-label -Wpointer-arith -Wreturn-type -Wsign-compare -Wmultichar
                 -Winit-self -Wuninitialized -Wno-deprecated -Wformat-security -ffunction-sections -fdata-sections)
     if(NOT "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
         add_definitions(-Wformat-nonliteral -Wl,--gc-sections)
     endif()
 	if(NOT WIN32)
-	    add_definitions(-fstack-protector)
+	    add_definitions(-fstack-protector -fPIC -fvisibility=hidden)
 	endif()
 endif()
 add_definitions(-Dopen62541_EXPORTS) # dllexport/dllimport differentiation in ua_config.h when building the lib on windows
@@ -161,6 +161,8 @@ if(CLIENT)
 endif()
 
 # build example server
+option(EXAMPLESERVER "Build a test server" OFF)
+if(EXAMPLESERVER)
 set(server_sources examples/opcuaServer.c
                    examples/logger_stdout.c)
 if(NOT ENABLE_MULTITHREADING)
@@ -177,6 +179,8 @@ if(ENABLE_MULTITHREADING)
     find_package(LibUV REQUIRED)
     target_link_libraries(exampleServer urcu-cds urcu uv)
 endif()
+endif()
+
 
 # build unit tests
 option(ENABLE_UNIT_TESTS "Run unit tests after building" OFF)

+ 7 - 12
examples/opcuaClient.c

@@ -356,12 +356,6 @@ int main(int argc, char *argv[]) {
 	{
 		alwaysSameNode = UA_FALSE;
 	}
-	/*UA_Int32 pid;
-	if((pid = fork()) < 0) {
-	    printf("no fork possible");
-	    return 0;
-	}
-	else*/{
 
 
 	//Create socket
@@ -408,10 +402,11 @@ int main(int argc, char *argv[]) {
 	UA_NodeId messageType;
 	recvOffset = 24;
 	UA_NodeId_decodeBinary(reply,&recvOffset,&messageType);
-	UA_CreateSessionResponse createSessionResponse;
-	UA_CreateSessionResponse_decodeBinary(reply,&recvOffset,&createSessionResponse);
+	UA_CreateSessionResponse *createSessionResponse;
+	createSessionResponse = (UA_CreateSessionResponse*)&(reply->data[recvOffset]);
+	//UA_CreateSessionResponse_decodeBinary(reply,&recvOffset,&createSessionResponse);
 
-	sendActivateSession(sock, secureChannelId, openSecChannelRsp.securityToken.tokenId, 53, 3,createSessionResponse.authenticationToken);
+	sendActivateSession(sock, secureChannelId, openSecChannelRsp.securityToken.tokenId, 53, 3,createSessionResponse->authenticationToken);
 	received = recv(sock, reply->data, reply->length, 0);
 
     UA_NodeId *nodesToRead;
@@ -440,12 +435,12 @@ int main(int argc, char *argv[]) {
 
 	for (UA_UInt32 i = 0; i < tries; i++) {
 
-		tic = sendReadRequest(sock, secureChannelId, openSecChannelRsp.securityToken.tokenId, 54+i, 4+i,createSessionResponse.authenticationToken,nodesToReadSize,nodesToRead);
+		tic = sendReadRequest(sock, secureChannelId, openSecChannelRsp.securityToken.tokenId, 54+i, 4+i,createSessionResponse->authenticationToken,nodesToReadSize,nodesToRead);
 
 		received = recv(sock, reply->data, 2000, 0);
 		toc = UA_DateTime_now() - tic;
 
-		timeDiffs[i] = (UA_Double)toc/(UA_Double)10e3;
+		timeDiffs[i] = (UA_Double)toc/(UA_Double)1e4;
 		sum = sum + timeDiffs[i];
 		//printf("read request took: %16.10f ms \n",timeDiffs[i]);
 	}
@@ -478,6 +473,6 @@ int main(int argc, char *argv[]) {
 	UA_Array_delete(nodesToRead,nodesToReadSize,&UA_[UA_NODEID]);
 	close(sock);
 	return 0;
-	}
+
 
 }

+ 1 - 2
src/ua_securechannel.c

@@ -27,8 +27,7 @@ void UA_SecureChannel_delete(UA_SecureChannel *channel) {
 }
 
 UA_Boolean UA_SecureChannel_compare(UA_SecureChannel *sc1, UA_SecureChannel *sc2) {
-    return (sc1->securityToken.channelId == sc2->securityToken.channelId) ?
-           UA_TRUE : UA_FALSE;
+    return (sc1->securityToken.channelId == sc2->securityToken.channelId);
 }
 
 //TODO implement real nonce generator - DUMMY function

+ 4 - 0
src/ua_types.c

@@ -175,11 +175,15 @@ UA_StatusCode UA_String_copyprintf(char const *fmt, UA_String *dst, ...) {
     char src[UA_STRING_COPYPRINTF_BUFSIZE];
     va_list ap;
     va_start(ap, dst);
+#ifndef __MINGW32__
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wformat-nonliteral"
+#endif
     // vsnprintf should only take a literal and no variable to be secure
     UA_Int32 len = vsnprintf(src, UA_STRING_COPYPRINTF_BUFSIZE, fmt, ap);
+#ifndef __MINGW32__
 #pragma GCC diagnostic pop
+#endif
     va_end(ap);
     if(len < 0)  // FIXME: old glibc 2.0 would return -1 when truncated
         return UA_STATUSCODE_BADINTERNALERROR;

+ 1 - 1
src/ua_util.h

@@ -9,7 +9,7 @@
 #include "ua_config.h"
 
 #include <stddef.h> /* Needed for sys/queue.h */
-#ifndef MSVC
+#if !defined(MSVC) && !defined(__MINGW32__)
 #include <sys/queue.h>
 #else
 #include "queue.h"