Browse Source

cosmetic: cleanup examples

Julius Pfrommer 7 years ago
parent
commit
714f75aaa6
2 changed files with 7 additions and 27 deletions
  1. 6 7
      examples/client.c
  2. 1 20
      examples/server.c

+ 6 - 7
examples/client.c

@@ -16,22 +16,21 @@
 
 #include <stdio.h>
 
-static void handler_TheAnswerChanged(UA_UInt32 monId, UA_DataValue *value, void *context) {
+static void
+handler_TheAnswerChanged(UA_UInt32 monId, UA_DataValue *value, void *context) {
     printf("The Answer has changed!\n");
-    return;
 }
 
 static UA_StatusCode
 nodeIter(UA_NodeId childId, UA_Boolean isInverse, UA_NodeId referenceTypeId, void *handle) {
-  UA_NodeId *parent = (UA_NodeId *) handle;
-
-  if(!isInverse) {
+    if(isInverse)
+        return UA_STATUSCODE_GOOD;
+    UA_NodeId *parent = (UA_NodeId *)handle;
     printf("%d, %d --- %d ---> NodeId %d, %d\n",
            parent->namespaceIndex, parent->identifier.numeric,
            referenceTypeId.identifier.numeric, childId.namespaceIndex,
            childId.identifier.numeric);
-  }
-  return UA_STATUSCODE_GOOD;
+    return UA_STATUSCODE_GOOD;
 }
 
 int main(int argc, char *argv[]) {

+ 1 - 20
examples/server.c

@@ -1,10 +1,6 @@
 /* This work is licensed under a Creative Commons CCZero 1.0 Universal License.
  * See http://creativecommons.org/publicdomain/zero/1.0/ for more information. */
 
-/* Compile with single file release:
- * - single-threaded: gcc -std=c99 server.c open62541.c -o server
- * - multi-threaded: gcc -std=c99 server.c open62541.c -o server -lurcu-cds -lurcu -lurcu-common -lpthread */
-
 #ifdef _MSC_VER
 #define _CRT_SECURE_NO_WARNINGS //disable fopen deprication warning in msvs
 #endif
@@ -26,22 +22,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-#ifdef _MSC_VER
-# include <io.h> //access
-#else
-# include <unistd.h> //access
-#endif
-
-#ifdef UA_ENABLE_MULTITHREADING
-# ifdef UA_NO_AMALGAMATION
-#  ifndef __USE_XOPEN2K
-#   define __USE_XOPEN2K
-#  endif
-# endif
-#include <pthread.h>
-#endif
-
-UA_Boolean running = 1;
+UA_Boolean running = true;
 UA_Logger logger = UA_Log_Stdout;
 
 static UA_ByteString loadCertificate(void) {