* EXPORT_SPEC missing on some declarations in ixml/inc/ixml.h.

Thanks to David Maass.

* sizeof is unsigned, so %zu is more adequate than %zd.

* Using an invented printf directive PRIzu that on MSVC
expands to "lu", and on normal C99 compilers expands to "zu".

* Rewrote raw_find_str. Now it no longer uses strcasestr(), but it
transforms the first input buffer into lowercase.



git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@184 119443c7-1b9e-41f8-b6fc-b9c35fce742c
This commit is contained in:
Marcelo Roberto Jimenez 2007-05-16 02:02:16 +00:00
parent 3fa207984a
commit 4ceb6c67d1
8 changed files with 109 additions and 68 deletions

View File

@ -2,6 +2,21 @@
Version 1.4.7
*************************************************************************
2007-05-15 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
* EXPORT_SPEC missing on some declarations in ixml/inc/ixml.h.
Thanks to David Maass.
2007-05-15 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
* sizeof is unsigned, so %zu is more adequate than %zd.
2007-05-15 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
* Using an invented printf directive PRIzu that on MSVC
expands to "lu", and on normal C99 compilers expands to "zu".
2007-05-15 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
* Rewrote raw_find_str. Now it no longer uses strcasestr(), but it
transforms the first input buffer into lowercase.
2007-05-08 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
* Fix for debug printf format strings. size_t are not expected
in a string format like "%.*s".

View File

