naett.c

Tiny cross-platform HTTP / HTTPS client library in C.
git clone git://git.finwo.net/lib/naett.c
Log | Files | Refs | README | LICENSE

commit ecca78319fea82a868e9ef745d8c13168b2e8a29
parent 703a562dc80252f42275bd3c2ec934484b980d6b
Author: Erik Agsjö <erik.agsjo@gmail.com>
Date:   Wed, 10 Nov 2021 22:27:11 +0100

More warnings and a bugfix

Diffstat:
MMakefile | 2+-
Mmain.c | 3++-
Mnaett.c | 8++++----
3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/Makefile b/Makefile @@ -1,4 +1,4 @@ -CFLAGS = -g +CFLAGS = -g -Wall -pedantic -Wno-gnu-zero-variadic-macro-arguments #CFLAGS = -O2 ifeq ($(OS),Windows_NT) diff --git a/main.c b/main.c @@ -12,5 +12,6 @@ int main(int argc, char** argv) { int bodyLength = 0; const char* body = naettGetBody(res, &bodyLength); - printf("Got %d bytes of type %s\n", bodyLength, naettGetHeader(res, "content-type")); + printf("Got %d bytes of type '%s':\n", bodyLength, naettGetHeader(res, "Content-Type")); + printf("%.100s\n...\n", body); } diff --git a/naett.c b/naett.c @@ -156,11 +156,11 @@ naettOption* naettBodyReader(naettReadFunc reader, void* userData) { InternalParam* readerParam = &option->params[0]; InternalParam* dataParam = &option->params[1]; - readerParam->ptr = reader; + readerParam->ptr = (void*) reader; readerParam->offset = offsetof(RequestOptions, bodyReader); readerParam->setter = ptrSetter; - dataParam->ptr = reader; + dataParam->ptr = userData; dataParam->offset = offsetof(RequestOptions, bodyReaderData); dataParam->setter = ptrSetter; @@ -174,11 +174,11 @@ naettOption* naettBodyWriter(naettWriteFunc writer, void* userData) { InternalParam* writerParam = &option->params[0]; InternalParam* dataParam = &option->params[1]; - writerParam->ptr = writer; + writerParam->ptr = (void*) writer; writerParam->offset = offsetof(RequestOptions, bodyWriter); writerParam->setter = ptrSetter; - dataParam->ptr = writer; + dataParam->ptr = userData; dataParam->offset = offsetof(RequestOptions, bodyWriterData); dataParam->setter = ptrSetter;