Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
mongoose
Commits
70dc6d8d
Commit
70dc6d8d
authored
Dec 29, 2019
by
Deomid Ryabkov
Committed by
Cesanta Bot
Dec 29, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add mg_strcasecmp()
CL: Add mg_strcasecmp() PUBLISHED_FROM=cd2a26fa12473bfa0f5e7a0a1d34fb86562ee082
parent
10b11b03
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
2 deletions
+25
-2
mongoose.c
mongoose.c
+19
-2
mongoose.h
mongoose.h
+6
-0
No files found.
mongoose.c
View file @
70dc6d8d
...
@@ -1764,8 +1764,10 @@ int mg_strcmp(const struct mg_str str1, const struct mg_str str2) WEAK;
...
@@ -1764,8 +1764,10 @@ int mg_strcmp(const struct mg_str str1, const struct mg_str str2) WEAK;
int
mg_strcmp
(
const
struct
mg_str
str1
,
const
struct
mg_str
str2
)
{
int
mg_strcmp
(
const
struct
mg_str
str1
,
const
struct
mg_str
str2
)
{
size_t
i
=
0
;
size_t
i
=
0
;
while
(
i
<
str1
.
len
&&
i
<
str2
.
len
)
{
while
(
i
<
str1
.
len
&&
i
<
str2
.
len
)
{
if
(
str1
.
p
[
i
]
<
str2
.
p
[
i
])
return
-
1
;
int
c1
=
str1
.
p
[
i
];
if
(
str1
.
p
[
i
]
>
str2
.
p
[
i
])
return
1
;
int
c2
=
str2
.
p
[
i
];
if
(
c1
<
c2
)
return
-
1
;
if
(
c1
>
c2
)
return
1
;
i
++
;
i
++
;
}
}
if
(
i
<
str1
.
len
)
return
1
;
if
(
i
<
str1
.
len
)
return
1
;
...
@@ -1787,6 +1789,21 @@ int mg_strncmp(const struct mg_str str1, const struct mg_str str2, size_t n) {
...
@@ -1787,6 +1789,21 @@ int mg_strncmp(const struct mg_str str1, const struct mg_str str2, size_t n) {
return
mg_strcmp
(
s1
,
s2
);
return
mg_strcmp
(
s1
,
s2
);
}
}
int
mg_strcasecmp
(
const
struct
mg_str
str1
,
const
struct
mg_str
str2
)
WEAK
;
int
mg_strcasecmp
(
const
struct
mg_str
str1
,
const
struct
mg_str
str2
)
{
size_t
i
=
0
;
while
(
i
<
str1
.
len
&&
i
<
str2
.
len
)
{
int
c1
=
tolower
((
int
)
str1
.
p
[
i
]);
int
c2
=
tolower
((
int
)
str2
.
p
[
i
]);
if
(
c1
<
c2
)
return
-
1
;
if
(
c1
>
c2
)
return
1
;
i
++
;
}
if
(
i
<
str1
.
len
)
return
1
;
if
(
i
<
str2
.
len
)
return
-
1
;
return
0
;
}
void
mg_strfree
(
struct
mg_str
*
s
)
WEAK
;
void
mg_strfree
(
struct
mg_str
*
s
)
WEAK
;
void
mg_strfree
(
struct
mg_str
*
s
)
{
void
mg_strfree
(
struct
mg_str
*
s
)
{
char
*
sp
=
(
char
*
)
s
->
p
;
char
*
sp
=
(
char
*
)
s
->
p
;
...
...
mongoose.h
View file @
70dc6d8d
...
@@ -2351,6 +2351,11 @@ int mg_strcmp(const struct mg_str str1, const struct mg_str str2);
...
@@ -2351,6 +2351,11 @@ int mg_strcmp(const struct mg_str str1, const struct mg_str str2);
*/
*/
int
mg_strncmp
(
const
struct
mg_str
str1
,
const
struct
mg_str
str2
,
size_t
n
);
int
mg_strncmp
(
const
struct
mg_str
str1
,
const
struct
mg_str
str2
,
size_t
n
);
/*
* Compare two `mg_str`s ignoreing case; return value is the same as `strcmp`.
*/
int
mg_strcasecmp
(
const
struct
mg_str
str1
,
const
struct
mg_str
str2
);
/*
/*
* Free the string (assuming it was heap allocated).
* Free the string (assuming it was heap allocated).
*/
*/
...
@@ -6239,6 +6244,7 @@ int mg_dns_encode_record(struct mbuf *io, struct mg_dns_resource_record *rr,
...
@@ -6239,6 +6244,7 @@ int mg_dns_encode_record(struct mbuf *io, struct mg_dns_resource_record *rr,
* Encodes a DNS name.
* Encodes a DNS name.
*/
*/
int
mg_dns_encode_name
(
struct
mbuf
*
io
,
const
char
*
name
,
size_t
len
);
int
mg_dns_encode_name
(
struct
mbuf
*
io
,
const
char
*
name
,
size_t
len
);
int
mg_dns_encode_name_s
(
struct
mbuf
*
io
,
struct
mg_str
name
);
/* Low-level: parses a DNS response. */
/* Low-level: parses a DNS response. */
int
mg_parse_dns
(
const
char
*
buf
,
int
len
,
struct
mg_dns_message
*
msg
);
int
mg_parse_dns
(
const
char
*
buf
,
int
len
,
struct
mg_dns_message
*
msg
);
...
...
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