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 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> 2007-05-17 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
* Removed all uses of the DBGONLY(x) macro. A static inline empty * 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. function now is used and the compiler takes care of optimizing it out.

View File

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

View File

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

View File

@ -93,36 +93,35 @@ genaCallback( IN http_parser_t * parser,
xboolean found_function = FALSE; xboolean found_function = FALSE;
if( request->method == HTTPMETHOD_SUBSCRIBE ) { if( request->method == HTTPMETHOD_SUBSCRIBE ) {
DEVICEONLY( found_function = TRUE; #ifdef INCLUDE_DEVICE_APIS
if( httpmsg_find_hdr( request, HDR_NT, NULL ) == NULL ) found_function = TRUE;
{ if( httpmsg_find_hdr( request, HDR_NT, NULL ) == NULL ) {
// renew subscription // renew subscription
gena_process_subscription_renewal_request gena_process_subscription_renewal_request
( info, request );} ( info, request );
else } else {
{
// subscribe // subscribe
gena_process_subscription_request( info, request );} gena_process_subscription_request( info, request );
}
UpnpPrintf( UPNP_ALL, GENA, __FILE__, __LINE__, UpnpPrintf( UPNP_ALL, GENA, __FILE__, __LINE__,
"got subscription request\n" ); "got subscription request\n" );
) } else if( request->method == HTTPMETHOD_UNSUBSCRIBE ) {
} found_function = TRUE;
else
if( request->method == HTTPMETHOD_UNSUBSCRIBE ) {
DEVICEONLY( found_function = TRUE;
// unsubscribe // unsubscribe
gena_process_unsubscribe_request( info, gena_process_unsubscribe_request( info, request );
request ); ) #endif
} else if( request->method == HTTPMETHOD_NOTIFY ) { } else if( request->method == HTTPMETHOD_NOTIFY ) {
CLIENTONLY( found_function = TRUE; #ifdef INCLUDE_CLIENT_APIS
found_function = TRUE;
// notify // notify
gena_process_notification_event( info, request ); ) gena_process_notification_event( info, request );
#endif
} }
if( !found_function ) { if( !found_function ) {
// handle missing functions of device or ctrl pt // handle missing functions of device or ctrl pt
error_respond( info, HTTP_NOT_IMPLEMENTED, request ); error_respond( info, HTTP_NOT_IMPLEMENTED, request );
} }
} }
#endif // EXCLUDE_GENA #endif // EXCLUDE_GENA

View File

@ -2505,7 +2505,7 @@ print_http_headers( http_message_t * hmsg )
if( hmsg->is_request ) { if( hmsg->is_request ) {
printf( "method = %d, version = %d.%d, url = %.*s\n", printf( "method = %d, version = %d.%d, url = %.*s\n",
hmsg->method, hmsg->major_version, hmsg->minor_version, 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 { } else {
printf( "resp status = %d, version = %d.%d, status msg = %.*s\n", printf( "resp status = %d, version = %d.%d, status msg = %.*s\n",
hmsg->status_code, hmsg->major_version, hmsg->minor_version, hmsg->status_code, hmsg->major_version, hmsg->minor_version,

View File

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

View File

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

View File

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

View File

@ -33,7 +33,7 @@
#define SOAPLIB_H #define SOAPLIB_H
//SOAP module API to be called in Upnp-Dk API // SOAP module API to be called in Upnp-Dk API
/**************************************************************************** /****************************************************************************
* Function : soap_device_callback * Function : soap_device_callback
* *

View File

@ -211,8 +211,15 @@ int Make_Socket_NoBlocking (int sock);
* Returns: void * * Returns: void *
* 1 if successful else appropriate error * 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 ); 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 * Function : ssdp_handle_ctrlpt_msg

View File

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

View File

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

View File

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