diff --git a/ChangeLog b/ChangeLog index 1fc1f79..3e2d2bb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,11 @@ Version 1.4.7 ******************************************************************************* +2007-05-21 Marcelo Jimenez + * More MSVC fixes, using XINLINE instead of inline, MSVC has troubles + with inline. Thanks to David Maass for reporting. + * Changed XINLINE to UPNP_INLINE. + 2007-05-21 Marcelo Jimenez * Added the file build/inc/msvc/inttypes.h. This file is for use with MSVC only, because it does not provide C99 compatibility. diff --git a/ixml/src/inc/ixmlmembuf.h b/ixml/src/inc/ixmlmembuf.h index cd99c25..ad81ad0 100644 --- a/ixml/src/inc/ixmlmembuf.h +++ b/ixml/src/inc/ixmlmembuf.h @@ -39,7 +39,7 @@ #define MAXVAL( a, b ) ( (a) > (b) ? (a) : (b) ) #ifndef WIN32 - #define XINLINE inline + #define UPNP_INLINE inline #endif #define MEMBUF_DEF_SIZE_INC 20 diff --git a/upnp/inc/upnp.h b/upnp/inc/upnp.h index 290cd5e..50d1e6c 100644 --- a/upnp/inc/upnp.h +++ b/upnp/inc/upnp.h @@ -65,20 +65,35 @@ #else #define EXPORT_SPEC #endif - #ifdef UPNP_USE_MSVCPP // define some things the M$ VC++ doesn't know + #ifdef UPNP_USE_MSVCPP + // define some things the M$ VC++ doesn't know + #define UPNP_INLINE typedef __int64 int64_t; #define PRId64 "I64d" #define PRIzu "lu" #endif - #ifdef UPNP_USE_BCBPP // define some things Borland Builder doesn't know + #ifdef UPNP_USE_BCBPP + // define some things Borland Builder doesn't know + #define UPNP_INLINE inline typedef __int64 int64_t; +#warning The Borland C compiler is probably broken on PRId64, please someone provide a proper fix here + #define PRId64 "I64d" #define PRIzu "zu" #endif #else #define EXPORT_SPEC + #define UPNP_INLINE inline + // Invented this macro so that we can live a little longer with MSVC lack of C99. #define PRIzu "zu" #endif +// +// Defining this macro here gives some interesting information about unused +// functions in the code. Of course, this should never go uncommented on a +// release. +// +//#define inline + #ifndef WIN32 #define UpnpCloseSocket close diff --git a/upnp/inc/upnpdebug.h b/upnp/inc/upnpdebug.h index f9822ba..007f6e4 100644 --- a/upnp/inc/upnpdebug.h +++ b/upnp/inc/upnpdebug.h @@ -100,12 +100,13 @@ typedef enum Upnp_LogLevel_e { /*************************************************************************** - * Function : UpnpInitLog - * - * Parameters: void - * - * Description: + * Function : UpnpInitLog + * + * Parameters: void + * + * Description: * This functions initializes the log files + * * Returns: int * -1 : If fails * UPNP_E_SUCCESS : if success @@ -113,7 +114,7 @@ typedef enum Upnp_LogLevel_e { #ifdef DEBUG int UpnpInitLog(); #else -static inline int UpnpInitLog() { return UPNP_E_SUCCESS; } +static UPNP_INLINE int UpnpInitLog() { return UPNP_E_SUCCESS; } #endif // for backward compatibility @@ -132,7 +133,7 @@ static inline int UpnpInitLog() { return UPNP_E_SUCCESS; } #ifdef DEBUG void UpnpSetLogLevel(Upnp_LogLevel log_level); #else -static inline void UpnpSetLogLevel(Upnp_LogLevel log_level) {} +static UPNP_INLINE void UpnpSetLogLevel(Upnp_LogLevel log_level) {} #endif @@ -148,7 +149,7 @@ static inline void UpnpSetLogLevel(Upnp_LogLevel log_level) {} #ifdef DEBUG void UpnpCloseLog(); #else -static inline void UpnpCloseLog() {} +static UPNP_INLINE void UpnpCloseLog() {} #endif // for backward compatibility @@ -174,7 +175,7 @@ void UpnpSetLogFileNames( const char *ErrFileName, const char *InfoFileName); #else -static inline void UpnpSetLogFileNames( +static UPNP_INLINE void UpnpSetLogFileNames( const char *ErrFileName, const char *InfoFileName) {} #endif @@ -202,7 +203,7 @@ static inline void UpnpSetLogFileNames( #ifdef DEBUG FILE *UpnpGetDebugFile(Upnp_LogLevel level, Dbg_Module module); #else -static inline FILE *UpnpGetDebugFile(Upnp_LogLevel level, Dbg_Module module) +static UPNP_INLINE FILE *UpnpGetDebugFile(Upnp_LogLevel level, Dbg_Module module) { return NULL; } @@ -232,7 +233,7 @@ int DebugAtThisLevel( IN Upnp_LogLevel DLevel, IN Dbg_Module Module); #else -static inline int DebugAtThisLevel( +static UPNP_INLINE int DebugAtThisLevel( IN Upnp_LogLevel DLevel, IN Dbg_Module Module) { return 0; } #endif @@ -269,7 +270,7 @@ void UpnpPrintf (Upnp_LogLevel DLevel, Dbg_Module Module, #endif ; #else -static inline void UpnpPrintf( +static UPNP_INLINE void UpnpPrintf( Upnp_LogLevel DLevel, Dbg_Module Module, const char* DbgFileName, @@ -300,7 +301,7 @@ void UpnpDisplayBanner( size_t size, int starlength); #else -static inline void UpnpDisplayBanner( +static UPNP_INLINE void UpnpDisplayBanner( FILE *fd, const char **lines, size_t size, @@ -328,7 +329,7 @@ void UpnpDisplayFileAndLine( const char *DbgFileName, int DbgLineNo); #else -static inline void UpnpDisplayFileAndLine( +static UPNP_INLINE void UpnpDisplayFileAndLine( FILE *fd, const char *DbgFileName, int DbgLineNo) {} diff --git a/upnp/src/api/upnpdebug.c b/upnp/src/api/upnpdebug.c index 861314e..708fcad 100644 --- a/upnp/src/api/upnpdebug.c +++ b/upnp/src/api/upnpdebug.c @@ -88,18 +88,19 @@ UpnpSetLogFileNames ( IN const char *ErrFileName, /*************************************************************************** - * Function : UpnpInitLog - * - * Parameters: void - * - * Description: + * Function : UpnpInitLog + * + * Parameters: void + * + * Description: * This functions initializes the log files + * * Returns: int * -1 : If fails * UPNP_E_SUCCESS : if success ***************************************************************************/ int -UpnpInitLog( ) +UpnpInitLog() { ithread_mutex_init( &GlobalDebugMutex, NULL ); @@ -139,7 +140,7 @@ UpnpSetLogLevel (Upnp_LogLevel log_level) * Returns: void ***************************************************************************/ void -UpnpCloseLog( ) +UpnpCloseLog() { if( DEBUG_TARGET == 1 ) { fflush( ErrFileHnd ); diff --git a/upnp/src/gena/gena_device.c b/upnp/src/gena/gena_device.c index 76b1577..33594ac 100644 --- a/upnp/src/gena/gena_device.c +++ b/upnp/src/gena/gena_device.c @@ -188,7 +188,7 @@ free_notify_struct( IN notify_thread_struct * input ) * * Note : called by genaNotify ****************************************************************************/ -static XINLINE int +static UPNP_INLINE int notify_send_and_recv( IN uri_type * destination_url, IN membuffer * mid_msg, IN char *propertySet, diff --git a/upnp/src/genlib/miniserver/miniserver.c b/upnp/src/genlib/miniserver/miniserver.c index 4ea189d..2021b9c 100644 --- a/upnp/src/genlib/miniserver/miniserver.c +++ b/upnp/src/genlib/miniserver/miniserver.c @@ -215,7 +215,7 @@ dispatch_request( IN SOCKINFO * info, * * Note : ************************************************************************/ -static XINLINE void +static UPNP_INLINE void handle_error( IN SOCKINFO * info, int http_error_code, int major, @@ -333,7 +333,7 @@ handle_request( void *args ) * * Note : ************************************************************************/ -static XINLINE void +static UPNP_INLINE void schedule_request_job( IN int connfd, IN struct sockaddr_in *clientAddr ) { diff --git a/upnp/src/genlib/net/http/httpparser.c b/upnp/src/genlib/net/http/httpparser.c index c0136db..0351814 100644 --- a/upnp/src/genlib/net/http/httpparser.c +++ b/upnp/src/genlib/net/http/httpparser.c @@ -121,7 +121,7 @@ str_int_entry Http_Header_Names[NUM_HTTP_HEADER_NAMES] = { * * Note : ************************************************************************/ -static XINLINE void +static UPNP_INLINE void scanner_init( OUT scanner_t * scanner, IN membuffer * bufptr ) { @@ -142,7 +142,7 @@ scanner_init( OUT scanner_t * scanner, * * Note : ************************************************************************/ -static XINLINE xboolean +static UPNP_INLINE xboolean is_separator_char( IN char c ) { return strchr( " \t()<>@,;:\\\"/[]?={}", c ) != NULL; @@ -160,7 +160,7 @@ is_separator_char( IN char c ) * * Note : ************************************************************************/ -static XINLINE xboolean +static UPNP_INLINE xboolean is_identifier_char( IN char c ) { return ( c >= 32 && c <= 126 ) && !is_separator_char( c ); @@ -178,7 +178,7 @@ is_identifier_char( IN char c ) * * Note : ************************************************************************/ -static XINLINE xboolean +static UPNP_INLINE xboolean is_control_char( IN char c ) { return ( ( c >= 0 && c <= 31 ) || ( c == 127 ) ); @@ -196,7 +196,7 @@ is_control_char( IN char c ) * * Note : ************************************************************************/ -static XINLINE xboolean +static UPNP_INLINE xboolean is_qdtext_char( IN char cc ) { unsigned char c = ( unsigned char )cc; @@ -375,7 +375,7 @@ scanner_get_token( INOUT scanner_t * scanner, * * Note : ************************************************************************/ -static XINLINE char * +static UPNP_INLINE char * scanner_get_str( IN scanner_t * scanner ) { return scanner->msg->buf + scanner->cursor; @@ -395,7 +395,9 @@ scanner_get_str( IN scanner_t * scanner ) * * Note : ************************************************************************/ -static XINLINE void +#warning The only use of the function 'scanner_pushback()' in the code is commented out. +#warning 'scanner_pushback()' is a good candidate for removal. +static UPNP_INLINE void scanner_pushback( INOUT scanner_t * scanner, IN size_t pushback_bytes ) { @@ -614,7 +616,7 @@ httpmsg_find_hdr( IN http_message_t * msg, * * Note : ************************************************************************/ -static XINLINE int +static UPNP_INLINE int skip_blank_lines( INOUT scanner_t * scanner ) { memptr token; @@ -651,7 +653,7 @@ skip_blank_lines( INOUT scanner_t * scanner ) * * Note : ************************************************************************/ -static XINLINE int +static UPNP_INLINE int skip_lws( INOUT scanner_t * scanner ) { memptr token; @@ -698,7 +700,7 @@ skip_lws( INOUT scanner_t * scanner ) * * Description : Match a string without whitespace or CRLF (%S) * -* Return : XINLINE parse_status_t ; +* Return : UPNP_INLINE parse_status_t ; * PARSE_OK * PARSE_NO_MATCH * PARSE_FAILURE @@ -706,7 +708,7 @@ skip_lws( INOUT scanner_t * scanner ) * * Note : ************************************************************************/ -static XINLINE parse_status_t +static UPNP_INLINE parse_status_t match_non_ws_string( INOUT scanner_t * scanner, OUT memptr * str ) { @@ -772,7 +774,7 @@ match_non_ws_string( INOUT scanner_t * scanner, * * Note : ************************************************************************/ -static XINLINE parse_status_t +static UPNP_INLINE parse_status_t match_raw_value( INOUT scanner_t * scanner, OUT memptr * raw_value ) { @@ -863,7 +865,7 @@ match_raw_value( INOUT scanner_t * scanner, * PARSE_FAILURE -- bad input * PARSE_INCOMPLETE ************************************************************************/ -static XINLINE int +static UPNP_INLINE int match_int( INOUT scanner_t * scanner, IN int base, OUT int *value ) @@ -922,7 +924,7 @@ match_int( INOUT scanner_t * scanner, * PARSE_FAILURE * PARSE_INCOMPLETE ************************************************************************/ -static XINLINE int +static UPNP_INLINE int read_until_crlf( INOUT scanner_t * scanner, OUT memptr * str ) { @@ -963,7 +965,9 @@ read_until_crlf( INOUT scanner_t * scanner, * PARSE_FAILURE * PARSE_INCOMPLETE ************************************************************************/ -static XINLINE int +#warning There are currently no uses of the function 'skip_to_end_of_header()' in the code. +#warning 'skip_to_end_of_header()' is a good candidate for removal. +static UPNP_INLINE int skip_to_end_of_header( INOUT scanner_t * scanner ) { memptr dummy_raw_value; @@ -990,7 +994,7 @@ skip_to_end_of_header( INOUT scanner_t * scanner ) * PARSE_NO_MATCH * PARSE_INCOMPLETE ************************************************************************/ -static XINLINE parse_status_t +static UPNP_INLINE parse_status_t match_char( INOUT scanner_t * scanner, IN char c, IN xboolean case_sensitive ) @@ -1337,7 +1341,7 @@ matchstr( IN char *str, * Returns: * void ************************************************************************/ -static XINLINE void +static UPNP_INLINE void parser_init( OUT http_parser_t * parser ) { memset( parser, 0, sizeof( http_parser_t ) ); @@ -1872,7 +1876,7 @@ parser_parse_headers_old( INOUT http_parser_t * parser ) * PARSE_FAILURE -- entity length > content-length value * PARSE_SUCCESS ************************************************************************/ -static XINLINE parse_status_t +static UPNP_INLINE parse_status_t parser_parse_entity_using_clen( INOUT http_parser_t * parser ) { //int entity_length; @@ -1919,7 +1923,7 @@ parser_parse_entity_using_clen( INOUT http_parser_t * parser ) * PARSE_FAILURE -- entity length > content-length value * PARSE_SUCCESS ************************************************************************/ -static XINLINE parse_status_t +static UPNP_INLINE parse_status_t parser_parse_chunky_body( INOUT http_parser_t * parser ) { parse_status_t status; @@ -1964,7 +1968,7 @@ parser_parse_chunky_body( INOUT http_parser_t * parser ) * PARSE_FAILURE -- entity length > content-length value * PARSE_SUCCESS ************************************************************************/ -static XINLINE parse_status_t +static UPNP_INLINE parse_status_t parser_parse_chunky_headers( INOUT http_parser_t * parser ) { parse_status_t status; @@ -2004,7 +2008,7 @@ parser_parse_chunky_headers( INOUT http_parser_t * parser ) * PARSE_SUCCESS * PARSE_CONTINUE_1 ************************************************************************/ -static XINLINE parse_status_t +static UPNP_INLINE parse_status_t parser_parse_chunky_entity( INOUT http_parser_t * parser ) { scanner_t *scanner = &parser->scanner; @@ -2055,7 +2059,7 @@ parser_parse_chunky_entity( INOUT http_parser_t * parser ) * Returns: * PARSE_INCOMPLETE_ENTITY ************************************************************************/ -static XINLINE parse_status_t +static UPNP_INLINE parse_status_t parser_parse_entity_until_close( INOUT http_parser_t * parser ) { size_t cursor; @@ -2090,7 +2094,7 @@ parser_parse_entity_until_close( INOUT http_parser_t * parser ) * PARSE_FAILURE * PARSE_COMPLETE -- no more reading to do ************************************************************************/ -XINLINE parse_status_t +UPNP_INLINE parse_status_t parser_get_entity_read_method( INOUT http_parser_t * parser ) { http_message_t *hmsg = &parser->msg; @@ -2195,7 +2199,7 @@ parser_get_entity_read_method( INOUT http_parser_t * parser ) * PARSE_FAILURE * PARSE_COMPLETE -- no more reading to do ************************************************************************/ -XINLINE parse_status_t +UPNP_INLINE parse_status_t parser_parse_entity( INOUT http_parser_t * parser ) { parse_status_t status = PARSE_OK; diff --git a/upnp/src/genlib/net/http/httpreadwrite.c b/upnp/src/genlib/net/http/httpreadwrite.c index c7a36c0..d144441 100644 --- a/upnp/src/genlib/net/http/httpreadwrite.c +++ b/upnp/src/genlib/net/http/httpreadwrite.c @@ -2343,7 +2343,7 @@ http_OpenHttpGetEx( IN const char *url_str, * Description : Returns the server information for the operating * system * -* Return : XINLINE void +* Return : UPNP_INLINE void * * Note : ************************************************************************/ diff --git a/upnp/src/genlib/net/http/statcodes.c b/upnp/src/genlib/net/http/statcodes.c index 950c379..ad690e1 100644 --- a/upnp/src/genlib/net/http/statcodes.c +++ b/upnp/src/genlib/net/http/statcodes.c @@ -118,7 +118,7 @@ static xboolean gInitialized = FALSE; * Returns: * void ************************************************************************/ -static XINLINE void +static UPNP_INLINE void init_table( IN const char *encoded_str, OUT const char *table[], IN int tbl_size ) @@ -144,7 +144,7 @@ init_table( IN const char *encoded_str, * Returns: * void ************************************************************************/ -static XINLINE void +static UPNP_INLINE void init_tables( void ) { init_table( Http1xxStr, Http1xxCodes, NUM_1XX_CODES ); diff --git a/upnp/src/genlib/net/http/webserver.c b/upnp/src/genlib/net/http/webserver.c index 3e6a3ba..3551ab0 100644 --- a/upnp/src/genlib/net/http/webserver.c +++ b/upnp/src/genlib/net/http/webserver.c @@ -205,7 +205,7 @@ extern str_int_entry Http_Header_Names[NUM_HTTP_HEADER_NAMES]; * Returns: * void ************************************************************************/ -static XINLINE void +static UPNP_INLINE void media_list_init( void ) { int i; @@ -243,7 +243,7 @@ media_list_init( void ) * 0 on success; * -1 on error ************************************************************************/ -static XINLINE int +static UPNP_INLINE int search_extension( IN const char *extension, OUT const char **con_type, OUT const char **con_subtype ) @@ -290,7 +290,7 @@ search_extension( IN const char *extension, * 0 - On Sucess * UPNP_E_OUTOF_MEMORY - on memory allocation failures ************************************************************************/ -XINLINE int +UPNP_INLINE int get_content_type( IN const char *filename, OUT DOMString * content_type ) { @@ -348,7 +348,7 @@ get_content_type( IN const char *filename, * Returns: * void ************************************************************************/ -static XINLINE void +static UPNP_INLINE void glob_alias_init( void ) { struct xml_alias_t *alias = &gAliasDoc; @@ -370,7 +370,7 @@ glob_alias_init( void ) * Returns: * BOOLEAN ************************************************************************/ -static XINLINE xboolean +static UPNP_INLINE xboolean is_valid_alias( IN const struct xml_alias_t *alias ) { return alias->doc.buf != NULL; @@ -700,7 +700,7 @@ web_server_set_root_dir( IN const char *root_dir ) * TRUE - On Success * FALSE if request is not an alias ************************************************************************/ -static XINLINE xboolean +static UPNP_INLINE xboolean get_alias( IN const char *request_file, OUT struct xml_alias_t *alias, OUT struct File_Info *info ) diff --git a/upnp/src/genlib/util/membuffer.c b/upnp/src/genlib/util/membuffer.c index 2299c3e..bed1a61 100644 --- a/upnp/src/genlib/util/membuffer.c +++ b/upnp/src/genlib/util/membuffer.c @@ -171,7 +171,7 @@ memptr_cmp_nocase( IN memptr * m, * * Note : ************************************************************************/ -static XINLINE void +static UPNP_INLINE void membuffer_initialize( INOUT membuffer * m ) { m->buf = NULL; diff --git a/upnp/src/inc/httpparser.h b/upnp/src/inc/httpparser.h index 181b113..821862b 100644 --- a/upnp/src/inc/httpparser.h +++ b/upnp/src/inc/httpparser.h @@ -491,7 +491,7 @@ const char* method_to_str( IN http_method_t method ); #ifdef DEBUG void print_http_headers( IN http_message_t *hmsg ); #else -static inline void print_http_headers( IN http_message_t *hmsg ) {} +static UPNP_INLINE void print_http_headers( IN http_message_t *hmsg ) {} #endif #ifdef __cplusplus diff --git a/upnp/src/inc/service_table.h b/upnp/src/inc/service_table.h index a41ae57..f15ed89 100644 --- a/upnp/src/inc/service_table.h +++ b/upnp/src/inc/service_table.h @@ -269,7 +269,7 @@ void printService( Dbg_Level level, Dbg_Module module); #else -static inline void printService( +static UPNP_INLINE void printService( service_info *service, Dbg_Level level, Dbg_Module module) {} @@ -296,7 +296,7 @@ void printServiceList( Dbg_Level level, Dbg_Module module); #else -static inline void printServiceList( +static UPNP_INLINE void printServiceList( service_info *service, Dbg_Level level, Dbg_Module module) {} @@ -324,7 +324,7 @@ void printServiceTable( Dbg_Level level, Dbg_Module module); #else -static inline void printServiceTable( +static UPNP_INLINE void printServiceTable( service_table *table, Dbg_Level level, Dbg_Module module) {} diff --git a/upnp/src/inc/ssdplib.h b/upnp/src/inc/ssdplib.h index 34d2d17..f8c7271 100644 --- a/upnp/src/inc/ssdplib.h +++ b/upnp/src/inc/ssdplib.h @@ -184,12 +184,12 @@ typedef int (*ParserFun)(char *, Event *); //int AnalyzeCommand(char * szCommand, Event * Evt); /************************************************************************ -* Function : Make_Socket_NoBlocking -* -* Parameters: -* IN int sock: socket +* Function : Make_Socket_NoBlocking * -* Description: +* Parameters: +* IN int sock: socket +* +* Description: * This function to make ssdp socket non-blocking. * * Returns: int @@ -198,12 +198,12 @@ typedef int (*ParserFun)(char *, Event *); int Make_Socket_NoBlocking (int sock); /************************************************************************ -* Function : ssdp_handle_device_request -* -* Parameters: +* Function : ssdp_handle_device_request +* +* Parameters: * IN void *data: * -* Description: +* Description: * This function handles the search request. It do the sanity checks of * the request and then schedules a thread to send a random time reply ( * random within maximum time given by the control point to reply). @@ -222,18 +222,18 @@ static inline void ssdp_handle_device_request( #endif /************************************************************************ -* Function : ssdp_handle_ctrlpt_msg -* -* Parameters: +* Function : ssdp_handle_ctrlpt_msg +* +* Parameters: * IN http_message_t* hmsg: SSDP message from the device * IN struct sockaddr_in* dest_addr: Address of the device * IN xboolean timeout: timeout kept by the control point while sending -* search message +* search message * IN void* cookie: Cookie stored by the control point application. -* This cookie will be returned to the control point -* in the callback -* -* Description: +* This cookie will be returned to the control point +* in the callback +* +* Description: * This function handles the ssdp messages from the devices. These * messages includes the search replies, advertisement of device coming * alive and bye byes. @@ -241,20 +241,21 @@ static inline void ssdp_handle_device_request( * Returns: void * ***************************************************************************/ -void ssdp_handle_ctrlpt_msg( IN http_message_t* hmsg, - IN struct sockaddr_in* dest_addr, - IN xboolean timeout, - IN void* cookie ); +void ssdp_handle_ctrlpt_msg( + IN http_message_t* hmsg, + IN struct sockaddr_in* dest_addr, + IN xboolean timeout, + IN void* cookie ); /************************************************************************ -* Function : unique_service_name -* -* Parameters: -* IN char *cmd: Service Name string -* OUT SsdpEvent *Evt: The SSDP event structure partially filled -* by all the function. +* Function : unique_service_name * -* Description: +* Parameters: +* IN char *cmd: Service Name string +* OUT SsdpEvent *Evt: The SSDP event structure partially filled +* by all the function. +* +* Description: * This function fills the fields of the event structure like DeviceType, * Device UDN and Service Type * @@ -265,12 +266,12 @@ int unique_service_name(char * cmd, SsdpEvent * Evt); /************************************************************************ -* Function : get_ssdp_sockets -* -* Parameters: +* Function : get_ssdp_sockets +* +* Parameters: * OUT MiniServerSockArray *out: Arrays of SSDP sockets * -* Description: +* Description: * This function creates the ssdp sockets. It set their option to listen * for multicast traffic. * @@ -281,12 +282,12 @@ int get_ssdp_sockets(MiniServerSockArray *out); /************************************************************************ -* Function : readFromSSDPSocket -* -* Parameters: +* Function : readFromSSDPSocket +* +* Parameters: * IN SOCKET socket: SSDP socket * -* Description: +* Description: * This function reads the data from the ssdp socket. * * Returns: void @@ -296,13 +297,13 @@ void readFromSSDPSocket(SOCKET socket); /************************************************************************ -* Function : ssdp_request_type1 -* -* Parameters: +* Function : ssdp_request_type1 +* +* Parameters: * IN char *cmd: command came in the ssdp request * -* Description: -* This function figures out the type of the SSDP search in the +* Description: +* This function figures out the type of the SSDP search in the * in the request. * * Returns: enum SsdpSearchType @@ -312,14 +313,14 @@ enum SsdpSearchType ssdp_request_type1(IN char *cmd); /************************************************************************ -* Function : ssdp_request_type -* -* Parameters: +* Function : ssdp_request_type +* +* Parameters: * IN char *cmd: command came in the ssdp request * OUT SsdpEvent *Evt: The event structure partially filled by * this function. * -* Description: +* Description: * This function starts filling the SSDP event structure based upon the * request received. * @@ -330,17 +331,15 @@ int ssdp_request_type(IN char * cmd, OUT SsdpEvent * Evt); /************************************************************************ -* Function : SearchByTarget -* -* Parameters: -* IN int Mx:Number of seconds to wait, to collect all the -* responses. -* char *St: Search target. -* void *Cookie: cookie provided by control point application. This -* cokie will be returned to application in the -* callback. +* Function : SearchByTarget * -* Description: +* Parameters: +* IN int Mx:Number of seconds to wait, to collect all the responses. +* char *St: Search target. +* void *Cookie: cookie provided by control point application. This +* cokie will be returned to application in the callback. +* +* Description: * This function creates and send the search request for a specific URL. * * Returns: int @@ -349,214 +348,224 @@ int ssdp_request_type(IN char * cmd, OUT SsdpEvent * Evt); int SearchByTarget(IN int Mx, IN char *St, IN void *Cookie); /************************************************************************ -* Function : DeviceAdvertisement -* -* Parameters: -* IN char * DevType : type of the device -* IN int RootDev: flag to indicate if the device is root device -* IN char * nt : value of NT -* IN char * usn : -* IN char * location :Location URL. -* IN int duration :Service duration in sec. +* Function : DeviceAdvertisement * -* Description: -* This function creates the device advertisement request based on +* Parameters: +* IN char *DevType : type of the device +* IN int RootDev : flag to indicate if the device is root device +* IN char *Udn : +* IN char *Location: Location URL. +* IN int Duration : Service duration in sec. +* +* Description: +* This function creates the device advertisement request based on * the input parameter, and send it to the multicast channel. * * Returns: int * UPNP_E_SUCCESS if successful else appropriate error ***************************************************************************/ -int DeviceAdvertisement(IN char * DevType, int RootDev,char * Udn, - IN char * Location, IN int Duration); +int DeviceAdvertisement( + IN char *DevType, + IN int RootDev, + IN char *Udn, + IN char *Location, + IN int Duration); /************************************************************************ -* Function : DeviceShutdown -* +* Function : DeviceShutdown +* * Parameters: * IN char *DevType: Device Type. * IN int RootDev:1 means root device. -* IN char * Udn: Device UDN +* IN char *Udn: Device UDN * IN char *_Server: -* IN char * Location: Location URL -* IN int Duration :Device duration in sec. +* IN char *Location: Location URL +* IN int Duration :Device duration in sec. * -* Description: +* Description: * This function creates a HTTP device shutdown request packet * and sent it to the multicast channel through RequestHandler. * * Returns: int * UPNP_E_SUCCESS if successful else appropriate error ***************************************************************************/ -int DeviceShutdown( IN char * DevType, - IN int RootDev, - IN char * Udn, - IN char * _Server, - IN char * Location, - IN int Duration ); +int DeviceShutdown( + IN char *DevType, + IN int RootDev, + IN char *Udn, + IN char *_Server, + IN char *Location, + IN int Duration); /************************************************************************ -* Function : DeviceReply -* +* Function : DeviceReply +* * Parameters: * IN struct sockaddr_in * DestAddr:destination IP address. * IN char *DevType: Device type * IN int RootDev: 1 means root device 0 means embedded device. -* IN char * Udn: Device UDN -* IN char * Location: Location of Device description document. -* IN int Duration :Life time of this device. - -* Description: +* IN char *Udn: Device UDN +* IN char *Location: Location of Device description document. +* IN int Duration :Life time of this device. +* +* Description: * This function creates the reply packet based on the input parameter, * and send it to the client address given in its input parameter DestAddr. * * Returns: int * UPNP_E_SUCCESS if successful else appropriate error ***************************************************************************/ -int DeviceReply(IN struct sockaddr_in * DestAddr, - IN char *DevType, - IN int RootDev, - IN char * Udn, - IN char * Location, IN int Duration); +int DeviceReply( + IN struct sockaddr_in * DestAddr, + IN char *DevType, + IN int RootDev, + IN char *Udn, + IN char *Location, IN int Duration); /************************************************************************ -* Function : SendReply -* +* Function : SendReply +* * Parameters: * IN struct sockaddr_in * DestAddr:destination IP address. * IN char *DevType: Device type * IN int RootDev: 1 means root device 0 means embedded device. * IN char * Udn: Device UDN * IN char *_Server: -* IN char * Location: Location of Device description document. -* IN int Duration :Life time of this device. +* IN char *Location: Location of Device description document. +* IN int Duration :Life time of this device. * IN int ByType: * -* Description: +* Description: * This function creates the reply packet based on the input parameter, * and send it to the client addesss given in its input parameter DestAddr. * * Returns: int * UPNP_E_SUCCESS if successful else appropriate error ***************************************************************************/ -int SendReply(IN struct sockaddr_in * DestAddr, - IN char *DevType, - IN int RootDev, - IN char * Udn, - IN char * Location, - IN int Duration, - IN int ByType ); +int SendReply( + IN struct sockaddr_in * DestAddr, + IN char *DevType, + IN int RootDev, + IN char *Udn, + IN char *Location, + IN int Duration, + IN int ByType ); /************************************************************************ -* Function : ServiceAdvertisement -* +* Function : ServiceAdvertisement +* * Parameters: * IN char * Udn: Device UDN * IN char *ServType: Service Type. * IN char * Location: Location of Device description document. -* IN int Duration :Life time of this device. - -* Description: +* IN int Duration :Life time of this device. +* +* Description: * This function creates the advertisement packet based * on the input parameter, and send it to the multicast channel. - * * Returns: int * UPNP_E_SUCCESS if successful else appropriate error ***************************************************************************/ -int ServiceAdvertisement( IN char * Udn, - IN char * ServType, - IN char * Location, - IN int Duration); +int ServiceAdvertisement( + IN char *Udn, + IN char *ServType, + IN char *Location, + IN int Duration); /************************************************************************ -* Function : ServiceReply -* +* Function : ServiceReply +* * Parameters: * IN struct sockaddr_in *DestAddr: -* IN char * Udn: Device UDN +* IN char *Udn: Device UDN * IN char *ServType: Service Type. * IN char *Server: Not used -* IN char * Location: Location of Device description document. -* IN int Duration :Life time of this device. - -* Description: +* IN char *Location: Location of Device description document. +* IN int Duration :Life time of this device. +* +* Description: * This function creates the advertisement packet based * on the input parameter, and send it to the multicast channel. - * * Returns: int * UPNP_E_SUCCESS if successful else appropriate error ***************************************************************************/ -int ServiceReply(IN struct sockaddr_in *DestAddr, - IN char * ServType, - IN char * Udn, - IN char * Location, - IN int Duration); +int ServiceReply( + IN struct sockaddr_in *DestAddr, + IN char *ServType, + IN char *Udn, + IN char *Location, + IN int Duration); /************************************************************************ -* Function : ServiceShutdown -* -* Parameters: -* IN char * Udn: Device UDN +* Function : ServiceShutdown +* +* Parameters: +* IN char *Udn: Device UDN * IN char *ServType: Service Type. -* IN char * Location: Location of Device description document. -* IN int Duration :Service duration in sec. - -* Description: +* IN char *Location: Location of Device description document. +* IN int Duration :Service duration in sec. +* +* Description: * This function creates a HTTP service shutdown request packet * and sent it to the multicast channel through RequestHandler. * * Returns: int * UPNP_E_SUCCESS if successful else appropriate error ***************************************************************************/ -int ServiceShutdown( IN char * Udn, IN char * ServType, - IN char * Location, - IN int Duration); +int ServiceShutdown( + IN char *Udn, + IN char *ServType, + IN char *Location, + IN int Duration); /************************************************************************ -* Function : advertiseAndReplyThread -* -* Parameters: -* IN void *data: Structure containing the search request +* Function : advertiseAndReplyThread * -* Description: +* Parameters: +* IN void *data: Structure containing the search request +* +* Description: * This function is a wrapper function to reply the search request * coming from the control point. * * Returns: void * * always return NULL ***************************************************************************/ -void * advertiseAndReplyThread(IN void * data); +void *advertiseAndReplyThread(IN void * data); /************************************************************************ -* Function : AdvertiseAndReply -* -* Parameters: -* IN int AdFlag: -1 = Send shutdown, 0 = send reply, -* 1 = Send Advertisement +* Function : AdvertiseAndReply +* +* Parameters: +* IN int AdFlag: -1 = Send shutdown, +* 0 = send reply, +* 1 = Send Advertisement * IN UpnpDevice_Handle Hnd: Device handle * IN enum SsdpSearchType SearchType:Search type for sending replies * IN struct sockaddr_in *DestAddr:Destination address -* IN char *DeviceType:Device type +* IN char *DeviceType:Device type * IN char *DeviceUDN:Device UDN -* IN char *ServiceType:Service type +* IN char *ServiceType:Service type * IN int Exp:Advertisement age * -* Description: +* Description: * This function to send SSDP advertisements, replies and shutdown messages. * * Returns: int * UPNP_E_SUCCESS if successful else appropriate error ***************************************************************************/ -int AdvertiseAndReply(IN int AdFlag, - IN UpnpDevice_Handle Hnd, - IN enum SsdpSearchType SearchType, - IN struct sockaddr_in *DestAddr, - IN char *DeviceType, - IN char *DeviceUDN, - IN char *ServiceType, int Exp); +int AdvertiseAndReply( + IN int AdFlag, + IN UpnpDevice_Handle Hnd, + IN enum SsdpSearchType SearchType, + IN struct sockaddr_in *DestAddr, + IN char *DeviceType, + IN char *DeviceUDN, + IN char *ServiceType, int Exp); #endif diff --git a/upnp/src/inc/unixutil.h b/upnp/src/inc/unixutil.h index 0f9624f..6b2566c 100644 --- a/upnp/src/inc/unixutil.h +++ b/upnp/src/inc/unixutil.h @@ -36,12 +36,11 @@ #include #ifndef WIN32 - #include + #include #else - #define XINLINE - - typedef int socklen_t; - #define EAFNOSUPPORT 97 + typedef int socklen_t; + #define EAFNOSUPPORT 97 #endif #endif // GENLIB_NET_UNIXUTIL_H + diff --git a/upnp/src/inc/uri.h b/upnp/src/inc/uri.h index 2b2b1ca..1c3847c 100644 --- a/upnp/src/inc/uri.h +++ b/upnp/src/inc/uri.h @@ -190,7 +190,7 @@ void free_URL_list(URL_list * list); #ifdef DEBUG void print_uri(uri_type *in); #else -static inline void print_uri(uri_type *in) {} +static UPNP_INLINE void print_uri(uri_type *in) {} #endif /************************************************************************ @@ -208,7 +208,7 @@ static inline void print_uri(uri_type *in) {} #ifdef DEBUG void print_token(token *in); #else -static inline void print_token(token * in) {} +static UPNP_INLINE void print_token(token * in) {} #endif /************************************************************************ diff --git a/upnp/src/inc/util.h b/upnp/src/inc/util.h index e785311..3982d5d 100644 --- a/upnp/src/inc/util.h +++ b/upnp/src/inc/util.h @@ -136,31 +136,28 @@ void linecopylen( OUT char dest[LINE_SIZE], IN const char* src, IN size_t srclen #endif ////////////////////////////////// - // C specific #ifndef __cplusplus -#ifndef WIN32 - #define XINLINE inline -#else +#ifdef WIN32 + #ifndef S_ISREG + #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) + #endif - #ifndef S_ISREG - #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) - #endif - - #ifndef S_ISDIR - #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) - #endif + #ifndef S_ISDIR + #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) + #endif - #define EADDRINUSE WSAEADDRINUSE + #define EADDRINUSE WSAEADDRINUSE - #define strcasecmp stricmp - #define strncasecmp strnicmp + #define strcasecmp stricmp + #define strncasecmp strnicmp - #define sleep(a) Sleep((a)*1000) - #define usleep(a) Sleep((a)/1000) + #define sleep(a) Sleep((a)*1000) + #define usleep(a) Sleep((a)/1000) #endif #endif // __cplusplus #endif /* GENLIB_UTIL_UTIL_H */ + diff --git a/upnp/src/soap/soap_ctrlpt.c b/upnp/src/soap/soap_ctrlpt.c index fb41a36..43970be 100644 --- a/upnp/src/soap/soap_ctrlpt.c +++ b/upnp/src/soap/soap_ctrlpt.c @@ -244,7 +244,7 @@ get_node_value( IN IXML_Node * node ) * * Note : ****************************************************************************/ -static XINLINE int +static UPNP_INLINE int get_host_and_path( IN char *ctrl_url, OUT const memptr *host, OUT const memptr *path, @@ -277,7 +277,7 @@ get_host_and_path( IN char *ctrl_url, * * Note : ****************************************************************************/ -static XINLINE int +static UPNP_INLINE int get_action_name( IN char *action, OUT memptr * name ) { @@ -303,7 +303,7 @@ get_action_name( IN char *action, * * Note : ****************************************************************************/ -static XINLINE int +static UPNP_INLINE int add_man_header( INOUT membuffer * headers ) { char *soap_action_hdr; diff --git a/upnp/src/soap/soap_device.c b/upnp/src/soap/soap_device.c index 0b89c7e..98a02f7 100644 --- a/upnp/src/soap/soap_device.c +++ b/upnp/src/soap/soap_device.c @@ -85,7 +85,7 @@ const char *ContentTypeHeader = * 0 if successful else returns appropriate error. * Note : ****************************************************************************/ -static XINLINE int +static UPNP_INLINE int get_request_type( IN http_message_t * request, OUT memptr * action_name ) { @@ -262,7 +262,7 @@ send_error_response( IN SOCKINFO * info, * * Note : ****************************************************************************/ -static XINLINE void +static UPNP_INLINE void send_var_query_response( IN SOCKINFO * info, IN const char *var_value, IN http_message_t * hmsg ) @@ -326,12 +326,12 @@ send_var_query_response( IN SOCKINFO * info, * Description : This function separates the action node from * the root DOM node. * -* Return : static XINLINE int +* Return : static UPNP_INLINE int * 0 if successful, or -1 if fails. * * Note : ****************************************************************************/ -static XINLINE int +static UPNP_INLINE int get_action_node( IN IXML_Document * TempDoc, IN char *NodeName, OUT IXML_Document ** RespNode ) @@ -681,7 +681,7 @@ get_device_info( IN http_message_t * request, * * Note : ****************************************************************************/ -static XINLINE void +static UPNP_INLINE void send_action_response( IN SOCKINFO * info, IN IXML_Document * action_resp, IN http_message_t * request ) @@ -769,7 +769,7 @@ error_handler: * returns 0 if successful else returns -1. * Note : ****************************************************************************/ -static XINLINE int +static UPNP_INLINE int get_var_name( IN IXML_Document * TempDoc, OUT char *VarName ) { @@ -840,7 +840,7 @@ error_handler: * * Note : ****************************************************************************/ -static XINLINE void +static UPNP_INLINE void handle_query_variable( IN SOCKINFO * info, IN http_message_t * request, IN IXML_Document * xml_doc ) diff --git a/upnp/src/ssdp/ssdp_ctrlpt.c b/upnp/src/ssdp/ssdp_ctrlpt.c index ff63e63..fbeebd0 100644 --- a/upnp/src/ssdp/ssdp_ctrlpt.c +++ b/upnp/src/ssdp/ssdp_ctrlpt.c @@ -55,12 +55,12 @@ /************************************************************************ -* Function : send_search_result -* -* Parameters: +* Function : send_search_result +* +* Parameters: * IN void *data: Search reply from the device -* -* Description: +* +* Description: * This function sends a callback to the control point application with * a SEARCH result * @@ -125,16 +125,16 @@ ssdp_handle_ctrlpt_msg( IN http_message_t * hmsg, // we are assuming that there can be only one client supported at a time - HandleLock( ); + HandleLock(); if( GetClientHandleInfo( &handle, &ctrlpt_info ) != HND_CLIENT ) { - HandleUnlock( ); + HandleUnlock(); return; } // copy ctrlpt_callback = ctrlpt_info->Callback; ctrlpt_cookie = ctrlpt_info->Cookie; - HandleUnlock( ); + HandleUnlock(); // search timeout if( timeout ) { @@ -268,9 +268,9 @@ ssdp_handle_ctrlpt_msg( IN http_message_t * hmsg, return; // bad reply } //check each current search - HandleLock( ); + HandleLock(); if( GetClientHandleInfo( &handle, &ctrlpt_info ) != HND_CLIENT ) { - HandleUnlock( ); + HandleUnlock(); return; } node = ListHead( &ctrlpt_info->SsdpSearchList ); @@ -344,28 +344,30 @@ ssdp_handle_ctrlpt_msg( IN http_message_t * hmsg, node = ListNext( &ctrlpt_info->SsdpSearchList, node ); } - HandleUnlock( ); + HandleUnlock(); //ctrlpt_callback( UPNP_DISCOVERY_SEARCH_RESULT, ¶m, cookie ); } } /************************************************************************ -* Function : process_reply -* -* Parameters: -* IN char* request_buf: the response came from the device -* IN int buf_len: The length of the response buffer -* IN struct sockaddr_in* dest_addr: The address of the device -* IN void *cookie : cookie passed by the control point application -* at the time of sending search message +* Function : process_reply * -* Description: +* Parameters: +* IN char* request_buf: the response came from the device +* IN int buf_len: The length of the response buffer +* IN struct sockaddr_in* dest_addr: The address of the device +* IN void *cookie : cookie passed by the control point application +* at the time of sending search message +* +* Description: * This function processes reply recevied from a search * * Returns: void * ***************************************************************************/ -static XINLINE void +#warning There are currently no uses of the function 'process_reply()' in the code. +#warning 'process_reply()' is a good candidate for removal. +static UPNP_INLINE void process_reply( IN char *request_buf, IN int buf_len, IN struct sockaddr_in *dest_addr, @@ -388,17 +390,17 @@ process_reply( IN char *request_buf, } /************************************************************************ -* Function : CreateClientRequestPacket -* -* Parameters: -* IN char * RqstBuf:Output string in HTTP format. -* IN char *SearchTarget:Search Target -* IN int Mx dest_addr: Number of seconds to wait to -* collect all the responses +* Function : CreateClientRequestPacket * -* Description: +* Parameters: +* IN char * RqstBuf:Output string in HTTP format. +* IN char *SearchTarget:Search Target +* IN int Mx dest_addr: Number of seconds to wait to +* collect all the responses +* +* Description: * This function creates a HTTP search request packet -* depending on the input parameter. +* depending on the input parameter. * * Returns: void * @@ -430,12 +432,12 @@ CreateClientRequestPacket( IN char *RqstBuf, } /************************************************************************ -* Function : searchExpired -* -* Parameters: +* Function : searchExpired +* +* Parameters: * IN void * arg: * -* Description: +* Description: * This function * * Returns: void @@ -456,13 +458,13 @@ searchExpired( void *arg ) void *cookie = NULL; int found = 0; - HandleLock( ); + HandleLock(); //remove search target from search list if( GetClientHandleInfo( &handle, &ctrlpt_info ) != HND_CLIENT ) { free( id ); - HandleUnlock( ); + HandleUnlock(); return; } @@ -483,7 +485,7 @@ searchExpired( void *arg ) } node = ListNext( &ctrlpt_info->SsdpSearchList, node ); } - HandleUnlock( ); + HandleUnlock(); if( found ) { ctrlpt_callback( UPNP_DISCOVERY_SEARCH_TIMEOUT, NULL, cookie ); @@ -558,9 +560,9 @@ SearchByTarget( IN int Mx, FD_SET( gSsdpReqSocket, &wrSet ); //add search criteria to list - HandleLock( ); + HandleLock(); if( GetClientHandleInfo( &handle, &ctrlpt_info ) != HND_CLIENT ) { - HandleUnlock( ); + HandleUnlock(); free( ReqBuf ); return UPNP_E_INTERNAL_ERROR; } @@ -581,7 +583,7 @@ SearchByTarget( IN int Mx, newArg->timeoutEventId = ( *id ); ListAddTail( &ctrlpt_info->SsdpSearchList, newArg ); - HandleUnlock( ); + HandleUnlock(); setsockopt( gSsdpReqSocket, IPPROTO_IP, IP_MULTICAST_IF, ( char * )&addr, sizeof( addr ) ); diff --git a/upnp/src/ssdp/ssdp_server.c b/upnp/src/ssdp/ssdp_server.c index 5851fc4..aaf07d7 100644 --- a/upnp/src/ssdp/ssdp_server.c +++ b/upnp/src/ssdp/ssdp_server.c @@ -641,7 +641,7 @@ free_ssdp_event_handler_data( void *the_data ) * Returns: xboolean * returns TRUE if msg is valid else FALSE ***************************************************************************/ -static XINLINE xboolean +static UPNP_INLINE xboolean valid_ssdp_msg( IN http_message_t * hmsg ) { memptr hdr_value; @@ -683,7 +683,7 @@ valid_ssdp_msg( IN http_message_t * hmsg ) * Returns: int * 0 if successful -1 if error ***************************************************************************/ -static XINLINE int +static UPNP_INLINE int start_event_handler( void *Data ) { diff --git a/upnp/src/urlconfig/urlconfig.c b/upnp/src/urlconfig/urlconfig.c index ec6de8b..7da2fa3 100644 --- a/upnp/src/urlconfig/urlconfig.c +++ b/upnp/src/urlconfig/urlconfig.c @@ -62,7 +62,7 @@ * * Note : ************************************************************************/ -static XINLINE void +static UPNP_INLINE void addrToString( IN const struct sockaddr_in *addr, OUT char ipaddr_port[] ) { @@ -87,7 +87,7 @@ addrToString( IN const struct sockaddr_in *addr, * * Note : 'newAlias' should be freed using free() ************************************************************************/ -static XINLINE int +static UPNP_INLINE int calc_alias( IN const char *alias, IN const char *rootPath, OUT char **newAlias ) @@ -148,7 +148,7 @@ calc_alias( IN const char *alias, * * Note : ************************************************************************/ -static XINLINE int +static UPNP_INLINE int calc_descURL( IN const char *ipPortStr, IN const char *alias, OUT char descURL[LINE_SIZE] )