From f372faf6144d36b690e9d7d56e4d7f55bf4341e0 Mon Sep 17 00:00:00 2001 From: Sergey Lyubka <valenok@gmail.com> Date: Tue, 9 Sep 2014 22:44:57 +0100 Subject: [PATCH] Moved hello.c example to its own dir --- examples/hello_world/Makefile | 19 +++++++++++++++++++ .../{hello.c => hello_world/hello_world.c} | 15 ++++++--------- 2 files changed, 25 insertions(+), 9 deletions(-) create mode 100644 examples/hello_world/Makefile rename examples/{hello.c => hello_world/hello_world.c} (73%) diff --git a/examples/hello_world/Makefile b/examples/hello_world/Makefile new file mode 100644 index 000000000..c2c836bbe --- /dev/null +++ b/examples/hello_world/Makefile @@ -0,0 +1,19 @@ +# Copyright (c) 2014 Cesanta Software +# All rights reserved + +PROG = hello_world +CFLAGS = -W -Wall -I../.. $(CFLAGS_EXTRA) +SOURCES = $(PROG).c ../../mongoose.c + +all: $(PROG) + ./$(PROG) + +$(PROG): $(SOURCES) Makefile + $(CC) -o $(PROG) $(SOURCES) $(CFLAGS) + +win: + wine cl $(SOURCES) /MD /nologo /DNDEBUG /O1 /I../.. /Fe$(PROG).exe + wine $(PROG).exe + +clean: + rm -rf $(PROG) *.exe *.dSYM *.obj *.exp .*o *.lib *.gc* diff --git a/examples/hello.c b/examples/hello_world/hello_world.c similarity index 73% rename from examples/hello.c rename to examples/hello_world/hello_world.c index 00423db92..d985ce135 100644 --- a/examples/hello.c +++ b/examples/hello_world/hello_world.c @@ -3,16 +3,13 @@ #include "mongoose.h" static int ev_handler(struct mg_connection *conn, enum mg_event ev) { - int result = MG_FALSE; - - if (ev == MG_REQUEST) { - mg_printf_data(conn, "Hello! Requested URI is [%s]", conn->uri); - result = MG_TRUE; - } else if (ev == MG_AUTH) { - result = MG_TRUE; + switch (ev) { + case MG_AUTH: return MG_TRUE; + case MG_REQUEST: + mg_printf_data(conn, "Hello! Requested URI is [%s]", conn->uri); + return MG_TRUE; + default: return MG_FALSE; } - - return result; } int main(void) { -- GitLab