From ab276158552f8bc6f30f99001c7cdd266aad9a47 Mon Sep 17 00:00:00 2001 From: Marcelo Roberto Jimenez Date: Tue, 16 Nov 2010 03:14:12 -0200 Subject: [PATCH] Removes C++ style comments. --- upnp/inc/upnpdebug.h | 109 ++-- upnp/sample/common/sample_util.h | 4 +- .../sample/tvcombo/linux/upnp_tv_combo_main.c | 10 +- upnp/sample/tvcombo/upnp_tv_ctrlpt.c | 18 +- upnp/sample/tvcombo/upnp_tv_ctrlpt.h | 3 +- upnp/sample/tvcombo/upnp_tv_device.c | 52 +- upnp/sample/tvcombo/upnp_tv_device.h | 50 +- .../tvctrlpt/linux/upnp_tv_ctrlpt_main.c | 8 +- upnp/sample/tvctrlpt/upnp_tv_ctrlpt.c | 18 +- .../tvdevice/linux/upnp_tv_device_main.c | 4 +- upnp/sample/tvdevice/upnp_tv_device.c | 52 +- upnp/sample/tvdevice/upnp_tv_device.h | 50 +- upnp/src/api/UpnpString.c | 8 +- upnp/src/api/upnpapi.c | 117 ++--- upnp/src/api/upnptools.c | 4 +- upnp/src/gena/gena_callback2.c | 74 +-- upnp/src/gena/gena_ctrlpt.c | 108 ++-- upnp/src/gena/gena_device.c | 98 ++-- upnp/src/genlib/client_table/client_table.c | 6 +- upnp/src/genlib/net/http/httpparser.c | 487 +++++++++--------- upnp/src/genlib/net/http/httpreadwrite.c | 256 ++++----- upnp/src/genlib/net/http/parsetools.c | 103 ++-- upnp/src/genlib/net/http/statcodes.c | 64 +-- upnp/src/genlib/net/http/webserver.c | 232 ++++----- upnp/src/genlib/net/uri/uri.c | 46 +- upnp/src/genlib/service_table/service_table.c | 15 +- upnp/src/genlib/util/membuffer.c | 62 +-- upnp/src/genlib/util/strintmap.c | 74 +-- upnp/src/genlib/util/util.c | 91 +--- upnp/src/inc/global.h | 3 - upnp/src/inc/httpparser.h | 266 +++++----- upnp/src/inc/httpreadwrite.h | 72 ++- upnp/src/inc/membuffer.h | 109 ++-- upnp/src/inc/parsetools.h | 92 ++-- upnp/src/inc/service_table.h | 58 +-- upnp/src/inc/ssdplib.h | 15 +- upnp/src/inc/statcodes.h | 69 ++- upnp/src/inc/strintmap.h | 73 +-- upnp/src/inc/upnputil.h | 207 ++++---- upnp/src/inc/uri.h | 56 +- upnp/src/inc/webserver.h | 4 +- upnp/src/soap/soap_ctrlpt.c | 163 +++--- upnp/src/soap/soap_device.c | 178 +++---- upnp/src/ssdp/ssdp_ctrlpt.c | 105 ++-- upnp/src/ssdp/ssdp_device.c | 118 ++--- upnp/src/ssdp/ssdp_server.c | 67 +-- upnp/src/urlconfig/urlconfig.c | 32 +- upnp/src/uuid/sysdep.c | 43 +- 48 files changed, 1883 insertions(+), 2070 deletions(-) diff --git a/upnp/inc/upnpdebug.h b/upnp/inc/upnpdebug.h index a7c0674..de04d19 100644 --- a/upnp/inc/upnpdebug.h +++ b/upnp/inc/upnpdebug.h @@ -1,31 +1,31 @@ /******************************************************************************* * - * Copyright (c) 2000-2003 Intel Corporation - * Copyright (c) 2006 Rémi Turboult - * All rights reserved. + * Copyright (c) 2000-2003 Intel Corporation + * Copyright (c) 2006 Rémi Turboult + * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither name of Intel Corporation nor the names of its contributors - * may be used to endorse or promote products derived from this software + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * - Neither name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ******************************************************************************/ @@ -33,32 +33,27 @@ #ifndef UPNP_DEBUG_H #define UPNP_DEBUG_H - /*! * \file */ - #include "ThreadPool.h" #include "upnpconfig.h" #include "UpnpGlobal.h" /* for UPNP_INLINE */ - #include - #ifdef __cplusplus extern "C" { #endif - -/** \name Other debugging features +/*! \name Other debugging features * * The UPnP SDK contains other features to aid in debugging. */ /*@{*/ -/** \name Upnp_LogLevel +/*! \name Upnp_LogLevel * The user has the option to select 4 different types of debugging levels, * see \c UpnpSetLogLevel. * The critical level will show only those messages @@ -85,7 +80,6 @@ typedef enum Upnp_Module { HTTP } Dbg_Module; - /*@{*/ typedef enum Upnp_LogLevel_e { UPNP_CRITICAL, @@ -95,14 +89,11 @@ typedef enum Upnp_LogLevel_e { } Upnp_LogLevel; /*@}*/ - -/** +/*! * Default log level : see \c Upnp_LogLevel */ #define UPNP_DEFAULT_LOG_LEVEL UPNP_ALL - - /*! * \brief Initialize the log files. * @@ -117,7 +108,6 @@ static UPNP_INLINE int UpnpInitLog(void) } #endif - /*! * \brief Set the log level (see \c Upnp_LogLevel). */ @@ -126,10 +116,13 @@ void UpnpSetLogLevel( /*! [in] Log level. */ Upnp_LogLevel log_level); #else -static UPNP_INLINE void UpnpSetLogLevel(Upnp_LogLevel log_level) {} +static UPNP_INLINE void UpnpSetLogLevel(Upnp_LogLevel log_level) +{ + return; + log_level = log_level; +} #endif - /*! * \brief Closes the log files. */ @@ -139,7 +132,6 @@ void UpnpCloseLog(void); static UPNP_INLINE void UpnpCloseLog(void) {} #endif - /*! * \brief Set the name for error and information files, respectively. */ @@ -152,10 +144,14 @@ void UpnpSetLogFileNames( #else static UPNP_INLINE void UpnpSetLogFileNames( const char *ErrFileName, - const char *InfoFileName) {} + const char *InfoFileName) +{ + return; + ErrFileName = ErrFileName; + InfoFileName = InfoFileName; +} #endif - /*! * \brief Check if the module is turned on for debug and returns the file * descriptor corresponding to the debug level @@ -174,6 +170,8 @@ FILE *UpnpGetDebugFile( static UPNP_INLINE FILE *UpnpGetDebugFile(Upnp_LogLevel level, Dbg_Module module) { return NULL; + level = level; + module = module; } #endif @@ -196,6 +194,8 @@ static UPNP_INLINE int DebugAtThisLevel( Dbg_Module Module) { return 0; + DLevel = DLevel; + Module = Module; } #endif @@ -234,6 +234,12 @@ static UPNP_INLINE void UpnpPrintf( const char* FmtStr, ...) { + return; + DLevel = DLevel; + Module = Module; + DbgFileName = DbgFileName; + DbgLineNo = DbgLineNo; + FmtStr = FmtStr; } #endif /* DEBUG */ @@ -254,7 +260,13 @@ void UpnpDisplayFileAndLine( static UPNP_INLINE void UpnpDisplayFileAndLine( FILE *fd, const char *DbgFileName, - int DbgLineNo) {} + int DbgLineNo) +{ + return; + fd = fd; + DbgFileName = DbgFileName; + DbgLineNo = DbgLineNo; +} #endif @@ -276,7 +288,14 @@ static UPNP_INLINE void UpnpDisplayBanner( FILE *fd, const char **lines, size_t size, - int starlength) {} + int starlength) +{ + return; + fd = fd; + lines = lines; + size = size; + starlength = starlength; +} #endif @@ -300,10 +319,14 @@ static UPNP_INLINE void PrintThreadPoolStats( int DbgLineNo, const char *msg) { + return; + tp = tp; + DbgFileName = DbgFileName; + DbgLineNo = DbgLineNo; + msg = msg; } #endif - /*@}*/ #ifdef __cplusplus diff --git a/upnp/sample/common/sample_util.h b/upnp/sample/common/sample_util.h index 649b50c..836a93e 100644 --- a/upnp/sample/common/sample_util.h +++ b/upnp/sample/common/sample_util.h @@ -191,7 +191,7 @@ int SampleUtil_FindAndParseService ( ********************************************************************************/ typedef void (*print_string)(const char *string); -//global print function used by sample util +/*global print function used by sample util */ extern print_string gPrintFun; /******************************************************************************** @@ -212,7 +212,7 @@ typedef void (*state_update)( const char *UDN, eventType type); -//global state update function used by smaple util +/*global state update function used by smaple util */ extern state_update gStateUpdateFun; /******************************************************************************** diff --git a/upnp/sample/tvcombo/linux/upnp_tv_combo_main.c b/upnp/sample/tvcombo/linux/upnp_tv_combo_main.c index 59e6efc..4aadb10 100644 --- a/upnp/sample/tvcombo/linux/upnp_tv_combo_main.c +++ b/upnp/sample/tvcombo/linux/upnp_tv_combo_main.c @@ -52,10 +52,10 @@ enum cmdloop_tvcmds { Data structure for parsing commands from the command line */ struct cmdloop_commands { - char *str; // the string - int cmdnum; // the command - int numargs; // the number of arguments - char *args; // the args + char *str; /* the string */ + int cmdnum; /* the command */ + int numargs; /* the number of arguments */ + char *args; /* the args */ } cmdloop_commands; /* @@ -417,7 +417,7 @@ device_main( int argc, char **argv ) SampleUtil_Initialize( linux_print ); - // Parse options + /* Parse options */ for( i = 1; i < argc; i++ ) { if( strcmp( argv[i], "-ip" ) == 0 ) { ip_address = argv[++i]; diff --git a/upnp/sample/tvcombo/upnp_tv_ctrlpt.c b/upnp/sample/tvcombo/upnp_tv_ctrlpt.c index 4b3f168..444afe3 100644 --- a/upnp/sample/tvcombo/upnp_tv_ctrlpt.c +++ b/upnp/sample/tvcombo/upnp_tv_ctrlpt.c @@ -125,7 +125,7 @@ TvCtrlPointDeleteNode( struct TvDeviceNode *node ) } } - //Notify New Device Added + /*Notify New Device Added */ SampleUtil_StateUpdate( NULL, NULL, node->device.UDN, DEVICE_REMOVED ); free( node ); node = NULL; @@ -374,7 +374,7 @@ TvCtrlPointSendAction( int service, param_val[param] ) != UPNP_E_SUCCESS ) { SampleUtil_Print ( "ERROR: TvCtrlPointSendAction: Trying to add action param" ); - //return -1; // TBD - BAD! leaves mutex locked + /*return -1; // TBD - BAD! leaves mutex locked */ } } } @@ -716,7 +716,7 @@ TvCtrlPointAddDevice( IXML_Document *DescDoc, if( strcmp( deviceType, TvDeviceType ) == 0 ) { SampleUtil_Print( "Found Tv device" ); - // Check if this device is already in the list + /* Check if this device is already in the list */ tmpdevnode = GlobalDeviceList; while( tmpdevnode ) { if( strcmp( tmpdevnode->device.UDN, UDN ) == 0 ) { @@ -727,8 +727,8 @@ TvCtrlPointAddDevice( IXML_Document *DescDoc, } if( found ) { - // The device is already there, so just update - // the advertisement timeout field + /* The device is already there, so just update */ + /* the advertisement timeout field */ tmpdevnode->device.AdvrTimeOut = expires; } else { for( service = 0; service < TV_SERVICE_SERVCOUNT; service++ ) { @@ -794,7 +794,7 @@ TvCtrlPointAddDevice( IXML_Document *DescDoc, deviceNode->next = NULL; - // Insert the new device node in the list + /* Insert the new device node in the list */ if( ( tmpdevnode = GlobalDeviceList ) ) { while( tmpdevnode ) { @@ -809,7 +809,7 @@ TvCtrlPointAddDevice( IXML_Document *DescDoc, GlobalDeviceList = deviceNode; } - //Notify New Device Added + /*Notify New Device Added */ SampleUtil_StateUpdate( NULL, NULL, deviceNode->device.UDN, DEVICE_ADDED ); } @@ -1225,7 +1225,7 @@ TvCtrlPointVerifyTimeouts( int incr ) while( curdevnode ) { curdevnode->device.AdvrTimeOut -= incr; - //SampleUtil_Print("Advertisement Timeout: %d\n", curdevnode->device.AdvrTimeOut); + /*SampleUtil_Print("Advertisement Timeout: %d\n", curdevnode->device.AdvrTimeOut); */ if( curdevnode->device.AdvrTimeOut <= 0 ) { /* @@ -1281,7 +1281,7 @@ TvCtrlPointVerifyTimeouts( int incr ) static int TvCtrlPointTimerLoopRun = 1; void *TvCtrlPointTimerLoop(void *args) { - int incr = 30; // how often to verify the timeouts, in seconds + int incr = 30; /* how often to verify the timeouts, in seconds */ while (TvCtrlPointTimerLoopRun) { isleep( incr ); diff --git a/upnp/sample/tvcombo/upnp_tv_ctrlpt.h b/upnp/sample/tvcombo/upnp_tv_ctrlpt.h index eeef79a..3345a7a 100644 --- a/upnp/sample/tvcombo/upnp_tv_ctrlpt.h +++ b/upnp/sample/tvcombo/upnp_tv_ctrlpt.h @@ -168,4 +168,5 @@ int TvCtrlPointProcessCommand(char *cmdline); }; #endif -#endif //UPNP_TV_CTRLPT_H +#endif /*UPNP_TV_CTRLPT_H */ + diff --git a/upnp/sample/tvcombo/upnp_tv_device.c b/upnp/sample/tvcombo/upnp_tv_device.c index 578370f..be19f29 100644 --- a/upnp/sample/tvcombo/upnp_tv_device.c +++ b/upnp/sample/tvcombo/upnp_tv_device.c @@ -92,31 +92,31 @@ UpnpDevice_Handle device_handle = -1; */ ithread_mutex_t TVDevMutex; -//Color constants +/*Color constants */ #define MAX_COLOR 10 #define MIN_COLOR 1 -//Brightness constants +/*Brightness constants */ #define MAX_BRIGHTNESS 10 #define MIN_BRIGHTNESS 1 -//Power constants +/*Power constants */ #define POWER_ON 1 #define POWER_OFF 0 -//Tint constants +/*Tint constants */ #define MAX_TINT 10 #define MIN_TINT 1 -//Volume constants +/*Volume constants */ #define MAX_VOLUME 10 #define MIN_VOLUME 1 -//Contrast constants +/*Contrast constants */ #define MAX_CONTRAST 10 #define MIN_CONTRAST 1 -//Channel constants +/*Channel constants */ #define MAX_CHANNEL 100 #define MIN_CHANNEL 1 @@ -287,7 +287,7 @@ TvDeviceStateTableInit( IN char *DescDocURL ) *ctrlurl_pict = NULL; char *udn = NULL; - //Download description document + /*Download description document */ if( UpnpDownloadXmlDoc( DescDocURL, &DescDoc ) != UPNP_E_SUCCESS ) { SampleUtil_Print( "TvDeviceStateTableInit -- Error Parsing %s\n", DescDocURL ); @@ -312,7 +312,7 @@ TvDeviceStateTableInit( IN char *DescDocURL ) goto error_handler; } - //set control service table + /*set control service table */ SetServiceTable( TV_SERVICE_CONTROL, udn, servid_ctrl, TvServiceType[TV_SERVICE_CONTROL], &tv_service_table[TV_SERVICE_CONTROL] ); @@ -331,14 +331,14 @@ TvDeviceStateTableInit( IN char *DescDocURL ) ret = UPNP_E_INVALID_DESC; goto error_handler; } - //set picture service table + /*set picture service table */ SetServiceTable( TV_SERVICE_PICTURE, udn, servid_pict, TvServiceType[TV_SERVICE_PICTURE], &tv_service_table[TV_SERVICE_PICTURE] ); error_handler: - //clean up + /*clean up */ if( udn ) free( udn ); if( servid_ctrl ) @@ -380,7 +380,7 @@ int TvDeviceHandleSubscriptionRequest(IN const UpnpSubscriptionRequest *sr_event const char *l_udn = NULL; const char *l_sid = NULL; - // lock state mutex + /* lock state mutex */ ithread_mutex_lock(&TVDevMutex); l_serviceId = UpnpString_get_String(UpnpSubscriptionRequest_get_ServiceId(sr_event)); @@ -394,22 +394,22 @@ int TvDeviceHandleSubscriptionRequest(IN const UpnpSubscriptionRequest *sr_event PropSet = NULL; for (j = 0; j< tv_service_table[i].VariableCount; ++j) { - // add each variable to the property set - // for initial state dump + /* add each variable to the property set */ + /* for initial state dump */ UpnpAddToPropertySet( &PropSet, tv_service_table[i].VariableName[j], tv_service_table[i].VariableStrVal[j]); } - // dump initial state + /* dump initial state */ UpnpAcceptSubscriptionExt( device_handle, l_udn, l_serviceId, PropSet, l_sid); - // free document + /* free document */ Document_free(PropSet); #endif UpnpAcceptSubscription( @@ -454,14 +454,14 @@ int TvDeviceHandleGetVarRequest(INOUT UpnpStateVarRequest *cgv_event) ithread_mutex_lock(&TVDevMutex); for (i = 0; i < TV_SERVICE_SERVCOUNT; i++) { - // check udn and service id + /* check udn and service id */ const char *devUDN = UpnpString_get_String(UpnpStateVarRequest_get_DevUDN(cgv_event)); const char *serviceID = UpnpString_get_String(UpnpStateVarRequest_get_ServiceID(cgv_event)); if (strcmp(devUDN, tv_service_table[i].UDN) == 0 && strcmp(serviceID, tv_service_table[i].ServiceId) == 0) { - // check variable name + /* check variable name */ for (j = 0; j < tv_service_table[i].VariableCount; j++) { const char *stateVarName = UpnpString_get_String( UpnpStateVarRequest_get_StateVarName(cgv_event)); @@ -563,7 +563,7 @@ int TvDeviceHandleActionRequest(INOUT UpnpActionRequest *ca_event) if (retCode == UPNP_E_SUCCESS) { UpnpActionRequest_set_ErrCode(ca_event, UPNP_E_SUCCESS); } else { - // copy the error string + /* copy the error string */ UpnpActionRequest_strcpy_ErrStr(ca_event, errorString); switch (retCode) { case UPNP_E_INVALID_PARAM: @@ -603,7 +603,7 @@ TvDeviceSetServiceTableVar( IN unsigned int service, IN unsigned int variable, IN char *value ) { - //IXML_Document *PropSet= NULL; + /*IXML_Document *PropSet= NULL; */ if( ( service >= TV_SERVICE_SERVCOUNT ) || ( variable >= tv_service_table[service].VariableCount ) @@ -615,8 +615,8 @@ TvDeviceSetServiceTableVar( IN unsigned int service, strcpy( tv_service_table[service].VariableStrVal[variable], value ); - /* - //Using utility api +#if 0 + /*Using utility api */ PropSet= UpnpCreatePropertySet(1,tv_service_table[service]. VariableName[variable], tv_service_table[service]. @@ -625,9 +625,9 @@ TvDeviceSetServiceTableVar( IN unsigned int service, UpnpNotifyExt(device_handle, tv_service_table[service].UDN, tv_service_table[service].ServiceId,PropSet); - //Free created property set + /*Free created property set */ Document_free(PropSet); - */ +#endif UpnpNotify( device_handle, tv_service_table[service].UDN, @@ -696,7 +696,7 @@ TvDevicePowerOn( IN IXML_Document *in, OUT IXML_Document **out, OUT char **error ( *errorString ) = NULL; if( TvDeviceSetPower( POWER_ON ) ) { - //create a response + /*create a response */ if( UpnpAddToActionResponse( out, "PowerOn", TvServiceType[TV_SERVICE_CONTROL], @@ -733,7 +733,7 @@ TvDevicePowerOff( IN IXML_Document * in, ( *out ) = NULL; ( *errorString ) = NULL; if( TvDeviceSetPower( POWER_OFF ) ) { - //create a response + /*create a response */ if( UpnpAddToActionResponse( out, "PowerOff", TvServiceType[TV_SERVICE_CONTROL], diff --git a/upnp/sample/tvcombo/upnp_tv_device.h b/upnp/sample/tvcombo/upnp_tv_device.h index 855d984..9eb1130 100644 --- a/upnp/sample/tvcombo/upnp_tv_device.h +++ b/upnp/sample/tvcombo/upnp_tv_device.h @@ -61,74 +61,74 @@ extern "C" { #endif -//Color constants +/*Color constants */ #define MAX_COLOR 10 #define MIN_COLOR 1 -//Brightness constants +/*Brightness constants */ #define MAX_BRIGHTNESS 10 #define MIN_BRIGHTNESS 1 -//Power constants +/*Power constants */ #define POWER_ON 1 #define POWER_OFF 0 -//Tint constants +/*Tint constants */ #define MAX_TINT 10 #define MIN_TINT 1 -//Volume constants +/*Volume constants */ #define MAX_VOLUME 10 #define MIN_VOLUME 1 -//Contrast constants +/*Contrast constants */ #define MAX_CONTRAST 10 #define MIN_CONTRAST 1 -//Channel constants +/*Channel constants */ #define MAX_CHANNEL 100 #define MIN_CHANNEL 1 -//Number of services. +/*Number of services. */ #define TV_SERVICE_SERVCOUNT 2 -//Index of control service +/*Index of control service */ #define TV_SERVICE_CONTROL 0 -//Index of picture service +/*Index of picture service */ #define TV_SERVICE_PICTURE 1 -//Number of control variables +/*Number of control variables */ #define TV_CONTROL_VARCOUNT 3 -//Index of power variable +/*Index of power variable */ #define TV_CONTROL_POWER 0 -//Index of channel variable +/*Index of channel variable */ #define TV_CONTROL_CHANNEL 1 -//Index of volume variable +/*Index of volume variable */ #define TV_CONTROL_VOLUME 2 -//Number of picture variables +/*Number of picture variables */ #define TV_PICTURE_VARCOUNT 4 -//Index of color variable +/*Index of color variable */ #define TV_PICTURE_COLOR 0 -//Index of tint variable +/*Index of tint variable */ #define TV_PICTURE_TINT 1 -//Index of contrast variable +/*Index of contrast variable */ #define TV_PICTURE_CONTRAST 2 -//Index of brightness variable +/*Index of brightness variable */ #define TV_PICTURE_BRIGHTNESS 3 -//Max value length +/*Max value length */ #define TV_MAX_VAL_LEN 5 -//Max actions +/*Max actions */ #define TV_MAXACTIONS 12 /* This should be the maximum VARCOUNT from above */ @@ -177,10 +177,10 @@ struct TvService { unsigned int VariableCount; }; -//Array of service structures +/*Array of service structures */ extern struct TvService tv_service_table[]; -//Device handle returned from sdk +/*Device handle returned from sdk */ extern UpnpDevice_Handle device_handle; @@ -310,7 +310,7 @@ int TvDeviceCallbackEventHandler(Upnp_EventType, void*, void*); *****************************************************************************/ int TvDeviceSetServiceTableVar(unsigned int, unsigned int, char*); -//Control Service Actions +/*Control Service Actions */ /****************************************************************************** * TvDevicePowerOn @@ -436,7 +436,7 @@ int TvDeviceIncreaseVolume(IN IXML_Document *in, OUT IXML_Document **out, OUT ch int TvDeviceDecreaseVolume(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString); -//Picture Service Actions +/*Picture Service Actions */ /****************************************************************************** * TvDeviceSetColor diff --git a/upnp/sample/tvctrlpt/linux/upnp_tv_ctrlpt_main.c b/upnp/sample/tvctrlpt/linux/upnp_tv_ctrlpt_main.c index bd54b68..5ab59ce 100644 --- a/upnp/sample/tvctrlpt/linux/upnp_tv_ctrlpt_main.c +++ b/upnp/sample/tvctrlpt/linux/upnp_tv_ctrlpt_main.c @@ -51,10 +51,10 @@ enum cmdloop_tvcmds { Data structure for parsing commands from the command line */ struct cmdloop_commands { - char *str; // the string - int cmdnum; // the command - int numargs; // the number of arguments - char *args; // the args + char *str; /* the string */ + int cmdnum; /* the command */ + int numargs; /* the number of arguments */ + char *args; /* the args */ } cmdloop_commands; /* diff --git a/upnp/sample/tvctrlpt/upnp_tv_ctrlpt.c b/upnp/sample/tvctrlpt/upnp_tv_ctrlpt.c index 5ab61a8..99fb731 100644 --- a/upnp/sample/tvctrlpt/upnp_tv_ctrlpt.c +++ b/upnp/sample/tvctrlpt/upnp_tv_ctrlpt.c @@ -125,7 +125,7 @@ TvCtrlPointDeleteNode( struct TvDeviceNode *node ) } } - //Notify New Device Added + /*Notify New Device Added */ SampleUtil_StateUpdate( NULL, NULL, node->device.UDN, DEVICE_REMOVED ); free( node ); node = NULL; @@ -374,7 +374,7 @@ TvCtrlPointSendAction( int service, param_val[param] ) != UPNP_E_SUCCESS ) { SampleUtil_Print ( "ERROR: TvCtrlPointSendAction: Trying to add action param" ); - //return -1; // TBD - BAD! leaves mutex locked + /*return -1; // TBD - BAD! leaves mutex locked */ } } } @@ -716,7 +716,7 @@ TvCtrlPointAddDevice( IXML_Document *DescDoc, if( strcmp( deviceType, TvDeviceType ) == 0 ) { SampleUtil_Print( "Found Tv device" ); - // Check if this device is already in the list + /* Check if this device is already in the list */ tmpdevnode = GlobalDeviceList; while( tmpdevnode ) { if( strcmp( tmpdevnode->device.UDN, UDN ) == 0 ) { @@ -727,8 +727,8 @@ TvCtrlPointAddDevice( IXML_Document *DescDoc, } if( found ) { - // The device is already there, so just update - // the advertisement timeout field + /* The device is already there, so just update */ + /* the advertisement timeout field */ tmpdevnode->device.AdvrTimeOut = expires; } else { for( service = 0; service < TV_SERVICE_SERVCOUNT; service++ ) { @@ -794,7 +794,7 @@ TvCtrlPointAddDevice( IXML_Document *DescDoc, deviceNode->next = NULL; - // Insert the new device node in the list + /* Insert the new device node in the list */ if( ( tmpdevnode = GlobalDeviceList ) ) { while( tmpdevnode ) { @@ -809,7 +809,7 @@ TvCtrlPointAddDevice( IXML_Document *DescDoc, GlobalDeviceList = deviceNode; } - //Notify New Device Added + /*Notify New Device Added */ SampleUtil_StateUpdate( NULL, NULL, deviceNode->device.UDN, DEVICE_ADDED ); } @@ -1225,7 +1225,7 @@ TvCtrlPointVerifyTimeouts( int incr ) while( curdevnode ) { curdevnode->device.AdvrTimeOut -= incr; - //SampleUtil_Print("Advertisement Timeout: %d\n", curdevnode->device.AdvrTimeOut); + /*SampleUtil_Print("Advertisement Timeout: %d\n", curdevnode->device.AdvrTimeOut); */ if( curdevnode->device.AdvrTimeOut <= 0 ) { /* @@ -1281,7 +1281,7 @@ TvCtrlPointVerifyTimeouts( int incr ) static int TvCtrlPointTimerLoopRun = 1; void *TvCtrlPointTimerLoop(void *args) { - int incr = 30; // how often to verify the timeouts, in seconds + int incr = 30; /* how often to verify the timeouts, in seconds */ while (TvCtrlPointTimerLoopRun) { isleep( incr ); diff --git a/upnp/sample/tvdevice/linux/upnp_tv_device_main.c b/upnp/sample/tvdevice/linux/upnp_tv_device_main.c index f3c47b5..9b360b5 100644 --- a/upnp/sample/tvdevice/linux/upnp_tv_device_main.c +++ b/upnp/sample/tvdevice/linux/upnp_tv_device_main.c @@ -79,7 +79,7 @@ TvDeviceCommandLoop( void *args ) SampleUtil_Print( "\n>> " ); - // Get a command line + /* Get a command line */ fgets( cmdline, 100, stdin ); sscanf( cmdline, "%s", cmd ); @@ -141,7 +141,7 @@ int main( IN int argc, IN char **argv ) SampleUtil_Initialize( linux_print ); - // Parse options + /* Parse options */ for( i = 1; i < argc; i++ ) { if( strcmp( argv[i], "-ip" ) == 0 ) { ip_address = argv[++i]; diff --git a/upnp/sample/tvdevice/upnp_tv_device.c b/upnp/sample/tvdevice/upnp_tv_device.c index e16c14c..c7d8185 100644 --- a/upnp/sample/tvdevice/upnp_tv_device.c +++ b/upnp/sample/tvdevice/upnp_tv_device.c @@ -94,31 +94,31 @@ UpnpDevice_Handle device_handle = -1; */ ithread_mutex_t TVDevMutex; -//Color constants +/*Color constants */ #define MAX_COLOR 10 #define MIN_COLOR 1 -//Brightness constants +/*Brightness constants */ #define MAX_BRIGHTNESS 10 #define MIN_BRIGHTNESS 1 -//Power constants +/*Power constants */ #define POWER_ON 1 #define POWER_OFF 0 -//Tint constants +/*Tint constants */ #define MAX_TINT 10 #define MIN_TINT 1 -//Volume constants +/*Volume constants */ #define MAX_VOLUME 10 #define MIN_VOLUME 1 -//Contrast constants +/*Contrast constants */ #define MAX_CONTRAST 10 #define MIN_CONTRAST 1 -//Channel constants +/*Channel constants */ #define MAX_CHANNEL 100 #define MIN_CHANNEL 1 @@ -289,7 +289,7 @@ TvDeviceStateTableInit( IN char *DescDocURL ) *ctrlurl_pict = NULL; char *udn = NULL; - //Download description document + /*Download description document */ if( UpnpDownloadXmlDoc( DescDocURL, &DescDoc ) != UPNP_E_SUCCESS ) { SampleUtil_Print( "TvDeviceStateTableInit -- Error Parsing %s\n", DescDocURL ); @@ -314,7 +314,7 @@ TvDeviceStateTableInit( IN char *DescDocURL ) goto error_handler; } - //set control service table + /*set control service table */ SetServiceTable( TV_SERVICE_CONTROL, udn, servid_ctrl, TvServiceType[TV_SERVICE_CONTROL], &tv_service_table[TV_SERVICE_CONTROL] ); @@ -333,14 +333,14 @@ TvDeviceStateTableInit( IN char *DescDocURL ) ret = UPNP_E_INVALID_DESC; goto error_handler; } - //set picture service table + /*set picture service table */ SetServiceTable( TV_SERVICE_PICTURE, udn, servid_pict, TvServiceType[TV_SERVICE_PICTURE], &tv_service_table[TV_SERVICE_PICTURE] ); error_handler: - //clean up + /*clean up */ if( udn ) free( udn ); if( servid_ctrl ) @@ -382,7 +382,7 @@ int TvDeviceHandleSubscriptionRequest(IN const UpnpSubscriptionRequest *sr_event const char *l_udn = NULL; const char *l_sid = NULL; - // lock state mutex + /* lock state mutex */ ithread_mutex_lock(&TVDevMutex); l_serviceId = UpnpString_get_String(UpnpSubscriptionRequest_get_ServiceId(sr_event)); @@ -396,22 +396,22 @@ int TvDeviceHandleSubscriptionRequest(IN const UpnpSubscriptionRequest *sr_event PropSet = NULL; for (j = 0; j< tv_service_table[i].VariableCount; ++j) { - // add each variable to the property set - // for initial state dump + /* add each variable to the property set */ + /* for initial state dump */ UpnpAddToPropertySet( &PropSet, tv_service_table[i].VariableName[j], tv_service_table[i].VariableStrVal[j]); } - // dump initial state + /* dump initial state */ UpnpAcceptSubscriptionExt( device_handle, l_udn, l_serviceId, PropSet, l_sid); - // free document + /* free document */ Document_free(PropSet); #endif UpnpAcceptSubscription( @@ -456,14 +456,14 @@ int TvDeviceHandleGetVarRequest(INOUT UpnpStateVarRequest *cgv_event) ithread_mutex_lock(&TVDevMutex); for (i = 0; i < TV_SERVICE_SERVCOUNT; i++) { - // check udn and service id + /* check udn and service id */ const char *devUDN = UpnpString_get_String(UpnpStateVarRequest_get_DevUDN(cgv_event)); const char *serviceID = UpnpString_get_String(UpnpStateVarRequest_get_ServiceID(cgv_event)); if (strcmp(devUDN, tv_service_table[i].UDN) == 0 && strcmp(serviceID, tv_service_table[i].ServiceId) == 0) { - // check variable name + /* check variable name */ for (j = 0; j < tv_service_table[i].VariableCount; j++) { const char *stateVarName = UpnpString_get_String( UpnpStateVarRequest_get_StateVarName(cgv_event)); @@ -565,7 +565,7 @@ int TvDeviceHandleActionRequest(INOUT UpnpActionRequest *ca_event) if (retCode == UPNP_E_SUCCESS) { UpnpActionRequest_set_ErrCode(ca_event, UPNP_E_SUCCESS); } else { - // copy the error string + /* copy the error string */ UpnpActionRequest_strcpy_ErrStr(ca_event, errorString); switch (retCode) { case UPNP_E_INVALID_PARAM: @@ -605,7 +605,7 @@ TvDeviceSetServiceTableVar( IN unsigned int service, IN unsigned int variable, IN char *value ) { - //IXML_Document *PropSet= NULL; + /*IXML_Document *PropSet= NULL; */ if( ( service >= TV_SERVICE_SERVCOUNT ) || ( variable >= tv_service_table[service].VariableCount ) @@ -617,8 +617,8 @@ TvDeviceSetServiceTableVar( IN unsigned int service, strcpy( tv_service_table[service].VariableStrVal[variable], value ); - /* - //Using utility api +#if 0 + /*Using utility api */ PropSet= UpnpCreatePropertySet(1,tv_service_table[service]. VariableName[variable], tv_service_table[service]. @@ -627,9 +627,9 @@ TvDeviceSetServiceTableVar( IN unsigned int service, UpnpNotifyExt(device_handle, tv_service_table[service].UDN, tv_service_table[service].ServiceId,PropSet); - //Free created property set + /*Free created property set */ Document_free(PropSet); - */ +#endif UpnpNotify( device_handle, tv_service_table[service].UDN, @@ -698,7 +698,7 @@ TvDevicePowerOn( IN IXML_Document *in, OUT IXML_Document **out, OUT char **error ( *errorString ) = NULL; if( TvDeviceSetPower( POWER_ON ) ) { - //create a response + /*create a response */ if( UpnpAddToActionResponse( out, "PowerOn", TvServiceType[TV_SERVICE_CONTROL], @@ -735,7 +735,7 @@ TvDevicePowerOff( IN IXML_Document * in, ( *out ) = NULL; ( *errorString ) = NULL; if( TvDeviceSetPower( POWER_OFF ) ) { - //create a response + /*create a response */ if( UpnpAddToActionResponse( out, "PowerOff", TvServiceType[TV_SERVICE_CONTROL], diff --git a/upnp/sample/tvdevice/upnp_tv_device.h b/upnp/sample/tvdevice/upnp_tv_device.h index 855d984..9eb1130 100644 --- a/upnp/sample/tvdevice/upnp_tv_device.h +++ b/upnp/sample/tvdevice/upnp_tv_device.h @@ -61,74 +61,74 @@ extern "C" { #endif -//Color constants +/*Color constants */ #define MAX_COLOR 10 #define MIN_COLOR 1 -//Brightness constants +/*Brightness constants */ #define MAX_BRIGHTNESS 10 #define MIN_BRIGHTNESS 1 -//Power constants +/*Power constants */ #define POWER_ON 1 #define POWER_OFF 0 -//Tint constants +/*Tint constants */ #define MAX_TINT 10 #define MIN_TINT 1 -//Volume constants +/*Volume constants */ #define MAX_VOLUME 10 #define MIN_VOLUME 1 -//Contrast constants +/*Contrast constants */ #define MAX_CONTRAST 10 #define MIN_CONTRAST 1 -//Channel constants +/*Channel constants */ #define MAX_CHANNEL 100 #define MIN_CHANNEL 1 -//Number of services. +/*Number of services. */ #define TV_SERVICE_SERVCOUNT 2 -//Index of control service +/*Index of control service */ #define TV_SERVICE_CONTROL 0 -//Index of picture service +/*Index of picture service */ #define TV_SERVICE_PICTURE 1 -//Number of control variables +/*Number of control variables */ #define TV_CONTROL_VARCOUNT 3 -//Index of power variable +/*Index of power variable */ #define TV_CONTROL_POWER 0 -//Index of channel variable +/*Index of channel variable */ #define TV_CONTROL_CHANNEL 1 -//Index of volume variable +/*Index of volume variable */ #define TV_CONTROL_VOLUME 2 -//Number of picture variables +/*Number of picture variables */ #define TV_PICTURE_VARCOUNT 4 -//Index of color variable +/*Index of color variable */ #define TV_PICTURE_COLOR 0 -//Index of tint variable +/*Index of tint variable */ #define TV_PICTURE_TINT 1 -//Index of contrast variable +/*Index of contrast variable */ #define TV_PICTURE_CONTRAST 2 -//Index of brightness variable +/*Index of brightness variable */ #define TV_PICTURE_BRIGHTNESS 3 -//Max value length +/*Max value length */ #define TV_MAX_VAL_LEN 5 -//Max actions +/*Max actions */ #define TV_MAXACTIONS 12 /* This should be the maximum VARCOUNT from above */ @@ -177,10 +177,10 @@ struct TvService { unsigned int VariableCount; }; -//Array of service structures +/*Array of service structures */ extern struct TvService tv_service_table[]; -//Device handle returned from sdk +/*Device handle returned from sdk */ extern UpnpDevice_Handle device_handle; @@ -310,7 +310,7 @@ int TvDeviceCallbackEventHandler(Upnp_EventType, void*, void*); *****************************************************************************/ int TvDeviceSetServiceTableVar(unsigned int, unsigned int, char*); -//Control Service Actions +/*Control Service Actions */ /****************************************************************************** * TvDevicePowerOn @@ -436,7 +436,7 @@ int TvDeviceIncreaseVolume(IN IXML_Document *in, OUT IXML_Document **out, OUT ch int TvDeviceDecreaseVolume(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString); -//Picture Service Actions +/*Picture Service Actions */ /****************************************************************************** * TvDeviceSetColor diff --git a/upnp/src/api/UpnpString.c b/upnp/src/api/UpnpString.c index 031ad27..3c9eb6b 100644 --- a/upnp/src/api/UpnpString.c +++ b/upnp/src/api/UpnpString.c @@ -66,7 +66,7 @@ struct SUpnpString UpnpString *UpnpString_new() { - // All bytes are zero, and so is the length of the string. + /* All bytes are zero, and so is the length of the string. */ struct SUpnpString *p = calloc(1, sizeof (struct SUpnpString)); if (p == NULL) { goto error_handler1; @@ -75,7 +75,7 @@ UpnpString *UpnpString_new() p->m_length = 0; #endif - // This byte is zero, calloc does initialize it. + /* This byte is zero, calloc does initialize it. */ p->m_string = calloc(1, 1); if (p->m_string == NULL) { goto error_handler2; @@ -83,7 +83,7 @@ UpnpString *UpnpString_new() return (UpnpString *)p; - //free(p->m_string); + /*free(p->m_string); */ error_handler2: free(p); error_handler1: @@ -120,7 +120,7 @@ UpnpString *UpnpString_dup(const UpnpString *p) return (UpnpString *)q; - //free(q->m_string); + /*free(q->m_string); */ error_handler2: free(q); error_handler1: diff --git a/upnp/src/api/upnpapi.c b/upnp/src/api/upnpapi.c index 0290458..cf5f56d 100644 --- a/upnp/src/api/upnpapi.c +++ b/upnp/src/api/upnpapi.c @@ -925,7 +925,7 @@ int UpnpRegisterRootDevice2( } HandleTable[*Hnd] = HInfo; - // prevent accidental removal of a non-existent alias + /* prevent accidental removal of a non-existent alias */ HInfo->aliasInstalled = 0; retVal = GetDescDocumentAndURL( @@ -1189,7 +1189,7 @@ int UpnpUnRegisterRootDevice(UpnpDevice_Handle Hnd) HandleUnlock(); return UPNP_E_INVALID_HANDLE; } - //info = (struct Handle_Info *) HandleTable[Hnd]; + /*info = (struct Handle_Info *) HandleTable[Hnd]; */ ixmlNodeList_free( HInfo->DeviceList ); ixmlNodeList_free( HInfo->ServiceList ); ixmlDocument_free( HInfo->DescDocument ); @@ -1202,7 +1202,7 @@ int UpnpUnRegisterRootDevice(UpnpDevice_Handle Hnd) if( HInfo->aliasInstalled ) { web_server_set_alias( NULL, NULL, 0, 0 ); } -#endif // INTERNAL_WEB_SERVER +#endif /* INTERNAL_WEB_SERVER */ if( HInfo->DeviceAf == AF_INET ) { UpnpSdkDeviceRegisteredV4 = 0; @@ -2973,9 +2973,9 @@ int UpnpDownloadXmlDoc(const char *url, IXML_Document **xmlDoc) int UpnpGetIfInfo(const char *IfName) { #ifdef WIN32 - // ---------------------------------------------------- - // WIN32 implementation will use the IpHlpAPI library. - // ---------------------------------------------------- + /* ---------------------------------------------------- */ + /* WIN32 implementation will use the IpHlpAPI library. */ + /* ---------------------------------------------------- */ PIP_ADAPTER_ADDRESSES adapts = NULL; PIP_ADAPTER_ADDRESSES adapts_item; PIP_ADAPTER_UNICAST_ADDRESS uni_addr; @@ -2987,7 +2987,7 @@ int UpnpGetIfInfo(const char *IfName) int ifname_found = 0; int valid_addr_found = 0; - // Get Adapters addresses required size. + /* Get Adapters addresses required size. */ ret = GetAdaptersAddresses(AF_UNSPEC, GAA_FLAG_SKIP_ANYCAST | GAA_FLAG_SKIP_DNS_SERVER, NULL, adapts, &adapts_sz ); @@ -2997,13 +2997,13 @@ int UpnpGetIfInfo(const char *IfName) return UPNP_E_INIT; } - // Allocate enough memory. + /* Allocate enough memory. */ adapts = (PIP_ADAPTER_ADDRESSES)malloc( adapts_sz ); if( adapts == NULL ) { return UPNP_E_OUTOF_MEMORY; } - // Do the call that will actually return the info. + /* Do the call that will actually return the info. */ ret = GetAdaptersAddresses( AF_UNSPEC, GAA_FLAG_SKIP_ANYCAST | GAA_FLAG_SKIP_DNS_SERVER, NULL, adapts, &adapts_sz ); @@ -3014,7 +3014,7 @@ int UpnpGetIfInfo(const char *IfName) return UPNP_E_INIT; } - // Copy interface name, if it was provided. + /* Copy interface name, if it was provided. */ if( IfName != NULL ) { if( strlen(IfName) > sizeof(gIF_NAME) ) return UPNP_E_INVALID_INTERFACE; @@ -3031,17 +3031,17 @@ int UpnpGetIfInfo(const char *IfName) } if( ifname_found == 0 ) { - // We have found a valid interface name. Keep it. + /* We have found a valid interface name. Keep it. */ strncpy( gIF_NAME, adapts_item->FriendlyName, sizeof(gIF_NAME) ); ifname_found = 1; } else { if( strncmp( gIF_NAME, adapts_item->FriendlyName, sizeof(gIF_NAME) ) != 0 ) { - // This is not the interface we're looking for. + /* This is not the interface we're looking for. */ continue; } } - // Loop thru this adapter's unicast IP addresses. + /* Loop thru this adapter's unicast IP addresses. */ uni_addr = adapts_item->FirstUnicastAddress; while( uni_addr ) { ip_addr = uni_addr->Address.lpSockaddr; @@ -3051,7 +3051,7 @@ int UpnpGetIfInfo(const char *IfName) valid_addr_found = 1; break; case AF_INET6: - // Only keep IPv6 link-local addresses. + /* Only keep IPv6 link-local addresses. */ if( IN6_IS_ADDR_LINKLOCAL(&((struct sockaddr_in6 *)ip_addr)->sin6_addr) ) { memcpy( &v6_addr, &((struct sockaddr_in6 *)ip_addr)->sin6_addr, sizeof(v6_addr) ); valid_addr_found = 1; @@ -3059,14 +3059,14 @@ int UpnpGetIfInfo(const char *IfName) break; default: if( valid_addr_found == 0 ) { - // Address is not IPv4 or IPv6 and no valid address has - // yet been found for this interface. Discard interface name. + /* Address is not IPv4 or IPv6 and no valid address has */ + /* yet been found for this interface. Discard interface name. */ ifname_found = 0; } break; } - // Next address. + /* Next address. */ uni_addr = uni_addr->Next; } @@ -3075,11 +3075,11 @@ int UpnpGetIfInfo(const char *IfName) break; } - // Next adapter. + /* Next adapter. */ adapts_item = adapts_item->Next; } - // Failed to find a valid interface, or valid address. + /* Failed to find a valid interface, or valid address. */ if( ifname_found == 0 || valid_addr_found == 0 ) { UpnpPrintf( UPNP_CRITICAL, API, __FILE__, __LINE__, "Failed to find an adapter with valid IP addresses for use.\n" ); @@ -3095,7 +3095,7 @@ int UpnpGetIfInfo(const char *IfName) int ifname_found = 0; int valid_addr_found = 0; - // Copy interface name, if it was provided. + /* Copy interface name, if it was provided. */ if( IfName != NULL ) { if( strlen(IfName) > sizeof(gIF_NAME) ) return UPNP_E_INVALID_INTERFACE; @@ -3104,18 +3104,18 @@ int UpnpGetIfInfo(const char *IfName) ifname_found = 1; } - // Get system interface addresses. + /* Get system interface addresses. */ if( getifaddrs(&ifap) != 0 ) { UpnpPrintf( UPNP_CRITICAL, API, __FILE__, __LINE__, "getifaddrs failed to find list of addresses\n" ); return UPNP_E_INIT; } - // cycle through available interfaces and their addresses. + /* cycle through available interfaces and their addresses. */ for (ifa = ifap; ifa != NULL; ifa = ifa->ifa_next) { - // Skip LOOPBACK interfaces, DOWN interfaces and interfaces that - // don't support MULTICAST. + /* Skip LOOPBACK interfaces, DOWN interfaces and interfaces that */ + /* don't support MULTICAST. */ if( ( ifa->ifa_flags & IFF_LOOPBACK ) || ( !( ifa->ifa_flags & IFF_UP ) ) || ( !( ifa->ifa_flags & IFF_MULTICAST ) ) ) { @@ -3123,17 +3123,17 @@ int UpnpGetIfInfo(const char *IfName) } if( ifname_found == 0 ) { - // We have found a valid interface name. Keep it. + /* We have found a valid interface name. Keep it. */ strncpy( gIF_NAME, ifa->ifa_name, sizeof(gIF_NAME) ); ifname_found = 1; } else { if( strncmp( gIF_NAME, ifa->ifa_name, sizeof(gIF_NAME) ) != 0 ) { - // This is not the interface we're looking for. + /* This is not the interface we're looking for. */ continue; } } - // Keep interface addresses for later. + /* Keep interface addresses for later. */ switch( ifa->ifa_addr->sa_family ) { case AF_INET: @@ -3141,7 +3141,7 @@ int UpnpGetIfInfo(const char *IfName) valid_addr_found = 1; break; case AF_INET6: - // Only keep IPv6 link-local addresses. + /* Only keep IPv6 link-local addresses. */ if( IN6_IS_ADDR_LINKLOCAL(&((struct sockaddr_in6 *)(ifa->ifa_addr))->sin6_addr) ) { memcpy( &v6_addr, &((struct sockaddr_in6 *)(ifa->ifa_addr))->sin6_addr, sizeof(v6_addr) ); valid_addr_found = 1; @@ -3149,8 +3149,8 @@ int UpnpGetIfInfo(const char *IfName) break; default: if( valid_addr_found == 0 ) { - // Address is not IPv4 or IPv6 and no valid address has - // yet been found for this interface. Discard interface name. + /* Address is not IPv4 or IPv6 and no valid address has */ + /* yet been found for this interface. Discard interface name. */ ifname_found = 0; } break; @@ -3158,7 +3158,7 @@ int UpnpGetIfInfo(const char *IfName) } freeifaddrs(ifap); - // Failed to find a valid interface, or valid address. + /* Failed to find a valid interface, or valid address. */ if( ifname_found == 0 || valid_addr_found == 0 ) { UpnpPrintf( UPNP_CRITICAL, API, __FILE__, __LINE__, "Failed to find an adapter with valid IP addresses for use.\n" ); @@ -3178,11 +3178,11 @@ int UpnpGetIfInfo(const char *IfName) struct in6_addr v6_addr; int if_idx; char addr6[8][5]; - char buf[65]; // INET6_ADDRSTRLEN + char buf[65]; /* INET6_ADDRSTRLEN */ int ifname_found = 0; int valid_addr_found = 0; - // Copy interface name, if it was provided. + /* Copy interface name, if it was provided. */ if( IfName != NULL ) { if( strlen(IfName) > sizeof(gIF_NAME) ) return UPNP_E_INVALID_INTERFACE; @@ -3191,14 +3191,14 @@ int UpnpGetIfInfo(const char *IfName) ifname_found = 1; } - // Create an unbound datagram socket to do the SIOCGIFADDR ioctl on. + /* Create an unbound datagram socket to do the SIOCGIFADDR ioctl on. */ if( ( LocalSock = socket( AF_INET, SOCK_DGRAM, IPPROTO_UDP ) ) < 0 ) { UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, "Can't create addrlist socket\n" ); return UPNP_E_INIT; } - // Get the interface configuration information... + /* Get the interface configuration information... */ ifConf.ifc_len = sizeof szBuffer; ifConf.ifc_ifcu.ifcu_buf = ( caddr_t ) szBuffer; @@ -3208,13 +3208,13 @@ int UpnpGetIfInfo(const char *IfName) return UPNP_E_INIT; } - // Cycle through the list of interfaces looking for IP addresses. + /* Cycle through the list of interfaces looking for IP addresses. */ for( i = 0; i < ifConf.ifc_len ; ) { struct ifreq *pifReq = ( struct ifreq * )( ( caddr_t ) ifConf.ifc_req + i ); i += sizeof *pifReq; - // See if this is the sort of interface we want to deal with. + /* See if this is the sort of interface we want to deal with. */ strcpy( ifReq.ifr_name, pifReq->ifr_name ); if( ioctl( LocalSock, SIOCGIFFLAGS, &ifReq ) < 0 ) { UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, @@ -3222,8 +3222,8 @@ int UpnpGetIfInfo(const char *IfName) ifReq.ifr_name ); } - // Skip LOOPBACK interfaces, DOWN interfaces and interfaces that - // don't support MULTICAST. + /* Skip LOOPBACK interfaces, DOWN interfaces and interfaces that */ + /* don't support MULTICAST. */ if( ( ifReq.ifr_flags & IFF_LOOPBACK ) || ( !( ifReq.ifr_flags & IFF_UP ) ) || ( !( ifReq.ifr_flags & IFF_MULTICAST ) ) ) { @@ -3231,19 +3231,19 @@ int UpnpGetIfInfo(const char *IfName) } if( ifname_found == 0 ) { - // We have found a valid interface name. Keep it. + /* We have found a valid interface name. Keep it. */ strncpy( gIF_NAME, pifReq->ifr_name, sizeof(gIF_NAME) ); ifname_found = 1; } else { if( strncmp( gIF_NAME, pifReq->ifr_name, sizeof(gIF_NAME) ) != 0 ) { - // This is not the interface we're looking for. + /* This is not the interface we're looking for. */ continue; } } - // Check address family. + /* Check address family. */ if( pifReq->ifr_addr.sa_family == AF_INET ) { - // Copy interface name, IPv4 address and interface index. + /* Copy interface name, IPv4 address and interface index. */ strncpy( gIF_NAME, pifReq->ifr_name, sizeof(gIF_NAME) ); inet_ntop(AF_INET, &((struct sockaddr_in*)&pifReq->ifr_addr)->sin_addr, gIF_IPV4, sizeof(gIF_IPV4)); gIF_INDEX = if_nametoindex(gIF_NAME); @@ -3251,13 +3251,13 @@ int UpnpGetIfInfo(const char *IfName) valid_addr_found = 1; break; } else { - // Address is not IPv4 + /* Address is not IPv4 */ ifname_found = 0; } } close( LocalSock ); - // Failed to find a valid interface, or valid address. + /* Failed to find a valid interface, or valid address. */ if (ifname_found == 0 || valid_addr_found == 0) { UpnpPrintf(UPNP_CRITICAL, API, __FILE__, __LINE__, "Failed to find an adapter with valid IP addresses for use.\n"); @@ -3265,31 +3265,31 @@ int UpnpGetIfInfo(const char *IfName) return UPNP_E_INVALID_INTERFACE; } - // Try to get the IPv6 address for the same interface - // from "/proc/net/if_inet6", if possible. + /* Try to get the IPv6 address for the same interface */ + /* from "/proc/net/if_inet6", if possible. */ inet6_procfd = fopen("/proc/net/if_inet6", "r"); if (inet6_procfd) { while (fscanf(inet6_procfd, "%4s%4s%4s%4s%4s%4s%4s%4s %02x %*02x %*02x %*02x %*20s\n", addr6[0],addr6[1],addr6[2],addr6[3], addr6[4],addr6[5],addr6[6],addr6[7], &if_idx) != EOF) { - // Get same interface as IPv4 address retrieved. + /* Get same interface as IPv4 address retrieved. */ if( gIF_INDEX == if_idx ) { snprintf(buf, sizeof(buf), "%s:%s:%s:%s:%s:%s:%s:%s", addr6[0],addr6[1],addr6[2],addr6[3], addr6[4],addr6[5],addr6[6],addr6[7]); - // Validate formed address and check for link-local. + /* Validate formed address and check for link-local. */ if (inet_pton(AF_INET6, buf, &v6_addr) > 0) { if (IN6_IS_ADDR_ULA(&v6_addr)) { - // Got valid IPv6 ula. + /* Got valid IPv6 ula. */ strncpy(gIF_IPV6_ULA_GUA, buf, sizeof(gIF_IPV6_ULA_GUA)); } else if (IN6_IS_ADDR_GLOBAL(&v6_addr) && strlen(gIF_IPV6_ULA_GUA) == 0) { - // got a GUA, should store it while no ULA is found + /* got a GUA, should store it while no ULA is found */ strncpy(gIF_IPV6_ULA_GUA, buf, sizeof(gIF_IPV6_ULA_GUA)); } else if (IN6_IS_ADDR_LINKLOCAL(&v6_addr) && strlen(gIF_IPV6) == 0) { - // got a Link local IPv6 address. + /* got a Link local IPv6 address. */ strncpy(gIF_IPV6, buf, sizeof(gIF_IPV6)); } } @@ -3710,7 +3710,7 @@ int UpnpAddVirtualDir(const char *newDirName) char dirName[NAME_SIZE]; if( UpnpSdkInit != 1 ) { - // SDK is not initialized + /* SDK is not initialized */ return UPNP_E_FINISH; } @@ -3727,7 +3727,7 @@ int UpnpAddVirtualDir(const char *newDirName) pCurVirtualDir = pVirtualDirList; while( pCurVirtualDir != NULL ) { - // already has this entry + /* already has this entry */ if( strcmp( pCurVirtualDir->dirName, dirName ) == 0 ) { return UPNP_E_SUCCESS; } @@ -3744,7 +3744,7 @@ int UpnpAddVirtualDir(const char *newDirName) strcpy( pNewVirtualDir->dirName, dirName ); *( pNewVirtualDir->dirName + strlen( dirName ) ) = 0; - if( pVirtualDirList == NULL ) { // first virtual dir + if( pVirtualDirList == NULL ) { /* first virtual dir */ pVirtualDirList = pNewVirtualDir; } else { pLast = pVirtualDirList; @@ -3775,11 +3775,8 @@ int UpnpRemoveVirtualDir(const char *dirName) if( pVirtualDirList == NULL ) { return UPNP_E_INVALID_PARAM; } - // - // Handle the special case where the directory that we are - // removing is the first and only one in the list. - // - + /* Handle the special case where the directory that we are */ + /* removing is the first and only one in the list. */ if( ( pVirtualDirList->next == NULL ) && ( strcmp( pVirtualDirList->dirName, dirName ) == 0 ) ) { free( pVirtualDirList ); diff --git a/upnp/src/api/upnptools.c b/upnp/src/api/upnptools.c index 3bbe9eb..3c05830 100644 --- a/upnp/src/api/upnptools.c +++ b/upnp/src/api/upnptools.c @@ -314,7 +314,7 @@ static IXML_Document *makeAction( } if (NumArg > 0) { - //va_start(ArgList, Arg); + /*va_start(ArgList, Arg); */ ArgName = Arg; for ( ; ; ) { ArgValue = va_arg(ArgList, const char *); @@ -333,7 +333,7 @@ static IXML_Document *makeAction( break; } } - //va_end(ArgList); + /*va_end(ArgList); */ } return ActionDoc; diff --git a/upnp/src/gena/gena_callback2.c b/upnp/src/gena/gena_callback2.c index 231c5b5..12b3650 100644 --- a/upnp/src/gena/gena_callback2.c +++ b/upnp/src/gena/gena_callback2.c @@ -1,33 +1,33 @@ -/////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2000-2003 Intel Corporation -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// * Neither name of Intel Corporation nor the names of its contributors -// may be used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -/////////////////////////////////////////////////////////////////////////// +/******************************************************************************* + * + * Copyright (c) 2000-2003 Intel Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * - Neither name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ******************************************************************************/ #include "config.h" #if EXCLUDE_GENA == 0 @@ -63,7 +63,7 @@ error_respond( IN SOCKINFO * info, int major, minor; - // retrieve the minor and major version from the GENA request + /* retrieve the minor and major version from the GENA request */ http_CalcResponseVersion( hmsg->major_version, hmsg->minor_version, &major, &minor ); @@ -96,32 +96,32 @@ genaCallback( IN http_parser_t * parser, #ifdef INCLUDE_DEVICE_APIS found_function = TRUE; if( httpmsg_find_hdr( request, HDR_NT, NULL ) == NULL ) { - // renew subscription + /* renew subscription */ gena_process_subscription_renewal_request ( info, request ); } else { - // subscribe + /* 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 + /* unsubscribe */ gena_process_unsubscribe_request( info, request ); #endif } else if( request->method == HTTPMETHOD_NOTIFY ) { #ifdef INCLUDE_CLIENT_APIS found_function = TRUE; - // notify + /* notify */ gena_process_notification_event( info, request ); #endif } 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 ); } } -#endif // EXCLUDE_GENA +#endif /* EXCLUDE_GENA */ diff --git a/upnp/src/gena/gena_ctrlpt.c b/upnp/src/gena/gena_ctrlpt.c index 1ee5ac1..805d1aa 100644 --- a/upnp/src/gena/gena_ctrlpt.c +++ b/upnp/src/gena/gena_ctrlpt.c @@ -105,7 +105,7 @@ static void GenaAutoRenewSubscription( } UpnpPrintf(UPNP_INFO, GENA, __FILE__, __LINE__, "HANDLE IS VALID"); - // make callback + /* make callback */ callback_fun = handle_info->Callback; cookie = handle_info->Cookie; HandleUnlock(); @@ -156,13 +156,13 @@ static int ScheduleGenaAutoRenew( goto end_function; } - // schedule expire event + /* schedule expire event */ UpnpEventSubscribe_set_ErrCode(RenewEventStruct, UPNP_E_SUCCESS); UpnpEventSubscribe_set_TimeOut(RenewEventStruct, TimeOut); UpnpEventSubscribe_set_SID(RenewEventStruct, GenlibClientSubscription_get_SID(sub)); UpnpEventSubscribe_set_PublisherUrl(RenewEventStruct, GenlibClientSubscription_get_EventURL(sub)); - // RenewEvent->EventType=UPNP_EVENT_SUBSCRIPTION_EXPIRE; + /* RenewEvent->EventType=UPNP_EVENT_SUBSCRIPTION_EXPIRE; */ RenewEvent->handle = client_handle; RenewEvent->Event = RenewEventStruct; @@ -170,7 +170,7 @@ static int ScheduleGenaAutoRenew( TPJobSetFreeFunction(&job, (free_routine)free_upnp_timeout); TPJobSetPriority(&job, MED_PRIORITY); - // Schedule the job + /* Schedule the job */ return_code = TimerThreadSchedule( &gTimerThread, TimeOut - AUTO_RENEW_TIME, @@ -211,7 +211,7 @@ static int gena_unsubscribe( uri_type dest_url; membuffer request; - // parse url + /* parse url */ return_code = http_FixStrUrl( UpnpString_get_String(url), UpnpString_get_Length(url), @@ -220,7 +220,7 @@ static int gena_unsubscribe( return return_code; } - // make request msg + /* make request msg */ membuffer_init(&request); request.size_inc = 30; return_code = http_MakeMessage( @@ -229,14 +229,14 @@ static int gena_unsubscribe( HTTPMETHOD_UNSUBSCRIBE, &dest_url, "SID: ", UpnpString_get_String(sid)); - // Not able to make the message so destroy the existing buffer + /* Not able to make the message so destroy the existing buffer */ if (return_code != 0) { membuffer_destroy(&request); return return_code; } - // send request and get reply + /* send request and get reply */ return_code = http_RequestAndResponse( &dest_url, request.buf, request.length, HTTPMETHOD_UNSUBSCRIBE, HTTP_DEFAULT_TIMEOUT, response); @@ -282,7 +282,7 @@ static int gena_subscribe( UpnpString_clear(sid); - // request timeout to string + /* request timeout to string */ if (timeout == NULL) { timeout = &local_timeout; } @@ -294,7 +294,7 @@ static int gena_subscribe( sprintf(timeout_str, "%d", *timeout); } - // parse url + /* parse url */ return_code = http_FixStrUrl( UpnpString_get_String(url), UpnpString_get_Length(url), @@ -303,11 +303,11 @@ static int gena_subscribe( return return_code; } - // make request msg + /* make request msg */ membuffer_init(&request); request.size_inc = 30; if (renewal_sid) { - // renew subscription + /* renew subscription */ return_code = http_MakeMessage( &request, 1, 1, "q" "ssc" "sscc", @@ -315,7 +315,7 @@ static int gena_subscribe( "SID: ", UpnpString_get_String(renewal_sid), "TIMEOUT: Second-", timeout_str ); } else { - // subscribe + /* subscribe */ if (dest_url.hostport.IPaddress.ss_family == AF_INET6) { struct sockaddr_in6* DestAddr6 = (struct sockaddr_in6*)&dest_url.hostport.IPaddress; return_code = http_MakeMessage( @@ -342,7 +342,7 @@ static int gena_subscribe( return return_code; } - // send request and get reply + /* send request and get reply */ return_code = http_RequestAndResponse(&dest_url, request.buf, request.length, HTTPMETHOD_SUBSCRIBE, @@ -361,7 +361,7 @@ static int gena_subscribe( return UPNP_E_SUBSCRIBE_UNACCEPTED; } - // get SID and TIMEOUT + /* get SID and TIMEOUT */ if (httpmsg_find_hdr(&response.msg, HDR_SID, &sid_hdr) == NULL || sid_hdr.length == 0 || httpmsg_find_hdr( &response.msg, HDR_TIMEOUT, &timeout_hdr ) == NULL || @@ -371,10 +371,10 @@ static int gena_subscribe( return UPNP_E_BAD_RESPONSE; } - // save timeout + /* save timeout */ parse_ret = matchstr(timeout_hdr.buf, timeout_hdr.length, "%iSecond-%d%0", timeout); if (parse_ret == PARSE_OK) { - // nothing to do + /* nothing to do */ } else if (memptr_cmp_nocase(&timeout_hdr, "Second-infinite") == 0) { *timeout = -1; } else { @@ -383,7 +383,7 @@ static int gena_subscribe( return UPNP_E_BAD_RESPONSE; } - // save SID + /* save SID */ UpnpString_set_StringN(sid, sid_hdr.buf, sid_hdr.length); if (UpnpString_get_String(sid) == NULL) { httpmsg_destroy(&response.msg); @@ -452,7 +452,7 @@ int genaUnSubscribe( GenlibClientSubscription *sub_copy = GenlibClientSubscription_new(); http_parser_t response; - // validate handle and sid + /* validate handle and sid */ HandleLock(); if (GetHandleInfo(client_handle, &handle_info) != HND_CLIENT) { HandleUnlock(); @@ -514,7 +514,7 @@ int genaSubscribe( UpnpString_clear(out_sid); HandleReadLock(); - // validate handle + /* validate handle */ if (GetHandleInfo(client_handle, &handle_info) != HND_CLIENT) { HandleUnlock(); @@ -522,7 +522,7 @@ int genaSubscribe( } HandleUnlock(); - // subscribe + /* subscribe */ SubscribeLock(); return_code = gena_subscribe(PublisherURL, TimeOut, NULL, ActualSID); HandleLock(); @@ -538,16 +538,16 @@ int genaSubscribe( goto error_handler; } - // generate client SID + /* generate client SID */ uuid_create(&uid ); uuid_unpack(&uid, temp_sid); sprintf(temp_sid2, "uuid:%s", temp_sid); UpnpString_set_String(out_sid, temp_sid2); - // create event url + /* create event url */ UpnpString_assign(EventURL, PublisherURL); - // fill subscription + /* fill subscription */ if (newSubscription == NULL) { return_code = UPNP_E_OUTOF_MEMORY; goto error_handler; @@ -559,7 +559,7 @@ int genaSubscribe( GenlibClientSubscription_set_Next(newSubscription, handle_info->ClientSubList); handle_info->ClientSubList = newSubscription; - // schedule expiration event + /* schedule expiration event */ return_code = ScheduleGenaAutoRenew(client_handle, *TimeOut, newSubscription); error_handler: @@ -590,7 +590,7 @@ int genaRenewSubscription( HandleLock(); - // validate handle and sid + /* validate handle and sid */ if (GetHandleInfo(client_handle, &handle_info) != HND_CLIENT) { HandleUnlock(); @@ -606,7 +606,7 @@ int genaRenewSubscription( goto exit_function; } - // remove old events + /* remove old events */ if (TimerThreadRemove( &gTimerThread, GenlibClientSubscription_get_RenewEventId(sub), @@ -635,17 +635,17 @@ int genaRenewSubscription( goto exit_function; } - // we just called GetHandleInfo, so we don't check for return value - //GetHandleInfo(client_handle, &handle_info); + /* we just called GetHandleInfo, so we don't check for return value */ + /*GetHandleInfo(client_handle, &handle_info); */ if (return_code != UPNP_E_SUCCESS) { - // network failure (remove client sub) + /* network failure (remove client sub) */ RemoveClientSubClientSID(&handle_info->ClientSubList, in_sid); free_client_subscription(sub_copy); HandleUnlock(); goto exit_function; } - // get subscription + /* get subscription */ sub = GetClientSubClientSID(handle_info->ClientSubList, in_sid); if (sub == NULL) { free_client_subscription(sub_copy); @@ -654,10 +654,10 @@ int genaRenewSubscription( goto exit_function; } - // store actual sid + /* store actual sid */ GenlibClientSubscription_set_ActualSID(sub, ActualSID); - // start renew subscription timer + /* start renew subscription timer */ return_code = ScheduleGenaAutoRenew(client_handle, *TimeOut, sub); if (return_code != GENA_SUCCESS) { RemoveClientSubClientSID( @@ -693,7 +693,7 @@ void gena_process_notification_event( nts_hdr; memptr seq_hdr; - // get SID + /* get SID */ if (httpmsg_find_hdr(event, HDR_SID, &sid_hdr) == NULL) { error_respond(info, HTTP_PRECONDITION_FAILED, event); goto exit_function; @@ -701,28 +701,28 @@ void gena_process_notification_event( sid.buff = sid_hdr.buf; sid.size = sid_hdr.length; - // get event key + /* get event key */ if (httpmsg_find_hdr(event, HDR_SEQ, &seq_hdr) == NULL || matchstr(seq_hdr.buf, seq_hdr.length, "%d%0", &eventKey) != PARSE_OK) { error_respond( info, HTTP_BAD_REQUEST, event ); goto exit_function; } - // get NT and NTS headers + /* get NT and NTS headers */ if (httpmsg_find_hdr(event, HDR_NT, &nt_hdr) == NULL || httpmsg_find_hdr(event, HDR_NTS, &nts_hdr) == NULL) { error_respond( info, HTTP_BAD_REQUEST, event ); goto exit_function; } - // verify NT and NTS headers + /* verify NT and NTS headers */ if (memptr_cmp(&nt_hdr, "upnp:event") != 0 || memptr_cmp(&nts_hdr, "upnp:propchange") != 0) { error_respond(info, HTTP_PRECONDITION_FAILED, event); goto exit_function; } - // parse the content (should be XML) + /* parse the content (should be XML) */ if (!has_xml_content_type(event) || event->msg.length == 0 || ixmlParseBufferEx(event->entity.buf, &ChangedVars) != IXML_SUCCESS) { @@ -732,28 +732,28 @@ void gena_process_notification_event( HandleLock(); - // get client info + /* get client info */ if (GetClientHandleInfo(&client_handle, &handle_info) != HND_CLIENT) { error_respond(info, HTTP_PRECONDITION_FAILED, event); HandleUnlock(); goto exit_function; } - // get subscription based on SID + /* get subscription based on SID */ subscription = GetClientSubActualSID(handle_info->ClientSubList, &sid); if (subscription == NULL) { if (eventKey == 0) { - // wait until we've finished processing a subscription - // (if we are in the middle) - // this is to avoid mistakenly rejecting the first event if we - // receive it before the subscription response + /* wait until we've finished processing a subscription */ + /* (if we are in the middle) */ + /* this is to avoid mistakenly rejecting the first event if we */ + /* receive it before the subscription response */ HandleUnlock(); - // try and get Subscription Lock - // (in case we are in the process of subscribing) + /* try and get Subscription Lock */ + /* (in case we are in the process of subscribing) */ SubscribeLock(); - // get HandleLock again + /* get HandleLock again */ HandleLock(); if (GetClientHandleInfo(&client_handle, &handle_info) != HND_CLIENT) { @@ -779,24 +779,24 @@ void gena_process_notification_event( } } - // success + /* success */ error_respond(info, HTTP_OK, event); - // fill event struct + /* fill event struct */ UpnpEvent_set_EventKey(event_struct, eventKey); UpnpEvent_set_ChangedVariables(event_struct, ChangedVars); UpnpEvent_set_SID(event_struct, GenlibClientSubscription_get_SID(subscription)); - // copy callback + /* copy callback */ callback = handle_info->Callback; cookie = handle_info->Cookie; HandleUnlock(); - // make callback with event struct - // In future, should find a way of mainting - // that the handle is not unregistered in the middle of a - // callback + /* make callback with event struct */ + /* In future, should find a way of mainting */ + /* that the handle is not unregistered in the middle of a */ + /* callback */ callback(UPNP_EVENT_RECEIVED, event_struct, cookie); exit_function: diff --git a/upnp/src/gena/gena_device.c b/upnp/src/gena/gena_device.c index 0f4af9a..e80a297 100644 --- a/upnp/src/gena/gena_device.c +++ b/upnp/src/gena/gena_device.c @@ -280,7 +280,7 @@ static int genaNotify( membuffer_init( &mid_msg ); - // make 'end' msg (the part that won't vary with the destination) + /* make 'end' msg (the part that won't vary with the destination) */ endmsg.size_inc = 30; if( http_MakeMessage( &mid_msg, 1, 1, @@ -291,7 +291,7 @@ static int genaNotify( membuffer_destroy( &mid_msg ); return UPNP_E_OUTOF_MEMORY; } - // send a notify to each url until one goes thru + /* send a notify to each url until one goes thru */ for( i = 0; i < sub->DeliveryURLs.size; i++ ) { url = &sub->DeliveryURLs.parsedURLs[i]; return_code = notify_send_and_recv( @@ -308,7 +308,7 @@ static int genaNotify( return_code = GENA_SUCCESS; } else { if( response.msg.status_code == HTTP_PRECONDITION_FAILED ) { - //Invalid SID gets removed + /*Invalid SID gets removed */ return_code = GENA_E_NOTIFY_UNACCEPTED_REMOVE_SUB; } else { return_code = GENA_E_NOTIFY_UNACCEPTED; @@ -345,9 +345,9 @@ static void genaNotifyThread( * is a lot of notifications, then multiple threads will acquire a read * lock and the thread which sends the notification will be blocked forever * on the HandleLock at the end of this function. */ - //HandleReadLock(); + /*HandleReadLock(); */ HandleLock(); - //validate context + /*validate context */ if( GetHandleInfo( in->device_handle, &handle_info ) != HND_DEVICE ) { free_notify_struct( in ); @@ -366,7 +366,7 @@ static void genaNotifyThread( } #ifdef UPNP_ENABLE_NOTIFICATION_REORDERING - //If the event is out of order push it back to the job queue + /*If the event is out of order push it back to the job queue */ if( in->eventKey != sub->ToSendEventKey ) { TPJobInit( &job, ( start_routine ) genaNotifyThread, input ); @@ -388,7 +388,7 @@ static void genaNotifyThread( HandleUnlock(); - //send the notify + /*send the notify */ return_code = genaNotify( in->headers, in->propertySet, &sub_copy ); freeSubscription( &sub_copy ); @@ -400,7 +400,7 @@ static void genaNotifyThread( HandleUnlock(); return; } - //validate context + /*validate context */ if( ( ( service = FindServiceId( &handle_info->ServiceTable, in->servId, in->UDN ) ) == NULL ) || ( !service->active ) @@ -412,7 +412,7 @@ static void genaNotifyThread( sub->ToSendEventKey++; - if( sub->ToSendEventKey < 0 ) //wrap to 1 for overflow + if( sub->ToSendEventKey < 0 ) /*wrap to 1 for overflow */ sub->ToSendEventKey = 1; if( return_code == GENA_E_NOTIFY_UNACCEPTED_REMOVE_SUB ) { @@ -1233,20 +1233,20 @@ void gena_process_subscription_request( goto exit_function; } - // check NT header - // Windows Millenium Interoperability: - // we accept either upnp:event, or upnp:propchange for the NT header + /* check NT header */ + /* Windows Millenium Interoperability: */ + /* we accept either upnp:event, or upnp:propchange for the NT header */ if (memptr_cmp_nocase(&nt_hdr, "upnp:event") != 0) { error_respond(info, HTTP_PRECONDITION_FAILED, request); goto exit_function; } - // if a SID is present then the we have a bad request "incompatible headers" + /* if a SID is present then the we have a bad request "incompatible headers" */ if (httpmsg_find_hdr(request, HDR_SID, NULL) != NULL) { error_respond(info, HTTP_BAD_REQUEST, request); goto exit_function; } - // look up service by eventURL + /* look up service by eventURL */ event_url_path = str_alloc(request->uri.pathquery.buff, request->uri.pathquery.size); if (event_url_path == NULL) { error_respond(info, HTTP_INTERNAL_SERVER_ERROR, request); @@ -1259,7 +1259,7 @@ void gena_process_subscription_request( HandleLock(); - // CURRENTLY, ONLY ONE DEVICE + /* CURRENTLY, ONLY ONE DEVICE */ if (GetDeviceHandleInfo(info->foreign_sockaddr.ss_family , &device_handle, &handle_info) != HND_DEVICE) { free(event_url_path); @@ -1282,14 +1282,14 @@ void gena_process_subscription_request( service->TotalSubscriptions, handle_info->MaxSubscriptions); - // too many subscriptions + /* too many subscriptions */ if (handle_info->MaxSubscriptions != -1 && service->TotalSubscriptions >= handle_info->MaxSubscriptions) { error_respond(info, HTTP_INTERNAL_SERVER_ERROR, request); HandleUnlock(); goto exit_function; } - // generate new subscription + /* generate new subscription */ sub = (subscription *)malloc(sizeof (subscription)); if (sub == NULL) { error_respond(info, HTTP_INTERNAL_SERVER_ERROR, request); @@ -1304,7 +1304,7 @@ void gena_process_subscription_request( sub->DeliveryURLs.URLs = NULL; sub->DeliveryURLs.parsedURLs = NULL; - // check for valid callbacks + /* check for valid callbacks */ if (httpmsg_find_hdr( request, HDR_CALLBACK, &callback_hdr) == NULL) { error_respond(info, HTTP_PRECONDITION_FAILED, request); freeSubscriptionList(sub); @@ -1324,20 +1324,20 @@ void gena_process_subscription_request( HandleUnlock(); goto exit_function; } - // set the timeout + /* set the timeout */ if (httpmsg_find_hdr(request, HDR_TIMEOUT, &timeout_hdr) != NULL) { if (matchstr(timeout_hdr.buf, timeout_hdr.length, "%iSecond-%d%0", &time_out) == PARSE_OK) { - // nothing + /* nothing */ } else if(memptr_cmp_nocase(&timeout_hdr, "Second-infinite") == 0) { - // infinite timeout + /* infinite timeout */ time_out = -1; } else { - // default is > 1800 seconds + /* default is > 1800 seconds */ time_out = DEFAULT_TIMEOUT; } } - // replace infinite timeout with max timeout, if possible + /* replace infinite timeout with max timeout, if possible */ if (handle_info->MaxSubscriptionTimeOut != -1) { if (time_out == -1 || time_out > handle_info->MaxSubscriptionTimeOut) { @@ -1347,40 +1347,40 @@ void gena_process_subscription_request( if (time_out >= 0) { sub->expireTime = time(NULL) + time_out; } else { - // infinite time + /* infinite time */ sub->expireTime = 0; } - // generate SID + /* generate SID */ uuid_create(&uid); uuid_unpack(&uid, temp_sid); sprintf(sub->sid, "uuid:%s", temp_sid); - // respond OK + /* respond OK */ if (respond_ok(info, time_out, sub, request) != UPNP_E_SUCCESS) { freeSubscriptionList(sub); HandleUnlock(); goto exit_function; } - // add to subscription list + /* add to subscription list */ sub->next = service->subscriptionList; service->subscriptionList = sub; service->TotalSubscriptions++; - // finally generate callback for init table dump + /* finally generate callback for init table dump */ UpnpSubscriptionRequest_strcpy_ServiceId(request_struct, service->serviceId); UpnpSubscriptionRequest_strcpy_UDN(request_struct, service->UDN); UpnpSubscriptionRequest_strcpy_SID(request_struct, sub->sid); - // copy callback + /* copy callback */ callback_fun = handle_info->Callback; cookie = handle_info->Cookie; HandleUnlock(); - // make call back with request struct - // in the future should find a way of mainting that the handle - // is not unregistered in the middle of a callback + /* make call back with request struct */ + /* in the future should find a way of mainting that the handle */ + /* is not unregistered in the middle of a callback */ callback_fun(UPNP_EVENT_SUBSCRIPTION_REQUEST, request_struct, cookie); exit_function: @@ -1402,13 +1402,13 @@ void gena_process_subscription_renewal_request( membuffer event_url_path; memptr timeout_hdr; - // if a CALLBACK or NT header is present, then it is an error + /* if a CALLBACK or NT header is present, then it is an error */ if( httpmsg_find_hdr( request, HDR_CALLBACK, NULL ) != NULL || httpmsg_find_hdr( request, HDR_NT, NULL ) != NULL ) { error_respond( info, HTTP_BAD_REQUEST, request ); return; } - // get SID + /* get SID */ if( httpmsg_find_hdr( request, HDR_SID, &temp_hdr ) == NULL || temp_hdr.length > SID_SIZE ) { error_respond( info, HTTP_PRECONDITION_FAILED, request ); @@ -1417,7 +1417,7 @@ void gena_process_subscription_renewal_request( memcpy( sid, temp_hdr.buf, temp_hdr.length ); sid[temp_hdr.length] = '\0'; - // lookup service by eventURL + /* lookup service by eventURL */ membuffer_init( &event_url_path ); if( membuffer_append( &event_url_path, request->uri.pathquery.buff, request->uri.pathquery.size ) != 0 ) { @@ -1427,7 +1427,7 @@ void gena_process_subscription_renewal_request( HandleLock(); - // CURRENTLY, ONLY SUPPORT ONE DEVICE + /* CURRENTLY, ONLY SUPPORT ONE DEVICE */ if( GetDeviceHandleInfo( info->foreign_sockaddr.ss_family, &device_handle, &handle_info ) != HND_DEVICE ) { error_respond( info, HTTP_PRECONDITION_FAILED, request ); @@ -1439,7 +1439,7 @@ void gena_process_subscription_renewal_request( event_url_path.buf ); membuffer_destroy( &event_url_path ); - // get subscription + /* get subscription */ if( service == NULL || !service->active || ( ( sub = GetSubscriptionSID( sid, service ) ) == NULL ) ) { @@ -1453,7 +1453,7 @@ void gena_process_subscription_renewal_request( "Max Subscriptions allowed:%d\n", service->TotalSubscriptions, handle_info->MaxSubscriptions ); - // too many subscriptions + /* too many subscriptions */ if( handle_info->MaxSubscriptions != -1 && service->TotalSubscriptions > handle_info->MaxSubscriptions ) { error_respond( info, HTTP_INTERNAL_SERVER_ERROR, request ); @@ -1461,25 +1461,25 @@ void gena_process_subscription_renewal_request( HandleUnlock(); return; } - // set the timeout + /* set the timeout */ if( httpmsg_find_hdr( request, HDR_TIMEOUT, &timeout_hdr ) != NULL ) { if( matchstr( timeout_hdr.buf, timeout_hdr.length, "%iSecond-%d%0", &time_out ) == PARSE_OK ) { - //nothing + /*nothing */ } else if( memptr_cmp_nocase( &timeout_hdr, "Second-infinite" ) == 0 ) { - time_out = -1; // inifinite timeout + time_out = -1; /* inifinite timeout */ } else { - time_out = DEFAULT_TIMEOUT; // default is > 1800 seconds + time_out = DEFAULT_TIMEOUT; /* default is > 1800 seconds */ } } - // replace infinite timeout with max timeout, if possible + /* replace infinite timeout with max timeout, if possible */ if( handle_info->MaxSubscriptionTimeOut != -1 ) { if( time_out == -1 || time_out > handle_info->MaxSubscriptionTimeOut ) { @@ -1513,13 +1513,13 @@ void gena_process_unsubscribe_request( memptr temp_hdr; membuffer event_url_path; - // if a CALLBACK or NT header is present, then it is an error + /* if a CALLBACK or NT header is present, then it is an error */ if( httpmsg_find_hdr( request, HDR_CALLBACK, NULL ) != NULL || httpmsg_find_hdr( request, HDR_NT, NULL ) != NULL ) { error_respond( info, HTTP_BAD_REQUEST, request ); return; } - // get SID + /* get SID */ if( httpmsg_find_hdr( request, HDR_SID, &temp_hdr ) == NULL || temp_hdr.length > SID_SIZE ) { error_respond( info, HTTP_PRECONDITION_FAILED, request ); @@ -1528,7 +1528,7 @@ void gena_process_unsubscribe_request( memcpy( sid, temp_hdr.buf, temp_hdr.length ); sid[temp_hdr.length] = '\0'; - // lookup service by eventURL + /* lookup service by eventURL */ membuffer_init( &event_url_path ); if( membuffer_append( &event_url_path, request->uri.pathquery.buff, request->uri.pathquery.size ) != 0 ) { @@ -1538,7 +1538,7 @@ void gena_process_unsubscribe_request( HandleLock(); - // CURRENTLY, ONLY SUPPORT ONE DEVICE + /* CURRENTLY, ONLY SUPPORT ONE DEVICE */ if( GetDeviceHandleInfo( info->foreign_sockaddr.ss_family, &device_handle, &handle_info ) != HND_DEVICE ) { error_respond( info, HTTP_PRECONDITION_FAILED, request ); @@ -1550,7 +1550,7 @@ void gena_process_unsubscribe_request( event_url_path.buf ); membuffer_destroy( &event_url_path ); - // validate service + /* validate service */ if( service == NULL || !service->active || GetSubscriptionSID( sid, service ) == NULL ) { @@ -1560,7 +1560,7 @@ void gena_process_unsubscribe_request( } RemoveSubscriptionSID(sid, service); - error_respond(info, HTTP_OK, request); // success + error_respond(info, HTTP_OK, request); /* success */ HandleUnlock(); } diff --git a/upnp/src/genlib/client_table/client_table.c b/upnp/src/genlib/client_table/client_table.c index 895fbfe..75fe65b 100644 --- a/upnp/src/genlib/client_table/client_table.c +++ b/upnp/src/genlib/client_table/client_table.c @@ -16,7 +16,7 @@ #ifdef INCLUDE_CLIENT_APIS -#include // for calloc(), free() +#include /* for calloc(), free() */ void free_client_subscription(GenlibClientSubscription *sub) @@ -28,8 +28,8 @@ void free_client_subscription(GenlibClientSubscription *sub) GenlibClientSubscription_strcpy_ActualSID(sub, ""); GenlibClientSubscription_strcpy_EventURL(sub, ""); if (renewEventId != -1) { - // do not remove timer event of copy - // invalid timer event id + /* do not remove timer event of copy */ + /* invalid timer event id */ if (TimerThreadRemove(&gTimerThread, renewEventId, &tempJob) == 0) { event = (upnp_timeout *)tempJob.arg; free_upnp_timeout(event); diff --git a/upnp/src/genlib/net/http/httpparser.c b/upnp/src/genlib/net/http/httpparser.c index 42849c0..8965490 100644 --- a/upnp/src/genlib/net/http/httpparser.c +++ b/upnp/src/genlib/net/http/httpparser.c @@ -37,7 +37,7 @@ */ -#define _GNU_SOURCE // For strcasestr() in string.h +#define _GNU_SOURCE /* For strcasestr() in string.h */ #include "config.h" @@ -205,7 +205,7 @@ static UPNP_INLINE xboolean is_qdtext_char(IN char cc) { unsigned char c = ( unsigned char )cc; - // we don't check for this; it's checked in get_token() + /* we don't check for this; it's checked in get_token() */ assert( c != '"' ); if( ( c >= 32 && c != 127 ) || @@ -241,7 +241,7 @@ static parse_status_t scanner_get_token( OUT token_type_t *tok_type) { char *cursor; - char *null_terminator; // point to null-terminator in buffer + char *null_terminator; /* point to null-terminator in buffer */ char c; token_type_t token_type; xboolean got_end_quote; @@ -250,18 +250,18 @@ static parse_status_t scanner_get_token( assert( token ); assert( tok_type ); - // point to next char in buffer + /* point to next char in buffer */ cursor = scanner->msg->buf + scanner->cursor; null_terminator = scanner->msg->buf + scanner->msg->length; - // not enough chars in input to parse + /* not enough chars in input to parse */ if( cursor == null_terminator ) { return PARSE_INCOMPLETE; } c = *cursor; if( is_identifier_char( c ) ) { - // scan identifier + /* scan identifier */ token->buf = cursor++; token_type = TT_IDENTIFIER; @@ -271,10 +271,10 @@ static parse_status_t scanner_get_token( } if( !scanner->entire_msg_loaded && cursor == null_terminator ) { - // possibly more valid chars + /* possibly more valid chars */ return PARSE_INCOMPLETE; } - // calc token length + /* calc token length */ token->length = cursor - token->buf; } else if( c == ' ' || c == '\t' ) { token->buf = cursor++; @@ -285,35 +285,35 @@ static parse_status_t scanner_get_token( } if( !scanner->entire_msg_loaded && cursor == null_terminator ) { - // possibly more chars + /* possibly more chars */ return PARSE_INCOMPLETE; } token->length = cursor - token->buf; } else if( c == TOKCHAR_CR ) { - // scan CRLF + /* scan CRLF */ token->buf = cursor++; if( cursor == null_terminator ) { - // not enuf info to determine CRLF + /* not enuf info to determine CRLF */ return PARSE_INCOMPLETE; } if( *cursor != TOKCHAR_LF ) { - // couldn't match CRLF; match as CR - token_type = TT_CTRL; // ctrl char + /* couldn't match CRLF; match as CR */ + token_type = TT_CTRL; /* ctrl char */ token->length = 1; } else { - // got CRLF + /* got CRLF */ token->length = 2; token_type = TT_CRLF; cursor++; } - } else if( c == TOKCHAR_LF ) // accept \n as CRLF + } else if( c == TOKCHAR_LF ) /* accept \n as CRLF */ { token->buf = cursor++; token->length = 1; token_type = TT_CRLF; } else if( c == '"' ) { - // quoted text + /* quoted text */ token->buf = cursor++; token_type = TT_QUOTEDSTRING; got_end_quote = FALSE; @@ -326,34 +326,34 @@ static parse_status_t scanner_get_token( } else if( c == '\\' ) { if( cursor < null_terminator ) { c = *cursor++; - //if ( !(c > 0 && c <= 127) ) + /*if ( !(c > 0 && c <= 127) ) */ if( c == 0 ) { return PARSE_FAILURE; } } - // else, while loop handles incomplete buf + /* else, while loop handles incomplete buf */ } else if( is_qdtext_char( c ) ) { - // just accept char + /* just accept char */ } else { - // bad quoted text + /* bad quoted text */ return PARSE_FAILURE; } } if( got_end_quote ) { token->length = cursor - token->buf; - } else // incomplete + } else /* incomplete */ { assert( cursor == null_terminator ); return PARSE_INCOMPLETE; } } else if( is_separator_char( c ) ) { - // scan separator + /* scan separator */ token->buf = cursor++; token_type = TT_SEPARATOR; token->length = 1; } else if( is_control_char( c ) ) { - // scan ctrl char + /* scan ctrl char */ token->buf = cursor++; token_type = TT_CTRL; @@ -362,7 +362,7 @@ static parse_status_t scanner_get_token( return PARSE_FAILURE; } - scanner->cursor += token->length; // move to next token + scanner->cursor += token->length; /* move to next token */ *tok_type = token_type; return PARSE_OK; } @@ -533,7 +533,7 @@ http_header_t *httpmsg_find_hdr( IN int header_name_id, OUT memptr *value) { - http_header_t header; // temp header for searching + http_header_t header; /* temp header for searching */ ListNode *node; http_header_t *data; @@ -609,24 +609,24 @@ static UPNP_INLINE int skip_lws(INOUT scanner_t *scanner) save_pos = scanner->cursor; matched = FALSE; - // get CRLF or WS + /* get CRLF or WS */ status = scanner_get_token( scanner, &token, &tok_type ); if( status == PARSE_OK ) { if( tok_type == TT_CRLF ) { - // get WS + /* get WS */ status = scanner_get_token( scanner, &token, &tok_type ); } if( status == PARSE_OK && tok_type == TT_WHITESPACE ) { matched = TRUE; } else { - // did not match LWS; pushback token(s) + /* did not match LWS; pushback token(s) */ scanner->cursor = save_pos; } } } while( matched ); - // if entire msg is loaded, ignore an 'incomplete' warning + /* if entire msg is loaded, ignore an 'incomplete' warning */ if( status == PARSE_INCOMPLETE && scanner->entire_msg_loaded ) { status = PARSE_OK; } @@ -664,13 +664,13 @@ static UPNP_INLINE parse_status_t match_non_ws_string( save_cursor = scanner->cursor; str->length = 0; - str->buf = scanner_get_str( scanner ); // point to next char in input + str->buf = scanner_get_str( scanner ); /* point to next char in input */ while( !done ) { status = scanner_get_token( scanner, &token, &tok_type ); if( status == PARSE_OK && tok_type != TT_WHITESPACE && tok_type != TT_CRLF ) { - // append non-ws token + /* append non-ws token */ str->length += token.length; } else { done = TRUE; @@ -678,21 +678,21 @@ static UPNP_INLINE parse_status_t match_non_ws_string( } if( status == PARSE_OK ) { - // last token was WS; push it back in + /* last token was WS; push it back in */ scanner->cursor -= token.length; } - // tolerate 'incomplete' msg + /* tolerate 'incomplete' msg */ if( status == PARSE_OK || ( status == PARSE_INCOMPLETE && scanner->entire_msg_loaded ) ) { if( str->length == 0 ) { - // no strings found + /* no strings found */ return PARSE_NO_MATCH; } else { return PARSE_OK; } } else { - // error -- pushback tokens + /* error -- pushback tokens */ scanner->cursor = save_cursor; return status; } @@ -732,7 +732,7 @@ static UPNP_INLINE parse_status_t match_raw_value( save_pos = scanner->cursor; - // value points to start of input + /* value points to start of input */ raw_value->buf = scanner_get_str( scanner ); raw_value->length = 0; @@ -741,47 +741,47 @@ static UPNP_INLINE parse_status_t match_raw_value( if( status == PARSE_OK ) { if( !saw_crlf ) { if( tok_type == TT_CRLF ) { - // CRLF could end value + /* CRLF could end value */ saw_crlf = TRUE; - // save input position at start of CRLF + /* save input position at start of CRLF */ pos_at_crlf = scanner->cursor - token.length; } - // keep appending value + /* keep appending value */ raw_value->length += token.length; - } else // already seen CRLF + } else /* already seen CRLF */ { if( tok_type == TT_WHITESPACE ) { - // start again; forget CRLF + /* start again; forget CRLF */ saw_crlf = FALSE; raw_value->length += token.length; } else { - // non-ws means value ended just before CRLF + /* non-ws means value ended just before CRLF */ done = TRUE; - // point to the crlf which ended the value + /* point to the crlf which ended the value */ scanner->cursor = pos_at_crlf; } } } else { - // some kind of error; restore scanner position + /* some kind of error; restore scanner position */ scanner->cursor = save_pos; done = TRUE; } } if( status == PARSE_OK ) { - // trim whitespace on right side of value + /* trim whitespace on right side of value */ while( raw_value->length > 0 ) { - // get last char + /* get last char */ c = raw_value->buf[raw_value->length - 1]; if( c != ' ' && c != '\t' && c != TOKCHAR_CR && c != TOKCHAR_LF ) { - // done; no more whitespace + /* done; no more whitespace */ break; } - // remove whitespace + /* remove whitespace */ raw_value->length--; } } @@ -829,7 +829,7 @@ static UPNP_INLINE int match_int( num = strtol( token.buf, &end_ptr, base ); if( ( num < 0 ) - // all and only those chars in token should be used for num + /* all and only those chars in token should be used for num */ || ( end_ptr != token.buf + token.length ) || ( ( num == LONG_MIN || num == LONG_MAX ) && ( errno == ERANGE ) ) @@ -837,14 +837,14 @@ static UPNP_INLINE int match_int( status = PARSE_NO_MATCH; } - *value = num; // save result + *value = num; /* save result */ } else { - status = PARSE_NO_MATCH; // token must be an identifier + status = PARSE_NO_MATCH; /* token must be an identifier */ } } if( status != PARSE_OK ) { - // restore scanner position for bad values + /* restore scanner position for bad values */ scanner->cursor = save_pos; } @@ -879,16 +879,16 @@ read_until_crlf( INOUT scanner_t * scanner, start_pos = scanner->cursor; str->buf = scanner_get_str( scanner ); - // read until we hit a crlf + /* read until we hit a crlf */ do { status = scanner_get_token( scanner, &token, &tok_type ); } while( status == PARSE_OK && tok_type != TT_CRLF ); if( status == PARSE_OK ) { - // pushback crlf in stream + /* pushback crlf in stream */ scanner->cursor -= token.length; - // str should include all strings except crlf at the end + /* str should include all strings except crlf at the end */ str->length = scanner->cursor - start_pos; } @@ -922,7 +922,7 @@ match_char( INOUT scanner_t * scanner, if( scanner->cursor >= scanner->msg->length ) { return PARSE_INCOMPLETE; } - // read next char from scanner + /* read next char from scanner */ scan_char = scanner->msg->buf[scanner->cursor++]; if( case_sensitive ) { @@ -933,38 +933,41 @@ match_char( INOUT scanner_t * scanner, } } -//////////////////////////////////////////////////////////////////////// -// args for ... -// %d, int * (31-bit positive integer) -// %x, int * (31-bit postive number encoded as hex) -// %s, memptr* (simple identifier) -// %q, memptr* (quoted string) -// %S, memptr* (non-whitespace string) -// %R, memptr* (raw value) -// %U, uri_type* (url) -// %L, memptr* (string until end of line) -// %P, int * (current index of the string being scanned) -// -// no args for -// ' ' LWS* -// \t whitespace -// "%%" matches '%' -// "% " matches ' ' -// %c matches CRLF -// %i ignore case in literal matching -// %n case-sensitive matching in literals -// %w optional whitespace; (similar to '\t', -// except whitespace is optional) -// %0 (zero) match null-terminator char '\0' -// (can only be used as last char in fmt) -// use only in matchstr(), not match() -// other chars match literally -// -// returns: -// PARSE_OK -// PARSE_INCOMPLETE -// PARSE_FAILURE -- bad input -// PARSE_NO_MATCH -- input does not match pattern +/* + * + * + * args for ... + * %d, int * (31-bit positive integer) + * %x, int * (31-bit postive number encoded as hex) + * %s, memptr* (simple identifier) + * %q, memptr* (quoted string) + * %S, memptr* (non-whitespace string) + * %R, memptr* (raw value) + * %U, uri_type* (url) + * %L, memptr* (string until end of line) + * %P, int * (current index of the string being scanned) + * + * no args for + * ' ' LWS* + * \t whitespace + * "%%" matches '%' + * "% " matches ' ' + * %c matches CRLF + * %i ignore case in literal matching + * %n case-sensitive matching in literals + * %w optional whitespace; (similar to '\t', + * except whitespace is optional) + * %0 (zero) match null-terminator char '\0' + * (can only be used as last char in fmt) + * use only in matchstr(), not match() + * other chars match literally + * + * returns: + * PARSE_OK + * PARSE_INCOMPLETE + * PARSE_FAILURE -- bad input + * PARSE_NO_MATCH -- input does not match pattern + */ /************************************************************************ * Function : vfmatch @@ -1008,7 +1011,7 @@ vfmatch( INOUT scanner_t * scanner, assert( scanner != NULL ); assert( fmt != NULL ); - // save scanner pos; to aid error recovery + /* save scanner pos; to aid error recovery */ save_pos = scanner->cursor; status = PARSE_OK; @@ -1019,34 +1022,34 @@ vfmatch( INOUT scanner_t * scanner, switch ( c ) { - case 'R': // raw value + case 'R': /* raw value */ str_ptr = va_arg( argp, memptr * ); assert( str_ptr != NULL ); status = match_raw_value( scanner, str_ptr ); break; - case 's': // simple identifier + case 's': /* simple identifier */ str_ptr = va_arg( argp, memptr * ); assert( str_ptr != NULL ); status = scanner_get_token( scanner, str_ptr, &tok_type ); if( status == PARSE_OK && tok_type != TT_IDENTIFIER ) { - // not an identifier + /* not an identifier */ status = PARSE_NO_MATCH; } break; - case 'c': // crlf + case 'c': /* crlf */ status = scanner_get_token( scanner, &token, &tok_type ); if( status == PARSE_OK && tok_type != TT_CRLF ) { - // not CRLF token + /* not CRLF token */ status = PARSE_NO_MATCH; } break; - case 'd': // integer - case 'x': // hex number + case 'd': /* integer */ + case 'x': /* hex number */ int_ptr = va_arg( argp, int * ); assert( int_ptr != NULL ); @@ -1054,8 +1057,8 @@ vfmatch( INOUT scanner_t * scanner, status = match_int( scanner, base, int_ptr ); break; - case 'S': // non-whitespace string - case 'U': // uri + case 'S': /* non-whitespace string */ + case 'U': /* uri */ if( c == 'S' ) { str_ptr = va_arg( argp, memptr * ); } else { @@ -1074,53 +1077,53 @@ vfmatch( INOUT scanner_t * scanner, } break; - case 'L': // string till eol + case 'L': /* string till eol */ str_ptr = va_arg( argp, memptr * ); assert( str_ptr != NULL ); status = read_until_crlf( scanner, str_ptr ); break; - case ' ': // match space - case '%': // match percentage symbol + case ' ': /* match space */ + case '%': /* match percentage symbol */ status = match_char( scanner, c, case_sensitive ); break; - case 'n': // case-sensitive match + case 'n': /* case-sensitive match */ case_sensitive = TRUE; break; - case 'i': // ignore case + case 'i': /* ignore case */ case_sensitive = FALSE; break; - case 'q': // quoted string + case 'q': /* quoted string */ str_ptr = ( memptr * ) va_arg( argp, memptr * ); status = scanner_get_token( scanner, str_ptr, &tok_type ); if( status == PARSE_OK && tok_type != TT_QUOTEDSTRING ) { - status = PARSE_NO_MATCH; // not a quoted string + status = PARSE_NO_MATCH; /* not a quoted string */ } break; - case 'w': // optional whitespace + case 'w': /* optional whitespace */ status = scanner_get_token( scanner, &token, &tok_type ); if( status == PARSE_OK && tok_type != TT_WHITESPACE ) { - // restore non-whitespace token + /* restore non-whitespace token */ scanner->cursor -= token.length; } break; - case 'P': // current pos of scanner + case 'P': /* current pos of scanner */ int_ptr = va_arg( argp, int * ); assert( int_ptr != NULL ); *int_ptr = scanner->cursor; break; - // valid only in matchstr() - case '0': // end of msg? - // check that we are 1 beyond last char + /* valid only in matchstr() */ + case '0': /* end of msg? */ + /* check that we are 1 beyond last char */ if( scanner->cursor == scanner->msg->length && scanner->msg->buf[scanner->cursor] == '\0' ) { status = PARSE_OK; @@ -1130,24 +1133,24 @@ vfmatch( INOUT scanner_t * scanner, break; default: - assert( 0 ); // unknown option + assert( 0 ); /* unknown option */ } } else { switch ( c ) { - case ' ': // LWS* + case ' ': /* LWS* */ status = skip_lws( scanner ); break; - case '\t': // Whitespace + case '\t': /* Whitespace */ status = scanner_get_token( scanner, &token, &tok_type ); if( status == PARSE_OK && tok_type != TT_WHITESPACE ) { - // not whitespace token + /* not whitespace token */ status = PARSE_NO_MATCH; } break; - default: // match characters + default: /* match characters */ { status = match_char( scanner, c, case_sensitive ); } @@ -1156,7 +1159,7 @@ vfmatch( INOUT scanner_t * scanner, } if( status != PARSE_OK ) { - // on error, restore original scanner pos + /* on error, restore original scanner pos */ scanner->cursor = save_pos; } @@ -1223,14 +1226,14 @@ matchstr( IN char *str, membuffer buf; va_list arg_list; - // null terminate str + /* null terminate str */ save_char = str[slen]; str[slen] = '\0'; membuffer_init( &buf ); - // under no circumstances should this buffer be modifed because its memory - // might have not come from malloc() + /* under no circumstances should this buffer be modifed because its memory */ + /* might have not come from malloc() */ membuffer_attach( &buf, str, slen ); scanner_init( &scanner, &buf ); @@ -1240,10 +1243,10 @@ matchstr( IN char *str, ret_code = vfmatch( &scanner, fmt, arg_list ); va_end( arg_list ); - // restore str + /* restore str */ str[slen] = save_char; - // don't destroy buf + /* don't destroy buf */ return ret_code; } @@ -1264,7 +1267,7 @@ parser_init( OUT http_parser_t * parser ) { memset( parser, 0, sizeof( http_parser_t ) ); - parser->http_error_code = HTTP_BAD_REQUEST; // err msg by default + parser->http_error_code = HTTP_BAD_REQUEST; /* err msg by default */ parser->ent_position = ENTREAD_DETERMINE_READ_METHOD; parser->valid_ssdp_notify_hack = FALSE; @@ -1303,7 +1306,7 @@ parser_parse_requestline( INOUT http_parser_t * parser ) if( status != PARSE_OK ) { return status; } - //simple get http 0.9 as described in http 1.0 spec + /*simple get http 0.9 as described in http 1.0 spec */ status = match( &parser->scanner, "%s\t%S%w%c", &method_str, &url_str ); @@ -1315,7 +1318,7 @@ parser_parse_requestline( INOUT http_parser_t * parser ) Http_Method_Table, NUM_HTTP_METHODS, TRUE ); if( index < 0 ) { - // error; method not found + /* error; method not found */ parser->http_error_code = HTTP_NOT_IMPLEMENTED; return PARSE_FAILURE; } @@ -1327,10 +1330,10 @@ parser_parse_requestline( INOUT http_parser_t * parser ) hmsg->method = HTTPMETHOD_SIMPLEGET; - // store url + /* store url */ hmsg->urlbuf = str_alloc( url_str.buf, url_str.length ); if( hmsg->urlbuf == NULL ) { - // out of mem + /* out of mem */ parser->http_error_code = HTTP_INTERNAL_SERVER_ERROR; return PARSE_FAILURE; } @@ -1339,7 +1342,7 @@ parser_parse_requestline( INOUT http_parser_t * parser ) return PARSE_FAILURE; } - parser->position = POS_COMPLETE; // move to headers + parser->position = POS_COMPLETE; /* move to headers */ return PARSE_SUCCESS; } @@ -1350,10 +1353,10 @@ parser_parse_requestline( INOUT http_parser_t * parser ) if( status != PARSE_OK ) { return status; } - // store url + /* store url */ hmsg->urlbuf = str_alloc( url_str.buf, url_str.length ); if( hmsg->urlbuf == NULL ) { - // out of mem + /* out of mem */ parser->http_error_code = HTTP_INTERNAL_SERVER_ERROR; return PARSE_FAILURE; } @@ -1361,15 +1364,15 @@ parser_parse_requestline( INOUT http_parser_t * parser ) HTTP_SUCCESS ) { return PARSE_FAILURE; } - // scan version + /* scan version */ save_char = version_str.buf[version_str.length]; - version_str.buf[version_str.length] = '\0'; // null-terminate + version_str.buf[version_str.length] = '\0'; /* null-terminate */ num_scanned = sscanf( version_str.buf, "%d . %d", &hmsg->major_version, &hmsg->minor_version ); - version_str.buf[version_str.length] = save_char; // restore + version_str.buf[version_str.length] = save_char; /* restore */ if( num_scanned != 2 || hmsg->major_version < 0 || hmsg->minor_version < 0 ) { - // error; bad http version + /* error; bad http version */ return PARSE_FAILURE; } @@ -1377,13 +1380,13 @@ parser_parse_requestline( INOUT http_parser_t * parser ) map_str_to_int( method_str.buf, method_str.length, Http_Method_Table, NUM_HTTP_METHODS, TRUE ); if( index < 0 ) { - // error; method not found + /* error; method not found */ parser->http_error_code = HTTP_NOT_IMPLEMENTED; return PARSE_FAILURE; } hmsg->method = Http_Method_Table[index].id; - parser->position = POS_HEADERS; // move to headers + parser->position = POS_HEADERS; /* move to headers */ return PARSE_OK; } @@ -1418,10 +1421,10 @@ parser_parse_responseline( INOUT http_parser_t * parser ) if( status != PARSE_OK ) { return status; } - // response line - //status = match( &parser->scanner, "%ihttp%w/%w%d\t.\t%d\t%d\t%L%c", - // &hmsg->major_version, &hmsg->minor_version, - // &hmsg->status_code, &hmsg->status_msg ); + /* response line */ + /*status = match( &parser->scanner, "%ihttp%w/%w%d\t.\t%d\t%d\t%L%c", */ + /* &hmsg->major_version, &hmsg->minor_version, */ + /* &hmsg->status_code, &hmsg->status_msg ); */ status = match( &parser->scanner, "%ihttp%w/%w%L%c", &line ); if( status != PARSE_OK ) { @@ -1429,60 +1432,60 @@ parser_parse_responseline( INOUT http_parser_t * parser ) } save_char = line.buf[line.length]; - line.buf[line.length] = '\0'; // null-terminate + line.buf[line.length] = '\0'; /* null-terminate */ - // scan http version and ret code + /* scan http version and ret code */ num_scanned = sscanf( line.buf, "%d . %d %d", &hmsg->major_version, &hmsg->minor_version, &hmsg->status_code ); - line.buf[line.length] = save_char; // restore + line.buf[line.length] = save_char; /* restore */ if( num_scanned != 3 || hmsg->major_version < 0 || /* HTTP version equals to 1.0 should fail as required by the * UPnP certification tool */ hmsg->minor_version < 1 || hmsg->status_code < 0 ) { - // bad response line + /* bad response line */ return PARSE_FAILURE; } - // - // point to status msg - // + /* */ + /* point to status msg */ + /* */ p = line.buf; - // skip 3 ints + /* skip 3 ints */ for( i = 0; i < 3; i++ ) { - // go to start of num + /* go to start of num */ while( !isdigit( *p ) ) { p++; } - // skip int + /* skip int */ while( isdigit( *p ) ) { p++; } } - // whitespace must exist after status code + /* whitespace must exist after status code */ if( *p != ' ' && *p != '\t' ) { return PARSE_FAILURE; } - // skip whitespace + /* skip whitespace */ while( *p == ' ' || *p == '\t' ) { p++; } - // now, p is at start of status msg + /* now, p is at start of status msg */ if( membuffer_assign( &hmsg->status_msg, p, line.length - ( p - line.buf ) ) != 0 ) { - // out of mem + /* out of mem */ parser->http_error_code = HTTP_INTERNAL_SERVER_ERROR; return PARSE_FAILURE; } - parser->position = POS_HEADERS; // move to headers + parser->position = POS_HEADERS; /* move to headers */ return PARSE_OK; } @@ -1523,9 +1526,9 @@ parser_parse_headers( INOUT http_parser_t * parser ) while( TRUE ) { save_pos = scanner->cursor; - // - // check end of headers - // + /* */ + /* check end of headers */ + /* */ status = scanner_get_token( scanner, &token, &tok_type ); if( status != PARSE_OK ) { return status; @@ -1533,40 +1536,40 @@ parser_parse_headers( INOUT http_parser_t * parser ) if( tok_type == TT_CRLF ) { - // end of headers + /* end of headers */ if( ( parser->msg.is_request ) && ( parser->msg.method == HTTPMETHOD_POST ) ) { - parser->position = POS_COMPLETE; //post entity parsing - //is handled separately + parser->position = POS_COMPLETE; /*post entity parsing */ + /*is handled separately */ return PARSE_SUCCESS; } - parser->position = POS_ENTITY; // read entity next + parser->position = POS_ENTITY; /* read entity next */ return PARSE_OK; } - // - // not end; read header - // + /* */ + /* not end; read header */ + /* */ if( tok_type != TT_IDENTIFIER ) { - return PARSE_FAILURE; // didn't see header name + return PARSE_FAILURE; /* didn't see header name */ } status = match( scanner, " : %R%c", &hdr_value ); if( status != PARSE_OK ) { - // pushback tokens; useful only on INCOMPLETE error + /* pushback tokens; useful only on INCOMPLETE error */ scanner->cursor = save_pos; return status; } - // - // add header - // + /* */ + /* add header */ + /* */ - // find header + /* find header */ index = map_str_to_int( token.buf, token.length, Http_Header_Names, NUM_HTTP_HEADER_NAMES, FALSE ); if( index != -1 ) { - //Check if it is a soap header + /*Check if it is a soap header */ if( Http_Header_Names[index].id == HDR_SOAPACTION ) { parser->msg.method = SOAPMETHOD_POST; } @@ -1582,13 +1585,13 @@ parser_parse_headers( INOUT http_parser_t * parser ) orig_header = httpmsg_find_hdr_str( &parser->msg, token.buf ); - token.buf[token.length] = save_char; // restore + token.buf[token.length] = save_char; /* restore */ } if( orig_header == NULL ) { - // - // add new header - // + /* */ + /* add new header */ + /* */ header = ( http_header_t * ) malloc( sizeof( http_header_t ) ); if( header == NULL ) { @@ -1598,17 +1601,17 @@ parser_parse_headers( INOUT http_parser_t * parser ) membuffer_init( &header->name_buf ); membuffer_init( &header->value ); - // value can be 0 length + /* value can be 0 length */ if( hdr_value.length == 0 ) { hdr_value.buf = "\0"; hdr_value.length = 1; } - // save in header in buffers + /* save in header in buffers */ if( membuffer_assign ( &header->name_buf, token.buf, token.length ) != 0 || membuffer_assign( &header->value, hdr_value.buf, hdr_value.length ) != 0 ) { - // not enuf mem + /* not enuf mem */ free (header); parser->http_error_code = HTTP_INTERNAL_SERVER_ERROR; return PARSE_FAILURE; @@ -1620,7 +1623,7 @@ parser_parse_headers( INOUT http_parser_t * parser ) ListAddTail( &parser->msg.headers, header ); - //NNS: ret = dlist_append( &parser->msg.headers, header ); + /*NNS: ret = dlist_append( &parser->msg.headers, header ); */ /** TODO: remove that? */ if( ret == UPNP_E_OUTOF_MEMORY ) { parser->http_error_code = HTTP_INTERNAL_SERVER_ERROR; @@ -1628,24 +1631,24 @@ parser_parse_headers( INOUT http_parser_t * parser ) } /** end of remove that? */ } else if( hdr_value.length > 0 ) { - // - // append value to existing header - // + /* */ + /* append value to existing header */ + /* */ - // append space + /* append space */ ret = membuffer_append_str( &orig_header->value, ", " ); - // append continuation of header value + /* append continuation of header value */ ret2 = membuffer_append( &orig_header->value, hdr_value.buf, hdr_value.length ); if( ret == UPNP_E_OUTOF_MEMORY || ret2 == UPNP_E_OUTOF_MEMORY ) { - // not enuf mem + /* not enuf mem */ parser->http_error_code = HTTP_INTERNAL_SERVER_ERROR; return PARSE_FAILURE; } } - } // end while + } /* end while */ } @@ -1665,33 +1668,33 @@ parser_parse_headers( INOUT http_parser_t * parser ) static UPNP_INLINE parse_status_t parser_parse_entity_using_clen( INOUT http_parser_t * parser ) { - //int entity_length; + /*int entity_length; */ assert( parser->ent_position == ENTREAD_USING_CLEN ); - // determine entity (i.e. body) length so far + /* determine entity (i.e. body) length so far */ parser->msg.entity.length = parser->msg.msg.length - parser->entity_start_position + parser->msg.entity_offset; if( parser->msg.entity.length < parser->content_length ) { - // more data to be read + /* more data to be read */ return PARSE_INCOMPLETE; } else { if( parser->msg.entity.length > parser->content_length ) { - // silently discard extra data + /* silently discard extra data */ parser->msg.msg.buf[parser->entity_start_position - parser->msg.entity_offset + parser->content_length] = '\0'; } - // save entity length + /* save entity length */ parser->msg.entity.length = parser->content_length; - // save entity start ptr; (the very last thing to do) + /* save entity start ptr; (the very last thing to do) */ parser->msg.entity.buf = parser->msg.msg.buf + parser->entity_start_position; - // done reading entity + /* done reading entity */ parser->position = POS_COMPLETE; return PARSE_SUCCESS; } @@ -1716,29 +1719,29 @@ parser_parse_chunky_body( INOUT http_parser_t * parser ) parse_status_t status; size_t save_pos; - // if 'chunk_size' of bytes have been read; read next chunk + /* if 'chunk_size' of bytes have been read; read next chunk */ if( ( int )( parser->msg.msg.length - parser->scanner.cursor ) >= parser->chunk_size ) { - // move to next chunk + /* move to next chunk */ parser->scanner.cursor += parser->chunk_size; save_pos = parser->scanner.cursor; - //discard CRLF + /*discard CRLF */ status = match( &parser->scanner, "%c" ); if( status != PARSE_OK ) { - parser->scanner.cursor -= parser->chunk_size; //move back - //parser->scanner.cursor = save_pos; + parser->scanner.cursor -= parser->chunk_size; /*move back */ + /*parser->scanner.cursor = save_pos; */ return status; } membuffer_delete( &parser->msg.msg, save_pos, ( parser->scanner.cursor - save_pos ) ); parser->scanner.cursor = save_pos; - parser->msg.entity.length += parser->chunk_size; //update temp + parser->msg.entity.length += parser->chunk_size; /*update temp */ parser->ent_position = ENTREAD_USING_CHUNKED; return PARSE_CONTINUE_1; } else { - return PARSE_INCOMPLETE; // need more data for chunk + return PARSE_INCOMPLETE; /* need more data for chunk */ } } @@ -1764,10 +1767,10 @@ parser_parse_chunky_headers( INOUT http_parser_t * parser ) save_pos = parser->scanner.cursor; status = parser_parse_headers( parser ); if( status == PARSE_OK ) { - // finally, done with the whole msg + /* finally, done with the whole msg */ parser->position = POS_COMPLETE; - // save entity start ptr as the very last thing to do + /* save entity start ptr as the very last thing to do */ parser->msg.entity.buf = parser->msg.msg.buf + parser->entity_start_position; @@ -1807,7 +1810,7 @@ parser_parse_chunky_entity( INOUT http_parser_t * parser ) save_pos = scanner->cursor; - // get size of chunk, discard extension, discard CRLF + /* get size of chunk, discard extension, discard CRLF */ status = match( scanner, "%x%L%c", &parser->chunk_size, &dummy ); if( status != PARSE_OK ) { scanner->cursor = save_pos; @@ -1815,24 +1818,24 @@ parser_parse_chunky_entity( INOUT http_parser_t * parser ) "CHUNK COULD NOT BE PARSED\n" ); return status; } - // remove chunk info just matched; just retain data + /* remove chunk info just matched; just retain data */ membuffer_delete( &parser->msg.msg, save_pos, ( scanner->cursor - save_pos ) ); - scanner->cursor = save_pos; // adjust scanner too + scanner->cursor = save_pos; /* adjust scanner too */ if( parser->chunk_size == 0 ) { - // done reading entity; determine length of entity + /* done reading entity; determine length of entity */ parser->msg.entity.length = parser->scanner.cursor - parser->entity_start_position; - // read entity headers + /* read entity headers */ parser->ent_position = ENTREAD_CHUNKY_HEADERS; } else { - // read chunk body + /* read chunk body */ parser->ent_position = ENTREAD_CHUNKY_BODY; } - return PARSE_CONTINUE_1; // continue to reading body + return PARSE_CONTINUE_1; /* continue to reading body */ } /************************************************************************ @@ -1853,19 +1856,19 @@ parser_parse_entity_until_close( INOUT http_parser_t * parser ) assert( parser->ent_position == ENTREAD_UNTIL_CLOSE ); - // eat any and all data + /* eat any and all data */ cursor = parser->msg.msg.length; - // update entity length + /* update entity length */ parser->msg.entity.length = cursor - parser->entity_start_position; - // update pointer + /* update pointer */ parser->msg.entity.buf = parser->msg.msg.buf + parser->entity_start_position; parser->scanner.cursor = cursor; - return PARSE_INCOMPLETE_ENTITY; // add anything + return PARSE_INCOMPLETE_ENTITY; /* add anything */ } /************************************************************************ @@ -1890,34 +1893,34 @@ parser_get_entity_read_method( INOUT http_parser_t * parser ) assert( parser->ent_position == ENTREAD_DETERMINE_READ_METHOD ); - // entity points to start of msg body + /* entity points to start of msg body */ parser->msg.entity.buf = scanner_get_str( &parser->scanner ); parser->msg.entity.length = 0; - // remember start of body + /* remember start of body */ parser->entity_start_position = parser->scanner.cursor; - // std http rules for determining content length + /* std http rules for determining content length */ - // * no body for 1xx, 204, 304 and HEAD, GET, - // SUBSCRIBE, UNSUBSCRIBE + /* * no body for 1xx, 204, 304 and HEAD, GET, */ + /* SUBSCRIBE, UNSUBSCRIBE */ if( hmsg->is_request ) { switch ( hmsg->method ) { case HTTPMETHOD_HEAD: case HTTPMETHOD_GET: - //case HTTPMETHOD_POST: + /*case HTTPMETHOD_POST: */ case HTTPMETHOD_SUBSCRIBE: case HTTPMETHOD_UNSUBSCRIBE: case HTTPMETHOD_MSEARCH: - // no body; mark as done + /* no body; mark as done */ parser->position = POS_COMPLETE; return PARSE_SUCCESS; break; default: - ; // do nothing + ; /* do nothing */ } - } else // response + } else /* response */ { response_code = hmsg->status_code; @@ -1934,10 +1937,10 @@ parser_get_entity_read_method( INOUT http_parser_t * parser ) } } - // * transfer-encoding -- used to indicate chunked data + /* * transfer-encoding -- used to indicate chunked data */ if( httpmsg_find_hdr( hmsg, HDR_TRANSFER_ENCODING, &hdr_value ) ) { if( raw_find_str( &hdr_value, "chunked" ) >= 0 ) { - // read method to use chunked transfer encoding + /* read method to use chunked transfer encoding */ parser->ent_position = ENTREAD_USING_CHUNKED; UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__, "Found Chunked Encoding ....\n" ); @@ -1945,22 +1948,22 @@ parser_get_entity_read_method( INOUT http_parser_t * parser ) return PARSE_CONTINUE_1; } } - // * use content length + /* * use content length */ if( httpmsg_find_hdr( hmsg, HDR_CONTENT_LENGTH, &hdr_value ) ) { parser->content_length = raw_to_int( &hdr_value, 10 ); if( parser->content_length < 0 ) { - // bad content-length + /* bad content-length */ return PARSE_FAILURE; } parser->ent_position = ENTREAD_USING_CLEN; return PARSE_CONTINUE_1; } - // * multi-part/byteranges not supported (yet) + /* * multi-part/byteranges not supported (yet) */ - // * read until connection is closed + /* * read until connection is closed */ if( hmsg->is_request ) { - // set hack flag for NOTIFY methods; if set to true this is - // a valid SSDP notify msg + /* set hack flag for NOTIFY methods; if set to true this is */ + /* a valid SSDP notify msg */ if( hmsg->method == HTTPMETHOD_NOTIFY ) { parser->valid_ssdp_notify_hack = TRUE; } @@ -2087,8 +2090,8 @@ parser_parse( INOUT http_parser_t * parser ) { parse_status_t status; - //takes an http_parser_t with memory already allocated - //in the message + /*takes an http_parser_t with memory already allocated */ + /*in the message */ assert( parser != NULL ); do { @@ -2151,10 +2154,10 @@ parser_append( INOUT http_parser_t * parser, assert( parser != NULL ); assert( buf != NULL ); - // append data to buffer + /* append data to buffer */ ret_code = membuffer_append( &parser->msg.msg, buf, buf_length ); if( ret_code != 0 ) { - // set failure status + /* set failure status */ parser->http_error_code = HTTP_INTERNAL_SERVER_ERROR; return PARSE_FAILURE; } @@ -2186,7 +2189,7 @@ int raw_to_int(IN memptr *raw_value, IN int base) errno = 0; num = strtol( raw_value->buf, &end_ptr, base ); if( ( num < 0 ) - // all and only those chars in token should be used for num + /* all and only those chars in token should be used for num */ || ( end_ptr != raw_value->buf + raw_value->length ) || ( ( num == LONG_MIN || num == LONG_MAX ) && ( errno == ERANGE ) ) @@ -2217,28 +2220,28 @@ int raw_find_str(IN memptr *raw_value, IN const char *str) char *ptr; int i = 0; - // save + /* save */ c = raw_value->buf[raw_value->length]; - // Make it lowercase + /* Make it lowercase */ for (i = 0; raw_value->buf[i]; ++i) { raw_value->buf[i] = tolower(raw_value->buf[i]); } - // null-terminate + /* null-terminate */ raw_value->buf[raw_value->length] = 0; - // Find the substring position + /* Find the substring position */ ptr = strstr( raw_value->buf, str ); - // restore the "length" byte + /* restore the "length" byte */ raw_value->buf[raw_value->length] = c; if( ptr == 0 ) { return -1; } - // return index + /* return index */ return ptr - raw_value->buf; } diff --git a/upnp/src/genlib/net/http/httpreadwrite.c b/upnp/src/genlib/net/http/httpreadwrite.c index 93e29ef..69b4f40 100644 --- a/upnp/src/genlib/net/http/httpreadwrite.c +++ b/upnp/src/genlib/net/http/httpreadwrite.c @@ -394,7 +394,7 @@ int http_RecvMessage( while (TRUE) { num_read = sock_read(info, buf, sizeof buf, timeout_secs); if (num_read > 0) { - // got data + /* got data */ status = parser_append(parser, buf, num_read); if (status == PARSE_SUCCESS) { UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__, @@ -416,10 +416,10 @@ int http_RecvMessage( ret = UPNP_E_BAD_HTTPMSG; goto ExitFunction; } else if (status == PARSE_INCOMPLETE_ENTITY) { - // read until close + /* read until close */ ok_on_close = TRUE; } else if (status == PARSE_CONTINUE_1) { - // Web post request. + /* Web post request. */ line = __LINE__; ret = PARSE_SUCCESS; goto ExitFunction; @@ -434,8 +434,8 @@ int http_RecvMessage( ret = 0; goto ExitFunction; } else { - // partial msg - *http_error_code = HTTP_BAD_REQUEST; // or response + /* partial msg */ + *http_error_code = HTTP_BAD_REQUEST; /* or response */ line = __LINE__; ret = UPNP_E_BAD_HTTPMSG; goto ExitFunction; @@ -478,8 +478,8 @@ ExitFunction: * char *buf = "POST /xyz.cgi http/1.1\r\n\r\n"; * char *filename = "foo.dat"; * int status = http_SendMessage( tcpsock, "mf", - * buf, strlen(buf), // args for memory buffer - * filename ); // arg for file + * buf, strlen(buf), + * filename ); * * Returns: * UPNP_E_OUTOF_MEMORY @@ -507,7 +507,7 @@ http_SendMessage( IN SOCKINFO * info, char Chunk_Header[CHUNK_HEADER_SIZE]; int RetVal = 0; - // 10 byte allocated for chunk header. + /* 10 byte allocated for chunk header. */ int Data_Buf_Size = WEB_SERVER_BUF_SIZE; va_start( argp, fmt ); @@ -536,7 +536,7 @@ http_SendMessage( IN SOCKINFO * info, file_buf = ChunkBuf + CHUNK_HEADER_SIZE; } else if( c == 'f' ) { - // file name + /* file name */ filename = va_arg(argp, char *); if( Instr && Instr->IsVirtualFile ) { Fp = (virtualDirCallback.open)( filename, UPNP_READ ); @@ -572,7 +572,7 @@ http_SendMessage( IN SOCKINFO * info, } amount_to_be_read = amount_to_be_read - num_read; if( Instr->ReadSendSize < 0 ) { - // read until close + /* read until close */ amount_to_be_read = Data_Buf_Size; } } else { @@ -580,7 +580,7 @@ http_SendMessage( IN SOCKINFO * info, } if( num_read == 0 ) { - // EOF so no more to send. + /* EOF so no more to send. */ if( Instr && Instr->IsChunkActive ) { char *str = "0\r\n\r\n"; num_written = sock_write(info, str, strlen(str), TimeOut); @@ -589,45 +589,45 @@ http_SendMessage( IN SOCKINFO * info, } goto Cleanup_File; } - // Create chunk for the current buffer. + /* Create chunk for the current buffer. */ if( Instr && Instr->IsChunkActive ) { - // Copy CRLF at the end of the chunk + /* Copy CRLF at the end of the chunk */ memcpy( file_buf + num_read, "\r\n", 2 ); - // Hex length for the chunk size. + /* Hex length for the chunk size. */ sprintf( Chunk_Header, "%x", num_read ); - //itoa(num_read,Chunk_Header,16); + /*itoa(num_read,Chunk_Header,16); */ strcat( Chunk_Header, "\r\n" ); - // Copy the chunk size header + /* Copy the chunk size header */ memcpy( file_buf - strlen( Chunk_Header ), Chunk_Header, strlen( Chunk_Header ) ); - // on the top of the buffer. - //file_buf[num_read+strlen(Chunk_Header)] = NULL; - //printf("Sending %s\n",file_buf-strlen(Chunk_Header)); + /* on the top of the buffer. */ + /*file_buf[num_read+strlen(Chunk_Header)] = NULL; */ + /*printf("Sending %s\n",file_buf-strlen(Chunk_Header)); */ num_written = sock_write( info, file_buf - strlen( Chunk_Header ), num_read + strlen( Chunk_Header ) + 2, TimeOut ); if( num_written != num_read + ( int )strlen( Chunk_Header ) + 2 ) { - // Send error nothing we can do. + /* Send error nothing we can do. */ goto Cleanup_File; } } else { - // write data + /* write data */ num_written = sock_write( info, file_buf, num_read, TimeOut ); UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__, ">>> (SENT) >>>\n%.*s\n------------\n", ( int )num_written, file_buf ); - // Send error nothing we can do + /* Send error nothing we can do */ if( num_written != num_read ) { goto Cleanup_File; } } - } // while + } /* while */ Cleanup_File: va_end( argp ); if( Instr && Instr->IsVirtualFile ) { @@ -639,7 +639,7 @@ Cleanup_File: return RetVal; } else if( c == 'b' ) { - // memory buffer + /* memory buffer */ buf = va_arg(argp, char *); buf_length = va_arg(argp, size_t); if( buf_length > 0 ) { @@ -779,7 +779,7 @@ http_Download( IN const char *url_str, membuffer request; char *urlPath = alloca( strlen( url_str ) + 1 ); - //ret_code = parse_uri( (char*)url_str, strlen(url_str), &url ); + /*ret_code = parse_uri( (char*)url_str, strlen(url_str), &url ); */ UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__, "DOWNLOAD URL : %s\n", url_str ); ret_code = @@ -787,7 +787,7 @@ http_Download( IN const char *url_str, if( ret_code != UPNP_E_SUCCESS ) { return ret_code; } - // make msg + /* make msg */ membuffer_init( &request ); strcpy( urlPath, url_str ); @@ -824,7 +824,7 @@ http_Download( IN const char *url_str, UpnpPrintf(UPNP_INFO, HTTP, __FILE__, __LINE__, "HTTP Buffer:\n%s\n" "----------END--------\n", request.buf); - // get doc msg + /* get doc msg */ ret_code = http_RequestAndResponse( &url, request.buf, request.length, HTTPMETHOD_GET, timeout_secs, &response ); @@ -838,13 +838,13 @@ http_Download( IN const char *url_str, UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__, "Response\n" ); print_http_headers( &response.msg ); - // optional content-type + /* optional content-type */ if( content_type ) { if( httpmsg_find_hdr( &response.msg, HDR_CONTENT_TYPE, &ctype ) == NULL ) { - *content_type = '\0'; // no content-type + *content_type = '\0'; /* no content-type */ } else { - // safety + /* safety */ copy_len = ctype.length < LINE_SIZE - 1 ? ctype.length : LINE_SIZE - 1; @@ -852,36 +852,36 @@ http_Download( IN const char *url_str, content_type[copy_len] = '\0'; } } - // - // extract doc from msg - // + /* */ + /* extract doc from msg */ + /* */ if( ( *doc_length = ( int )response.msg.entity.length ) == 0 ) { - // 0-length msg + /* 0-length msg */ *document = NULL; } else if( response.msg.status_code == HTTP_OK ) { - //LEAK_FIX_MK - // copy entity - entity_start = response.msg.entity.buf; // what we want - msg_length = response.msg.msg.length; // save for posterity - msg_start = membuffer_detach( &response.msg.msg ); // whole msg + /*LEAK_FIX_MK */ + /* copy entity */ + entity_start = response.msg.entity.buf; /* what we want */ + msg_length = response.msg.msg.length; /* save for posterity */ + msg_start = membuffer_detach( &response.msg.msg ); /* whole msg */ - // move entity to the start; copy null-terminator too + /* move entity to the start; copy null-terminator too */ memmove( msg_start, entity_start, *doc_length + 1 ); - // save mem for body only - *document = realloc( msg_start, *doc_length + 1 ); //LEAK_FIX_MK - // *document = Realloc( msg_start,msg_length, *doc_length + 1 );//LEAK_FIX_MK + /* save mem for body only */ + *document = realloc( msg_start, *doc_length + 1 ); /*LEAK_FIX_MK */ + /* *document = Realloc( msg_start,msg_length, *doc_length + 1 ); LEAK_FIX_MK */ - // shrink can't fail + /* shrink can't fail */ assert( ( int )msg_length > *doc_length ); assert( *document != NULL ); } if( response.msg.status_code == HTTP_OK ) { - ret_code = 0; // success + ret_code = 0; /* success */ } else { - // server sent error msg (not requested doc) + /* server sent error msg (not requested doc) */ ret_code = response.msg.status_code; } @@ -935,7 +935,7 @@ MakePostMessage( const char *url_str, if( ret_code != UPNP_E_SUCCESS ) { return ret_code; } - // make msg + /* make msg */ membuffer_init( request ); strcpy( urlPath, url_str ); @@ -1045,12 +1045,12 @@ http_WriteHttpPost( IN void *Handle, return UPNP_E_OUTOF_MEMORY; } - // begin chunk + /* begin chunk */ sprintf( tempbuf, "%x\r\n", ( *size ) ); tempSize = strlen( tempbuf ); memcpy( tempbuf + tempSize, buf, ( *size ) ); memcpy( tempbuf + tempSize + ( *size ), "\r\n", 2 ); - // end of chunk + /* end of chunk */ tempbufSize = tempSize + ( *size ) + 2; freeTempbuf = 1; } @@ -1061,7 +1061,7 @@ http_WriteHttpPost( IN void *Handle, numWritten = sock_write( &handle->sock_info, tempbuf, tempbufSize, &timeout ); - //(*size) = sock_write(&handle->sock_info,tempbuf,tempbufSize,&timeout); + /*(*size) = sock_write(&handle->sock_info,tempbuf,tempbufSize,&timeout); */ if( freeTempbuf ) { free( tempbuf ); @@ -1109,9 +1109,9 @@ http_CloseHttpPost( IN void *Handle, } if( handle->contentLength == UPNP_USING_CHUNKED ) { - retc = sock_write( &handle->sock_info, "0\r\n\r\n", strlen( "0\r\n\r\n" ), &timeout ); //send last chunk + retc = sock_write( &handle->sock_info, "0\r\n\r\n", strlen( "0\r\n\r\n" ), &timeout ); /*send last chunk */ } - //read response + /*read response */ parser_response_init( &response, HTTPMETHOD_POST ); retc = @@ -1120,7 +1120,7 @@ http_CloseHttpPost( IN void *Handle, ( *httpStatus ) = http_error_code; - sock_destroy( &handle->sock_info, SD_BOTH ); //should shutdown completely + sock_destroy( &handle->sock_info, SD_BOTH ); /*should shutdown completely */ httpmsg_destroy( &response.msg ); free( handle ); @@ -1262,7 +1262,7 @@ MakeGetMessage( const char *url_str, if( ret_code != UPNP_E_SUCCESS ) { return ret_code; } - // make msg + /* make msg */ membuffer_init( request ); strcpy( urlPath, url_str ); @@ -1339,7 +1339,7 @@ static int ReadResponseLineAndHeaders( int done = 0; int ret_code = 0; - //read response line + /*read response line */ status = parser_parse_responseline( parser ); if( status == PARSE_OK ) { @@ -1347,17 +1347,17 @@ static int ReadResponseLineAndHeaders( } else if( status == PARSE_INCOMPLETE ) { done = 0; } else { - //error + /*error */ return status; } while( !done ) { num_read = sock_read( info, buf, sizeof( buf ), timeout_secs ); if( num_read > 0 ) { - // append data to buffer + /* append data to buffer */ ret_code = membuffer_append( &parser->msg.msg, buf, num_read ); if( ret_code != 0 ) { - // set failure status + /* set failure status */ parser->http_error_code = HTTP_INTERNAL_SERVER_ERROR; return PARSE_FAILURE; } @@ -1367,13 +1367,13 @@ static int ReadResponseLineAndHeaders( } else if( status == PARSE_INCOMPLETE ) { done = 0; } else { - //error + /*error */ return status; } } else if( num_read == 0 ) { - // partial msg - *http_error_code = HTTP_BAD_REQUEST; // or response + /* partial msg */ + *http_error_code = HTTP_BAD_REQUEST; /* or response */ return UPNP_E_BAD_HTTPMSG; } else { @@ -1391,18 +1391,18 @@ static int ReadResponseLineAndHeaders( } else if( status == PARSE_INCOMPLETE ) { done = 0; } else { - //error + /*error */ return status; } - //read headers + /*read headers */ while( !done ) { num_read = sock_read( info, buf, sizeof( buf ), timeout_secs ); if( num_read > 0 ) { - // append data to buffer + /* append data to buffer */ ret_code = membuffer_append( &parser->msg.msg, buf, num_read ); if( ret_code != 0 ) { - // set failure status + /* set failure status */ parser->http_error_code = HTTP_INTERNAL_SERVER_ERROR; return PARSE_FAILURE; } @@ -1414,13 +1414,13 @@ static int ReadResponseLineAndHeaders( } else if( status == PARSE_INCOMPLETE ) { done = 0; } else { - //error + /*error */ return status; } } else if( num_read == 0 ) { - // partial msg - *http_error_code = HTTP_BAD_REQUEST; // or response + /* partial msg */ + *http_error_code = HTTP_BAD_REQUEST; /* or response */ return UPNP_E_BAD_HTTPMSG; } else { @@ -1473,7 +1473,7 @@ int http_ReadHttpGet( } return UPNP_E_INVALID_PARAM; } - //first parse what has already been gotten + /*first parse what has already been gotten */ if( handle->response.position != POS_COMPLETE ) { status = parser_parse_entity( &handle->response ); } else { @@ -1481,16 +1481,16 @@ int http_ReadHttpGet( } if( status == PARSE_INCOMPLETE_ENTITY ) { - // read until close + /* read until close */ ok_on_close = TRUE; } else if( ( status != PARSE_SUCCESS ) && ( status != PARSE_CONTINUE_1 ) && ( status != PARSE_INCOMPLETE ) ) { - //error + /*error */ *size = 0; return UPNP_E_BAD_RESPONSE; } - //read more if necessary entity + /*read more if necessary entity */ while( ( ( handle->response.msg.entity_offset + *size ) > handle->response.msg.entity.length ) && ( ! handle->cancel ) @@ -1499,11 +1499,11 @@ int http_ReadHttpGet( sock_read( &handle->sock_info, tempbuf, sizeof( tempbuf ), &timeout ); if( num_read > 0 ) { - // append data to buffer + /* append data to buffer */ ret_code = membuffer_append( &handle->response.msg.msg, tempbuf, num_read ); if( ret_code != 0 ) { - // set failure status + /* set failure status */ handle->response.http_error_code = HTTP_INTERNAL_SERVER_ERROR; *size = 0; @@ -1511,12 +1511,12 @@ int http_ReadHttpGet( } status = parser_parse_entity( &handle->response ); if( status == PARSE_INCOMPLETE_ENTITY ) { - // read until close + /* read until close */ ok_on_close = TRUE; } else if( ( status != PARSE_SUCCESS ) && ( status != PARSE_CONTINUE_1 ) && ( status != PARSE_INCOMPLETE ) ) { - //error + /*error */ *size = 0; return UPNP_E_BAD_RESPONSE; } @@ -1527,9 +1527,9 @@ int http_ReadHttpGet( handle->response.msg.msg.buf ); handle->response.position = POS_COMPLETE; } else { - // partial msg + /* partial msg */ *size = 0; - handle->response.http_error_code = HTTP_BAD_REQUEST; // or response + handle->response.http_error_code = HTTP_BAD_REQUEST; /* or response */ return UPNP_E_BAD_HTTPMSG; } } else { @@ -1641,7 +1641,7 @@ http_CloseHttpGet( IN void *Handle ) return UPNP_E_INVALID_PARAM; } - sock_destroy( &handle->sock_info, SD_BOTH ); //should shutdown completely + sock_destroy( &handle->sock_info, SD_BOTH ); /*should shutdown completely */ httpmsg_destroy( &handle->response.msg ); free( handle ); return UPNP_E_SUCCESS; @@ -1864,8 +1864,8 @@ http_SendStatusResponse( IN SOCKINFO * info, ret = http_MakeMessage( &membuf, response_major, response_minor, "RSCB", - http_status_code, // response start line - http_status_code ); // body + http_status_code, /* response start line */ + http_status_code ); /* body */ if( ret == 0 ) { timeout = HTTP_DEFAULT_TIMEOUT; ret = http_SendMessage( info, &timeout, "b", @@ -1903,25 +1903,25 @@ http_SendStatusResponse( IN SOCKINFO * info, * depending on major,minor version * 'c': (no args) appends CRLF "\r\n" * 'D': (no args) appends HTTP DATE: header - * 'd': arg = int number // appends decimal number - * 'G': arg = range information // add range header - * 'h': arg = off_t number // appends off_t number - * 'K': (no args) // add chunky header - * 'L': arg = language information // add Content-Language header if + * 'd': arg = int number -- appends decimal number + * 'G': arg = range information -- add range header + * 'h': arg = off_t number -- appends off_t number + * 'K': (no args) -- add chunky header + * 'L': arg = language information -- add Content-Language header if * Accept-Language header is not empty and if * WEB_SERVER_CONTENT_LANGUAGE is not empty - * 'N': arg1 = off_t content_length // content-length header - * 'q': arg1 = http_method_t // request start line and HOST header + * 'N': arg1 = off_t content_length -- content-length header + * 'q': arg1 = http_method_t -- request start line and HOST header * arg2 = (uri_type *) - * 'Q': arg1 = http_method_t; // start line of request + * 'Q': arg1 = http_method_t; -- start line of request * arg2 = char* url; * arg3 = size_t url_length - * 'R': arg = int status_code // adds a response start line + * 'R': arg = int status_code -- adds a response start line * 'S': (no args) appends HTTP SERVER: header * 's': arg = const char* C_string * 'T': arg = char * content_type; format * e.g: "text/html"; content-type header - * 't': arg = time_t * gmt_time // appends time in RFC 1123 fmt + * 't': arg = time_t * gmt_time -- appends time in RFC 1123 fmt * 'U': (no args) appends HTTP USER-AGENT: header * 'X': arg = const char useragent; "redsonic" HTTP X-User-Agent: useragent * @@ -1967,7 +1967,7 @@ http_MakeMessage( INOUT membuffer * buf, while( ( c = *fmt++ ) != 0 ) { if( c == 's' ) { - // C string + /* C string */ s = ( char * )va_arg( argp, char * ); assert( s ); UpnpPrintf(UPNP_ALL,HTTP,__FILE__,__LINE__,"Adding a string : %s\n", s); @@ -1975,26 +1975,26 @@ http_MakeMessage( INOUT membuffer * buf, goto error_handler; } } else if( c == 'K' ) { - // Add Chunky header + /* Add Chunky header */ if( membuffer_append ( buf, "TRANSFER-ENCODING: chunked\r\n", strlen( "Transfer-Encoding: chunked\r\n" ) ) != 0 ) { goto error_handler; } } else if( c == 'G' ) { - // Add Range header + /* Add Range header */ struct SendInstruction *RespInstr; RespInstr = (struct SendInstruction *) va_arg( argp, struct SendInstruction *); assert( RespInstr ); - // connection header + /* connection header */ if( membuffer_append ( buf, RespInstr->RangeHeader, strlen( RespInstr->RangeHeader ) ) != 0 ) { goto error_handler; } } else if( c == 'b' ) { - // mem buffer + /* mem buffer */ s = ( char * )va_arg( argp, char * ); UpnpPrintf(UPNP_ALL,HTTP,__FILE__,__LINE__, @@ -2006,13 +2006,13 @@ http_MakeMessage( INOUT membuffer * buf, } } else if( c == 'c' ) { - // crlf + /* crlf */ if( membuffer_append( buf, "\r\n", 2 ) != 0 ) { goto error_handler; } } else if( c == 'd' ) { - // integer + /* integer */ num = ( int )va_arg( argp, int ); sprintf( tempbuf, "%"PRIzu, num ); if( membuffer_append( buf, tempbuf, strlen( tempbuf ) ) != 0 ) { @@ -2020,7 +2020,7 @@ http_MakeMessage( INOUT membuffer * buf, } } else if( c == 'h' ) { - // off_t + /* off_t */ bignum = ( off_t )va_arg( argp, off_t ); sprintf( tempbuf, "%"PRId64, (int64_t)bignum ); @@ -2029,15 +2029,15 @@ http_MakeMessage( INOUT membuffer * buf, } } else if( c == 't' || c == 'D' ) { - // date + /* date */ if( c == 'D' ) { - // header + /* header */ start_str = "DATE: "; end_str = "\r\n"; curr_time = time( NULL ); date = gmtime( &curr_time ); } else { - // date value only + /* date value only */ start_str = end_str = ""; loc_time = ( time_t * ) va_arg( argp, time_t * ); assert( loc_time ); @@ -2054,8 +2054,8 @@ http_MakeMessage( INOUT membuffer * buf, goto error_handler; } } else if ( c == 'L' ) { - // Add CONTENT-LANGUAGE header only if WEB_SERVER_CONTENT_LANGUAGE - // is not empty and if Accept-Language header is not empty + /* Add CONTENT-LANGUAGE header only if WEB_SERVER_CONTENT_LANGUAGE */ + /* is not empty and if Accept-Language header is not empty */ struct SendInstruction *RespInstr; RespInstr = (struct SendInstruction *) va_arg( argp, struct SendInstruction *); @@ -2071,14 +2071,14 @@ http_MakeMessage( INOUT membuffer * buf, if( ( http_major_version > 1 ) || ( http_major_version == 1 && http_minor_version == 1 ) ) { - // connection header + /* connection header */ if( membuffer_append_str( buf, "CONNECTION: close\r\n" ) != 0 ) { goto error_handler; } } } else if( c == 'N' ) { - // content-length header + /* content-length header */ bignum = ( off_t )va_arg( argp, off_t ); assert( bignum >= 0 ); @@ -2089,7 +2089,7 @@ http_MakeMessage( INOUT membuffer * buf, goto error_handler; } } else if( c == 'S' || c == 'U' ) { - // SERVER or USER-AGENT header + /* SERVER or USER-AGENT header */ temp_str = ( c == 'S' ) ? "SERVER: " : "USER-AGENT: "; get_sdk_info( tempbuf ); if (http_MakeMessage( @@ -2099,7 +2099,7 @@ http_MakeMessage( INOUT membuffer * buf, goto error_handler; } } else if( c == 'X' ) { - // C string + /* C string */ s = ( char * )va_arg( argp, char * ); assert( s ); if( membuffer_append_str( buf, "X-User-Agent: ") != 0 ) { @@ -2109,15 +2109,15 @@ http_MakeMessage( INOUT membuffer * buf, goto error_handler; } } else if( c == 'R' ) { - // response start line - // e.g.: 'HTTP/1.1 200 OK' - // - // code + /* response start line */ + /* e.g.: 'HTTP/1.1 200 OK' */ + /* */ + /* code */ status_code = ( int )va_arg( argp, int ); assert( status_code > 0 ); sprintf( tempbuf, "HTTP/%d.%d %d ", http_major_version, http_minor_version, status_code ); - // str + /* str */ status_msg = http_get_code_text( status_code ); if (http_MakeMessage( buf, http_major_version, http_minor_version, @@ -2127,8 +2127,8 @@ http_MakeMessage( INOUT membuffer * buf, goto error_handler; } } else if( c == 'B' ) { - // body of a simple reply - // + /* body of a simple reply */ + /* */ status_code = ( int )va_arg( argp, int ); sprintf( tempbuf, "%s%d %s%s", "

