Permalink
Browse files

start using clang-format (using the same defs as h2o/h2o; fixes #17)

  • Loading branch information...
kazuho committed May 20, 2015
1 parent 667c802 commit 296dc4317717a4933912d18f8359cafc18a8b297
Showing with 860 additions and 900 deletions.
  1. +6 −0 .clang-format
  2. +32 −19 bench.c
  3. +478 −492 picohttpparser.c
  4. +15 −22 picohttpparser.h
  5. +329 −367 test.c
View
@@ -0,0 +1,6 @@
# requires clang-format >= 3.6
BasedOnStyle: "LLVM"
IndentWidth: 4
ColumnLimit: 132
BreakBeforeBraces: Linux
AllowShortFunctionsOnASingleLine: None
View
51 bench.c
@@ -28,26 +28,39 @@
#include <stdio.h>
#include "picohttpparser.h"
#define REQ "GET /wp-content/uploads/2010/03/hello-kitty-darth-vader-pink.jpg HTTP/1.1\r\nHost: www.kittyhell.com\r\nUser-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; ja-JP-mac; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 Pathtraq/0.9\r\nAccept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\nAccept-Language: ja,en-us;q=0.7,en;q=0.3\r\nAccept-Encoding: gzip,deflate\r\nAccept-Charset: Shift_JIS,utf-8;q=0.7,*;q=0.7\r\nKeep-Alive: 115\r\nConnection: keep-alive\r\nCookie: wp_ozh_wsa_visits=2; wp_ozh_wsa_visit_lasttime=xxxxxxxxxx; __utma=xxxxxxxxx.xxxxxxxxxx.xxxxxxxxxx.xxxxxxxxxx.xxxxxxxxxx.x; __utmz=xxxxxxxxx.xxxxxxxxxx.x.x.utmccn=(referral)|utmcsr=reader.livedoor.com|utmcct=/reader/|utmcmd=referral\r\n\r\n"
#define REQ \
"GET /wp-content/uploads/2010/03/hello-kitty-darth-vader-pink.jpg HTTP/1.1\r\n" \
"Host: www.kittyhell.com\r\n" \
"User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; ja-JP-mac; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 " \
"Pathtraq/0.9\r\n" \
"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n" \
"Accept-Language: ja,en-us;q=0.7,en;q=0.3\r\n" \
"Accept-Encoding: gzip,deflate\r\n" \
"Accept-Charset: Shift_JIS,utf-8;q=0.7,*;q=0.7\r\n" \
"Keep-Alive: 115\r\n" \
"Connection: keep-alive\r\n" \
"Cookie: wp_ozh_wsa_visits=2; wp_ozh_wsa_visit_lasttime=xxxxxxxxxx; " \
"__utma=xxxxxxxxx.xxxxxxxxxx.xxxxxxxxxx.xxxxxxxxxx.xxxxxxxxxx.x; " \
"__utmz=xxxxxxxxx.xxxxxxxxxx.x.x.utmccn=(referral)|utmcsr=reader.livedoor.com|utmcct=/reader/|utmcmd=referral\r\n" \
"\r\n"
int main(void)
{
const char* method;
size_t method_len;
const char* path;
size_t path_len;
int minor_version;
struct phr_header headers[32];
size_t num_headers;
int i, ret;
for (i = 0; i < 10000000; i++) {
num_headers = sizeof(headers) / sizeof(headers[0]);
ret = phr_parse_request(REQ, sizeof(REQ) - 1, &method, &method_len, &path,
&path_len, &minor_version, headers, &num_headers,
0);
assert(ret == sizeof(REQ) - 1);
}
return 0;
const char *method;
size_t method_len;
const char *path;
size_t path_len;
int minor_version;
struct phr_header headers[32];
size_t num_headers;
int i, ret;
for (i = 0; i < 10000000; i++) {
num_headers = sizeof(headers) / sizeof(headers[0]);
ret = phr_parse_request(REQ, sizeof(REQ) - 1, &method, &method_len, &path, &path_len, &minor_version, headers, &num_headers,
0);
assert(ret == sizeof(REQ) - 1);
}
return 0;
}
Oops, something went wrong.

0 comments on commit 296dc43

Please sign in to comment.