Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
osie
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Martin Manchev
osie
Commits
50276413
Commit
50276413
authored
May 05, 2022
by
Ivan Tyagov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup.
parent
e05da676
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
21 deletions
+25
-21
coupler/opc-ua-server/common.h
coupler/opc-ua-server/common.h
+25
-21
No files found.
coupler/opc-ua-server/common.h
View file @
50276413
...
@@ -6,11 +6,10 @@
...
@@ -6,11 +6,10 @@
#include <stdio.h>
#include <stdio.h>
#include <open62541/server.h>
#include <open62541/server.h>
unsigned
long
int
getMilliSecondsSinceEpoch
()
{
unsigned
long
int
getMilliSecondsSinceEpoch
()
{
/*
/*
* Return milli seconds since epoch.
* Return milli seconds since epoch.
*/
*/
struct
timeval
current_time
;
struct
timeval
current_time
;
gettimeofday
(
&
current_time
,
NULL
);
gettimeofday
(
&
current_time
,
NULL
);
unsigned
long
int
ms
=
current_time
.
tv_sec
*
1000
+
current_time
.
tv_usec
/
1000
;
unsigned
long
int
ms
=
current_time
.
tv_sec
*
1000
+
current_time
.
tv_usec
/
1000
;
...
@@ -21,8 +20,7 @@ unsigned long int getMilliSecondsSinceEpoch() {
...
@@ -21,8 +20,7 @@ unsigned long int getMilliSecondsSinceEpoch() {
*
*
* @param path specifies the file name given in argv[]
* @param path specifies the file name given in argv[]
* @return Returns the file content after parsing */
* @return Returns the file content after parsing */
static
UA_INLINE
UA_ByteString
static
UA_INLINE
UA_ByteString
loadFile
(
const
char
*
const
path
)
{
loadFile
(
const
char
*
const
path
)
{
UA_ByteString
fileContents
=
UA_STRING_NULL
;
UA_ByteString
fileContents
=
UA_STRING_NULL
;
/* Open the file */
/* Open the file */
...
@@ -49,25 +47,29 @@ loadFile(const char *const path) {
...
@@ -49,25 +47,29 @@ loadFile(const char *const path) {
return
fileContents
;
return
fileContents
;
}
}
char
*
randomString
(
size_t
length
)
char
*
randomString
(
size_t
length
)
{
{
/*
static
char
charset
[]
=
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
;
* Generate a random string.
char
*
randomString
=
NULL
;
*/
if
(
length
)
{
static
char
charset
[]
=
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
;
randomString
=
malloc
(
sizeof
(
char
)
*
(
length
+
1
));
char
*
randomString
=
NULL
;
if
(
randomString
)
{
if
(
length
)
{
for
(
int
n
=
0
;
n
<
length
;
n
++
)
{
randomString
=
malloc
(
sizeof
(
char
)
*
(
length
+
1
));
if
(
randomString
)
{
for
(
int
n
=
0
;
n
<
length
;
n
++
)
{
int
key
=
rand
()
%
(
int
)(
sizeof
(
charset
)
-
1
);
int
key
=
rand
()
%
(
int
)(
sizeof
(
charset
)
-
1
);
randomString
[
n
]
=
charset
[
key
];
randomString
[
n
]
=
charset
[
key
];
}
}
randomString
[
length
]
=
'\0'
;
randomString
[
length
]
=
'\0'
;
}
}
}
return
randomString
;
}
return
randomString
;
}
}
char
*
convertInt2Str
(
int
my_int
){
char
*
convertInt2Str
(
int
my_int
){
/* Convert integer to string */
/*
* Convert integer to string.
*/
int
length
=
snprintf
(
NULL
,
0
,
"%d"
,
my_int
);
int
length
=
snprintf
(
NULL
,
0
,
"%d"
,
my_int
);
char
*
my_str
=
malloc
(
length
+
1
);
char
*
my_str
=
malloc
(
length
+
1
);
snprintf
(
my_str
,
length
+
1
,
"%d"
,
my_int
);
snprintf
(
my_str
,
length
+
1
,
"%d"
,
my_int
);
...
@@ -75,16 +77,18 @@ char *convertInt2Str(int my_int){
...
@@ -75,16 +77,18 @@ char *convertInt2Str(int my_int){
}
}
char
*
convertLongInt2Str
(
long
int
my_int
){
char
*
convertLongInt2Str
(
long
int
my_int
){
/* Convert integer to string */
/*
* Convert a long integer to string.
*/
int
length
=
snprintf
(
NULL
,
0
,
"%ld"
,
my_int
);
int
length
=
snprintf
(
NULL
,
0
,
"%ld"
,
my_int
);
char
*
my_str
=
malloc
(
length
+
1
);
char
*
my_str
=
malloc
(
length
+
1
);
snprintf
(
my_str
,
length
+
1
,
"%ld"
,
my_int
);
snprintf
(
my_str
,
length
+
1
,
"%ld"
,
my_int
);
return
my_str
;
return
my_str
;
}
}
/*
* dictionary implementation based on https://gist.github.com/kylef/86784/fe97567ec9baf5c0dce3c7fcbec948e21dfcce09
// XXX: dictionary implementation based on https://gist.github.com/kylef/86784/fe97567ec9baf5c0dce3c7fcbec948e21dfcce09
*/
typedef
struct
dict_t_struct
{
typedef
struct
dict_t_struct
{
char
*
key
;
char
*
key
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment