webserver.h
/**************************************************************************
*
* Copyright (c) 2000-2003 Intel Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* - Neither name of Intel Corporation nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
**************************************************************************/
#ifndef GENLIB_NET_HTTP_WEBSERVER_H
#define GENLIB_NET_HTTP_WEBSERVER_H
#include "httpparser.h"
#include "sock.h"
#include <time.h>
#ifdef __cplusplus
extern "C" {
#endif
struct SendInstruction
{
int IsVirtualFile;
int IsChunkActive;
int IsRangeActive;
int IsTrailers;
char RangeHeader[200];
char AcceptLanguageHeader[200];
off_t RangeOffset;
off_t ReadSendSize;
long RecvWriteSize;
const void *CorsHeader;
const void *Cookie;
const void *RequestCookie;
/* Later few more member could be added depending
* on the requirement.*/
};
int web_server_init(void);
void web_server_destroy(void);
int web_server_set_alias(
const char *alias_name,
const char *alias_content,
size_t alias_content_length,
time_t last_modified);
int web_server_set_root_dir(
const char *root_dir);
int web_server_set_cors(
const char *cors_string);
void web_server_callback(
http_parser_t *parser,
http_message_t *req,
SOCKINFO *info);
#ifdef __cplusplus
} /* extern C */
#endif
#endif /* GENLIB_NET_HTTP_WEBSERVER_H */
httpparser.h
sock.h
SOCKINFO
Definition sock.h:60
SendInstruction
Definition webserver.h:44
SendInstruction::CorsHeader
const void * CorsHeader
Definition webserver.h:57
SendInstruction::RecvWriteSize
long RecvWriteSize
Definition webserver.h:55
SendInstruction::ReadSendSize
off_t ReadSendSize
Definition webserver.h:53
SendInstruction::RequestCookie
const void * RequestCookie
Definition webserver.h:61
SendInstruction::Cookie
const void * Cookie
Definition webserver.h:59
http_message_t
Definition httpparser.h:182
http_parser_t
Definition httpparser.h:217
web_server_init
int web_server_init()
Initilialize the different documents. Initialize the memory for root directory for web server....
Definition webserver.c:472
web_server_set_root_dir
int web_server_set_root_dir(const char *root_dir)
Assign the path specfied by the input const char* root_dir parameter to the global Document root dire...
Definition webserver.c:595
web_server_set_cors
int web_server_set_cors(const char *cors_string)
Assign the Access-Control-Allow-Origin specfied by the input const char* cors_string parameterto the ...
Definition webserver.c:613
web_server_destroy
void web_server_destroy(void)
Release memory allocated for the global web server root directory and the global XML document....
Definition webserver.c:501
web_server_set_alias
int web_server_set_alias(const char *alias_name, const char *alias_content, size_t alias_content_length, time_t last_modified)
Replaces current alias with the given alias. To remove the current alias, set alias_name to NULL.
Definition webserver.c:424
web_server_callback
void web_server_callback(http_parser_t *parser, http_message_t *req, SOCKINFO *info)
Main entry point into web server; Handles HTTP GET and HEAD requests.
Definition webserver.c:1723