Dallas Semiconductor DS80C400 C Libraries Home Page

Main Page   Data Structures   File List   Data Fields   Globals  

rom400_http.h File Reference


Detailed Description

Http Server functions in the DS80C400 ROM.

This library contains functions for implementing http server in DS80C400 ROM

For detailed information on the DS80C400 please see the High-Speed Microcontroller User's Guide: DS80C400 Supplement.

Warning:
Some functions in this library are NOT multi-process safe--that is, if you call the same method from two different processes at the same time, the parameters to the function may be destroyed, yielding unpredictable results. Consult each individual funtion's documentation for details on which functions are multi-process safe.

Go to the source code of this file.

Data Structures

struct  _http_request
struct  _http_response
struct  _http_session
struct  _http_variable

Defines

#define HTTP_VERSION   3
#define HTTP_INSUFFICIENT_MEMORY   -1
#define HTTP_LOGFILE_ERROR   -2
#define HTTP_SOCKET_ERROR   -3
#define HTTP_REQUEST_NOT_PROCESSED   -4
#define HTTP_DENY_CONNECTION   -5
#define HTTP_TASK_ERROR   -6
#define HTTP_SERVER_ALREADY_RUNNING   -7
#define HTTP_NOSERVERTASK   -8
#define HTTP_STATUS_SUCCESS   0
#define HTTP_DISABLE_LOG   0
#define HTTP_ENABLE_LOG   1
#define HTTP_ENABLE_VARIABLE_PARSING   1
#define HTTP_DISABLE_VARIABLE_PARSING   0
#define HTTP_STOP_SERVERTASK   0
#define HTTP_RUN_SERVERTASK   1
#define DEFAULT_BUF_SIZE   400
#define DEFAULT_MAX_PENDING_CONNECIONS   5
#define HTTP_DEFAULT_PORT   80
#define HTTP_MAX_URL   400
#define HTTP_MAX_BUFSIZE   400
#define HTTP_GET_METHOD   1
#define HTTP_POST_METHOD   2
#define HTTP_HEAD_METHOD   3

Typedefs

typedef _http_variable http_variable
typedef _http_request http_request
typedef _http_response http_response
typedef _http_session http_session

Functions

unsigned int http_version (void)
 Returns the version number of http server library.

int http_init (struct sockaddr server_addr)
 Initializes http server library.

int http_setrootdir (char *rootdir)
 Sets http root directory.

char * http_getrootdir (void)
 Returns http root directory.

int http_setindexpage (char *index)
 Sets index page name.

char * http_getindexpage (void)
 Returns current index page.

void http_setportnumber (int portnumber)
 Sets HTTP Server Port number.

int http_getportnumber (void)
 Returns current http server port number.

void http_setheaderbufsize (int buffersize)
 Sets header buffer size.

int http_getheaderbufsize (void)
 Returns header buffer size.

void http_set_req_linesize (int buffersize)
 Sets the maximum size value of each line of http request.

int http_get_req_linesize (void)
 Returns the maximum size value of each line of http request.

void http_set_req_process_options (char flag)
 Sets Http request Variable parsing status flag value.

char http_get_req_process_options (void)
 Returns Http request Variable parsing status flag value.

int http_getlogging (void)
 Returns logging status.

int http_setlogging (char logstatus)
 Sets logging status.

char * http_getlogfilename (void)
 Returns log file name.

int http_setlogfilename (char *logfilename)
 Sets log file name.

void http_setmaxconnections (int max_connection)
 Sets maximum number of pending connections value.

int http_getmaxconnections (void)
 Returns the current value for maximum number of pending connections.

void http_setclientsocktimeout (long milli_sec)
 Sets http client socket timeout value.

long http_getclientsocktimeout (void)
 Returns the current value for http client socket timeout.

void http_reg_req_callback (int(*func)())
 Registers callback function to process http request.

void http_reg_acl_callback (int(*func)())
 Registers access control callback function.

void http_sendheaders (http_session *https)
 Sends http response headers to client.

int http_start_server (void)
 Starts http server.

int http_kill_server (void)
 Terminates http server.

void http_decode_urlencodeddata (char *pathname)
 Decodes the url path which was encoded in "application/x-www-form-urlencoded" format.

char http_hex_from_ascii (char c)
 Returns hexadecimal value for input ascii digit.

int http_change_server_state (char server_state)
 Changes Http Server state.


