Main Page | Modules | Data Structures | Directories | File List | Data Fields | Globals

# Embedded HTTP Demon

## Defines
#define | HTTP_SERVLETS 1
#define | SLERR_OK 0
#define | SLERR_FAIL -1
#define | SLERR_NEEDMEM -2
#define | SLERR_BADREQUEST -3
#define | SLERR_NOTFOUND -4
#define | SLERR_SERVER -5
#define | SLERR_CREATED -6
#define | SLERR_ACCEPTED -7
#define | SLERR_PARTIAL -8
#define | SLERR_FORBIDDEN -9
#define | SLERR_TOOLARGE -10
#define | SLERR_UNAVAILABLE -11
#define | SLERR_BUSY -12
#define | HSL_LINK_RAW 0x00000001
#define | HSL_LINK_SID 0x00000002
#define | HSL_LINK_QM 0x80000000
## Typedefs
typedef void * | SERVLET_t
typedef sint_t(* | SERVLETFUNC_t )(SERVLET_t slobj)
## Functions
sint_t | hsl_create (SERVLETFUNC_t func, const char *filename)
sint_t | hsl_destroy (SERVLETFUNC_t func)
char * | hsl_getParameterByName (SERVLET_t *slobj, const char *name)
char * | hsl_getOwnName (SERVLET_t *slobj)
sint_t | hsl_setStreamBufSize (SERVLET_t *slobj, u32_t bufsize)
sint_t | hsl_printf (SERVLET_t *slobj, const char *fmt,...)
void * | hsl_getSession (SERVLET_t *slobj)
void * | hsl_newSession (SERVLET_t *slobj, u32_t memsize, u32_t timeout)
sint_t | hsl_destroySession (SERVLET_t *slobj)
sint_t | hsl_formAddSessionId (SERVLET_t *slobj)
sint_t | hsl_linkCreate (SERVLET_t *slobj, const char *url, u32_t flags)
sint_t | hsl_linkAddStringVal (SERVLET_t *slobj, const char *name, const char *val)
sint_t | hsl_linkAddNumberVal (SERVLET_t *slobj, const char *name, u32_t val)
sint_t | hsl_linkInsert (SERVLET_t *slobj, const char *linktext)
sint_t | hsl_addSessionIdToForm (SERVLET_t *slobj)
sint_t | httpd_start (const char *rootDirectory, u32_t maxServletMem, u32_t maxSessionMem)
sint_t | httpd_stop (void)
sint_t | httpd_running (void)

## Define Documentation

#define HSL_LINK_QM 0x80000000

#define HSL_LINK_RAW 0x00000001

#define HSL_LINK_SID 0x00000002

#define HTTP_SERVLETS 1

| define this to 1 to enable servlet support

#define SLERR_ACCEPTED -7

#define SLERR_BADREQUEST -3

#define SLERR_BUSY -12

#define SLERR_CREATED -6

#define SLERR_FAIL -1

#define SLERR_FORBIDDEN -9

#define SLERR_NEEDMEM -2

#define SLERR_NOTFOUND -4

#define SLERR_OK 0

#define SLERR_PARTIAL -8

#define SLERR_SERVER -5

#define SLERR_TOOLARGE -10

#define SLERR_UNAVAILABLE -11

## Typedef Documentation

typedef void* SERVLET_t

| Servlet object

typedef sint_t(* SERVLETFUNC_t)(SERVLET_t slobj)

| Function pointer to servlet function.

## Function Documentation

sint_t hsl_addSessionIdToForm | ( | SERVLET_t * | slobj | ) |

  | Servlet function: Add the session id as a hidden parameter to a form. Parameters:
  | slobj | pointer to the servlet object
Returns: zero on success See also: hsl_linkCreate

sint_t hsl_create | ( | SERVLETFUNC_t | func,
|  | const char * | filename
| ) |

  | Servlet function: Create a new servlet object. This function is used to create and add a new servlet object to the http demon. Parameters:
  | func | pointer to servlet function
  | filename | name of path and file that is overloaded by the servlet
Returns: zero on success. See also: hsl_destroy, hsl_getParameterByName

sint_t hsl_destroy | ( | SERVLETFUNC_t | func | ) |

  | Servlet function: Destroy a servlet object. The servlet object will be removed from the http demon. Parameters:
  | func | pointer to the servlet function.
Returns: zero on success. See also: hsl_create

sint_t hsl_destroySession | ( | SERVLET_t * | slobj | ) |

  | Servlet function: This function destorys a servlet session. It should be called when the user logs out. Parameters:
  | slobj | pointer to the servlet object
Returns: zero on success See also: hsl_getSession, hsl_newSession, hsl_create

sint_t hsl_formAddSessionId | ( | SERVLET_t * | slobj | ) |

  | Servlet function: Inserts the current session ID into a web formular. Creates the string '<input type="hidden" name="sid" value="xxxxxxxx">' Parameters:
  | slobj | pointer to the servlet object
Returns: zero on success

char* hsl_getOwnName | ( | SERVLET_t * | slobj | ) |

  | Servlet function: This function returns the own name (name of the servlet). Parameters:
  | slobj | pointer to the servlet object
Returns: pointer to the name of the servlet (read only) See also: hsl_create

char* hsl_getParameterByName | ( | SERVLET_t * | slobj,
|  | const char * | name
| ) |

  | Servlet function: Get the value of a named parameter from the request URI. Parameters:
  | slobj | pointer to the servlet object
  | name | name of the parameter to retrieve
Returns: Pointer to a zero terminated ascii string containing the parameter value. See also: hsl_create

