Doxygen, reformating, compiler warnings.
This commit is contained in:
parent
978f10449f
commit
9e7e7e3b89
@ -2293,7 +2293,7 @@ EXPORT_SPEC int UpnpWriteHttpPost(
|
||||
/*! [in] The buffer to be posted. */
|
||||
char *buf,
|
||||
/*! [in] The size, in bytes of \b buf. */
|
||||
unsigned int *size,
|
||||
size_t *size,
|
||||
/*! [in] A timeout value sent with the request during which a response is
|
||||
* expected from the server, failing which, an error is reported. If
|
||||
* value is negative, timeout is infinite. */
|
||||
|
@ -2801,7 +2801,7 @@ int UpnpOpenHttpPost(
|
||||
int UpnpWriteHttpPost(
|
||||
void *handle,
|
||||
char *buf,
|
||||
unsigned int *size,
|
||||
size_t *size,
|
||||
int timeout)
|
||||
{
|
||||
return http_WriteHttpPost(handle, buf, size, timeout);
|
||||
@ -2887,21 +2887,18 @@ int UpnpHttpGetProgress(void *Handle, size_t *length, size_t *total)
|
||||
|
||||
int UpnpDownloadUrlItem(const char *url, char **outBuf, char *contentType)
|
||||
{
|
||||
int ret_code;
|
||||
int dummy;
|
||||
int ret_code;
|
||||
size_t dummy;
|
||||
|
||||
if( url == NULL || outBuf == NULL || contentType == NULL ) {
|
||||
return UPNP_E_INVALID_PARAM;
|
||||
}
|
||||
if (url == NULL || outBuf == NULL || contentType == NULL)
|
||||
return UPNP_E_INVALID_PARAM;
|
||||
ret_code = http_Download(url, HTTP_DEFAULT_TIMEOUT, outBuf, &dummy,
|
||||
contentType);
|
||||
if (ret_code > 0)
|
||||
/* error reply was received */
|
||||
ret_code = UPNP_E_INVALID_URL;
|
||||
|
||||
ret_code = http_Download( url, HTTP_DEFAULT_TIMEOUT, outBuf, &dummy,
|
||||
contentType );
|
||||
if( ret_code > 0 ) {
|
||||
/* error reply was received */
|
||||
ret_code = UPNP_E_INVALID_URL;
|
||||
}
|
||||
|
||||
return ret_code;
|
||||
return ret_code;
|
||||
}
|
||||
|
||||
|
||||
|
@ -483,7 +483,7 @@ static int get_port(
|
||||
*port = ntohs(((struct sockaddr_in6*)&sockinfo)->sin6_port);
|
||||
}
|
||||
UpnpPrintf(UPNP_INFO, MSERV, __FILE__, __LINE__,
|
||||
"sockfd = %d, .... port = %d\n", sockfd, port);
|
||||
"sockfd = %d, .... port = %u\n", sockfd, *port);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -397,8 +397,8 @@ static void alias_release(
|
||||
ithread_mutex_unlock(&gWebMutex);
|
||||
return;
|
||||
}
|
||||
assert(alias->ct > 0);
|
||||
*alias->ct = *alias->ct - 1;
|
||||
assert(*alias->ct > 0);
|
||||
*alias->ct -= 1;
|
||||
if (*alias->ct <= 0) {
|
||||
membuffer_destroy(&alias->doc);
|
||||
membuffer_destroy(&alias->name);
|
||||
|
@ -107,7 +107,7 @@ static int sock_read_write(
|
||||
/*! Buffer to get data to or send data from. */
|
||||
OUT char *buffer,
|
||||
/*! Size of the buffer. */
|
||||
IN size_t bufsize,
|
||||
IN int bufsize,
|
||||
/*! timeout value. */
|
||||
IN int *timeoutSecs,
|
||||
/*! Boolean value specifying read or write option. */
|
||||
@ -120,36 +120,34 @@ static int sock_read_write(
|
||||
long numBytes;
|
||||
time_t start_time = time(NULL);
|
||||
SOCKET sockfd = info->socket;
|
||||
long bytes_sent = 0, byte_left = 0, num_written;
|
||||
long bytes_sent = 0;
|
||||
long byte_left = 0;
|
||||
long num_written;
|
||||
|
||||
FD_ZERO(&readSet);
|
||||
FD_ZERO(&writeSet);
|
||||
if (bRead) {
|
||||
if (bRead)
|
||||
FD_SET(sockfd, &readSet);
|
||||
} else {
|
||||
else
|
||||
FD_SET(sockfd, &writeSet);
|
||||
}
|
||||
timeout.tv_sec = *timeoutSecs;
|
||||
timeout.tv_usec = 0;
|
||||
while (TRUE) {
|
||||
if (*timeoutSecs < 0) {
|
||||
if (*timeoutSecs < 0)
|
||||
retCode = select(sockfd + 1, &readSet, &writeSet,
|
||||
NULL, NULL);
|
||||
} else {
|
||||
else
|
||||
retCode = select(sockfd + 1, &readSet, &writeSet,
|
||||
NULL, &timeout);
|
||||
}
|
||||
if (retCode == 0) {
|
||||
if (retCode == 0)
|
||||
return UPNP_E_TIMEDOUT;
|
||||
}
|
||||
if (retCode == -1) {
|
||||
if (errno == EINTR)
|
||||
continue;
|
||||
return UPNP_E_SOCKET_ERROR;
|
||||
} else {
|
||||
} else
|
||||
/* read or write. */
|
||||
break;
|
||||
}
|
||||
}
|
||||
#ifdef SO_NOSIGPIPE
|
||||
{
|
||||
@ -161,21 +159,21 @@ static int sock_read_write(
|
||||
#endif
|
||||
if (bRead) {
|
||||
/* read data. */
|
||||
numBytes = (long)recv(sockfd, buffer, bufsize, MSG_NOSIGNAL);
|
||||
numBytes = (long)recv(sockfd, buffer, (size_t)bufsize, MSG_NOSIGNAL);
|
||||
} else {
|
||||
byte_left = bufsize;
|
||||
bytes_sent = 0;
|
||||
while (byte_left > 0) {
|
||||
/* write data. */
|
||||
num_written = send(sockfd,
|
||||
buffer + bytes_sent, byte_left,
|
||||
buffer + bytes_sent, (size_t)byte_left,
|
||||
MSG_DONTROUTE | MSG_NOSIGNAL);
|
||||
if (num_written == -1) {
|
||||
#ifdef SO_NOSIGPIPE
|
||||
setsockopt(sockfd, SOL_SOCKET,
|
||||
SO_NOSIGPIPE, &old, olen);
|
||||
#endif
|
||||
return num_written;
|
||||
return (int)num_written;
|
||||
}
|
||||
byte_left = byte_left - num_written;
|
||||
bytes_sent += num_written;
|
||||
@ -186,26 +184,24 @@ static int sock_read_write(
|
||||
setsockopt(sockfd, SOL_SOCKET, SO_NOSIGPIPE, &old, olen);
|
||||
}
|
||||
#endif
|
||||
if (numBytes < 0) {
|
||||
if (numBytes < 0)
|
||||
return UPNP_E_SOCKET_ERROR;
|
||||
}
|
||||
/* subtract time used for reading/writing. */
|
||||
if (*timeoutSecs != 0) {
|
||||
*timeoutSecs -= time(NULL) - start_time;
|
||||
}
|
||||
if (*timeoutSecs != 0)
|
||||
*timeoutSecs -= (int)(time(NULL) - start_time);
|
||||
|
||||
return numBytes;
|
||||
return (int)numBytes;
|
||||
}
|
||||
|
||||
int sock_read(IN SOCKINFO *info, OUT char *buffer, IN size_t bufsize,
|
||||
int sock_read(IN SOCKINFO *info, OUT char *buffer, IN int bufsize,
|
||||
INOUT int *timeoutSecs)
|
||||
{
|
||||
return sock_read_write(info, buffer, bufsize, timeoutSecs, TRUE);
|
||||
}
|
||||
|
||||
int sock_write(IN SOCKINFO *info, IN char *buffer, IN size_t bufsize,
|
||||
int sock_write(IN SOCKINFO *info, IN const char *buffer, IN int bufsize,
|
||||
INOUT int *timeoutSecs)
|
||||
{
|
||||
return sock_read_write(info, buffer, bufsize, timeoutSecs, FALSE);
|
||||
return sock_read_write(info, (char *)buffer, bufsize, timeoutSecs, FALSE);
|
||||
}
|
||||
|
||||
|
@ -271,197 +271,170 @@ void print_uri(uri_type *in)
|
||||
#ifdef DEBUG
|
||||
void print_token(token * in)
|
||||
{
|
||||
int i = 0;
|
||||
printf( "Token Size : %"PRIzu"\n\'", in->size );
|
||||
for( i = 0; i < in->size; i++ ) {
|
||||
putchar( in->buff[i] );
|
||||
}
|
||||
putchar( '\'' );
|
||||
putchar( '\n' );
|
||||
size_t i = 0;
|
||||
|
||||
printf("Token Size : %" PRIzu "\n\'", in->size);
|
||||
for (i = 0; i < in->size; i++)
|
||||
putchar(in->buff[i]);
|
||||
putchar('\'');
|
||||
putchar('\n');
|
||||
}
|
||||
#endif /* DEBUG */
|
||||
|
||||
|
||||
int token_string_casecmp(token *in1, char *in2)
|
||||
int token_string_casecmp(token *in1, const char *in2)
|
||||
{
|
||||
size_t in2_length = strlen(in2);
|
||||
|
||||
if (in1->size != in2_length) {
|
||||
if (in1->size != in2_length)
|
||||
return 1;
|
||||
} else {
|
||||
else
|
||||
return strncasecmp(in1->buff, in2, in1->size);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int token_string_cmp(token * in1, char *in2)
|
||||
{
|
||||
size_t in2_length = strlen(in2);
|
||||
|
||||
if (in1->size != in2_length) {
|
||||
if (in1->size != in2_length)
|
||||
return 1;
|
||||
} else {
|
||||
else
|
||||
return strncmp(in1->buff, in2, in1->size);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int token_cmp(token *in1, token *in2)
|
||||
{
|
||||
if (in1->size != in2->size) {
|
||||
if (in1->size != in2->size)
|
||||
return 1;
|
||||
} else {
|
||||
else
|
||||
return memcmp(in1->buff, in2->buff, in1->size);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int parse_hostport(
|
||||
const char *in,
|
||||
size_t max,
|
||||
hostport_type *out)
|
||||
{
|
||||
char workbuf[256];
|
||||
char* c;
|
||||
struct sockaddr_in* sai4 = (struct sockaddr_in*)&out->IPaddress;
|
||||
struct sockaddr_in6* sai6 = (struct sockaddr_in6*)&out->IPaddress;
|
||||
char *srvname = NULL;
|
||||
char *srvport = NULL;
|
||||
char *last_dot = NULL;
|
||||
unsigned short int port;
|
||||
int af = AF_UNSPEC;
|
||||
int hostport_size;
|
||||
int has_port = 0;
|
||||
int ret;
|
||||
char workbuf[256];
|
||||
char *c;
|
||||
struct sockaddr_in *sai4 = (struct sockaddr_in *)&out->IPaddress;
|
||||
struct sockaddr_in6 *sai6 = (struct sockaddr_in6 *)&out->IPaddress;
|
||||
char *srvname = NULL;
|
||||
char *srvport = NULL;
|
||||
char *last_dot = NULL;
|
||||
unsigned short int port;
|
||||
int af = AF_UNSPEC;
|
||||
size_t hostport_size;
|
||||
int has_port = 0;
|
||||
int ret;
|
||||
|
||||
memset( out, 0, sizeof(hostport_type) );
|
||||
memset(out, 0, sizeof(hostport_type));
|
||||
/* Work on a copy of the input string. */
|
||||
strncpy(workbuf, in, sizeof(workbuf));
|
||||
c = workbuf;
|
||||
if (*c == '[') {
|
||||
/* IPv6 addresses are enclosed in square brackets. */
|
||||
srvname = ++c;
|
||||
while (*c != '\0' && *c != ']')
|
||||
c++;
|
||||
if (*c == '\0')
|
||||
/* did not find closing bracket. */
|
||||
return UPNP_E_INVALID_URL;
|
||||
/* NULL terminate the srvname and then increment c. */
|
||||
*c++ = '\0'; /* overwrite the ']' */
|
||||
if (*c == ':') {
|
||||
has_port = 1;
|
||||
c++;
|
||||
}
|
||||
af = AF_INET6;
|
||||
} else {
|
||||
/* IPv4 address -OR- host name. */
|
||||
srvname = c;
|
||||
while (*c != ':' && *c != '/' &&
|
||||
(isalnum(*c) || *c == '.' || *c == '-')) {
|
||||
if (*c == '.')
|
||||
last_dot = c;
|
||||
c++;
|
||||
}
|
||||
has_port = (*c == ':') ? 1 : 0;
|
||||
/* NULL terminate the srvname */
|
||||
*c = '\0';
|
||||
if (has_port == 1)
|
||||
c++;
|
||||
if (last_dot != NULL && isdigit(*(last_dot + 1)))
|
||||
/* Must be an IPv4 address. */
|
||||
af = AF_INET;
|
||||
else {
|
||||
/* Must be a host name. */
|
||||
struct addrinfo hints, *res, *res0;
|
||||
|
||||
/* Work on a copy of the input string. */
|
||||
strncpy( workbuf, in, sizeof(workbuf) );
|
||||
memset(&hints, 0, sizeof(hints));
|
||||
hints.ai_family = AF_UNSPEC;
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
|
||||
c = workbuf;
|
||||
if( *c == '[' ) {
|
||||
/* IPv6 addresses are enclosed in square brackets. */
|
||||
srvname = ++c;
|
||||
while( *c != '\0' && *c != ']' ) {
|
||||
c++;
|
||||
}
|
||||
if( *c == '\0' ) {
|
||||
/* did not find closing bracket. */
|
||||
return UPNP_E_INVALID_URL;
|
||||
}
|
||||
/* NULL terminate the srvname and then increment c. */
|
||||
*c++ = '\0'; /* overwrite the ']' */
|
||||
if( *c == ':' ) {
|
||||
has_port = 1;
|
||||
c++;
|
||||
}
|
||||
af = AF_INET6;
|
||||
}
|
||||
else {
|
||||
/* IPv4 address -OR- host name. */
|
||||
srvname = c;
|
||||
while( (*c != ':') && (*c != '/') && ( (isalnum(*c)) || (*c == '.') || (*c == '-') ) ) {
|
||||
if( *c == '.' )
|
||||
last_dot = c;
|
||||
c++;
|
||||
}
|
||||
has_port = (*c == ':') ? 1 : 0;
|
||||
/* NULL terminate the srvname */
|
||||
*c = '\0';
|
||||
if( has_port == 1 )
|
||||
c++;
|
||||
ret = getaddrinfo(srvname, NULL, &hints, &res0);
|
||||
if (ret == 0) {
|
||||
for (res = res0; res; res = res->ai_next) {
|
||||
if (res->ai_family == AF_INET ||
|
||||
res->ai_family == AF_INET6) {
|
||||
/* Found a valid IPv4 or IPv6 address. */
|
||||
memcpy(&out->IPaddress,
|
||||
res->ai_addr,
|
||||
res->ai_addrlen);
|
||||
break;
|
||||
}
|
||||
}
|
||||
freeaddrinfo(res0);
|
||||
if (res == NULL)
|
||||
/* Didn't find an AF_INET or AF_INET6 address. */
|
||||
return UPNP_E_INVALID_URL;
|
||||
} else
|
||||
/* getaddrinfo failed. */
|
||||
return UPNP_E_INVALID_URL;
|
||||
}
|
||||
}
|
||||
/* Check if a port is specified. */
|
||||
if (has_port == 1) {
|
||||
/* Port is specified. */
|
||||
srvport = c;
|
||||
while (*c != '\0' && isdigit(*c))
|
||||
c++;
|
||||
port = (unsigned short int)atoi(srvport);
|
||||
if (port == 0)
|
||||
/* Bad port number. */
|
||||
return UPNP_E_INVALID_URL;
|
||||
} else
|
||||
/* Port was not specified, use default port. */
|
||||
port = 80;
|
||||
/* The length of the host and port string can be calculated by */
|
||||
/* subtracting pointers. */
|
||||
hostport_size = (size_t)(c - workbuf);
|
||||
/* Fill in the 'out' information. */
|
||||
if (af == AF_INET) {
|
||||
sai4->sin_family = AF_INET;
|
||||
sai4->sin_port = htons(port);
|
||||
ret = inet_pton(AF_INET, srvname, &sai4->sin_addr);
|
||||
} else if (af == AF_INET6) {
|
||||
sai6->sin6_family = AF_INET6;
|
||||
sai6->sin6_port = htons(port);
|
||||
sai6->sin6_scope_id = gIF_INDEX;
|
||||
ret = inet_pton(AF_INET6, srvname, &sai6->sin6_addr);
|
||||
} else {
|
||||
/* IP address was set by the hostname (getaddrinfo). */
|
||||
/* Override port: */
|
||||
if (out->IPaddress.ss_family == AF_INET)
|
||||
sai4->sin_port = htons(port);
|
||||
else
|
||||
sai6->sin6_port = htons(port);
|
||||
ret = 1;
|
||||
}
|
||||
/* Check if address was converted successfully. */
|
||||
if (ret <= 0)
|
||||
return UPNP_E_INVALID_URL;
|
||||
out->text.size = hostport_size;
|
||||
out->text.buff = in;
|
||||
|
||||
if( last_dot != NULL && isdigit(*(last_dot+1)) ) {
|
||||
/* Must be an IPv4 address. */
|
||||
af = AF_INET;
|
||||
}
|
||||
else {
|
||||
/* Must be a host name. */
|
||||
struct addrinfo hints, *res, *res0;
|
||||
|
||||
memset(&hints, 0, sizeof(hints));
|
||||
hints.ai_family = AF_UNSPEC;
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
|
||||
ret = getaddrinfo(srvname, NULL, &hints, &res0);
|
||||
if( ret == 0 ) {
|
||||
for (res = res0; res; res = res->ai_next) {
|
||||
if( res->ai_family == AF_INET ||
|
||||
res->ai_family == AF_INET6 ) {
|
||||
/* Found a valid IPv4 or IPv6 address. */
|
||||
memcpy( &out->IPaddress, res->ai_addr,
|
||||
res->ai_addrlen );
|
||||
break;
|
||||
}
|
||||
}
|
||||
freeaddrinfo(res0);
|
||||
|
||||
if( res == NULL ) {
|
||||
/* Didn't find an AF_INET or AF_INET6 address. */
|
||||
return UPNP_E_INVALID_URL;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* getaddrinfo failed. */
|
||||
return UPNP_E_INVALID_URL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Check if a port is specified. */
|
||||
if( has_port == 1 ) {
|
||||
/* Port is specified. */
|
||||
srvport = c;
|
||||
while( *c != '\0' && isdigit(*c) ) {
|
||||
c++;
|
||||
}
|
||||
port = (unsigned short int)atoi(srvport);
|
||||
if( port == 0 ) {
|
||||
/* Bad port number. */
|
||||
return UPNP_E_INVALID_URL;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* Port was not specified, use default port. */
|
||||
port = 80;
|
||||
}
|
||||
|
||||
/* The length of the host and port string can be calculated by */
|
||||
/* subtracting pointers. */
|
||||
hostport_size = (int)(c - workbuf);
|
||||
|
||||
/* Fill in the 'out' information. */
|
||||
if( af == AF_INET ) {
|
||||
sai4->sin_family = AF_INET;
|
||||
sai4->sin_port = htons(port);
|
||||
ret = inet_pton(AF_INET, srvname, &sai4->sin_addr);
|
||||
}
|
||||
else if( af == AF_INET6 ) {
|
||||
sai6->sin6_family = AF_INET6;
|
||||
sai6->sin6_port = htons(port);
|
||||
sai6->sin6_scope_id = gIF_INDEX;
|
||||
ret = inet_pton(AF_INET6, srvname, &sai6->sin6_addr);
|
||||
} else {
|
||||
/* IP address was set by the hostname (getaddrinfo). */
|
||||
/* Override port: */
|
||||
if( out->IPaddress.ss_family == AF_INET )
|
||||
sai4->sin_port = htons(port);
|
||||
else
|
||||
sai6->sin6_port = htons(port);
|
||||
ret = 1;
|
||||
}
|
||||
|
||||
/* Check if address was converted successfully. */
|
||||
if (ret <= 0) {
|
||||
return UPNP_E_INVALID_URL;
|
||||
}
|
||||
|
||||
out->text.size = hostport_size;
|
||||
out->text.buff = in;
|
||||
|
||||
return hostport_size;
|
||||
max = max;
|
||||
return (int)hostport_size;
|
||||
max = max;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -206,7 +206,7 @@ int http_RequestAndResponse(
|
||||
* IN int timeout_secs; time out value
|
||||
* OUT char** document; buffer to store the document extracted
|
||||
* from the donloaded message.
|
||||
* OUT int* doc_length; length of the extracted document
|
||||
* OUT size_t* doc_length; length of the extracted document
|
||||
* OUT char* content_type; Type of content
|
||||
*
|
||||
* Description:
|
||||
@ -221,7 +221,7 @@ int http_Download(
|
||||
IN const char* url,
|
||||
IN int timeout_secs,
|
||||
OUT char** document,
|
||||
OUT int* doc_length,
|
||||
OUT size_t *doc_length,
|
||||
OUT char* content_type );
|
||||
|
||||
|
||||
@ -232,7 +232,7 @@ int http_Download(
|
||||
* IN void *Handle: Handle to the http post object
|
||||
* IN char *buf: Buffer to send to peer, if format used
|
||||
* is not UPNP_USING_CHUNKED,
|
||||
* IN unsigned int *size: Size of the data to be sent.
|
||||
* IN size_t *size: Size of the data to be sent.
|
||||
* IN int timeout: time out value
|
||||
*
|
||||
* Description:
|
||||
@ -246,7 +246,7 @@ int http_Download(
|
||||
************************************************************************/
|
||||
int http_WriteHttpPost(IN void *Handle,
|
||||
IN char *buf,
|
||||
IN unsigned int *size,
|
||||
IN size_t *size,
|
||||
IN int timeout);
|
||||
|
||||
|
||||
@ -350,7 +350,6 @@ int http_HttpGetProgress(
|
||||
OUT size_t *length,
|
||||
OUT size_t *total);
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* Function: http_CloseHttpGet
|
||||
*
|
||||
@ -367,74 +366,61 @@ int http_HttpGetProgress(
|
||||
************************************************************************/
|
||||
int http_CloseHttpGet(IN void *Handle);
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* Function: http_OpenHttpGet
|
||||
/*!
|
||||
* \brief Makes the HTTP GET message, connects to the peer,
|
||||
* sends the HTTP GET request, gets the response and parses the response.
|
||||
*
|
||||
* Parameters:
|
||||
* IN const char *url_str: String as a URL
|
||||
* IN OUT void **Handle: Pointer to buffer to store HTTP
|
||||
* post handle
|
||||
* IN OUT char **contentType: Type of content
|
||||
* OUT int *contentLength: length of content
|
||||
* OUT int *httpStatus: HTTP status returned on receiving a
|
||||
* response message
|
||||
* IN int timeout: time out value
|
||||
* If a proxy URL is defined then the connection is made there.
|
||||
*
|
||||
* Description:
|
||||
* Makes the HTTP GET message, connects to the peer,
|
||||
* sends the HTTP GET request, gets the response and parses the
|
||||
* response.
|
||||
*
|
||||
* Return: int
|
||||
* UPNP_E_SUCCESS - On Success
|
||||
* UPNP_E_INVALID_PARAM - Invalid Paramters
|
||||
* UPNP_E_OUTOF_MEMORY
|
||||
* UPNP_E_SOCKET_ERROR
|
||||
* UPNP_E_BAD_RESPONSE
|
||||
************************************************************************/
|
||||
* \return integer
|
||||
* \li \c UPNP_E_SUCCESS - On Success
|
||||
* \li \c UPNP_E_INVALID_PARAM - Invalid Paramters
|
||||
* \li \c UPNP_E_OUTOF_MEMORY
|
||||
* \li \c UPNP_E_SOCKET_ERROR
|
||||
* \li \c UPNP_E_BAD_RESPONSE
|
||||
*/
|
||||
int http_OpenHttpGet(
|
||||
IN const char *url_str,
|
||||
IN OUT void **Handle,
|
||||
IN OUT char **contentType,
|
||||
OUT int *contentLength,
|
||||
OUT int *httpStatus,
|
||||
IN int timeout);
|
||||
/* [in] String as a URL. */
|
||||
const char *url_str,
|
||||
/* [in,out] Pointer to buffer to store HTTP post handle. */
|
||||
void **Handle,
|
||||
/* [in,out] Type of content. */
|
||||
char **contentType,
|
||||
/* [out] length of content. */
|
||||
int *contentLength,
|
||||
/* [out] HTTP status returned on receiving a response message. */
|
||||
int *httpStatus,
|
||||
/* [in] time out value. */
|
||||
int timeout);
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* Function: http_OpenHttpGetProxy
|
||||
/*!
|
||||
* \brief Makes the HTTP GET message, connects to the peer,
|
||||
* sends the HTTP GET request, gets the response and parses the response.
|
||||
*
|
||||
* Parameters:
|
||||
* IN const char *url_str; String as a URL
|
||||
* IN const char *proxy_str; String as a URL
|
||||
* IN OUT void **Handle; Pointer to buffer to store HTTP
|
||||
* post handle
|
||||
* IN OUT char **contentType; Type of content
|
||||
* OUT int *contentLength; length of content
|
||||
* OUT int *httpStatus; HTTP status returned on receiving a
|
||||
* response message
|
||||
* IN int timeout: time out value
|
||||
* If a proxy URL is defined then the connection is made there.
|
||||
*
|
||||
* Description:
|
||||
* Makes the HTTP GET message, connects to the peer,
|
||||
* sends the HTTP GET request, gets the response and parses the response.
|
||||
* If a proxy URL is defined then the connection is made there.
|
||||
*
|
||||
* Return: int
|
||||
* UPNP_E_SUCCESS - On Success
|
||||
* UPNP_E_INVALID_PARAM - Invalid Paramters
|
||||
* UPNP_E_OUTOF_MEMORY
|
||||
* UPNP_E_SOCKET_ERROR
|
||||
* UPNP_E_BAD_RESPONSE
|
||||
************************************************************************/
|
||||
int http_OpenHttpGetProxy(IN const char *url_str,
|
||||
IN const char *proxy_str,
|
||||
IN OUT void **Handle,
|
||||
IN OUT char **contentType,
|
||||
OUT int *contentLength,
|
||||
OUT int *httpStatus,
|
||||
IN int timeout);
|
||||
* \return integer
|
||||
* \li \c UPNP_E_SUCCESS - On Success
|
||||
* \li \c UPNP_E_INVALID_PARAM - Invalid Paramters
|
||||
* \li \c UPNP_E_OUTOF_MEMORY
|
||||
* \li \c UPNP_E_SOCKET_ERROR
|
||||
* \li \c UPNP_E_BAD_RESPONSE
|
||||
*/
|
||||
int http_OpenHttpGetProxy(
|
||||
/* [in] String as a URL. */
|
||||
const char *url_str,
|
||||
/* [in] String as a URL. */
|
||||
const char *proxy_str,
|
||||
/* [in,out] Pointer to buffer to store HTTP post handle. */
|
||||
void **Handle,
|
||||
/* [in,out] Type of content. */
|
||||
char **contentType,
|
||||
/* [out] length of content. */
|
||||
int *contentLength,
|
||||
/* [out] HTTP status returned on receiving a response message. */
|
||||
int *httpStatus,
|
||||
/* [in] time out value. */
|
||||
int timeout);
|
||||
|
||||
|
||||
/************************************************************************
|
||||
@ -463,61 +449,55 @@ int http_SendStatusResponse(
|
||||
IN int request_major_version,
|
||||
IN int request_minor_version );
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* Function: http_MakeMessage
|
||||
/*!
|
||||
* \brief Generate an HTTP message based on the format that is specified in
|
||||
* the input parameters.
|
||||
*
|
||||
* Parameters:
|
||||
* INOUT membuffer* buf; buffer with the contents of the
|
||||
* message
|
||||
* IN int http_major_version; HTTP major version
|
||||
* IN int http_minor_version; HTTP minor version
|
||||
* IN const char* fmt; Pattern format
|
||||
* ...;
|
||||
\verbatim
|
||||
Format types:
|
||||
'B': arg = int status_code -- appends content-length, content-type and HTML body for given code.
|
||||
'b': arg1 = const char *buf;
|
||||
arg2 = size_t buf_length memory ptr
|
||||
'C': (no args) -- appends a HTTP CONNECTION: close header depending on major, minor version.
|
||||
'c': (no args) -- appends CRLF "\r\n"
|
||||
'D': (no args) -- appends HTTP DATE: header
|
||||
'd': arg = int number -- appends decimal number
|
||||
'G': arg = range information -- add range header
|
||||
'h': arg = off_t number -- appends off_t number
|
||||
'K': (no args) -- add chunky header
|
||||
'L': arg = language information -- add Content-Language header if Accept-Language header is not empty and if
|
||||
WEB_SERVER_CONTENT_LANGUAGE is not empty
|
||||
'N': arg1 = off_t content_length -- content-length header
|
||||
'q': arg1 = http_method_t -- request start line and HOST header
|
||||
arg2 = (uri_type *)
|
||||
'Q': arg1 = http_method_t; -- start line of request
|
||||
arg2 = char* url;
|
||||
arg3 = size_t url_length
|
||||
'R': arg = int status_code -- adds a response start line
|
||||
'S': (no args) -- appends HTTP SERVER: header
|
||||
's': arg = const char * -- C_string
|
||||
'T': arg = char * content_type; -- format e.g: "text/html"; content-type header
|
||||
't': arg = time_t * gmt_time -- appends time in RFC 1123 fmt
|
||||
'U': (no args) -- appends HTTP USER-AGENT: header
|
||||
'X': arg = const char -- useragent; "redsonic" HTTP X-User-Agent: useragent
|
||||
\endverbatim
|
||||
*
|
||||
* Description:
|
||||
* Generate an HTTP message based on the format that is specified
|
||||
* in the input parameters.
|
||||
*
|
||||
* fmt types:
|
||||
* 'B': arg = int status_code
|
||||
* appends content-length, content-type and HTML body
|
||||
* for given code
|
||||
* 'b': arg1 = const char* buf;
|
||||
* arg2 = size_t buf_length memory ptr
|
||||
* 'C': (no args) appends a HTTP CONNECTION: close header
|
||||
* depending on major,minor version
|
||||
* 'c': (no args) appends CRLF "\r\n"
|
||||
* 'D': (no args) appends HTTP DATE: header
|
||||
* 'd': arg = int number // appends decimal number
|
||||
* 'G': arg = range information // add range header
|
||||
* 'h': arg = off_t number // appends off_t number
|
||||
* 'K': (no args) // add chunky header
|
||||
* 'N': arg1 = off_t content_length // content-length header
|
||||
* 'q': arg1 = http_method_t // request start line and HOST header
|
||||
* arg2 = (uri_type *)
|
||||
* 'Q': arg1 = http_method_t; // start line of request
|
||||
* arg2 = char* url;
|
||||
* arg3 = size_t url_length
|
||||
* 'R': arg = int status_code // adds a response start line
|
||||
* 'S': (no args) appends HTTP SERVER: header
|
||||
* 's': arg = const char* C_string
|
||||
* 'T': arg = char * content_type; format
|
||||
* e.g: "text/html"; content-type header
|
||||
* 't': arg = time_t * gmt_time // appends time in RFC 1123 fmt
|
||||
* 'U': (no args) appends HTTP USER-AGENT: header
|
||||
* 'X': arg = const char useragent; "redsonic" HTTP X-User-Agent: useragent
|
||||
*
|
||||
* Return: int
|
||||
* 0 - On Success
|
||||
* UPNP_E_OUTOF_MEMORY
|
||||
* UPNP_E_INVALID_URL
|
||||
************************************************************************/
|
||||
* \return
|
||||
* \li \c 0 - On Success
|
||||
* \li \c UPNP_E_OUTOF_MEMORY
|
||||
* \li \c UPNP_E_INVALID_URL
|
||||
*/
|
||||
int http_MakeMessage(
|
||||
/* [in,out] Buffer with the contents of the message. */
|
||||
INOUT membuffer* buf,
|
||||
/* [in] HTTP major version. */
|
||||
IN int http_major_version,
|
||||
/* [in] HTTP minor version. */
|
||||
IN int http_minor_version,
|
||||
IN const char* fmt, ... );
|
||||
/* [in] Pattern format. */
|
||||
IN const char* fmt,
|
||||
/* [in] Format arguments. */
|
||||
... );
|
||||
|
||||
|
||||
/************************************************************************
|
||||
|
@ -110,7 +110,7 @@ int sock_read(
|
||||
/*! Buffer to get data to. */
|
||||
OUT char* buffer,
|
||||
/*! Size of the buffer. */
|
||||
IN size_t bufsize,
|
||||
IN int bufsize,
|
||||
/*! timeout value. */
|
||||
INOUT int *timeoutSecs);
|
||||
|
||||
@ -126,9 +126,9 @@ int sock_write(
|
||||
/*! Socket Information Object. */
|
||||
IN SOCKINFO *info,
|
||||
/*! Buffer to send data from. */
|
||||
IN char* buffer,
|
||||
IN const char *buffer,
|
||||
/*! Size of the buffer. */
|
||||
IN size_t bufsize,
|
||||
IN int bufsize,
|
||||
/*! timeout value. */
|
||||
INOUT int *timeoutSecs);
|
||||
|
||||
|
@ -247,7 +247,7 @@ int token_string_casecmp(
|
||||
/*! [in] Token object whose buffer is to be compared. */
|
||||
token *in1,
|
||||
/*! [in] String of characters to compare with. */
|
||||
char *in2);
|
||||
const char *in2);
|
||||
|
||||
/*!
|
||||
* \brief Compares a null terminated string to a token (exact).
|
||||
|
@ -157,7 +157,6 @@ int AdvertiseAndReply(
|
||||
if (NumCopy != 0)
|
||||
imillisleep(SSDP_PAUSE);
|
||||
NumCopy++;
|
||||
|
||||
for (i = 0;; i++) {
|
||||
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
|
||||
"Entering new device list with i = %lu\n\n", i);
|
||||
@ -168,31 +167,29 @@ int AdvertiseAndReply(
|
||||
break;
|
||||
}
|
||||
dbgStr = ixmlNode_getNodeName(tmpNode);
|
||||
|
||||
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
|
||||
"Extracting device type once for %s\n", dbgStr);
|
||||
ixmlNodeList_free(nodeList);
|
||||
nodeList = ixmlElement_getElementsByTagName(
|
||||
(IXML_Element *)tmpNode, "deviceType");
|
||||
if (!nodeList) continue;
|
||||
|
||||
if (!nodeList)
|
||||
continue;
|
||||
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
|
||||
"Extracting UDN for %s\n", dbgStr);
|
||||
dbgStr = ixmlNode_getNodeName(tmpNode);
|
||||
|
||||
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
|
||||
"Extracting device type\n");
|
||||
tmpNode2 = ixmlNodeList_item(nodeList, 0);
|
||||
if (!tmpNode2) continue;
|
||||
|
||||
if (!tmpNode2)
|
||||
continue;
|
||||
textNode = ixmlNode_getFirstChild(tmpNode2);
|
||||
if (!textNode) continue;
|
||||
|
||||
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
|
||||
"Extracting device type \n");
|
||||
tmpStr = ixmlNode_getNodeValue(textNode);
|
||||
if (!tmpStr) continue;
|
||||
|
||||
if (!tmpStr)
|
||||
continue;
|
||||
strcpy(devType, tmpStr);
|
||||
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
|
||||
"Extracting device type = %s\n", devType);
|
||||
@ -201,7 +198,6 @@ int AdvertiseAndReply(
|
||||
"TempNode is NULL\n");
|
||||
}
|
||||
dbgStr = ixmlNode_getNodeName(tmpNode);
|
||||
|
||||
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
|
||||
"Extracting UDN for %s\n", dbgStr);
|
||||
ixmlNodeList_free(nodeList);
|
||||
@ -226,8 +222,8 @@ int AdvertiseAndReply(
|
||||
}
|
||||
tmpStr = ixmlNode_getNodeValue(textNode);
|
||||
if (!tmpStr) {
|
||||
UpnpPrintf(UPNP_CRITICAL, API, __FILE__, __LINE__,
|
||||
"UDN not found!\n");
|
||||
UpnpPrintf(UPNP_CRITICAL, API, __FILE__,
|
||||
__LINE__, "UDN not found!\n");
|
||||
continue;
|
||||
}
|
||||
strcpy(UDNstr, tmpStr);
|
||||
@ -237,11 +233,13 @@ int AdvertiseAndReply(
|
||||
/* send the device advertisement */
|
||||
if (AdFlag == 1) {
|
||||
DeviceAdvertisement(devType, i == 0,
|
||||
UDNstr, SInfo->DescURL, Exp, SInfo->DeviceAf );
|
||||
UDNstr, SInfo->DescURL, Exp,
|
||||
SInfo->DeviceAf);
|
||||
} else {
|
||||
/* AdFlag == -1 */
|
||||
DeviceShutdown(devType, i == 0, UDNstr,
|
||||
SERVER, SInfo->DescURL, Exp, SInfo->DeviceAf );
|
||||
SERVER, SInfo->DescURL, Exp,
|
||||
SInfo->DeviceAf);
|
||||
}
|
||||
} else {
|
||||
switch (SearchType) {
|
||||
|
@ -31,21 +31,19 @@
|
||||
system dependent call to get IEEE node ID.
|
||||
This sample implementation generates a random node ID
|
||||
*/
|
||||
void
|
||||
get_ieee_node_identifier(uuid_node_t *node)
|
||||
void get_ieee_node_identifier(uuid_node_t *node)
|
||||
{
|
||||
unsigned char seed[16];
|
||||
static int inited = 0;
|
||||
static uuid_node_t saved_node;
|
||||
unsigned char seed[16];
|
||||
static int inited = 0;
|
||||
static uuid_node_t saved_node;
|
||||
|
||||
if (!inited) {
|
||||
get_random_info(seed);
|
||||
seed[0] |= 0x80;
|
||||
memcpy(&saved_node, seed, sizeof (uuid_node_t));
|
||||
inited = 1;
|
||||
};
|
||||
|
||||
*node = saved_node;
|
||||
if (!inited) {
|
||||
get_random_info(seed);
|
||||
seed[0] |= 0x80;
|
||||
memcpy(&saved_node, seed, sizeof(uuid_node_t));
|
||||
inited = 1;
|
||||
};
|
||||
*node = saved_node;
|
||||
};
|
||||
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
@ -57,31 +55,25 @@ get_ieee_node_identifier(uuid_node_t *node)
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
void
|
||||
get_system_time( uuid_time_t * uuid_time )
|
||||
void get_system_time(uuid_time_t *uuid_time)
|
||||
{
|
||||
ULARGE_INTEGER time;
|
||||
|
||||
GetSystemTimeAsFileTime( ( FILETIME * ) & time );
|
||||
|
||||
/*
|
||||
NT keeps time in FILETIME format which is 100ns ticks since
|
||||
Jan 1, 1601. UUIDs use time in 100ns ticks since Oct 15, 1582.
|
||||
The difference is 17 Days in Oct + 30 (Nov) + 31 (Dec)
|
||||
+ 18 years and 5 leap days.
|
||||
*/
|
||||
|
||||
time.QuadPart += ( unsigned __int64 )( 1000 * 1000 * 10 ) /* seconds */
|
||||
* ( unsigned __int64 )( 60 * 60 * 24 ) /* days */
|
||||
* ( unsigned __int64 )( 17 + 30 + 31 + 365 * 18 + 5 ); /* # of days */
|
||||
|
||||
*uuid_time = time.QuadPart;
|
||||
ULARGE_INTEGER time;
|
||||
|
||||
GetSystemTimeAsFileTime((FILETIME *) & time);
|
||||
/*
|
||||
NT keeps time in FILETIME format which is 100ns ticks since
|
||||
Jan 1, 1601. UUIDs use time in 100ns ticks since Oct 15, 1582.
|
||||
The difference is 17 Days in Oct + 30 (Nov) + 31 (Dec)
|
||||
+ 18 years and 5 leap days.
|
||||
*/
|
||||
time.QuadPart += (unsigned __int64)(1000 * 1000 * 10) /* seconds */
|
||||
*(unsigned __int64)(60 * 60 * 24) /* days */
|
||||
*(unsigned __int64)(17 + 30 + 31 + 365 * 18 + 5); /* # of days */
|
||||
*uuid_time = time.QuadPart;
|
||||
};
|
||||
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
void
|
||||
get_random_info(char seed[16])
|
||||
void get_random_info(char seed[16])
|
||||
{
|
||||
MD5_CTX c;
|
||||
typedef struct {
|
||||
@ -121,25 +113,22 @@ get_random_info(char seed[16])
|
||||
#else /* WIN32 */
|
||||
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
void
|
||||
get_system_time(uuid_time_t *uuid_time)
|
||||
void get_system_time(uuid_time_t *uuid_time)
|
||||
{
|
||||
struct timeval tp;
|
||||
struct timeval tp;
|
||||
|
||||
gettimeofday( &tp, ( struct timezone * )0 );
|
||||
|
||||
/*
|
||||
Offset between UUID formatted times and Unix formatted times.
|
||||
UUID UTC base time is October 15, 1582.
|
||||
Unix base time is January 1, 1970.
|
||||
*/
|
||||
*uuid_time = ( tp.tv_sec * 10000000 ) + ( tp.tv_usec * 10 ) +
|
||||
I64( 0x01B21DD213814000 );
|
||||
gettimeofday(&tp, (struct timezone *)0);
|
||||
/*
|
||||
Offset between UUID formatted times and Unix formatted times.
|
||||
UUID UTC base time is October 15, 1582.
|
||||
Unix base time is January 1, 1970.
|
||||
*/
|
||||
*uuid_time = (uuid_time_t) (tp.tv_sec * 10000000 + tp.tv_usec * 10 +
|
||||
I64(0x01B21DD213814000));
|
||||
};
|
||||
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
void
|
||||
get_random_info(unsigned char seed[16])
|
||||
void get_random_info(unsigned char seed[16])
|
||||
{
|
||||
MD5_CTX c;
|
||||
typedef struct {
|
||||
|
Loading…
Reference in New Issue
Block a user