Removed all uses of the DEVICEONLY(x) macro.

git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@187 119443c7-1b9e-41f8-b6fc-b9c35fce742c
This commit is contained in:
Marcelo Roberto Jimenez 2007-05-19 02:10:02 +00:00
parent 4e1240a0a8
commit 83fb96fbe2
14 changed files with 183 additions and 176 deletions

View File

@ -2,6 +2,9 @@
Version 1.4.7
*******************************************************************************
2007-05-18 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
* Removed all uses of the DEVICEONLY(x) macro.
2007-05-17 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
* Removed all uses of the DBGONLY(x) macro. A static inline empty
function now is used and the compiler takes care of optimizing it out.

View File

@ -338,12 +338,6 @@
# define CLIENTONLY(x)
#endif
#ifdef INCLUDE_DEVICE_APIS
# define DEVICEONLY(x) x
#else
# define DEVICEONLY(x)
#endif
//@}
#endif

View File

@ -29,7 +29,7 @@
//
///////////////////////////////////////////////////////////////////////////
//File upnpapi.c
#include "config.h"
#include <assert.h>
#include <signal.h>
@ -63,25 +63,19 @@
#include "httpreadwrite.h"
//************************************
// Needed for GENA
#include "gena.h"
#include "service_table.h"
#include "miniserver.h"
//*******************************************
/*
********************* */
#ifdef INTERNAL_WEB_SERVER
#include "webserver.h"
#include "urlconfig.h"
#endif // INTERNAL_WEB_SERVER
/*
****************** */
// Mutex to synchronize the subscription handling at the client side
CLIENTONLY( ithread_mutex_t GlobalClientSubscribeMutex;
)
CLIENTONLY( ithread_mutex_t GlobalClientSubscribeMutex; )
//Mutex to synchronize handles ( root device or control point handle)
ithread_mutex_t GlobalHndMutex;
@ -264,8 +258,7 @@ int UpnpInit( IN const char *HostIP,
UpnpSdkInit = 1;
#if EXCLUDE_SOAP == 0
DEVICEONLY( SetSoapCallback( soap_device_callback );
);
SetSoapCallback( soap_device_callback );
#endif
#if EXCLUDE_GENA == 0
SetGenaCallback( genaCallback );
@ -357,10 +350,12 @@ PrintThreadPoolStats (const char* DbgFileName, int DbgLineNo,
int
UpnpFinish()
{
DEVICEONLY( UpnpDevice_Handle device_handle;
)
CLIENTONLY( UpnpClient_Handle client_handle;
)
#ifdef INCLUDE_DEVICE_APIS
UpnpDevice_Handle device_handle;
#endif
#ifdef INCLUDE_CLIENT_APIS
UpnpClient_Handle client_handle;
#endif
struct Handle_Info *temp;
#ifdef DEBUG
@ -371,8 +366,9 @@ UpnpFinish()
// WSACleanup( );
#endif
if( UpnpSdkInit != 1 )
if( UpnpSdkInit != 1 ) {
return UPNP_E_FINISH;
}
UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
"Inside UpnpFinish : UpnpSdkInit is :%d:\n",
@ -1308,10 +1304,8 @@ UpnpRegisterClient( IN Upnp_FunPtr Fun,
if( UpnpSdkInit != 1 ) {
return UPNP_E_FINISH;
}
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
"Inside UpnpRegisterClient \n" );
if( Fun == NULL || Hnd == NULL ) {
return UPNP_E_INVALID_PARAM;
}
@ -1322,7 +1316,6 @@ UpnpRegisterClient( IN Upnp_FunPtr Fun,
HandleUnlock();
return UPNP_E_ALREADY_REGISTERED;
}
if( ( *Hnd = GetFreeHandle() ) == UPNP_E_OUTOF_HANDLE ) {
HandleUnlock();
return UPNP_E_OUTOF_MEMORY;
@ -1336,17 +1329,15 @@ UpnpRegisterClient( IN Upnp_FunPtr Fun,
HInfo->HType = HND_CLIENT;
HInfo->Callback = Fun;
HInfo->Cookie = ( void * )Cookie;
DEVICEONLY( HInfo->MaxAge = 0;
)
HInfo->ClientSubList = NULL;
ListInit( &HInfo->SsdpSearchList, NULL, NULL );
DEVICEONLY( HInfo->MaxSubscriptions = UPNP_INFINITE;
)
DEVICEONLY( HInfo->MaxSubscriptionTimeOut = UPNP_INFINITE;
)
#ifdef INCLUDE_DEVICE_APIS
HInfo->MaxAge = 0;
HInfo->MaxSubscriptions = UPNP_INFINITE;
HInfo->MaxSubscriptionTimeOut = UPNP_INFINITE;
#endif
HandleTable[*Hnd] = HInfo;
UpnpSdkClientRegistered = 1;
HandleUnlock();
@ -3674,11 +3665,11 @@ int PrintHandleInfo( IN UpnpClient_Handle Hnd )
"Printing information for Handle_%d\n", Hnd);
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
"HType_%d\n", HndInfo->HType);
DEVICEONLY(
#ifdef INCLUDE_DEVICE_APIS
if(HndInfo->HType != HND_CLIENT)
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
"DescURL_%s\n", HndInfo->DescURL );
)
#endif
#endif
} else {
return UPNP_E_INVALID_HANDLE;

View File

@ -93,31 +93,29 @@ genaCallback( IN http_parser_t * parser,
xboolean found_function = FALSE;
if( request->method == HTTPMETHOD_SUBSCRIBE ) {
DEVICEONLY( found_function = TRUE;
if( httpmsg_find_hdr( request, HDR_NT, NULL ) == NULL )
{
#ifdef INCLUDE_DEVICE_APIS
found_function = TRUE;
if( httpmsg_find_hdr( request, HDR_NT, NULL ) == NULL ) {
// renew subscription
gena_process_subscription_renewal_request
( info, request );}
else
{
( info, request );
} else {
// subscribe
gena_process_subscription_request( info, request );}
gena_process_subscription_request( info, request );
}
UpnpPrintf( UPNP_ALL, GENA, __FILE__, __LINE__,
"got subscription request\n" );
)
}
else
if( request->method == HTTPMETHOD_UNSUBSCRIBE ) {
DEVICEONLY( found_function = TRUE;
} else if( request->method == HTTPMETHOD_UNSUBSCRIBE ) {
found_function = TRUE;
// unsubscribe
gena_process_unsubscribe_request( info,
request ); )
gena_process_unsubscribe_request( info, request );
#endif
} else if( request->method == HTTPMETHOD_NOTIFY ) {
CLIENTONLY( found_function = TRUE;
#ifdef INCLUDE_CLIENT_APIS
found_function = TRUE;
// notify
gena_process_notification_event( info, request ); )
gena_process_notification_event( info, request );
#endif
}
if( !found_function ) {
@ -126,3 +124,4 @@ genaCallback( IN http_parser_t * parser,
}
}
#endif // EXCLUDE_GENA

View File

@ -2505,7 +2505,7 @@ print_http_headers( http_message_t * hmsg )
if( hmsg->is_request ) {
printf( "method = %d, version = %d.%d, url = %.*s\n",
hmsg->method, hmsg->major_version, hmsg->minor_version,
hmsg->uri.pathquery.size, hmsg->uri.pathquery.buff);
(int)hmsg->uri.pathquery.size, hmsg->uri.pathquery.buff);
} else {
printf( "resp status = %d, version = %d.%d, status msg = %.*s\n",
hmsg->status_code, hmsg->major_version, hmsg->minor_version,

View File

@ -338,12 +338,6 @@
# define CLIENTONLY(x)
#endif
#ifdef INCLUDE_DEVICE_APIS
# define DEVICEONLY(x) x
#else
# define DEVICEONLY(x)
#endif
//@}
#endif

View File

@ -219,8 +219,9 @@ CLIENTONLY(EXTERN_C int genaUnregisterClient(
* Returns: int
* returns UPNP_E_SUCCESS if successful else returns GENA_E_BAD_HANDLE
****************************************************************************/
DEVICEONLY(EXTERN_C int genaUnregisterDevice(
UpnpDevice_Handle device_handle);)
#ifdef INCLUDE_DEVICE_APIS
EXTERN_C int genaUnregisterDevice(UpnpDevice_Handle device_handle);
#endif
/************************************************************************
@ -266,13 +267,15 @@ CLIENTONLY(EXTERN_C int genaRenewSubscription(
* Note : This function is similar to the genaNotifyAllExt. The only difference
* is it takes event variable array instead of xml document.
****************************************************************************/
DEVICEONLY(EXTERN_C int genaNotifyAll(UpnpDevice_Handle device_handle,
#ifdef INCLUDE_DEVICE_APIS
EXTERN_C int genaNotifyAll(
UpnpDevice_Handle device_handle,
char *UDN,
char *servId,
char **VarNames,
char **VarValues,
int var_count
);)
int var_count);
#endif
/****************************************************************************
* Function : genaNotifyAllExt
@ -291,8 +294,13 @@ DEVICEONLY(EXTERN_C int genaNotifyAll(UpnpDevice_Handle device_handle,
* Note : This function is similar to the genaNotifyAll. the only difference
* is it takes the document instead of event variable array
****************************************************************************/
DEVICEONLY(EXTERN_C int genaNotifyAllExt(UpnpDevice_Handle device_handle,
char *UDN, char *servId,IN IXML_Document *PropSet);)
#ifdef INCLUDE_DEVICE_APIS
EXTERN_C int genaNotifyAllExt(
UpnpDevice_Handle device_handle,
char *UDN,
char *servId,
IN IXML_Document *PropSet);
#endif
/****************************************************************************
* Function : genaInitNotify
@ -315,13 +323,15 @@ DEVICEONLY(EXTERN_C int genaNotifyAllExt(UpnpDevice_Handle device_handle,
* Note : No other event will be sent to this control point before the
* intial state table dump.
****************************************************************************/
DEVICEONLY(EXTERN_C int genaInitNotify(IN UpnpDevice_Handle device_handle,
#ifdef INCLUDE_DEVICE_APIS
EXTERN_C int genaInitNotify(IN UpnpDevice_Handle device_handle,
IN char *UDN,
IN char *servId,
IN char **VarNames,
IN char **VarValues,
IN int var_count,
IN Upnp_SID sid);)
IN Upnp_SID sid);
#endif
/****************************************************************************
* Function : genaInitNotifyExt
@ -343,12 +353,14 @@ DEVICEONLY(EXTERN_C int genaInitNotify(IN UpnpDevice_Handle device_handle,
* Note : No other event will be sent to this control point before the
* intial state table dump.
****************************************************************************/
DEVICEONLY(EXTERN_C int genaInitNotifyExt(
#ifdef INCLUDE_DEVICE_APIS
EXTERN_C int genaInitNotifyExt(
IN UpnpDevice_Handle device_handle,
IN char *UDN,
IN char *servId,
IN IXML_Document *PropSet,
IN Upnp_SID sid);)
IN Upnp_SID sid);
#endif
/************************************************************************

View File

@ -88,7 +88,11 @@ void SetHTTPGetCallback( MiniServerCallback callback );
*
* Note :
************************************************************************/
#ifdef INCLUDE_DEVICE_APIS
void SetSoapCallback( MiniServerCallback callback );
#else
static inline void SetSoapCallback( MiniServerCallback callback ) {}
#endif
/************************************************************************
* Function : SetGenaCallback

View File

@ -211,8 +211,15 @@ int Make_Socket_NoBlocking (int sock);
* Returns: void *
* 1 if successful else appropriate error
***************************************************************************/
void ssdp_handle_device_request( IN http_message_t* hmsg,
#ifdef INCLUDE_DEVICE_APIS
void ssdp_handle_device_request(
IN http_message_t* hmsg,
IN struct sockaddr_in* dest_addr );
#else
static inline void ssdp_handle_device_request(
IN http_message_t* hmsg,
IN struct sockaddr_in* dest_addr ) {}
#endif
/************************************************************************
* Function : ssdp_handle_ctrlpt_msg

View File

@ -71,25 +71,30 @@ struct Handle_Info
Upnp_FunPtr Callback; // Callback function pointer.
char * Cookie;
DEVICEONLY(char DescURL[LINE_SIZE];) // URL for the use of SSDP
DEVICEONLY(char DescXML[LINE_SIZE];) // XML file path for device
// Device Only
#ifdef INCLUDE_DEVICE_APIS
char DescURL[LINE_SIZE]; // URL for the use of SSDP
char DescXML[LINE_SIZE]; // XML file path for device
//description
DEVICEONLY(int MaxAge;) // Advertisement timeout
DEVICEONLY(IXML_Document *DescDocument;) // Description parsed in
int MaxAge; // Advertisement timeout
IXML_Document *DescDocument;// Description parsed in
//terms of DOM document
DEVICEONLY(IXML_NodeList *DeviceList;) // List of devices in the
IXML_NodeList *DeviceList; // List of devices in the
//description document
DEVICEONLY(IXML_NodeList *ServiceList;) // List of services in the
IXML_NodeList *ServiceList; // List of services in the
// description document
DEVICEONLY(service_table ServiceTable;) //table holding subscriptions and
service_table ServiceTable; //table holding subscriptions and
//URL information
DEVICEONLY(int MaxSubscriptions;)
DEVICEONLY(int MaxSubscriptionTimeOut;)
int MaxSubscriptions;
int MaxSubscriptionTimeOut;
#endif
// Client only
CLIENTONLY(client_subscription * ClientSubList;) //client subscription list
CLIENTONLY(LinkedList SsdpSearchList;) // active ssdp searches
#ifdef INCLUDE_CLIENT_APIS
client_subscription *ClientSubList; //client subscription list
LinkedList SsdpSearchList; // active ssdp searches
#endif
int aliasInstalled; // 0 = not installed; otherwise installed
};

View File

@ -95,6 +95,7 @@ advertiseAndReplyThread( IN void *data )
* Returns: void *
* 1 if successful else appropriate error
***************************************************************************/
#ifdef INCLUDE_DEVICE_APIS
void
ssdp_handle_device_request( IN http_message_t * hmsg,
IN struct sockaddr_in *dest_addr )
@ -190,6 +191,7 @@ ssdp_handle_device_request( IN http_message_t * hmsg,
TimerThreadSchedule( &gTimerThread, replyTime, REL_SEC, &job,
SHORT_TERM, NULL );
}
#endif
/************************************************************************
* Function : NewRequestHandler

View File

@ -746,14 +746,10 @@ ssdp_event_handler_thread( void *the_data )
// send msg to device or ctrlpt
if( ( hmsg->method == HTTPMETHOD_NOTIFY ) ||
( hmsg->request_method == HTTPMETHOD_MSEARCH ) ) {
CLIENTONLY( ssdp_handle_ctrlpt_msg( hmsg, &data->dest_addr,
FALSE, NULL );
);
FALSE, NULL ););
} else {
DEVICEONLY( ssdp_handle_device_request( hmsg, &data->dest_addr );
);
ssdp_handle_device_request( hmsg, &data->dest_addr );
}
// free data