The use of LIBHTTPD

Source: Internet
Author: User
Tags html header response code strcmp

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, "

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.