From 8a3c72fdaabdc8c565a8c91361a2f8d38c892e1e Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Fri, 26 Aug 2016 18:51:11 -0400 Subject: initial commit --- test.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 test.c (limited to 'test.c') diff --git a/test.c b/test.c new file mode 100644 index 0000000..3d16363 --- /dev/null +++ b/test.c @@ -0,0 +1,59 @@ +#include +#include +#include +#include +#include + +#define UNUSED(a) ((void) (a)) + +static const char * +str_test_basic = + "GET / HTTP/1.1\r\n" + "Host: pablotron.org\r\n" + "Connection: close\r\n" + "\r\n"; + +static bool +test_basic_cb( + fhp_t *fhp, + fhp_token_t token, + uint8_t * const buf, + size_t len +) { + UNUSED(fhp); + UNUSED(buf); + + fprintf(stderr, "test_basic_cb(): token = %u, len = %lu\n", token, len); + + // return success + return true; +} + +static void +test_basic(void) { + char buf[1024]; + fhp_err_t err; + fhp_t fhp; + + if ((err = fhp_init(&fhp, test_basic_cb, NULL)) != FHP_OK) { + fhp_strerror(err, buf, sizeof(buf)); + fprintf(stderr, "ERROR: fhp_init(): %s\n", buf); + exit(EXIT_FAILURE); + } + + size_t len = strlen(str_test_basic); + if ((err = fhp_push(&fhp, (uint8_t*) str_test_basic, len)) != FHP_OK) { + fhp_strerror(err, buf, sizeof(buf)); + fprintf(stderr, "ERROR: fhp_push(): %s\n", buf); + exit(EXIT_FAILURE); + } +} + +int main(int argc, char *argv[]) { + UNUSED(argc); + UNUSED(argv); + + test_basic(); + + return EXIT_SUCCESS; +} -- cgit v1.2.3