diff --git a/ChangeLog b/ChangeLog index 29384b9..3dd50ad 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,9 @@ Version 1.4.7 ******************************************************************************* +2007-05-18 Marcelo Jimenez + * Removed all uses of the DEVICEONLY(x) macro. + 2007-05-17 Marcelo Jimenez * 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. diff --git a/build/inc/config.h b/build/inc/config.h index 57688ba..aaa6ee6 100644 --- a/build/inc/config.h +++ b/build/inc/config.h @@ -338,12 +338,6 @@ # define CLIENTONLY(x) #endif -#ifdef INCLUDE_DEVICE_APIS -# define DEVICEONLY(x) x -#else -# define DEVICEONLY(x) -#endif - //@} #endif diff --git a/upnp/src/api/upnpapi.c b/upnp/src/api/upnpapi.c index 8b8db6c..06ed445 100644 --- a/upnp/src/api/upnpapi.c +++ b/upnp/src/api/upnpapi.c @@ -29,7 +29,7 @@ // /////////////////////////////////////////////////////////////////////////// -//File upnpapi.c + #include "config.h" #include #include @@ -37,22 +37,22 @@ #include #include #ifndef WIN32 - #include - #include - #include + #include + #include + #include - #ifndef SPARC_SOLARIS -// #include - #include - #else - #include - #include - #include - #endif + #ifndef SPARC_SOLARIS +// #include + #include + #else + #include + #include + #include + #endif - #include - #include - #include + #include + #include + #include #endif #include "upnpapi.h" #include "httpreadwrite.h" @@ -63,36 +63,30 @@ #include "httpreadwrite.h" -//************************************ -//Needed for GENA +// Needed for GENA #include "gena.h" #include "service_table.h" #include "miniserver.h" -//******************************************* -/* - ********************* */ #ifdef INTERNAL_WEB_SERVER -#include "webserver.h" -#include "urlconfig.h" + #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; - ) - //Mutex to synchronize handles ( root device or control point handle) - ithread_mutex_t GlobalHndMutex; +// Mutex to synchronize the subscription handling at the client side +CLIENTONLY( ithread_mutex_t GlobalClientSubscribeMutex; ) -//Mutex to synchronize the uuid creation process - ithread_mutex_t gUUIDMutex; +//Mutex to synchronize handles ( root device or control point handle) + ithread_mutex_t GlobalHndMutex; - TimerThread gTimerThread; +// Mutex to synchronize the uuid creation process + ithread_mutex_t gUUIDMutex; - ThreadPool gRecvThreadPool; + TimerThread gTimerThread; - ThreadPool gSendThreadPool; + ThreadPool gRecvThreadPool; + + ThreadPool gSendThreadPool; //Flag to indicate the state of web server WebServerState bWebServerState = WEB_SERVER_DISABLED; @@ -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; - ) - - HandleTable[*Hnd] = HInfo; +#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; diff --git a/upnp/src/gena/gena_callback2.c b/upnp/src/gena/gena_callback2.c index 4783476..231c5b5 100644 --- a/upnp/src/gena/gena_callback2.c +++ b/upnp/src/gena/gena_callback2.c @@ -93,36 +93,35 @@ 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 ) - { - // renew subscription - gena_process_subscription_renewal_request - ( info, request );} - else - { - // subscribe - gena_process_subscription_request( info, request );} +#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 { + // subscribe + gena_process_subscription_request( info, request ); + } + UpnpPrintf( UPNP_ALL, GENA, __FILE__, __LINE__, + "got subscription request\n" ); + } else if( request->method == HTTPMETHOD_UNSUBSCRIBE ) { + found_function = TRUE; + // unsubscribe + gena_process_unsubscribe_request( info, request ); +#endif + } else if( request->method == HTTPMETHOD_NOTIFY ) { +#ifdef INCLUDE_CLIENT_APIS + found_function = TRUE; + // notify + gena_process_notification_event( info, request ); +#endif + } - UpnpPrintf( UPNP_ALL, GENA, __FILE__, __LINE__, - "got subscription request\n" ); - ) - } - else - if( request->method == HTTPMETHOD_UNSUBSCRIBE ) { - DEVICEONLY( found_function = TRUE; - // unsubscribe - gena_process_unsubscribe_request( info, - request ); ) - } else if( request->method == HTTPMETHOD_NOTIFY ) { - CLIENTONLY( found_function = TRUE; - // notify - gena_process_notification_event( info, request ); ) - } - - if( !found_function ) { + if( !found_function ) { // handle missing functions of device or ctrl pt error_respond( info, HTTP_NOT_IMPLEMENTED, request ); - } } +} #endif // EXCLUDE_GENA + diff --git a/upnp/src/genlib/miniserver/miniserver.c b/upnp/src/genlib/miniserver/miniserver.c index 3561894..4ea189d 100644 --- a/upnp/src/genlib/miniserver/miniserver.c +++ b/upnp/src/genlib/miniserver/miniserver.c @@ -106,16 +106,16 @@ SetHTTPGetCallback( MiniServerCallback callback ) } /************************************************************************ -* Function : SetSoapCallback +* Function : SetSoapCallback * -* Parameters : -* MiniServerCallback callback ; - SOAP Callback to be invoked +* Parameters : +* MiniServerCallback callback ; - SOAP Callback to be invoked * -* Description : Set SOAP Callback +* Description : Set SOAP Callback * -* Return : void +* Return : void * -* Note : +* Note : ************************************************************************/ void SetSoapCallback( MiniServerCallback callback ) diff --git a/upnp/src/genlib/net/http/httpparser.c b/upnp/src/genlib/net/http/httpparser.c index 638b6b6..c0136db 100644 --- a/upnp/src/genlib/net/http/httpparser.c +++ b/upnp/src/genlib/net/http/httpparser.c @@ -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, diff --git a/upnp/src/inc/config.h b/upnp/src/inc/config.h index 57688ba..aaa6ee6 100644 --- a/upnp/src/inc/config.h +++ b/upnp/src/inc/config.h @@ -338,12 +338,6 @@ # define CLIENTONLY(x) #endif -#ifdef INCLUDE_DEVICE_APIS -# define DEVICEONLY(x) x -#else -# define DEVICEONLY(x) -#endif - //@} #endif diff --git a/upnp/src/inc/gena.h b/upnp/src/inc/gena.h index 69de0ed..3e179df 100644 --- a/upnp/src/inc/gena.h +++ b/upnp/src/inc/gena.h @@ -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,33 +267,40 @@ 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, - char *UDN, - char *servId, - char **VarNames, - char **VarValues, - int var_count - );) +#ifdef INCLUDE_DEVICE_APIS +EXTERN_C int genaNotifyAll( + UpnpDevice_Handle device_handle, + char *UDN, + char *servId, + char **VarNames, + char **VarValues, + int var_count); +#endif /**************************************************************************** -* Function : genaNotifyAllExt +* Function : genaNotifyAllExt * -* Parameters : -* IN UpnpDevice_Handle device_handle : Device handle -* IN char *UDN : Device udn -* IN char *servId : Service ID -* IN IXML_Document *PropSet : XML document Event varible property set +* Parameters : +* IN UpnpDevice_Handle device_handle : Device handle +* IN char *UDN : Device udn +* IN char *servId : Service ID +* IN IXML_Document *PropSet : XML document Event varible property set * -* Description : This function sends a notification to all the subscribed +* Description : This function sends a notification to all the subscribed * control points * -* Return : int +* Return : int * -* Note : This function is similar to the genaNotifyAll. the only difference -* is it takes the document instead of event variable array +* 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, - IN char *UDN, - IN char *servId, - IN char **VarNames, - IN char **VarValues, - IN int var_count, - IN Upnp_SID sid);) +#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); +#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( - IN UpnpDevice_Handle device_handle, - IN char *UDN, - IN char *servId, - IN IXML_Document *PropSet, - IN Upnp_SID sid);) +#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); +#endif /************************************************************************ diff --git a/upnp/src/inc/miniserver.h b/upnp/src/inc/miniserver.h index e546da8..fbe9faf 100644 --- a/upnp/src/inc/miniserver.h +++ b/upnp/src/inc/miniserver.h @@ -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 diff --git a/upnp/src/inc/soaplib.h b/upnp/src/inc/soaplib.h index 71fc7cb..2231192 100644 --- a/upnp/src/inc/soaplib.h +++ b/upnp/src/inc/soaplib.h @@ -33,28 +33,28 @@ #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 * -* Parameters : -* IN http_parser_t *parser : Parsed request received by the device -* IN http_message_t* request : HTTP request -* INOUT SOCKINFO *info : socket info +* Parameters : +* IN http_parser_t *parser : Parsed request received by the device +* IN http_message_t* request : HTTP request +* INOUT SOCKINFO *info : socket info * -* Description : This is a callback called by minisever after receiving -* the request from the control point. This function will start -* processing the request. It calls handle_invoke_action to handle the -* SOAP action +* Description : This is a callback called by minisever after receiving +* the request from the control point. This function will start +* processing the request. It calls handle_invoke_action to handle the +* SOAP action * -* Return : void +* Return : void * -* Note : +* Note : ****************************************************************************/ -void soap_device_callback( - IN http_parser_t *parser, - IN http_message_t* request, - INOUT SOCKINFO *info ); +void soap_device_callback( + IN http_parser_t *parser, + IN http_message_t* request, + INOUT SOCKINFO *info ); /**************************************************************************** diff --git a/upnp/src/inc/ssdplib.h b/upnp/src/inc/ssdplib.h index 7fa8e48..34d2d17 100644 --- a/upnp/src/inc/ssdplib.h +++ b/upnp/src/inc/ssdplib.h @@ -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, - IN struct sockaddr_in* dest_addr ); +#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 diff --git a/upnp/src/inc/upnpapi.h b/upnp/src/inc/upnpapi.h index a0b9287..5af5659 100644 --- a/upnp/src/inc/upnpapi.h +++ b/upnp/src/inc/upnpapi.h @@ -71,27 +71,32 @@ 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 - //description + // 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 - //terms of DOM document - DEVICEONLY(IXML_NodeList *DeviceList;) // List of devices in the - //description document - DEVICEONLY(IXML_NodeList *ServiceList;) // List of services in the - // description document - DEVICEONLY(service_table ServiceTable;) //table holding subscriptions and + int MaxAge; // Advertisement timeout + IXML_Document *DescDocument;// Description parsed in + //terms of DOM document + IXML_NodeList *DeviceList; // List of devices in the + //description document + IXML_NodeList *ServiceList; // List of services in the + // description document + 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 + // Client only +#ifdef INCLUDE_CLIENT_APIS + client_subscription *ClientSubList; //client subscription list + LinkedList SsdpSearchList; // active ssdp searches +#endif int aliasInstalled; // 0 = not installed; otherwise installed -} ; +}; extern ithread_mutex_t GlobalHndMutex; Upnp_Handle_Type GetHandleInfo(int Hnd, struct Handle_Info **HndInfo); diff --git a/upnp/src/ssdp/ssdp_device.c b/upnp/src/ssdp/ssdp_device.c index 79efdc1..18d30b0 100644 --- a/upnp/src/ssdp/ssdp_device.c +++ b/upnp/src/ssdp/ssdp_device.c @@ -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 diff --git a/upnp/src/ssdp/ssdp_server.c b/upnp/src/ssdp/ssdp_server.c index d5da2b9..5851fc4 100644 --- a/upnp/src/ssdp/ssdp_server.c +++ b/upnp/src/ssdp/ssdp_server.c @@ -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