mirror of
https://github.com/open62541/open62541.git
synced 2026-10-26 10:48:32 +08:00
make UA_readNumber an internal function
This commit is contained in:
@@ -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
@@ -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
@@ -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
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include "ua_types.h"
|
||||
#include "ua_client.h"
|
||||
#include "ua_util.h"
|
||||
#include "check.h"
|
||||
|
||||
START_TEST(EndpointUrl_split) {
|
||||
|
||||
Reference in New Issue
Block a user