Add function http_parser_version().

Fixes #115.
make-http-max-header-size-gyp-configurable
Ben Noordhuis 12 years ago
parent 6df37aa52d
commit d3264312e1

@ -2173,3 +2173,10 @@ int
http_body_is_final(const struct http_parser *parser) {
return parser->state == s_message_done;
}
unsigned long
http_parser_version(void) {
return HTTP_PARSER_VERSION_MAJOR * 0x10000 |
HTTP_PARSER_VERSION_MINOR * 0x00100 |
HTTP_PARSER_VERSION_PATCH * 0x00001;
}

@ -27,6 +27,7 @@ extern "C" {
/* Also update SONAME in the Makefile whenever you change these. */
#define HTTP_PARSER_VERSION_MAJOR 2
#define HTTP_PARSER_VERSION_MINOR 1
#define HTTP_PARSER_VERSION_PATCH 0
#include <sys/types.h>
#if defined(_WIN32) && !defined(__MINGW32__) && (!defined(_MSC_VER) || _MSC_VER<1600)
@ -262,6 +263,18 @@ struct http_parser_url {
};
/* Returns the library version. Bits 16-23 contain the major version number,
* bits 8-15 the minor version number and bits 0-7 the patch level.
* Usage example:
*
* unsigned long version = http_parser_version();
* unsigned major = (version >> 16) & 255;
* unsigned minor = (version >> 8) & 255;
* unsigned patch = version & 255;
* printf("http_parser v%u.%u.%u\n", major, minor, version);
*/
unsigned long http_parser_version(void);
void http_parser_init(http_parser *parser, enum http_parser_type type);

@ -3170,6 +3170,16 @@ main (void)
int i, j, k;
int request_count;
int response_count;
unsigned long version;
unsigned major;
unsigned minor;
unsigned patch;
version = http_parser_version();
major = (version >> 16) & 255;
minor = (version >> 8) & 255;
patch = version & 255;
printf("http_parser v%u.%u.%u (0x%06lx)\n", major, minor, patch, version);
printf("sizeof(http_parser) = %u\n", (unsigned int)sizeof(http_parser));

Loading…
Cancel
Save