Doxygen, reformating, compiler warnings.

This commit is contained in:
Marcelo Roberto Jimenez 2010-11-21 21:40:07 -02:00
parent 978f10449f
commit 9e7e7e3b89
13 changed files with 1710 additions and 2206 deletions

View File

@ -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. */

View File

@ -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);
@ -2888,18 +2888,15 @@ int UpnpHttpGetProgress(void *Handle, size_t *length, size_t *total)
int UpnpDownloadUrlItem(const char *url, char **outBuf, char *contentType)
{
int ret_code;
int dummy;
size_t dummy;
if( url == NULL || outBuf == NULL || contentType == NULL ) {
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 ) {
if (ret_code > 0)
/* error reply was received */
ret_code = UPNP_E_INVALID_URL;
}
return ret_code;
}

View File

@ -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;
}

View File

@ -139,11 +139,8 @@ static UPNP_INLINE void scanner_init(OUT scanner_t *scanner, IN membuffer *bufpt
*
* Description : Finds the separator character.
*
* Return : xboolean ;
*
* Note :
************************************************************************/
static UPNP_INLINE xboolean is_separator_char(IN char c)
static UPNP_INLINE int is_separator_char(IN char c)
{
return strchr(" \t()<>@,;:\\\"/[]?={}", c) != NULL;
}
@ -156,11 +153,8 @@ static UPNP_INLINE xboolean is_separator_char(IN char c)
*
* Description : Calls the function to indentify separator character
*
* Return : xboolean ;
*
* Note :
************************************************************************/
static UPNP_INLINE xboolean is_identifier_char(IN char c)
static UPNP_INLINE int is_identifier_char(IN char c)
{
return c >= 32 && c <= 126 && !is_separator_char(c);
}
@ -173,11 +167,8 @@ static UPNP_INLINE xboolean is_identifier_char(IN char c)
*
* Description : Determines if the passed value is a control character
*
* Return : xboolean ;
*
* Note :
************************************************************************/
static UPNP_INLINE xboolean is_control_char(IN char c)
static UPNP_INLINE int is_control_char(IN char c)
{
return (c >= 0 && c <= 31) || c == 127;
}
@ -190,11 +181,8 @@ static UPNP_INLINE xboolean is_control_char(IN char c)
*
* Description : Checks to see if the passed in value is CR/LF
*
* Return : xboolean ;
*
* Note :
************************************************************************/
static UPNP_INLINE xboolean is_qdtext_char(IN char cc)
static UPNP_INLINE int is_qdtext_char(IN char cc)
{
unsigned char c = ( unsigned char )cc;
@ -237,7 +225,7 @@ static parse_status_t scanner_get_token(
char *null_terminator; /* point to null-terminator in buffer */
char c;
token_type_t token_type;
xboolean got_end_quote;
int got_end_quote;
assert(scanner);
assert(token);
@ -246,50 +234,36 @@ static parse_status_t scanner_get_token(
/* point to next char in buffer */
cursor = scanner->msg->buf + scanner->cursor;
null_terminator = scanner->msg->buf + scanner->msg->length;
/* not enough chars in input to parse */
if( cursor == null_terminator ) {
if (cursor == null_terminator)
return PARSE_INCOMPLETE;
}
c = *cursor;
if (is_identifier_char(c)) {
/* scan identifier */
token->buf = cursor++;
token_type = TT_IDENTIFIER;
while( is_identifier_char( *cursor ) ) {
while (is_identifier_char(*cursor))
cursor++;
}
if( !scanner->entire_msg_loaded && cursor == null_terminator ) {
if (!scanner->entire_msg_loaded && cursor == null_terminator)
/* possibly more valid chars */
return PARSE_INCOMPLETE;
}
/* calc token length */
token->length = cursor - token->buf;
token->length = (size_t)(cursor - token->buf);
} else if (c == ' ' || c == '\t') {
token->buf = cursor++;
token_type = TT_WHITESPACE;
while( *cursor == ' ' || *cursor == '\t' ) {
while (*cursor == ' ' || *cursor == '\t')
cursor++;
}
if( !scanner->entire_msg_loaded && cursor == null_terminator ) {
if (!scanner->entire_msg_loaded && cursor == null_terminator)
/* possibly more chars */
return PARSE_INCOMPLETE;
}
token->length = cursor - token->buf;
token->length = (size_t)(cursor - token->buf);
} else if (c == TOKCHAR_CR) {
/* scan CRLF */
token->buf = cursor++;
if( cursor == null_terminator ) {
if (cursor == null_terminator)
/* not enuf info to determine CRLF */
return PARSE_INCOMPLETE;
}
if (*cursor != TOKCHAR_LF) {
/* couldn't match CRLF; match as CR */
token_type = TT_CTRL; /* ctrl char */
@ -300,8 +274,7 @@ static parse_status_t scanner_get_token(
token_type = TT_CRLF;
cursor++;
}
} else if( c == TOKCHAR_LF ) /* accept \n as CRLF */
{
} else if (c == TOKCHAR_LF) { /* accept \n as CRLF */
token->buf = cursor++;
token->length = 1;
token_type = TT_CRLF;
@ -310,7 +283,6 @@ static parse_status_t scanner_get_token(
token->buf = cursor++;
token_type = TT_QUOTEDSTRING;
got_end_quote = FALSE;
while (cursor < null_terminator) {
c = *cursor++;
if (c == '"') {
@ -320,40 +292,35 @@ static parse_status_t scanner_get_token(
if (cursor < null_terminator) {
c = *cursor++;
/*if ( !(c > 0 && c <= 127) ) */
if( c == 0 ) {
if (c == 0)
return PARSE_FAILURE;
}
}
/* else, while loop handles incomplete buf */
} else if (is_qdtext_char(c)) {
/* just accept char */
} else {
} else
/* bad quoted text */
return PARSE_FAILURE;
}
}
if( got_end_quote ) {
token->length = cursor - token->buf;
} else /* incomplete */
{
if (got_end_quote)
token->length = (size_t)(cursor - token->buf);
else { /* incomplete */
assert(cursor == null_terminator);
return PARSE_INCOMPLETE;
}
} else if (is_separator_char(c)) {
/* scan separator */
token->buf = cursor++;
token_type = TT_SEPARATOR;
token->length = 1;
} else if (is_control_char(c)) {
/* scan ctrl char */
token->buf = cursor++;
token_type = TT_CTRL;
token->length = 1;
} else {
} else
return PARSE_FAILURE;
}
scanner->cursor += token->length; /* move to next token */
*tok_type = token_type;
@ -596,7 +563,7 @@ static UPNP_INLINE int skip_lws(INOUT scanner_t *scanner)
token_type_t tok_type;
parse_status_t status;
size_t save_pos;
xboolean matched;
int matched;
do {
save_pos = scanner->cursor;
@ -651,7 +618,7 @@ static UPNP_INLINE parse_status_t match_non_ws_string(
memptr token;
token_type_t tok_type;
parse_status_t status;
xboolean done = FALSE;
int done = FALSE;
size_t save_cursor;
save_cursor = scanner->cursor;
@ -717,8 +684,8 @@ static UPNP_INLINE parse_status_t match_raw_value(
memptr token;
token_type_t tok_type;
parse_status_t status;
xboolean done = FALSE;
xboolean saw_crlf = FALSE;
int done = FALSE;
int saw_crlf = FALSE;
size_t pos_at_crlf = 0;
size_t save_pos;
char c;
@ -814,28 +781,23 @@ static UPNP_INLINE int match_int(
size_t save_pos;
save_pos = scanner->cursor;
status = scanner_get_token(scanner, &token, &tok_type);
if (status == PARSE_OK) {
if (tok_type == TT_IDENTIFIER) {
errno = 0;
num = strtol(token.buf, &end_ptr, base);
if( ( num < 0 )
/* all and only those chars in token should be used for num */
|| ( end_ptr != token.buf + token.length )
|| ( ( num == LONG_MIN || num == LONG_MAX )
&& ( errno == ERANGE ) )
) {
if (num < 0 || end_ptr != token.buf + token.length ||
((num == LONG_MIN || num == LONG_MAX) && (errno == ERANGE))) {
status = PARSE_NO_MATCH;
}
*value = num; /* save result */
/* save result */
*value = (int)num;
} else {
status = PARSE_NO_MATCH; /* token must be an identifier */
/* token must be an identifier */
status = PARSE_NO_MATCH;
}
}
if (status != PARSE_OK) {
/* restore scanner position for bad values */
scanner->cursor = save_pos;
@ -894,7 +856,7 @@ read_until_crlf( INOUT scanner_t * scanner,
* Parameters:
* INOUT scanner_t* scanner ; Scanner Object
* IN char c ; Character to be compared with
* IN xboolean case_sensitive; Flag indicating whether
* IN int case_sensitive; Flag indicating whether
* comparison should be case sensitive
*
* Description: Compares a character to the next char in the scanner;
@ -908,7 +870,7 @@ read_until_crlf( INOUT scanner_t * scanner,
static UPNP_INLINE parse_status_t
match_char( INOUT scanner_t * scanner,
IN char c,
IN xboolean case_sensitive )
IN int case_sensitive )
{
char scan_char;
@ -982,8 +944,8 @@ match_char( INOUT scanner_t * scanner,
*
* Note :
************************************************************************/
static int
vfmatch( INOUT scanner_t * scanner,
static int vfmatch(
INOUT scanner_t *scanner,
IN const char *fmt,
va_list argp)
{
@ -996,7 +958,7 @@ vfmatch( INOUT scanner_t * scanner,
uri_type *uri_ptr;
size_t save_pos;
int stat;
xboolean case_sensitive = TRUE;
int case_sensitive = TRUE;
memptr token;
token_type_t tok_type;
int base;
@ -1012,15 +974,12 @@ vfmatch( INOUT scanner_t * scanner,
) {
if( c == '%' ) {
c = *fmt_ptr++;
switch ( c ) {
case 'R': /* raw value */
str_ptr = va_arg( argp, memptr * );
assert( str_ptr != NULL );
status = match_raw_value( scanner, str_ptr );
break;
case 's': /* simple identifier */
str_ptr = va_arg( argp, memptr * );
assert( str_ptr != NULL );
@ -1031,7 +990,6 @@ vfmatch( INOUT scanner_t * scanner,
status = PARSE_NO_MATCH;
}
break;
case 'c': /* crlf */
status = scanner_get_token( scanner,
&token, &tok_type );
@ -1040,16 +998,13 @@ vfmatch( INOUT scanner_t * scanner,
status = PARSE_NO_MATCH;
}
break;
case 'd': /* integer */
case 'x': /* hex number */
int_ptr = va_arg(argp, int *);
assert(int_ptr != NULL);
base = ( c == 'd' ? 10 : 16 );
base = c == 'd' ? 10 : 16;
status = match_int(scanner, base, int_ptr);
break;
case 'S': /* non-whitespace string */
case 'U': /* uri */
if( c == 'S' ) {
@ -1069,26 +1024,21 @@ vfmatch( INOUT scanner_t * scanner,
}
}
break;
case 'L': /* string till eol */
str_ptr = va_arg( argp, memptr * );
assert( str_ptr != NULL );
status = read_until_crlf( scanner, str_ptr );
break;
case ' ': /* match space */
case '%': /* match percentage symbol */
status = match_char( scanner, c, case_sensitive );
break;
case 'n': /* case-sensitive match */
case_sensitive = TRUE;
break;
case 'i': /* ignore case */
case_sensitive = FALSE;
break;
case 'q': /* quoted string */
str_ptr = ( memptr * ) va_arg( argp, memptr * );
status =
@ -1097,8 +1047,8 @@ vfmatch( INOUT scanner_t * scanner,
status = PARSE_NO_MATCH; /* not a quoted string */
}
break;
case 'w': /* optional whitespace */
case 'w':
/* optional whitespace */
status = scanner_get_token( scanner,
&token, &tok_type );
if( status == PARSE_OK && tok_type != TT_WHITESPACE ) {
@ -1106,16 +1056,15 @@ vfmatch( INOUT scanner_t * scanner,
scanner->cursor -= token.length;
}
break;
case 'P': /* current pos of scanner */
case 'P':
/* current pos of scanner */
int_ptr = va_arg( argp, int * );
assert( int_ptr != NULL );
*int_ptr = scanner->cursor;
*int_ptr = (int)scanner->cursor;
break;
/* valid only in matchstr() */
case '0': /* end of msg? */
case '0':
/* end of msg? */
/* check that we are 1 beyond last char */
if( scanner->cursor == scanner->msg->length &&
scanner->msg->buf[scanner->cursor] == '\0' ) {
@ -1124,16 +1073,15 @@ vfmatch( INOUT scanner_t * scanner,
status = PARSE_NO_MATCH;
}
break;
default:
assert( 0 ); /* unknown option */
/* unknown option */
assert( 0 );
}
} else {
switch ( c ) {
case ' ': /* LWS* */
status = skip_lws( scanner );
break;
case '\t': /* Whitespace */
status = scanner_get_token( scanner,
&token, &tok_type );
@ -1142,7 +1090,6 @@ vfmatch( INOUT scanner_t * scanner,
status = PARSE_NO_MATCH;
}
break;
default: /* match characters */
{
status = match_char( scanner, c, case_sensitive );
@ -1150,7 +1097,6 @@ vfmatch( INOUT scanner_t * scanner,
}
}
}
if( status != PARSE_OK ) {
/* on error, restore original scanner pos */
scanner->cursor = save_pos;
@ -1175,8 +1121,8 @@ vfmatch( INOUT scanner_t * scanner,
* PARSE_NO_MATCH
* PARSE_INCOMPLETE
************************************************************************/
static int
match( INOUT scanner_t * scanner,
static int match(
INOUT scanner_t *scanner,
IN const char *fmt,
...)
{
@ -1397,8 +1343,7 @@ parser_parse_requestline( INOUT http_parser_t * parser )
* PARSE_SUCCESS
* PARSE_FAILURE
************************************************************************/
parse_status_t
parser_parse_responseline( INOUT http_parser_t * parser )
parse_status_t parser_parse_responseline(INOUT http_parser_t *parser)
{
parse_status_t status;
http_message_t *hmsg = &parser->msg;
@ -1406,78 +1351,58 @@ parser_parse_responseline( INOUT http_parser_t * parser )
char save_char;
int num_scanned;
int i;
size_t n;
char *p;
assert(parser->position == POS_RESPONSE_LINE);
status = skip_blank_lines(&parser->scanner);
if( status != PARSE_OK ) {
if (status != PARSE_OK)
return status;
}
/* response line */
/*status = match( &parser->scanner, "%ihttp%w/%w%d\t.\t%d\t%d\t%L%c", */
/* &hmsg->major_version, &hmsg->minor_version, */
/* &hmsg->status_code, &hmsg->status_msg ); */
status = match(&parser->scanner, "%ihttp%w/%w%L%c", &line);
if( status != PARSE_OK ) {
if (status != PARSE_OK)
return status;
}
save_char = line.buf[line.length];
line.buf[line.length] = '\0'; /* null-terminate */
/* scan http version and ret code */
num_scanned = sscanf(line.buf, "%d . %d %d",
&hmsg->major_version, &hmsg->minor_version,
&hmsg->status_code);
line.buf[line.length] = save_char; /* restore */
if( num_scanned != 3 ||
hmsg->major_version < 0 ||
if (num_scanned != 3 || hmsg->major_version < 0 ||
/* HTTP version equals to 1.0 should fail as required by the
* UPnP certification tool */
hmsg->minor_version < 1 || hmsg->status_code < 0 ) {
hmsg->minor_version < 1 || hmsg->status_code < 0)
/* bad response line */
return PARSE_FAILURE;
}
/* */
/* point to status msg */
/* */
p = line.buf;
/* skip 3 ints */
for (i = 0; i < 3; i++) {
/* go to start of num */
while( !isdigit( *p ) ) {
while (!isdigit(*p))
p++;
}
/* skip int */
while( isdigit( *p ) ) {
while (isdigit(*p))
p++;
}
}
/* whitespace must exist after status code */
if( *p != ' ' && *p != '\t' ) {
if (*p != ' ' && *p != '\t')
return PARSE_FAILURE;
}
/* skip whitespace */
while( *p == ' ' || *p == '\t' ) {
while (*p == ' ' || *p == '\t')
p++;
}
/* now, p is at start of status msg */
if( membuffer_assign( &hmsg->status_msg, p,
line.length - ( p - line.buf ) ) != 0 ) {
n = line.length - (size_t)(p - line.buf);
if (membuffer_assign(&hmsg->status_msg, p, n) != 0) {
/* out of mem */
parser->http_error_code = HTTP_INTERNAL_SERVER_ERROR;
return PARSE_FAILURE;
}
parser->position = POS_HEADERS; /* move to headers */
return PARSE_OK;
@ -1496,8 +1421,7 @@ parser_parse_responseline( INOUT http_parser_t * parser )
* PARSE_SUCCESS
* PARSE_FAILURE
************************************************************************/
parse_status_t
parser_parse_headers( INOUT http_parser_t * parser )
parse_status_t parser_parse_headers(INOUT http_parser_t *parser)
{
parse_status_t status;
memptr token;
@ -1518,17 +1442,12 @@ parser_parse_headers( INOUT http_parser_t * parser )
while (TRUE) {
save_pos = scanner->cursor;
/* */
/* check end of headers */
/* */
status = scanner_get_token(scanner, &token, &tok_type);
if (status != PARSE_OK) {
return status;
}
if (tok_type == TT_CRLF) {
/* end of headers */
if ((parser->msg.is_request)
&& (parser->msg.method == HTTPMETHOD_POST)) {
@ -1536,108 +1455,90 @@ parser_parse_headers( INOUT http_parser_t * parser )
/*is handled separately */
return PARSE_SUCCESS;
}
parser->position = POS_ENTITY; /* read entity next */
return PARSE_OK;
}
/* */
/* not end; read header */
/* */
if (tok_type != TT_IDENTIFIER) {
return PARSE_FAILURE; /* didn't see header name */
}
status = match(scanner, " : %R%c", &hdr_value);
if (status != PARSE_OK) {
/* pushback tokens; useful only on INCOMPLETE error */
scanner->cursor = save_pos;
return status;
}
/* */
/* add header */
/* */
/* find header */
index = map_str_to_int( token.buf, token.length, Http_Header_Names,
index =
map_str_to_int(token.buf, token.length, Http_Header_Names,
NUM_HTTP_HEADER_NAMES, FALSE);
if (index != -1) {
/*Check if it is a soap header */
if (Http_Header_Names[index].id == HDR_SOAPACTION) {
parser->msg.method = SOAPMETHOD_POST;
}
header_id = Http_Header_Names[index].id;
orig_header =
httpmsg_find_hdr(&parser->msg, header_id, NULL);
} else {
header_id = HDR_UNKNOWN;
save_char = token.buf[token.length];
token.buf[token.length] = '\0';
orig_header = httpmsg_find_hdr_str( &parser->msg, token.buf );
orig_header =
httpmsg_find_hdr_str(&parser->msg, token.buf);
token.buf[token.length] = save_char; /* restore */
}
if (orig_header == NULL) {
/* */
/* add new header */
/* */
header = ( http_header_t * ) malloc( sizeof( http_header_t ) );
header =
(http_header_t *) malloc(sizeof(http_header_t));
if (header == NULL) {
parser->http_error_code = HTTP_INTERNAL_SERVER_ERROR;
parser->http_error_code =
HTTP_INTERNAL_SERVER_ERROR;
return PARSE_FAILURE;
}
membuffer_init(&header->name_buf);
membuffer_init(&header->value);
/* value can be 0 length */
if (hdr_value.length == 0) {
/* FIXME: Is this a bug? buf is not const. */
hdr_value.buf = "\0";
hdr_value.length = 1;
}
/* save in header in buffers */
if( membuffer_assign
( &header->name_buf, token.buf, token.length ) != 0
|| membuffer_assign( &header->value, hdr_value.buf,
hdr_value.length ) != 0 ) {
/* not enuf mem */
if (membuffer_assign(&header->name_buf, token.buf, token.length) ||
membuffer_assign(&header->value, hdr_value.buf, hdr_value.length)) {
/* not enough mem */
free(header);
parser->http_error_code = HTTP_INTERNAL_SERVER_ERROR;
return PARSE_FAILURE;
}
header->name.buf = header->name_buf.buf;
header->name.length = header->name_buf.length;
header->name_id = header_id;
ListAddTail(&parser->msg.headers, header);
/*NNS: ret = dlist_append( &parser->msg.headers, header ); */
/** TODO: remove that? */
if (ret == UPNP_E_OUTOF_MEMORY) {
parser->http_error_code = HTTP_INTERNAL_SERVER_ERROR;
parser->http_error_code =
HTTP_INTERNAL_SERVER_ERROR;
return PARSE_FAILURE;
}
/** end of remove that? */
} else if (hdr_value.length > 0) {
/* */
/* append value to existing header */
/* */
/* append space */
ret = membuffer_append_str(&orig_header->value, ", ");
/* append continuation of header value */
ret2 = membuffer_append(&orig_header->value,
hdr_value.buf, hdr_value.length );
if( ret == UPNP_E_OUTOF_MEMORY || ret2 == UPNP_E_OUTOF_MEMORY ) {
hdr_value.buf,
hdr_value.length);
if (ret == UPNP_E_OUTOF_MEMORY
|| ret2 == UPNP_E_OUTOF_MEMORY) {
/* not enuf mem */
parser->http_error_code = HTTP_INTERNAL_SERVER_ERROR;
parser->http_error_code =
HTTP_INTERNAL_SERVER_ERROR;
return PARSE_FAILURE;
}
}
@ -1706,36 +1607,35 @@ parser_parse_entity_using_clen( INOUT http_parser_t * parser )
* PARSE_FAILURE -- entity length > content-length value
* PARSE_SUCCESS
************************************************************************/
static UPNP_INLINE parse_status_t
parser_parse_chunky_body( INOUT http_parser_t * parser )
static UPNP_INLINE parse_status_t parser_parse_chunky_body(
INOUT http_parser_t *parser)
{
parse_status_t status;
size_t save_pos;
/* if 'chunk_size' of bytes have been read; read next chunk */
if( ( int )( parser->msg.msg.length - parser->scanner.cursor ) >=
parser->chunk_size ) {
if ((int)(parser->msg.msg.length - parser->scanner.cursor) >= parser->chunk_size) {
/* move to next chunk */
parser->scanner.cursor += parser->chunk_size;
save_pos = parser->scanner.cursor;
/* discard CRLF */
status = match(&parser->scanner, "%c");
if (status != PARSE_OK) {
parser->scanner.cursor -= parser->chunk_size; /*move back */
/*move back */
parser->scanner.cursor -= parser->chunk_size;
/*parser->scanner.cursor = save_pos; */
return status;
}
membuffer_delete(&parser->msg.msg, save_pos,
(parser->scanner.cursor - save_pos));
parser->scanner.cursor = save_pos;
parser->msg.entity.length += parser->chunk_size; /*update temp */
/*update temp */
parser->msg.entity.length += parser->chunk_size;
parser->ent_position = ENTREAD_USING_CHUNKED;
return PARSE_CONTINUE_1;
} else {
return PARSE_INCOMPLETE; /* need more data for chunk */
}
} else
/* need more data for chunk */
return PARSE_INCOMPLETE;
}
/************************************************************************
@ -1943,11 +1843,7 @@ parser_get_entity_read_method( INOUT http_parser_t * parser )
}
/* * use content length */
if( httpmsg_find_hdr( hmsg, HDR_CONTENT_LENGTH, &hdr_value ) ) {
parser->content_length = raw_to_int( &hdr_value, 10 );
if( parser->content_length < 0 ) {
/* bad content-length */
return PARSE_FAILURE;
}
parser->content_length = (unsigned int)raw_to_int(&hdr_value, 10);
parser->ent_position = ENTREAD_USING_CLEN;
return PARSE_CONTINUE_1;
}
@ -2175,10 +2071,8 @@ int raw_to_int(IN memptr *raw_value, IN int base)
long num;
char *end_ptr;
if( raw_value->length == 0 ) {
if (raw_value->length == 0)
return -1;
}
errno = 0;
num = strtol(raw_value->buf, &end_ptr, base);
if ((num < 0)
@ -2189,8 +2083,7 @@ int raw_to_int(IN memptr *raw_value, IN int base)
) {
return -1;
}
return num;
return (int)num;
}
/************************************************************************
@ -2218,7 +2111,7 @@ int raw_find_str(IN memptr *raw_value, IN const char *str)
/* Make it lowercase */
for (i = 0; raw_value->buf[i]; ++i) {
raw_value->buf[i] = tolower(raw_value->buf[i]);
raw_value->buf[i] = (char)tolower(raw_value->buf[i]);
}
/* null-terminate */
@ -2235,7 +2128,7 @@ int raw_find_str(IN memptr *raw_value, IN const char *str)
}
/* return index */
return ptr - raw_value->buf;
return (int)(ptr - raw_value->buf);
}
/************************************************************************

File diff suppressed because it is too large Load Diff

View File

@ -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);

View File

@ -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,37 +120,35 @@ 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
{
int old;
@ -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 (int)numBytes;
}
return 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);
}

View File

@ -271,50 +271,43 @@ void print_uri(uri_type *in)
#ifdef DEBUG
void print_token(token * in)
{
int i = 0;
size_t i = 0;
printf("Token Size : %" PRIzu "\n\'", in->size);
for( i = 0; i < in->size; i++ ) {
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,
@ -330,26 +323,22 @@ int parse_hostport(
char *last_dot = NULL;
unsigned short int port;
int af = AF_UNSPEC;
int hostport_size;
size_t hostport_size;
int has_port = 0;
int ret;
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 != ']' ) {
while (*c != '\0' && *c != ']')
c++;
}
if( *c == '\0' ) {
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 == ':') {
@ -357,11 +346,11 @@ int parse_hostport(
c++;
}
af = AF_INET6;
}
else {
} else {
/* IPv4 address -OR- host name. */
srvname = c;
while( (*c != ':') && (*c != '/') && ( (isalnum(*c)) || (*c == '.') || (*c == '-') ) ) {
while (*c != ':' && *c != '/' &&
(isalnum(*c) || *c == '.' || *c == '-')) {
if (*c == '.')
last_dot = c;
c++;
@ -371,11 +360,9 @@ int parse_hostport(
*c = '\0';
if (has_port == 1)
c++;
if( last_dot != NULL && isdigit(*(last_dot+1)) ) {
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;
@ -390,54 +377,43 @@ int parse_hostport(
if (res->ai_family == AF_INET ||
res->ai_family == AF_INET6) {
/* Found a valid IPv4 or IPv6 address. */
memcpy( &out->IPaddress, res->ai_addr,
memcpy(&out->IPaddress,
res->ai_addr,
res->ai_addrlen);
break;
}
}
freeaddrinfo(res0);
if( res == NULL ) {
if (res == NULL)
/* Didn't find an AF_INET or AF_INET6 address. */
return UPNP_E_INVALID_URL;
}
}
else {
} 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) ) {
while (*c != '\0' && isdigit(*c))
c++;
}
port = (unsigned short int)atoi(srvport);
if( port == 0 ) {
if (port == 0)
/* Bad port number. */
return UPNP_E_INVALID_URL;
}
}
else {
} 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);
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 ) {
} else if (af == AF_INET6) {
sai6->sin6_family = AF_INET6;
sai6->sin6_port = htons(port);
sai6->sin6_scope_id = gIF_INDEX;
@ -451,16 +427,13 @@ int parse_hostport(
sai6->sin6_port = htons(port);
ret = 1;
}
/* Check if address was converted successfully. */
if (ret <= 0) {
if (ret <= 0)
return UPNP_E_INVALID_URL;
}
out->text.size = hostport_size;
out->text.buff = in;
return hostport_size;
return (int)hostport_size;
max = max;
}

View File

@ -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
*
* 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
*
* 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
************************************************************************/
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);
/************************************************************************
* Function: http_OpenHttpGetProxy
*
* 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
*
* Description:
* Makes the HTTP GET message, connects to the peer,
/*!
* \brief 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_OpenHttpGet(
/* [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);
/*!
* \brief 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 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. */
... );
/************************************************************************

View File

@ -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);

View File

@ -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).

View File

@ -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) {

View File

@ -31,8 +31,7 @@
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;
@ -44,7 +43,6 @@ get_ieee_node_identifier(uuid_node_t *node)
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;
};
/*-----------------------------------------------------------------------------*/
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;
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 );
*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 {