Forráskód Böngészése

added dynamically linked examples to the standard build, fixed the unexposed structs/functions, relates to #234

Stasik0 10 éve
szülő
commit
ab4e2d882b

+ 4 - 0
CMakeLists.txt

@@ -204,6 +204,8 @@ if(BUILD_EXAMPLESERVER)
     endif()
     add_executable(exampleServer examples/server.c ${server_source})
     add_executable(exampleServer_simple examples/server_simple.c ${server_source})
+    add_executable(exampleServer_so examples/server.c)
+	target_link_libraries(exampleServer_so open62541)
     if(WIN32)
         target_link_libraries(exampleServer ws2_32)
         target_link_libraries(exampleServer_simple ws2_32)
@@ -238,6 +240,8 @@ if(BUILD_EXAMPLECLIENT)
         list(APPEND client_source examples/networklayer_tcp.c examples/logger_stdout.c)
     endif()
 	add_executable(exampleClient examples/client.c ${client_source})
+	add_executable(exampleClient_so examples/client.c)
+	target_link_libraries(exampleClient_so open62541)
     if(WIN32)
         target_link_libraries(exampleClient ws2_32)
     else()

+ 2 - 2
examples/logger_stdout.h

@@ -14,6 +14,6 @@
 #endif
 
 /** Initialises the logger for the current thread. */
-UA_Logger Logger_Stdout_new(void);
+UA_EXPORT UA_Logger Logger_Stdout_new(void);
 
-#endif /* LOGGER_STDOUT_H_ */
+#endif /* LOGGER_STDOUT_H_ */

+ 2 - 2
examples/networklayer_tcp.h

@@ -18,8 +18,8 @@ extern "C" {
 #endif
 
 /** @brief Create the TCP networklayer and listen to the specified port */
-UA_ServerNetworkLayer ServerNetworkLayerTCP_new(UA_ConnectionConfig conf, UA_UInt32 port);
-UA_Connection ClientNetworkLayerTCP_connect(char *endpointUrl, UA_Logger *logger);
+UA_EXPORT UA_ServerNetworkLayer ServerNetworkLayerTCP_new(UA_ConnectionConfig conf, UA_UInt32 port);
+UA_EXPORT UA_Connection ClientNetworkLayerTCP_connect(char *endpointUrl, UA_Logger *logger);
 
 #ifdef __cplusplus
 } // extern "C"

+ 1 - 1
include/ua_client.h

@@ -28,7 +28,7 @@ typedef struct UA_ClientConfig {
 extern const UA_ClientConfig UA_ClientConfig_standard;
 UA_Client UA_EXPORT * UA_Client_new(UA_ClientConfig config, UA_Logger logger);
 
-void UA_Client_delete(UA_Client* client);
+UA_EXPORT void UA_Client_delete(UA_Client* client);
 
 UA_StatusCode UA_EXPORT UA_Client_connect(UA_Client *client, UA_ConnectClientConnection connFunc, char *endpointUrl);
 UA_StatusCode UA_EXPORT UA_Client_disconnect(UA_Client *client);

+ 1 - 1
src/client/ua_client.c

@@ -31,7 +31,7 @@ struct UA_Client {
     UA_ClientConfig config;
 };
 
-const UA_ClientConfig UA_ClientConfig_standard =
+UA_EXPORT const UA_ClientConfig UA_ClientConfig_standard =
     { 5 /* ms receive timout */, {.protocolVersion = 0, .sendBufferSize = 65536, .recvBufferSize  = 65536,
                                   .maxMessageSize = 65536, .maxChunkCount = 1}};
 

+ 4 - 7
src/server/ua_server.c

@@ -7,7 +7,7 @@
 #include "ua_nodeids.h"
 
 
-const UA_ServerConfig UA_ServerConfig_standard = {
+UA_EXPORT const UA_ServerConfig UA_ServerConfig_standard = {
         UA_TRUE,
         UA_TRUE,
         (char *[]){"user1","user2"},
@@ -850,17 +850,14 @@ UA_Server * UA_Server_new(UA_ServerConfig config) {
    UA_VariableNode *maxBrowseContinuationPoints = UA_VariableNode_new();
    copyNames((UA_Node*)maxBrowseContinuationPoints, "MaxBrowseContinuationPoints");
    maxBrowseContinuationPoints->nodeId.identifier.numeric = UA_NS0ID_SERVER_SERVERCAPABILITIES_MAXBROWSECONTINUATIONPOINTS;
-   UA_UInt16 *maxBrowseContinuationPointsValue = UA_UInt16_new();
-   *maxBrowseContinuationPointsValue = 0;
-   maxBrowseContinuationPoints->value.variant.data = maxBrowseContinuationPointsValue;
-   maxBrowseContinuationPoints->value.variant.arrayLength = -1;
+   maxBrowseContinuationPoints->value.variant.data = UA_UInt16_new();
+   *((UA_UInt16*)maxBrowseContinuationPoints->value.variant.data) = 1;
    maxBrowseContinuationPoints->value.variant.type = &UA_TYPES[UA_TYPES_UINT16];
    UA_Server_addNode(server, (UA_Node*)maxBrowseContinuationPoints,
        &UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_SERVER_SERVERCAPABILITIES),
        &UA_NODEID_NUMERIC(0, UA_NS0ID_HASPROPERTY));
    ADDREFERENCE(UA_NODEID_NUMERIC(0, UA_NS0ID_SERVER_SERVERCAPABILITIES_MAXBROWSECONTINUATIONPOINTS),
-       UA_NODEID_NUMERIC(0, UA_NS0ID_HASTYPEDEFINITION),
-       UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_PROPERTYTYPE));
+       UA_NODEID_NUMERIC(0, UA_NS0ID_HASTYPEDEFINITION), UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_PROPERTYTYPE));
 
    UA_ObjectNode *serverdiagnostics = UA_ObjectNode_new();
    copyNames((UA_Node*)serverdiagnostics, "ServerDiagnostics");