Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cellframe-sdk
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Code
Merge requests
15
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cellframe
cellframe-sdk
Commits
2b5aac21
Unverified
Commit
2b5aac21
authored
5 years ago
by
Dmitriy A. Gerasimov
Committed by
GitHub
5 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #52 from kelvinblockchain/feature-2302
Feature 2302
parents
b86ad74b
f628feaf
No related branches found
No related tags found
1 merge request
!24
Support 3689
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
core/dap_strfuncs.c
+51
-23
51 additions, 23 deletions
core/dap_strfuncs.c
core/dap_strfuncs.h
+5
-1
5 additions, 1 deletion
core/dap_strfuncs.h
test/core/dap_strfuncs_test.c
+2
-2
2 additions, 2 deletions
test/core/dap_strfuncs_test.c
test/crypto/main.c
+1
-1
1 addition, 1 deletion
test/crypto/main.c
with
59 additions
and
27 deletions
core/dap_strfuncs.c
+
51
−
23
View file @
2b5aac21
...
...
@@ -8,7 +8,6 @@
#include
<stdlib.h>
#include
<string.h>
#include
<ctype.h>
#include
<time.h>
#include
<errno.h>
#include
"dap_common.h"
...
...
@@ -23,7 +22,6 @@ char *strndup(char *str, int len) {
}
#endif
/**
* dap_strlen:
* @a_str: (nullable): the string
...
...
@@ -42,6 +40,36 @@ size_t dap_strlen(const char *a_str)
return
l_length
;
}
/**
* dap_strcmp:
* @a_str1: (nullable): the string
* @a_str2: (nullable): the string
*
* Compare a_str1 and a_str2
*/
int
dap_strcmp
(
const
char
*
a_str1
,
const
char
*
a_str2
)
{
if
(
a_str1
&&
a_str2
)
{
return
strcmp
(
a_str1
,
a_str2
);
}
return
-
1
;
}
/**
* dap_strcmp:
* @a_str1: (nullable): the string
* @a_str2: (nullable): the string
*
* Compare a_n characters of a_str1 and a_str2
*/
int
dap_strncmp
(
const
char
*
a_str1
,
const
char
*
a_str2
,
size_t
a_n
)
{
if
(
a_str1
&&
a_str2
)
{
return
strncmp
(
a_str1
,
a_str2
,
a_n
);
}
return
-
1
;
}
/**
* dap_strdup:
* @a_str: (nullable): the string to duplicate
...
...
@@ -115,27 +143,27 @@ char* dap_strdup_printf(const char *a_format, ...)
}
/*
// alternative version
char* dap_strdup_printf2(const char *a_format, ...)
{
size_t l_buffer_size = 0;
char *l_buffer = NULL;
va_list l_args;
va_start(l_args, a_format);
l_buffer_size += vsnprintf(l_buffer, 0, a_format, l_args);
va_end(l_args);
if(!l_buffer_size)
return NULL;
l_buffer = DAP_NEW_SIZE(char, l_buffer_size + 1);
va_start(l_args, a_format);
vsnprintf(l_buffer, l_buffer_size + 1, a_format, l_args);
va_end(l_args);
return l_buffer;
}*/
// alternative version
char* dap_strdup_printf2(const char *a_format, ...)
{
size_t l_buffer_size = 0;
char *l_buffer = NULL;
va_list l_args;
va_start(l_args, a_format);
l_buffer_size += vsnprintf(l_buffer, 0, a_format, l_args);
va_end(l_args);
if(!l_buffer_size)
return NULL;
l_buffer = DAP_NEW_SIZE(char, l_buffer_size + 1);
va_start(l_args, a_format);
vsnprintf(l_buffer, l_buffer_size + 1, a_format, l_args);
va_end(l_args);
return l_buffer;
}*/
/**
* dap_stpcpy:
...
...
This diff is collapsed.
Click to expand it.
core/dap_strfuncs.h
+
5
−
1
View file @
2b5aac21
...
...
@@ -33,6 +33,11 @@
#define clamp(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x)))
size_t
dap_strlen
(
const
char
*
a_str
);
// compare a_str1 and a_str2
int
dap_strcmp
(
const
char
*
a_str1
,
const
char
*
a_str2
);
// compare a_n characters of a_str1 and a_str2
int
dap_strncmp
(
const
char
*
a_str1
,
const
char
*
a_str2
,
size_t
a_n
);
// duplicates a string
char
*
dap_strdup
(
const
char
*
a_str
);
char
*
dap_strdup_vprintf
(
const
char
*
a_format
,
va_list
a_args
);
char
*
dap_strdup_printf
(
const
char
*
a_format
,
...);
...
...
@@ -66,4 +71,3 @@ char* dap_strreverse(char *a_string);
#define DAP_USEC_PER_SEC 1000000
void
dap_usleep
(
time_t
a_microseconds
);
This diff is collapsed.
Click to expand it.
test/core/dap_strfuncs_test.c
+
2
−
2
View file @
2b5aac21
...
...
@@ -59,14 +59,14 @@ void dap_str_array_test(void)
const
char
*
l_s_in
=
"1:23:: Test: :
\n
:String:"
;
char
**
l_s_array
=
dap_strsplit
(
l_s_in
,
":"
,
-
1
);
in
t
l_count
=
1
;
size_
t
l_count
=
1
;
char
*
l_s_tmp
=
dap_strstr_len
(
l_s_in
,
-
1
,
":"
);
while
(
l_s_tmp
)
{
l_s_tmp
=
dap_strstr_len
(
l_s_tmp
+
1
,
-
1
,
":"
);
l_count
++
;
}
char
**
l_s_array_copy
=
dap_strdupv
(
l_s_array
);
char
**
l_s_array_copy
=
dap_strdupv
(
(
const
char
**
)
l_s_array
);
dap_assert_PIF
(
dap_str_countv
(
l_s_array
)
==
l_count
,
"String split"
);
dap_assert_PIF
(
dap_str_countv
(
l_s_array_copy
)
==
l_count
,
"String copy"
);
...
...
This diff is collapsed.
Click to expand it.
test/crypto/main.c
+
1
−
1
View file @
2b5aac21
...
...
@@ -15,7 +15,7 @@
int
main
(
void
)
{
// switch off debug info from library
set
_log_level
(
L_CRITICAL
);
dap
_log_level
_set
(
L_CRITICAL
);
dap_enc_aes_tests_run
();
dap_enc_oaes_tests_run
();
dap_enc_base64_tests_run
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment