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

make UA_readNumber an internal function

Julius Pfrommer 8 éve
szülő
commit
c256b78abc
4 módosított fájl, 13 hozzáadás és 10 törlés
  1. 0 6
      include/ua_connection.h
  2. 3 3
      src/ua_connection.c
  3. 9 1
      src/ua_util.h
  4. 1 0
      tests/check_utils.c

+ 0 - 6
include/ua_connection.h

@@ -125,12 +125,6 @@ UA_StatusCode UA_EXPORT
 UA_EndpointUrl_split(const char *endpointUrl, char *hostname,
                      UA_UInt16 * port, const char ** path);
 
-/* Convert given byte string to a positive number. Returns the number of valid
- * digits. Stops if a non-digit char is found and returns the number of digits
- * up to that point. */
-size_t UA_EXPORT
-UA_readNumber(UA_Byte *buf, size_t buflen, UA_UInt32 *number);
-
 #ifdef __cplusplus
 } // extern "C"
 #endif

+ 3 - 3
src/ua_connection.c

@@ -313,14 +313,14 @@ UA_EndpointUrl_split(const char *endpointUrl, char *hostname,
 }
 
 size_t UA_readNumber(UA_Byte *buf, size_t buflen, UA_UInt32 *number) {
-    if (!buf)
-        return 0;
+    UA_assert(buf);
+    UA_assert(number);
     UA_UInt32 n = 0;
     size_t progress = 0;
     /* read numbers until the end or a non-number character appears */
     while(progress < buflen) {
         UA_Byte c = buf[progress];
-        if('0' > c || '9' < c)
+        if(c < '0' || c > '9')
             break;
         n = (n*10) + (UA_UInt32)(c-'0');
         ++progress;

+ 9 - 1
src/ua_util.h

@@ -5,7 +5,7 @@
 #ifndef UA_UTIL_H_
 #define UA_UTIL_H_
 
-#include "ua_config.h"
+#include "ua_types.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -106,6 +106,14 @@ UA_atomic_add(volatile uint32_t *addr, uint32_t increase) {
 #endif
 }
 
+/* Utility Functions
+ * ----------------- */
+
+/* Convert given byte string to a positive number. Returns the number of valid
+ * digits. Stops if a non-digit char is found and returns the number of digits
+ * up to that point. */
+size_t UA_readNumber(UA_Byte *buf, size_t buflen, UA_UInt32 *number);
+
 #ifdef __cplusplus
 } // extern "C"
 #endif

+ 1 - 0
tests/check_utils.c

@@ -6,6 +6,7 @@
 
 #include "ua_types.h"
 #include "ua_client.h"
+#include "ua_util.h"
 #include "check.h"
 
 START_TEST(EndpointUrl_split) {