Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongoose
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
esp
mongoose
Commits
e95c0749
Commit
e95c0749
authored
9 years ago
by
Alexander Alashkin
Committed by
Marko Mikulicic
9 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace strnlen with c_strnlen
PUBLISHED_FROM=815cfaea77171761c952966e98466b87b719de06
parent
4ca73566
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
5 additions
and
15 deletions
+5
-15
Makefile
examples/api_server/Makefile
+1
-1
examples.mk
examples/examples.mk
+1
-1
mongoose.c
mongoose.c
+2
-4
mongoose.h
mongoose.h
+1
-9
No files found.
examples/api_server/Makefile
View file @
e95c0749
...
@@ -4,7 +4,7 @@ CFLAGS = -W -Wall $(CFLAGS_EXTRA)
...
@@ -4,7 +4,7 @@ CFLAGS = -W -Wall $(CFLAGS_EXTRA)
ifeq
($(OS),
Windows_NT)
ifeq
($(OS),
Windows_NT)
CFLAGS
+=
-lws2_32
-D_MG_PROVIDE_STRNLEN
CFLAGS
+=
-lws2_32
CC
=
gcc
CC
=
gcc
else
else
UNAME_S
:=
$(
shell
uname
-s
)
UNAME_S
:=
$(
shell
uname
-s
)
...
...
This diff is collapsed.
Click to expand it.
examples/examples.mk
View file @
e95c0749
...
@@ -5,7 +5,7 @@ all: $(PROG)
...
@@ -5,7 +5,7 @@ all: $(PROG)
ifeq ($(OS), Windows_NT)
ifeq ($(OS), Windows_NT)
# TODO(alashkin): enable SSL in Windows
# TODO(alashkin): enable SSL in Windows
CFLAGS += -lws2_32
-D_MG_PROVIDE_STRNLEN
CFLAGS += -lws2_32
CC = gcc
CC = gcc
else
else
ifeq ($(SSL_LIB),openssl)
ifeq ($(SSL_LIB),openssl)
...
...
This diff is collapsed.
Click to expand it.
mongoose.c
View file @
e95c0749
...
@@ -1751,14 +1751,12 @@ void cs_hmac_sha1(const unsigned char *key, size_t keylen,
...
@@ -1751,14 +1751,12 @@ void cs_hmac_sha1(const unsigned char *key, size_t keylen,
/* Amalgamated: #include "common/platform.h" */
/* Amalgamated: #include "common/platform.h" */
/* Amalgamated: #include "common/str_util.h" */
/* Amalgamated: #include "common/str_util.h" */
#ifdef _MG_PROVIDE_STRNLEN
size_t
c_strnlen
(
const
char
*
s
,
size_t
maxlen
)
{
size_t
strnlen
(
const
char
*
s
,
size_t
maxlen
)
{
size_t
l
=
0
;
size_t
l
=
0
;
for
(;
l
<
maxlen
&&
s
[
l
]
!=
'\0'
;
l
++
)
{
for
(;
l
<
maxlen
&&
s
[
l
]
!=
'\0'
;
l
++
)
{
}
}
return
l
;
return
l
;
}
}
#endif
#define C_SNPRINTF_APPEND_CHAR(ch) \
#define C_SNPRINTF_APPEND_CHAR(ch) \
do { \
do { \
...
@@ -1887,7 +1885,7 @@ int c_vsnprintf(char *buf, size_t buf_size, const char *fmt, va_list ap) {
...
@@ -1887,7 +1885,7 @@ int c_vsnprintf(char *buf, size_t buf_size, const char *fmt, va_list ap) {
if
(
ch
==
's'
)
{
if
(
ch
==
's'
)
{
const
char
*
s
=
va_arg
(
ap
,
const
char
*
);
/* Always fetch parameter */
const
char
*
s
=
va_arg
(
ap
,
const
char
*
);
/* Always fetch parameter */
int
j
;
int
j
;
int
pad
=
field_width
-
(
precision
>=
0
?
strnlen
(
s
,
precision
)
:
0
);
int
pad
=
field_width
-
(
precision
>=
0
?
c_
strnlen
(
s
,
precision
)
:
0
);
for
(
j
=
0
;
j
<
pad
;
j
++
)
{
for
(
j
=
0
;
j
<
pad
;
j
++
)
{
C_SNPRINTF_APPEND_CHAR
(
' '
);
C_SNPRINTF_APPEND_CHAR
(
' '
);
}
}
...
...
This diff is collapsed.
Click to expand it.
mongoose.h
View file @
e95c0749
...
@@ -857,6 +857,7 @@ int cs_base64_decode(const unsigned char *s, int len, char *dst);
...
@@ -857,6 +857,7 @@ int cs_base64_decode(const unsigned char *s, int len, char *dst);
extern
"C"
{
extern
"C"
{
#endif
#endif
size_t
c_strnlen
(
const
char
*
s
,
size_t
maxlen
);
int
c_snprintf
(
char
*
buf
,
size_t
buf_size
,
const
char
*
format
,
...);
int
c_snprintf
(
char
*
buf
,
size_t
buf_size
,
const
char
*
format
,
...);
int
c_vsnprintf
(
char
*
buf
,
size_t
buf_size
,
const
char
*
format
,
va_list
ap
);
int
c_vsnprintf
(
char
*
buf
,
size_t
buf_size
,
const
char
*
format
,
va_list
ap
);
/*
/*
...
@@ -865,15 +866,6 @@ int c_vsnprintf(char *buf, size_t buf_size, const char *format, va_list ap);
...
@@ -865,15 +866,6 @@ int c_vsnprintf(char *buf, size_t buf_size, const char *format, va_list ap);
*/
*/
const
char
*
c_strnstr
(
const
char
*
s
,
const
char
*
find
,
size_t
slen
);
const
char
*
c_strnstr
(
const
char
*
s
,
const
char
*
find
,
size_t
slen
);
#if (!(defined(_XOPEN_SOURCE) && _XOPEN_SOURCE >= 700) && \
!(defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200809L) && \
!(defined(__DARWIN_C_LEVEL) && __DARWIN_C_LEVEL >= 200809L) && \
!defined(RTOS_SDK)) && \
!(defined(_MSC_VER) && _MSC_VER >= 1600
/* MSVC2010+ has strnlen */
)
#define _MG_PROVIDE_STRNLEN
size_t
strnlen
(
const
char
*
s
,
size_t
maxlen
);
#endif
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
This diff is collapsed.
Click to expand it.
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