From ceca52de302bfb5e116210496042008006edac5d Mon Sep 17 00:00:00 2001 From: Sergey Lyubka Date: Tue, 9 Sep 2014 23:23:29 +0100 Subject: [PATCH] Moved file send_file example to separate dir --- examples/send_file/Makefile | 19 +++++++++++++++++++ examples/{file.c => send_file/send_file.c} | 9 +++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 examples/send_file/Makefile rename examples/{file.c => send_file/send_file.c} (72%) diff --git a/examples/send_file/Makefile b/examples/send_file/Makefile new file mode 100644 index 00000000..3793867e --- /dev/null +++ b/examples/send_file/Makefile @@ -0,0 +1,19 @@ +# Copyright (c) 2014 Cesanta Software +# All rights reserved + +PROG = send_file +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/file.c b/examples/send_file/send_file.c similarity index 72% rename from examples/file.c rename to examples/send_file/send_file.c index 025060eb..ddb9350a 100644 --- a/examples/file.c +++ b/examples/send_file/send_file.c @@ -1,9 +1,14 @@ +// Copyright (c) 2014 Cesanta Software +// All rights reserved +// +// This example demostrates how to send arbitrary files to the client. + #include "mongoose.h" static int ev_handler(struct mg_connection *conn, enum mg_event ev) { switch (ev) { case MG_REQUEST: - mg_send_file(conn, "file.c"); + mg_send_file(conn, "send_file.c"); // Also could be a directory, or CGI file return MG_MORE; // It is important to return MG_MORE after mg_send_file! case MG_AUTH: return MG_TRUE; default: return MG_FALSE; @@ -19,4 +24,4 @@ int main(void) { mg_destroy_server(&server); return 0; -} \ No newline at end of file +}