Define Documentation

#define DEFAULT_BUF_SIZE   400
 

Define for default header buffer size

See also:
http_getheaderbufsize

http_setheaderbufsize

#define DEFAULT_MAX_PENDING_CONNECIONS   5
 

Define for default maximum pending connections allowed

See also:
http_setmaxconnections

http_getmaxconnections

#define HTTP_DEFAULT_PORT   80
 

Define for default http port number

See also:
http_getportnumber

http_setportnumber

#define HTTP_DENY_CONNECTION   -5
 

Error value to indicate that http client connection is denied by access control callback function

See also:
http_reg_acl_callback

#define HTTP_DISABLE_LOG   0
 

Define for disabling logging activity

See also:
http_setlogging

http_getlogging

#define HTTP_DISABLE_VARIABLE_PARSING   0
 

Define for disabling variable parsing status flag

See also:
http_set_req_process_options

http_get_req_process_options

#define HTTP_ENABLE_LOG   1
 

Define for enabling logging activity

See also:
http_setlogging

http_getlogging

#define HTTP_ENABLE_VARIABLE_PARSING   1
 

Define for enabling variable parsing status flag

See also:
http_set_req_process_options

http_get_req_process_options

#define HTTP_GET_METHOD   1
 

Get request method type

See also:
http_request

http_session

#define HTTP_HEAD_METHOD   3
 

Head request method type

See also:
http_request

http_session

#define HTTP_INSUFFICIENT_MEMORY   -1
 

Insufficient memory error value

See also:
http_setrootdir

http_setindexpage

http_setlogfilename

#define HTTP_LOGFILE_ERROR   -2
 

Error opening log file

See also:
http_setlogging

#define HTTP_MAX_BUFSIZE   400
 

Define for maximum buffer size

See also:
http_request

http_session

#define HTTP_MAX_URL   400
 

Define for maximum url path name size

See also:
http_request

http_session

#define HTTP_NOSERVERTASK   -8
 

Error value to indicate that http server task is not running

See also:
http_start_server

http_kill_server

http_change_server_state

#define HTTP_POST_METHOD   2
 

Post request method type

See also:
http_request

http_session

#define HTTP_REQUEST_NOT_PROCESSED   -4
 

Error value to indicate that http request was not processed by callback function

See also:
http_reg_req_callback

#define HTTP_RUN_SERVERTASK   1
 

Define for running http server task

See also:
http_change_server_state

#define HTTP_SERVER_ALREADY_RUNNING   -7
 

Error value to indicate that server is already running

See also:
http_start_server

#define HTTP_SOCKET_ERROR   -3
 

Socket error value

See also:
http_start_server

#define HTTP_STATUS_SUCCESS   0
 

Http Status Success value, this value is returned when operation is completed successfully

See also:
http_setrootdir

http_setindexpage

http_setlogfilename

http_start_server

#http_stop_server

#define HTTP_STOP_SERVERTASK   0
 

Define for stopping http server task

See also:
http_change_server_state

#define HTTP_TASK_ERROR   -6
 

New task creation error

See also:
http_start_server

#define HTTP_VERSION   3
 

Version number associated with this header file. Should be the same as the version number returned by the http_version function.

See also:
http_version


Typedef Documentation

typedef struct _http_request http_request
 

Structure for http request

typedef struct _http_response http_response
 

Structure for http response

typedef struct _http_session http_session
 

Structure for http session

typedef struct _http_variable http_variable
 

Structure for http variable names and values


Function Documentation

int http_change_server_state char    server_state
 

Changes Http Server state.

This function sets http server state

This function is safe to be called from multiple processes at the same time.

Parameters:
server_state Server state. Should be either HTTP_RUN_SERVERTASK or HTTP_STOP_SERVERTASK
Returns:
HTTP_STATUS_SUCCESS or HTTP_NOSERVERTASK

void http_decode_urlencodeddata char *    pathname
 

Decodes the url path which was encoded in "application/x-www-form-urlencoded" format.

This function decodes the url path which was encoded in "application/x-www-form-urlencoded" format.

This function is safe to be called from multiple processes at the same time.

Parameters:
pathname pointer to url path name

int http_get_req_linesize void   
 

Returns the maximum size value of each line of http request.

This function returns the maximum size value of each line of http request

This function is safe to be called from multiple processes at the same time.

