Fixed a printf format problem on the upnp_tv_device.c from both

upnp/sample/tvdevie and upnp/sample/tvcombo directories. The variable
port was a short int instead of an unsigned short and it was beeing
print as a negative value.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@332 119443c7-1b9e-41f8-b6fc-b9c35fce742c
This commit is contained in:
Marcelo Roberto Jimenez
2008-03-09 02:10:18 +00:00
parent 0b39b2ad6c
commit 3846fcc9ba
5 changed files with 100 additions and 64 deletions

View File

@@ -2,6 +2,12 @@
Version 1.6.6 Version 1.6.6
******************************************************************************* *******************************************************************************
2008-03-08 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
* Fixed a printf format problem on the upnp_tv_device.c from both
upnp/sample/tvdevie and upnp/sample/tvcombo directories. The variable
port was a short int instead of an unsigned short and it was beeing
print as a negative value.
2008-03-08 Marcelo Jimenez <mroberto(at)users.sourceforge.net> 2008-03-08 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
* SF Bug Tracker [ 1902668 ] Cannot compile on MSVC * SF Bug Tracker [ 1902668 ] Cannot compile on MSVC
Submitted By Luke Kim - nereusuj Submitted By Luke Kim - nereusuj

View File

@@ -1354,7 +1354,7 @@ TvCtrlPointStart( print_string printFunctionPtr,
{ {
ithread_t timer_thread; ithread_t timer_thread;
int rc; int rc;
short int port = 0; unsigned short port = 0;
char *ip_address = NULL; char *ip_address = NULL;
SampleUtil_Initialize( printFunctionPtr ); SampleUtil_Initialize( printFunctionPtr );
@@ -1362,34 +1362,42 @@ TvCtrlPointStart( print_string printFunctionPtr,
ithread_mutex_init( &DeviceListMutex, 0 ); ithread_mutex_init( &DeviceListMutex, 0 );
SampleUtil_Print( "Intializing UPnP with ipaddress=%s port=%d", SampleUtil_Print(
"Initializing UPnP Sdk with\n"
"\tipaddress = %s port = %u\n",
ip_address, port ); ip_address, port );
rc = UpnpInit( ip_address, port ); rc = UpnpInit( ip_address, port );
if( UPNP_E_SUCCESS != rc ) { if( UPNP_E_SUCCESS != rc ) {
SampleUtil_Print( "WinCEStart: UpnpInit() Error: %d", rc ); SampleUtil_Print( "WinCEStart: UpnpInit() Error: %d", rc );
//UpnpFinish( ); //UpnpFinish();
//return TV_ERROR; //return TV_ERROR;
} }
if( NULL == ip_address ) if( NULL == ip_address ) {
ip_address = UpnpGetServerIpAddress( ); ip_address = UpnpGetServerIpAddress();
if( 0 == port ) }
port = UpnpGetServerPort( ); if( 0 == port ) {
port = UpnpGetServerPort();
}
SampleUtil_Print( "UPnP Initialized (%s:%d)", ip_address, port ); SampleUtil_Print(
"UPnP Initialized\n"
"\tipaddress= %s port = %u\n",
ip_address, port );
SampleUtil_Print( "Registering Control Point" ); SampleUtil_Print( "Registering Control Point" );
rc = UpnpRegisterClient( TvCtrlPointCallbackEventHandler, rc = UpnpRegisterClient( TvCtrlPointCallbackEventHandler,
&ctrlpt_handle, &ctrlpt_handle ); &ctrlpt_handle, &ctrlpt_handle );
if( UPNP_E_SUCCESS != rc ) { if( UPNP_E_SUCCESS != rc ) {
SampleUtil_Print( "Error registering CP: %d", rc ); SampleUtil_Print( "Error registering CP: %d", rc );
UpnpFinish( ); UpnpFinish();
return TV_ERROR; return TV_ERROR;
} }
SampleUtil_Print( "Control Point Registered" ); SampleUtil_Print( "Control Point Registered" );
TvCtrlPointRefresh( ); TvCtrlPointRefresh();
// start a timer thread // start a timer thread
ithread_create( &timer_thread, NULL, TvCtrlPointTimerLoop, NULL ); ithread_create( &timer_thread, NULL, TvCtrlPointTimerLoop, NULL );

View File

@@ -1958,32 +1958,37 @@ TvDeviceStart( char *ip_address,
SampleUtil_Initialize( pfun ); SampleUtil_Initialize( pfun );
SampleUtil_Print SampleUtil_Print(
( "Initializing UPnP Sdk with \n \t ipaddress = %s port = %d\n", "Initializing UPnP Sdk with\n"
"\tipaddress = %s port = %u\n",
ip_address, port ); ip_address, port );
if( ( ret = UpnpInit( ip_address, port ) ) != UPNP_E_SUCCESS ) { if( ( ret = UpnpInit( ip_address, port ) ) != UPNP_E_SUCCESS ) {
SampleUtil_Print( "Error with UpnpInit -- %d\n", ret ); SampleUtil_Print( "Error with UpnpInit -- %d\n", ret );
UpnpFinish( ); UpnpFinish();
return ret; return ret;
} }
if( ip_address == NULL ) { if( ip_address == NULL ) {
ip_address = UpnpGetServerIpAddress( ); ip_address = UpnpGetServerIpAddress();
} }
if( port == 0 ) { if( port == 0 ) {
port = UpnpGetServerPort( ); port = UpnpGetServerPort();
} }
SampleUtil_Print( "UPnP Initialized\n \t ipaddress= %s port = %d\n", SampleUtil_Print(
"UPnP Initialized\n"
"\tipaddress= %s port = %u\n",
ip_address, port ); ip_address, port );
if( desc_doc_name == NULL ) if( desc_doc_name == NULL ) {
desc_doc_name = "tvcombodesc.xml"; desc_doc_name = "tvcombodesc.xml";
}
if( web_dir_path == NULL ) if( web_dir_path == NULL ) {
web_dir_path = DEFAULT_WEB_DIR; web_dir_path = DEFAULT_WEB_DIR;
}
snprintf( desc_doc_url, DESC_URL_SIZE, "http://%s:%d/%s", ip_address, snprintf( desc_doc_url, DESC_URL_SIZE, "http://%s:%d/%s", ip_address,
port, desc_doc_name ); port, desc_doc_name );
@@ -1995,12 +2000,13 @@ TvDeviceStart( char *ip_address,
SampleUtil_Print SampleUtil_Print
( "Error specifying webserver root directory -- %s: %d\n", ( "Error specifying webserver root directory -- %s: %d\n",
web_dir_path, ret ); web_dir_path, ret );
UpnpFinish( ); UpnpFinish();
return ret; return ret;
} }
SampleUtil_Print SampleUtil_Print(
( "Registering the RootDevice\n\t with desc_doc_url: %s\n", "Registering the RootDevice\n"
"\t with desc_doc_url: %s\n",
desc_doc_url ); desc_doc_url );
if( ( ret = UpnpRegisterRootDevice( desc_doc_url, if( ( ret = UpnpRegisterRootDevice( desc_doc_url,
@@ -2008,24 +2014,25 @@ TvDeviceStart( char *ip_address,
&device_handle, &device_handle ) ) &device_handle, &device_handle ) )
!= UPNP_E_SUCCESS ) { != UPNP_E_SUCCESS ) {
SampleUtil_Print( "Error registering the rootdevice : %d\n", ret ); SampleUtil_Print( "Error registering the rootdevice : %d\n", ret );
UpnpFinish( ); UpnpFinish();
return ret; return ret;
} else { } else {
SampleUtil_Print( "RootDevice Registered\n" ); SampleUtil_Print(
"RootDevice Registered\n"
SampleUtil_Print( "Initializing State Table\n" ); "Initializing State Table\n");
TvDeviceStateTableInit( desc_doc_url ); TvDeviceStateTableInit( desc_doc_url );
SampleUtil_Print( "State Table Initialized\n" ); SampleUtil_Print("State Table Initialized\n");
if( ( ret = if( ( ret =
UpnpSendAdvertisement( device_handle, default_advr_expire ) ) UpnpSendAdvertisement( device_handle, default_advr_expire ) )
!= UPNP_E_SUCCESS ) { != UPNP_E_SUCCESS ) {
SampleUtil_Print( "Error sending advertisements : %d\n", ret ); SampleUtil_Print( "Error sending advertisements : %d\n", ret );
UpnpFinish( ); UpnpFinish();
return ret; return ret;
} }
SampleUtil_Print( "Advertisements Sent\n" ); SampleUtil_Print("Advertisements Sent\n");
} }
return UPNP_E_SUCCESS; return UPNP_E_SUCCESS;
} }

View File

@@ -1354,7 +1354,7 @@ TvCtrlPointStart( print_string printFunctionPtr,
{ {
ithread_t timer_thread; ithread_t timer_thread;
int rc; int rc;
short int port = 0; unsigned short port = 0;
char *ip_address = NULL; char *ip_address = NULL;
SampleUtil_Initialize( printFunctionPtr ); SampleUtil_Initialize( printFunctionPtr );
@@ -1362,34 +1362,42 @@ TvCtrlPointStart( print_string printFunctionPtr,
ithread_mutex_init( &DeviceListMutex, 0 ); ithread_mutex_init( &DeviceListMutex, 0 );
SampleUtil_Print( "Initializing UPnP with ipaddress=%s port=%d", SampleUtil_Print(
"Initializing UPnP Sdk with\n"
"\tipaddress = %s port = %u\n",
ip_address, port ); ip_address, port );
rc = UpnpInit( ip_address, port ); rc = UpnpInit( ip_address, port );
if( UPNP_E_SUCCESS != rc ) { if( UPNP_E_SUCCESS != rc ) {
SampleUtil_Print( "WinCEStart: UpnpInit() Error: %d", rc ); SampleUtil_Print( "WinCEStart: UpnpInit() Error: %d", rc );
UpnpFinish( ); UpnpFinish();
return TV_ERROR; return TV_ERROR;
} }
if( NULL == ip_address ) if( NULL == ip_address ) {
ip_address = UpnpGetServerIpAddress( ); ip_address = UpnpGetServerIpAddress();
if( 0 == port ) }
port = UpnpGetServerPort( ); if( 0 == port ) {
port = UpnpGetServerPort();
}
SampleUtil_Print( "UPnP Initialized (%s:%d)", ip_address, port ); SampleUtil_Print(
"UPnP Initialized\n"
"\tipaddress= %s port = %u\n",
ip_address, port );
SampleUtil_Print( "Registering Control Point" ); SampleUtil_Print( "Registering Control Point" );
rc = UpnpRegisterClient( TvCtrlPointCallbackEventHandler, rc = UpnpRegisterClient( TvCtrlPointCallbackEventHandler,
&ctrlpt_handle, &ctrlpt_handle ); &ctrlpt_handle, &ctrlpt_handle );
if( UPNP_E_SUCCESS != rc ) { if( UPNP_E_SUCCESS != rc ) {
SampleUtil_Print( "Error registering CP: %d", rc ); SampleUtil_Print( "Error registering CP: %d", rc );
UpnpFinish( ); UpnpFinish();
return TV_ERROR; return TV_ERROR;
} }
SampleUtil_Print( "Control Point Registered" ); SampleUtil_Print( "Control Point Registered" );
TvCtrlPointRefresh( ); TvCtrlPointRefresh();
// start a timer thread // start a timer thread
ithread_create( &timer_thread, NULL, TvCtrlPointTimerLoop, NULL ); ithread_create( &timer_thread, NULL, TvCtrlPointTimerLoop, NULL );

View File

@@ -1960,30 +1960,35 @@ TvDeviceStart( char *ip_address,
SampleUtil_Initialize( pfun ); SampleUtil_Initialize( pfun );
SampleUtil_Print SampleUtil_Print(
( "Initializing UPnP Sdk with \n \t ipaddress = %s port = %d\n", "Initializing UPnP Sdk with\n"
"\tipaddress = %s port = %u\n",
ip_address, port ); ip_address, port );
if( ( ret = UpnpInit( ip_address, port ) ) != UPNP_E_SUCCESS ) { if( ( ret = UpnpInit( ip_address, port ) ) != UPNP_E_SUCCESS ) {
SampleUtil_Print( "Error with UpnpInit -- %d\n", ret ); SampleUtil_Print( "Error with UpnpInit -- %d\n", ret );
UpnpFinish( ); UpnpFinish();
return ret; return ret;
} }
if( ip_address == NULL ) { if( ip_address == NULL ) {
ip_address = UpnpGetServerIpAddress( ); ip_address = UpnpGetServerIpAddress();
} }
port = UpnpGetServerPort( ); port = UpnpGetServerPort();
SampleUtil_Print( "UPnP Initialized\n \t ipaddress= %s port = %d\n", SampleUtil_Print(
"UPnP Initialized\n"
"\tipaddress= %s port = %u\n",
ip_address, port ); ip_address, port );
if( desc_doc_name == NULL ) if( desc_doc_name == NULL ) {
desc_doc_name = "tvdevicedesc.xml"; desc_doc_name = "tvdevicedesc.xml";
}
if( web_dir_path == NULL ) if( web_dir_path == NULL ) {
web_dir_path = DEFAULT_WEB_DIR; web_dir_path = DEFAULT_WEB_DIR;
}
snprintf( desc_doc_url, DESC_URL_SIZE, "http://%s:%d/%s", ip_address, snprintf( desc_doc_url, DESC_URL_SIZE, "http://%s:%d/%s", ip_address,
port, desc_doc_name ); port, desc_doc_name );
@@ -1995,12 +2000,13 @@ TvDeviceStart( char *ip_address,
SampleUtil_Print SampleUtil_Print
( "Error specifying webserver root directory -- %s: %d\n", ( "Error specifying webserver root directory -- %s: %d\n",
web_dir_path, ret ); web_dir_path, ret );
UpnpFinish( ); UpnpFinish();
return ret; return ret;
} }
SampleUtil_Print SampleUtil_Print(
( "Registering the RootDevice\n\t with desc_doc_url: %s\n", "Registering the RootDevice\n"
"\t with desc_doc_url: %s\n",
desc_doc_url ); desc_doc_url );
if( ( ret = UpnpRegisterRootDevice( desc_doc_url, if( ( ret = UpnpRegisterRootDevice( desc_doc_url,
@@ -2008,24 +2014,25 @@ TvDeviceStart( char *ip_address,
&device_handle, &device_handle ) ) &device_handle, &device_handle ) )
!= UPNP_E_SUCCESS ) { != UPNP_E_SUCCESS ) {
SampleUtil_Print( "Error registering the rootdevice : %d\n", ret ); SampleUtil_Print( "Error registering the rootdevice : %d\n", ret );
UpnpFinish( ); UpnpFinish();
return ret; return ret;
} else { } else {
SampleUtil_Print( "RootDevice Registered\n" ); SampleUtil_Print(
"RootDevice Registered\n"
SampleUtil_Print( "Initializing State Table\n" ); "Initializing State Table\n");
TvDeviceStateTableInit( desc_doc_url ); TvDeviceStateTableInit( desc_doc_url );
SampleUtil_Print( "State Table Initialized\n" ); SampleUtil_Print("State Table Initialized\n");
if( ( ret = if( ( ret =
UpnpSendAdvertisement( device_handle, default_advr_expire ) ) UpnpSendAdvertisement( device_handle, default_advr_expire ) )
!= UPNP_E_SUCCESS ) { != UPNP_E_SUCCESS ) {
SampleUtil_Print( "Error sending advertisements : %d\n", ret ); SampleUtil_Print( "Error sending advertisements : %d\n", ret );
UpnpFinish( ); UpnpFinish();
return ret; return ret;
} }
SampleUtil_Print( "Advertisements Sent\n" ); SampleUtil_Print("Advertisements Sent\n");
} }
return UPNP_E_SUCCESS; return UPNP_E_SUCCESS;
} }