Commits

Jeremy Sandell committed fab057a Draft

code cleanup

Comments (0)

Files changed (5)

 DEBUG_FLAGS="-g"
 
 HTTP_PARSER_LIB="http_parser"
-RELEASE_FLAGS=""
+RELEASE_FLAGS="-m32 -release -O"
 
 if [[ $DEBUG ]];then
 HTTP_PARSER_LIB="http_parser_g"
 echo "Release"
 
 echo "[net.http._parser]"
-dmd -release -O -c -odobj -w -wi -L-L$HTTP_PARSER_PATH -L-l$HTTP_PARSER_LIB net/http/_parser.di 
+dmd $RELEASE_FLAGS -c -odobj -w -wi -L-L$HTTP_PARSER_PATH -L-l$HTTP_PARSER_LIB net/http/_parser.di 
 
 echo "[net.http.parser]"
-dmd -release -O -c -odobj -w -wi -L-L$HTTP_PARSER_PATH -L-l$HTTP_PARSER_LIB net/http/parser.di 
+dmd $RELEASE_FLAGS -c -odobj -w -wi -L-L$HTTP_PARSER_PATH -L-l$HTTP_PARSER_LIB net/http/parser.di 
 
 echo "[parse.d]"
-dmd -release -O -ofparse.exe -odobj -w -wi -L-L$HTTP_PARSER_PATH -L-l$HTTP_PARSER_LIB parse.d obj/_parser.o obj/parser.o
+dmd $RELEASE_FLAGS -ofparse.exe -odobj -w -wi -L-L$HTTP_PARSER_PATH -L-l$HTTP_PARSER_LIB parse.d obj/_parser.o obj/parser.o
 
 fi
 

http_parser.di