Returns:
the maximum size value of each http request line

char http_get_req_process_options void   
 

Returns Http request Variable parsing status flag value.

This function is safe to be called from multiple processes at the same time.

Returns:
The variable parsing status flag value

long http_getclientsocktimeout void   
 

Returns the current value for http client socket timeout.

This function returns the current value for http client socket timeout

This function is safe to be called from multiple processes at the same time.

Returns:
The current value for http client socket timeout

int http_getheaderbufsize void   
 

Returns header buffer size.

This function returns buffer size value for http request and response headers.

This function is safe to be called from multiple processes at the same time.

Returns:
header buffer size

char* http_getindexpage void   
 

Returns current index page.

This function returns the current index page name.

This function is safe to be called from multiple processes at the same time.

Returns:
The starting address of index page name. NULL will be returned if there is no index page set.

char* http_getlogfilename void   
 

Returns log file name.

This function returns the log file name.

This function is safe to be called from multiple processes at the same time.

Returns:
The address of log file name. NULL will be returned if there is no log file set.

int http_getlogging void   
 

Returns logging status.

This function returns the current logging status

This function is safe to be called from multiple processes at the same time.

Returns:
HTTP_DISABLE_LOG or HTTP_ENABLE_LOG

int http_getmaxconnections void   
 

Returns the current value for maximum number of pending connections.

This function returns the current value for maximum number of pending connections

This function is safe to be called from multiple processes at the same time.

Returns:
The current value for maximum number of pending connections.

int http_getportnumber void   
 

Returns current http server port number.

This function returns the current http server port number

This function is safe to be called from multiple processes at the same time.

Returns:
http server port number

char* http_getrootdir void   
 

Returns http root directory.

This function returns the current root directory path name.

This function is safe to be called from multiple processes at the same time.

Returns:
The starting address of root directory path name. NULL will be returned if there is no root directory set.

char http_hex_from_ascii char    c
 

Returns hexadecimal value for input ascii digit.

This function returns hexadecimal value for input ascii digit

This function is safe to be called from multiple processes at the same time.

Parameters:
c ascii digit
Returns:
hexadecimal value for input ascii digit

int http_init struct sockaddr    server_addr
 

Initializes http server library.

This function initializes the internal data structures of http server library

Warning:
This function is not multi-process safe. If two processes try to call this function at the same time, its parameters may be destroyed, yielding unpredictable results.
Parameters:
server_addr Address of http server. Should be initialized with the IP address of the TINI it is running on.
Returns:
Always returns HTTP_STATUS_SUCCESS

int http_kill_server void   
 

Terminates http server.

This function Terminates http server

This function is safe to be called from multiple processes at the same time.

Returns:
HTTP_STATUS_SUCCESS, HTTP_NOSERVERTASK

void http_reg_acl_callback int(*    func)()
 

Registers access control callback function.

This function registers callback function to process http request

Warning:
This function is not multi-process safe. If two processes try to call this function at the same time, its parameters may be destroyed, yielding unpredictable results.
Parameters:
func - the function pointer to call back function
NOTE:

Access control callback function should have the following function prototype to receive the sockaddr pointer

int << http access control call back function name >> (sockaddr *address)

NOTE: Access control callback routine should return HTTP_STATUS_SUCCESS value to process the http request, HTTP_DENY_CONNECTION error value to deny the client connection

Warning:
this callback function should be multi-task safe.

void http_reg_req_callback int(*    func)()
 

Registers callback function to process http request.

This function registers callback function to process http request

Warning:
This function is not multi-process safe. If two processes try to call this function at the same time, its parameters may be destroyed, yielding unpredictable results.
Parameters:
func - the function pointer to call back function
NOTE: Http request process callback function should have the following function prototype to receive http session structure pointer.

int << http request process call back function name >> (http_session *https)

NOTE: Http request process callback routine should return HTTP_STATUS_SUCCESS value, if the request was processed. HTTP_REQUEST_NOT_PROCESSED error value to let http library process the request.

Warning:
this callback function should be multi-task safe.

void http_sendheaders http_session   https
 

Sends http response headers to client.

This function sends http response headers to client

This function is safe to be called from multiple processes at the same time.

NOTE: the response code, content type, content length, and response header values can be modified from application before sending response headers

Parameters:
https the pointer to http session object that contains response header value

void http_set_req_linesize int    buffersize
 