void* hsl_getSession | ( | SERVLET_t * | slobj | ) |

  | Servlet function: This function returns a pointer to the servlets session memory. Parameters:
  | slobj | pointer to the servlet object
Returns: The pointer to the session memory. If NULL is returned, no session is associated with the servlet. The servlet may call hsl_newSession to create a new session. See also: hsl_newSession, hsl_destroySession, hsl_create

sint_t hsl_linkAddNumberVal | ( | SERVLET_t * | slobj,
|  | const char * | name,
|  | u32_t | val
| ) |

  | Servlet function: Add a decimal value to the parameter list of a link. The link must have been created with hsl_linkCreate before this function can be called. Parameters:
  | slobj | pointer to the servlet object
  | name | name of the parameter
  | val | decimal value of the parameter
Returns: zero on success See also: hsl_linkCreate, hsl_linkAddStringVal, hsl_linkInsert

sint_t hsl_linkAddStringVal | ( | SERVLET_t * | slobj,
|  | const char * | name,
|  | const char * | val
| ) |

  | Servlet function: Add a string value to the parameter list of a link. The link must have been created with hsl_linkCreate before this function can be called. Parameters:
  | slobj | pointer to the servlet object
  | name | name of the parameter
  | val | string value of the parameter
Returns: zero on success See also: hsl_linkCreate, hsl_linkAddNumberVal, hsl_linkInsert

sint_t hsl_linkCreate | ( | SERVLET_t * | slobj,
|  | const char * | url,
|  | u32_t | flags
| ) |

  | Servlet function: Create a new link object. You must use this function in your servlet if you wish to pass a session ID with a link back to your servlet. Further, this function simplifies the creation of links with an appended parameter list. To create dynamic links, you need to call these functions in the following order: hsl_linkCreate, hsl_linkAddStringVal, hsl_linkInsert Parameters:
  | slobj | pointer to the servlet object
  | url | the base url of the link (without parametes) Note: If this parameter is set to NULL, the filename of the servlet is inserted.
  | flags | bitmask of flags: HSL_LINK_RAW create URL only, without link-tags( <a=href...> ) HSL_LINK_SID append session ID to the link
Returns: zero on success See also: hsl_linkAddStringVal, hsl_linkAddNumberVal, hsl_linkInsert, hsl_addSessionIdToForm

sint_t hsl_linkInsert | ( | SERVLET_t * | slobj,
|  | const char * | linktext
| ) |

  | Servlet function: Insert a link that was created by hsl_linkCreate into the dynamic html page. Parameters:
  | slobj | pointer to the servlet object
  | linktext | Link text that is displayed to the user. Note that this text may contain further html commands. If the link was created with the flag HSL_LINK_RAW, this parameter is a don't care.
Returns: zero on success See also: hsl_linkCreate, hsl_linkAddStringVal, hsl_linkAddNumberVal

void* hsl_newSession | ( | SERVLET_t * | slobj,
|  | u32_t | memsize,
|  | u32_t | timeout
| ) |

  | Servlet function: This function creates a new session. A session is understood as a memory buffer where the servlet can store its private data. The lifetime of a session is limmited, it is removed automatically by the http demon when it timed out. Parameters:
  | slobj | pointer to the servlet object
  | memsize | memory size of the session (in bytes)
  | timeout | lifetime of the session (in seconds)
Returns: On success, a pointer to the memory buffer of the session is returned. If this function fails, NULL is returned. If this happens, the servlet should return with SLERR_BUSY. See also: hsl_getSession, hsl_destroySession, hsl_create

sint_t hsl_printf | ( | SERVLET_t * | slobj,
|  | const char * | fmt,
|  |  | ...
| ) |

  | Servlet function: Print formatted to the stdout of the current servlet instance. Parameters:
  | slobj | pointer to the servlet object
  | fmt | format string, followed by options
Returns: A positive value denoting the count of printed characters on success. A negative value is returned on error. See also: hsl_setStreamBufSize, hsl_create

sint_t hsl_setStreamBufSize | ( | SERVLET_t * | slobj,
|  | u32_t | bufsize
| ) |

  | Servlet function: Request more memory for the output stream buffer. Per default, one kilobyte (=1024 bytes) is reserved for the output stream. If larger HTML pages shall be created, the buffer size must be increased by calling this function from within the servlet. Parameters:
  | slobj | pointer to the servlet object
  | bufsize | bufsize
Returns: status code. If the status is not SLERR_OK, the servlet function MUST return this code to the http demon. The http demon will call the servlet function again when the requested memory is available. See also: hsl_printf, hsl_getParameterByName, hsl_create

sint_t httpd_running | ( | void |  | ) |

| This function can be used to test if the HTTP demon task is still running. Returns: nonzero when the httpd is running.

sint_t httpd_start | ( | const char * | rootDirectory,
|  | u32_t | maxServletMem,
|  | u32_t | maxSessionMem
| ) |

  | This function starts the HTTP demon. The function call does not return, so it is recommended to setup a new task that executes this function. To terminate the demon you can call the function httpd_stop. Parameters:
  | rootDirectory | HTTP root directory name on the filesystem (this is the '/' directory where the initial index.html is stored).
  | maxServletMem | Maximum sum of bytes servlets may allocate to buffer their output stream. This parameter is a don't care if servlets are disabled.
  | maxSessionMem | Maximum sum of bytes all servlets together are allowed to allocate for their local session memory. If you use sessions, you may need to set this value high, because much memory will pend in sessions that are going to timeout. This parameter is a don't care if servlets are disabled.
Returns: zero on success.

sint_t httpd_stop | ( | void |  | ) |

| This function stoppes the HTTP demon. Note that it takes a while (up to 1 second) until this function returns. Returns: zero on success.