Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nghttp2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
nghttp2
Commits
0a6877d0
Commit
0a6877d0
authored
Jul 14, 2015
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nghttpx: Supply template version strcopy
parent
7f7b6d64
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
32 deletions
+25
-32
src/shrpx_config.cc
src/shrpx_config.cc
+7
-26
src/shrpx_config.h
src/shrpx_config.h
+18
-6
No files found.
src/shrpx_config.cc
View file @
0a6877d0
...
...
@@ -59,8 +59,6 @@
#include "template.h"
#include "base64.h"
using
namespace
nghttp2
;
namespace
shrpx
{
namespace
{
...
...
@@ -227,21 +225,6 @@ std::string read_passwd_from_file(const char *filename) {
return
line
;
}
std
::
unique_ptr
<
char
[]
>
strcopy
(
const
char
*
val
)
{
return
strcopy
(
val
,
strlen
(
val
));
}
std
::
unique_ptr
<
char
[]
>
strcopy
(
const
char
*
val
,
size_t
len
)
{
auto
res
=
make_unique
<
char
[]
>
(
len
+
1
);
memcpy
(
res
.
get
(),
val
,
len
);
res
[
len
]
=
'\0'
;
return
res
;
}
std
::
unique_ptr
<
char
[]
>
strcopy
(
const
std
::
string
&
val
)
{
return
strcopy
(
val
.
c_str
(),
val
.
size
());
}
std
::
vector
<
char
*>
parse_config_str_list
(
const
char
*
s
,
char
delim
)
{
size_t
len
=
1
;
for
(
const
char
*
first
=
s
,
*
p
=
nullptr
;
(
p
=
strchr
(
first
,
delim
));
...
...
@@ -394,7 +377,6 @@ std::vector<LogFragment> parse_log_format(const char *optarg) {
auto
type
=
SHRPX_LOGF_NONE
;
const
char
*
value
=
nullptr
;
size_t
valuelen
=
0
;
if
(
util
::
strieq_l
(
"remote_addr"
,
var_name
,
var_namelen
))
{
type
=
SHRPX_LOGF_REMOTE_ADDR
;
...
...
@@ -411,7 +393,6 @@ std::vector<LogFragment> parse_log_format(const char *optarg) {
}
else
if
(
util
::
istartsWith
(
var_name
,
var_namelen
,
"http_"
))
{
type
=
SHRPX_LOGF_HTTP
;
value
=
var_name
+
sizeof
(
"http_"
)
-
1
;
valuelen
=
var_namelen
-
(
sizeof
(
"http_"
)
-
1
);
}
else
if
(
util
::
strieq_l
(
"remote_port"
,
var_name
,
var_namelen
))
{
type
=
SHRPX_LOGF_REMOTE_PORT
;
}
else
if
(
util
::
strieq_l
(
"server_port"
,
var_name
,
var_namelen
))
{
...
...
@@ -437,9 +418,8 @@ std::vector<LogFragment> parse_log_format(const char *optarg) {
}
if
(
literal_start
<
var_start
)
{
res
.
push_back
(
make_log_fragment
(
SHRPX_LOGF_LITERAL
,
strcopy
(
literal_start
,
var_start
-
literal_start
)));
res
.
push_back
(
make_log_fragment
(
SHRPX_LOGF_LITERAL
,
strcopy
(
literal_start
,
var_start
)));
}
literal_start
=
p
;
...
...
@@ -449,7 +429,8 @@ std::vector<LogFragment> parse_log_format(const char *optarg) {
continue
;
}
res
.
push_back
(
make_log_fragment
(
type
,
strcopy
(
value
,
valuelen
)));
res
.
push_back
(
make_log_fragment
(
type
,
strcopy
(
value
,
var_name
+
var_namelen
)));
auto
&
v
=
res
.
back
().
value
;
for
(
size_t
i
=
0
;
v
[
i
];
++
i
)
{
if
(
v
[
i
]
==
'_'
)
{
...
...
@@ -459,8 +440,8 @@ std::vector<LogFragment> parse_log_format(const char *optarg) {
}
if
(
literal_start
!=
eop
)
{
res
.
push_back
(
make_log_fragment
(
SHRPX_LOGF_LITERAL
,
strcopy
(
literal_start
,
eop
-
literal_start
)));
res
.
push_back
(
make_log_fragment
(
SHRPX_LOGF_LITERAL
,
strcopy
(
literal_start
,
eop
)));
}
return
res
;
...
...
@@ -537,7 +518,7 @@ int parse_config(const char *opt, const char *optarg,
DownstreamAddr
addr
;
if
(
util
::
istartsWith
(
optarg
,
SHRPX_UNIX_PATH_PREFIX
))
{
auto
path
=
optarg
+
str_size
(
SHRPX_UNIX_PATH_PREFIX
);
addr
.
host
=
strcopy
(
path
,
pat_delim
-
path
);
addr
.
host
=
strcopy
(
path
,
pat_delim
);
addr
.
host_unix
=
true
;
}
else
{
if
(
split_host_port
(
host
,
sizeof
(
host
),
&
port
,
optarg
,
...
...
src/shrpx_config.h
View file @
0a6877d0
...
...
@@ -50,6 +50,10 @@
#include <nghttp2/nghttp2.h>
#include "template.h"
using
namespace
nghttp2
;
namespace
shrpx
{
struct
LogFragment
;
...
...
@@ -416,15 +420,23 @@ std::pair<std::string, std::string> parse_header(const char *optarg);
std
::
vector
<
LogFragment
>
parse_log_format
(
const
char
*
optarg
);
// Returns a copy of NULL-terminated string |val|.
std
::
unique_ptr
<
char
[]
>
strcopy
(
const
char
*
val
);
// Returns a copy of NULL-terminated string [first, last).
template
<
typename
InputIt
>
std
::
unique_ptr
<
char
[]
>
strcopy
(
InputIt
first
,
InputIt
last
)
{
auto
res
=
make_unique
<
char
[]
>
(
last
-
first
+
1
);
*
std
::
copy
(
first
,
last
,
res
.
get
())
=
'\0'
;
return
res
;
}
// Returns a copy of string |val| of length |n|. The returned string
// will be NULL-terminated.
std
::
unique_ptr
<
char
[]
>
strcopy
(
const
char
*
val
,
size_t
n
);
// Returns a copy of NULL-terminated string |val|.
inline
std
::
unique_ptr
<
char
[]
>
strcopy
(
const
char
*
val
)
{
return
strcopy
(
val
,
val
+
strlen
(
val
));
}
// Returns a copy of val.c_str().
std
::
unique_ptr
<
char
[]
>
strcopy
(
const
std
::
string
&
val
);
inline
std
::
unique_ptr
<
char
[]
>
strcopy
(
const
std
::
string
&
val
)
{
return
strcopy
(
std
::
begin
(
val
),
std
::
end
(
val
));
}
// Returns string for syslog |facility|.
const
char
*
str_syslog_facility
(
int
facility
);
...
...
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