Sets the maximum size value of each line of http request.

This function sets the maximum size value of each line of http request

Warning:
This function is not multi-process safe. If two processes try to call this function at the same time, its parameters may be destroyed, yielding unpredictable results.
Parameters:
buffersize the maximum size value of each http request line

void http_set_req_process_options char    flag
 

Sets Http request Variable parsing status flag value.

This function sets http request variable parsing status flag value. By default, the flag contains HTTP_ENABLE_VARIABLE_PARSING value. When the flag is set with HTTP_ENABLE_VARIABLE_PARSING, The http server parses the variables from "query string", and "message body" and stores it in variable list. The variable needs to be passed using standard convention(variablename=value) to make http server library to parse the variables successfully. The parsing process can be disabled by setting HTTP_DISABLE_VARIABLE_PARSING value, and user can access both "query string" and "messagebody" values from querystring,messagebody members of http session object.

This function is safe to be called from multiple processes at the same time.

Parameters:
flag Http request Variable parsing status flag value. Should be one of HTTP_ENABLE_VARIABLE_PARSING, HTTP_DISABLE_VARIABLE_PARSING

void http_setclientsocktimeout long    milli_sec
 

Sets http client socket timeout value.

This function sets http client socket timeout value

Warning:
This function is not multi-process safe. If two processes try to call this function at the same time, its parameters may be destroyed, yielding unpredictable results.
Parameters:
milli_sec timeout value in milliseconds

void http_setheaderbufsize int    buffersize
 

Sets header buffer size.

This function sets both http request and http response header buffer size

Warning:
This function is not multi-process safe. If two processes try to call this function at the same time, its parameters may be destroyed, yielding unpredictable results.
Parameters:
buffersize the input buffer size value

int http_setindexpage char *    index
 

Sets index page name.

This function sets index page name in http library. Index page will be sent to http client if url request path is "/"

Warning:
This function is not multi-process safe. If two processes try to call this function at the same time, its parameters may be destroyed, yielding unpredictable results.
Parameters:
index Index page name
Returns:

int http_setlogfilename char *    logfilename
 

Sets log file name.

This function sets log file name with http library.

Warning:
This function is not multi-process safe. If two processes try to call this function at the same time, its parameters may be destroyed, yielding unpredictable results.
Parameters:
logfilename - name of the log file
Returns:
NOTE: Logging activity has to be disabled and re-enabled in order to use new log file name for logging

int http_setlogging char    logstatus
 

Sets logging status.

This function sets the logging status with http server library

Warning:
This function is not multi-process safe. If two processes try to call this function at the same time, its parameters may be destroyed, yielding unpredictable results.
Parameters:
logstatus Logging status value. Either HTTP_DISABLE_LOG or HTTP_ENABLE_LOG
Returns:
HTTP_STATUS_SUCCESS or HTTP_LOGFILE_ERROR

void http_setmaxconnections int    max_connection
 

Sets maximum number of pending connections value.

This function sets maximum number of pending connections allowed in the listen queue

Warning:
This function is not multi-process safe. If two processes try to call this function at the same time, its parameters may be destroyed, yielding unpredictable results.
Parameters:
max_connection Value for maximum number of pending connections

void http_setportnumber int    portnumber
 

Sets HTTP Server Port number.

This function sets http server port number

Warning:
This function is not multi-process safe. If two processes try to call this function at the same time, its parameters may be destroyed, yielding unpredictable results.
Parameters:
portnumber the input http server port number
NOTE: http server has to be stopped and re-started in order to use new http port number.

int http_setrootdir char *    rootdir
 

Sets http root directory.

This function sets http root directory in http library. url pathname for particular resource is "relative path name" to root directory.

Warning:
This function is not multi-process safe. If two processes try to call this function at the same time, its parameters may be destroyed, yielding unpredictable results.
Parameters:
rootdir root directory path
Returns:

int http_start_server void   
 

Starts http server.

This function starts http server

This function is safe to be called from multiple processes at the same time.

Returns:
One of: HTTP_STATUS_SUCCESS, HTTP_TASK_ERROR, HTTP_SOCKET_ERROR, or HTTP_SERVER_ALREADY_RUNNING

unsigned int http_version void   
 

Returns the version number of http server library.

Returns:
Version number of http server library.


Copyright 2004 Dallas Semiconductor, Inc.. Documentation generated by Doxygen.