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
9390c66b
Commit
9390c66b
authored
Jan 09, 2014
by
Sergey Lyubka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved next_option() to the rest of string functions
parent
2f69ca37
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
39 deletions
+39
-39
mongoose.c
mongoose.c
+39
-39
No files found.
mongoose.c
View file @
9390c66b
...
...
@@ -427,6 +427,45 @@ static void mg_strlcpy(register char *dst, register const char *src, size_t n) {
*
dst
=
'\0'
;
}
// A helper function for traversing a comma separated list of values.
// It returns a list pointer shifted to the next value, or NULL if the end
// of the list found.
// Value is stored in val vector. If value has form "x=y", then eq_val
// vector is initialized to point to the "y" part, and val vector length
// is adjusted to point only to "x".
static
const
char
*
next_option
(
const
char
*
list
,
struct
vec
*
val
,
struct
vec
*
eq_val
)
{
if
(
list
==
NULL
||
*
list
==
'\0'
)
{
// End of the list
list
=
NULL
;
}
else
{
val
->
ptr
=
list
;
if
((
list
=
strchr
(
val
->
ptr
,
','
))
!=
NULL
)
{
// Comma found. Store length and shift the list ptr
val
->
len
=
list
-
val
->
ptr
;
list
++
;
}
else
{
// This value is the last one
list
=
val
->
ptr
+
strlen
(
val
->
ptr
);
val
->
len
=
list
-
val
->
ptr
;
}
if
(
eq_val
!=
NULL
)
{
// Value has form "x=y", adjust pointers and lengths
// so that val points to "x", and eq_val points to "y".
eq_val
->
len
=
0
;
eq_val
->
ptr
=
(
const
char
*
)
memchr
(
val
->
ptr
,
'='
,
val
->
len
);
if
(
eq_val
->
ptr
!=
NULL
)
{
eq_val
->
ptr
++
;
// Skip over '=' character
eq_val
->
len
=
val
->
ptr
+
val
->
len
-
eq_val
->
ptr
;
val
->
len
=
(
eq_val
->
ptr
-
val
->
ptr
)
-
1
;
}
}
}
return
list
;
}
static
int
spool
(
struct
iobuf
*
io
,
const
void
*
buf
,
int
len
)
{
static
const
double
mult
=
1
.
2
;
char
*
p
=
NULL
;
...
...
@@ -589,45 +628,6 @@ int mg_printf(struct mg_connection *conn, const char *fmt, ...) {
return
len
;
}
// A helper function for traversing a comma separated list of values.
// It returns a list pointer shifted to the next value, or NULL if the end
// of the list found.
// Value is stored in val vector. If value has form "x=y", then eq_val
// vector is initialized to point to the "y" part, and val vector length
// is adjusted to point only to "x".
static
const
char
*
next_option
(
const
char
*
list
,
struct
vec
*
val
,
struct
vec
*
eq_val
)
{
if
(
list
==
NULL
||
*
list
==
'\0'
)
{
// End of the list
list
=
NULL
;
}
else
{
val
->
ptr
=
list
;
if
((
list
=
strchr
(
val
->
ptr
,
','
))
!=
NULL
)
{
// Comma found. Store length and shift the list ptr
val
->
len
=
list
-
val
->
ptr
;
list
++
;
}
else
{
// This value is the last one
list
=
val
->
ptr
+
strlen
(
val
->
ptr
);
val
->
len
=
list
-
val
->
ptr
;
}
if
(
eq_val
!=
NULL
)
{
// Value has form "x=y", adjust pointers and lengths
// so that val points to "x", and eq_val points to "y".
eq_val
->
len
=
0
;
eq_val
->
ptr
=
(
const
char
*
)
memchr
(
val
->
ptr
,
'='
,
val
->
len
);
if
(
eq_val
->
ptr
!=
NULL
)
{
eq_val
->
ptr
++
;
// Skip over '=' character
eq_val
->
len
=
val
->
ptr
+
val
->
len
-
eq_val
->
ptr
;
val
->
len
=
(
eq_val
->
ptr
-
val
->
ptr
)
-
1
;
}
}
}
return
list
;
}
static
int
mg_socketpair
(
sock_t
sp
[
2
])
{
struct
sockaddr_in
sa
;
sock_t
sock
,
ret
=
-
1
;
...
...
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