@ -1738,7 +1738,7 @@ ixmlNodeList_free(IXML_NodeList *nList
* of the DOM tree or {\tt NULL} on an error.
*/
DOMString
EXPORT_SPEC DOMString
ixmlPrintDocument(IXML_Document *doc);
/** Renders a {\bf Node} and all sub-elements into an XML text
@ -1756,7 +1756,7 @@ ixmlPrintDocument(IXML_Document *doc);
* of the DOM tree or {\tt NULL} on an error.
*/
DOMString
EXPORT_SPEC DOMString
ixmlPrintNode(IXML_Node *doc
/** The root of the {\bf Node} tree to render to XML text. */
);
@ -1777,7 +1777,7 @@ ixmlPrintNode(IXML_Node *doc
* of the DOM tree or {\tt NULL} on an error.
*/
DOMString
EXPORT_SPEC DOMString
ixmlDocumenttoString(IXML_Document *doc);
/** Renders a {\bf Node} and all sub-elements into an XML text
@ -1809,7 +1809,7 @@ ixmlNodetoString(IXML_Node *doc
* characters are replaced by the {\bf errorChar}, and invalid "&" entities
* are left untranslated. The parsing is then allowed to continue.
*/
void
EXPORT_SPEC void
ixmlRelaxParser(char errorChar);

View File

@ -36,66 +36,77 @@
//@{
#if defined MYLIB_LARGEFILE_SENSITIVE && _FILE_OFFSET_BITS+0 != 64
#if defined __GNUC__
#warning libupnp requires largefile mode - use AC_SYS_LARGEFILE
#else
#error libupnp requires largefile mode - use AC_SYS_LARGEFILE
#endif
#if defined __GNUC__
#warning libupnp requires largefile mode - use AC_SYS_LARGEFILE
#else
#error libupnp requires largefile mode - use AC_SYS_LARGEFILE
#endif
#endif
#include <stdio.h>
#ifdef __FreeBSD__
#include <time.h>
#include <time.h>
#endif
#include "ixml.h"
#include "upnpconfig.h"
#if UPNP_HAVE_DEBUG
# include "upnpdebug.h"
#include "upnpdebug.h"
#endif
#ifdef WIN32
#ifndef UPNP_STATIC_LIB
#ifdef LIBUPNP_EXPORTS
// set up declspec for dll export to make functions visible to library users
#define EXPORT_SPEC __declspec(dllexport)
#else
#define EXPORT_SPEC __declspec(dllimport)
#endif
#else
#define EXPORT_SPEC
#endif
#ifdef UPNP_USE_MSVCPP // define some things the M$ VC++ doesn't knows
typedef __int64 int64_t;
#endif
#ifdef UPNP_USE_BCBPP // define some things Borland Builder doesn't knows
typedef __int64 int64_t;
#endif
#ifndef UPNP_STATIC_LIB
#ifdef LIBUPNP_EXPORTS
// set up declspec for dll export to make functions visible to library users
#define EXPORT_SPEC __declspec(dllexport)
#else
#define EXPORT_SPEC __declspec(dllimport)
#endif
#else
#define EXPORT_SPEC
#endif
#ifdef UPNP_USE_MSVCPP // define some things the M$ VC++ doesn't know
typedef __int64 int64_t;
#define PRId64 "I64d"
#define PRIzu "lu"
#endif
#ifdef UPNP_USE_BCBPP // define some things Borland Builder doesn't know
typedef __int64 int64_t;
#define PRIzu "zu"
#endif
#else
#define EXPORT_SPEC
#define EXPORT_SPEC
#define PRIzu "zu"
#endif
#ifndef WIN32
#define UpnpCloseSocket close
#define UpnpCloseSocket close
#else
#define UpnpCloseSocket closesocket
#define fseeko fseek
#define UpnpCloseSocket closesocket
#define fseeko fseek
#endif
#define UPNP_SOCKETERROR -1
#define UPNP_INVALID_SOCKET -1
#ifndef WIN32
#define SOCKET int
#define SOCKET int
#endif
#ifndef WIN32
#include <netinet/in.h>
#include <netinet/in.h>
#else
#include <winsock2.h>
#include <time.h>
#include <winsock2.h>
#include <time.h>
#endif
#include <sys/types.h>
#define NUM_HANDLE 200
#define LINE_SIZE 180
#define NAME_SIZE 256
@ -104,7 +115,6 @@
#define SERL_NUMR_SIZE 64
#define MODL_DESC_SIZE 64
#define UPNP_INFINITE -1
#define UPNP_USING_CHUNKED -3
#define UPNP_UNTIL_CLOSE -4
@ -2724,3 +2734,4 @@ EXPORT_SPEC void UpnpFree(
//@} The API
#endif

View File

@ -574,7 +574,7 @@ genaInitNotify( IN UpnpDevice_Handle device_handle,
}
sprintf( headers, "CONTENT-TYPE: text/xml\r\nCONTENT-LENGTH: "
"%zd\r\nNT: upnp:event\r\nNTS: upnp:propchange\r\n",
"%"PRIzu"\r\nNT: upnp:event\r\nNTS: upnp:propchange\r\n",
strlen( propertySet ) + 1 );
//schedule thread for initial notification

View File

@ -2414,37 +2414,50 @@ raw_to_int( IN memptr * raw_value,
}
/************************************************************************
* Function: raw_find_str
*
* Parameters:
* IN memptr* raw_value ; Buffer containg the string
* IN const char* str ; Substring to be found
*
* Description: Find a substring from raw character string buffer
*
* Returns:
* Function: raw_find_str
*
* Parameters:
* IN memptr* raw_value ; Buffer containg the string
* IN const char* str ; Substring to be found
*
* Description: Find a substring from raw character string buffer
*
* Side effects: raw_value is transformed to lowercase.
*
* Returns:
* int - index at which the substring is found.
************************************************************************/
int
raw_find_str( IN memptr * raw_value,
raw_find_str( IN memptr *raw_value,
IN const char *str )
{
char c;
char *ptr;
int i = 0;
c = raw_value->buf[raw_value->length]; // save
raw_value->buf[raw_value->length] = 0; // null-terminate
// save
c = raw_value->buf[raw_value->length];
// Use strcasestr because the string may not always be exact case
ptr = strcasestr( raw_value->buf, str );
// Make it lowercase
for (i = 0; raw_value->buf[i]; ++i) {
raw_value->buf[i] = tolower(raw_value->buf[i]);
}
raw_value->buf[raw_value->length] = c; // restore
// null-terminate
raw_value->buf[raw_value->length] = 0;
// Find the substring position
ptr = strstr( raw_value->buf, str );
// restore the "length" byte
raw_value->buf[raw_value->length] = c;
if( ptr == 0 ) {
return -1;
}
return ptr - raw_value->buf; // return index
// return index
return ptr - raw_value->buf;
}
/************************************************************************

View File

@ -643,7 +643,7 @@ http_Download( IN const char *url_str,
*temp = '/';
DBGONLY( UpnpPrintf
( UPNP_INFO, HTTP, __FILE__, __LINE__,
"HOSTNAME : %s Length : %zu\n", hoststr, hostlen );
"HOSTNAME : %s Length : %"PRIzu"\n", hoststr, hostlen );
)
ret_code = http_MakeMessage(
@ -800,7 +800,7 @@ MakePostMessage( const char *url_str,
hostlen = strlen( hoststr );
*temp = '/';
DBGONLY( UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
"HOSTNAME : %s Length : %zd\n", hoststr, hostlen );
"HOSTNAME : %s Length : %"PRIzu"\n", hoststr, hostlen );
)
if( contentLength >= 0 ) {
@ -1137,7 +1137,7 @@ MakeGetMessage( const char *url_str,
hostlen = strlen( hoststr );
*temp = '/';
DBGONLY( UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
"HOSTNAME : %s Length : %zd\n", hoststr, hostlen );
"HOSTNAME : %s Length : %"PRIzu"\n", hoststr, hostlen );
)
if( proxy_str ) {
@ -1906,7 +1906,7 @@ http_MakeMessage( INOUT membuffer * buf,
{
num = ( int )va_arg( argp, int );
sprintf( tempbuf, "%zu", num );
sprintf( tempbuf, "%"PRIzu, num );
if( membuffer_append( buf, tempbuf, strlen( tempbuf ) ) != 0 ) {
goto error_handler;
}
@ -2214,7 +2214,7 @@ MakeGetMessageEx( const char *url_str,
*temp = '/';
DBGONLY( UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
"HOSTNAME : %s Length : %zd\n",
"HOSTNAME : %s Length : %"PRIzu"\n",
hoststr, hostlen );
)

View File

@ -393,7 +393,7 @@ DBGONLY( void print_uri( uri_type * in ) {
************************************************************************/
DBGONLY( void print_token( token * in ) {
int i = 0;
printf( "Token Size : %zd\n\'", in->size );
printf( "Token Size : %"PRIzu"\n\'", in->size );
for( i = 0; i < in->size; i++ ) {
putchar( in->buff[i] );}
putchar( '\'' ); putchar( '\n' );}

View File

@ -448,15 +448,17 @@ int matchstr( IN char *str, IN size_t slen, IN const char* fmt, ... );
int raw_to_int( IN memptr* raw_value, int base );
/************************************************************************
* Function: raw_find_str
*
* Parameters:
* IN memptr* raw_value ; Buffer containg the string
* IN const char* str ; Substring to be found
*
* Description: Find a substring from raw character string buffer
*
* Returns:
* Function: raw_find_str
*
* Parameters:
* IN memptr* raw_value ; Buffer containg the string
* IN const char* str ; Substring to be found
*
* Description: Find a substring from raw character string buffer
*
* Side effects: raw_value is transformed to lowercase.
*
* Returns:
* int - index at which the substring is found.
************************************************************************/
int raw_find_str( IN memptr* raw_value, IN const char* str );