diff --git a/upnp/sample/common/sample_util.c b/upnp/sample/common/sample_util.c index f304225..76b77b2 100644 --- a/upnp/sample/common/sample_util.c +++ b/upnp/sample/common/sample_util.c @@ -29,6 +29,13 @@ * ******************************************************************************/ +/*! + * \addtogroup UpnpSamples + * + * @{ + * + * \file + */ #define SAMPLE_UTIL_C #include "sample_util.h" @@ -666,3 +673,5 @@ void linux_print(const char *format, ...) fflush(stdout); va_end(argList); } + +/*! @} UpnpSamples */ diff --git a/upnp/sample/common/sample_util.h b/upnp/sample/common/sample_util.h index a169ca1..4ec5cb2 100644 --- a/upnp/sample/common/sample_util.h +++ b/upnp/sample/common/sample_util.h @@ -1,3 +1,6 @@ +#ifndef SAMPLE_UTIL_H +#define SAMPLE_UTIL_H + /******************************************************************************* * * Copyright (c) 2000-2003 Intel Corporation @@ -29,10 +32,11 @@ * ******************************************************************************/ -#ifndef SAMPLE_UTIL_H -#define SAMPLE_UTIL_H - /*! + * \defgroup UpnpSamples Sample Code + * + * @{ + * * \file */ @@ -259,5 +263,7 @@ void linux_print(const char *format, ...) #define strcasecmp stricmp #endif +/*! @} UpnpSamples */ + #endif /* SAMPLE_UTIL_H */ diff --git a/upnp/sample/common/tv_ctrlpt.c b/upnp/sample/common/tv_ctrlpt.c index 03356e2..4a7e669 100644 --- a/upnp/sample/common/tv_ctrlpt.c +++ b/upnp/sample/common/tv_ctrlpt.c @@ -29,6 +29,18 @@ * ******************************************************************************/ +/*! + * \addtogroup UpnpSamples + * + * @{ + * + * \name Control Point Sample Module + * + * @{ + * + * \file + */ + #include "tv_ctrlpt.h" #include "upnp.h" @@ -1574,3 +1586,6 @@ int TvCtrlPointProcessCommand(char *cmdline) return TV_SUCCESS; } +/*! @} Control Point Sample Module */ + +/*! @} UpnpSamples */ diff --git a/upnp/sample/common/tv_ctrlpt.h b/upnp/sample/common/tv_ctrlpt.h index 00ed420..49207a0 100644 --- a/upnp/sample/common/tv_ctrlpt.h +++ b/upnp/sample/common/tv_ctrlpt.h @@ -33,6 +33,14 @@ **************************************************************************/ /*! + * \addtogroup UpnpSamples + * + * @{ + * + * \name Contro Point Sample API + * + * @{ + * * \file */ @@ -42,17 +50,13 @@ extern "C" { #include "sample_util.h" -#include "ithread.h" #include "upnp.h" #include "UpnpString.h" #include "upnptools.h" -#include "UpnpUniStd.h" /* for close() */ #include #include #include -#include -#include #define TV_SERVICE_SERVCOUNT 2 #define TV_SERVICE_CONTROL 0 @@ -213,5 +217,9 @@ int TvCtrlPointProcessCommand(char *cmdline); }; #endif -#endif /* UPNP_TV_CTRLPT_H */ +/*! @} Device Sample */ + +/*! @} UpnpSamples */ + +#endif /* UPNP_TV_CTRLPT_H */ diff --git a/upnp/sample/common/tv_device.c b/upnp/sample/common/tv_device.c index 93946f4..85f1ee8 100644 --- a/upnp/sample/common/tv_device.c +++ b/upnp/sample/common/tv_device.c @@ -29,6 +29,18 @@ * ******************************************************************************/ +/*! + * \addtogroup UpnpSamples + * + * @{ + * + * \name Device Sample Module + * + * @{ + * + * \file + */ + #include "tv_device.h" #include @@ -40,12 +52,14 @@ /*! Global arrays for storing Tv Control Service variable names, values, * and defaults. */ const char *tvc_varname[] = { "Power", "Channel", "Volume" }; + char tvc_varval[TV_CONTROL_VARCOUNT][TV_MAX_VAL_LEN]; const char *tvc_varval_def[] = { "1", "1", "5" }; /*! Global arrays for storing Tv Picture Service variable names, values, * and defaults. */ const char *tvp_varname[] = { "Color", "Tint", "Contrast", "Brightness" }; + char tvp_varval[TV_PICTURE_VARCOUNT][TV_MAX_VAL_LEN]; const char *tvp_varval_def[] = { "5", "5", "5", "5" }; @@ -97,196 +111,181 @@ ithread_mutex_t TVDevMutex; */ static int SetServiceTable( /*! [in] one of TV_SERVICE_CONTROL or, TV_SERVICE_PICTURE. */ - IN int serviceType, + int serviceType, /*! [in] UDN of device containing service. */ - IN const char *UDN, + const char *UDN, /*! [in] serviceId of service. */ - IN const char *serviceId, + const char *serviceId, /*! [in] service type (as specified in Description Document) . */ - IN const char *serviceTypeS, + const char *serviceTypeS, /*! [in,out] service containing table to be set. */ - INOUT struct TvService *out) + struct TvService *out) { - int i = 0; + int i = 0; - strcpy( out->UDN, UDN ); - strcpy( out->ServiceId, serviceId ); - strcpy( out->ServiceType, serviceTypeS ); + strcpy(out->UDN, UDN); + strcpy(out->ServiceId, serviceId); + strcpy(out->ServiceType, serviceTypeS); - switch ( serviceType ) { - case TV_SERVICE_CONTROL: - out->VariableCount = TV_CONTROL_VARCOUNT; - for( i = 0; - i < tv_service_table[TV_SERVICE_CONTROL].VariableCount; - i++ ) { - tv_service_table[TV_SERVICE_CONTROL].VariableName[i] - = tvc_varname[i]; - tv_service_table[TV_SERVICE_CONTROL].VariableStrVal[i] - = tvc_varval[i]; - strcpy( tv_service_table[TV_SERVICE_CONTROL]. - VariableStrVal[i], tvc_varval_def[i] ); - } + switch (serviceType) { + case TV_SERVICE_CONTROL: + out->VariableCount = TV_CONTROL_VARCOUNT; + for (i = 0; + i < tv_service_table[TV_SERVICE_CONTROL].VariableCount; + i++) { + tv_service_table[TV_SERVICE_CONTROL].VariableName[i] + = tvc_varname[i]; + tv_service_table[TV_SERVICE_CONTROL].VariableStrVal[i] + = tvc_varval[i]; + strcpy(tv_service_table[TV_SERVICE_CONTROL]. + VariableStrVal[i], tvc_varval_def[i]); + } + break; + case TV_SERVICE_PICTURE: + out->VariableCount = TV_PICTURE_VARCOUNT; + for (i = 0; + i < tv_service_table[TV_SERVICE_PICTURE].VariableCount; + i++) { + tv_service_table[TV_SERVICE_PICTURE].VariableName[i] = + tvp_varname[i]; + tv_service_table[TV_SERVICE_PICTURE].VariableStrVal[i] = + tvp_varval[i]; + strcpy(tv_service_table[TV_SERVICE_PICTURE]. + VariableStrVal[i], tvp_varval_def[i]); + } + break; + default: + assert(0); + } - break; - case TV_SERVICE_PICTURE: - out->VariableCount = TV_PICTURE_VARCOUNT; - - for( i = 0; - i < tv_service_table[TV_SERVICE_PICTURE].VariableCount; - i++ ) { - tv_service_table[TV_SERVICE_PICTURE].VariableName[i] = - tvp_varname[i]; - tv_service_table[TV_SERVICE_PICTURE].VariableStrVal[i] = - tvp_varval[i]; - strcpy( tv_service_table[TV_SERVICE_PICTURE]. - VariableStrVal[i], tvp_varval_def[i] ); - } - - break; - default: - assert( 0 ); - } - - return SetActionTable( serviceType, out ); + return SetActionTable(serviceType, out); } int SetActionTable(int serviceType, struct TvService *out) { - if( serviceType == TV_SERVICE_CONTROL ) { - out->ActionNames[0] = "PowerOn"; - out->actions[0] = TvDevicePowerOn; - out->ActionNames[1] = "PowerOff"; - out->actions[1] = TvDevicePowerOff; - out->ActionNames[2] = "SetChannel"; - out->actions[2] = TvDeviceSetChannel; - out->ActionNames[3] = "IncreaseChannel"; - out->actions[3] = TvDeviceIncreaseChannel; - out->ActionNames[4] = "DecreaseChannel"; - out->actions[4] = TvDeviceDecreaseChannel; - out->ActionNames[5] = "SetVolume"; - out->actions[5] = TvDeviceSetVolume; - out->ActionNames[6] = "IncreaseVolume"; - out->actions[6] = TvDeviceIncreaseVolume; - out->ActionNames[7] = "DecreaseVolume"; - out->actions[7] = TvDeviceDecreaseVolume; - out->ActionNames[8] = NULL; - return 1; - } else if( serviceType == TV_SERVICE_PICTURE ) { - out->ActionNames[0] = "SetColor"; - out->ActionNames[1] = "IncreaseColor"; - out->ActionNames[2] = "DecreaseColor"; - out->actions[0] = TvDeviceSetColor; - out->actions[1] = TvDeviceIncreaseColor; - out->actions[2] = TvDeviceDecreaseColor; - out->ActionNames[3] = "SetTint"; - out->ActionNames[4] = "IncreaseTint"; - out->ActionNames[5] = "DecreaseTint"; - out->actions[3] = TvDeviceSetTint; - out->actions[4] = TvDeviceIncreaseTint; - out->actions[5] = TvDeviceDecreaseTint; + if (serviceType == TV_SERVICE_CONTROL) { + out->ActionNames[0] = "PowerOn"; + out->actions[0] = TvDevicePowerOn; + out->ActionNames[1] = "PowerOff"; + out->actions[1] = TvDevicePowerOff; + out->ActionNames[2] = "SetChannel"; + out->actions[2] = TvDeviceSetChannel; + out->ActionNames[3] = "IncreaseChannel"; + out->actions[3] = TvDeviceIncreaseChannel; + out->ActionNames[4] = "DecreaseChannel"; + out->actions[4] = TvDeviceDecreaseChannel; + out->ActionNames[5] = "SetVolume"; + out->actions[5] = TvDeviceSetVolume; + out->ActionNames[6] = "IncreaseVolume"; + out->actions[6] = TvDeviceIncreaseVolume; + out->ActionNames[7] = "DecreaseVolume"; + out->actions[7] = TvDeviceDecreaseVolume; + out->ActionNames[8] = NULL; + return 1; + } else if (serviceType == TV_SERVICE_PICTURE) { + out->ActionNames[0] = "SetColor"; + out->ActionNames[1] = "IncreaseColor"; + out->ActionNames[2] = "DecreaseColor"; + out->actions[0] = TvDeviceSetColor; + out->actions[1] = TvDeviceIncreaseColor; + out->actions[2] = TvDeviceDecreaseColor; + out->ActionNames[3] = "SetTint"; + out->ActionNames[4] = "IncreaseTint"; + out->ActionNames[5] = "DecreaseTint"; + out->actions[3] = TvDeviceSetTint; + out->actions[4] = TvDeviceIncreaseTint; + out->actions[5] = TvDeviceDecreaseTint; - out->ActionNames[6] = "SetBrightness"; - out->ActionNames[7] = "IncreaseBrightness"; - out->ActionNames[8] = "DecreaseBrightness"; - out->actions[6] = TvDeviceSetBrightness; - out->actions[7] = TvDeviceIncreaseBrightness; - out->actions[8] = TvDeviceDecreaseBrightness; + out->ActionNames[6] = "SetBrightness"; + out->ActionNames[7] = "IncreaseBrightness"; + out->ActionNames[8] = "DecreaseBrightness"; + out->actions[6] = TvDeviceSetBrightness; + out->actions[7] = TvDeviceIncreaseBrightness; + out->actions[8] = TvDeviceDecreaseBrightness; - out->ActionNames[9] = "SetContrast"; - out->ActionNames[10] = "IncreaseContrast"; - out->ActionNames[11] = "DecreaseContrast"; + out->ActionNames[9] = "SetContrast"; + out->ActionNames[10] = "IncreaseContrast"; + out->ActionNames[11] = "DecreaseContrast"; - out->actions[9] = TvDeviceSetContrast; - out->actions[10] = TvDeviceIncreaseContrast; - out->actions[11] = TvDeviceDecreaseContrast; - return 1; - } + out->actions[9] = TvDeviceSetContrast; + out->actions[10] = TvDeviceIncreaseContrast; + out->actions[11] = TvDeviceDecreaseContrast; + return 1; + } - return 0; + return 0; } int TvDeviceStateTableInit(char *DescDocURL) { - IXML_Document *DescDoc = NULL; - int ret = UPNP_E_SUCCESS; - char *servid_ctrl = NULL, - *evnturl_ctrl = NULL, - *ctrlurl_ctrl = NULL; - char *servid_pict = NULL, - *evnturl_pict = NULL, - *ctrlurl_pict = NULL; - char *udn = NULL; + IXML_Document *DescDoc = NULL; + int ret = UPNP_E_SUCCESS; + char *servid_ctrl = NULL; + char *evnturl_ctrl = NULL; + char *ctrlurl_ctrl = NULL; + char *servid_pict = NULL; + char *evnturl_pict = NULL; + char *ctrlurl_pict = NULL; + char *udn = NULL; - /*Download description document */ - if( UpnpDownloadXmlDoc( DescDocURL, &DescDoc ) != UPNP_E_SUCCESS ) { - SampleUtil_Print( "TvDeviceStateTableInit -- Error Parsing %s\n", - DescDocURL ); - ret = UPNP_E_INVALID_DESC; - goto error_handler; - } + /*Download description document */ + if (UpnpDownloadXmlDoc(DescDocURL, &DescDoc) != UPNP_E_SUCCESS) { + SampleUtil_Print("TvDeviceStateTableInit -- Error Parsing %s\n", + DescDocURL); + ret = UPNP_E_INVALID_DESC; + goto error_handler; + } + udn = SampleUtil_GetFirstDocumentItem(DescDoc, "UDN"); + /* Find the Tv Control Service identifiers */ + if (!SampleUtil_FindAndParseService(DescDoc, DescDocURL, + TvServiceType[TV_SERVICE_CONTROL], + &servid_ctrl, &evnturl_ctrl, + &ctrlurl_ctrl)) { + SampleUtil_Print("TvDeviceStateTableInit -- Error: Could not find Service: %s\n", + TvServiceType[TV_SERVICE_CONTROL]); + ret = UPNP_E_INVALID_DESC; + goto error_handler; + } + /* set control service table */ + SetServiceTable(TV_SERVICE_CONTROL, udn, servid_ctrl, + TvServiceType[TV_SERVICE_CONTROL], + &tv_service_table[TV_SERVICE_CONTROL]); - udn = SampleUtil_GetFirstDocumentItem( DescDoc, "UDN" ); + /* Find the Tv Picture Service identifiers */ + if (!SampleUtil_FindAndParseService(DescDoc, DescDocURL, + TvServiceType[TV_SERVICE_PICTURE], + &servid_pict, &evnturl_pict, + &ctrlurl_pict)) { + SampleUtil_Print("TvDeviceStateTableInit -- Error: Could not find Service: %s\n", + TvServiceType[TV_SERVICE_PICTURE]); + ret = UPNP_E_INVALID_DESC; + goto error_handler; + } + /* set picture service table */ + SetServiceTable(TV_SERVICE_PICTURE, udn, servid_pict, + TvServiceType[TV_SERVICE_PICTURE], + &tv_service_table[TV_SERVICE_PICTURE]); - /* - Find the Tv Control Service identifiers - */ - if( !SampleUtil_FindAndParseService( DescDoc, DescDocURL, - TvServiceType[TV_SERVICE_CONTROL], - &servid_ctrl, &evnturl_ctrl, - &ctrlurl_ctrl ) ) { - SampleUtil_Print( "TvDeviceStateTableInit -- Error: Could not find" - " Service: %s\n", - TvServiceType[TV_SERVICE_CONTROL] ); +error_handler: + /* clean up */ + if (udn) + free(udn); + if (servid_ctrl) + free(servid_ctrl); + if (evnturl_ctrl) + free(evnturl_ctrl); + if (ctrlurl_ctrl) + free(ctrlurl_ctrl); + if (servid_pict) + free(servid_pict); + if (evnturl_pict) + free(evnturl_pict); + if (ctrlurl_pict) + free(ctrlurl_pict); + if (DescDoc) + ixmlDocument_free(DescDoc); - ret = UPNP_E_INVALID_DESC; - goto error_handler; - } - - /*set control service table */ - SetServiceTable( TV_SERVICE_CONTROL, udn, servid_ctrl, - TvServiceType[TV_SERVICE_CONTROL], - &tv_service_table[TV_SERVICE_CONTROL] ); - - /* - Find the Tv Picture Service identifiers - */ - if( !SampleUtil_FindAndParseService( DescDoc, DescDocURL, - TvServiceType[TV_SERVICE_PICTURE], - &servid_pict, &evnturl_pict, - &ctrlurl_pict ) ) { - SampleUtil_Print( "TvDeviceStateTableInit -- Error: Could not find" - " Service: %s\n", - TvServiceType[TV_SERVICE_PICTURE] ); - - ret = UPNP_E_INVALID_DESC; - goto error_handler; - } - /*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 */ - if( udn ) - free( udn ); - if( servid_ctrl ) - free( servid_ctrl ); - if( evnturl_ctrl ) - free( evnturl_ctrl ); - if( ctrlurl_ctrl ) - free( ctrlurl_ctrl ); - if( servid_pict ) - free( servid_pict ); - if( evnturl_pict ) - free( evnturl_pict ); - if( ctrlurl_pict ) - free( ctrlurl_pict ); - if( DescDoc ) - ixmlDocument_free( DescDoc ); - - return ( ret ); + return (ret); } int TvDeviceHandleSubscriptionRequest(const UpnpSubscriptionRequest *sr_event) @@ -311,35 +310,33 @@ int TvDeviceHandleSubscriptionRequest(const UpnpSubscriptionRequest *sr_event) #if 0 PropSet = NULL; - for (j = 0; j< tv_service_table[i].VariableCount; ++j) { + for (j = 0; j < tv_service_table[i].VariableCount; ++j) { /* 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]); + UpnpAddToPropertySet(&PropSet, + tv_service_table[i]. + VariableName[j], + tv_service_table[i]. + VariableStrVal[j]); } /* dump initial state */ - UpnpAcceptSubscriptionExt( - device_handle, - l_udn, - l_serviceId, - PropSet, - l_sid); + UpnpAcceptSubscriptionExt(device_handle, + l_udn, + l_serviceId, PropSet, l_sid); /* free document */ Document_free(PropSet); #endif - UpnpAcceptSubscription( - device_handle, - l_udn, - l_serviceId, - (const char **)tv_service_table[i]. - VariableName, - (const char **)tv_service_table[i]. - VariableStrVal, - tv_service_table[i].VariableCount, - l_sid); + UpnpAcceptSubscription(device_handle, + l_udn, + l_serviceId, + (const char **) + tv_service_table[i].VariableName, + (const char **) + tv_service_table + [i].VariableStrVal, + tv_service_table[i]. + VariableCount, l_sid); } } @@ -383,8 +380,7 @@ int TvDeviceHandleGetVarRequest(UpnpStateVarRequest *cgv_event) if (getvar_succeeded) { UpnpStateVarRequest_set_ErrCode(cgv_event, UPNP_E_SUCCESS); } else { - SampleUtil_Print( - "Error in UPNP_CONTROL_GET_VAR_REQUEST callback:\n" + SampleUtil_Print("Error in UPNP_CONTROL_GET_VAR_REQUEST callback:\n" " Unknown variable name = %s\n", UpnpString_get_String(UpnpStateVarRequest_get_StateVarName(cgv_event))); UpnpStateVarRequest_set_ErrCode(cgv_event, 404); @@ -419,7 +415,7 @@ int TvDeviceHandleActionRequest(UpnpActionRequest *ca_event) strcmp(serviceID, tv_service_table[TV_SERVICE_CONTROL].ServiceId) == 0) { /* Request for action in the TvDevice Control Service. */ service = TV_SERVICE_CONTROL; - } else if (strcmp(devUDN, tv_service_table[TV_SERVICE_PICTURE].UDN) == 0 && + } else if (strcmp(devUDN, tv_service_table[TV_SERVICE_PICTURE].UDN) == 0 && strcmp(serviceID, tv_service_table[TV_SERVICE_PICTURE].ServiceId) == 0) { /* Request for action in the TvDevice Picture Service. */ service = TV_SERVICE_PICTURE; @@ -432,7 +428,7 @@ int TvDeviceHandleActionRequest(UpnpActionRequest *ca_event) i++) { if (!strcmp(actionName, tv_service_table[service].ActionNames[i])) { if (!strcmp(tv_service_table[TV_SERVICE_CONTROL]. - VariableStrVal[TV_CONTROL_POWER], "1") || + VariableStrVal[TV_CONTROL_POWER], "1") || !strcmp(actionName, "PowerOn")) { retCode = tv_service_table[service].actions[i]( UpnpActionRequest_get_ActionRequest(ca_event), @@ -475,43 +471,34 @@ int TvDeviceHandleActionRequest(UpnpActionRequest *ca_event) int TvDeviceSetServiceTableVar(unsigned int service, int variable, char *value) { - /*IXML_Document *PropSet= NULL; */ + /* IXML_Document *PropSet= NULL; */ + if (service >= TV_SERVICE_SERVCOUNT || + variable >= tv_service_table[service].VariableCount || + strlen(value) >= TV_MAX_VAL_LEN) + return (0); - if( ( service >= TV_SERVICE_SERVCOUNT ) - || ( variable >= tv_service_table[service].VariableCount ) - || ( strlen( value ) >= TV_MAX_VAL_LEN ) ) { - return ( 0 ); - } - - ithread_mutex_lock( &TVDevMutex ); - - strcpy( tv_service_table[service].VariableStrVal[variable], value ); + ithread_mutex_lock(&TVDevMutex); + strcpy(tv_service_table[service].VariableStrVal[variable], value); #if 0 - /*Using utility api */ - PropSet= UpnpCreatePropertySet(1,tv_service_table[service]. - VariableName[variable], - tv_service_table[service]. - VariableStrVal[variable]); - - UpnpNotifyExt(device_handle, tv_service_table[service].UDN, - tv_service_table[service].ServiceId,PropSet); - - /*Free created property set */ - Document_free(PropSet); + /* Using utility api */ + PropSet = UpnpCreatePropertySet(1, + tv_service_table[service].VariableName[variable], + tv_service_table[service].VariableStrVal[variable]); + UpnpNotifyExt(device_handle, tv_service_table[service].UDN, + tv_service_table[service].ServiceId, PropSet); + /* Free created property set */ + Document_free(PropSet); #endif + UpnpNotify(device_handle, + tv_service_table[service].UDN, + tv_service_table[service].ServiceId, + (const char **)&tv_service_table[service].VariableName[variable], + (const char **)&tv_service_table[service].VariableStrVal[variable], 1); - UpnpNotify( device_handle, - tv_service_table[service].UDN, - tv_service_table[service].ServiceId, - ( const char ** )&tv_service_table[service]. - VariableName[variable], - ( const char ** )&tv_service_table[service]. - VariableStrVal[variable], 1 ); + ithread_mutex_unlock(&TVDevMutex); - ithread_mutex_unlock( &TVDevMutex ); - - return ( 1 ); + return 1; } /*! @@ -523,216 +510,206 @@ static int TvDeviceSetPower( /*! [in] If 1, turn power on. If 0, turn power off. */ int on) { - char value[TV_MAX_VAL_LEN]; - int ret = 0; + char value[TV_MAX_VAL_LEN]; + int ret = 0; - if( on != POWER_ON && on != POWER_OFF ) { - SampleUtil_Print( "error: can't set power to value %d\n", on ); - return 0; - } + if (on != POWER_ON && on != POWER_OFF) { + SampleUtil_Print("error: can't set power to value %d\n", on); + return 0; + } - /* Vendor-specific code to turn the power on/off goes here. */ + /* Vendor-specific code to turn the power on/off goes here. */ - sprintf( value, "%d", on ); - ret = TvDeviceSetServiceTableVar( TV_SERVICE_CONTROL, TV_CONTROL_POWER, - value ); + sprintf(value, "%d", on); + ret = TvDeviceSetServiceTableVar(TV_SERVICE_CONTROL, TV_CONTROL_POWER, + value); - return ret; + return ret; } -int TvDevicePowerOn(IXML_Document *in, IXML_Document **out, const char **errorString) +int TvDevicePowerOn(IXML_Document * in,IXML_Document **out, + const char **errorString) { - ( *out ) = NULL; - ( *errorString ) = NULL; + (*out) = NULL; + (*errorString) = NULL; - if( TvDeviceSetPower( POWER_ON ) ) { - /*create a response */ - - if( UpnpAddToActionResponse( out, "PowerOn", - TvServiceType[TV_SERVICE_CONTROL], - "Power", "1" ) != UPNP_E_SUCCESS ) { - ( *out ) = NULL; - ( *errorString ) = "Internal Error"; - return UPNP_E_INTERNAL_ERROR; - } - return UPNP_E_SUCCESS; - } else { - ( *errorString ) = "Internal Error"; - return UPNP_E_INTERNAL_ERROR; - } - in = in; + if (TvDeviceSetPower(POWER_ON)) { + /* create a response */ + if (UpnpAddToActionResponse(out, "PowerOn", + TvServiceType[TV_SERVICE_CONTROL], + "Power", "1") != UPNP_E_SUCCESS) { + (*out) = NULL; + (*errorString) = "Internal Error"; + return UPNP_E_INTERNAL_ERROR; + } + return UPNP_E_SUCCESS; + } else { + (*errorString) = "Internal Error"; + return UPNP_E_INTERNAL_ERROR; + } + in = in; } -int TvDevicePowerOff(IXML_Document *in, IXML_Document **out, const char **errorString) +int TvDevicePowerOff(IXML_Document *in, IXML_Document **out, + const char **errorString) { - ( *out ) = NULL; - ( *errorString ) = NULL; - if( TvDeviceSetPower( POWER_OFF ) ) { - /*create a response */ + (*out) = NULL; + (*errorString) = NULL; + if (TvDeviceSetPower(POWER_OFF)) { + /*create a response */ - if( UpnpAddToActionResponse( out, "PowerOff", - TvServiceType[TV_SERVICE_CONTROL], - "Power", "0" ) != UPNP_E_SUCCESS ) { - ( *out ) = NULL; - ( *errorString ) = "Internal Error"; - return UPNP_E_INTERNAL_ERROR; - } - - return UPNP_E_SUCCESS; - } - - ( *errorString ) = "Internal Error"; - return UPNP_E_INTERNAL_ERROR; - in = in; + if (UpnpAddToActionResponse(out, "PowerOff", + TvServiceType[TV_SERVICE_CONTROL], + "Power", "0") != UPNP_E_SUCCESS) { + (*out) = NULL; + (*errorString) = "Internal Error"; + return UPNP_E_INTERNAL_ERROR; + } + return UPNP_E_SUCCESS; + } + (*errorString) = "Internal Error"; + return UPNP_E_INTERNAL_ERROR; + in = in; } -int TvDeviceSetChannel(IXML_Document *in, IXML_Document **out, const char **errorString) +int TvDeviceSetChannel(IXML_Document * in, IXML_Document ** out, + const char **errorString) { - char *value = NULL; + char *value = NULL; + int channel = 0; - int channel = 0; - - ( *out ) = NULL; - ( *errorString ) = NULL; - - if( !( value = SampleUtil_GetFirstDocumentItem( in, "Channel" ) ) ) { - ( *errorString ) = "Invalid Channel"; - return UPNP_E_INVALID_PARAM; - } - - channel = atoi( value ); - - if( channel < MIN_CHANNEL || channel > MAX_CHANNEL ) { - - free( value ); - SampleUtil_Print( "error: can't change to channel %d\n", channel ); - ( *errorString ) = "Invalid Channel"; - return UPNP_E_INVALID_PARAM; - } - - /* Vendor-specific code to set the channel goes here. */ - - if( TvDeviceSetServiceTableVar( TV_SERVICE_CONTROL, - TV_CONTROL_CHANNEL, value ) ) { - if( UpnpAddToActionResponse( out, "SetChannel", - TvServiceType[TV_SERVICE_CONTROL], - "NewChannel", - value ) != UPNP_E_SUCCESS ) { - ( *out ) = NULL; - ( *errorString ) = "Internal Error"; - free( value ); - return UPNP_E_INTERNAL_ERROR; - } - free( value ); - return UPNP_E_SUCCESS; - } else { - free( value ); - ( *errorString ) = "Internal Error"; - return UPNP_E_INTERNAL_ERROR; - } + (*out) = NULL; + (*errorString) = NULL; + if (!(value = SampleUtil_GetFirstDocumentItem(in, "Channel"))) { + (*errorString) = "Invalid Channel"; + return UPNP_E_INVALID_PARAM; + } + channel = atoi(value); + if (channel < MIN_CHANNEL || channel > MAX_CHANNEL) { + free(value); + SampleUtil_Print("error: can't change to channel %d\n", + channel); + (*errorString) = "Invalid Channel"; + return UPNP_E_INVALID_PARAM; + } + /* Vendor-specific code to set the channel goes here. */ + if (TvDeviceSetServiceTableVar(TV_SERVICE_CONTROL, + TV_CONTROL_CHANNEL, value)) { + if (UpnpAddToActionResponse(out, "SetChannel", + TvServiceType[TV_SERVICE_CONTROL], + "NewChannel", + value) != UPNP_E_SUCCESS) { + (*out) = NULL; + (*errorString) = "Internal Error"; + free(value); + return UPNP_E_INTERNAL_ERROR; + } + free(value); + return UPNP_E_SUCCESS; + } else { + free(value); + (*errorString) = "Internal Error"; + return UPNP_E_INTERNAL_ERROR; + } } -int IncrementChannel(int incr, IN IXML_Document *in, IXML_Document **out, const char **errorString) +int IncrementChannel(int incr, IN IXML_Document * in, IXML_Document ** out, + const char **errorString) { - int curchannel; - int newchannel; + int curchannel; + int newchannel; + const char *actionName = NULL; + char value[TV_MAX_VAL_LEN]; - const char *actionName = NULL; - char value[TV_MAX_VAL_LEN]; + if (incr > 0) { + actionName = "IncreaseChannel"; + } else { + actionName = "DecreaseChannel"; + } - if( incr > 0 ) { - actionName = "IncreaseChannel"; - } else { - actionName = "DecreaseChannel"; - } + ithread_mutex_lock(&TVDevMutex); + curchannel = + atoi(tv_service_table[TV_SERVICE_CONTROL].VariableStrVal + [TV_CONTROL_CHANNEL]); + ithread_mutex_unlock(&TVDevMutex); - ithread_mutex_lock( &TVDevMutex ); - curchannel = atoi( tv_service_table[TV_SERVICE_CONTROL]. - VariableStrVal[TV_CONTROL_CHANNEL] ); - ithread_mutex_unlock( &TVDevMutex ); + newchannel = curchannel + incr; - newchannel = curchannel + incr; - - if( newchannel < MIN_CHANNEL || newchannel > MAX_CHANNEL ) { - SampleUtil_Print( "error: can't change to channel %d\n", - newchannel ); - ( *errorString ) = "Invalid Channel"; - return UPNP_E_INVALID_PARAM; - } - - /* Vendor-specific code to set the channel goes here. */ - - sprintf( value, "%d", newchannel ); - - if( TvDeviceSetServiceTableVar( TV_SERVICE_CONTROL, - TV_CONTROL_CHANNEL, value ) ) { - if( UpnpAddToActionResponse( out, actionName, - TvServiceType[TV_SERVICE_CONTROL], - "Channel", value ) != UPNP_E_SUCCESS ) - { - ( *out ) = NULL; - ( *errorString ) = "Internal Error"; - return UPNP_E_INTERNAL_ERROR; - } - return UPNP_E_SUCCESS; - } else { - ( *errorString ) = "Internal Error"; - return UPNP_E_INTERNAL_ERROR; - } - in = in; + if (newchannel < MIN_CHANNEL || newchannel > MAX_CHANNEL) { + SampleUtil_Print("error: can't change to channel %d\n", + newchannel); + (*errorString) = "Invalid Channel"; + return UPNP_E_INVALID_PARAM; + } + /* Vendor-specific code to set the channel goes here. */ + sprintf(value, "%d", newchannel); + if (TvDeviceSetServiceTableVar(TV_SERVICE_CONTROL, + TV_CONTROL_CHANNEL, value)) { + if (UpnpAddToActionResponse(out, actionName, + TvServiceType[TV_SERVICE_CONTROL], + "Channel", value) != UPNP_E_SUCCESS) + { + (*out) = NULL; + (*errorString) = "Internal Error"; + return UPNP_E_INTERNAL_ERROR; + } + return UPNP_E_SUCCESS; + } else { + (*errorString) = "Internal Error"; + return UPNP_E_INTERNAL_ERROR; + } + in = in; } -int TvDeviceDecreaseChannel(IXML_Document *in, IXML_Document **out, const char **errorString) +int TvDeviceDecreaseChannel(IXML_Document * in, IXML_Document ** out, + const char **errorString) { - return IncrementChannel(-1, in, out, errorString); + return IncrementChannel(-1, in, out, errorString); } -int TvDeviceIncreaseChannel(IXML_Document *in, IXML_Document **out, const char **errorString) +int TvDeviceIncreaseChannel(IXML_Document * in, IXML_Document ** out, + const char **errorString) { - return IncrementChannel(1, in, out, errorString); + return IncrementChannel(1, in, out, errorString); } -int TvDeviceSetVolume(IXML_Document *in, IXML_Document **out, const char **errorString) +int TvDeviceSetVolume(IXML_Document * in, IXML_Document ** out, + const char **errorString) { - char *value = NULL; - int volume = 0; + char *value = NULL; + int volume = 0; - ( *out ) = NULL; - ( *errorString ) = NULL; - - if( !( value = SampleUtil_GetFirstDocumentItem( in, "Volume" ) ) ) { - ( *errorString ) = "Invalid Volume"; - return UPNP_E_INVALID_PARAM; - } - - volume = atoi( value ); - - if( volume < MIN_VOLUME || volume > MAX_VOLUME ) { - SampleUtil_Print( "error: can't change to volume %d\n", volume ); - ( *errorString ) = "Invalid Volume"; - return UPNP_E_INVALID_PARAM; - } - - /* Vendor-specific code to set the volume goes here. */ - - if( TvDeviceSetServiceTableVar( TV_SERVICE_CONTROL, - TV_CONTROL_VOLUME, value ) ) { - if( UpnpAddToActionResponse( out, "SetVolume", - TvServiceType[TV_SERVICE_CONTROL], - "NewVolume", - value ) != UPNP_E_SUCCESS ) { - ( *out ) = NULL; - ( *errorString ) = "Internal Error"; - free( value ); - return UPNP_E_INTERNAL_ERROR; - } - free( value ); - return UPNP_E_SUCCESS; - } else { - free( value ); - ( *errorString ) = "Internal Error"; - return UPNP_E_INTERNAL_ERROR; - } + (*out) = NULL; + (*errorString) = NULL; + if (!(value = SampleUtil_GetFirstDocumentItem(in, "Volume"))) { + (*errorString) = "Invalid Volume"; + return UPNP_E_INVALID_PARAM; + } + volume = atoi(value); + if (volume < MIN_VOLUME || volume > MAX_VOLUME) { + SampleUtil_Print("error: can't change to volume %d\n", volume); + (*errorString) = "Invalid Volume"; + return UPNP_E_INVALID_PARAM; + } + /* Vendor-specific code to set the volume goes here. */ + if (TvDeviceSetServiceTableVar(TV_SERVICE_CONTROL, + TV_CONTROL_VOLUME, value)) { + if (UpnpAddToActionResponse(out, "SetVolume", + TvServiceType[TV_SERVICE_CONTROL], + "NewVolume", + value) != UPNP_E_SUCCESS) { + (*out) = NULL; + (*errorString) = "Internal Error"; + free(value); + return UPNP_E_INTERNAL_ERROR; + } + free(value); + return UPNP_E_SUCCESS; + } else { + free(value); + (*errorString) = "Internal Error"; + return UPNP_E_INTERNAL_ERROR; + } } /*! @@ -743,108 +720,105 @@ static int IncrementVolume( /*! [in] The increment by which to change the volume. */ int incr, /*! [in] Action request document. */ - IXML_Document *in, + IXML_Document * in, /*! [out] Action result document. */ - IXML_Document **out, + IXML_Document ** out, /*! [out] Error string in case action was unsuccessful. */ const char **errorString) { - int curvolume; - int newvolume; - const char *actionName = NULL; - char value[TV_MAX_VAL_LEN]; + int curvolume; + int newvolume; + const char *actionName = NULL; + char value[TV_MAX_VAL_LEN]; - if( incr > 0 ) { - actionName = "IncreaseVolume"; - } else { - actionName = "DecreaseVolume"; - } + if (incr > 0) { + actionName = "IncreaseVolume"; + } else { + actionName = "DecreaseVolume"; + } - ithread_mutex_lock( &TVDevMutex ); - curvolume = atoi( tv_service_table[TV_SERVICE_CONTROL]. - VariableStrVal[TV_CONTROL_VOLUME] ); - ithread_mutex_unlock( &TVDevMutex ); + ithread_mutex_lock(&TVDevMutex); + curvolume = + atoi(tv_service_table[TV_SERVICE_CONTROL].VariableStrVal + [TV_CONTROL_VOLUME]); + ithread_mutex_unlock(&TVDevMutex); - newvolume = curvolume + incr; - - if( newvolume < MIN_VOLUME || newvolume > MAX_VOLUME ) { - SampleUtil_Print( "error: can't change to volume %d\n", - newvolume ); - ( *errorString ) = "Invalid Volume"; - return UPNP_E_INVALID_PARAM; - } - - /* Vendor-specific code to set the volume goes here. */ - - sprintf( value, "%d", newvolume ); - - if( TvDeviceSetServiceTableVar( TV_SERVICE_CONTROL, - TV_CONTROL_VOLUME, value ) ) { - if( UpnpAddToActionResponse( out, actionName, - TvServiceType[TV_SERVICE_CONTROL], - "Volume", value ) != UPNP_E_SUCCESS ) { - ( *out ) = NULL; - ( *errorString ) = "Internal Error"; - return UPNP_E_INTERNAL_ERROR; - } - return UPNP_E_SUCCESS; - } else { - ( *errorString ) = "Internal Error"; - return UPNP_E_INTERNAL_ERROR; - } - in = in; + newvolume = curvolume + incr; + if (newvolume < MIN_VOLUME || newvolume > MAX_VOLUME) { + SampleUtil_Print("error: can't change to volume %d\n", + newvolume); + (*errorString) = "Invalid Volume"; + return UPNP_E_INVALID_PARAM; + } + /* Vendor-specific code to set the volume goes here. */ + sprintf(value, "%d", newvolume); + if (TvDeviceSetServiceTableVar(TV_SERVICE_CONTROL, + TV_CONTROL_VOLUME, value)) { + if (UpnpAddToActionResponse(out, actionName, + TvServiceType[TV_SERVICE_CONTROL], + "Volume", + value) != UPNP_E_SUCCESS) { + (*out) = NULL; + (*errorString) = "Internal Error"; + return UPNP_E_INTERNAL_ERROR; + } + return UPNP_E_SUCCESS; + } else { + (*errorString) = "Internal Error"; + return UPNP_E_INTERNAL_ERROR; + } + in = in; } -int TvDeviceIncreaseVolume(IXML_Document *in, IXML_Document **out, const char **errorString) +int TvDeviceIncreaseVolume(IXML_Document * in, IXML_Document ** out, + const char **errorString) { - return IncrementVolume( 1, in, out, errorString ); + return IncrementVolume(1, in, out, errorString); } -int TvDeviceDecreaseVolume(IXML_Document *in, IXML_Document **out, const char **errorString) +int TvDeviceDecreaseVolume(IXML_Document * in, IXML_Document ** out, + const char **errorString) { - return IncrementVolume( -1, in, out, errorString ); + return IncrementVolume(-1, in, out, errorString); } -int TvDeviceSetColor(IXML_Document *in, IXML_Document **out, const char **errorString) +int TvDeviceSetColor(IXML_Document * in, IXML_Document ** out, + const char **errorString) { - char *value = NULL; - int color = 0; + char *value = NULL; + int color = 0; - ( *out ) = NULL; - ( *errorString ) = NULL; - if( !( value = SampleUtil_GetFirstDocumentItem( in, "Color" ) ) ) { - ( *errorString ) = "Invalid Color"; - return UPNP_E_INVALID_PARAM; - } - - color = atoi( value ); - - if( color < MIN_COLOR || color > MAX_COLOR ) { - SampleUtil_Print( "error: can't change to color %d\n", color ); - ( *errorString ) = "Invalid Color"; - return UPNP_E_INVALID_PARAM; - } - - /* Vendor-specific code to set the volume goes here. */ - - if( TvDeviceSetServiceTableVar( TV_SERVICE_PICTURE, - TV_PICTURE_COLOR, value ) ) { - if( UpnpAddToActionResponse( out, "SetColor", - TvServiceType[TV_SERVICE_PICTURE], - "NewColor", - value ) != UPNP_E_SUCCESS ) { - ( *out ) = NULL; - ( *errorString ) = "Internal Error"; - free( value ); - return UPNP_E_INTERNAL_ERROR; - } - free( value ); - return UPNP_E_SUCCESS; - } else { - free( value ); - ( *errorString ) = "Internal Error"; - return UPNP_E_INTERNAL_ERROR; - } + (*out) = NULL; + (*errorString) = NULL; + if (!(value = SampleUtil_GetFirstDocumentItem(in, "Color"))) { + (*errorString) = "Invalid Color"; + return UPNP_E_INVALID_PARAM; + } + color = atoi(value); + if (color < MIN_COLOR || color > MAX_COLOR) { + SampleUtil_Print("error: can't change to color %d\n", color); + (*errorString) = "Invalid Color"; + return UPNP_E_INVALID_PARAM; + } + /* Vendor-specific code to set the volume goes here. */ + if (TvDeviceSetServiceTableVar(TV_SERVICE_PICTURE, + TV_PICTURE_COLOR, value)) { + if (UpnpAddToActionResponse(out, "SetColor", + TvServiceType[TV_SERVICE_PICTURE], + "NewColor", + value) != UPNP_E_SUCCESS) { + (*out) = NULL; + (*errorString) = "Internal Error"; + free(value); + return UPNP_E_INTERNAL_ERROR; + } + free(value); + return UPNP_E_SUCCESS; + } else { + free(value); + (*errorString) = "Internal Error"; + return UPNP_E_INTERNAL_ERROR; + } } /*! @@ -855,108 +829,103 @@ static int IncrementColor( /*! [in] The increment by which to change the volume. */ int incr, /*! [in] Action request document. */ - IXML_Document *in, + IXML_Document * in, /*! [out] Action result document. */ - IXML_Document **out, + IXML_Document ** out, /*! [out] Error string in case action was unsuccessful. */ const char **errorString) { - int curcolor; - int newcolor; - const char *actionName; - char value[TV_MAX_VAL_LEN]; + int curcolor; + int newcolor; + const char *actionName; + char value[TV_MAX_VAL_LEN]; - if( incr > 0 ) { - actionName = "IncreaseColor"; - } else { - actionName = "DecreaseColor"; - } + if (incr > 0) { + actionName = "IncreaseColor"; + } else { + actionName = "DecreaseColor"; + } - ithread_mutex_lock( &TVDevMutex ); - curcolor = atoi( tv_service_table[TV_SERVICE_PICTURE]. - VariableStrVal[TV_PICTURE_COLOR] ); - ithread_mutex_unlock( &TVDevMutex ); + ithread_mutex_lock(&TVDevMutex); + curcolor = + atoi(tv_service_table[TV_SERVICE_PICTURE].VariableStrVal + [TV_PICTURE_COLOR]); + ithread_mutex_unlock(&TVDevMutex); - newcolor = curcolor + incr; - - if( newcolor < MIN_COLOR || newcolor > MAX_COLOR ) { - SampleUtil_Print( "error: can't change to color %d\n", newcolor ); - ( *errorString ) = "Invalid Color"; - return UPNP_E_INVALID_PARAM; - } - - /* Vendor-specific code to set the volume goes here. */ - - sprintf( value, "%d", newcolor ); - - if( TvDeviceSetServiceTableVar( TV_SERVICE_PICTURE, - TV_PICTURE_COLOR, value ) ) { - if( UpnpAddToActionResponse( out, actionName, - TvServiceType[TV_SERVICE_PICTURE], - "Color", value ) != UPNP_E_SUCCESS ) { - ( *out ) = NULL; - ( *errorString ) = "Internal Error"; - return UPNP_E_INTERNAL_ERROR; - } - return UPNP_E_SUCCESS; - } else { - ( *errorString ) = "Internal Error"; - return UPNP_E_INTERNAL_ERROR; - } - in = in; + newcolor = curcolor + incr; + if (newcolor < MIN_COLOR || newcolor > MAX_COLOR) { + SampleUtil_Print("error: can't change to color %d\n", newcolor); + (*errorString) = "Invalid Color"; + return UPNP_E_INVALID_PARAM; + } + /* Vendor-specific code to set the volume goes here. */ + sprintf(value, "%d", newcolor); + if (TvDeviceSetServiceTableVar(TV_SERVICE_PICTURE, + TV_PICTURE_COLOR, value)) { + if (UpnpAddToActionResponse(out, actionName, + TvServiceType[TV_SERVICE_PICTURE], + "Color", value) != UPNP_E_SUCCESS) { + (*out) = NULL; + (*errorString) = "Internal Error"; + return UPNP_E_INTERNAL_ERROR; + } + return UPNP_E_SUCCESS; + } else { + (*errorString) = "Internal Error"; + return UPNP_E_INTERNAL_ERROR; + } + in = in; } -int TvDeviceDecreaseColor(IXML_Document *in, IXML_Document **out, const char **errorString) +int TvDeviceDecreaseColor(IXML_Document * in, IXML_Document ** out, + const char **errorString) { - return IncrementColor(-1, in, out, errorString); + return IncrementColor(-1, in, out, errorString); } -int TvDeviceIncreaseColor(IXML_Document *in, IXML_Document **out, const char **errorString) +int TvDeviceIncreaseColor(IXML_Document * in, IXML_Document ** out, + const char **errorString) { - return IncrementColor(1, in, out, errorString); + return IncrementColor(1, in, out, errorString); } -int TvDeviceSetTint(IXML_Document *in, IXML_Document **out, const char **errorString) +int TvDeviceSetTint(IXML_Document * in, IXML_Document ** out, + const char **errorString) { - char *value = NULL; - int tint = -1; + char *value = NULL; + int tint = -1; - ( *out ) = NULL; - ( *errorString ) = NULL; - - if( !( value = SampleUtil_GetFirstDocumentItem( in, "Tint" ) ) ) { - ( *errorString ) = "Invalid Tint"; - return UPNP_E_INVALID_PARAM; - } - - tint = atoi( value ); - - if( tint < MIN_TINT || tint > MAX_TINT ) { - SampleUtil_Print( "error: can't change to tint %d\n", tint ); - ( *errorString ) = "Invalid Tint"; - return UPNP_E_INVALID_PARAM; - } - - /* Vendor-specific code to set the volume goes here. */ - - if( TvDeviceSetServiceTableVar( TV_SERVICE_PICTURE, - TV_PICTURE_TINT, value ) ) { - if( UpnpAddToActionResponse( out, "SetTint", - TvServiceType[TV_SERVICE_PICTURE], - "NewTint", value ) != UPNP_E_SUCCESS ) - { - ( *out ) = NULL; - ( *errorString ) = "Internal Error"; - free( value ); - return UPNP_E_INTERNAL_ERROR; - } - free( value ); - return UPNP_E_SUCCESS; - } else { - free( value ); - ( *errorString ) = "Internal Error"; - return UPNP_E_INTERNAL_ERROR; - } + (*out) = NULL; + (*errorString) = NULL; + if (!(value = SampleUtil_GetFirstDocumentItem(in, "Tint"))) { + (*errorString) = "Invalid Tint"; + return UPNP_E_INVALID_PARAM; + } + tint = atoi(value); + if (tint < MIN_TINT || tint > MAX_TINT) { + SampleUtil_Print("error: can't change to tint %d\n", tint); + (*errorString) = "Invalid Tint"; + return UPNP_E_INVALID_PARAM; + } + /* Vendor-specific code to set the volume goes here. */ + if (TvDeviceSetServiceTableVar(TV_SERVICE_PICTURE, + TV_PICTURE_TINT, value)) { + if (UpnpAddToActionResponse(out, "SetTint", + TvServiceType[TV_SERVICE_PICTURE], + "NewTint", value) != UPNP_E_SUCCESS) + { + (*out) = NULL; + (*errorString) = "Internal Error"; + free(value); + return UPNP_E_INTERNAL_ERROR; + } + free(value); + return UPNP_E_SUCCESS; + } else { + free(value); + (*errorString) = "Internal Error"; + return UPNP_E_INTERNAL_ERROR; + } } /****************************************************************************** @@ -973,51 +942,49 @@ int TvDeviceSetTint(IXML_Document *in, IXML_Document **out, const char **errorSt * IXML_Document **out - action result document * char **errorString - errorString (in case action was unsuccessful) *****************************************************************************/ -int IncrementTint(IN int incr, IN IXML_Document *in, OUT IXML_Document **out, OUT const char **errorString) +int IncrementTint(IN int incr, IN IXML_Document *in, OUT IXML_Document **out, + OUT const char **errorString) { - int curtint; - int newtint; - const char *actionName = NULL; - char value[TV_MAX_VAL_LEN]; + int curtint; + int newtint; + const char *actionName = NULL; + char value[TV_MAX_VAL_LEN]; - if( incr > 0 ) { - actionName = "IncreaseTint"; - } else { - actionName = "DecreaseTint"; - } + if (incr > 0) { + actionName = "IncreaseTint"; + } else { + actionName = "DecreaseTint"; + } - ithread_mutex_lock( &TVDevMutex ); - curtint = atoi( tv_service_table[TV_SERVICE_PICTURE]. - VariableStrVal[TV_PICTURE_TINT] ); - ithread_mutex_unlock( &TVDevMutex ); + ithread_mutex_lock(&TVDevMutex); + curtint = + atoi(tv_service_table[TV_SERVICE_PICTURE].VariableStrVal + [TV_PICTURE_TINT]); + ithread_mutex_unlock(&TVDevMutex); - newtint = curtint + incr; - - if( newtint < MIN_TINT || newtint > MAX_TINT ) { - SampleUtil_Print( "error: can't change to tint %d\n", newtint ); - ( *errorString ) = "Invalid Tint"; - return UPNP_E_INVALID_PARAM; - } - - /* Vendor-specific code to set the volume goes here. */ - - sprintf( value, "%d", newtint ); - - if( TvDeviceSetServiceTableVar( TV_SERVICE_PICTURE, - TV_PICTURE_TINT, value ) ) { - if( UpnpAddToActionResponse( out, actionName, - TvServiceType[TV_SERVICE_PICTURE], - "Tint", value ) != UPNP_E_SUCCESS ) { - ( *out ) = NULL; - ( *errorString ) = "Internal Error"; - return UPNP_E_INTERNAL_ERROR; - } - return UPNP_E_SUCCESS; - } else { - ( *errorString ) = "Internal Error"; - return UPNP_E_INTERNAL_ERROR; - } - in = in; + newtint = curtint + incr; + if (newtint < MIN_TINT || newtint > MAX_TINT) { + SampleUtil_Print("error: can't change to tint %d\n", newtint); + (*errorString) = "Invalid Tint"; + return UPNP_E_INVALID_PARAM; + } + /* Vendor-specific code to set the volume goes here. */ + sprintf(value, "%d", newtint); + if (TvDeviceSetServiceTableVar(TV_SERVICE_PICTURE, + TV_PICTURE_TINT, value)) { + if (UpnpAddToActionResponse(out, actionName, + TvServiceType[TV_SERVICE_PICTURE], + "Tint", value) != UPNP_E_SUCCESS) { + (*out) = NULL; + (*errorString) = "Internal Error"; + return UPNP_E_INTERNAL_ERROR; + } + return UPNP_E_SUCCESS; + } else { + (*errorString) = "Internal Error"; + return UPNP_E_INTERNAL_ERROR; + } + in = in; } /****************************************************************************** @@ -1033,10 +1000,10 @@ int IncrementTint(IN int incr, IN IXML_Document *in, OUT IXML_Document **out, OU * char **errorString - errorString (in case action was unsuccessful) * *****************************************************************************/ -int -TvDeviceIncreaseTint( IN IXML_Document *in, OUT IXML_Document **out, OUT const char **errorString) +int TvDeviceIncreaseTint(IN IXML_Document *in, OUT IXML_Document **out, + OUT const char **errorString) { - return IncrementTint( 1, in, out, errorString ); + return IncrementTint(1, in, out, errorString); } /****************************************************************************** @@ -1052,10 +1019,10 @@ TvDeviceIncreaseTint( IN IXML_Document *in, OUT IXML_Document **out, OUT const c * char **errorString - errorString (in case action was unsuccessful) * *****************************************************************************/ -int -TvDeviceDecreaseTint( IN IXML_Document *in, OUT IXML_Document **out, OUT const char **errorString) +int TvDeviceDecreaseTint(IN IXML_Document *in, OUT IXML_Document **out, + OUT const char **errorString) { - return IncrementTint( -1, in, out, errorString ); + return IncrementTint(-1, in, out, errorString); } /***************************************************************************** @@ -1073,49 +1040,45 @@ TvDeviceDecreaseTint( IN IXML_Document *in, OUT IXML_Document **out, OUT const c * char **errorString - errorString (in case action was unsuccessful) * ****************************************************************************/ -int -TvDeviceSetContrast( IN IXML_Document *in, OUT IXML_Document **out, OUT const char **errorString) +int TvDeviceSetContrast(IN IXML_Document *in, OUT IXML_Document **out, + OUT const char **errorString) { - char *value = NULL; - int contrast = -1; + char *value = NULL; + int contrast = -1; - ( *out ) = NULL; - ( *errorString ) = NULL; + (*out) = NULL; + (*errorString) = NULL; - if( !( value = SampleUtil_GetFirstDocumentItem( in, "Contrast" ) ) ) { - ( *errorString ) = "Invalid Contrast"; - return UPNP_E_INVALID_PARAM; - } - - contrast = atoi( value ); - - if( contrast < MIN_CONTRAST || contrast > MAX_CONTRAST ) { - SampleUtil_Print( "error: can't change to contrast %d\n", - contrast ); - ( *errorString ) = "Invalid Contrast"; - return UPNP_E_INVALID_PARAM; - } - - /* Vendor-specific code to set the volume goes here. */ - - if( TvDeviceSetServiceTableVar( TV_SERVICE_PICTURE, - TV_PICTURE_CONTRAST, value ) ) { - if( UpnpAddToActionResponse( out, "SetContrast", - TvServiceType[TV_SERVICE_PICTURE], - "NewContrast", - value ) != UPNP_E_SUCCESS ) { - ( *out ) = NULL; - ( *errorString ) = "Internal Error"; - free( value ); - return UPNP_E_INTERNAL_ERROR; - } - free( value ); - return UPNP_E_SUCCESS; - } else { - free( value ); - ( *errorString ) = "Internal Error"; - return UPNP_E_INTERNAL_ERROR; - } + if (!(value = SampleUtil_GetFirstDocumentItem(in, "Contrast"))) { + (*errorString) = "Invalid Contrast"; + return UPNP_E_INVALID_PARAM; + } + contrast = atoi(value); + if (contrast < MIN_CONTRAST || contrast > MAX_CONTRAST) { + SampleUtil_Print("error: can't change to contrast %d\n", + contrast); + (*errorString) = "Invalid Contrast"; + return UPNP_E_INVALID_PARAM; + } + /* Vendor-specific code to set the volume goes here. */ + if (TvDeviceSetServiceTableVar(TV_SERVICE_PICTURE, + TV_PICTURE_CONTRAST, value)) { + if (UpnpAddToActionResponse(out, "SetContrast", + TvServiceType[TV_SERVICE_PICTURE], + "NewContrast", + value) != UPNP_E_SUCCESS) { + (*out) = NULL; + (*errorString) = "Internal Error"; + free(value); + return UPNP_E_INTERNAL_ERROR; + } + free(value); + return UPNP_E_SUCCESS; + } else { + free(value); + (*errorString) = "Internal Error"; + return UPNP_E_INTERNAL_ERROR; + } } @@ -1127,114 +1090,106 @@ static int IncrementContrast( /*! [in] The increment by which to change the volume. */ int incr, /*! [in] Action request document. */ - IXML_Document *in, + IXML_Document * in, /*! [out] Action result document. */ - IXML_Document **out, + IXML_Document ** out, /*! [out] Error string in case action was unsuccessful. */ const char **errorString) { - int curcontrast; - int newcontrast; - const char *actionName = NULL; - char value[TV_MAX_VAL_LEN]; + int curcontrast; + int newcontrast; + const char *actionName = NULL; + char value[TV_MAX_VAL_LEN]; - if( incr > 0 ) { - actionName = "IncreaseContrast"; - } else { - actionName = "DecreaseContrast"; - } + if (incr > 0) { + actionName = "IncreaseContrast"; + } else { + actionName = "DecreaseContrast"; + } - ithread_mutex_lock( &TVDevMutex ); - curcontrast = atoi( tv_service_table[TV_SERVICE_PICTURE]. - VariableStrVal[TV_PICTURE_CONTRAST] ); - ithread_mutex_unlock( &TVDevMutex ); + ithread_mutex_lock(&TVDevMutex); + curcontrast = + atoi(tv_service_table[TV_SERVICE_PICTURE].VariableStrVal + [TV_PICTURE_CONTRAST]); + ithread_mutex_unlock(&TVDevMutex); - newcontrast = curcontrast + incr; - - if( newcontrast < MIN_CONTRAST || newcontrast > MAX_CONTRAST ) { - SampleUtil_Print( "error: can't change to contrast %d\n", - newcontrast ); - ( *errorString ) = "Invalid Contrast"; - return UPNP_E_INVALID_PARAM; - } - - /* Vendor-specific code to set the channel goes here. */ - - sprintf( value, "%d", newcontrast ); - - if( TvDeviceSetServiceTableVar( TV_SERVICE_PICTURE, - TV_PICTURE_CONTRAST, value ) ) { - if( UpnpAddToActionResponse( out, actionName, - TvServiceType[TV_SERVICE_PICTURE], - "Contrast", - value ) != UPNP_E_SUCCESS ) { - ( *out ) = NULL; - ( *errorString ) = "Internal Error"; - return UPNP_E_INTERNAL_ERROR; - } - return UPNP_E_SUCCESS; - } else { - ( *errorString ) = "Internal Error"; - return UPNP_E_INTERNAL_ERROR; - } - in = in; + newcontrast = curcontrast + incr; + if (newcontrast < MIN_CONTRAST || newcontrast > MAX_CONTRAST) { + SampleUtil_Print("error: can't change to contrast %d\n", + newcontrast); + (*errorString) = "Invalid Contrast"; + return UPNP_E_INVALID_PARAM; + } + /* Vendor-specific code to set the channel goes here. */ + sprintf(value, "%d", newcontrast); + if (TvDeviceSetServiceTableVar(TV_SERVICE_PICTURE, + TV_PICTURE_CONTRAST, value)) { + if (UpnpAddToActionResponse(out, actionName, + TvServiceType[TV_SERVICE_PICTURE], + "Contrast", + value) != UPNP_E_SUCCESS) { + (*out) = NULL; + (*errorString) = "Internal Error"; + return UPNP_E_INTERNAL_ERROR; + } + return UPNP_E_SUCCESS; + } else { + (*errorString) = "Internal Error"; + return UPNP_E_INTERNAL_ERROR; + } + in = in; } -int TvDeviceIncreaseContrast(IXML_Document *in, IXML_Document **out, - const char **errorString) +int TvDeviceIncreaseContrast(IXML_Document * in, IXML_Document ** out, + const char **errorString) { - return IncrementContrast(1, in, out, errorString); + return IncrementContrast(1, in, out, errorString); } -int TvDeviceDecreaseContrast(IXML_Document *in, IXML_Document **out, - const char **errorString) +int TvDeviceDecreaseContrast(IXML_Document * in, IXML_Document ** out, + const char **errorString) { - return IncrementContrast(-1, in, out, errorString); + return IncrementContrast(-1, in, out, errorString); } -int TvDeviceSetBrightness(IXML_Document *in, IXML_Document **out, - const char **errorString) +int TvDeviceSetBrightness(IXML_Document * in, IXML_Document ** out, + const char **errorString) { - char *value = NULL; - int brightness = -1; + char *value = NULL; + int brightness = -1; - ( *out ) = NULL; - ( *errorString ) = NULL; - - if( !( value = SampleUtil_GetFirstDocumentItem( in, "Brightness" ) ) ) { - ( *errorString ) = "Invalid Brightness"; - return UPNP_E_INVALID_PARAM; - } - - brightness = atoi( value ); - - if( brightness < MIN_BRIGHTNESS || brightness > MAX_BRIGHTNESS ) { - SampleUtil_Print( "error: can't change to brightness %d\n", - brightness ); - ( *errorString ) = "Invalid Brightness"; - return UPNP_E_INVALID_PARAM; - } - - /* Vendor-specific code to set the volume goes here. */ - - if( TvDeviceSetServiceTableVar( TV_SERVICE_PICTURE, - TV_PICTURE_BRIGHTNESS, value ) ) { - if( UpnpAddToActionResponse( out, "SetBrightness", - TvServiceType[TV_SERVICE_PICTURE], - "NewBrightness", - value ) != UPNP_E_SUCCESS ) { - ( *out ) = NULL; - ( *errorString ) = "Internal Error"; - free( value ); - return UPNP_E_INTERNAL_ERROR; - } - free( value ); - return UPNP_E_SUCCESS; - } else { - free( value ); - ( *errorString ) = "Internal Error"; - return UPNP_E_INTERNAL_ERROR; - } + (*out) = NULL; + (*errorString) = NULL; + if (!(value = SampleUtil_GetFirstDocumentItem(in, "Brightness"))) { + (*errorString) = "Invalid Brightness"; + return UPNP_E_INVALID_PARAM; + } + brightness = atoi(value); + if (brightness < MIN_BRIGHTNESS || brightness > MAX_BRIGHTNESS) { + SampleUtil_Print("error: can't change to brightness %d\n", + brightness); + (*errorString) = "Invalid Brightness"; + return UPNP_E_INVALID_PARAM; + } + /* Vendor-specific code to set the volume goes here. */ + if (TvDeviceSetServiceTableVar(TV_SERVICE_PICTURE, + TV_PICTURE_BRIGHTNESS, value)) { + if (UpnpAddToActionResponse(out, "SetBrightness", + TvServiceType[TV_SERVICE_PICTURE], + "NewBrightness", + value) != UPNP_E_SUCCESS) { + (*out) = NULL; + (*errorString) = "Internal Error"; + free(value); + return UPNP_E_INTERNAL_ERROR; + } + free(value); + return UPNP_E_SUCCESS; + } else { + free(value); + (*errorString) = "Internal Error"; + return UPNP_E_INTERNAL_ERROR; + } } /*! @@ -1245,67 +1200,66 @@ static int IncrementBrightness( /*! [in] The increment by which to change the brightness. */ int incr, /*! [in] action request document. */ - IXML_Document *in, + IXML_Document * in, /*! [out] action result document. */ - IXML_Document **out, + IXML_Document ** out, /*! [out] errorString (in case action was unsuccessful). */ const char **errorString) { - int curbrightness; - int newbrightness; - const char *actionName = NULL; - char value[TV_MAX_VAL_LEN]; + int curbrightness; + int newbrightness; + const char *actionName = NULL; + char value[TV_MAX_VAL_LEN]; - if( incr > 0 ) { - actionName = "IncreaseBrightness"; - } else { - actionName = "DecreaseBrightness"; - } + if (incr > 0) { + actionName = "IncreaseBrightness"; + } else { + actionName = "DecreaseBrightness"; + } - ithread_mutex_lock( &TVDevMutex ); - curbrightness = atoi( tv_service_table[TV_SERVICE_PICTURE]. - VariableStrVal[TV_PICTURE_BRIGHTNESS] ); - ithread_mutex_unlock( &TVDevMutex ); + ithread_mutex_lock(&TVDevMutex); + curbrightness = + atoi(tv_service_table[TV_SERVICE_PICTURE].VariableStrVal + [TV_PICTURE_BRIGHTNESS]); + ithread_mutex_unlock(&TVDevMutex); - newbrightness = curbrightness + incr; - - if( newbrightness < MIN_BRIGHTNESS || newbrightness > MAX_BRIGHTNESS ) { - SampleUtil_Print( "error: can't change to brightness %d\n", - newbrightness ); - ( *errorString ) = "Invalid Brightness"; - return UPNP_E_INVALID_PARAM; - } - - /* Vendor-specific code to set the channel goes here. */ - - sprintf( value, "%d", newbrightness ); - - if( TvDeviceSetServiceTableVar( TV_SERVICE_PICTURE, - TV_PICTURE_BRIGHTNESS, value ) ) { - if( UpnpAddToActionResponse( out, actionName, - TvServiceType[TV_SERVICE_PICTURE], - "Brightness", - value ) != UPNP_E_SUCCESS ) { - ( *out ) = NULL; - ( *errorString ) = "Internal Error"; - return UPNP_E_INTERNAL_ERROR; - } - return UPNP_E_SUCCESS; - } else { - ( *errorString ) = "Internal Error"; - return UPNP_E_INTERNAL_ERROR; - } - in = in; + newbrightness = curbrightness + incr; + if (newbrightness < MIN_BRIGHTNESS || newbrightness > MAX_BRIGHTNESS) { + SampleUtil_Print("error: can't change to brightness %d\n", + newbrightness); + (*errorString) = "Invalid Brightness"; + return UPNP_E_INVALID_PARAM; + } + /* Vendor-specific code to set the channel goes here. */ + sprintf(value, "%d", newbrightness); + if (TvDeviceSetServiceTableVar(TV_SERVICE_PICTURE, + TV_PICTURE_BRIGHTNESS, value)) { + if (UpnpAddToActionResponse(out, actionName, + TvServiceType[TV_SERVICE_PICTURE], + "Brightness", + value) != UPNP_E_SUCCESS) { + (*out) = NULL; + (*errorString) = "Internal Error"; + return UPNP_E_INTERNAL_ERROR; + } + return UPNP_E_SUCCESS; + } else { + (*errorString) = "Internal Error"; + return UPNP_E_INTERNAL_ERROR; + } + in = in; } -int TvDeviceIncreaseBrightness(IXML_Document *in, IXML_Document **out, const char **errorString) +int TvDeviceIncreaseBrightness(IXML_Document * in, IXML_Document ** out, + const char **errorString) { - return IncrementBrightness(1, in, out, errorString); + return IncrementBrightness(1, in, out, errorString); } -int TvDeviceDecreaseBrightness(IXML_Document *in, IXML_Document **out, const char **errorString) +int TvDeviceDecreaseBrightness(IXML_Document * in, IXML_Document ** out, + const char **errorString) { - return IncrementBrightness(-1, in, out, errorString); + return IncrementBrightness(-1, in, out, errorString); } int TvDeviceCallbackEventHandler(Upnp_EventType EventType, const void *Event, void *Cookie) @@ -1320,7 +1274,7 @@ int TvDeviceCallbackEventHandler(Upnp_EventType EventType, const void *Event, vo case UPNP_CONTROL_ACTION_REQUEST: TvDeviceHandleActionRequest((UpnpActionRequest *)Event); break; - /* ignore these cases, since this is not a control point */ + /* ignore these cases, since this is not a control point */ case UPNP_DISCOVERY_ADVERTISEMENT_ALIVE: case UPNP_DISCOVERY_SEARCH_RESULT: case UPNP_DISCOVERY_SEARCH_TIMEOUT: @@ -1333,8 +1287,9 @@ int TvDeviceCallbackEventHandler(Upnp_EventType EventType, const void *Event, vo case UPNP_EVENT_UNSUBSCRIBE_COMPLETE: break; default: - SampleUtil_Print("Error in TvDeviceCallbackEventHandler: unknown event type %d\n", - EventType); + SampleUtil_Print + ("Error in TvDeviceCallbackEventHandler: unknown event type %d\n", + EventType); } /* Print a summary of the event received */ SampleUtil_PrintEvent(EventType, Event); @@ -1344,8 +1299,8 @@ int TvDeviceCallbackEventHandler(Upnp_EventType EventType, const void *Event, vo } int TvDeviceStart(char *ip_address, unsigned short port, - const char *desc_doc_name, const char *web_dir_path, - print_string pfun, int combo) + const char *desc_doc_name, const char *web_dir_path, + print_string pfun, int combo) { int ret = UPNP_E_SUCCESS; char desc_doc_url[DESC_URL_SIZE]; @@ -1353,11 +1308,9 @@ int TvDeviceStart(char *ip_address, unsigned short port, ithread_mutex_init(&TVDevMutex, NULL); SampleUtil_Initialize(pfun); - SampleUtil_Print( - "Initializing UPnP Sdk with\n" - "\tipaddress = %s port = %u\n", - ip_address ? ip_address : "{NULL}", - port); + SampleUtil_Print("Initializing UPnP Sdk with\n" + "\tipaddress = %s port = %u\n", + ip_address ? ip_address : "{NULL}", port); ret = UpnpInit(ip_address, port); if (ret != UPNP_E_SUCCESS) { SampleUtil_Print("Error with UpnpInit -- %d\n", ret); @@ -1367,11 +1320,9 @@ int TvDeviceStart(char *ip_address, unsigned short port, } ip_address = UpnpGetServerIpAddress(); port = UpnpGetServerPort(); - SampleUtil_Print( - "UPnP Initialized\n" - "\tipaddress = %s port = %u\n", - ip_address ? ip_address : "{NULL}", - port); + SampleUtil_Print("UPnP Initialized\n" + "\tipaddress = %s port = %u\n", + ip_address ? ip_address : "{NULL}", port); if (!desc_doc_name) { if (combo) { desc_doc_name = "tvcombodesc.xml"; @@ -1383,38 +1334,37 @@ int TvDeviceStart(char *ip_address, unsigned short port, web_dir_path = DEFAULT_WEB_DIR; } snprintf(desc_doc_url, DESC_URL_SIZE, "http://%s:%d/%s", ip_address, - port, desc_doc_name); + port, desc_doc_name); SampleUtil_Print("Specifying the webserver root directory -- %s\n", - web_dir_path ); + web_dir_path); ret = UpnpSetWebServerRootDir(web_dir_path); if (ret != UPNP_E_SUCCESS) { - SampleUtil_Print( - "Error specifying webserver root directory -- %s: %d\n", - web_dir_path, ret); + SampleUtil_Print + ("Error specifying webserver root directory -- %s: %d\n", + web_dir_path, ret); UpnpFinish(); return ret; } - SampleUtil_Print( - "Registering the RootDevice\n" - "\t with desc_doc_url: %s\n", - desc_doc_url); + SampleUtil_Print("Registering the RootDevice\n" + "\t with desc_doc_url: %s\n", desc_doc_url); ret = UpnpRegisterRootDevice(desc_doc_url, TvDeviceCallbackEventHandler, - &device_handle, &device_handle); + &device_handle, &device_handle); if (ret != UPNP_E_SUCCESS) { - SampleUtil_Print("Error registering the rootdevice : %d\n", ret); + SampleUtil_Print("Error registering the rootdevice : %d\n", + ret); UpnpFinish(); return ret; } else { - SampleUtil_Print( - "RootDevice Registered\n" - "Initializing State Table\n"); - TvDeviceStateTableInit(desc_doc_url); + SampleUtil_Print("RootDevice Registered\n" + "Initializing State Table\n"); + TvDeviceStateTableInit(desc_doc_url); SampleUtil_Print("State Table Initialized\n"); ret = UpnpSendAdvertisement(device_handle, default_advr_expire); if (ret != UPNP_E_SUCCESS) { - SampleUtil_Print("Error sending advertisements : %d\n", ret); + SampleUtil_Print("Error sending advertisements : %d\n", + ret); UpnpFinish(); return ret; @@ -1448,16 +1398,14 @@ void *TvDeviceCommandLoop(void *args) /* Get a command line */ fgets(cmdline, 100, stdin); sscanf(cmdline, "%s", cmd); - if( strcasecmp(cmd, "exit") == 0) { + if (strcasecmp(cmd, "exit") == 0) { SampleUtil_Print("Shutting down...\n"); TvDeviceStop(); exit(0); } else { - SampleUtil_Print( - "\n Unknown command: %s\n\n", cmd); - SampleUtil_Print( - " Valid Commands:\n" - " Exit\n\n"); + SampleUtil_Print("\n Unknown command: %s\n\n", cmd); + SampleUtil_Print(" Valid Commands:\n" + " Exit\n\n"); } } @@ -1476,37 +1424,39 @@ int device_main(int argc, char *argv[]) SampleUtil_Initialize(linux_print); /* Parse options */ - for(i = 1; i < argc; i++) { + for (i = 1; i < argc; i++) { if (strcmp(argv[i], "-ip") == 0) { ip_address = argv[++i]; - } else if(strcmp(argv[i], "-port") == 0) { + } else if (strcmp(argv[i], "-port") == 0) { sscanf(argv[++i], "%u", &portTemp); - } else if(strcmp(argv[i], "-desc") == 0) { + } else if (strcmp(argv[i], "-desc") == 0) { desc_doc_name = argv[++i]; - } else if(strcmp(argv[i], "-webdir") == 0) { + } else if (strcmp(argv[i], "-webdir") == 0) { web_dir_path = argv[++i]; - } else if(strcmp(argv[i], "-help") == 0) { - SampleUtil_Print( - "Usage: %s -ip ipaddress -port port" - " -desc desc_doc_name -webdir web_dir_path" - " -help (this message)\n", argv[0]); - SampleUtil_Print( - "\tipaddress: IP address of the device" - " (must match desc. doc)\n" - "\t\te.g.: 192.168.0.4\n" - "\tport: Port number to use for" - " receiving UPnP messages (must match desc. doc)\n" - "\t\te.g.: 5431\n" - "\tdesc_doc_name: name of device description document\n" - "\t\te.g.: tvdevicedesc.xml\n" - "\tweb_dir_path: Filesystem path where web files" - " related to the device are stored\n" - "\t\te.g.: /upnp/sample/tvdevice/web\n"); + } else if (strcmp(argv[i], "-help") == 0) { + SampleUtil_Print("Usage: %s -ip ipaddress -port port" + " -desc desc_doc_name -webdir web_dir_path" + " -help (this message)\n", argv[0]); + SampleUtil_Print + ("\tipaddress: IP address of the device" + " (must match desc. doc)\n" + "\t\te.g.: 192.168.0.4\n" + "\tport: Port number to use for" + " receiving UPnP messages (must match desc. doc)\n" + "\t\te.g.: 5431\n" + "\tdesc_doc_name: name of device description document\n" + "\t\te.g.: tvdevicedesc.xml\n" + "\tweb_dir_path: Filesystem path where web files" + " related to the device are stored\n" + "\t\te.g.: /upnp/sample/tvdevice/web\n"); return 1; } } port = (unsigned short)portTemp; return TvDeviceStart(ip_address, port, desc_doc_name, web_dir_path, - linux_print, 0); + linux_print, 0); } +/*! @} Device Sample Module */ + +/*! @} UpnpSamples */ diff --git a/upnp/sample/common/tv_device.h b/upnp/sample/common/tv_device.h index 4bf9a28..da4cad2 100644 --- a/upnp/sample/common/tv_device.h +++ b/upnp/sample/common/tv_device.h @@ -33,6 +33,14 @@ **************************************************************************/ /*! + * \addtogroup UpnpSamples + * + * @{ + * + * \name Device Sample API + * + * @{ + * * \file */ @@ -47,7 +55,6 @@ extern "C" { #include "ithread.h" #include "upnp.h" -#include "UpnpUniStd.h" /* for close() */ #include #include @@ -557,5 +564,8 @@ int device_main(int argc, char *argv[]); } #endif -#endif +/*! @} Control Point Sample API */ +/*! @} UpnpSamples */ + +#endif /* UPNP_TV_DEVICE_H */