Typedefs | |
typedef struct _HTTP_STREAM | HTTP_STREAM |
typedef void(* | HTTP_CLIENT_HANDLER )(HTTP_STREAM *) |
Functions | |
int | StreamInit (void) |
Initialize the stream. | |
int | StreamClientAccept (HTTP_CLIENT_HANDLER handler, const char *params) |
Accept stream clients. | |
int | StreamReadUntilChars (HTTP_STREAM *sp, const char *delim, const char *ignore, char *buf, int siz) |
Read data from a stream until any of the specified characters appears. | |
int | StreamReadUntilString (HTTP_STREAM *sp, const char *delim, char *buf, int siz) |
Read data from a stream until a specified string appears. | |
int | s_write (const void *buf, size_t size, size_t count, HTTP_STREAM *sp) |
Write data items to a stream. | |
int | s_puts (const char *str, HTTP_STREAM *sp) |
Write a string to a stream. | |
int | s_vputs (HTTP_STREAM *sp,...) |
Write a variable number of strings to a stream. | |
int | s_printf (HTTP_STREAM *sp, const char *fmt,...) |
Print formatted data to a stream. | |
int | s_flush (HTTP_STREAM *sp) |
Flush a stream. | |
const char * | StreamInfo (HTTP_STREAM *hs, int item) |
Default environment variables | |
#define | SITEM_REMOTE_ADDR 1 |
The IP address of the host making this request. | |
#define | SITEM_REMOTE_PORT 2 |
The port number used by the remote host when making this request. | |
#define | SITEM_SERVER_ADDR 3 |
The IP address of the server for this URL. | |
#define | SITEM_SERVER_NAME 4 |
The servers host name, DNS alias or IP address. | |
#define | SITEM_SERVER_PORT 5 |
The port number on this server to which this request was directed. |
#define SITEM_REMOTE_ADDR 1 |
The IP address of the host making this request.
Referenced by ISC_LIST(), and StreamInfo().
#define SITEM_REMOTE_PORT 2 |
The port number used by the remote host when making this request.
Referenced by ISC_LIST(), and StreamInfo().
#define SITEM_SERVER_ADDR 3 |
The IP address of the server for this URL.
Referenced by ISC_LIST(), and StreamInfo().
#define SITEM_SERVER_NAME 4 |
The servers host name, DNS alias or IP address.
Referenced by ISC_LIST(), and StreamInfo().
#define SITEM_SERVER_PORT 5 |
The port number on this server to which this request was directed.
Referenced by ISC_LIST(), and StreamInfo().
typedef struct _HTTP_STREAM HTTP_STREAM |
typedef void(* HTTP_CLIENT_HANDLER)(HTTP_STREAM *) |
int StreamInit | ( | void | ) |
Initialize the stream.
This function must be called before before calling StreamClientAccept() and will initialize the platform dependent stream processing.
$Id$
References printf.
int StreamClientAccept | ( | HTTP_CLIENT_HANDLER | handler, |
const char * | params | ||
) |
Accept stream clients.
If no error occurs, this function will never return.
handler | Client handler to be called when a client successfully connected. |
params | Stream specific parameters. For TCP/IP connections this is currently used to specify the port number. If NULL, then the server will listen at default port 80. |
References AF_INET, atoi(), calloc, _CLIENT_THREAD_PARAM::ctp_handler, _CLIENT_THREAD_PARAM::ctp_stream, free(), htonl, htons, HTTP_ASSERT, INADDR_ANY, IPPROTO_TCP, malloc(), memcpy(), memset(), NULL, NutTcpAccept(), NutTcpCloseSocket(), NutTcpCreateSocket(), NutTcpSetSockOpt(), rc, SO_RCVBUF, SO_RCVTIMEO, SOCK_STREAM, StreamClientThread(), _HTTP_STREAM::strm_caddr, _HTTP_STREAM::strm_csock, _HTTP_STREAM::strm_saddr, _HTTP_STREAM::strm_sock, _HTTP_STREAM::strm_ssock, and TCP_MAXSEG.
int StreamReadUntilChars | ( | HTTP_STREAM * | sp, |
const char * | delim, | ||
const char * | ignore, | ||
char * | buf, | ||
int | siz | ||
) |
Read data from a stream until any of the specified characters appears.
sp | Pointer to the stream's information structure. |
delim | The function will return as soon as any of the characters in this string is read. |
ignore | String of all characters that will be skipped. |
buf | Pointer to the buffer that will receive the data read from the stream. Characters to ignore are not stored. The delimiter will be replaced by a string terminator (ASCII 0). |
siz | Size of the buffer, given in bytes. |
References HTTP_ASSERT, NULL, NutTcpReceive(), rc, strchr(), _HTTP_STREAM::strm_csock, _HTTP_STREAM::strm_ibuf, _HTTP_STREAM::strm_ilen, _HTTP_STREAM::strm_ipos, and _HTTP_STREAM::strm_sock.
Referenced by HttpArgReadNext(), HttpParseHeader(), and HttpParseMultipartHeader().
int StreamReadUntilString | ( | HTTP_STREAM * | sp, |
const char * | delim, | ||
char * | buf, | ||
int | siz | ||
) |
Read data from a stream until a specified string appears.
sp | Pointer to the stream's information structure. |
delim | The function will return as soon as this string appears. |
ignore | String of all characters that will be skipped. |
buf | Pointer to the buffer that will receive the data read from the stream. Characters to ignore are not stored. The searched string will be replaced by a string terminator (ASCII 0). |
siz | Size of the buffer, given in bytes. |
References HTTP_ASSERT, memcmp(), memcpy(), NULL, NutTcpReceive(), rc, strlen(), _HTTP_STREAM::strm_csock, _HTTP_STREAM::strm_ibuf, _HTTP_STREAM::strm_ilen, _HTTP_STREAM::strm_ipos, and _HTTP_STREAM::strm_sock.
int s_write | ( | const void * | buf, |
size_t | size, | ||
size_t | count, | ||
HTTP_STREAM * | sp | ||
) |
Write data items to a stream.
This function is similar to the standard function fwrite().
buf | Pointer to items to be written. |
size | Item size in bytes. |
count | Number of items to write. |
sp | Pointer to the stream's information structure. |
References HTTP_ASSERT, NULL, NutTcpDeviceWrite(), _HTTP_STREAM::strm_csock, and _HTTP_STREAM::strm_sock.
Referenced by HttpSsiProcessFile(), and MediaTypeHandlerBinary().
int s_puts | ( | const char * | str, |
HTTP_STREAM * | sp | ||
) |
Write a string to a stream.
This function is similar to the standard function fputs().
sp | Pointer to the stream's information structure. |
str | String to write. |
References HTTP_ASSERT, NULL, NutTcpDeviceWrite(), strlen(), _HTTP_STREAM::strm_csock, and _HTTP_STREAM::strm_sock.
Referenced by HttpSendHeaderBottom(), HttpSsiEchoHandler(), and HttpSsiHandler().
int s_vputs | ( | HTTP_STREAM * | sp, |
... | |||
) |
Write a variable number of strings to a stream.
sp | Pointer to the stream's information structure. |
References free(), HTTP_ASSERT, malloc(), NULL, NutTcpDeviceWrite(), rc, strcat(), strlen(), _HTTP_STREAM::strm_csock, and _HTTP_STREAM::strm_sock.
Referenced by HttpSendHeaderBottom(), HttpSendHeaderDate(), HttpSendHeaderTop(), HttpSendRedirection(), and HttpSsiHandler().
int s_printf | ( | HTTP_STREAM * | sp, |
const char * | fmt, | ||
... | |||
) |
Print formatted data to a stream.
This function is similar to the standard function fprintf().
sp | Pointer to the stream's information structure. |
fmt | Format string containing conversion specifications. |
References free(), HTTP_ASSERT, malloc(), NULL, NutTcpDeviceWrite(), rc, _HTTP_STREAM::strm_csock, _HTTP_STREAM::strm_sock, and vsprintf().
Referenced by HttpSendError(), HttpSendHeaderBottom(), HttpSendHeaderTop(), and HttpSendRedirection().
int s_flush | ( | HTTP_STREAM * | sp | ) |
Flush a stream.
This function is similar to the standard function fflush().
The calling thread may be suspended until all buffered output data has been written.
sp | Pointer to the stream's information structure. |
References NULL, NutTcpDeviceWrite(), and _HTTP_STREAM::strm_sock.
Referenced by HttpSendError(), HttpSendRedirection(), HttpSsiProcessFile(), and MediaTypeHandlerBinary().
const char* StreamInfo | ( | HTTP_STREAM * | hs, |
int | item | ||
) |
References free(), inet_ntoa(), malloc(), NULL, SITEM_REMOTE_ADDR, SITEM_REMOTE_PORT, SITEM_SERVER_ADDR, SITEM_SERVER_NAME, SITEM_SERVER_PORT, sprintf, strdup(), _HTTP_STREAM::strm_caddr, and _HTTP_STREAM::strm_saddr.
Referenced by HttpStreamInfo().