-module http_parser;
-import std.bitmanip;
-
-public import core.stdc.config;
-
-pragma(lib, "http_parser_g");
-
-/*
-* Borrowed from  git://github.com/D-Programming-Deimos/libevent.git
-*/
-
-template ExternC(T) if (is(typeof(*(T.init)) P == function)) {
-    static if (is(typeof(*(T.init)) R == return)) {
-        static if (is(typeof(*(T.init)) P == function)) {
-            alias extern(C) R function(P) ExternC;
-        }
-    }
-}
-
-const int HTTP_MAX_HEADER_SIZE = (80 * 1024);
-
-struct http_parser {
-    // original header had these as bit fields.
-
-    mixin(bitfields!(
-      ubyte, "type", 2,
-      ubyte, "flags", 6
-    ));
-
-    ubyte state;
-    ubyte header_state;
-    ubyte index;
-
-    uint nread;
-    ulong content_length;
-
-    ushort http_major;
-    ushort http_minor;
-    ushort status_code;
-    ubyte method;
-
-    mixin(bitfields!(
-      ubyte, "http_errno", 7,
-      ubyte, "upgrade", 1
-    ));
-
-    void *data;
-    string[string] _headers; // internal binding data
-    string _last_header; // internal binding data
-    string _body; // internal binding data
-};
-struct http_parser_settings {
-    ExternC!(int function (http_parser *p)) on_message_begin;
-    ExternC!(int function (http_parser *p, const(char)* buf, size_t length)) on_url;
-    ExternC!(int function (http_parser *p, const(char)* buf, size_t length)) on_header_field;
-    //extern(D) int function (http_parser *p, const(char)* buf, size_t length) on_header_field;
-    ExternC!(int function (http_parser *p, const(char)* buf, size_t length)) on_header_value;
-    ExternC!(int function (http_parser *p)) on_headers_complete;
-    ExternC!(int function (http_parser *p, const(char)* buf, size_t length)) on_body;
-    ExternC!(int function (http_parser *p)) on_message_complete;
-};
-    
-
-    /*
-    alias int function (http_parser *p, const(char)* buf, size_t length) http_data_cb;
-    alias int function (http_parser*) http_cb;
-    struct http_parser_settings {
-        http_cb on_message_begin;
-        http_data_cb on_url;
-        http_data_cb on_header_field;
-        http_data_cb on_header_value;
-        http_cb on_headers_complete;
-        http_data_cb on_body;
-        http_cb on_message_complete;
-    };
-    */
-
-    //alias int delegate (http_parser *_, const char *buf, size_t length) http_data_cb;
-    //alias int delegate (http_parser*) http_cb;
-
-extern(C):
-nothrow:
-
-
-    enum http_method : ubyte
-    {
-        HTTP_DELETE = 0,
-        HTTP_GET = 1,
-        HTTP_HEAD = 2,
-        HTTP_POST = 3,
-        HTTP_PUT = 4,
-        HTTP_CONNECT = 5,
-        HTTP_OPTIONS = 6,
-        HTTP_TRACE = 7,
-        HTTP_COPY = 8,
-        HTTP_LOCK = 9,
-        HTTP_MKCOL = 10,
-        HTTP_MOVE = 11,
-        HTTP_PROPFIND = 12,
-        HTTP_PROPPATCH = 13,
-        HTTP_SEARCH = 14,
-        HTTP_UNLOCK = 15,
-        HTTP_REPORT = 16,
-        HTTP_MKACTIVITY = 17,
-        HTTP_CHECKOUT = 18,
-        HTTP_MERGE = 19,
-        HTTP_MSEARCH = 20,
-        HTTP_NOTIFY = 21,
-        HTTP_SUBSCRIBE = 22,
-        HTTP_UNSUBSCRIBE = 23,
-        HTTP_PATCH = 24,
-        HTTP_PURGE = 25,
-    };
-
-    enum http_parser_type : ubyte
-    { HTTP_REQUEST, HTTP_RESPONSE, HTTP_BOTH };
-
-    enum flags 
-    {
-        F_CHUNKED = 1 << 0,
-        F_CONNECTION_KEEP_ALIVE = 1 << 1,
-        F_CONNECTION_CLOSE = 1 << 2,
-        F_TRAILING = 1 << 3,
-        F_UPGRADE = 1 << 4,
-        F_SKIPBODY = 1 << 5
-    };
-
-    enum http_errno : ubyte
-    {
-        HPE_OK,
-        HPE_CB_message_begin,
-        HPE_CB_url,
-        HPE_CB_header_field,
-        HPE_CB_header_value,
-        HPE_CB_headers_complete,
-        HPE_CB_body,
-        HPE_CB_message_complete,
-        HPE_INVALID_EOF_STATE,
-        HPE_HEADER_OVERFLOW,
-        HPE_CLOSED_CONNECTION,
-        HPE_INVALID_VERSION,
-        HPE_INVALID_STATUS,
-        HPE_INVALID_METHOD,
-        HPE_INVALID_URL,
-        HPE_INVALID_HOST,
-        HPE_INVALID_PORT,
-        HPE_INVALID_PATH,
-        HPE_INVALID_QUERY_STRING,
-        HPE_INVALID_FRAGMENT,
-        HPE_LF_EXPECTED,
-        HPE_INVALID_HEADER_TOKEN,
-        HPE_INVALID_CONTENT_LENGTH,
-        HPE_INVALID_CHUNK_SIZE,
-        HPE_INVALID_CONSTANT,
-        HPE_INVALID_INTERNAL_STATE,
-        HPE_STRICT,
-        HPE_PAUSED,
-        HPE_UNKNOWN,
-    };
-
-
-
-
-    enum http_parser_url_fields
-    { 
-        UF_SCHEMA = 0,
-        UF_HOST = 1,
-        UF_PORT = 2,
-        UF_PATH = 3,
-        UF_QUERY = 4,
-        UF_FRAGMENT = 5,
-        UF_MAX = 6,
-    };
-
-    struct http_parser_url {
-        ushort field_set;
-        ushort port;
-
-        /*
-        struct field_data {
-            ushort off;
-            ushort len;
-        };
-        */
-        struct FieldData {
-            ushort off;
-            ushort len;
-        };
-        FieldData field_data[http_parser_url_fields.UF_MAX];
-    };
-
-    void http_parser_init(http_parser *parser, http_parser_type type);
-
-    size_t http_parser_execute(http_parser *parser,
-                               const (http_parser_settings)* settings,
-                               const (char)* data,
-                               size_t len);
-
-    int http_should_keep_alive(http_parser *parser);
-    const (char)* http_method_str(http_method m);
-    const (char)* http_errno_name(http_errno err);
-    const (char)* http_errno_description(http_errno err);
-
-    int http_parser_parse_url(const (char)* buf,
-                              size_t buflen,
-                              int is_connect,
-                              http_parser_url *u);
-    
-    void http_parser_pause(http_parser *parser, int paused);
 import std.socket : InternetAddress, TcpSocket;
+import std.stdio : writefln;
 import std.c.stdlib : EXIT_SUCCESS, EXIT_FAILURE;
 import std.array : appender;
 import std.typecons : Tuple;
 import std.string: format;
 import std.conv : to;
 import std.base64 : Base64;
-
 import net.http.parser;
 
-debug=loud;
-
-debug(info)
-{
-    import std.stdio;
-}
-
-debug(loud)
-{
-    import std.stdio;
-}
-
-debug(summary)
-{
-    import std.stdio;
-}
-
-debug(connection)
-{
-    import std.stdio;
-}
+//debug=connection;
 
 
 string b64encode(string input)
     return cast(string)Base64.decode(cast(ubyte[])input);
 }
 