", @@ -2138,29 +2138,29 @@ http_MakeMessage( INOUT membuffer * buf, if (http_MakeMessage( buf, http_major_version, http_minor_version, "NTcs", - bignum, // content-length - "text/html", // content-type - tempbuf ) != 0 // body + bignum, /* content-length */ + "text/html", /* content-type */ + tempbuf ) != 0 /* body */ ) { goto error_handler; } } else if( c == 'Q' ) { - // request start line - // GET /foo/bar.html HTTP/1.1\r\n + /* request start line */ + /* GET /foo/bar.html HTTP/1.1\r\n */ method = ( http_method_t ) va_arg( argp, http_method_t ); method_str = method_to_str( method ); url_str = ( const char * )va_arg( argp, const char * ); - num = ( size_t )va_arg( argp, size_t ); // length of url_str + num = ( size_t )va_arg( argp, size_t ); /* length of url_str */ if (http_MakeMessage( buf, http_major_version, http_minor_version, "ssbsdsdc", - method_str, // method - " ", url_str, num, // url + method_str, /* method */ + " ", url_str, num, /* url */ " HTTP/", http_major_version, ".", http_minor_version ) != 0 ) { goto error_handler; } } else if( c == 'q' ) { - // request start line and HOST header + /* request start line and HOST header */ method = ( http_method_t ) va_arg( argp, http_method_t ); uri_ptr = ( uri_type * ) va_arg( argp, uri_type * ); assert( uri_ptr ); @@ -2176,8 +2176,8 @@ http_MakeMessage( INOUT membuffer * buf, goto error_handler; } } else if( c == 'T' ) { - // content type header - temp_str = ( const char * )va_arg( argp, const char * ); // type/subtype format + /* content type header */ + temp_str = ( const char * )va_arg( argp, const char * ); /* type/subtype format */ if (http_MakeMessage( buf, http_major_version, http_minor_version, "ssc", @@ -2266,7 +2266,7 @@ MakeGetMessageEx( const char *url_str, strlen( url_str ), url ) ) != UPNP_E_SUCCESS ) { break; } - // make msg + /* make msg */ membuffer_init( request ); urlPath = alloca( strlen( url_str ) + 1 ); if( !urlPath ) { @@ -2483,7 +2483,7 @@ int http_OpenHttpGetEx( * Return: * UPNP_INLINE void ************************************************************************/ -// 'info' should have a size of at least 100 bytes +/* 'info' should have a size of at least 100 bytes */ void get_sdk_info( OUT char *info ) { diff --git a/upnp/src/genlib/net/http/parsetools.c b/upnp/src/genlib/net/http/parsetools.c index a1dc759..5ed30e1 100644 --- a/upnp/src/genlib/net/http/parsetools.c +++ b/upnp/src/genlib/net/http/parsetools.c @@ -1,38 +1,40 @@ -/////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2000-2003 Intel Corporation -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// * Neither name of Intel Corporation nor the names of its contributors -// may be used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -/////////////////////////////////////////////////////////////////////////// +/******************************************************************************* + * + * Copyright (c) 2000-2003 Intel Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * - Neither name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ******************************************************************************/ -/************************************************************************ -* Purpose: This file a function to extract the header information from * -* an http message and then matches the data with XML data. * -************************************************************************/ +/*! + * \file + * + * Purpose: This file a function to extract the header information from + * an http message and then matches the data with XML data. + */ #include "config.h" #include @@ -42,30 +44,17 @@ #include "statcodes.h" #include "parsetools.h" -/************************************************************************ -* Function: has_xml_content_type -* -* Parameters: -* IN http_message_t* hmsg ; HTTP Message object -* -* Description: Find the header from the HTTP message and match the -* header for xml data. -* -* Returns: -* BOOLEAN -************************************************************************/ -xboolean -has_xml_content_type( IN http_message_t * hmsg ) +xboolean has_xml_content_type(http_message_t *hmsg) { - memptr hdr_value; + memptr hdr_value; - assert( hmsg ); + assert(hmsg); - // find 'content-type' header which must have text/xml - if( httpmsg_find_hdr( hmsg, HDR_CONTENT_TYPE, &hdr_value ) != NULL && - matchstr( hdr_value.buf, hdr_value.length, - "%itext%w/%wxml" ) == PARSE_OK ) { - return TRUE; - } - return FALSE; + /* find 'content-type' header which must have text/xml */ + if (httpmsg_find_hdr(hmsg, HDR_CONTENT_TYPE, &hdr_value) && + matchstr(hdr_value.buf, hdr_value.length, "%itext%w/%wxml" ) == PARSE_OK) { + return TRUE; + } + return FALSE; } + diff --git a/upnp/src/genlib/net/http/statcodes.c b/upnp/src/genlib/net/http/statcodes.c index f11c3cb..385ad09 100644 --- a/upnp/src/genlib/net/http/statcodes.c +++ b/upnp/src/genlib/net/http/statcodes.c @@ -1,33 +1,33 @@ -/////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2000-2003 Intel Corporation -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// * Neither name of Intel Corporation nor the names of its contributors -// may be used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -/////////////////////////////////////////////////////////////////////////// +/******************************************************************************* + * + * Copyright (c) 2000-2003 Intel Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * - Neither name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ******************************************************************************/ /************************************************************************ * Purpose: This file defines status codes, buffers to store the status * @@ -128,7 +128,7 @@ init_table( IN const char *encoded_str, for( i = 0; i < tbl_size; i++ ) { table[i] = s; - s += strlen( s ) + 1; // next entry + s += strlen( s ) + 1; /* next entry */ } } @@ -153,7 +153,7 @@ init_tables( void ) init_table( Http4xxStr, Http4xxCodes, NUM_4XX_CODES ); init_table( Http5xxStr, Http5xxCodes, NUM_5XX_CODES ); - gInitialized = TRUE; // mark only after complete + gInitialized = TRUE; /* mark only after complete */ } /************************************************************************ diff --git a/upnp/src/genlib/net/http/webserver.c b/upnp/src/genlib/net/http/webserver.c index f502f18..c0d0370 100644 --- a/upnp/src/genlib/net/http/webserver.c +++ b/upnp/src/genlib/net/http/webserver.c @@ -316,7 +316,7 @@ static UPNP_INLINE int get_content_type( UpnpFileInfo_set_ContentType(fileInfo, NULL); - // get ext + /* get ext */ extension = strrchr(filename, '.'); if (extension != NULL) { if (search_extension(extension + 1, &type, &subtype) == 0) { @@ -325,7 +325,7 @@ static UPNP_INLINE int get_content_type( } if (!ctype_found) { - // unknown content type + /* unknown content type */ type = gMediaTypes[APPLICATION_INDEX]; subtype = "octet-stream"; } @@ -396,7 +396,7 @@ static void alias_release( struct xml_alias_t *alias) { ithread_mutex_lock(&gWebMutex); - // ignore invalid alias + /* ignore invalid alias */ if (!is_valid_alias(alias)) { ithread_mutex_unlock(&gWebMutex); return; @@ -420,7 +420,7 @@ int web_server_set_alias(const char *alias_name, alias_release(&gAliasDoc); if (alias_name == NULL) { - // don't serve aliased doc anymore + /* don't serve aliased doc anymore */ return 0; } assert(alias_content != NULL); @@ -428,24 +428,24 @@ int web_server_set_alias(const char *alias_name, membuffer_init(&alias.name); alias.ct = NULL; do { - // insert leading /, if missing + /* insert leading /, if missing */ if (*alias_name != '/') { if (membuffer_assign_str(&alias.name, "/") != 0) { - break; // error; out of mem + break; /* error; out of mem */ } } ret_code = membuffer_append_str(&alias.name, alias_name); if (ret_code != 0) { - break; // error + break; /* error */ } if ((alias.ct = (int *)malloc(sizeof(int))) == NULL) { - break; // error + break; /* error */ } *alias.ct = 1; membuffer_attach(&alias.doc, (char *)alias_content, alias_content_length); alias.last_modified = last_modified; - // save in module var + /* save in module var */ ithread_mutex_lock(&gWebMutex); gAliasDoc = alias; ithread_mutex_unlock(&gWebMutex); @@ -453,8 +453,8 @@ int web_server_set_alias(const char *alias_name, return 0; } while (FALSE); - // error handler - // free temp alias + /* error handler */ + /* free temp alias */ membuffer_destroy(&alias.name); membuffer_destroy(&alias.doc); free(alias.ct); @@ -465,13 +465,13 @@ int web_server_init() { int ret = 0; if (bWebServerState == WEB_SERVER_DISABLED) { - // decode media list + /* decode media list */ media_list_init(); membuffer_init(&gDocumentRootDir); glob_alias_init(); pVirtualDirList = NULL; - // Initialize callbacks + /* Initialize callbacks */ virtualDirCallback.get_info = NULL; virtualDirCallback.open = NULL; virtualDirCallback.read = NULL; @@ -543,7 +543,7 @@ static int get_file_info( return -1; } - // check readable + /* check readable */ fp = fopen(filename, "r"); UpnpFileInfo_set_IsReadable(info, fp != NULL); if (fp) { @@ -575,9 +575,9 @@ int web_server_set_root_dir(const char *root_dir) if (ret != 0) { return ret; } - // remove trailing '/', if any + /* remove trailing '/', if any */ if (gDocumentRootDir.length > 0) { - index = gDocumentRootDir.length - 1; // last char + index = gDocumentRootDir.length - 1; /* last char */ if (gDocumentRootDir.buf[index] == '/') { membuffer_delete(&gDocumentRootDir, index, 1); } @@ -900,7 +900,7 @@ static int CheckOtherHTTPHeaders( { http_header_t *header; ListNode *node; - //NNS: dlist_node* node; + /*NNS: dlist_node* node; */ int index, RetCode = HTTP_OK; char *TmpBuf; @@ -910,7 +910,7 @@ static int CheckOtherHTTPHeaders( node = ListHead(&Req->headers); while (node != NULL) { header = (http_header_t *) node->item; - // find header type. + /* find header type. */ index = map_str_to_int((const char *)header->name.buf, header->name.length, Http_Header_Names, NUM_HTTP_HEADER_NAMES, FALSE); @@ -959,23 +959,23 @@ static int CheckOtherHTTPHeaders( header.value is the value. */ /* - case HDR_CONTENT_TYPE: //return 1; - case HDR_CONTENT_LANGUAGE://return 1; - case HDR_LOCATION: //return 1; - case HDR_CONTENT_LOCATION://return 1; - case HDR_ACCEPT: //return 1; - case HDR_ACCEPT_CHARSET://return 1; - case HDR_USER_AGENT: break;//return 1; + case HDR_CONTENT_TYPE: return 1; + case HDR_CONTENT_LANGUAGE:return 1; + case HDR_LOCATION: return 1; + case HDR_CONTENT_LOCATION:return 1; + case HDR_ACCEPT: return 1; + case HDR_ACCEPT_CHARSET: return 1; + case HDR_USER_AGENT: return 1; */ - //Header check for encoding + /*Header check for encoding */ /* - case HDR_ACCEPT_RANGE: //Server capability. - case HDR_CONTENT_RANGE://Response. + case HDR_ACCEPT_RANGE: + case HDR_CONTENT_RANGE: case HDR_IF_RANGE: */ - //Header check for encoding + /*Header check for encoding */ /* case HDR_ACCEPT_ENCODING: if(StrStr(TmpBuf, "identity")) @@ -984,7 +984,7 @@ static int CheckOtherHTTPHeaders( } else return -1; case HDR_CONTENT_ENCODING: - case HDR_TRANSFER_ENCODING: //Response + case HDR_TRANSFER_ENCODING: */ break; } @@ -1040,22 +1040,22 @@ static int process_request( req->method == HTTPMETHOD_HEAD || req->method == HTTPMETHOD_POST || req->method == HTTPMETHOD_SIMPLEGET); - // init + /* init */ request_doc = NULL; finfo = UpnpFileInfo_new(); alias_grabbed = FALSE; - err_code = HTTP_INTERNAL_SERVER_ERROR; // default error + err_code = HTTP_INTERNAL_SERVER_ERROR; /* default error */ using_virtual_dir = FALSE; using_alias = FALSE; http_CalcResponseVersion(req->major_version, req->minor_version, &resp_major, &resp_minor); - // - // remove dots - // + /* */ + /* remove dots */ + /* */ request_doc = malloc(url->pathquery.size + 1); if (request_doc == NULL) { - goto error_handler; // out of mem + goto error_handler; /* out of mem */ } memcpy(request_doc, url->pathquery.buff, url->pathquery.size); request_doc[url->pathquery.size] = '\0'; @@ -1067,7 +1067,7 @@ static int process_request( goto error_handler; } if (*request_doc != '/') { - // no slash + /* no slash */ err_code = HTTP_BAD_REQUEST; goto error_handler; } @@ -1094,13 +1094,13 @@ static int process_request( } if (using_virtual_dir) { if (req->method != HTTPMETHOD_POST) { - // get file info + /* get file info */ if (virtualDirCallback. get_info(filename->buf, finfo) != 0) { err_code = HTTP_NOT_FOUND; goto error_handler; } - // try index.html if req is a dir + /* try index.html if req is a dir */ if (UpnpFileInfo_get_IsDirectory(finfo)) { if (filename->buf[filename->length - 1] == '/') { temp_str = "index.html"; @@ -1111,49 +1111,49 @@ static int process_request( 0) { goto error_handler; } - // get info + /* get info */ if (virtualDirCallback.get_info(filename->buf, finfo) != UPNP_E_SUCCESS || UpnpFileInfo_get_IsDirectory(finfo)) { err_code = HTTP_NOT_FOUND; goto error_handler; } } - // not readable + /* not readable */ if (!UpnpFileInfo_get_IsReadable(finfo)) { err_code = HTTP_FORBIDDEN; goto error_handler; } - // finally, get content type - // if ( get_content_type(filename->buf, &content_type) != 0 ) - //{ - // goto error_handler; - // } + /* finally, get content type */ + /* if ( get_content_type(filename->buf, &content_type) != 0 ) */ + /*{ */ + /* goto error_handler; */ + /* } */ } } else if (!using_alias) { if (gDocumentRootDir.length == 0) { goto error_handler; } - // - // get file name - // + /* */ + /* get file name */ + /* */ - // filename str + /* filename str */ if (membuffer_assign_str(filename, gDocumentRootDir.buf) != 0 || membuffer_append_str(filename, request_doc) != 0) { - goto error_handler; // out of mem + goto error_handler; /* out of mem */ } - // remove trailing slashes + /* remove trailing slashes */ while (filename->length > 0 && filename->buf[filename->length - 1] == '/') { membuffer_delete(filename, filename->length - 1, 1); } if (req->method != HTTPMETHOD_POST) { - // get info on file + /* get info on file */ if (get_file_info(filename->buf, finfo) != 0) { err_code = HTTP_NOT_FOUND; goto error_handler; } - // try index.html if req is a dir + /* try index.html if req is a dir */ if (UpnpFileInfo_get_IsDirectory(finfo)) { if (filename->buf[filename->length - 1] == '/') { temp_str = "index.html"; @@ -1164,27 +1164,27 @@ static int process_request( 0) { goto error_handler; } - // get info + /* get info */ if (get_file_info(filename->buf, finfo) != 0 || UpnpFileInfo_get_IsDirectory(finfo)) { err_code = HTTP_NOT_FOUND; goto error_handler; } } - // not readable + /* not readable */ if (!UpnpFileInfo_get_IsReadable(finfo)) { err_code = HTTP_FORBIDDEN; goto error_handler; } } - // finally, get content type - // if ( get_content_type(filename->buf, &content_type) != 0 ) - // { - // goto error_handler; - // } + /* finally, get content type */ + /* if ( get_content_type(filename->buf, &content_type) != 0 ) */ + /* { */ + /* goto error_handler; */ + /* } */ } RespInstr->ReadSendSize = UpnpFileInfo_get_FileLength(finfo); - // Check other header field. + /* Check other header field. */ err_code = CheckOtherHTTPHeaders(req, RespInstr, UpnpFileInfo_get_FileLength(finfo)); if (err_code != HTTP_OK) { @@ -1200,58 +1200,58 @@ static int process_request( extra_headers = ""; } if (RespInstr->IsRangeActive && RespInstr->IsChunkActive) { - // Content-Range: bytes 222-3333/4000 HTTP_PARTIAL_CONTENT - // Transfer-Encoding: chunked + /* Content-Range: bytes 222-3333/4000 HTTP_PARTIAL_CONTENT */ + /* Transfer-Encoding: chunked */ if (http_MakeMessage(headers, resp_major, resp_minor, "R" "T" "GKLD" "s" "tcS" "Xc" "sCc", - HTTP_PARTIAL_CONTENT, // status code - UpnpFileInfo_get_ContentType(finfo), // content type - RespInstr, // range info - RespInstr, // language info + HTTP_PARTIAL_CONTENT, /* status code */ + UpnpFileInfo_get_ContentType(finfo), /* content type */ + RespInstr, /* range info */ + RespInstr, /* language info */ "LAST-MODIFIED: ", UpnpFileInfo_get_LastModified(finfo), X_USER_AGENT, extra_headers) != 0) { goto error_handler; } } else if (RespInstr->IsRangeActive && !RespInstr->IsChunkActive) { - // Content-Range: bytes 222-3333/4000 HTTP_PARTIAL_CONTENT - // Transfer-Encoding: chunked + /* Content-Range: bytes 222-3333/4000 HTTP_PARTIAL_CONTENT */ + /* Transfer-Encoding: chunked */ if (http_MakeMessage(headers, resp_major, resp_minor, "R" "N" "T" "GLD" "s" "tcS" "Xc" "sCc", - HTTP_PARTIAL_CONTENT, // status code - RespInstr->ReadSendSize, // content length - UpnpFileInfo_get_ContentType(finfo), // content type - RespInstr, // range info - RespInstr, // language info + HTTP_PARTIAL_CONTENT, /* status code */ + RespInstr->ReadSendSize, /* content length */ + UpnpFileInfo_get_ContentType(finfo), /* content type */ + RespInstr, /* range info */ + RespInstr, /* language info */ "LAST-MODIFIED: ", UpnpFileInfo_get_LastModified(finfo), X_USER_AGENT, extra_headers) != 0) { goto error_handler; } } else if (!RespInstr->IsRangeActive && RespInstr->IsChunkActive) { - // Content-Range: bytes 222-3333/4000 HTTP_PARTIAL_CONTENT - // Transfer-Encoding: chunked + /* Content-Range: bytes 222-3333/4000 HTTP_PARTIAL_CONTENT */ + /* Transfer-Encoding: chunked */ if (http_MakeMessage(headers, resp_major, resp_minor, "RK" "TLD" "s" "tcS" "Xc" "sCc", - HTTP_OK, // status code - UpnpFileInfo_get_ContentType(finfo), // content type - RespInstr, // language info + HTTP_OK, /* status code */ + UpnpFileInfo_get_ContentType(finfo), /* content type */ + RespInstr, /* language info */ "LAST-MODIFIED: ", UpnpFileInfo_get_LastModified(finfo), X_USER_AGENT, extra_headers) != 0) { goto error_handler; } } else { - // !RespInstr->IsRangeActive && !RespInstr->IsChunkActive + /* !RespInstr->IsRangeActive && !RespInstr->IsChunkActive */ if (RespInstr->ReadSendSize >= 0) { - // Content-Range: bytes 222-3333/4000 HTTP_PARTIAL_CONTENT - // Transfer-Encoding: chunked + /* Content-Range: bytes 222-3333/4000 HTTP_PARTIAL_CONTENT */ + /* Transfer-Encoding: chunked */ if (http_MakeMessage(headers, resp_major, resp_minor, "R" "N" "TLD" "s" "tcS" "Xc" "sCc", - HTTP_OK, // status code - RespInstr->ReadSendSize, // content length - UpnpFileInfo_get_ContentType(finfo), // content type - RespInstr, // language info + HTTP_OK, /* status code */ + RespInstr->ReadSendSize, /* content length */ + UpnpFileInfo_get_ContentType(finfo), /* content type */ + RespInstr, /* language info */ "LAST-MODIFIED: ", UpnpFileInfo_get_LastModified(finfo), X_USER_AGENT, @@ -1259,13 +1259,13 @@ static int process_request( goto error_handler; } } else { - // Content-Range: bytes 222-3333/4000 HTTP_PARTIAL_CONTENT - // Transfer-Encoding: chunked + /* Content-Range: bytes 222-3333/4000 HTTP_PARTIAL_CONTENT */ + /* Transfer-Encoding: chunked */ if (http_MakeMessage(headers, resp_major, resp_minor, "R" "TLD" "s" "tcS" "b" "Xc" "sCc", - HTTP_OK, // status code - UpnpFileInfo_get_ContentType(finfo), // content type - RespInstr, // language info + HTTP_OK, /* status code */ + UpnpFileInfo_get_ContentType(finfo), /* content type */ + RespInstr, /* language info */ "LAST-MODIFIED: ", UpnpFileInfo_get_LastModified(finfo), X_USER_AGENT, @@ -1277,16 +1277,16 @@ static int process_request( if (req->method == HTTPMETHOD_HEAD) { *rtype = RESP_HEADERS; } else if (using_alias) { - // GET xml + /* GET xml */ *rtype = RESP_XMLDOC; } else if (using_virtual_dir) { *rtype = RESP_WEBDOC; } else { - // GET filename + /* GET filename */ *rtype = RESP_FILEDOC; } - // simple get http 0.9 as specified in http 1.0 - // don't send headers + /* simple get http 0.9 as specified in http 1.0 */ + /* don't send headers */ if (req->method == HTTPMETHOD_SIMPLEGET) { membuffer_destroy(headers); } @@ -1346,37 +1346,37 @@ static int http_RecvPostMessage( } parser->position = POS_ENTITY; do { - // first parse what has already been gotten + /* first parse what has already been gotten */ if (parser->position != POS_COMPLETE) { status = parser_parse_entity(parser); } if (status == PARSE_INCOMPLETE_ENTITY) { - // read until close + /* read until close */ ok_on_close = TRUE; } else if ((status != PARSE_SUCCESS) && (status != PARSE_CONTINUE_1) && (status != PARSE_INCOMPLETE)) { - // error + /* error */ fclose(Fp); return HTTP_BAD_REQUEST; } - // read more if necessary entity + /* read more if necessary entity */ while (entity_offset + Data_Buf_Size > parser->msg.entity.length && parser->position != POS_COMPLETE) { num_read = sock_read(info, Buf, sizeof(Buf), &Timeout); if (num_read > 0) { - // append data to buffer + /* append data to buffer */ ret_code = membuffer_append(&parser->msg.msg, Buf, num_read); if (ret_code != 0) { - // set failure status + /* set failure status */ parser->http_error_code = HTTP_INTERNAL_SERVER_ERROR; return HTTP_INTERNAL_SERVER_ERROR; } status = parser_parse_entity(parser); if (status == PARSE_INCOMPLETE_ENTITY) { - // read until close + /* read until close */ ok_on_close = TRUE; } else if ((status != PARSE_SUCCESS) && (status != PARSE_CONTINUE_1) @@ -1391,7 +1391,7 @@ static int http_RecvPostMessage( print_http_headers(&parser->msg); parser->position = POS_COMPLETE; } else { - // partial msg or response + /* partial msg or response */ parser->http_error_code = HTTP_BAD_REQUEST; return HTTP_BAD_REQUEST; } @@ -1442,36 +1442,36 @@ void web_server_callback(http_parser_t *parser, INOUT http_message_t *req, struct xml_alias_t xmldoc; struct SendInstruction RespInstr; - //Initialize instruction header. + /*Initialize instruction header. */ RespInstr.IsVirtualFile = 0; RespInstr.IsChunkActive = 0; RespInstr.IsRangeActive = 0; RespInstr.IsTrailers = 0; memset(RespInstr.AcceptLanguageHeader, 0, sizeof(RespInstr.AcceptLanguageHeader)); - // init + /* init */ membuffer_init(&headers); membuffer_init(&filename); - //Process request should create the different kind of header depending on the - //the type of request. + /*Process request should create the different kind of header depending on the */ + /*the type of request. */ ret = process_request(req, &rtype, &headers, &filename, &xmldoc, &RespInstr); if (ret != UPNP_E_SUCCESS) { - // send error code + /* send error code */ http_SendStatusResponse(info, ret, req->major_version, req->minor_version); } else { - // send response + /* send response */ switch (rtype) { case RESP_FILEDOC: - // send file, I = further instruction to send data. + /* send file, I = further instruction to send data. */ http_SendMessage(info, &timeout, "Ibf", &RespInstr, headers.buf, headers.length, filename.buf); break; case RESP_XMLDOC: - // send xmldoc , I = further instruction to send data. + /* send xmldoc , I = further instruction to send data. */ http_SendMessage(info, &timeout, "Ibb", &RespInstr, headers.buf, headers.length, @@ -1479,7 +1479,7 @@ void web_server_callback(http_parser_t *parser, INOUT http_message_t *req, alias_release(&xmldoc); break; case RESP_WEBDOC: - //, I = further instruction to send data. + /*, I = further instruction to send data. */ /* http_SendVirtualDirDoc( info, &timeout, "Ibf",&RespInstr, headers.buf, headers.length, @@ -1491,16 +1491,16 @@ void web_server_callback(http_parser_t *parser, INOUT http_message_t *req, filename.buf); break; case RESP_HEADERS: - // headers only + /* headers only */ http_SendMessage(info, &timeout, "b", headers.buf, headers.length); break; case RESP_POST: - // headers only + /* headers only */ ret = http_RecvPostMessage(parser, info, filename.buf, &RespInstr); - // Send response. + /* Send response. */ http_MakeMessage(&headers, 1, 1, "RTLSXcCc", ret, "text/html", X_USER_AGENT); diff --git a/upnp/src/genlib/net/uri/uri.c b/upnp/src/genlib/net/uri/uri.c index df9470d..57d858f 100644 --- a/upnp/src/genlib/net/uri/uri.c +++ b/upnp/src/genlib/net/uri/uri.c @@ -228,7 +228,7 @@ int copy_URL_list(URL_list *in, URL_list *out) memcpy( out->URLs, in->URLs, len ); for( i = 0; i < in->size; i++ ) { - //copy the parsed uri + /*copy the parsed uri */ out->parsedURLs[i].type = in->parsedURLs[i].type; copy_token( &in->parsedURLs[i].scheme, in->URLs, &out->parsedURLs[i].scheme, out->URLs ); @@ -343,22 +343,22 @@ int parse_hostport( memset( out, 0, sizeof(hostport_type) ); - // Work on a copy of the input string. + /* Work on a copy of the input string. */ strncpy( workbuf, in, sizeof(workbuf) ); c = workbuf; if( *c == '[' ) { - // IPv6 addresses are enclosed in square brackets. + /* IPv6 addresses are enclosed in square brackets. */ srvname = ++c; while( *c != '\0' && *c != ']' ) { c++; } if( *c == '\0' ) { - // did not find closing bracket. + /* did not find closing bracket. */ return UPNP_E_INVALID_URL; } - // NULL terminate the srvname and then increment c. - *c++ = '\0'; // overwrite the ']' + /* NULL terminate the srvname and then increment c. */ + *c++ = '\0'; /* overwrite the ']' */ if( *c == ':' ) { has_port = 1; c++; @@ -366,7 +366,7 @@ int parse_hostport( af = AF_INET6; } else { - // IPv4 address -OR- host name. + /* IPv4 address -OR- host name. */ srvname = c; while( (*c != ':') && (*c != '/') && ( (isalnum(*c)) || (*c == '.') || (*c == '-') ) ) { if( *c == '.' ) @@ -374,17 +374,17 @@ int parse_hostport( c++; } has_port = (*c == ':') ? 1 : 0; - // NULL terminate the srvname + /* NULL terminate the srvname */ *c = '\0'; if( has_port == 1 ) c++; if( last_dot != NULL && isdigit(*(last_dot+1)) ) { - // Must be an IPv4 address. + /* Must be an IPv4 address. */ af = AF_INET; } else { - // Must be a host name. + /* Must be a host name. */ struct addrinfo hints, *res, *res0; memset(&hints, 0, sizeof(hints)); @@ -396,7 +396,7 @@ int parse_hostport( for (res = res0; res; res = res->ai_next) { if( res->ai_family == AF_INET || res->ai_family == AF_INET6 ) { - // Found a valid IPv4 or IPv6 address. + /* Found a valid IPv4 or IPv6 address. */ memcpy( &out->IPaddress, res->ai_addr, res->ai_addrlen ); break; @@ -405,40 +405,40 @@ int parse_hostport( freeaddrinfo(res0); if( res == NULL ) { - // Didn't find an AF_INET or AF_INET6 address. + /* Didn't find an AF_INET or AF_INET6 address. */ return UPNP_E_INVALID_URL; } } else { - // getaddrinfo failed. + /* getaddrinfo failed. */ return UPNP_E_INVALID_URL; } } } - // Check if a port is specified. + /* Check if a port is specified. */ if( has_port == 1 ) { - // Port is specified. + /* Port is specified. */ srvport = c; while( *c != '\0' && isdigit(*c) ) { c++; } port = (unsigned short int)atoi(srvport); if( port == 0 ) { - // Bad port number. + /* Bad port number. */ return UPNP_E_INVALID_URL; } } else { - // Port was not specified, use default port. + /* Port was not specified, use default port. */ port = 80; } - // The length of the host and port string can be calculated by - // subtracting pointers. + /* The length of the host and port string can be calculated by */ + /* subtracting pointers. */ hostport_size = (int)(c - workbuf); - // Fill in the 'out' information. + /* Fill in the 'out' information. */ if( af == AF_INET ) { sai4->sin_family = AF_INET; sai4->sin_port = htons(port); @@ -450,8 +450,8 @@ int parse_hostport( sai6->sin6_scope_id = gIF_INDEX; ret = inet_pton(AF_INET6, srvname, &sai6->sin6_addr); } else { - // IP address was set by the hostname (getaddrinfo). - // Override port: + /* IP address was set by the hostname (getaddrinfo). */ + /* Override port: */ if( out->IPaddress.ss_family == AF_INET ) sai4->sin_port = htons(port); else @@ -562,7 +562,7 @@ int remove_dots(char *in, size_t size) copyTo = Segments[--lastSegment]; } else { free( Segments ); - //TRACE("ERROR RESOLVING URL, ../ at ROOT"); + /*TRACE("ERROR RESOLVING URL, ../ at ROOT"); */ return UPNP_E_INVALID_URL; } continue; diff --git a/upnp/src/genlib/service_table/service_table.c b/upnp/src/genlib/service_table/service_table.c index bc720ab..88c8040 100644 --- a/upnp/src/genlib/service_table/service_table.c +++ b/upnp/src/genlib/service_table/service_table.c @@ -135,7 +135,7 @@ subscription *GetSubscriptionSID(const Upnp_SID sid, service_info *service) } } if( found ) { - //get the current_time + /*get the current_time */ time( ¤t_time ); if( ( found->expireTime != 0 ) && ( found->expireTime < current_time ) ) { @@ -161,7 +161,7 @@ subscription *GetNextSubscription(service_info *service, subscription *current) subscription *previous = NULL; int notDone = 1; - // get the current_time + /* get the current_time */ time( ¤t_time ); while( ( notDone ) && ( current ) ) { previous = current; @@ -195,7 +195,7 @@ subscription *GetFirstSubscription(service_info *service) temp.next = service->subscriptionList; next = GetNextSubscription(service, &temp); service->subscriptionList = temp.next; - // service->subscriptionList = next; + /* service->subscriptionList = next; */ return next; } @@ -980,9 +980,9 @@ removeServiceTable( IXML_Node * node, && ( ( getSubElement( "UDN", node, ¤tUDN ) ) && ( UDN = getElementValue( currentUDN ) ) ) ) { current_service = start_search; - //Services are put in the service table in the order in which they appear in the - //description document, therefore we go through the list only once to remove a particular - //root device + /*Services are put in the service table in the order in which they appear in the */ + /*description document, therefore we go through the list only once to remove a particular */ + /*root device */ while( ( current_service ) && ( strcmp( current_service->UDN, UDN ) ) ) { current_service = current_service->next; @@ -1108,4 +1108,5 @@ getServiceTable( IXML_Node * node, return 0; } -#endif // INCLUDE_DEVICE_APIS +#endif /* INCLUDE_DEVICE_APIS */ + diff --git a/upnp/src/genlib/util/membuffer.c b/upnp/src/genlib/util/membuffer.c index 3224fda..6ac3831 100644 --- a/upnp/src/genlib/util/membuffer.c +++ b/upnp/src/genlib/util/membuffer.c @@ -70,7 +70,7 @@ str_alloc( IN const char *str, s = ( char * )malloc( str_len + 1 ); if( s == NULL ) { - return NULL; // no mem + return NULL; /* no mem */ } memcpy( s, str, str_len ); @@ -111,8 +111,8 @@ memptr_cmp( IN memptr * m, cmp = strncmp( m->buf, s, m->length ); if( cmp == 0 && m->length < strlen( s ) ) { - // both strings equal for 'm->length' chars - // if m is shorter than s, then s is greater + /* both strings equal for 'm->length' chars */ + /* if m is shorter than s, then s is greater */ return -1; } @@ -147,8 +147,8 @@ memptr_cmp_nocase( IN memptr * m, cmp = strncasecmp( m->buf, s, m->length ); if( cmp == 0 && m->length < strlen( s ) ) { - // both strings equal for 'm->length' chars - // if m is shorter than s, then s is greater + /* both strings equal for 'm->length' chars */ + /* if m is shorter than s, then s is greater */ return -1; } @@ -204,20 +204,20 @@ membuffer_set_size( INOUT membuffer * m, size_t alloc_len; char *temp_buf; - if( new_length >= m->length ) // increase length + if( new_length >= m->length ) /* increase length */ { - // need more mem? + /* need more mem? */ if( new_length <= m->capacity ) { - return 0; // have enough mem; done + return 0; /* have enough mem; done */ } diff = new_length - m->length; alloc_len = MAXVAL( m->size_inc, diff ) + m->capacity; - } else // decrease length + } else /* decrease length */ { assert( new_length <= m->length ); - // if diff is 0..m->size_inc, don't free + /* if diff is 0..m->size_inc, don't free */ if( ( m->capacity - new_length ) <= m->size_inc ) { return 0; } @@ -227,21 +227,21 @@ membuffer_set_size( INOUT membuffer * m, assert( alloc_len >= new_length ); - temp_buf = realloc( m->buf, alloc_len + 1 ); //LEAK_FIX_MK + temp_buf = realloc( m->buf, alloc_len + 1 ); /*LEAK_FIX_MK */ - //temp_buf = Realloc( m->buf,m->length, alloc_len + 1 );//LEAK_FIX_MK + /*temp_buf = Realloc( m->buf,m->length, alloc_len + 1 );LEAK_FIX_MK */ if( temp_buf == NULL ) { - // try smaller size + /* try smaller size */ alloc_len = new_length; - temp_buf = realloc( m->buf, alloc_len + 1 ); //LEAK_FIX_MK - //temp_buf = Realloc( m->buf,m->length, alloc_len + 1 );//LEAK_FIX_MK + temp_buf = realloc( m->buf, alloc_len + 1 ); /*LEAK_FIX_MK */ + /*temp_buf = Realloc( m->buf,m->length, alloc_len + 1 );LEAK_FIX_MK */ if( temp_buf == NULL ) { return UPNP_E_OUTOF_MEMORY; } } - // save + /* save */ m->buf = temp_buf; m->capacity = alloc_len; return 0; @@ -320,20 +320,20 @@ membuffer_assign( INOUT membuffer * m, assert( m != NULL ); - // set value to null + /* set value to null */ if( buf == NULL ) { membuffer_destroy( m ); return 0; } - // alloc mem + /* alloc mem */ return_code = membuffer_set_size( m, buf_len ); if( return_code != 0 ) { return return_code; } - // copy + /* copy */ if( buf_len ) { memcpy( m->buf, buf, buf_len ); - m->buf[buf_len] = 0; // null-terminate + m->buf[buf_len] = 0; /* null-terminate */ } m->length = buf_len; @@ -446,18 +446,18 @@ membuffer_insert( INOUT membuffer * m, if( buf == NULL || buf_len == 0 ) { return 0; } - // alloc mem + /* alloc mem */ return_code = membuffer_set_size( m, m->length + buf_len ); if( return_code != 0 ) { return return_code; } - // insert data + /* insert data */ - // move data to right of insertion point + /* move data to right of insertion point */ memmove( m->buf + index + buf_len, m->buf + index, m->length - index ); memcpy( m->buf + index, buf, buf_len ); m->length += buf_len; - m->buf[m->length] = 0; // null-terminate + m->buf[m->length] = 0; /* null-terminate */ return 0; } @@ -499,22 +499,22 @@ membuffer_delete( INOUT membuffer * m, assert( index >= 0 && index < ( int )m->length ); - // shrink count if it goes beyond buffer + /* shrink count if it goes beyond buffer */ if( index + num_bytes > m->length ) { num_bytes = m->length - ( size_t ) index; - copy_len = 0; // every thing at and after index purged + copy_len = 0; /* every thing at and after index purged */ } else { - // calc num bytes after deleted string + /* calc num bytes after deleted string */ copy_len = m->length - ( index + num_bytes ); } memmove( m->buf + index, m->buf + index + num_bytes, copy_len ); new_length = m->length - num_bytes; - return_value = membuffer_set_size( m, new_length ); // trim buffer - assert( return_value == 0 ); // shrinking should always work + return_value = membuffer_set_size( m, new_length ); /* trim buffer */ + assert( return_value == 0 ); /* shrinking should always work */ - // don't modify until buffer is set + /* don't modify until buffer is set */ m->length = new_length; m->buf[new_length] = 0; } @@ -543,7 +543,7 @@ membuffer_detach( INOUT membuffer * m ) buf = m->buf; - // free all + /* free all */ membuffer_initialize( m ); return buf; diff --git a/upnp/src/genlib/util/strintmap.c b/upnp/src/genlib/util/strintmap.c index 0e9db10..183a5b3 100644 --- a/upnp/src/genlib/util/strintmap.c +++ b/upnp/src/genlib/util/strintmap.c @@ -1,33 +1,33 @@ -/////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2000-2003 Intel Corporation -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// * Neither name of Intel Corporation nor the names of its contributors -// may be used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -/////////////////////////////////////////////////////////////////////////// +/******************************************************************************* + * + * Copyright (c) 2000-2003 Intel Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * - Neither name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ******************************************************************************/ /************************************************************************ * Purpose: This file contains string to integer and integer to string @@ -82,24 +82,24 @@ map_str_to_int( IN const char *name, while( top <= bot ) { mid = ( top + bot ) / 2; if( case_sensitive ) { - //cmp = strcmp( name, table[mid].name ); + /*cmp = strcmp( name, table[mid].name ); */ cmp = memptr_cmp( &name_ptr, table[mid].name ); } else { - //cmp = strcasecmp( name, table[mid].name ); + /*cmp = strcasecmp( name, table[mid].name ); */ cmp = memptr_cmp_nocase( &name_ptr, table[mid].name ); } if( cmp > 0 ) { - top = mid + 1; // look below mid + top = mid + 1; /* look below mid */ } else if( cmp < 0 ) { - bot = mid - 1; // look above mid - } else // cmp == 0 + bot = mid - 1; /* look above mid */ + } else /* cmp == 0 */ { - return mid; // match; return table index + return mid; /* match; return table index */ } } - return -1; // header name not found + return -1; /* header name not found */ } /************************************************************************ diff --git a/upnp/src/genlib/util/util.c b/upnp/src/genlib/util/util.c index 694efdd..6a44c27 100644 --- a/upnp/src/genlib/util/util.c +++ b/upnp/src/genlib/util/util.c @@ -29,90 +29,39 @@ * ******************************************************************************/ -/************************************************************************ -* Purpose: This file contains functions for copying strings based on -* different options. -************************************************************************/ - +/*! + * \file + * + * Purpose: This file contains functions for copying strings based on + * different options. + */ #include "config.h" #include "upnp.h" #include "upnputil.h" - #include - -/************************************************************************ -* Function : linecopy -* -* Parameters : -* OUT char dest[LINE_SIZE] ; output buffer -* IN const char* src ; input buffer -* -* Description : Copy no of bytes spcified by the LINE_SIZE constant, -* from the source buffer. Null terminate the destination buffer -* -* Return : void ; -* -* Note : -************************************************************************/ -void -linecopy( OUT char dest[LINE_SIZE], - IN const char *src ) +void linecopy(char dest[LINE_SIZE], const char *src) { - strncpy( dest, src, LINE_SIZE - 1 ); - dest[LINE_SIZE - 1] = '\0'; // null-terminate if len(src) >= LINE_SIZE + strncpy(dest, src, LINE_SIZE - 1); + /* null-terminate if len(src) >= LINE_SIZE. */ + dest[LINE_SIZE - 1] = '\0'; } -/************************************************************************ -* Function : namecopy -* -* Parameters : -* OUT char dest[NAME_SIZE] ; output buffer -* IN const char* src ; input buffer -* -* Description : Copy no of bytes spcified by the NAME_SIZE constant, -* from the source buffer. Null terminate the destination buffer -* -* Return : void ; -* -* Note : -************************************************************************/ -void -namecopy( OUT char dest[NAME_SIZE], - IN const char *src ) +void namecopy(char dest[NAME_SIZE], const char *src) { - strncpy( dest, src, NAME_SIZE - 1 ); - dest[NAME_SIZE - 1] = '\0'; // null-terminate if len(src) >= NAME_SIZE + strncpy(dest, src, NAME_SIZE - 1); + /* null-terminate if len(src) >= NAME_SIZE. */ + dest[NAME_SIZE - 1] = '\0'; } -/************************************************************************ -* Function : linecopylen -* -* Parameters : -* OUT char dest[LINE_SIZE] ; output buffer -* IN const char* src ; input buffer -* IN size_t srclen ; bytes to be copied. -* -* Description : Determine if the srclen passed in paramter is less than -* the permitted LINE_SIZE. If it is use the passed parameter, if not -* use the permitted LINE_SIZE as the length parameter -* Copy no of bytes spcified by the LINE_SIZE constant, -* from the source buffer. Null terminate the destination buffer -* -* Return : void ; -* -* Note : -************************************************************************/ -void -linecopylen( OUT char dest[LINE_SIZE], - IN const char *src, - IN size_t srclen ) +void linecopylen(char dest[LINE_SIZE], const char *src, size_t srclen) { - int len; + int len; - len = srclen < ( LINE_SIZE - 1 ) ? srclen : ( LINE_SIZE - 1 ); - strncpy( dest, src, len ); - dest[len] = '\0'; + len = srclen < (LINE_SIZE - 1) ? srclen : (LINE_SIZE - 1); + strncpy(dest, src, len); + dest[len] = '\0'; } + diff --git a/upnp/src/inc/global.h b/upnp/src/inc/global.h index 7e28174..eba2dde 100644 --- a/upnp/src/inc/global.h +++ b/upnp/src/inc/global.h @@ -29,11 +29,9 @@ * **************************************************************************/ - #ifndef GLOBAL_H #define GLOBAL_H - /* GLOBAL.H - RSAREF types and constants */ /* PROTOTYPES should be set to one if and only if the compiler supports function argument prototyping. @@ -42,7 +40,6 @@ been defined with C compiler flags. */ - #ifndef PROTOTYPES #define PROTOTYPES 1 #endif diff --git a/upnp/src/inc/httpparser.h b/upnp/src/inc/httpparser.h index d6134e9..e4ec967 100644 --- a/upnp/src/inc/httpparser.h +++ b/upnp/src/inc/httpparser.h @@ -29,49 +29,45 @@ * ******************************************************************************/ - #ifndef GENLIB_NET_HTTP_HTTPPARSER_H #define GENLIB_NET_HTTP_HTTPPARSER_H - /*! * \file */ - #include "LinkedList.h" #include "membuffer.h" #include "uri.h" #include "upnputil.h" +/* private types */ -////// private types //////////// +/* scanner */ - -////////////////////// -// scanner -/////////////////////// -// Used to represent different types of tokens in input -typedef enum // token_type_t +/* Used to represent different types of tokens in input. */ +typedef enum { TT_IDENTIFIER, TT_WHITESPACE, TT_CRLF, - TT_CTRL, // needed ?? - TT_SEPARATOR, // ?? - TT_QUOTEDSTRING, // ?? + TT_CTRL, + TT_SEPARATOR, + TT_QUOTEDSTRING, } token_type_t; -typedef struct // scanner_t +typedef struct { - membuffer* msg; // raw http msg - size_t cursor; // current position in buffer - xboolean entire_msg_loaded; // set this to TRUE if the entire msg is loaded in - // in 'msg'; else FALSE if only partial msg in 'msg' - // (default is FALSE) + /*! raw http msg. */ + membuffer* msg; + /*! current position in buffer. */ + size_t cursor; + /*! set this to TRUE if the entire msg is loaded in 'msg'; + * else FALSE if only partial msg in 'msg' (default is FALSE). */ + xboolean entire_msg_loaded; } scanner_t; -typedef enum // parser_pos_t +typedef enum { POS_REQUEST_LINE, POS_RESPONSE_LINE, @@ -80,21 +76,17 @@ typedef enum // parser_pos_t POS_COMPLETE, } parser_pos_t; - #define ENTREAD_DETERMINE_READ_METHOD 1 -#define ENTREAD_USING_CLEN 2 -#define ENTREAD_USING_CHUNKED 3 -#define ENTREAD_UNTIL_CLOSE 4 -#define ENTREAD_CHUNKY_BODY 5 -#define ENTREAD_CHUNKY_HEADERS 6 +#define ENTREAD_USING_CLEN 2 +#define ENTREAD_USING_CHUNKED 3 +#define ENTREAD_UNTIL_CLOSE 4 +#define ENTREAD_CHUNKY_BODY 5 +#define ENTREAD_CHUNKY_HEADERS 6 +/* end of private section. */ -// end of private section -////////////////// -// ################################################################################## - -// method in a HTTP request -typedef enum // http_method_t +/* method in a HTTP request. */ +typedef enum { HTTPMETHOD_POST, HTTPMETHOD_MPOST, @@ -105,116 +97,121 @@ typedef enum // http_method_t HTTPMETHOD_HEAD, HTTPMETHOD_MSEARCH, HTTPMETHOD_UNKNOWN, - SOAPMETHOD_POST, //murari + SOAPMETHOD_POST, HTTPMETHOD_SIMPLEGET } http_method_t; -// different types of HTTP headers -#define HDR_UNKNOWN -1 +/* different types of HTTP headers */ +#define HDR_UNKNOWN -1 #define HDR_CACHE_CONTROL 1 #define HDR_CALLBACK 2 #define HDR_CONTENT_LENGTH 3 #define HDR_CONTENT_TYPE 4 -#define HDR_DATE 5 -#define HDR_EXT 6 -#define HDR_HOST 7 -//#define HDR_IF_MODIFIED_SINCE 8 -//#define HDR_IF_UNMODIFIED_SINCE 9 -//#define HDR_LAST_MODIFIED 10 +#define HDR_DATE 5 +#define HDR_EXT 6 +#define HDR_HOST 7 +/*define HDR_IF_MODIFIED_SINCE 8 */ +/*define HDR_IF_UNMODIFIED_SINCE 9 */ +/*define HDR_LAST_MODIFIED 10 */ #define HDR_LOCATION 11 -#define HDR_MAN 12 -#define HDR_MX 13 -#define HDR_NT 14 -#define HDR_NTS 15 -#define HDR_SERVER 16 -#define HDR_SEQ 17 -#define HDR_SID 18 +#define HDR_MAN 12 +#define HDR_MX 13 +#define HDR_NT 14 +#define HDR_NTS 15 +#define HDR_SERVER 16 +#define HDR_SEQ 17 +#define HDR_SID 18 #define HDR_SOAPACTION 19 -#define HDR_ST 20 -#define HDR_TIMEOUT 21 -#define HDR_TRANSFER_ENCODING 22 -#define HDR_USN 23 +#define HDR_ST 20 +#define HDR_TIMEOUT 21 +#define HDR_TRANSFER_ENCODING 22 +#define HDR_USN 23 #define HDR_USER_AGENT 24 -//Adding new header difinition//Beg_Murari -#define HDR_ACCEPT 25 -#define HDR_ACCEPT_ENCODING 26 -#define HDR_ACCEPT_CHARSET 27 -#define HDR_ACCEPT_LANGUAGE 28 -#define HDR_ACCEPT_RANGE 29 -#define HDR_CONTENT_ENCODING 30 -#define HDR_CONTENT_LANGUAGE 31 -#define HDR_CONTENT_LOCATION 32 -#define HDR_CONTENT_RANGE 33 -#define HDR_IF_RANGE 34 -#define HDR_RANGE 35 -#define HDR_TE 36 -//End_Murari +/* Adding new header difinition */ +#define HDR_ACCEPT 25 +#define HDR_ACCEPT_ENCODING 26 +#define HDR_ACCEPT_CHARSET 27 +#define HDR_ACCEPT_LANGUAGE 28 +#define HDR_ACCEPT_RANGE 29 +#define HDR_CONTENT_ENCODING 30 +#define HDR_CONTENT_LANGUAGE 31 +#define HDR_CONTENT_LOCATION 32 +#define HDR_CONTENT_RANGE 33 +#define HDR_IF_RANGE 34 +#define HDR_RANGE 35 +#define HDR_TE 36 -// status of parsing -typedef enum // parse_status_t -{ - PARSE_SUCCESS = 0, // msg was parsed successfully - PARSE_INCOMPLETE, // need more data to continue - PARSE_INCOMPLETE_ENTITY, // for responses that don't have length specified - PARSE_FAILURE, // parse failed; check status code for details - PARSE_OK, // done partial - PARSE_NO_MATCH, // token not matched - - // private +/*! status of parsing */ +typedef enum { + /*! msg was parsed successfully. */ + PARSE_SUCCESS = 0, + /*! need more data to continue. */ + PARSE_INCOMPLETE, + /*! for responses that don't have length specified. */ + PARSE_INCOMPLETE_ENTITY, + /*! parse failed; check status code for details. */ + PARSE_FAILURE, + /*! done partial. */ + PARSE_OK, + /*! token not matched. */ + PARSE_NO_MATCH, + /*! private. */ PARSE_CONTINUE_1 } parse_status_t; -typedef struct // http_header_t -{ - memptr name; // header name as a string - int name_id; // header name id (for a selective group of headers only) - membuffer value; // raw-value; could be multi-lined; min-length = 0 - - // private - membuffer name_buf; +typedef struct { + /*! header name as a string. */ + memptr name; + /*! header name id (for a selective group of headers only). */ + int name_id; + /*! raw-value; could be multi-lined; min-length = 0. */ + membuffer value; + /* private. */ + membuffer name_buf; } http_header_t; -typedef struct // http_message_t -{ - int initialized; - // request only +typedef struct { + int initialized; + /*! request only. */ http_method_t method; + /*! request only. */ uri_type uri; - - // response only + /*! response only. */ http_method_t request_method; + /*! response only. */ int status_code; + /*! response only. */ membuffer status_msg; - - // fields used in both request or response messages - xboolean is_request; // if TRUE, msg is a request, else response - - int major_version; // http major.minor version + /* fields used in both request or response messages. */ + /*! if TRUE, msg is a request, else response. */ + xboolean is_request; + /* http major version. */ + int major_version; + /* http minor version. */ int minor_version; - - + /*! . */ LinkedList headers; -//NNS: dlist headers; // dlist - memptr entity; // message body(entity) - - // private fields - membuffer msg; // entire raw message - char *urlbuf; // storage for url string + /*! message body(entity). */ + memptr entity; + /* private fields. */ + /*! entire raw message. */ + membuffer msg; + /*! storage for url string. */ + char *urlbuf; + /*! . */ size_t entity_offset; } http_message_t; -typedef struct // http_parser_t -{ +typedef struct { http_message_t msg; - int http_error_code; // read-only; in case of parse error, this - // contains the HTTP error code (4XX or 5XX) - - // read-only; this is set to true if a NOTIFY request has no content-length. - // used to read valid sspd notify msg. - xboolean valid_ssdp_notify_hack; - - // private data -- don't touch + /*! read-only; in case of parse error, this + * contains the HTTP error code (4XX or 5XX). */ + int http_error_code; + /*! read-only; this is set to true if a NOTIFY request has no + * content-length. used to read valid sspd notify msg. */ + xboolean valid_ssdp_notify_hack; + /* private data -- don't touch. */ parser_pos_t position; int ent_position; unsigned int content_length; @@ -223,15 +220,9 @@ typedef struct // http_parser_t scanner_t scanner; } http_parser_t; - -//-------------------------------------------------- -//////////////// functions ///////////////////////// -//-------------------------------------------------- - #ifdef __cplusplus extern "C" { -#endif // __cplusplus - +#endif /* __cplusplus */ /************************************************************************ * Function : httpmsg_init @@ -272,8 +263,7 @@ void httpmsg_destroy( INOUT http_message_t* msg ); * in the linked list of messages * * Return : http_header_t* - Pointer to a header on success; -* NULL on failure -* +* NULL on failure * Note : ************************************************************************/ http_header_t* httpmsg_find_hdr_str( IN http_message_t* msg, @@ -289,8 +279,8 @@ http_header_t* httpmsg_find_hdr_str( IN http_message_t* msg, * * Description : Finds header from a list, with the given 'name_id'. * -* Return : http_header_t* - Pointer to a header on success; * -* NULL on failure +* Return : http_header_t* - Pointer to a header on success; +* NULL on failure * * Note : ************************************************************************/ @@ -404,9 +394,9 @@ parse_status_t parser_get_entity_read_method( INOUT http_parser_t* parser ); * * Parameters: * INOUT http_parser_t* parser ; HTTP Parser Object -* IN const char* buf ; buffer to be appended to the parser -* buffer -* IN size_t buf_length ; Size of the buffer +* IN const char* buf ; buffer to be appended to the parser +* buffer +* IN size_t buf_length ; Size of the buffer * * Description: The parser function. Depending on the position of the * parser object the actual parsing function is invoked @@ -422,8 +412,8 @@ parse_status_t parser_append( INOUT http_parser_t* parser, * Function: matchstr * * Parameters: -* IN char *str ; String to be matched -* IN size_t slen ; Length of the string +* IN char *str ; String to be matched +* IN size_t slen ; Length of the string * IN const char* fmt ; Pattern format * ... * @@ -437,10 +427,6 @@ parse_status_t parser_append( INOUT http_parser_t* parser, ************************************************************************/ int matchstr( IN char *str, IN size_t slen, IN const char* fmt, ... ); -// ==================================================== -// misc functions - - /************************************************************************ * Function: raw_to_int * @@ -481,26 +467,28 @@ int raw_find_str( IN memptr* raw_value, IN const char* str ); * nameConverts a http_method id stored in the HTTP Method * * Returns: -* const char* ptr - Ptr to the HTTP Method * +* const char* ptr - Ptr to the HTTP Method ************************************************************************/ const char* method_to_str( IN http_method_t method ); - /*! * \brief Print the HTTP headers. */ #ifdef DEBUG void print_http_headers( /*! [in] HTTP Message object. */ - http_message_t *hmsg ); + http_message_t *hmsg); #else -static UPNP_INLINE void print_http_headers(http_message_t *hmsg) {} +static UPNP_INLINE void print_http_headers(http_message_t *hmsg) +{ + return; + hmsg = hmsg; +} #endif #ifdef __cplusplus } /* extern "C" */ #endif /* __cplusplus */ - #endif /* GENLIB_NET_HTTP_HTTPPARSER_H */ diff --git a/upnp/src/inc/httpreadwrite.h b/upnp/src/inc/httpreadwrite.h index c026187..4723ff0 100644 --- a/upnp/src/inc/httpreadwrite.h +++ b/upnp/src/inc/httpreadwrite.h @@ -1,33 +1,33 @@ -/////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2000-2003 Intel Corporation -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// * Neither name of Intel Corporation nor the names of its contributors -// may be used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -/////////////////////////////////////////////////////////////////////////// +/******************************************************************************* + * + * Copyright (c) 2000-2003 Intel Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * - Neither name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ******************************************************************************/ #ifndef GENLIB_NET_HTTP_HTTPREADWRITE_H #define GENLIB_NET_HTTP_HTTPREADWRITE_H @@ -37,17 +37,14 @@ #include "sock.h" #include "httpparser.h" -// timeout in secs +/*! timeout in secs. */ #define HTTP_DEFAULT_TIMEOUT 30 - - #ifdef __cplusplus #extern "C" { #endif -int -http_CancelHttpGet( IN void *Handle ); +int http_CancelHttpGet(IN void *Handle); /************************************************************************ * Function: http_FixUrl @@ -65,7 +62,6 @@ http_CancelHttpGet( IN void *Handle ); ************************************************************************/ int http_FixUrl( IN uri_type* url, OUT uri_type* fixed_url ); - /************************************************************************ * Function: http_FixStrUrl * @@ -597,9 +593,9 @@ int http_OpenHttpGetEx(IN const char *url_str, void get_sdk_info( OUT char *info ); #ifdef __cplusplus -} // #extern "C" +} /* #extern "C" */ #endif -#endif // GENLIB_NET_HTTP_HTTPREADWRITE_H +#endif /* GENLIB_NET_HTTP_HTTPREADWRITE_H */ diff --git a/upnp/src/inc/membuffer.h b/upnp/src/inc/membuffer.h index 24d7c38..1be14c4 100644 --- a/upnp/src/inc/membuffer.h +++ b/upnp/src/inc/membuffer.h @@ -1,72 +1,72 @@ -/////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2000-2003 Intel Corporation -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// * Neither name of Intel Corporation nor the names of its contributors -// may be used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -/////////////////////////////////////////////////////////////////////////// +/******************************************************************************* + * + * Copyright (c) 2000-2003 Intel Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * - Neither name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ******************************************************************************/ #ifndef GENLIB_UTIL_MEMBUFFER_H #define GENLIB_UTIL_MEMBUFFER_H - #include #include "upnputil.h" #define MINVAL( a, b ) ( (a) < (b) ? (a) : (b) ) #define MAXVAL( a, b ) ( (a) > (b) ? (a) : (b) ) -// pointer to a chunk of memory -typedef struct // memptr +/*! pointer to a chunk of memory. */ +typedef struct { - char *buf; // start of memory (read/write) - size_t length; // length of memory (read-only) + /*! start of memory (read/write). */ + char *buf; + /*! length of memory (read-only). */ + size_t length; } memptr; -// maintains a block of dynamically allocated memory -// note: Total length/capacity should not exceed MAX_INT -typedef struct // membuffer +/*! Maintains a block of dynamically allocated memory + * note: Total length/capacity should not exceed MAX_INT */ +typedef struct { - char *buf; // mem buffer; must not write beyond buf[length-1] (read/write) - size_t length; // length of buffer (read-only) - size_t capacity; // total allocated memory (read-only) - size_t size_inc; // used to increase size; MUST be > 0; (read/write) - - // default value of size_inc - #define MEMBUF_DEF_SIZE_INC 5 + /*! mem buffer; must not write beyond buf[length-1] (read/write). */ + char *buf; + /*! length of buffer (read-only). */ + size_t length; + /*! total allocated memory (read-only). */ + size_t capacity; + /*! used to increase size; MUST be > 0; (read/write). */ + size_t size_inc; + /*! default value of size_inc. */ + #define MEMBUF_DEF_SIZE_INC 5 } membuffer; -//-------------------------------------------------- -//////////////// functions ///////////////////////// -//-------------------------------------------------- - #ifdef __cplusplus extern "C" { -#endif // __cplusplus +#endif /* __cplusplus */ /************************************************************************ * Function : str_alloc @@ -84,7 +84,7 @@ extern "C" { * * Note : ************************************************************************/ -char* str_alloc( IN const char* str, IN size_t str_len ); +char *str_alloc( IN const char* str, IN size_t str_len ); /************************************************************************ * Function : memptr_cmp @@ -332,7 +332,8 @@ char* membuffer_detach( INOUT membuffer* m ); ************************************************************************/ void membuffer_attach( INOUT membuffer* m, IN char* new_buf, IN size_t buf_len ); #ifdef __cplusplus -} // extern "C" -#endif // __cplusplus +} /* extern "C" */ +#endif /* __cplusplus */ + +#endif /* GENLIB_UTIL_H */ -#endif // GENLIB_UTIL_H diff --git a/upnp/src/inc/parsetools.h b/upnp/src/inc/parsetools.h index d2faee3..40fae2c 100644 --- a/upnp/src/inc/parsetools.h +++ b/upnp/src/inc/parsetools.h @@ -1,63 +1,61 @@ -/////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2000-2003 Intel Corporation -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// * Neither name of Intel Corporation nor the names of its contributors -// may be used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -/////////////////////////////////////////////////////////////////////////// +/******************************************************************************* + * + * Copyright (c) 2000-2003 Intel Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * - Neither name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ******************************************************************************/ #ifndef GENLIB_NET_HTTP_PARSETOOLS_H #define GENLIB_NET_HTTP_PARSETOOLS_H +/*! + * \file + */ + #include "upnputil.h" #include "httpparser.h" - #ifdef __cplusplus extern "C" { #endif - -/************************************************************************ -* Function: has_xml_content_type -* -* Parameters: -* IN http_message_t* hmsg ; HTTP Message object -* -* Description: Find the header from the HTTP message and match the -* header for xml data. -* -* Returns: -* BOOLEAN -************************************************************************/ -xboolean has_xml_content_type( IN http_message_t* hmsg ); +/*! + * \brief Find the header from the HTTP message and match the header for + * xml data. + * + * \return boolean. + */ +xboolean has_xml_content_type( + /*! HTTP Message object. */ + IN http_message_t *hmsg); #ifdef __cplusplus -} // extern C +} /* extern C */ #endif +#endif /* GENLIB_NET_HTTP_PARSETOOLS_H */ -#endif // GENLIB_NET_HTTP_PARSETOOLS_H diff --git a/upnp/src/inc/service_table.h b/upnp/src/inc/service_table.h index 7777ab4..2112f8a 100644 --- a/upnp/src/inc/service_table.h +++ b/upnp/src/inc/service_table.h @@ -29,38 +29,30 @@ * ******************************************************************************/ - #ifndef SERVICE_TABLE_H #define SERVICE_TABLE_H - /*! * \file */ - #ifdef __cplusplus extern "C" { #endif - #include "config.h" #include "uri.h" #include "ixml.h" #include "upnp.h" #include "upnpdebug.h" - #include #include - #define SID_SIZE 41 - #ifdef INCLUDE_DEVICE_APIS - typedef struct SUBSCRIPTION { Upnp_SID sid; int eventKey; @@ -71,7 +63,6 @@ typedef struct SUBSCRIPTION { struct SUBSCRIPTION *next; } subscription; - typedef struct SERVICE_INFO { DOMString serviceType; DOMString serviceId; @@ -85,17 +76,14 @@ typedef struct SERVICE_INFO { struct SERVICE_INFO *next; } service_info; - typedef struct SERVICE_TABLE { DOMString URLBase; service_info *serviceList; service_info *endServiceList; } service_table; - /* Functions for Subscriptions */ - /*! * \brief Makes a copy of the subscription. * @@ -107,7 +95,6 @@ int copy_subscription( /*! [in] Destination subscription. */ subscription *out); - /* * \brief Remove the subscription represented by the const Upnp_SID sid parameter * from the service table and update the service table. @@ -118,7 +105,6 @@ void RemoveSubscriptionSID( /*! [in] Service object providing the list of subscriptions. */ service_info *service); - /*! * \brief Return the subscription from the service table that matches * const Upnp_SID sid value. @@ -130,7 +116,6 @@ subscription *GetSubscriptionSID( const Upnp_SID sid, /*! [in] Service object providing the list of subscriptions. */ service_info *service); - /*! * \brief Gets pointer to the first subscription node in the service table. @@ -141,7 +126,6 @@ subscription *GetFirstSubscription( /*! [in] Service object providing the list of subscriptions. */ service_info *service); - /*! * \brief Get current and valid subscription from the service table. * @@ -153,7 +137,6 @@ subscription *GetNextSubscription( /*! [in] Current subscription object. */ subscription *current); - /*! * \brief Free's the memory allocated for storing the URL of the subscription. */ @@ -161,7 +144,6 @@ void freeSubscription( /*! [in] Subscription object to be freed. */ subscription *sub); - /*! * \brief Free's memory allocated for all the subscriptions in the service table. */ @@ -169,7 +151,6 @@ void freeSubscriptionList( /*! [in] Head of the subscription list. */ subscription * head); - /*! * \brief Traverses through the service table and returns a pointer to the * service node that matches a known service id and a known UDN. @@ -186,7 +167,6 @@ service_info *FindServiceId( * table. */ const char *UDN); - /*! * \brief Traverses the service table and finds the node whose event URL Path * matches a know value. @@ -200,7 +180,6 @@ service_info *FindServiceEventURLPath( /*! [in] Event URL path used to find a service from the table. */ char *eventURLPath); - /*! * \brief Traverses the service table and finds the node whose control URL Path * matches a know value. @@ -214,7 +193,6 @@ service_info * FindServiceControlURLPath( /*! [in] Control URL path used to find a service from the table. */ const char *controlURLPath); - /*! * \brief For debugging purposes prints information from the service passed * into the function. @@ -231,10 +209,15 @@ void printService( static UPNP_INLINE void printService( service_info *service, Upnp_LogLevel level, - Dbg_Module module) {} + Dbg_Module module) +{ + return; + service = service; + level = level; + module = module; +} #endif - /*! * \brief For debugging purposes prints information of each service from the * service table passed into the function. @@ -251,10 +234,15 @@ void printServiceList( static UPNP_INLINE void printServiceList( service_info *service, Upnp_LogLevel level, - Dbg_Module module) {} + Dbg_Module module) +{ + return; + service = service; + level = level; + module = module; +} #endif - /*! * \brief For debugging purposes prints the URL base of the table and information * of each service from the service table passed into the function. @@ -271,10 +259,15 @@ void printServiceTable( static UPNP_INLINE void printServiceTable( service_table *table, Upnp_LogLevel level, - Dbg_Module module) {} + Dbg_Module module) +{ + return; + table = table; + level = level; + module = module; +} #endif - /*! * \brief Free's memory allocated for the various components of the service * entry in the service table. @@ -283,7 +276,6 @@ void freeService( /*! [in] Service information that is to be freed. */ service_info *in); - /*! * \brief Free's memory allocated for the various components of each service * entry in the service table. @@ -292,7 +284,6 @@ void freeServiceList( /*! [in] Head of the service list to be freed. */ service_info *head); - /*! * \brief Free's dynamic memory in table (does not free table, only memory * within the structure). @@ -301,7 +292,6 @@ void freeServiceTable( /*! [in] Service table whose internal memory needs to be freed. */ service_table *table); - /*! * \brief This function assumes that services for a particular root device are * placed linearly in the service table, and in the order in which they are @@ -316,7 +306,6 @@ int removeServiceTable( /*! [in] Service table from which services will be removed. */ service_table *in); - /*! * \brief Add Service to the table. */ @@ -329,7 +318,6 @@ int addServiceTable( * service list. */ const char *DefaultURLBase); - /*! * \brief Retrieve service from the table. * @@ -343,10 +331,8 @@ int getServiceTable( /*! [in] Default base URL on which the URL will be returned. */ const char *DefaultURLBase); - /* Misc helper functions */ - /*! * \brief Returns the clone of the element value. * @@ -358,7 +344,6 @@ DOMString getElementValue( /*! [in] Input node which provides the list of child nodes. */ IXML_Node *node); - /*! * \brief Traverses through a list of XML nodes to find the node with the * known element name. @@ -375,7 +360,6 @@ int getSubElement( /*! [out] Ouput node to which the matched child node is returned. */ IXML_Node **out); - #endif /* INCLUDE_DEVICE_APIS */ #ifdef __cplusplus diff --git a/upnp/src/inc/ssdplib.h b/upnp/src/inc/ssdplib.h index ec21f66..4ca9af3 100644 --- a/upnp/src/inc/ssdplib.h +++ b/upnp/src/inc/ssdplib.h @@ -29,7 +29,6 @@ * **************************************************************************/ - #ifndef SSDPLIB_H #define SSDPLIB_H @@ -113,11 +112,8 @@ typedef enum SsdpCmdType{ #define E_SOCKET -7 #define RQST_TIMEOUT 20 - - -/* Structure to store the SSDP information */ -typedef struct SsdpEventStruct -{ +/*! Structure to store the SSDP information */ +typedef struct SsdpEventStruct { enum SsdpCmdType Cmd; enum SsdpSearchType RequestType; int ErrCode; @@ -125,7 +121,8 @@ typedef struct SsdpEventStruct int Mx; char UDN[LINE_SIZE]; char DeviceType[LINE_SIZE]; - char ServiceType[LINE_SIZE]; //NT or ST + /* NT or ST */ + char ServiceType[LINE_SIZE]; char Location[LINE_SIZE]; char HostAddr[LINE_SIZE]; char Os[LINE_SIZE]; @@ -146,7 +143,7 @@ typedef struct TData char * Data; struct sockaddr_storage DestAddr; -}ThreadData; +} ThreadData; typedef struct ssdpsearchreply { @@ -155,7 +152,7 @@ typedef struct ssdpsearchreply struct sockaddr_storage dest_addr; SsdpEvent event; -}SsdpSearchReply; +} SsdpSearchReply; typedef struct ssdpsearcharg { diff --git a/upnp/src/inc/statcodes.h b/upnp/src/inc/statcodes.h index 9ca7abb..9ce22db 100644 --- a/upnp/src/inc/statcodes.h +++ b/upnp/src/inc/statcodes.h @@ -1,38 +1,38 @@ -/////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2000-2003 Intel Corporation -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// * Neither name of Intel Corporation nor the names of its contributors -// may be used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -/////////////////////////////////////////////////////////////////////////// +/******************************************************************************* + * + * Copyright (c) 2000-2003 Intel Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * - Neither name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ******************************************************************************/ #ifndef GENLIB_NET_HTTP_STATCODES_H #define GENLIB_NET_HTTP_STATCODES_H -// HTTP response status codes +/* HTTP response status codes */ #define HTTP_CONTINUE 100 #define HTTP_SWITCHING_PROCOTOLS 101 @@ -80,15 +80,13 @@ #define HTTP_GATEWAY_TIMEOUT 504 #define HTTP_HTTP_VERSION_NOT_SUPPORTED 505 -// *********** HTTP lib error codes ********** +/* HTTP lib error codes */ #define HTTP_E_OUT_OF_MEMORY -2 #define HTTP_E_BAD_MSG_FORMAT -3 #define HTTP_E_TIMEDOUT -4 #define HTTP_E_FILE_READ -5 -// ******************************************* - #ifdef __cplusplus extern "C" { #endif @@ -109,7 +107,8 @@ extern "C" { const char* http_get_code_text( int statusCode ); #ifdef __cplusplus -} // extern C +} /* extern C */ #endif #endif /* GENLIB_NET_HTTP_STATCODES_H */ + diff --git a/upnp/src/inc/strintmap.h b/upnp/src/inc/strintmap.h index f5fffa7..bcb9d7a 100644 --- a/upnp/src/inc/strintmap.h +++ b/upnp/src/inc/strintmap.h @@ -1,33 +1,33 @@ -/////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2000-2003 Intel Corporation -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// * Neither name of Intel Corporation nor the names of its contributors -// may be used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -/////////////////////////////////////////////////////////////////////////// +/******************************************************************************* + * + * Copyright (c) 2000-2003 Intel Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * - Neither name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ******************************************************************************/ #ifndef GENLIB_UTIL_STRINTMAP_H #define GENLIB_UTIL_STRINTMAP_H @@ -35,12 +35,12 @@ #include #include "upnputil.h" -// Util to map from a string to an integer and vice versa +/* Util to map from a string to an integer and vice versa */ -typedef struct // str_int_entry +typedef struct /* str_int_entry */ { - char *name; // a value in string form - int id; // same value in integer form + char *name; /* a value in string form */ + int id; /* same value in integer form */ } str_int_entry; #ifdef __cplusplus @@ -95,8 +95,9 @@ int map_int_to_str( IN int id, IN str_int_entry* table, IN int num_entries ); #ifdef __cplusplus -} // extern C +} /* extern C */ #endif -#endif // GENLIB_UTIL_STRINTMAP_H +#endif /* GENLIB_UTIL_STRINTMAP_H */ + diff --git a/upnp/src/inc/upnputil.h b/upnp/src/inc/upnputil.h index a5d308a..f0d2801 100644 --- a/upnp/src/inc/upnputil.h +++ b/upnp/src/inc/upnputil.h @@ -1,42 +1,44 @@ -/////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2000-2003 Intel Corporation -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// * Neither name of Intel Corporation nor the names of its contributors -// may be used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -/////////////////////////////////////////////////////////////////////////// +/******************************************************************************* + * + * Copyright (c) 2000-2003 Intel Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * - Neither name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ******************************************************************************/ #ifndef UTIL_H #define UTIL_H +/*! + * \file + */ #include "upnp.h" - -// usually used to specify direction of parameters in functions +/* usually used to specify direction of parameters in functions */ #ifndef IN #define IN #endif @@ -55,7 +57,7 @@ #define EVENT_TERMINATE -3 -// boolean type in C +/*! boolean type in C. */ typedef char xboolean; #ifndef TRUE @@ -66,108 +68,73 @@ typedef char xboolean; #define FALSE 0 #endif - -/////////////////////////// -// funcs - #ifdef __cplusplus extern "C" { #endif -/************************************************************************ - * Function: logerror - * - * Parameters: - * IN const char *fmt; format string - * - * Description: Log an error message. - * - * Return: void - ************************************************************************/ -void log_error( IN const char *fmt, ... ); +/*! + * \brief Copy no of bytes spcified by the LINE_SIZE constant, from the + * source buffer. Null terminate the destination buffer. + */ +void linecopy( + /*! [out] output buffer. */ + char dest[LINE_SIZE], + /*! [in] input buffer. */ + const char *src); -/************************************************************************ - * Function: linecopy - * - * Parameters: - * OUT char dest[LINE_SIZE]; output buffer - * IN const char *src; input buffer - * - * Description: Copy no of bytes spcified by the LINE_SIZE constant, - * from the source buffer. Null terminate the destination buffer. - * - * Return: void - ************************************************************************/ -void linecopy( OUT char dest[LINE_SIZE], IN const char* src ); +/*! + * \brief Copy no of bytes spcified by the NAME_SIZE constant, from the + * source buffer. Null terminate the destination buffer + */ +void namecopy( + /*! [out] output buffer. */ + char dest[NAME_SIZE], + /*! [in] input buffer. */ + const char *src); -/************************************************************************ - * Function: namecopy +/*! + * \brief Determine if the srclen passed in paramter is less than the + * permitted LINE_SIZE. If it is use the passed parameter, if not + * use the permitted LINE_SIZE as the length parameter. * - * Parameters: - * OUT char dest[NAME_SIZE]; output buffer - * IN const char *src; input buffer - * - * Description: Copy no of bytes spcified by the NAME_SIZE constant, - * from the source buffer. Null terminate the destination buffer - * - * Return: void - ************************************************************************/ -void namecopy( OUT char dest[NAME_SIZE], IN const char* src ); - -/************************************************************************ - * Function: linecopylen - * - * Parameters: - * OUT char dest[LINE_SIZE]; output buffer - * IN const char *src; input buffer - * IN size_t srclen; bytes to be copied. - * - * Description : Determine if the srclen passed in paramter is less than - * the permitted LINE_SIZE. If it is use the passed parameter, if not - * use the permitted LINE_SIZE as the length parameter - * Copy no of bytes spcified by the LINE_SIZE constant, - * from the source buffer. Null terminate the destination buffer - * - * Return: void - ************************************************************************/ -void linecopylen( OUT char dest[LINE_SIZE], IN const char* src, IN size_t srclen ); - + * Copy no of bytes spcified by the LINE_SIZE constant, from the source + * buffer. Null terminate the destination buffer. + */ +void linecopylen( + /*! [out] output buffer. */ + char dest[LINE_SIZE], + /*! [in] input buffer. */ + const char *src, + /*! [in] bytes to be copied. */ + size_t srclen); #ifdef __cplusplus -} // extern C +} #endif /* Size of the errorBuffer variable, passed to the strerror_r() function */ #define ERROR_BUFFER_LEN 256 -////////////////////////////////// -// C specific +/* C specific */ #ifndef __cplusplus - -#ifdef WIN32 - #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 - - #define EADDRINUSE WSAEADDRINUSE - - #define strcasecmp stricmp - #define strncasecmp strnicmp - - #define sleep(a) Sleep((a)*1000) - #define usleep(a) Sleep((a)/1000) - - #define strerror_r(a,b,c) (strerror_s((b),(c),(a))) -#else - #define max(a, b) (((a)>(b))? (a):(b)) - #define min(a, b) (((a)<(b))? (a):(b)) -#endif /* WIN32 */ - -#endif // __cplusplus + #ifdef WIN32 + #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 + #define EADDRINUSE WSAEADDRINUSE + #define strcasecmp stricmp + #define strncasecmp strnicmp + #define sleep(a) Sleep((a)*1000) + #define usleep(a) Sleep((a)/1000) + #define strerror_r(a,b,c) (strerror_s((b),(c),(a))) + #else + #define max(a, b) (((a)>(b))? (a):(b)) + #define min(a, b) (((a)<(b))? (a):(b)) + #endif /* WIN32 */ +#endif /* __cplusplus */ #endif /* UTIL_H */ diff --git a/upnp/src/inc/uri.h b/upnp/src/inc/uri.h index e372a5c..8230540 100644 --- a/upnp/src/inc/uri.h +++ b/upnp/src/inc/uri.h @@ -29,11 +29,9 @@ * ******************************************************************************/ - #ifndef GENLIB_NET_URI_H #define GENLIB_NET_URI_H - /*! * \file */ @@ -42,11 +40,9 @@ #include #endif - #include "UpnpGlobal.h" /* for */ #include "UpnpInet.h" - #include #include #include @@ -58,7 +54,6 @@ #include #include - #ifdef WIN32 #include "inet_pton.h" #else @@ -66,49 +61,45 @@ #include /* for struct addrinfo */ #endif - #ifdef WIN32 #define strncasecmp strnicmp #else /* Other systems have strncasecmp */ #endif - #ifdef __cplusplus extern "C" { #endif +/*! length for HTTP DATE: "DATE: Sun, 01 Jul 2000 08:15:23 GMT" */ +#define HTTP_DATE_LENGTH 37 -#define HTTP_DATE_LENGTH 37 // length for HTTP DATE: - //"DATE: Sun, 01 Jul 2000 08:15:23 GMT" #define SEPARATORS "()<>@,;:\\\"/[]?={} \t" #define MARK "-_.!~*'()" -#define RESERVED ";/?:@&=+$,{}" //added {} for compatibility + +/*! added {} for compatibility */ +#define RESERVED ";/?:@&=+$,{}" + #define HTTP_SUCCESS 1 - - #define FALSE 0 #define TAB 9 #define CR 13 #define LF 10 #define SOCKET_BUFFER_SIZE 5000 - enum hostType { HOSTNAME, IPv4address }; - enum pathType { ABS_PATH, REL_PATH, OPAQUE_PART }; - #ifdef WIN32 - /* there is a conflict in windows with other symbols */ + /* there is a conflict in windows with other symbols. */ enum uriType { absolute, relative @@ -120,7 +111,6 @@ enum pathType { }; #endif - /*! * \brief Buffer used in parsinghttp messages, urls, etc. generally this simply * holds a pointer into a larger array. @@ -130,7 +120,6 @@ typedef struct TOKEN { size_t size; } token; - /*! * \brief Represents a host port: e.g. "127.127.0.1:80" text is a token * pointing to the full string representation. @@ -142,7 +131,6 @@ typedef struct HOSTPORT { struct sockaddr_storage IPaddress; } hostport_type; - /*! * \brief Represents a URI used in parse_uri and elsewhere */ @@ -155,7 +143,6 @@ typedef struct URI{ hostport_type hostport; } uri_type; - /*! * \brief Represents a list of URLs as in the "callback" header of SUBSCRIBE * message in GENA. "char *" URLs holds dynamic memory. @@ -169,7 +156,6 @@ typedef struct URL_LIST { uri_type *parsedURLs; } URL_list; - /*! * \brief Replaces an escaped sequence with its unescaped version as in * http://www.ietf.org/rfc/rfc2396.txt (RFC explaining URIs) @@ -190,7 +176,6 @@ int replace_escaped( /*! [out] . */ size_t *max); - /*! * \brief Copies one URL_list into another. * @@ -218,7 +203,6 @@ void free_URL_list( /*! [in] URL list object. */ URL_list *list); - /*! * \brief Function useful in debugging for printing a parsed uri. */ @@ -227,10 +211,13 @@ void print_uri( /*! [in] URI object to print. */ uri_type *in); #else -static UPNP_INLINE void print_uri(uri_type *in) {} +static UPNP_INLINE void print_uri(uri_type *in) +{ + return; + in = in; +} #endif - /*! * \brief Function useful in debugging for printing a token. */ @@ -239,10 +226,15 @@ void print_token( /*! [in] Token object to print. */ token *in); #else -static UPNP_INLINE void print_token(token * in) {} +static UPNP_INLINE void print_token( + /*! [in] Token object to print. */ + token *in) +{ + return; + in = in; +} #endif - /*! * \brief Compares buffer in the token object with the buffer in in2. * @@ -257,7 +249,6 @@ int token_string_casecmp( /*! [in] String of characters to compare with. */ char *in2); - /*! * \brief Compares a null terminated string to a token (exact). * @@ -272,7 +263,6 @@ int token_string_cmp( /*! [in] String of characters to compare with. */ char *in2); - /*! * \brief Compares two tokens. * @@ -287,7 +277,6 @@ int token_cmp( /*! [in] Second token object used for the comparison. */ token *in2); - /*! * \brief Parses a string representing a host and port (e.g. "127.127.0.1:80" * or "localhost") and fills out a hostport_type struct with internet address @@ -304,7 +293,6 @@ int parse_hostport( * an internet address. */ hostport_type *out); - /*! * \brief Removes http escaped characters such as: "%20" and replaces them with * their character representation. i.e. "hello%20foo" -> "hello foo". @@ -320,7 +308,6 @@ int remove_escaped_chars( /*! [in,out] Size limit for the number of characters. */ size_t *size); - /*! * \brief Removes ".", and ".." from a path. * @@ -349,7 +336,6 @@ int remove_dots( /*! [in] Size limit for the number of characters. */ size_t size); - /*! * \brief resolves a relative url with a base url returning a NEW (dynamically * allocated with malloc) full url. @@ -370,7 +356,6 @@ char *resolve_rel_url( /*! [in] Relative URL. */ char *rel_url); - /*! * \brief Parses a uri as defined in http://www.ietf.org/rfc/rfc2396.txt * (RFC explaining URIs). @@ -391,7 +376,6 @@ int parse_uri( /*! [out] Output parameter which will have the parsed uri information. */ uri_type *out); - /*! * \brief Same as parse_uri(), except that all strings are unescaped * (%XX replaced by chars). @@ -408,7 +392,6 @@ int parse_uri_and_unescape( /*! [out] Output parameter which will have the parsed uri information. */ uri_type *out); - /*! * \brief * @@ -422,7 +405,6 @@ int parse_token( /*! [in] . */ int max_size); - /* Commented #defines, functions and typdefs */ #if 0 diff --git a/upnp/src/inc/webserver.h b/upnp/src/inc/webserver.h index f5e7840..36e86ba 100644 --- a/upnp/src/inc/webserver.h +++ b/upnp/src/inc/webserver.h @@ -130,9 +130,9 @@ void web_server_callback( #ifdef __cplusplus -} // extern C +} /* extern C */ #endif -#endif // GENLIB_NET_HTTP_WEBSERVER_H +#endif /* GENLIB_NET_HTTP_WEBSERVER_H */ diff --git a/upnp/src/soap/soap_ctrlpt.c b/upnp/src/soap/soap_ctrlpt.c index 3d3a5f1..f4bc97e 100644 --- a/upnp/src/soap/soap_ctrlpt.c +++ b/upnp/src/soap/soap_ctrlpt.c @@ -1,33 +1,33 @@ -/////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2000-2003 Intel Corporation -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// * Neither name of Intel Corporation nor the names of its contributors -// may be used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -/////////////////////////////////////////////////////////////////////////// +/******************************************************************************* + * + * Copyright (c) 2000-2003 Intel Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * - Neither name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ******************************************************************************/ #include "config.h" #ifdef INCLUDE_CLIENT_APIS @@ -54,9 +54,9 @@ #define SOAP_ACTION_RESP 1 #define SOAP_VAR_RESP 2 -//#define SOAP_ERROR_RESP 3 +/*#define SOAP_ERROR_RESP 3*/ #define SOAP_ACTION_RESP_ERROR 3 -#define SOAP_VAR_RESP_ERROR 4 +#define SOAP_VAR_RESP_ERROR 4 /**************************************************************************** * Function : dom_cmp_name @@ -96,7 +96,7 @@ dom_cmp_name( IN char *name, strcmp( nameptr.buf, name ) == 0 ) { ret_code = 0; } else { - ret_code = 1; // names are not the same + ret_code = 1; /* names are not the same */ } return ret_code; @@ -125,20 +125,20 @@ dom_find_node( IN char *node_name, { IXML_Node *node; - // invalid args + /* invalid args */ if( node_name == NULL || start_node == NULL ) { return UPNP_E_NOT_FOUND; } node = ixmlNode_getFirstChild( start_node ); while( node != NULL ) { - // match name + /* match name */ if( dom_cmp_name( node_name, node ) == 0 ) { *matching_node = node; return UPNP_E_SUCCESS; } - // free and next node - node = ixmlNode_getNextSibling( node ); // next node + /* free and next node */ + node = ixmlNode_getNextSibling( node ); /* next node */ } return UPNP_E_NOT_FOUND; @@ -193,10 +193,10 @@ dom_find_deep_node( IN char *names[], return UPNP_E_SUCCESS; } - node = match_node; // try again + node = match_node; /* try again */ } - return UPNP_E_NOT_FOUND; // this line not reached + return UPNP_E_NOT_FOUND; /* this line not reached */ } /**************************************************************************** @@ -253,7 +253,7 @@ get_host_and_path( IN char *ctrl_url, if( parse_uri( ctrl_url, strlen( ctrl_url ), url ) != HTTP_SUCCESS ) { return -1; } - // This is done to ensure that the buffer is kept const + /* This is done to ensure that the buffer is kept const */ ((memptr *)host)->buf = (char *)url->hostport.text.buff; ((memptr *)host)->length = url->hostport.text.size; @@ -310,15 +310,15 @@ add_man_header( INOUT membuffer * headers ) char *man_hdr = "MAN: \"http://schemas.xmlsoap.org/soap/envelope/\"; " "ns=01\r\n01-"; - // change POST to M-POST + /* change POST to M-POST */ if( membuffer_insert( headers, "M-", 2, 0 ) != 0 ) { return UPNP_E_OUTOF_MEMORY; } soap_action_hdr = strstr( headers->buf, "SOAPACTION:" ); - assert( soap_action_hdr != NULL ); // can't fail + assert( soap_action_hdr != NULL ); /* can't fail */ - // insert MAN header + /* insert MAN header */ if( membuffer_insert( headers, man_hdr, strlen( man_hdr ), soap_action_hdr - headers->buf ) != 0 ) { return UPNP_E_OUTOF_MEMORY; @@ -357,16 +357,16 @@ soap_request_and_response( IN membuffer * request, httpmsg_destroy( &response->msg ); return ret_code; } - // method-not-allowed error + /* method-not-allowed error */ if( response->msg.status_code == HTTP_METHOD_NOT_ALLOWED ) { - ret_code = add_man_header( request ); // change to M-POST msg + ret_code = add_man_header( request ); /* change to M-POST msg */ if( ret_code != 0 ) { return ret_code; } - httpmsg_destroy( &response->msg ); // about to reuse response + httpmsg_destroy( &response->msg ); /* about to reuse response */ - // try again + /* try again */ ret_code = http_RequestAndResponse( destination_url, request->buf, request->length, HTTPMETHOD_MPOST, @@ -423,9 +423,9 @@ get_response_value( IN http_message_t * hmsg, char *names[5]; const DOMString nodeValue; - err_code = UPNP_E_BAD_RESPONSE; // default error + err_code = UPNP_E_BAD_RESPONSE; /* default error */ - // only 200 and 500 status codes are relevant + /* only 200 and 500 status codes are relevant */ if( ( hmsg->status_code != HTTP_OK && hmsg->status_code != HTTP_INTERNAL_SERVER_ERROR ) || !has_xml_content_type( hmsg ) ) { @@ -445,9 +445,9 @@ get_response_value( IN http_message_t * hmsg, } if( code == SOAP_ACTION_RESP ) { - // - // try reading soap action response - // + /* */ + /* try reading soap action response */ + /* */ assert( action_value != NULL ); *action_value = NULL; @@ -474,7 +474,7 @@ get_response_value( IN http_message_t * hmsg, done = TRUE; } } else if( code == SOAP_VAR_RESP ) { - // try reading var response + /* try reading var response */ assert( str_value != NULL ); *str_value = NULL; @@ -496,7 +496,7 @@ get_response_value( IN http_message_t * hmsg, } if( !done ) { - // not action or var resp; read error code and description + /* not action or var resp; read error code and description */ *str_value = NULL; names[0] = "Envelope"; @@ -522,7 +522,7 @@ get_response_value( IN http_message_t * hmsg, *upnp_error_code = atoi( temp_str ); if( *upnp_error_code < 400 ) { err_code = *upnp_error_code; - goto error_handler; // bad SOAP error code + goto error_handler; /* bad SOAP error code */ } if( code == SOAP_VAR_RESP ) { @@ -616,27 +616,27 @@ SoapSendAction( IN char *action_url, size_t xml_end_len; size_t action_str_len; - *response_node = NULL; // init + *response_node = NULL; /* init */ - err_code = UPNP_E_OUTOF_MEMORY; // default error + err_code = UPNP_E_OUTOF_MEMORY; /* default error */ UpnpPrintf( UPNP_INFO, SOAP, __FILE__, __LINE__, "Inside SoapSendAction():" ); - // init + /* init */ membuffer_init( &request ); membuffer_init( &responsename ); - // print action + /* print action */ action_str = ixmlPrintNode( ( IXML_Node * ) action_node ); if( action_str == NULL ) { goto error_handler; } - // get action name + /* get action name */ if( get_action_name( action_str, &name ) != 0 ) { err_code = UPNP_E_INVALID_ACTION; goto error_handler; } - // parse url + /* parse url */ if( http_FixStrUrl( action_url, strlen( action_url ), &url ) != 0 ) { err_code = UPNP_E_INVALID_URL; goto error_handler; @@ -653,7 +653,7 @@ SoapSendAction( IN char *action_url, xml_end_len = strlen( xml_end ); action_str_len = strlen( action_str ); - // make request msg + /* make request msg */ request.size_inc = 50; content_length = xml_start_len + action_str_len + xml_end_len; if (http_MakeMessage( @@ -680,7 +680,7 @@ SoapSendAction( IN char *action_url, membuffer_append_str( &responsename, "Response" ) != 0 ) { goto error_handler; } - // get action node from the response + /* get action node from the response */ ret_code = get_response_value( &response.msg, SOAP_ACTION_RESP, responsename.buf, &upnp_error_code, ( IXML_Node ** ) response_node, @@ -767,32 +767,32 @@ SoapSendActionEx( IN char *action_url, size_t xml_end_len; off_t content_length; - *response_node = NULL; // init + *response_node = NULL; /* init */ - err_code = UPNP_E_OUTOF_MEMORY; // default error + err_code = UPNP_E_OUTOF_MEMORY; /* default error */ UpnpPrintf( UPNP_INFO, SOAP, __FILE__, __LINE__, "Inside SoapSendActionEx():" ); - // init + /* init */ membuffer_init( &request ); membuffer_init( &responsename ); - // header string + /* header string */ xml_header_str = ixmlPrintNode( ( IXML_Node * ) header ); if( xml_header_str == NULL ) { goto error_handler; } - // print action + /* print action */ action_str = ixmlPrintNode( ( IXML_Node * ) action_node ); if( action_str == NULL ) { goto error_handler; } - // get action name + /* get action name */ if( get_action_name( action_str, &name ) != 0 ) { err_code = UPNP_E_INVALID_ACTION; goto error_handler; } - // parse url + /* parse url */ if( http_FixStrUrl( action_url, strlen( action_url ), &url ) != 0 ) { err_code = UPNP_E_INVALID_URL; goto error_handler; @@ -814,7 +814,7 @@ SoapSendActionEx( IN char *action_url, xml_header_end_len = strlen( xml_header_end ); xml_header_str_len = strlen( xml_header_str ); - // make request msg + /* make request msg */ request.size_inc = 50; content_length = xml_start_len + @@ -848,7 +848,7 @@ SoapSendActionEx( IN char *action_url, membuffer_append_str( &responsename, "Response" ) != 0 ) { goto error_handler; } - // get action node from the response + /* get action node from the response */ ret_code = get_response_value( &response.msg, SOAP_ACTION_RESP, responsename.buf, &upnp_error_code, ( IXML_Node ** ) response_node, @@ -896,8 +896,8 @@ SoapGetServiceVarStatus( IN char *action_url, IN char *var_name, OUT char **var_value ) { - const memptr host; // value for HOST header - const memptr path; // ctrl path in first line in msg + const memptr host; /* value for HOST header */ + const memptr path; /* ctrl path in first line in msg */ uri_type url; membuffer request; int ret_code; @@ -919,15 +919,15 @@ SoapGetServiceVarStatus( IN char *action_url, "\r\n" "\r\n"; - *var_value = NULL; // return NULL in case of an error + *var_value = NULL; /* return NULL in case of an error */ membuffer_init( &request ); - // get host hdr and url path + /* get host hdr and url path */ if( get_host_and_path( action_url, &host, &path, &url ) == -1 ) { return UPNP_E_INVALID_URL; } - // make headers + /* make headers */ request.size_inc = 50; content_length = strlen( xml_start ) + strlen( var_name ) + strlen( xml_end ); if (http_MakeMessage( @@ -941,13 +941,13 @@ SoapGetServiceVarStatus( IN char *action_url, xml_start, var_name, xml_end ) != 0 ) { return UPNP_E_OUTOF_MEMORY; } - // send msg and get reply + /* send msg and get reply */ ret_code = soap_request_and_response( &request, &url, &response ); membuffer_destroy( &request ); if( ret_code != UPNP_E_SUCCESS ) { return ret_code; } - // get variable value from the response + /* get variable value from the response */ ret_code = get_response_value( &response.msg, SOAP_VAR_RESP, NULL, &upnp_error_code, NULL, var_value ); @@ -962,5 +962,6 @@ SoapGetServiceVarStatus( IN char *action_url, } } -#endif // EXCLUDE_SOAP -#endif // INCLUDE_CLIENT_APIS +#endif /* EXCLUDE_SOAP */ +#endif /* INCLUDE_CLIENT_APIS */ + diff --git a/upnp/src/soap/soap_device.c b/upnp/src/soap/soap_device.c index 4fc7aa6..b321b50 100644 --- a/upnp/src/soap/soap_device.c +++ b/upnp/src/soap/soap_device.c @@ -29,19 +29,15 @@ * ******************************************************************************/ - /*! * \file */ - #include "config.h" - #ifdef INCLUDE_DEVICE_APIS #if EXCLUDE_SOAP == 0 - #define SOAP_BODY "Body" #define SOAP_URN "http:/""/schemas.xmlsoap.org/soap/envelope/" @@ -58,12 +54,10 @@ #include "unixutil.h" #include "upnpapi.h" - #ifdef WIN32 #define snprintf _snprintf #endif - /*! timeout duration in secs for transmission/reception */ #define SOAP_TIMEOUT UPNP_TIMEOUT @@ -85,23 +79,16 @@ static const char *Soap_Invalid_Var = "Invalid Var"; const char *ContentTypeHeader = "CONTENT-TYPE: text/xml; charset=\"utf-8\"\r\n"; - -/**************************************************************************** -* Function : get_request_type -* -* Parameters : -* IN http_message_t* request : HTTP request -* OUT memptr* action_name : SOAP action name -* -* Description : This function retrives the name of the SOAP action -* -* Return : int -* 0 if successful else returns appropriate error. -* Note : -****************************************************************************/ -static UPNP_INLINE int -get_request_type( IN http_message_t * request, - OUT memptr * action_name ) +/*! + * \brief This function retrives the name of the SOAP action. + * + * \return 0 if successful else returns appropriate error. + */ +static UPNP_INLINE int get_request_type( + /*! [in] HTTP request. */ + http_message_t *request, + /*! [out] SOAP action name. */ + memptr *action_name) { memptr value; memptr ns_value, @@ -111,16 +98,15 @@ get_request_type( IN http_message_t * request, char *s; membuffer soap_action_name; - // find soapaction header - // + /* find soapaction header */ if( request->method == SOAPMETHOD_POST ) { if( httpmsg_find_hdr( request, HDR_SOAPACTION, &value ) == NULL ) { return SREQ_HDR_NOT_FOUND; } - } else // M-POST - { - // get NS value from MAN header + } else { + /* M-POST */ + /* get NS value from MAN header */ hdr = httpmsg_find_hdr( request, HDR_MAN, &value ); if( hdr == NULL ) { return SREQ_HDR_NOT_FOUND; @@ -130,7 +116,7 @@ get_request_type( IN http_message_t * request, &dummy_quote, &ns_value ) != 0 ) { return SREQ_BAD_HDR_FORMAT; } - // create soapaction name header + /* create soapaction name header */ membuffer_init( &soap_action_name ); if( ( membuffer_assign( &soap_action_name, ns_value.buf, ns_value.length ) @@ -153,8 +139,7 @@ get_request_type( IN http_message_t * request, value.length = hdr->value.length; } - // determine type - // + /* determine type */ save_char = value.buf[value.length]; value.buf[value.length] = '\0'; @@ -164,21 +149,22 @@ get_request_type( IN http_message_t * request, return SREQ_BAD_HDR_FORMAT; } - s++; // move to value + /* move to value */ + s++; if( matchstr( s, value.length - ( s - value.buf ), "%s", action_name ) != PARSE_OK ) { value.buf[value.length] = save_char; return SREQ_BAD_HDR_FORMAT; } - // action name or variable ? + /* action name or variable ? */ if( memptr_cmp( action_name, "QueryStateVariable" ) == 0 ) { - // query variable + /* query variable */ action_name->buf = NULL; action_name->length = 0; } - - value.buf[value.length] = save_char; // restore + /* restore */ + value.buf[value.length] = save_char; return 0; } @@ -208,7 +194,7 @@ send_error_response( IN SOCKINFO * info, int major, minor; const char *start_body = -// "\n" required?? +/* "\n" required?? */ "\n" @@ -233,14 +219,14 @@ send_error_response( IN SOCKINFO * info, sprintf( err_code_str, "%d", error_code ); - // calc body len + /* calc body len */ content_length = strlen( start_body ) + strlen( err_code_str ) + strlen( mid_body ) + strlen( err_msg ) + strlen( end_body ); http_CalcResponseVersion( hmsg->major_version, hmsg->minor_version, &major, &minor ); - // make headers + /* make headers */ membuffer_init( &headers ); if (http_MakeMessage( &headers, major, minor, @@ -253,9 +239,9 @@ send_error_response( IN SOCKINFO * info, start_body, err_code_str, mid_body, err_msg, end_body ) != 0 ) { membuffer_destroy( &headers ); - return; // out of mem + return; /* out of mem */ } - // send err msg + /* send err msg */ http_SendMessage( info, &timeout_secs, "b", headers.buf, headers.length ); @@ -306,7 +292,7 @@ send_var_query_response( IN SOCKINFO * info, content_length = strlen( start_body ) + strlen( var_value ) + strlen( end_body ); - // make headers + /* make headers */ membuffer_init( &response ); if (http_MakeMessage( @@ -319,10 +305,10 @@ send_var_query_response( IN SOCKINFO * info, X_USER_AGENT, start_body, var_value, end_body ) != 0 ) { membuffer_destroy( &response ); - return; // out of mem + return; /* out of mem */ } - // send msg + /* send msg */ http_SendMessage( info, &timeout_secs, "b", response.buf, response.length ); @@ -355,7 +341,7 @@ get_action_node( IN IXML_Document * TempDoc, IXML_Node *ActNode = NULL; DOMString ActNodeName = NULL; const DOMString nodeName; - int ret_code = -1; // error, by default + int ret_code = -1; /* error, by default */ IXML_NodeList *nl = NULL; UpnpPrintf( UPNP_INFO, SOAP, __FILE__, __LINE__, @@ -363,7 +349,7 @@ get_action_node( IN IXML_Document * TempDoc, *RespNode = NULL; - // Got the Envelope node here + /* Got the Envelope node here */ EnvpNode = ixmlNode_getFirstChild( ( IXML_Node * ) TempDoc ); if( EnvpNode == NULL ) { goto error_handler; @@ -381,12 +367,12 @@ get_action_node( IN IXML_Document * TempDoc, if( BodyNode == NULL ) { goto error_handler; } - // Got action node here + /* Got action node here */ ActNode = ixmlNode_getFirstChild( BodyNode ); if( ActNode == NULL ) { goto error_handler; } - //Test whether this is the action node + /* Test whether this is the action node */ nodeName = ixmlNode_getNodeName( ActNode ); if( nodeName == NULL ) { goto error_handler; @@ -408,7 +394,7 @@ get_action_node( IN IXML_Document * TempDoc, } } - ret_code = 0; // success + ret_code = 0; /* success */ error_handler: @@ -500,8 +486,7 @@ check_soap_action_header( IN http_message_t * request, char *temp = NULL; char *temp2 = NULL; - //check soap action header - + /* check soap action header */ soap_action_header = httpmsg_find_hdr( request, HDR_SOAPACTION, &header_name ); @@ -535,35 +520,28 @@ check_soap_action_header( IN http_message_t * request, return ret_code; } - ( *temp ) = 0; //temp make string - - //check to see if it is Query State Variable or - //Service Action + ( *temp ) = 0; /* temp make string */ + /* check to see if it is Query State Variable or + * Service Action */ tempSize = strlen( urn ) + 2; - ns_compare = ( char * )malloc( tempSize ); - if( !ns_compare ) { ret_code = UPNP_E_OUTOF_MEMORY; free( temp_header_value ); return ret_code; } - snprintf( ns_compare, tempSize, "\"%s", urn ); - if( strcmp( temp_header_value, ns_compare ) ) { ret_code = UPNP_E_INVALID_ACTION; } else { ret_code = UPNP_E_SUCCESS; temp++; temp2 = strchr( temp, '\"' ); - - if( temp2 ) //remove ending " if present + if( temp2 ) /* remove ending " if present */ { ( *temp2 ) = 0; } - if( *temp ) ( *actionName ) = strdup( temp ); if( !*actionName ) { @@ -613,11 +591,11 @@ get_device_info( IN http_message_t *request, int device_hnd; service_info *serv_info; char save_char; - int ret_code = -1; // error by default + int ret_code = -1; /* error by default */ const char *control_url; char *actionName = NULL; - // null-terminate pathquery of url + /* null-terminate pathquery of url */ control_url = request->uri.pathquery.buff; save_char = control_url[request->uri.pathquery.size]; ((char *)control_url)[request->uri.pathquery.size] = '\0'; @@ -643,7 +621,7 @@ get_device_info( IN http_message_t *request, ret_code = UPNP_E_INVALID_ACTION; goto error_handler; } - //check soap body + /* check soap body */ ret_code = check_soap_body( actionDoc, QUERY_STATE_VAR_URN, actionName ); free( actionName ); @@ -659,7 +637,7 @@ get_device_info( IN http_message_t *request, ret_code = UPNP_E_INVALID_SERVICE; goto error_handler; } - //check soap body + /* check soap body */ ret_code = check_soap_body( actionDoc, serv_info->serviceType, actionName ); @@ -677,8 +655,8 @@ get_device_info( IN http_message_t *request, ret_code = 0; - error_handler: - ((char *)control_url)[request->uri.pathquery.size] = save_char; // restore +error_handler: + ((char *)control_url)[request->uri.pathquery.size] = save_char; /* restore */ HandleUnlock(); return ret_code; } @@ -711,19 +689,18 @@ send_action_response( IN SOCKINFO * info, int ret_code; int timeout_secs = SOAP_TIMEOUT; static char *start_body = -// "" required?? + /*"" required?? */ "\n"; static char *end_body = " "; - // init + /* init */ http_CalcResponseVersion( request->major_version, request->minor_version, &major, &minor ); membuffer_init( &headers ); - err_code = UPNP_E_OUTOF_MEMORY; // one error only - - // get xml + err_code = UPNP_E_OUTOF_MEMORY; /* one error only */ + /* get xml */ xml_response = ixmlPrintNode( ( IXML_Node * ) action_resp ); if( xml_response == NULL ) { goto error_handler; @@ -733,20 +710,18 @@ send_action_response( IN SOCKINFO * info, strlen( start_body ) + strlen( xml_response ) + strlen( end_body ); - - // make headers + /* make headers */ if (http_MakeMessage( &headers, major, minor, "RNsDsSXcc", - HTTP_OK, // status code + HTTP_OK, /* status code */ content_length, ContentTypeHeader, "EXT:\r\n", X_USER_AGENT) != 0 ) { goto error_handler; } - - // send whole msg + /* send whole msg */ ret_code = http_SendMessage( info, &timeout_secs, "bbbb", headers.buf, headers.length, start_body, strlen( start_body ), @@ -765,7 +740,7 @@ error_handler: ixmlFreeDOMString( xml_response ); membuffer_destroy( &headers ); if( err_code != 0 ) { - // only one type of error to worry about - out of mem + /* only one type of error to worry about - out of mem */ send_error_response( info, SOAP_ACTION_FAILED, "Out of memory", request ); } @@ -798,22 +773,22 @@ get_var_name( IN IXML_Document * TempDoc, const DOMString Temp = NULL; int ret_val = -1; - // Got the Envelop node here + /* Got the Envelop node here */ EnvpNode = ixmlNode_getFirstChild( ( IXML_Node * ) TempDoc ); if( EnvpNode == NULL ) { goto error_handler; } - // Got Body here + /* Got Body here */ BodyNode = ixmlNode_getFirstChild( EnvpNode ); if( BodyNode == NULL ) { goto error_handler; } - // Got action node here + /* Got action node here */ StNode = ixmlNode_getFirstChild( BodyNode ); if( StNode == NULL ) { goto error_handler; } - //Test whether this is the action node + /* Test whether this is the action node */ StNodeName = ixmlNode_getNodeName( StNode ); if( StNodeName == NULL || strstr( StNodeName, "QueryStateVariable" ) == NULL ) { @@ -833,7 +808,7 @@ get_var_name( IN IXML_Document * TempDoc, "Received query for variable name %s\n", VarName ); - ret_val = 0; // success + ret_val = 0; /* success */ error_handler: return ret_val; @@ -957,19 +932,19 @@ handle_invoke_action( IN SOCKINFO * info, int err_code; const char *err_str; - // null-terminate + /* null-terminate */ save_char = action_name.buf[action_name.length]; action_name.buf[action_name.length] = '\0'; - // set default error + /* set default error */ err_code = SOAP_INVALID_ACTION; err_str = Soap_Invalid_Action; - // get action node + /* get action node */ if( get_action_node( xml_doc, action_name.buf, &actionRequestDoc ) == -1 ) { goto error_handler; } - // get device info for action event + /* get device info for action event */ err_code = get_device_info( request, 0, @@ -1005,21 +980,21 @@ handle_invoke_action( IN SOCKINFO * info, } goto error_handler; } - // validate, and handle action error + /* validate, and handle action error */ actionResultDoc = UpnpActionRequest_get_ActionResult(action); if (actionResultDoc == NULL) { err_code = SOAP_ACTION_FAILED; err_str = Soap_Action_Failed; goto error_handler; } - // send response + /* send response */ send_action_response(info, actionResultDoc, request); err_code = 0; - // error handling and cleanup + /* error handling and cleanup */ error_handler: - action_name.buf[action_name.length] = save_char; // restore + action_name.buf[action_name.length] = save_char; /* restore */ if( err_code != 0 ) { send_error_response( info, err_code, err_str, request ); } @@ -1056,19 +1031,19 @@ soap_device_callback( IN http_parser_t * parser, memptr action_name; IXML_Document *xml_doc = NULL; - // set default error + /* set default error */ err_code = SOAP_INVALID_ACTION; err_str = Soap_Invalid_Action; - // validate: content-type == text/xml + /* validate: content-type == text/xml */ if( !has_xml_content_type( request ) ) { goto error_handler; } - // type of request + /* type of request */ if( get_request_type( request, &action_name ) != 0 ) { goto error_handler; } - // parse XML + /* parse XML */ err_code = ixmlParseBufferEx( request->entity.buf, &xml_doc ); if( err_code != IXML_SUCCESS ) { if( err_code == IXML_INSUFFICIENT_MEMORY ) { @@ -1082,14 +1057,14 @@ soap_device_callback( IN http_parser_t * parser, } if( action_name.length == 0 ) { - // query var + /* query var */ handle_query_variable( info, request, xml_doc ); } else { - // invoke action + /* invoke action */ handle_invoke_action( info, request, action_name, xml_doc ); } - err_code = 0; // no error + err_code = 0; /* no error */ error_handler: ixmlDocument_free( xml_doc ); @@ -1098,6 +1073,7 @@ soap_device_callback( IN http_parser_t * parser, } } -#endif // EXCLUDE_SOAP +#endif /* EXCLUDE_SOAP */ + +#endif /* INCLUDE_DEVICE_APIS */ -#endif // INCLUDE_DEVICE_APIS diff --git a/upnp/src/ssdp/ssdp_ctrlpt.c b/upnp/src/ssdp/ssdp_ctrlpt.c index 4321f32..2225be3 100644 --- a/upnp/src/ssdp/ssdp_ctrlpt.c +++ b/upnp/src/ssdp/ssdp_ctrlpt.c @@ -29,17 +29,13 @@ * **************************************************************************/ - #include "config.h" - #include "upnputil.h" - #ifdef INCLUDE_CLIENT_APIS #if EXCLUDE_SSDP == 0 - #include "httpparser.h" #include "httpreadwrite.h" #include "ssdp_ResultData.h" @@ -50,15 +46,12 @@ #include "UpnpInet.h" #include "ThreadPool.h" - #include - #ifdef WIN32 #include #endif /* WIN32 */ - /************************************************************************ * Function: send_search_result * @@ -107,13 +100,16 @@ void send_search_result(IN void *data) void ssdp_handle_ctrlpt_msg( IN http_message_t *hmsg, IN struct sockaddr_storage *dest_addr, - IN xboolean timeout, // only in search reply - IN void *cookie) // only in search reply + /* only in search reply */ + IN xboolean timeout, + /* only in search reply */ + IN void *cookie) { int handle; struct Handle_Info *ctrlpt_info = NULL; memptr hdr_value; - xboolean is_byebye; // byebye or alive + /* byebye or alive */ + xboolean is_byebye; UpnpDiscovery *param = UpnpDiscovery_new(); int expires; int ret; @@ -131,20 +127,18 @@ void ssdp_handle_ctrlpt_msg( SSDPResultData *threadData = NULL; ThreadPoolJob job; - // we are assuming that there can be only one client supported at a time - + /* we are assuming that there can be only one client supported at a time */ HandleReadLock(); if ( GetClientHandleInfo( &handle, &ctrlpt_info ) != HND_CLIENT ) { HandleUnlock(); goto end_ssdp_handle_ctrlpt_msg; } - // copy + /* copy */ ctrlpt_callback = ctrlpt_info->Callback; ctrlpt_cookie = ctrlpt_info->Cookie; HandleUnlock(); - - // search timeout + /* search timeout */ if ( timeout ) { ctrlpt_callback( UPNP_DISCOVERY_SEARCH_TIMEOUT, NULL, cookie ); goto end_ssdp_handle_ctrlpt_msg; @@ -152,8 +146,7 @@ void ssdp_handle_ctrlpt_msg( UpnpDiscovery_set_ErrCode(param, UPNP_E_SUCCESS); - // MAX-AGE - // assume error + /* MAX-AGE, assume error */ expires = -1; UpnpDiscovery_set_Expires(param, expires); if ( httpmsg_find_hdr( hmsg, HDR_CACHE_CONTROL, &hdr_value ) != NULL ) { @@ -164,28 +157,28 @@ void ssdp_handle_ctrlpt_msg( } } - // DATE + /* DATE */ if ( httpmsg_find_hdr( hmsg, HDR_DATE, &hdr_value ) != NULL ) { UpnpDiscovery_strcpy_Date(param, hdr_value.buf); } - // dest addr + /* dest addr */ UpnpDiscovery_set_DestAddr(param, dest_addr); - // EXT + /* EXT */ if ( httpmsg_find_hdr( hmsg, HDR_EXT, &hdr_value ) != NULL ) { UpnpDiscovery_strncpy_Ext(param, hdr_value.buf, hdr_value.length); } - // LOCATION + /* LOCATION */ if ( httpmsg_find_hdr( hmsg, HDR_LOCATION, &hdr_value ) != NULL ) { UpnpDiscovery_strncpy_Location(param, hdr_value.buf, hdr_value.length); } - // SERVER / USER-AGENT + /* SERVER / USER-AGENT */ if ( httpmsg_find_hdr( hmsg, HDR_SERVER, &hdr_value ) != NULL || httpmsg_find_hdr( hmsg, HDR_USER_AGENT, &hdr_value ) != NULL ) { UpnpDiscovery_strncpy_Os(param, hdr_value.buf, hdr_value.length); } - // clear everything + /* clear everything */ event.UDN[0] = '\0'; event.DeviceType[0] = '\0'; event.ServiceType[0] = '\0'; @@ -213,11 +206,11 @@ void ssdp_handle_ctrlpt_msg( UpnpDiscovery_strcpy_ServiceType(param, event.ServiceType); } - // ADVERT. OR BYEBYE + /* ADVERT. OR BYEBYE */ if( hmsg->is_request ) { - // use NTS hdr to determine advert., or byebye + /* use NTS hdr to determine advert., or byebye */ if ( httpmsg_find_hdr( hmsg, HDR_NTS, &hdr_value ) == NULL ) { - // error; NTS header not found + /* error; NTS header not found */ goto end_ssdp_handle_ctrlpt_msg; } if ( memptr_cmp( &hdr_value, "ssdp:alive" ) == 0 ) { @@ -225,37 +218,37 @@ void ssdp_handle_ctrlpt_msg( } else if( memptr_cmp( &hdr_value, "ssdp:byebye" ) == 0 ) { is_byebye = TRUE; } else { - // bad value + /* bad value */ goto end_ssdp_handle_ctrlpt_msg; } if ( is_byebye ) { - // check device byebye + /* check device byebye */ if( !nt_found || !usn_found ) { - // bad byebye + /* bad byebye */ goto end_ssdp_handle_ctrlpt_msg; } event_type = UPNP_DISCOVERY_ADVERTISEMENT_BYEBYE; } else { - // check advertisement - // .Expires is valid if positive. This is for testing - // only. Expires should be greater than 1800 (30 mins) + /* check advertisement. + * Expires is valid if positive. This is for testing + * only. Expires should be greater than 1800 (30 mins) */ if( !nt_found || !usn_found || UpnpString_get_Length(UpnpDiscovery_get_Location(param)) == 0 || UpnpDiscovery_get_Expires(param) <= 0 ) { - // bad advertisement + /* bad advertisement */ goto end_ssdp_handle_ctrlpt_msg; } event_type = UPNP_DISCOVERY_ADVERTISEMENT_ALIVE; } - // call callback + /* call callback */ ctrlpt_callback( event_type, param, ctrlpt_cookie ); } else { - // reply (to a SEARCH) - // - // only checking to see if there is a valid ST header + /* reply (to a SEARCH) */ + /* */ + /* only checking to see if there is a valid ST header */ st_found = FALSE; if( httpmsg_find_hdr( hmsg, HDR_ST, &hdr_value ) != NULL ) { save_char = hdr_value.buf[hdr_value.length]; @@ -268,10 +261,10 @@ void ssdp_handle_ctrlpt_msg( UpnpString_get_Length(UpnpDiscovery_get_Location(param)) == 0 || !usn_found || !st_found ) { - // bad reply + /* bad reply */ goto end_ssdp_handle_ctrlpt_msg; } - // check each current search + /* check each current search */ HandleLock(); if( GetClientHandleInfo( &handle, &ctrlpt_info ) != HND_CLIENT ) { HandleUnlock(); @@ -279,14 +272,14 @@ void ssdp_handle_ctrlpt_msg( } node = ListHead( &ctrlpt_info->SsdpSearchList ); - // temporary add null termination - //save_char = hdr_value.buf[ hdr_value.length ]; - //hdr_value.buf[ hdr_value.length ] = '\0'; + /* temporary add null termination */ + /*save_char = hdr_value.buf[ hdr_value.length ]; */ + /*hdr_value.buf[ hdr_value.length ] = '\0'; */ while( node != NULL ) { searchArg = node->item; matched = 0; - // check for match of ST header and search target + /* check for match of ST header and search target */ switch ( searchArg->requestType ) { case SSDP_ALL: matched = 1; @@ -320,7 +313,7 @@ void ssdp_handle_ctrlpt_msg( } if (matched) { - // schedule call back + /* schedule call back */ threadData = SSDPResultData_new(); if (threadData != NULL) { SSDPResultData_set_Param(threadData, param); @@ -336,7 +329,7 @@ void ssdp_handle_ctrlpt_msg( } HandleUnlock(); - //ctrlpt_callback( UPNP_DISCOVERY_SEARCH_RESULT, param, cookie ); + /*ctrlpt_callback( UPNP_DISCOVERY_SEARCH_RESULT, param, cookie ); */ } end_ssdp_handle_ctrlpt_msg: UpnpDiscovery_delete(param); @@ -431,15 +424,14 @@ static void CreateClientRequestPacketUlaGua( * Returns: void * ***************************************************************************/ -void -searchExpired( void *arg ) +void searchExpired(void *arg) { - int *id = ( int * )arg; + int *id = (int *)arg; int handle = -1; struct Handle_Info *ctrlpt_info = NULL; - //remove search Target from list and call client back + /* remove search Target from list and call client back */ ListNode *node = NULL; SsdpSearchArg *item; Upnp_FunPtr ctrlpt_callback; @@ -448,18 +440,14 @@ searchExpired( void *arg ) HandleLock(); - //remove search target from search list - + /* remove search target from search list */ if( GetClientHandleInfo( &handle, &ctrlpt_info ) != HND_CLIENT ) { free( id ); HandleUnlock(); return; } - ctrlpt_callback = ctrlpt_info->Callback; - node = ListHead( &ctrlpt_info->SsdpSearchList ); - while( node != NULL ) { item = ( SsdpSearchArg * ) node->item; if( item->timeoutEventId == ( *id ) ) { @@ -531,7 +519,7 @@ int SearchByTarget( unsigned long addrv4 = inet_addr(gIF_IPV4); int max_fd = 0; - //ThreadData *ThData; + /*ThreadData *ThData;*/ ThreadPoolJob job; requestType = ssdp_request_type1(St); @@ -647,7 +635,7 @@ int SearchByTarget( imillisleep(SSDP_PAUSE); } } -#endif //IPv6 +#endif /* IPv6 */ if (gSsdpReqSocket4 != INVALID_SOCKET && FD_ISSET(gSsdpReqSocket4, &wrSet)) { @@ -668,5 +656,6 @@ int SearchByTarget( return 1; } -#endif // EXCLUDE_SSDP -#endif // INCLUDE_CLIENT_APIS +#endif /* EXCLUDE_SSDP */ +#endif /* INCLUDE_CLIENT_APIS */ + diff --git a/upnp/src/ssdp/ssdp_device.c b/upnp/src/ssdp/ssdp_device.c index fdd8548..5b9207a 100644 --- a/upnp/src/ssdp/ssdp_device.c +++ b/upnp/src/ssdp/ssdp_device.c @@ -120,34 +120,38 @@ void ssdp_handle_device_request( int replyTime; int maxAge; - // check man hdr + /* check man hdr. */ if( httpmsg_find_hdr( hmsg, HDR_MAN, &hdr_value ) == NULL || memptr_cmp( &hdr_value, "\"ssdp:discover\"" ) != 0 ) { - return; // bad or missing hdr + /* bad or missing hdr. */ + return; } - // MX header + /* MX header. */ if( httpmsg_find_hdr( hmsg, HDR_MX, &hdr_value ) == NULL || ( mx = raw_to_int( &hdr_value, 10 ) ) < 0 ) { return; } - // ST header + /* ST header. */ if( httpmsg_find_hdr( hmsg, HDR_ST, &hdr_value ) == NULL ) { return; } save_char = hdr_value.buf[hdr_value.length]; hdr_value.buf[hdr_value.length] = '\0'; ret_code = ssdp_request_type( hdr_value.buf, &event ); - hdr_value.buf[hdr_value.length] = save_char; // restore + /* restore. */ + hdr_value.buf[hdr_value.length] = save_char; if( ret_code == -1 ) { - return; // bad ST header + /* bad ST header. */ + return; } HandleLock(); - // device info + /* device info */ if( GetDeviceHandleInfo( dest_addr->ss_family, &handle, &dev_info ) != HND_DEVICE ) { HandleUnlock(); - return; // no info found + /* no info found. */ + return; } maxAge = dev_info->MaxAge; HandleUnlock(); @@ -180,11 +184,9 @@ void ssdp_handle_device_request( TPJobInit( &job, advertiseAndReplyThread, threadArg ); TPJobSetFreeFunction( &job, ( free_routine ) free ); - //Subtract a percentage from the mx - //to allow for network and processing delays - // (i.e. if search is for 30 seconds, - // respond withing 0 - 27 seconds) - + /* Subtract a percentage from the mx to allow for network and processing + * delays (i.e. if search is for 30 seconds, respond + * within 0 - 27 seconds). */ if( mx >= 2 ) { mx -= MAXVAL( 1, mx / MX_FUDGE_FACTOR ); } @@ -225,7 +227,8 @@ NewRequestHandler( IN struct sockaddr *DestAddr, int socklen = sizeof( struct sockaddr_storage ); int Index; unsigned long replyAddr = inet_addr( gIF_IPV4 ); - int ttl = 4; // a/c to UPNP Spec + /* a/c to UPNP Spec */ + int ttl = 4; int hops = 1; char buf_ntop[64]; int ret = UPNP_E_SUCCESS; @@ -480,7 +483,7 @@ DeviceAdvertisement( IN char *DevType, struct sockaddr_in* DestAddr4 = (struct sockaddr_in*)&__ss; struct sockaddr_in6* DestAddr6 = (struct sockaddr_in6*)&__ss; - //char Mil_Nt[LINE_SIZE] + /* char Mil_Nt[LINE_SIZE] */ char Mil_Usn[LINE_SIZE]; char *msgs[3]; int ret_code = UPNP_E_SUCCESS; @@ -509,24 +512,20 @@ DeviceAdvertisement( IN char *DevType, msgs[1] = NULL; msgs[2] = NULL; - //If deviceis a root device , here we need to - //send 3 advertisement or reply + /* If deviceis a root device , here we need to send 3 advertisement + * or reply */ if( RootDev ) { sprintf( Mil_Usn, "%s::upnp:rootdevice", Udn ); CreateServicePacket( MSGTYPE_ADVERTISEMENT, "upnp:rootdevice", Mil_Usn, Location, Duration, &msgs[0], AddressFamily ); } - // both root and sub-devices need to send these two messages - // - + /* both root and sub-devices need to send these two messages */ CreateServicePacket( MSGTYPE_ADVERTISEMENT, Udn, Udn, Location, Duration, &msgs[1], AddressFamily ); - sprintf( Mil_Usn, "%s::%s", Udn, DevType ); CreateServicePacket( MSGTYPE_ADVERTISEMENT, DevType, Mil_Usn, Location, Duration, &msgs[2], AddressFamily ); - - // check error + /* check error */ if( ( RootDev && msgs[0] == NULL ) || msgs[1] == NULL || msgs[2] == NULL ) { free( msgs[0] ); @@ -534,17 +533,17 @@ DeviceAdvertisement( IN char *DevType, free( msgs[2] ); return UPNP_E_OUTOF_MEMORY; } - // send packets + /* send packets */ if( RootDev ) { - // send 3 msg types + /* send 3 msg types */ ret_code = NewRequestHandler( (struct sockaddr*)&__ss, 3, &msgs[0] ); - } else // sub-device + } else /* sub-device */ { - // send 2 msg types + /* send 2 msg types */ ret_code = NewRequestHandler( (struct sockaddr*)&__ss, 2, &msgs[1] ); } - // free msgs + /* free msgs */ free( msgs[0] ); free( msgs[1] ); free( msgs[2] ); @@ -590,17 +589,17 @@ SendReply( IN struct sockaddr *DestAddr, msgs[1] = NULL; if( RootDev ) { - // one msg for root device + /* one msg for root device */ num_msgs = 1; sprintf( Mil_Usn, "%s::upnp:rootdevice", Udn ); CreateServicePacket( MSGTYPE_REPLY, "upnp:rootdevice", Mil_Usn, Location, Duration, &msgs[0], DestAddr->sa_family ); } else { - // two msgs for embedded devices + /* two msgs for embedded devices */ num_msgs = 1; - //NK: FIX for extra response when someone searches by udn + /*NK: FIX for extra response when someone searches by udn */ if( !ByType ) { CreateServicePacket( MSGTYPE_REPLY, Udn, Udn, Location, Duration, &msgs[0], DestAddr->sa_family ); @@ -611,7 +610,7 @@ SendReply( IN struct sockaddr *DestAddr, } } - // check error + /* check error */ for( i = 0; i < num_msgs; i++ ) { if( msgs[i] == NULL ) { free( msgs[0] ); @@ -619,7 +618,7 @@ SendReply( IN struct sockaddr *DestAddr, } } - // send msgs + /* send msgs */ ret_code = NewRequestHandler( DestAddr, num_msgs, msgs ); for( i = 0; i < num_msgs; i++ ) { if( msgs[i] != NULL ) @@ -663,28 +662,23 @@ DeviceReply( IN struct sockaddr *DestAddr, szReq[1] = NULL; szReq[2] = NULL; - // create 2 or 3 msgs - + /* create 2 or 3 msgs */ if( RootDev ) { - // 3 replies for root device + /* 3 replies for root device */ strcpy( Mil_Nt, "upnp:rootdevice" ); sprintf( Mil_Usn, "%s::upnp:rootdevice", Udn ); CreateServicePacket( MSGTYPE_REPLY, Mil_Nt, Mil_Usn, Location, Duration, &szReq[0], DestAddr->sa_family ); } - sprintf( Mil_Nt, "%s", Udn ); sprintf( Mil_Usn, "%s", Udn ); CreateServicePacket( MSGTYPE_REPLY, Mil_Nt, Mil_Usn, Location, Duration, &szReq[1], DestAddr->sa_family ); - sprintf( Mil_Nt, "%s", DevType ); sprintf( Mil_Usn, "%s::%s", Udn, DevType ); CreateServicePacket( MSGTYPE_REPLY, Mil_Nt, Mil_Usn, Location, Duration, &szReq[2], DestAddr->sa_family ); - - // check error - + /* check error */ if( ( RootDev && szReq[0] == NULL ) || szReq[1] == NULL || szReq[2] == NULL ) { free( szReq[0] ); @@ -692,14 +686,13 @@ DeviceReply( IN struct sockaddr *DestAddr, free( szReq[2] ); return UPNP_E_OUTOF_MEMORY; } - // send replies + /* send replies */ if( RootDev ) { RetVal = NewRequestHandler( DestAddr, 3, szReq ); } else { RetVal = NewRequestHandler( DestAddr, 2, &szReq[1] ); } - - // free + /* free */ free( szReq[0] ); free( szReq[1] ); free( szReq[2] ); @@ -756,8 +749,8 @@ ServiceAdvertisement( IN char *Udn, sprintf( Mil_Usn, "%s::%s", Udn, ServType ); - //CreateServiceRequestPacket(1,szReq[0],Mil_Nt,Mil_Usn, - //Server,Location,Duration); + /* CreateServiceRequestPacket(1,szReq[0],Mil_Nt,Mil_Usn, + * Server,Location,Duration); */ CreateServicePacket( MSGTYPE_ADVERTISEMENT, ServType, Mil_Usn, Location, Duration, &szReq[0], AddressFamily ); if( szReq[0] == NULL ) { @@ -860,10 +853,10 @@ ServiceShutdown( IN char *Udn, "Invalid device address family.\n" ); } - //sprintf(Mil_Nt,"%s",ServType); + /* sprintf(Mil_Nt,"%s",ServType); */ sprintf( Mil_Usn, "%s::%s", Udn, ServType ); - //CreateServiceRequestPacket(0,szReq[0],Mil_Nt,Mil_Usn, - //Server,Location,Duration); + /* CreateServiceRequestPacket(0,szReq[0],Mil_Nt,Mil_Usn, + * Server,Location,Duration); */ CreateServicePacket( MSGTYPE_SHUTDOWN, ServType, Mil_Usn, Location, Duration, &szReq[0], AddressFamily ); if( szReq[0] == NULL ) { @@ -929,25 +922,21 @@ DeviceShutdown( IN char *DevType, UpnpPrintf( UPNP_CRITICAL, SSDP, __FILE__, __LINE__, "Invalid device address family.\n" ); } - - // root device has one extra msg + /* root device has one extra msg */ if( RootDev ) { sprintf( Mil_Usn, "%s::upnp:rootdevice", Udn ); CreateServicePacket( MSGTYPE_SHUTDOWN, "upnp:rootdevice", Mil_Usn, Location, Duration, &msgs[0], AddressFamily ); } - UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__, "In function DeviceShutdown\n" ); - // both root and sub-devices need to send these two messages + /* both root and sub-devices need to send these two messages */ CreateServicePacket( MSGTYPE_SHUTDOWN, Udn, Udn, Location, Duration, &msgs[1], AddressFamily ); - sprintf( Mil_Usn, "%s::%s", Udn, DevType ); CreateServicePacket( MSGTYPE_SHUTDOWN, DevType, Mil_Usn, Location, Duration, &msgs[2], AddressFamily ); - - // check error + /* check error */ if( ( RootDev && msgs[0] == NULL ) || msgs[1] == NULL || msgs[2] == NULL ) { free( msgs[0] ); @@ -955,17 +944,16 @@ DeviceShutdown( IN char *DevType, free( msgs[2] ); return UPNP_E_OUTOF_MEMORY; } - // send packets + /* send packets */ if( RootDev ) { - // send 3 msg types + /* send 3 msg types */ ret_code = NewRequestHandler( (struct sockaddr*)&__ss, 3, &msgs[0] ); - } else // sub-device - { - // send 2 msg types + } else { + /* sub-device */ + /* send 2 msg types */ ret_code = NewRequestHandler( (struct sockaddr*)&__ss, 2, &msgs[1] ); } - - // free msgs + /* free msgs */ free( msgs[0] ); free( msgs[1] ); free( msgs[2] ); @@ -973,6 +961,6 @@ DeviceShutdown( IN char *DevType, return ret_code; } -#endif // EXCLUDE_SSDP -#endif // INCLUDE_DEVICE_APIS +#endif /* EXCLUDE_SSDP */ +#endif /* INCLUDE_DEVICE_APIS */ diff --git a/upnp/src/ssdp/ssdp_server.c b/upnp/src/ssdp/ssdp_server.c index 8a24e7e..a2bc0a2 100644 --- a/upnp/src/ssdp/ssdp_server.c +++ b/upnp/src/ssdp/ssdp_server.c @@ -595,11 +595,9 @@ ssdp_request_type1( IN char *cmd ) * Returns: int * 0 on success; -1 on error ***************************************************************************/ -int -ssdp_request_type( IN char *cmd, - OUT SsdpEvent * Evt ) +int ssdp_request_type(IN char *cmd, OUT SsdpEvent *Evt) { - // clear event + /* clear event */ memset( Evt, 0, sizeof( SsdpEvent ) ); unique_service_name( cmd, Evt ); Evt->ErrCode = NO_ERROR_FOUND; @@ -624,15 +622,13 @@ ssdp_request_type( IN char *cmd, * Returns: VOID * ***************************************************************************/ -static void -free_ssdp_event_handler_data( void *the_data ) +static void free_ssdp_event_handler_data(void *the_data) { ssdp_thread_data *data = ( ssdp_thread_data * ) the_data; if( data != NULL ) { http_message_t *hmsg = &data->parser.msg; - - // free data + /* free data */ httpmsg_destroy( hmsg ); free( data ); } @@ -653,7 +649,7 @@ free_ssdp_event_handler_data( void *the_data ) ***************************************************************************/ static UPNP_INLINE xboolean valid_ssdp_msg(IN http_message_t *hmsg) { - memptr hdr_value; + memptr hdr_value; /* check for valid methods - NOTIFY or M-SEARCH */ if (hmsg->method != HTTPMETHOD_NOTIFY && @@ -699,8 +695,7 @@ static UPNP_INLINE xboolean valid_ssdp_msg(IN http_message_t *hmsg) * Returns: int * 0 if successful -1 if error ***************************************************************************/ -static UPNP_INLINE int -start_event_handler( void *Data ) +static UPNP_INLINE int start_event_handler(void *Data) { http_parser_t *parser = NULL; @@ -716,23 +711,23 @@ start_event_handler( void *Data ) UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__, "SSDP recvd bad msg code = %d\n", status ); - // ignore bad msg, or not enuf mem + /* ignore bad msg, or not enuf mem */ goto error_handler; } - // valid notify msg + /* valid notify msg */ } else if( status != PARSE_SUCCESS ) { UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__, "SSDP recvd bad msg code = %d\n", status ); goto error_handler; } - // check msg + /* check msg */ if( valid_ssdp_msg( &parser->msg ) != TRUE ) { goto error_handler; } - return 0; //////// done; thread will free 'data' + return 0; /* done; thread will free 'data' */ - error_handler: +error_handler: free_ssdp_event_handler_data( data ); return -1; } @@ -798,16 +793,13 @@ readFromSSDPSocket( SOCKET socket ) requestBuf = staticBuf; - //in case memory - //can't be allocated, still drain the - //socket using a static buffer - + /* in case memory can't be allocated, still drain the socket using a + * static buffer. */ data = ( ssdp_thread_data * ) malloc( sizeof( ssdp_thread_data ) ); if( data != NULL ) { - //initialize parser - + /* initialize parser */ #ifdef INCLUDE_CLIENT_APIS #ifdef UPNP_ENABLE_IPV6 if( socket == gSsdpReqSocket4 || socket == gSsdpReqSocket6 ) { @@ -826,11 +818,9 @@ readFromSSDPSocket( SOCKET socket ) #else parser_request_init( &data->parser ); #endif - - //set size of parser buffer - + /* set size of parser buffer */ if( membuffer_set_size( &data->parser.msg.msg, BUFSIZE ) == 0 ) { - //use this as the buffer for recv + /* use this as the buffer for recv */ requestBuf = data->parser.msg.msg.buf; } else { @@ -867,10 +857,10 @@ readFromSSDPSocket( SOCKET socket ) "%s\n" "End of received multicast packet ----------------------------------------------\n", requestBuf ); - //add thread pool job to handle request + /* add thread pool job to handle request */ if( data != NULL ) { data->parser.msg.msg.length += byteReceived; - // null-terminate + /* null-terminate */ data->parser.msg.msg.buf[byteReceived] = 0; memcpy( &data->dest_addr, &__ss, sizeof(__ss) ); TPJobInit( &job, ( start_routine ) @@ -935,7 +925,7 @@ int get_ssdp_sockets(MiniServerSockArray *out) } else { out->ssdpReqSock6 = INVALID_SOCKET; } -#endif //IPv6 +#endif /* IPv6 */ #endif /* INCLUDE_CLIENT_APIS */ @@ -993,8 +983,7 @@ int get_ssdp_sockets(MiniServerSockArray *out) } else { out->ssdpSock6UlaGua = INVALID_SOCKET; } -#endif //IPv6 - +#endif /* IPv6 */ return UPNP_E_SUCCESS; } @@ -1030,7 +1019,7 @@ int create_ssdp_sock_reqv4( SOCKET* ssdpReqSock ) setsockopt( *ssdpReqSock, IPPROTO_IP, IP_MULTICAST_TTL, &ttl, sizeof (ttl) ); - // just do it, regardless if fails or not. + /* just do it, regardless if fails or not. */ Make_Socket_NoBlocking( *ssdpReqSock ); return UPNP_E_SUCCESS; @@ -1064,18 +1053,18 @@ int create_ssdp_sock_reqv6( SOCKET* ssdpReqSock ) return UPNP_E_OUTOF_SOCKET; } - // MUST use scoping of IPv6 addresses to control the propagation os SSDP - // messages instead of relying on the Hop Limit (Equivalent to the TTL - // limit in IPv4). + /* MUST use scoping of IPv6 addresses to control the propagation os SSDP + * messages instead of relying on the Hop Limit (Equivalent to the TTL + * limit in IPv4). */ setsockopt( *ssdpReqSock, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, &hops, sizeof(hops) ); - // just do it, regardless if fails or not. + /* just do it, regardless if fails or not. */ Make_Socket_NoBlocking( *ssdpReqSock ); return UPNP_E_SUCCESS; } -#endif // IPv6 +#endif /* IPv6 */ #endif /* INCLUDE_CLIENT_APIS */ @@ -1317,7 +1306,7 @@ int create_ssdp_sock_v6( SOCKET* ssdpSock ) return UPNP_E_SUCCESS; } -#endif // IPv6 +#endif /* IPv6 */ /************************************************************************ * Function : create_ssdp_sock_v6_ula_gua @@ -1429,7 +1418,7 @@ int create_ssdp_sock_v6_ula_gua(SOCKET *ssdpSock) return UPNP_E_SUCCESS; } -#endif //IPv6 +#endif /* IPv6 */ #endif /* EXCLUDE_SSDP */ diff --git a/upnp/src/urlconfig/urlconfig.c b/upnp/src/urlconfig/urlconfig.c index f30ea60..e947724 100644 --- a/upnp/src/urlconfig/urlconfig.c +++ b/upnp/src/urlconfig/urlconfig.c @@ -120,15 +120,15 @@ calc_alias( IN const char *alias, assert( rootPath ); assert( alias ); - // add / suffix, if missing + /* add / suffix, if missing */ root_len = strlen( rootPath ); if( root_len == 0 || rootPath[root_len - 1] != '/' ) { temp_str = "/"; } else { - temp_str = ""; // suffix already present + temp_str = ""; /* suffix already present */ } - // discard / prefix, if present + /* discard / prefix, if present */ if( alias[0] == '/' ) { aliasPtr = alias + 1; } else { @@ -241,11 +241,11 @@ config_description_doc( INOUT IXML_Document * doc, membuffer_init( &url_str ); membuffer_init( &root_path ); - err_code = UPNP_E_OUTOF_MEMORY; // default error + err_code = UPNP_E_OUTOF_MEMORY; /* default error */ baseList = ixmlDocument_getElementsByTagName( doc, urlBaseStr ); if( baseList == NULL ) { - // urlbase not found -- create new one + /* urlbase not found -- create new one */ addNew = TRUE; element = ixmlDocument_createElement( doc, urlBaseStr ); if( element == NULL ) { @@ -284,7 +284,7 @@ config_description_doc( INOUT IXML_Document * doc, } } else { - // urlbase found + /* urlbase found */ urlbase_node = ixmlNodeList_item( baseList, 0 ); assert( urlbase_node != NULL ); @@ -312,7 +312,7 @@ config_description_doc( INOUT IXML_Document * doc, membuffer_append_str( &url_str, ip_str ) != 0 ) { goto error_handler; } - // add leading '/' if missing from relative path + /* add leading '/' if missing from relative path */ if( ( uri.pathquery.size > 0 && uri.pathquery.buff[0] != '/' ) || ( uri.pathquery.size == 0 ) ) { @@ -328,7 +328,7 @@ config_description_doc( INOUT IXML_Document * doc, uri.pathquery.size ) != 0 ) { goto error_handler; } - // add trailing '/' if missing + /* add trailing '/' if missing */ if( url_str.buf[url_str.length - 1] != '/' ) { if( membuffer_append( &url_str, "/", 1 ) != 0 ) { goto error_handler; @@ -341,7 +341,7 @@ config_description_doc( INOUT IXML_Document * doc, } } - *root_path_str = membuffer_detach( &root_path ); // return path + *root_path_str = membuffer_detach( &root_path ); /* return path */ err_code = UPNP_E_SUCCESS; error_handler: @@ -400,27 +400,27 @@ configure_urlbase( INOUT IXML_Document * doc, int err_code; char ipaddr_port[LINE_SIZE]; - err_code = UPNP_E_OUTOF_MEMORY; // default error + err_code = UPNP_E_OUTOF_MEMORY; /* default error */ - // get IP address and port + /* get IP address and port */ addrToString( serverAddr, ipaddr_port ); - // config url-base in 'doc' + /* config url-base in 'doc' */ err_code = config_description_doc( doc, ipaddr_port, &root_path ); if( err_code != UPNP_E_SUCCESS ) { goto error_handler; } - // calc alias + /* calc alias */ err_code = calc_alias( alias, root_path, &new_alias ); if( err_code != UPNP_E_SUCCESS ) { goto error_handler; } - // calc full url for desc doc + /* calc full url for desc doc */ err_code = calc_descURL( ipaddr_port, new_alias, docURL ); if( err_code != UPNP_E_SUCCESS ) { goto error_handler; } - // xml doc to str + /* xml doc to str */ xml_str = ixmlPrintDocument( doc ); if( xml_str == NULL ) { goto error_handler; @@ -430,7 +430,7 @@ configure_urlbase( INOUT IXML_Document * doc, "desc url: %s\n", docURL ); UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, "doc = %s\n", xml_str ); - // store in web server + /* store in web server */ err_code = web_server_set_alias( new_alias, xml_str, strlen( xml_str ), last_modified ); diff --git a/upnp/src/uuid/sysdep.c b/upnp/src/uuid/sysdep.c index 711c5f0..a1762fc 100644 --- a/upnp/src/uuid/sysdep.c +++ b/upnp/src/uuid/sysdep.c @@ -1,31 +1,28 @@ /* - ** Copyright (c) 1990- 1993, 1996 Open Software Foundation, Inc. - ** Copyright (c) 1989 by Hewlett-Packard Company, Palo Alto, Ca. & - ** Digital Equipment Corporation, Maynard, Mass. - ** Copyright (c) 1998 Microsoft. - ** To anyone who acknowledges that this file is provided "AS IS" - ** without any express or implied warranty: permission to use, copy, - ** modify, and distribute this file for any purpose is hereby - ** granted without fee, provided that the above copyright notices and - ** this notice appears in all source code copies, and that none of - ** the names of Open Software Foundation, Inc., Hewlett-Packard - ** Company, or Digital Equipment Corporation be used in advertising - ** or publicity pertaining to distribution of the software without - ** specific, written prior permission. Neither Open Software - ** Foundation, Inc., Hewlett-Packard Company, Microsoft, nor Digital Equipment - ** Corporation makes any representations about the suitability of - ** this software for any purpose. + * Copyright (c) 1990- 1993, 1996 Open Software Foundation, Inc. + * Copyright (c) 1989 by Hewlett-Packard Company, Palo Alto, Ca. & + * Digital Equipment Corporation, Maynard, Mass. + * Copyright (c) 1998 Microsoft. + * To anyone who acknowledges that this file is provided "AS IS" + * without any express or implied warranty: permission to use, copy, + * modify, and distribute this file for any purpose is hereby + * granted without fee, provided that the above copyright notices and + * this notice appears in all source code copies, and that none of + * the names of Open Software Foundation, Inc., Hewlett-Packard + * Company, or Digital Equipment Corporation be used in advertising + * or publicity pertaining to distribution of the software without + * specific, written prior permission. Neither Open Software + * Foundation, Inc., Hewlett-Packard Company, Microsoft, nor Digital Equipment + * Corporation makes any representations about the suitability of + * this software for any purpose. */ #include "config.h" - #include "sysdep.h" - #include "UpnpInet.h" - #include #include @@ -74,9 +71,9 @@ get_system_time( uuid_time_t * uuid_time ) + 18 years and 5 leap days. */ - time.QuadPart += ( unsigned __int64 )( 1000 * 1000 * 10 ) // seconds - * ( unsigned __int64 )( 60 * 60 * 24 ) // days - * ( unsigned __int64 )( 17 + 30 + 31 + 365 * 18 + 5 ); // # of days + time.QuadPart += ( unsigned __int64 )( 1000 * 1000 * 10 ) /* seconds */ + * ( unsigned __int64 )( 60 * 60 * 24 ) /* days */ + * ( unsigned __int64 )( 17 + 30 + 31 + 365 * 18 + 5 ); /* # of days */ *uuid_time = time.QuadPart; @@ -146,7 +143,7 @@ get_random_info(unsigned char seed[16]) { MD5_CTX c; typedef struct { - //struct sysinfo s; + /*struct sysinfo s; */ struct timeval t; char hostname[257]; } randomness;