send_file.c
Go to the documentation of this file.
00001 // Copyright (c) 2014 Cesanta Software
00002 // All rights reserved
00003 //
00004 // This example demostrates how to send arbitrary files to the client.
00005 
00006 #include "mongoose.h"
00007 
00008 static int ev_handler(struct mg_connection *conn, enum mg_event ev) {
00009   switch (ev) {
00010     case MG_REQUEST:
00011       mg_send_file(conn, "send_file.c", NULL);  // Also could be a dir, or CGI
00012       return MG_MORE; // It is important to return MG_MORE after mg_send_file!
00013     case MG_AUTH: return MG_TRUE;
00014     default: return MG_FALSE;
00015   }
00016 }
00017 
00018 int main(void) {
00019   struct mg_server *server = mg_create_server(NULL, ev_handler);
00020   mg_set_option(server, "listening_port", "8080");
00021 
00022   printf("Starting on port %s\n", mg_get_option(server, "listening_port"));
00023   for (;;) mg_poll_server(server, 1000);
00024   mg_destroy_server(&server);
00025 
00026   return 0;
00027 }


rc_visard_driver
Author(s): Heiko Hirschmueller , Christian Emmerich , Felix Ruess
autogenerated on Thu Jun 6 2019 20:43:06