+
 int main(string[] args)
 {
 
 
     string user_agent = "Mozilla/5.0 (X11; Linux i686) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.47 Safari/536.11";
     auto parser = new Parser;
+    auto address = new InternetAddress(c.domain, c.port);
 
-    debug(connection)
-    {
-        writefln("connecting to %s on port %d", c.domain, c.port);
-        writefln("url is %s", c.url);
-    }
-    
-    auto address = new InternetAddress(c.domain, c.port);
-    auto sock = new TcpSocket(address);
-
+    bool connected = false;
 
     scope(exit)
     {
-        sock.close();
         delete address;
-        delete sock;
-    }
-    
-    debug(connection) writefln("connected!");
-
-    // send the request
-
-    string request = format("GET %s HTTP/1.1\r\n"
-                            "Host: %s\r\n"
-                            "Authorization: Basic %s\r\n"
-                            "User-Agent: %s\r\n"
-                            "\r\n",
-                            c.url, c.domain, auth.encoded, user_agent);
-
-
-    auto response = appender!string();
-
-    debug(connection) writefln("sending:\n%s", request);
-
-    ptrdiff_t s;
-
-    s = sock.send(request);
-    
-    debug(connection) writefln("send len = %s, request len = %s", s, request.length);
-
-
-    string receive_buffer;
-    receive_buffer.length = 8192;
-
-
-    ptrdiff_t r;
-
-    while ((r = sock.receive(cast(void[])receive_buffer)) > 0)
-    {
-        response.put(receive_buffer[0 .. r]);
+        delete parser;
     }
 
-    debug(loud) writefln("received: %s", response.data.length);
+    try
+    {
+        debug(connection)
+        {
+            writefln("connecting to %s on port %d", c.domain, c.port);
+            writefln("url is %s", c.url);
+        }
 
+        auto sock = new TcpSocket(address);
+        scope(exit) sock.close();
 
-    // get the header
-    parser.parse(response.data);
+        connected=true;
 
-    debug(summary)
-    {
-        banner();
-        //writefln("content: %s", parser.content);
-        writefln("content_length: %s", parser.content_length);
-        writefln("headers: %s", parser.headers);
-        writefln("status: %s", parser.code);
+
+        debug(connection) writefln("connected!");
+
+        // send the request
+
+        string request = format("GET %s HTTP/1.1\r\n"
+                                "Host: %s\r\n"
+                                "Authorization: Basic %s\r\n"
+                                "User-Agent: %s\r\n"
+                                "\r\n",
+                                c.url, c.domain, auth.encoded, user_agent);
+
+
+        auto response = appender!string();
+
+        debug(connection) writefln("sending:\n%s", request);
+
+        ptrdiff_t s;
+
+        s = sock.send(request);
+        
+        debug(connection) writefln("send len = %s, request len = %s", s, request.length);
+
+
+        string receive_buffer;
+        receive_buffer.length = 8192;
+
+
+        ptrdiff_t r;
+
+        while ((r = sock.receive(cast(void[])receive_buffer)) > 0)
+        {
+            response.put(receive_buffer[0 .. r]);
+        }
+
+
+        // get the header
+        parser.parse(response.data);
+
+        debug(summary)
+        {
+            writefln("content_length: %s", parser.content_length);
+            writefln("headers: %s", parser.headers);
+            writefln("status: %s", parser.code);
+        }
+
+        if (parser.code != 200)
+            writefln(response.data);
 
     }
+    catch(Exception e)
+    {
+        writefln("connection failed: %s", e.msg);
+    }
 
-    if (parser.code != 200)
-        writeln(response.data);
-
-
-    return EXIT_SUCCESS;
+    return connected ? EXIT_SUCCESS : EXIT_FAILURE;
 }
 
-
-debug(info)
-{
-    void banner(string message = "main()", int len=42)
-    {
-        int line[];
-        line.length = len;
-
-        foreach(int x;line)
-            writef("-");
-
-        writef("\n");
-
-        writefln(message);
-
-        foreach(int x;line) writef("-");
-        writef("\n");
-    }
-}
-
-debug(summary)
-{
-    void banner(string message = "main()", int len=42)
-    {
-        int line[];
-        line.length = len;
-
-        foreach(int x;line)
-            writef("-");
-
-        writef("\n");
-
-        writefln(message);
-
-        foreach(int x;line) writef("-");
-        writef("\n");
-    }
-}

tmp.h

-# 1 "/home/jeremy/Desktop/repos/git/http-parser/http_parser.h"
-# 1 "<built-in>"
-# 1 "<command-line>"
-# 1 "/home/jeremy/Desktop/repos/git/http-parser/http_parser.h"
-# 30 "/home/jeremy/Desktop/repos/git/http-parser/http_parser.h"
-# 1 "/usr/include/i386-linux-gnu/sys/types.h" 1 3 4
-# 26 "/usr/include/i386-linux-gnu/sys/types.h" 3 4
-# 1 "/usr/include/features.h" 1 3 4
-# 324 "/usr/include/features.h" 3 4
-# 1 "/usr/include/i386-linux-gnu/bits/predefs.h" 1 3 4
-# 325 "/usr/include/features.h" 2 3 4
-# 357 "/usr/include/features.h" 3 4
-# 1 "/usr/include/i386-linux-gnu/sys/cdefs.h" 1 3 4
-# 378 "/usr/include/i386-linux-gnu/sys/cdefs.h" 3 4
-# 1 "/usr/include/i386-linux-gnu/bits/wordsize.h" 1 3 4
-# 379 "/usr/include/i386-linux-gnu/sys/cdefs.h" 2 3 4
-# 358 "/usr/include/features.h" 2 3 4
-# 389 "/usr/include/features.h" 3 4
-# 1 "/usr/include/i386-linux-gnu/gnu/stubs.h" 1 3 4
-
-
-
-# 1 "/usr/include/i386-linux-gnu/bits/wordsize.h" 1 3 4
-# 5 "/usr/include/i386-linux-gnu/gnu/stubs.h" 2 3 4
-
-
-# 1 "/usr/include/i386-linux-gnu/gnu/stubs-32.h" 1 3 4
-# 8 "/usr/include/i386-linux-gnu/gnu/stubs.h" 2 3 4
-# 390 "/usr/include/features.h" 2 3 4
-# 27 "/usr/include/i386-linux-gnu/sys/types.h" 2 3 4
-
-
-
-# 1 "/usr/include/i386-linux-gnu/bits/types.h" 1 3 4
-# 28 "/usr/include/i386-linux-gnu/bits/types.h" 3 4
-# 1 "/usr/include/i386-linux-gnu/bits/wordsize.h" 1 3 4
-# 29 "/usr/include/i386-linux-gnu/bits/types.h" 2 3 4
-
-
-typedef unsigned char __u_char;
-typedef unsigned short int __u_short;
-typedef unsigned int __u_int;
-typedef unsigned long int __u_long;
-
-
-typedef signed char __int8_t;
-typedef unsigned char __uint8_t;
-typedef signed short int __int16_t;
-typedef unsigned short int __uint16_t;
-typedef signed int __int32_t;
-typedef unsigned int __uint32_t;
-
-
-
-
-__extension__ typedef signed long long int __int64_t;
-__extension__ typedef unsigned long long int __uint64_t;
-
-
-
-
-
-
-
-__extension__ typedef long long int __quad_t;
-__extension__ typedef unsigned long long int __u_quad_t;
-# 131 "/usr/include/i386-linux-gnu/bits/types.h" 3 4
-# 1 "/usr/include/i386-linux-gnu/bits/typesizes.h" 1 3 4
-# 132 "/usr/include/i386-linux-gnu/bits/types.h" 2 3 4
-
-
-__extension__ typedef __u_quad_t __dev_t;
-__extension__ typedef unsigned int __uid_t;
-__extension__ typedef unsigned int __gid_t;
-__extension__ typedef unsigned long int __ino_t;
-__extension__ typedef __u_quad_t __ino64_t;
-__extension__ typedef unsigned int __mode_t;
-__extension__ typedef unsigned int __nlink_t;
-__extension__ typedef long int __off_t;
-__extension__ typedef __quad_t __off64_t;
-__extension__ typedef int __pid_t;
-__extension__ typedef struct { int __val[2]; } __fsid_t;
-__extension__ typedef long int __clock_t;
-__extension__ typedef unsigned long int __rlim_t;
-__extension__ typedef __u_quad_t __rlim64_t;
-__extension__ typedef unsigned int __id_t;
-__extension__ typedef long int __time_t;
-__extension__ typedef unsigned int __useconds_t;
-__extension__ typedef long int __suseconds_t;
-
-__extension__ typedef int __daddr_t;
-__extension__ typedef long int __swblk_t;
-__extension__ typedef int __key_t;
-
-
-__extension__ typedef int __clockid_t;
-
-
-__extension__ typedef void * __timer_t;
-
-
-__extension__ typedef long int __blksize_t;
-
-
-
-
-__extension__ typedef long int __blkcnt_t;
-__extension__ typedef __quad_t __blkcnt64_t;
-
-
-__extension__ typedef unsigned long int __fsblkcnt_t;
-__extension__ typedef __u_quad_t __fsblkcnt64_t;
-
-
-__extension__ typedef unsigned long int __fsfilcnt_t;
-__extension__ typedef __u_quad_t __fsfilcnt64_t;
-
-__extension__ typedef int __ssize_t;
-
-
-
-typedef __off64_t __loff_t;
-typedef __quad_t *__qaddr_t;
-typedef char *__caddr_t;
-
-
-__extension__ typedef int __intptr_t;
-
-
-__extension__ typedef unsigned int __socklen_t;
-# 31 "/usr/include/i386-linux-gnu/sys/types.h" 2 3 4
-
-
-
-typedef __u_char u_char;
-typedef __u_short u_short;
-typedef __u_int u_int;
-typedef __u_long u_long;
-typedef __quad_t quad_t;
-typedef __u_quad_t u_quad_t;
-typedef __fsid_t fsid_t;
-
-
-
-
-typedef __loff_t loff_t;
-
-
-
-typedef __ino_t ino_t;
-# 61 "/usr/include/i386-linux-gnu/sys/types.h" 3 4
-typedef __dev_t dev_t;
-
-
-
-
-typedef __gid_t gid_t;
-
-
-
-
-typedef __mode_t mode_t;
-
-
-
-
-typedef __nlink_t nlink_t;
-
-
-
-
-typedef __uid_t uid_t;
-
-
-
-
-
-typedef __off_t off_t;
-# 99 "/usr/include/i386-linux-gnu/sys/types.h" 3 4
-typedef __pid_t pid_t;
-
-
-
-
-
-typedef __id_t id_t;
-
-
-
-
-typedef __ssize_t ssize_t;
-
-
-
-
-
-typedef __daddr_t daddr_t;
-typedef __caddr_t caddr_t;
-
-
-
-
-
-typedef __key_t key_t;
-# 133 "/usr/include/i386-linux-gnu/sys/types.h" 3 4
-# 1 "/usr/include/time.h" 1 3 4
-# 58 "/usr/include/time.h" 3 4
-
-
-typedef __clock_t clock_t;
-
-
-
-# 74 "/usr/include/time.h" 3 4
-
-
-typedef __time_t time_t;
-
-
-
-# 92 "/usr/include/time.h" 3 4
-typedef __clockid_t clockid_t;
-# 104 "/usr/include/time.h" 3 4
-typedef __timer_t timer_t;
-# 134 "/usr/include/i386-linux-gnu/sys/types.h" 2 3 4
-# 147 "/usr/include/i386-linux-gnu/sys/types.h" 3 4
-# 1 "/usr/lib/gcc/i686-linux-gnu/4.6/include/stddef.h" 1 3 4
-# 212 "/usr/lib/gcc/i686-linux-gnu/4.6/include/stddef.h" 3 4
-typedef unsigned int size_t;
-# 148 "/usr/include/i386-linux-gnu/sys/types.h" 2 3 4
-
-
-
-typedef unsigned long int ulong;
-typedef unsigned short int ushort;
-typedef unsigned int uint;
-# 195 "/usr/include/i386-linux-gnu/sys/types.h" 3 4
-typedef int int8_t __attribute__ ((__mode__ (__QI__)));
-typedef int int16_t __attribute__ ((__mode__ (__HI__)));
-typedef int int32_t __attribute__ ((__mode__ (__SI__)));
-typedef int int64_t __attribute__ ((__mode__ (__DI__)));
-
-
-typedef unsigned int u_int8_t __attribute__ ((__mode__ (__QI__)));
-typedef unsigned int u_int16_t __attribute__ ((__mode__ (__HI__)));
-typedef unsigned int u_int32_t __attribute__ ((__mode__ (__SI__)));
-typedef unsigned int u_int64_t __attribute__ ((__mode__ (__DI__)));
-
-typedef int register_t __attribute__ ((__mode__ (__word__)));
-# 217 "/usr/include/i386-linux-gnu/sys/types.h" 3 4
-# 1 "/usr/include/endian.h" 1 3 4
-# 37 "/usr/include/endian.h" 3 4
-# 1 "/usr/include/i386-linux-gnu/bits/endian.h" 1 3 4
-# 38 "/usr/include/endian.h" 2 3 4
-# 61 "/usr/include/endian.h" 3 4
-# 1 "/usr/include/i386-linux-gnu/bits/byteswap.h" 1 3 4
-# 62 "/usr/include/endian.h" 2 3 4
-# 218 "/usr/include/i386-linux-gnu/sys/types.h" 2 3 4
-
-
-# 1 "/usr/include/i386-linux-gnu/sys/select.h" 1 3 4
-# 31 "/usr/include/i386-linux-gnu/sys/select.h" 3 4
-# 1 "/usr/include/i386-linux-gnu/bits/select.h" 1 3 4
-# 32 "/usr/include/i386-linux-gnu/sys/select.h" 2 3 4
-
-
-# 1 "/usr/include/i386-linux-gnu/bits/sigset.h" 1 3 4
-# 24 "/usr/include/i386-linux-gnu/bits/sigset.h" 3 4
-typedef int __sig_atomic_t;
-
-
-
-
-typedef struct
-  {
-    unsigned long int __val[(1024 / (8 * sizeof (unsigned long int)))];
-  } __sigset_t;
-# 35 "/usr/include/i386-linux-gnu/sys/select.h" 2 3 4
-
-
-
-typedef __sigset_t sigset_t;
-
-
-
-
-
-# 1 "/usr/include/time.h" 1 3 4
-# 120 "/usr/include/time.h" 3 4
-struct timespec
-  {
-    __time_t tv_sec;
-    long int tv_nsec;
-  };
-# 45 "/usr/include/i386-linux-gnu/sys/select.h" 2 3 4
-
-# 1 "/usr/include/i386-linux-gnu/bits/time.h" 1 3 4
-# 31 "/usr/include/i386-linux-gnu/bits/time.h" 3 4
-struct timeval
-  {
-    __time_t tv_sec;
-    __suseconds_t tv_usec;
-  };
-# 47 "/usr/include/i386-linux-gnu/sys/select.h" 2 3 4
-
-
-typedef __suseconds_t suseconds_t;
-
-
-
-
-
-typedef long int __fd_mask;
-# 65 "/usr/include/i386-linux-gnu/sys/select.h" 3 4
-typedef struct
-  {
-
-
-
-
-
-
-    __fd_mask __fds_bits[1024 / (8 * (int) sizeof (__fd_mask))];
-
-
-  } fd_set;
-
-
-
-
-
-
-typedef __fd_mask fd_mask;
-# 97 "/usr/include/i386-linux-gnu/sys/select.h" 3 4
-
-# 107 "/usr/include/i386-linux-gnu/sys/select.h" 3 4
-extern int select (int __nfds, fd_set *__restrict __readfds,
-     fd_set *__restrict __writefds,
-     fd_set *__restrict __exceptfds,
-     struct timeval *__restrict __timeout);
-# 119 "/usr/include/i386-linux-gnu/sys/select.h" 3 4
-extern int pselect (int __nfds, fd_set *__restrict __readfds,
-      fd_set *__restrict __writefds,
-      fd_set *__restrict __exceptfds,
-      const struct timespec *__restrict __timeout,
-      const __sigset_t *__restrict __sigmask);
-# 132 "/usr/include/i386-linux-gnu/sys/select.h" 3 4
-
-# 221 "/usr/include/i386-linux-gnu/sys/types.h" 2 3 4
-
-
-# 1 "/usr/include/i386-linux-gnu/sys/sysmacros.h" 1 3 4
-# 30 "/usr/include/i386-linux-gnu/sys/sysmacros.h" 3 4
-
-
-__extension__
-extern unsigned int gnu_dev_major (unsigned long long int __dev)
-     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
-__extension__
-extern unsigned int gnu_dev_minor (unsigned long long int __dev)
-     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
-__extension__
-extern unsigned long long int gnu_dev_makedev (unsigned int __major,
-            unsigned int __minor)
-     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
-# 64 "/usr/include/i386-linux-gnu/sys/sysmacros.h" 3 4
-
-# 224 "/usr/include/i386-linux-gnu/sys/types.h" 2 3 4
-
-
-
-
-
-typedef __blksize_t blksize_t;
-
-
-
-
-
-
-typedef __blkcnt_t blkcnt_t;
-
-
-
-typedef __fsblkcnt_t fsblkcnt_t;
-
-
-
-typedef __fsfilcnt_t fsfilcnt_t;
-# 271 "/usr/include/i386-linux-gnu/sys/types.h" 3 4
-# 1 "/usr/include/i386-linux-gnu/bits/pthreadtypes.h" 1 3 4
-# 36 "/usr/include/i386-linux-gnu/bits/pthreadtypes.h" 3 4
-typedef unsigned long int pthread_t;
-
-
-typedef union
-{
-  char __size[36];
-  long int __align;
-} pthread_attr_t;
-
-
-typedef struct __pthread_internal_slist
-{
-  struct __pthread_internal_slist *__next;
-} __pthread_slist_t;
-
-
-
-
-typedef union
-{
-  struct __pthread_mutex_s
-  {
-    int __lock;
-    unsigned int __count;
-    int __owner;
-
-
-    int __kind;
-    unsigned int __nusers;
-    __extension__ union
-    {
-      int __spins;
-      __pthread_slist_t __list;
-    };
-  } __data;
-  char __size[24];
-  long int __align;
-} pthread_mutex_t;
-
-typedef union
-{
-  char __size[4];
-  long int __align;
-} pthread_mutexattr_t;
-
-
-
-
-typedef union
-{
-  struct
-  {
-    int __lock;
-    unsigned int __futex;
-    __extension__ unsigned long long int __total_seq;
-    __extension__ unsigned long long int __wakeup_seq;
-    __extension__ unsigned long long int __woken_seq;
-    void *__mutex;
-    unsigned int __nwaiters;
-    unsigned int __broadcast_seq;
-  } __data;
-  char __size[48];
-  __extension__ long long int __align;
-} pthread_cond_t;
-
-typedef union
-{
-  char __size[4];
-  long int __align;
-} pthread_condattr_t;
-
-
-
-typedef unsigned int pthread_key_t;
-
-
-
-typedef int pthread_once_t;
-
-
-
-
-
-typedef union
-{
-  struct
-  {
-    int __lock;
-    unsigned int __nr_readers;
-    unsigned int __readers_wakeup;
-    unsigned int __writer_wakeup;
-    unsigned int __nr_readers_queued;
-    unsigned int __nr_writers_queued;
-
-
-    unsigned char __flags;
-    unsigned char __shared;
-    unsigned char __pad1;
-    unsigned char __pad2;
-    int __writer;
-  } __data;
-  char __size[32];
-  long int __align;
-} pthread_rwlock_t;
-
-typedef union
-{
-  char __size[8];
-  long int __align;
-} pthread_rwlockattr_t;
-
-
-
-
-
-typedef volatile int pthread_spinlock_t;
-
-
-
-
-typedef union
-{
-  char __size[20];
-  long int __align;
-} pthread_barrier_t;
-
-typedef union
-{
-  char __size[4];
-  int __align;
-} pthread_barrierattr_t;
-# 272 "/usr/include/i386-linux-gnu/sys/types.h" 2 3 4
-
-
-
-# 31 "/home/jeremy/Desktop/repos/git/http-parser/http_parser.h" 2
-# 44 "/home/jeremy/Desktop/repos/git/http-parser/http_parser.h"
-# 1 "/usr/lib/gcc/i686-linux-gnu/4.6/include/stdint.h" 1 3 4
-
-
-# 1 "/usr/include/stdint.h" 1 3 4
-# 27 "/usr/include/stdint.h" 3 4
-# 1 "/usr/include/i386-linux-gnu/bits/wchar.h" 1 3 4
-# 28 "/usr/include/stdint.h" 2 3 4
-# 1 "/usr/include/i386-linux-gnu/bits/wordsize.h" 1 3 4
-# 29 "/usr/include/stdint.h" 2 3 4
-# 49 "/usr/include/stdint.h" 3 4
-typedef unsigned char uint8_t;
-typedef unsigned short int uint16_t;
-
-typedef unsigned int uint32_t;
-
-
-
-
-
-__extension__
-typedef unsigned long long int uint64_t;
-
-
-
-
-
-
-typedef signed char int_least8_t;
-typedef short int int_least16_t;
-typedef int int_least32_t;
-
-
-
-__extension__
-typedef long long int int_least64_t;
-
-
-
-typedef unsigned char uint_least8_t;
-typedef unsigned short int uint_least16_t;
-typedef unsigned int uint_least32_t;
-
-
-
-__extension__
-typedef unsigned long long int uint_least64_t;
-
-
-
-
-
-
-typedef signed char int_fast8_t;
-
-
-
-
-
-typedef int int_fast16_t;
-typedef int int_fast32_t;
-__extension__
-typedef long long int int_fast64_t;
-
-
-
-typedef unsigned char uint_fast8_t;
-
-
-
-
-
-typedef unsigned int uint_fast16_t;
-typedef unsigned int uint_fast32_t;
-__extension__
-typedef unsigned long long int uint_fast64_t;
-# 126 "/usr/include/stdint.h" 3 4
-typedef int intptr_t;
-
-
-typedef unsigned int uintptr_t;
-# 138 "/usr/include/stdint.h" 3 4
-__extension__
-typedef long long int intmax_t;
-__extension__
-typedef unsigned long long int uintmax_t;
-# 4 "/usr/lib/gcc/i686-linux-gnu/4.6/include/stdint.h" 2 3 4
-# 45 "/home/jeremy/Desktop/repos/git/http-parser/http_parser.h" 2
-# 66 "/home/jeremy/Desktop/repos/git/http-parser/http_parser.h"
-typedef struct http_parser http_parser;
-typedef struct http_parser_settings http_parser_settings;
-# 83 "/home/jeremy/Desktop/repos/git/http-parser/http_parser.h"
-typedef int (*http_data_cb) (http_parser*, const char *at, size_t length);
-typedef int (*http_cb) (http_parser*);
-# 121 "/home/jeremy/Desktop/repos/git/http-parser/http_parser.h"
-enum http_method
-  {
-
-  HTTP_DELETE = 0, HTTP_GET = 1, HTTP_HEAD = 2, HTTP_POST = 3, HTTP_PUT = 4, HTTP_CONNECT = 5, HTTP_OPTIONS = 6, HTTP_TRACE = 7, HTTP_COPY = 8, HTTP_LOCK = 9, HTTP_MKCOL = 10, HTTP_MOVE = 11, HTTP_PROPFIND = 12, HTTP_PROPPATCH = 13, HTTP_SEARCH = 14, HTTP_UNLOCK = 15, HTTP_REPORT = 16, HTTP_MKACTIVITY = 17, HTTP_CHECKOUT = 18, HTTP_MERGE = 19, HTTP_MSEARCH = 20, HTTP_NOTIFY = 21, HTTP_SUBSCRIBE = 22, HTTP_UNSUBSCRIBE = 23, HTTP_PATCH = 24, HTTP_PURGE = 25,
-
-  };
-
-
-enum http_parser_type { HTTP_REQUEST, HTTP_RESPONSE, HTTP_BOTH };
-
-
-
-enum flags
-  { F_CHUNKED = 1 << 0
-  , F_CONNECTION_KEEP_ALIVE = 1 << 1
-  , F_CONNECTION_CLOSE = 1 << 2
-  , F_TRAILING = 1 << 3
-  , F_UPGRADE = 1 << 4
-  , F_SKIPBODY = 1 << 5
-  };
-# 190 "/home/jeremy/Desktop/repos/git/http-parser/http_parser.h"
-enum http_errno {
-  HPE_OK, HPE_CB_message_begin, HPE_CB_url, HPE_CB_header_field, HPE_CB_header_value, HPE_CB_headers_complete, HPE_CB_body, HPE_CB_message_complete, HPE_INVALID_EOF_STATE, HPE_HEADER_OVERFLOW, HPE_CLOSED_CONNECTION, HPE_INVALID_VERSION, HPE_INVALID_STATUS, HPE_INVALID_METHOD, HPE_INVALID_URL, HPE_INVALID_HOST, HPE_INVALID_PORT, HPE_INVALID_PATH, HPE_INVALID_QUERY_STRING, HPE_INVALID_FRAGMENT, HPE_LF_EXPECTED, HPE_INVALID_HEADER_TOKEN, HPE_INVALID_CONTENT_LENGTH, HPE_INVALID_CHUNK_SIZE, HPE_INVALID_CONSTANT, HPE_INVALID_INTERNAL_STATE, HPE_STRICT, HPE_PAUSED, HPE_UNKNOWN,
-};
-# 207 "/home/jeremy/Desktop/repos/git/http-parser/http_parser.h"
-struct http_parser {
-
-  unsigned char type : 2;
-  unsigned char flags : 6;
-  unsigned char state;
-  unsigned char header_state;
-  unsigned char index;
-
-  uint32_t nread;
-  uint64_t content_length;
-
-
-  unsigned short http_major;
-  unsigned short http_minor;
-  unsigned short status_code;
-  unsigned char method;
-  unsigned char http_errno : 7;
-
-
-
-
-
-
-  unsigned char upgrade : 1;
-
-
-
-
-
-
-  void *data;
-};
-
-
-struct http_parser_settings {
-  http_cb on_message_begin;
-  http_data_cb on_url;
-  http_data_cb on_header_field;
-  http_data_cb on_header_value;
-  http_cb on_headers_complete;
-  http_data_cb on_body;
-  http_cb on_message_complete;
-};
-
-
-enum http_parser_url_fields
-  { UF_SCHEMA = 0
-  , UF_HOST = 1
-  , UF_PORT = 2
-  , UF_PATH = 3
-  , UF_QUERY = 4
-  , UF_FRAGMENT = 5
-  , UF_MAX = 6
-  };
-# 270 "/home/jeremy/Desktop/repos/git/http-parser/http_parser.h"
-struct http_parser_url {
-  uint16_t field_set;
-  uint16_t port;
-
-  struct {
-    uint16_t off;
-    uint16_t len;
-  } field_data[UF_MAX];
-};
-
-
-void http_parser_init(http_parser *parser, enum http_parser_type type);
-
-
-size_t http_parser_execute(http_parser *parser,
-                           const http_parser_settings *settings,
-                           const char *data,
-                           size_t len);
-# 296 "/home/jeremy/Desktop/repos/git/http-parser/http_parser.h"
-int http_should_keep_alive(http_parser *parser);
-
-
-const char *http_method_str(enum http_method m);
-
-
-const char *http_errno_name(enum http_errno err);
-
-
-const char *http_errno_description(enum http_errno err);
-
-
-int http_parser_parse_url(const char *buf, size_t buflen,
-                          int is_connect,
-                          struct http_parser_url *u);
-
-
-void http_parser_pause(http_parser *parser, int paused);

util.d

-/*
-* Borrowed from  git://github.com/D-Programming-Deimos/libevent.git
-*/
-module util;
-
-public import core.stdc.config;
-
-//package:
-
-bool pointsTo(S, T)(ref S source, ref T target);
-
-
-
-
-
-template ExternC(T) if (is(typeof(*(T.init)) P == function)) {
-    static if (is(typeof(*(T.init)) R == return)) {
-        static if (is(typeof(*(T.init)) P == function)) {
-            alias extern(C) R function(P) ExternC;
-        }
-    }
-}