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
c907e6c5
Commit
c907e6c5
authored
Jul 06, 2016
by
Deomid Ryabkov
Committed by
Cesanta Bot
Jul 06, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Commonize mg_str
PUBLISHED_FROM=0e6a1c1a2356c1e12580e498c64ba7be367f601c
parent
29b3950e
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
82 additions
and
113 deletions
+82
-113
intro.md
docs/c-api/net.h/intro.md
+0
-1
struct_mg_str.md
docs/c-api/net.h/struct_mg_str.md
+0
-13
MG_MK_STR.md
docs/c-api/util.h/MG_MK_STR.md
+0
-10
intro.md
docs/c-api/util.h/intro.md
+0
-4
mg_mk_str.md
docs/c-api/util.h/mg_mk_str.md
+0
-11
mg_vcasecmp.md
docs/c-api/util.h/mg_vcasecmp.md
+0
-11
mg_vcmp.md
docs/c-api/util.h/mg_vcmp.md
+0
-11
mongoose.c
mongoose.c
+35
-24
mongoose.h
mongoose.h
+47
-28
No files found.
docs/c-api/net.h/intro.md
View file @
c907e6c5
...
...
@@ -25,7 +25,6 @@ items:
-
{
type
:
file
,
name
:
mg_set_timer.md
}
-
{
type
:
file
,
name
:
mg_time.md
}
-
{
type
:
file
,
name
:
mg_event_handler_t.md
}
-
{
type
:
file
,
name
:
struct_mg_str.md
}
-
{
type
:
file
,
name
:
struct_mg_mgr.md
}
-
{
type
:
file
,
name
:
struct_mg_connection.md
}
-
{
type
:
file
,
name
:
struct_mg_add_sock_opts.md
}
...
...
docs/c-api/net.h/struct_mg_str.md
deleted
100644 → 0
View file @
29b3950e
---
title
:
"
struct
mg_str"
decl_name
:
"
struct
mg_str"
symbol_kind
:
"
struct"
signature
:
|
struct mg_str {
const char *p; /* Memory chunk pointer */
size_t len; /* Memory chunk length */
};
---
Describes chunk of memory
docs/c-api/util.h/MG_MK_STR.md
deleted
100644 → 0
View file @
29b3950e
---
title
:
"
MG_MK_STR()"
decl_name
:
"
MG_MK_STR"
symbol_kind
:
"
func"
signature
:
|
#define MG_MK_STR(str_literal);
---
Macro for initializing mg_str.
docs/c-api/util.h/intro.md
View file @
c907e6c5
...
...
@@ -6,8 +6,6 @@ items:
-
{
type
:
file
,
name
:
mg_skip.md
}
-
{
type
:
file
,
name
:
mg_ncasecmp.md
}
-
{
type
:
file
,
name
:
mg_casecmp.md
}
-
{
type
:
file
,
name
:
mg_vcmp.md
}
-
{
type
:
file
,
name
:
mg_vcasecmp.md
}
-
{
type
:
file
,
name
:
mg_base64_decode.md
}
-
{
type
:
file
,
name
:
mg_base64_encode.md
}
-
{
type
:
file
,
name
:
mg_stat.md
}
...
...
@@ -23,8 +21,6 @@ items:
-
{
type
:
file
,
name
:
mg_is_big_endian.md
}
-
{
type
:
file
,
name
:
mg_next_comma_list_entry.md
}
-
{
type
:
file
,
name
:
mg_match_prefix.md
}
-
{
type
:
file
,
name
:
mg_mk_str.md
}
-
{
type
:
file
,
name
:
MG_MK_STR.md
}
---
...
...
docs/c-api/util.h/mg_mk_str.md
deleted
100644 → 0
View file @
29b3950e
---
title
:
"
mg_mk_str()"
decl_name
:
"
mg_mk_str"
symbol_kind
:
"
func"
signature
:
|
struct mg_str mg_mk_str(const char *s);
---
A helper function for creating mg_str struct from plain C string.
`NULL`
is allowed and becomes
`{NULL, 0}`
.
docs/c-api/util.h/mg_vcasecmp.md
deleted
100644 → 0
View file @
29b3950e
---
title
:
"
mg_vcasecmp()"
decl_name
:
"
mg_vcasecmp"
symbol_kind
:
"
func"
signature
:
|
int mg_vcasecmp(const struct mg_str *str2, const char *str1);
---
Cross-platform version of
`strncasecmp()`
where first string is
specified by
`struct mg_str`
.
docs/c-api/util.h/mg_vcmp.md
deleted
100644 → 0
View file @
29b3950e
---
title
:
"
mg_vcmp()"
decl_name
:
"
mg_vcmp"
symbol_kind
:
"
func"
signature
:
|
int mg_vcmp(const struct mg_str *str2, const char *str1);
---
Cross-platform version of
`strcmp()`
where where first string is
specified by
`struct mg_str`
.
mongoose.c
View file @
c907e6c5
...
...
@@ -954,6 +954,41 @@ void mbuf_remove(struct mbuf *mb, size_t n) {
#endif
/* EXCLUDE_COMMON */
#ifdef MG_MODULE_LINES
#line 1 "./src/../../common/mg_str.c"
#endif
/*
* Copyright (c) 2014-2016 Cesanta Software Limited
* All rights reserved
*/
/* Amalgamated: #include "common/mg_str.h" */
#include <string.h>
struct
mg_str
mg_mk_str
(
const
char
*
s
)
{
struct
mg_str
ret
=
{
s
,
0
};
if
(
s
!=
NULL
)
ret
.
len
=
strlen
(
s
);
return
ret
;
}
int
mg_vcmp
(
const
struct
mg_str
*
str1
,
const
char
*
str2
)
{
size_t
n2
=
strlen
(
str2
),
n1
=
str1
->
len
;
int
r
=
memcmp
(
str1
->
p
,
str2
,
(
n1
<
n2
)
?
n1
:
n2
);
if
(
r
==
0
)
{
return
n1
-
n2
;
}
return
r
;
}
int
mg_vcasecmp
(
const
struct
mg_str
*
str1
,
const
char
*
str2
)
{
size_t
n2
=
strlen
(
str2
),
n1
=
str1
->
len
;
int
r
=
mg_ncasecmp
(
str1
->
p
,
str2
,
(
n1
<
n2
)
?
n1
:
n2
);
if
(
r
==
0
)
{
return
n1
-
n2
;
}
return
r
;
}
#ifdef MG_MODULE_LINES
#line 1 "./src/../../common/sha1.c"
#endif
/* Copyright(c) By Steve Reid <steve@edmweb.com> */
...
...
@@ -7302,24 +7337,6 @@ int mg_casecmp(const char *s1, const char *s2) {
return
mg_ncasecmp
(
s1
,
s2
,
(
size_t
)
~
0
);
}
int
mg_vcasecmp
(
const
struct
mg_str
*
str1
,
const
char
*
str2
)
{
size_t
n2
=
strlen
(
str2
),
n1
=
str1
->
len
;
int
r
=
mg_ncasecmp
(
str1
->
p
,
str2
,
(
n1
<
n2
)
?
n1
:
n2
);
if
(
r
==
0
)
{
return
n1
-
n2
;
}
return
r
;
}
int
mg_vcmp
(
const
struct
mg_str
*
str1
,
const
char
*
str2
)
{
size_t
n2
=
strlen
(
str2
),
n1
=
str1
->
len
;
int
r
=
memcmp
(
str1
->
p
,
str2
,
(
n1
<
n2
)
?
n1
:
n2
);
if
(
r
==
0
)
{
return
n1
-
n2
;
}
return
r
;
}
#ifndef MG_DISABLE_FILESYSTEM
int
mg_stat
(
const
char
*
path
,
cs_stat_t
*
st
)
{
#ifdef _WIN32
...
...
@@ -7641,12 +7658,6 @@ int mg_match_prefix(const char *pattern, int pattern_len, const char *str) {
const
struct
mg_str
pstr
=
{
pattern
,
(
size_t
)
pattern_len
};
return
mg_match_prefix_n
(
pstr
,
mg_mk_str
(
str
));
}
struct
mg_str
mg_mk_str
(
const
char
*
s
)
{
struct
mg_str
ret
=
{
s
,
0
};
if
(
s
!=
NULL
)
ret
.
len
=
strlen
(
s
);
return
ret
;
}
#ifdef MG_MODULE_LINES
#line 1 "./src/mqtt.c"
#endif
...
...
mongoose.h
View file @
c907e6c5
...
...
@@ -841,6 +841,53 @@ double cs_time();
#endif
/* __cplusplus */
#endif
/* CS_COMMON_CS_TIME_H_ */
/*
* Copyright (c) 2014-2016 Cesanta Software Limited
* All rights reserved
*/
#ifndef CS_COMMON_MG_STR_H_
#define CS_COMMON_MG_STR_H_
#include <stddef.h>
#ifdef __cplusplus
extern
"C"
{
#endif
/* __cplusplus */
/* Describes chunk of memory */
struct
mg_str
{
const
char
*
p
;
/* Memory chunk pointer */
size_t
len
;
/* Memory chunk length */
};
/*
* A helper function for creating mg_str struct from plain C string.
* `NULL` is allowed and becomes `{NULL, 0}`.
*/
struct
mg_str
mg_mk_str
(
const
char
*
s
);
/* Macro for initializing mg_str. */
#define MG_MK_STR(str_literal) \
{ str_literal, sizeof(str_literal) - 1 }
/*
* Cross-platform version of `strcmp()` where where first string is
* specified by `struct mg_str`.
*/
int
mg_vcmp
(
const
struct
mg_str
*
str2
,
const
char
*
str1
);
/*
* Cross-platform version of `strncasecmp()` where first string is
* specified by `struct mg_str`.
*/
int
mg_vcasecmp
(
const
struct
mg_str
*
str2
,
const
char
*
str1
);
#ifdef __cplusplus
}
#endif
/* __cplusplus */
#endif
/* CS_COMMON_MG_STR_H_ */
/*
* Copyright (c) 2015 Cesanta Software Limited
* All rights reserved
...
...
@@ -1140,12 +1187,6 @@ union socket_address {
#endif
};
/* Describes chunk of memory */
struct
mg_str
{
const
char
*
p
;
/* Memory chunk pointer */
size_t
len
;
/* Memory chunk length */
};
struct
mg_connection
;
/*
...
...
@@ -1793,18 +1834,6 @@ int mg_ncasecmp(const char *s1, const char *s2, size_t len);
*/
int
mg_casecmp
(
const
char
*
s1
,
const
char
*
s2
);
/*
* Cross-platform version of `strcmp()` where where first string is
* specified by `struct mg_str`.
*/
int
mg_vcmp
(
const
struct
mg_str
*
str2
,
const
char
*
str1
);
/*
* Cross-platform version of `strncasecmp()` where first string is
* specified by `struct mg_str`.
*/
int
mg_vcasecmp
(
const
struct
mg_str
*
str2
,
const
char
*
str1
);
/*
* Decode base64-encoded string `s`, `len` into the destination `dst`.
* Destination has to have enough space to hold decoded buffer.
...
...
@@ -1963,16 +1992,6 @@ const char *mg_next_comma_list_entry(const char *list, struct mg_str *val,
int
mg_match_prefix
(
const
char
*
pattern
,
int
pattern_len
,
const
char
*
str
);
int
mg_match_prefix_n
(
const
struct
mg_str
pattern
,
const
struct
mg_str
str
);
/*
* A helper function for creating mg_str struct from plain C string.
* `NULL` is allowed and becomes `{NULL, 0}`.
*/
struct
mg_str
mg_mk_str
(
const
char
*
s
);
/* Macro for initializing mg_str. */
#define MG_MK_STR(str_literal) \
{ str_literal, sizeof(str_literal) - 1 }
#ifdef __cplusplus
}
#endif
/* __cplusplus */
...
...
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