Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
pistache
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
pistache
Commits
7cefb695
Commit
7cefb695
authored
Sep 01, 2015
by
Mathieu Stefani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polished multi-lines macros
parent
b63025ad
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
19 deletions
+19
-19
src/http_header.cc
src/http_header.cc
+19
-19
No files found.
src/http_header.cc
View file @
7cefb695
...
@@ -96,30 +96,30 @@ CacheControl::parseRaw(const char* str, size_t len) {
...
@@ -96,30 +96,30 @@ CacheControl::parseRaw(const char* str, size_t len) {
#define MAX_SIZE(s) \
#define MAX_SIZE(s) \
std::min(sizeof(s) - 1, len - (begin - str))
std::min(sizeof(s) - 1, len - (begin - str))
#define TRY_PARSE_TRIVIAL_DIRECTIVE(dstr, directive) \
#define TRY_PARSE_TRIVIAL_DIRECTIVE(dstr, directive)
\
if (memcmp(begin, dstr, MAX_SIZE(dstr)) == 0) { \
if (memcmp(begin, dstr, MAX_SIZE(dstr)) == 0) {
\
directives_.push_back(CacheDirective(CacheDirective::directive)); \
directives_.push_back(CacheDirective(CacheDirective::directive)); \
begin += sizeof(dstr) - 1; \
begin += sizeof(dstr) - 1;
\
break; \
break;
\
} \
}
\
(void) 0
(void) 0
// @Todo: check for overflow
// @Todo: check for overflow
#define TRY_PARSE_TIMED_DIRECTIVE(dstr, directive) \
#define TRY_PARSE_TIMED_DIRECTIVE(dstr, directive)
\
if (memcmp(begin, dstr, MAX_SIZE(dstr)) == 0) { \
if (memcmp(begin, dstr, MAX_SIZE(dstr)) == 0) {
\
const char *p = static_cast<const char *>(memchr(str, '=', len)); \
const char *p = static_cast<const char *>(memchr(str, '=', len));
\
if (p == NULL) { \
if (p == NULL) {
\
throw std::runtime_error("Invalid caching directive, missing delta-seconds"); \
throw std::runtime_error("Invalid caching directive, missing delta-seconds");
\
} \
}
\
char *end; \
char *end;
\
int secs = strtol(p + 1, &end, 10); \
int secs = strtol(p + 1, &end, 10);
\
if (!eof(end) && *end != ',') { \
if (!eof(end) && *end != ',') {
\
throw std::runtime_error("Invalid caching directive, malformated delta-seconds"); \
throw std::runtime_error("Invalid caching directive, malformated delta-seconds");
\
} \
}
\
directives_.push_back(CacheDirective(CacheDirective::directive, std::chrono::seconds(secs))); \
directives_.push_back(CacheDirective(CacheDirective::directive, std::chrono::seconds(secs))); \
begin = end; \
begin = end;
\
break; \
break;
\
} \
}
\
(void) 0
(void) 0
const
char
*
begin
=
str
;
const
char
*
begin
=
str
;
...
...
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