LIBHTTPD is an open source lightweight embedded web server,libhttpd that implements a subset of HTTP, uses tabular technology to automate HTML form data, and produces content that can be either static or dynamically generated by invoking a C function ( callback); LIBHTTPD provides APIs that allow users to easily add their Web content to the program.
LIBHTTPD in English with the use of the manual, but also increased the use of instance source code, in the programming can make a good template:
#include "config.h" #include <stdio.h> #include <unistd.h> #include <signal.h> #ifdef _WIN32 # includ E <getopt.h> #else # include <sys/time.h> #endif #include ' httpd.h ' * * * * * * * * * * * * * *.
It is loaded into the content * * tree using httpdaddstaticcontent (). */#define test1_html '
The following is reproduced in the web blog about the function of LIBHTTPD interface functions, more detailed function features see LIBHTTPD manual:
----------------------------------------------------------------------------------httpdcreate () Create a Web server httpd *
Httpdcreate (host, Port) char * Host int Port example:server = httpdcreate ("192.168.1.1", Http_port);
if (server = = NULL) perror ("couldn ' t create HTTP server");
Server2 = Httpdcreate (NULL, 2048); ------------------------------------------------------------------------------------Httpdsetaccesslog ()
Set access log files Httpdsetaccesslog (server, FP) httpd *server;
FILE *FP;
EXAMPLE:FP = fopen ("/tmp/access.log", "a");
Httpdsetaccesslog (server, FP); --------------------------------------------------------------------Httpdseterrorlog () to set the error log file Httpdseterrorlog
(server, FP) httpd *server;
FILE *FP;
Example:httpdseterrorlog (server, stderr);
------------------------------------------------------------------------Httpdsetfilebase () to set the file base path name
Httpdseterrorlog (server, path) httpd *server;
Char *path; ExampLe:httpdsetfilebase (server, "/usr/local/www-pages");
------------------------------------------------------------------------httpdaddccontent () calls the C function to produce output
Httpdaddccontent (server, dir, name, Indexflag, preload, functptr) httpd *server;
Char *dir, *name;
int Indexflag, (*) () preload;
void (*) () functptr;
Example:void Index_callbackl (server) httpd *server;
{httpdoutput (server, "