* * $Log$ * *
Definition in file utils.c.
Go to the source code of this file.
Defines | |
#define | MAX_HEADERLINE_SIZE 255 |
Functions | |
int | TcpHostConnect (TCPSOCKET *sock, CONST char *rhost, u_short port) |
Connect TCP host. | |
FILE * | TcpStreamAccept (TCPSOCKET *sock, u_short port, char *mode) |
int | TcpGetBuffer (TCPSOCKET *sock, char *buff, u_int size, u_int *status) |
Get a specified number of characters from TCP socket connection. | |
int | TcpGetTag (TCPSOCKET *sock, char *tag, int size) |
char * | LocateAttributeString (CONST char *tag, CONST char *name) |
int | TcpGetLine (TCPSOCKET *sock, char *line, u_short size) |
Get line from TCP socket connection. | |
int | TcpPutString (TCPSOCKET *sock, char *str) |
Send complete string via TCP. | |
int | TcpGetHeaderLines (TCPSOCKET *sock, char ***array) |
Get header line array from TCP socket connection. | |
void | TcpReleaseHeaderLines (char **array) |
Release previously allocated memory for the header lines. | |
void | HttpSchemeRelease (HTTP_SCHEME *schm) |
HTTP_SCHEME * | HttpSchemeParse (CONST char *uri) |
void | Led0 (int on) |
Switch LED0 on or off. | |
char * | strdup (CONST char *str) |
Create a copy of a string. |
#define MAX_HEADERLINE_SIZE 255 |
int TcpHostConnect | ( | TCPSOCKET * | sock, | |
CONST char * | rhost, | |||
u_short | port | |||
) |
Connect TCP host.
Definition at line 68 of file utils.c.
Referenced by OpenTcpStream(), ShoutCastGetPlayList(), and StationConnect().
FILE* TcpStreamAccept | ( | TCPSOCKET * | sock, | |
u_short | port, | |||
char * | mode | |||
) |
Definition at line 92 of file utils.c.
Referenced by Service(), XmlCmdService(), and XmlRepoService().
int TcpGetBuffer | ( | TCPSOCKET * | sock, | |
char * | buff, | |||
u_int | size, | |||
u_int * | status | |||
) |
Get a specified number of characters from TCP socket connection.
The low level NutTcpReceive() routine may return less than the number of bytes specified. This routine makes sure, that the complete buffer is filled. However, an additional pointer to a status is passed to this routine. If the status changes, the routine will be aborted.
Any TCP receive timeout is ignored, but required in order to detect status changes.
sock | Socket descriptor. This pointer must have been retrieved by calling NutTcpCreateSocket(). In addition a connection must have been established by calling NutTcpConnect() or NutTcpAccept(). | |
buff | Pointer to the buffer. | |
size | Size of the buffer. | |
status | Pointer to a status. |
Definition at line 143 of file utils.c.
Referenced by ProcessMetaData().
char* LocateAttributeString | ( | CONST char * | tag, | |
CONST char * | name | |||
) |
int TcpGetLine | ( | TCPSOCKET * | sock, | |
char * | line, | |||
u_short | size | |||
) |
Get line from TCP socket connection.
ASCII codes below 32 or above 127 are discarded.
sock | Socket descriptor. This pointer must have been retrieved by calling NutTcpCreateSocket(). In addition a connection must have been established by calling NutTcpConnect() or NutTcpAccept(). | |
line | Pointer to the buffer that receives the string. | |
size | Size of the buffer. If the received line doesn't fit, then remaining characters will be discarded. |
Definition at line 261 of file utils.c.
Referenced by ShoutCastGetPlayList(), and TcpGetHeaderLines().
int TcpPutString | ( | TCPSOCKET * | sock, | |
char * | str | |||
) |
Send complete string via TCP.
The low level NutTcpSend() routine limits the number of bytes to the maximum segment size of the connection. This routine makes sure, that the complete string is transmitted.
sock | Socket descriptor. This pointer must have been retrieved by calling NutTcpCreateSocket(). In addition a connection must have been established by calling NutTcpConnect() or NutTcpAccept(). | |
str | Pointer to a buffer containing the string to send. |
Definition at line 301 of file utils.c.
Referenced by ShoutCastGetPlayList(), and StationConnect().
int TcpGetHeaderLines | ( | TCPSOCKET * | sock, | |
char *** | array | |||
) |
Get header line array from TCP socket connection.
Receives lines from a TCP stream until the first empty line appears and stores all lines in an array of strings. The empty line is not stored, but the last pointer of the array is set to NULL.
The routine allocates the array and all string. The caller should use TcpReleaseHeaderLines() to release all allocated memory.
sock | Socket descriptor. This pointer must have been retrieved by calling NutTcpCreateSocket(). In addition a connection must have been established by calling NutTcpConnect() or NutTcpAccept(). | |
array | Pointer to a string array pointer, which receives the address of the newly allocated string array. If no non-empty lines were received or if an error occured, then the string array pointer will be set to NULL. |
Definition at line 338 of file utils.c.
Referenced by StationConnect().
void TcpReleaseHeaderLines | ( | char ** | array | ) |
Release previously allocated memory for the header lines.
Should be called to release all memory allocated by TcpGetHeaderLines().
array | String array to be released. |
Definition at line 428 of file utils.c.
Referenced by StationDisconnect().
void HttpSchemeRelease | ( | HTTP_SCHEME * | schm | ) |
Definition at line 442 of file utils.c.
Referenced by HttpSchemeParse(), ShoutCastAddStation(), ShoutCastGetGenreList(), ShoutCastGetPlayList(), ShoutCastGetStationList(), and StationConnect().
HTTP_SCHEME* HttpSchemeParse | ( | CONST char * | uri | ) |
Definition at line 453 of file utils.c.
Referenced by ShoutCastAddStation(), ShoutCastGetGenreList(), ShoutCastGetPlayList(), ShoutCastGetStationList(), and StationConnect().
void Led0 | ( | int | on | ) |
char* strdup | ( | CONST char * | str | ) |
Create a copy of a string.
Allocates sufficient memory from heap for a copy of the string does the copy.
Missing Nut/OS function.
str | Pointer to the string to copy. |
Definition at line 541 of file utils.c.
Referenced by FavListCopy(), FavListLoad(), FavListSet(), HttpSchemeParse(), and ProcessMetaData().