diff --git a/examples/hello/Makefile b/examples/hello/Makefile index 4424e3b5..3e5b7e71 100644 --- a/examples/hello/Makefile +++ b/examples/hello/Makefile @@ -1,4 +1,4 @@ -# +# # Copyright (c) 2013 No Face Press, LLC # License http://opensource.org/licenses/mit-license.php MIT License # @@ -10,27 +10,27 @@ PROG = hello SRC = hello.c TOP = ../.. -CIVETWEB_LIB = libcivetweb.a +HTTP_LIB = libhttp.a CFLAGS = -I$(TOP)/include $(COPT) LIBS = -lpthread include $(TOP)/resources/Makefile.in-os -ifeq ($(TARGET_OS),LINUX) +ifeq ($(TARGET_OS),LINUX) LIBS += -ldl endif all: $(PROG) -$(PROG): $(CIVETWEB_LIB) $(SRC) - $(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(SRC) $(CIVETWEB_LIB) $(LIBS) +$(PROG): $(HTTP_LIB) $(SRC) + $(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(SRC) $(HTTP_LIB) $(LIBS) -$(CIVETWEB_LIB): - $(MAKE) -C $(TOP) clean lib - cp $(TOP)/$(CIVETWEB_LIB) . +$(HTTP_LIB): + $(MAKE) -C $(TOP) + cp $(TOP)/lib/$(HTTP_LIB) . clean: - rm -f $(CIVETWEB_LIB) $(PROG) + rm -f $(HTTP_LIB) $(PROG) .PHONY: all clean diff --git a/examples/hello/hello.c b/examples/hello/hello.c index a77af2ec..09000d95 100644 --- a/examples/hello/hello.c +++ b/examples/hello/hello.c @@ -1,11 +1,11 @@ #include #include -#include "civetweb.h" +#include "libhttp.h" -// This function will be called by civetweb on every new request. -static int begin_request_handler(struct httplib_connection *conn) +// This function will be called by libhttp on every new request. +static int begin_request_handler(struct lh_ctx_t *ctx, struct lh_con_t *conn) { - const struct httplib_request_info *request_info = httplib_get_request_info(conn); + const struct lh_rqi_t *request_info = httplib_get_request_info(conn); char content[100]; // Prepare the message we're going to send @@ -14,7 +14,7 @@ static int begin_request_handler(struct httplib_connection *conn) request_info->remote_port); // Send HTTP reply to the client - httplib_printf(conn, + httplib_printf(ctx,conn, "HTTP/1.1 200 OK\r\n" "Content-Type: text/plain\r\n" "Content-Length: %d\r\n" // Always set Content-Length @@ -22,18 +22,18 @@ static int begin_request_handler(struct httplib_connection *conn) "%s", content_length, content); - // Returning non-zero tells civetweb that our function has replied to - // the client, and civetweb should not send client any more data. + // Returning non-zero tells libhttp that our function has replied to + // the client, and libhttp should not send client any more data. return 1; } int main(void) { - struct httplib_context *ctx; - struct httplib_callbacks callbacks; + struct lh_ctx_t *ctx; + struct lh_clb_t callbacks; // List of options. Last element must be NULL. - const char *options[] = {"listening_ports", "8080", NULL}; + struct lh_opt_t options[] = {(struct lh_opt_t){"listening_ports","8080"},{NULL}}; // Prepare callbacks structure. We have only one callback, the rest are NULL. memset(&callbacks, 0, sizeof(callbacks));