diff --git a/upnp/sample/tvcombo/linux/upnp_tv_combo_main.c b/upnp/sample/tvcombo/linux/upnp_tv_combo_main.c index 613e933..59e6efc 100644 --- a/upnp/sample/tvcombo/linux/upnp_tv_combo_main.c +++ b/upnp/sample/tvcombo/linux/upnp_tv_combo_main.c @@ -130,7 +130,8 @@ TvCtrlPointPrintLongHelp( void ) SampleUtil_Print( "" ); SampleUtil_Print( "This sample control point application automatically searches" ); SampleUtil_Print( "for and subscribes to the services of television device emulator" ); - SampleUtil_Print( "devices. While registers a tv device itself." ); + SampleUtil_Print( "devices, described in the tvdevicedesc.xml description document." ); + SampleUtil_Print( "It also registers itself as a tv device." ); SampleUtil_Print( "" ); SampleUtil_Print( "Commands:" ); SampleUtil_Print( " Help" ); @@ -456,7 +457,8 @@ int main( int argc, char **argv ) { int rc; ithread_t cmdloop_thread; -#ifndef WIN32 +#ifdef WIN32 +#else int sig; sigset_t sigs_to_catch; #endif @@ -471,7 +473,9 @@ int main( int argc, char **argv ) /* start a command loop thread */ code = ithread_create( &cmdloop_thread, NULL, TvCtrlPointCommandLoop, NULL ); -#ifndef WIN32 +#ifdef WIN32 + ithread_join(cmdloop_thread, NULL); +#else /* Catch Ctrl-C and properly shutdown */ @@ -480,12 +484,8 @@ int main( int argc, char **argv ) sigwait( &sigs_to_catch, &sig ); SampleUtil_Print( "Shutting down on signal %d...\n", sig ); -#else - ithread_join(cmdloop_thread, NULL); #endif TvDeviceStop(); rc = TvCtrlPointStop(); - return rc; } - diff --git a/upnp/sample/tvcombo/upnp_tv_ctrlpt.c b/upnp/sample/tvcombo/upnp_tv_ctrlpt.c index 31eba55..e44eb04 100644 --- a/upnp/sample/tvcombo/upnp_tv_ctrlpt.c +++ b/upnp/sample/tvcombo/upnp_tv_ctrlpt.c @@ -138,11 +138,10 @@ TvCtrlPointDeleteNode( struct TvDeviceNode *node ) * UDN -- The Unique Device Name for the device to remove * ********************************************************************************/ -int -TvCtrlPointRemoveDevice( char *UDN ) +int TvCtrlPointRemoveDevice(const char *UDN) { - struct TvDeviceNode *curdevnode, - *prevdevnode; + struct TvDeviceNode *curdevnode; + struct TvDeviceNode *prevdevnode; ithread_mutex_lock( &DeviceListMutex ); @@ -668,8 +667,8 @@ TvCtrlPointPrintDevice( int devnum ) * ********************************************************************************/ void -TvCtrlPointAddDevice( IXML_Document * DescDoc, - char *location, +TvCtrlPointAddDevice( IXML_Document *DescDoc, + const char *location, int expires ) { char *deviceType = NULL; @@ -682,20 +681,19 @@ TvCtrlPointAddDevice( IXML_Document * DescDoc, char *eventURL[TV_SERVICE_SERVCOUNT] = { NULL, NULL }; char *controlURL[TV_SERVICE_SERVCOUNT] = { NULL, NULL }; Upnp_SID eventSID[TV_SERVICE_SERVCOUNT]; - int TimeOut[TV_SERVICE_SERVCOUNT] = - { default_timeout, default_timeout }; + int TimeOut[TV_SERVICE_SERVCOUNT] = { + default_timeout, + default_timeout }; struct TvDeviceNode *deviceNode; struct TvDeviceNode *tmpdevnode; int ret = 1; int found = 0; - int service, - var; + int service; + int var; ithread_mutex_lock( &DeviceListMutex ); - /* - Read key elements from description document - */ + /* Read key elements from description document */ UDN = SampleUtil_GetFirstDocumentItem( DescDoc, "UDN" ); deviceType = SampleUtil_GetFirstDocumentItem( DescDoc, "deviceType" ); friendlyName = @@ -703,9 +701,8 @@ TvCtrlPointAddDevice( IXML_Document * DescDoc, baseURL = SampleUtil_GetFirstDocumentItem( DescDoc, "URLBase" ); relURL = SampleUtil_GetFirstDocumentItem( DescDoc, "presentationURL" ); - ret = - UpnpResolveURL( ( baseURL ? baseURL : location ), relURL, - presURL ); + ret = UpnpResolveURL( + ( baseURL ? baseURL : location ), relURL, presURL); if( UPNP_E_SUCCESS != ret ) SampleUtil_Print( "Error generating presURL from %s + %s", baseURL, @@ -939,34 +936,36 @@ TvStateUpdate( char *UDN, * changes -- The DOM document representing the changes * ********************************************************************************/ -void -TvCtrlPointHandleEvent( Upnp_SID sid, - int evntkey, - IXML_Document * changes ) +void TvCtrlPointHandleEvent( + const Upnp_SID sid, + int evntkey, + IXML_Document *changes) { - struct TvDeviceNode *tmpdevnode; - int service; + struct TvDeviceNode *tmpdevnode; + int service; - ithread_mutex_lock( &DeviceListMutex ); + ithread_mutex_lock(&DeviceListMutex); - tmpdevnode = GlobalDeviceList; - while( tmpdevnode ) { - for( service = 0; service < TV_SERVICE_SERVCOUNT; service++ ) { - if( strcmp( tmpdevnode->device.TvService[service].SID, sid ) == - 0 ) { - SampleUtil_Print( "Received Tv %s Event: %d for SID %s", - TvServiceName[service], evntkey, sid ); + tmpdevnode = GlobalDeviceList; + while (tmpdevnode) { + for (service = 0; service < TV_SERVICE_SERVCOUNT; ++service) { + if(strcmp(tmpdevnode->device.TvService[service].SID, sid) == 0) { + SampleUtil_Print("Received Tv %s Event: %d for SID %s", + TvServiceName[service], + evntkey, + sid ); + TvStateUpdate( + tmpdevnode->device.UDN, + service, + changes, + (char **)&tmpdevnode->device.TvService[service].VariableStrVal); + break; + } + } + tmpdevnode = tmpdevnode->next; + } - TvStateUpdate( tmpdevnode->device.UDN, service, changes, - ( char ** )&tmpdevnode->device. - TvService[service].VariableStrVal ); - break; - } - } - tmpdevnode = tmpdevnode->next; - } - - ithread_mutex_unlock( &DeviceListMutex ); + ithread_mutex_unlock(&DeviceListMutex); } /******************************************************************************** @@ -983,10 +982,10 @@ TvCtrlPointHandleEvent( Upnp_SID sid, * timeout -- The new timeout for the subscription * ********************************************************************************/ -void -TvCtrlPointHandleSubscribeUpdate( char *eventURL, - Upnp_SID sid, - int timeout ) +void TvCtrlPointHandleSubscribeUpdate( + const char *eventURL, + const Upnp_SID sid, + int timeout) { struct TvDeviceNode *tmpdevnode; int service; @@ -1014,10 +1013,10 @@ TvCtrlPointHandleSubscribeUpdate( char *eventURL, ithread_mutex_unlock( &DeviceListMutex ); } -void -TvCtrlPointHandleGetVar( char *controlURL, - char *varName, - DOMString varValue ) +void TvCtrlPointHandleGetVar( + const char *controlURL, + const char *varName, + const DOMString varValue) { struct TvDeviceNode *tmpdevnode; @@ -1026,14 +1025,11 @@ TvCtrlPointHandleGetVar( char *controlURL, ithread_mutex_lock( &DeviceListMutex ); tmpdevnode = GlobalDeviceList; - while( tmpdevnode ) { - for( service = 0; service < TV_SERVICE_SERVCOUNT; service++ ) { - if( strcmp - ( tmpdevnode->device.TvService[service].ControlURL, - controlURL ) == 0 ) { - SampleUtil_StateUpdate( varName, varValue, - tmpdevnode->device.UDN, - GET_VAR_COMPLETE ); + while (tmpdevnode) { + for (service = 0; service < TV_SERVICE_SERVCOUNT; service++) { + if (strcmp(tmpdevnode->device.TvService[service].ControlURL, controlURL) == 0) { + SampleUtil_StateUpdate( + varName, varValue, tmpdevnode->device.UDN, GET_VAR_COMPLETE); break; } } @@ -1057,186 +1053,137 @@ TvCtrlPointHandleGetVar( char *controlURL, * Cookie -- Optional data specified during callback registration * ********************************************************************************/ -int -TvCtrlPointCallbackEventHandler( Upnp_EventType EventType, - void *Event, - void *Cookie ) +int TvCtrlPointCallbackEventHandler(Upnp_EventType EventType, void *Event, void *Cookie) { - SampleUtil_PrintEvent( EventType, Event ); + /*int errCode = 0;*/ - switch ( EventType ) { - /* - SSDP Stuff - */ - case UPNP_DISCOVERY_ADVERTISEMENT_ALIVE: - case UPNP_DISCOVERY_SEARCH_RESULT: - { - struct Upnp_Discovery *d_event = - ( struct Upnp_Discovery * )Event; - IXML_Document *DescDoc = NULL; - int ret; + SampleUtil_PrintEvent(EventType, Event); + switch ( EventType ) { + /* SSDP Stuff */ + case UPNP_DISCOVERY_ADVERTISEMENT_ALIVE: + case UPNP_DISCOVERY_SEARCH_RESULT: { + struct Upnp_Discovery *d_event = (struct Upnp_Discovery *)Event; + IXML_Document *DescDoc = NULL; + int ret; - if( d_event->ErrCode != UPNP_E_SUCCESS ) { - SampleUtil_Print( "Error in Discovery Callback -- %d", - d_event->ErrCode ); - } + if (d_event->ErrCode != UPNP_E_SUCCESS) { + SampleUtil_Print( + "Error in Discovery Callback -- %d", d_event->ErrCode); + } + ret = UpnpDownloadXmlDoc(d_event->Location, &DescDoc); + if (ret != UPNP_E_SUCCESS) { + SampleUtil_Print( + "Error obtaining device description from %s -- error = %d", + d_event->Location, ret); + } else { + TvCtrlPointAddDevice( + DescDoc, d_event->Location, d_event->Expires); + } + if (DescDoc) { + ixmlDocument_free(DescDoc); + } + TvCtrlPointPrintList(); + break; + } + case UPNP_DISCOVERY_SEARCH_TIMEOUT: + /* Nothing to do here... */ + break; + case UPNP_DISCOVERY_ADVERTISEMENT_BYEBYE: { + struct Upnp_Discovery *d_event = (struct Upnp_Discovery *)Event; - if( ( ret = - UpnpDownloadXmlDoc( d_event->Location, - &DescDoc ) ) != - UPNP_E_SUCCESS ) { - SampleUtil_Print - ( "Error obtaining device description from %s -- error = %d", - d_event->Location, ret ); - } else { - TvCtrlPointAddDevice( DescDoc, d_event->Location, - d_event->Expires ); - } + if (d_event->ErrCode != UPNP_E_SUCCESS) { + SampleUtil_Print( + "Error in Discovery ByeBye Callback -- %d", d_event->ErrCode); + } + SampleUtil_Print("Received ByeBye for Device: %s", d_event->DeviceId); + TvCtrlPointRemoveDevice(d_event->DeviceId); + SampleUtil_Print("After byebye:"); + TvCtrlPointPrintList(); + break; + } + /* SOAP Stuff */ + case UPNP_CONTROL_ACTION_COMPLETE: { + struct Upnp_Action_Complete *a_event = (struct Upnp_Action_Complete *)Event; - if( DescDoc ) - ixmlDocument_free( DescDoc ); + if (a_event->ErrCode != UPNP_E_SUCCESS) { + SampleUtil_Print( + "Error in Action Complete Callback -- %d", a_event->ErrCode); + } + /* No need for any processing here, just print out results. + * Service state table updates are handled by events. */ + break; + } + case UPNP_CONTROL_GET_VAR_COMPLETE: { + struct Upnp_State_Var_Complete *sv_event = (struct Upnp_State_Var_Complete *)Event; - TvCtrlPointPrintList(); - break; - } + if (sv_event->ErrCode != UPNP_E_SUCCESS) { + SampleUtil_Print( + "Error in Get Var Complete Callback -- %d", sv_event->ErrCode); + } else { + TvCtrlPointHandleGetVar( + sv_event->CtrlUrl, + sv_event->StateVarName, + sv_event->CurrentVal); + } + break; + } + /* GENA Stuff */ + case UPNP_EVENT_RECEIVED: { + struct Upnp_Event *e_event = (struct Upnp_Event *)Event; - case UPNP_DISCOVERY_SEARCH_TIMEOUT: - /* - Nothing to do here... - */ - break; + TvCtrlPointHandleEvent( + e_event->Sid, + e_event->EventKey, + e_event->ChangedVariables); + break; + } + case UPNP_EVENT_SUBSCRIBE_COMPLETE: + case UPNP_EVENT_UNSUBSCRIBE_COMPLETE: + case UPNP_EVENT_RENEWAL_COMPLETE: { + struct Upnp_Event_Subscribe *es_event = (struct Upnp_Event_Subscribe *)Event; - case UPNP_DISCOVERY_ADVERTISEMENT_BYEBYE: - { - struct Upnp_Discovery *d_event = - ( struct Upnp_Discovery * )Event; + if (es_event->ErrCode != UPNP_E_SUCCESS) { + SampleUtil_Print( + "Error in Event Subscribe Callback -- %d", es_event->ErrCode); + } else { + TvCtrlPointHandleSubscribeUpdate( + es_event->PublisherUrl, + es_event->Sid, + es_event->TimeOut); + } + break; + } + case UPNP_EVENT_AUTORENEWAL_FAILED: + case UPNP_EVENT_SUBSCRIPTION_EXPIRED: { + struct Upnp_Event_Subscribe *es_event = (struct Upnp_Event_Subscribe *)Event; + int TimeOut = default_timeout; + Upnp_SID newSID; + int ret; - if( d_event->ErrCode != UPNP_E_SUCCESS ) { - SampleUtil_Print - ( "Error in Discovery ByeBye Callback -- %d", - d_event->ErrCode ); - } + ret = UpnpSubscribe( + ctrlpt_handle, + es_event->PublisherUrl, + &TimeOut, + newSID); + if (ret == UPNP_E_SUCCESS) { + SampleUtil_Print("Subscribed to EventURL with SID=%s", newSID); + TvCtrlPointHandleSubscribeUpdate( + es_event->PublisherUrl, + newSID, + TimeOut); + } else { + SampleUtil_Print("Error Subscribing to EventURL -- %d", ret); + } + break; + } + /* ignore these cases, since this is not a device */ + case UPNP_EVENT_SUBSCRIPTION_REQUEST: + case UPNP_CONTROL_GET_VAR_REQUEST: + case UPNP_CONTROL_ACTION_REQUEST: + break; + } - SampleUtil_Print( "Received ByeBye for Device: %s", - d_event->DeviceId ); - TvCtrlPointRemoveDevice( d_event->DeviceId ); - - SampleUtil_Print( "After byebye:" ); - TvCtrlPointPrintList(); - - break; - } - - /* - SOAP Stuff - */ - case UPNP_CONTROL_ACTION_COMPLETE: - { - struct Upnp_Action_Complete *a_event = - ( struct Upnp_Action_Complete * )Event; - - if( a_event->ErrCode != UPNP_E_SUCCESS ) { - SampleUtil_Print - ( "Error in Action Complete Callback -- %d", - a_event->ErrCode ); - } - - /* - No need for any processing here, just print out results. Service state - table updates are handled by events. - */ - - break; - } - - case UPNP_CONTROL_GET_VAR_COMPLETE: - { - struct Upnp_State_Var_Complete *sv_event = - ( struct Upnp_State_Var_Complete * )Event; - - if( sv_event->ErrCode != UPNP_E_SUCCESS ) { - SampleUtil_Print - ( "Error in Get Var Complete Callback -- %d", - sv_event->ErrCode ); - } else { - TvCtrlPointHandleGetVar( sv_event->CtrlUrl, - sv_event->StateVarName, - sv_event->CurrentVal ); - } - - break; - } - - /* - GENA Stuff - */ - case UPNP_EVENT_RECEIVED: - { - struct Upnp_Event *e_event = ( struct Upnp_Event * )Event; - - TvCtrlPointHandleEvent( e_event->Sid, e_event->EventKey, - e_event->ChangedVariables ); - break; - } - - case UPNP_EVENT_SUBSCRIBE_COMPLETE: - case UPNP_EVENT_UNSUBSCRIBE_COMPLETE: - case UPNP_EVENT_RENEWAL_COMPLETE: - { - struct Upnp_Event_Subscribe *es_event = - ( struct Upnp_Event_Subscribe * )Event; - - if( es_event->ErrCode != UPNP_E_SUCCESS ) { - SampleUtil_Print - ( "Error in Event Subscribe Callback -- %d", - es_event->ErrCode ); - } else { - TvCtrlPointHandleSubscribeUpdate( es_event-> - PublisherUrl, - es_event->Sid, - es_event->TimeOut ); - } - - break; - } - - case UPNP_EVENT_AUTORENEWAL_FAILED: - case UPNP_EVENT_SUBSCRIPTION_EXPIRED: - { - int TimeOut = default_timeout; - Upnp_SID newSID; - int ret; - - struct Upnp_Event_Subscribe *es_event = - ( struct Upnp_Event_Subscribe * )Event; - - ret = - UpnpSubscribe( ctrlpt_handle, es_event->PublisherUrl, - &TimeOut, newSID ); - - if( ret == UPNP_E_SUCCESS ) { - SampleUtil_Print( "Subscribed to EventURL with SID=%s", - newSID ); - TvCtrlPointHandleSubscribeUpdate( es_event-> - PublisherUrl, newSID, - TimeOut ); - } else { - SampleUtil_Print - ( "Error Subscribing to EventURL -- %d", ret ); - } - break; - } - - /* - ignore these cases, since this is not a device - */ - case UPNP_EVENT_SUBSCRIPTION_REQUEST: - case UPNP_CONTROL_GET_VAR_REQUEST: - case UPNP_CONTROL_ACTION_REQUEST: - break; - } - - return 0; + return 0; } /******************************************************************************** diff --git a/upnp/sample/tvcombo/upnp_tv_ctrlpt.h b/upnp/sample/tvcombo/upnp_tv_ctrlpt.h index 7c2d079..9889d6f 100644 --- a/upnp/sample/tvcombo/upnp_tv_ctrlpt.h +++ b/upnp/sample/tvcombo/upnp_tv_ctrlpt.h @@ -1,33 +1,33 @@ -/////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2000-2003 Intel Corporation -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// * Neither name of Intel Corporation nor the names of its contributors -// may be used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -/////////////////////////////////////////////////////////////////////////// +/******************************************************************************* + * + * Copyright (c) 2000-2003 Intel Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * - Neither name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ******************************************************************************/ #ifndef UPNP_TV_CTRLPT_H #define UPNP_TV_CTRLPT_H @@ -111,8 +111,8 @@ extern ithread_mutex_t DeviceListMutex; extern UpnpClient_Handle ctrlpt_handle; void TvCtrlPointPrintHelp( void ); -int TvCtrlPointDeleteNode(struct TvDeviceNode*); -int TvCtrlPointRemoveDevice(char*); +int TvCtrlPointDeleteNode(struct TvDeviceNode *); +int TvCtrlPointRemoveDevice(const char *); int TvCtrlPointRemoveAll( void ); int TvCtrlPointRefresh( void ); @@ -140,11 +140,11 @@ int TvCtrlPointGetBrightness(int); int TvCtrlPointGetDevice(int, struct TvDeviceNode **); int TvCtrlPointPrintList( void ); int TvCtrlPointPrintDevice(int); -void TvCtrlPointAddDevice (IXML_Document *, char *, int); -void TvCtrlPointHandleGetVar(char *,char *,DOMString); +void TvCtrlPointAddDevice(IXML_Document *, const char *, int); +void TvCtrlPointHandleGetVar(const char *, const char *, const DOMString); void TvStateUpdate(char*,int, IXML_Document * , char **); -void TvCtrlPointHandleEvent(Upnp_SID, int, IXML_Document *); -void TvCtrlPointHandleSubscribeUpdate(char *, Upnp_SID, int); +void TvCtrlPointHandleEvent(const Upnp_SID, int, IXML_Document *); +void TvCtrlPointHandleSubscribeUpdate(const char *, const Upnp_SID, int); int TvCtrlPointCallbackEventHandler(Upnp_EventType, void *, void *); void TvCtrlPointVerifyTimeouts(int); void TvCtrlPointPrintCommands( void ); diff --git a/upnp/sample/tvctrlpt/linux/upnp_tv_ctrlpt_main.c b/upnp/sample/tvctrlpt/linux/upnp_tv_ctrlpt_main.c index 811ff31..bd54b68 100644 --- a/upnp/sample/tvctrlpt/linux/upnp_tv_ctrlpt_main.c +++ b/upnp/sample/tvctrlpt/linux/upnp_tv_ctrlpt_main.c @@ -405,7 +405,8 @@ int main( int argc, char **argv ) { int rc; ithread_t cmdloop_thread; -#ifndef WIN32 +#ifdef WIN32 +#else int sig; sigset_t sigs_to_catch; #endif @@ -420,7 +421,9 @@ int main( int argc, char **argv ) /* start a command loop thread */ code = ithread_create( &cmdloop_thread, NULL, TvCtrlPointCommandLoop, NULL ); -#ifndef WIN32 +#ifdef WIN32 + ithread_join(cmdloop_thread, NULL); +#else /* Catch Ctrl-C and properly shutdown */ @@ -428,9 +431,7 @@ int main( int argc, char **argv ) sigaddset( &sigs_to_catch, SIGINT ); sigwait( &sigs_to_catch, &sig ); - SampleUtil_Print( "Shutting down on signal %d...", sig ); -#else - ithread_join(cmdloop_thread, NULL); + SampleUtil_Print( "Shutting down on signal %d...\n", sig ); #endif rc = TvCtrlPointStop(); diff --git a/upnp/sample/tvctrlpt/upnp_tv_ctrlpt.c b/upnp/sample/tvctrlpt/upnp_tv_ctrlpt.c index 75c9991..47e4a88 100644 --- a/upnp/sample/tvctrlpt/upnp_tv_ctrlpt.c +++ b/upnp/sample/tvctrlpt/upnp_tv_ctrlpt.c @@ -29,9 +29,14 @@ * ******************************************************************************/ + #include "upnp_tv_ctrlpt.h" -/* + +#include "upnp.h" + + +/*! Mutex for protecting the global device list in a multi-threaded, asynchronous environment. All functions should lock this mutex before reading @@ -48,7 +53,7 @@ char *TvServiceType[] = { }; char *TvServiceName[] = { "Control", "Picture" }; -/* +/*! Global arrays for storing variable names and counts for TvControl and TvPicture services */ @@ -59,12 +64,12 @@ char *TvVarName[TV_SERVICE_SERVCOUNT][TV_MAXVARS] = { char TvVarCount[TV_SERVICE_SERVCOUNT] = { TV_CONTROL_VARCOUNT, TV_PICTURE_VARCOUNT }; -/* +/*! Timeout to request during subscriptions */ int default_timeout = 1801; -/* +/*! The first node in the global device list, or NULL if empty */ struct TvDeviceNode *GlobalDeviceList = NULL; @@ -139,10 +144,10 @@ TvCtrlPointDeleteNode( struct TvDeviceNode *node ) * ********************************************************************************/ int -TvCtrlPointRemoveDevice( char *UDN ) +TvCtrlPointRemoveDevice(const char *UDN) { - struct TvDeviceNode *curdevnode, - *prevdevnode; + struct TvDeviceNode *curdevnode; + struct TvDeviceNode *prevdevnode; ithread_mutex_lock( &DeviceListMutex ); @@ -668,8 +673,8 @@ TvCtrlPointPrintDevice( int devnum ) * ********************************************************************************/ void -TvCtrlPointAddDevice( IXML_Document * DescDoc, - char *location, +TvCtrlPointAddDevice( IXML_Document *DescDoc, + const char *location, int expires ) { char *deviceType = NULL; @@ -682,20 +687,19 @@ TvCtrlPointAddDevice( IXML_Document * DescDoc, char *eventURL[TV_SERVICE_SERVCOUNT] = { NULL, NULL }; char *controlURL[TV_SERVICE_SERVCOUNT] = { NULL, NULL }; Upnp_SID eventSID[TV_SERVICE_SERVCOUNT]; - int TimeOut[TV_SERVICE_SERVCOUNT] = - { default_timeout, default_timeout }; + int TimeOut[TV_SERVICE_SERVCOUNT] = { + default_timeout, + default_timeout }; struct TvDeviceNode *deviceNode; struct TvDeviceNode *tmpdevnode; int ret = 1; int found = 0; - int service, - var; + int service; + int var; ithread_mutex_lock( &DeviceListMutex ); - /* - Read key elements from description document - */ + /* Read key elements from description document */ UDN = SampleUtil_GetFirstDocumentItem( DescDoc, "UDN" ); deviceType = SampleUtil_GetFirstDocumentItem( DescDoc, "deviceType" ); friendlyName = @@ -703,9 +707,8 @@ TvCtrlPointAddDevice( IXML_Document * DescDoc, baseURL = SampleUtil_GetFirstDocumentItem( DescDoc, "URLBase" ); relURL = SampleUtil_GetFirstDocumentItem( DescDoc, "presentationURL" ); - ret = - UpnpResolveURL( ( baseURL ? baseURL : location ), relURL, - presURL ); + ret = UpnpResolveURL( + ( baseURL ? baseURL : location ), relURL, presURL); if( UPNP_E_SUCCESS != ret ) SampleUtil_Print( "Error generating presURL from %s + %s", baseURL, @@ -939,34 +942,36 @@ TvStateUpdate( char *UDN, * changes -- The DOM document representing the changes * ********************************************************************************/ -void -TvCtrlPointHandleEvent( Upnp_SID sid, - int evntkey, - IXML_Document * changes ) +void TvCtrlPointHandleEvent( + const Upnp_SID sid, + int evntkey, + IXML_Document *changes) { - struct TvDeviceNode *tmpdevnode; - int service; + struct TvDeviceNode *tmpdevnode; + int service; - ithread_mutex_lock( &DeviceListMutex ); + ithread_mutex_lock(&DeviceListMutex); - tmpdevnode = GlobalDeviceList; - while( tmpdevnode ) { - for( service = 0; service < TV_SERVICE_SERVCOUNT; service++ ) { - if( strcmp( tmpdevnode->device.TvService[service].SID, sid ) == - 0 ) { - SampleUtil_Print( "Received Tv %s Event: %d for SID %s", - TvServiceName[service], evntkey, sid ); + tmpdevnode = GlobalDeviceList; + while (tmpdevnode) { + for (service = 0; service < TV_SERVICE_SERVCOUNT; ++service) { + if (strcmp(tmpdevnode->device.TvService[service].SID, sid) == 0) { + SampleUtil_Print("Received Tv %s Event: %d for SID %s", + TvServiceName[service], + evntkey, + sid); + TvStateUpdate( + tmpdevnode->device.UDN, + service, + changes, + (char **)&tmpdevnode->device.TvService[service].VariableStrVal); + break; + } + } + tmpdevnode = tmpdevnode->next; + } - TvStateUpdate( tmpdevnode->device.UDN, service, changes, - ( char ** )&tmpdevnode->device. - TvService[service].VariableStrVal ); - break; - } - } - tmpdevnode = tmpdevnode->next; - } - - ithread_mutex_unlock( &DeviceListMutex ); + ithread_mutex_unlock(&DeviceListMutex); } /******************************************************************************** @@ -983,10 +988,10 @@ TvCtrlPointHandleEvent( Upnp_SID sid, * timeout -- The new timeout for the subscription * ********************************************************************************/ -void -TvCtrlPointHandleSubscribeUpdate( char *eventURL, - Upnp_SID sid, - int timeout ) +void TvCtrlPointHandleSubscribeUpdate( + const char *eventURL, + const Upnp_SID sid, + int timeout) { struct TvDeviceNode *tmpdevnode; int service; @@ -1015,9 +1020,9 @@ TvCtrlPointHandleSubscribeUpdate( char *eventURL, } void -TvCtrlPointHandleGetVar( char *controlURL, - char *varName, - DOMString varValue ) +TvCtrlPointHandleGetVar( const char *controlURL, + const char *varName, + const DOMString varValue ) { struct TvDeviceNode *tmpdevnode; @@ -1026,14 +1031,11 @@ TvCtrlPointHandleGetVar( char *controlURL, ithread_mutex_lock( &DeviceListMutex ); tmpdevnode = GlobalDeviceList; - while( tmpdevnode ) { - for( service = 0; service < TV_SERVICE_SERVCOUNT; service++ ) { - if( strcmp - ( tmpdevnode->device.TvService[service].ControlURL, - controlURL ) == 0 ) { - SampleUtil_StateUpdate( varName, varValue, - tmpdevnode->device.UDN, - GET_VAR_COMPLETE ); + while (tmpdevnode) { + for (service = 0; service < TV_SERVICE_SERVCOUNT; service++) { + if (strcmp(tmpdevnode->device.TvService[service].ControlURL, controlURL ) == 0 ) { + SampleUtil_StateUpdate( + varName, varValue, tmpdevnode->device.UDN, GET_VAR_COMPLETE ); break; } } @@ -1057,186 +1059,152 @@ TvCtrlPointHandleGetVar( char *controlURL, * Cookie -- Optional data specified during callback registration * ********************************************************************************/ -int -TvCtrlPointCallbackEventHandler( Upnp_EventType EventType, - void *Event, - void *Cookie ) +int TvCtrlPointCallbackEventHandler(Upnp_EventType EventType, void *Event, void *Cookie) { - SampleUtil_PrintEvent( EventType, Event ); + /*int errCode = 0;*/ - switch ( EventType ) { - /* - SSDP Stuff - */ - case UPNP_DISCOVERY_ADVERTISEMENT_ALIVE: - case UPNP_DISCOVERY_SEARCH_RESULT: - { - struct Upnp_Discovery *d_event = - ( struct Upnp_Discovery * )Event; - IXML_Document *DescDoc = NULL; - int ret; + SampleUtil_PrintEvent(EventType, Event); + switch ( EventType ) { + /* SSDP Stuff */ + case UPNP_DISCOVERY_ADVERTISEMENT_ALIVE: + case UPNP_DISCOVERY_SEARCH_RESULT: { + struct Upnp_Discovery *d_event = (struct Upnp_Discovery *)Event; + IXML_Document *DescDoc = NULL; + int ret; - if( d_event->ErrCode != UPNP_E_SUCCESS ) { - SampleUtil_Print( "Error in Discovery Callback -- %d", - d_event->ErrCode ); - } + if (d_event->ErrCode != UPNP_E_SUCCESS) { + SampleUtil_Print( + "Error in Discovery Callback -- %d", d_event->ErrCode); + } - if( ( ret = - UpnpDownloadXmlDoc( d_event->Location, - &DescDoc ) ) != - UPNP_E_SUCCESS ) { - SampleUtil_Print - ( "Error obtaining device description from %s -- error = %d", - d_event->Location, ret ); - } else { - TvCtrlPointAddDevice( DescDoc, d_event->Location, - d_event->Expires ); - } + ret = UpnpDownloadXmlDoc(d_event->Location, &DescDoc); + if (ret != UPNP_E_SUCCESS) { + SampleUtil_Print( + "Error obtaining device description from %s -- error = %d", + d_event->Location, ret ); + } else { + TvCtrlPointAddDevice( + DescDoc, d_event->Location, d_event->Expires); + } - if( DescDoc ) - ixmlDocument_free( DescDoc ); + if( DescDoc ) { + ixmlDocument_free(DescDoc); + } - TvCtrlPointPrintList(); - break; - } + TvCtrlPointPrintList(); + break; + } - case UPNP_DISCOVERY_SEARCH_TIMEOUT: - /* - Nothing to do here... - */ - break; + case UPNP_DISCOVERY_SEARCH_TIMEOUT: + /* Nothing to do here... */ + break; - case UPNP_DISCOVERY_ADVERTISEMENT_BYEBYE: - { - struct Upnp_Discovery *d_event = - ( struct Upnp_Discovery * )Event; + case UPNP_DISCOVERY_ADVERTISEMENT_BYEBYE: { + struct Upnp_Discovery *d_event = (struct Upnp_Discovery *)Event; - if( d_event->ErrCode != UPNP_E_SUCCESS ) { - SampleUtil_Print - ( "Error in Discovery ByeBye Callback -- %d", - d_event->ErrCode ); - } + if (d_event->ErrCode != UPNP_E_SUCCESS) { + SampleUtil_Print( + "Error in Discovery ByeBye Callback -- %d", d_event->ErrCode); + } - SampleUtil_Print( "Received ByeBye for Device: %s", - d_event->DeviceId ); - TvCtrlPointRemoveDevice( d_event->DeviceId ); + SampleUtil_Print("Received ByeBye for Device: %s", d_event->DeviceId); + TvCtrlPointRemoveDevice(d_event->DeviceId); - SampleUtil_Print( "After byebye:" ); - TvCtrlPointPrintList(); + SampleUtil_Print("After byebye:"); + TvCtrlPointPrintList(); - break; - } + break; + } + /* SOAP Stuff */ + case UPNP_CONTROL_ACTION_COMPLETE: { + struct Upnp_Action_Complete *a_event = (struct Upnp_Action_Complete *)Event; - /* - SOAP Stuff - */ - case UPNP_CONTROL_ACTION_COMPLETE: - { - struct Upnp_Action_Complete *a_event = - ( struct Upnp_Action_Complete * )Event; + if (a_event->ErrCode != UPNP_E_SUCCESS) { + SampleUtil_Print( + "Error in Action Complete Callback -- %d", + a_event->ErrCode); + } - if( a_event->ErrCode != UPNP_E_SUCCESS ) { - SampleUtil_Print - ( "Error in Action Complete Callback -- %d", - a_event->ErrCode ); - } + /* No need for any processing here, just print out results. + * Service state table updates are handled by events. */ - /* - No need for any processing here, just print out results. Service state - table updates are handled by events. - */ + break; + } + case UPNP_CONTROL_GET_VAR_COMPLETE: { + struct Upnp_State_Var_Complete *sv_event = (struct Upnp_State_Var_Complete *)Event; - break; - } + if (sv_event->ErrCode != UPNP_E_SUCCESS) { + SampleUtil_Print( + "Error in Get Var Complete Callback -- %d", + sv_event->ErrCode); + } else { + TvCtrlPointHandleGetVar( + sv_event->CtrlUrl, + sv_event->StateVarName, + sv_event->CurrentVal); + } + break; + } + /* GENA Stuff */ + case UPNP_EVENT_RECEIVED: { + struct Upnp_Event *e_event = (struct Upnp_Event *)Event; - case UPNP_CONTROL_GET_VAR_COMPLETE: - { - struct Upnp_State_Var_Complete *sv_event = - ( struct Upnp_State_Var_Complete * )Event; + TvCtrlPointHandleEvent( + e_event->Sid, + e_event->EventKey, + e_event->ChangedVariables); + break; + } + case UPNP_EVENT_SUBSCRIBE_COMPLETE: + case UPNP_EVENT_UNSUBSCRIBE_COMPLETE: + case UPNP_EVENT_RENEWAL_COMPLETE: { + struct Upnp_Event_Subscribe *es_event = (struct Upnp_Event_Subscribe *)Event; - if( sv_event->ErrCode != UPNP_E_SUCCESS ) { - SampleUtil_Print - ( "Error in Get Var Complete Callback -- %d", - sv_event->ErrCode ); - } else { - TvCtrlPointHandleGetVar( sv_event->CtrlUrl, - sv_event->StateVarName, - sv_event->CurrentVal ); - } + if (es_event->ErrCode != UPNP_E_SUCCESS) { + SampleUtil_Print( + "Error in Event Subscribe Callback -- %d", + es_event->ErrCode); + } else { + TvCtrlPointHandleSubscribeUpdate( + es_event->PublisherUrl, + es_event->Sid, + es_event->TimeOut); + } - break; - } + break; + } + case UPNP_EVENT_AUTORENEWAL_FAILED: + case UPNP_EVENT_SUBSCRIPTION_EXPIRED: { + struct Upnp_Event_Subscribe *es_event = (struct Upnp_Event_Subscribe *)Event; + int TimeOut = default_timeout; + Upnp_SID newSID; + int ret; - /* - GENA Stuff - */ - case UPNP_EVENT_RECEIVED: - { - struct Upnp_Event *e_event = ( struct Upnp_Event * )Event; + ret = UpnpSubscribe( + ctrlpt_handle, + es_event->PublisherUrl, + &TimeOut, + newSID); - TvCtrlPointHandleEvent( e_event->Sid, e_event->EventKey, - e_event->ChangedVariables ); - break; - } + if (ret == UPNP_E_SUCCESS) { + SampleUtil_Print("Subscribed to EventURL with SID=%s", newSID); + TvCtrlPointHandleSubscribeUpdate( + es_event->PublisherUrl, + newSID, + TimeOut); + } else { + SampleUtil_Print("Error Subscribing to EventURL -- %d", ret); + } + break; + } + /* ignore these cases, since this is not a device */ + case UPNP_EVENT_SUBSCRIPTION_REQUEST: + case UPNP_CONTROL_GET_VAR_REQUEST: + case UPNP_CONTROL_ACTION_REQUEST: + break; + } - case UPNP_EVENT_SUBSCRIBE_COMPLETE: - case UPNP_EVENT_UNSUBSCRIBE_COMPLETE: - case UPNP_EVENT_RENEWAL_COMPLETE: - { - struct Upnp_Event_Subscribe *es_event = - ( struct Upnp_Event_Subscribe * )Event; - - if( es_event->ErrCode != UPNP_E_SUCCESS ) { - SampleUtil_Print - ( "Error in Event Subscribe Callback -- %d", - es_event->ErrCode ); - } else { - TvCtrlPointHandleSubscribeUpdate( es_event-> - PublisherUrl, - es_event->Sid, - es_event->TimeOut ); - } - - break; - } - - case UPNP_EVENT_AUTORENEWAL_FAILED: - case UPNP_EVENT_SUBSCRIPTION_EXPIRED: - { - int TimeOut = default_timeout; - Upnp_SID newSID; - int ret; - - struct Upnp_Event_Subscribe *es_event = - ( struct Upnp_Event_Subscribe * )Event; - - ret = - UpnpSubscribe( ctrlpt_handle, es_event->PublisherUrl, - &TimeOut, newSID ); - - if( ret == UPNP_E_SUCCESS ) { - SampleUtil_Print( "Subscribed to EventURL with SID=%s", - newSID ); - TvCtrlPointHandleSubscribeUpdate( es_event-> - PublisherUrl, newSID, - TimeOut ); - } else { - SampleUtil_Print - ( "Error Subscribing to EventURL -- %d", ret ); - } - break; - } - - /* - ignore these cases, since this is not a device - */ - case UPNP_EVENT_SUBSCRIPTION_REQUEST: - case UPNP_CONTROL_GET_VAR_REQUEST: - case UPNP_CONTROL_ACTION_REQUEST: - break; - } - - return 0; + return 0; } /******************************************************************************** diff --git a/upnp/sample/tvctrlpt/upnp_tv_ctrlpt.h b/upnp/sample/tvctrlpt/upnp_tv_ctrlpt.h index 7c2d079..98da86c 100644 --- a/upnp/sample/tvctrlpt/upnp_tv_ctrlpt.h +++ b/upnp/sample/tvctrlpt/upnp_tv_ctrlpt.h @@ -1,55 +1,65 @@ -/////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2000-2003 Intel Corporation -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// * Neither name of Intel Corporation nor the names of its contributors -// may be used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -/////////////////////////////////////////////////////////////////////////// +/************************************************************************** + * + * Copyright (c) 2000-2003 Intel Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * - Neither name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + **************************************************************************/ + #ifndef UPNP_TV_CTRLPT_H #define UPNP_TV_CTRLPT_H + #ifdef __cplusplus extern "C" { #endif -#include + +#include "sample_util.h" + #include "ithread.h" -#ifndef WIN32 -#include -#endif -#include -#include -#include -#include - #include "upnp.h" #include "upnptools.h" -#include "sample_util.h" + + +#include +#include +#include +#include +#include + + +#ifdef WIN32 + /* Do not #include */ +#else + #include +#endif + #define TV_SERVICE_SERVCOUNT 2 #define TV_SERVICE_CONTROL 0 @@ -68,12 +78,12 @@ extern "C" { #define TV_MAX_VAL_LEN 5 -#define TV_SUCCESS 0 -#define TV_ERROR (-1) -#define TV_WARNING 1 +#define TV_SUCCESS 0 +#define TV_ERROR (-1) +#define TV_WARNING 1 /* This should be the maximum VARCOUNT from above */ -#define TV_MAXVARS TV_PICTURE_VARCOUNT +#define TV_MAXVARS TV_PICTURE_VARCOUNT extern char TvDeviceType[]; extern char *TvServiceType[]; @@ -110,11 +120,11 @@ extern ithread_mutex_t DeviceListMutex; extern UpnpClient_Handle ctrlpt_handle; -void TvCtrlPointPrintHelp( void ); +void TvCtrlPointPrintHelp(void); int TvCtrlPointDeleteNode(struct TvDeviceNode*); -int TvCtrlPointRemoveDevice(char*); -int TvCtrlPointRemoveAll( void ); -int TvCtrlPointRefresh( void ); +int TvCtrlPointRemoveDevice(const char *); +int TvCtrlPointRemoveAll(void); +int TvCtrlPointRefresh(void); int TvCtrlPointSendAction(int, int, char *, char **, char **, int); @@ -140,11 +150,11 @@ int TvCtrlPointGetBrightness(int); int TvCtrlPointGetDevice(int, struct TvDeviceNode **); int TvCtrlPointPrintList( void ); int TvCtrlPointPrintDevice(int); -void TvCtrlPointAddDevice (IXML_Document *, char *, int); -void TvCtrlPointHandleGetVar(char *,char *,DOMString); +void TvCtrlPointAddDevice(IXML_Document *, const char *, int); +void TvCtrlPointHandleGetVar(const char *, const char *, const DOMString); void TvStateUpdate(char*,int, IXML_Document * , char **); -void TvCtrlPointHandleEvent(Upnp_SID, int, IXML_Document *); -void TvCtrlPointHandleSubscribeUpdate(char *, Upnp_SID, int); +void TvCtrlPointHandleEvent(const Upnp_SID, int, IXML_Document *); +void TvCtrlPointHandleSubscribeUpdate(const char *, const Upnp_SID, int); int TvCtrlPointCallbackEventHandler(Upnp_EventType, void *, void *); void TvCtrlPointVerifyTimeouts(int); void TvCtrlPointPrintCommands( void ); diff --git a/upnp/sample/tvdevice/linux/upnp_tv_device_main.c b/upnp/sample/tvdevice/linux/upnp_tv_device_main.c index 1398386..f3c47b5 100644 --- a/upnp/sample/tvdevice/linux/upnp_tv_device_main.c +++ b/upnp/sample/tvdevice/linux/upnp_tv_device_main.c @@ -130,7 +130,8 @@ int main( IN int argc, IN char **argv ) *web_dir_path = NULL; int rc; ithread_t cmdloop_thread; -#ifndef WIN32 +#ifdef WIN32 +#else int sig; sigset_t sigs_to_catch; #endif @@ -178,7 +179,9 @@ int main( IN int argc, IN char **argv ) /* start a command loop thread */ code = ithread_create( &cmdloop_thread, NULL, TvDeviceCommandLoop, NULL ); -#ifndef WIN32 +#ifdef WIN32 + ithread_join(cmdloop_thread, NULL); +#else /* Catch Ctrl-C and properly shutdown */ @@ -187,8 +190,6 @@ int main( IN int argc, IN char **argv ) sigwait( &sigs_to_catch, &sig ); SampleUtil_Print( "Shutting down on signal %d...\n", sig ); -#else - ithread_join(cmdloop_thread, NULL); #endif rc = TvDeviceStop();