mirror of
https://github.com/cesanta/mongoose.git
synced 2025-01-16 20:41:20 +08:00
Moved file send_file example to separate dir
This commit is contained in:
parent
8a3691055c
commit
ceca52de30
19
examples/send_file/Makefile
Normal file
19
examples/send_file/Makefile
Normal file
@ -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*
|
@ -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"
|
#include "mongoose.h"
|
||||||
|
|
||||||
static int ev_handler(struct mg_connection *conn, enum mg_event ev) {
|
static int ev_handler(struct mg_connection *conn, enum mg_event ev) {
|
||||||
switch (ev) {
|
switch (ev) {
|
||||||
case MG_REQUEST:
|
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!
|
return MG_MORE; // It is important to return MG_MORE after mg_send_file!
|
||||||
case MG_AUTH: return MG_TRUE;
|
case MG_AUTH: return MG_TRUE;
|
||||||
default: return MG_FALSE;
|
default: return MG_FALSE;
|
Loading…
x
Reference in New Issue
Block a user