Fix coding style according to tizen rule 90/106290/2
authorKyungwook Tak <k.tak@samsung.com>
Wed, 21 Dec 2016 04:39:55 +0000 (13:39 +0900)
committerKyungwook Tak <k.tak@samsung.com>
Wed, 21 Dec 2016 09:12:42 +0000 (18:12 +0900)
Use pre-commit.sh to fit style

Change-Id: I5ca49a7698e1c6f6fa0ab891b4966343e77a8908
Signed-off-by: Kyungwook Tak <k.tak@samsung.com>
52 files changed:
include/drm-tizen-apps.h
include/drm-tizen-error.h
include/drm-tizen-mid.h
pre-commit.sh [new file with mode: 0755]
service/drm-tapps-initialize.cpp
service/drm-tapps.cpp
tadcore/DrmFileHandleMgr/DrmFileApi.cpp
tadcore/DrmFileHandleMgr/DrmFileHandler.cpp
tadcore/DrmFileHandleMgr/DrmFileMgr.cpp
tadcore/Svc/DrmTdcSvc.cpp
tadcore/TADCCore/TADC_Core.cpp
tadcore/TADCCore/TADC_Sub.cpp
tadcore/TADCCore/TADC_Util.cpp
tadcore/TADCInterface/DUIDGenerator.cpp
tadcore/TADCInterface/TADC_IF.cpp
tadcore/XMLParser/CPointerArray.cpp
tadcore/XMLParser/CXMLAttribute.cpp
tadcore/XMLParser/CXMLElement.cpp
tadcore/XMLParser/CXMLFile.cpp
tadcore/include/CPointerArray.h
tadcore/include/CXMLAttribute.h
tadcore/include/CXMLElement.h
tadcore/include/CXMLFile.h
tadcore/include/DUIDGenerator.h
tadcore/include/DrmFileApi.h
tadcore/include/DrmFileHandler.h
tadcore/include/DrmFileMgr.h
tadcore/include/DrmTdcSvc.h
tadcore/include/TADC_Core.h
tadcore/include/TADC_ErrorCode.h
tadcore/include/TADC_IF.h
tadcore/include/TADC_Sub.h
tadcore/include/TADC_Util.h
tadcore/include/TadcTypes.h
tappsd/inc/DTapps2Base64.h
tappsd/inc/DTapps2HMAC.h
tappsd/inc/DTapps2Rights.h
tappsd/inc/DTapps2SqliteDB.h
tappsd/inc/DTapps2Time.h
tappsd/inc/drm_intf_tapps.h
tappsd/src/db/DTapps2SqlData.cpp
tappsd/src/db/DTapps2SqliteDB.cpp
tappsd/src/intf/drm_intf_tapps.cpp
tappsd/src/rights/DTapps2Rights.cpp
tappsd/src/util/DTapps2Base64.cpp
tappsd/src/util/DTapps2HMAC.cpp
tappsd/src/util/DTapps2Time.cpp
test/drm_testapps.cpp
test/drm_testcore.cpp
test/drm_testcore.h
test/drm_testutil.cpp
test/drm_testutil.h

index eed6922..65f0160 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  *
- * @file     drm-service-apps.h
- * @author   Sunggun Jung    <sunggun.jung@samsung.com>
- * 
+ * @file     drm-tizen-apps.h
+ * @author   Sunggun Jung <sunggun.jung@samsung.com>
  */
-
 #ifndef __DRM_TIZEN_APPS_H__
 #define __DRM_TIZEN_APPS_H__
 
@@ -28,89 +26,97 @@ extern "C" {
 #include <time.h>
 #include "drm-tizen-error.h"
 
-
 /**
 * @internal
 * @defgroup DRM-TAPPS drm-tapps
-* @{  
+* @{
 */
 
-/**   
- *  An application can request generate request for getting License.
- * 
- * @param[in]        pRespBuf          Response Data String of the Purchase Request ( Null terminator string )
- * @param[in]        respBufLen        pResBuf Length
- * @param[in][out]   pReqBuf           License Request Data
- * @param[in][out]   pReqBufLen        IN : pReqBuf Length, OUT : Rights Request Data String Size ( including null terminator )
- * @param[in][out]   pLicenseUrl       License Acquisition URL Data
- * @param[in][out]   pLicenseUrlLen    IN : pLicenseUrl Length, OUT : Rights Issuer Server URL Data String Size (  including null terminator )
- * @return           This function returns TADC_SUCCESS(1) on success or an integer value other than 1 on failure.
- * @remarks     
- * @see              drm_tdc_generate_purchase_request
- * @since         
+/**
+ * An application can request generate request for getting License.
+ *
+ * @param[in]      pRespBuf       Response Data String of the Purchase Request
+ *                                (Null terminator string)
+ * @param[in]      respBufLen     pResBuf Length
+ * @param[in][out] pReqBuf        License Request Data
+ * @param[in][out] pReqBufLen     IN : pReqBuf Length
+ *                                OUT : Rights Request Data String Size
+ *                                      (including null terminator)
+ * @param[in][out] pLicenseUrl    License Acquisition URL Data
+ * @param[in][out] pLicenseUrlLen IN : pLicenseUrl Length
+ *                                OUT : Rights Issuer Server URL Data String Size
+ *                                (including null terminator)
+ *
+ * @return TADC_SUCCESS(1) on success or an integer value other than 1 on failure.
+ *
+ * @see drm_tdc_generate_purchase_request()
  */
-int drm_tizen_generate_license_request(const char *pRespBuf, unsigned int respBufLen, char *pReqBuf, unsigned int *pReqBufLen, char *pLicenseUrl, unsigned int *pLicenseUrlLen);
+int drm_tizen_generate_license_request(
+       const char *pRespBuf, unsigned int respBufLen,
+       char *pReqBuf, unsigned int *pReqBufLen,
+       char *pLicenseUrl, unsigned int *pLicenseUrlLen);
 
-/**   
- *  An application can get TAD license which is encrypted.
+/**
+ * An application can get TAD license which is encrypted.
  *
- * @param[in]        pRespBuf          Response Data String of the Rights Request ( Null terminator string )
- * @param[in]        respBufLen        pResBuf Length
- * @return           This function returns TADC_SUCCESS(1) on success or an integer value other than 1 on failure.
- * @remarks     
- * @see
- * @since         
+ * @param[in] pRespBuf   Response Data String of the Rights Request
+ *                       (Null terminator string)
+ * @param[in] respBufLen pResBuf Length
+ * @return TADC_SUCCESS(1) on success or an integer value other than 1 on failure.
  */
 int drm_tizen_register_license(const char *pRespBuf, unsigned int respBufLen);
 
-/**   
- * API for checks whether the app drm file or not
- * 
- * @param[in]        pDcfPath          File path that to be checked whether the app drm file or not
- * @param[in]        dcfPathLen        File path length that to be checked whether the app drm file or not
- * @return           This function returns TADC_SUCCESS(1) on success or an integer value other than 1 on failure.
- * @remarks
- * @see
- * @since         
+/**
+ * Checks whether the app drm file or not
+ *
+ * @param[in] pDcfPath   File path that to be checked whether the app drm file or not
+ * @param[in] dcfPathLen File path length that to be checked whether the app
+ *                       drm file or not
+ *
+ * @return TADC_SUCCESS(1) on success or an integer value other than 1 on failure.
  */
 int drm_tizen_is_drm_file(const char *pDcfPath, int dcfPathLen);
 
-/**   
- *  An application can get decrypted contents(Apps) which is encrypted.
- * 
- * @param[in]        pTADCFilepath     TDC DRM File Path        
- * @param[in]        tadcFileLen       TDC DRM File length    
- * @param[in]        pDecryptedFile    Decrypted File Path
- * @param[in]        decryptedFileLen  Decrypted File length
- * @return           This function returns TADC_SUCCESS(1) on success or an integer value other than 1 on failure.
- * @remarks     
- * @see
- * @since         
+/**
+ * An application can get decrypted contents(Apps) which is encrypted.
+ *
+ * @param[in] pTADCFilepath     TDC DRM File Path
+ * @param[in] tadcFileLen       TDC DRM File length
+ * @param[in] pDecryptedFile    Decrypted File Path
+ * @param[in] decryptedFileLen  Decrypted File length
+ *
+ * @return TADC_SUCCESS(1) on success or an integer value other than 1 on failure.
  */
-//Decrypt DRM File
-int drm_tizen_decrypt_package ( const char *pTADCFilepath, int tadcFileLen, const char *pDecryptedFile, int decryptedFileLen );
+int drm_tizen_decrypt_package(const char *pTADCFilepath, int tadcFileLen,
+                                                         const char *pDecryptedFile, int decryptedFileLen);
 
-/**   
- *  An application can request purchase request for getting License.
- * 
- * @param[in]        pTADCFilepath     File path of Tizen Apps DRM contents
- * @param[out]       pReqBuf           Purchase Request Data
- * @param[in][out]   pReqBufLen        IN : pReqBuf Length, OUT : Purchase Request Data String Size ( including null terminator )
- * @param[out]       pLicenseUrl       License Acquisition URL Data
- * @param[in][out]   pLicenseUrlLen    IN : pLicenseUrl Length, OUT : License Server URL Data String Size (  including null terminator )
- * @return           This function returns TADC_SUCCESS(1) on success or an integer value other than 1 on failure.
- * @remarks     
- * @see                DrmTdcGenerateLicenseRequest
- * @since         
+/**
+ * An application can request purchase request for getting License.
+ *
+ * @param[in]      pTADCFilepath     File path of Tizen Apps DRM contents
+ * @param[out]     pReqBuf           Purchase Request Data
+ * @param[in][out] pReqBufLen        IN : pReqBuf Length
+ *                                   OUT : Purchase Request Data String Size
+ *                                   (including null terminator)
+ * @param[out]     pLicenseUrl       License Acquisition URL Data
+ * @param[in][out] pLicenseUrlLen    IN : pLicenseUrl Length
+ *                                   OUT : License Server URL Data String Size
+ *                                   (including null terminator)
+ *
+ * @return TADC_SUCCESS(1) on success or an integer value other than 1 on failure.
+ *
+ * @see DrmTdcGenerateLicenseRequest()
  */
-int drm_tizen_generate_purchase_request ( const char *pTADCFilepath, char *pReqBuf, unsigned int *pReqBufLen, char *pLicenseUrl, unsigned int *pLicenseUrlLen );
+int drm_tizen_generate_purchase_request(const char *pTADCFilepath,
+                                                                               char *pReqBuf, unsigned int *pReqBufLen, char *pLicenseUrl,
+                                                                               unsigned int *pLicenseUrlLen);
 
 /**
 *@}
-*/ /* Doxygen : addtogroup*/
+*/
 
 #ifdef __cplusplus
 }
 #endif
 
-#endif
+#endif //__DRM_TIZEN_APPS_H__
index 91f15a0..f01dde4 100644 (file)
@@ -13,7 +13,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 #ifndef __DRM_TIZEN_ERROR_H__
 #define __DRM_TIZEN_ERROR_H__
 
 extern "C" {
 #endif
 
-
-#define                TADC_SUCCESS                                    1                               // SUCCESS
+#define TADC_SUCCESS                    1      // SUCCESS
 // TADC Error Message Define
-#define                TADC_GETDUID_ERROR                              0x0611                  // Get IMEI Error
-#define                TADC_GETMCC_ERROR                               0x0612                  // Get MCC Error
-#define                TADC_GETMNC_ERROR                               0x0613                  // Get MNC Error
-
-#define                TADC_REQMAKEHMAC_ERROR                  0x0620                  // Make Signature Fail in Reauest Message
-#define                TADC_RESPONSEMESSAGE_ERROR              0x0621                  // Response Message structure Error
-#define                TADC_RESPONSESIGNATURE_ERROR    0x0622                  // Response Message Signature Error
-
-#define                TADC_GETDHKEY_ERROR                             0x0630                  // Get DH Key Error
-#define                TADC_GETRESPONSLICENSE_ERROR    0x0631                  // Get License information Error in Response Message
-#define                TADC_LICENSEXMLPARSING_ERROR    0x0632                  // License XML parsing Error in Response Message
-
-#define                TADC_NOTTADCFILE_ERROR                  0x0640                  // This is not TADC Contents
-#define                TADC_CONTENTSVERSION_ERROR              0x0641                  // TADC Contents Version Error
-#define                TADC_CONTENTSHMAC_ERROR                 0x0642                  // Contents Signature Error
-#define                TADC_CONTENTSXML_ERROR                  0x0643                  // Contents XML Error in Header
-#define                TADC_CONTENTSSTRUCT_ERROR               0X0644                  // Contents Header Struct Error
-
-#define                TADC_RULE_DUID_ERROR                    0x0651                  // IMEI Rule check Error
-#define                TADC_RULE_MIN_ERROR                             0x0652                  // MIN Rule check Error
-#define                TADC_RULE_NOINFOMATION                  0X0653                  // NO Information in DB
-
-#define                TADC_PARAMETER_ERROR                    0X0660                  // Input Parameter Error
-#define                TADC_XMLPARSER_ERROR                    0X0661                  // XML Parser Error
-#define                TADC_MEMAlOC_ERROR                              0x0662                  // Memory Alocation Error
-
-#define                TADC_CID_NULL_ERROR                             0X0670                  // CID Null Error
-#define                TADC_SID_NULL_ERROR                             0X0671                  // CID Null Error
-
-//2011.03.08
-#define                TADC_RO_SIGNATURE_ERROR                 0X0680                  // RO Signature Fail
-#define                TADC_RO_CERTIFICATE_ERROR               0X0681                  // RO Certificate Fail
-
-//2013.03.11
-#define                TADC_DHINFO_MAX_ERROR                   0x0690                  // DHINFO Max error
-#define                TADC_GET_ROACQ_INFO_ERROR               0x0691                  // TADC_GetROAcqInfo Fail
-#define                TADC_MAKE_LICENSEREQ_ERROR              0x0692                  // SACD_MakeRequestRO Fail
-#define                TADC_GET_HASHREQID_ERROR                0x0693                  // TADC_GetHashReqID Fail
-#define                TADC_GET_RORES_INFO_ERROR               0x0694                  // TADC_GetROAcqInfo Fail
-
-#define                TADC_PARSE_TIMECONSTRAINTS_ERROR        0x0695                  // DTappsDtTmStr2StrucTm Fail
-#define                TADC_LICENSE_INVALID_ERROR              0x0696                  // DSaapsValidateConstraints Fail
-
-#define                TADC_GET_DEVICEKEY_ERROR                0x0697                  // DTappsGetDeviceKey Fail
-#define                TADC_GET_BASE64ENCODE_ERROR             0x0698                  // DTappsB64Encode Fail
-#define                TADC_SET_AES_ENCRYPTKEY_ERROR   0x0699                  // DTAPPS_AES_SET_ENCR_KEY Fail
-#define                TADC_SET_AES_WRAPKEY_ERROR              0x0700                  // DTAPPS_AES_WRAP_KEY Fail
-#define                TADC_DB_INSTALL_ERROR                   0x0702                  // DTapps_DB_Install Fail
-#define                TADC_DB_READ_ERROR                              0x0703                  // DTapps_DB_Install Fail
-
-#define                TADC_FILE_OPEN_ERROR                    0x0704                  //
-#define                TADC_FILE_READ_ERROR                    0x0705                  //
-#define                TADC_GET_FILEHEADER_ERROR               0x0706                  // DrmTdcGetFileHeader Fail
-#define                TADC_GET_CEK_ERROR                              0x0707                  // DSaapsGetCek Fail
-#define                TADC_GET_FILE_HANDLER_ERROR             0x0708
-#define                TADC_DECRYPT_PACKAGE_ERROR              0x0709                  // DrmTdcDecryptPackage2 Fail
-
-#define                TADC_LICENSE_VALID                              1
-#define                TADC_LICENSE_DB_ERROR                   0x802
-#define                TADC_LICENSE_NO_LICENSE                 0x805
-#define                TADC_LICENSE_DUID_MISMATCH              0x806
-#define                TADC_LICENSE_UNKNOWN_ERROR              0x807
+#define TADC_GETDUID_ERROR              0x0611 // Get IMEI Error
+#define TADC_GETMCC_ERROR               0x0612 // Get MCC Error
+#define TADC_GETMNC_ERROR               0x0613 // Get MNC Error
+
+#define TADC_REQMAKEHMAC_ERROR          0x0620 // Make Signature Fail in Reauest Message
+#define TADC_RESPONSEMESSAGE_ERROR      0x0621 // Response Message structure Error
+#define TADC_RESPONSESIGNATURE_ERROR    0x0622 // Response Message Signature Error
+
+#define TADC_GETDHKEY_ERROR             0x0630 // Get DH Key Error
+#define TADC_GETRESPONSLICENSE_ERROR    0x0631 // Get License information Error
+#define TADC_LICENSEXMLPARSING_ERROR    0x0632 // License XML parsing Error
+
+#define TADC_NOTTADCFILE_ERROR          0x0640 // This is not TADC Contents
+#define TADC_CONTENTSVERSION_ERROR      0x0641 // TADC Contents Version Error
+#define TADC_CONTENTSHMAC_ERROR         0x0642 // Contents Signature Error
+#define TADC_CONTENTSXML_ERROR          0x0643 // Contents XML Error in Header
+#define TADC_CONTENTSSTRUCT_ERROR       0X0644 // Contents Header Struct Error
+
+#define TADC_RULE_DUID_ERROR            0x0651 // IMEI Rule check Error
+#define TADC_RULE_MIN_ERROR             0x0652 // MIN Rule check Error
+#define TADC_RULE_NOINFOMATION          0X0653 // NO Information in DB
+
+#define TADC_PARAMETER_ERROR            0X0660 // Input Parameter Error
+#define TADC_XMLPARSER_ERROR            0X0661 // XML Parser Error
+#define TADC_MEMAlOC_ERROR              0x0662 // Memory Alocation Error
+
+#define TADC_CID_NULL_ERROR             0X0670 // CID Null Error
+#define TADC_SID_NULL_ERROR             0X0671 // CID Null Error
+
+#define TADC_RO_SIGNATURE_ERROR         0X0680 // RO Signature Fail
+#define TADC_RO_CERTIFICATE_ERROR       0X0681 // RO Certificate Fail
+
+#define TADC_DHINFO_MAX_ERROR           0x0690 // DHINFO Max error
+#define TADC_GET_ROACQ_INFO_ERROR       0x0691 // TADC_GetROAcqInfo Fail
+#define TADC_MAKE_LICENSEREQ_ERROR      0x0692 // SACD_MakeRequestRO Fail
+#define TADC_GET_HASHREQID_ERROR        0x0693 // TADC_GetHashReqID Fail
+#define TADC_GET_RORES_INFO_ERROR       0x0694 // TADC_GetROAcqInfo Fail
+
+#define TADC_PARSE_TIMECONSTRAINTS_ERROR 0x0695 // DTappsDtTmStr2StrucTm Fail
+#define TADC_LICENSE_INVALID_ERROR       0x0696 // DSaapsValidateConstraints Fail
+
+#define TADC_GET_DEVICEKEY_ERROR         0x0697 // DTappsGetDeviceKey Fail
+#define TADC_GET_BASE64ENCODE_ERROR      0x0698 // DTappsB64Encode Fail
+#define TADC_SET_AES_ENCRYPTKEY_ERROR    0x0699 // DTAPPS_AES_SET_ENCR_KEY Fail
+#define TADC_SET_AES_WRAPKEY_ERROR       0x0700 // DTAPPS_AES_WRAP_KEY Fail
+#define TADC_DB_INSTALL_ERROR            0x0702 // DTapps_DB_Install Fail
+#define TADC_DB_READ_ERROR               0x0703 // DTapps_DB_Install Fail
+
+#define TADC_FILE_OPEN_ERROR             0x0704
+#define TADC_FILE_READ_ERROR             0x0705
+#define TADC_GET_FILEHEADER_ERROR        0x0706 // DrmTdcGetFileHeader Fail
+#define TADC_GET_CEK_ERROR               0x0707 // DSaapsGetCek Fail
+#define TADC_GET_FILE_HANDLER_ERROR      0x0708
+#define TADC_DECRYPT_PACKAGE_ERROR       0x0709 // DrmTdcDecryptPackage2 Fail
+
+#define TADC_LICENSE_VALID               1
+#define TADC_LICENSE_DB_ERROR            0x802
+#define TADC_LICENSE_NO_LICENSE          0x805
+#define TADC_LICENSE_DUID_MISMATCH       0x806
+#define TADC_LICENSE_UNKNOWN_ERROR       0x807
 
 #ifdef __cplusplus
 }
 #endif
 
 #endif // __DRM_TIZEN_ERROR_H__
-
index b1f5fc5..f4d044e 100644 (file)
@@ -16,9 +16,7 @@
  * @file     drm-tizen-mid.h
  * @author   Sunggun Jung <sunggun.jung@samsung.com>
  *           Kyungwook Tak <k.tak@samsung.com>
- *
  */
-
 #ifndef __DRM_TIZEN_MID_H__
 #define __DRM_TIZEN_MID_H__
 
@@ -32,10 +30,12 @@ extern "C" {
 #include <linux/unistd.h>
 #include <unistd.h>
 
-/*Flag to Enable Widget DRM Rights installation using the Linux OMA DRM design */
+// Flag to Enable Widget DRM Rights installation using the Linux OMA DRM design
 //#define __EDRM_ENABLE_WIDGET_DRM__
 #define drmgettid() (long int)syscall(__NR_gettid)
-#define DRM_FILENAME(X) (strrchr((char*)(X), '/') ? (char*)(strrchr((char*)(X), '/') + 1) : ((char*)(X)) )
+#define DRM_FILENAME(X) \
+       (strrchr((char *)(X), '/') ? \
+        (char *)(strrchr((char *)(X), '/') + 1) : ((char *)(X)))
 
 
 #ifdef TAG_DRM_TIZEN
@@ -45,12 +45,16 @@ extern "C" {
 
 #include <dlog.h>
 
-/* Tizen Apps DRM related logs */
-#define DRM_TAPPS_LOG(FMT, ARG...)               SLOG(LOG_INFO, TAG_DRM_TIZEN, FMT, ##ARG)
-#define DRM_TAPPS_FRQ_LOG(FMT, ARG...)           SLOG(LOG_DEBUG, TAG_DRM_TIZEN, FMT, ##ARG)
-#define DRM_TAPPS_EXCEPTION(FMT, ARG...)         SLOG(LOG_ERROR, TAG_DRM_TIZEN, FMT, ##ARG)
-#define DRM_TAPPS_SECURE_LOG(FMT, ARG...)        SECURE_SLOG(LOG_INFO, TAG_DRM_TIZEN, FMT, ##ARG)
-#define DRM_TAPPS_SECURE_EXCEPTION(FMT, ARG...)  SECURE_SLOG(LOG_ERROR, TAG_DRM_TIZEN, FMT, ##ARG)
+#define DRM_TAPPS_LOG(FMT, ARG...) \
+       SLOG(LOG_INFO, TAG_DRM_TIZEN, FMT, ##ARG)
+#define DRM_TAPPS_FRQ_LOG(FMT, ARG...) \
+       SLOG(LOG_DEBUG, TAG_DRM_TIZEN, FMT, ##ARG)
+#define DRM_TAPPS_EXCEPTION(FMT, ARG...) \
+       SLOG(LOG_ERROR, TAG_DRM_TIZEN, FMT, ##ARG)
+#define DRM_TAPPS_SECURE_LOG(FMT, ARG...) \
+       SECURE_SLOG(LOG_INFO, TAG_DRM_TIZEN, FMT, ##ARG)
+#define DRM_TAPPS_SECURE_EXCEPTION(FMT, ARG...) \
+       SECURE_SLOG(LOG_ERROR, TAG_DRM_TIZEN, FMT, ##ARG)
 
 #ifdef __cplusplus
 }
diff --git a/pre-commit.sh b/pre-commit.sh
new file mode 100755 (executable)
index 0000000..8712c5a
--- /dev/null
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+# check coding style by astyle
+# it's done based on astyle version 2.05.1
+astyle ./*.cpp ./*.h --recursive \
+       --style=stroustrup --suffix=none --indent=force-tab=4 --pad-oper --pad-header \
+       --unpad-paren --align-pointer=name --align-reference=name --indent-col1-comments \
+       --close-templates --break-blocks --max-code-length=80 --break-after-logical \
+       --indent-preproc-define --convert-tabs
index e8910e1..dcba8b7 100644 (file)
@@ -24,24 +24,20 @@ static int __drm_tad_create_db(void)
        int IsBeginSuccessful = 0;
 
        char Table_Name[16] = "dtapps2rights";
-       charsql_query_table = NULL;
+       char *sql_query_table = NULL;
        void *pDb = NULL;
 
        db_ret = DTappsDBOpen(pDb, __func__);
 
-       if(db_ret != TRUE)
-       {
+       if (db_ret != TRUE) {
                DRM_TAPPS_EXCEPTION("DTappsDBOpen FAILED");
-
                return -1;
        }
 
        db_ret = DTappsDBBeginImmedTrans(__func__);
 
-       if(db_ret != TRUE)
-       {
+       if (db_ret != TRUE) {
                DRM_TAPPS_EXCEPTION("DTappsDBBeginImmedTrans FAILED");
-
                goto ErrorExit;
        }
 
@@ -49,10 +45,8 @@ static int __drm_tad_create_db(void)
 
        sql_query_table = DTappsGetSQLCreateTable(Table_Name);
 
-       if(sql_query_table == NULL)
-       {
+       if (sql_query_table == NULL) {
                DRM_TAPPS_EXCEPTION("DTappsGetSQLCreateTable FAILED");
-
                goto ErrorExit;
        }
 
@@ -60,17 +54,14 @@ static int __drm_tad_create_db(void)
 
        db_ret = DTappsExecuteSQL(pDb, sql_query_table);
 
-       if(db_ret != TRUE)
-       {
+       if (db_ret != TRUE) {
                DRM_TAPPS_EXCEPTION("DTappsGetSQLCreateTable FAILED");
-
                goto ErrorExit;
        }
 
        db_ret = DTappsDBCommit(__func__);
 
-       if(db_ret != TRUE)
-       {
+       if (db_ret != TRUE) {
                DRM_TAPPS_EXCEPTION("DTappsDBCommit FAILED");
 
                goto ErrorExit;
@@ -78,10 +69,8 @@ static int __drm_tad_create_db(void)
 
        db_ret = DTappsDBClose(__func__);
 
-       if(db_ret != TRUE)
-       {
+       if (db_ret != TRUE) {
                DRM_TAPPS_EXCEPTION("DTappsDBClose FAILED");
-
                goto ErrorExit;
        }
 
@@ -92,15 +81,12 @@ static int __drm_tad_create_db(void)
 ErrorExit:
 
        if (1 == IsBeginSuccessful)
-       {
-                DTappsDBRollback(__func__);
-       }
+               DTappsDBRollback(__func__);
 
        db_ret = DTappsDBClose(__func__);
-       if(db_ret != TRUE)
-       {
+
+       if (db_ret != TRUE)
                DRM_TAPPS_EXCEPTION("DTappsDBClose FAILED");
-       }
 
        DRM_TAPPS_EXCEPTION("TAD DB creation FAILED");
 
@@ -109,16 +95,14 @@ ErrorExit:
 
 int main(int, char *[])
 {
-       DRM_TAPPS_FRQ_LOG("=============Start Create TAD DB file ================\n\n ");
-
-       if(0 != __drm_tad_create_db())
-       {
-               DRM_TAPPS_EXCEPTION("=============Error Creating TAD DB file ================\n\n ");
+       DRM_TAPPS_FRQ_LOG("=========Start Create TAD DB file ============\n\n");
 
+       if (0 != __drm_tad_create_db()) {
+               DRM_TAPPS_EXCEPTION("=========Error Creating TAD DB file ============\n\n");
                return 1;
        }
 
-       DRM_TAPPS_FRQ_LOG("=============Success Created TAD DB file  ================\n\n ");
+       DRM_TAPPS_FRQ_LOG("=========Success Created TAD DB file  ============\n\n");
 
        return 0;
 }
index cb7472d..93eec5e 100644 (file)
@@ -14,7 +14,7 @@
  * limitations under the License.
  *
  * @file     drm-tapps.cpp
- * @author   Sunggun Jung    <sunggun.jung@samsung.com>
+ * @author   Sunggun Jung <sunggun.jung@samsung.com>
  *
  */
 
 #include "DTapps2HMAC.h"
 #include "DTapps2Rights.h"
 
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__((visibility("default")))
+#endif
+
 /* Enable this flag to take API level time profiling */
 //#define __DRM_TAPPS_API_TIME_PROFILING__
 
 #ifdef __DRM_TAPPS_API_TIME_PROFILING__
 #include <sys/time.h>
 
-class DrmTappsProf
-{
+class DrmTappsProf {
 public:
-       DrmTappsProf(const charfunction);
+       DrmTappsProf(const char *function);
        ~DrmTappsProf();
        struct timeval TappsStartTv;
        struct timeval TappsStopTv;
        char TappsfunNane[256];
 };
 
-DrmTappsProf::DrmTappsProf(const charfunction)
+DrmTappsProf::DrmTappsProf(const char *function)
 {
        memcpy(TappsfunNane, function, strlen(function));
        gettimeofday(&TappsStartTv, NULL);
-       DRM_TAPPS_EXCEPTION("[DRM-TIZEN-PERF]START:SEC=%ld, USEC=%ld for [%s]",(long int)(TappsStartTv.tv_sec) , (long int)(TappsStartTv.tv_usec),function);
+       DRM_TAPPS_EXCEPTION("[DRM-TIZEN-PERF]START:SEC=%ld, USEC=%ld for [%s]",
+                                               (long int)(TappsStartTv.tv_sec) , (long int)(TappsStartTv.tv_usec), function);
 }
 
 DrmTappsProf::~DrmTappsProf()
 {
        gettimeofday(&TappsStopTv, NULL);
-       DRM_TAPPS_EXCEPTION("[DRM-TIZEN-PERF] STOP:SEC=%ld, USEC=%ld for [%s]", (long int)(TappsStopTv.tv_sec), (long int)(TappsStopTv.tv_usec),TappsfunNane);
-       DRM_TAPPS_EXCEPTION("[DRM-TIZEN-PERF]TOTAL_DIFFF  : USEC=%ld for [%s]", ((long int)(TappsStopTv.tv_sec - TappsStartTv.tv_sec) * (1000000) + (long int)(TappsStopTv.tv_usec - TappsStartTv.tv_usec)), TappsfunNane);
+       DRM_TAPPS_EXCEPTION("[DRM-TIZEN-PERF] STOP:SEC=%ld, USEC=%ld for [%s]",
+                                               (long int)(TappsStopTv.tv_sec), (long int)(TappsStopTv.tv_usec), TappsfunNane);
+       DRM_TAPPS_EXCEPTION("[DRM-TIZEN-PERF]TOTAL_DIFFF  : USEC=%ld for [%s]",
+                                               ((long int)(TappsStopTv.tv_sec - TappsStartTv.tv_sec) * (1000000) + (long int)(
+                                                        TappsStopTv.tv_usec - TappsStartTv.tv_usec)), TappsfunNane);
 }
 
 #define DRM_TAPPS_API_TIME() DrmTappsProf DrmTappsObj(__func__);
@@ -66,98 +73,84 @@ DrmTappsProf::~DrmTappsProf()
 #define DRM_TAPPS_API_TIME()
 #endif /* __DRM_TAPPS_API_TIME_PROFILING__ */
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Define EXPORT_API */
-#ifndef EXPORT_API
-#define EXPORT_API __attribute__((visibility("default")))
-#endif
-
-int _drm_tapps_generate_purchase_request(const char *pTADCFilepath, char *pReqBuf, unsigned int *pReqBufLen, char *pLicenseUrl, unsigned int *pLicenseUrlLen);
-int _drm_tapps_generate_license_request(const char *pRespBuf, unsigned int respBufLen, char *pReqBuf, unsigned int *pReqBufLen, char *pLicenseUrl, unsigned int *pLicenseUrlLen);
+int _drm_tapps_generate_purchase_request(
+       const char *pTADCFilepath,
+       char *pReqBuf, unsigned int *pReqBufLen, char *pLicenseUrl,
+       unsigned int *pLicenseUrlLen);
+int _drm_tapps_generate_license_request(
+       const char *pRespBuf, unsigned int respBufLen,
+       char *pReqBuf, unsigned int *pReqBufLen,
+       char *pLicenseUrl, unsigned int *pLicenseUrlLen);
 int _drm_tapps_register_license(const char *pRespBuf, unsigned int respBufLen);
-int _drm_tapps_decrypt_package(const char *pTADCFilepath, int stadFileLen, const char *pDecryptedFile, int decryptedFileLen);
+int _drm_tapps_decrypt_package(const char *pTADCFilepath, int stadFileLen,
+                                                          const char *pDecryptedFile, int decryptedFileLen);
 int _drm_tapps_is_drm_file(const char *pDcfPath, int dcfPathLen);
 
-EXPORT_API int drm_tizen_generate_license_request(
-       const char *pRespBuf,        //Response Data String of the Purchase Request ( Null terminator string )
-       unsigned int respBufLen,     //pResBuf Length
-       char *pReqBuf,               //License Request Data
-       unsigned int *pReqBufLen,    //IN : pReqBuf Length, OUT : Rights Request Data String Size ( including null terminator )
-       char *pLicenseUrl,           //License Acquisition URL Data
-       unsigned int *pLicenseUrlLen //IN : pLicenseUrl Length, OUT : Rights Issuer Server URL Data String Size (  including null terminator )
-)
+EXPORT_API
+int drm_tizen_generate_license_request(
+       const char *pRespBuf, unsigned int respBufLen,
+       char *pReqBuf, unsigned int *pReqBufLen,
+       char *pLicenseUrl, unsigned int *pLicenseUrlLen)
 {
        int ret = TADC_SUCCESS;
        DRM_TAPPS_LOG("%s starts", __func__);
 
-       if (pRespBuf == NULL || pReqBuf == NULL || pLicenseUrl == NULL)
-       {
+       if (pRespBuf == NULL || pReqBuf == NULL || pLicenseUrl == NULL) {
                DRM_TAPPS_EXCEPTION("%s) Error : Parameters NULL.", __func__);
                return TADC_PARAMETER_ERROR;
        }
 
-       if (strlen(pRespBuf) != respBufLen)
-       {
-               DRM_TAPPS_EXCEPTION("%s) Error : Input value and size weren't equal.", __func__);
+       if (strlen(pRespBuf) != respBufLen) {
+               DRM_TAPPS_EXCEPTION("%s) Error : Input value and size weren't equal.",
+                                                       __func__);
                return TADC_PARAMETER_ERROR;
        }
 
-       ret = _drm_tapps_generate_license_request(pRespBuf, respBufLen, pReqBuf, pReqBufLen, pLicenseUrl, pLicenseUrlLen);
+       ret = _drm_tapps_generate_license_request(pRespBuf, respBufLen, pReqBuf,
+                       pReqBufLen, pLicenseUrl, pLicenseUrlLen);
        DRM_TAPPS_LOG("%s result=%x", __func__, ret);
 
        return ret;
 }
 
 int _drm_tapps_generate_license_request(
-       const char *pRespBuf,        //Response Data String of the Purchase Request ( Null terminator string )
-       unsigned int respBufLen,     //pResBuf Length
-       char *pReqBuf,               //License Request Data
-       unsigned int *pReqBufLen,    //IN : pReqBuf Length, OUT : Rights Request Data String Size ( including null terminator )
-       char *pLicenseUrl,           //License Acquisition URL Data
-       unsigned int *pLicenseUrlLen //IN : pLicenseUrl Length, OUT : Rights Issuer Server URL Data String Size (  including null terminator )
-)
+       const char *pRespBuf, unsigned int respBufLen,
+       char *pReqBuf, unsigned int *pReqBufLen,
+       char *pLicenseUrl, unsigned int *pLicenseUrlLen)
 {
        int ret = TADC_SUCCESS;
        DRM_TAPPS_LOG("%s starts", __func__);
 
-       if (pRespBuf == NULL || pReqBuf == NULL || pLicenseUrl == NULL)
-       {
+       if (pRespBuf == NULL || pReqBuf == NULL || pLicenseUrl == NULL) {
                DRM_TAPPS_EXCEPTION("%s) Error : Parameters NULL.", __func__);
                return TADC_PARAMETER_ERROR;
        }
 
-       if (strlen(pRespBuf) != respBufLen)
-       {
-               DRM_TAPPS_EXCEPTION("%s) Error : Input value and size weren't equal.", __func__);
+       if (strlen(pRespBuf) != respBufLen) {
+               DRM_TAPPS_EXCEPTION("%s) Error : Input value and size weren't equal.",
+                                                       __func__);
                return TADC_PARAMETER_ERROR;
        }
 
-       ret = DrmTdcGenerateLicenseRequest( pRespBuf, respBufLen, pReqBuf, pReqBufLen, pLicenseUrl, pLicenseUrlLen );
+       ret = DrmTdcGenerateLicenseRequest(pRespBuf, respBufLen, pReqBuf, pReqBufLen,
+                                                                          pLicenseUrl, pLicenseUrlLen);
        DRM_TAPPS_LOG("%s result = %x", __func__, ret);
 
        return ret;
 }
 
-EXPORT_API int drm_tizen_register_license
-(
-       const char *pRespBuf,                           //Response Data String of the Rights Request ( Null terminator string )
-       unsigned int respBufLen                         //pResBuf Length
-)
+EXPORT_API
+int drm_tizen_register_license(const char *pRespBuf, unsigned int respBufLen)
 {
        int ret = TADC_SUCCESS;
        DRM_TAPPS_LOG("%s starts", __func__);
 
-       if (pRespBuf == NULL)
-       {
+       if (pRespBuf == NULL) {
                DRM_TAPPS_EXCEPTION("%s) Parameters NULL!", __func__);
                return TADC_PARAMETER_ERROR;
        }
 
-       if (strlen(pRespBuf) != respBufLen)
-       {
+       if (strlen(pRespBuf) != respBufLen) {
                DRM_TAPPS_EXCEPTION("%s) Input value and size wasn't equal.", __func__);
                return TADC_PARAMETER_ERROR;
        }
@@ -173,19 +166,17 @@ int _drm_tapps_register_license(const char *pRespBuf, unsigned int respBufLen)
        DRM_TAPPS_API_TIME()
 
        int Ret = TADC_SUCCESS;
-       char pDecLicenseBuf[1024*8] = {0, };
+       char pDecLicenseBuf[1024 * 8] = {0, };
        unsigned int decLicenseBufLen = 0;
 
        DRM_TAPPS_LOG("%s starts", __func__);
 
-       if(pRespBuf == NULL)
-       {
+       if (pRespBuf == NULL) {
                DRM_TAPPS_EXCEPTION("%s) Parameters NULL!", __func__);
                return TADC_PARAMETER_ERROR;
        }
 
-       if (strlen(pRespBuf) != respBufLen)
-       {
+       if (strlen(pRespBuf) != respBufLen) {
                DRM_TAPPS_EXCEPTION("%s) Input value and size weren't equal.", __func__);
                return TADC_PARAMETER_ERROR;
        }
@@ -193,17 +184,19 @@ int _drm_tapps_register_license(const char *pRespBuf, unsigned int respBufLen)
        memset(pDecLicenseBuf, 0x00, sizeof(pDecLicenseBuf));
        decLicenseBufLen = sizeof(pDecLicenseBuf);
 
-       /* Has to be enabled when the response from server is known which will be encrypted!! */
-       Ret = DrmTdcDecryptLicense(pRespBuf, respBufLen, pDecLicenseBuf, &decLicenseBufLen);
-       if (Ret != TADC_SUCCESS)
-       {
-               DRM_TAPPS_EXCEPTION("DrmTdcDecryptLicense failed!!! Ret = %x",Ret);
+       // Has to be enabled when the response from server is known
+       // which will be encrypted!!
+       Ret = DrmTdcDecryptLicense(pRespBuf, respBufLen, pDecLicenseBuf,
+                                                          &decLicenseBufLen);
+
+       if (Ret != TADC_SUCCESS) {
+               DRM_TAPPS_EXCEPTION("DrmTdcDecryptLicense failed!!! Ret = %x", Ret);
                return Ret;
        }
 
        Ret = DTappsInstallLicense(pDecLicenseBuf);
-       if (Ret != TADC_SUCCESS)
-       {
+
+       if (Ret != TADC_SUCCESS) {
                DRM_TAPPS_EXCEPTION("DTappsInstallLicense failed!!! Ret = %x", Ret);
                goto DTAPPS_EXIT;
        }
@@ -220,14 +213,13 @@ EXPORT_API int drm_tizen_is_drm_file(const char *pDcfPath, int dcfPathLen)
        int ret = TADC_SUCCESS;
 
        DRM_TAPPS_LOG("%s starts", __func__);
-       if (pDcfPath == NULL)
-       {
+
+       if (pDcfPath == NULL) {
                DRM_TAPPS_EXCEPTION("%s) Parameters NULL!", __func__);
                return TADC_PARAMETER_ERROR;
        }
 
-       if ((int)strlen(pDcfPath) != dcfPathLen)
-       {
+       if ((int)strlen(pDcfPath) != dcfPathLen) {
                DRM_TAPPS_EXCEPTION("%s) Input value and size wasn't equal.", __func__);
                return TADC_PARAMETER_ERROR;
        }
@@ -249,15 +241,14 @@ int _drm_tapps_is_drm_file(const char *pDcfPath, int dcfPathLen)
        DrmTdcFileHeader fileHeader;
 
        DRM_TAPPS_LOG("%s starts", __func__);
-       if (pDcfPath == NULL)
-       {
+
+       if (pDcfPath == NULL) {
                DRM_TAPPS_EXCEPTION("%s) Parameters NULL!", __func__);
                ret = TADC_PARAMETER_ERROR;
                goto finish;
        }
 
-       if ((int)strlen(pDcfPath) != dcfPathLen)
-       {
+       if ((int)strlen(pDcfPath) != dcfPathLen) {
                DRM_TAPPS_EXCEPTION("%s) Input value and size wasn't equal.", __func__);
                ret = TADC_PARAMETER_ERROR;
                goto finish;
@@ -265,8 +256,8 @@ int _drm_tapps_is_drm_file(const char *pDcfPath, int dcfPathLen)
 
        memset(&fileHeader, 0, sizeof(DrmTdcFileHeader));
        bRet = DrmTdcGetFileHeader(pDcfPath, &fileHeader);
-       if (bRet == FALSE)
-       {
+
+       if (bRet == FALSE) {
                DRM_TAPPS_EXCEPTION("%s Error : DrmTdcGetFileHeader is failed", __func__);
                ret = TADC_NOTTADCFILE_ERROR;
        }
@@ -277,29 +268,25 @@ finish:
        return ret;
 }
 
-EXPORT_API int drm_tizen_decrypt_package(
- const char *pTADCFilepath,   /* TDC DRM File Path  */
- int stadFileLen,
- const char *pDecryptedFile,   /* Decrypted File Path */
- int decryptedFileLen
-)
+EXPORT_API
+int drm_tizen_decrypt_package(
+       const char *pTADCFilepath, int stadFileLen,
+       const char *pDecryptedFile, int decryptedFileLen)
 {
        int ret = TADC_SUCCESS;
-       DRM_TAPPS_LOG("drm_tizen_decrypt_package(%s, %s) started!", pTADCFilepath, pDecryptedFile);
+       DRM_TAPPS_LOG("drm_tizen_decrypt_package(%s, %s) started!", pTADCFilepath,
+                                 pDecryptedFile);
 
-       ret = _drm_tapps_decrypt_package(pTADCFilepath, stadFileLen, pDecryptedFile, decryptedFileLen);
+       ret = _drm_tapps_decrypt_package(pTADCFilepath, stadFileLen, pDecryptedFile,
+                                                                        decryptedFileLen);
        DRM_TAPPS_LOG("%s result=%x", __func__, ret);
 
        return ret;
 }
 
-int _drm_tapps_decrypt_package
-(
- const char *pTADCFilepath,   //TDC DRM File Path
- int stadFileLen,
- const char *pDecryptedFile,   //Decrypted File Path
- int decryptedFileLen
-)
+int _drm_tapps_decrypt_package(
+       const char *pTADCFilepath, int stadFileLen,
+       const char *pDecryptedFile, int decryptedFileLen)
 {
        DRM_TAPPS_API_TIME()
 
@@ -313,113 +300,103 @@ int _drm_tapps_decrypt_package
        memset(&fileHeader, 0x00, sizeof(fileHeader));
 
        DRM_TAPPS_LOG("%s starts", __func__);
-       if (pTADCFilepath == NULL || pDecryptedFile == NULL)
-       {
+
+       if (pTADCFilepath == NULL || pDecryptedFile == NULL) {
                DRM_TAPPS_EXCEPTION("%s) Parameters NULL!", __func__);
                return TADC_PARAMETER_ERROR;
        }
 
-       if (((int)strlen(pTADCFilepath) != stadFileLen ) || ((int)strlen(pDecryptedFile) != decryptedFileLen))
-       {
+       if (((int)strlen(pTADCFilepath) != stadFileLen) ||
+                       ((int)strlen(pDecryptedFile) != decryptedFileLen)) {
                DRM_TAPPS_EXCEPTION("%s) Input value and size wasn't equal.", __func__);
                return TADC_PARAMETER_ERROR;
        }
-       DRM_TAPPS_SECURE_LOG("%s) TADC File Path=%s, Decrypted File Path=%s", __func__, pTADCFilepath, pDecryptedFile);
+
+       DRM_TAPPS_SECURE_LOG("%s) TADC File Path=%s, Decrypted File Path=%s", __func__,
+                                                pTADCFilepath, pDecryptedFile);
 
        bRet = DrmTdcGetFileHeader(pTADCFilepath, &fileHeader);
-       if (FALSE == bRet)
-       {
+
+       if (FALSE == bRet) {
                DRM_TAPPS_EXCEPTION("DrmTdcGetFileHeader failed!!");
                ret = TADC_GET_FILEHEADER_ERROR;
                goto TAPPS_END;
        }
-       DRM_TAPPS_LOG("pTADCFilepath=%s, fileHeader.cid=%s, fileHeader.riurl=%s", pTADCFilepath, fileHeader.cid, fileHeader.riurl);
 
-       bRet = DTappsGetCEK(fileHeader.cid,&t_RO);
-       if(FALSE == bRet)
-       {
-               DRM_TAPPS_EXCEPTION("DTappsGetCEK failed!! pTADCFilepath=%s, fileHeader.cid=%s", pTADCFilepath, fileHeader.cid);
+       DRM_TAPPS_LOG("pTADCFilepath=%s, fileHeader.cid=%s, fileHeader.riurl=%s",
+                                 pTADCFilepath, fileHeader.cid, fileHeader.riurl);
+
+       bRet = DTappsGetCEK(fileHeader.cid, &t_RO);
+
+       if (FALSE == bRet) {
+               DRM_TAPPS_EXCEPTION("DTappsGetCEK failed!! pTADCFilepath=%s, fileHeader.cid=%s",
+                                                       pTADCFilepath, fileHeader.cid);
                ret = TADC_GET_CEK_ERROR;
                goto TAPPS_END;
        }
-       DRM_TAPPS_SECURE_LOG("fileHeader.cid=%s, t_RO.t_Content.CEK=%s", fileHeader.cid, t_RO.t_Content.CEK);
+
+       DRM_TAPPS_SECURE_LOG("fileHeader.cid=%s, t_RO.t_Content.CEK=%s", fileHeader.cid,
+                                                t_RO.t_Content.CEK);
 
        bRet = DrmTdcDecryptPackage2(pTADCFilepath, t_RO, pDecryptedFile);
-       if(FALSE == bRet)
-       {
-               DRM_TAPPS_EXCEPTION("DrmTdcDecryptPackage2 failed!!, pTADCFilepath=%s, pDecryptedFile=%s",pTADCFilepath,pDecryptedFile);
+
+       if (FALSE == bRet) {
+               DRM_TAPPS_EXCEPTION(
+                       "DrmTdcDecryptPackage2 failed!!, pTADCFilepath=%s, pDecryptedFile=%s",
+                       pTADCFilepath, pDecryptedFile);
+
                ret = TADC_DECRYPT_PACKAGE_ERROR;
                goto TAPPS_END;
        }
 
 TAPPS_END:
-       if (t_RO.t_Content.CID)
-       {
+
+       if (t_RO.t_Content.CID) {
                DTAPPS_FREE(t_RO.t_Content.CID);
        }
-       if (t_RO.t_Content.CEK)
-       {
+
+       if (t_RO.t_Content.CEK) {
                DTAPPS_FREE(t_RO.t_Content.CEK);
        }
-       if ((t_RO.PerFlag & DUID_RULE) && (t_RO.t_Permission.t_Individual.DUID))
-       {
+
+       if ((t_RO.PerFlag & DUID_RULE) && (t_RO.t_Permission.t_Individual.DUID)) {
                DTAPPS_FREE(t_RO.t_Permission.t_Individual.DUID);
        }
-       if (bRet == FALSE)
-       {
-               DRM_TAPPS_EXCEPTION("%s failed!! pTADCFilepath=%s, pDecryptedFile=%s", __func__, pTADCFilepath, pDecryptedFile);
+
+       if (bRet == FALSE) {
+               DRM_TAPPS_EXCEPTION(
+                       "%s failed!! pTADCFilepath=%s, pDecryptedFile=%s",
+                       __func__, pTADCFilepath, pDecryptedFile);
                return ret;
-       }
-       else
-       {
+       } else {
                DRM_TAPPS_LOG("%s Success!!", __func__);
                return ret;
        }
 }
 
-EXPORT_API int drm_tizen_generate_purchase_request
-(
-       const char *pTADCFilepath,              //TDC DRM File Path
-       char *pReqBuf,                          //Purchase Request Data
-       unsigned int *pReqBufLen,               //IN : pReqBuf Length, OUT : Purchase Request Data String Size ( including null terminator )
-       char *pLicenseUrl,                      //License Acquisition URL Data
-       unsigned int *pLicenseUrlLen    //IN : pLicenseUrl Length, OUT : License Server URL Data String Size (  including null terminator )
-)
+EXPORT_API
+int drm_tizen_generate_purchase_request(
+       const char *pTADCFilepath, char *pReqBuf, unsigned int *pReqBufLen,
+       char *pLicenseUrl, unsigned int *pLicenseUrlLen)
 {
        DRM_TAPPS_LOG("%s started!", __func__);
 
        return _drm_tapps_generate_purchase_request(pTADCFilepath,
-                                                                                               pReqBuf,
-                                                                                               pReqBufLen,
-                                                                                               pLicenseUrl,
-                                                                                               pLicenseUrlLen);
+                       pReqBuf,
+                       pReqBufLen,
+                       pLicenseUrl,
+                       pLicenseUrlLen);
 }
 
-int _drm_tapps_generate_purchase_request
-(
-       const char *pTADCFilepath,              //TDC DRM File Path
-       char *pReqBuf,                          //Purchase Request Data
-       unsigned int *pReqBufLen,               //IN : pReqBuf Length, OUT : Purchase Request Data String Size ( including null terminator )
-       char *pLicenseUrl,                      //License Acquisition URL Data
-       unsigned int *pLicenseUrlLen    //IN : pLicenseUrl Length, OUT : License Server URL Data String Size (  including null terminator )
-)
+int _drm_tapps_generate_purchase_request(
+       const char *pTADCFilepath, char *pReqBuf, unsigned int *pReqBufLen,
+       char *pLicenseUrl, unsigned int *pLicenseUrlLen)
 {
        DRM_TAPPS_API_TIME()
 
-       bool bRet = FALSE;
-
        DRM_TAPPS_LOG("%s starts", __func__);
-       bRet = DrmTdcGeneratePurchaseRequest(pTADCFilepath, pReqBuf, pReqBufLen, pLicenseUrl, pLicenseUrlLen);
-       if (bRet == FALSE)
-       {
-               return 0;
-       }
-    else
-       {
-               return 1;
-       }
-}
+       bool bRet = DrmTdcGeneratePurchaseRequest(
+                                       pTADCFilepath, pReqBuf, pReqBufLen, pLicenseUrl, pLicenseUrlLen);
 
-#ifdef __cplusplus
+       return (bRet == FALSE) ? 0 : 1;
 }
-#endif
index 1447364..9dd6ced 100644 (file)
 #include "drm_intf_tapps.h"
 
 EXPORT_API
-int DrmTdcFileOpen(const char* filePath, int* handle)
+int DrmTdcFileOpen(const char *filePath, int *handle)
 {
        int nRet = TADC_SUCCESS;
        int key = 0;
 
-       DrmFileMgrpDrmFileMgr = NULL;
+       DrmFileMgr *pDrmFileMgr = NULL;
 
-       if (filePath == NULL || strlen(filePath) < 1)
-       {
+       if (filePath == NULL || strlen(filePath) < 1) {
                DRM_TAPPS_EXCEPTION("Parameter error!");
                return TADC_PARAMETER_ERROR;
        }
 
        pDrmFileMgr = DrmFileMgr::GetInstance();
-       if (pDrmFileMgr == NULL)
-       {
+
+       if (pDrmFileMgr == NULL) {
                DRM_TAPPS_EXCEPTION("DrmFileMgr::GetInstance() error!");
                return TADC_GET_FILE_HANDLER_ERROR;
        }
 
        nRet = pDrmFileMgr->OpenFileHandler(filePath, &key);
-       if (nRet != TADC_SUCCESS)
-       {
+
+       if (nRet != TADC_SUCCESS) {
                DRM_TAPPS_EXCEPTION("DrmFileMgr::OpenFileHandler() error!");
                return nRet;
        }
@@ -52,21 +51,21 @@ int DrmTdcFileOpen(const char* filePath, int* handle)
 }
 
 EXPORT_API
-int DrmTdcFileClose(inthandle)
+int DrmTdcFileClose(int *handle)
 {
        int nRet = TADC_SUCCESS;
        int key = *handle;
 
        DrmFileMgr *pDrmFileMgr = DrmFileMgr::GetInstance();
-       if (pDrmFileMgr == NULL)
-       {
+
+       if (pDrmFileMgr == NULL) {
                DRM_TAPPS_EXCEPTION("DrmFileMgr::GetInstance() error!");
                return TADC_GET_FILE_HANDLER_ERROR;
        }
 
        nRet = pDrmFileMgr->CloseFileHandler(key);
-       if (nRet != TADC_SUCCESS)
-       {
+
+       if (nRet != TADC_SUCCESS) {
                DRM_TAPPS_EXCEPTION("DrmFileMgr::OpenFileHandler() error!");
                return nRet;
        }
@@ -75,57 +74,59 @@ int DrmTdcFileClose(int* handle)
 }
 
 EXPORT_API
-int DrmTdcFileRead(int* handle, void* pBuf, long long bufLen, long long* pReadLen)
+int DrmTdcFileRead(int *handle, void *pBuf, long long bufLen,
+                                  long long *pReadLen)
 {
        int nRet = TADC_SUCCESS;
        int key = *handle;
 
-       DrmFileMgrpDrmFileMgr = NULL;
-       DrmFileHandlerpDrmFileHandler = NULL;
+       DrmFileMgr *pDrmFileMgr = NULL;
+       DrmFileHandler *pDrmFileHandler = NULL;
 
        pDrmFileMgr = DrmFileMgr::GetInstance();
-       if (pDrmFileMgr == NULL)
-       {
+
+       if (pDrmFileMgr == NULL) {
                DRM_TAPPS_EXCEPTION("DrmFileMgr::GetInstance() error!");
                return TADC_GET_FILE_HANDLER_ERROR;
        }
 
        nRet = pDrmFileMgr->GetFileHandler(key, &pDrmFileHandler);
-       if (nRet != TADC_SUCCESS)
-       {
+
+       if (nRet != TADC_SUCCESS) {
                DRM_TAPPS_EXCEPTION("DrmFileMgr::GetFileHandler() error!");
                return nRet;
        }
 
        nRet = pDrmFileHandler->DrmRead(pBuf, bufLen, pReadLen);
-       if (nRet != TADC_SUCCESS)
-       {
+
+       if (nRet != TADC_SUCCESS) {
                DRM_TAPPS_EXCEPTION("DrmFileMgr::DrmRead() error!");
                return nRet;
        }
+
        return nRet;
 }
 
 EXPORT_API
-int DrmTdcFileTell(inthandle, long long *position)
+int DrmTdcFileTell(int *handle, long long *position)
 {
        int nRet = TADC_SUCCESS;
        int key = *handle;
        long long offset = 0;
 
-       DrmFileMgrpDrmFileMgr = NULL;
-       DrmFileHandlerpDrmFileHandler = NULL;
+       DrmFileMgr *pDrmFileMgr = NULL;
+       DrmFileHandler *pDrmFileHandler = NULL;
 
        pDrmFileMgr = DrmFileMgr::GetInstance();
-       if (pDrmFileMgr == NULL)
-       {
+
+       if (pDrmFileMgr == NULL) {
                DRM_TAPPS_EXCEPTION("DrmFileMgr::GetInstance() error!");
                return TADC_GET_FILE_HANDLER_ERROR;
        }
 
        nRet = pDrmFileMgr->GetFileHandler(key, &pDrmFileHandler);
-       if (nRet != TADC_SUCCESS)
-       {
+
+       if (nRet != TADC_SUCCESS) {
                DRM_TAPPS_EXCEPTION("DrmFileMgr::GetFileHandler() error!");
                return nRet;
        }
@@ -138,31 +139,31 @@ int DrmTdcFileTell(int* handle, long long *position)
 }
 
 EXPORT_API
-int DrmTdcFileSeek(inthandle, long long offset, int origin)
+int DrmTdcFileSeek(int *handle, long long offset, int origin)
 {
        int nRet = TADC_SUCCESS;
        int key = *handle;
 
-       DrmFileMgrpDrmFileMgr = NULL;
-       DrmFileHandlerpDrmFileHandler = NULL;
+       DrmFileMgr *pDrmFileMgr = NULL;
+       DrmFileHandler *pDrmFileHandler = NULL;
 
        pDrmFileMgr = DrmFileMgr::GetInstance();
-       if (pDrmFileMgr == NULL)
-       {
+
+       if (pDrmFileMgr == NULL) {
                DRM_TAPPS_EXCEPTION("DrmFileMgr::GetInstance() error!");
                return TADC_GET_FILE_HANDLER_ERROR;
        }
 
        nRet = pDrmFileMgr->GetFileHandler(key, &pDrmFileHandler);
-       if (nRet != TADC_SUCCESS)
-       {
+
+       if (nRet != TADC_SUCCESS) {
                DRM_TAPPS_EXCEPTION("DrmFileMgr::GetFileHandler() error!");
                return nRet;
        }
 
        nRet = pDrmFileHandler->DrmSeek(offset, origin);
-       if (nRet != TADC_SUCCESS)
-       {
+
+       if (nRet != TADC_SUCCESS) {
                DRM_TAPPS_EXCEPTION("DrmFileHandler::DrmSeek() error!");
                return nRet;
        }
index 0776dff..63e2e2d 100644 (file)
@@ -80,7 +80,7 @@ DrmFileHandler::~DrmFileHandler(void)
                fclose(m_pFP);
 }
 
-int DrmFileHandler::Construct(const charszDrmFilePath)
+int DrmFileHandler::Construct(const char *szDrmFilePath)
 {
        T_FILE_HEADER t_FileHeader;
        T_DRM_HEADER t_DRMHeader;
@@ -99,8 +99,10 @@ int DrmFileHandler::Construct(const char* szDrmFilePath)
        }
 
        int ret = TADC_GetDRMHeaderFromFile(szDrmFilePath, &t_FileHeader, &t_DRMHeader);
+
        if (ret < 0) {
-               DRM_TAPPS_EXCEPTION("Error : TADC_GetDRMHeaderFromFile() - %s TADC Error Code - %d", szDrmFilePath, ret);
+               DRM_TAPPS_EXCEPTION("Error : TADC_GetDRMHeaderFromFile() - %s TADC Error Code - %d",
+                                                       szDrmFilePath, ret);
                return TADC_NOTTADCFILE_ERROR;
        }
 
@@ -108,7 +110,8 @@ int DrmFileHandler::Construct(const char* szDrmFilePath)
        auto drmHeaderPtr = createDrmHeaderPtr(&t_DRMHeader);
 
        // 2. Validate license and get the CEK for the DRM file
-       bool bRet = DTappsGetCEK((char*)t_DRMHeader.CID, &t_RO);
+       bool bRet = DTappsGetCEK((char *)t_DRMHeader.CID, &t_RO);
+
        if (!bRet) {
                DRM_TAPPS_EXCEPTION("Error : DTappsGetCEK() - %s", t_DRMHeader.CID);
                return TADC_GET_CEK_ERROR;
@@ -121,9 +124,9 @@ int DrmFileHandler::Construct(const char* szDrmFilePath)
        memset(m_pFilePath, 0x00, strlen(szDrmFilePath) + 1);
        memcpy(m_pFilePath, szDrmFilePath, strlen(szDrmFilePath));
 
-       m_pCID = new unsigned char[strlen((char*)t_DRMHeader.CID) + 1];
-       memset(m_pCID, 0x00, strlen((char*)t_DRMHeader.CID) + 1);
-       memcpy(m_pCID, t_DRMHeader.CID, strlen((char*)t_DRMHeader.CID));
+       m_pCID = new unsigned char[strlen((char *)t_DRMHeader.CID) + 1];
+       memset(m_pCID, 0x00, strlen((char *)t_DRMHeader.CID) + 1);
+       memcpy(m_pCID, t_DRMHeader.CID, strlen((char *)t_DRMHeader.CID));
 
        m_pCEK = new unsigned char[CEK_SIZE + 1];
        memset(m_pCEK, 0x00, CEK_SIZE + 1);
@@ -135,6 +138,7 @@ int DrmFileHandler::Construct(const char* szDrmFilePath)
 
        // 4. Open the DRM file and set the filepointer to member variable
        m_pFP = fopen(szDrmFilePath, "rb");
+
        if (m_pFP == nullptr) {
                DRM_TAPPS_EXCEPTION("Error : fopen() - %s", szDrmFilePath);
                return TADC_FILE_OPEN_ERROR;
@@ -146,8 +150,10 @@ int DrmFileHandler::Construct(const char* szDrmFilePath)
        m_OriginEndOffset = ftell(m_pFP);
 
        m_plaintextSize = m_OriginEndOffset - m_PlaintextStartOffset;
+
        if (m_plaintextSize != t_DRMHeader.PlaintextSize) {
-               DRM_TAPPS_EXCEPTION("Error : plaintext file size incorrect. real = %ld, header = %ld", m_plaintextSize, t_DRMHeader.PlaintextSize);
+               DRM_TAPPS_EXCEPTION("Error : plaintext file size incorrect. real = %ld, header = %ld",
+                                                       m_plaintextSize, t_DRMHeader.PlaintextSize);
                return TADC_FILE_OPEN_ERROR;
        }
 
@@ -194,31 +200,28 @@ int DrmFileHandler::DrmSeek(long long offset, int origin)
 
        m_decReadlen = 0;
 
-       if (origin == SEEK_SET)
-       {
+       if (origin == SEEK_SET) {
                DrmOffset = offset;
-               if (DrmOffset < 0 || DrmOffset > m_plaintextSize)
-               {
-                       DRM_TAPPS_EXCEPTION("Parameter Wrong! Offset can not be minus. offset=%lld, m_OriginCurOffset=%lld, m_plaintextSize=%lld", offset, m_OriginCurOffset, m_plaintextSize);
+
+               if (DrmOffset < 0 || DrmOffset > m_plaintextSize) {
+                       DRM_TAPPS_EXCEPTION("Parameter Wrong! Offset can not be minus. offset=%lld, m_OriginCurOffset=%lld, m_plaintextSize=%lld",
+                                                               offset, m_OriginCurOffset, m_plaintextSize);
                        return TADC_PARAMETER_ERROR;
                }
 
                OriginOffset = m_PlaintextStartOffset + DrmOffset;
-               if (fseek(m_pFP, OriginOffset, SEEK_SET) != 0)
-               {
+
+               if (fseek(m_pFP, OriginOffset, SEEK_SET) != 0) {
                        DRM_TAPPS_EXCEPTION("fseek failed.");
                        return TADC_FILE_READ_ERROR;
                }
 
                m_OriginCurOffset = OriginOffset;
                m_DrmCurOffset = DrmOffset;
-       }
-       else if (origin == SEEK_CUR)
-       {
+       } else if (origin == SEEK_CUR) {
                temp = m_OriginCurOffset;
 
-               if (temp == -1)
-               {
+               if (temp == -1) {
                        DRM_TAPPS_EXCEPTION("GetOriginCurOffset() failed.");
                        return TADC_FILE_READ_ERROR;
                }
@@ -226,42 +229,38 @@ int DrmFileHandler::DrmSeek(long long offset, int origin)
                OriginOffset = temp + offset;
                DrmOffset = OriginOffset - m_PlaintextStartOffset;
 
-               if (DrmOffset < 0 || DrmOffset > m_plaintextSize)
-               {
-                       DRM_TAPPS_EXCEPTION("Parameter Wrong! Offset can not be minus. offset=%lld, m_OriginCurOffset=%lld, OriginOffset=%lld, DrmOffset=%lld, m_plaintextSize=%lld", offset, temp, OriginOffset, DrmOffset, m_plaintextSize);
+               if (DrmOffset < 0 || DrmOffset > m_plaintextSize) {
+                       DRM_TAPPS_EXCEPTION("Parameter Wrong! Offset can not be minus. offset=%lld, m_OriginCurOffset=%lld, OriginOffset=%lld, DrmOffset=%lld, m_plaintextSize=%lld",
+                                                               offset, temp, OriginOffset, DrmOffset, m_plaintextSize);
                        return TADC_PARAMETER_ERROR;
                }
 
-               if (fseek(m_pFP, OriginOffset, SEEK_SET) != 0)
-               {
+               if (fseek(m_pFP, OriginOffset, SEEK_SET) != 0) {
                        DRM_TAPPS_EXCEPTION("fseek failed.");
                        return TADC_FILE_READ_ERROR;
                }
 
                m_OriginCurOffset = OriginOffset;
                m_DrmCurOffset = DrmOffset;
-       }
-       else if (origin == SEEK_END)
-       {
+       } else if (origin == SEEK_END) {
                OriginOffset = m_OriginEndOffset + offset;
-               if (fseek(m_pFP, OriginOffset, SEEK_SET) != 0)
-               {
+
+               if (fseek(m_pFP, OriginOffset, SEEK_SET) != 0) {
                        DRM_TAPPS_EXCEPTION("fseek failed.");
                        return TADC_FILE_READ_ERROR;
                }
 
                DrmOffset = OriginOffset - m_PlaintextStartOffset;
-               if (DrmOffset < 0 || DrmOffset > m_plaintextSize)
-               {
-                       DRM_TAPPS_EXCEPTION("Parameter Wrong! Offset can not be minus. offset=%lld, m_OriginCurOffset=%lld, OriginOffset=%lld, DrmOffset=%lld, m_plaintextSize=%lld", offset, temp, OriginOffset, DrmOffset, m_plaintextSize);
+
+               if (DrmOffset < 0 || DrmOffset > m_plaintextSize) {
+                       DRM_TAPPS_EXCEPTION("Parameter Wrong! Offset can not be minus. offset=%lld, m_OriginCurOffset=%lld, OriginOffset=%lld, DrmOffset=%lld, m_plaintextSize=%lld",
+                                                               offset, temp, OriginOffset, DrmOffset, m_plaintextSize);
                        return TADC_PARAMETER_ERROR;
                }
 
                m_OriginCurOffset = OriginOffset;
                m_DrmCurOffset = DrmOffset;
-       }
-       else
-       {
+       } else {
                DRM_TAPPS_EXCEPTION("Parameter Wrong!");
                return TADC_PARAMETER_ERROR;
        }
@@ -272,13 +271,13 @@ int DrmFileHandler::DrmSeek(long long offset, int origin)
 long long DrmFileHandler::DrmTell(void)
 {
        return m_DrmCurOffset;
-//     return GetDrmCurOffset();
+       //  return GetDrmCurOffset();
 }
 
 int DrmFileHandler::DrmDecryptBlocks(void)
 {
        int ret = TADC_SUCCESS;
-       const char* packagePath = (const char*)m_pFilePath;
+       const char *packagePath = (const char *)m_pFilePath;
        T_FILE_HEADER t_FileHeader;
        T_DRM_HEADER t_DRMHeader;
        T_DEVICE_INFO t_DeviceInfo;
@@ -292,29 +291,36 @@ int DrmFileHandler::DrmDecryptBlocks(void)
        memset(&t_RO, 0x00, sizeof(T_RO));
 
        bool bRet = DrmTdcGetFileHeader(packagePath, &fileHeader);
+
        if (bRet == FALSE) {
                DRM_TAPPS_EXCEPTION("DrmDecryptBlocks Error : DrmTdcGetFileHeader()");
                return TADC_GET_FILEHEADER_ERROR;
        }
 
        bRet = DTappsGetCEK(fileHeader.cid, &t_RO);
+
        if (bRet == FALSE) {
-               DRM_TAPPS_SECURE_EXCEPTION("DrmDecryptBlocks Error : DTappsGetCEK() packagePath=%s, fileHeader.cid=%s", packagePath, fileHeader.cid);
+               DRM_TAPPS_SECURE_EXCEPTION("DrmDecryptBlocks Error : DTappsGetCEK() packagePath=%s, fileHeader.cid=%s",
+                                                                  packagePath, fileHeader.cid);
                return TADC_GET_CEK_ERROR;
        }
 
        auto roPtr = createRoPtr(&t_RO);
 
-       DRM_TAPPS_SECURE_LOG("fileHeader.cid=%s, t_RO.t_Content.CEK=%s", fileHeader.cid, t_RO.t_Content.CEK);
+       DRM_TAPPS_SECURE_LOG("fileHeader.cid=%s, t_RO.t_Content.CEK=%s", fileHeader.cid,
+                                                t_RO.t_Content.CEK);
 
-       if ((ret = TADC_SetDeviceInfo(&t_DeviceInfo) ) == TADC_GETDUID_ERROR) {
-               DRM_TAPPS_EXCEPTION("DrmDecryptBlocks Error : TADC_SetDeviceInfo(), TADC Error Code - %d", ret);
+       if ((ret = TADC_SetDeviceInfo(&t_DeviceInfo)) == TADC_GETDUID_ERROR) {
+               DRM_TAPPS_EXCEPTION("DrmDecryptBlocks Error : TADC_SetDeviceInfo(), TADC Error Code - %d",
+                                                       ret);
                return TADC_FILE_READ_ERROR;
        }
 
        ret = TADC_GetDRMHeaderFromFile(packagePath, &t_FileHeader, &t_DRMHeader);
+
        if (ret < 0) {
-               DRM_TAPPS_EXCEPTION("DrmDecryptBlocks Error : TADC_GetDRMHeaderFromFile() - %s,  TADC Error Code - %d", packagePath, ret);
+               DRM_TAPPS_EXCEPTION("DrmDecryptBlocks Error : TADC_GetDRMHeaderFromFile() - %s,  TADC Error Code - %d",
+                                                       packagePath, ret);
                return TADC_NOTTADCFILE_ERROR;
        }
 
@@ -323,7 +329,8 @@ int DrmFileHandler::DrmDecryptBlocks(void)
 
        //Get CEK
        if ((ret = TADC_GetCEK(&t_DeviceInfo, &t_RO, &t_DRMHeader)) < 0) {
-               DRM_TAPPS_EXCEPTION("DrmDecryptBlocks Error: TADC_GetCEK, TADC Error Code - %d", ret);
+               DRM_TAPPS_EXCEPTION("DrmDecryptBlocks Error: TADC_GetCEK, TADC Error Code - %d",
+                                                       ret);
                return TADC_GET_CEK_ERROR;
        }
 
@@ -336,10 +343,13 @@ int DrmFileHandler::DrmDecryptBlocks(void)
        }
 
        auto EncBlockCnt = m_blockCnt;
+
        if (m_encryptionRange != -1)
                EncBlockCnt = m_encryptionRange;
 
-       m_pDecBuf = new (std::nothrow) unsigned char[(EncBlockCnt * TDC_DECRYPT_BLOCKSIZE) + 1];
+       m_pDecBuf = new(std::nothrow) unsigned char[(EncBlockCnt *
+                       TDC_DECRYPT_BLOCKSIZE) + 1];
+
        if (m_pDecBuf == nullptr) {
                DRM_TAPPS_EXCEPTION("DrmRead Error : m_pDecBuf Memory allocation failed");
                return TADC_MEMAlOC_ERROR;
@@ -348,30 +358,36 @@ int DrmFileHandler::DrmDecryptBlocks(void)
        auto ReadLen = fread(m_pDecBuf, 1, EncBlockCnt * TDC_DECRYPT_BLOCKSIZE, m_pFP);
 
        long long l = 0;
-       for (size_t k = 0 ; k < ReadLen ; k += 512) {
+
+       for (size_t k = 0; k < ReadLen; k += 512) {
                if (l < EncBlockCnt) {
                        auto DecLen = ReadLen - k;
-                       DecLen = ( DecLen > 512) ? 512 : DecLen;
+                       DecLen = (DecLen > 512) ? 512 : DecLen;
 
-                       if ((ret = TADC_DecryptBlock((char*)m_pDecBuf + k, DecLen, &t_DRMHeader)) < 0) {
-                               DRM_TAPPS_EXCEPTION("DrmDecryptBlocks Error : TADC_DecryptBlock, TADC Error Code - %d", ret);
+                       if ((ret = TADC_DecryptBlock((char *)m_pDecBuf + k, DecLen,
+                                                                                &t_DRMHeader)) < 0) {
+                               DRM_TAPPS_EXCEPTION("DrmDecryptBlocks Error : TADC_DecryptBlock, TADC Error Code - %d",
+                                                                       ret);
                                return TADC_DECRYPT_PACKAGE_ERROR;
                        }
                }
+
                l += 1;
        }
 
        return ret;
 }
 
-int DrmFileHandler::DrmRead(void* pBuf, long long buflen, long long* pReadLen)
+int DrmFileHandler::DrmRead(void *pBuf, long long buflen, long long *pReadLen)
 {
        auto EncBlockCnt = m_blockCnt;
+
        if (m_encryptionRange != -1)
                EncBlockCnt = m_encryptionRange;
 
        if (m_DrmCurOffset > EncBlockCnt * TDC_DECRYPT_BLOCKSIZE) {
-               auto pNewReadBuf = BufPtr(new (std::nothrow) TADC_U8[buflen + 1]);
+               auto pNewReadBuf = BufPtr(new(std::nothrow) TADC_U8[buflen + 1]);
+
                if (!pNewReadBuf) {
                        DRM_TAPPS_EXCEPTION("DrmRead Error : pNewReadBuf Malloc Fail");
                        return TADC_MEMAlOC_ERROR;
@@ -384,14 +400,16 @@ int DrmFileHandler::DrmRead(void* pBuf, long long buflen, long long* pReadLen)
                *pReadLen = ReadLen;
        } else {
                if (buflen > EncBlockCnt * TDC_DECRYPT_BLOCKSIZE - m_DrmCurOffset) {
-                       auto pTempReadBuf = createBufPtr(new (std::nothrow) TADC_U8[buflen + 1]);
+                       auto pTempReadBuf = createBufPtr(new(std::nothrow) TADC_U8[buflen + 1]);
+
                        if (!pTempReadBuf) {
                                DRM_TAPPS_EXCEPTION("DrmRead Error : pTempReadBuf Malloc Fail");
                                return TADC_MEMAlOC_ERROR;
                        }
 
                        m_decReadlen = (EncBlockCnt * TDC_DECRYPT_BLOCKSIZE) - m_DrmCurOffset;
-                       TADC_IF_MemCpy(pTempReadBuf.get(), reinterpret_cast<char *>(m_pDecBuf) + m_DrmCurOffset, m_decReadlen);
+                       TADC_IF_MemCpy(pTempReadBuf.get(),
+                                                  reinterpret_cast<char *>(m_pDecBuf) + m_DrmCurOffset, m_decReadlen);
 
                        m_extraReadlen = buflen - m_decReadlen;
 
@@ -400,7 +418,8 @@ int DrmFileHandler::DrmRead(void* pBuf, long long buflen, long long* pReadLen)
                                return TADC_FILE_READ_ERROR;
                        }
 
-                       auto pNewReadBuf = BufPtr(new (std::nothrow) TADC_U8[m_extraReadlen + 1]);
+                       auto pNewReadBuf = BufPtr(new(std::nothrow) TADC_U8[m_extraReadlen + 1]);
+
                        if (!pNewReadBuf) {
                                DRM_TAPPS_EXCEPTION("DrmRead Error : pNewReadBuf Malloc Fail");
                                return TADC_MEMAlOC_ERROR;
@@ -408,13 +427,17 @@ int DrmFileHandler::DrmRead(void* pBuf, long long buflen, long long* pReadLen)
 
                        auto ReadLen = fread(pNewReadBuf.get(), 1, m_extraReadlen, m_pFP);
 
-                       TADC_IF_MemCpy((char*)pTempReadBuf.get() + m_decReadlen, pNewReadBuf.get(), ReadLen);
+                       TADC_IF_MemCpy((char *)pTempReadBuf.get() + m_decReadlen, pNewReadBuf.get(),
+                                                  ReadLen);
                        TADC_IF_MemCpy(pBuf, pTempReadBuf.get(), buflen);
                } else {
                        if (m_DrmCurOffset == 0)
-                               TADC_IF_MemCpy(pBuf, reinterpret_cast<char *>(m_pDecBuf) + m_decReadlen, buflen);
+                               TADC_IF_MemCpy(pBuf, reinterpret_cast<char *>(m_pDecBuf) + m_decReadlen,
+                                                          buflen);
                        else
-                               TADC_IF_MemCpy(pBuf, reinterpret_cast<char *>(m_pDecBuf) + m_DrmCurOffset + m_decReadlen, buflen);
+                               TADC_IF_MemCpy(pBuf, reinterpret_cast<char *>(m_pDecBuf) + m_DrmCurOffset +
+                                                          m_decReadlen, buflen);
+
                        m_decReadlen = m_decReadlen + buflen;
                }
 
index f50e6b0..7a5ae5e 100644 (file)
@@ -41,7 +41,8 @@ DrmFileMgr *DrmFileMgr::GetInstance(void)
        if (m_pInstance != NULL)
                return m_pInstance;
 
-       m_pInstance = new (std::nothrow) DrmFileMgr();
+       m_pInstance = new(std::nothrow) DrmFileMgr();
+
        if (m_pInstance == NULL) {
                DRM_TAPPS_EXCEPTION("Creating DrmFileMgr m_pInstance failed.");
                return NULL;
@@ -76,7 +77,8 @@ int DrmFileMgr::OpenFileHandler(const char *filePath, int *key)
                return TADC_PARAMETER_ERROR;
        }
 
-       auto pDrmFileHandler = new (std::nothrow) DrmFileHandler();
+       auto pDrmFileHandler = new(std::nothrow) DrmFileHandler();
+
        if (pDrmFileHandler == NULL) {
                DRM_TAPPS_EXCEPTION("DrmFileHandler allocation failed.");
                return TADC_MEMAlOC_ERROR;
@@ -110,6 +112,7 @@ int DrmFileMgr::CloseFileHandler(int key)
        }
 
        auto &pHandler = m_HandlerMap[key];
+
        if (pHandler != NULL)
                delete pHandler;
 
index cf2d49d..f1e7bee 100644 (file)
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
- */
-
-/**
+ *
  * @file    DrmTdcSvc.cpp
- * @brief   This file is for TADC Testcase temporarily.
+ * @brief   TADC Testcase temporarily.
  * @author  Sangil Yoon (si83.yoon@samsung.com)
  * @version 1.0
  *
 #define TDC_DECRYPT_IOLEN 1024 * 1024 // 1024 Kbyte
 
 //DH Session Info Structure
-typedef struct
-{
+typedef struct {
        BYTE hashReqID[DHINFO_MAX][DHINFO_REQIDLEN]; //LicenseRequest Request ID Hash 20byte
        T_ROACQ_INFO t_ROAcqInfo[DHINFO_MAX];        //DH Info
-
 } DrmTdcDHInfo;
 
 
@@ -48,10 +44,8 @@ static BOOL g_DrmTdcDHFlag = FALSE;
 
 static char g_sTimeStamp[21]; //2011.03.08, GMT ("CCCC-YY-MMThh:mm:ssZ")
 
-bool DrmTdcGetFileHeader(
-       IN const char *pTADCFilepath, //TDC DRM File Path
-       IN OUT DrmTdcFileHeader *pFileHeader //File Header Info ( CID, License URL )
-)
+bool DrmTdcGetFileHeader(const char *pTADCFilepath,
+                                                DrmTdcFileHeader *pFileHeader)
 {
        T_FILE_HEADER t_FileHeader;
        T_DRM_HEADER t_DRMHeader;
@@ -69,21 +63,24 @@ bool DrmTdcGetFileHeader(
 
        //Get DRM Header Info
        if (TADC_GetDRMHeaderFromFile(pTADCFilepath, &t_FileHeader, &t_DRMHeader) < 0) {
-               DRM_TAPPS_EXCEPTION("DrmTdcGetFileHeader Error : TADC_GetDRMHeaderFromFile (%s)", pTADCFilepath);
+               DRM_TAPPS_EXCEPTION("TADC_GetDRMHeaderFromFile (%s)", pTADCFilepath);
                TADC_MEMFree_DRMHeader(&t_DRMHeader);
                return FALSE;
        }
 
        //Copy to pFileHeader ( CID, RIURL )
-    if( (sizeof(pFileHeader->cid) < strlen((char *)t_DRMHeader.CID) + 1 ) ||
-        (sizeof(pFileHeader->riurl) < strlen((char *)t_DRMHeader.RIURL) + 1 )) {
-        DRM_TAPPS_EXCEPTION("DrmTdcGetFileHeader Error : TADC_GetDRMHeaderFromFile. Invalid cid or riurl(%s)", pTADCFilepath);
-           TADC_MEMFree_FileHeader(&t_FileHeader);
-        TADC_MEMFree_DRMHeader(&t_DRMHeader);
-        return FALSE;
-    }
+       if ((sizeof(pFileHeader->cid) < strlen((char *)t_DRMHeader.CID) + 1) ||
+                       (sizeof(pFileHeader->riurl) < strlen((char *)t_DRMHeader.RIURL) + 1)) {
+               DRM_TAPPS_EXCEPTION("TADC_GetDRMHeaderFromFile. Invalid cid or riurl(%s)",
+                                                       pTADCFilepath);
+               TADC_MEMFree_FileHeader(&t_FileHeader);
+               TADC_MEMFree_DRMHeader(&t_DRMHeader);
+               return FALSE;
+       }
+
        memcpy(pFileHeader->cid, t_DRMHeader.CID, strlen((char *)t_DRMHeader.CID) + 1);
-       memcpy(pFileHeader->riurl, t_DRMHeader.RIURL, strlen((char *)t_DRMHeader.RIURL) + 1);
+       memcpy(pFileHeader->riurl, t_DRMHeader.RIURL,
+                  strlen((char *)t_DRMHeader.RIURL) + 1);
 
        //Free
        TADC_MEMFree_FileHeader(&t_FileHeader);
@@ -92,11 +89,8 @@ bool DrmTdcGetFileHeader(
        return TRUE;
 }
 
-bool DrmTdcDecryptPackage(
-       IN const char *pTADCFilepath,
-       IN const char *pLicenseBuf,
-       IN unsigned int licenseBufLen,
-       IN const char *pDecryptedFile)
+bool DrmTdcDecryptPackage(const char *pTADCFilepath, const char *pLicenseBuf,
+                                                 unsigned int licenseBufLen, const char *pDecryptedFile)
 {
        T_FILE_HEADER t_FileHeader;
        T_DRM_HEADER t_DRMHeader;
@@ -114,9 +108,9 @@ bool DrmTdcDecryptPackage(
 
        //null check
        if (!pTADCFilepath
-               || !pLicenseBuf
-               || !pDecryptedFile
-               || licenseBufLen < 1) {
+                       || !pLicenseBuf
+                       || !pDecryptedFile
+                       || licenseBufLen < 1) {
                DRM_TAPPS_EXCEPTION("DrmTdcDecryptPackage Error : Parameter Null");
                return FALSE;
        }
@@ -127,7 +121,8 @@ bool DrmTdcDecryptPackage(
                return FALSE;
        }
 
-       auto pReadBuf = (TADC_U8*)TADC_IF_Malloc(TDC_DECRYPT_IOLEN);
+       auto pReadBuf = (TADC_U8 *)TADC_IF_Malloc(TDC_DECRYPT_IOLEN);
+
        if (!pReadBuf) {
                DRM_TAPPS_EXCEPTION("DrmTdcDecryptPackage Error : pReadBuf Malloc Fail");
                return FALSE;
@@ -143,7 +138,7 @@ bool DrmTdcDecryptPackage(
        }
 
        // RO XML Parser
-       if (TADC_GetResponseROInfo((unsigned char*)pLicenseBuf, &t_RO) < 0) {
+       if (TADC_GetResponseROInfo((unsigned char *)pLicenseBuf, &t_RO) < 0) {
                DRM_TAPPS_EXCEPTION("DrmTdcDecryptPackage Error : TADC_GetResponseROInfo");
                TADC_MEMFree_FileHeader(&t_FileHeader);
                TADC_MEMFree_DRMHeader(&t_DRMHeader);
@@ -166,7 +161,8 @@ bool DrmTdcDecryptPackage(
        //Decrypt File
        //File Open ( DRM File )
        if ((hFile1 = fopen(pTADCFilepath, "rb")) == INVALID_HOBJ) {
-               DRM_TAPPS_EXCEPTION("DrmTdcDecryptPackage Error : DRM FmOpenFile (%s)", pTADCFilepath);
+               DRM_TAPPS_EXCEPTION("DrmTdcDecryptPackage Error : DRM FmOpenFile (%s)",
+                                                       pTADCFilepath);
                TADC_MEMFree_FileHeader(&t_FileHeader);
                TADC_MEMFree_DRMHeader(&t_DRMHeader);
                TADC_MEMFree_RO(&t_RO);
@@ -176,7 +172,7 @@ bool DrmTdcDecryptPackage(
 
        //File Create ( Decrypted File )
        if ((hFile2 = fopen(pDecryptedFile, "w+b")) == INVALID_HOBJ) {
-               DRM_TAPPS_EXCEPTION("DrmTdcDecryptPackage Error : Decrypted File FmOpenFile (%s)", pDecryptedFile);
+               DRM_TAPPS_EXCEPTION("Decrypted File FmOpenFile (%s)", pDecryptedFile);
                fclose(hFile1);
                TADC_MEMFree_FileHeader(&t_FileHeader);
                TADC_MEMFree_DRMHeader(&t_DRMHeader);
@@ -195,10 +191,12 @@ bool DrmTdcDecryptPackage(
        auto BlockCnt = (size2 / 512) + ((size2 % 512) ? 1 : 0);
 
        auto EncBlockCnt = BlockCnt;
+
        if (t_DRMHeader.EncryptionRange != -1)
                EncBlockCnt = t_DRMHeader.EncryptionRange;
 
        long int i = 0;
+
        while (i < BlockCnt) {
                size_t ReadLen = fread(pReadBuf, 1, TDC_DECRYPT_IOLEN, hFile1);
 
@@ -211,7 +209,7 @@ bool DrmTdcDecryptPackage(
                                DecLen = (DecLen > 512) ? 512 : DecLen;
 
                                if (TADC_DecryptBlock((char *)pReadBuf + k, DecLen, &t_DRMHeader) < 0) {
-                                       DRM_TAPPS_EXCEPTION("DrmTdcDecryptPackage Error : TADC_DecryptBlock");
+                                       DRM_TAPPS_EXCEPTION("TADC_DecryptBlock");
                                        fclose(hFile1);
                                        fclose(hFile2);
                                        TADC_MEMFree_FileHeader(&t_FileHeader);
@@ -221,8 +219,10 @@ bool DrmTdcDecryptPackage(
                                        return FALSE;
                                }
                        }
+
                        i += 1;
                }
+
                fwrite(pReadBuf, 1, ReadLen, hFile2);
        }
 
@@ -237,10 +237,8 @@ bool DrmTdcDecryptPackage(
        return TRUE;
 }
 
-bool DrmTdcDecryptPackage2(
-       IN const char *pTADCFilepath,
-       IN T_RO t_RO,
-       IN const char *pDecryptedFile)
+bool DrmTdcDecryptPackage2(const char *pTADCFilepath, T_RO t_RO,
+                                                  const char *pDecryptedFile)
 {
        T_FILE_HEADER t_FileHeader;
        T_DRM_HEADER t_DRMHeader;
@@ -265,15 +263,16 @@ bool DrmTdcDecryptPackage2(
                return FALSE;
        }
 
-       auto pReadBuf = (TADC_U8*)TADC_IF_Malloc(TDC_DECRYPT_IOLEN);
+       auto pReadBuf = (TADC_U8 *)TADC_IF_Malloc(TDC_DECRYPT_IOLEN);
+
        if (!pReadBuf) {
-               DRM_TAPPS_EXCEPTION("DrmTdcDecryptPackage2 Error : pReadBuf Malloc Fail");
+               DRM_TAPPS_EXCEPTION("pReadBuf Malloc Fail");
                return FALSE;
        }
 
        //Get DRM Header Info
        if (TADC_GetDRMHeaderFromFile(pTADCFilepath, &t_FileHeader, &t_DRMHeader) < 0) {
-               DRM_TAPPS_EXCEPTION("DrmTdcDecryptPackage2 Error : TADC_GetDRMHeaderFromFile");
+               DRM_TAPPS_EXCEPTION("TADC_GetDRMHeaderFromFile");
                TADC_MEMFree_FileHeader(&t_FileHeader);
                TADC_MEMFree_DRMHeader(&t_DRMHeader);
                TADC_IF_Free(pReadBuf);
@@ -282,7 +281,7 @@ bool DrmTdcDecryptPackage2(
 
        //Get CEK
        if (TADC_GetCEK(&t_DeviceInfo, &t_RO, &t_DRMHeader) < 0) {
-               DRM_TAPPS_EXCEPTION("DrmTdcDecryptPackage2 Error : TADC_GetCEK");
+               DRM_TAPPS_EXCEPTION("TADC_GetCEK");
                TADC_MEMFree_FileHeader(&t_FileHeader);
                TADC_MEMFree_DRMHeader(&t_DRMHeader);
                TADC_IF_Free(pReadBuf);
@@ -292,7 +291,7 @@ bool DrmTdcDecryptPackage2(
        //Decrypt File
        //File Open ( DRM File )
        if ((hFile1 = fopen(pTADCFilepath, "rb")) == INVALID_HOBJ) {
-               DRM_TAPPS_EXCEPTION("DrmTdcDecryptPackage2 Error : DRM FmOpenFile (%s)", pTADCFilepath);
+               DRM_TAPPS_EXCEPTION("DRM FmOpenFile (%s)", pTADCFilepath);
                TADC_MEMFree_FileHeader(&t_FileHeader);
                TADC_MEMFree_DRMHeader(&t_DRMHeader);
                TADC_IF_Free(pReadBuf);
@@ -301,7 +300,7 @@ bool DrmTdcDecryptPackage2(
 
        //File Create ( Decrypted File )
        if ((hFile2 = fopen(pDecryptedFile, "w+b")) == INVALID_HOBJ) {
-               DRM_TAPPS_EXCEPTION("DrmTdcDecryptPackage2 Error : Decrypted File FmOpenFile (%s)", pDecryptedFile);
+               DRM_TAPPS_EXCEPTION("Decrypted File FmOpenFile (%s)", pDecryptedFile);
                fclose(hFile1);
                TADC_MEMFree_FileHeader(&t_FileHeader);
                TADC_MEMFree_DRMHeader(&t_DRMHeader);
@@ -313,29 +312,31 @@ bool DrmTdcDecryptPackage2(
        auto size1 = ftell(hFile1);
 
        auto offset = t_FileHeader.Offset1 + 35 + t_DRMHeader.XmlSize;
-       fseek(hFile1, offset, SEEK_SET );
+       fseek(hFile1, offset, SEEK_SET);
 
        auto size2 = size1 - offset; //plain file size
        auto BlockCnt = (size2 / 512) + ((size2 % 512) ? 1 : 0);
 
        auto EncBlockCnt = BlockCnt;
+
        if (t_DRMHeader.EncryptionRange != -1)
                EncBlockCnt = t_DRMHeader.EncryptionRange;
 
        long int i = 0;
+
        while (i < BlockCnt) {
                auto ReadLen = fread(pReadBuf, 1, TDC_DECRYPT_IOLEN, hFile1);
 
                if (ReadLen < 1)
                        break;
 
-               for (size_t k = 0 ; k < ReadLen ; k += 512) {
+               for (size_t k = 0; k < ReadLen; k += 512) {
                        if (i < EncBlockCnt) {
                                auto DecLen = ReadLen - k;
-                               DecLen = ( DecLen > 512) ? 512 : DecLen;
+                               DecLen = (DecLen > 512) ? 512 : DecLen;
 
-                               if (TADC_DecryptBlock((char*)pReadBuf + k, DecLen, &t_DRMHeader) < 0) {
-                                       DRM_TAPPS_EXCEPTION("DrmTdcDecryptPackage2 Error : TADC_DecryptBlock");
+                               if (TADC_DecryptBlock((char *)pReadBuf + k, DecLen, &t_DRMHeader) < 0) {
+                                       DRM_TAPPS_EXCEPTION("TADC_DecryptBlock");
                                        fclose(hFile1);
                                        fclose(hFile2);
                                        TADC_MEMFree_FileHeader(&t_FileHeader);
@@ -344,8 +345,10 @@ bool DrmTdcDecryptPackage2(
                                        return FALSE;
                                }
                        }
+
                        i += 1;
                }
+
                fwrite(pReadBuf, 1, ReadLen, hFile2);
        }
 
@@ -359,26 +362,22 @@ bool DrmTdcDecryptPackage2(
        return TRUE;
 }
 
-bool DrmTdcGeneratePurchaseRequest(
-       IN const char *pTADCFilepath,        //TDC DRM File Path
-       IN OUT char *pReqBuf,                //Purchase Request Data
-       IN OUT unsigned int *pReqBufLen,     //IN : pReqBuf Length, OUT : Purchase Request Data String Size ( including null terminator )
-       IN OUT char *pLicenseUrl,            //License Acquisition URL Data
-       IN OUT unsigned int *pLicenseUrlLen  //IN : pLicenseUrl Length, OUT : License Server URL Data String Size (  including null terminator )
-)
+bool DrmTdcGeneratePurchaseRequest(const char *pTADCFilepath, char *pReqBuf,
+                                                                  unsigned int *pReqBufLen, char *pLicenseUrl,
+                                                                  unsigned int *pLicenseUrlLen)
 {
        T_FILE_HEADER t_FileHeader;
        T_DRM_HEADER t_DRMHeader;
        T_DEVICE_INFO t_DeviceInfo;
-       char ReqLicBuf[REQU_MAXSIZE] = {0}; //Request buff max size. (2011.03.08)
+       char ReqLicBuf[REQU_MAXSIZE] = {0, };
 
        //null check
        if (!pTADCFilepath
-               || !pReqBuf
-               || !pLicenseUrl
-               || *pReqBufLen < 512
-               || *pLicenseUrlLen < 512) {
-               DRM_TAPPS_EXCEPTION("DrmTdcGeneratePurchaseRequest Error : Parameter Null");
+                       || !pReqBuf
+                       || !pLicenseUrl
+                       || *pReqBufLen < 512
+                       || *pLicenseUrlLen < 512) {
+               DRM_TAPPS_EXCEPTION("Parameter Null");
                return FALSE;
        }
 
@@ -388,27 +387,29 @@ bool DrmTdcGeneratePurchaseRequest(
 
        //Set DeviceInfo
        if (TADC_SetDeviceInfo(&t_DeviceInfo) == TADC_GETDUID_ERROR) {
-               DRM_TAPPS_EXCEPTION("DrmTdcGeneratePurchaseRequest Error : TADC_SetDeviceInfo");
+               DRM_TAPPS_EXCEPTION("TADC_SetDeviceInfo");
                return FALSE;
        }
 
        //Get DRM Header Info
        if (TADC_GetDRMHeaderFromFile(pTADCFilepath, &t_FileHeader, &t_DRMHeader) < 0) {
-               DRM_TAPPS_EXCEPTION("DrmTdcGeneratePurchaseRequest Error : TADC_GetDRMHeaderFromFile");
+               DRM_TAPPS_EXCEPTION("TADC_GetDRMHeaderFromFile");
                TADC_MEMFree_DRMHeader(&t_DRMHeader);
                return FALSE;
        }
 
-       if (TADC_MakeRequestLicense(&t_DeviceInfo, &t_FileHeader, &t_DRMHeader, (unsigned char*)ReqLicBuf, sizeof(ReqLicBuf)) < 0) {
-               DRM_TAPPS_EXCEPTION("DrmTdcGeneratePurchaseRequest Error : TADC_MakeRequestLicense");
+       if (TADC_MakeRequestLicense(&t_DeviceInfo, &t_FileHeader, &t_DRMHeader,
+                                                               (unsigned char *)ReqLicBuf, sizeof(ReqLicBuf)) < 0) {
+               DRM_TAPPS_EXCEPTION("TADC_MakeRequestLicense");
                TADC_MEMFree_DRMHeader(&t_DRMHeader);
                return FALSE;
        }
 
        //Copy pReqBuf
        size_t tmpLen = strlen((char *)ReqLicBuf);
+
        if (*pReqBufLen <= tmpLen) {
-               DRM_TAPPS_EXCEPTION("DrmTdcGeneratePurchaseRequest Error : *pReqBufLen(%d) <= %d", *pReqBufLen, tmpLen);
+               DRM_TAPPS_EXCEPTION("*pReqBufLen(%d) <= %d", *pReqBufLen, tmpLen);
                TADC_MEMFree_DRMHeader(&t_DRMHeader);
                return FALSE;
        }
@@ -417,8 +418,9 @@ bool DrmTdcGeneratePurchaseRequest(
 
        //Copy License URL
        tmpLen = strlen((char *)t_DRMHeader.RIURL);
+
        if (*pLicenseUrlLen <= tmpLen) {
-               DRM_TAPPS_EXCEPTION("DrmTdcGeneratePurchaseRequest Error : *pLicenseUrlLen(%d) <= %d", *pLicenseUrlLen, tmpLen);
+               DRM_TAPPS_EXCEPTION("*pLicenseUrlLen(%d) <= %d", *pLicenseUrlLen, tmpLen);
                TADC_MEMFree_DRMHeader(&t_DRMHeader);
                return FALSE;
        }
@@ -432,14 +434,9 @@ bool DrmTdcGeneratePurchaseRequest(
        return TRUE;
 }
 
-int DrmTdcGenerateLicenseRequest(
-       IN const char *pRespBuf,              //Response Data String of the Purchase Request ( Null terminator string )
-       IN unsigned int respBufLen,           //pResBuf Length
-       IN OUT char *pReqBuf,                 //License Request Data
-       IN OUT unsigned int *pReqBufLen,      //IN : pReqBuf Length, OUT : Rights Request Data String Size ( including null terminator )
-       IN OUT char *pLicenseUrl,             //License Acquisition URL Data
-       IN OUT unsigned int *pLicenseUrlLen   //IN : pLicenseUrl Length, OUT : Rights Issuer Server URL Data String Size (  including null terminator )
-)
+int DrmTdcGenerateLicenseRequest(const char *pRespBuf, unsigned int respBufLen,
+                                                                char *pReqBuf, unsigned int *pReqBufLen, char *pLicenseUrl,
+                                                                unsigned int *pLicenseUrlLen)
 {
        T_ROACQ_INFO *pt_ROAcqInfo = NULL;
 
@@ -450,12 +447,12 @@ int DrmTdcGenerateLicenseRequest(
 
        //null check
        if (!pRespBuf
-               || !pReqBuf
-               || !pLicenseUrl
-               || respBufLen < 1
-               || *pReqBufLen < 512
-               ||  *pLicenseUrlLen < 512) {
-               DRM_TAPPS_EXCEPTION("DrmTdcGenerateLicenseRequest Error : Parameter Null");
+                       || !pReqBuf
+                       || !pLicenseUrl
+                       || respBufLen < 1
+                       || *pReqBufLen < 512
+                       ||  *pLicenseUrlLen < 512) {
+               DRM_TAPPS_EXCEPTION("Parameter Null");
                return TADC_PARAMETER_ERROR;
        }
 
@@ -464,8 +461,9 @@ int DrmTdcGenerateLicenseRequest(
                g_DrmTdcDHFlag = TRUE;
        }
 
-       for (idx = 0 ; idx < DHINFO_MAX ; idx++) {
-               if (!TADC_IF_MemCmp(g_DrmTdcDHInfo.hashReqID[idx], sha1_tmp, DHINFO_REQIDLEN)) {
+       for (idx = 0; idx < DHINFO_MAX; idx++) {
+               if (!TADC_IF_MemCmp(
+                                       g_DrmTdcDHInfo.hashReqID[idx], sha1_tmp, DHINFO_REQIDLEN)) {
                        pt_ROAcqInfo = &g_DrmTdcDHInfo.t_ROAcqInfo[idx];
                        break;
                }
@@ -475,21 +473,22 @@ int DrmTdcGenerateLicenseRequest(
        DRM_TAPPS_LOG("DrmTdcGenerateLicenseRequest ID Idx = %d", idx);
 
        if (idx == DHINFO_MAX) {
-               DRM_TAPPS_EXCEPTION("DrmTdcGenerateLicenseRequest Error : idx == DHINFO_MAX");
+               DRM_TAPPS_EXCEPTION("idx == DHINFO_MAX");
                return TADC_DHINFO_MAX_ERROR;
        }
 
        //Get ReqID
-       if (TADC_GetROAcqInfo((unsigned char*)pRespBuf, pt_ROAcqInfo) < 0) {
-               DRM_TAPPS_EXCEPTION("DrmTdcGenerateLicenseRequest Error : TADC_GetROAcqInfo");
+       if (TADC_GetROAcqInfo((unsigned char *)pRespBuf, pt_ROAcqInfo) < 0) {
+               DRM_TAPPS_EXCEPTION("TADC_GetROAcqInfo");
                return TADC_GET_ROACQ_INFO_ERROR;
        }
 
        ROVer[0] = 2;
        ROVer[1] = 0;
 
-       if (TADC_MakeRequestRO(pt_ROAcqInfo, (unsigned char*)ReqROBuf, sizeof(ReqROBuf), ROVer) < 0) {
-               DRM_TAPPS_EXCEPTION("DrmTdcGenerateLicenseRequest Error : TADC_MakeRequestRO");
+       if (TADC_MakeRequestRO(pt_ROAcqInfo, (unsigned char *)ReqROBuf,
+                                                  sizeof(ReqROBuf), ROVer) < 0) {
+               DRM_TAPPS_EXCEPTION("TADC_MakeRequestRO");
                return TADC_MAKE_LICENSEREQ_ERROR;
        }
 
@@ -497,12 +496,15 @@ int DrmTdcGenerateLicenseRequest(
        DRM_TAPPS_LOG("Debug Log == Copy ReqID Hash Successfully Done!");
 
        //Copy ReqID Hash
-       TADC_IF_SHA1(pt_ROAcqInfo -> ReqID, TADC_IF_StrLen((char*)pt_ROAcqInfo -> ReqID), g_DrmTdcDHInfo.hashReqID[idx]);
+       TADC_IF_SHA1(pt_ROAcqInfo -> ReqID,
+                                TADC_IF_StrLen((char *)pt_ROAcqInfo -> ReqID),
+                                g_DrmTdcDHInfo.hashReqID[idx]);
 
        //Copy pReqBuf
        size_t tmpLen = strlen((char *)ReqROBuf);
+
        if (*pReqBufLen <= tmpLen) {
-               DRM_TAPPS_EXCEPTION("DrmTdcGenerateLicenseRequest Error : *pReqBufLen(%d) <= %d", *pReqBufLen, tmpLen);
+               DRM_TAPPS_EXCEPTION("*pReqBufLen(%d) <= %d", *pReqBufLen, tmpLen);
                return TADC_MEMAlOC_ERROR;
        }
 
@@ -510,8 +512,9 @@ int DrmTdcGenerateLicenseRequest(
 
        //Copy License URL
        tmpLen = strlen((char *)pt_ROAcqInfo->ROAcqURL);
+
        if (*pLicenseUrlLen <= tmpLen) {
-               DRM_TAPPS_EXCEPTION("DrmTdcGenerateLicenseRequest Error : *pLicenseUrlLen(%d) <= %d", *pLicenseUrlLen, tmpLen);
+               DRM_TAPPS_EXCEPTION("*pLicenseUrlLen(%d) <= %d", *pLicenseUrlLen, tmpLen);
                return TADC_MEMAlOC_ERROR;
        }
 
@@ -523,12 +526,8 @@ int DrmTdcGenerateLicenseRequest(
        return TADC_SUCCESS;
 }
 
-int DrmTdcDecryptLicense(
-       IN const char *pRespBuf,              //Response Data String of the Rights Request ( Null terminator string )
-       IN unsigned int respBufLen,           //pResBuf Length
-       IN OUT char *pDecLicenseBuf,          //Decrypted Rights Object
-       IN OUT unsigned int *decLicenseBufLen //IN : pDecLicenseBuf Length, OUT : Decrypted Rights Object String Size (  including null terminator )
-)
+int DrmTdcDecryptLicense(const char *pRespBuf, unsigned int respBufLen,
+                                                char *pDecLicenseBuf, unsigned int *decLicenseBufLen)
 {
        T_ROACQ_INFO *pt_ROAcqInfo = NULL;
        T_RO t_RO;
@@ -538,17 +537,17 @@ int DrmTdcDecryptLicense(
 
        //null check
        if (!pRespBuf
-               || !pDecLicenseBuf
-               || respBufLen < 1
-               || *decLicenseBufLen < 512) {
-               DRM_TAPPS_EXCEPTION("DrmTdcDecryptLicense Error : Parameter Null  \n");
+                       || !pDecLicenseBuf
+                       || respBufLen < 1
+                       || *decLicenseBufLen < 512) {
+               DRM_TAPPS_EXCEPTION("Parameter Null");
                return TADC_PARAMETER_ERROR;
        }
 
        memset(&t_RO, 0x00, sizeof(T_RO));
 
-       if (TADC_GetHashReqID((unsigned char*)pRespBuf, sha1_tmp) < 0) {
-               DRM_TAPPS_EXCEPTION("DrmTdcDecryptLicense Error : TADC_GetHashReqID  \n");
+       if (TADC_GetHashReqID((unsigned char *)pRespBuf, sha1_tmp) < 0) {
+               DRM_TAPPS_EXCEPTION("TADC_GetHashReqID");
                return TADC_GET_HASHREQID_ERROR;
        }
 
@@ -560,26 +559,29 @@ int DrmTdcDecryptLicense(
        }
 
        if (idx == DHINFO_MAX) {
-               DRM_TAPPS_EXCEPTION("DrmTdcDecryptLicense Error : idx == DHINFO_MAX!, Session-key is not same.\n");
+               DRM_TAPPS_EXCEPTION("idx == DHINFO_MAX!, Session-key is not same.");
                return TADC_DHINFO_MAX_ERROR;
        }
 
        //Get Decrypted License
-       if ((ret = TADC_GetResponseRO((unsigned char*)pRespBuf, pt_ROAcqInfo, &t_RO, (unsigned char*)pDecLicenseBuf)) < 0) {
+       if ((ret = TADC_GetResponseRO((unsigned char *)pRespBuf, pt_ROAcqInfo, &t_RO,
+                                                                 (unsigned char *)pDecLicenseBuf)) < 0) {
                DrmTdcDHInfoFree(idx); //2010.02.26
-               DRM_TAPPS_EXCEPTION("DrmTdcDecryptLicense Error : TADC_GetResponseRO! Ret[%x]", ret);
+               DRM_TAPPS_EXCEPTION("TADC_GetResponseRO! Ret[%x]", ret);
                return TADC_GET_RORES_INFO_ERROR;
        }
+
        *decLicenseBufLen = strlen(pDecLicenseBuf) + 1;
 
        // Check Signature and Certificate Chain
-       if ((ret = TADC_VerifyROSignature((unsigned char*)pDecLicenseBuf))) {
+       if ((ret = TADC_VerifyROSignature((unsigned char *)pDecLicenseBuf))) {
                DRM_TAPPS_EXCEPTION("TADC_VerifyROSignature Error Code = %x", ret);
                return TADC_RO_SIGNATURE_ERROR;
        }
 
        //2011.03.08, return time stamp
-       memcpy(g_sTimeStamp, pt_ROAcqInfo->sTimeStamp, strlen((char *)pt_ROAcqInfo->sTimeStamp) + 1);
+       memcpy(g_sTimeStamp, pt_ROAcqInfo->sTimeStamp,
+                  strlen((char *)pt_ROAcqInfo->sTimeStamp) + 1);
 
        //Free
        TADC_MEMFree_RO(&t_RO);
@@ -595,7 +597,8 @@ void DrmTdcDHInfoInit(void)
 
 bool DrmTdcDHInfoFree(int idx)
 {
-       memset(&g_DrmTdcDHInfo.hashReqID[idx], 0x00, sizeof(g_DrmTdcDHInfo.hashReqID[idx]));
+       memset(&g_DrmTdcDHInfo.hashReqID[idx], 0x00,
+                  sizeof(g_DrmTdcDHInfo.hashReqID[idx]));
 
        if (TADC_MEMFree_ROAcqInfo(&g_DrmTdcDHInfo.t_ROAcqInfo[idx]) < 0)
                return FALSE;
index 3204ebd..3b348c1 100644 (file)
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
- */
-
-/**
+ *
  * @file    TADC_Core.cpp
- * @brief   This file includes implementations of the Tizen Apps DRM Core APIs.
+ * @brief   Tizen Apps DRM Core APIs.
 */
 
 #include "drm-tizen-error.h"
 #include "TADC_ErrorCode.h"
 
 static BYTE g_baSignatureKey[32] = {
-       0x29, 0x2b, 0xf2, 0x29, 0x1f, 0x8b, 0x47, 0x81, 0x95, 0x0a, 0x84, 0xf8, 0x91, 0xda, 0x07, 0xd0,
-       0x9c, 0xde, 0x32, 0x3e, 0x9e, 0x46, 0x4a, 0xfc, 0xa4, 0xcc, 0x55, 0x6e, 0xf2, 0x81, 0x61, 0xdb
+       0x29, 0x2b, 0xf2, 0x29, 0x1f, 0x8b, 0x47, 0x81,
+       0x95, 0x0a, 0x84, 0xf8, 0x91, 0xda, 0x07, 0xd0,
+       0x9c, 0xde, 0x32, 0x3e, 0x9e, 0x46, 0x4a, 0xfc,
+       0xa4, 0xcc, 0x55, 0x6e, 0xf2, 0x81, 0x61, 0xdb
 };
 
 static BYTE g_baAESKey[32] = {
-       0xf8, 0x87, 0x0a, 0xc5, 0xd3, 0x6d, 0x44, 0x49, 0x03, 0x9f, 0xbd, 0x1e, 0xa8, 0x2f, 0xf6, 0xc3,
-       0xdf, 0x3b, 0x02, 0x13, 0x58, 0x1b, 0x12, 0x30, 0x1c, 0xd7, 0xad, 0xa5, 0x1f, 0x5d, 0x01, 0x33
+       0xf8, 0x87, 0x0a, 0xc5, 0xd3, 0x6d, 0x44, 0x49,
+       0x03, 0x9f, 0xbd, 0x1e, 0xa8, 0x2f, 0xf6, 0xc3,
+       0xdf, 0x3b, 0x02, 0x13, 0x58, 0x1b, 0x12, 0x30,
+       0x1c, 0xd7, 0xad, 0xa5, 0x1f, 0x5d, 0x01, 0x33
 };
 
-//Error Code
 static DWORD g_TADCErrorCode = 0;
 
 int TADC_SetDeviceInfo(T_DEVICE_INFO *t_DeviceInfo)
@@ -44,8 +45,8 @@ int TADC_SetDeviceInfo(T_DEVICE_INFO *t_DeviceInfo)
 
        TADC_IF_MemSet(t_DeviceInfo, 0, sizeof(T_DEVICE_INFO));
 
-// Mandatory value
-       nResult = TADC_IF_GetDUID((CHAR*)t_DeviceInfo->DUID);
+       // Mandatory value
+       nResult = TADC_IF_GetDUID((CHAR *)t_DeviceInfo->DUID);
        IF_ERROR_RETURN(nResult, TADC_GETDUID_ERROR);
 
        return nResult;
@@ -54,7 +55,7 @@ int TADC_SetDeviceInfo(T_DEVICE_INFO *t_DeviceInfo)
 int TADC_MakeRequestLicense(T_DEVICE_INFO *t_DeviceInfo,
                                                        T_FILE_HEADER *t_FileHeader,
                                                        T_DRM_HEADER *t_DRMHeader,
-                                                       unsigned char * outBuffer,
+                                                       unsigned char *outBuffer,
                                                        size_t outBufferSize)
 {
        int nResult = 0;
@@ -63,26 +64,22 @@ int TADC_MakeRequestLicense(T_DEVICE_INFO *t_DeviceInfo,
        //Param Check
        IF_TRUE_RETURN(outBuffer == NULL, TADC_PARAMETER_ERROR);
 
-       snprintf(
-               (char*)outBuffer,
-               outBufferSize,
-               "<?xml version='1.0'?>\n<request>\n<DeviceInfo>\n<duid>%s</duid>\n</DeviceInfo>\n",
-                       t_DeviceInfo->DUID);
-       length = TADC_IF_StrLen((char*)outBuffer);
+       snprintf((char *)outBuffer, outBufferSize,
+                        "<?xml version='1.0'?>\n<request>\n<DeviceInfo>\n"
+                        "<duid>%s</duid>\n</DeviceInfo>\n",
+                        t_DeviceInfo->DUID);
+       length = TADC_IF_StrLen((char *)outBuffer);
        IF_TRUE_RETURN(length <= 0, TADC_XMLPARSER_ERROR);
 
        //Null Check
        IF_TRUE_RETURN(t_DRMHeader->SID == NULL, TADC_SID_NULL_ERROR);
        IF_TRUE_RETURN(t_DRMHeader->CID == NULL, TADC_CID_NULL_ERROR);
 
-       snprintf(
-               (char*)outBuffer + length,
-               outBufferSize - length,
-               "<ContentInfo>\n<DRMType>%d</DRMType>\n<sid>%s</sid>\n<cid>%s</cid>\n</ContentInfo>\n</request>",
-                       t_FileHeader->DRMType,
-                       t_DRMHeader->SID,
-                       t_DRMHeader->CID);
-       length = TADC_IF_StrLen((char*)outBuffer);
+       snprintf((char *)outBuffer + length, outBufferSize - length,
+                        "<ContentInfo>\n<DRMType>%d</DRMType>\n<sid>%s</sid>\n"
+                        "<cid>%s</cid>\n</ContentInfo>\n</request>",
+                        t_FileHeader->DRMType, t_DRMHeader->SID, t_DRMHeader->CID);
+       length = TADC_IF_StrLen((char *)outBuffer);
        IF_TRUE_RETURN(length <= 0, TADC_XMLPARSER_ERROR);
 
        DRM_TAPPS_LOG("TADC_MakeRequestLicense Success!\n");
@@ -90,7 +87,7 @@ int TADC_MakeRequestLicense(T_DEVICE_INFO *t_DeviceInfo,
        return nResult;
 }
 
-int TADC_GetROAcqInfo(unsigned char * inBuffer, T_ROACQ_INFO *t_ROAcqInfo)
+int TADC_GetROAcqInfo(unsigned char *inBuffer, T_ROACQ_INFO *t_ROAcqInfo)
 {
        int nResult = -1;
        int i = 0, j = 0;
@@ -99,27 +96,26 @@ int TADC_GetROAcqInfo(unsigned char * inBuffer, T_ROACQ_INFO *t_ROAcqInfo)
 
        //Check Param buffer
        IF_TRUE_RETURN(inBuffer == NULL, TADC_PARAMETER_ERROR);
-       nSize = TADC_IF_StrLen((char*) inBuffer);
-       IF_TRUE_RETURN( nSize<=40 || nSize>RESP_MAXSIZE, TADC_PARAMETER_ERROR);
+       nSize = TADC_IF_StrLen((char *) inBuffer);
+       IF_TRUE_RETURN(nSize <= 40 || nSize > RESP_MAXSIZE, TADC_PARAMETER_ERROR);
 
        //Check XML Result Code ( Success result='0' )
        nResult = -1;
-       for (i = 0 ; i < nSize ; i++)
-       {
-               if (!TADC_IF_MemCmp((char*)(inBuffer+i), "<response result=", 17))
-               {
+
+       for (i = 0; i < nSize; i++) {
+               if (!TADC_IF_MemCmp((char *)(inBuffer + i), "<response result=", 17)) {
                        i += 17;
-                       if ((!memcmp((char*)(inBuffer+i), "'0'", 3)) || (!memcmp((char*)(inBuffer+i), "\"0\"", 3)))
-                       {
+
+                       if ((!memcmp((char *)(inBuffer + i), "'0'", 3)) ||
+                                       (!memcmp((char *)(inBuffer + i), "\"0\"", 3))) {
                                nResult = 0;
                                break;
-                       }
-                       else
-                       {
+                       } else {
                                nResult = -1;
                        }
                }
        }
+
        IF_TRUE_RETURN(((i == nSize) || (nResult < 0)), TADC_RESPONSEMESSAGE_ERROR);
 
 
@@ -129,63 +125,62 @@ int TADC_GetROAcqInfo(unsigned char * inBuffer, T_ROACQ_INFO *t_ROAcqInfo)
        //Get RIURL
        length = 0;
 
-       for (i = 0 ; i < nSize ; i++)
-       {
-               if (!TADC_IF_MemCmp((char*)(inBuffer + i), "<riurl>", 7))
-               {
+       for (i = 0; i < nSize; i++) {
+               if (!TADC_IF_MemCmp((char *)(inBuffer + i), "<riurl>", 7)) {
                        i += 7;
-                       for (j = i ; j < nSize ; j++)
-                       {
-                               if (!TADC_IF_MemCmp((char*)(inBuffer + j), "</riurl>", 8))
-                               {
+
+                       for (j = i; j < nSize; j++) {
+                               if (!TADC_IF_MemCmp((char *)(inBuffer + j), "</riurl>", 8)) {
                                        length = j - i;
                                        IF_TRUE_RETURN(length <= 0, TADC_PARAMETER_ERROR);
-                                       t_ROAcqInfo->ROAcqURL = (TADC_U8*)TADC_IF_Malloc(length + 1);
+                                       t_ROAcqInfo->ROAcqURL = (TADC_U8 *)TADC_IF_Malloc(length + 1);
                                        IF_TRUE_RETURN(t_ROAcqInfo->ROAcqURL == NULL, TADC_MEMAlOC_ERROR);
                                        TADC_IF_MemSet(t_ROAcqInfo->ROAcqURL, 0, length + 1);
                                        TADC_IF_MemCpy(t_ROAcqInfo->ROAcqURL, inBuffer + i, length);
                                        break;
                                }
                        }
+
                        break;
                }
        }
+
        IF_TRUE_RETURN(length <= 0, TADC_RESPONSEMESSAGE_ERROR);
 
        //Get ReqID
        length = 0;
 
-       for (i = 0 ; i < nSize ; i++)
-       {
-               if (!TADC_IF_MemCmp((char*)(inBuffer + i), "<reqid>", 7))
-               {
+       for (i = 0; i < nSize; i++) {
+               if (!TADC_IF_MemCmp((char *)(inBuffer + i), "<reqid>", 7)) {
                        i += 7;
-                       for (j = i ; j < nSize ; j++)
-                       {
-                               if (!TADC_IF_MemCmp((char*)(inBuffer + j), "</reqid>", 8))
-                               {
+
+                       for (j = i; j < nSize; j++) {
+                               if (!TADC_IF_MemCmp((char *)(inBuffer + j), "</reqid>", 8)) {
                                        length = j - i;
                                        IF_TRUE_RETURN(length <= 0, TADC_PARAMETER_ERROR);
-                                       t_ROAcqInfo->ReqID = (TADC_U8*)TADC_IF_Malloc(length + 1);
+                                       t_ROAcqInfo->ReqID = (TADC_U8 *)TADC_IF_Malloc(length + 1);
                                        IF_TRUE_RETURN(t_ROAcqInfo->ReqID == NULL, TADC_MEMAlOC_ERROR);
                                        TADC_IF_MemSet(t_ROAcqInfo->ReqID, 0, length + 1);
-                                       TADC_IF_MemCpy(t_ROAcqInfo->ReqID, inBuffer+i, length);
+                                       TADC_IF_MemCpy(t_ROAcqInfo->ReqID, inBuffer + i, length);
                                        break;
                                }
                        }
+
                        break;
                }
        }
+
        IF_TRUE_RETURN(length <= 0, TADC_RESPONSEMESSAGE_ERROR);
        DRM_TAPPS_LOG("TADC_GetROAcqInfo Success!\n");
 
        return nResult;
 }
 
-int TADC_MakeRequestRO(T_ROACQ_INFO *t_ROAcqInfo, unsigned char * outBuffer, size_t outBufferSize, unsigned char * ROVer)
+int TADC_MakeRequestRO(T_ROACQ_INFO *t_ROAcqInfo, unsigned char *outBuffer,
+                                          size_t outBufferSize, unsigned char *ROVer)
 {
        BYTE sha1_tmp[20];
-       TADC_U8ReqTemp;
+       TADC_U8 *ReqTemp;
        LPSTR psz64Parameter = NULL;
 
        TADC_U8 key[16];
@@ -209,8 +204,8 @@ int TADC_MakeRequestRO(T_ROACQ_INFO *t_ROAcqInfo, unsigned char * outBuffer, siz
 
        // Debug
        DRM_TAPPS_LOG("Debug Log == TADC_MakeRequestRO  : After Check Param Buffer   \n");
-       len = TADC_IF_StrLen((char*)t_ROAcqInfo->ReqID);
-       IF_TRUE_RETURN( (len <= 0 || len > 512), TADC_PARAMETER_ERROR);
+       len = TADC_IF_StrLen((char *)t_ROAcqInfo->ReqID);
+       IF_TRUE_RETURN((len <= 0 || len > 512), TADC_PARAMETER_ERROR);
 
        // Debug
        DRM_TAPPS_LOG("Debug Log == TADC_MakeRequestRO  : After Check t_ROAcqInfo->ReqID Len   \n");
@@ -219,65 +214,55 @@ int TADC_MakeRequestRO(T_ROACQ_INFO *t_ROAcqInfo, unsigned char * outBuffer, siz
 
        // Debug
        DRM_TAPPS_LOG("Debug Log == TADC_MakeRequestRO  : After TADC_IF_GetDHKey  \n");
-       IF_TRUE_RETURN(t_ROAcqInfo->t_DHInfo.pSize <= 0 || t_ROAcqInfo->t_DHInfo.pSize > DHKey_SIZE, TADC_PARAMETER_ERROR);
-       IF_TRUE_RETURN(t_ROAcqInfo->t_DHInfo.ASize <= 0 || t_ROAcqInfo->t_DHInfo.ASize > DHKey_SIZE, TADC_PARAMETER_ERROR);
+       IF_TRUE_RETURN(t_ROAcqInfo->t_DHInfo.pSize <= 0 ||
+                                  t_ROAcqInfo->t_DHInfo.pSize > DHKey_SIZE, TADC_PARAMETER_ERROR);
+       IF_TRUE_RETURN(t_ROAcqInfo->t_DHInfo.ASize <= 0 ||
+                                  t_ROAcqInfo->t_DHInfo.ASize > DHKey_SIZE, TADC_PARAMETER_ERROR);
 
        //If ROVer 2.0 then add <reqversion> element. 2011.03.08
-       if (ROVer != NULL && ROVer[0] >= 2)
-       {
-               snprintf(
-                       (char*)outBuffer,
-                       outBufferSize,
-                       "<?xml version='1.0'?>\n<request>\n<reqversion>%d.%d</reqversion>\n<reqid>%s</reqid>\n<reqdataset>",
-                               ROVer[0],
-                               ROVer[1],
-                               t_ROAcqInfo->ReqID);
-       }
-       else
-       {
-               snprintf(
-                       (char*)outBuffer,
-                       outBufferSize,
-                       "<?xml version='1.0'?>\n<request>\n<reqid>%s</reqid>\n<reqdataset>",
-                               t_ROAcqInfo->ReqID);
-       }
-
-       len = TADC_IF_StrLen((char*)outBuffer);
+       if (ROVer != NULL && ROVer[0] >= 2) {
+               snprintf((char *)outBuffer, outBufferSize,
+                                "<?xml version='1.0'?>\n<request>\n"
+                                "<reqversion>%d.%d</reqversion>\n"
+                                "<reqid>%s</reqid>\n<reqdataset>",
+                                ROVer[0], ROVer[1], t_ROAcqInfo->ReqID);
+       } else {
+               snprintf((char *)outBuffer, outBufferSize,
+                                "<?xml version='1.0'?>\n<request>\n"
+                                "<reqid>%s</reqid>\n<reqdataset>",
+                                t_ROAcqInfo->ReqID);
+       }
+
+       len = TADC_IF_StrLen((char *)outBuffer);
        i += len;
 
        reqdataset_size = i;
 
-       TADC_IF_StrNCpy((char*)outBuffer+i, "p=", 2);
+       TADC_IF_StrNCpy((char *)outBuffer + i, "p=", 2);
        i += 2;
 
-       for (k = 0 ; k < t_ROAcqInfo->t_DHInfo.pSize ; k++)
-       {
-               snprintf(
-                       (char*)outBuffer + i + (k * 2),
-                       outBufferSize - i - (k * 2),
-                       "%02X",
-                               t_ROAcqInfo->t_DHInfo.p[k]);
+       for (k = 0; k < t_ROAcqInfo->t_DHInfo.pSize; k++) {
+               snprintf((char *)outBuffer + i + (k * 2), outBufferSize - i - (k * 2),
+                                "%02X", t_ROAcqInfo->t_DHInfo.p[k]);
        }
+
        i += (k * 2);
 
        snprintf(
-               (char*)outBuffer + i,
+               (char *)outBuffer + i,
                outBufferSize - i,
                ";g=%ld",
-                       t_ROAcqInfo->t_DHInfo.g);
+               t_ROAcqInfo->t_DHInfo.g);
        i += 4;
 
-       TADC_IF_StrNCpy((char*)outBuffer + i, ";A=", 3);
+       TADC_IF_StrNCpy((char *)outBuffer + i, ";A=", 3);
        i += 3;
 
-       for (k = 0 ; k < t_ROAcqInfo->t_DHInfo.ASize ; k++)
-       {
-               snprintf(
-                       (char*)outBuffer + i + (k * 2),
-                       outBufferSize - i - (k * 2),
-                       "%02X",
-                               t_ROAcqInfo->t_DHInfo.A[k]);
+       for (k = 0; k < t_ROAcqInfo->t_DHInfo.ASize; k++) {
+               snprintf((char *)outBuffer + i + (k * 2), outBufferSize - i - (k * 2),
+                                "%02X", t_ROAcqInfo->t_DHInfo.A[k]);
        }
+
        i += (k * 2);
 
        outBuffer[i] = 0;
@@ -285,23 +270,24 @@ int TADC_MakeRequestRO(T_ROACQ_INFO *t_ROAcqInfo, unsigned char * outBuffer, siz
        StrSize = i - reqdataset_size;
 
        //MemAlloc
-       ReqTemp = (TADC_U8*)TADC_IF_Malloc(StrSize);
+       ReqTemp = (TADC_U8 *)TADC_IF_Malloc(StrSize);
        IF_TRUE_RETURN(ReqTemp == NULL, TADC_MEMAlOC_ERROR);
 
        TADC_IF_MemSet(ReqTemp, 0, StrSize);
-       TADC_IF_MemCpy(ReqTemp, outBuffer+reqdataset_size, StrSize);
+       TADC_IF_MemCpy(ReqTemp, outBuffer + reqdataset_size, StrSize);
        TADC_IF_SHA1(ReqTemp, StrSize, sha1_tmp);
 
        TADC_IF_MemCpy(key, &g_baAESKey[0], 16);
        TADC_IF_MemCpy(iv, &g_baAESKey[16], 16);
-       TADC_IF_AES_CTR(key, 16, iv, 20, (unsigned char*)sha1_tmp, &outlen, (unsigned char*)sha1_tmp);
+       TADC_IF_AES_CTR(key, 16, iv, 20, (unsigned char *)sha1_tmp, &outlen,
+                                       (unsigned char *)sha1_tmp);
 
        // Debug
        DRM_TAPPS_LOG("Debug Log == TADC_MakeRequestRO  : After TADC_IF_AES_CTR  \n");
 
-       psz64Parameter = Base64Encode(sha1_tmp, sizeof(sha1_tmp));      //MemAlloc
-       if (psz64Parameter == NULL)
-       {
+       psz64Parameter = Base64Encode(sha1_tmp, sizeof(sha1_tmp));  //MemAlloc
+
+       if (psz64Parameter == NULL) {
                TADC_IF_Free(ReqTemp);
                return TADC_MEMAlOC_ERROR;
        }
@@ -309,24 +295,24 @@ int TADC_MakeRequestRO(T_ROACQ_INFO *t_ROAcqInfo, unsigned char * outBuffer, siz
        // Debug
        DRM_TAPPS_LOG("Debug Log == TADC_MakeRequestRO  : After Base64Encode  \n");
 
-       TADC_IF_StrNCpy((char*)(outBuffer + i), ";hmac=", 6);
-       len = TADC_IF_StrLen((char*)psz64Parameter);
+       TADC_IF_StrNCpy((char *)(outBuffer + i), ";hmac=", 6);
+       len = TADC_IF_StrLen((char *)psz64Parameter);
        TADC_IF_MemCpy(outBuffer + i + 6, psz64Parameter, len);
-       TADC_IF_StrNCpy((char*)outBuffer + i + 6 + len, "</reqdataset>\n</request>", 24);
+       TADC_IF_StrNCpy((char *)outBuffer + i + 6 + len, "</reqdataset>\n</request>",
+                                       24);
 
        //MemFree
-       if (ReqTemp != NULL)
-       {
+       if (ReqTemp != NULL) {
                TADC_IF_Free(ReqTemp);
                ReqTemp = NULL;
        }
-       if (psz64Parameter != NULL)
-       {
+
+       if (psz64Parameter != NULL) {
                TADC_IF_Free(psz64Parameter);
                psz64Parameter = NULL;
        }
 
-       len = TADC_IF_StrLen((char*)outBuffer);
+       len = TADC_IF_StrLen((char *)outBuffer);
        IF_TRUE_RETURN(len <= 0, TADC_REQMAKEHMAC_ERROR);
 
        DRM_TAPPS_LOG("TADC_MakeRequestRO Success!\n");
@@ -334,50 +320,46 @@ int TADC_MakeRequestRO(T_ROACQ_INFO *t_ROAcqInfo, unsigned char * outBuffer, siz
        return len;
 }
 
-int TADC_GetHashReqID(unsigned char * inBuffer, unsigned char *hashReqID)
+int TADC_GetHashReqID(unsigned char *inBuffer, unsigned char *hashReqID)
 {
        //Check Param Buffer
        IF_TRUE_RETURN(inBuffer == NULL, TADC_PARAMETER_ERROR);
        IF_TRUE_RETURN(hashReqID == NULL, TADC_PARAMETER_ERROR);
-       int nSize = TADC_IF_StrLen((char*)inBuffer);
-       IF_TRUE_RETURN(nSize <= 40 || nSize>RESP_MAXSIZE, TADC_PARAMETER_ERROR);
+       int nSize = TADC_IF_StrLen((char *)inBuffer);
+       IF_TRUE_RETURN(nSize <= 40 || nSize > RESP_MAXSIZE, TADC_PARAMETER_ERROR);
 
        //Check XML Result Code ( Success result='0' )
        int nResult = -1;
        int i = 0;
 
-       for (i = 0 ; i < nSize ; i++)
-       {
-               if (!TADC_IF_MemCmp((char*)(inBuffer + i), "<response result=", 17))
-               {
+       for (i = 0; i < nSize; i++) {
+               if (!TADC_IF_MemCmp((char *)(inBuffer + i), "<response result=", 17)) {
                        i += 17;
-                       if ((!memcmp((char*)(inBuffer + i), "'0'", 3)) || (!memcmp((char*)(inBuffer + i), "\"0\"", 3)))
-                       {
+
+                       if ((!memcmp((char *)(inBuffer + i), "'0'", 3)) ||
+                                       (!memcmp((char *)(inBuffer + i), "\"0\"", 3))) {
                                nResult = 0;
                                break;
-                       }
-                       else
-                       {
+                       } else {
                                nResult = -1;
                        }
                }
        }
+
        IF_TRUE_RETURN(((i == nSize) || (nResult < 0)), TADC_RESPONSEMESSAGE_ERROR);
 
        //Get reqid
        int length = 0;
        char tmpbuf[512] = {0, };
 
-       for (i = 0 ; i < nSize ; i++)
-       {
-               if (!TADC_IF_MemCmp(inBuffer + i, "reqid=", 6))
-               {
+       for (i = 0; i < nSize; i++) {
+               if (!TADC_IF_MemCmp(inBuffer + i, "reqid=", 6)) {
                        i += 6;
                        length = 40;
                        IF_TRUE_RETURN(i + length > nSize || inBuffer[i + length] != ';',
-                                       TADC_RESPONSEMESSAGE_ERROR);
+                                                  TADC_RESPONSEMESSAGE_ERROR);
 
-                       TADC_IF_StrNCpy(tmpbuf, (char*)(inBuffer + i), length);
+                       TADC_IF_StrNCpy(tmpbuf, (char *)(inBuffer + i), length);
                        tmpbuf[length] = '\0';
 
                        break;
@@ -387,20 +369,19 @@ int TADC_GetHashReqID(unsigned char * inBuffer, unsigned char *hashReqID)
        // reqid not found
        IF_TRUE_RETURN(length == 0, TADC_RESPONSEMESSAGE_ERROR);
 
-       if ((nResult = HEX2BIN((char*)tmpbuf, hashReqID, &length)) < 0)
-       {
+       if ((nResult = HEX2BIN((char *)tmpbuf, hashReqID, &length)) < 0) {
                return -1;
        }
 
-       if (length != 20)
-       {
+       if (length != 20) {
                return -1;
        }
 
        return 0;
 }
 
-int TADC_GetResponseRO(unsigned char * inBuffer, T_ROACQ_INFO *t_ROAcqInfo, T_RO *t_RO, unsigned char *outBuffer)
+int TADC_GetResponseRO(unsigned char *inBuffer, T_ROACQ_INFO *t_ROAcqInfo,
+                                          T_RO *t_RO, unsigned char *outBuffer)
 {
        int nHMacSize = 28; // Base64 Enc length of SHA1 20byte
        TADC_U8 sha1_tmp[20] = {0, };
@@ -429,38 +410,44 @@ int TADC_GetResponseRO(unsigned char * inBuffer, T_ROACQ_INFO *t_ROAcqInfo, T_RO
        int req_length = 0;
        int nResult = 0;
 
-       char pRoHeader[36] = {'<', '?', 'x', 'm', 'l', ' ', 'v', 'e', 'r', 's', 'i', 'o', 'n', '=', '"', '1', '.', '0', '"', '?', '>', 0x0A,
-                                               '<', 'T', 'i', 'z', 'e', 'n', 'L', 'i', 'c', 'e', 'n', 's', 'e', '>'};
+       char pRoHeader[36] = {
+               '<', '?', 'x', 'm', 'l', ' ', 'v', 'e',
+               'r', 's', 'i', 'o', 'n', '=', '"', '1',
+               '.', '0', '"', '?', '>', 0x0A, '<', 'T',
+               'i', 'z', 'e', 'n', 'L', 'i', 'c', 'e',
+               'n', 's', 'e', '>'
+       };
 
        //Check Param Buffer
        IF_TRUE_RETURN(inBuffer == NULL, TADC_PARAMETER_ERROR);
-       IF_TRUE_RETURN(t_ROAcqInfo== NULL, TADC_PARAMETER_ERROR);
+       IF_TRUE_RETURN(t_ROAcqInfo == NULL, TADC_PARAMETER_ERROR);
        IF_TRUE_RETURN(t_RO == NULL, TADC_PARAMETER_ERROR);
 
-       nSize = TADC_IF_StrLen((char*)inBuffer);
-       IF_TRUE_RETURN( nSize <= 40 || nSize>RESP_MAXSIZE, TADC_PARAMETER_ERROR);
+       nSize = TADC_IF_StrLen((char *)inBuffer);
+       IF_TRUE_RETURN(nSize <= 40 || nSize > RESP_MAXSIZE, TADC_PARAMETER_ERROR);
 
-       IF_TRUE_RETURN(t_ROAcqInfo->t_DHInfo.pSize<=0 || t_ROAcqInfo->t_DHInfo.pSize>DHKey_SIZE, TADC_PARAMETER_ERROR);
-       IF_TRUE_RETURN(t_ROAcqInfo->t_DHInfo.ASize<=0 || t_ROAcqInfo->t_DHInfo.ASize>DHKey_SIZE, TADC_PARAMETER_ERROR);
+       IF_TRUE_RETURN(t_ROAcqInfo->t_DHInfo.pSize <= 0 ||
+                                  t_ROAcqInfo->t_DHInfo.pSize > DHKey_SIZE, TADC_PARAMETER_ERROR);
+       IF_TRUE_RETURN(t_ROAcqInfo->t_DHInfo.ASize <= 0 ||
+                                  t_ROAcqInfo->t_DHInfo.ASize > DHKey_SIZE, TADC_PARAMETER_ERROR);
 
        //Check XML Result Code ( Success result='0' )
        nResult = -1;
-       for (i = 0 ; i < nSize ; i++)
-       {
-               if (!TADC_IF_MemCmp((char*)(inBuffer + i), "<response result=", 17))
-               {
+
+       for (i = 0; i < nSize; i++) {
+               if (!TADC_IF_MemCmp((char *)(inBuffer + i), "<response result=", 17)) {
                        i += 17;
-                       if ((!memcmp((char*)(inBuffer + i), "'0'", 3)) || (!memcmp((char*)(inBuffer + i), "\"0\"", 3)))
-                       {
+
+                       if ((!memcmp((char *)(inBuffer + i), "'0'", 3)) ||
+                                       (!memcmp((char *)(inBuffer + i), "\"0\"", 3))) {
                                nResult = 0;
                                break;
-                       }
-                       else
-                       {
+                       } else {
                                nResult = -1;
                        }
                }
        }
+
        IF_TRUE_RETURN(((i == nSize) || (nResult < 0)), TADC_RESPONSEMESSAGE_ERROR);
 
        //Init
@@ -472,59 +459,60 @@ int TADC_GetResponseRO(unsigned char * inBuffer, T_ROACQ_INFO *t_ROAcqInfo, T_RO
        //Check HMAC
        req_length = 0;
 
-       for (i = 0 ; i < nSize ; i++)
-       {
-               if (!TADC_IF_MemCmp((char*)(inBuffer + i), "<responsedata>", 14))
-               {
+       for (i = 0; i < nSize; i++) {
+               if (!TADC_IF_MemCmp((char *)(inBuffer + i), "<responsedata>", 14)) {
                        i += 14;
-                       for (j = i ; j < nSize ; j++)
-                       {
-                               if (!TADC_IF_MemCmp((char*)(inBuffer+j), ";hmac=", 6))
-                               {
-                                       req_length = j-i;
-                                       IF_TRUE_RETURN(req_length <= 0 || req_length >= RESP_MAXSIZE, TADC_PARAMETER_ERROR);
-
-                                       ReqTemp = (TADC_U8*)TADC_IF_Malloc(req_length);
+
+                       for (j = i; j < nSize; j++) {
+                               if (!TADC_IF_MemCmp((char *)(inBuffer + j), ";hmac=", 6)) {
+                                       req_length = j - i;
+                                       IF_TRUE_RETURN(req_length <= 0 ||
+                                                                  req_length >= RESP_MAXSIZE, TADC_PARAMETER_ERROR);
+
+                                       ReqTemp = (TADC_U8 *)TADC_IF_Malloc(req_length);
                                        IF_TRUE_RETURN(ReqTemp == NULL, TADC_MEMAlOC_ERROR);
 
                                        TADC_IF_MemSet(ReqTemp, 0, req_length);
-                                       TADC_IF_MemCpy(ReqTemp, inBuffer+i, req_length);
+                                       TADC_IF_MemCpy(ReqTemp, inBuffer + i, req_length);
 
                                        i += req_length;
 
-                                       TADC_IF_StrNCpy(hmacBuf, (char*)(inBuffer + i + 6), nHMacSize);
+                                       TADC_IF_StrNCpy(hmacBuf, (char *)(inBuffer + i + 6), nHMacSize);
                                        break;
                                }
                        }
+
                        break;
                }
        }
+
        IF_TRUE_RETURN(req_length <= 0, TADC_RESPONSEMESSAGE_ERROR);
 
-       pbBuffer = Base64Decode( (LPCSTR)hmacBuf, &length );
-       if (pbBuffer == NULL)
-       {
+       pbBuffer = Base64Decode((LPCSTR)hmacBuf, &length);
+
+       if (pbBuffer == NULL) {
                TADC_IF_Free(ReqTemp);
                ReqTemp = NULL;
                return -1;
        }
 
-       TADC_IF_MemCpy(key, &g_baAESKey[0], 16 );
-       TADC_IF_MemCpy(iv, &g_baAESKey[16], 16 );
-       TADC_IF_AES_CTR(key, 16, iv, 20, (unsigned char*)pbBuffer, &outlen, (unsigned char*)pbBuffer);
+       TADC_IF_MemCpy(key, &g_baAESKey[0], 16);
+       TADC_IF_MemCpy(iv, &g_baAESKey[16], 16);
+       TADC_IF_AES_CTR(key, 16, iv, 20, (unsigned char *)pbBuffer, &outlen,
+                                       (unsigned char *)pbBuffer);
 
        TADC_IF_SHA1(ReqTemp, req_length, sha1_tmp);
-       if (ReqTemp != NULL)
-       {
+
+       if (ReqTemp != NULL) {
                TADC_IF_Free(ReqTemp);
                ReqTemp = NULL;
        }
 
-       if (TADC_IF_MemCmp(sha1_tmp, pbBuffer, sizeof(sha1_tmp)))
-       {
+       if (TADC_IF_MemCmp(sha1_tmp, pbBuffer, sizeof(sha1_tmp))) {
                TADC_IF_Free(pbBuffer);
                pbBuffer = NULL;
-               DRM_TAPPS_EXCEPTION("TADC_IF_MemCmp Error Code = %x", TADC_RESPONSESIGNATURE_ERROR);
+               DRM_TAPPS_EXCEPTION("TADC_IF_MemCmp Error Code = %x",
+                                                       TADC_RESPONSESIGNATURE_ERROR);
                return TADC_RESPONSESIGNATURE_ERROR;
        }
 
@@ -533,39 +521,38 @@ int TADC_GetResponseRO(unsigned char * inBuffer, T_ROACQ_INFO *t_ROAcqInfo, T_RO
 
        req_length = 0;
 
-       for (i = 0 ; i < nSize ; i++)
-       {
-               if (!TADC_IF_MemCmp(inBuffer + i, "B=", 2))
-               {
+       for (i = 0; i < nSize; i++) {
+               if (!TADC_IF_MemCmp(inBuffer + i, "B=", 2)) {
                        i += 2;
-                       for (j = i ; j < nSize ; j++)
-                       {
-                               if (!TADC_IF_MemCmp(inBuffer + j, ";", 1))
-                               {
+
+                       for (j = i; j < nSize; j++) {
+                               if (!TADC_IF_MemCmp(inBuffer + j, ";", 1)) {
                                        req_length = j - i;
-                                       IF_TRUE_RETURN(req_length <= 0 || req_length >= (int)sizeof(tmpDH_B), TADC_PARAMETER_ERROR);
-                                       TADC_IF_StrNCpy((char*)tmpDH_B, (char*)(inBuffer + i), req_length);
+                                       IF_TRUE_RETURN(req_length <= 0 ||
+                                                                  req_length >= (int)sizeof(tmpDH_B), TADC_PARAMETER_ERROR);
+                                       TADC_IF_StrNCpy((char *)tmpDH_B, (char *)(inBuffer + i), req_length);
                                        tmpDH_B[req_length] = 0;
                                        break;
                                }
                        }
+
                        break;
                }
        }
+
        IF_TRUE_RETURN(req_length <= 0, TADC_RESPONSEMESSAGE_ERROR);
 
        TADC_IF_MemSet(t_ROAcqInfo->t_DHInfo.B, 0, sizeof(t_ROAcqInfo->t_DHInfo.B));
-       TADC_IF_MemCpy(t_ROAcqInfo->t_DHInfo.B, tmpDH_B, sizeof(t_ROAcqInfo->t_DHInfo.B));
+       TADC_IF_MemCpy(t_ROAcqInfo->t_DHInfo.B, tmpDH_B,
+                                  sizeof(t_ROAcqInfo->t_DHInfo.B));
 
-       if (HEX2BIN((char*)tmpDH_B, t_ROAcqInfo->t_DHInfo.B, (int*)&t_ROAcqInfo->t_DHInfo.BSize) < 0)
-       {
+       if (HEX2BIN((char *)tmpDH_B, t_ROAcqInfo->t_DHInfo.B,
+                               (int *)&t_ROAcqInfo->t_DHInfo.BSize) < 0) {
                return TADC_GETDHKEY_ERROR;
        }
 
-       if(t_ROAcqInfo->t_DHInfo.BSize != 16 && t_ROAcqInfo->t_DHInfo.BSize != 64)
-       {
+       if (t_ROAcqInfo->t_DHInfo.BSize != 16 && t_ROAcqInfo->t_DHInfo.BSize != 64)
                return TADC_GETDHKEY_ERROR;
-       }
 
        TADC_IF_MemSet(t_ROAcqInfo->t_DHInfo.K, 0, sizeof(t_ROAcqInfo->t_DHInfo.K));
 
@@ -574,35 +561,35 @@ int TADC_GetResponseRO(unsigned char * inBuffer, T_ROACQ_INFO *t_ROAcqInfo, T_RO
 
        req_length = 0;
 
-       for (i = 0 ; i < nSize ; i++)
-       {
-               if (!TADC_IF_MemCmp((char*)(inBuffer + i), "license=", 8))
-               {
+       for (i = 0; i < nSize; i++) {
+               if (!TADC_IF_MemCmp((char *)(inBuffer + i), "license=", 8)) {
                        i += 8;
-                       for (j = i ; j < nSize ; j++)
-                       {
-                               if (!TADC_IF_MemCmp((char*)(inBuffer + j), ";hmac=", 6))
-                               {
+
+                       for (j = i; j < nSize; j++) {
+                               if (!TADC_IF_MemCmp((char *)(inBuffer + j), ";hmac=", 6)) {
                                        req_length = j - i;
-                                       IF_TRUE_RETURN(req_length <= 0 || req_length >= RESP_MAXSIZE, TADC_PARAMETER_ERROR);
+                                       IF_TRUE_RETURN(req_length <= 0 ||
+                                                                  req_length >= RESP_MAXSIZE, TADC_PARAMETER_ERROR);
 
-                                       License = (char*)TADC_IF_Malloc(req_length + 1);
+                                       License = (char *)TADC_IF_Malloc(req_length + 1);
                                        IF_TRUE_RETURN(License == NULL, TADC_MEMAlOC_ERROR);
 
                                        TADC_IF_MemSet(License, 0, req_length + 1);
-                                       TADC_IF_StrNCpy(License, (char*)(inBuffer + i), req_length);
+                                       TADC_IF_StrNCpy(License, (char *)(inBuffer + i), req_length);
                                        break;
                                }
                        }
+
                        break;
                }
        }
+
        IF_TRUE_RETURN(req_length <= 0, TADC_RESPONSEMESSAGE_ERROR);
 
        // Get RO License Info
        pbBuffer = Base64Decode((LPCSTR)License, &length);
-       if(!pbBuffer)
-       {
+
+       if (!pbBuffer) {
                TADC_IF_Free(License);
                License = NULL;
                return -1;
@@ -615,7 +602,8 @@ int TADC_GetResponseRO(unsigned char * inBuffer, T_ROACQ_INFO *t_ROAcqInfo, T_RO
        // Decrypt License
        TADC_IF_MemCpy(key, &t_ROAcqInfo->t_DHInfo.K[0], 16);
        TADC_IF_MemCpy(iv, &t_ROAcqInfo->t_DHInfo.K[16], 16);
-       TADC_IF_AES_CTR(key, 16, iv, length, (unsigned char*)pbBuffer, &outlen, (unsigned char*)pbBuffer);
+       TADC_IF_AES_CTR(key, 16, iv, length, (unsigned char *)pbBuffer, &outlen,
+                                       (unsigned char *)pbBuffer);
 
        // Test Code for get the plaintext ro
        /*
@@ -626,13 +614,14 @@ int TADC_GetResponseRO(unsigned char * inBuffer, T_ROACQ_INFO *t_ROAcqInfo, T_RO
 #if 0
        DRM_TAPPS_LOG("fopen started.");
        fd = fopen("/tmp/1.ro", "w+b");
-       if (fd == NULL)
-       {
+
+       if (fd == NULL) {
                DRM_TAPPS_EXCEPTION("fopen() failed.");
                return -1;
        }
+
        DRM_TAPPS_LOG("fopen done.");
-       fwrite(pbBuffer, 1, strlen((char*)pbBuffer), fd);
+       fwrite(pbBuffer, 1, strlen((char *)pbBuffer), fd);
        DRM_TAPPS_LOG("fwrite done.");
        fclose(fd);
        DRM_TAPPS_LOG("fclose done.");
@@ -640,21 +629,22 @@ int TADC_GetResponseRO(unsigned char * inBuffer, T_ROACQ_INFO *t_ROAcqInfo, T_RO
 #endif
        // Test Code Done!
 
-       if(TADC_IF_MemCmp((char*)pbBuffer, pRoHeader, 36))
-       {
+       if (TADC_IF_MemCmp((char *)pbBuffer, pRoHeader, 36)) {
                TADC_IF_Free(pbBuffer);
                pbBuffer = NULL;
-               DRM_TAPPS_EXCEPTION("TADC_IF_MemCmp Error Code = %x", TADC_LICENSEXMLPARSING_ERROR);
+               DRM_TAPPS_EXCEPTION("TADC_IF_MemCmp Error Code = %x",
+                                                       TADC_LICENSEXMLPARSING_ERROR);
                return TADC_LICENSEXMLPARSING_ERROR;
        }
+
        TADC_IF_MemCpy(outBuffer, pbBuffer, length);
        TADC_IF_Free(pbBuffer);
        pbBuffer = NULL;
 
-       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       ///////////////////////////////////////////////////////////////
        // 2011.03.08
        // Get timeStamp
-       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       ///////////////////////////////////////////////////////////////
        retLen = length;
        // <timeStamp>
        req_length = 0;
@@ -662,6 +652,7 @@ int TADC_GetResponseRO(unsigned char * inBuffer, T_ROACQ_INFO *t_ROAcqInfo, T_RO
        DRM_TAPPS_LOG("timeStamp parsing start");
 
        i = FindString(inBuffer, nSize, (unsigned char *)"<timeStamp>", 11);
+
        if (i < 0) {
                DRM_TAPPS_LOG("No timeStamp. TADC_GetResponseRO Success!");
                return retLen;
@@ -676,18 +667,18 @@ int TADC_GetResponseRO(unsigned char * inBuffer, T_ROACQ_INFO *t_ROAcqInfo, T_RO
        if (req_length <= 0)
                return retLen;
 
-       timeStamp =  (char*)TADC_IF_Malloc(req_length + 1);
+       timeStamp = (char *)TADC_IF_Malloc(req_length + 1);
        IF_TRUE_RETURN(timeStamp == NULL, TADC_MEMAlOC_ERROR);
 
        TADC_IF_MemSet(timeStamp, 0, req_length + 1);
-       TADC_IF_StrNCpy(timeStamp, (char*)(inBuffer + i), req_length);
+       TADC_IF_StrNCpy(timeStamp, (char *)(inBuffer + i), req_length);
 
        DRM_TAPPS_LOG("timeStamp parsing end.. req_length[%d]", req_length);
 
        // Get RO License Info
        pbBuffer = Base64Decode((LPCSTR)timeStamp, &length);
-       if (!pbBuffer)
-       {
+
+       if (!pbBuffer) {
                TADC_IF_Free(timeStamp);
                timeStamp = NULL;
                DRM_TAPPS_EXCEPTION("Base64Decode Failed");
@@ -703,13 +694,14 @@ int TADC_GetResponseRO(unsigned char * inBuffer, T_ROACQ_INFO *t_ROAcqInfo, T_RO
        // Decrypt timeStamp
        TADC_IF_MemCpy(key, &t_ROAcqInfo->t_DHInfo.K[0], 16);
        TADC_IF_MemCpy(iv, &t_ROAcqInfo->t_DHInfo.K[16], 16);
-       TADC_IF_AES_CTR(key, 16, iv, length, (unsigned char*)pbBuffer, &outlen, (unsigned char*)pbBuffer);
+       TADC_IF_AES_CTR(key, 16, iv, length, (unsigned char *)pbBuffer, &outlen,
+                                       (unsigned char *)pbBuffer);
 
-       if (length >= (int)sizeof(t_ROAcqInfo->sTimeStamp))
-       {
+       if (length >= (int)sizeof(t_ROAcqInfo->sTimeStamp)) {
                TADC_IF_Free(pbBuffer);
                pbBuffer = NULL;
-               DRM_TAPPS_EXCEPTION("TADC_IF_MemCmp Error Code = %x", TADC_RESPONSEMESSAGE_ERROR);
+               DRM_TAPPS_EXCEPTION("TADC_IF_MemCmp Error Code = %x",
+                                                       TADC_RESPONSEMESSAGE_ERROR);
                return TADC_RESPONSEMESSAGE_ERROR;
        }
 
@@ -723,41 +715,43 @@ int TADC_GetResponseRO(unsigned char * inBuffer, T_ROACQ_INFO *t_ROAcqInfo, T_RO
        return retLen;
 }
 
-int TADC_VerifyROSignature(IN LPBYTE pszXML)
+int TADC_VerifyROSignature(LPBYTE pszXML)
 {
        int nResult = 0;
        int length = 0, i = 0, i2 = 0;
 
-       unsigned charpSigData = NULL;
-       unsigned charpRICert = NULL;
-       unsigned charpRICACert = NULL;
+       unsigned char *pSigData = NULL;
+       unsigned char *pRICert = NULL;
+       unsigned char *pRICACert = NULL;
 
        int inLen = 0, sigLen = 0, certLen = 0, certLen2 = 0;
 
-       unsigned charp;
+       unsigned char *p;
        char TempBuf[CERT_MAXSIZE] = {0, };
 
        //Check Param Buffer
        IF_TRUE_RETURN(pszXML == NULL, TADC_PARAMETER_ERROR);
 
        //Check Version
-       i = FindString(pszXML, TADC_IF_StrLen((char*)pszXML), (LPBYTE)"<version>2.0</version>", 22);
-       if (i < 0)
-       {
-               DRM_TAPPS_EXCEPTION("TADC_IF_VerifyROSignature Debug : It is not the TAD-RO2.0 format. \n");
+       i = FindString(pszXML, TADC_IF_StrLen((char *)pszXML),
+                                  (LPBYTE)"<version>2.0</version>", 22);
+
+       if (i < 0) {
+               DRM_TAPPS_EXCEPTION("It is not the TAD-RO2.0 format.");
                return 0;
        }
 
-       DRM_TAPPS_LOG("TADC_IF_VerifyROSignature Debug : It is the TAD-RO2.0 format.\n");
+       DRM_TAPPS_LOG("It is the TAD-RO2.0 format.");
 
        //Get Certificates ( RI Cert )
        TADC_IF_MemSet(TempBuf, 0x00, CERT_MAXSIZE);
 
-       i = FindString(pszXML, TADC_IF_StrLen((char*)pszXML), (LPBYTE)"<CertificateChain>", 18);
+       i = FindString(pszXML, TADC_IF_StrLen((char *)pszXML),
+                                  (LPBYTE)"<CertificateChain>", 18);
        IF_TRUE_RETURN(i < 0, TADC_RO_CERTIFICATE_ERROR);
 
        p = pszXML + i; // <certificateChain>
-       length = TADC_IF_StrLen((char*)pszXML) - i;
+       length = TADC_IF_StrLen((char *)pszXML) - i;
 
        i = FindString(p, length, (LPBYTE)"<Certificate>", 13);
        IF_TRUE_RETURN(i < 0, TADC_RO_CERTIFICATE_ERROR);
@@ -767,9 +761,9 @@ int TADC_VerifyROSignature(IN LPBYTE pszXML)
        IF_TRUE_RETURN(i2 < (i + 13), TADC_RO_CERTIFICATE_ERROR);
        certLen = i2 - i; // size of RI Cert
 
-       TADC_IF_StrNCpy(TempBuf, (char*)p+i, certLen);
+       TADC_IF_StrNCpy(TempBuf, (char *)p + i, certLen);
 
-       pRICert = Base64Decode( (LPCSTR)TempBuf, &certLen );
+       pRICert = Base64Decode((LPCSTR)TempBuf, &certLen);
        IF_TRUE_RETURN(pRICert == NULL, TADC_RO_CERTIFICATE_ERROR);
        TADC_IF_MemSet(TempBuf, 0x00, CERT_MAXSIZE);
 
@@ -778,48 +772,55 @@ int TADC_VerifyROSignature(IN LPBYTE pszXML)
        length = length - (i2 + 14);
 
        i = FindString(p, length, (LPBYTE)"<Certificate>", 13);
-       IF_TRUE_RETURN2(i < 0, TADC_IF_Free(pRICert),,,TADC_RO_CERTIFICATE_ERROR);
+       IF_TRUE_RETURN2(i < 0, TADC_IF_Free(pRICert), , , TADC_RO_CERTIFICATE_ERROR);
        i += 13; // start position of RICA Cert
 
        i2 = FindString(p, length, (LPBYTE)"</Certificate>", 14);
-       IF_TRUE_RETURN2(i2 < (i + 13), TADC_IF_Free(pRICert),,,TADC_RO_CERTIFICATE_ERROR);
+       IF_TRUE_RETURN2(i2 < (i + 13), TADC_IF_Free(pRICert), , ,
+                                       TADC_RO_CERTIFICATE_ERROR);
        certLen2 = i2 - i; // size of RICA Cert
 
-       TADC_IF_StrNCpy(TempBuf, (char*)p + i, certLen2);
+       TADC_IF_StrNCpy(TempBuf, (char *)p + i, certLen2);
 
        pRICACert = Base64Decode((LPCSTR)TempBuf, &certLen2);
-       IF_TRUE_RETURN2(pRICACert == NULL, TADC_IF_Free(pRICert),,,TADC_RO_CERTIFICATE_ERROR);
+       IF_TRUE_RETURN2(pRICACert == NULL, TADC_IF_Free(pRICert), , ,
+                                       TADC_RO_CERTIFICATE_ERROR);
        TADC_IF_MemSet(TempBuf, 0x00, CERT_MAXSIZE);
 
        //Get position of indata
-       inLen = FindString(pszXML, TADC_IF_StrLen((char*)pszXML), (LPBYTE)"</CertificateChain>", 19);
-       IF_TRUE_RETURN2(inLen < 0, TADC_IF_Free(pRICert),TADC_IF_Free(pRICACert),,TADC_RO_CERTIFICATE_ERROR);
+       inLen = FindString(pszXML, TADC_IF_StrLen((char *)pszXML),
+                                          (LPBYTE)"</CertificateChain>", 19);
+       IF_TRUE_RETURN2(inLen < 0, TADC_IF_Free(pRICert), TADC_IF_Free(pRICACert), ,
+                                       TADC_RO_CERTIFICATE_ERROR);
        inLen += 19;
 
        //Get signature value </certificateChain>
        p = pszXML + inLen;
-       length = TADC_IF_StrLen((char*)pszXML)-inLen;
+       length = TADC_IF_StrLen((char *)pszXML) - inLen;
 
        i = FindString(p, length, (LPBYTE)"<SignatureValue>", 16);
-       IF_TRUE_RETURN2(i < 0, TADC_IF_Free(pRICert),TADC_IF_Free(pRICACert),,TADC_RO_SIGNATURE_ERROR);
+       IF_TRUE_RETURN2(i < 0, TADC_IF_Free(pRICert), TADC_IF_Free(pRICACert), ,
+                                       TADC_RO_SIGNATURE_ERROR);
        i += 16; // start position of signature value
 
        i2 = FindString(p, length, (LPBYTE)"</SignatureValue>", 17);
-       IF_TRUE_RETURN2(i2 < (i + 16), TADC_IF_Free(pRICert),TADC_IF_Free(pRICACert),,TADC_RO_SIGNATURE_ERROR);
+       IF_TRUE_RETURN2(i2 < (i + 16), TADC_IF_Free(pRICert), TADC_IF_Free(pRICACert), ,
+                                       TADC_RO_SIGNATURE_ERROR);
        sigLen = i2 - i; // size of signature value
 
-       TADC_IF_StrNCpy(TempBuf, (char*)p + i, sigLen);
+       TADC_IF_StrNCpy(TempBuf, (char *)p + i, sigLen);
 
-       pSigData = Base64Decode( (LPCSTR)TempBuf, &sigLen );
-       IF_TRUE_RETURN2(pSigData == NULL, TADC_IF_Free(pRICert),TADC_IF_Free(pRICACert),,TADC_RO_SIGNATURE_ERROR);
+       pSigData = Base64Decode((LPCSTR)TempBuf, &sigLen);
+       IF_TRUE_RETURN2(pSigData == NULL, TADC_IF_Free(pRICert),
+                                       TADC_IF_Free(pRICACert), , TADC_RO_SIGNATURE_ERROR);
        TADC_IF_MemSet(TempBuf, 0x00, CERT_MAXSIZE);
 
        //Verify the certificate chain
        nResult = TADC_IF_VerifyCertChain(pRICACert, certLen2, pRICert, certLen);
+
        if (nResult == 0)
-       {
-               nResult = TADC_IF_VerifySignature(pszXML, inLen, pSigData, sigLen, pRICert, certLen);
-       }
+               nResult = TADC_IF_VerifySignature(pszXML, inLen, pSigData, sigLen, pRICert,
+                                                                                 certLen);
 
        TADC_IF_Free(pRICert);
        TADC_IF_Free(pRICACert);
@@ -828,19 +829,24 @@ int TADC_VerifyROSignature(IN LPBYTE pszXML)
        return nResult;
 }
 
-int TADC_GetResponseROInfo(IN LPBYTE pszXML,  T_RO *t_RO)
+int TADC_GetResponseROInfo(LPBYTE pszXML, T_RO *t_RO)
 {
        int nResult = 0;
        CXMLFile oXMLFile;
-       CXMLElementpRoot, *pElement;
+       CXMLElement *pRoot, *pElement;
        CPointerArray paChilds;
        LPCTSTR pszValue;
        LPBYTE pbBuffer = NULL;
        int length = 0;
        TADC_U8 TempVersion[3] = {0, };
 
-       char pRoHeader[36] = {'<', '?', 'x', 'm', 'l', ' ', 'v', 'e', 'r', 's', 'i', 'o', 'n', '=', '"', '1', '.', '0', '"', '?', '>', 0x0A,
-                                               '<', 'T', 'i', 'z', 'e', 'n', 'L', 'i', 'c', 'e', 'n', 's', 'e', '>'};
+       char pRoHeader[36] = {
+               '<', '?', 'x', 'm', 'l', ' ', 'v', 'e',
+               'r', 's', 'i', 'o', 'n', '=', '"', '1',
+               '.', '0', '"', '?', '>', 0x0A, '<', 'T',
+               'i', 'z', 'e', 'n', 'L', 'i', 'c', 'e',
+               'n', 's', 'e', '>'
+       };
 
        //Check Param Buffer
        IF_TRUE_RETURN(pszXML == NULL, TADC_PARAMETER_ERROR);
@@ -850,23 +856,22 @@ int TADC_GetResponseROInfo(IN LPBYTE pszXML,  T_RO *t_RO)
        TADC_IF_MemSet(t_RO, 0, sizeof(T_RO));
        TADC_IF_MemSet(TempVersion, 0, sizeof(TempVersion));
 
-       if (TADC_IF_MemCmp((char*)pszXML, pRoHeader, 36))
-       {
+       if (TADC_IF_MemCmp((char *)pszXML, pRoHeader, 36)) {
                DRM_TAPPS_EXCEPTION("TADC_IF_MemCmp Error Code = %x", TADC_XMLPARSER_ERROR);
                return -1;
        }
 
        // Verify the signature ( 2011.03.08, Joseph Ahn )
        nResult = TADC_VerifyROSignature(pszXML);
-       if (nResult != 0)
-       {
+
+       if (nResult != 0) {
                DRM_TAPPS_EXCEPTION("TADC_VerifyROSignature Error Code = %x", nResult);
                return -1;
        }
 
        nResult = oXMLFile.LoadFromStream((LPCTSTR)pszXML);
-       if (nResult < 0)
-       {
+
+       if (nResult < 0) {
                DRM_TAPPS_EXCEPTION("oXMLFile.LoadFromStream is failed\n");
                nResult = -1;
                goto finish;
@@ -874,83 +879,81 @@ int TADC_GetResponseROInfo(IN LPBYTE pszXML,  T_RO *t_RO)
 
        // Set Version
        pRoot = oXMLFile.GetRoot();
-       if (pRoot == NULL)
-       {
+
+       if (pRoot == NULL) {
                DRM_TAPPS_EXCEPTION("oXMLFile.GetRoot is failed\n");
                nResult = -1;
                goto finish;
        }
 
        paChilds.RemoveAll();
-       nResult = pRoot->Find( &paChilds, _T("ContentInfo"), _T("cid"), NULL);
-       if (nResult != 0)
-       {
+       nResult = pRoot->Find(&paChilds, _T("ContentInfo"), _T("cid"), NULL);
+
+       if (nResult != 0) {
                DRM_TAPPS_EXCEPTION("pRoot->Find is failed\n");
                nResult = -1;
                goto finish;
        }
 
-       if (paChilds.GetCount() != 1)
-       {
+       if (paChilds.GetCount() != 1) {
                DRM_TAPPS_EXCEPTION("paChilds.GetCount() is failed\n");
                nResult = -1;
                goto finish;
        }
 
-       pElement = (CXMLElement*)paChilds.Get(0);
+       pElement = (CXMLElement *)paChilds.Get(0);
        pszValue = pElement->GetValue();
-       if (pszValue == NULL)
-       {
+
+       if (pszValue == NULL) {
                DRM_TAPPS_EXCEPTION("pElement->GetValue() is failed\n");
                nResult = -1;
                goto finish;
        }
 
-       length = TADC_IF_StrLen((char*)pszValue);
-       if (length <= 0 || length > CID_SIZE)
-       {
+       length = TADC_IF_StrLen((char *)pszValue);
+
+       if (length <= 0 || length > CID_SIZE) {
                DRM_TAPPS_EXCEPTION("TADC_IF_StrLen is failed(%d) -  %s\n", length, pszValue);
                nResult = -1;
                goto finish;
        }
 
-       t_RO->t_Content.CID = (TADC_U8*)TADC_IF_Malloc(length + 1); //2011.03.08 ( CID_SIZE -> length )
+       t_RO->t_Content.CID = (TADC_U8 *)TADC_IF_Malloc(length + 1);
        IF_TRUE_GOTO(t_RO->t_Content.CID == NULL, -2);
-       TADC_IF_MemSet(t_RO->t_Content.CID, 0, length + 1); //2011.03.08 ( CID_SIZE -> length )
-       TADC_IF_StrNCpy((CHAR*)t_RO->t_Content.CID, pszValue, length);
+       TADC_IF_MemSet(t_RO->t_Content.CID, 0, length + 1);
+       TADC_IF_StrNCpy((CHAR *)t_RO->t_Content.CID, pszValue, length);
 
        // Get KeyValue (CEK)
        pRoot = oXMLFile.GetRoot();
        IF_TRUE_GOTO(pRoot == NULL, ERROR_INVALID_DATA);
 
        paChilds.RemoveAll();
-       nResult = pRoot->Find( &paChilds, _T("KeyInfo"), _T("CipherValue"), NULL);
+       nResult = pRoot->Find(&paChilds, _T("KeyInfo"), _T("CipherValue"), NULL);
 
        IF_TRUE_GOTO(nResult != 0, ERROR_INVALID_DATA);
        IF_TRUE_GOTO(paChilds.GetCount() != 1, ERROR_INVALID_DATA);
 
-       pElement = (CXMLElement*)paChilds.Get(0);
+       pElement = (CXMLElement *)paChilds.Get(0);
        pszValue = pElement->GetValue();
        IF_TRUE_GOTO(pszValue == NULL, -2);
 
        pbBuffer = Base64Decode(pszValue, &length);
-       if (pbBuffer == NULL)
-       {
+
+       if (pbBuffer == NULL) {
                DRM_TAPPS_EXCEPTION("TADC_IF_MemCmp Error Code = %x", TADC_XMLPARSER_ERROR);
                return -1;
        }
 
-       if (length <= 0 || length > CEK_SIZE)
-       {
+       if (length <= 0 || length > CEK_SIZE) {
                TADC_IF_Free(pbBuffer);
                pbBuffer = NULL;
                nResult = -1;
                goto finish;
        }
 
-       t_RO->t_Content.CEK = (TADC_U8*)TADC_IF_Malloc(length + 1); //2011.03.08 ( CEK_SIZE -> length )
+       t_RO->t_Content.CEK = (TADC_U8 *)TADC_IF_Malloc(length + 1);
        IF_TRUE_GOTO(t_RO->t_Content.CEK == NULL, -2);
-       TADC_IF_MemSet(t_RO->t_Content.CEK, 0, length + 1); //2011.03.08 ( CEK_SIZE -> length )
+       TADC_IF_MemSet(t_RO->t_Content.CEK, 0, length + 1);
        TADC_IF_MemCpy(t_RO->t_Content.CEK, pbBuffer, length);
 
        TADC_IF_Free(pbBuffer);
@@ -961,34 +964,33 @@ int TADC_GetResponseROInfo(IN LPBYTE pszXML,  T_RO *t_RO)
        IF_TRUE_GOTO(pRoot == NULL, ERROR_INVALID_DATA);
 
        paChilds.RemoveAll();
-       nResult = pRoot->Find( &paChilds, _T("DeviceInfo"), _T("DUID"), NULL);
+       nResult = pRoot->Find(&paChilds, _T("DeviceInfo"), _T("DUID"), NULL);
 
        IF_TRUE_GOTO(nResult != 0, ERROR_INVALID_DATA);
        IF_TRUE_GOTO(paChilds.GetCount() != 1, ERROR_INVALID_DATA);
 
-       pElement = (CXMLElement*)paChilds.Get(0);
+       pElement = (CXMLElement *)paChilds.Get(0);
        pszValue = pElement->GetValue();
        IF_TRUE_GOTO(pszValue == NULL, -1);
-       length = TADC_IF_StrLen((char*)pszValue);
-       if (length <= 0)
-       {
+       length = TADC_IF_StrLen((char *)pszValue);
+
+       if (length <= 0) {
                nResult = -1;
                goto finish;
        }
 
        t_RO->PerFlag |= DUID_RULE;
        t_RO->t_Permission.t_Individual.BindingType |= DUID_RULE;
-       t_RO->t_Permission.t_Individual.DUID = (TADC_U8*)TADC_IF_Malloc(length + 1);
+       t_RO->t_Permission.t_Individual.DUID = (TADC_U8 *)TADC_IF_Malloc(length + 1);
 
-       if (t_RO->t_Permission.t_Individual.DUID == NULL)
-       {
+       if (t_RO->t_Permission.t_Individual.DUID == NULL) {
                DRM_TAPPS_EXCEPTION("TADC_IF_MemCmp Error Code = %x", TADC_MEMAlOC_ERROR);
                nResult = -2;
                goto finish;
        }
 
        TADC_IF_MemSet(t_RO->t_Permission.t_Individual.DUID, 0, length + 1);
-       TADC_IF_MemCpy((CHAR*)t_RO->t_Permission.t_Individual.DUID, pszValue, length);
+       TADC_IF_MemCpy((CHAR *)t_RO->t_Permission.t_Individual.DUID, pszValue, length);
 
        nResult = 0;
 
@@ -996,24 +998,20 @@ finish:
        pszValue = NULL;
 
        if (nResult < 0)
-       {
                DRM_TAPPS_EXCEPTION("TADC_IF_MemCmp Error Code = %x", TADC_XMLPARSER_ERROR);
-       }
 
        if (nResult == -2)
-       {
                DRM_TAPPS_EXCEPTION("TADC_IF_MemCmp Error Code = %x", TADC_MEMAlOC_ERROR);
-       }
 
        TADC_IF_Free(pbBuffer);
 
        return nResult;
 }
 
-int TADC_GetFileHeader(unsigned char * inBuffer,  T_FILE_HEADER *t_FileHeader)
+int TADC_GetFileHeader(unsigned char *inBuffer,  T_FILE_HEADER *t_FileHeader)
 {
        int i = 0;
-       BYTE FixedFileType[8] = {0x00,0x00,0x00,0x14,0x66,0x74,0x79,0x70};
+       BYTE FixedFileType[8] = {0x00, 0x00, 0x00, 0x14, 0x66, 0x74, 0x79, 0x70};
        char tmp[2];
 
        //Check Param Bufffer
@@ -1024,70 +1022,73 @@ int TADC_GetFileHeader(unsigned char * inBuffer,  T_FILE_HEADER *t_FileHeader)
        TADC_IF_MemSet(t_FileHeader, 0, sizeof(T_FILE_HEADER));
        TADC_IF_MemSet(tmp, 0, sizeof(tmp));
 
-       if (TADC_IF_MemCmp(inBuffer, FixedFileType, sizeof(FixedFileType)))
-       {
-               DRM_TAPPS_EXCEPTION("TADC_IF_MemCmp Error Code = %x", TADC_CONTENTSSTRUCT_ERROR);
+       if (TADC_IF_MemCmp(inBuffer, FixedFileType, sizeof(FixedFileType))) {
+               DRM_TAPPS_EXCEPTION("TADC_IF_MemCmp Error Code = %x",
+                                                       TADC_CONTENTSSTRUCT_ERROR);
                return -1;
        }
+
        i += 8;
 
-       if (TADC_IF_MemCmp(inBuffer+i, "TADF", 4))
-       {
-               DRM_TAPPS_EXCEPTION("TADC_IF_MemCmp Error Code = %x", TADC_CONTENTSSTRUCT_ERROR);
+       if (TADC_IF_MemCmp(inBuffer + i, "TADF", 4)) {
+               DRM_TAPPS_EXCEPTION("TADC_IF_MemCmp Error Code = %x",
+                                                       TADC_CONTENTSSTRUCT_ERROR);
                return -2;
        }
+
        i += 4;
 
        t_FileHeader->Version[0] = '1';
        t_FileHeader->Version[1] = '0';
        i += 4;
 
-       if (TADC_IF_MemCmp(inBuffer+i, "TADF", 4))
-       {
-               DRM_TAPPS_EXCEPTION("TADC_IF_MemCmp Error Code = %x", TADC_CONTENTSSTRUCT_ERROR);
+       if (TADC_IF_MemCmp(inBuffer + i, "TADF", 4)) {
+               DRM_TAPPS_EXCEPTION("TADC_IF_MemCmp Error Code = %x",
+                                                       TADC_CONTENTSSTRUCT_ERROR);
                return -2;
        }
+
        i += 4;
 
        t_FileHeader->DRMType = inBuffer[i];
        i += 1;
 
-       TADC_IF_MemCpy(t_FileHeader->ContentsType, inBuffer+i, 128);
+       TADC_IF_MemCpy(t_FileHeader->ContentsType, inBuffer + i, 128);
        i += 128;
 
-       TADC_IF_MemCpy(&t_FileHeader->TotalSize, inBuffer+i, 8);
+       TADC_IF_MemCpy(&t_FileHeader->TotalSize, inBuffer + i, 8);
        i += 8;
        t_FileHeader->TotalSize = _hton64(t_FileHeader->TotalSize);
 
-       TADC_IF_MemCpy(&t_FileHeader->Offset1, inBuffer+i, 8);
+       TADC_IF_MemCpy(&t_FileHeader->Offset1, inBuffer + i, 8);
        i += 8;
        t_FileHeader->Offset1 = _hton64(t_FileHeader->Offset1);
 
-       TADC_IF_MemCpy(&t_FileHeader->Offset2, inBuffer+i, 8);
+       TADC_IF_MemCpy(&t_FileHeader->Offset2, inBuffer + i, 8);
        i += 8;
        t_FileHeader->Offset2 = _hton64(t_FileHeader->Offset2);
 
-       TADC_IF_MemCpy(&t_FileHeader->Offset3, inBuffer+i, 8);
+       TADC_IF_MemCpy(&t_FileHeader->Offset3, inBuffer + i, 8);
        i += 8;
        t_FileHeader->Offset3 = _hton64(t_FileHeader->Offset3);
 
-       TADC_IF_MemCpy(&t_FileHeader->Offset4, inBuffer+i, 8);
+       TADC_IF_MemCpy(&t_FileHeader->Offset4, inBuffer + i, 8);
        i += 8;
        t_FileHeader->Offset4 = _hton64(t_FileHeader->Offset4);
 
-       TADC_IF_MemCpy(&t_FileHeader->Offset5, inBuffer+i, 8);
+       TADC_IF_MemCpy(&t_FileHeader->Offset5, inBuffer + i, 8);
        i += 8;
        t_FileHeader->Offset5 = _hton64(t_FileHeader->Offset5);
 
-       TADC_IF_MemCpy(&t_FileHeader->Offset6, inBuffer+i, 8);
+       TADC_IF_MemCpy(&t_FileHeader->Offset6, inBuffer + i, 8);
        i += 8;
        t_FileHeader->Offset6 = _hton64(t_FileHeader->Offset6);
 
-       TADC_IF_MemCpy(&t_FileHeader->Offset7, inBuffer+i, 8);
+       TADC_IF_MemCpy(&t_FileHeader->Offset7, inBuffer + i, 8);
        i += 8;
        t_FileHeader->Offset7 = _hton64(t_FileHeader->Offset7);
 
-       TADC_IF_MemCpy(&t_FileHeader->Offset8, inBuffer+i, 8);
+       TADC_IF_MemCpy(&t_FileHeader->Offset8, inBuffer + i, 8);
        i += 8;
        t_FileHeader->Offset8 = _hton64(t_FileHeader->Offset8);
 
@@ -1095,7 +1096,7 @@ int TADC_GetFileHeader(unsigned char * inBuffer,  T_FILE_HEADER *t_FileHeader)
        return 0;
 }
 
-int TADC_GetDRMHeader(unsigned char * inBuffer, T_DRM_HEADER *t_DRMHeader)
+int TADC_GetDRMHeader(unsigned char *inBuffer, T_DRM_HEADER *t_DRMHeader)
 {
        int i = 0;
 
@@ -1106,17 +1107,17 @@ int TADC_GetDRMHeader(unsigned char * inBuffer, T_DRM_HEADER *t_DRMHeader)
        //Init
        TADC_IF_MemSet(t_DRMHeader, 0, sizeof(T_DRM_HEADER));
 
-       if (TADC_IF_MemCmp(inBuffer, "TIZEN_DRM", 9))
-       {
+       if (TADC_IF_MemCmp(inBuffer, "TIZEN_DRM", 9)) {
                DRM_TAPPS_EXCEPTION("TADC_IF_MemCmp Error Code = %x", TADC_NOTTADCFILE_ERROR);
                return -1;
        }
+
        i += 9;
 
-       TADC_IF_MemCpy(t_DRMHeader->Version, inBuffer+i, 2);
+       TADC_IF_MemCpy(t_DRMHeader->Version, inBuffer + i, 2);
        i += 2;
 
-       TADC_IF_MemCpy(&t_DRMHeader->XmlSize, inBuffer+i, 4);
+       TADC_IF_MemCpy(&t_DRMHeader->XmlSize, inBuffer + i, 4);
        i += 4;
 
        t_DRMHeader->XmlSize = htonl_(t_DRMHeader->XmlSize);
@@ -1125,51 +1126,51 @@ int TADC_GetDRMHeader(unsigned char * inBuffer, T_DRM_HEADER *t_DRMHeader)
        return 0;
 }
 
-int TADC_GetDRMHeaderInfo(unsigned char * inBuffer, T_DRM_HEADER *t_DRMHeader)
+int TADC_GetDRMHeaderInfo(unsigned char *inBuffer, T_DRM_HEADER *t_DRMHeader)
 {
        int nResult = 0;
        CXMLFile oXMLFile;
-       CXMLElementpRoot, *pNode;
+       CXMLElement *pRoot, *pNode;
        CPointerArray paChilds;
        LPCTSTR pszValue;
 
        BYTE sha1_tmp[20];
-       unsigned char *ReqTemp=NULL;
+       unsigned char *ReqTemp = NULL;
 
        TADC_U8 key[16];
        TADC_U8 iv[16];
 
-       int outlen=0;
-       long Length=0;
+       int outlen = 0;
+       long Length = 0;
 
        //Check Param
        IF_TRUE_RETURN(inBuffer == NULL, TADC_PARAMETER_ERROR);
        IF_TRUE_RETURN(t_DRMHeader == NULL, TADC_PARAMETER_ERROR);
 
-       IF_TRUE_RETURN(t_DRMHeader->XmlSize <= 0 || t_DRMHeader->XmlSize > ROXML_MAXSIZE, TADC_PARAMETER_ERROR);
+       IF_TRUE_RETURN(t_DRMHeader->XmlSize <= 0 ||
+                                  t_DRMHeader->XmlSize > ROXML_MAXSIZE, TADC_PARAMETER_ERROR);
 
-       ReqTemp = (TADC_U8*)TADC_IF_Malloc(t_DRMHeader->XmlSize);
+       ReqTemp = (TADC_U8 *)TADC_IF_Malloc(t_DRMHeader->XmlSize);
        IF_TRUE_RETURN(ReqTemp == NULL, TADC_MEMAlOC_ERROR);
 
        TADC_IF_MemSet(ReqTemp, 0, t_DRMHeader->XmlSize);
-       TADC_IF_MemSet(sha1_tmp, 0, sizeof(sha1_tmp)  );
+       TADC_IF_MemSet(sha1_tmp, 0, sizeof(sha1_tmp));
 
        //Get HMAC
        TADC_IF_MemCpy(ReqTemp, inBuffer + 20, t_DRMHeader->XmlSize);
        TADC_IF_SHA1(ReqTemp, t_DRMHeader->XmlSize, sha1_tmp);
 
-       if (ReqTemp != NULL)
-       {
+       if (ReqTemp != NULL) {
                TADC_IF_Free(ReqTemp);
                ReqTemp = NULL;
        }
 
        TADC_IF_MemCpy(key, &g_baSignatureKey[0], 16);
        TADC_IF_MemCpy(iv, &g_baSignatureKey[16], 16);
-       TADC_IF_AES_CTR(key, 16, iv, 20, (unsigned char*)sha1_tmp, &outlen, (unsigned char*)sha1_tmp);
+       TADC_IF_AES_CTR(key, 16, iv, 20, (unsigned char *)sha1_tmp, &outlen,
+                                       (unsigned char *)sha1_tmp);
 
-       if (TADC_IF_MemCmp(sha1_tmp, inBuffer, sizeof(sha1_tmp)))
-       {
+       if (TADC_IF_MemCmp(sha1_tmp, inBuffer, sizeof(sha1_tmp))) {
                DRM_TAPPS_EXCEPTION("TADC_IF_MemCmp Error Code = %x", TADC_CONTENTSHMAC_ERROR);
                return -1;
        }
@@ -1177,56 +1178,49 @@ int TADC_GetDRMHeaderInfo(unsigned char * inBuffer, T_DRM_HEADER *t_DRMHeader)
        //Load XML Header
        nResult = oXMLFile.LoadFromStream((LPCTSTR)(inBuffer + 20));
 
-       if (nResult != 0)
-       {
+       if (nResult != 0) {
                DRM_TAPPS_EXCEPTION("TADC_IF_MemCmp Error Code = %x", TADC_CONTENTSXML_ERROR);
                goto finish;
        }
 
        pRoot = oXMLFile.GetRoot();
-       IF_TRUE_GOTO( pRoot == NULL, ERROR_INVALID_DATA );
+       IF_TRUE_GOTO(pRoot == NULL, ERROR_INVALID_DATA);
 
        paChilds.RemoveAll();
-       nResult = pRoot->Find( &paChilds, _T("SID"), NULL );
+       nResult = pRoot->Find(&paChilds, _T("SID"), NULL);
 
-       if (nResult == 0)
-       {
-               if (paChilds.GetCount() == 1)
-               {
-                       pNode = (CXMLElement*)paChilds.Get(0);
+       if (nResult == 0) {
+               if (paChilds.GetCount() == 1) {
+                       pNode = (CXMLElement *)paChilds.Get(0);
                        pszValue = pNode->GetValue();
-                       Length = TADC_IF_StrLen((char*)pszValue);
+                       Length = TADC_IF_StrLen((char *)pszValue);
 
-                       if (Length > 0)
-                       {
-                               t_DRMHeader->SID = (TADC_U8*)TADC_IF_Malloc(Length + 1);
+                       if (Length > 0) {
+                               t_DRMHeader->SID = (TADC_U8 *)TADC_IF_Malloc(Length + 1);
                                IF_TRUE_RETURN(t_DRMHeader->SID == NULL, TADC_MEMAlOC_ERROR);
                                TADC_IF_MemSet(t_DRMHeader->SID, 0, Length + 1);
-                               TADC_IF_StrNCpy((CHAR*)t_DRMHeader->SID, pszValue, Length);
+                               TADC_IF_StrNCpy((CHAR *)t_DRMHeader->SID, pszValue, Length);
                        }
                }
        }
 
        pRoot = oXMLFile.GetRoot();
-       IF_TRUE_GOTO( pRoot == NULL, ERROR_INVALID_DATA );
+       IF_TRUE_GOTO(pRoot == NULL, ERROR_INVALID_DATA);
 
        paChilds.RemoveAll();
-       nResult = pRoot->Find( &paChilds, _T("CID"), NULL );
+       nResult = pRoot->Find(&paChilds, _T("CID"), NULL);
 
-       if (nResult == 0)
-       {
-               if (paChilds.GetCount() == 1)
-               {
-                       pNode = (CXMLElement*)paChilds.Get(0);
+       if (nResult == 0) {
+               if (paChilds.GetCount() == 1) {
+                       pNode = (CXMLElement *)paChilds.Get(0);
                        pszValue = pNode->GetValue();
-                       Length = TADC_IF_StrLen((char*)pszValue); //2011.03.08
+                       Length = TADC_IF_StrLen((char *)pszValue);
 
-                       if (Length > 0)
-                       {
-                               t_DRMHeader->CID = (TADC_U8*)TADC_IF_Malloc(Length + 1); //2011.03.08 ( CID_SIZE -> Length )
+                       if (Length > 0) {
+                               t_DRMHeader->CID = (TADC_U8 *)TADC_IF_Malloc(Length + 1);
                                IF_TRUE_RETURN(t_DRMHeader->CID == NULL, TADC_MEMAlOC_ERROR);
-                               TADC_IF_MemSet(t_DRMHeader->CID, 0, Length + 1); //2011.03.08 ( CID_SIZE -> Length )
-                               TADC_IF_StrNCpy((CHAR*)t_DRMHeader->CID, pszValue, Length); //2011.03.08 ( CID_SIZE -> Length )
+                               TADC_IF_MemSet(t_DRMHeader->CID, 0, Length + 1);
+                               TADC_IF_StrNCpy((CHAR *)t_DRMHeader->CID, pszValue, Length);
                        }
                }
        }
@@ -1236,148 +1230,133 @@ int TADC_GetDRMHeaderInfo(unsigned char * inBuffer, T_DRM_HEADER *t_DRMHeader)
        paChilds.RemoveAll();
        nResult = pRoot->Find(&paChilds, _T("ContentType"), NULL);
 
-       if (nResult == 0)
-       {
-               if (paChilds.GetCount() == 1)
-               {
-                       pNode = (CXMLElement*)paChilds.Get(0);
+       if (nResult == 0) {
+               if (paChilds.GetCount() == 1) {
+                       pNode = (CXMLElement *)paChilds.Get(0);
                        pszValue = pNode->GetValue();
-                       Length = TADC_IF_StrLen((char*)pszValue);
+                       Length = TADC_IF_StrLen((char *)pszValue);
                        TADC_IF_MemSet(t_DRMHeader->ContentsType, 0, 128);
-                       TADC_IF_StrNCpy((CHAR*)t_DRMHeader->ContentsType, pszValue, Length);
+                       TADC_IF_StrNCpy((CHAR *)t_DRMHeader->ContentsType, pszValue, Length);
                }
        }
 
        pRoot = oXMLFile.GetRoot();
-       IF_TRUE_GOTO( pRoot == NULL, ERROR_INVALID_DATA );
+       IF_TRUE_GOTO(pRoot == NULL, ERROR_INVALID_DATA);
        paChilds.RemoveAll();
-       nResult = pRoot->Find( &paChilds, _T("EncryptionMethod"), NULL );
+       nResult = pRoot->Find(&paChilds, _T("EncryptionMethod"), NULL);
 
-       if (nResult == 0)
-       {
-               if (paChilds.GetCount() == 1)
-               {
-                       pNode = (CXMLElement*)paChilds.Get(0);
+       if (nResult == 0) {
+               if (paChilds.GetCount() == 1) {
+                       pNode = (CXMLElement *)paChilds.Get(0);
                        pszValue = pNode->GetValue();
-                       t_DRMHeader->EncryptionMethod = TADC_IF_AtoI((char*)pszValue);
+                       t_DRMHeader->EncryptionMethod = TADC_IF_AtoI((char *)pszValue);
                }
        }
 
        pRoot = oXMLFile.GetRoot();
-       IF_TRUE_GOTO( pRoot == NULL, ERROR_INVALID_DATA );
+       IF_TRUE_GOTO(pRoot == NULL, ERROR_INVALID_DATA);
        paChilds.RemoveAll();
-       nResult = pRoot->Find( &paChilds, _T("EncryptionLevel"), NULL );
+       nResult = pRoot->Find(&paChilds, _T("EncryptionLevel"), NULL);
 
-       if (nResult == 0)
-       {
-               if (paChilds.GetCount() == 1)
-               {
-                       pNode = (CXMLElement*)paChilds.Get(0);
+       if (nResult == 0) {
+               if (paChilds.GetCount() == 1) {
+                       pNode = (CXMLElement *)paChilds.Get(0);
                        pszValue = pNode->GetValue();
-                       t_DRMHeader->EncryptionLevel = TADC_IF_AtoI((char*)pszValue);
+                       t_DRMHeader->EncryptionLevel = TADC_IF_AtoI((char *)pszValue);
                }
        }
 
        pRoot = oXMLFile.GetRoot();
-       IF_TRUE_GOTO( pRoot == NULL, ERROR_INVALID_DATA );
+       IF_TRUE_GOTO(pRoot == NULL, ERROR_INVALID_DATA);
        paChilds.RemoveAll();
-       nResult = pRoot->Find( &paChilds, _T("EncryptionRange"), NULL );
+       nResult = pRoot->Find(&paChilds, _T("EncryptionRange"), NULL);
 
-       if (nResult == 0)
-       {
-               if (paChilds.GetCount() == 1)
-               {
-                       pNode = (CXMLElement*)paChilds.Get(0);
+       if (nResult == 0) {
+               if (paChilds.GetCount() == 1) {
+                       pNode = (CXMLElement *)paChilds.Get(0);
                        pszValue = pNode->GetValue();
-                       t_DRMHeader->EncryptionRange = TADC_IF_AtoI((char*)pszValue);
+                       t_DRMHeader->EncryptionRange = TADC_IF_AtoI((char *)pszValue);
                }
        }
 
        pRoot = oXMLFile.GetRoot();
-       IF_TRUE_GOTO( pRoot == NULL, ERROR_INVALID_DATA );
+       IF_TRUE_GOTO(pRoot == NULL, ERROR_INVALID_DATA);
        paChilds.RemoveAll();
-       nResult = pRoot->Find( &paChilds, _T("RIURL"), NULL );
+       nResult = pRoot->Find(&paChilds, _T("RIURL"), NULL);
 
-       if (nResult == 0)
-       {
-               if (paChilds.GetCount() == 1)
-               {
-                       pNode = (CXMLElement*)paChilds.Get(0);
+       if (nResult == 0) {
+               if (paChilds.GetCount() == 1) {
+                       pNode = (CXMLElement *)paChilds.Get(0);
                        pszValue = pNode->GetValue();
-                       Length = TADC_IF_StrLen((char*)pszValue);
+                       Length = TADC_IF_StrLen((char *)pszValue);
 
-                       if (Length > 0)
-                       {
-                               t_DRMHeader->RIURL = (TADC_U8*)TADC_IF_Malloc(Length+1);
+                       if (Length > 0) {
+                               t_DRMHeader->RIURL = (TADC_U8 *)TADC_IF_Malloc(Length + 1);
                                IF_TRUE_RETURN(t_DRMHeader->RIURL == NULL, TADC_MEMAlOC_ERROR);
-                               TADC_IF_MemSet(t_DRMHeader->RIURL, 0, Length+1);
-                               TADC_IF_StrNCpy((CHAR*)t_DRMHeader->RIURL, pszValue, Length);
+                               TADC_IF_MemSet(t_DRMHeader->RIURL, 0, Length + 1);
+                               TADC_IF_StrNCpy((CHAR *)t_DRMHeader->RIURL, pszValue, Length);
                        }
                }
        }
 
        // dummy RIURL(DRM Server spec changed)
-       if (t_DRMHeader->RIURL == NULL)
-       {
+       if (t_DRMHeader->RIURL == NULL) {
                pszValue = "dummy_riurl";
                Length = TADC_IF_StrLen(pszValue);
-               t_DRMHeader->RIURL = (TADC_U8*)TADC_IF_Malloc(Length+1);
+               t_DRMHeader->RIURL = (TADC_U8 *)TADC_IF_Malloc(Length + 1);
                IF_TRUE_RETURN(t_DRMHeader->RIURL == NULL, TADC_MEMAlOC_ERROR);
-               TADC_IF_MemSet(t_DRMHeader->RIURL, 0, Length+1);
-               TADC_IF_StrNCpy((CHAR*)t_DRMHeader->RIURL, pszValue, Length);
+               TADC_IF_MemSet(t_DRMHeader->RIURL, 0, Length + 1);
+               TADC_IF_StrNCpy((CHAR *)t_DRMHeader->RIURL, pszValue, Length);
        }
 
-       DRM_TAPPS_LOG("t_DRMHeader->RIURL = %s\n", (char*)t_DRMHeader->RIURL);
+       DRM_TAPPS_LOG("t_DRMHeader->RIURL = %s\n", (char *)t_DRMHeader->RIURL);
 
        pRoot = oXMLFile.GetRoot();
-       IF_TRUE_GOTO( pRoot == NULL, ERROR_INVALID_DATA );
+       IF_TRUE_GOTO(pRoot == NULL, ERROR_INVALID_DATA);
        paChilds.RemoveAll();
-       nResult = pRoot->Find( &paChilds, _T("PlaintextSize"), NULL );
+       nResult = pRoot->Find(&paChilds, _T("PlaintextSize"), NULL);
 
-       if (nResult == 0)
-       {
-               if (paChilds.GetCount() == 1)
-               {
-                       pNode = (CXMLElement*)paChilds.Get(0);
+       if (nResult == 0) {
+               if (paChilds.GetCount() == 1) {
+                       pNode = (CXMLElement *)paChilds.Get(0);
                        pszValue = pNode->GetValue();
-                       t_DRMHeader->PlaintextSize = TADC_IF_AtoI((char*)pszValue);
+                       t_DRMHeader->PlaintextSize = TADC_IF_AtoI((char *)pszValue);
                }
        }
 
        pRoot = oXMLFile.GetRoot();
-       IF_TRUE_GOTO( pRoot == NULL, ERROR_INVALID_DATA );
+       IF_TRUE_GOTO(pRoot == NULL, ERROR_INVALID_DATA);
        paChilds.RemoveAll();
-       nResult = pRoot->Find( &paChilds, _T("Packdate"), NULL );
+       nResult = pRoot->Find(&paChilds, _T("Packdate"), NULL);
 
-       if (nResult == 0)
-       {
-               if (paChilds.GetCount() == 1)
-               {
-                       pNode = (CXMLElement*)paChilds.Get(0);
+       if (nResult == 0) {
+               if (paChilds.GetCount() == 1) {
+                       pNode = (CXMLElement *)paChilds.Get(0);
                        pszValue = pNode->GetValue();
-                       Length = TADC_IF_StrLen((char*)pszValue);
+                       Length = TADC_IF_StrLen((char *)pszValue);
 
-                       if (Length > 0)
-                       {
-                               t_DRMHeader->Packdate = (TADC_U8*)TADC_IF_Malloc(Length+1);
+                       if (Length > 0) {
+                               t_DRMHeader->Packdate = (TADC_U8 *)TADC_IF_Malloc(Length + 1);
                                IF_TRUE_RETURN(t_DRMHeader->Packdate == NULL, TADC_MEMAlOC_ERROR);
-                               TADC_IF_MemSet(t_DRMHeader->Packdate, 0, Length+1);
-                               TADC_IF_StrNCpy((char*)t_DRMHeader->Packdate, pszValue, Length);
+                               TADC_IF_MemSet(t_DRMHeader->Packdate, 0, Length + 1);
+                               TADC_IF_StrNCpy((char *)t_DRMHeader->Packdate, pszValue, Length);
                        }
                }
        }
 
 finish:
-       if (nResult != 0)
-       {
+
+       if (nResult != 0) {
                DRM_TAPPS_EXCEPTION("TADC_IF_MemCmp Error Code = %x", TADC_CONTENTSXML_ERROR);
-               STACKTRACE( _T( "CNCG20File::_ParseHeader()" ) );
+               STACKTRACE(_T("CNCG20File::_ParseHeader()"));
        }
+
        DRM_TAPPS_LOG("TADC_GetDRMHeaderInfo Success! \n");
        return nResult;
 }
 
-int TADC_GetCEK(T_DEVICE_INFO *t_DeviceInfo, T_RO *t_RODB, T_DRM_HEADER *t_DRMHeader)
+int TADC_GetCEK(T_DEVICE_INFO *t_DeviceInfo, T_RO *t_RODB,
+                               T_DRM_HEADER *t_DRMHeader)
 {
        int length1 = 0;
 
@@ -1388,21 +1367,27 @@ int TADC_GetCEK(T_DEVICE_INFO *t_DeviceInfo, T_RO *t_RODB, T_DRM_HEADER *t_DRMHe
        IF_TRUE_RETURN(t_RODB == NULL, TADC_PARAMETER_ERROR);
        IF_TRUE_RETURN(t_RODB->t_Content.CID == NULL, TADC_PARAMETER_ERROR);
 
-       if(!TADC_IF_StrCmp((char*)t_DRMHeader->CID, (char*)t_RODB->t_Content.CID)) //2011.03.08 ( TADC_IF_MemCmp -> TADC_IF_StrCmp )
-       {
-               if((t_RODB->PerFlag & DUID_RULE) && (t_RODB->t_Permission.t_Individual.BindingType & DUID_RULE))
-               {
-                       IF_TRUE_RETURN(t_RODB->t_Permission.t_Individual.DUID == NULL, TADC_PARAMETER_ERROR);
-                       length1 = TADC_IF_StrLen((char*)t_DeviceInfo->DUID);
-                       DRM_TAPPS_LOG("t_DeviceInfo->DUID = %s, t_RODB->t_Permission.t_Individual.DUID is %s, length1 is %d\n", t_DeviceInfo->DUID, t_RODB->t_Permission.t_Individual.DUID, length1);
-                       /*if(TADC_IF_MemCmp(t_DeviceInfo->DUID, t_RODB->t_Permission.t_Individual.DUID, length1))
-                       {
-                               DRM_TAPPS_EXCEPTION("TADC_IF_MemCmp Error Code = %x", TADC_RULE_DUID_ERROR);
-                               return -1;
-                       } */
+       if (!TADC_IF_StrCmp((char *)t_DRMHeader->CID, (char *)t_RODB->t_Content.CID)) {
+               if ((t_RODB->PerFlag & DUID_RULE) &&
+                               (t_RODB->t_Permission.t_Individual.BindingType & DUID_RULE)) {
+                       IF_TRUE_RETURN(t_RODB->t_Permission.t_Individual.DUID == NULL,
+                                                  TADC_PARAMETER_ERROR);
+                       length1 = TADC_IF_StrLen((char *)t_DeviceInfo->DUID);
+                       DRM_TAPPS_LOG(
+                               "t_DeviceInfo->DUID = %s, "
+                               "t_RODB->t_Permission.t_Individual.DUID is %s, "
+                               "length1 is %d\n",
+                               t_DeviceInfo->DUID, t_RODB->t_Permission.t_Individual.DUID, length1);
+                       /*if (TADC_IF_MemCmp(t_DeviceInfo->DUID,
+                        *                   t_RODB->t_Permission.t_Individual.DUID, length1)) {
+                           DRM_TAPPS_EXCEPTION("TADC_IF_MemCmp Error Code = %x",
+                                               TADC_RULE_DUID_ERROR);
+                           return -1;
+                       }*/
                }
+
                IF_TRUE_RETURN(t_RODB->t_Content.CEK == NULL, TADC_PARAMETER_ERROR);
-               t_DRMHeader->CEK = (TADC_U8*)TADC_IF_Malloc(CEK_SIZE + 1);
+               t_DRMHeader->CEK = (TADC_U8 *)TADC_IF_Malloc(CEK_SIZE + 1);
                IF_TRUE_RETURN(t_DRMHeader->CEK == NULL, TADC_MEMAlOC_ERROR);
                TADC_IF_MemSet(t_DRMHeader->CEK, 0, CEK_SIZE + 1);
                TADC_IF_MemCpy(t_DRMHeader->CEK, t_RODB->t_Content.CEK, CEK_SIZE);
@@ -1416,7 +1401,8 @@ int TADC_GetCEK(T_DEVICE_INFO *t_DeviceInfo, T_RO *t_RODB, T_DRM_HEADER *t_DRMHe
        return -1;
 }
 
-int TADC_DecryptBlock(char *pbBuffer, int nSize, const T_DRM_HEADER *t_DRMHeader)
+int TADC_DecryptBlock(char *pbBuffer, int nSize,
+                                         const T_DRM_HEADER *t_DRMHeader)
 {
        TADC_U8 key[16] = {0, };
        TADC_U8 iv[16] = {0, };
@@ -1443,27 +1429,22 @@ int TADC_DecryptBlock(char *pbBuffer, int nSize, const T_DRM_HEADER *t_DRMHeader
        nEncryptionMethod = t_DRMHeader->EncryptionMethod;
 
        IF_TRUE_RETURN(nEncryptionMethod != 1, TADC_PARAMETER_ERROR);
-       IF_TRUE_RETURN(nEncryptionLevel < 0 || nEncryptionLevel > 32, TADC_PARAMETER_ERROR);
+       IF_TRUE_RETURN(nEncryptionLevel < 0 ||
+                                  nEncryptionLevel > 32, TADC_PARAMETER_ERROR);
 
-       TADC_IF_MemSet( baToBeEncrypted, 1, 32 );
+       TADC_IF_MemSet(baToBeEncrypted, 1, 32);
 
        if (nEncryptionLevel > 16)
-       {
                nBlocks = 16;
-       }
        else
-       {
                nBlocks = nEncryptionLevel;
-       }
 
-       for (i = 0 ; i < nBlocks ; i++)
-       {
+       for (i = 0; i < nBlocks; i++) {
                nIndex = 31 - (i * 2);
                baToBeEncrypted[nIndex] = 0;
        }
 
-       for (i = 16 ; i < nEncryptionLevel ; i++)
-       {
+       for (i = 16; i < nEncryptionLevel; i++) {
                nIndex = 30 - ((i - 16) * 2);
                baToBeEncrypted[nIndex] = 0;
        }
@@ -1474,15 +1455,11 @@ int TADC_DecryptBlock(char *pbBuffer, int nSize, const T_DRM_HEADER *t_DRMHeader
        length = 0;
        totlength = 0;
 
-       for (i = 0 ; i < 32 ; i++)
-       {
+       for (i = 0; i < 32; i++) {
                if (nRemainBytes < 16)
-               {
                        nBlockBytes = nRemainBytes;
-               }
 
-               if (baToBeEncrypted[i] == 1)
-               {
+               if (baToBeEncrypted[i] == 1) {
                        TADC_IF_MemCpy(temp + length, pbBuffer + totlength, nBlockBytes);
                        length += nBlockBytes;
                }
@@ -1491,14 +1468,13 @@ int TADC_DecryptBlock(char *pbBuffer, int nSize, const T_DRM_HEADER *t_DRMHeader
                totlength += nBlockBytes;
 
                if (nRemainBytes < 1)
-               {
                        break;
-               }
        }
 
        TADC_IF_MemCpy(key, &t_DRMHeader->CEK[0], 16);
        TADC_IF_MemCpy(iv, &t_DRMHeader->CEK[16], 16);
-       TADC_IF_AES_CTR(key, 16, iv, length, (unsigned char*)temp, &length, (unsigned char*)temp);
+       TADC_IF_AES_CTR(key, 16, iv, length, (unsigned char *)temp, &length,
+                                       (unsigned char *)temp);
 
        nRemainBytes = nSize;
        nBlockBytes = 16;
@@ -1506,15 +1482,11 @@ int TADC_DecryptBlock(char *pbBuffer, int nSize, const T_DRM_HEADER *t_DRMHeader
        length = 0;
        totlength = 0;
 
-       for (i = 0 ; i < 32 ; i++)
-       {
+       for (i = 0; i < 32; i++) {
                if (nRemainBytes < 16)
-               {
                        nBlockBytes = nRemainBytes;
-               }
 
-               if (baToBeEncrypted[i] == 1)
-               {
+               if (baToBeEncrypted[i] == 1) {
                        TADC_IF_MemCpy(pbBuffer + totlength, temp + length, nBlockBytes);
                        length += nBlockBytes;
                }
@@ -1522,28 +1494,27 @@ int TADC_DecryptBlock(char *pbBuffer, int nSize, const T_DRM_HEADER *t_DRMHeader
                nRemainBytes -= nBlockBytes;
                totlength += nBlockBytes;
 
-               if (nRemainBytes < 1)
-               {
+               if (nRemainBytes < 1) {
                        break;
                }
        }
+
        return 0;
 }
 
-int TADC_GetDRMHeaderFromFile(const char *pTADCFilepath, T_FILE_HEADER *t_FileHeader, T_DRM_HEADER *t_DRMHeader )
+int TADC_GetDRMHeaderFromFile(const char *pTADCFilepath,
+                                                         T_FILE_HEADER *t_FileHeader, T_DRM_HEADER *t_DRMHeader)
 {
-
        unsigned char tempbuf[512];
        unsigned char *pbuf = NULL;
 
-       int ret=0;
-       ULONG readsize=0, ReadLen=0;
+       int ret = 0;
+       ULONG readsize = 0, ReadLen = 0;
 
-       FILE *hFile =  0; //Apps drm file
+       FILE *hFile = 0; //Apps drm file
 
        //null check
-       if (pTADCFilepath == NULL || t_FileHeader == NULL || t_DRMHeader == NULL)
-       {
+       if (pTADCFilepath == NULL || t_FileHeader == NULL || t_DRMHeader == NULL) {
                DRM_TAPPS_EXCEPTION("Error : Parameter Null.");
                return -1;
        }
@@ -1552,8 +1523,7 @@ int TADC_GetDRMHeaderFromFile(const char *pTADCFilepath, T_FILE_HEADER *t_FileHe
        TADC_IF_MemSet(tempbuf, 0, sizeof(tempbuf));
 
        //File Open
-       if ((hFile = fopen(pTADCFilepath, "rb")) == NULL)
-       {
+       if ((hFile = fopen(pTADCFilepath, "rb")) == NULL) {
                DRM_TAPPS_EXCEPTION("Error : fopen() error.");
                return -1;
        }
@@ -1562,55 +1532,57 @@ int TADC_GetDRMHeaderFromFile(const char *pTADCFilepath, T_FILE_HEADER *t_FileHe
 
        //FmReadFile(hFile, tempbuf, readsize, &ReadLen);
        ReadLen = fread(tempbuf, 1, readsize, hFile);
-       if ((readsize != ReadLen) || (ret=TADC_GetFileHeader(tempbuf, t_FileHeader)) < 0)
-       {
+
+       if ((readsize != ReadLen) ||
+                       (ret = TADC_GetFileHeader(tempbuf, t_FileHeader)) < 0) {
                DRM_TAPPS_EXCEPTION("Error : fread() error.");
                fclose(hFile);
                return -1;
        }
+
        TADC_IF_MemSet(tempbuf, 0, sizeof(tempbuf));
 
        //Tizen Apps DRM Type Check
-       if (t_FileHeader->DRMType & TIZEN_DRM)
-       {
+       if (t_FileHeader->DRMType & TIZEN_DRM) {
                DRM_TAPPS_LOG("It's a TAPPS DCF = %s", pTADCFilepath);
                readsize = 15;
                ReadLen = fread(tempbuf, 1, readsize, hFile);
-               if ((readsize != ReadLen) || (ret=TADC_GetDRMHeader(tempbuf, t_DRMHeader)) < 0)
-               {
+
+               if ((readsize != ReadLen) ||
+                               (ret = TADC_GetDRMHeader(tempbuf, t_DRMHeader)) < 0) {
                        DRM_TAPPS_EXCEPTION("Error : fread() error.");
                        fclose(hFile);
                        return -1;
                }
 
                readsize = 20 + t_DRMHeader->XmlSize;
-               if ((pbuf = (unsigned char*)TADC_IF_Malloc( readsize * sizeof(char))) == NULL) 
-               {
+
+               pbuf = (unsigned char *)TADC_IF_Malloc(readsize * sizeof(char));
+
+               if (pbuf == NULL) {
                        DRM_TAPPS_EXCEPTION("Error : fread() error.");
                        fclose(hFile);
                        return -1;
                }
 
                ReadLen = fread(pbuf, 1, readsize, hFile);
-               if (readsize != ReadLen)
-               {
+
+               if (readsize != ReadLen) {
                        DRM_TAPPS_EXCEPTION("Error : fread() error.");
                        TADC_IF_Free(pbuf);
                        fclose(hFile);
                        return -1;
                }
 
-               if (TADC_GetDRMHeaderInfo(pbuf, t_DRMHeader) < 0)
-               {
+               if (TADC_GetDRMHeaderInfo(pbuf, t_DRMHeader) < 0) {
                        DRM_TAPPS_EXCEPTION("Error : TADC_GetDRMHeaderInfo error.");
                        TADC_IF_Free(pbuf);
                        fclose(hFile);
                        return -1;
                }
+
                TADC_IF_Free(pbuf);
-       }
-       else
-       {
+       } else {
                DRM_TAPPS_EXCEPTION("Error : It's not a TApps DCF file.");
                fclose(hFile);
                return -1;
@@ -1633,20 +1605,17 @@ int TADC_MEMFree_RO(T_RO *t_ro)
        IF_TRUE_RETURN(t_ro == NULL, TADC_PARAMETER_ERROR);
        t_ro->PerFlag = 0;
 
-       if (t_ro->t_Content.CID != NULL)
-       {
+       if (t_ro->t_Content.CID != NULL) {
                TADC_IF_Free(t_ro->t_Content.CID);
                t_ro->t_Content.CID = NULL;
        }
 
-       if (t_ro->t_Content.CEK!= NULL)
-       {
+       if (t_ro->t_Content.CEK != NULL) {
                TADC_IF_Free(t_ro->t_Content.CEK);
                t_ro->t_Content.CEK = NULL;
        }
 
-       if (t_ro->t_Permission.t_Individual.DUID != NULL)
-       {
+       if (t_ro->t_Permission.t_Individual.DUID != NULL) {
                TADC_IF_Free(t_ro->t_Permission.t_Individual.DUID);
                t_ro->t_Permission.t_Individual.DUID = NULL;
        }
@@ -1668,14 +1637,12 @@ int TADC_MEMFree_DRMHeader(T_DRM_HEADER *t_DrmHeader)
        t_DrmHeader->XmlSize = 0;
        TADC_IF_MemSet(t_DrmHeader->Version, 0, sizeof(t_DrmHeader->Version));
 
-       if (t_DrmHeader->SID != NULL)
-       {
+       if (t_DrmHeader->SID != NULL) {
                TADC_IF_Free(t_DrmHeader->SID);
                t_DrmHeader->SID = NULL;
        }
 
-       if (t_DrmHeader->CID != NULL)
-       {
+       if (t_DrmHeader->CID != NULL) {
                TADC_IF_Free(t_DrmHeader->CID);
                t_DrmHeader->CID = NULL;
        }
@@ -1683,24 +1650,23 @@ int TADC_MEMFree_DRMHeader(T_DRM_HEADER *t_DrmHeader)
        TADC_IF_MemSet(t_DrmHeader->ContentsType, 0, sizeof(t_DrmHeader->ContentsType));
        t_DrmHeader->EncryptionRange = 0;
 
-       if (t_DrmHeader->RIURL != NULL)
-       {
+       if (t_DrmHeader->RIURL != NULL) {
                TADC_IF_Free(t_DrmHeader->RIURL);
                t_DrmHeader->RIURL = NULL;
        }
 
        t_DrmHeader->PlaintextSize = 0;
-       if (t_DrmHeader->Packdate != NULL)
-       {
+
+       if (t_DrmHeader->Packdate != NULL) {
                TADC_IF_Free(t_DrmHeader->Packdate);
                t_DrmHeader->Packdate = NULL;
        }
 
-       if (t_DrmHeader->CEK != NULL)
-       {
+       if (t_DrmHeader->CEK != NULL) {
                TADC_IF_Free(t_DrmHeader->CEK);
                t_DrmHeader->CEK = NULL;
        }
+
        return 0;
 }
 
@@ -1708,14 +1674,12 @@ int TADC_MEMFree_ROAcqInfo(T_ROACQ_INFO *t_ROAcqInfo)
 {
        IF_TRUE_RETURN(t_ROAcqInfo == NULL, TADC_PARAMETER_ERROR);
 
-       if (t_ROAcqInfo->ROAcqURL != NULL)
-       {
+       if (t_ROAcqInfo->ROAcqURL != NULL) {
                TADC_IF_Free(t_ROAcqInfo->ROAcqURL);
                t_ROAcqInfo->ROAcqURL = NULL;
        }
 
-       if (t_ROAcqInfo->ReqID != NULL)
-       {
+       if (t_ROAcqInfo->ReqID != NULL) {
                TADC_IF_Free(t_ROAcqInfo->ReqID);
                t_ROAcqInfo->ReqID = NULL;
        }
index 685299d..12b0b75 100644 (file)
 
 unsigned int htons_(unsigned int hostshort)
 {
-       BYTE    *pBuffer;
-       unsigned int    nResult;
+       BYTE *pBuffer;
+       unsigned int nResult;
 
        nResult = 0;
        pBuffer = (LPBYTE)&hostshort;
-       nResult = (((pBuffer[0] << 8) & 0xFF00) | (pBuffer[1] & 0x00FF));
+       nResult = (((pBuffer[0] << 8) & 0xFF00) | (pBuffer[1] & 0x00FF));
 
        return nResult;
 }
 
 DWORD htonl_(DWORD hostlong)
 {
-       DWORD   nResult = hostlong >> 16;
-       unsigned int    upper   = (unsigned int)nResult & 0x0000FFFF;
-       unsigned int    lower   = (unsigned int)hostlong & 0x0000FFFF;
+       DWORD nResult = hostlong >> 16;
+       unsigned int upper = (unsigned int)nResult & 0x0000FFFF;
+       unsigned int lower = (unsigned int)hostlong & 0x0000FFFF;
 
-       upper   = htons_(upper);
-       lower   = htons_(lower);
-    nResult    = 0x10000 * lower + upper;
+       upper = htons_(upper);
+       lower = htons_(lower);
+       nResult = 0x10000 * lower + upper;
 
        return nResult;
 }
 
-INT64 _hton64( INT64 n64host )
+INT64 _hton64(INT64 n64host)
 {
-       INT64   result;
-       LPBYTE   p;
-       short   n64Test;
-       int      n32High, n32Low;
+       INT64 result;
+       LPBYTE p;
+       short n64Test;
+       int n32High, n32Low;
 
-       static int  isLittleEndian = -1;
+       static int isLittleEndian = -1;
 
-       if( isLittleEndian == -1 )
-       {
+       if (isLittleEndian == -1) {
                n64Test = 0x01;
                p = (LPBYTE)&n64Test;
 
-               if( p[ 0 ] == 0x01 )
-               {
+               if (p[0] == 0x01)
                        isLittleEndian = 1;
-               }
                else
-               {
                        isLittleEndian = 0;
-               }
        }
 
-       if( isLittleEndian == 1 )
-       {
-               n32Low = (INT32)( n64host & 0xFFFFFFFF );
-               n32High = (INT32)( n64host >> 32 );
+       if (isLittleEndian == 1) {
+               n32Low = (INT32)(n64host & 0xFFFFFFFF);
+               n32High = (INT32)(n64host >> 32);
 
-               n32Low = htonl_( n32Low );
-               n32High = htonl_( n32High );
+               n32Low = htonl_(n32Low);
+               n32High = htonl_(n32High);
 
-               result = ( (INT64)n32Low << 32 ) | n32High;
+               result = ((INT64)n32Low << 32) | n32High;
                return result;
-       }
-       else
-       {
+       } else {
                return n64host;
        }
 }
index e198fc1..4f08b07 100644 (file)
 
 // -------------------------- Base64 --------------------------------
 static CHAR __base64_table[] = {
-       'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
-       'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
-       'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
-       'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/', '\0'
+       'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
+       'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
+       'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
+       'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
+       'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
+       'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
+       'w', 'x', 'y', 'z', '0', '1', '2', '3',
+       '4', '5', '6', '7', '8', '9', '+', '/',
+       '\0'
 };
 
 static BYTE __reverse_table[256] = {
-       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3e, 0xff, 0xff, 0xff, 0x3f,
-       0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-       0xff, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
-       0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0xff, 0xff, 0xff, 0xff, 0xff,
-       0xff, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28,
-       0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0xff, 0xff, 0xff, 0xff, 0xff,
-       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
+       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+       0xff, 0xff, 0xff, 0x3e, 0xff, 0xff, 0xff, 0x3f,
+       0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b,
+       0x3c, 0x3d, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+       0xff, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
+       0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
+       0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16,
+       0x17, 0x18, 0x19, 0xff, 0xff, 0xff, 0xff, 0xff,
+       0xff, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20,
+       0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28,
+       0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30,
+       0x31, 0x32, 0x33, 0xff, 0xff, 0xff, 0xff, 0xff,
+       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
 };
 
 static CHAR __base64_pad = '=';
 
-LPSTR Base64Encode( LPBYTE pbData,  int nLength )
+LPSTR Base64Encode(LPBYTE pbData,  int nLength)
 {
        int i = 0, result = 0;
        LPSTR pszResult = NULL;
 
        if (nLength <= 0)
-       {
                return NULL;
-       }
-       result = ( ( nLength + 3 - nLength % 3 ) * 4 / 3 + 1 );
 
-       pszResult = (LPSTR)TADC_IF_Malloc( result );
+       result = ((nLength + 3 - nLength % 3) * 4 / 3 + 1);
+
+       pszResult = (LPSTR)TADC_IF_Malloc(result);
 
        if (pszResult == NULL)
-       {
                return NULL;
-       }
 
        TADC_IF_MemSet(pszResult, 0x00, result);
 
        i = 0;
 
-       while (nLength > 2)
-       {
+       while (nLength > 2) {
                /* keep going until we have less than 24 bits */
-               pszResult[ i++ ] = __base64_table[ pbData[ 0 ] >> 2 ];
-               pszResult[ i++ ] = __base64_table[ ( ( pbData[ 0 ] & 0x03 ) << 4 ) + ( pbData[ 1 ] >> 4 ) ];
-               pszResult[ i++ ] = __base64_table[ ( ( pbData[ 1 ] & 0x0f ) << 2 ) + ( pbData[ 2 ] >> 6 ) ];
-               pszResult[ i++ ] = __base64_table[ pbData[ 2 ] & 0x3f ];
+               pszResult[i++] = __base64_table[pbData[0] >> 2];
+               pszResult[i++] = __base64_table[((pbData[0] & 0x03) << 4) +
+                                                                               (pbData[1] >> 4)];
+               pszResult[i++] = __base64_table[((pbData[1] & 0x0f) << 2) +
+                                                                               (pbData[2] >> 6)];
+               pszResult[i++] = __base64_table[pbData[2] & 0x3f];
 
                pbData += 3;
                nLength -= 3; /* we just handle 3 octets of data */
        }
 
        /* now deal with the tail end of things */
-       if (nLength != 0)
-       {
-               pszResult[ i++ ] = __base64_table[ pbData[ 0 ] >> 2 ];
-               if (nLength == 1)
-               {
-                       pszResult[ i++ ] = __base64_table[ ( pbData[ 0 ] & 0x03 ) << 4 ];
-                       pszResult[ i++ ] = __base64_pad;
-                       pszResult[ i++ ] = __base64_pad;
-               }
-               else
-               {
-                       pszResult[ i++ ] = __base64_table[ ( ( pbData[ 0 ] & 0x03 ) << 4 ) + ( pbData[ 1 ] >> 4 ) ];
-                       pszResult[ i++ ] = __base64_table[ ( pbData[ 1 ] & 0x0f ) << 2 ];
-                       pszResult[ i++ ] = __base64_pad;
+       if (nLength != 0) {
+               pszResult[i++] = __base64_table[pbData[0] >> 2];
+
+               if (nLength == 1) {
+                       pszResult[i++] = __base64_table[(pbData[0] & 0x03) << 4];
+                       pszResult[i++] = __base64_pad;
+                       pszResult[i++] = __base64_pad;
+               } else {
+                       pszResult[i++] = __base64_table[((pbData[0] & 0x03) << 4) +
+                                                                                       (pbData[1] >> 4)];
+                       pszResult[i++] = __base64_table[(pbData[1] & 0x0f) << 2];
+                       pszResult[i++] = __base64_pad;
                }
        }
-       pszResult[ i ] = 0;
+
+       pszResult[i] = 0;
        return pszResult;
 }
 
-LPBYTE Base64Decode(LPCSTR pszString, intpnLength)
+LPBYTE Base64Decode(LPCSTR pszString, int *pnLength)
 {
        size_t nStrLength = TADC_IF_StrLen(pszString);
+
        if (nStrLength % 4 != 0)
                return NULL;
 
        LPBYTE pbResult = (LPBYTE)TADC_IF_Malloc(nStrLength + 1);
+
        if (pbResult == NULL)
-                return NULL;
+               return NULL;
 
        TADC_IF_MemSet(pbResult, 0x00, nStrLength + 1);
 
@@ -144,52 +164,43 @@ LPBYTE Base64Decode(LPCSTR pszString, int* pnLength)
 }
 // -------------------------- Base64 --------------------------------]]]]
 
-int HEX2BIN(LPCSTR pszHex, LPBYTE baBin, int* pnLength )
+int HEX2BIN(LPCSTR pszHex, LPBYTE baBin, int *pnLength)
 {
-       CHAR szTemp[ 3 ];
-       CHAR szHex[ 1024 ];
+       CHAR szTemp[3];
+       CHAR szHex[1024];
        int i = 0, nLength = 0;
 
        nLength = TADC_IF_StrLen(pszHex);
 
        if (nLength <= 0)
-       {
                return -1;
-       }
 
-       if ((nLength % 2) == 0)
-       {
+       if ((nLength % 2) == 0) {
                TADC_IF_StrNCpy(szHex, pszHex, nLength);
-       }
-       else
-       {
-               szHex[ 0 ] = '0';
-               TADC_IF_StrNCpy(&szHex[ 1 ], pszHex, nLength);
+       } else {
+               szHex[0] = '0';
+               TADC_IF_StrNCpy(&szHex[1], pszHex, nLength);
                nLength += 1;
        }
 
        *pnLength = nLength / 2;
-       szTemp[ 2 ] = 0;
+       szTemp[2] = 0;
 
-       for (i = 0 ; i < *pnLength ; i++ )
-       {
-               szTemp[ 0 ] = szHex[ i * 2 ];
-               szTemp[ 1 ] = szHex[ i * 2 + 1 ];
-               baBin[ i ] = (BYTE)strtoul( szTemp, NULL, 16 );
+       for (i = 0; i < *pnLength; i++) {
+               szTemp[0] = szHex[i * 2];
+               szTemp[1] = szHex[i * 2 + 1];
+               baBin[i] = (BYTE)strtoul(szTemp, NULL, 16);
        }
+
        return 0;
 }
 
-//Find String (2011.03.08)
 //return : start position of find string or error (-1)
 int FindString(unsigned char *in, int inLen, unsigned char *find, int findLen)
 {
-       int i = 0;
-
-       for (i = 0 ; i <= inLen - findLen ; i++)
-       {
+       for (int i = 0; i <= inLen - findLen; i++)
                if (!TADC_IF_MemCmp(in + i, find, findLen))
-               return i;
-       }
+                       return i;
+
        return -1;
 }
index 43ddacb..0e24e78 100644 (file)
 // limitations under the License.
 //
 
-/**
- * @file               DUIDGenerator.cpp
- * @brief              This is the implementation file for get_id.
- */
-
 #include <stdlib.h>
 #include <string.h>
 #include <device_info.h>
@@ -36,6 +31,7 @@ int get_duid(char **duid)
        }
 
        device_id = get_device_id();
+
        if (device_id == NULL) {
                DRM_TAPPS_EXCEPTION("Failed to generate DUID.");
                return -1;
index ef85b20..6033592 100644 (file)
@@ -49,6 +49,7 @@ int TADC_IF_GetDUID(char *Duid)
        }
 
        char *duid = NULL;
+
        if (get_duid(&duid) < 0 || !duid) {
                DRM_TAPPS_EXCEPTION("Failed to get DUID.");
                return TADC_GETDUID_ERROR;
@@ -68,17 +69,16 @@ int TADC_IF_GetDHKey(T_DH_INFO *t_dhinfo)
        TADC_IF_MemSet(t_dhinfo, 0, sizeof(t_dh_info));
 
        // Debug
-       DRM_TAPPS_LOG("Debug Log == TADC_IF_GetDHKey  : After  TADC_IF_MemSet(t_dhinfo, 0, sizeof(t_dh_info))");
+       DRM_TAPPS_LOG("After TADC_IF_MemSet(t_dhinfo, 0, sizeof(t_dh_info))");
 
        //1. dh new
-       if ((pDH = DH_new()) == NULL)
-       {
+       if ((pDH = DH_new()) == NULL) {
                DRM_TAPPS_EXCEPTION("DH_new() error!");
                return -1;
        }
 
        // Debug
-       DRM_TAPPS_LOG("Debug Log == TADC_IF_GetDHKey  : After DH_new");
+       DRM_TAPPS_LOG("After DH_new");
 
        //2. Set the Prime and Generator Value
        BYTE prime64[64] = {
@@ -88,7 +88,8 @@ int TADC_IF_GetDHKey(T_DH_INFO *t_dhinfo)
                0x44, 0x22, 0xDA, 0x07, 0x32, 0x18, 0xC1, 0xF8, 0xC4, 0xED,
                0x9F, 0x66, 0x88, 0xCF, 0xD6, 0x18, 0x8B, 0x28, 0x56, 0xA5,
                0xB3, 0x6A, 0x8E, 0xBB, 0xC4, 0x2B, 0x2B, 0x3A, 0x9C, 0x20,
-               0x4E, 0xF7, 0x7F, 0xC3 };
+               0x4E, 0xF7, 0x7F, 0xC3
+       };
        BYTE generator[1] = {DH_GENERATOR_5};
 
        pDH->p = BN_bin2bn(prime64, 64, NULL);
@@ -98,17 +99,16 @@ int TADC_IF_GetDHKey(T_DH_INFO *t_dhinfo)
        pDH->flags &= ~DH_FLAG_NO_EXP_CONSTTIME;
 
        // Debug
-       DRM_TAPPS_LOG("Debug Log == TADC_IF_GetDHKey  : After Set the Prime and Generator Value");
+       DRM_TAPPS_LOG("After Set the Prime and Generator Value");
 
        //3. Generate DH Key
-       if (!DH_generate_key(pDH))
-       {
+       if (!DH_generate_key(pDH)) {
                DRM_TAPPS_EXCEPTION("DH_generate_key() error!");
                return -1;
        }
 
        // Debug
-       DRM_TAPPS_LOG("Debug Log == TADC_IF_GetDHKey  : After DH_generate_key");
+       DRM_TAPPS_LOG("After DH_generate_key");
 
        //4. Save DH Infos ( p, g, A, a )
        TADC_IF_MemCpy(t_dhinfo->p, prime64, 64);
@@ -121,7 +121,7 @@ int TADC_IF_GetDHKey(T_DH_INFO *t_dhinfo)
        DH_free(pDH);
 
        // Debug
-       DRM_TAPPS_LOG("Debug Log == TADC_IF_GetDHKey  : After DH_free");
+       DRM_TAPPS_LOG("After DH_free");
 
        return 0;
 }
@@ -139,8 +139,7 @@ int TADC_IF_GetDHKey_K(T_DH_INFO *t_dhinfo)
        TADC_IF_MemSet(tempbuf, 0, sizeof(tempbuf));
 
        //1. dh new
-       if ((pDH = DH_new()) == NULL)
-       {
+       if ((pDH = DH_new()) == NULL) {
                DRM_TAPPS_EXCEPTION("DH_new() error!");
                return -1;
        }
@@ -157,14 +156,12 @@ int TADC_IF_GetDHKey_K(T_DH_INFO *t_dhinfo)
        pPubKey = BN_bin2bn(t_dhinfo->B, t_dhinfo->BSize, NULL);
 
        //4. Compute DH Session Key
-       if ((i = DH_compute_key((BYTE*)tempbuf, pPubKey, pDH)) < 0)
-       {
+       if ((i = DH_compute_key((BYTE *)tempbuf, pPubKey, pDH)) < 0) {
                DRM_TAPPS_EXCEPTION("DH_compute_key() error! \n");
                return -1;
        }
 
-       for (i = 0 ; i < (t_dhinfo -> BSize / 2) ; i++)
-       {
+       for (i = 0; i < (t_dhinfo -> BSize / 2); i++) {
                t_dhinfo->K[i] = tempbuf[i * 2] ^ tempbuf[(i * 2) + 1];
        }
 
@@ -176,7 +173,8 @@ int TADC_IF_GetDHKey_K(T_DH_INFO *t_dhinfo)
 }
 
 /* Only handles 128 bit aes key */
-int TADC_IF_AES_CTR(unsigned char *pKey, int ivLen, unsigned char *pIV, int inLen, unsigned char *in, int *pOutLen, unsigned char *out)
+int TADC_IF_AES_CTR(unsigned char *pKey, int ivLen, unsigned char *pIV,
+                                       int inLen, unsigned char *in, int *pOutLen, unsigned char *out)
 {
        AES_KEY stKey;
        UINT num;
@@ -209,21 +207,21 @@ int TADC_IF_SHA1(unsigned char *in, int inLen, unsigned char *out)
        return 0;
 }
 
-int TADC_IF_VerifySignature(unsigned charinData, int inLen,
-                                                       unsigned charsigData, int sigLen,
-                                                       unsigned charcert, int certLen)
+int TADC_IF_VerifySignature(unsigned char *inData, int inLen,
+                                                       unsigned char *sigData, int sigLen,
+                                                       unsigned char *cert, int certLen)
 {
        unsigned char hashValue[20];
        int iRet = 0;
 
-       X509pX509 = NULL;
-       EVP_PKEYpKey = NULL;
-       RSApRsa = NULL;
+       X509 *pX509 = NULL;
+       EVP_PKEY *pKey = NULL;
+       RSA *pRsa = NULL;
 
        //Check parameters
-       if (inData == NULL || sigData == NULL || cert == NULL || inLen < 1 || sigLen < 1 || certLen < 1)
-       {
-               DRM_TAPPS_EXCEPTION("TADC_IF_VerifySignature Error : Parameter error!");
+       if (inData == NULL || sigData == NULL || cert == NULL || inLen < 1 ||
+                       sigLen < 1 || certLen < 1) {
+               DRM_TAPPS_EXCEPTION("Parameter error!");
                return -1;
        }
 
@@ -233,75 +231,67 @@ int TADC_IF_VerifySignature(unsigned char* inData, int inLen,
        TADC_IF_SHA1(inData, inLen, hashValue);
 
        //2. Get RSA Public Key from cert data ( DER )
-       pX509 = d2i_X509(NULL, (const unsigned char**)&cert, certLen);
-       if (pX509 == NULL)
-       {
-               DRM_TAPPS_EXCEPTION("TADC_IF_VerifySignature Error : Get RSA Public Key from cert data!");
+       pX509 = d2i_X509(NULL, (const unsigned char **)&cert, certLen);
+
+       if (pX509 == NULL) {
+               DRM_TAPPS_EXCEPTION("Get RSA Public Key from cert data!");
                return -1;
        }
 
        pKey = X509_get_pubkey(pX509);
-       if (pKey == NULL)
-       {
-               DRM_TAPPS_EXCEPTION("TADC_IF_VerifySignature Error : X509_get_pubkey!");
+
+       if (pKey == NULL) {
+               DRM_TAPPS_EXCEPTION("X509_get_pubkey!");
                return -1;
        }
 
        pRsa = EVP_PKEY_get1_RSA(pKey);
-       if (pRsa == NULL)
-       {
-               DRM_TAPPS_EXCEPTION("TADC_IF_VerifySignature Error : EVP_PKEY_get1_RSA!");
-               if (NULL != pKey)
-               {
+
+       if (pRsa == NULL) {
+               DRM_TAPPS_EXCEPTION("EVP_PKEY_get1_RSA!");
+
+               if (NULL != pKey) {
                        EVP_PKEY_free(pKey);
                }
+
                return -1;
        }
 
        //3. Verify RSA Sign
        iRet = RSA_verify(NID_sha1, hashValue, 20, sigData, sigLen, pRsa);
-       if (1 != iRet)
-       {
+
+       if (1 != iRet) {
                int err = 0;
-               char tmpBuf[120] = {0,};
+               char tmpBuf[120] = { 0, };
 
                while ((err = ERR_get_error()) != 0)
-               {
-                       DRM_TAPPS_EXCEPTION("TADC_IF_VerifySignature Error : RSA_verify error(%s)", ERR_error_string(err, tmpBuf));
-               }
-               //Error
-               //DRM_TAPPS_EXCEPTION("TADC_IF_VerifySignature Error : RSA_verify error(%s)", ERR_error_string(ERR_get_error(), NULL));
+                       DRM_TAPPS_EXCEPTION("RSA_verify error(%s)", ERR_error_string(err, tmpBuf));
 
                if (NULL != pKey)
-               {
                        EVP_PKEY_free(pKey);
-               }
 
                return -1;
        }
 
-       //free
        if (NULL != pKey)
-       {
                EVP_PKEY_free(pKey);
-       }
 
        return 0;
 }
 
-int AddCertUntrustedCerts(STACK_OF(X509)* untrustedCerts, unsigned char* cert, int certLen)
+int AddCertUntrustedCerts(STACK_OF(X509)* untrustedCerts, unsigned char *cert,
+                                                 int certLen)
 {
-       X509pstX509 = NULL;
+       X509 *pstX509 = NULL;
 
-       if (untrustedCerts == NULL || cert == NULL || certLen < 1)
-       {
+       if (untrustedCerts == NULL || cert == NULL || certLen < 1) {
                DRM_TAPPS_EXCEPTION("AddCertSTORE Error : Parameter error!");
                return -1;
        }
 
        pstX509 = d2i_X509(NULL, (const unsigned char **) &cert, certLen);
-       if (pstX509 == NULL)
-       {
+
+       if (pstX509 == NULL) {
                DRM_TAPPS_EXCEPTION("AddCertSTORE Error : d2i_X509 error!");
                return -1;
        }
@@ -311,24 +301,24 @@ int AddCertUntrustedCerts(STACK_OF(X509)* untrustedCerts, unsigned char* cert, i
        return 0;
 }
 
-int AddCertSTOREFromFile(X509_STORE* pstStore, const char* filePath)
+int AddCertSTOREFromFile(X509_STORE *pstStore, const char *filePath)
 {
-       X509pstX509 = NULL;
-       FILEfile = NULL;
+       X509 *pstX509 = NULL;
+       FILE *file = NULL;
        int ret = 0;
 
        file = fopen(filePath, "r");
-       if(!file)
-       {
-               DRM_TAPPS_EXCEPTION("AddCertSTOREFromFile Error : Parameter error! Fail to open a cert file.");
+
+       if (!file) {
+               DRM_TAPPS_EXCEPTION("Parameter error! Fail to open a cert file.");
                ret = -1;
                goto error;
        }
 
        pstX509 = PEM_read_X509(file, NULL, NULL, NULL);
-       if (pstX509 == NULL)
-       {
-               DRM_TAPPS_EXCEPTION("AddCertSTORE Error : d2i_X509 error!");
+
+       if (pstX509 == NULL) {
+               DRM_TAPPS_EXCEPTION("d2i_X509 error!");
                ret = -1;
                goto error;
        }
@@ -336,12 +326,14 @@ int AddCertSTOREFromFile(X509_STORE* pstStore, const char* filePath)
        X509_STORE_add_cert(pstStore, pstX509);
 
 error:
-       if(file!=NULL)
+
+       if (file != NULL)
                fclose(file);
+
        return ret;
 }
 
-int AddCertSTOREFromDir(X509_STORE* pstStore, const char* dirPath)
+int AddCertSTOREFromDir(X509_STORE *pstStore, const char *dirPath)
 {
        int ret = 0;
 
@@ -351,77 +343,87 @@ int AddCertSTOREFromDir(X509_STORE* pstStore, const char* dirPath)
        int error;
        char file_path_buff[512];
 
-       if (pstStore == NULL || dirPath == NULL)
-       {
-               DRM_TAPPS_EXCEPTION("AddCertSTOREFromDir Error : Parameter error!");
+       if (pstStore == NULL || dirPath == NULL) {
+               DRM_TAPPS_EXCEPTION("Parameter error!");
                ret = -1;
                goto error;
        }
 
        dir = opendir(dirPath);
-       if(dir == NULL) {
-               DRM_TAPPS_EXCEPTION("AddCertSTOREFromDir Error : cannot open directory!");
+
+       if (dir == NULL) {
+               DRM_TAPPS_EXCEPTION("cannot open directory(%s)!", dirPath);
                ret = -1;
                goto error;
        }
 
-       for(;;) {
+       while (true) {
                error = readdir_r(dir, &entry, &result);
-               if( error != 0 ) {
-                       DRM_TAPPS_EXCEPTION("AddCertSTOREFromDir Error : fail to read entries from a directory!");
+
+               if (error != 0) {
+                       DRM_TAPPS_EXCEPTION("fail to read entries from a directory(%s)!", dirPath);
                        ret = -1;
                        goto error;
                }
+
                // readdir_r returns NULL in *result if the end
                // of the directory stream is reached
-               if(result == NULL)
+               if (result == NULL)
                        break;
 
-               if(entry.d_type == DT_REG) { // regular file
+               if (entry.d_type == DT_REG) { // regular file
                        memset(file_path_buff, 0, sizeof(file_path_buff));
-                       snprintf(file_path_buff, sizeof(file_path_buff), "%s/%s", dirPath, entry.d_name);
-                       if(AddCertSTOREFromFile(pstStore, file_path_buff) == 0) {
+                       snprintf(file_path_buff, sizeof(file_path_buff), "%s/%s", dirPath,
+                                        entry.d_name);
+
+                       if (AddCertSTOREFromFile(pstStore, file_path_buff) == 0) {
                                DRM_TAPPS_LOG("Add root cert : file=%s", file_path_buff);
-                       }else {
+                       } else {
                                DRM_TAPPS_LOG("Fail to add root cert : file=%s", file_path_buff);
                        }
                }
        }
 
 error:
-       if(dir!=NULL)
+
+       if (dir != NULL)
                closedir(dir);
+
        return ret;
 }
 
-int TADC_IF_VerifyCertChain(unsigned charrica, int ricaLen,
-                                                       unsigned charcert, int certLen)
+int TADC_IF_VerifyCertChain(unsigned char *rica, int ricaLen,
+                                                       unsigned char *cert, int certLen)
 {
        OpenSSL_add_all_algorithms();
 
        X509_STORE *pstStore = X509_STORE_new();
+
        if (pstStore == NULL)
                return -1;
 
        std::unique_ptr<X509_STORE, void(*)(X509_STORE *)>
-               _scoped_x509_store(pstStore, X509_STORE_free);
+       _scoped_x509_store(pstStore, X509_STORE_free);
 
        STACK_OF(X509) *untrustedCerts = sk_X509_new_null();
+
        if (untrustedCerts == NULL)
                return -1;
 
        std::unique_ptr<STACK_OF(X509), std::function<void(STACK_OF(X509) *)>>
-               _scoped_x509_stack(untrustedCerts, [](STACK_OF(X509) *s) { sk_X509_free(s); });
+       _scoped_x509_stack(untrustedCerts, [](STACK_OF(X509) *s) {
+               sk_X509_free(s);
+       });
 
        //Add RICA Cert to certchain
        if (AddCertUntrustedCerts(untrustedCerts, rica, ricaLen) != 0) {
-               DRM_TAPPS_EXCEPTION("TADC_IF_VerifyCertChain Error : Add RICA Cert to certchain!");
+               DRM_TAPPS_EXCEPTION("Add RICA Cert to certchain!");
                return -1;
        }
 
        //Add Root CA Cert
        if (AddCertSTOREFromDir(pstStore, RO_ISSUER_ROOT_CERTS_DIR) != 0) {
-               DRM_TAPPS_EXCEPTION("TADC_IF_VerifyCertChain Error : Add Root CA Cert!");
+               DRM_TAPPS_EXCEPTION("Add Root CA Cert!");
                return -1;
        }
 
@@ -429,19 +431,20 @@ int TADC_IF_VerifyCertChain(unsigned char* rica, int ricaLen,
        X509 *pstX509 = d2i_X509(NULL, (const unsigned char **)&cert, certLen);
 
        if (pstX509 == NULL) {
-               DRM_TAPPS_EXCEPTION("TADC_IF_VerifyCertChain Error : Get Cert d2i_X509 error!");
+               DRM_TAPPS_EXCEPTION("Get Cert d2i_X509 error!");
                return -1;
        }
 
        X509_STORE_set_flags(pstStore, X509_V_FLAG_CB_ISSUER_CHECK);
        X509_STORE_CTX *pstStoreCtx = X509_STORE_CTX_new();
+
        if (pstStoreCtx == NULL) {
-               DRM_TAPPS_EXCEPTION("TADC_IF_VerifyCertChain Error : 509_STORE_CTX_new error!");
+               DRM_TAPPS_EXCEPTION("509_STORE_CTX_new error!");
                return -1;
        }
 
        std::unique_ptr<X509_STORE_CTX, void(*)(X509_STORE_CTX *)>
-               _scoped_x509_store_ctx(pstStoreCtx, X509_STORE_CTX_free);
+       _scoped_x509_store_ctx(pstStoreCtx, X509_STORE_CTX_free);
 
        //init
        X509_STORE_CTX_init(pstStoreCtx, pstStore, pstX509, untrustedCerts);
@@ -454,10 +457,13 @@ int TADC_IF_VerifyCertChain(unsigned char* rica, int ricaLen,
        case 1:
                DRM_TAPPS_LOG("TADC_IF_VerifyCertChain Success!");
                return 0;
+
        case 0:
                DRM_TAPPS_EXCEPTION("TADC_IF_VerifyCertChain Failed: %s",
-                               X509_verify_cert_error_string(X509_STORE_CTX_get_error(pstStoreCtx)));
+                                                       X509_verify_cert_error_string(
+                                                               X509_STORE_CTX_get_error(pstStoreCtx)));
                return -1;
+
        default:
                DRM_TAPPS_EXCEPTION("TADC_IF_VerifyCertChain Error: X509_verify_cert error!");
                return -1;
@@ -511,10 +517,8 @@ void *TADC_IF_Malloc(size_t size)
 
 void TADC_IF_Free(void *memblock)
 {
-       if(memblock != NULL)
-       {
+       if (memblock != NULL)
                free(memblock);
-       }
 }
 
 int TADC_IF_AtoI(char *str)
index 681f225..82dba08 100644 (file)
@@ -21,7 +21,7 @@
 //////////////////////////////////////////////////////////////////////
 // Construction/Destruction
 //////////////////////////////////////////////////////////////////////
-#define                        BUFFER_INC_SIZE                         128
+#define BUFFER_INC_SIZE 128
 
 CPointerArray::CPointerArray()
 {
@@ -32,38 +32,32 @@ CPointerArray::CPointerArray()
 
 CPointerArray::~CPointerArray()
 {
-       if( m_ppData != NULL )
-       {
+       if (m_ppData != NULL)
                delete[] m_ppData;
-       }
 }
 
-int CPointerArray::Add( LPVOID pData )
+int CPointerArray::Add(LPVOID pData)
 {
-       int                                     nResult;
-       int                                     nNewSize;
-       LPVOID*                         ppTemp;
+       int nResult;
+       int nNewSize;
+       LPVOID *ppTemp;
 
-       if( m_ppData == NULL )
-       {
+       if (m_ppData == NULL) {
                m_nMaxSize = BUFFER_INC_SIZE;
-               m_ppData = new LPVOID[ BUFFER_INC_SIZE ];
+               m_ppData = new LPVOID[BUFFER_INC_SIZE];
 
-               if(m_ppData == NULL)
-               {
+               if (m_ppData == NULL) {
                        nResult = -1;
-
                        goto finish;
                }
        }
 
-       if( m_nNumOfData >= m_nMaxSize )
-       {
+       if (m_nNumOfData >= m_nMaxSize) {
                nNewSize = m_nMaxSize += BUFFER_INC_SIZE;
-               ppTemp = new LPVOID[ nNewSize ];
-               IF_TRUE_GOTO( ppTemp == NULL, -1 );
-               
-               memcpy( ppTemp, m_ppData, BUFFER_INC_SIZE * sizeof( LPVOID ) );
+               ppTemp = new LPVOID[nNewSize];
+               IF_TRUE_GOTO(ppTemp == NULL, -1);
+
+               memcpy(ppTemp, m_ppData, BUFFER_INC_SIZE * sizeof(LPVOID));
 
                delete[] m_ppData;
 
@@ -71,58 +65,47 @@ int CPointerArray::Add( LPVOID pData )
                m_ppData = ppTemp;
        }
 
-       m_ppData[ m_nNumOfData ] = pData;
+       m_ppData[m_nNumOfData] = pData;
        m_nNumOfData++;
 
        nResult = 0;
 
 finish:
 
-       if( nResult != 0 )
-       {
+       if (nResult != 0)
                DRM_TAPPS_EXCEPTION("CPointerArray::Add() Error! \n");
-       }
 
        return nResult;
 }
 
-int CPointerArray::Remove( int nIndex )
+int CPointerArray::Remove(int nIndex)
 {
-       int             nResult;
-       int             i;
-
-       if( ( nIndex < 0 ) || ( nIndex >= m_nNumOfData ) )
-       {
-               nResult = -1;//ERRORMSG( ERROR_INVALID_PARAMETER, NULL );
+       int nResult;
 
+       if ((nIndex < 0) || (nIndex >= m_nNumOfData)) {
+               nResult = -1; //ERRORMSG( ERROR_INVALID_PARAMETER, NULL );
                goto finish;
        }
 
-       for( i = nIndex ; i < m_nNumOfData - 1 ; i++ )
-       {
-               m_ppData[ i ] = m_ppData[ i + 1 ];
-       }
-       
+       for (int i = nIndex; i < m_nNumOfData - 1; i++)
+               m_ppData[i] = m_ppData[i + 1];
+
        m_nNumOfData--;
 
        nResult = 0;
 
 finish:
 
-       if( nResult != 0 )
-       {
+       if (nResult != 0)
                DRM_TAPPS_EXCEPTION("CPointerArray::Remove() Error! \n");
-       }
 
        return nResult;
 }
 
-LPVOID CPointerArray::Get( int nIndex )
+LPVOID CPointerArray::Get(int nIndex)
 {
-       if( ( nIndex < 0 ) || ( nIndex >= m_nNumOfData ) )
-       {
+       if ((nIndex < 0) || (nIndex >= m_nNumOfData))
                return NULL;
-       }
 
-       return m_ppData[ nIndex ];
+       return m_ppData[nIndex];
 }
index a6c6fa0..a81a1c1 100644 (file)
@@ -55,6 +55,7 @@ int CXMLAttribute::SetName(LPCTSTR pszName)
        memcpy(m_pszName, pszName, pszNameLen + 1);
 
 finish:
+
        if (nResult)
                DRM_TAPPS_EXCEPTION("CXMLAttribute::SetName() Error!");
 
@@ -80,6 +81,7 @@ int CXMLAttribute::SetValue(LPCTSTR pszValue)
        memcpy(m_pszValue, pszValue, pszValueLen + 1);
 
 finish:
+
        if (nResult)
                DRM_TAPPS_EXCEPTION("CXMLAttribute::SetValue() Error!");
 
index bcfdf5e..d9f0541 100644 (file)
@@ -37,10 +37,10 @@ CXMLElement::~CXMLElement()
                delete[] m_pszValue;
 
        for (int i = 0; i < m_pAttributes.GetCount(); i++)
-               delete (CXMLAttribute *)m_pAttributes.Get(i);
+               delete(CXMLAttribute *)m_pAttributes.Get(i);
 
        for (int i = 0; i < m_pChilds.GetCount(); i++)
-               delete (CXMLElement *)m_pChilds.Get(i);
+               delete(CXMLElement *)m_pChilds.Get(i);
 }
 
 int CXMLElement::SetName(LPCTSTR pszName)
@@ -57,6 +57,7 @@ int CXMLElement::SetName(LPCTSTR pszName)
        memcpy(m_pszName, pszName, pszNameLen + 1);
 
 finish:
+
        if (nResult)
                DRM_TAPPS_EXCEPTION("CXMLElement::SetName() Error!");
 
@@ -77,9 +78,10 @@ int CXMLElement::SetValue(LPCTSTR pszValue)
        memcpy(m_pszValue, pszValue, pszValueLen + 1);
 
 finish:
+
        if (nResult)
                DRM_TAPPS_EXCEPTION("CXMLElement::SetValue() Error!");
-       
+
        return nResult;
 }
 
@@ -97,6 +99,7 @@ int CXMLElement::AddAttribute(LPCTSTR pszName, LPCTSTR pszValue)
        m_pAttributes.Add(pAttribute);
 
 finish:
+
        if (nResult)
                DRM_TAPPS_EXCEPTION("CXMLElement::AddAttribute() Error!");
 
@@ -125,6 +128,7 @@ int CXMLElement::Find(CPointerArray *pSearchedChild, LPCTSTR pszChildName, ...)
                goto finish;
 
 finish:
+
        if (nResult)
                DRM_TAPPS_EXCEPTION("CXMLElement::Find() Error!");
 
@@ -132,7 +136,8 @@ finish:
        return nResult;
 }
 
-int CXMLElement::_SearchNodes(CPointerArray* ppaChildNodes, CXMLElement* pCurrent, LPCTSTR pszTagName, va_list args)
+int CXMLElement::_SearchNodes(CPointerArray *ppaChildNodes,
+                                                         CXMLElement *pCurrent, LPCTSTR pszTagName, va_list args)
 {
        int nResult = 0;
 
@@ -157,10 +162,11 @@ int CXMLElement::_SearchNodes(CPointerArray* ppaChildNodes, CXMLElement* pCurren
                                nResult = _SearchNodes(ppaChildNodes, pChild, pszNextName, args);
                }
        }
-       
+
        nResult = 0;
 
 finish:
+
        if (nResult)
                DRM_TAPPS_EXCEPTION("CXMLElement::_SearchNodes() Error!");
 
index f4b32c0..4a1d485 100644 (file)
 #define _MAX_VALUE_LENGTH 4096
 
 
-#define                _SKIP_WHITESPACE()                      while(  ( *m_pszXML == ' ' ) || \
-                                                                                               ( *m_pszXML == '\n' ) || \
-                                                                                               ( *m_pszXML == '\r' ) || \
-                                                                                               ( *m_pszXML == 0x09 ) ) m_pszXML++
-
-typedef struct _tagESCAPE_CHARSET
-{
-       LPCTSTR                 pszEscape;
-       TCHAR                   chReplace;
+#define _SKIP_WHITESPACE() \
+       while ((*m_pszXML == ' ') || \
+                       (*m_pszXML == '\n') || \
+                       (*m_pszXML == '\r') || \
+                       (*m_pszXML == 0x09)) m_pszXML++
+
+typedef struct _tagESCAPE_CHARSET {
+       LPCTSTR         pszEscape;
+       TCHAR           chReplace;
 } T_ESCAPE_CHARSET;
 
 //////////////////////////////////////////////////////////////////////
@@ -47,7 +47,7 @@ CXMLFile::CXMLFile()
 
        for (int i = 0; i < ELEMENT_QUEUE_MAX; ++i)
                m_paElementQueue[i] = NULL;
-       
+
        m_pszXML = NULL;
 }
 
@@ -75,6 +75,7 @@ int CXMLFile::LoadFromStream(LPCTSTR pszXML)
                goto finish;
 
 finish:
+
        if (nResult)
                DRM_TAPPS_EXCEPTION("CXMLFile::LoadFromStream() Error! \n");
 
@@ -83,11 +84,11 @@ finish:
 
 int CXMLFile::LoadFromFile(LPCTSTR pszFileName)
 {
-       int                                     nResult;
-       FILE*                           hFile = NULL;
-       DWORD                           dwFileSize, dwReadBytes;
-       LPBYTE                          pbBuffer = NULL;
-       LPTSTR                          pszXML = NULL;
+       int  nResult;
+       FILE *hFile = NULL;
+       DWORD dwFileSize, dwReadBytes;
+       LPBYTE pbBuffer = NULL;
+       LPTSTR pszXML = NULL;
 
        hFile = fopen(pszFileName, "rb");
 
@@ -100,20 +101,21 @@ int CXMLFile::LoadFromFile(LPCTSTR pszFileName)
        dwFileSize = ftell(hFile);
        fseek(hFile, 0, SEEK_SET);
 
-       pbBuffer = new BYTE[ dwFileSize + 1 ];
-       IF_TRUE_GOTO( pbBuffer == NULL, TADC_MEMAlOC_ERROR );
+       pbBuffer = new BYTE[dwFileSize + 1];
+       IF_TRUE_GOTO(pbBuffer == NULL, TADC_MEMAlOC_ERROR);
 
-       dwReadBytes = fread ( pbBuffer, 1, dwFileSize + 1, hFile);
+       dwReadBytes = fread(pbBuffer, 1, dwFileSize + 1, hFile);
 
-       IF_TRUE_GOTO( dwFileSize != dwReadBytes, TADC_PARAMETER_ERROR );
+       IF_TRUE_GOTO(dwFileSize != dwReadBytes, TADC_PARAMETER_ERROR);
 
-       pbBuffer[ dwFileSize ] = 0;
+       pbBuffer[dwFileSize] = 0;
 
-       pszXML = new CHAR[ dwFileSize + 256 ];
-       IF_TRUE_GOTO( pszXML == NULL, TADC_MEMAlOC_ERROR );
+       pszXML = new CHAR[dwFileSize + 256];
+       IF_TRUE_GOTO(pszXML == NULL, TADC_MEMAlOC_ERROR);
 
 #ifdef _UNICODE
-       nResult = MultiByteToWideChar( CP_ACP, 0, (LPCSTR)pbBuffer, -1, pszXML, dwFileSize + 256 );
+       nResult = MultiByteToWideChar(CP_ACP, 0, (LPCSTR)pbBuffer, -1, pszXML,
+                                                                 dwFileSize + 256);
 #else
        memcpy(pszXML, pbBuffer, dwFileSize + 1);
 #endif
@@ -126,9 +128,10 @@ int CXMLFile::LoadFromFile(LPCTSTR pszFileName)
        nResult = 0;
 
 finish:
+
        if (hFile)
                fclose(hFile);
-       
+
        if (nResult)
                DRM_TAPPS_EXCEPTION("CXMLFile::LoadFromFile() Error! \n");
 
@@ -143,15 +146,15 @@ finish:
 
 int CXMLFile::_Parse()
 {
-       int                                     nResult, i;
-       CXMLElement*            pXMLElement = NULL;
-       CXMLElement*            pCurrentElement = NULL;
-       CXMLElement*            pTemp = NULL;
-       TCHAR                           szElementName[_MAX_NAME_LENGTH];
-       TCHAR                           szValue[_MAX_VALUE_LENGTH];
-       LPCTSTR                         psz;
-       size_t                          orig_pszXML_len = strlen(m_pszXML);
-       size_t                          tmp_pszXML_len = orig_pszXML_len;
+       int nResult, i;
+       CXMLElement *pXMLElement = NULL;
+       CXMLElement *pCurrentElement = NULL;
+       CXMLElement *pTemp = NULL;
+       TCHAR szElementName[_MAX_NAME_LENGTH];
+       TCHAR szValue[_MAX_VALUE_LENGTH];
+       LPCTSTR psz;
+       size_t orig_pszXML_len = strlen(m_pszXML);
+       size_t tmp_pszXML_len = orig_pszXML_len;
 
        _SKIP_WHITESPACE();
 
@@ -163,7 +166,7 @@ int CXMLFile::_Parse()
 
                if (*m_pszXML == '<') {
                        m_pszXML++;
-                       
+
                        _SKIP_WHITESPACE();
 
                        if (*m_pszXML == '!') {
@@ -172,22 +175,21 @@ int CXMLFile::_Parse()
                                // Comment
                                //
                                //------------------------------------------------------------------------
-                       }
-                       else if (*m_pszXML == '?') {
+                       } else if (*m_pszXML == '?') {
                                //------------------------------------------------------------------------
                                //
                                // <? ... ?>
                                //
                                //------------------------------------------------------------------------
-                               psz = _tcsstr(m_pszXML, _T( "?>" ));
+                               psz = _tcsstr(m_pszXML, _T("?>"));
+
                                if (!psz) {
                                        nResult = -1;
                                        goto finish;
                                }
-                               
+
                                m_pszXML = psz + 2;
-                       }
-                       else if (*m_pszXML == '/') {
+                       } else if (*m_pszXML == '/') {
                                m_pszXML++;
                                //------------------------------------------------------------------------
                                //
@@ -198,19 +200,20 @@ int CXMLFile::_Parse()
 
                                if (nResult != 0)
                                        goto finish;
-                               
+
                                //2011.04.27
                                if (!pCurrentElement) {
                                        nResult = -1;
                                        goto finish;
                                }
-                               
+
                                if (TADC_IF_StrCmp(pCurrentElement->GetName(), (LPTSTR)szElementName) != 0) {
                                        nResult = -1;
                                        goto finish;
                                }
 
                                tmp_pszXML_len = orig_pszXML_len;
+
                                while (*m_pszXML != '>' && tmp_pszXML_len > 0) {
                                        tmp_pszXML_len--;
                                        m_pszXML++;
@@ -224,12 +227,12 @@ int CXMLFile::_Parse()
                                        pCurrentElement = pTemp;
                                else
                                        pCurrentElement = m_pRoot;
-                       }
-                       else {
-                               pXMLElement = new CXMLElement;                  
+                       } else {
+                               pXMLElement = new CXMLElement;
                                IF_TRUE_GOTO(pXMLElement == NULL, TADC_MEMAlOC_ERROR);
-                               
+
                                nResult = _GetElementName((LPTSTR)szElementName);
+
                                if (nResult)
                                        goto finish;
 
@@ -237,7 +240,7 @@ int CXMLFile::_Parse()
 
                                if (!m_pRoot)
                                        m_pRoot = pXMLElement;
-                               
+
                                if (pCurrentElement) {
                                        pCurrentElement->AddChild(pXMLElement);
                                        _Push(pCurrentElement);
@@ -245,8 +248,7 @@ int CXMLFile::_Parse()
 
                                pCurrentElement = pXMLElement;
                        }
-               }
-               else if (*m_pszXML == '/') {
+               } else if (*m_pszXML == '/') {
                        m_pszXML++;
 
                        if (*m_pszXML != '>') {
@@ -255,14 +257,14 @@ int CXMLFile::_Parse()
                        }
 
                        pCurrentElement = _Pop();
-               }
-               else if (*m_pszXML == '>') {
+               } else if (*m_pszXML == '>') {
                        m_pszXML++;
                        _SKIP_WHITESPACE();
 
                        i = 0;
 
                        tmp_pszXML_len = orig_pszXML_len;
+
                        while (*m_pszXML != '<' && tmp_pszXML_len > 0) {
                                tmp_pszXML_len--;
                                szValue[i] = *m_pszXML;
@@ -271,10 +273,10 @@ int CXMLFile::_Parse()
                        }
 
                        szValue[i] = 0;
+
                        if (pCurrentElement)
                                pCurrentElement->SetValue((LPTSTR)szValue);
-               }
-               else {
+               } else {
                        _SKIP_WHITESPACE();
 
                        nResult = _GetAttributeNameAndValue((LPTSTR)szElementName, (LPTSTR)szValue);
@@ -290,6 +292,7 @@ int CXMLFile::_Parse()
        nResult = 0;
 
 finish:
+
        if (nResult)
                DRM_TAPPS_EXCEPTION("CXMLFile::_Parse() Error!. nResult[%d]", nResult);
 
@@ -300,21 +303,21 @@ int CXMLFile::_GetElementName(LPTSTR pszElementName)
 {
        _SKIP_WHITESPACE();
 
-       while ((*m_pszXML != 0 )
-               && (*m_pszXML != ' ')
-               && (*m_pszXML != '>')
-               && (*m_pszXML != '/')) {
+       while ((*m_pszXML != 0)
+                       && (*m_pszXML != ' ')
+                       && (*m_pszXML != '>')
+                       && (*m_pszXML != '/')) {
                *pszElementName = *m_pszXML;
                m_pszXML++;
                pszElementName++;
        }
-       
+
        *pszElementName = 0;
 
        return 0;
 }
 
-CXMLElementCXMLFile::_Pop()
+CXMLElement *CXMLFile::_Pop()
 {
        if (m_nQueueIndex < 1)
                return NULL;
@@ -322,9 +325,10 @@ CXMLElement* CXMLFile::_Pop()
        return m_paElementQueue[--m_nQueueIndex];
 }
 
-int CXMLFile::_Push(IN CXMLElement* p)
+int CXMLFile::_Push(CXMLElement *p)
 {
-       if (m_nQueueIndex >= (int)sizeof(m_paElementQueue) / (int)sizeof(m_paElementQueue[0]))
+       if (m_nQueueIndex >= (int)sizeof(m_paElementQueue) / (int)sizeof(
+                               m_paElementQueue[0]))
                return ERROR_INSUFFICIENT_BUFFER;
 
        m_paElementQueue[m_nQueueIndex++] = p;
@@ -334,49 +338,55 @@ int CXMLFile::_Push(IN CXMLElement* p)
 
 int CXMLFile::_GetAttributeNameAndValue(LPTSTR pszName, LPTSTR pszValue)
 {
-       int                                                     nResult, nLength, i;
-       LPCTSTR                                         psz;
-       TCHAR                                           chQuotation;
-       bool                                            isFound;
-    LPTSTR                      origValueAddr = pszValue;
-       static T_ESCAPE_CHARSET         stEscape[] = {  { _T( "&amp" ), _T( '&' ) },
-                                                                                               { _T( "&qt" ), _T( '>' ) },
-                                                                                               { _T( "&lt" ), _T( '<' ) },
-                                                                                               { _T( "&quot" ), _T( '"' ) },
-                                                                                               { _T( "&apos" ), _T( '\'' ) } };
+       int nResult, nLength, i;
+       LPCTSTR psz;
+       TCHAR chQuotation;
+       bool isFound;
+       LPTSTR origValueAddr = pszValue;
+       static T_ESCAPE_CHARSET stEscape[] = {
+               { _T("&amp"), _T('&') },
+               { _T("&qt"), _T('>') },
+               { _T("&lt"), _T('<') },
+               { _T("&quot"), _T('"') },
+               { _T("&apos"), _T('\'') }
+       };
 
        _SKIP_WHITESPACE();
 
-       psz = _tcschr( m_pszXML, '=' );
+       psz = _tcschr(m_pszXML, '=');
+
        if (!psz) {
-               nResult = -1;//ERRORMSG( ERROR_SXS_XML_E_BADXMLDECL, NULL );
+               nResult = -1; //ERRORMSG(ERROR_SXS_XML_E_BADXMLDECL, NULL);
                goto finish;
        }
 
        nLength = (int)(psz - m_pszXML);
-    if( _MAX_NAME_LENGTH < nLength + 1) {
-        nResult = -1;
-        goto finish;
-    }
+
+       if (_MAX_NAME_LENGTH < nLength + 1) {
+               nResult = -1;
+               goto finish;
+       }
+
        memcpy(pszName, m_pszXML, nLength + 1);
 
        m_pszXML = psz + 1;
 
        _SKIP_WHITESPACE();
 
-       if (( *m_pszXML == '\'' ) || ( *m_pszXML == '"' )) {
+       if ((*m_pszXML == '\'') || (*m_pszXML == '"')) {
                chQuotation = *m_pszXML;
                m_pszXML++;
-       }
-       else {
+       } else {
                chQuotation = ' ';
        }
 
-       while (*m_pszXML != 0 && ((pszValue - origValueAddr)< _MAX_VALUE_LENGTH) ) {
+       while (*m_pszXML != 0 && ((pszValue - origValueAddr) < _MAX_VALUE_LENGTH)) {
                if (*m_pszXML == '&') {
                        isFound = FALSE;
+
                        for (i = 0; i < (int)sizeof(stEscape) / (int)sizeof(stEscape[0]); i++) {
-                               if (TADC_IF_StrNCmp(m_pszXML, stEscape[i].pszEscape, TADC_IF_StrLen(stEscape[i].pszEscape)) == 0) {
+                               if (TADC_IF_StrNCmp(m_pszXML, stEscape[i].pszEscape,
+                                                                       TADC_IF_StrLen(stEscape[i].pszEscape)) == 0) {
                                        *pszValue = stEscape[i].chReplace;
                                        pszValue++;
                                        m_pszXML += TADC_IF_StrLen(stEscape[i].pszEscape);
@@ -391,22 +401,17 @@ int CXMLFile::_GetAttributeNameAndValue(LPTSTR pszName, LPTSTR pszValue)
                                pszValue++;
                                m_pszXML++;
                        }
-               }
-               else if (*m_pszXML == chQuotation) {
+               } else if (*m_pszXML == chQuotation) {
                        m_pszXML++;
                        break;
-               }
-               else if (*m_pszXML == '/' || *m_pszXML == '>')
-               {
+               } else if (*m_pszXML == '/' || *m_pszXML == '>') {
                        if (chQuotation == ' ')
                                break;
 
                        *pszValue = *m_pszXML;
                        pszValue++;
                        m_pszXML++;
-               }
-               else
-               {
+               } else {
                        *pszValue = *m_pszXML;
                        pszValue++;
                        m_pszXML++;
@@ -417,6 +422,7 @@ int CXMLFile::_GetAttributeNameAndValue(LPTSTR pszName, LPTSTR pszValue)
        nResult = 0;
 
 finish:
+
        if (nResult)
                DRM_TAPPS_EXCEPTION("CXMLFile::_GetAttributeNameAndValue() Error!");
 
index a279382..74d8cf1 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 #ifndef __CPOINTERARRAY_H__
 #define __CPOINTERARRAY_H__
 
-
-#if !defined(AFX_CPOINTERARRAY_H__AB67E4BE_A233_4E3E_B257_9830D90326EE__INCLUDED_)
-#define AFX_CPOINTERARRAY_H__AB67E4BE_A233_4E3E_B257_9830D90326EE__INCLUDED_
-
-#if _MSC_VER > 1000
-#pragma once
-#endif // _MSC_VER > 1000
-
 #include "TadcTypes.h"
 
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-class CPointerArray
-{
+class CPointerArray {
 protected:
-       LPVOID*                                         m_ppData;
-       int                                                     m_nMaxSize;
-       int                                                     m_nNumOfData;
+       LPVOID *m_ppData;
+       int m_nMaxSize;
+       int m_nNumOfData;
 
 public:
        CPointerArray();
        virtual ~CPointerArray();
 
-       int                                     Add( LPVOID pData );
-       int                                     Remove( int nIndex );
-       LPVOID                          Get( int nIndex );
-       inline int                      GetCount() { return m_nNumOfData; }
-       inline void                     RemoveAll() { m_nNumOfData = 0; }
+       int Add(LPVOID pData);
+       int Remove(int nIndex);
+       LPVOID Get(int nIndex);
+       inline int GetCount()
+       {
+               return m_nNumOfData;
+       }
+
+       inline void RemoveAll()
+       {
+               m_nNumOfData = 0;
+       }
 };
 
-#ifdef __cplusplus
-}
-#endif  /* __cplusplus */
-
-#endif // !defined(AFX_CPOINTERARRAY_H__AB67E4BE_A233_4E3E_B257_9830D90326EE__INCLUDED_)
 #endif /* __CPOINTERARRAY_H__ */
index 1e68d4d..046e771 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+#ifndef __CXMLATTRIBUTE_H__
+#define __CXMLATTRIBUTE_H__
 
 #include "TadcTypes.h"
 
-#if !defined(AFX_CXMLATTRIBUTE_H__2B925786_3613_47B0_B85D_CAF2053F46DB__INCLUDED_)
-#define AFX_CXMLATTRIBUTE_H__2B925786_3613_47B0_B85D_CAF2053F46DB__INCLUDED_
-
-#if _MSC_VER > 1000
-#pragma once
-#endif // _MSC_VER > 1000
-
-class CXMLAttribute
-{
+class CXMLAttribute {
 protected:
-       LPTSTR                                                  m_pszName;
-       LPTSTR                                                  m_pszValue;
+       LPTSTR m_pszName;
+       LPTSTR m_pszValue;
 
 public:
        CXMLAttribute();
        virtual ~CXMLAttribute();
 
-       int                                             SetName( LPCTSTR pszName );
-       int                                             SetValue( LPCTSTR pszValue );
+       int SetName(LPCTSTR pszName);
+       int SetValue(LPCTSTR pszValue);
+
+       inline LPCTSTR GetName()
+       {
+               return m_pszName;
+       }
 
-       inline LPCTSTR                  GetName() { return m_pszName; }
-       inline LPCTSTR                  GetValue() { return m_pszValue; }
+       inline LPCTSTR GetValue()
+       {
+               return m_pszValue;
+       }
 };
 
-#endif // !defined(AFX_CXMLATTRIBUTE_H__2B925786_3613_47B0_B85D_CAF2053F46DB__INCLUDED_)
+#endif //__CXMLATTRIBUTE_H_
index d3f9c38..12d5020 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
-#if !defined(AFX_CXMLELEMENT_H__B6A6A39B_1980_4A4F_B68B_E87B53A3EE9B__INCLUDED_)
-#define AFX_CXMLELEMENT_H__B6A6A39B_1980_4A4F_B68B_E87B53A3EE9B__INCLUDED_
+#ifndef __CXMLELEMENT_H__
+#define __CXMLELEMENT_H__
 
 #include "TadcTypes.h"
 #include "CXMLAttribute.h"
 #include "CPointerArray.h"
 
-#if _MSC_VER > 1000
-#pragma once
-#endif // _MSC_VER > 1000
-
-class CXMLElement  
-{
+class CXMLElement {
 protected:
-       LPTSTR                                  m_pszName;
-       LPTSTR                                  m_pszValue;
-       
-       CPointerArray                   m_pChilds;
-       CPointerArray                   m_pAttributes;
-       
-       int                                     _SearchNodes(  CPointerArray* ppaChildNodes,  CXMLElement* pCurrent,  LPCTSTR pszTagName,  va_list args );
+       LPTSTR m_pszName;
+       LPTSTR m_pszValue;
+
+       CPointerArray m_pChilds;
+       CPointerArray m_pAttributes;
+
+       int _SearchNodes(CPointerArray *ppaChildNodes, CXMLElement *pCurrent,
+                                        LPCTSTR pszTagName,  va_list args);
 
 public:
        CXMLElement();
        virtual ~CXMLElement();
 
-       int                                     SetName(  LPCTSTR pszName );
-       int                                     SetValue(  LPCTSTR pszValue );
-       int                                     AddAttribute(  LPCTSTR pszName,  LPCTSTR pszValue );
+       int SetName(LPCTSTR pszName);
+       int SetValue(LPCTSTR pszValue);
+       int AddAttribute(LPCTSTR pszName,  LPCTSTR pszValue);
+
+       inline LPCTSTR GetName()
+       {
+               return m_pszName;
+       }
+
+       inline LPCTSTR GetValue()
+       {
+               return m_pszValue;
+       }
+
+       int AddChild(CXMLElement *pChild);
+
+       LPCTSTR GetAttribute(LPCTSTR pszName);
+
+       inline int GetChildCount()
+       {
+               return m_pChilds.GetCount();
+       }
 
-       inline LPCTSTR                  GetName() { return m_pszName; }
-       inline LPCTSTR                  GetValue() { return m_pszValue; }
+       inline int GetAttributeCount()
+       {
+               return m_pAttributes.GetCount();
+       }
 
-       int                                     AddChild(  CXMLElement* pChild );
-       LPCTSTR                                 GetAttribute(  LPCTSTR pszName );
+       inline CXMLElement *GetChild(int nIndex)
+       {
+               return (CXMLElement *)m_pChilds.Get(nIndex);
+       }
 
-       inline int                              GetChildCount() { return m_pChilds.GetCount(); }
-       inline int                              GetAttributeCount() { return m_pAttributes.GetCount(); }
-       inline CXMLElement*     GetChild(  int nIndex ) { return (CXMLElement*)m_pChilds.Get( nIndex ); }
-       inline CXMLAttribute*   GetAttribute(  int nIndex ) { return (CXMLAttribute*)m_pAttributes.Get( nIndex ); }
+       inline CXMLAttribute *GetAttribute(int nIndex)
+       {
+               return (CXMLAttribute *)m_pAttributes.Get(nIndex);
+       }
 
-       int                                             Find(  CPointerArray* pSearchedChild,  LPCTSTR pszChildName, ... );
+       int Find(CPointerArray *pSearchedChild, LPCTSTR pszChildName, ...);
 };
 
-#endif // !defined(AFX_CXMLELEMENT_H__B6A6A39B_1980_4A4F_B68B_E87B53A3EE9B__INCLUDED_)
+#endif //__CXMLELEMENT_H__
index 527162b..1e6688d 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
-#if !defined(AFX_CXMLFILE_H__21F76587_B9C8_4407_9C16_186F3D47ADE1__INCLUDED_)
-#define AFX_CXMLFILE_H__21F76587_B9C8_4407_9C16_186F3D47ADE1__INCLUDED_
+#ifndef __CXMLFILE_H__
+#define __CXMLFILE_H__
 
 #include "TadcTypes.h"
 #include "CXMLElement.h"
 
-#if _MSC_VER > 1000
-#pragma once
-#endif // _MSC_VER > 1000
-
-#ifndef IN
-       #define IN
-#endif
-
-#ifndef OUT
-       #define OUT
-#endif
+#define ELEMENT_QUEUE_MAX 2048
 
-#define ELEMENT_QUEUE_MAX      2048
-
-class CXMLFile  
-{
+class CXMLFile {
 protected:
-       LPCTSTR                                 m_pszXML;
-       CXMLElement*                    m_paElementQueue[ ELEMENT_QUEUE_MAX ];
-       int                                             m_nQueueIndex;
-       CXMLElement*                    m_pRoot;
-       
-       int                                     _Parse();
-       int                                     _GetElementName(  LPTSTR pszElementName );
-       CXMLElement*                    _Pop();
-       int                                     _Push( CXMLElement* p );
-       int                                     _GetAttributeNameAndValue(  LPTSTR pszName,  LPTSTR pszValue );
+       LPCTSTR m_pszXML;
+       CXMLElement *m_paElementQueue[ELEMENT_QUEUE_MAX];
+       int m_nQueueIndex;
+       CXMLElement *m_pRoot;
+
+       int _Parse();
+       int _GetElementName(LPTSTR pszElementName);
+       CXMLElement *_Pop();
+       int _Push(CXMLElement *p);
+       int _GetAttributeNameAndValue(LPTSTR pszName, LPTSTR pszValue);
 
 public:
        CXMLFile();
        virtual ~CXMLFile();
 
-       int                                     LoadFromStream(  LPCTSTR pszXML );
-       int                                     LoadFromFile(  LPCTSTR pszFileName );
-       inline CXMLElement*     GetRoot() { return m_pRoot; }
+       int LoadFromStream(LPCTSTR pszXML);
+       int LoadFromFile(LPCTSTR pszFileName);
+
+       inline CXMLElement *GetRoot()
+       {
+               return m_pRoot;
+       }
 };
 
-#endif // !defined(AFX_CXMLFILE_H__21F76587_B9C8_4407_9C16_186F3D47ADE1__INCLUDED_)
+#endif //__CXMLFILE_H_
index 1327de4..676c3ef 100644 (file)
 // See the License for the specific language governing permissions and
 // limitations under the License.
 //
-
-/**
- * @file               DUIDGenerator.h
- */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
+#ifndef __DUIDGENERATOR_H_
+#define __DUIDGENERATOR_H_
 
 int get_duid(char **duid);
 
-#ifdef __cplusplus
-}
-#endif
+#endif //__DUIDGENERATOR_H_
index 1cf570c..1c73320 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 #ifndef __DRM_FILE_API_H__
 #define __DRM_FILE_API_H__
 
-
 #include "DrmFileMgr.h"
 #include "TADC_ErrorCode.h"
 
 /*
 enum
 {
-       DRM_SEEK_SET = 0,
-       DRM_SEET_CUR,
-       DRM_SEEK_END
+    DRM_SEEK_SET = 0,
+    DRM_SEET_CUR,
+    DRM_SEEK_END
 } DRM_SEEK_TYPE
 */
 
 //typedef int DrmHandler;
 
-int DrmTdcFileOpen(const char* filePath, int* handle);
+int DrmTdcFileOpen(const char *filePath, int *handle);
 
-int DrmTdcFileClose(inthandle);
+int DrmTdcFileClose(int *handle);
 
-int DrmTdcFileRead(int* handle, void* pBuf, long long bufLen, long long* pReadLen);
+int DrmTdcFileRead(int *handle, void *pBuf, long long bufLen,
+                                  long long *pReadLen);
 
 //int DrmTdcFileSeek(int* handle, DRM_SEEK_TYPE type, long long offset);
 
-int DrmTdcFileSeek(inthandle, long long offset, int origin);
+int DrmTdcFileSeek(int *handle, long long offset, int origin);
 
-int DrmTdcFileTell(inthandle, long long *position);
+int DrmTdcFileTell(int *handle, long long *position);
 
-#endif
+#endif //__DRM_FILE_API_H_
index 7ef315b..1055f11 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+#ifndef __DRMFILEHANDLER_H_
+#define __DRMFILEHANDLER_H_
 
 #include <stdio.h>
 
 #include "DrmTdcSvc.h"
 
-class DrmFileHandler
-{
-
+class DrmFileHandler {
 public:
        DrmFileHandler(void);
        ~DrmFileHandler(void);
 
-       int     Construct(const char* szDrmFilePath);
-       int     DrmSeek(long long offset, int origin);
+       int Construct(const char *szDrmFilePath);
+       int DrmSeek(long long offset, int origin);
        long long DrmTell(void);
-       int     DrmRead(void* pBuf, long long bufLen, long long* pReadLen);
+       int DrmRead(void *pBuf, long long bufLen, long long *pReadLen);
 
 #ifndef TEST_CODE_ENABLED
 private:
 #endif
-       int     DrmDecryptBlocks(void);
+       int DrmDecryptBlocks(void);
        long long GetCurBlockIndex(void);
 
        unsigned char *m_pFilePath;
@@ -41,7 +41,7 @@ private:
        unsigned char *m_pCEK;
        unsigned char *m_pDecBuf;
 
-       int     m_PlaintextStartOffset;
+       int m_PlaintextStartOffset;
        FILE *m_pFP;
 
        long m_encryptionLevel;
@@ -56,3 +56,5 @@ private:
        long long m_decReadlen;
        long long m_extraReadlen;
 };
+
+#endif //__DRMFILEHANDLER_H_
index c4b7409..1de99c1 100644 (file)
@@ -13,6 +13,8 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+#ifndef __DRMFILEMGR_H_
+#define __DRMFILEMGR_H_
 
 #include <map>
 #include "DrmFileHandler.h"
@@ -37,3 +39,5 @@ private:
        static DrmFileMgr *m_pInstance;
        DrmHandlerMap m_HandlerMap;
 };
+
+#endif //__DRMFILEMGR_H_
index e105fb3..7cdca85 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
-/** 
- * @file       DrmTdcSvc.h
- * @brief      This file includes definitions of the Tizen Apps DRM functions.
- * @author     Sunggun.jung (sunggun.jung@samsung.com)
- */
-
-#ifndef DRMTDCSVC_H
-#define DRMTDCSVC_H
-
-#ifdef  __cplusplus
-extern "C" {
-#endif
+#ifndef __DRMTDCSVC_H_
+#define __DRMTDCSVC_H_
 
 #include "TADC_Core.h"
 
-
-//TDC DRM File Header Info
-typedef struct
-{
-       char cid[1024];         // CID ( Content ID )
-       char riurl[1024];       // RIURL ( Rights Issuer URL )
-               
+/**
+ * TDC DRM File Header Info
+ */
+typedef struct {
+       char cid[1024];   // Content ID
+       char riurl[1024]; // Rights Issuer URL
 } DrmTdcFileHeader;
 
-#ifndef IN
-#define IN
-#endif
-
-#ifndef OUT
-#define OUT
-#endif
-
-/**   
- *  An application can get file Header Info ( CID, License URL )
- * 
- * @param[in]          filePath                file path of Tizen Apps DRM contents
- * @param[out] pFileHeader     Pointer to be stored TAD Header information.
- * @return             This function   returns TRUE on success or FALSE on failure.
- * @remarks     
- * @see              
- * @since         
+/**
+ * An application can get file Header Info
+ *
+ * @param[in]  filePath    file path of Tizen Apps DRM contents
+ * @param[out] pFileHeader Pointer to be stored TAD Header information.
+ *
+ * @return TRUE on success or FALSE on failure.
  */
-bool DrmTdcGetFileHeader
-(
-       IN const char *pTADCFilepath,                   //TDC DRM File Path
-       IN OUT DrmTdcFileHeader *pFileHeader    //File Header Info ( CID, License URL )
-);
+bool DrmTdcGetFileHeader(const char *pTADCFilepath,
+                                                DrmTdcFileHeader *pFileHeader);
 
-/**   
- *  An application can request purchase request for getting License.
- * 
- * @param[in]                  pTADCFilepath   File path of Tizen Apps DRM contents
- * @param[out]         pReqBuf Purchase Request Data
- * @param[in][out]     pReqBufLen      IN : pReqBuf Length, OUT : Purchase Request Data String Size ( including null terminator )
- * @param[out]         pLicenseUrl     License Acquisition URL Data
- * @param[in][out]     pLicenseUrlLen  IN : pLicenseUrl Length, OUT : License Server URL Data String Size (  including null terminator )
- * @return                     This function   returns TRUE on success or FALSE on failure.
- * @remarks     
- * @see                                DrmTdcGenerateLicenseRequest
- * @since         
+/**
+ * An application can request purchase request for getting License.
+ *
+ * @param[in]      pTADCFilepath  File path of Tizen Apps DRM contents
+ * @param[out]     pReqBuf        Purchase Request Data
+ * @param[in][out] pReqBufLen     IN : pReqBuf Length
+ *                                OUT : Purchase Request Data String Size
+ *                                (including null terminator)
+ * @param[out]     pLicenseUrl    License Acquisition URL Data
+ * @param[in][out] pLicenseUrlLen IN : pLicenseUrl Length
+ *                                OUT : License Server URL Data String Size
+ *                                (including null terminator)
+ *
+ * @return TRUE on success or FALSE on failure.
+ *
+ * @see DrmTdcGenerateLicenseRequest()
  */
-bool DrmTdcGeneratePurchaseRequest
-(
-       IN const char *pTADCFilepath,           //TDC DRM File Path
-       IN OUT char *pReqBuf,                           //Purchase Request Data
-       IN OUT unsigned int *pReqBufLen,                //IN : pReqBuf Length, OUT : Purchase Request Data String Size ( including null terminator )
-       IN OUT char *pLicenseUrl,                       //License Acquisition URL Data
-       IN OUT unsigned int *pLicenseUrlLen     //IN : pLicenseUrl Length, OUT : License Server URL Data String Size (  including null terminator )
-);
+bool DrmTdcGeneratePurchaseRequest(const char *pTADCFilepath, char *pReqBuf,
+                                                                  unsigned int *pReqBufLen, char *pLicenseUrl, unsigned int *pLicenseUrlLen);
 
-/**   
- *  An application can request generate request for getting License.
- * 
- * @param[in]                  pRespBuf                        Response Data String of the Purchase Request ( Null terminator string ) 
- * @param[in]                  respBufLen              pResBuf Length
- * @param[in][out]     pReqBuf                 License Request Data
- * @param[in][out]     pReqBufLen              IN : pReqBuf Length, OUT : Rights Request Data String Size ( including null terminator )
- * @param[in][out]     pLicenseUrl             License Acquisition URL Data
- * @param[in][out]     pLicenseUrlLen  IN : IN : pLicenseUrl Length, OUT : Rights Issuer Server URL Data String Size (  including null terminator )
- * @return                     This function   returns TRUE on success or FALSE on failure.
- * @remarks     
- * @see                DrmTdcGeneratePurchaseRequest
- * @since         
+/**
+ * An application can request generate request for getting License.
+ *
+ * @param[in]      pRespBuf       Response Data String of the Purchase Request
+ *                                (Null terminator string)
+ * @param[in]      respBufLen     pResBuf Length
+ * @param[in][out] pReqBuf        License Request Data
+ * @param[in][out] pReqBufLen     IN : pReqBuf Length
+ *                                OUT : Rights Request Data String Size
+ *                                (including null terminator)
+ * @param[in][out] pLicenseUrl    License Acquisition URL Data
+ * @param[in][out] pLicenseUrlLen IN : IN : pLicenseUrl Length
+ *                                OUT : Rights Issuer Server URL Data String Size
+ *                                (including null terminator)
+ *
+ * @return TRUE on success or FALSE on failure.
+ *
+ * @see DrmTdcGeneratePurchaseRequest()
  */
-int DrmTdcGenerateLicenseRequest
-(
-       IN const char *pRespBuf,                        //Response Data String of the Purchase Request ( Null terminator string ) 
-       IN unsigned int respBufLen,                     //pResBuf Length
-       IN OUT char *pReqBuf,                           //License Request Data
-       IN OUT unsigned int *pReqBufLen,                //IN : pReqBuf Length, OUT : Rights Request Data String Size ( including null terminator )
-       IN OUT char *pLicenseUrl,                       //License Acquisition URL Data
-       IN OUT unsigned int *pLicenseUrlLen     //IN : pLicenseUrl Length, OUT : Rights Issuer Server URL Data String Size (  including null terminator )
-);
+int DrmTdcGenerateLicenseRequest(const char *pRespBuf, unsigned int respBufLen,
+                                                                char *pReqBuf, unsigned int *pReqBufLen, char *pLicenseUrl,
+                                                                unsigned int *pLicenseUrlLen);
 
-/**   
- *  An application can get TAD license which is encrypted.
- * 
- * @param[in]                  pRespBuf                        Response Data String of the Rights Request ( Null terminator string ) 
- * @param[in]                  respBufLen              pResBuf Length
- * @param[in][out]     pDecLicenseBuf  Decrypted Rights Object
- * @param[in][out]     decLicenseBufLen        IN : pDecLicenseBuf Length, OUT : Decrypted Rights Object String Size (  including null terminator )
- * @return             This function   returns TRUE on success or FALSE on failure.
- * @remarks     
- * @see                DrmTdcDecryptPackage
- * @since         
+/**
+ * An application can get TAD license which is encrypted.
+ *
+ * @param[in]      pRespBuf         Response Data String of the Rights Request
+ *                                  (Null terminator string)
+ * @param[in]      respBufLen       pResBuf Length
+ * @param[in][out] pDecLicenseBuf   Decrypted Rights Object
+ * @param[in][out] decLicenseBufLen IN : pDecLicenseBuf Length
+ *                                  OUT : Decrypted Rights Object String Size
+ *                                  (including null terminator)
+ *
+ * @return TRUE on success or FALSE on failure.
+ *
+ * @see DrmTdcDecryptPackage()
  */
-int DrmTdcDecryptLicense
-(
-       IN const char *pRespBuf,                                //Response Data String of the Rights Request ( Null terminator string ) 
-       IN unsigned int respBufLen,                             //pResBuf Length
-       IN OUT char *pDecLicenseBuf,                    //Decrypted Rights Object
-       IN OUT unsigned int *decLicenseBufLen   //IN : pDecLicenseBuf Length, OUT : Decrypted Rights Object String Size (  including null terminator )
-);
+int DrmTdcDecryptLicense(const char *pRespBuf, unsigned int respBufLen,
+                                                char *pDecLicenseBuf, unsigned int *decLicenseBufLen);
 
-/**   
- *  An application can get decrypted contents(Apps) which is encrypted.
- * 
- * @param[in]          pTADCFilepath   TDC DRM File Path
- * @param[in]          pLicenseBuf             pResBuf Length
- * @param[in]          licenseBufLen           pDecLicenseBuf Length
- * @param[in]          pDecryptedFile  Decrypted File Path
- * @return             This function   returns TRUE on success or FALSE on failure.
- * @remarks     
- * @see                DrmTdcDecryptLicense
- * @since         
+/**
+ * An application can get decrypted contents(Apps) which is encrypted.
+ *
+ * @param[in] pTADCFilepath   TDC DRM File Path
+ * @param[in] pLicenseBuf     pResBuf Length
+ * @param[in] licenseBufLen   pDecLicenseBuf Length
+ * @param[in] pDecryptedFile  Decrypted File Path
+ *
+ * @return TRUE on success or FALSE on failure.
+ *
+ * @see DrmTdcDecryptLicense()
  */
-//Decrypt DRM File
-bool DrmTdcDecryptPackage
-(
-       IN const char *pTADCFilepath,           //TDC DRM File Path
-       IN const char *pLicenseBuf,                     //Decrypted Rights Object
-       IN unsigned int licenseBufLen,          //pDecLicenseBuf Length
-       IN const char *pDecryptedFile                   //Decrypted File Path
-);
+bool DrmTdcDecryptPackage(const char *pTADCFilepath, const char *pLicenseBuf,
+                                                 unsigned int licenseBufLen, const char *pDecryptedFile);
 
-/**   
- *  An application can get decrypted contents(Apps) which is encrypted.
- * 
- * @param[in]          pTADCFilepath   TDC DRM File Path
- * @param[in]          t_RO                    Decrypted RO Info
- * @param[in]          pDecryptedFile  Decrypted File Path
- * @return             This function   returns TRUE on success or FALSE on failure.
- * @remarks     
- * @see                DrmTdcDecryptLicense
- * @since         
+/**
+ * An application can get decrypted contents(Apps) which is encrypted.
+ *
+ * @param[in] pTADCFilepath   TDC DRM File Path
+ * @param[in] t_RO            Decrypted RO Info
+ * @param[in] pDecryptedFile  Decrypted File Path
+ *
+ * @return TRUE on success or FALSE on failure.
+ *
+ * @see DrmTdcDecryptLicense()
  */
-//Decrypt DRM File
-bool DrmTdcDecryptPackage2
-(
-       IN const char *pTADCFilepath,           //TDC DRM File Path
-       IN T_RO           t_RO,                                 //RO Info       
-       IN const char *pDecryptedFile           //Decrypted File Path
-);
+bool DrmTdcDecryptPackage2(const char *pTADCFilepath, T_RO t_RO,
+                                                  const char *pDecryptedFile);
 
-/**   
- *  An application can check contents(Apps) which is valid.
- * 
- * @param[in]          szCid   CID ( Content ID )
- * @see                DrmTdcGetFileHeader
- * @since         
+/**
+ * An application can check contents(Apps) which is valid.
+ *
+ * @param[in] szCid Content ID
+ *
+ * @see DrmTdcGetFileHeader()
+ *
+ * @return TRUE on success or FALSE on failure.
  */
-//Decrypt DRM File
-bool DrmTdcHasValidLicense
-(
-       IN const char *szCid // CID ( Content ID )
-);
+bool DrmTdcHasValidLicense(const char *szCid);
 
 //DrmTdcDHInfo Structure Init
 void DrmTdcDHInfoInit(void);
@@ -187,8 +144,4 @@ void DrmTdcDHInfoInit(void);
 //DrmTdcDHInfo Structure Free
 bool DrmTdcDHInfoFree(int idx);
 
-#ifdef  __cplusplus
-}
-#endif
-
-#endif
+#endif //__DRMTDCSVC_H_
index 928538d..14ccd4c 100644 (file)
@@ -13,8 +13,8 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
-#pragma once
+#ifndef __TADCCORE_H_
+#define __TADCCORE_H_
 
 #include <stdio.h>
 #include <stdlib.h>
 #include "CXMLElement.h"
 #include "CXMLFile.h"
 
-#define                STACKTRACE(pszFunction)         // RETAILMSG(1, pszFunction);
+#define STACKTRACE(pszFunction)     // RETAILMSG(1, pszFunction);
 #undef ERRORMSG
-#define                ERRORMSG        //-1
-#define                IF_ERROR_RETURN( error , errcode)       if(error < 0){DRM_TAPPS_EXCEPTION("TADC Debug Error Code = %x", errcode); return error;}
-#define                IF_TRUE_RETURN( error , errcode)        if(error){DRM_TAPPS_EXCEPTION("TADC Debug Error Code = %x", errcode); return -1;}
+#define ERRORMSG    //-1
+#define IF_ERROR_RETURN(error , errcode) \
+       if (error < 0) { \
+               DRM_TAPPS_EXCEPTION("TADC Debug Error Code = %x", errcode); \
+               return error; \
+       }
+#define IF_TRUE_RETURN(error , errcode) \
+       if (error) { \
+               DRM_TAPPS_EXCEPTION("TADC Debug Error Code = %x", errcode); \
+               return -1; \
+       }
 
 //2011.03.08
-#define                IF_TRUE_RETURN2( error , do1, do2, do3, errcode)        if(error){ do1; do2; do3; DRM_TAPPS_EXCEPTION("TADC Debug Error Code = %x", errcode); return -1;}
+#define IF_TRUE_RETURN2(error , do1, do2, do3, errcode) \
+       if (error) { \
+               do1; \
+               do2; \
+               do3; \
+               DRM_TAPPS_EXCEPTION("TADC Debug Error Code = %x", errcode); \
+               return -1; \
+       }
 
 #ifndef TADC_SWAP32
-#define TADC_SWAP32(x)         ((((TADC_U32)(x) & 0x000000ffL) << 24) |        (((TADC_U32)(x) & 0x0000ff00L) << 8) | (((TADC_U32)(x) & 0x00ff0000L) >> 8) | (((TADC_U32)(x) & 0xff000000L) >> 24))
+#define TADC_SWAP32(x) \
+       ((((TADC_U32)(x) & 0x000000ffL) << 24) | \
+        (((TADC_U32)(x) & 0x0000ff00L) << 8) | \
+        (((TADC_U32)(x) & 0x00ff0000L) >> 8) | \
+        (((TADC_U32)(x) & 0xff000000L) >> 24))
 #endif
 
-#define        TADC_U8         unsigned char
-#define        TADC_U16        unsigned short
-#define        TADC_U32        unsigned long
-#define        DWORD           unsigned long
-#define        LPBYTE          unsigned char*
-#define        TCHAR           unsigned char
+#define TADC_U8 unsigned char
+#define TADC_U16 unsigned short
+#define TADC_U32 unsigned long
+#define DWORD unsigned long
+#define LPBYTE unsigned char *
+#define TCHAR unsigned char
 
-#define BYTE           unsigned char
-#define UINT           unsigned int
-#define ULONG          unsigned long
-#define INT32          long
-#define INT64          long long
-#define TRUE           1
-#define FALSE          0
+#define BYTE unsigned char
+#define UINT unsigned int
+#define ULONG unsigned long
+#define INT32 long
+#define INT64 long long
+#define TRUE 1
+#define FALSE 0
 
 
-#define                REQU_MAXSIZE    1024*5  //2011.03.08 (HTTP Request Buffer Max Size)
-#define                RESP_MAXSIZE    1024*10 //2011.03.08 (HTTP Response Buffer Max Size)
+#define REQU_MAXSIZE 1024 * 5  // HTTP Request Buffer Max Size
+#define RESP_MAXSIZE 1024 * 10 // HTTP Response Buffer Max Size
 
-#define                ROXML_MAXSIZE   4096*2  //2011.03.08
-#define                CERT_MAXSIZE    4096    //2011.03.08
+#define ROXML_MAXSIZE 4096 * 2
+#define CERT_MAXSIZE 4096
 
-#define                SID_SIZE        4
-#define                CID_SIZE        1024            //2011.03.08 ( 32 -> 1024 )
-#define                CEK_SIZE        32          // multiplication of 8
-#define                GMT_SIZE        21
+#define SID_SIZE 4
+#define CID_SIZE 1024 // 32 -> 1024
+#define CEK_SIZE 32   // multiplication of 8
+#define GMT_SIZE 21
 
 // Core Value Size define
-#define                DUID_SIZE               32
-#define                DEVICEKEY_SIZE  16
-#define                ROID_SIZE               32
-#define                DHKey_SIZE              128             //Max 1024 bit
+#define DUID_SIZE 32
+#define DEVICEKEY_SIZE 16
+#define ROID_SIZE 32
+#define DHKey_SIZE 128 // bit
 
 // DRM Type : Tizen DRM DRM - 1
-#define                TIZEN_DRM               1
+#define TIZEN_DRM 1
 
 // RO Permission Type
-#define                DUID_RULE               1
+#define DUID_RULE 1
 
 typedef char CHAR;
 typedef bool BOOL;
 
-typedef struct t_file_header
-{
-       unsigned char   Version[2];
-       unsigned char   DRMType;
-       unsigned char   ContentsType[128];
-       long long               TotalSize;
-       long long               Offset1;
-       long long               Offset2;
-       long long               Offset3;
-       long long               Offset4;
-       long long               Offset5;
-       long long               Offset6;
-       long long               Offset7;
-       long long               Offset8;
-}T_FILE_HEADER;
-
-typedef struct t_drm_header
-{
-       long                    XmlSize;
-       unsigned char   Version[2];
-       unsigned char   *SID;
-       unsigned char   *CID;
-       unsigned char   ContentsType[128];
-       long                    EncryptionMethod;
-       long                    EncryptionLevel;
-       long long               EncryptionRange;
-       unsigned char   *RIURL;
-       long long               PlaintextSize;
-       unsigned char   *Packdate;
-       unsigned char   *CEK;
+typedef struct t_file_header {
+       unsigned char Version[2];
+       unsigned char DRMType;
+       unsigned char ContentsType[128];
+       long long TotalSize;
+       long long Offset1;
+       long long Offset2;
+       long long Offset3;
+       long long Offset4;
+       long long Offset5;
+       long long Offset6;
+       long long Offset7;
+       long long Offset8;
+} T_FILE_HEADER;
+
+typedef struct t_drm_header {
+       long XmlSize;
+       unsigned char Version[2];
+       unsigned char *SID;
+       unsigned char *CID;
+       unsigned char ContentsType[128];
+       long EncryptionMethod;
+       long EncryptionLevel;
+       long long EncryptionRange;
+       unsigned char *RIURL;
+       long long PlaintextSize;
+       unsigned char *Packdate;
+       unsigned char *CEK;
 } T_DRM_HEADER;
 
-typedef struct t_decice_info
-{
-       unsigned char   DUID[DUID_SIZE + 1];
+typedef struct t_decice_info {
+       unsigned char DUID[DUID_SIZE + 1];
 } T_DEVICE_INFO;
 
-typedef struct t_dh_info
-{
-       unsigned char   p[DHKey_SIZE+1];                                // DH prime binary
-       long                    pSize;
-       long                    g;                                                      // DH primitive root. ( 2 or 5 )
-       unsigned char   a[DHKey_SIZE+1];                                // DH Client private  binary
-       long                    aSize;
-       unsigned char   A[DHKey_SIZE+1];                                // DH Client public binary (ga mod p)
-       long                    ASize;
-       unsigned char   B[DHKey_SIZE+1];                                // DH Server public binary (gb mod p)
-       long                    BSize;
-       unsigned char   K[32+1];                                                // DH Session Key
+typedef struct t_dh_info {
+       unsigned char p[DHKey_SIZE + 1]; // DH prime binary
+       long pSize;
+       long g;                          // DH primitive root. ( 2 or 5 )
+       unsigned char a[DHKey_SIZE + 1]; // DH Client private  binary
+       long aSize;
+       unsigned char A[DHKey_SIZE + 1]; // DH Client public binary (ga mod p)
+       long ASize;
+       unsigned char B[DHKey_SIZE + 1]; // DH Server public binary (gb mod p)
+       long BSize;
+       unsigned char K[32 + 1]; // DH Session Key
 } T_DH_INFO;
 
-typedef struct t_ro_content
-{
-       unsigned char   *CID;
-       unsigned char   *CEK;
+typedef struct t_ro_content {
+       unsigned char *CID;
+       unsigned char *CEK;
 } T_RO_CONTENT;
 
-typedef struct t_roacq_info
-{
-       unsigned char*  ROAcqURL;
-       unsigned char*  ReqID;
-       T_DH_INFO               t_DHInfo;
-       unsigned char   sTimeStamp[21];
+typedef struct t_roacq_info {
+       unsigned char *ROAcqURL;
+       unsigned char *ReqID;
+       T_DH_INFO t_DHInfo;
+       unsigned char sTimeStamp[21];
 } T_ROACQ_INFO;
 
-typedef struct t_individual
-{
-       unsigned char   BindingType;
-       unsigned char*  DUID;
+typedef struct t_individual {
+       unsigned char BindingType;
+       unsigned char *DUID;
 } T_INDIVIDUAL;
 
-typedef struct t_ro_permission
-{
+typedef struct t_ro_permission {
        T_INDIVIDUAL t_Individual;
 } T_RO_PERMISSION;
 
 
-typedef struct t_ro
-{
-       short   int             PerFlag;
-       T_RO_CONTENT    t_Content;
+typedef struct  t_ro {
+       short int PerFlag;
+       T_RO_CONTENT t_Content;
        T_RO_PERMISSION t_Permission;
 } T_RO;
 
-int    TADC_SetDeviceInfo(T_DEVICE_INFO *t_DeviceInfo);
-int    TADC_GetFileHeader(unsigned char *inBuffer, T_FILE_HEADER *t_FileHeader);
-int    TADC_GetDRMHeader(unsigned char *inBuffer, T_DRM_HEADER *t_DRMHeader);
-int    TADC_GetDRMHeaderInfo(unsigned char * inBuffer, T_DRM_HEADER *t_DRMHeader);
-int    TADC_GetDRMHeaderFromFile(const char *pTADCFilepath, T_FILE_HEADER *t_FileHeader, T_DRM_HEADER *t_DRMHeader);
-int    TADC_MakeRequestLicense(T_DEVICE_INFO *t_DeviceInfo, T_FILE_HEADER *t_FileHeader, T_DRM_HEADER *t_DRMHeader, unsigned char * outBuffer, size_t outBufferSize);
-int    TADC_GetROAcqInfo(unsigned char *inBuffer, T_ROACQ_INFO *t_ROAcqInfo);
-int    TADC_MakeRequestRO(T_ROACQ_INFO *t_ROAcqInfo, unsigned char *outBuffer, size_t outBufferSize, unsigned char *ROVer=NULL); //2011.03.08
-int    TADC_GetResponseRO(unsigned char *inBuffer, T_ROACQ_INFO *t_ROAcqInfo, T_RO *t_RO, unsigned char *outBuffer);
+int TADC_SetDeviceInfo(T_DEVICE_INFO *t_DeviceInfo);
+int TADC_GetFileHeader(unsigned char *inBuffer, T_FILE_HEADER *t_FileHeader);
+int TADC_GetDRMHeader(unsigned char *inBuffer, T_DRM_HEADER *t_DRMHeader);
+int TADC_GetDRMHeaderInfo(unsigned char *inBuffer, T_DRM_HEADER *t_DRMHeader);
+int TADC_GetDRMHeaderFromFile(const char *pTADCFilepath,
+                                                         T_FILE_HEADER *t_FileHeader, T_DRM_HEADER *t_DRMHeader);
+int TADC_MakeRequestLicense(T_DEVICE_INFO *t_DeviceInfo,
+                                                       T_FILE_HEADER *t_FileHeader, T_DRM_HEADER *t_DRMHeader,
+                                                       unsigned char *outBuffer, size_t outBufferSize);
+int TADC_GetROAcqInfo(unsigned char *inBuffer, T_ROACQ_INFO *t_ROAcqInfo);
+int TADC_MakeRequestRO(T_ROACQ_INFO *t_ROAcqInfo, unsigned char *outBuffer,
+                                          size_t outBufferSize, unsigned char *ROVer = NULL);
+int TADC_GetResponseRO(unsigned char *inBuffer, T_ROACQ_INFO *t_ROAcqInfo,
+                                          T_RO *t_RO, unsigned char *outBuffer);
 int TADC_GetResponseROInfo(LPBYTE pszXML,  T_RO *t_RO);
-int    TADC_GetHashReqID(unsigned char *inBuffer, unsigned char *hashReqID);
-int    TADC_GetCEK(T_DEVICE_INFO *t_DeviceInfo, T_RO *t_RODB, T_DRM_HEADER *t_DRMHeader );
-int TADC_DecryptBlock(char* pbBuffer, int nSize, const T_DRM_HEADER *t_DRMHeader);
-int    TADC_VerifyROSignature(IN LPBYTE pszXML);
+int TADC_GetHashReqID(unsigned char *inBuffer, unsigned char *hashReqID);
+int TADC_GetCEK(T_DEVICE_INFO *t_DeviceInfo, T_RO *t_RODB,
+                               T_DRM_HEADER *t_DRMHeader);
+int TADC_DecryptBlock(char *pbBuffer, int nSize,
+                                         const T_DRM_HEADER *t_DRMHeader);
+int TADC_VerifyROSignature(LPBYTE pszXML);
 DWORD TADC_GetLastError(void);
 int TADC_MEMFree_RO(T_RO *t_ro);
 int TADC_MEMFree_FileHeader(T_FILE_HEADER *t_FileHeader);
 int TADC_MEMFree_DRMHeader(T_DRM_HEADER *t_DrmHeader);
 int TADC_MEMFree_ROAcqInfo(T_ROACQ_INFO *t_ROAcqInfo);
+
+#endif //__TADCCORE_H_
index e7515df..7372c48 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 #ifndef __TADC_ERRORCODE_H__
 #define __TADC_ERRORCODE_H__
 
 #include "drm-tizen-error.h"
 
 #endif // __TADC_ERRORCODE_H__
-
index e868971..06d78e5 100644 (file)
@@ -13,8 +13,8 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
-#pragma once
+#ifndef __TADCIF_H_
+#define __TADCIF_H_
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -32,13 +32,15 @@ int TADC_IF_GetDUID(char *DUID);
 int TADC_IF_GetDHKey(T_DH_INFO *t_dhinfo);
 int TADC_IF_GetDHKey_K(T_DH_INFO *t_dhinfo);
 
-int TADC_IF_AES_CTR(unsigned char *pKey, int ivLen, unsigned char *pIV, int inLen, unsigned char *in, int *pOutLen, unsigned char *out);
+int TADC_IF_AES_CTR(unsigned char *pKey, int ivLen, unsigned char *pIV,
+                                       int inLen, unsigned char *in, int *pOutLen, unsigned char *out);
 int TADC_IF_SHA1(unsigned char *in, int inLen, unsigned char *out);
 
 size_t TADC_IF_StrLen(const char *string);
 int TADC_IF_StrCmp(const char *string1, const char *string2);
 int TADC_IF_StrNCmp(const char *string1, const char *string2, size_t count);
-char *TADC_IF_StrNCpy(char *strDestination, const char *strSource, size_t count);
+char *TADC_IF_StrNCpy(char *strDestination, const char *strSource,
+                                         size_t count);
 
 int TADC_IF_MemCmp(const void *buf1, const void *buf2, size_t count);
 void TADC_IF_MemCpy(void *dest, const void *src, size_t count);
@@ -51,9 +53,11 @@ int TADC_IF_AtoI(char *str);
 
 void TADC_IF_Debug(const char *str);
 
-int TADC_IF_VerifySignature( unsigned char* inData, int inLen,
-                                                        unsigned char* sigData, int sigLen,
-                                                        unsigned char* cert, int certLen );
+int TADC_IF_VerifySignature(unsigned char *inData, int inLen,
+                                                       unsigned char *sigData, int sigLen,
+                                                       unsigned char *cert, int certLen);
+
+int TADC_IF_VerifyCertChain(unsigned char *rica, int ricaLen,
+                                                       unsigned char *cert, int certLen);
 
-int TADC_IF_VerifyCertChain( unsigned char* rica, int ricaLen,
-                                                        unsigned char* cert, int certLen );
+#endif //__TADCIF_H_
index 7a4e11d..937ed39 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
-#pragma once
+#ifndef __TADCSUB_H_
+#define __TADCSUB_H_
 
 #include "TADC_Core.h"
 
-extern DWORD   m_NEDErrorCode;
+extern DWORD m_NEDErrorCode;
+
+extern UINT htons_(UINT hostshort);
+extern DWORD htonl_(DWORD hostlong);
+extern INT64 _hton64(INT64 n64host);
 
-extern         UINT htons_(UINT hostshort);
-extern DWORD htonl_(DWORD hostlong);
-extern INT64 _hton64( INT64 n64host );
+#endif //__TADCSUB_H_
index 4ac466f..e7428a6 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
-#pragma once
+#ifndef __TADCUTIL_H_
+#define __TADCUTIL_H_
 
 #include "TadcTypes.h"
 
-LPSTR Base64Encode( LPBYTE pbData,  int nLength ) ;
-LPBYTE Base64Decode(  LPCSTR pszString,  int* pnLength ) ;
-int FindString( unsigned char *in, int inLen, unsigned char *find, int findLen );
-int HEX2BIN(  LPCSTR pszHex,  LPBYTE baBin,  int* pnLength ) ;
+LPSTR Base64Encode(LPBYTE pbData, int nLength);
+LPBYTE Base64Decode(LPCSTR pszString, int *pnLength);
+int FindString(unsigned char *in, int inLen, unsigned char *find, int findLen);
+int HEX2BIN(LPCSTR pszHex, LPBYTE baBin, int *pnLength);
+
+#endif //__TADCUTIL_H_
index 5834858..5389b24 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 /**
- * @file       TadcTypes.h
- * @brief      This file includes definitions of constants,
- *                     enumerations, and datastructures for the DRM service.
- * @version    1.0
+ * @file    TadcTypes.h
+ * @brief   Constants, enumerations, and datastructures for the DRM service.
+ * @version 1.0
  */
-
 #ifndef __TADC_DRM_TYPES_H__
 #define __TADC_DRM_TYPES_H__
 
 #include <stdarg.h>
 
 #define _T
-#define                IF_ERROR_GOTO( error )  if( FAILED( HRESULT_FROM_WIN32( error ) ) ) { nResult = ERRORMSG( error, NULL ); goto finish; }
-#define                IF_TRUE_GOTO( cond, error )     if( cond ) { nResult = -1; goto finish; }
+#define IF_ERROR_GOTO(error) \
+       if (FAILED(HRESULT_FROM_WIN32(error))) { \
+               nResult = ERRORMSG(error, NULL); \
+               goto finish; \
+       }
+#define IF_TRUE_GOTO(cond, error) \
+       if (cond) { \
+               nResult = -1; \
+               goto finish; \
+       }
 
 #ifndef _SHP_SIMUL
-typedef voidLPVOID;
-typedef const charLPCTSTR;
-typedef unsigned charLPBYTE;
+typedef void *LPVOID;
+typedef const char *LPCTSTR;
+typedef unsigned char *LPBYTE;
 typedef char TCHAR;
-typedef charLPTSTR;
+typedef char *LPTSTR;
 typedef LPTSTR LPSTR;
 typedef LPCTSTR LPCTSTR;
 typedef LPCTSTR LPCSTR;
 
 //typedef HFile HANDLE;
-#define ERROR_INVALID_DATA               13L
-#define ERROR_INSUFFICIENT_BUFFER        122L    // dderror
+#define ERROR_INVALID_DATA        13L
+#define ERROR_INSUFFICIENT_BUFFER 122L // dderror
 //#define CopyMemory AcMemcpy
-#define INVALID_HOBJ   NULL
-#endif
+#define INVALID_HOBJ NULL
+#endif //_SHP_SIMUL
 
-#endif //__TADC_DRM_TYPES_H__
+#endif  //__TADC_DRM_TYPES_H__
index 2741427..a5c9f6c 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 /**
- * @file       DTapps2Base64.h
- * @brief      This file includes declarations for Base64 Encode Decode APIs.
+ * @file    DTapps2Base64.h
+ * @brief   Base64 Encode Decode APIs.
  */
-
 #ifndef __DTAPPS_BASE64_H__
 #define __DTAPPS_BASE64_H__
 
-#ifdef __cplusplus
-        extern "C" {
-#endif
-
 #include "drm_intf_tapps.h"
 
-BOOL DTappsB64Encode(unsigned char* in, int in_size, unsigned char* out, int out_size);
-int DTappsB64Decode(unsigned char* in, int in_size, unsigned char* out, int& out_size);
-
-#ifdef __cplusplus
-}
-#endif
-
+BOOL DTappsB64Encode(unsigned char *in, int in_size, unsigned char *out,
+                                        int out_size);
+int DTappsB64Decode(unsigned char *in, int in_size, unsigned char *out,
+                                       int &out_size);
 
 #endif /*__DTAPPS_BASE64_H__ */
index 3cac56b..3a098b3 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 /**
- * @file       DTapps2HMAC.h
- * @brief      This file includes declarations relating to HMAC.
+ * @file    DTapps2HMAC.h
+ * @brief   HMAC.
  */
-
 #ifndef __DTAPPS_HMAC_H__
 #define __DTAPPS_HMAC_H__
 
-#ifdef __cplusplus
-        extern "C" {
-#endif
-
 #include "drm_intf_tapps.h"
 
-void DTappsCalHMACSHA1(unsigned char* key,int key_len,unsigned char* msg,size_t msglen,unsigned char *md,unsigned int *md_len);
-int DTappsGetDeviceKey(unsigned char **pDevKey,unsigned int *DevKeyLen);
+void DTappsCalHMACSHA1(unsigned char *key, int key_len, unsigned char *msg,
+                                          size_t msglen, unsigned char *md, unsigned int *md_len);
+int DTappsGetDeviceKey(unsigned char **pDevKey, unsigned int *DevKeyLen);
 void DTappsFreeDeviceKey(unsigned char **pDevKey);
 
-#ifdef __cplusplus
-}
-#endif
-
 #endif /*__DTAPPS_HMAC_H__ */
index 66a8e71..55db0ea 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 /**
- * @file       DTapps2Rights.h
- * @brief      This file includes declarations and classes relating to Rights.
+ * @file    DTapps2Rights.h
+ * @brief   Rights.
  */
-
 #ifndef __DTAPPS_RIGHTS_H__
 #define __DTAPPS_RIGHTS_H__
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 #include "drm_intf_tapps.h"
 
-#define DTAPPS_NAME_SIZE       512
-#define DTAPPS_CEK_SIZE                32
-#define DTAPPS_CID_SIZE                1024
+#define DTAPPS_NAME_SIZE    512
+#define DTAPPS_CEK_SIZE     32
+#define DTAPPS_CID_SIZE     1024
 
-typedef enum
-{
+typedef enum {
        DTAPPS_INSTALL,
        DTAPPS_VERIFY,
 } DTAPPS_OPERATION;
 
-typedef struct
-{
+typedef struct {
        unsigned char DUID[DTAPPS_DUID_SIZE + 1];
 } DTAPPS_CONSTRAINTS;
 
 /*
 typedef enum
 {
-       DTAPPS_LIC_VALID = 1,
-       DTAPPS_LIC_NO_LICENCE,
-       DTAPPS_LIC_DUID_MISMATCH,
-       DTAPPS_LIC_UNKNOWN_ERROR = -1,
-       DTAPPS_LIC_DB_ERROR = -998,
+    DTAPPS_LIC_VALID = 1,
+    DTAPPS_LIC_NO_LICENCE,
+    DTAPPS_LIC_DUID_MISMATCH,
+    DTAPPS_LIC_UNKNOWN_ERROR = -1,
+    DTAPPS_LIC_DB_ERROR = -998,
 } int;
 */
 
-typedef struct
-{
-    int r_id;
-    char name[512];
-    char cid[1024];
-    char time[64];// enough size
-    #ifdef DTAPPS_STORE_CEK_IN_DB
-    char cek[128];
-    char cek_hash[64];
-    #endif
-    char constraint_buffer[512];
-    char constraint_hash[64];
+typedef struct {
+       int r_id;
+       char name[512];
+       char cid[1024];
+       char time[64];// enough size
+#ifdef DTAPPS_STORE_CEK_IN_DB
+       char cek[128];
+       char cek_hash[64];
+#endif
+       char constraint_buffer[512];
+       char constraint_hash[64];
 } DTAPPS_RIGHTS_ROW;
 
-int DTappsValidateConstraints(DTAPPS_CONSTRAINTS* st_const, DTAPPS_OPERATION opr);
-int DTappsInstallLicense(const char* declicbuffer);
-int DTappsHasValidLicense(const char* szCid);
-int DTappsGetROInfo(const char* pszXML, T_RO *t_RO, unsigned char* name);
-int DTappsCalcEval(DTAPPS_CONSTRAINTS* st_const);
-BOOL DTappsGetCEK(const char* szCid,T_RO* t_RO);
+int DTappsValidateConstraints(DTAPPS_CONSTRAINTS *st_const,
+                                                         DTAPPS_OPERATION opr);
+int DTappsInstallLicense(const char *declicbuffer);
+int DTappsHasValidLicense(const char *szCid);
+int DTappsGetROInfo(const char *pszXML, T_RO *t_RO, unsigned char *name);
+int DTappsCalcEval(DTAPPS_CONSTRAINTS *st_const);
+BOOL DTappsGetCEK(const char *szCid, T_RO *t_RO);
 
 /* Declaration for Table Handling */
-BOOL DTapps_RIGHTS_INSTALL(const char* name,
-                          const char* time,
-                          #ifdef DTAPPS_STORE_CEK_IN_DB
-                          const char* cek,
-                          const char* cek_hash,
-                          #endif
-                          const char* constraint_buffer,
-                          const char* constraint_hash,
-                          const char* cid,
-                          BOOL isUpdate);
-
-BOOL DTapps_RIGHTS_SELECT_ONE(const char* cid, DTAPPS_RIGHTS_ROW* row);
-
-#ifdef __cplusplus
-}
+BOOL DTapps_RIGHTS_INSTALL(const char *name,
+                                                  const char *time,
+#ifdef DTAPPS_STORE_CEK_IN_DB
+                                                  const char *cek,
+                                                  const char *cek_hash,
 #endif
+                                                  const char *constraint_buffer,
+                                                  const char *constraint_hash,
+                                                  const char *cid,
+                                                  BOOL isUpdate);
+
+BOOL DTapps_RIGHTS_SELECT_ONE(const char *cid, DTAPPS_RIGHTS_ROW *row);
 
 #endif /*__DTAPPS_RIGHTS_H__ */
index 4e434d9..72fc9b5 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 /**
- * @file       DTapps2SqliteDB.h
- * @brief      This file includes declarations and classes relating to DataBase.
+ * @file    DTapps2SqliteDB.h
+ * @brief   DataBase.
  */
-
 #ifndef __DTAPPS_SQLITE_DB_H__
 #define __DTAPPS_SQLITE_DB_H__
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 #include "TADC_Core.h"
 #include "drm_intf_tapps.h"
 
 #define DTAPPS_SQL_FREE_TABLE sqlite3_free_table
 
-typedef        struct _tagTAPPSSqliteSelectTable{
-       sqlite3*        handle;
-       char**          result;
-       int             n_rows;
-       int             n_cols;
-}TAPPSSqliteSelectTable;
+typedef struct _tagTAPPSSqliteSelectTable {
+       sqlite3 *handle;
+       char **result;
+       int n_rows;
+       int n_cols;
+} TAPPSSqliteSelectTable;
 
 /* Declarations for DB Wrappers */
-BOOL DTappsDBOpen(void *&pDb,const char* CallingFun);
-BOOL DTappsDBGet(void *& pDBConnection);
-BOOL DTappsDBClose(const char* CallingFun);
-BOOL DTappsDBBeginImmedTrans (const char* CallingFun);
-BOOL DTappsDBCommit(const char* CallingFun);
-BOOL DTappsDBRollback (const char* CallingFun);
-BOOL DTappsExecuteSQL(void* pDB, const char* query);
-BOOL DTappsSQLGetTable(void* pDB, const char* query, TAPPSSqliteSelectTable* select_table);
-char* DTappsGetSQLCreateTable(const char* tableName);
-void* DTappsStmtPrepare(void* pDB, const char* query);
-int DTappsStmtBindParam (
-       void* pStmt,
+BOOL DTappsDBOpen(void *&pDb, const char *CallingFun);
+BOOL DTappsDBGet(void *&pDBConnection);
+BOOL DTappsDBClose(const char *CallingFun);
+BOOL DTappsDBBeginImmedTrans(const char *CallingFun);
+BOOL DTappsDBCommit(const char *CallingFun);
+BOOL DTappsDBRollback(const char *CallingFun);
+BOOL DTappsExecuteSQL(void *pDB, const char *query);
+BOOL DTappsSQLGetTable(void *pDB, const char *query,
+                                          TAPPSSqliteSelectTable *select_table);
+char *DTappsGetSQLCreateTable(const char *tableName);
+void *DTappsStmtPrepare(void *pDB, const char *query);
+int DTappsStmtBindParam(
+       void *pStmt,
        unsigned int dIdx,
        unsigned int Type,
-       void* pParam,
-       unsigned int dParamSize );
-int DTappsStmtExecute (void* pStmt);
-int DTappsStmtRelease (void* pStmt);
-BOOL DTapps_DB_Install(const char* sql_query);
-BOOL DTapps_Read_DB(const char* sql_query, TAPPSSqliteSelectTable* select_table);
-
-#ifdef __cplusplus
-}
-#endif
+       void *pParam,
+       unsigned int dParamSize);
+int DTappsStmtExecute(void *pStmt);
+int DTappsStmtRelease(void *pStmt);
+BOOL DTapps_DB_Install(const char *sql_query);
+BOOL DTapps_Read_DB(const char *sql_query,
+                                       TAPPSSqliteSelectTable *select_table);
 
 #endif /*__DTAPPS_SQLITE_DB_H__ */
index 4a3ec33..0f4565e 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 /**
- * @file       DTapps2Time.h
- * @brief      This file includes declarations relating to TIME APIs.
+ * @file    DTapps2Time.h
+ * @brief   TIME APIs.
  */
-
 #ifndef __DTAPPS_TIME_H__
 #define __DTAPPS_TIME_H__
 
-#ifdef __cplusplus
-         extern "C" {
-#endif
-
 #include "drm_intf_tapps.h"
 
-BOOL DTappsDtTmStr2Sec(unsigned char *time_str,time_t *TotalSec);
-BOOL DTappsDtTmStr2StrucTm(unsigned char *time_str,struct tm *time_fmt);
-BOOL DTappsGetSecureTime(time_t* seconds);
-
-#ifdef __cplusplus
-}
-#endif
+BOOL DTappsDtTmStr2Sec(unsigned char *time_str, time_t *TotalSec);
+BOOL DTappsDtTmStr2StrucTm(unsigned char *time_str, struct tm *time_fmt);
+BOOL DTappsGetSecureTime(time_t *seconds);
 
 #endif /*__DTAPPS_TIME_H__ */
index bcaa94f..85ed411 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 /**
- * @file       drm_intf_tapps.h
- * @brief      This file includes declarations of the drm TAPPS intf APIs.
+ * @file    drm_intf_tapps.h
+ * @brief   drm TAPPS intf APIs.
  */
-
 #ifndef __DRM_INTF_TAPPS_H__
 #define __DRM_INTF_TAPPS_H__
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/syscall.h>
@@ -59,9 +53,7 @@ extern "C" {
 
 #define DTAPPS_DUID_SIZE 32
 
-#if  0
-#define DTAPPS_IMEI_PATH VCONFKEY_TELEPHONY_IMEI
-#endif
+//#define DTAPPS_IMEI_PATH VCONFKEY_TELEPHONY_IMEI
 
 /*************************************************************************************************************/
 typedef bool BOOL;
@@ -86,14 +78,14 @@ typedef bool BOOL;
 #define DTAPPS_DB_NAME DB_PATH
 
 typedef enum {
-   TAPPSDB_TYPE_NONE,
-   TAPPSDB_TYPE_INT,
-   TAPPSDB_TYPE_DATETIME,
-   TAPPSDB_TYPE_CHAR,
-   TAPPSDB_TYPE_VARCHAR,
-   TAPPSDB_TYPE_BINARY,
-   TAPPSDB_TYPE_BLOB,
-   TAPPSDB_TYPE_UNKNOWN = 0xFFFFFFFF
+       TAPPSDB_TYPE_NONE,
+       TAPPSDB_TYPE_INT,
+       TAPPSDB_TYPE_DATETIME,
+       TAPPSDB_TYPE_CHAR,
+       TAPPSDB_TYPE_VARCHAR,
+       TAPPSDB_TYPE_BINARY,
+       TAPPSDB_TYPE_BLOB,
+       TAPPSDB_TYPE_UNKNOWN = 0xFFFFFFFF
 } TAPPSDbType;
 
 /* Enable this Flag if CEK is to be stored in DB */
@@ -109,28 +101,28 @@ typedef enum {
 #define MCATCH_B _M_catch:
 
 #define MTHROW_B   \
-{                  \
-       goto _M_catch; \
-}
+       {                  \
+               goto _M_catch; \
+       }
 
 #define MTHROW_BL            \
-{                            \
-       M_LOGLINE("Throw error") \
-       goto _M_catch;           \
-}
+       {                            \
+               M_LOGLINE("Throw error") \
+               goto _M_catch;           \
+       }
 
 
 #define MCFG_DISPLAY_ERROR_LINE
 
 #define DRM_LINUX_SYSDEBUG(dbg_lvl, FMT, ARG...) \
-{                                                \
-       if ((dbg_lvl) == MID_EXCEPTION)              \
-               DRM_TAPPS_EXCEPTION(FMT, ##ARG);         \
-       else if((dbg_lvl) == MID_DRM)                \
-               DRM_TAPPS_LOG(FMT, ##ARG);               \
-       else                                         \
-               DRM_TAPPS_FRQ_LOG(FMT, ##ARG);           \
-}
+       {                                                \
+               if ((dbg_lvl) == MID_EXCEPTION)              \
+                       DRM_TAPPS_EXCEPTION(FMT, ##ARG);         \
+               else if ((dbg_lvl) == MID_DRM)               \
+                       DRM_TAPPS_LOG(FMT, ##ARG);               \
+               else                                         \
+                       DRM_TAPPS_FRQ_LOG(FMT, ##ARG);           \
+       }
 
 #ifdef MCFG_DISPLAY_ERROR_LINE
 #define M_LOGLINE(log_prefix) DRM_LINUX_SYSDEBUG(MID_EXCEPTION, "(%s)[Statement] "#log_prefix"", __func__)
@@ -139,12 +131,12 @@ typedef enum {
 #endif // MCFG_DISPLAY_ERROR_LINE
 
 #define MTRY_BL(f)                     \
-{                                      \
-       if ((f) == 0) {                    \
-               M_LOGLINE("Try catched("#f")") \
-               goto _M_catch;                 \
-       }                                  \
-}
+       {                                      \
+               if ((f) == 0) {                    \
+                       M_LOGLINE("Try catched("#f")") \
+                       goto _M_catch;                 \
+               }                                  \
+       }
 
 /*************************************************************************************************************/
 /* Mutex structure */
@@ -152,8 +144,8 @@ typedef pthread_mutex_t dtapps_mutex_t;
 
 #define dtappslockarg  dtapps_mutex_t*
 
-int dtapps_mutex_lock (dtappslockarg dtapps_mutex);
-int dtapps_mutex_unlock (dtappslockarg dtapps_mutex);
+int dtapps_mutex_lock(dtappslockarg dtapps_mutex);
+int dtapps_mutex_unlock(dtappslockarg dtapps_mutex);
 
 /*************************************************************************************************************/
 /* Memory Operations Wrapper APIs */
@@ -177,16 +169,19 @@ int dtapps_mutex_unlock (dtappslockarg dtapps_mutex);
 
 /* String Operations Wrapper APIs */
 #ifdef _TAPPS_DEBUG_ENABLE_
-unsigned int TAPPS_gstrlcat(char* s1,const char* s2,unsigned int destsize,const char* funName, unsigned int lineno);
-unsigned int TAPPS_gstrlcpy(char* s1,const char* s2,unsigned int destsize,const char* funName, unsigned int lineno);
-unsigned int TAPPS_strlen(const char* s,const char* funName, unsigned int lineno);
-
-#define TAPPS_GSTRLCPY(dest,src,LenDest) TAPPS_gstrlcpy(dest,src,LenDest,__func__,__LINE__)
-#define TAPPS_GSTRLCAT(dest,src,LenDest) TAPPS_gstrlcat(dest,src,LenDest,__func__,__LINE__)
-#define TAPPS_STRLEN(string) TAPPS_strlen(string,__func__,__LINE__)
+unsigned int TAPPS_gstrlcat(char *s1, const char *s2, unsigned int destsize,
+                                                       const char *funName, unsigned int lineno);
+unsigned int TAPPS_gstrlcpy(char *s1, const char *s2, unsigned int destsize,
+                                                       const char *funName, unsigned int lineno);
+unsigned int TAPPS_strlen(const char *s, const char *funName,
+                                                 unsigned int lineno);
+
+#define TAPPS_GSTRLCPY(dest, src, LenDest) TAPPS_gstrlcpy(dest, src, LenDest, __func__, __LINE__)
+#define TAPPS_GSTRLCAT(dest, src, LenDest) TAPPS_gstrlcat(dest, src, LenDest, __func__, __LINE__)
+#define TAPPS_STRLEN(string) TAPPS_strlen(string, __func__, __LINE__)
 #else
-#define TAPPS_GSTRLCPY(dest,src,LenDest) g_strlcpy(dest, src, LenDest)
-#define TAPPS_GSTRLCAT(dest,src,LenDest) g_strlcat(dest, src, LenDest)
+#define TAPPS_GSTRLCPY(dest, src, LenDest) g_strlcpy(dest, src, LenDest)
+#define TAPPS_GSTRLCAT(dest, src, LenDest) g_strlcat(dest, src, LenDest)
 #define TAPPS_STRLEN(string) strlen(string)
 #endif
 
@@ -194,11 +189,11 @@ unsigned int TAPPS_strlen(const char* s,const char* funName, unsigned int lineno
 #define DTAPPS_ATOI atoi
 #define DTAPPS_STRNCMP strncmp
 
-int TAPPS_strnicmp(const char * s1, const char * s2, unsigned int sz);
+int TAPPS_strnicmp(const char *s1, const char *s2, unsigned int sz);
 /*************************************************************************************************************/
 /* SLEEP API */
 
-void dtapps_sleep(unsigned int TimeInSec,unsigned int TimeInMicroSec);
+void dtapps_sleep(unsigned int TimeInSec, unsigned int TimeInMicroSec);
 
 /*************************************************************************************************************/
 
@@ -210,8 +205,5 @@ void dtapps_sleep(unsigned int TimeInSec,unsigned int TimeInMicroSec);
 #define DTAPPS_AES_UNWRAP_KEY AES_unwrap_key
 
 /*************************************************************************************************************/
-#ifdef __cplusplus
-}
-#endif
 
 #endif /* __DRM_INTF_TAPPS_H__ */
index 475693f..529cb53 100644 (file)
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
- */
-
-/**
- * @file       DTapps2SqlData.cpp
- * @brief      This file contains all the Database tables.
+ *
+ * @file    DTapps2SqlData.cpp
+ * @brief   Database tables.
  */
 
 #include "drm_intf_tapps.h"
 #define DTAPPS_TABLE_CONTINUE        "\0\1"
 #define DTAPPS_TABLE_END             "\0",
 
-const char* dtappsCreateTableSQLData[] =
-{
+const char *dtappsCreateTableSQLData[] = {
        DTAPPS_TABLE_NAME("dtapps2rights")
-               "CREATE TABLE dtapps2rights ("
-               "r_id INTEGER PRIMARY KEY AUTOINCREMENT,"
-               "name VARCHAR(512) DEFAULT NULL,"
-               "cid VARCHAR(1024) DEFAULT NULL,"
-               "time_t DATETIME,"
-               #ifdef DTAPPS_STORE_CEK_IN_DB
-               "cek VARCHAR(128) DEFAULT NULL,"
-               "cek_hash VARCHAR(64) DEFAULT NULL,"
-               #endif
-               "constraint_buffer VARCHAR(512) DEFAULT NULL,"
-               "constraint_hash VARCHAR(64) DEFAULT NULL"
+       "CREATE TABLE dtapps2rights ("
+       "r_id INTEGER PRIMARY KEY AUTOINCREMENT,"
+       "name VARCHAR(512) DEFAULT NULL,"
+       "cid VARCHAR(1024) DEFAULT NULL,"
+       "time_t DATETIME,"
+#ifdef DTAPPS_STORE_CEK_IN_DB
+       "cek VARCHAR(128) DEFAULT NULL,"
+       "cek_hash VARCHAR(64) DEFAULT NULL,"
+#endif
+       "constraint_buffer VARCHAR(512) DEFAULT NULL,"
+       "constraint_hash VARCHAR(64) DEFAULT NULL"
        ");"
 
        DTAPPS_TABLE_END
index 49f26f8..31d78e0 100644 (file)
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
+ *
+ * @file    DTapps2SqliteDB.cpp
+ * @brief   DataBase.
  */
-
-/**
- * @file       DTapps2SqliteDB.cpp
- * @brief      This file includes functions relating to DataBase.
- */
-
 #include "DTapps2SqliteDB.h"
 #include <map>
 #include <memory>
@@ -33,65 +30,63 @@ static dtapps_mutex_t dtapps_sqlite_db_mutex = PTHREAD_MUTEX_INITIALIZER;
 
 typedef long int dtappsThreadID;
 
- class DtappsDBConnectionInfo
- {
- public:
-        DtappsDBConnectionInfo();
-        int     countOpenConnection;
-        sqlite3 *pDBConnection;
- };
-
- using namespace std;
- static std::map<dtappsThreadID, std::unique_ptr<DtappsDBConnectionInfo>> g_dtapps_sqlite_connection_table;
-
- DtappsDBConnectionInfo::DtappsDBConnectionInfo()
- {
-        countOpenConnection=0;
-        pDBConnection=NULL;
- }
-
- class TAPPSDbApiLock
- {
- public:
+class DtappsDBConnectionInfo {
+public:
+       DtappsDBConnectionInfo();
+       int countOpenConnection;
+       sqlite3 *pDBConnection;
+};
+
+using namespace std;
+static std::map<dtappsThreadID, std::unique_ptr<DtappsDBConnectionInfo>>
+               g_dtapps_sqlite_connection_table;
+
+DtappsDBConnectionInfo::DtappsDBConnectionInfo()
+{
+       countOpenConnection = 0;
+       pDBConnection = NULL;
+}
+
+class TAPPSDbApiLock {
+public:
        TAPPSDbApiLock();
        ~TAPPSDbApiLock();
- };
-
- TAPPSDbApiLock::TAPPSDbApiLock()
- {
-        DRM_TAPPS_FRQ_LOG("LOCK by TID = %ld",drmgettid());
-        if (0 != dtapps_mutex_lock (&dtapps_sqlite_db_mutex))
-        {
-                DRM_TAPPS_EXCEPTION("Error while mutex locking.");
-        }
- }
-
- TAPPSDbApiLock::~TAPPSDbApiLock()
- {
-        DRM_TAPPS_FRQ_LOG("UNLOCK by TID = %ld",drmgettid());
-        if (0 != dtapps_mutex_unlock(&dtapps_sqlite_db_mutex))
-        {
-                DRM_TAPPS_EXCEPTION("Error while mutex unlocking");
-        }
- }
+};
+
+TAPPSDbApiLock::TAPPSDbApiLock()
+{
+       DRM_TAPPS_FRQ_LOG("LOCK by TID = %ld", drmgettid());
+
+       if (0 != dtapps_mutex_lock(&dtapps_sqlite_db_mutex))
+               DRM_TAPPS_EXCEPTION("Error while mutex locking.");
+}
+
+TAPPSDbApiLock::~TAPPSDbApiLock()
+{
+       DRM_TAPPS_FRQ_LOG("UNLOCK by TID = %ld", drmgettid());
+
+       if (0 != dtapps_mutex_unlock(&dtapps_sqlite_db_mutex))
+               DRM_TAPPS_EXCEPTION("Error while mutex unlocking");
+}
 
 #define __DTAPPS_DB_SQLITE_RETRY__  (10)
 
-#define        DTAPPS_SQLITE3_SQL_BEGIN_IMMEDIATE              "BEGIN IMMEDIATE TRANSACTION"
-#define        DTAPPS_SQLITE3_SQL_COMMIT                               "COMMIT TRANSACTION"
-#define        DTAPPS_SQLITE3_SQL_ROLLBACK                             "ROLLBACK TRANSACTION"
+#define DTAPPS_SQLITE3_SQL_BEGIN_IMMEDIATE "BEGIN IMMEDIATE TRANSACTION"
+#define DTAPPS_SQLITE3_SQL_COMMIT          "COMMIT TRANSACTION"
+#define DTAPPS_SQLITE3_SQL_ROLLBACK        "ROLLBACK TRANSACTION"
 
 /* DataBase Related API Wrappers */
-BOOL DTappsDBOpen(void *&pDb, const charCallingFun)
+BOOL DTappsDBOpen(void *&pDb, const char *CallingFun)
 {
-       DRM_TAPPS_LOG("[%s]: started.Calling function = %s",__func__,CallingFun);
+       DRM_TAPPS_LOG("[%s]: started.Calling function = %s", __func__, CallingFun);
 
        TAPPSDbApiLock Dblock;
        dtappsThreadID id_curr_thread = drmgettid();
 
-       DRM_TAPPS_SECURE_LOG("DB-OPEN-CLOSE [%s]Parent Process ID=[%ld]:Process-ID=[%ld]:Thread-ID=[%ld], id_curr_thread=[%ld]",__func__,getppid(),getpid(),drmgettid(), id_curr_thread);
+       DRM_TAPPS_SECURE_LOG("id_curr_thread=[%ld]", id_curr_thread);
 
        auto it = g_dtapps_sqlite_connection_table.find(id_curr_thread);
+
        if (it != g_dtapps_sqlite_connection_table.end()) {
                DRM_TAPPS_FRQ_LOG("Connection already exists..");
                auto &pDBConnectionInfo = it->second;
@@ -100,7 +95,10 @@ BOOL DTappsDBOpen(void *&pDb, const char* CallingFun)
                if (pDBConnectionInfo == NULL || pDBConnectionInfo->pDBConnection == NULL)
                        return FALSE;
 
-               DRM_TAPPS_FRQ_LOG("pDBConnectionInfo->countOpenConnection=[%d], pDBConnectionInfo->pDBConnection=[0x%x]", pDBConnectionInfo->countOpenConnection, pDBConnectionInfo->pDBConnection);
+               DRM_TAPPS_FRQ_LOG("pDBConnectionInfo->countOpenConnection=[%d], "
+                                                 "pDBConnectionInfo->pDBConnection=[0x%x]",
+                                                 pDBConnectionInfo->countOpenConnection,
+                                                 pDBConnectionInfo->pDBConnection);
 
                ++(pDBConnectionInfo->countOpenConnection);
                pDb = pDBConnectionInfo->pDBConnection;
@@ -108,6 +106,7 @@ BOOL DTappsDBOpen(void *&pDb, const char* CallingFun)
                DRM_TAPPS_LOG("no connection exists..");
                std::unique_ptr<DtappsDBConnectionInfo> pDBConnectionInfo(
                        new(std::nothrow) DtappsDBConnectionInfo);
+
                if (pDBConnectionInfo == NULL)
                        return FALSE;
 
@@ -115,8 +114,9 @@ BOOL DTappsDBOpen(void *&pDb, const char* CallingFun)
 
                sqlite3 *h_db = NULL;
                int result = db_util_open(DTAPPS_DB_NAME, &h_db, 0);
+
                if (result != SQLITE_OK) {
-                       DRM_TAPPS_EXCEPTION("sqlite msg :[%d]%s",result, sqlite3_errmsg(h_db));
+                       DRM_TAPPS_EXCEPTION("sqlite msg :[%d]%s", result, sqlite3_errmsg(h_db));
                        DRM_TAPPS_SECURE_LOG("db name :%s", DTAPPS_DB_NAME);
                        return FALSE;
                }
@@ -129,7 +129,10 @@ BOOL DTappsDBOpen(void *&pDb, const char* CallingFun)
                pDb = pDBConnectionInfo->pDBConnection;
 
                // Insert the node
-               DRM_TAPPS_FRQ_LOG("pDBConnectionInfo->countOpenConnection=[%d], pDBConnectionInfo->pDBConnection=[0x%x]", pDBConnectionInfo->countOpenConnection, pDBConnectionInfo->pDBConnection);
+               DRM_TAPPS_FRQ_LOG("pDBConnectionInfo->countOpenConnection=[%d], "
+                                                 "pDBConnectionInfo->pDBConnection=[0x%x]",
+                                                 pDBConnectionInfo->countOpenConnection,
+                                                 pDBConnectionInfo->pDBConnection);
 
                g_dtapps_sqlite_connection_table.emplace(
                        std::make_pair(id_curr_thread, std::move(pDBConnectionInfo)));
@@ -140,7 +143,7 @@ BOOL DTappsDBOpen(void *&pDb, const char* CallingFun)
        return TRUE;
 }
 
-BOOL DTappsDBGet(void *& pDBConnection)
+BOOL DTappsDBGet(void *&pDBConnection)
 {
        DRM_TAPPS_LOG("Inside %s", __func__);
 
@@ -148,36 +151,36 @@ BOOL DTappsDBGet(void *& pDBConnection)
        dtappsThreadID id_curr_thread = drmgettid();
        pDBConnection = NULL;
 
-       DRM_TAPPS_LOG("Parent Process ID=[%ld]:Process-ID=[%ld]:Thread-ID=[%ld], id_curr_thread=[%ld]",getppid(),getpid(),drmgettid(), id_curr_thread);
+       DRM_TAPPS_LOG("id_curr_thread=[%ld]", id_curr_thread);
 
        auto it = g_dtapps_sqlite_connection_table.find(id_curr_thread);
+
        if (it == g_dtapps_sqlite_connection_table.end() ||
-               it->second == NULL ||
-               it->second->pDBConnection == NULL)
+                       it->second == NULL ||
+                       it->second->pDBConnection == NULL)
                return FALSE;
 
        auto &pDBConnectionInfo = it->second;
        DRM_TAPPS_FRQ_LOG("countOpenConnection=[%d], pDBConnection=[0x%x]",
-               pDBConnectionInfo->countOpenConnection, pDBConnectionInfo->pDBConnection);
+                                         pDBConnectionInfo->countOpenConnection,
+                                         pDBConnectionInfo->pDBConnection);
 
        pDBConnection = pDBConnectionInfo->pDBConnection;
 
        return TRUE;
 }
 
-BOOL DTappsDBClose(const charCallingFun)
+BOOL DTappsDBClose(const char *CallingFun)
 {
        DRM_TAPPS_LOG("Inside %s Calling function = %s", __func__, CallingFun);
 
        TAPPSDbApiLock Dblock;
        dtappsThreadID id_curr_thread = drmgettid();
 
-       DRM_TAPPS_SECURE_LOG(
-               "DB-OPEN-CLOSE [%s]Parent Process ID=[%ld]:Process-ID=[%ld]"
-                       ":Thread-ID=[%ld], id_curr_thread=[%ld]",
-               __func__, getppid(), getpid(), drmgettid(), id_curr_thread);
+       DRM_TAPPS_SECURE_LOG("id_curr_thread=[%ld]", id_curr_thread);
 
        auto it = g_dtapps_sqlite_connection_table.find(id_curr_thread);
+
        if (it == g_dtapps_sqlite_connection_table.end()) {
                return FALSE;
        } else if (it->second == NULL || it->second->pDBConnection == NULL) {
@@ -187,11 +190,13 @@ BOOL DTappsDBClose(const char* CallingFun)
 
        auto &pDBConnectionInfo = it->second;
        DRM_TAPPS_FRQ_LOG("countOpenConnection=[%d], pDBConnection=[0x%x]",
-               pDBConnectionInfo->countOpenConnection, pDBConnectionInfo->pDBConnection);
+                                         pDBConnectionInfo->countOpenConnection,
+                                         pDBConnectionInfo->pDBConnection);
 
        int countConnection = --(pDBConnectionInfo->countOpenConnection);
 
        DRM_TAPPS_LOG(" countConnection=[%d] ", countConnection);
+
        if (countConnection != 0)
                return TRUE;
 
@@ -201,6 +206,7 @@ BOOL DTappsDBClose(const char* CallingFun)
 
        DRM_TAPPS_LOG("finalizing all statements..pDBConnection=[0x%x]", pDBConnection);
        sqlite3_stmt *pstmt = NULL;
+
        while ((pstmt = sqlite3_next_stmt(pDBConnection, pstmt)) != NULL) {
                DRM_TAPPS_LOG("finalizing DB statement..pstmt=[0x%x]", pstmt);
                sqlite3_finalize(pstmt);
@@ -209,9 +215,10 @@ BOOL DTappsDBClose(const char* CallingFun)
        BOOL ret = TRUE;
 
        DRM_TAPPS_LOG(" Closing DB connection..pDBConnection=[0x%x]", pDBConnection);
+
        if (db_util_close(pDBConnection) != SQLITE_OK) {
                DRM_TAPPS_EXCEPTION("db_util_close failed. errmsg:%s",
-                       sqlite3_errmsg(pDBConnection));
+                                                       sqlite3_errmsg(pDBConnection));
                ret = FALSE;
        }
 
@@ -223,248 +230,255 @@ BOOL DTappsDBClose(const char* CallingFun)
        return ret;
 }
 
-BOOL DTappsDBBeginImmedTrans (const char* CallingFun)
+BOOL DTappsDBBeginImmedTrans(const char *CallingFun)
 {
        DRM_TAPPS_LOG("Inside %s, Calling function = %s", __func__, CallingFun);
 
        dtappsThreadID id_curr_thread = drmgettid();
 
-       int count_try_db=0,rc = -1;
+       int count_try_db = 0, rc = -1;
 
-       DRM_TAPPS_SECURE_LOG("DB-OPEN-CLOSE-BEG-COM-RB [%s]Parent Process ID=[%ld]:Process-ID=[%ld]:Thread-ID=[%ld], id_curr_thread=[%ld]",__func__,getppid(),getpid(),drmgettid(), id_curr_thread);
+       DRM_TAPPS_SECURE_LOG("id_curr_thread=[%ld]", id_curr_thread);
 
        auto it = g_dtapps_sqlite_connection_table.find(id_curr_thread);
+
        if (it == g_dtapps_sqlite_connection_table.end())
                return FALSE;
 
        auto &pDBConnectionInfo = it->second;
-       DRM_TAPPS_FRQ_LOG("countOpenConnection=[%d], DBConnection=[0x%x]", __func__, pDBConnectionInfo->countOpenConnection, pDBConnectionInfo->pDBConnection);
+       DRM_TAPPS_FRQ_LOG("countOpenConnection=[%d], DBConnection=[0x%x]",
+                                         pDBConnectionInfo->countOpenConnection,
+                                         pDBConnectionInfo->pDBConnection);
 
        auto pDBConnection = pDBConnectionInfo->pDBConnection;
 
        DRM_TAPPS_LOG("Beginning DB operations..pDBConnection=[0x%x]", pDBConnection);
 
-       do {
+       while (true) {
                DRM_TAPPS_LOG("START BEGIN");
-               rc = sqlite3_exec (pDBConnection, DTAPPS_SQLITE3_SQL_BEGIN_IMMEDIATE, NULL, NULL, NULL);
+               rc = sqlite3_exec(pDBConnection, DTAPPS_SQLITE3_SQL_BEGIN_IMMEDIATE, NULL, NULL,
+                                                 NULL);
 
                DRM_TAPPS_FRQ_LOG("START BEGIN rc=%d", rc);
-               if (rc != SQLITE_OK)
-               {
-                       DRM_TAPPS_FRQ_LOG("pDBConnection=0x%x rc=%d ErrMsg:%s", pDBConnection, rc, sqlite3_errmsg(pDBConnection));
-                       if (rc == SQLITE_BUSY)
-                       {
+
+               if (rc != SQLITE_OK) {
+                       DRM_TAPPS_FRQ_LOG("pDBConnection=0x%x rc=%d ErrMsg:%s", pDBConnection, rc,
+                                                         sqlite3_errmsg(pDBConnection));
+
+                       if (rc == SQLITE_BUSY) {
                                dtapps_sleep(2, 0);
                                DRM_TAPPS_FRQ_LOG("Tried [%d] times to begin", count_try_db);
                                count_try_db++;
 
-                               if (count_try_db >= (int)__DTAPPS_DB_SQLITE_RETRY__)
-                               {
-                                       DRM_TAPPS_EXCEPTION("Error pDBConnection=0x%x rc=%d ErrMsg:%s", pDBConnection, rc, sqlite3_errmsg(pDBConnection));
+                               if (count_try_db >= (int)__DTAPPS_DB_SQLITE_RETRY__) {
+                                       DRM_TAPPS_EXCEPTION("Error pDBConnection=0x%x rc=%d ErrMsg:%s",
+                                                                               pDBConnection, rc,
+                                                                               sqlite3_errmsg(pDBConnection));
                                        MTHROW_BL
                                }
-                       }
-                       else
-                       {
-                               DRM_TAPPS_EXCEPTION("Error pDBConnection=0x%x rc=%d ErrMsg:%s", pDBConnection, rc, sqlite3_errmsg(pDBConnection));
+                       } else {
+                               DRM_TAPPS_EXCEPTION("Error pDBConnection=0x%x rc=%d ErrMsg:%s",
+                                                                       pDBConnection, rc,
+                                                                       sqlite3_errmsg(pDBConnection));
                                MTHROW_BL
                        }
-               }
-               else
-               {
+               } else {
                        DRM_TAPPS_LOG("begin SUCCESS count_try_db=%d", count_try_db);
                        break;
                }
-       } while(1);
+       }
 
-       DRM_TAPPS_LOG("This fn finishes successfully..pDBConnection=[0x%x]", pDBConnection);
+       DRM_TAPPS_LOG("This fn finishes successfully..pDBConnection=[0x%x]",
+                                 pDBConnection);
 
        return TRUE;
 
-MCATCH_B
-    DRM_TAPPS_EXCEPTION("This fn fails.. pDBConnection=[0x%x]", pDBConnection);
-    return FALSE;
+       MCATCH_B
+       DRM_TAPPS_EXCEPTION("This fn fails.. pDBConnection=[0x%x]", pDBConnection);
+       return FALSE;
 }
 
-BOOL DTappsDBCommit(const charCallingFun)
+BOOL DTappsDBCommit(const char *CallingFun)
 {
-       DRM_TAPPS_LOG("Inside %s, Calling function = %s", __func__,CallingFun);
+       DRM_TAPPS_LOG("Inside %s, Calling function = %s", __func__, CallingFun);
        dtappsThreadID id_curr_thread = drmgettid();
 
-       int count_try_db_commit=0,rc = -1;
+       int count_try_db_commit = 0, rc = -1;
 
-       DRM_TAPPS_SECURE_LOG("DB-OPEN-CLOSE-BEG-COM-RB [%s]Parent Process ID=[%ld]:Process-ID=[%ld]:Thread-ID=[%ld], id_curr_thread=[%ld]",__func__,getppid(),getpid(),drmgettid(), id_curr_thread);
+       DRM_TAPPS_SECURE_LOG("id_curr_thread=[%ld]", id_curr_thread);
 
        auto it = g_dtapps_sqlite_connection_table.find(id_curr_thread);
+
        if (it == g_dtapps_sqlite_connection_table.end())
                return FALSE;
 
        auto &pDBConnectionInfo = it->second;
-       DRM_TAPPS_FRQ_LOG("countOpenConnection=[%d], pDBConnection=[0x%x]", pDBConnectionInfo->countOpenConnection, pDBConnectionInfo->pDBConnection);
+       DRM_TAPPS_FRQ_LOG("countOpenConnection=[%d], pDBConnection=[0x%x]",
+                                         pDBConnectionInfo->countOpenConnection,
+                                         pDBConnectionInfo->pDBConnection);
 
        auto pDBConnection = pDBConnectionInfo->pDBConnection;
 
        DRM_TAPPS_LOG("Commiting DB operations..pDBConnection=[0x%x]", pDBConnection);
 
-       do {
+       while (true) {
                DRM_TAPPS_FRQ_LOG("START Commit");
-               rc = sqlite3_exec (pDBConnection, DTAPPS_SQLITE3_SQL_COMMIT, NULL, NULL, NULL);
+               rc = sqlite3_exec(pDBConnection, DTAPPS_SQLITE3_SQL_COMMIT, NULL, NULL, NULL);
                DRM_TAPPS_FRQ_LOG("START Commit rc=%d", rc);
 
-               if (rc != SQLITE_OK)
-               {
-                       DRM_TAPPS_FRQ_LOG("pDBConnection=0x%x rc=%d ErrMsg:%s", pDBConnection, rc, sqlite3_errmsg(pDBConnection));
+               if (rc != SQLITE_OK) {
+                       DRM_TAPPS_FRQ_LOG("pDBConnection=0x%x rc=%d ErrMsg:%s", pDBConnection, rc,
+                                                         sqlite3_errmsg(pDBConnection));
 
-                       if (rc == SQLITE_BUSY)
-                       {
+                       if (rc == SQLITE_BUSY) {
                                dtapps_sleep(2, 0);
                                DRM_TAPPS_FRQ_LOG("Tried [%d] times to Commit", count_try_db_commit);
                                count_try_db_commit++;
-                               if (count_try_db_commit >= (int)__DTAPPS_DB_SQLITE_RETRY__)
-                               {
-                                       DRM_TAPPS_EXCEPTION("Error pDBConnection=0x%x rc=%d ErrMsg:%s", pDBConnection, rc, sqlite3_errmsg(pDBConnection));
+
+                               if (count_try_db_commit >= (int)__DTAPPS_DB_SQLITE_RETRY__) {
+                                       DRM_TAPPS_EXCEPTION("Error pDBConnection=0x%x rc=%d ErrMsg:%s",
+                                                                               pDBConnection, rc,
+                                                                               sqlite3_errmsg(pDBConnection));
                                        MTHROW_BL
                                }
-                       }
-                       else
-                       {
-                               DRM_TAPPS_EXCEPTION("Error pDBConnection=0x%x rc=%d ErrMsg:%s", pDBConnection, rc, sqlite3_errmsg(pDBConnection));
+                       } else {
+                               DRM_TAPPS_EXCEPTION("Error pDBConnection=0x%x rc=%d ErrMsg:%s",
+                                                                       pDBConnection, rc,
+                                                                       sqlite3_errmsg(pDBConnection));
                                MTHROW_BL
                        }
-               }
-               else
-               {
-                       DRM_TAPPS_FRQ_LOG("Commit SUCCESS count_try_db_commit=%d", count_try_db_commit);
+               } else {
+                       DRM_TAPPS_FRQ_LOG("Commit SUCCESS count_try_db_commit=%d",
+                                                         count_try_db_commit);
                        break;
                }
-       } while(1);
+       }
 
-       DRM_TAPPS_LOG("This fn finishes successfully..pDBConnection=[0x%x]", pDBConnection);
+       DRM_TAPPS_LOG("Finishes successfully..pDBConnection=[0x%x]", pDBConnection);
 
        return TRUE;
 
-MCATCH_B
-    DRM_TAPPS_EXCEPTION("[%s] This fn fails.. pDBConnection=[0x%x]", pDBConnection);
+       MCATCH_B
+       DRM_TAPPS_EXCEPTION("Fails.. pDBConnection=[0x%x]", pDBConnection);
 
-    return FALSE;
+       return FALSE;
 }
 
-BOOL DTappsDBRollback (const char* CallingFun)
+BOOL DTappsDBRollback(const char *CallingFun)
 {
-       DRM_TAPPS_LOG("Inside %s, Calling function = %s", __func__,CallingFun);
+       DRM_TAPPS_LOG("Inside %s, Calling function = %s", __func__, CallingFun);
 
        dtappsThreadID id_curr_thread = drmgettid();
 
        int count_try_db_rollback = 0, rc = -1;
 
-       DRM_TAPPS_SECURE_LOG("DB-OPEN-CLOSE-BEG-COM-RB [%s]Parent Process ID=[%ld]:Process-ID=[%ld]:Thread-ID=[%ld], id_curr_thread=[%ld]",__func__,getppid(),getpid(),drmgettid(), id_curr_thread);
+       DRM_TAPPS_SECURE_LOG("id_curr_thread=[%ld]", id_curr_thread);
 
        auto it = g_dtapps_sqlite_connection_table.find(id_curr_thread);
+
        if (it == g_dtapps_sqlite_connection_table.end())
                return FALSE;
 
        auto &pDBConnectionInfo = it->second;
-       DRM_TAPPS_SECURE_LOG("[%s] countOpenConnection=[%d], pDBConnection=[0x%x]", __func__, pDBConnectionInfo->countOpenConnection, pDBConnectionInfo->pDBConnection);
+       DRM_TAPPS_SECURE_LOG("[%s] countOpenConnection=[%d], pDBConnection=[0x%x]",
+                                                __func__, pDBConnectionInfo->countOpenConnection,
+                                                pDBConnectionInfo->pDBConnection);
 
        auto pDBConnection = pDBConnectionInfo->pDBConnection;
 
        DRM_TAPPS_LOG("Rollback DB operations..pDBConnection=[0x%x]", pDBConnection);
 
-       do {
+       while (true) {
                DRM_TAPPS_FRQ_LOG("START Rollback");
-               rc = sqlite3_exec (pDBConnection, DTAPPS_SQLITE3_SQL_ROLLBACK, NULL, NULL, NULL);
-               DRM_TAPPS_FRQ_LOG("START  Rollback rc=%d",rc);
+               rc = sqlite3_exec(pDBConnection, DTAPPS_SQLITE3_SQL_ROLLBACK, NULL, NULL, NULL);
+               DRM_TAPPS_FRQ_LOG("START  Rollback rc=%d", rc);
 
-               if (rc != SQLITE_OK)
-               {
-                       DRM_TAPPS_FRQ_LOG("pDBConnection=0x%x rc=%d ErrMsg:%s",pDBConnection,rc,sqlite3_errmsg(pDBConnection));
+               if (rc != SQLITE_OK) {
+                       DRM_TAPPS_FRQ_LOG("pDBConnection=0x%x rc=%d ErrMsg:%s", pDBConnection, rc,
+                                                         sqlite3_errmsg(pDBConnection));
 
-                       if(rc == SQLITE_BUSY)
-                       {
-                               dtapps_sleep(2,0);
-                               DRM_TAPPS_FRQ_LOG("Tried [%d] times to Rollback",count_try_db_rollback);
+                       if (rc == SQLITE_BUSY) {
+                               dtapps_sleep(2, 0);
+                               DRM_TAPPS_FRQ_LOG("Tried [%d] times to Rollback", count_try_db_rollback);
                                count_try_db_rollback++;
-                               if(count_try_db_rollback >= (int)__DTAPPS_DB_SQLITE_RETRY__)
-                               {
-                                       DRM_TAPPS_EXCEPTION("Error pDBConnection=0x%x rc=%d ErrMsg:%s",pDBConnection,rc,sqlite3_errmsg(pDBConnection));
+
+                               if (count_try_db_rollback >= (int)__DTAPPS_DB_SQLITE_RETRY__) {
+                                       DRM_TAPPS_EXCEPTION("Error pDBConnection=0x%x rc=%d ErrMsg:%s",
+                                                                               pDBConnection, rc,
+                                                                               sqlite3_errmsg(pDBConnection));
                                        MTHROW_BL
                                }
-                       }
-                       else
-                       {
-                               DRM_TAPPS_EXCEPTION("Error pDBConnection=0x%x rc=%d ErrMsg:%s",pDBConnection,rc,sqlite3_errmsg(pDBConnection));
+                       } else {
+                               DRM_TAPPS_EXCEPTION("Error pDBConnection=0x%x rc=%d ErrMsg:%s",
+                                                                       pDBConnection, rc,
+                                                                       sqlite3_errmsg(pDBConnection));
                                MTHROW_BL
                        }
-               }
-               else
-               {
-                       DRM_TAPPS_FRQ_LOG("Rollback SUCCESS count_try_db_rollback=%d",count_try_db_rollback);
+               } else {
+                       DRM_TAPPS_FRQ_LOG("Rollback SUCCESS count_try_db_rollback=%d",
+                                                         count_try_db_rollback);
                        break;
                }
-       } while(1);
+       }
 
-       DRM_TAPPS_LOG("This fn finishes successfully..pDBConnection=[0x%x]", pDBConnection);
+       DRM_TAPPS_LOG("This fn finishes successfully..pDBConnection=[0x%x]",
+                                 pDBConnection);
 
        return TRUE;
 
-MCATCH_B
-    DRM_TAPPS_EXCEPTION("This fn fails.. pDBConnection=[0x%x]", pDBConnection);
+       MCATCH_B
+       DRM_TAPPS_EXCEPTION("This fn fails.. pDBConnection=[0x%x]", pDBConnection);
 
-    return FALSE;
+       return FALSE;
 }
 
 
-BOOL DTappsExecuteSQL(void* pDB, const char* query)
+BOOL DTappsExecuteSQL(void *pDB, const char *query)
 {
        int count_try_db_exe = 0, rc = 0;
-       sqlite3* h_db = (sqlite3*)pDB;
+       sqlite3 *h_db = (sqlite3 *)pDB;
 
        TAPPSDbApiLock Dblock;
 
-       do
-       {
-               rc = sqlite3_exec (h_db, query, NULL, NULL, NULL);
+       while (true) {
+               rc = sqlite3_exec(h_db, query, NULL, NULL, NULL);
                DRM_TAPPS_FRQ_LOG("EXECUTE rc=%d", rc);
 
-               if (rc != SQLITE_OK)
-               {
-                       if (rc == SQLITE_BUSY)
-                       {
+               if (rc != SQLITE_OK) {
+                       if (rc == SQLITE_BUSY) {
                                dtapps_sleep(2, 0);
-                               DRM_TAPPS_FRQ_LOG("Tried [%d] times to execute",count_try_db_exe);
+                               DRM_TAPPS_FRQ_LOG("Tried [%d] times to execute", count_try_db_exe);
                                count_try_db_exe++;
 
-                               if (count_try_db_exe >= (int)__DTAPPS_DB_SQLITE_RETRY__)
-                               {
-                                       DRM_TAPPS_EXCEPTION("h_db=0x%x rc=%d ErrMsg:%s count_try_db_exe=%d",h_db,rc,sqlite3_errmsg(h_db),count_try_db_exe);
-                                       DRM_TAPPS_EXCEPTION("query=[%s]",query);
+                               if (count_try_db_exe >= (int)__DTAPPS_DB_SQLITE_RETRY__) {
+                                       DRM_TAPPS_EXCEPTION("h_db=0x%x rc=%d ErrMsg:%s count_try_db_exe=%d",
+                                                                               h_db, rc, sqlite3_errmsg(h_db), count_try_db_exe);
+                                       DRM_TAPPS_EXCEPTION("query=[%s]", query);
                                        return FALSE;
                                }
-                       }
-                       else
-                       {
-                               DRM_TAPPS_EXCEPTION("h_db=0x%x rc=%d ErrMsg:%s", h_db, rc, sqlite3_errmsg(h_db));
+                       } else {
+                               DRM_TAPPS_EXCEPTION("h_db=0x%x rc=%d ErrMsg:%s", h_db, rc,
+                                                                       sqlite3_errmsg(h_db));
                                DRM_TAPPS_EXCEPTION("query=[%s]", query);
                                return FALSE;
                        }
-               }
-               else
-               {
+               } else {
                        DRM_TAPPS_FRQ_LOG("EXECUTE SUCCESS count_try_db_exe=%d", count_try_db_exe);
                        break;
                }
-       } while(1);
+       }
 
        return TRUE;
 }
 
 
-BOOL DTappsSQLGetTable(void* pDB, const char* query, TAPPSSqliteSelectTable* select_table)
+BOOL DTappsSQLGetTable(void *pDB, const char *query,
+                                          TAPPSSqliteSelectTable *select_table)
 {
        int rc = 0;
-       sqlite3* h_db = (sqlite3*)pDB;
+       sqlite3 *h_db = (sqlite3 *)pDB;
 
-       DRM_TAPPS_FRQ_LOG("h_db=0x%x query=%s", h_db,query);
+       DRM_TAPPS_FRQ_LOG("h_db=0x%x query=%s", h_db, query);
        TAPPSDbApiLock Dblock;
        select_table->handle = h_db;
 
@@ -472,76 +486,70 @@ BOOL DTappsSQLGetTable(void* pDB, const char* query, TAPPSSqliteSelectTable* sel
 
        int count_try_db_select = 0;
 
-       do
-       {
-               rc = sqlite3_get_table(h_db, query, &select_table->result, &select_table->n_rows, &select_table->n_cols, NULL);
+       while (true) {
+               rc = sqlite3_get_table(h_db, query, &select_table->result,
+                                                          &select_table->n_rows, &select_table->n_cols, NULL);
 
                DRM_TAPPS_FRQ_LOG("SELECT rc=%d", rc);
 
-               if (rc != SQLITE_OK)
-               {
-                       if (rc == SQLITE_BUSY)
-                       {
-                               dtapps_sleep(2,0);
-                               DRM_TAPPS_FRQ_LOG("SELECT  Tried [%d] times to select \n",count_try_db_select);
+               if (rc != SQLITE_OK) {
+                       if (rc == SQLITE_BUSY) {
+                               dtapps_sleep(2, 0);
+                               DRM_TAPPS_FRQ_LOG("SELECT Tried [%d] times to select",
+                                                                 count_try_db_select);
 
                                count_try_db_select++;
 
-                               if(count_try_db_select >= (int)__DTAPPS_DB_SQLITE_RETRY__)
-                               {
-                                       DRM_TAPPS_EXCEPTION("SELECT  h_db=0x%x rc=%d ErrMsg:%s count_try_db_select=%d \n",h_db,rc,sqlite3_errmsg(h_db),count_try_db_select);
-                                       DRM_TAPPS_EXCEPTION("query=[%s] \n",query);
+                               if (count_try_db_select >= (int)__DTAPPS_DB_SQLITE_RETRY__) {
+                                       DRM_TAPPS_EXCEPTION("SELECT  h_db=0x%x rc=%d ErrMsg:%s "
+                                                                               "count_try_db_select=%d",
+                                                                               h_db, rc, sqlite3_errmsg(h_db),
+                                                                               count_try_db_select);
+                                       DRM_TAPPS_EXCEPTION("query=[%s]", query);
 
                                        return FALSE;
                                }
-                       }
-                       else
-                       {
-                               DRM_TAPPS_EXCEPTION("SELECT h_db=0x%x rc=%d ErrMsg:%s \n",h_db,rc,sqlite3_errmsg(h_db));
-                               DRM_TAPPS_EXCEPTION("%s query=[%s] \n",query);
+                       } else {
+                               DRM_TAPPS_EXCEPTION("SELECT h_db=0x%x rc=%d ErrMsg:%s", h_db, rc,
+                                                                       sqlite3_errmsg(h_db));
+                               DRM_TAPPS_EXCEPTION("query=[%s]", query);
 
                                return FALSE;
                        }
-               }
-               else
-               {
-                       DRM_TAPPS_FRQ_LOG("SELECT SUCCESS count_try_db_select=%d \n",count_try_db_select);
-
+               } else {
+                       DRM_TAPPS_FRQ_LOG("SELECT SUCCESS count_try_db_select=%d",
+                                                         count_try_db_select);
                        break;
                }
-       } while(1);
+       }
 
-       DRM_TAPPS_FRQ_LOG("n_rows=%d n_cols=%d \n",select_table->n_rows, select_table->n_cols);
+       DRM_TAPPS_FRQ_LOG("n_rows=%d n_cols=%d", select_table->n_rows,
+                                         select_table->n_cols);
 
        return TRUE;
 }
 
-extern const chardtappsCreateTableSQLData[];
+extern const char *dtappsCreateTableSQLData[];
 
-char* DTappsGetSQLCreateTable(const char* tableName)
+char *DTappsGetSQLCreateTable(const char *tableName)
 {
-       int index=0;
+       int index = 0;
 
-       if(!tableName)
-       {
+       if (!tableName)
                return NULL;
-       }
 
-       DRM_TAPPS_FRQ_LOG("tableName = %s",tableName);
+       DRM_TAPPS_FRQ_LOG("tableName = %s", tableName);
 
-       while(dtappsCreateTableSQLData[index])
-       {
-               if(TAPPS_strnicmp( dtappsCreateTableSQLData[index],tableName,TAPPS_STRLEN(tableName))==0)
-               {
-                       char* sql = (char*)dtappsCreateTableSQLData[index];
-                       sql = sql + TAPPS_STRLEN(dtappsCreateTableSQLData[index])+1;
+       while (dtappsCreateTableSQLData[index]) {
+               if (TAPPS_strnicmp(dtappsCreateTableSQLData[index], tableName,
+                                                  TAPPS_STRLEN(tableName)) == 0) {
+                       char *sql = (char *)dtappsCreateTableSQLData[index];
+                       sql = sql + TAPPS_STRLEN(dtappsCreateTableSQLData[index]) + 1;
 
-                       DRM_TAPPS_FRQ_LOG("sql query = %s",sql);
+                       DRM_TAPPS_FRQ_LOG("sql query = %s", sql);
 
                        return sql;
-               }
-               else
-               {
+               } else {
                        index++;
                }
        }
@@ -551,32 +559,30 @@ char* DTappsGetSQLCreateTable(const char* tableName)
        return NULL;
 }
 
-void* DTappsStmtPrepare(void* pDB, const char* query)
+void *DTappsStmtPrepare(void *pDB, const char *query)
 {
        int rc = 0;
-       sqlite3*        h_db = (sqlite3*)pDB;
-       sqlite3_stmt*   stmt = 0;
+       sqlite3 *h_db = (sqlite3 *)pDB;
+       sqlite3_stmt *stmt = 0;
 
-       DRM_TAPPS_FRQ_LOG("h_db=0x%x query=%s \n",h_db,query);
+       DRM_TAPPS_FRQ_LOG("h_db=0x%x query=%s", h_db, query);
 
        TAPPSDbApiLock Dblock;
 
-       if(0 == TAPPS_strnicmp(query, "SELECT", 6))
-       {
-               DRM_TAPPS_EXCEPTION("Doesn't support 'Select' query h_db=0x%x query=%s \n",h_db,query);
-
+       if (0 == TAPPS_strnicmp(query, "SELECT", 6)) {
+               DRM_TAPPS_EXCEPTION("Doesn't support 'Select' query h_db=0x%x query=%s",
+                                                       h_db, query);
                return NULL;
        }
 
-       rc = sqlite3_prepare( h_db, query, -1, &stmt, NULL);
+       rc = sqlite3_prepare(h_db, query, -1, &stmt, NULL);
 
-       DRM_TAPPS_FRQ_LOG("%s: rc=%d query=%s stmt=0x%x \n",__func__,rc,query,stmt);
-
-       if (rc != SQLITE_OK)
-       {
-               DRM_TAPPS_EXCEPTION("DTappsStmtPrepare: h_db=0x%x err: %s \n",h_db,sqlite3_errmsg(h_db));
-               DRM_TAPPS_EXCEPTION("DTappsStmtPrepare: query: %s\n", query);
+       DRM_TAPPS_FRQ_LOG("%s: rc=%d query=%s stmt=0x%x", __func__, rc, query, stmt);
 
+       if (rc != SQLITE_OK) {
+               DRM_TAPPS_EXCEPTION("DTappsStmtPrepare: h_db=0x%x err: %s", h_db,
+                                                       sqlite3_errmsg(h_db));
+               DRM_TAPPS_EXCEPTION("DTappsStmtPrepare: query: %s", query);
                return NULL;
        }
 
@@ -584,24 +590,18 @@ void* DTappsStmtPrepare(void* pDB, const char* query)
 }
 
 
-int DTappsStmtBindParam (
-       void* pStmt,
-       unsigned int dIdx,
-       unsigned int Type,
-       void* pParam,
-       unsigned int dParamSize )
+int DTappsStmtBindParam(void *pStmt, unsigned int dIdx, unsigned int Type,
+                                               void *pParam, unsigned int dParamSize)
 {
        int rc = 0;
-       sqlite3_stmt*   stmt = (sqlite3_stmt*)pStmt;
+       sqlite3_stmt *stmt = (sqlite3_stmt *)pStmt;
 
-       DRM_TAPPS_FRQ_LOG("Enter \n");
+       DRM_TAPPS_FRQ_LOG("Enter");
 
        TAPPSDbApiLock Dblock;
 
-       if(stmt == NULL)
-       {
-               DRM_TAPPS_EXCEPTION("DTappsStmtBindParam: stmt is NULL \n");
-
+       if (stmt == NULL) {
+               DRM_TAPPS_EXCEPTION("DTappsStmtBindParam: stmt is NULL");
                return FALSE;
        }
 
@@ -609,57 +609,57 @@ int DTappsStmtBindParam (
         * Notice:
         *  The parameter index in SQL starts from 1 in sqlite3.
         */
-       switch(Type)
-       {
+       switch (Type) {
        case TAPPSDB_TYPE_NONE:
-               rc = sqlite3_bind_null( stmt, dIdx+1);
+               rc = sqlite3_bind_null(stmt, dIdx + 1);
 
                break;
 
        case TAPPSDB_TYPE_INT:
-               rc = sqlite3_bind_int( stmt, dIdx+1, *(int*)pParam);
-               DRM_TAPPS_FRQ_LOG(" rc=%d type=%d pParam=%d \n",rc,Type,*(int*)pParam);
+               rc = sqlite3_bind_int(stmt, dIdx + 1, *(int *)pParam);
+               DRM_TAPPS_FRQ_LOG("rc=%d type=%d pParam=%d", rc, Type, *(int *)pParam);
 
                break;
 
        case TAPPSDB_TYPE_DATETIME:
-
        case TAPPSDB_TYPE_CHAR:
-
        case TAPPSDB_TYPE_VARCHAR:
-               rc = sqlite3_bind_text( stmt, dIdx+1, (char*)pParam, dParamSize, SQLITE_TRANSIENT);
-               DRM_TAPPS_FRQ_LOG("rc=%d type=%d dParamSize=%d pParam=%s \n",rc,Type,dParamSize,pParam);
+               rc = sqlite3_bind_text(stmt, dIdx + 1, (char *)pParam, dParamSize,
+                                                          SQLITE_TRANSIENT);
+               DRM_TAPPS_FRQ_LOG("rc=%d type=%d dParamSize=%d pParam=%s", rc, Type,
+                                                 dParamSize, pParam);
 
                break;
 
        case TAPPSDB_TYPE_BINARY:
-
        case TAPPSDB_TYPE_BLOB:
-               #if 0
+#if 0
                {
-                       char* packet64=NULL;
-                       unsigned int packet64_size=0;
-                       if(CMStringUtil::GetBase64Encode((unsigned char*)pParam,dParamSize, &packet64) == true)
-                       {
+                       char *packet64 = NULL;
+                       unsigned int packet64_size = 0;
+
+                       if (CMStringUtil::GetBase64Encode((unsigned char *)pParam, dParamSize,
+                                                                                         &packet64) == true) {
                                packet64_size = MSTRLEN(packet64);
-                               rc = sqlite3_bind_blob( stmt, dIdx+1, packet64, packet64_size, SQLITE_TRANSIENT);
-                               DRM_OMA_FRQ_LOG("%s: rc=%d type=%d packet64_size=%d packet64=%s \n",__func__,rc,Type,packet64_size,packet64);
-                               if(packet64) MDELETES0(packet64);
+                               rc = sqlite3_bind_blob(stmt, dIdx + 1, packet64, packet64_size,
+                                                                          SQLITE_TRANSIENT);
+                               DRM_OMA_FRQ_LOG("%s: rc=%d type=%d packet64_size=%d packet64=%s \n", __func__,
+                                                               rc, Type, packet64_size, packet64);
+
+                               if (packet64) MDELETES0(packet64);
                        }
                }
-               #endif
+
+#endif
                break;
 
        case TAPPSDB_TYPE_UNKNOWN:
-
        default:
                break;
-       }//switch
-
-       if(rc != SQLITE_OK)
-       {
-               DRM_TAPPS_EXCEPTION("DTappsStmtBindParam: errno: %d\n", rc);
+       }
 
+       if (rc != SQLITE_OK) {
+               DRM_TAPPS_EXCEPTION("DTappsStmtBindParam: errno: %d", rc);
                return FALSE;
        }
 
@@ -667,80 +667,64 @@ int DTappsStmtBindParam (
 }
 
 
-int DTappsStmtExecute (void* pStmt)
+int DTappsStmtExecute(void *pStmt)
 {
-       int CntTryStmtExe=0, rc =-1;
-       sqlite3_stmt*   stmt = (sqlite3_stmt*)pStmt;
+       int CntTryStmtExe = 0, rc = -1;
+       sqlite3_stmt *stmt = (sqlite3_stmt *)pStmt;
 
-       DRM_TAPPS_FRQ_LOG("%s:stmt=0x%x \n",__func__,stmt);
+       DRM_TAPPS_FRQ_LOG("%s:stmt=0x%x", __func__, stmt);
 
        TAPPSDbApiLock Dblock;
 
-       if(stmt == NULL)
-       {
-               DRM_TAPPS_EXCEPTION("stmt is NULL \n");
-
+       if (stmt == NULL) {
+               DRM_TAPPS_EXCEPTION("stmt is NULL");
                return FALSE;
        }
 
-       do
-       {
+       while (true) {
                rc = sqlite3_step(stmt);
 
-               DRM_TAPPS_FRQ_LOG(" rc=%d \n",rc);
+               DRM_TAPPS_FRQ_LOG("rc=%d", rc);
 
-               if ( rc != SQLITE_DONE )
-               {
-                       if(rc == SQLITE_BUSY)
-                       {
-                               dtapps_sleep(2,0);
-                               DRM_TAPPS_FRQ_LOG("Tried [%d] times to execute stmt \n",CntTryStmtExe);
+               if (rc != SQLITE_DONE) {
+                       if (rc == SQLITE_BUSY) {
+                               dtapps_sleep(2, 0);
+                               DRM_TAPPS_FRQ_LOG("Tried [%d] times to execute stmt", CntTryStmtExe);
 
                                CntTryStmtExe++;
 
-                               if(CntTryStmtExe >= (int)__DTAPPS_DB_SQLITE_RETRY__)
-                               {
-                                       DRM_TAPPS_EXCEPTION("stmt=0x%x rc=%d CntTryStmtExe=%d \n",stmt,rc,CntTryStmtExe);
-
+                               if (CntTryStmtExe >= (int)__DTAPPS_DB_SQLITE_RETRY__) {
+                                       DRM_TAPPS_EXCEPTION("stmt=0x%x rc=%d CntTryStmtExe=%d", stmt, rc,
+                                                                               CntTryStmtExe);
                                        return FALSE;
                                }
-                       }
-                       else
-                       {
-                               DRM_TAPPS_EXCEPTION("stmt=0x%x rc=%d \n",stmt,rc);
-
+                       } else {
+                               DRM_TAPPS_EXCEPTION("stmt=0x%x rc=%d", stmt, rc);
                                return FALSE;
                        }
-               }
-               else
-               {
-                       DRM_TAPPS_FRQ_LOG("STMT EXECUTE SUCCESS CntTryStmtExe=%d \n",CntTryStmtExe);
-
+               } else {
+                       DRM_TAPPS_FRQ_LOG("STMT EXECUTE SUCCESS CntTryStmtExe=%d", CntTryStmtExe);
                        return TRUE;
                }
-       } while(1);
+       }
 }
 
-
-int DTappsStmtRelease (void* pStmt)
+int DTappsStmtRelease(void *pStmt)
 {
-       int     rc = 0;
-       sqlite3_stmt*   stmt = (sqlite3_stmt*)pStmt;
-       DRM_TAPPS_FRQ_LOG("%s:Enter \n",__func__);
+       int rc = 0;
+       sqlite3_stmt *stmt = (sqlite3_stmt *)pStmt;
+       DRM_TAPPS_FRQ_LOG("%s:Enter", __func__);
        TAPPSDbApiLock Dblock;
+
        if (!stmt)
-       {
                return FALSE;
-       }
-
-       rc = sqlite3_finalize (stmt);
 
-       DRM_TAPPS_FRQ_LOG("rc=%d \n",rc);
+       rc = sqlite3_finalize(stmt);
 
-       if ( rc != SQLITE_OK )
-       {
-               DRM_TAPPS_EXCEPTION("DTappsStmtRelease() Errmsg ; %d \n", rc);
+       DRM_TAPPS_FRQ_LOG("rc=%d", rc);
 
+       if (rc != SQLITE_OK) {
+               DRM_TAPPS_EXCEPTION("DTappsStmtRelease() Errmsg : %d", rc);
                return FALSE;
        }
 
@@ -748,26 +732,22 @@ int DTappsStmtRelease (void* pStmt)
 }
 
 
-BOOL DTapps_DB_Install(const charsql_query)
+BOOL DTapps_DB_Install(const char *sql_query)
 {
        void *pDb = NULL;
        BOOL ret_value = FALSE;
 
-       if(sql_query == NULL)
-       {
-               DRM_TAPPS_EXCEPTION("Parameter NULL!!!, sql_query = %p",sql_query);
-
+       if (sql_query == NULL) {
+               DRM_TAPPS_EXCEPTION("Parameter NULL!!!, sql_query = %p", sql_query);
                return FALSE;
        }
 
        DRM_TAPPS_LOG("Open DB......");
 
-       ret_value = DTappsDBOpen(pDb,__func__);
-
-       if(ret_value != TRUE)
-       {
-               DRM_TAPPS_EXCEPTION("DB Open Failed!! ret_value = %d",ret_value);
+       ret_value = DTappsDBOpen(pDb, __func__);
 
+       if (ret_value != TRUE) {
+               DRM_TAPPS_EXCEPTION("DB Open Failed!! ret_value = %d", ret_value);
                return FALSE;
        }
 
@@ -775,21 +755,17 @@ BOOL DTapps_DB_Install(const char* sql_query)
 
        ret_value = DTappsDBBeginImmedTrans(__func__);
 
-       if(ret_value != TRUE)
-       {
-               DRM_TAPPS_EXCEPTION("DB Begin Transaction ret_value = %d",ret_value);
-
+       if (ret_value != TRUE) {
+               DRM_TAPPS_EXCEPTION("DB Begin Transaction ret_value = %d", ret_value);
                goto Error_Exit;
        }
 
        DRM_TAPPS_LOG("Execute SQL to Insert Contents into Table........");
 
-       ret_value = DTappsExecuteSQL(pDb,sql_query);
-
-       if(ret_value != TRUE)
-       {
-               DRM_TAPPS_EXCEPTION("Execute SQL Query Failed!! ret_value = %d",ret_value);
+       ret_value = DTappsExecuteSQL(pDb, sql_query);
 
+       if (ret_value != TRUE) {
+               DRM_TAPPS_EXCEPTION("Execute SQL Query Failed!! ret_value = %d", ret_value);
                goto Error_Exit;
        }
 
@@ -797,10 +773,8 @@ BOOL DTapps_DB_Install(const char* sql_query)
 
        ret_value = DTappsDBCommit(__func__);
 
-       if(ret_value != TRUE)
-       {
-               DRM_TAPPS_EXCEPTION("Commit DB Failed!! ret_value = %d",ret_value);
-
+       if (ret_value != TRUE) {
+               DRM_TAPPS_EXCEPTION("Commit DB Failed!! ret_value = %d", ret_value);
                goto Error_Exit;
        }
 
@@ -808,10 +782,8 @@ BOOL DTapps_DB_Install(const char* sql_query)
 
        ret_value = DTappsDBClose(__func__);
 
-       if(ret_value != TRUE)
-       {
-               DRM_TAPPS_EXCEPTION("Close DB Failed!! ret_value = %d",ret_value);
-
+       if (ret_value != TRUE) {
+               DRM_TAPPS_EXCEPTION("Close DB Failed!! ret_value = %d", ret_value);
                goto Error_Exit;
        }
 
@@ -821,43 +793,36 @@ BOOL DTapps_DB_Install(const char* sql_query)
 
 Error_Exit:
 
-       ret_value = DTappsDBRollback (__func__);
+       ret_value = DTappsDBRollback(__func__);
 
-       if(ret_value != TRUE)
-       {
-               DRM_TAPPS_EXCEPTION("Rollback DB Failed!! ret_value = %d",ret_value);
-       }
+       if (ret_value != TRUE)
+               DRM_TAPPS_EXCEPTION("Rollback DB Failed!! ret_value = %d", ret_value);
 
        ret_value = DTappsDBClose(__func__);
 
-       if(ret_value != TRUE)
-       {
-               DRM_TAPPS_EXCEPTION("Close DB Failed!! ret_value = %d",ret_value);
-       }
+       if (ret_value != TRUE)
+               DRM_TAPPS_EXCEPTION("Close DB Failed!! ret_value = %d", ret_value);
 
        return FALSE;
 }
 
-BOOL DTapps_Read_DB(const char* sql_query, TAPPSSqliteSelectTable* select_table)
+BOOL DTapps_Read_DB(const char *sql_query, TAPPSSqliteSelectTable *select_table)
 {
        void *pDb = NULL;
        BOOL ret_value = FALSE;
 
-       if(sql_query == NULL || select_table == NULL)
-       {
-               DRM_TAPPS_EXCEPTION("Parameters NULL, sql_query = %p, select_table = %p",sql_query,select_table);
-
+       if (sql_query == NULL || select_table == NULL) {
+               DRM_TAPPS_EXCEPTION("Parameters NULL, sql_query = %p, select_table = %p",
+                                                       sql_query, select_table);
                return FALSE;
        }
 
        DRM_TAPPS_LOG("Open DB......");
 
-       ret_value = DTappsDBOpen(pDb,__func__);
-
-       if(ret_value != TRUE)
-       {
-               DRM_TAPPS_EXCEPTION("DB Open Failed!! ret_value = %d",ret_value);
+       ret_value = DTappsDBOpen(pDb, __func__);
 
+       if (ret_value != TRUE) {
+               DRM_TAPPS_EXCEPTION("DB Open Failed!! ret_value = %d", ret_value);
                return FALSE;
        }
 
@@ -865,21 +830,17 @@ BOOL DTapps_Read_DB(const char* sql_query, TAPPSSqliteSelectTable* select_table)
 
        ret_value = DTappsDBBeginImmedTrans(__func__);
 
-       if(ret_value != TRUE)
-       {
-               DRM_TAPPS_EXCEPTION("DB Begin Transaction Failed!! ret_value = %d",ret_value);
-
+       if (ret_value != TRUE) {
+               DRM_TAPPS_EXCEPTION("DB Begin Transaction Failed!! ret_value = %d", ret_value);
                goto Error_Exit;
        }
 
        DRM_TAPPS_LOG("Get the Result Table........");
 
-       ret_value = DTappsSQLGetTable(pDb,sql_query,select_table);
-
-       if(ret_value != TRUE)
-       {
-               DRM_TAPPS_EXCEPTION("DB Get Table failed!! ret_value = %d",ret_value);
+       ret_value = DTappsSQLGetTable(pDb, sql_query, select_table);
 
+       if (ret_value != TRUE) {
+               DRM_TAPPS_EXCEPTION("DB Get Table failed!! ret_value = %d", ret_value);
                goto Error_Exit;
        }
 
@@ -887,10 +848,8 @@ BOOL DTapps_Read_DB(const char* sql_query, TAPPSSqliteSelectTable* select_table)
 
        ret_value = DTappsDBClose(__func__);
 
-       if(ret_value != TRUE)
-       {
-               DRM_TAPPS_EXCEPTION("DB Close failed!! ret_value = %d",ret_value);
-
+       if (ret_value != TRUE) {
+               DRM_TAPPS_EXCEPTION("DB Close failed!! ret_value = %d", ret_value);
                goto Error_Exit;
        }
 
@@ -900,19 +859,15 @@ BOOL DTapps_Read_DB(const char* sql_query, TAPPSSqliteSelectTable* select_table)
 
 Error_Exit:
 
-       ret_value = DTappsDBRollback (__func__);
+       ret_value = DTappsDBRollback(__func__);
 
-       if(ret_value != TRUE)
-       {
-               DRM_TAPPS_EXCEPTION("Rollback DB Failed!! ret_value = %d",ret_value);
-       }
+       if (ret_value != TRUE)
+               DRM_TAPPS_EXCEPTION("Rollback DB Failed!! ret_value = %d", ret_value);
 
        ret_value = DTappsDBClose(__func__);
 
-       if(ret_value != TRUE)
-       {
-               DRM_TAPPS_EXCEPTION("Close DB Failed!! ret_value = %d",ret_value);
-       }
+       if (ret_value != TRUE)
+               DRM_TAPPS_EXCEPTION("Close DB Failed!! ret_value = %d", ret_value);
 
        DRM_TAPPS_EXCEPTION("Reading DB function failed!!!");
 
index 6257e57..2af4fb0 100644 (file)
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
- */
-
-/**
- * @file       drm_intf_tapps.cpp
- * @brief      This file includes definitions of the drm TAPPS intf APIs.
+ *
+ * @file    drm_intf_tapps.cpp
+ * @brief   drm TAPPS intf APIs.
  */
 
 #include "drm_intf_tapps.h"
 
 /* String Operations */
 #ifdef _TAPPS_DEBUG_ENABLE_
-unsigned int TAPPS_gstrlcat(char* s1,const char* s2,unsigned int destsize,const char* funName, unsigned int lineno)
+unsigned int TAPPS_gstrlcat(char *s1, const char *s2, unsigned int destsize,
+                                                       const char *funName, unsigned int lineno)
 {
        unsigned int ret_g_strlcat = (unsigned int)g_strlcat(s1, s2, destsize);
 
-       if(ret_g_strlcat >= (unsigned int)destsize)
-       {
-               DRM_TAPPS_EXCEPTION("Truncation occured during concatenation at [%s:%u] s1=%s s2=%s destsize=%u ret_g_strlcpy=%u \n",funName,lineno,s1,s2,destsize,ret_g_strlcat);
-       }
-       else
-       {
-               DRM_TAPPS_FRQ_LOG("Concatenation Successful at [%s:%u] s1=%s s2=%s destsize=%u ret_g_strlcpy=%u \n",funName,lineno,s1,s2,destsize,ret_g_strlcat);
+       if (ret_g_strlcat >= (unsigned int)destsize) {
+               DRM_TAPPS_EXCEPTION("Truncation occured during concatenation at [%s:%u] "
+                                                       "s1=%s s2=%s destsize=%u ret_g_strlcpy=%u",
+                                                       funName, lineno, s1, s2, destsize, ret_g_strlcat);
+       } else {
+               DRM_TAPPS_FRQ_LOG("Concatenation Successful at [%s:%u] s1=%s s2=%s "
+                                                 "destsize=%u ret_g_strlcpy=%u",
+                                                 funName, lineno, s1, s2, destsize, ret_g_strlcat);
        }
 
        return ret_g_strlcat;
 }
 
-unsigned int TAPPS_gstrlcpy(char* s1,const char* s2,unsigned int destsize,const char* funName, unsigned int lineno)
+unsigned int TAPPS_gstrlcpy(char *s1, const char *s2, unsigned int destsize,
+                                                       const char *funName, unsigned int lineno)
 {
        unsigned int ret_g_strlcpy = (unsigned int)g_strlcpy(s1, s2, destsize);
 
-       if(ret_g_strlcpy >= (unsigned int)destsize)
-       {
-               DRM_TAPPS_EXCEPTION("Truncation occured during copying at [%s:%u] s1=%s s2=%s destsize=%u ret_g_strlcpy=%u \n",funName,lineno,s1,s2,destsize,ret_g_strlcpy);
-       }
-       else
-       {
-               DRM_TAPPS_FRQ_LOG("Copy Successful at [%s:%u] s1=%s s2=%s destsize=%u ret_g_strlcpy=%u \n",funName,lineno,s1,s2,destsize,ret_g_strlcpy);
+       if (ret_g_strlcpy >= (unsigned int)destsize) {
+               DRM_TAPPS_EXCEPTION("Truncation occured during copying at [%s:%u] "
+                                                       "s1=%s s2=%s destsize=%u ret_g_strlcpy=%u",
+                                                       funName, lineno, s1, s2, destsize, ret_g_strlcpy);
+       } else {
+               DRM_TAPPS_FRQ_LOG("Copy Successful at [%s:%u] s1=%s s2=%s destsize=%u "
+                                                 "ret_g_strlcpy=%u",
+                                                 funName, lineno, s1, s2, destsize, ret_g_strlcpy);
        }
 
        return ret_g_strlcpy;
 }
 
-unsigned int TAPPS_strlen(const char* s,const char* funName, unsigned int lineno)
+unsigned int TAPPS_strlen(const char *s, const char *funName,
+                                                 unsigned int lineno)
 {
-       DRM_TAPPS_FRQ_LOG("Function = %s, Line number = %u",funName,lineno);
+       DRM_TAPPS_FRQ_LOG("Function = %s, Line number = %u", funName, lineno);
 
        return strlen(s);
 }
 #endif
 
-int TAPPS_strnicmp(const char * s1, const char * s2, unsigned int sz)
+int TAPPS_strnicmp(const char *s1, const char *s2, unsigned int sz)
 {
-       int tmp1=0, tmp2=0;
+       int tmp1 = 0, tmp2 = 0;
 
-       unsigned int idx =0;
+       unsigned int idx = 0;
 
-       do
-       {
-               if ( ((tmp1 = (unsigned char)(*(s1++))) >= 'A') && (tmp1 <= 'Z') )
+       do {
+               if (((tmp1 = (unsigned char)(*(s1++))) >= 'A') && (tmp1 <= 'Z'))
                        tmp1 -= ('A' - 'a');
 
-               if ( ((tmp2 = (unsigned char)(*(s2++))) >= 'A') && (tmp2 <= 'Z') )
+               if (((tmp2 = (unsigned char)(*(s2++))) >= 'A') && (tmp2 <= 'Z'))
                        tmp2 -= ('A' - 'a');
 
                idx++;
-       } while ( tmp1 && (tmp1== tmp2)  && idx < sz);
+       } while (tmp1 && (tmp1 == tmp2)  && idx < sz);
 
        return (tmp1 - tmp2);
 }
@@ -86,71 +88,66 @@ int TAPPS_strnicmp(const char * s1, const char * s2, unsigned int sz)
 
 /* Mutex Handling */
 
-int dtapps_mutex_lock (dtappslockarg dtapps_mutex)
+int dtapps_mutex_lock(dtappslockarg dtapps_mutex)
 {
-       int retval=-1;
+       int retval = -1;
 
-       DRM_TAPPS_FRQ_LOG( "%s MUT-LK-ULK Thread [%d] trying to lock the Mutex=0x%x \n",__func__,drmgettid(),dtapps_mutex);
+       DRM_TAPPS_FRQ_LOG("MUT-LK-ULK Thread [%d] trying to lock the Mutex=0x%x",
+                                         drmgettid(), dtapps_mutex);
 
        retval = pthread_mutex_lock(dtapps_mutex);
 
-       if(retval != 0)
-       {
-               if(retval == EDEADLK)
-               {
-                       DRM_TAPPS_FRQ_LOG("Mutex is already locked by the same thread  \n");
-               }
-               else
-               {
-                       DRM_TAPPS_EXCEPTION( "Error locking mutex %d  \n", retval);
+       if (retval != 0) {
+               if (retval == EDEADLK) {
+                       DRM_TAPPS_FRQ_LOG("Mutex is already locked by the same thread");
+               } else {
+                       DRM_TAPPS_EXCEPTION("Error locking mutex %d", retval);
                        perror("\n drm_mutex_lock:Error:");
                }
-               retval=-1;
-       }
-       else
-       {
-               DRM_TAPPS_FRQ_LOG( "Mutex lock is successful  \n");
+
+               retval = -1;
+       } else {
+               DRM_TAPPS_FRQ_LOG("Mutex lock is successful");
        }
-       DRM_TAPPS_FRQ_LOG( "%s retval=%d \n",__func__,retval);
+
+       DRM_TAPPS_FRQ_LOG("retval=%d", retval);
 
        return retval;
 }
 
 
-int dtapps_mutex_unlock (dtappslockarg dtapps_mutex)
+int dtapps_mutex_unlock(dtappslockarg dtapps_mutex)
 {
-       int status=-1;
+       int status = -1;
 
-       DRM_TAPPS_FRQ_LOG( "%s MUT-LK-ULK Thread [%d] trying to unlock the Mutex=0x%x \n",__func__,drmgettid(),dtapps_mutex);
+       DRM_TAPPS_FRQ_LOG("MUT-LK-ULK Thread [%d] trying to unlock the Mutex=0x%x",
+                                         drmgettid(), dtapps_mutex);
 
        status = pthread_mutex_unlock(dtapps_mutex);
 
-       if(status != 0)
-       {
-               DRM_TAPPS_EXCEPTION( "Error unlocking mutex:return value=[%d] \n", status);
-               perror("\n drm_mutex_unlock:Error:");
+       if (status != 0) {
+               DRM_TAPPS_EXCEPTION("Error unlocking mutex:return value=[%d]", status);
+               perror("drm_mutex_unlock:Error:");
                status = -1;
-       }
-       else
-       {
-               DRM_TAPPS_FRQ_LOG( "Mutex unlocked is successful :return value=[%d] \n",status);
+       } else {
+               DRM_TAPPS_FRQ_LOG("Mutex unlocked is successful :return value=[%d]", status);
        }
 
-       DRM_TAPPS_FRQ_LOG( "%s status=%d \n",__func__,status);
+       DRM_TAPPS_FRQ_LOG("status=%d", status);
 
        return status;
 }
 
-void dtapps_sleep(unsigned int TimeInSec,unsigned int TimeInMicroSec)
+void dtapps_sleep(unsigned int TimeInSec, unsigned int TimeInMicroSec)
 {
        struct timeval tv;
-       int retval= -1;
+       int retval = -1;
        tv.tv_sec = TimeInSec;
        tv.tv_usec = TimeInMicroSec;
 
-       DRM_TAPPS_FRQ_LOG("%s TimeInSec =%u TimeInMicroSec=%u \n",__func__,tv.tv_sec,tv.tv_usec);
+       DRM_TAPPS_FRQ_LOG("TimeInSec =%u TimeInMicroSec=%u", tv.tv_sec, tv.tv_usec);
 
        retval = select(0, NULL, NULL, NULL, &tv);
 
-       DRM_TAPPS_FRQ_LOG("%s select retval=%d \n",__func__,retval);
+       DRM_TAPPS_FRQ_LOG("select retval=%d \n", retval);
 }
index 9b81050..bd97a32 100644 (file)
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
- */
-
-/**
- * @file       DTapps2Rights.cpp
- * @brief      This file includes functions relating to Rights.
+ *
+ * @file    DTapps2Rights.cpp
+ * @brief   Rights.
  */
 
 #include <string>
 #include "DTapps2Time.h"
 
 /* Validation and Installation of the Constraints Structure */
-int DTappsValidateConstraints(DTAPPS_CONSTRAINTS* st_const, DTAPPS_OPERATION opr)
+int DTappsValidateConstraints(DTAPPS_CONSTRAINTS *st_const,
+                                                         DTAPPS_OPERATION opr)
 {
        int ret = TADC_LICENSE_VALID;
        char DUID[DTAPPS_DUID_SIZE] = {0, };
        unsigned char zeroduid[DTAPPS_DUID_SIZE] = {0, };
        int retDeviceInfo = 0;
 
-       if (st_const == NULL)
-       {
+       if (st_const == NULL) {
                DRM_TAPPS_EXCEPTION("Invalid Paramter st_const = %p", st_const);
                ret = TADC_PARAMETER_ERROR;
                goto Error_Exit;
        }
 
        /* Check for DUID */
-       if (DTAPPS_MEMCMP(st_const->DUID, zeroduid, DTAPPS_DUID_SIZE))
-       {
+       if (DTAPPS_MEMCMP(st_const->DUID, zeroduid, DTAPPS_DUID_SIZE)) {
                DRM_TAPPS_LOG("st_const->DUID = %s", st_const->DUID);
-               if(opr == DTAPPS_VERIFY || opr == DTAPPS_INSTALL)
-               {
+
+               if (opr == DTAPPS_VERIFY || opr == DTAPPS_INSTALL) {
                        retDeviceInfo = TADC_IF_GetDUID(DUID);
-                       if (retDeviceInfo < 0)
-                       {
-                               DRM_TAPPS_EXCEPTION("Retrieve for DUID Failed!!! DUID = %s, duid_len = %d", DUID, strlen(DUID));
+
+                       if (retDeviceInfo < 0) {
+                               DRM_TAPPS_EXCEPTION("Retrieve for DUID Failed!!! DUID = %s, duid_len = %d",
+                                                                       DUID, strlen(DUID));
                                return TADC_LICENSE_UNKNOWN_ERROR;
                        }
-                       if (!(DTAPPS_MEMCMP(st_const->DUID, DUID, DTAPPS_DUID_SIZE)))
-                       {
-                               DRM_TAPPS_LOG("DUID match!! st_const->DUID = %s, DUID = %s", st_const->DUID, DUID);
+
+                       if (!(DTAPPS_MEMCMP(st_const->DUID, DUID, DTAPPS_DUID_SIZE))) {
+                               DRM_TAPPS_LOG("DUID match!! st_const->DUID = %s, DUID = %s", st_const->DUID,
+                                                         DUID);
                                ret = TADC_LICENSE_VALID;
-                       }
-                       else
-                       {
-                               DRM_TAPPS_EXCEPTION("DUID don't match!!! st_const->DUID = %s, DUID = %s", st_const->DUID, DUID);
+                       } else {
+                               DRM_TAPPS_EXCEPTION("DUID don't match!!! st_const->DUID = %s, DUID = %s",
+                                                                       st_const->DUID, DUID);
                                ret = TADC_LICENSE_DUID_MISMATCH;
                                goto Error_Exit;
                        }
                }
        }
+
        DRM_TAPPS_LOG("ret = %d", ret);
        return ret;
 
@@ -81,9 +80,9 @@ Error_Exit:
        return ret;
 }
 
-int DTappsInstallLicense(const chardeclicbuffer)
+int DTappsInstallLicense(const char *declicbuffer)
 {
-       unsigned chardb_buffer_org = NULL;
+       unsigned char *db_buffer_org = NULL;
        unsigned char db_buffer_enc[512] = {0, };
        int len_enc = 0, check_ret = 0;
        unsigned char *pDevKey = NULL;
@@ -125,36 +124,40 @@ int DTappsInstallLicense(const char* declicbuffer)
        // Copy necessary fields into structure to be stored in DB
        DTAPPS_CONSTRAINTS st_constraints = {0, };
 
-       // First Parse the decrypted Licence buffer in order to fill the t_RO buffer and use it to store in DB
+       // First Parse the decrypted Licence buffer in order
+       // to fill the t_RO buffer and use it to store in DB
        check_ret = DTappsGetROInfo(declicbuffer, &t_RO, name);
-       if (check_ret < 0)
-       {
-               DRM_TAPPS_EXCEPTION("DTappsGetROInfo Error Code = %x, check_ret = %d", TADC_LICENSEXMLPARSING_ERROR,check_ret);
+
+       if (check_ret < 0) {
+               DRM_TAPPS_EXCEPTION("DTappsGetROInfo Error Code = %x, check_ret = %d",
+                                                       TADC_LICENSEXMLPARSING_ERROR, check_ret);
                ret = TADC_LICENSEXMLPARSING_ERROR;
                goto Error_Exit;
        }
 
        /* Copy DUID */
-       if (t_RO.t_Permission.t_Individual.DUID != NULL)
-       {
-               DTAPPS_MEMCPY(st_constraints.DUID, t_RO.t_Permission.t_Individual.DUID, TAPPS_STRLEN((const char*)t_RO.t_Permission.t_Individual.DUID));
+       if (t_RO.t_Permission.t_Individual.DUID != NULL) {
+               DTAPPS_MEMCPY(st_constraints.DUID, t_RO.t_Permission.t_Individual.DUID,
+                                         TAPPS_STRLEN((const char *)t_RO.t_Permission.t_Individual.DUID));
        }
+
        DRM_TAPPS_LOG("st_constraints.DUID = %s", st_constraints.DUID);
 
        /* Validation of constraints */
        check = DTappsValidateConstraints(&st_constraints, DTAPPS_INSTALL);
-       if (check != TADC_LICENSE_VALID)
-       {
-               DRM_TAPPS_LOG("Constraints obtained are NOT VALID!!!, check = %d",check);
+
+       if (check != TADC_LICENSE_VALID) {
+               DRM_TAPPS_LOG("Constraints obtained are NOT VALID!!!, check = %d", check);
                ret = TADC_LICENSE_INVALID_ERROR;
                goto Error_Exit;
        }
 
        /* Create the contraints buffer to be put in DB */
-       db_buffer_org = (unsigned char*)DTAPPS_MALLOC(sizeof(DTAPPS_CONSTRAINTS));
-       if (db_buffer_org == NULL)
-       {
-               DRM_TAPPS_EXCEPTION("Memory Allocation error , db_buffer_org = %p", db_buffer_org);
+       db_buffer_org = (unsigned char *)DTAPPS_MALLOC(sizeof(DTAPPS_CONSTRAINTS));
+
+       if (db_buffer_org == NULL) {
+               DRM_TAPPS_EXCEPTION("Memory Allocation error , db_buffer_org = %p",
+                                                       db_buffer_org);
                ret = TADC_MEMAlOC_ERROR;
                goto Error_Exit;
        }
@@ -162,83 +165,91 @@ int DTappsInstallLicense(const char* declicbuffer)
        DTAPPS_MEMSET(db_buffer_org, 0x00, sizeof(DTAPPS_CONSTRAINTS));
        DTAPPS_MEMCPY(db_buffer_org, &st_constraints, sizeof(DTAPPS_CONSTRAINTS));
 
-       /* Calculate the hash - HMAC for the constraints buffer */
-       if (0 == DTappsGetDeviceKey(&pDevKey, &DevKeyLen))
-       {
-               DRM_TAPPS_EXCEPTION("Error in DTAppsGetDeviceKey!!!, pDevKey = %p, DevKeyLen = %d", pDevKey, DevKeyLen);
+       // Calculate the hash - HMAC for the constraints buffer
+       if (0 == DTappsGetDeviceKey(&pDevKey, &DevKeyLen)) {
+               DRM_TAPPS_EXCEPTION("Error in DTAppsGetDeviceKey!!!, "
+                                                       "pDevKey = %p, DevKeyLen = %d",
+                                                       pDevKey, DevKeyLen);
                ret = TADC_GET_DEVICEKEY_ERROR;
                goto Error_Exit;
        }
 
-       DTappsCalHMACSHA1(pDevKey, (int)DevKeyLen, db_buffer_org, sizeof(DTAPPS_CONSTRAINTS), hash, &hash_len);
+       DTappsCalHMACSHA1(pDevKey, (int)DevKeyLen, db_buffer_org,
+                                         sizeof(DTAPPS_CONSTRAINTS), hash, &hash_len);
 
-       /* Encode the buffer and hash using Base64 and then store it into the DB */
-       /* Base64 Encode the constraints buffer */
+       // Encode the buffer and hash using Base64 and then store it into the DB
+       // Base64 Encode the constraints buffer
        len_enc = (sizeof(DTAPPS_CONSTRAINTS) + 2) / 3 * 4;
 
-       isOk = DTappsB64Encode(db_buffer_org, sizeof(DTAPPS_CONSTRAINTS), db_buffer_enc, len_enc);
-       if (isOk != TRUE)
-       {
+       isOk = DTappsB64Encode(db_buffer_org, sizeof(DTAPPS_CONSTRAINTS), db_buffer_enc,
+                                                  len_enc);
+
+       if (isOk != TRUE) {
                DRM_TAPPS_EXCEPTION("BASE64 Encoding failure!!!! ret = %d", isOk);
                ret = TADC_GET_BASE64ENCODE_ERROR;
                goto Error_Exit;
        }
 
-       /* Base64 Encode the hash buffer */
+       // Base64 Encode the hash buffer
        len_enc = (hash_len + 2) / 3 * 4;
 
        isOk = DTappsB64Encode(hash, hash_len, hash_enc, len_enc);
-       if (isOk != TRUE)
-       {
+
+       if (isOk != TRUE) {
                DRM_TAPPS_EXCEPTION("BASE64 Encoding failure!!!! ret = %d", isOk);
                ret = TADC_GET_BASE64ENCODE_ERROR;
                goto Error_Exit;
        }
 
        DRM_TAPPS_LOG("CEK installation started!!");
-       if (DTAPPS_MEMCMP((void*)t_RO.t_Content.CEK, (void*)nullCek, CEK_SIZE) != 0)
-       {
+
+       if (DTAPPS_MEMCMP((void *)t_RO.t_Content.CEK, (void *)nullCek, CEK_SIZE) != 0) {
 #ifdef DTAPPS_STORE_CEK_IN_DB
-               /* Store the CEK in DB */
-               /* First encrypt the CEK , calculate the HASH and then convert both into BASE64 Encoded form */
+               // Store the CEK in DB
+               // First encrypt the CEK , calculate the HASH and then convert both
+               // into BASE64 Encoded form
                //ceklen = (unsigned int)TAPPS_STRLEN((const char*) t_RO.t_Content.CEK);
-               /* keylen => Should be a multiple of 8 */
+               // keylen => Should be a multiple of 8
                keylen = CEK_SIZE;
                encr_cek_len = keylen + 8;
 
-               if ((check_ret = DTAPPS_AES_SET_ENCR_KEY(pDevKey, 128, &key)) != 0)
-               {
-                       DRM_TAPPS_EXCEPTION("DTAPPS_AES_SET_ENC_KEY failed!!, check_ret = %d", check_ret);
+               if ((check_ret = DTAPPS_AES_SET_ENCR_KEY(pDevKey, 128, &key)) != 0) {
+                       DRM_TAPPS_EXCEPTION("DTAPPS_AES_SET_ENC_KEY failed!!, check_ret = %d",
+                                                               check_ret);
                        ret =  TADC_SET_AES_ENCRYPTKEY_ERROR;
                        goto Error_Exit;
                }
 
-               encr_cek = (unsigned char*)DTAPPS_MALLOC(encr_cek_len);
-               if (NULL == encr_cek)
-               {
+               encr_cek = (unsigned char *)DTAPPS_MALLOC(encr_cek_len);
+
+               if (NULL == encr_cek) {
                        DRM_TAPPS_EXCEPTION("Memory Allocation Error!!, encr_cek = %p", encr_cek);
                        ret = TADC_MEMAlOC_ERROR;
                        goto Error_Exit;
                }
 
-               check_ret = DTAPPS_AES_WRAP_KEY(&key, NULL, encr_cek, t_RO.t_Content.CEK, keylen);
-               if (check_ret <= 0)
-               {
-                       DRM_TAPPS_EXCEPTION("DTAPPS_AES_WRAP_KEY failed!!, check_ret = %d", check_ret);
+               check_ret = DTAPPS_AES_WRAP_KEY(&key, NULL, encr_cek, t_RO.t_Content.CEK,
+                                                                               keylen);
+
+               if (check_ret <= 0) {
+                       DRM_TAPPS_EXCEPTION("DTAPPS_AES_WRAP_KEY failed!!, check_ret = %d",
+                                                               check_ret);
                        ret = TADC_SET_AES_WRAPKEY_ERROR;
                        goto Error_Exit;
                }
+
                DRM_TAPPS_LOG("encr_cek = %s", encr_cek);
 
                /* Calculate the HASH for Encrypted CEK */
-               DTappsCalHMACSHA1(pDevKey, (int)DevKeyLen, encr_cek, encr_cek_len, encr_cek_hash, &encr_cek_hash_len);
+               DTappsCalHMACSHA1(pDevKey, (int)DevKeyLen, encr_cek, encr_cek_len,
+                                                 encr_cek_hash, &encr_cek_hash_len);
                DRM_TAPPS_LOG("encr_cek_hash = %s", encr_cek_hash);
 
                /* Base64 Encode the Encrypted CEK */
                len_enc = (encr_cek_len + 2) / 3 * 4;
                isOk = DTappsB64Encode(encr_cek, encr_cek_len, b64_encr_cek, len_enc);
-               if (isOk != TRUE)
-               {
+
+               if (isOk != TRUE) {
                        DRM_TAPPS_EXCEPTION("BASE64 Encoding failure!!!! ret = %d", isOk);
                        ret = TADC_GET_BASE64ENCODE_ERROR;
                        goto Error_Exit;
@@ -246,87 +257,88 @@ int DTappsInstallLicense(const char* declicbuffer)
 
                /* Base64 Encode the Hash of Encrypted CEK */
                len_enc = (encr_cek_hash_len + 2) / 3 * 4;
-               isOk = DTappsB64Encode(encr_cek_hash, encr_cek_hash_len, b64_encr_cek_hash, len_enc);
-               if (isOk != TRUE)
-               {
+               isOk = DTappsB64Encode(encr_cek_hash, encr_cek_hash_len, b64_encr_cek_hash,
+                                                          len_enc);
+
+               if (isOk != TRUE) {
                        DRM_TAPPS_EXCEPTION("BASE64 Encoding failure!!!! ret = %d", isOk);
                        ret = TADC_GET_BASE64ENCODE_ERROR;
                        goto Error_Exit;
                }
 
-               DRM_TAPPS_LOG("b64_encr_cek = %s, b64_encr_cek_hash = %s", b64_encr_cek, b64_encr_cek_hash);
+               DRM_TAPPS_LOG("b64_encr_cek = %s, b64_encr_cek_hash = %s", b64_encr_cek,
+                                         b64_encr_cek_hash);
 #else
                DRM_TAPPS_LOG("CEK in Secure Storage to be implemented!!!");
 #endif
-       }
-       else
-       {
+       } else {
                DRM_TAPPS_EXCEPTION("t_RO.t_Content.CEK is null!!");
        }
 
        /* Calculate the Time of storage */
        now = DTAPPS_TIME(NULL);
        struct tm time_gmt;
-    DTAPPS_GMTIME_THREAD_SAFE(&now, &time_gmt);
+       DTAPPS_GMTIME_THREAD_SAFE(&now, &time_gmt);
 
        /* Format the time to be stored in the DB buffer - DATETIME format */
        len = DTAPPS_SNPRINTF(
-                       time_buffer,
-                       sizeof(time_buffer),
-                       "%04d-%02d-%02dT%02d:%02d:%02dZ",
-                               time_gmt.tm_year + 1900,
-                               time_gmt.tm_mon + 1,
-                               time_gmt.tm_mday,
-                               time_gmt.tm_hour,
-                               time_gmt.tm_min,
-                               time_gmt.tm_sec);
-
-       if ((len == -1) || (len >= (int)sizeof(time_buffer)))
-       {
-               DRM_TAPPS_EXCEPTION("snprintf failed , len = %d, sizeof(time_buffer) = %d",len,sizeof(time_buffer));
+                         time_buffer,
+                         sizeof(time_buffer),
+                         "%04d-%02d-%02dT%02d:%02d:%02dZ",
+                         time_gmt.tm_year + 1900,
+                         time_gmt.tm_mon + 1,
+                         time_gmt.tm_mday,
+                         time_gmt.tm_hour,
+                         time_gmt.tm_min,
+                         time_gmt.tm_sec);
+
+       if ((len == -1) || (len >= (int)sizeof(time_buffer))) {
+               DRM_TAPPS_EXCEPTION("snprintf failed , len = %d, sizeof(time_buffer) = %d", len,
+                                                       sizeof(time_buffer));
                ret = TADC_MEMAlOC_ERROR;
                goto Error_Exit;
        }
+
        DRM_TAPPS_LOG("time_buffer = %s", time_buffer);
-       DRM_TAPPS_LOG("Constraint_buffer = %s, Constraint_Hash = %s", db_buffer_enc, hash_enc);
+       DRM_TAPPS_LOG("Constraint_buffer = %s, Constraint_Hash = %s", db_buffer_enc,
+                                 hash_enc);
 
        // 2013/04/25 added for db update
-       isOk = DTapps_RIGHTS_SELECT_ONE((char*) t_RO.t_Content.CID, &row);
+       isOk = DTapps_RIGHTS_SELECT_ONE((char *) t_RO.t_Content.CID, &row);
 
        // if there is no rights in the db, insert into rights to db
-       if (isOk != TRUE)
-       {
+       if (isOk != TRUE) {
                DRM_TAPPS_LOG("Insert into dtapps2rights started....");
-        isOk = DTapps_RIGHTS_INSTALL((char*) name, time_buffer,
-                                                                       #ifdef DTAPPS_STORE_CEK_IN_DB
-                                                                       (char*) b64_encr_cek, (char*) b64_encr_cek_hash,
-                                                                       #endif
-                                                                       (char*) db_buffer_enc, (char*) hash_enc, (char*) t_RO.t_Content.CID,
-                                                                       FALSE);
-           if (isOk != TRUE)
-               {
+               isOk = DTapps_RIGHTS_INSTALL((char *) name, time_buffer,
+#ifdef DTAPPS_STORE_CEK_IN_DB
+                                                                        (char *) b64_encr_cek, (char *) b64_encr_cek_hash,
+#endif
+                                                                        (char *) db_buffer_enc, (char *) hash_enc,
+                                                                        (char *) t_RO.t_Content.CID, FALSE);
+
+               if (isOk != TRUE) {
                        DRM_TAPPS_EXCEPTION("DB Installation failure!!!! ret = %d", isOk);
                        ret = TADC_DB_INSTALL_ERROR;
                        goto Error_Exit;
                }
+
                DRM_TAPPS_LOG("DrmTdcInstallLicense Success!!!!!! ret = %d", ret);
-       }
-       // if there is same cid rights exist, update right to db
-       else
-       {
+       } else {
+               // if there is same cid rights exist, update right to db
                DRM_TAPPS_LOG("Update dtapps2rights started....");
-               isOk = DTapps_RIGHTS_INSTALL((char*) name, time_buffer,
-                                                                       #ifdef DTAPPS_STORE_CEK_IN_DB
-                                                                       (char*) b64_encr_cek, (char*) b64_encr_cek_hash,
-                                                                       #endif
-                                                                       (char*) db_buffer_enc, (char*) hash_enc, (char*) t_RO.t_Content.CID,
-                                                                       TRUE);
-           if (isOk != TRUE)
-               {
+               isOk = DTapps_RIGHTS_INSTALL((char *) name, time_buffer,
+#ifdef DTAPPS_STORE_CEK_IN_DB
+                                                                        (char *) b64_encr_cek, (char *) b64_encr_cek_hash,
+#endif
+                                                                        (char *) db_buffer_enc, (char *) hash_enc,
+                                                                        (char *) t_RO.t_Content.CID, TRUE);
+
+               if (isOk != TRUE) {
                        DRM_TAPPS_EXCEPTION("DB Update failure!!!! ret = %d", isOk);
                        ret = TADC_DB_INSTALL_ERROR;
                        goto Error_Exit;
                }
+
                DRM_TAPPS_LOG("DrmTdcInstallLicense Success!!!!!! ret = %d", ret);
        }
 
@@ -335,14 +347,14 @@ int DTappsInstallLicense(const char* declicbuffer)
            std::string tmpPath((char *)(t_RO.t_Content.CID));
            tmpPath += ".ro";
 
-               FILE *fd = fopen(tmpPath.c_str(), "w+b");
-               if (fd == NULL)
-               {
-                       goto Error_Exit;
-               }
-               fwrite(declicbuffer, 1, strlen(declicbuffer), fd);
-               fclose(fd);
-               DRM_TAPPS_LOG("Save decrypted RO success!, path = %s", tmpPath.c_str());
+           FILE *fd = fopen(tmpPath.c_str(), "w+b");
+           if (fd == NULL)
+           {
+               goto Error_Exit;
+           }
+           fwrite(declicbuffer, 1, strlen(declicbuffer), fd);
+           fclose(fd);
+           DRM_TAPPS_LOG("Save decrypted RO success!, path = %s", tmpPath.c_str());
        }*/
        // Test Code Done!
 
@@ -350,20 +362,20 @@ Error_Exit:
        TADC_MEMFree_RO(&t_RO);
 
        if (db_buffer_org)
-       {
-               DTAPPS_FREE((unsigned char*)db_buffer_org);
-       }
+               DTAPPS_FREE((unsigned char *)db_buffer_org);
+
        if (encr_cek)
-       {
                DTAPPS_FREE(encr_cek);
-       }
 
        return ret;
 }
 
-int DTappsHasValidLicense(const charszCid)
+int DTappsHasValidLicense(const char *szCid)
 {
-       int const_buf_enclen = 0, hash_buf_enclen = 0, const_buf_declen = 0, hash_buf_declen = 0;
+       int const_buf_enclen = 0;
+       int hash_buf_enclen = 0;
+       int const_buf_declen = 0;
+       int hash_buf_declen = 0;
 
        unsigned char *pDevKey = NULL;
        unsigned int DevKeyLen = 0;
@@ -379,16 +391,16 @@ int DTappsHasValidLicense(const char* szCid)
        DTAPPS_CONSTRAINTS st_constaints = {0, };
 
        check = DTapps_RIGHTS_SELECT_ONE(szCid, &row);
-       if (check != TRUE)
-       {
+
+       if (check != TRUE) {
                DRM_TAPPS_EXCEPTION("There is no RO in the DB. cid  = %s", szCid);
                check_valid = TADC_LICENSE_NO_LICENSE;
                goto DTAPPS_END;
        }
 
-       if (0 == DTappsGetDeviceKey(&pDevKey, &DevKeyLen))
-       {
-               DRM_TAPPS_EXCEPTION("Error in DTAppsGetDeviceKey pDevKey = %s, DevKeyLen = %d", pDevKey, DevKeyLen);
+       if (0 == DTappsGetDeviceKey(&pDevKey, &DevKeyLen)) {
+               DRM_TAPPS_EXCEPTION("Error in DTAppsGetDeviceKey pDevKey = %s, DevKeyLen = %d",
+                                                       pDevKey, DevKeyLen);
                check_valid = TADC_LICENSE_UNKNOWN_ERROR;
                goto DTAPPS_END;
        }
@@ -396,18 +408,24 @@ int DTappsHasValidLicense(const char* szCid)
        /* BASE64 Decode the constraints buffer extracted from the DB */
        const_buf_enclen = TAPPS_STRLEN(row.constraint_buffer);
        const_buf_declen = const_buf_enclen / 4 * 3;
-       if (const_buf_enclen <= 0)
-       {
+
+       if (const_buf_enclen <= 0) {
                DRM_TAPPS_EXCEPTION("There is no constaints buffer in the DB. cid = %s", szCid);
                check_valid = TADC_LICENSE_UNKNOWN_ERROR;
                goto DTAPPS_END;
        }
-       DRM_TAPPS_FRQ_LOG("const_buf_enclen = %d, const_buf_declen = %d", const_buf_enclen, const_buf_declen);
 
-       (void)DTappsB64Decode((unsigned char*)row.constraint_buffer, const_buf_enclen, const_buffer_dec, const_buf_declen);
-       if (const_buf_declen > (const_buf_enclen / 4 * 3))
-       {
-               DRM_TAPPS_EXCEPTION("BASE64 Decode error !!! const_buffer_dec = %s, const_buf_declen = %d, (const_buf_enclen/4*3) = %d", const_buffer_dec, const_buf_declen, (const_buf_enclen / 4 * 3));
+       DRM_TAPPS_FRQ_LOG("const_buf_enclen = %d, const_buf_declen = %d",
+                                         const_buf_enclen, const_buf_declen);
+
+       (void)DTappsB64Decode((unsigned char *)row.constraint_buffer, const_buf_enclen,
+                                                 const_buffer_dec, const_buf_declen);
+
+       if (const_buf_declen > (const_buf_enclen / 4 * 3)) {
+               DRM_TAPPS_EXCEPTION("BASE64 Decode error !!! const_buffer_dec = %s, "
+                                                       "const_buf_declen = %d, (const_buf_enclen/4*3) = %d",
+                                                       const_buffer_dec, const_buf_declen,
+                                                       (const_buf_enclen / 4 * 3));
                check_valid = TADC_LICENSE_UNKNOWN_ERROR;
                goto DTAPPS_END;
        }
@@ -418,31 +436,42 @@ int DTappsHasValidLicense(const char* szCid)
 
        hash_buf_enclen = TAPPS_STRLEN(row.constraint_hash);
        hash_buf_declen = hash_buf_enclen / 4 * 3;
-       if (hash_buf_enclen <= 0)
-       {
-               DRM_TAPPS_EXCEPTION("There is no constaints_hash buffer in the DB. cid = %s", szCid);
+
+       if (hash_buf_enclen <= 0) {
+               DRM_TAPPS_EXCEPTION("There is no constaints_hash buffer in the DB. cid = %s",
+                                                       szCid);
                check_valid = TADC_LICENSE_UNKNOWN_ERROR;
                goto DTAPPS_END;
        }
-       DRM_TAPPS_FRQ_LOG("hash_buf_enclen = %d, hash_buf_declen = %d", hash_buf_enclen, hash_buf_declen);
 
-       (void)DTappsB64Decode((unsigned char*)row.constraint_hash, hash_buf_enclen, hash_buffer_dec, hash_buf_declen);
-       if (hash_buf_declen > (hash_buf_enclen / 4 * 3))
-       {
-               DRM_TAPPS_EXCEPTION("BASE64 Decode error !!! hash_buffer_dec = %s, hash_buf_declen = %d, (hash_buf_enclen/4*3) = %d", hash_buffer_dec, hash_buf_declen, (hash_buf_enclen / 4 * 3));
+       DRM_TAPPS_FRQ_LOG("hash_buf_enclen = %d, hash_buf_declen = %d", hash_buf_enclen,
+                                         hash_buf_declen);
+
+       (void)DTappsB64Decode((unsigned char *)row.constraint_hash, hash_buf_enclen,
+                                                 hash_buffer_dec, hash_buf_declen);
+
+       if (hash_buf_declen > (hash_buf_enclen / 4 * 3)) {
+               DRM_TAPPS_EXCEPTION("BASE64 Decode error !!! hash_buffer_dec = %s, "
+                                                       "hash_buf_declen = %d, (hash_buf_enclen/4*3) = %d",
+                                                       hash_buffer_dec, hash_buf_declen,
+                                                       (hash_buf_enclen / 4 * 3));
                check_valid = TADC_LICENSE_UNKNOWN_ERROR;
                goto DTAPPS_END;
        }
 
-       /* Calculate the hash using HMAC from the BASE64Decoded Constraint Buffers and check with the BASE64Decoded Hash buffers */
-       DTappsCalHMACSHA1(pDevKey, (int)DevKeyLen, const_buffer_dec, const_buf_declen, md, &md_len);
-       if (DTAPPS_MEMCMP(md, hash_buffer_dec, hash_buf_declen) == 0)
-       {
-               DRM_TAPPS_LOG("HASH matching!!! md = %s, hash_buffer_dec = %s, hash_buf_declen = %d", md, hash_buffer_dec, hash_buf_declen);
-       }
-       else
-       {
-               DRM_TAPPS_EXCEPTION("HASH not matching!!! md = %s, hash_buffer_dec = %s, hash_buf_declen = %d", md, hash_buffer_dec, hash_buf_declen);
+       // Calculate the hash using HMAC from the BASE64Decoded Constraint Buffers
+       // and check with the BASE64Decoded Hash buffers
+       DTappsCalHMACSHA1(pDevKey, (int)DevKeyLen, const_buffer_dec, const_buf_declen,
+                                         md, &md_len);
+
+       if (DTAPPS_MEMCMP(md, hash_buffer_dec, hash_buf_declen) == 0) {
+               DRM_TAPPS_LOG("HASH matching!!! md = %s, hash_buffer_dec = %s, "
+                                         "hash_buf_declen = %d",
+                                         md, hash_buffer_dec, hash_buf_declen);
+       } else {
+               DRM_TAPPS_EXCEPTION("HASH not matching!!! md = %s, hash_buffer_dec = %s, "
+                                                       "hash_buf_declen = %d",
+                                                       md, hash_buffer_dec, hash_buf_declen);
                check_valid = TADC_LICENSE_UNKNOWN_ERROR;
                goto DTAPPS_END;
        }
@@ -451,65 +480,66 @@ int DTappsHasValidLicense(const char* szCid)
        DTAPPS_MEMCPY(&st_constaints, const_buffer_dec, sizeof(DTAPPS_CONSTRAINTS));
 
        check_valid = DTappsValidateConstraints(&st_constaints, DTAPPS_VERIFY);
-       if (check_valid != TADC_LICENSE_VALID)
-       {
-               DRM_TAPPS_LOG("Invalid Constraints for constraints_buffer = %s check_valid = %d", const_buffer_dec, check_valid);
-               /* TODO: Implementation of Auto Deletion feature to delete the rights from the DB if the rights are expired!!!*/
+
+       if (check_valid != TADC_LICENSE_VALID) {
+               DRM_TAPPS_LOG("Invalid Constraints for constraints_buffer = %s "
+                                         "check_valid = %d",
+                                         const_buffer_dec, check_valid);
+               // TODO: Implementation of Auto Deletion feature to delete the rights
+               //       from the DB if the rights are expired!!!
                goto DTAPPS_END;
-       }
-       else
-       {
-               DRM_TAPPS_LOG("Rights are Valid!!! Found atleast one Valid Rights..... return with Success!! check_valid = %d", check_valid);
+       } else {
+               DRM_TAPPS_LOG("Rights are Valid!!! Found atleast one Valid Rights..... "
+                                         "return with Success!! check_valid = %d",
+                                         check_valid);
        }
 
 DTAPPS_END:
-       if (pDevKey)
-       {
+
+       if (pDevKey) {
                DTappsFreeDeviceKey(&pDevKey);
        }
-       if (check_valid != TADC_LICENSE_VALID)
-       {
+
+       if (check_valid != TADC_LICENSE_VALID) {
                DRM_TAPPS_EXCEPTION("Constraints not Valid!!!! check_valid = %d", check_valid);
                DRM_TAPPS_EXCEPTION("DrmTdcHasValidLicense Failed!!!");
                return check_valid;
-       }
-       else
-       {
+       } else {
                DRM_TAPPS_LOG("Constraints are Valid!! check_valid = %d", check_valid);
                return TADC_LICENSE_VALID;
        }
 }
 
-int DTappsGetROInfo(const char* pszXML, T_RO *t_RO, unsigned char* name)
+int DTappsGetROInfo(const char *pszXML, T_RO *t_RO, unsigned char *name)
 {
-       int                             nResult = 0;
-       CXMLFile                oXMLFile;
-       CXMLElement*    pRoot, *pElement;
-       CPointerArray   paChilds;
-       LPCTSTR                 pszValue;
-       int                             length = 0;
-       unsigned char   *pbBuffer = NULL;
+       int             nResult = 0;
+       CXMLFile        oXMLFile;
+       CXMLElement    *pRoot, *pElement;
+       CPointerArray   paChilds;
+       LPCTSTR         pszValue;
+       int             length = 0;
+       unsigned char   *pbBuffer = NULL;
        int len_enc = 0, len_dec = 0;
 
        const char *pRoHeader = "<?xml version=\"1.0\"?>\n<TizenLicense>";
 
        //Check Param Buffer
-       if (pszXML == NULL || t_RO == NULL || name == NULL)
-       {
+       if (pszXML == NULL || t_RO == NULL || name == NULL) {
                DRM_TAPPS_EXCEPTION("Parameters NULL!!! pszXML = %p, t_RO = %p", pszXML, t_RO);
                return -1;
        }
 
        if (memcmp(pszXML, pRoHeader, strlen(pRoHeader))) {
-               DRM_TAPPS_EXCEPTION("TADC_IF_MemCmp. pRoHeader[%s] Error Code = %x", pRoHeader, TADC_XMLPARSER_ERROR);
+               DRM_TAPPS_EXCEPTION("TADC_IF_MemCmp. pRoHeader[%s] Error Code = %x", pRoHeader,
+                                                       TADC_XMLPARSER_ERROR);
                return -1;
        }
 
        DTAPPS_MEMSET(t_RO, 0, sizeof(T_RO));
 
        nResult = oXMLFile.LoadFromStream((LPCTSTR)pszXML);
-       if (nResult < 0)
-       {
+
+       if (nResult < 0) {
                DRM_TAPPS_EXCEPTION("oXMLFile.LoadFromStream is failed\n");
                nResult = -1;
                goto finish;
@@ -517,8 +547,8 @@ int DTappsGetROInfo(const char* pszXML, T_RO *t_RO, unsigned char* name)
 
        // Set Version
        pRoot = oXMLFile.GetRoot();
-       if (pRoot == NULL)
-       {
+
+       if (pRoot == NULL) {
                DRM_TAPPS_EXCEPTION("oXMLFile.GetRoot is failed\n");
                nResult = -1;
                goto finish;
@@ -526,8 +556,8 @@ int DTappsGetROInfo(const char* pszXML, T_RO *t_RO, unsigned char* name)
 
        // Get UID -> Name
        pRoot = oXMLFile.GetRoot();
-       if (pRoot == NULL)
-       {
+
+       if (pRoot == NULL) {
                DRM_TAPPS_EXCEPTION("oXMLFile.GetRoot is failed\n");
                nResult = -1;
                goto finish;
@@ -535,32 +565,31 @@ int DTappsGetROInfo(const char* pszXML, T_RO *t_RO, unsigned char* name)
 
        paChilds.RemoveAll();
        nResult = pRoot->Find(&paChilds, _T("LicenseInfo"), _T("uid"), NULL);
-       if (nResult != 0)
-       {
+
+       if (nResult != 0) {
                DRM_TAPPS_EXCEPTION("pRoot->Find is failed\n");
                nResult = -1;
                goto finish;
        }
 
-       if (paChilds.GetCount() != 1)
-       {
+       if (paChilds.GetCount() != 1) {
                DRM_TAPPS_EXCEPTION("paChilds.GetCount() is failed\n");
                nResult = -1;
                goto finish;
        }
 
-       pElement = (CXMLElement*) paChilds.Get(0);
+       pElement = (CXMLElement *) paChilds.Get(0);
        pszValue = pElement->GetValue();
-       if (pszValue == NULL)
-       {
+
+       if (pszValue == NULL) {
                DRM_TAPPS_EXCEPTION("pElement->GetValue() is failed\n");
                nResult = -2;
                goto finish;
        }
 
        length = TAPPS_STRLEN(pszValue);
-       if (length <= 0 || length > DTAPPS_NAME_SIZE)
-       {
+
+       if (length <= 0 || length > DTAPPS_NAME_SIZE) {
                DRM_TAPPS_EXCEPTION("TAPPS_STRLEN failed(%d) -  %s\n", length, pszValue);
                nResult = -1;
                goto finish;
@@ -571,8 +600,8 @@ int DTappsGetROInfo(const char* pszXML, T_RO *t_RO, unsigned char* name)
 
        // Get UID -> CID
        pRoot = oXMLFile.GetRoot();
-       if (pRoot == NULL)
-       {
+
+       if (pRoot == NULL) {
                DRM_TAPPS_EXCEPTION("oXMLFile.GetRoot is failed\n");
                nResult = -1;
                goto finish;
@@ -580,37 +609,37 @@ int DTappsGetROInfo(const char* pszXML, T_RO *t_RO, unsigned char* name)
 
        paChilds.RemoveAll();
        nResult = pRoot->Find(&paChilds, _T("ContentInfo"), _T("cid"), NULL);
-       if (nResult != 0)
-       {
+
+       if (nResult != 0) {
                DRM_TAPPS_EXCEPTION("pRoot->Find is failed\n");
                nResult = -1;
                goto finish;
        }
-       if (paChilds.GetCount() != 1)
-       {
+
+       if (paChilds.GetCount() != 1) {
                DRM_TAPPS_EXCEPTION("paChilds.GetCount() is failed\n");
                nResult = -1;
                goto finish;
        }
 
-       pElement = (CXMLElement*)paChilds.Get(0);
+       pElement = (CXMLElement *)paChilds.Get(0);
        pszValue = pElement->GetValue();
-       if (pszValue == NULL)
-       {
+
+       if (pszValue == NULL) {
                DRM_TAPPS_EXCEPTION("pElement->GetValue() is failed\n");
                nResult = -2;
                goto finish;
        }
 
        length = TAPPS_STRLEN(pszValue);
-       if (length <= 0 || length > CID_SIZE)
-       {
+
+       if (length <= 0 || length > CID_SIZE) {
                DRM_TAPPS_EXCEPTION("TAPPS_STRLEN is failed(%d) -  %s\n", length, pszValue);
                nResult = -1;
                goto finish;
        }
 
-       t_RO->t_Content.CID = (TADC_U8*)DTAPPS_MALLOC(CID_SIZE + 1);
+       t_RO->t_Content.CID = (TADC_U8 *)DTAPPS_MALLOC(CID_SIZE + 1);
        IF_TRUE_GOTO(t_RO->t_Content.CID == NULL, -2);
 
        memset(t_RO->t_Content.CID, 0, CID_SIZE + 1);
@@ -622,22 +651,23 @@ int DTappsGetROInfo(const char* pszXML, T_RO *t_RO, unsigned char* name)
        paChilds.RemoveAll();
        nResult = pRoot->Find(&paChilds, _T("KeyInfo"), _T("CipherValue"), NULL);
 
-       IF_TRUE_GOTO( nResult != 0, ERROR_INVALID_DATA );
-       IF_TRUE_GOTO( paChilds.GetCount() != 1, ERROR_INVALID_DATA );
+       IF_TRUE_GOTO(nResult != 0, ERROR_INVALID_DATA);
+       IF_TRUE_GOTO(paChilds.GetCount() != 1, ERROR_INVALID_DATA);
 
-       pElement = (CXMLElement*)paChilds.Get(0);
+       pElement = (CXMLElement *)paChilds.Get(0);
        pszValue = pElement->GetValue();
        IF_TRUE_GOTO(pszValue == NULL, -2);
 
        len_enc = TAPPS_STRLEN(pszValue);
        len_dec = len_enc / 4 * 3;
 
-       DRM_TAPPS_LOG("CEK raw = [%s], len_enc = [%d], len_dec = [%d]", pszValue, len_enc, len_dec);
+       DRM_TAPPS_LOG("CEK raw = [%s], len_enc = [%d], len_dec = [%d]", pszValue,
+                                 len_enc, len_dec);
 
 #if 0
-       pbBuffer = (unsigned char*)DTAPPS_MALLOC(len_dec + 1);
-       if (pbBuffer == NULL)
-       {
+       pbBuffer = (unsigned char *)DTAPPS_MALLOC(len_dec + 1);
+
+       if (pbBuffer == NULL) {
                DRM_TAPPS_EXCEPTION("Memory Allocation Error pbBuffer = %p", pbBuffer);
                nResult = -2;
                goto finish;
@@ -647,29 +677,32 @@ int DTappsGetROInfo(const char* pszXML, T_RO *t_RO, unsigned char* name)
 #endif
 
        pbBuffer = Base64Decode(pszValue, &len_dec);
-       if (pbBuffer == NULL)
-       {
+
+       if (pbBuffer == NULL) {
                DRM_TAPPS_EXCEPTION("Memory Allocation Error pbBuffer = %p", pbBuffer);
                nResult = -2;
                goto finish;
        }
 
-       if (len_dec > (len_enc / 4 * 3))
-       {
-               DRM_TAPPS_EXCEPTION("BASE64 Decode error !!! pbBuffer=%s, len_dec=%d, (len_enc/4*3)=%d", pbBuffer, len_dec, (len_enc / 4 * 3));
+       if (len_dec > (len_enc / 4 * 3)) {
+               DRM_TAPPS_EXCEPTION("BASE64 Decode error !!! pbBuffer=%s, len_dec=%d, "
+                                                       "(len_enc/4*3)=%d",
+                                                       pbBuffer, len_dec, (len_enc / 4 * 3));
                nResult = -1;
                goto finish;
        }
-       if (len_dec != CEK_SIZE)
-       {
-               DRM_TAPPS_EXCEPTION("BASE64 Decode error !!! CEK size=%d, len_dec=%d", CEK_SIZE, len_dec);
+
+       if (len_dec != CEK_SIZE) {
+               DRM_TAPPS_EXCEPTION("BASE64 Decode error !!! CEK size=%d, len_dec=%d", CEK_SIZE,
+                                                       len_dec);
                nResult = -1;
                goto finish;
        }
 
-       DRM_TAPPS_LOG("Base64Decoded CEK pbBuffer=%s, len_dec=%d, (len_enc/4*3)=%d", pbBuffer, len_dec, (len_enc / 4 * 3));
+       DRM_TAPPS_LOG("Base64Decoded CEK pbBuffer=%s, len_dec=%d, (len_enc/4*3)=%d",
+                                 pbBuffer, len_dec, (len_enc / 4 * 3));
 
-       t_RO->t_Content.CEK = (TADC_U8*)DTAPPS_MALLOC(CEK_SIZE + 1);
+       t_RO->t_Content.CEK = (TADC_U8 *)DTAPPS_MALLOC(CEK_SIZE + 1);
        IF_TRUE_GOTO(t_RO->t_Content.CEK == NULL, -2);
        DTAPPS_MEMSET(t_RO->t_Content.CEK, 0x00, CEK_SIZE + 1);
        DTAPPS_MEMCPY(t_RO->t_Content.CEK, pbBuffer, CEK_SIZE);
@@ -677,7 +710,7 @@ int DTappsGetROInfo(const char* pszXML, T_RO *t_RO, unsigned char* name)
 
        // Get individual
        pRoot = oXMLFile.GetRoot();
-       IF_TRUE_GOTO( pRoot == NULL, ERROR_INVALID_DATA );
+       IF_TRUE_GOTO(pRoot == NULL, ERROR_INVALID_DATA);
 
        paChilds.RemoveAll();
        nResult = pRoot->Find(&paChilds, _T("DeviceInfo"), _T("DUID"), NULL);
@@ -685,56 +718,55 @@ int DTappsGetROInfo(const char* pszXML, T_RO *t_RO, unsigned char* name)
        IF_TRUE_GOTO(nResult != 0, ERROR_INVALID_DATA);
        IF_TRUE_GOTO(paChilds.GetCount() != 1, ERROR_INVALID_DATA);
 
-       pElement = (CXMLElement*)paChilds.Get(0);
+       pElement = (CXMLElement *)paChilds.Get(0);
        pszValue = pElement->GetValue();
        IF_TRUE_GOTO(pszValue == NULL, -1);
-       length = TADC_IF_StrLen((char*)pszValue);
-       if (length <= 0)
-       {
+       length = TADC_IF_StrLen((char *)pszValue);
+
+       if (length <= 0) {
                nResult = -1;
                goto finish;
        }
 
        t_RO->PerFlag |= DUID_RULE;
        t_RO->t_Permission.t_Individual.BindingType |= DUID_RULE;
-       t_RO->t_Permission.t_Individual.DUID = (TADC_U8*)TADC_IF_Malloc(length + 1);
+       t_RO->t_Permission.t_Individual.DUID = (TADC_U8 *)TADC_IF_Malloc(length + 1);
 
-       if (t_RO->t_Permission.t_Individual.DUID == NULL)
-       {
+       if (t_RO->t_Permission.t_Individual.DUID == NULL) {
                DRM_TAPPS_EXCEPTION("TADC_IF_MemCmp Error Code = %x", TADC_MEMAlOC_ERROR);
                nResult = -2;
                goto finish;
        }
 
        TADC_IF_MemSet(t_RO->t_Permission.t_Individual.DUID, 0, length + 1);
-       TADC_IF_MemCpy((CHAR*)t_RO->t_Permission.t_Individual.DUID, pszValue, length);
+       TADC_IF_MemCpy((CHAR *)t_RO->t_Permission.t_Individual.DUID, pszValue, length);
 
        nResult = 0;
 
 finish:
        pszValue = NULL;
 
-       if (pbBuffer)
-       {
+       if (pbBuffer) {
                DTAPPS_FREE(pbBuffer);
        }
 
-       if (nResult < 0)
-       {
+       if (nResult < 0) {
                DRM_TAPPS_EXCEPTION(" Error Code = %x", TADC_XMLPARSER_ERROR);
        }
 
-       if (nResult == -2)
-       {
+       if (nResult == -2) {
                DRM_TAPPS_EXCEPTION(" Error Code = %x", TADC_MEMAlOC_ERROR);
        }
 
        return nResult;
 }
 
-BOOL DTappsGetCEK(const char* szCid, T_RO* t_RO)
+BOOL DTappsGetCEK(const char *szCid, T_RO *t_RO)
 {
-       int db_buf_enclen = 0, hash_buf_enclen = 0, db_buf_declen = 0, hash_buf_declen = 0;
+       int db_buf_enclen = 0;
+       int hash_buf_enclen = 0;
+       int db_buf_declen = 0;
+       int hash_buf_declen = 0;
        DTAPPS_RIGHTS_ROW row;
        BOOL check = FALSE;
 
@@ -755,46 +787,51 @@ BOOL DTappsGetCEK(const char* szCid, T_RO* t_RO)
 
        memset(&key, 0x00, sizeof(key));
 
-       if (NULL == szCid || NULL == t_RO)
-       {
+       if (NULL == szCid || NULL == t_RO) {
                DRM_TAPPS_EXCEPTION("Null Parameters!! szCid = %p, t_RO = %p", szCid, t_RO);
                goto DTAPPS_ERROR;
        }
 
        check = DTapps_RIGHTS_SELECT_ONE(szCid, &row);
-       if (check != TRUE)
-       {
+
+       if (check != TRUE) {
                DRM_TAPPS_EXCEPTION("There is no RO in the DB. cid=%s", szCid);
                check_valid = TADC_LICENSE_NO_LICENSE;
                goto DTAPPS_ERROR;
        }
 
-       if (0 == DTappsGetDeviceKey(&pDevKey, &DevKeyLen))
-       {
-               DRM_TAPPS_EXCEPTION("error in DTappsGetDeviceKey pDevKey = %s, DevKeyLen = %d", pDevKey, DevKeyLen);
+       if (0 == DTappsGetDeviceKey(&pDevKey, &DevKeyLen)) {
+               DRM_TAPPS_EXCEPTION("error in DTappsGetDeviceKey pDevKey = %s, DevKeyLen = %d",
+                                                       pDevKey, DevKeyLen);
                check_valid = TADC_LICENSE_UNKNOWN_ERROR;
                goto DTAPPS_ERROR;
        }
-       DRM_TAPPS_LOG("DTappsGetDeviceKey pDevKey = %s, DevKeyLen = %d", pDevKey, DevKeyLen);
+
+       DRM_TAPPS_LOG("DTappsGetDeviceKey pDevKey = %s, DevKeyLen = %d", pDevKey,
+                                 DevKeyLen);
 
        check_valid = TADC_LICENSE_VALID;
 
        /* BASE64 Decode the constraints buffer extracted from the DB */
        db_buf_enclen = TAPPS_STRLEN(row.constraint_buffer);
        db_buf_declen = db_buf_enclen / 4 * 3;
-       if (db_buf_enclen <= 0)
-       {
+
+       if (db_buf_enclen <= 0) {
                DRM_TAPPS_EXCEPTION("There is no constaints buffer in the DB. cid = %s", szCid);
                check_valid = TADC_LICENSE_UNKNOWN_ERROR;
                goto DTAPPS_ERROR;
        }
 
-       DRM_TAPPS_FRQ_LOG("db_buf_enclen = %d, db_buf_declen = %d", db_buf_enclen, db_buf_declen);
+       DRM_TAPPS_FRQ_LOG("db_buf_enclen = %d, db_buf_declen = %d", db_buf_enclen,
+                                         db_buf_declen);
 
-       (void)DTappsB64Decode((unsigned char*)row.constraint_buffer, db_buf_enclen, const_buffer_dec, db_buf_declen);
-       if (db_buf_declen > (db_buf_enclen / 4 * 3))
-       {
-               DRM_TAPPS_EXCEPTION("BASE64 Decode error! const_buffer_dec=%s, db_buf_declen=%d, (db_buf_enclen/4*3)=%d", const_buffer_dec, db_buf_declen, (db_buf_enclen / 4 * 3));
+       (void)DTappsB64Decode((unsigned char *)row.constraint_buffer, db_buf_enclen,
+                                                 const_buffer_dec, db_buf_declen);
+
+       if (db_buf_declen > (db_buf_enclen / 4 * 3)) {
+               DRM_TAPPS_EXCEPTION("BASE64 Decode error! const_buffer_dec=%s, "
+                                                       "db_buf_declen=%d, (db_buf_enclen/4*3)=%d",
+                                                       const_buffer_dec, db_buf_declen, (db_buf_enclen / 4 * 3));
                check_valid = TADC_LICENSE_UNKNOWN_ERROR;
                goto DTAPPS_ERROR;
        }
@@ -805,31 +842,40 @@ BOOL DTappsGetCEK(const char* szCid, T_RO* t_RO)
 
        hash_buf_enclen = TAPPS_STRLEN(row.constraint_hash);
        hash_buf_declen = hash_buf_enclen / 4 * 3;
-       if (hash_buf_enclen <= 0)
-       {
+
+       if (hash_buf_enclen <= 0) {
                DRM_TAPPS_EXCEPTION("There is no hash buffer in the DB. cid = %s", szCid);
                check_valid = TADC_LICENSE_UNKNOWN_ERROR;
                goto DTAPPS_ERROR;
        }
-       DRM_TAPPS_FRQ_LOG("hash_buf_enclen = %d, hash_buf_declen = %d", hash_buf_enclen, hash_buf_declen);
 
-       (void)DTappsB64Decode((unsigned char*)row.constraint_hash, hash_buf_enclen, hash_buffer, hash_buf_declen);
-       if (hash_buf_declen > (hash_buf_enclen / 4 * 3))
-       {
-               DRM_TAPPS_EXCEPTION("BASE64 Decode error! hash_buffer_dec=%s, hash_buf_declen=%d, (hash_buf_enclen/4*3)=%d", hash_buffer, hash_buf_declen, (hash_buf_enclen / 4 * 3));
+       DRM_TAPPS_FRQ_LOG("hash_buf_enclen = %d, hash_buf_declen = %d", hash_buf_enclen,
+                                         hash_buf_declen);
+
+       (void)DTappsB64Decode((unsigned char *)row.constraint_hash, hash_buf_enclen,
+                                                 hash_buffer, hash_buf_declen);
+
+       if (hash_buf_declen > (hash_buf_enclen / 4 * 3)) {
+               DRM_TAPPS_EXCEPTION("BASE64 Decode error! hash_buffer_dec=%s, "
+                                                       "hash_buf_declen=%d, (hash_buf_enclen/4*3)=%d",
+                                                       hash_buffer, hash_buf_declen, (hash_buf_enclen / 4 * 3));
                check_valid = TADC_LICENSE_UNKNOWN_ERROR;
                goto DTAPPS_ERROR;
        }
 
-       /* Calculate the hash using HMAC from the BASE64Decoded Constraint Buffers and check with the BASE64Decoded Hash buffers */
-       DTappsCalHMACSHA1(pDevKey, (int)DevKeyLen, const_buffer_dec, db_buf_declen, md, &md_len);
-       if (DTAPPS_MEMCMP(md, hash_buffer, hash_buf_declen) == 0)
-       {
-               DRM_TAPPS_LOG("HASH for constraint buffer matching! md=%s, hash_buffer_dec=%s, hash_buf_declen=%d", md, hash_buffer, hash_buf_declen);
-       }
-       else
-       {
-               DRM_TAPPS_EXCEPTION("HASH for constraint buffer not matching! md=%s, hash_buffer_dec=%s, hash_buf_declen=%d", md, hash_buffer, hash_buf_declen);
+       // Calculate the hash using HMAC from the BASE64Decoded Constraint Buffers
+       // and check with the BASE64Decoded Hash buffers
+       DTappsCalHMACSHA1(pDevKey, (int)DevKeyLen, const_buffer_dec, db_buf_declen, md,
+                                         &md_len);
+
+       if (DTAPPS_MEMCMP(md, hash_buffer, hash_buf_declen) == 0) {
+               DRM_TAPPS_LOG("HASH for constraint buffer matching! md=%s, "
+                                         "hash_buffer_dec=%s, hash_buf_declen=%d",
+                                         md, hash_buffer, hash_buf_declen);
+       } else {
+               DRM_TAPPS_EXCEPTION("HASH for constraint buffer not matching! md=%s, "
+                                                       "hash_buffer_dec=%s, hash_buf_declen=%d",
+                                                       md, hash_buffer, hash_buf_declen);
                check_valid = TADC_LICENSE_UNKNOWN_ERROR;
                goto DTAPPS_ERROR;
        }
@@ -838,40 +884,47 @@ BOOL DTappsGetCEK(const char* szCid, T_RO* t_RO)
        DTAPPS_MEMCPY(&st_constaints, const_buffer_dec, sizeof(DTAPPS_CONSTRAINTS));
 
        check_valid = DTappsValidateConstraints(&st_constaints, DTAPPS_VERIFY);
-       if (check_valid != TADC_LICENSE_VALID)
-       {
-               DRM_TAPPS_LOG("Invalid Constraints for constraints_buffer=%s, check_valid=%d", const_buffer_dec, check_valid);
-               /* TODO: Implementation of Auto Deletion feature to delete the rights from the DB if the rights are expired!!!*/
+
+       if (check_valid != TADC_LICENSE_VALID) {
+               DRM_TAPPS_LOG("Invalid Constraints for constraints_buffer=%s, check_valid=%d",
+                                         const_buffer_dec, check_valid);
+               // TODO: Implementation of Auto Deletion feature to delete the rights
+               //       from the DB if the rights are expired!!!
                goto DTAPPS_ERROR;
-       }
-       else
-       {
+       } else {
                DRM_TAPPS_LOG("Rights are Valid! check_valid = %d", check_valid);
 
-               /* Constraints valid - Extract CEK and fill the t_RO structure with CEK, DUID */
-               /* BASE64 Decode the CEK buffer extracted from the DB */
+               // Constraints valid - Extract CEK and fill the t_RO structure with CEK, DUID
+               // BASE64 Decode the CEK buffer extracted from the DB
                db_buf_enclen = TAPPS_STRLEN(row.cek);
                db_buf_declen = db_buf_enclen / 4 * 3;
-               if (db_buf_enclen <= 0)
-               {
+
+               if (db_buf_enclen <= 0) {
                        DRM_TAPPS_EXCEPTION("There is no CEK in the DB. cid = %s", szCid);
                        check_valid = TADC_LICENSE_UNKNOWN_ERROR;
                        goto DTAPPS_ERROR;
                }
-               DRM_TAPPS_FRQ_LOG("db_buf_enclen = %d, db_buf_declen = %d", db_buf_enclen, db_buf_declen);
+
+               DRM_TAPPS_FRQ_LOG("db_buf_enclen = %d, db_buf_declen = %d", db_buf_enclen,
+                                                 db_buf_declen);
 
                int cek_declen = 0;
 
-               (void)DTappsB64Decode((unsigned char*)row.cek, db_buf_enclen, encr_cek, cek_declen);
+               (void)DTappsB64Decode((unsigned char *)row.cek, db_buf_enclen, encr_cek,
+                                                         cek_declen);
                db_buf_declen = cek_declen;
 
-               if (cek_declen > (db_buf_enclen / 4 * 3))
-               {
-                       DRM_TAPPS_EXCEPTION("BASE64 Decode error! encr_cek=%s, cek_declen=%d, (db_buf_enclen/4*3)=%d", encr_cek, cek_declen, (db_buf_enclen / 4 * 3));
+               if (cek_declen > (db_buf_enclen / 4 * 3)) {
+                       DRM_TAPPS_EXCEPTION("BASE64 Decode error! encr_cek=%s, cek_declen=%d, "
+                                                               "(db_buf_enclen/4*3)=%d",
+                                                               encr_cek, cek_declen, (db_buf_enclen / 4 * 3));
                        check_valid = TADC_LICENSE_UNKNOWN_ERROR;
                        goto DTAPPS_ERROR;
                }
-               DRM_TAPPS_LOG("BASE64 encr_cek=%s, cek_declen=%d, db_buf_declen=%d, (db_buf_enclen/4*3)=%d", encr_cek, cek_declen, db_buf_declen, (db_buf_enclen / 4 * 3));
+
+               DRM_TAPPS_LOG("BASE64 encr_cek=%s, cek_declen=%d, db_buf_declen=%d, "
+                                         "(db_buf_enclen/4*3)=%d",
+                                         encr_cek, cek_declen, db_buf_declen, (db_buf_enclen / 4 * 3));
 
                /* BASE64 Decode the hash buffer extracted from the DB */
                DTAPPS_MEMSET(hash_buffer, 0x00, sizeof(hash_buffer));
@@ -879,96 +932,112 @@ BOOL DTappsGetCEK(const char* szCid, T_RO* t_RO)
 
                hash_buf_enclen = TAPPS_STRLEN(row.cek_hash);
                hash_buf_declen = hash_buf_enclen / 4 * 3;
-               if (hash_buf_enclen <= 0)
-               {
-                       DRM_TAPPS_EXCEPTION("There is no CEK_hash buffer in the DB. cid = %s", szCid);
+
+               if (hash_buf_enclen <= 0) {
+                       DRM_TAPPS_EXCEPTION("There is no CEK_hash buffer in the DB. cid = %s",
+                                                               szCid);
                        check_valid = TADC_LICENSE_UNKNOWN_ERROR;
                        goto DTAPPS_ERROR;
                }
-               DRM_TAPPS_FRQ_LOG("hash_buf_enclen = %d, hash_buf_declen = %d", hash_buf_enclen, hash_buf_declen);
 
-               (void)DTappsB64Decode((unsigned char*)row.cek_hash, hash_buf_enclen, hash_buffer, hash_buf_declen);
-               if (hash_buf_declen > (hash_buf_enclen / 4 * 3))
-               {
-                       DRM_TAPPS_EXCEPTION("BASE64 Decode error! hash_buffer_dec=%s, hash_buf_declen=%d, (hash_buf_enclen/4*3)=%d", hash_buffer, hash_buf_declen, (hash_buf_enclen/4*3));
+               DRM_TAPPS_FRQ_LOG("hash_buf_enclen = %d, hash_buf_declen = %d", hash_buf_enclen,
+                                                 hash_buf_declen);
+
+               (void)DTappsB64Decode((unsigned char *)row.cek_hash, hash_buf_enclen,
+                                                         hash_buffer, hash_buf_declen);
+
+               if (hash_buf_declen > (hash_buf_enclen / 4 * 3)) {
+                       DRM_TAPPS_EXCEPTION("BASE64 Decode error! hash_buffer_dec=%s, "
+                                                               "hash_buf_declen=%d, (hash_buf_enclen/4*3)=%d",
+                                                               hash_buffer, hash_buf_declen,
+                                                               (hash_buf_enclen / 4 * 3));
                        check_valid = TADC_LICENSE_UNKNOWN_ERROR;
                        goto DTAPPS_ERROR;
                }
 
-               /* Calculate the hash using HMAC from the BASE64Decoded Encrypted CEK Buffer and check with the BASE64Decoded Hash buffer */
-               DTappsCalHMACSHA1(pDevKey, (int)DevKeyLen, encr_cek, db_buf_declen, md, &md_len);
-               if (DTAPPS_MEMCMP(md, hash_buffer, hash_buf_declen) == 0)
-               {
-                       DRM_TAPPS_LOG("HASH for Encrypted CEK buffer matching! md=%s, hash_buffer_dec=%s, hash_buf_declen=%d", md, hash_buffer, hash_buf_declen);
-               }
-               else
-               {
-                       DRM_TAPPS_EXCEPTION("HASH for Encrypted CEK buffer not matching! md=%s, hash_buffer_dec=%s, hash_buf_declen=%d", md, hash_buffer, hash_buf_declen);
+               // Calculate the hash using HMAC from the BASE64Decoded Encrypted CEK Buffer
+               // and check with the BASE64Decoded Hash buffer
+               DTappsCalHMACSHA1(pDevKey, (int)DevKeyLen, encr_cek, db_buf_declen, md,
+                                                 &md_len);
+
+               if (DTAPPS_MEMCMP(md, hash_buffer, hash_buf_declen) == 0) {
+                       DRM_TAPPS_LOG("HASH for Encrypted CEK buffer matching! md=%s, "
+                                                 "hash_buffer_dec=%s, hash_buf_declen=%d",
+                                                 md, hash_buffer, hash_buf_declen);
+               } else {
+                       DRM_TAPPS_EXCEPTION("HASH for Encrypted CEK buffer not matching! "
+                                                               "md=%s, hash_buffer_dec=%s, hash_buf_declen=%d",
+                                                               md, hash_buffer, hash_buf_declen);
                        check_valid = TADC_LICENSE_UNKNOWN_ERROR;
                        goto DTAPPS_ERROR;
                }
 
                /* Allocate memory for CEK */
-               t_RO->t_Content.CEK = (unsigned char*)DTAPPS_MALLOC(CEK_SIZE + 1);
-               if (NULL == t_RO->t_Content.CEK)
-               {
-                       DRM_TAPPS_EXCEPTION("Memory Allocation Error!! t_RO->t_Content.CEK = %p", t_RO->t_Content.CEK);
+               t_RO->t_Content.CEK = (unsigned char *)DTAPPS_MALLOC(CEK_SIZE + 1);
+
+               if (NULL == t_RO->t_Content.CEK) {
+                       DRM_TAPPS_EXCEPTION("Memory Allocation Error!! t_RO->t_Content.CEK = %p",
+                                                               t_RO->t_Content.CEK);
                        check_valid = TADC_LICENSE_UNKNOWN_ERROR;
                        goto DTAPPS_ERROR;
                }
 
                DTAPPS_MEMSET(t_RO->t_Content.CEK, 0x00, CEK_SIZE + 1);
+
                /* Decrypt CEK and update t_RO structure */
-               if (DTAPPS_AES_SET_DECR_KEY(pDevKey, 128, &key))
-               {
+               if (DTAPPS_AES_SET_DECR_KEY(pDevKey, 128, &key)) {
                        DRM_TAPPS_EXCEPTION("AES_set_decrypt_key failed!!");
                        check_valid = TADC_LICENSE_UNKNOWN_ERROR;
                        goto DTAPPS_ERROR;
                }
 
-               (void)DTAPPS_AES_UNWRAP_KEY(&key, NULL, t_RO->t_Content.CEK, encr_cek, cek_declen);
+               (void)DTAPPS_AES_UNWRAP_KEY(&key, NULL, t_RO->t_Content.CEK, encr_cek,
+                                                                       cek_declen);
                DRM_TAPPS_LOG("DTAPPS_AES_UNWRAP_KEY success!!");
 
                /* Store DUID in t_RO */
-               if (st_constaints.DUID[0] != '\0')
-               {
-                       t_RO -> t_Permission.t_Individual.DUID = (unsigned char*)DTAPPS_MALLOC(DUID_SIZE + 1);
-                       if (NULL == t_RO -> t_Permission.t_Individual.DUID)
-                       {
-                               DRM_TAPPS_EXCEPTION("Memory Allocation Error!! t_RO->t_Permission.t_Individual.DUID = %p", t_RO -> t_Permission.t_Individual.DUID);
+               if (st_constaints.DUID[0] != '\0') {
+                       t_RO -> t_Permission.t_Individual.DUID = (unsigned char *)DTAPPS_MALLOC(
+                                               DUID_SIZE + 1);
+
+                       if (NULL == t_RO -> t_Permission.t_Individual.DUID) {
+                               DRM_TAPPS_EXCEPTION("Memory Allocation Error!! "
+                                                                       "t_RO->t_Permission.t_Individual.DUID = %p",
+                                                                       t_RO -> t_Permission.t_Individual.DUID);
                                check_valid = TADC_LICENSE_UNKNOWN_ERROR;
                                goto DTAPPS_ERROR;
                        }
+
                        DTAPPS_MEMSET(t_RO -> t_Permission.t_Individual.DUID, 0x00, DUID_SIZE + 1);
                        t_RO->PerFlag |= DUID_RULE;
                        t_RO->t_Permission.t_Individual.BindingType |= DUID_RULE;
-                       DTAPPS_MEMCPY(t_RO -> t_Permission.t_Individual.DUID, st_constaints.DUID, DUID_SIZE);
+                       DTAPPS_MEMCPY(t_RO -> t_Permission.t_Individual.DUID, st_constaints.DUID,
+                                                 DUID_SIZE);
                }
        }
 
 DTAPPS_ERROR:
-       if (pDevKey)
-       {
+
+       if (pDevKey) {
                DTappsFreeDeviceKey(&pDevKey);
        }
 
-       if (check_valid != TADC_LICENSE_VALID)
-       {
+       if (check_valid != TADC_LICENSE_VALID) {
                DRM_TAPPS_EXCEPTION("DTappsGetCEK FAILED!!!, check_valid = %d", check_valid);
                return FALSE;
-       }
-       else
-       {
+       } else {
                /* All fine... Allocate memory for CID and fill the value */
-               if ((t_RO != NULL) && (szCid != NULL))
-               {
-                       t_RO -> t_Content.CID = (unsigned char*) DTAPPS_MALLOC(CID_SIZE + 1);
-                       if (NULL == t_RO -> t_Content.CID)
-                       {
-                               DRM_TAPPS_EXCEPTION("Memory Allocation Error!! t_RO->t_Content.CID = %p", t_RO -> t_Content.CID);
+               if ((t_RO != NULL) && (szCid != NULL)) {
+                       t_RO -> t_Content.CID = (unsigned char *) DTAPPS_MALLOC(CID_SIZE + 1);
+
+                       if (NULL == t_RO -> t_Content.CID) {
+                               DRM_TAPPS_EXCEPTION("Memory Allocation Error!! "
+                                                                       "t_RO->t_Content.CID = %p",
+                                                                       t_RO -> t_Content.CID);
                                check_valid = TADC_LICENSE_UNKNOWN_ERROR;
                                goto DTAPPS_ERROR;
                        }
+
                        DTAPPS_MEMSET(t_RO -> t_Content.CID, 0x00, CID_SIZE + 1);
                        DTAPPS_MEMCPY(t_RO -> t_Content.CID, szCid, CID_SIZE);
                        DRM_TAPPS_LOG("DTappsGetCEK SUCCESS!!!, check_valid = %d", check_valid);
@@ -978,317 +1047,348 @@ DTAPPS_ERROR:
        }
 }
 
-BOOL DTapps_RIGHTS_INSTALL(const charname,
-                          const char* time,
-                          #ifdef DTAPPS_STORE_CEK_IN_DB
-                          const char* cek,
-                          const char* cek_hash,
-                          #endif
-                          const char* constraint_buffer,
-                          const char* constraint_hash,
-                          const char* cid,
-                          BOOL isUpdate)
+BOOL DTapps_RIGHTS_INSTALL(const char *name,
+                                                  const char *time,
+#ifdef DTAPPS_STORE_CEK_IN_DB
+                                                  const char *cek,
+                                                  const char *cek_hash,
+#endif
+                                                  const char *constraint_buffer,
+                                                  const char *constraint_hash,
+                                                  const char *cid,
+                                                  BOOL isUpdate)
 {
-    void*         pDb       = NULL;
-    const char*   query     = NULL;
-    sqlite3_stmt* pstmt     = NULL;
-    unsigned int  dIdx      = 0;
-    BOOL          ret_value = FALSE;
-
-    DRM_TAPPS_LOG("Open DB......");
-    ret_value = DTappsDBOpen(pDb,__func__);
-    if(ret_value != TRUE)
-    {
-        DRM_TAPPS_EXCEPTION("DB Open Failed!! ret_value = %d",ret_value);
-        return FALSE;
-    }
-
-    if(isUpdate == FALSE)
-    {
-        query = "INSERT INTO dtapps2rights (name, time_t, "
-                               #ifdef DTAPPS_STORE_CEK_IN_DB
-                               " cek, cek_hash, "
-                               #endif
-                               " constraint_buffer, constraint_hash, cid) "
-                               " VALUES (?, ?, "
-                               #ifdef DTAPPS_STORE_CEK_IN_DB
-                               " ?, ?, "
-                               #endif
-                               " ?, ?, ?);";
-    }
-    else
-    {
-        query = "UPDATE dtapps2rights SET name=?, time_t=?,"
-                               #ifdef DTAPPS_STORE_CEK_IN_DB
-                               " cek=?, cek_hash=?, "
-                               #endif
-                               " constraint_buffer=?, constraint_hash=? "
-                               " WHERE r_id=?;";
-    }
-
-    DRM_TAPPS_LOG("Prepare Statement........");
-    pstmt = (sqlite3_stmt*) DTappsStmtPrepare(pDb, query);
-    if(pstmt == NULL)
-    {
-        DRM_TAPPS_EXCEPTION("Prepare Statement failed. query=%s", query);
-        goto Error_Exit;
-    }
-
-    DRM_TAPPS_LOG("Binding Parameters........");
-    ret_value = DTappsStmtBindParam(pstmt, dIdx++, TAPPSDB_TYPE_VARCHAR, (void *)name, strlen(name));
-    if(ret_value != TRUE)
-    {
-        DRM_TAPPS_EXCEPTION("Binding Parameter(name=%s) failed. ret_value = %d", name, ret_value);
-        goto Error_Exit;
-    }
-
-    ret_value = DTappsStmtBindParam(pstmt, dIdx++, TAPPSDB_TYPE_VARCHAR, (void *)time, strlen(time));
-    if(ret_value != TRUE)
-    {
-        DRM_TAPPS_EXCEPTION("Binding Parameter(time=%s) failed. ret_value = %d", time, ret_value);
-        goto Error_Exit;
-    }
-
-    #ifdef DTAPPS_STORE_CEK_IN_DB
-    ret_value = DTappsStmtBindParam(pstmt, dIdx++, TAPPSDB_TYPE_VARCHAR, (void *)cek, strlen(cek));
-    if(ret_value != TRUE)
-    {
-        DRM_TAPPS_EXCEPTION("Binding Parameter(cek=%s) failed. ret_value = %d", cek, ret_value);
-        goto Error_Exit;
-    }
-
-    ret_value = DTappsStmtBindParam(pstmt, dIdx++, TAPPSDB_TYPE_VARCHAR, (void *)cek_hash, strlen(cek_hash));
-    if(ret_value != TRUE)
-    {
-        DRM_TAPPS_EXCEPTION("Binding Parameter(cek_hash=%s) failed. ret_value = %d", cek_hash, ret_value);
-        goto Error_Exit;
-    }
-    #endif
-
-    ret_value = DTappsStmtBindParam(pstmt, dIdx++, TAPPSDB_TYPE_VARCHAR, (void *)constraint_buffer, strlen(constraint_buffer));
-    if(ret_value != TRUE)
-    {
-        DRM_TAPPS_EXCEPTION("Binding Parameter(constraint_buffer=%s) failed. ret_value = %d", constraint_buffer, ret_value);
-        goto Error_Exit;
-    }
-
-    ret_value = DTappsStmtBindParam(pstmt, dIdx++, TAPPSDB_TYPE_VARCHAR, (void *)constraint_hash, strlen(constraint_hash));
-    if(ret_value != TRUE)
-    {
-        DRM_TAPPS_EXCEPTION("Binding Parameter(constraint_hash=%s) failed. ret_value = %d", constraint_hash, ret_value);
-        goto Error_Exit;
-    }
-
-    ret_value = DTappsStmtBindParam(pstmt, dIdx++, TAPPSDB_TYPE_VARCHAR, (void *)cid, strlen(cid));
-    if(ret_value != TRUE)
-    {
-        DRM_TAPPS_EXCEPTION("Binding Parameter(cid=%s) failed. ret_value = %d", cid, ret_value);
-        goto Error_Exit;
-    }
-
-    DRM_TAPPS_LOG("Begin Transaction........");
-    ret_value = DTappsDBBeginImmedTrans(__func__);
-    if(ret_value != TRUE)
-    {
-        DRM_TAPPS_EXCEPTION("DB Begin Transaction ret_value = %d",ret_value);
-        goto Error_Exit;
-    }
-
-    DRM_TAPPS_LOG("Execute SQL to Insert Contents into Table........");
-    ret_value = DTappsStmtExecute(pstmt);
-    if(ret_value != TRUE)
-    {
-        DRM_TAPPS_EXCEPTION("Execute SQL Query Failed!! ret_value = %d",ret_value);
-        goto Error_Exit;
-    }
-
-    DRM_TAPPS_LOG("Commit DB........");
-    ret_value = DTappsDBCommit(__func__);
-    if(ret_value != TRUE)
-    {
-        DRM_TAPPS_EXCEPTION("Commit DB Failed!! ret_value = %d",ret_value);
-        goto Error_Exit;
-    }
-
-    DRM_TAPPS_LOG("Release Statement........");
-    ret_value = DTappsStmtRelease(pstmt);
-    if(ret_value != TRUE)
-    {
-        DRM_TAPPS_EXCEPTION("Release Statement Failed!! ret_value = %d",ret_value);
-        pstmt = NULL;
-        goto Error_Exit;
-    }
-
-    DRM_TAPPS_LOG("Close DB........");
-    ret_value = DTappsDBClose(__func__);
-    if(ret_value != TRUE)
-    {
-        DRM_TAPPS_EXCEPTION("Close DB Failed!! ret_value = %d",ret_value);
-        goto Error_Exit;
-    }
-
-    DRM_TAPPS_LOG("Install DB Operartion Successful!!!");
-    return TRUE;
+       void *pDb = NULL;
+       const char *query = NULL;
+       sqlite3_stmt *pstmt = NULL;
+       unsigned int dIdx = 0;
+       BOOL ret_value = FALSE;
+
+       DRM_TAPPS_LOG("Open DB......");
+       ret_value = DTappsDBOpen(pDb, __func__);
+
+       if (ret_value != TRUE) {
+               DRM_TAPPS_EXCEPTION("DB Open Failed!! ret_value = %d", ret_value);
+               return FALSE;
+       }
+
+       if (isUpdate == FALSE) {
+               query = "INSERT INTO dtapps2rights (name, time_t, "
+#ifdef DTAPPS_STORE_CEK_IN_DB
+                               " cek, cek_hash, "
+#endif
+                               " constraint_buffer, constraint_hash, cid) "
+                               " VALUES (?, ?, "
+#ifdef DTAPPS_STORE_CEK_IN_DB
+                               " ?, ?, "
+#endif
+                               " ?, ?, ?);";
+       } else {
+               query = "UPDATE dtapps2rights SET name=?, time_t=?,"
+#ifdef DTAPPS_STORE_CEK_IN_DB
+                               " cek=?, cek_hash=?, "
+#endif
+                               " constraint_buffer=?, constraint_hash=? "
+                               " WHERE r_id=?;";
+       }
+
+       DRM_TAPPS_LOG("Prepare Statement........");
+       pstmt = (sqlite3_stmt *) DTappsStmtPrepare(pDb, query);
+
+       if (pstmt == NULL) {
+               DRM_TAPPS_EXCEPTION("Prepare Statement failed. query=%s", query);
+               goto Error_Exit;
+       }
+
+       DRM_TAPPS_LOG("Binding Parameters........");
+       ret_value = DTappsStmtBindParam(pstmt, dIdx++, TAPPSDB_TYPE_VARCHAR,
+                                                                       (void *)name, strlen(name));
+
+       if (ret_value != TRUE) {
+               DRM_TAPPS_EXCEPTION("Binding Parameter(name=%s) failed. ret_value = %d", name,
+                                                       ret_value);
+               goto Error_Exit;
+       }
+
+       ret_value = DTappsStmtBindParam(pstmt, dIdx++, TAPPSDB_TYPE_VARCHAR,
+                                                                       (void *)time, strlen(time));
+
+       if (ret_value != TRUE) {
+               DRM_TAPPS_EXCEPTION("Binding Parameter(time=%s) failed. ret_value = %d", time,
+                                                       ret_value);
+               goto Error_Exit;
+       }
+
+#ifdef DTAPPS_STORE_CEK_IN_DB
+       ret_value = DTappsStmtBindParam(pstmt, dIdx++, TAPPSDB_TYPE_VARCHAR,
+                                                                       (void *)cek, strlen(cek));
+
+       if (ret_value != TRUE) {
+               DRM_TAPPS_EXCEPTION("Binding Parameter(cek=%s) failed. ret_value = %d", cek,
+                                                       ret_value);
+               goto Error_Exit;
+       }
+
+       ret_value = DTappsStmtBindParam(pstmt, dIdx++, TAPPSDB_TYPE_VARCHAR,
+                                                                       (void *)cek_hash, strlen(cek_hash));
+
+       if (ret_value != TRUE) {
+               DRM_TAPPS_EXCEPTION("Binding Parameter(cek_hash=%s) failed. ret_value = %d",
+                                                       cek_hash, ret_value);
+               goto Error_Exit;
+       }
+
+#endif
+
+       ret_value = DTappsStmtBindParam(pstmt, dIdx++, TAPPSDB_TYPE_VARCHAR,
+                                                                       (void *)constraint_buffer, strlen(constraint_buffer));
+
+       if (ret_value != TRUE) {
+               DRM_TAPPS_EXCEPTION("Binding Parameter(constraint_buffer=%s) failed. "
+                                                       "ret_value = %d",
+                                                       constraint_buffer, ret_value);
+               goto Error_Exit;
+       }
+
+       ret_value = DTappsStmtBindParam(pstmt, dIdx++, TAPPSDB_TYPE_VARCHAR,
+                                                                       (void *)constraint_hash, strlen(constraint_hash));
+
+       if (ret_value != TRUE) {
+               DRM_TAPPS_EXCEPTION("Binding Parameter(constraint_hash=%s) failed. "
+                                                       "ret_value = %d",
+                                                       constraint_hash, ret_value);
+               goto Error_Exit;
+       }
+
+       ret_value = DTappsStmtBindParam(pstmt, dIdx++, TAPPSDB_TYPE_VARCHAR,
+                                                                       (void *)cid, strlen(cid));
+
+       if (ret_value != TRUE) {
+               DRM_TAPPS_EXCEPTION("Binding Parameter(cid=%s) failed. ret_value = %d", cid,
+                                                       ret_value);
+               goto Error_Exit;
+       }
+
+       DRM_TAPPS_LOG("Begin Transaction........");
+       ret_value = DTappsDBBeginImmedTrans(__func__);
+
+       if (ret_value != TRUE) {
+               DRM_TAPPS_EXCEPTION("DB Begin Transaction ret_value = %d", ret_value);
+               goto Error_Exit;
+       }
+
+       DRM_TAPPS_LOG("Execute SQL to Insert Contents into Table........");
+       ret_value = DTappsStmtExecute(pstmt);
+
+       if (ret_value != TRUE) {
+               DRM_TAPPS_EXCEPTION("Execute SQL Query Failed!! ret_value = %d", ret_value);
+               goto Error_Exit;
+       }
+
+       DRM_TAPPS_LOG("Commit DB........");
+       ret_value = DTappsDBCommit(__func__);
+
+       if (ret_value != TRUE) {
+               DRM_TAPPS_EXCEPTION("Commit DB Failed!! ret_value = %d", ret_value);
+               goto Error_Exit;
+       }
+
+       DRM_TAPPS_LOG("Release Statement........");
+       ret_value = DTappsStmtRelease(pstmt);
+
+       if (ret_value != TRUE) {
+               DRM_TAPPS_EXCEPTION("Release Statement Failed!! ret_value = %d", ret_value);
+               pstmt = NULL;
+               goto Error_Exit;
+       }
+
+       DRM_TAPPS_LOG("Close DB........");
+       ret_value = DTappsDBClose(__func__);
+
+       if (ret_value != TRUE) {
+               DRM_TAPPS_EXCEPTION("Close DB Failed!! ret_value = %d", ret_value);
+               goto Error_Exit;
+       }
+
+       DRM_TAPPS_LOG("Install DB Operartion Successful!!!");
+       return TRUE;
 
 Error_Exit:
-    if(pstmt != NULL)
-        DTappsStmtRelease(pstmt);
-
-    ret_value = DTappsDBRollback (__func__);
-    if(ret_value != TRUE)
-    {
-        DRM_TAPPS_EXCEPTION("Rollback DB Failed!! ret_value = %d",ret_value);
-    }
-
-    ret_value = DTappsDBClose(__func__);
-    if(ret_value != TRUE)
-    {
-        DRM_TAPPS_EXCEPTION("Close DB Failed!! ret_value = %d",ret_value);
-    }
-
-    return FALSE;
+
+       if (pstmt != NULL)
+               DTappsStmtRelease(pstmt);
+
+       ret_value = DTappsDBRollback(__func__);
+
+       if (ret_value != TRUE) {
+               DRM_TAPPS_EXCEPTION("Rollback DB Failed!! ret_value = %d", ret_value);
+       }
+
+       ret_value = DTappsDBClose(__func__);
+
+       if (ret_value != TRUE) {
+               DRM_TAPPS_EXCEPTION("Close DB Failed!! ret_value = %d", ret_value);
+       }
+
+       return FALSE;
 }
 
-BOOL DTapps_RIGHTS_SELECT_ONE(const char* cid, DTAPPS_RIGHTS_ROW* row)
+BOOL DTapps_RIGHTS_SELECT_ONE(const char *cid, DTAPPS_RIGHTS_ROW *row)
 {
-    void*         pDb       = NULL;
-    const char*   query     = NULL;
-    sqlite3_stmt* pstmt     = NULL;
-    unsigned int  dIdx      = 0;
-    BOOL          ret_value = FALSE;
-    int           db_ret    = -1;
-    DTAPPS_RIGHTS_ROW* result = row;
-
-    char *name, *time, *constraint_buffer, *constraint_hash;
-    #ifdef DTAPPS_STORE_CEK_IN_DB
-    char *cek, *cek_hash;
-    #endif
-
-    DRM_TAPPS_LOG("Open DB......");
-    ret_value = DTappsDBOpen(pDb,__func__);
-    if(ret_value != TRUE)
-    {
-        DRM_TAPPS_EXCEPTION("DB Open Failed!! ret_value = %d",ret_value);
-        return FALSE;
-    }
-
-    query = "SELECT r_id, name, time_t, "
-            #ifdef DTAPPS_STORE_CEK_IN_DB
-            " cek, cek_hash, "
-            #endif
-            " constraint_buffer, constraint_hash "
-            " FROM dtapps2rights"
-            " WHERE cid=? ORDER BY r_id desc limit 1;";
-
-
-    DRM_TAPPS_LOG("Begin Transaction........");
-    ret_value = DTappsDBBeginImmedTrans(__func__);
-    if(ret_value != TRUE)
-    {
-        DRM_TAPPS_EXCEPTION("DB Begin Transaction Failed!! ret_value = %d",ret_value);
-        goto Error_Exit;
-    }
-
-    DRM_TAPPS_LOG("Prepare Statement........");
-    db_ret = sqlite3_prepare((sqlite3*)pDb, query, -1, &pstmt, NULL);
-    if(pstmt == NULL)
-    {
-        DRM_TAPPS_EXCEPTION("Prepare Statement failed. query=%s, error=%s", query, sqlite3_errmsg((sqlite3*)pDb));
-        goto Error_Exit;
-    }
-
-    DRM_TAPPS_LOG("Binding Parameters........");
-    db_ret = sqlite3_bind_text(pstmt, ++dIdx, cid, strlen(cid), SQLITE_TRANSIENT);
-    if(db_ret != SQLITE_OK)
-    {
-        DRM_TAPPS_EXCEPTION("Binding Parameter(cid=%s) failed. ret_value = %d, query=%s", cid, db_ret, query);
-        goto Error_Exit;
-    }
-
-    DRM_TAPPS_LOG("Execute SQL to Select Contents from Table........");
-    db_ret = sqlite3_step(pstmt);
-    if(db_ret == SQLITE_OK || db_ret == SQLITE_DONE)
-    {
-        DRM_TAPPS_FRQ_LOG("Executed SQL Select Query. But no row was returned");
-        goto Error_Exit;
-    }
-    else if(db_ret != SQLITE_ROW)
-    {
-        DRM_TAPPS_EXCEPTION("Execute SQL Query Failed!! ret_value = %d, query=%s, error=%s",
-                            db_ret, query, sqlite3_errmsg((sqlite3*)pDb));
-        goto Error_Exit;
-    }
-
-    memset(result, 0, sizeof(DTAPPS_RIGHTS_ROW));
-
-    dIdx = 0;
-    result->r_id = sqlite3_column_int(pstmt, dIdx++);
-    DRM_TAPPS_LOG("....SEELECTED : r_id = %d", result->r_id);
-
-    name = (char*) sqlite3_column_text(pstmt, dIdx++);
-    if(name != NULL)
-        memcpy(result->name, name, strlen(name));
-    DRM_TAPPS_LOG("....SEELECTED : name = %s", result->name);
-
-    time= (char*) sqlite3_column_text(pstmt, dIdx++);
-    if(time != NULL)
-        memcpy(result->time, time, strlen(time));
-    DRM_TAPPS_LOG("....SEELECTED : time = %s", result->time);
-
-    #ifdef DTAPPS_STORE_CEK_IN_DB
-    cek= (char*) sqlite3_column_text(pstmt, dIdx++);
-    if(cek != NULL)
-        memcpy(result->cek, cek, strlen(cek));
-    DRM_TAPPS_LOG("....SEELECTED : cek = %s", result->cek);
-
-    cek_hash= (char*) sqlite3_column_text(pstmt, dIdx++);
-    if(cek_hash != NULL)
-        memcpy(result->cek_hash, cek_hash, strlen(cek_hash));
-    DRM_TAPPS_LOG("....SEELECTED : cek_hash = %s", result->cek_hash);
-    #endif
-
-    constraint_buffer = (char*) sqlite3_column_text(pstmt, dIdx++);
-    if(constraint_buffer != NULL)
-        memcpy(result->constraint_buffer, constraint_buffer, strlen(constraint_buffer));
-    DRM_TAPPS_LOG("....SEELECTED : constraint_buffer = %s", result->constraint_buffer);
-
-    constraint_hash = (char*) sqlite3_column_text(pstmt, dIdx++);
-    if(constraint_hash != NULL)
-        memcpy(result->constraint_hash, constraint_hash, strlen(constraint_hash));
-    DRM_TAPPS_LOG("....SEELECTED : constraint_hash = %s", result->constraint_hash);
-
-    memcpy(result->cid, cid, strlen(cid));
-    DRM_TAPPS_LOG("....SEELECTED : cid = %s", result->cid);
-
-    DRM_TAPPS_LOG("Release Statement........");
-    ret_value = DTappsStmtRelease(pstmt);
-    if(ret_value != TRUE)
-    {
-        DRM_TAPPS_EXCEPTION("Release Statement Failed!! ret_value = %d",ret_value);
-        pstmt = NULL;
-        goto Error_Exit;
-    }
-
-    DRM_TAPPS_LOG("Close DB........");
-    ret_value = DTappsDBClose(__func__);
-    if(ret_value != TRUE)
-    {
-        DRM_TAPPS_EXCEPTION("Close DB Failed!! ret_value = %d",ret_value);
-        goto Error_Exit;
-    }
-
-    DRM_TAPPS_LOG("Select a DB row Operartion Successful!!!");
-    return TRUE;
+       void *pDb = NULL;
+       const char *query = NULL;
+       sqlite3_stmt *pstmt = NULL;
+       unsigned int dIdx = 0;
+       BOOL ret_value = FALSE;
+       int db_ret = -1;
+       DTAPPS_RIGHTS_ROW *result = row;
+
+       char *name, *time, *constraint_buffer, *constraint_hash;
+#ifdef DTAPPS_STORE_CEK_IN_DB
+       char *cek, *cek_hash;
+#endif
+
+       DRM_TAPPS_LOG("Open DB......");
+       ret_value = DTappsDBOpen(pDb, __func__);
+
+       if (ret_value != TRUE) {
+               DRM_TAPPS_EXCEPTION("DB Open Failed!! ret_value = %d", ret_value);
+               return FALSE;
+       }
+
+       query = "SELECT r_id, name, time_t, "
+#ifdef DTAPPS_STORE_CEK_IN_DB
+                       " cek, cek_hash, "
+#endif
+                       " constraint_buffer, constraint_hash "
+                       " FROM dtapps2rights"
+                       " WHERE cid=? ORDER BY r_id desc limit 1;";
+
+
+       DRM_TAPPS_LOG("Begin Transaction........");
+       ret_value = DTappsDBBeginImmedTrans(__func__);
+
+       if (ret_value != TRUE) {
+               DRM_TAPPS_EXCEPTION("DB Begin Transaction Failed!! ret_value = %d", ret_value);
+               goto Error_Exit;
+       }
+
+       DRM_TAPPS_LOG("Prepare Statement........");
+       db_ret = sqlite3_prepare((sqlite3 *)pDb, query, -1, &pstmt, NULL);
+
+       if (pstmt == NULL) {
+               DRM_TAPPS_EXCEPTION("Prepare Statement failed. query=%s, error=%s", query,
+                                                       sqlite3_errmsg((sqlite3 *)pDb));
+               goto Error_Exit;
+       }
+
+       DRM_TAPPS_LOG("Binding Parameters........");
+       db_ret = sqlite3_bind_text(pstmt, ++dIdx, cid, strlen(cid), SQLITE_TRANSIENT);
+
+       if (db_ret != SQLITE_OK) {
+               DRM_TAPPS_EXCEPTION("Binding Parameter(cid=%s) failed. "
+                                                       "ret_value = %d, query=%s",
+                                                       cid, db_ret, query);
+               goto Error_Exit;
+       }
+
+       DRM_TAPPS_LOG("Execute SQL to Select Contents from Table........");
+       db_ret = sqlite3_step(pstmt);
+
+       if (db_ret == SQLITE_OK || db_ret == SQLITE_DONE) {
+               DRM_TAPPS_FRQ_LOG("Executed SQL Select Query. But no row was returned");
+               goto Error_Exit;
+       } else if (db_ret != SQLITE_ROW) {
+               DRM_TAPPS_EXCEPTION("Execute SQL Query Failed!! "
+                                                       "ret_value = %d, query=%s, error=%s",
+                                                       db_ret, query, sqlite3_errmsg((sqlite3 *)pDb));
+               goto Error_Exit;
+       }
+
+       memset(result, 0, sizeof(DTAPPS_RIGHTS_ROW));
+
+       dIdx = 0;
+       result->r_id = sqlite3_column_int(pstmt, dIdx++);
+       DRM_TAPPS_LOG("....SEELECTED : r_id = %d", result->r_id);
+
+       name = (char *) sqlite3_column_text(pstmt, dIdx++);
+
+       if (name != NULL)
+               memcpy(result->name, name, strlen(name));
+
+       DRM_TAPPS_LOG("....SEELECTED : name = %s", result->name);
+
+       time = (char *) sqlite3_column_text(pstmt, dIdx++);
+
+       if (time != NULL)
+               memcpy(result->time, time, strlen(time));
+
+       DRM_TAPPS_LOG("....SEELECTED : time = %s", result->time);
+
+#ifdef DTAPPS_STORE_CEK_IN_DB
+       cek = (char *) sqlite3_column_text(pstmt, dIdx++);
+
+       if (cek != NULL)
+               memcpy(result->cek, cek, strlen(cek));
+
+       DRM_TAPPS_LOG("....SEELECTED : cek = %s", result->cek);
+
+       cek_hash = (char *) sqlite3_column_text(pstmt, dIdx++);
+
+       if (cek_hash != NULL)
+               memcpy(result->cek_hash, cek_hash, strlen(cek_hash));
+
+       DRM_TAPPS_LOG("....SEELECTED : cek_hash = %s", result->cek_hash);
+#endif
+
+       constraint_buffer = (char *) sqlite3_column_text(pstmt, dIdx++);
+
+       if (constraint_buffer != NULL)
+               memcpy(result->constraint_buffer, constraint_buffer, strlen(constraint_buffer));
+
+       DRM_TAPPS_LOG("....SEELECTED : constraint_buffer = %s",
+                                 result->constraint_buffer);
+
+       constraint_hash = (char *) sqlite3_column_text(pstmt, dIdx++);
+
+       if (constraint_hash != NULL)
+               memcpy(result->constraint_hash, constraint_hash, strlen(constraint_hash));
+
+       DRM_TAPPS_LOG("....SEELECTED : constraint_hash = %s", result->constraint_hash);
+
+       memcpy(result->cid, cid, strlen(cid));
+       DRM_TAPPS_LOG("....SEELECTED : cid = %s", result->cid);
+
+       DRM_TAPPS_LOG("Release Statement........");
+       ret_value = DTappsStmtRelease(pstmt);
+
+       if (ret_value != TRUE) {
+               DRM_TAPPS_EXCEPTION("Release Statement Failed!! ret_value = %d", ret_value);
+               pstmt = NULL;
+               goto Error_Exit;
+       }
+
+       DRM_TAPPS_LOG("Close DB........");
+       ret_value = DTappsDBClose(__func__);
+
+       if (ret_value != TRUE) {
+               DRM_TAPPS_EXCEPTION("Close DB Failed!! ret_value = %d", ret_value);
+               goto Error_Exit;
+       }
+
+       DRM_TAPPS_LOG("Select a DB row Operartion Successful!!!");
+       return TRUE;
 
 Error_Exit:
-    if(pstmt)
-        DTappsStmtRelease(pstmt);
 
-    ret_value = DTappsDBClose(__func__);
-    if(ret_value != TRUE)
-    {
-        DRM_TAPPS_EXCEPTION("Close DB Failed!! ret_value = %d",ret_value);
-    }
+       if (pstmt)
+               DTappsStmtRelease(pstmt);
+
+       ret_value = DTappsDBClose(__func__);
+
+       if (ret_value != TRUE) {
+               DRM_TAPPS_EXCEPTION("Close DB Failed!! ret_value = %d", ret_value);
+       }
 
-    return FALSE;
+       return FALSE;
 }
index 205c9d7..79e0677 100644 (file)
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
- */
-
-/** 
- * @file       DTapps2Base64.cpp
- * @brief      This file includes functions relating to Base64 Encode Decode.
+ *
+ * @file    DTapps2Base64.cpp
+ * @brief   Base64 Encode Decode.
  */
 
 #include "DTapps2Base64.h"
 
-const unsigned char MAP[128] = 
-{
+const unsigned char MAP[128] = {
        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 62, 64, 64, 64, 63,
@@ -33,8 +30,7 @@ const unsigned char MAP[128] =
        41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 64, 64, 64, 64, 64,
 };
 
-const char CODE[64] = 
-{
+const char CODE[64] = {
        'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
        'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
        'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
@@ -42,84 +38,82 @@ const char CODE[64] =
        'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
        'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
        'w', 'x', 'y', 'z', '0', '1', '2', '3',
-       '4', '5', '6', '7', '8', '9', '+', '/' 
+       '4', '5', '6', '7', '8', '9', '+', '/'
 };
 
-BOOL DTappsB64Encode(unsigned char* in, int in_size, unsigned char* out, int out_size)
+BOOL DTappsB64Encode(unsigned char *in, int in_size, unsigned char *out,
+                                        int out_size)
 {
        int i, j;
        unsigned char a, b, c;
        int len = (in_size + 2) / 3 * 4;
-       if( out_size < len )
-          return FALSE;
-       
-       for( i = 0, j = 0; j < len; i += 3, j += 4 )
-       {
-          a = b = c = 0;
-          a = *(in+i);
-          *(out+j) = CODE[(a >> 2) & 0x3F];
-          if( in_size - i > 2 )
-          {
-                 b = *(in+i+1);
-                 c = *(in+i+2);
-                 *(out+j+1) = CODE[((a << 4) & 0x30) + ((b >> 4) & 0xf)];
-                 *(out+j+2) = CODE[((b << 2) & 0x3c) + ((c >> 6) & 0x3)];
-                 *(out+j+3) = CODE[c & 0x3F];
-          }
-          else if( in_size - i  > 1 )
-          {
-                 b = *(in+i+1);
-                 *(out+j+1) = CODE[((a << 4) & 0x30) + ((b >> 4) & 0xf)];
-                 *(out+j+2) = CODE[((b << 2) & 0x3c) + ((c >> 6) & 0x3)];
-                 *(out+j+3) = '=';
-          }
-          else
-          {
-                 *(out+j+1) = CODE[((a << 4) & 0x30) + ((b >> 4) & 0xf)];
-                 *(out+j+2) = '=';
-                 *(out+j+3) = '=';
-          }
+
+       if (out_size < len)
+               return FALSE;
+
+       for (i = 0, j = 0; j < len; i += 3, j += 4) {
+               a = b = c = 0;
+               a = *(in + i);
+               *(out + j) = CODE[(a >> 2) & 0x3F];
+
+               if (in_size - i > 2) {
+                       b = *(in + i + 1);
+                       c = *(in + i + 2);
+                       *(out + j + 1) = CODE[((a << 4) & 0x30) + ((b >> 4) & 0xf)];
+                       *(out + j + 2) = CODE[((b << 2) & 0x3c) + ((c >> 6) & 0x3)];
+                       *(out + j + 3) = CODE[c & 0x3F];
+               } else if (in_size - i  > 1) {
+                       b = *(in + i + 1);
+                       *(out + j + 1) = CODE[((a << 4) & 0x30) + ((b >> 4) & 0xf)];
+                       *(out + j + 2) = CODE[((b << 2) & 0x3c) + ((c >> 6) & 0x3)];
+                       *(out + j + 3) = '=';
+               } else {
+                       *(out + j + 1) = CODE[((a << 4) & 0x30) + ((b >> 4) & 0xf)];
+                       *(out + j + 2) = '=';
+                       *(out + j + 3) = '=';
+               }
        }
 
        return TRUE;
 }
 
 
-int DTappsB64Decode(unsigned char* in, int in_size, unsigned char* out, int& out_size)
+int DTappsB64Decode(unsigned char *in, int in_size, unsigned char *out,
+                                       int &out_size)
 {
        int i, j, k;
        unsigned char c[4];
        int read = 0;
-       for( i=j=k=0; i < in_size; i++ )
-       {
-          if( in[i] >= 128 )
-                 continue;
-          c[j] = MAP[(unsigned char)in[i]];
-          if( c[j] == 64 )
-                 continue;
-          j++;
-          switch( j )
-          {
-          case 2:
-                 out[k++] = (c[0]<<2) | ((c[1]>>4) & 0x3);
-                 break;
-          case 3:
-                 out[k++] = ((c[1]<<4) & 0xf0) | ((c[2]>>2) & 0xf);
-                 break;
-          case 4:
-                 out[k++] = ((c[2]<<6) & 0xc0) | c[3];
-                 read = i;
-                 j = 0;
-                 break;
-          }
+
+       for (i = j = k = 0; i < in_size; i++) {
+               if (in[i] >= 128)
+                       continue;
+
+               c[j] = MAP[(unsigned char)in[i]];
+
+               if (c[j] == 64)
+                       continue;
+
+               j++;
+
+               switch (j) {
+               case 2:
+                       out[k++] = (c[0] << 2) | ((c[1] >> 4) & 0x3);
+                       break;
+
+               case 3:
+                       out[k++] = ((c[1] << 4) & 0xf0) | ((c[2] >> 2) & 0xf);
+                       break;
+
+               case 4:
+                       out[k++] = ((c[2] << 6) & 0xc0) | c[3];
+                       read = i;
+                       j = 0;
+                       break;
+               }
        }
-        
+
        out_size = k;
 
-       return read+1;
+       return read + 1;
 }
index b454092..471b633 100644 (file)
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
- */
-/**
- * @file       DTapps2HMAC.cpp
- * @brief      This file includes functions relating to HMAC.
- * @author     Harsha Shekar (h.shekar@samsung.com)
+ *
+ * @file    DTapps2HMAC.cpp
+ * @brief   HMAC.
+ * @author  Harsha Shekar (h.shekar@samsung.com)
  */
 #include "DTapps2HMAC.h"
 
 
 #include <SecCryptoSvc.h>
 
-void DTappsCalHMACSHA1(unsigned char* key,int key_len,unsigned char* msg,size_t msglen,unsigned char *md,unsigned int *md_len)
+void DTappsCalHMACSHA1(unsigned char *key, int key_len, unsigned char *msg,
+                                          size_t msglen, unsigned char *md, unsigned int *md_len)
 {
-       HMAC(EVP_sha1(),(void*)key,key_len,msg,msglen,md,md_len);
+       HMAC(EVP_sha1(), (void *)key, key_len, msg, msglen, md, md_len);
 }
 
 int DTappsGetDeviceKey(unsigned char **pDevKey, unsigned int *pDevKeyLen)
@@ -38,9 +38,10 @@ int DTappsGetDeviceKey(unsigned char **pDevKey, unsigned int *pDevKeyLen)
        }
 
        constexpr int KeyLen = 16;
-       char passwd[30] = {0,};
+       char passwd[30] = { 0, };
        unsigned char *key = NULL;
        int ret = cs_derive_key_with_pass(passwd, strlen(passwd), KeyLen, &key);
+
        if (ret != CS_ERROR_NONE || key == NULL) {
                DRM_TAPPS_EXCEPTION("cs_derive_key_with_pass ret[%d]", ret);
                free(key);
index 74e8f9a..469cb9f 100644 (file)
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
- */
-
-/**
- * @file       DTapps2Time.cpp
- * @brief      This file includes functions relating to TIME APIs.
+ *
+ * @file    DTapps2Time.cpp
+ * @brief   TIME APIs.
  */
 
 #include "DTapps2Time.h"
 
-BOOL DTappsDtTmStr2Sec(unsigned char *time_str,time_t *TotalSec)
+BOOL DTappsDtTmStr2Sec(unsigned char *time_str, time_t *TotalSec)
 {
        char str[32] = {0};
        char short_str[5] = {0};
@@ -29,12 +27,12 @@ BOOL DTappsDtTmStr2Sec(unsigned char *time_str,time_t *TotalSec)
 
        memset(&time_fmt, 0x00, sizeof(time_fmt));
 
-       TAPPS_GSTRLCPY(str, (const char*)time_str, sizeof(str));
+       TAPPS_GSTRLCPY(str, (const char *)time_str, sizeof(str));
 
-       DRM_TAPPS_LOG("str = %s",str);
+       DRM_TAPPS_LOG("str = %s", str);
 
-       if(str[4] != '-' || str[7] != '-' || str[10] != 'T' || str[13] != ':' || str[16] != ':')
-       {
+       if (str[4] != '-' || str[7] != '-' || str[10] != 'T' || str[13] != ':' ||
+                       str[16] != ':') {
                DRM_TAPPS_EXCEPTION("Format is incorrect:str=%s", str);
 
                return FALSE;
@@ -44,7 +42,7 @@ BOOL DTappsDtTmStr2Sec(unsigned char *time_str,time_t *TotalSec)
        time_fmt.tm_year = DTAPPS_ATOI(short_str) - 1900;
        DRM_TAPPS_FRQ_LOG("tm_year = %d", time_fmt.tm_year);
 
-       DTAPPS_MEMSET(short_str, 0x0,5);
+       DTAPPS_MEMSET(short_str, 0x0, 5);
        DTAPPS_MEMCPY(short_str, str + 5, 2);
        time_fmt.tm_mon = DTAPPS_ATOI(short_str) - 1;
        DRM_TAPPS_FRQ_LOG("tm_mon = %d", time_fmt.tm_mon);
@@ -71,17 +69,17 @@ BOOL DTappsDtTmStr2Sec(unsigned char *time_str,time_t *TotalSec)
        return TRUE;
 }
 
-BOOL DTappsDtTmStr2StrucTm(unsigned char *time_str,struct tm *time_fmt)
+BOOL DTappsDtTmStr2StrucTm(unsigned char *time_str, struct tm *time_fmt)
 {
        char str[32] = {0};
        char short_str[5] = {0};
 
-       TAPPS_GSTRLCPY(str, (const char*)time_str, sizeof(str));
+       TAPPS_GSTRLCPY(str, (const char *)time_str, sizeof(str));
 
        DRM_TAPPS_LOG("str = %s", str);
 
-       if(str[4]!='-' || str[7]!='-' || str[10]!='T' || str[13]!=':' || str[16]!=':')
-       {
+       if (str[4] != '-' || str[7] != '-' || str[10] != 'T' || str[13] != ':' ||
+                       str[16] != ':') {
                DRM_TAPPS_EXCEPTION("Format is incorrect:str=%s", str);
 
                return FALSE;
@@ -115,7 +113,7 @@ BOOL DTappsDtTmStr2StrucTm(unsigned char *time_str,struct tm *time_fmt)
        return TRUE;
 }
 
-BOOL DTappsGetSecureTime(time_tseconds)
+BOOL DTappsGetSecureTime(time_t *seconds)
 {
        time_t now = 0, secure_sec = 0;
        int Delta = 0;
@@ -130,10 +128,11 @@ BOOL DTappsGetSecureTime(time_t* seconds)
        secure_sec = now + Delta;
 
        /* Operations to be done in GMT - Convert this to GM Time */
-    DTAPPS_GMTIME_THREAD_SAFE(&secure_sec, &gm_fmt);
+       DTAPPS_GMTIME_THREAD_SAFE(&secure_sec, &gm_fmt);
        *seconds = DTAPPS_MKTIME(&gm_fmt);
 
-       DRM_TAPPS_LOG("now = %d, secure_sec = %d, seconds(SecureTime in GMT) = %d", now, secure_sec, *seconds);
+       DRM_TAPPS_LOG("now = %d, secure_sec = %d, seconds(SecureTime in GMT) = %d", now,
+                                 secure_sec, *seconds);
 
        return TRUE;
 }
index 07c2194..4e38857 100644 (file)
@@ -37,12 +37,11 @@ bool _write_logfile(const char *filename, char *buf, unsigned int len)
 {
        FILE *fd = NULL;
 
-       if ((fd = fopen(filename,"w+b")) == NULL)
-       {
+       if ((fd = fopen(filename, "w+b")) == NULL) {
                return false;
        }
 
-       fwrite(buf, 1, len,fd);
+       fwrite(buf, 1, len, fd);
        fclose(fd);
 
        return true;
@@ -53,12 +52,11 @@ bool _read_logfile(const char *filename, char *buf, unsigned int *pLen)
        FILE *fd = NULL;
        int  nReadLen = 0;
 
-       if ((fd = fopen(filename,"r+b")) == NULL)
-       {
+       if ((fd = fopen(filename, "r+b")) == NULL) {
                return false;
        }
 
-       nReadLen = fread(buf, 1, *pLen,fd);
+       nReadLen = fread(buf, 1, *pLen, fd);
        *pLen = nReadLen;
 
        fclose(fd);
@@ -75,6 +73,7 @@ bool tc01_VerifyRoSignature_Positive_01(void)
        auto buf = _read_ro_file(pRo);
 
        int nRet = TADC_VerifyROSignature(buf.data());
+
        if (nRet != 0) {
                printf("VerifyROSignature Failed! : %s, %d\n", pRo, nRet);
                return false;
@@ -93,6 +92,7 @@ bool tc01_VerifyRoSignature_Positive_02(void)
        auto buf = _read_ro_file(pRo);
 
        int nRet = TADC_VerifyROSignature(buf.data());
+
        if (nRet != 0) {
                printf("VerifyROSignature Failed! : %s, %d\n", pRo, nRet);
                return false;
@@ -111,8 +111,8 @@ bool tc01_VerifyRoSignature_Positive_03(void)
        auto buf = _read_ro_file(pRo);
 
        int nRet = TADC_VerifyROSignature(buf.data());
-       if (nRet != 0)
-       {
+
+       if (nRet != 0) {
                printf("VerifyROSignature Failed! : %s, %d\n", pRo, nRet);
                return false;
        }
@@ -130,8 +130,10 @@ bool tc02_VerifyRoSignature_Negative_Cert_01(void)
        auto buf = _read_ro_file(pRo);
 
        int nRet = TADC_VerifyROSignature(buf.data());
+
        if (nRet >= 0) {
-               printf("VerifyROSignature have to be failed. But success! : %s, %d\n", pRo, nRet);
+               printf("VerifyROSignature have to be failed. But success! : %s, %d\n", pRo,
+                          nRet);
                return false;
        }
 
@@ -148,8 +150,10 @@ bool tc02_VerifyRoSignature_Negative_Cert_02(void)
        auto buf = _read_ro_file(pRo);
 
        int nRet = TADC_VerifyROSignature(buf.data());
+
        if (nRet >= 0) {
-               printf("VerifyROSignature have to be failed. But success! : %s, %d\n", pRo, nRet);
+               printf("VerifyROSignature have to be failed. But success! : %s, %d\n", pRo,
+                          nRet);
                return false;
        }
 
@@ -166,8 +170,10 @@ bool tc02_VerifyRoSignature_Negative_Cert_03(void)
        auto buf = _read_ro_file(pRo);
 
        int nRet = TADC_VerifyROSignature(buf.data());
+
        if (nRet >= 0) {
-               printf("VerifyROSignature have to be failed. But success! : %s, %d\n", pRo, nRet);
+               printf("VerifyROSignature have to be failed. But success! : %s, %d\n", pRo,
+                          nRet);
                return false;
        }
 
@@ -184,8 +190,10 @@ bool tc03_VerifyRoSignature_Negative_Signature_01(void)
        auto buf = _read_ro_file(pRo);
 
        int nRet = TADC_VerifyROSignature(buf.data());
+
        if (nRet >= 0) {
-               printf("VerifyROSignature have to be failed. But success! : %s, %d\n", pRo, nRet);
+               printf("VerifyROSignature have to be failed. But success! : %s, %d\n", pRo,
+                          nRet);
                return false;
        }
 
@@ -203,8 +211,10 @@ bool tc03_VerifyRoSignature_Negative_Signature_02(void)
        auto buf = _read_ro_file(pRo);
 
        int nRet = TADC_VerifyROSignature(buf.data());
+
        if (nRet >= 0) {
-               printf("VerifyROSignature have to be failed. But success! : %s, %d\n", pRo, nRet);
+               printf("VerifyROSignature have to be failed. But success! : %s, %d\n", pRo,
+                          nRet);
                return false;
        }
 
@@ -222,8 +232,10 @@ bool tc03_VerifyRoSignature_Negative_Signature_03(void)
        auto buf = _read_ro_file(pRo);
 
        int nRet = TADC_VerifyROSignature(buf.data());
+
        if (nRet >= 0) {
-               printf("VerifyROSignature have to be failed. But success! : %s, %d\n", pRo, nRet);
+               printf("VerifyROSignature have to be failed. But success! : %s, %d\n", pRo,
+                          nRet);
                return false;
        }
 
@@ -239,6 +251,7 @@ bool tc04_isDrmFile_Positive_01(void)
        printf("tc04_isDrmFile_Positive_01() -------- Started!\n");
 
        int nRet = drm_tizen_is_drm_file(pDCF, strlen(pDCF));
+
        if (nRet != TADC_SUCCESS) {
                printf("drm_tizen_is_drm_file failed. Path = %s, Ret = %d\n", pDCF,  nRet);
                printf("%s file is not TADC file!\n", pDCF);
@@ -257,6 +270,7 @@ bool tc04_isDrmFile_Positive_02(void)
        printf("tc04_isDrmFile_Positive_02() -------- Started!\n");
 
        int nRet = drm_tizen_is_drm_file(pDCF, strlen(pDCF));
+
        if (nRet != TADC_SUCCESS) {
                printf("drm_tizen_is_drm_file failed. Path = %s, Ret = %d\n", pDCF,  nRet);
                printf("%s file is not TADC file!\n", pDCF);
@@ -275,6 +289,7 @@ bool tc04_isDrmFile_Positive_03(void)
        printf("tc04_isDrmFile_Positive_03() -------- Started!\n");
 
        int nRet = drm_tizen_is_drm_file(pDCF, strlen(pDCF));
+
        if (nRet != TADC_SUCCESS) {
                printf("drm_tizen_is_drm_file failed. Path = %s, Ret = %d\n", pDCF,  nRet);
                printf("%s file is not TADC file!\n", pDCF);
@@ -293,8 +308,10 @@ bool tc05_isDrmFile_Negative_01(void)
        printf("tc05_isDrmFile_Negative_01() -------- Started! \n");
 
        int nRet = drm_tizen_is_drm_file(pApp, strlen(pApp));
-       if(nRet == TADC_SUCCESS) {
-               printf("drm_tizen_is_drm_file have to be failed. But Success!  Path = %s, Ret = %d\n", pApp,  nRet);
+
+       if (nRet == TADC_SUCCESS) {
+               printf("drm_tizen_is_drm_file have to be failed. But Success!  Path = %s, Ret = %d\n",
+                          pApp,  nRet);
                return false;
        }
 
@@ -310,8 +327,10 @@ bool tc05_isDrmFile_Negative_02(void)
        printf("tc05_isDrmFile_Negative_02() -------- Started! \n");
 
        int nRet = drm_tizen_is_drm_file(pApp, strlen(pApp));
-       if(nRet == TADC_SUCCESS) {
-               printf("drm_tizen_is_drm_file have to be failed. But Success!  Path = %s, Ret = %d\n", pApp,  nRet);
+
+       if (nRet == TADC_SUCCESS) {
+               printf("drm_tizen_is_drm_file have to be failed. But Success!  Path = %s, Ret = %d\n",
+                          pApp,  nRet);
                return false;
        }
 
@@ -327,8 +346,10 @@ bool tc05_isDrmFile_Negative_03(void)
        printf("tc05_isDrmFile_Negative_03() -------- Started! \n");
 
        int nRet = drm_tizen_is_drm_file(pApp, strlen(pApp));
-       if(nRet == TADC_SUCCESS) {
-               printf("drm_tizen_is_drm_file have to be failed. But Success!  Path = %s, Ret = %d\n", pApp,  nRet);
+
+       if (nRet == TADC_SUCCESS) {
+               printf("drm_tizen_is_drm_file have to be failed. But Success!  Path = %s, Ret = %d\n",
+                          pApp,  nRet);
                return false;
        }
 
@@ -341,8 +362,8 @@ bool
 tc06_DrmFileHandlerPositive_01(void)
 {
        const char *pDCF = TEST_DATA_DIR "/DCF/38EIfBurLJ.tpk";
-       DrmFileHandlerpDcfHandler = NULL;
-       unsigned charpBufCEK = NULL;
+       DrmFileHandler *pDcfHandler = NULL;
+       unsigned char *pBufCEK = NULL;
        unsigned char pCEK[CEK_SIZE + 1] = {0xB1, 0x03, 0x4F, 0x30, 0xC8, 0x52, 0x45, 0x7E, 0x9D, 0xA2, 0x52, 0x25, 0x2E, 0xA9, 0x9B, 0x2B, 0x25, 0x36, 0xF1, 0x8D, 0x04, 0xD1, 0x4C, 0xE3, 0x96, 0x81, 0xD9, 0x98, 0xBB, 0xD7, 0x7E, 0xCA, 0x00};
        unsigned char pCID[32] = "38EIfBurLJ-1.0.2";
 
@@ -354,71 +375,71 @@ tc06_DrmFileHandlerPositive_01(void)
 
        printf("tc06_DrmFileHandlerPositive_01() -------- Started! \n");
 
-       pBufCEK = (unsigned char*)malloc(CEK_SIZE + 1);
+       pBufCEK = (unsigned char *)malloc(CEK_SIZE + 1);
        memset(pBufCEK, 0x00, CEK_SIZE + 1);
 
        pDcfHandler = new DrmFileHandler();
-       if (pDcfHandler == NULL)
-       {
+
+       if (pDcfHandler == NULL) {
                goto CATCH;
        }
 
        nRet = pDcfHandler->Construct(pDCF);
-       if (nRet != 1)
-       {
-               printf("tc06_DrmFileHandlerPositive_01 - Construct() failed : %s, %x\n", pDCF, nRet);
+
+       if (nRet != 1) {
+               printf("tc06_DrmFileHandlerPositive_01 - Construct() failed : %s, %x\n", pDCF,
+                          nRet);
                goto CATCH;
        }
 
-       if (memcmp(pCEK, pDcfHandler->m_pCEK, CEK_SIZE) != 0)
-       {
+       if (memcmp(pCEK, pDcfHandler->m_pCEK, CEK_SIZE) != 0) {
                printf("tc06_DrmFileHandlerPositive_01 - CEK Comparison failed : %s\n", pDCF);
                goto CATCH;
        }
 
-       if (memcmp(pDCF, pDcfHandler->m_pFilePath, strlen((char*)pDcfHandler->m_pFilePath)) != 0)
-       {
-               printf("tc06_DrmFileHandlerPositive_01 - FilePath Comparison failed : %s\n", pDcfHandler->m_pFilePath);
+       if (memcmp(pDCF, pDcfHandler->m_pFilePath,
+                          strlen((char *)pDcfHandler->m_pFilePath)) != 0) {
+               printf("tc06_DrmFileHandlerPositive_01 - FilePath Comparison failed : %s\n",
+                          pDcfHandler->m_pFilePath);
                goto CATCH;
        }
 
-       if (memcmp(pCID, pDcfHandler->m_pCID, strlen((char*)pDcfHandler->m_pCID)) != 0)
-       {
-               printf("tc06_DrmFileHandlerPositive_01 - CID Comparison failed : %s\n", pDcfHandler->m_pCID);
+       if (memcmp(pCID, pDcfHandler->m_pCID,
+                          strlen((char *)pDcfHandler->m_pCID)) != 0) {
+               printf("tc06_DrmFileHandlerPositive_01 - CID Comparison failed : %s\n",
+                          pDcfHandler->m_pCID);
                goto CATCH;
        }
 
-       if (pDcfHandler->m_encryptionLevel != encryptionLevel)
-       {
-               printf("tc06_DrmFileHandlerPositive_01 - encryptionLevel Comparison failed : origin = %ld, result = %ld\n", encryptionLevel, pDcfHandler->m_encryptionLevel);
+       if (pDcfHandler->m_encryptionLevel != encryptionLevel) {
+               printf("tc06_DrmFileHandlerPositive_01 - encryptionLevel Comparison failed : origin = %ld, result = %ld\n",
+                          encryptionLevel, pDcfHandler->m_encryptionLevel);
                goto CATCH;
        }
 
-       if (pDcfHandler->m_encryptionRange != encryptionRange)
-       {
-               printf("tc06_DrmFileHandlerPositive_01 - encryptionRange Comparison failed : origin = %lld, result = %lld\n", encryptionRange, pDcfHandler->m_encryptionRange);
+       if (pDcfHandler->m_encryptionRange != encryptionRange) {
+               printf("tc06_DrmFileHandlerPositive_01 - encryptionRange Comparison failed : origin = %lld, result = %lld\n",
+                          encryptionRange, pDcfHandler->m_encryptionRange);
                goto CATCH;
        }
 
-       if (pDcfHandler->m_plaintextSize != plainTextSize)
-       {
-               printf("tc06_DrmFileHandlerPositive_01 - plainTextSize Comparison failed : origin = %lld, result = %lld\n", plainTextSize, pDcfHandler->m_plaintextSize);
+       if (pDcfHandler->m_plaintextSize != plainTextSize) {
+               printf("tc06_DrmFileHandlerPositive_01 - plainTextSize Comparison failed : origin = %lld, result = %lld\n",
+                          plainTextSize, pDcfHandler->m_plaintextSize);
                goto CATCH;
        }
 
-       if (pDcfHandler->m_OriginEndOffset != originalEndOffset)
-       {
-               printf("tc06_DrmFileHandlerPositive_01 - originalEndOffset Comparison failed : origin = %lld, result = %lld\n", originalEndOffset, pDcfHandler->m_OriginEndOffset);
+       if (pDcfHandler->m_OriginEndOffset != originalEndOffset) {
+               printf("tc06_DrmFileHandlerPositive_01 - originalEndOffset Comparison failed : origin = %lld, result = %lld\n",
+                          originalEndOffset, pDcfHandler->m_OriginEndOffset);
                goto CATCH;
        }
 
-       if (pDcfHandler != NULL)
-       {
+       if (pDcfHandler != NULL) {
                delete pDcfHandler;
        }
 
-       if (pBufCEK != NULL)
-       {
+       if (pBufCEK != NULL) {
                free(pBufCEK);
        }
 
@@ -427,13 +448,12 @@ tc06_DrmFileHandlerPositive_01(void)
        return true;
 
 CATCH:
-       if (pDcfHandler != NULL)
-       {
+
+       if (pDcfHandler != NULL) {
                delete pDcfHandler;
        }
 
-       if (pBufCEK != NULL)
-       {
+       if (pBufCEK != NULL) {
                free(pBufCEK);
        }
 
@@ -444,8 +464,8 @@ bool
 tc06_DrmFileHandlerPositive_02(void)
 {
        const char *pDCF = TEST_DATA_DIR "/DCF/8SPXfqc6iL.tpk";
-       unsigned charpBufCEK = NULL;
-       DrmFileHandlerpDcfHandler = NULL;
+       unsigned char *pBufCEK = NULL;
+       DrmFileHandler *pDcfHandler = NULL;
        unsigned char pCEK[CEK_SIZE + 1] = {0xBB, 0x87, 0x5D, 0xA8, 0x2C, 0xC4, 0x47, 0x81, 0x90, 0xBA, 0xD9, 0xB0, 0x0C, 0xD2, 0x94, 0xE9, 0x19, 0x0F, 0x24, 0x62, 0x5B, 0x0B, 0x49, 0x7A, 0xAE, 0x8E, 0x1D, 0x88, 0x7F, 0xF9, 0x96, 0xDB, 0x00};
        unsigned char pCID[32] = "8SPXfqc6iL-1.0.0";
 
@@ -457,71 +477,71 @@ tc06_DrmFileHandlerPositive_02(void)
 
        printf("tc06_DrmFileHandlerPositive_02() -------- Started! \n");
 
-       pBufCEK = (unsigned char*)malloc(CEK_SIZE + 1);
+       pBufCEK = (unsigned char *)malloc(CEK_SIZE + 1);
        memset(pBufCEK, 0x00, CEK_SIZE + 1);
 
        pDcfHandler = new DrmFileHandler();
-       if (pDcfHandler == NULL)
-       {
+
+       if (pDcfHandler == NULL) {
                goto CATCH;
        }
 
        nRet = pDcfHandler->Construct(pDCF);
-       if (nRet != 1)
-       {
-               printf("tc06_DrmFileHandlerPositive_02 - Construct() failed : %s, %x\n", pDCF, nRet);
+
+       if (nRet != 1) {
+               printf("tc06_DrmFileHandlerPositive_02 - Construct() failed : %s, %x\n", pDCF,
+                          nRet);
                goto CATCH;
        }
 
-       if (memcmp(pCEK, pDcfHandler->m_pCEK, CEK_SIZE) != 0)
-       {
+       if (memcmp(pCEK, pDcfHandler->m_pCEK, CEK_SIZE) != 0) {
                printf("tc06_DrmFileHandlerPositive_02 - CEK Comparison failed : %s\n", pDCF);
                goto CATCH;
        }
 
-       if (memcmp(pDCF, pDcfHandler->m_pFilePath, strlen((char*)pDcfHandler->m_pFilePath)) != 0)
-       {
-               printf("tc06_DrmFileHandlerPositive_02 - FilePath Comparison failed : %s\n", pDcfHandler->m_pFilePath);
+       if (memcmp(pDCF, pDcfHandler->m_pFilePath,
+                          strlen((char *)pDcfHandler->m_pFilePath)) != 0) {
+               printf("tc06_DrmFileHandlerPositive_02 - FilePath Comparison failed : %s\n",
+                          pDcfHandler->m_pFilePath);
                goto CATCH;
        }
 
-       if (memcmp(pCID, pDcfHandler->m_pCID, strlen((char*)pDcfHandler->m_pCID)) != 0)
-       {
-               printf("tc06_DrmFileHandlerPositive_02 - CID Comparison failed : %s\n", pDcfHandler->m_pCID);
+       if (memcmp(pCID, pDcfHandler->m_pCID,
+                          strlen((char *)pDcfHandler->m_pCID)) != 0) {
+               printf("tc06_DrmFileHandlerPositive_02 - CID Comparison failed : %s\n",
+                          pDcfHandler->m_pCID);
                goto CATCH;
        }
 
-       if (pDcfHandler->m_encryptionLevel != encryptionLevel)
-       {
-               printf("tc06_DrmFileHandlerPositive_02 - encryptionLevel Comparison failed : origin = %ld, result = %ld\n", encryptionLevel, pDcfHandler->m_encryptionLevel);
+       if (pDcfHandler->m_encryptionLevel != encryptionLevel) {
+               printf("tc06_DrmFileHandlerPositive_02 - encryptionLevel Comparison failed : origin = %ld, result = %ld\n",
+                          encryptionLevel, pDcfHandler->m_encryptionLevel);
                goto CATCH;
        }
 
-       if (pDcfHandler->m_encryptionRange != encryptionRange)
-       {
-               printf("tc06_DrmFileHandlerPositive_02 - encryptionRange Comparison failed : origin = %lld, result = %lld\n", encryptionRange, pDcfHandler->m_encryptionRange);
+       if (pDcfHandler->m_encryptionRange != encryptionRange) {
+               printf("tc06_DrmFileHandlerPositive_02 - encryptionRange Comparison failed : origin = %lld, result = %lld\n",
+                          encryptionRange, pDcfHandler->m_encryptionRange);
                goto CATCH;
        }
 
-       if (pDcfHandler->m_plaintextSize != plainTextSize)
-       {
-               printf("tc06_DrmFileHandlerPositive_02 - plainTextSize Comparison failed : origin = %lld, result = %lld\n", plainTextSize, pDcfHandler->m_plaintextSize);
+       if (pDcfHandler->m_plaintextSize != plainTextSize) {
+               printf("tc06_DrmFileHandlerPositive_02 - plainTextSize Comparison failed : origin = %lld, result = %lld\n",
+                          plainTextSize, pDcfHandler->m_plaintextSize);
                goto CATCH;
        }
 
-       if (pDcfHandler->m_OriginEndOffset != originalEndOffset)
-       {
-               printf("tc06_DrmFileHandlerPositive_02 - originalEndOffset Comparison failed : origin = %lld, result = %lld\n", originalEndOffset, pDcfHandler->m_OriginEndOffset);
+       if (pDcfHandler->m_OriginEndOffset != originalEndOffset) {
+               printf("tc06_DrmFileHandlerPositive_02 - originalEndOffset Comparison failed : origin = %lld, result = %lld\n",
+                          originalEndOffset, pDcfHandler->m_OriginEndOffset);
                goto CATCH;
        }
 
-       if (pDcfHandler != NULL)
-       {
+       if (pDcfHandler != NULL) {
                delete pDcfHandler;
        }
 
-       if (pBufCEK != NULL)
-       {
+       if (pBufCEK != NULL) {
                free(pBufCEK);
        }
 
@@ -530,13 +550,12 @@ tc06_DrmFileHandlerPositive_02(void)
        return true;
 
 CATCH:
-       if (pDcfHandler != NULL)
-       {
+
+       if (pDcfHandler != NULL) {
                delete pDcfHandler;
        }
 
-       if (pBufCEK != NULL)
-       {
+       if (pBufCEK != NULL) {
                free(pBufCEK);
        }
 
@@ -547,8 +566,8 @@ bool
 tc06_DrmFileHandlerPositive_03(void)
 {
        const char *pDCF = TEST_DATA_DIR "/DCF/FightGuiIF.tpk";
-       unsigned charpBufCEK = NULL;
-       DrmFileHandlerpDcfHandler = NULL;
+       unsigned char *pBufCEK = NULL;
+       DrmFileHandler *pDcfHandler = NULL;
        unsigned char pCEK[CEK_SIZE + 1] = {0x34, 0x5A, 0x94, 0x28, 0xC3, 0xF4, 0x44, 0x3F, 0x86, 0x6D, 0xCF, 0xC5, 0x78, 0x1F, 0x23, 0xCE, 0xE9, 0x9B, 0xC4, 0x45, 0xA3, 0x30, 0x47, 0x1E, 0xB4, 0xE0, 0xAF, 0x96, 0x0F, 0xDE, 0xA9, 0xB4, 0x00};
        unsigned char pCID[32] = "FightGuiIF-1.0.0";
 
@@ -560,71 +579,71 @@ tc06_DrmFileHandlerPositive_03(void)
 
        printf("tc06_DrmFileHandlerPositive_03() -------- Started! \n");
 
-       pBufCEK = (unsigned char*)malloc(CEK_SIZE + 1);
+       pBufCEK = (unsigned char *)malloc(CEK_SIZE + 1);
        memset(pBufCEK, 0x00, CEK_SIZE + 1);
 
        pDcfHandler = new DrmFileHandler();
-       if (pDcfHandler == NULL)
-       {
+
+       if (pDcfHandler == NULL) {
                goto CATCH;
        }
 
        nRet = pDcfHandler->Construct(pDCF);
-       if (nRet != 1)
-       {
-               printf("tc06_DrmFileHandlerPositive_03 - Construct() failed : %s, %x\n", pDCF, nRet);
+
+       if (nRet != 1) {
+               printf("tc06_DrmFileHandlerPositive_03 - Construct() failed : %s, %x\n", pDCF,
+                          nRet);
                goto CATCH;
        }
 
-       if (memcmp(pCEK, pDcfHandler->m_pCEK, CEK_SIZE) != 0)
-       {
+       if (memcmp(pCEK, pDcfHandler->m_pCEK, CEK_SIZE) != 0) {
                printf("tc06_DrmFileHandlerPositive_03 - CEK Comparison failed : %s\n", pDCF);
                goto CATCH;
        }
 
-       if (memcmp(pDCF, pDcfHandler->m_pFilePath, strlen((char*)pDcfHandler->m_pFilePath)) != 0)
-       {
-               printf("tc06_DrmFileHandlerPositive_03 - FilePath Comparison failed : %s\n", pDcfHandler->m_pFilePath);
+       if (memcmp(pDCF, pDcfHandler->m_pFilePath,
+                          strlen((char *)pDcfHandler->m_pFilePath)) != 0) {
+               printf("tc06_DrmFileHandlerPositive_03 - FilePath Comparison failed : %s\n",
+                          pDcfHandler->m_pFilePath);
                goto CATCH;
        }
 
-       if (memcmp(pCID, pDcfHandler->m_pCID, strlen((char*)pDcfHandler->m_pCID)) != 0)
-       {
-               printf("tc06_DrmFileHandlerPositive_03 - CID Comparison failed : %s\n", pDcfHandler->m_pCID);
+       if (memcmp(pCID, pDcfHandler->m_pCID,
+                          strlen((char *)pDcfHandler->m_pCID)) != 0) {
+               printf("tc06_DrmFileHandlerPositive_03 - CID Comparison failed : %s\n",
+                          pDcfHandler->m_pCID);
                goto CATCH;
        }
 
-       if (pDcfHandler->m_encryptionLevel != encryptionLevel)
-       {
-               printf("tc06_DrmFileHandlerPositive_03 - encryptionLevel Comparison failed : origin = %ld, result = %ld\n", encryptionLevel, pDcfHandler->m_encryptionLevel);
+       if (pDcfHandler->m_encryptionLevel != encryptionLevel) {
+               printf("tc06_DrmFileHandlerPositive_03 - encryptionLevel Comparison failed : origin = %ld, result = %ld\n",
+                          encryptionLevel, pDcfHandler->m_encryptionLevel);
                goto CATCH;
        }
 
-       if (pDcfHandler->m_encryptionRange != encryptionRange)
-       {
-               printf("tc06_DrmFileHandlerPositive_03 - encryptionRange Comparison failed : origin = %lld, result = %lld\n", encryptionRange, pDcfHandler->m_encryptionRange);
+       if (pDcfHandler->m_encryptionRange != encryptionRange) {
+               printf("tc06_DrmFileHandlerPositive_03 - encryptionRange Comparison failed : origin = %lld, result = %lld\n",
+                          encryptionRange, pDcfHandler->m_encryptionRange);
                goto CATCH;
        }
 
-       if (pDcfHandler->m_plaintextSize != plainTextSize)
-       {
-               printf("tc06_DrmFileHandlerPositive_03 - plainTextSize Comparison failed : origin = %lld, result = %lld\n", plainTextSize, pDcfHandler->m_plaintextSize);
+       if (pDcfHandler->m_plaintextSize != plainTextSize) {
+               printf("tc06_DrmFileHandlerPositive_03 - plainTextSize Comparison failed : origin = %lld, result = %lld\n",
+                          plainTextSize, pDcfHandler->m_plaintextSize);
                goto CATCH;
        }
 
-       if (pDcfHandler->m_OriginEndOffset != originalEndOffset)
-       {
-               printf("tc06_DrmFileHandlerPositive_03 - originalEndOffset Comparison failed : origin = %lld, result = %lld\n", originalEndOffset, pDcfHandler->m_OriginEndOffset);
+       if (pDcfHandler->m_OriginEndOffset != originalEndOffset) {
+               printf("tc06_DrmFileHandlerPositive_03 - originalEndOffset Comparison failed : origin = %lld, result = %lld\n",
+                          originalEndOffset, pDcfHandler->m_OriginEndOffset);
                goto CATCH;
        }
 
-       if (pDcfHandler != NULL)
-       {
+       if (pDcfHandler != NULL) {
                delete pDcfHandler;
        }
 
-       if (pBufCEK != NULL)
-       {
+       if (pBufCEK != NULL) {
                free(pBufCEK);
        }
 
@@ -633,13 +652,12 @@ tc06_DrmFileHandlerPositive_03(void)
        return true;
 
 CATCH:
-       if (pDcfHandler != NULL)
-       {
+
+       if (pDcfHandler != NULL) {
                delete pDcfHandler;
        }
 
-       if (pBufCEK != NULL)
-       {
+       if (pBufCEK != NULL) {
                free(pBufCEK);
        }
 
@@ -651,7 +669,7 @@ bool tc07_DrmFileMgrPositive_01(void)
        const char *pDCF = TEST_DATA_DIR "/DCF/38EIfBurLJ.tpk";
        int nRet = TADC_SUCCESS;
 
-       DrmFileMgrpDrmFileMgr = NULL;
+       DrmFileMgr *pDrmFileMgr = NULL;
        DrmFileHandler *pDcfHandler = NULL;
 
        unsigned char pCEK[CEK_SIZE + 1] = {0xB1, 0x03, 0x4F, 0x30, 0xC8, 0x52, 0x45, 0x7E, 0x9D, 0xA2, 0x52, 0x25, 0x2E, 0xA9, 0x9B, 0x2B, 0x25, 0x36, 0xF1, 0x8D, 0x04, 0xD1, 0x4C, 0xE3, 0x96, 0x81, 0xD9, 0x98, 0xBB, 0xD7, 0x7E, 0xCA, 0x00};
@@ -667,58 +685,61 @@ bool tc07_DrmFileMgrPositive_01(void)
        pDrmFileMgr = DrmFileMgr::GetInstance();
 
        nRet = pDrmFileMgr->OpenFileHandler(pDCF, &first_key);
-       if (nRet != TADC_SUCCESS)
-       {
-               printf("tc07_DrmFileMgrPositive_01 - OpenFileHandler() failed : key = %d, file = %s, %x\n", first_key, pDCF, nRet);
+
+       if (nRet != TADC_SUCCESS) {
+               printf("tc07_DrmFileMgrPositive_01 - OpenFileHandler() failed : key = %d, file = %s, %x\n",
+                          first_key, pDCF, nRet);
                goto CATCH;
        }
 
        nRet = pDrmFileMgr->GetFileHandler(first_key, &pDcfHandler);
-       if (nRet != TADC_SUCCESS)
-       {
-               printf("tc07_DrmFileMgrPositive_01 - GetFileHandler() failed : key = %d, file = %s, %x\n", first_key, pDCF, nRet);
+
+       if (nRet != TADC_SUCCESS) {
+               printf("tc07_DrmFileMgrPositive_01 - GetFileHandler() failed : key = %d, file = %s, %x\n",
+                          first_key, pDCF, nRet);
                goto CATCH;
        }
 
-       if (memcmp(pCEK, pDcfHandler->m_pCEK, CEK_SIZE) != 0)
-       {
+       if (memcmp(pCEK, pDcfHandler->m_pCEK, CEK_SIZE) != 0) {
                printf("tc07_DrmFileMgrPositive_01 - CEK Comparison failed : %s\n", pDCF);
                goto CATCH;
        }
 
-       if (memcmp(pDCF, pDcfHandler->m_pFilePath, strlen((char*)pDcfHandler->m_pFilePath)) != 0)
-       {
-               printf("tc07_DrmFileMgrPositive_01 - FilePath Comparison failed : %s\n", pDcfHandler->m_pFilePath);
+       if (memcmp(pDCF, pDcfHandler->m_pFilePath,
+                          strlen((char *)pDcfHandler->m_pFilePath)) != 0) {
+               printf("tc07_DrmFileMgrPositive_01 - FilePath Comparison failed : %s\n",
+                          pDcfHandler->m_pFilePath);
                goto CATCH;
        }
 
-       if (memcmp(pCID, pDcfHandler->m_pCID, strlen((char*)pDcfHandler->m_pCID)) != 0)
-       {
-               printf("tc07_DrmFileMgrPositive_01 - CID Comparison failed : %s\n", pDcfHandler->m_pCID);
+       if (memcmp(pCID, pDcfHandler->m_pCID,
+                          strlen((char *)pDcfHandler->m_pCID)) != 0) {
+               printf("tc07_DrmFileMgrPositive_01 - CID Comparison failed : %s\n",
+                          pDcfHandler->m_pCID);
                goto CATCH;
        }
 
-       if (pDcfHandler->m_encryptionLevel != encryptionLevel)
-       {
-               printf("tc07_DrmFileMgrPositive_01 - encryptionLevel Comparison failed : origin = %ld, result = %ld\n", encryptionLevel, pDcfHandler->m_encryptionLevel);
+       if (pDcfHandler->m_encryptionLevel != encryptionLevel) {
+               printf("tc07_DrmFileMgrPositive_01 - encryptionLevel Comparison failed : origin = %ld, result = %ld\n",
+                          encryptionLevel, pDcfHandler->m_encryptionLevel);
                goto CATCH;
        }
 
-       if (pDcfHandler->m_encryptionRange != encryptionRange)
-       {
-               printf("tc07_DrmFileMgrPositive_01 - encryptionRange Comparison failed : origin = %lld, result = %lld\n", encryptionRange, pDcfHandler->m_encryptionRange);
+       if (pDcfHandler->m_encryptionRange != encryptionRange) {
+               printf("tc07_DrmFileMgrPositive_01 - encryptionRange Comparison failed : origin = %lld, result = %lld\n",
+                          encryptionRange, pDcfHandler->m_encryptionRange);
                goto CATCH;
        }
 
-       if (pDcfHandler->m_plaintextSize != plainTextSize)
-       {
-               printf("tc07_DrmFileMgrPositive_01 - plainTextSize Comparison failed : origin = %lld, result = %lld\n", plainTextSize, pDcfHandler->m_plaintextSize);
+       if (pDcfHandler->m_plaintextSize != plainTextSize) {
+               printf("tc07_DrmFileMgrPositive_01 - plainTextSize Comparison failed : origin = %lld, result = %lld\n",
+                          plainTextSize, pDcfHandler->m_plaintextSize);
                goto CATCH;
        }
 
-       if (pDcfHandler->m_OriginEndOffset != originalEndOffset)
-       {
-               printf("tc07_DrmFileMgrPositive_01 - originalEndOffset Comparison failed : origin = %lld, result = %lld\n", originalEndOffset, pDcfHandler->m_OriginEndOffset);
+       if (pDcfHandler->m_OriginEndOffset != originalEndOffset) {
+               printf("tc07_DrmFileMgrPositive_01 - originalEndOffset Comparison failed : origin = %lld, result = %lld\n",
+                          originalEndOffset, pDcfHandler->m_OriginEndOffset);
                goto CATCH;
        }
 
@@ -736,7 +757,7 @@ bool tc07_DrmFileMgrPositive_02(void)
        const char *pDCF = TEST_DATA_DIR "/DCF/8SPXfqc6iL.tpk";
        int nRet = TADC_SUCCESS;
 
-       DrmFileMgrpDrmFileMgr = NULL;
+       DrmFileMgr *pDrmFileMgr = NULL;
        DrmFileHandler *pDcfHandler = NULL;
 
        unsigned char pCEK[CEK_SIZE + 1] = {0xBB, 0x87, 0x5D, 0xA8, 0x2C, 0xC4, 0x47, 0x81, 0x90, 0xBA, 0xD9, 0xB0, 0x0C, 0xD2, 0x94, 0xE9, 0x19, 0x0F, 0x24, 0x62, 0x5B, 0x0B, 0x49, 0x7A, 0xAE, 0x8E, 0x1D, 0x88, 0x7F, 0xF9, 0x96, 0xDB, 0x00};
@@ -752,58 +773,61 @@ bool tc07_DrmFileMgrPositive_02(void)
        pDrmFileMgr = DrmFileMgr::GetInstance();
 
        nRet = pDrmFileMgr->OpenFileHandler(pDCF, &second_key);
-       if (nRet != TADC_SUCCESS)
-       {
-               printf("tc07_DrmFileMgrPositive_02 - OpenFileHandler() failed : key = %d, file = %s, %x\n", second_key, pDCF, nRet);
+
+       if (nRet != TADC_SUCCESS) {
+               printf("tc07_DrmFileMgrPositive_02 - OpenFileHandler() failed : key = %d, file = %s, %x\n",
+                          second_key, pDCF, nRet);
                goto CATCH;
        }
 
        nRet = pDrmFileMgr->GetFileHandler(second_key, &pDcfHandler);
-       if (nRet != TADC_SUCCESS)
-       {
-               printf("tc07_DrmFileMgrPositive_02 - GetFileHandler() failed : key = %d, file = %s, %x\n", second_key, pDCF, nRet);
+
+       if (nRet != TADC_SUCCESS) {
+               printf("tc07_DrmFileMgrPositive_02 - GetFileHandler() failed : key = %d, file = %s, %x\n",
+                          second_key, pDCF, nRet);
                goto CATCH;
        }
 
-       if (memcmp(pCEK, pDcfHandler->m_pCEK, CEK_SIZE) != 0)
-       {
+       if (memcmp(pCEK, pDcfHandler->m_pCEK, CEK_SIZE) != 0) {
                printf("tc07_DrmFileMgrPositive_02 - CEK Comparison failed : %s\n", pDCF);
                goto CATCH;
        }
 
-       if (memcmp(pDCF, pDcfHandler->m_pFilePath, strlen((char*)pDcfHandler->m_pFilePath)) != 0)
-       {
-               printf("tc07_DrmFileMgrPositive_02 - FilePath Comparison failed : %s\n", pDcfHandler->m_pFilePath);
+       if (memcmp(pDCF, pDcfHandler->m_pFilePath,
+                          strlen((char *)pDcfHandler->m_pFilePath)) != 0) {
+               printf("tc07_DrmFileMgrPositive_02 - FilePath Comparison failed : %s\n",
+                          pDcfHandler->m_pFilePath);
                goto CATCH;
        }
 
-       if (memcmp(pCID, pDcfHandler->m_pCID, strlen((char*)pDcfHandler->m_pCID)) != 0)
-       {
-               printf("tc07_DrmFileMgrPositive_02 - CID Comparison failed : %s\n", pDcfHandler->m_pCID);
+       if (memcmp(pCID, pDcfHandler->m_pCID,
+                          strlen((char *)pDcfHandler->m_pCID)) != 0) {
+               printf("tc07_DrmFileMgrPositive_02 - CID Comparison failed : %s\n",
+                          pDcfHandler->m_pCID);
                goto CATCH;
        }
 
-       if (pDcfHandler->m_encryptionLevel != encryptionLevel)
-       {
-               printf("tc07_DrmFileMgrPositive_02 - encryptionLevel Comparison failed : origin = %ld, result = %ld\n", encryptionLevel, pDcfHandler->m_encryptionLevel);
+       if (pDcfHandler->m_encryptionLevel != encryptionLevel) {
+               printf("tc07_DrmFileMgrPositive_02 - encryptionLevel Comparison failed : origin = %ld, result = %ld\n",
+                          encryptionLevel, pDcfHandler->m_encryptionLevel);
                goto CATCH;
        }
 
-       if (pDcfHandler->m_encryptionRange != encryptionRange)
-       {
-               printf("tc07_DrmFileMgrPositive_02 - encryptionRange Comparison failed : origin = %lld, result = %lld\n", encryptionRange, pDcfHandler->m_encryptionRange);
+       if (pDcfHandler->m_encryptionRange != encryptionRange) {
+               printf("tc07_DrmFileMgrPositive_02 - encryptionRange Comparison failed : origin = %lld, result = %lld\n",
+                          encryptionRange, pDcfHandler->m_encryptionRange);
                goto CATCH;
        }
 
-       if (pDcfHandler->m_plaintextSize != plainTextSize)
-       {
-               printf("tc07_DrmFileMgrPositive_02 - plainTextSize Comparison failed : origin = %lld, result = %lld\n", plainTextSize, pDcfHandler->m_plaintextSize);
+       if (pDcfHandler->m_plaintextSize != plainTextSize) {
+               printf("tc07_DrmFileMgrPositive_02 - plainTextSize Comparison failed : origin = %lld, result = %lld\n",
+                          plainTextSize, pDcfHandler->m_plaintextSize);
                goto CATCH;
        }
 
-       if (pDcfHandler->m_OriginEndOffset != originalEndOffset)
-       {
-               printf("tc07_DrmFileMgrPositive_02 - originalEndOffset Comparison failed : origin = %lld, result = %lld\n", originalEndOffset, pDcfHandler->m_OriginEndOffset);
+       if (pDcfHandler->m_OriginEndOffset != originalEndOffset) {
+               printf("tc07_DrmFileMgrPositive_02 - originalEndOffset Comparison failed : origin = %lld, result = %lld\n",
+                          originalEndOffset, pDcfHandler->m_OriginEndOffset);
                goto CATCH;
        }
 
@@ -821,7 +845,7 @@ bool tc07_DrmFileMgrPositive_03(void)
        const char *pDCF  = TEST_DATA_DIR "/DCF/FightGuiIF.tpk";
        int nRet = TADC_SUCCESS;
 
-       DrmFileMgrpDrmFileMgr = NULL;
+       DrmFileMgr *pDrmFileMgr = NULL;
        DrmFileHandler *pDcfHandler = NULL;
 
        unsigned char pCEK[CEK_SIZE + 1] = {0x34, 0x5A, 0x94, 0x28, 0xC3, 0xF4, 0x44, 0x3F, 0x86, 0x6D, 0xCF, 0xC5, 0x78, 0x1F, 0x23, 0xCE, 0xE9, 0x9B, 0xC4, 0x45, 0xA3, 0x30, 0x47, 0x1E, 0xB4, 0xE0, 0xAF, 0x96, 0x0F, 0xDE, 0xA9, 0xB4, 0x00};
@@ -838,58 +862,61 @@ bool tc07_DrmFileMgrPositive_03(void)
        pDrmFileMgr = DrmFileMgr::GetInstance();
 
        nRet = pDrmFileMgr->OpenFileHandler(pDCF, &third_key);
-       if (nRet != TADC_SUCCESS)
-       {
-               printf("tc07_DrmFileMgrPositive_03 - OpenFileHandler() failed : key = %d, file = %s, %x\n", third_key, pDCF, nRet);
+
+       if (nRet != TADC_SUCCESS) {
+               printf("tc07_DrmFileMgrPositive_03 - OpenFileHandler() failed : key = %d, file = %s, %x\n",
+                          third_key, pDCF, nRet);
                goto CATCH;
        }
 
        nRet = pDrmFileMgr->GetFileHandler(third_key, &pDcfHandler);
-       if (nRet != TADC_SUCCESS)
-       {
-               printf("tc07_DrmFileMgrPositive_03 - GetFileHandler() failed : key = %d, file = %s, %x\n", third_key, pDCF, nRet);
+
+       if (nRet != TADC_SUCCESS) {
+               printf("tc07_DrmFileMgrPositive_03 - GetFileHandler() failed : key = %d, file = %s, %x\n",
+                          third_key, pDCF, nRet);
                goto CATCH;
        }
 
-       if (memcmp(pCEK, pDcfHandler->m_pCEK, CEK_SIZE) != 0)
-       {
+       if (memcmp(pCEK, pDcfHandler->m_pCEK, CEK_SIZE) != 0) {
                printf("tc07_DrmFileMgrPositive_03 - CEK Comparison failed : %s\n", pDCF);
                goto CATCH;
        }
 
-       if (memcmp(pDCF, pDcfHandler->m_pFilePath, strlen((char*)pDcfHandler->m_pFilePath)) != 0)
-       {
-               printf("tc07_DrmFileMgrPositive_03 - FilePath Comparison failed : %s\n", pDcfHandler->m_pFilePath);
+       if (memcmp(pDCF, pDcfHandler->m_pFilePath,
+                          strlen((char *)pDcfHandler->m_pFilePath)) != 0) {
+               printf("tc07_DrmFileMgrPositive_03 - FilePath Comparison failed : %s\n",
+                          pDcfHandler->m_pFilePath);
                goto CATCH;
        }
 
-       if (memcmp(pCID, pDcfHandler->m_pCID, strlen((char*)pDcfHandler->m_pCID)) != 0)
-       {
-               printf("tc07_DrmFileMgrPositive_03 - CID Comparison failed : %s\n", pDcfHandler->m_pCID);
+       if (memcmp(pCID, pDcfHandler->m_pCID,
+                          strlen((char *)pDcfHandler->m_pCID)) != 0) {
+               printf("tc07_DrmFileMgrPositive_03 - CID Comparison failed : %s\n",
+                          pDcfHandler->m_pCID);
                goto CATCH;
        }
 
-       if (pDcfHandler->m_encryptionLevel != encryptionLevel)
-       {
-               printf("tc07_DrmFileMgrPositive_03 - encryptionLevel Comparison failed : origin = %ld, result = %ld\n", encryptionLevel, pDcfHandler->m_encryptionLevel);
+       if (pDcfHandler->m_encryptionLevel != encryptionLevel) {
+               printf("tc07_DrmFileMgrPositive_03 - encryptionLevel Comparison failed : origin = %ld, result = %ld\n",
+                          encryptionLevel, pDcfHandler->m_encryptionLevel);
                goto CATCH;
        }
 
-       if (pDcfHandler->m_encryptionRange != encryptionRange)
-       {
-               printf("tc07_DrmFileMgrPositive_03 - encryptionRange Comparison failed : origin = %lld, result = %lld\n", encryptionRange, pDcfHandler->m_encryptionRange);
+       if (pDcfHandler->m_encryptionRange != encryptionRange) {
+               printf("tc07_DrmFileMgrPositive_03 - encryptionRange Comparison failed : origin = %lld, result = %lld\n",
+                          encryptionRange, pDcfHandler->m_encryptionRange);
                goto CATCH;
        }
 
-       if (pDcfHandler->m_plaintextSize != plainTextSize)
-       {
-               printf("tc07_DrmFileMgrPositive_03 - plainTextSize Comparison failed : origin = %lld, result = %lld\n", plainTextSize, pDcfHandler->m_plaintextSize);
+       if (pDcfHandler->m_plaintextSize != plainTextSize) {
+               printf("tc07_DrmFileMgrPositive_03 - plainTextSize Comparison failed : origin = %lld, result = %lld\n",
+                          plainTextSize, pDcfHandler->m_plaintextSize);
                goto CATCH;
        }
 
-       if (pDcfHandler->m_OriginEndOffset != originalEndOffset)
-       {
-               printf("tc07_DrmFileMgrPositive_03 - originalEndOffset Comparison failed : origin = %lld, result = %lld\n", originalEndOffset, pDcfHandler->m_OriginEndOffset);
+       if (pDcfHandler->m_OriginEndOffset != originalEndOffset) {
+               printf("tc07_DrmFileMgrPositive_03 - originalEndOffset Comparison failed : origin = %lld, result = %lld\n",
+                          originalEndOffset, pDcfHandler->m_OriginEndOffset);
                goto CATCH;
        }
 
@@ -907,7 +934,7 @@ bool tc08_DrmFileMgrPositive_GetFileHandler_01(void)
        const char *pDCF = TEST_DATA_DIR "/DCF/38EIfBurLJ.tpk";
        int nRet = TADC_SUCCESS;
 
-       DrmFileMgrpDrmFileMgr = NULL;
+       DrmFileMgr *pDrmFileMgr = NULL;
        DrmFileHandler *pDcfHandler = NULL;
 
        unsigned char pCEK[CEK_SIZE + 1] = {0xB1, 0x03, 0x4F, 0x30, 0xC8, 0x52, 0x45, 0x7E, 0x9D, 0xA2, 0x52, 0x25, 0x2E, 0xA9, 0x9B, 0x2B, 0x25, 0x36, 0xF1, 0x8D, 0x04, 0xD1, 0x4C, 0xE3, 0x96, 0x81, 0xD9, 0x98, 0xBB, 0xD7, 0x7E, 0xCA, 0x00};
@@ -924,51 +951,54 @@ bool tc08_DrmFileMgrPositive_GetFileHandler_01(void)
        pDrmFileMgr = DrmFileMgr::GetInstance();
 
        nRet = pDrmFileMgr->GetFileHandler(first_key, &pDcfHandler);
-       if (nRet != TADC_SUCCESS)
-       {
-               printf("tc08_DrmFileMgrPositive_GetFileHandler_01 failed : key = %d, file = %s, %x\n", first_key, pDCF, nRet);
+
+       if (nRet != TADC_SUCCESS) {
+               printf("tc08_DrmFileMgrPositive_GetFileHandler_01 failed : key = %d, file = %s, %x\n",
+                          first_key, pDCF, nRet);
                goto CATCH;
        }
 
-       if (memcmp(pCEK, pDcfHandler->m_pCEK, CEK_SIZE) != 0)
-       {
-               printf("tc08_DrmFileMgrPositive_GetFileHandler_01 - CEK Comparison failed : %s\n", pDCF);
+       if (memcmp(pCEK, pDcfHandler->m_pCEK, CEK_SIZE) != 0) {
+               printf("tc08_DrmFileMgrPositive_GetFileHandler_01 - CEK Comparison failed : %s\n",
+                          pDCF);
                goto CATCH;
        }
 
-       if (memcmp(pDCF, pDcfHandler->m_pFilePath, strlen((char*)pDcfHandler->m_pFilePath)) != 0)
-       {
-               printf("tc08_DrmFileMgrPositive_GetFileHandler_01 - FilePath Comparison failed : %s\n", pDcfHandler->m_pFilePath);
+       if (memcmp(pDCF, pDcfHandler->m_pFilePath,
+                          strlen((char *)pDcfHandler->m_pFilePath)) != 0) {
+               printf("tc08_DrmFileMgrPositive_GetFileHandler_01 - FilePath Comparison failed : %s\n",
+                          pDcfHandler->m_pFilePath);
                goto CATCH;
        }
 
-       if (memcmp(pCID, pDcfHandler->m_pCID, strlen((char*)pDcfHandler->m_pCID)) != 0)
-       {
-               printf("tc08_DrmFileMgrPositive_GetFileHandler_01 - CID Comparison failed : %s\n", pDcfHandler->m_pCID);
+       if (memcmp(pCID, pDcfHandler->m_pCID,
+                          strlen((char *)pDcfHandler->m_pCID)) != 0) {
+               printf("tc08_DrmFileMgrPositive_GetFileHandler_01 - CID Comparison failed : %s\n",
+                          pDcfHandler->m_pCID);
                goto CATCH;
        }
 
-       if (pDcfHandler->m_encryptionLevel != encryptionLevel)
-       {
-               printf("tc08_DrmFileMgrPositive_GetFileHandler_01 - encryptionLevel Comparison failed : origin = %ld, result = %ld\n", encryptionLevel, pDcfHandler->m_encryptionLevel);
+       if (pDcfHandler->m_encryptionLevel != encryptionLevel) {
+               printf("tc08_DrmFileMgrPositive_GetFileHandler_01 - encryptionLevel Comparison failed : origin = %ld, result = %ld\n",
+                          encryptionLevel, pDcfHandler->m_encryptionLevel);
                goto CATCH;
        }
 
-       if (pDcfHandler->m_encryptionRange != encryptionRange)
-       {
-               printf("tc08_DrmFileMgrPositive_GetFileHandler_01 - encryptionRange Comparison failed : origin = %lld, result = %lld\n", encryptionRange, pDcfHandler->m_encryptionRange);
+       if (pDcfHandler->m_encryptionRange != encryptionRange) {
+               printf("tc08_DrmFileMgrPositive_GetFileHandler_01 - encryptionRange Comparison failed : origin = %lld, result = %lld\n",
+                          encryptionRange, pDcfHandler->m_encryptionRange);
                goto CATCH;
        }
 
-       if (pDcfHandler->m_plaintextSize != plainTextSize)
-       {
-               printf("tc08_DrmFileMgrPositive_GetFileHandler_01 - plainTextSize Comparison failed : origin = %lld, result = %lld\n", plainTextSize, pDcfHandler->m_plaintextSize);
+       if (pDcfHandler->m_plaintextSize != plainTextSize) {
+               printf("tc08_DrmFileMgrPositive_GetFileHandler_01 - plainTextSize Comparison failed : origin = %lld, result = %lld\n",
+                          plainTextSize, pDcfHandler->m_plaintextSize);
                goto CATCH;
        }
 
-       if (pDcfHandler->m_OriginEndOffset != originalEndOffset)
-       {
-               printf("tc08_DrmFileMgrPositive_GetFileHandler_01 - originalEndOffset Comparison failed : origin = %lld, result = %lld\n", originalEndOffset, pDcfHandler->m_OriginEndOffset);
+       if (pDcfHandler->m_OriginEndOffset != originalEndOffset) {
+               printf("tc08_DrmFileMgrPositive_GetFileHandler_01 - originalEndOffset Comparison failed : origin = %lld, result = %lld\n",
+                          originalEndOffset, pDcfHandler->m_OriginEndOffset);
                goto CATCH;
        }
 
@@ -986,7 +1016,7 @@ bool tc08_DrmFileMgrPositive_GetFileHandler_02(void)
        const char *pDCF = TEST_DATA_DIR "/DCF/8SPXfqc6iL.tpk";
        int nRet = TADC_SUCCESS;
 
-       DrmFileMgrpDrmFileMgr = NULL;
+       DrmFileMgr *pDrmFileMgr = NULL;
        DrmFileHandler *pDcfHandler = NULL;
 
        unsigned char pCEK[CEK_SIZE + 1] = {0xBB, 0x87, 0x5D, 0xA8, 0x2C, 0xC4, 0x47, 0x81, 0x90, 0xBA, 0xD9, 0xB0, 0x0C, 0xD2, 0x94, 0xE9, 0x19, 0x0F, 0x24, 0x62, 0x5B, 0x0B, 0x49, 0x7A, 0xAE, 0x8E, 0x1D, 0x88, 0x7F, 0xF9, 0x96, 0xDB, 0x00};
@@ -1003,51 +1033,54 @@ bool tc08_DrmFileMgrPositive_GetFileHandler_02(void)
        pDrmFileMgr = DrmFileMgr::GetInstance();
 
        nRet = pDrmFileMgr->GetFileHandler(second_key, &pDcfHandler);
-       if (nRet != TADC_SUCCESS)
-       {
-               printf("tc08_DrmFileMgrPositive_GetFileHandler_02 failed : key = %d, file = %s, %x\n", second_key, pDCF, nRet);
+
+       if (nRet != TADC_SUCCESS) {
+               printf("tc08_DrmFileMgrPositive_GetFileHandler_02 failed : key = %d, file = %s, %x\n",
+                          second_key, pDCF, nRet);
                goto CATCH;
        }
 
-       if (memcmp(pCEK, pDcfHandler->m_pCEK, CEK_SIZE) != 0)
-       {
-               printf("tc08_DrmFileMgrPositive_GetFileHandler_02 - CEK Comparison failed : %s\n", pDCF);
+       if (memcmp(pCEK, pDcfHandler->m_pCEK, CEK_SIZE) != 0) {
+               printf("tc08_DrmFileMgrPositive_GetFileHandler_02 - CEK Comparison failed : %s\n",
+                          pDCF);
                goto CATCH;
        }
 
-       if (memcmp(pDCF, pDcfHandler->m_pFilePath, strlen((char*)pDcfHandler->m_pFilePath)) != 0)
-       {
-               printf("tc08_DrmFileMgrPositive_GetFileHandler_02 - FilePath Comparison failed : %s\n", pDcfHandler->m_pFilePath);
+       if (memcmp(pDCF, pDcfHandler->m_pFilePath,
+                          strlen((char *)pDcfHandler->m_pFilePath)) != 0) {
+               printf("tc08_DrmFileMgrPositive_GetFileHandler_02 - FilePath Comparison failed : %s\n",
+                          pDcfHandler->m_pFilePath);
                goto CATCH;
        }
 
-       if (memcmp(pCID, pDcfHandler->m_pCID, strlen((char*)pDcfHandler->m_pCID)) != 0)
-       {
-               printf("tc08_DrmFileMgrPositive_GetFileHandler_02 - CID Comparison failed : %s\n", pDcfHandler->m_pCID);
+       if (memcmp(pCID, pDcfHandler->m_pCID,
+                          strlen((char *)pDcfHandler->m_pCID)) != 0) {
+               printf("tc08_DrmFileMgrPositive_GetFileHandler_02 - CID Comparison failed : %s\n",
+                          pDcfHandler->m_pCID);
                goto CATCH;
        }
 
-       if (pDcfHandler->m_encryptionLevel != encryptionLevel)
-       {
-               printf("tc08_DrmFileMgrPositive_GetFileHandler_02 - encryptionLevel Comparison failed : origin = %ld, result = %ld\n", encryptionLevel, pDcfHandler->m_encryptionLevel);
+       if (pDcfHandler->m_encryptionLevel != encryptionLevel) {
+               printf("tc08_DrmFileMgrPositive_GetFileHandler_02 - encryptionLevel Comparison failed : origin = %ld, result = %ld\n",
+                          encryptionLevel, pDcfHandler->m_encryptionLevel);
                goto CATCH;
        }
 
-       if (pDcfHandler->m_encryptionRange != encryptionRange)
-       {
-               printf("tc08_DrmFileMgrPositive_GetFileHandler_02 - encryptionRange Comparison failed : origin = %lld, result = %lld\n", encryptionRange, pDcfHandler->m_encryptionRange);
+       if (pDcfHandler->m_encryptionRange != encryptionRange) {
+               printf("tc08_DrmFileMgrPositive_GetFileHandler_02 - encryptionRange Comparison failed : origin = %lld, result = %lld\n",
+                          encryptionRange, pDcfHandler->m_encryptionRange);
                goto CATCH;
        }
 
-       if (pDcfHandler->m_plaintextSize != plainTextSize)
-       {
-               printf("tc08_DrmFileMgrPositive_GetFileHandler_02 - plainTextSize Comparison failed : origin = %lld, result = %lld\n", plainTextSize, pDcfHandler->m_plaintextSize);
+       if (pDcfHandler->m_plaintextSize != plainTextSize) {
+               printf("tc08_DrmFileMgrPositive_GetFileHandler_02 - plainTextSize Comparison failed : origin = %lld, result = %lld\n",
+                          plainTextSize, pDcfHandler->m_plaintextSize);
                goto CATCH;
        }
 
-       if (pDcfHandler->m_OriginEndOffset != originalEndOffset)
-       {
-               printf("tc08_DrmFileMgrPositive_GetFileHandler_02 - originalEndOffset Comparison failed : origin = %lld, result = %lld\n", originalEndOffset, pDcfHandler->m_OriginEndOffset);
+       if (pDcfHandler->m_OriginEndOffset != originalEndOffset) {
+               printf("tc08_DrmFileMgrPositive_GetFileHandler_02 - originalEndOffset Comparison failed : origin = %lld, result = %lld\n",
+                          originalEndOffset, pDcfHandler->m_OriginEndOffset);
                goto CATCH;
        }
 
@@ -1065,7 +1098,7 @@ bool tc08_DrmFileMgrPositive_GetFileHandler_03(void)
        const char *pDCF = TEST_DATA_DIR "/DCF/FightGuiIF.tpk";
        int nRet = TADC_SUCCESS;
 
-       DrmFileMgrpDrmFileMgr = NULL;
+       DrmFileMgr *pDrmFileMgr = NULL;
        DrmFileHandler *pDcfHandler = NULL;
 
        unsigned char pCEK[CEK_SIZE + 1] = {0x34, 0x5A, 0x94, 0x28, 0xC3, 0xF4, 0x44, 0x3F, 0x86, 0x6D, 0xCF, 0xC5, 0x78, 0x1F, 0x23, 0xCE, 0xE9, 0x9B, 0xC4, 0x45, 0xA3, 0x30, 0x47, 0x1E, 0xB4, 0xE0, 0xAF, 0x96, 0x0F, 0xDE, 0xA9, 0xB4, 0x00};
@@ -1082,51 +1115,54 @@ bool tc08_DrmFileMgrPositive_GetFileHandler_03(void)
        pDrmFileMgr = DrmFileMgr::GetInstance();
 
        nRet = pDrmFileMgr->GetFileHandler(third_key, &pDcfHandler);
-       if (nRet != TADC_SUCCESS)
-       {
-               printf("tc08_DrmFileMgrPositive_GetFileHandler_03 failed : key = %d, file = %s, %x\n", third_key, pDCF, nRet);
+
+       if (nRet != TADC_SUCCESS) {
+               printf("tc08_DrmFileMgrPositive_GetFileHandler_03 failed : key = %d, file = %s, %x\n",
+                          third_key, pDCF, nRet);
                goto CATCH;
        }
 
-       if (memcmp(pCEK, pDcfHandler->m_pCEK, CEK_SIZE) != 0)
-       {
-               printf("tc08_DrmFileMgrPositive_GetFileHandler_03 - CEK Comparison failed : %s\n", pDCF);
+       if (memcmp(pCEK, pDcfHandler->m_pCEK, CEK_SIZE) != 0) {
+               printf("tc08_DrmFileMgrPositive_GetFileHandler_03 - CEK Comparison failed : %s\n",
+                          pDCF);
                goto CATCH;
        }
 
-       if (memcmp(pDCF, pDcfHandler->m_pFilePath, strlen((char*)pDcfHandler->m_pFilePath)) != 0)
-       {
-               printf("tc08_DrmFileMgrPositive_GetFileHandler_03 - FilePath Comparison failed : %s\n", pDcfHandler->m_pFilePath);
+       if (memcmp(pDCF, pDcfHandler->m_pFilePath,
+                          strlen((char *)pDcfHandler->m_pFilePath)) != 0) {
+               printf("tc08_DrmFileMgrPositive_GetFileHandler_03 - FilePath Comparison failed : %s\n",
+                          pDcfHandler->m_pFilePath);
                goto CATCH;
        }
 
-       if (memcmp(pCID, pDcfHandler->m_pCID, strlen((char*)pDcfHandler->m_pCID)) != 0)
-       {
-               printf("tc08_DrmFileMgrPositive_GetFileHandler_03 - CID Comparison failed : %s\n", pDcfHandler->m_pCID);
+       if (memcmp(pCID, pDcfHandler->m_pCID,
+                          strlen((char *)pDcfHandler->m_pCID)) != 0) {
+               printf("tc08_DrmFileMgrPositive_GetFileHandler_03 - CID Comparison failed : %s\n",
+                          pDcfHandler->m_pCID);
                goto CATCH;
        }
 
-       if (pDcfHandler->m_encryptionLevel != encryptionLevel)
-       {
-               printf("tc08_DrmFileMgrPositive_GetFileHandler_03 - encryptionLevel Comparison failed : origin = %ld, result = %ld\n", encryptionLevel, pDcfHandler->m_encryptionLevel);
+       if (pDcfHandler->m_encryptionLevel != encryptionLevel) {
+               printf("tc08_DrmFileMgrPositive_GetFileHandler_03 - encryptionLevel Comparison failed : origin = %ld, result = %ld\n",
+                          encryptionLevel, pDcfHandler->m_encryptionLevel);
                goto CATCH;
        }
 
-       if (pDcfHandler->m_encryptionRange != encryptionRange)
-       {
-               printf("tc08_DrmFileMgrPositive_GetFileHandler_03 - encryptionRange Comparison failed : origin = %lld, result = %lld\n", encryptionRange, pDcfHandler->m_encryptionRange);
+       if (pDcfHandler->m_encryptionRange != encryptionRange) {
+               printf("tc08_DrmFileMgrPositive_GetFileHandler_03 - encryptionRange Comparison failed : origin = %lld, result = %lld\n",
+                          encryptionRange, pDcfHandler->m_encryptionRange);
                goto CATCH;
        }
 
-       if (pDcfHandler->m_plaintextSize != plainTextSize)
-       {
-               printf("tc08_DrmFileMgrPositive_GetFileHandler_03 - plainTextSize Comparison failed : origin = %lld, result = %lld\n", plainTextSize, pDcfHandler->m_plaintextSize);
+       if (pDcfHandler->m_plaintextSize != plainTextSize) {
+               printf("tc08_DrmFileMgrPositive_GetFileHandler_03 - plainTextSize Comparison failed : origin = %lld, result = %lld\n",
+                          plainTextSize, pDcfHandler->m_plaintextSize);
                goto CATCH;
        }
 
-       if (pDcfHandler->m_OriginEndOffset != originalEndOffset)
-       {
-               printf("tc08_DrmFileMgrPositive_GetFileHandler_03 - originalEndOffset Comparison failed : origin = %lld, result = %lld\n", originalEndOffset, pDcfHandler->m_OriginEndOffset);
+       if (pDcfHandler->m_OriginEndOffset != originalEndOffset) {
+               printf("tc08_DrmFileMgrPositive_GetFileHandler_03 - originalEndOffset Comparison failed : origin = %lld, result = %lld\n",
+                          originalEndOffset, pDcfHandler->m_OriginEndOffset);
                goto CATCH;
        }
 
@@ -1144,7 +1180,7 @@ bool tc09_DrmFileMgrPositive_FileAPI_01(void)
        const char *pDCF = TEST_DATA_DIR "/DCF/38EIfBurLJ.tpk";
        int nRet = TADC_SUCCESS;
 
-       DrmFileMgrpDrmFileMgr = NULL;
+       DrmFileMgr *pDrmFileMgr = NULL;
        DrmFileHandler *pDcfHandler = NULL;
 
        long long originalEndOffset = 1631570;
@@ -1157,153 +1193,166 @@ bool tc09_DrmFileMgrPositive_FileAPI_01(void)
        pDrmFileMgr = DrmFileMgr::GetInstance();
 
        nRet = pDrmFileMgr->GetFileHandler(first_key, &pDcfHandler);
-       if (nRet != TADC_SUCCESS)
-       {
-               printf("tc09_DrmFileMgrPositive_FileAPI_01 failed : key = %d, file = %s, %x\n", first_key, pDCF, nRet);
+
+       if (nRet != TADC_SUCCESS) {
+               printf("tc09_DrmFileMgrPositive_FileAPI_01 failed : key = %d, file = %s, %x\n",
+                          first_key, pDCF, nRet);
                goto CATCH;
        }
 
-       if (pDcfHandler->m_OriginEndOffset != originalEndOffset)
-       {
-               printf("tc09_DrmFileMgrPositive_FileAPI_01 - originalEndOffset Comparison failed : origin = %lld, result = %lld\n", originalEndOffset, pDcfHandler->m_OriginEndOffset);
+       if (pDcfHandler->m_OriginEndOffset != originalEndOffset) {
+               printf("tc09_DrmFileMgrPositive_FileAPI_01 - originalEndOffset Comparison failed : origin = %lld, result = %lld\n",
+                          originalEndOffset, pDcfHandler->m_OriginEndOffset);
                goto CATCH;
        }
 
-       if (OriginCurOffset != pDcfHandler->m_OriginCurOffset)
-       {
-               printf("tc09_DrmFileMgrPositive_FileAPI_01 - originalCurOffset Comparison failed : origin = %lld, result = %lld\n", OriginCurOffset, pDcfHandler->m_OriginCurOffset);
+       if (OriginCurOffset != pDcfHandler->m_OriginCurOffset) {
+               printf("tc09_DrmFileMgrPositive_FileAPI_01 - originalCurOffset Comparison failed : origin = %lld, result = %lld\n",
+                          OriginCurOffset, pDcfHandler->m_OriginCurOffset);
                goto CATCH;
        }
 
-       for (i = 0 ; i <= pDcfHandler->m_DrmEndOffset ; i++)
-       {
+       for (i = 0; i <= pDcfHandler->m_DrmEndOffset; i++) {
                nRet = pDcfHandler->DrmSeek(i, SEEK_SET);
-               if (nRet != TADC_SUCCESS)
-               {
-                       printf("tc09_DrmFileMgrPositive_FileAPI_03 DrmSeek failed (SEEK_SET, forward) : key = %d, file = %s, i = %lld, ret = %x\n", first_key, pDCF, i, nRet);
+
+               if (nRet != TADC_SUCCESS) {
+                       printf("tc09_DrmFileMgrPositive_FileAPI_03 DrmSeek failed (SEEK_SET, forward) : key = %d, file = %s, i = %lld, ret = %x\n",
+                                  first_key, pDCF, i, nRet);
                        goto CATCH;
                }
 
                DrmCurOffset = pDcfHandler->DrmTell();
-               if (DrmCurOffset != pDcfHandler->m_DrmCurOffset)
-               {
-                       printf("tc09_DrmFileMgrPositive_FileAPI_01 - DrmCurOffset Comparison failed (SEEK_SET, forward) : origin = %lld, result = %lld, i = %lld\n", DrmCurOffset, pDcfHandler->m_DrmCurOffset, i);
+
+               if (DrmCurOffset != pDcfHandler->m_DrmCurOffset) {
+                       printf("tc09_DrmFileMgrPositive_FileAPI_01 - DrmCurOffset Comparison failed (SEEK_SET, forward) : origin = %lld, result = %lld, i = %lld\n",
+                                  DrmCurOffset, pDcfHandler->m_DrmCurOffset, i);
                        goto CATCH;
                }
        }
-       if (DrmCurOffset != pDcfHandler->m_DrmEndOffset)
-       {
-               printf("tc09_DrmFileMgrPositive_FileAPI_01 DrmSeek failed (SEEK_SET, forward), DrmCurOffset = %lld, RealEndOffset = %lld, %x\n", DrmCurOffset, pDcfHandler->m_DrmEndOffset, nRet);
+
+       if (DrmCurOffset != pDcfHandler->m_DrmEndOffset) {
+               printf("tc09_DrmFileMgrPositive_FileAPI_01 DrmSeek failed (SEEK_SET, forward), DrmCurOffset = %lld, RealEndOffset = %lld, %x\n",
+                          DrmCurOffset, pDcfHandler->m_DrmEndOffset, nRet);
                goto CATCH;
        }
 
-       for (i = pDcfHandler->m_DrmEndOffset ; i >= 0 ; i--)
-       {
+       for (i = pDcfHandler->m_DrmEndOffset; i >= 0; i--) {
                nRet = pDcfHandler->DrmSeek(i, SEEK_SET);
-               if (nRet != TADC_SUCCESS)
-               {
-                       printf("tc09_DrmFileMgrPositive_FileAPI_01 DrmSeek failed (SEEK_SET, backward) : key=%d, file=%s, i=%lld, %x\n", first_key, pDCF, i, nRet);
+
+               if (nRet != TADC_SUCCESS) {
+                       printf("tc09_DrmFileMgrPositive_FileAPI_01 DrmSeek failed (SEEK_SET, backward) : key=%d, file=%s, i=%lld, %x\n",
+                                  first_key, pDCF, i, nRet);
                        goto CATCH;
                }
 
                DrmCurOffset = pDcfHandler->DrmTell();
-               if (DrmCurOffset != pDcfHandler->m_DrmCurOffset)
-               {
-                       printf("tc09_DrmFileMgrPositive_FileAPI_01 - DrmCurOffset Comparison failed (SEEK_SET, backward) : origin = %lld, result = %lld, i=%lld\n", DrmCurOffset, pDcfHandler->m_DrmCurOffset, i);
+
+               if (DrmCurOffset != pDcfHandler->m_DrmCurOffset) {
+                       printf("tc09_DrmFileMgrPositive_FileAPI_01 - DrmCurOffset Comparison failed (SEEK_SET, backward) : origin = %lld, result = %lld, i=%lld\n",
+                                  DrmCurOffset, pDcfHandler->m_DrmCurOffset, i);
                        goto CATCH;
                }
        }
-       if (DrmCurOffset != 0)
-       {
-               printf("tc09_DrmFileMgrPositive_FileAPI_01 DrmSeek failed (SEEK_SET, backward), DrmCurOffset = %lld, %x\n", DrmCurOffset, nRet);
+
+       if (DrmCurOffset != 0) {
+               printf("tc09_DrmFileMgrPositive_FileAPI_01 DrmSeek failed (SEEK_SET, backward), DrmCurOffset = %lld, %x\n",
+                          DrmCurOffset, nRet);
                goto CATCH;
        }
 
-       for (i = 0 ; i <= pDcfHandler->m_DrmEndOffset ; i++)
-       {
+       for (i = 0; i <= pDcfHandler->m_DrmEndOffset; i++) {
                nRet = pDcfHandler->DrmSeek(-i, SEEK_END);
-               if (nRet != TADC_SUCCESS)
-               {
-                       printf("tc09_DrmFileMgrPositive_FileAPI_01 DrmSeek failed (SEEK_END, forward) : key=%d, file=%s, i=%lld, %x\n", first_key, pDCF, i, nRet);
+
+               if (nRet != TADC_SUCCESS) {
+                       printf("tc09_DrmFileMgrPositive_FileAPI_01 DrmSeek failed (SEEK_END, forward) : key=%d, file=%s, i=%lld, %x\n",
+                                  first_key, pDCF, i, nRet);
                        goto CATCH;
                }
 
                DrmCurOffset = pDcfHandler->DrmTell();
-               if (DrmCurOffset != pDcfHandler->m_DrmCurOffset)
-               {
-                       printf("tc09_DrmFileMgrPositive_FileAPI_01 - DrmCurOffset Comparison failed (SEEK_END, forward) : origin = %lld, result = %lld, i = %lld\n", DrmCurOffset, pDcfHandler->m_DrmCurOffset, i);
+
+               if (DrmCurOffset != pDcfHandler->m_DrmCurOffset) {
+                       printf("tc09_DrmFileMgrPositive_FileAPI_01 - DrmCurOffset Comparison failed (SEEK_END, forward) : origin = %lld, result = %lld, i = %lld\n",
+                                  DrmCurOffset, pDcfHandler->m_DrmCurOffset, i);
                        goto CATCH;
                }
        }
-       if (DrmCurOffset != 0)
-       {
-               printf("tc09_DrmFileMgrPositive_FileAPI_01 DrmSeek failed (SEEK_END, forward), DrmCurOffset = %lld, %x\n", DrmCurOffset, nRet);
+
+       if (DrmCurOffset != 0) {
+               printf("tc09_DrmFileMgrPositive_FileAPI_01 DrmSeek failed (SEEK_END, forward), DrmCurOffset = %lld, %x\n",
+                          DrmCurOffset, nRet);
                goto CATCH;
        }
 
-       for (i = pDcfHandler->m_DrmEndOffset ; i >= 0 ; i--)
-       {
+       for (i = pDcfHandler->m_DrmEndOffset; i >= 0; i--) {
                nRet = pDcfHandler->DrmSeek(-i, SEEK_END);
-               if (nRet != TADC_SUCCESS)
-               {
-                       printf("tc09_DrmFileMgrPositive_FileAPI_01 DrmSeek failed (SEEK_END, backward) : key=%d, file=%s, i=%lld, %x\n", first_key, pDCF, i, nRet);
+
+               if (nRet != TADC_SUCCESS) {
+                       printf("tc09_DrmFileMgrPositive_FileAPI_01 DrmSeek failed (SEEK_END, backward) : key=%d, file=%s, i=%lld, %x\n",
+                                  first_key, pDCF, i, nRet);
                        goto CATCH;
                }
 
                DrmCurOffset = pDcfHandler->DrmTell();
-               if (DrmCurOffset != pDcfHandler->m_DrmCurOffset)
-               {
-                       printf("tc09_DrmFileMgrPositive_FileAPI_01 - DrmCurOffset Comparison failed (SEEK_END, backward) : origin = %lld, result = %lld, i = %lld\n", DrmCurOffset, pDcfHandler->m_DrmCurOffset, i);
+
+               if (DrmCurOffset != pDcfHandler->m_DrmCurOffset) {
+                       printf("tc09_DrmFileMgrPositive_FileAPI_01 - DrmCurOffset Comparison failed (SEEK_END, backward) : origin = %lld, result = %lld, i = %lld\n",
+                                  DrmCurOffset, pDcfHandler->m_DrmCurOffset, i);
                        goto CATCH;
                }
        }
-       if (DrmCurOffset != pDcfHandler->m_DrmEndOffset)
-       {
-               printf("tc09_DrmFileMgrPositive_FileAPI_01 DrmSeek failed (SEEK_END, backward), DrmCurOffset = %lld, RealEndOffset = %lld, %x\n", DrmCurOffset, pDcfHandler->m_DrmEndOffset, nRet);
+
+       if (DrmCurOffset != pDcfHandler->m_DrmEndOffset) {
+               printf("tc09_DrmFileMgrPositive_FileAPI_01 DrmSeek failed (SEEK_END, backward), DrmCurOffset = %lld, RealEndOffset = %lld, %x\n",
+                          DrmCurOffset, pDcfHandler->m_DrmEndOffset, nRet);
                goto CATCH;
        }
 
-       for (i = 0 ; i < pDcfHandler->m_DrmEndOffset ; i++)
-       {
+       for (i = 0; i < pDcfHandler->m_DrmEndOffset; i++) {
                nRet = pDcfHandler->DrmSeek(-1, SEEK_CUR);
-               if (nRet != TADC_SUCCESS)
-               {
-                       printf("tc09_DrmFileMgrPositive_FileAPI_01 DrmSeek failed (SEEK_CUR, forward) : key=%d, file=%s, i=%lld, %x\n", first_key, pDCF, i, nRet);
+
+               if (nRet != TADC_SUCCESS) {
+                       printf("tc09_DrmFileMgrPositive_FileAPI_01 DrmSeek failed (SEEK_CUR, forward) : key=%d, file=%s, i=%lld, %x\n",
+                                  first_key, pDCF, i, nRet);
                        goto CATCH;
                }
 
                DrmCurOffset = pDcfHandler->DrmTell();
-               if (DrmCurOffset != pDcfHandler->m_DrmCurOffset)
-               {
-                       printf("tc09_DrmFileMgrPositive_FileAPI_01 - DrmCurOffset Comparison failed : origin=%lld, result=%lld\n", DrmCurOffset, pDcfHandler->m_DrmCurOffset);
+
+               if (DrmCurOffset != pDcfHandler->m_DrmCurOffset) {
+                       printf("tc09_DrmFileMgrPositive_FileAPI_01 - DrmCurOffset Comparison failed : origin=%lld, result=%lld\n",
+                                  DrmCurOffset, pDcfHandler->m_DrmCurOffset);
                        goto CATCH;
                }
        }
-       if (DrmCurOffset != 0)
-       {
-               printf("tc09_DrmFileMgrPositive_FileAPI_01 DrmSeek failed (SEEK_CUR, forward), DrmCurOffset = %lld, %x\n", DrmCurOffset, nRet);
+
+       if (DrmCurOffset != 0) {
+               printf("tc09_DrmFileMgrPositive_FileAPI_01 DrmSeek failed (SEEK_CUR, forward), DrmCurOffset = %lld, %x\n",
+                          DrmCurOffset, nRet);
                goto CATCH;
        }
 
-       for (i = 0 ; i < pDcfHandler->m_DrmEndOffset ; i++)
-       {
+       for (i = 0; i < pDcfHandler->m_DrmEndOffset; i++) {
                nRet = pDcfHandler->DrmSeek(1, SEEK_CUR);
-               if (nRet != TADC_SUCCESS)
-               {
-                       printf("tc09_DrmFileMgrPositive_FileAPI_01 DrmSeek failed (SEEK_CUR, backward) : key=%d, file=%s, i=%lld, %x\n", first_key, pDCF, i, nRet);
+
+               if (nRet != TADC_SUCCESS) {
+                       printf("tc09_DrmFileMgrPositive_FileAPI_01 DrmSeek failed (SEEK_CUR, backward) : key=%d, file=%s, i=%lld, %x\n",
+                                  first_key, pDCF, i, nRet);
                        goto CATCH;
                }
 
                DrmCurOffset = pDcfHandler->DrmTell();
-               if (DrmCurOffset != pDcfHandler->m_DrmCurOffset)
-               {
-                       printf("tc09_DrmFileMgrPositive_FileAPI_01 - DrmCurOffset Comparison failed (SEEK_CUR, backward) : origin = %lld, result = %lld, i = %lld\n", DrmCurOffset, pDcfHandler->m_DrmCurOffset, i);
+
+               if (DrmCurOffset != pDcfHandler->m_DrmCurOffset) {
+                       printf("tc09_DrmFileMgrPositive_FileAPI_01 - DrmCurOffset Comparison failed (SEEK_CUR, backward) : origin = %lld, result = %lld, i = %lld\n",
+                                  DrmCurOffset, pDcfHandler->m_DrmCurOffset, i);
                        goto CATCH;
                }
        }
-       if (DrmCurOffset != pDcfHandler->m_DrmEndOffset)
-       {
-               printf("tc09_DrmFileMgrPositive_FileAPI_01 DrmSeek failed (SEEK_CUR, backward), DrmCurOffset = %lld, %x\n", DrmCurOffset, nRet);
+
+       if (DrmCurOffset != pDcfHandler->m_DrmEndOffset) {
+               printf("tc09_DrmFileMgrPositive_FileAPI_01 DrmSeek failed (SEEK_CUR, backward), DrmCurOffset = %lld, %x\n",
+                          DrmCurOffset, nRet);
                goto CATCH;
        }
 
@@ -1320,7 +1369,7 @@ bool tc09_DrmFileMgrPositive_FileAPI_02(void)
        const char *pDCF = TEST_DATA_DIR "/DCF/8SPXfqc6iL.tpk";
        int nRet = TADC_SUCCESS;
 
-       DrmFileMgrpDrmFileMgr = NULL;
+       DrmFileMgr *pDrmFileMgr = NULL;
        DrmFileHandler *pDcfHandler = NULL;
 
        long long originalEndOffset = 705914;
@@ -1333,153 +1382,166 @@ bool tc09_DrmFileMgrPositive_FileAPI_02(void)
        pDrmFileMgr = DrmFileMgr::GetInstance();
 
        nRet = pDrmFileMgr->GetFileHandler(second_key, &pDcfHandler);
-       if (nRet != TADC_SUCCESS)
-       {
-               printf("tc09_DrmFileMgrPositive_FileAPI_02 failed : key = %d, file = %s, %x\n", second_key, pDCF, nRet);
+
+       if (nRet != TADC_SUCCESS) {
+               printf("tc09_DrmFileMgrPositive_FileAPI_02 failed : key = %d, file = %s, %x\n",
+                          second_key, pDCF, nRet);
                goto CATCH;
        }
 
-       if (pDcfHandler->m_OriginEndOffset != originalEndOffset)
-       {
-               printf("tc09_DrmFileMgrPositive_FileAPI_02 - originalEndOffset Comparison failed : origin = %lld, result = %lld\n", originalEndOffset, pDcfHandler->m_OriginEndOffset);
+       if (pDcfHandler->m_OriginEndOffset != originalEndOffset) {
+               printf("tc09_DrmFileMgrPositive_FileAPI_02 - originalEndOffset Comparison failed : origin = %lld, result = %lld\n",
+                          originalEndOffset, pDcfHandler->m_OriginEndOffset);
                goto CATCH;
        }
 
-       if (OriginCurOffset != pDcfHandler->m_OriginCurOffset)
-       {
-               printf("tc09_DrmFileMgrPositive_FileAPI_02 - originalCurOffset Comparison failed : origin = %lld, result = %lld\n", OriginCurOffset, pDcfHandler->m_OriginCurOffset);
+       if (OriginCurOffset != pDcfHandler->m_OriginCurOffset) {
+               printf("tc09_DrmFileMgrPositive_FileAPI_02 - originalCurOffset Comparison failed : origin = %lld, result = %lld\n",
+                          OriginCurOffset, pDcfHandler->m_OriginCurOffset);
                goto CATCH;
        }
 
-       for (i = 0 ; i <= pDcfHandler->m_DrmEndOffset ; i++)
-       {
+       for (i = 0; i <= pDcfHandler->m_DrmEndOffset; i++) {
                nRet = pDcfHandler->DrmSeek(i, SEEK_SET);
-               if (nRet != TADC_SUCCESS)
-               {
-                       printf("tc09_DrmFileMgrPositive_FileAPI_02 DrmSeek failed (SEEK_SET, forward) : key = %d, file = %s, i = %lld, ret = %x\n", second_key, pDCF, i, nRet);
+
+               if (nRet != TADC_SUCCESS) {
+                       printf("tc09_DrmFileMgrPositive_FileAPI_02 DrmSeek failed (SEEK_SET, forward) : key = %d, file = %s, i = %lld, ret = %x\n",
+                                  second_key, pDCF, i, nRet);
                        goto CATCH;
                }
 
                DrmCurOffset = pDcfHandler->DrmTell();
-               if (DrmCurOffset != pDcfHandler->m_DrmCurOffset)
-               {
-                       printf("tc09_DrmFileMgrPositive_FileAPI_02 - DrmCurOffset Comparison failed (SEEK_SET, forward : origin = %lld, result = %lld, i = %lld\n", DrmCurOffset, pDcfHandler->m_DrmCurOffset, i);
+
+               if (DrmCurOffset != pDcfHandler->m_DrmCurOffset) {
+                       printf("tc09_DrmFileMgrPositive_FileAPI_02 - DrmCurOffset Comparison failed (SEEK_SET, forward : origin = %lld, result = %lld, i = %lld\n",
+                                  DrmCurOffset, pDcfHandler->m_DrmCurOffset, i);
                        goto CATCH;
                }
        }
-       if (DrmCurOffset != pDcfHandler->m_DrmEndOffset)
-       {
-               printf("tc09_DrmFileMgrPositive_FileAPI_02 DrmSeek failed (SEEK_SET, forward), DrmCurOffset = %lld, RealEndOffset = %lld, %x\n", DrmCurOffset, pDcfHandler->m_DrmEndOffset, nRet);
+
+       if (DrmCurOffset != pDcfHandler->m_DrmEndOffset) {
+               printf("tc09_DrmFileMgrPositive_FileAPI_02 DrmSeek failed (SEEK_SET, forward), DrmCurOffset = %lld, RealEndOffset = %lld, %x\n",
+                          DrmCurOffset, pDcfHandler->m_DrmEndOffset, nRet);
                goto CATCH;
        }
 
-       for (i = pDcfHandler->m_DrmEndOffset ; i >= 0 ; i--)
-       {
+       for (i = pDcfHandler->m_DrmEndOffset; i >= 0; i--) {
                nRet = pDcfHandler->DrmSeek(i, SEEK_SET);
-               if (nRet != TADC_SUCCESS)
-               {
-                       printf("tc09_DrmFileMgrPositive_FileAPI_02 DrmSeek failed (SEEK_SET, backward) : key=%d, file=%s, i=%lld, %x\n", second_key, pDCF, i, nRet);
+
+               if (nRet != TADC_SUCCESS) {
+                       printf("tc09_DrmFileMgrPositive_FileAPI_02 DrmSeek failed (SEEK_SET, backward) : key=%d, file=%s, i=%lld, %x\n",
+                                  second_key, pDCF, i, nRet);
                        goto CATCH;
                }
 
                DrmCurOffset = pDcfHandler->DrmTell();
-               if (DrmCurOffset != pDcfHandler->m_DrmCurOffset)
-               {
-                       printf("tc09_DrmFileMgrPositive_FileAPI_02 - DrmCurOffset Comparison failed (SEEK_SET, backward) : origin = %lld, result = %lld, i = %lld\n", DrmCurOffset, pDcfHandler->m_DrmCurOffset, i);
+
+               if (DrmCurOffset != pDcfHandler->m_DrmCurOffset) {
+                       printf("tc09_DrmFileMgrPositive_FileAPI_02 - DrmCurOffset Comparison failed (SEEK_SET, backward) : origin = %lld, result = %lld, i = %lld\n",
+                                  DrmCurOffset, pDcfHandler->m_DrmCurOffset, i);
                        goto CATCH;
                }
        }
-       if (DrmCurOffset != 0)
-       {
-               printf("tc09_DrmFileMgrPositive_FileAPI_02 DrmSeek failed (SEEK_SET, backward), DrmCurOffset = %lld, %x\n", DrmCurOffset, nRet);
+
+       if (DrmCurOffset != 0) {
+               printf("tc09_DrmFileMgrPositive_FileAPI_02 DrmSeek failed (SEEK_SET, backward), DrmCurOffset = %lld, %x\n",
+                          DrmCurOffset, nRet);
                goto CATCH;
        }
 
-       for (i = 0 ; i <= pDcfHandler->m_DrmEndOffset ; i++)
-       {
+       for (i = 0; i <= pDcfHandler->m_DrmEndOffset; i++) {
                nRet = pDcfHandler->DrmSeek(-i, SEEK_END);
-               if (nRet != TADC_SUCCESS)
-               {
-                       printf("tc09_DrmFileMgrPositive_FileAPI_02 DrmSeek failed (SEEK_END, forward) : key=%d, file=%s, i=%lld, %x\n", second_key, pDCF, i, nRet);
+
+               if (nRet != TADC_SUCCESS) {
+                       printf("tc09_DrmFileMgrPositive_FileAPI_02 DrmSeek failed (SEEK_END, forward) : key=%d, file=%s, i=%lld, %x\n",
+                                  second_key, pDCF, i, nRet);
                        goto CATCH;
                }
 
                DrmCurOffset = pDcfHandler->DrmTell();
-               if (DrmCurOffset != pDcfHandler->m_DrmCurOffset)
-               {
-                       printf("tc09_DrmFileMgrPositive_FileAPI_02 - DrmCurOffset Comparison failed (SEEK_END, forward) : origin = %lld, result = %lld, i = %lld\n", DrmCurOffset, pDcfHandler->m_DrmCurOffset, i);
+
+               if (DrmCurOffset != pDcfHandler->m_DrmCurOffset) {
+                       printf("tc09_DrmFileMgrPositive_FileAPI_02 - DrmCurOffset Comparison failed (SEEK_END, forward) : origin = %lld, result = %lld, i = %lld\n",
+                                  DrmCurOffset, pDcfHandler->m_DrmCurOffset, i);
                        goto CATCH;
                }
        }
-       if (DrmCurOffset != 0)
-       {
-               printf("tc09_DrmFileMgrPositive_FileAPI_02 DrmSeek failed (SEEK_END, forward), DrmCurOffset = %lld, %x\n", DrmCurOffset, nRet);
+
+       if (DrmCurOffset != 0) {
+               printf("tc09_DrmFileMgrPositive_FileAPI_02 DrmSeek failed (SEEK_END, forward), DrmCurOffset = %lld, %x\n",
+                          DrmCurOffset, nRet);
                goto CATCH;
        }
 
-       for (i = pDcfHandler->m_DrmEndOffset ; i >= 0 ; i--)
-       {
+       for (i = pDcfHandler->m_DrmEndOffset; i >= 0; i--) {
                nRet = pDcfHandler->DrmSeek(-i, SEEK_END);
-               if (nRet != TADC_SUCCESS)
-               {
-                       printf("tc09_DrmFileMgrPositive_FileAPI_02 DrmSeek failed (SEEK_END, backward) : key=%d, file=%s, i=%lld, %x\n", second_key, pDCF, i, nRet);
+
+               if (nRet != TADC_SUCCESS) {
+                       printf("tc09_DrmFileMgrPositive_FileAPI_02 DrmSeek failed (SEEK_END, backward) : key=%d, file=%s, i=%lld, %x\n",
+                                  second_key, pDCF, i, nRet);
                        goto CATCH;
                }
 
                DrmCurOffset = pDcfHandler->DrmTell();
-               if (DrmCurOffset != pDcfHandler->m_DrmCurOffset)
-               {
-                       printf("tc09_DrmFileMgrPositive_FileAPI_02 - DrmCurOffset Comparison failed (SEEK_END, backward) : origin = %lld, result = %lld, i = %lld\n", DrmCurOffset, pDcfHandler->m_DrmCurOffset, i);
+
+               if (DrmCurOffset != pDcfHandler->m_DrmCurOffset) {
+                       printf("tc09_DrmFileMgrPositive_FileAPI_02 - DrmCurOffset Comparison failed (SEEK_END, backward) : origin = %lld, result = %lld, i = %lld\n",
+                                  DrmCurOffset, pDcfHandler->m_DrmCurOffset, i);
                        goto CATCH;
                }
        }
-       if (DrmCurOffset != pDcfHandler->m_DrmEndOffset)
-       {
-               printf("tc09_DrmFileMgrPositive_FileAPI_02 DrmSeek failed (SEEK_END, backward), DrmCurOffset = %lld, RealEndOffset = %lld, %x\n", DrmCurOffset, pDcfHandler->m_DrmEndOffset, nRet);
+
+       if (DrmCurOffset != pDcfHandler->m_DrmEndOffset) {
+               printf("tc09_DrmFileMgrPositive_FileAPI_02 DrmSeek failed (SEEK_END, backward), DrmCurOffset = %lld, RealEndOffset = %lld, %x\n",
+                          DrmCurOffset, pDcfHandler->m_DrmEndOffset, nRet);
                goto CATCH;
        }
 
-       for (i = 0 ; i < pDcfHandler->m_DrmEndOffset ; i++)
-       {
+       for (i = 0; i < pDcfHandler->m_DrmEndOffset; i++) {
                nRet = pDcfHandler->DrmSeek(-1, SEEK_CUR);
-               if (nRet != TADC_SUCCESS)
-               {
-                       printf("tc09_DrmFileMgrPositive_FileAPI_02 DrmSeek failed (SEEK_CUR, forward) : key=%d, file=%s, i=%lld, %x\n", second_key, pDCF, i, nRet);
+
+               if (nRet != TADC_SUCCESS) {
+                       printf("tc09_DrmFileMgrPositive_FileAPI_02 DrmSeek failed (SEEK_CUR, forward) : key=%d, file=%s, i=%lld, %x\n",
+                                  second_key, pDCF, i, nRet);
                        goto CATCH;
                }
 
                DrmCurOffset = pDcfHandler->DrmTell();
-               if (DrmCurOffset != pDcfHandler->m_DrmCurOffset)
-               {
-                       printf("tc09_DrmFileMgrPositive_FileAPI_02 - DrmCurOffset Comparison failed : origin=%lld, result=%lld\n", DrmCurOffset, pDcfHandler->m_DrmCurOffset);
+
+               if (DrmCurOffset != pDcfHandler->m_DrmCurOffset) {
+                       printf("tc09_DrmFileMgrPositive_FileAPI_02 - DrmCurOffset Comparison failed : origin=%lld, result=%lld\n",
+                                  DrmCurOffset, pDcfHandler->m_DrmCurOffset);
                        goto CATCH;
                }
        }
-       if (DrmCurOffset != 0)
-       {
-               printf("tc09_DrmFileMgrPositive_FileAPI_02 DrmSeek failed (SEEK_CUR, forward), DrmCurOffset = %lld, %x\n", DrmCurOffset, nRet);
+
+       if (DrmCurOffset != 0) {
+               printf("tc09_DrmFileMgrPositive_FileAPI_02 DrmSeek failed (SEEK_CUR, forward), DrmCurOffset = %lld, %x\n",
+                          DrmCurOffset, nRet);
                goto CATCH;
        }
 
-       for (i = 0 ; i < pDcfHandler->m_DrmEndOffset ; i++)
-       {
+       for (i = 0; i < pDcfHandler->m_DrmEndOffset; i++) {
                nRet = pDcfHandler->DrmSeek(1, SEEK_CUR);
-               if (nRet != TADC_SUCCESS)
-               {
-                       printf("tc09_DrmFileMgrPositive_FileAPI_02 DrmSeek failed (SEEK_CUR, backward) : key=%d, file=%s, i=%lld, %x\n", second_key, pDCF, i, nRet);
+
+               if (nRet != TADC_SUCCESS) {
+                       printf("tc09_DrmFileMgrPositive_FileAPI_02 DrmSeek failed (SEEK_CUR, backward) : key=%d, file=%s, i=%lld, %x\n",
+                                  second_key, pDCF, i, nRet);
                        goto CATCH;
                }
 
                DrmCurOffset = pDcfHandler->DrmTell();
-               if (DrmCurOffset != pDcfHandler->m_DrmCurOffset)
-               {
-                       printf("tc09_DrmFileMgrPositive_FileAPI_02 - DrmCurOffset Comparison failed (SEEK_CUR, backward) : origin = %lld, result = %lld, i = %lld\n", DrmCurOffset, pDcfHandler->m_DrmCurOffset, i);
+
+               if (DrmCurOffset != pDcfHandler->m_DrmCurOffset) {
+                       printf("tc09_DrmFileMgrPositive_FileAPI_02 - DrmCurOffset Comparison failed (SEEK_CUR, backward) : origin = %lld, result = %lld, i = %lld\n",
+                                  DrmCurOffset, pDcfHandler->m_DrmCurOffset, i);
                        goto CATCH;
                }
        }
-       if (DrmCurOffset != pDcfHandler->m_DrmEndOffset)
-       {
-               printf("tc09_DrmFileMgrPositive_FileAPI_02 DrmSeek failed (SEEK_CUR, backward), DrmCurOffset = %lld, %x\n", DrmCurOffset, nRet);
+
+       if (DrmCurOffset != pDcfHandler->m_DrmEndOffset) {
+               printf("tc09_DrmFileMgrPositive_FileAPI_02 DrmSeek failed (SEEK_CUR, backward), DrmCurOffset = %lld, %x\n",
+                          DrmCurOffset, nRet);
                goto CATCH;
        }
 
@@ -1496,7 +1558,7 @@ bool tc09_DrmFileMgrPositive_FileAPI_03(void)
        const char *pDCF = TEST_DATA_DIR "/DCF/FightGuiIF.tpk";
        int nRet = TADC_SUCCESS;
 
-       DrmFileMgrpDrmFileMgr = NULL;
+       DrmFileMgr *pDrmFileMgr = NULL;
        DrmFileHandler *pDcfHandler = NULL;
 
        long long originalEndOffset = 45194636;
@@ -1509,153 +1571,166 @@ bool tc09_DrmFileMgrPositive_FileAPI_03(void)
        pDrmFileMgr = DrmFileMgr::GetInstance();
 
        nRet = pDrmFileMgr->GetFileHandler(third_key, &pDcfHandler);
-       if (nRet != TADC_SUCCESS)
-       {
-               printf("tc09_DrmFileMgrPositive_FileAPI_03 failed : key = %d, file = %s, %x\n", third_key, pDCF, nRet);
+
+       if (nRet != TADC_SUCCESS) {
+               printf("tc09_DrmFileMgrPositive_FileAPI_03 failed : key = %d, file = %s, %x\n",
+                          third_key, pDCF, nRet);
                goto CATCH;
        }
 
-       if (pDcfHandler->m_OriginEndOffset != originalEndOffset)
-       {
-               printf("tc09_DrmFileMgrPositive_FileAPI_03 - originalEndOffset Comparison failed : origin = %lld, result = %lld\n", originalEndOffset, pDcfHandler->m_OriginEndOffset);
+       if (pDcfHandler->m_OriginEndOffset != originalEndOffset) {
+               printf("tc09_DrmFileMgrPositive_FileAPI_03 - originalEndOffset Comparison failed : origin = %lld, result = %lld\n",
+                          originalEndOffset, pDcfHandler->m_OriginEndOffset);
                goto CATCH;
        }
 
-       if (OriginCurOffset != pDcfHandler->m_OriginCurOffset)
-       {
-               printf("tc09_DrmFileMgrPositive_FileAPI_03 - originalCurOffset Comparison failed : origin = %lld, result = %lld\n", OriginCurOffset, pDcfHandler->m_OriginCurOffset);
+       if (OriginCurOffset != pDcfHandler->m_OriginCurOffset) {
+               printf("tc09_DrmFileMgrPositive_FileAPI_03 - originalCurOffset Comparison failed : origin = %lld, result = %lld\n",
+                          OriginCurOffset, pDcfHandler->m_OriginCurOffset);
                goto CATCH;
        }
 
-       for (i = 0 ; i <= pDcfHandler->m_DrmEndOffset ; i++)
-       {
+       for (i = 0; i <= pDcfHandler->m_DrmEndOffset; i++) {
                nRet = pDcfHandler->DrmSeek(i, SEEK_SET);
-               if (nRet != TADC_SUCCESS)
-               {
-                       printf("tc09_DrmFileMgrPositive_FileAPI_03 DrmSeek failed (SEEK_SET, forward) : key = %d, file = %s, i = %lld, ret = %x\n", third_key, pDCF, i, nRet);
+
+               if (nRet != TADC_SUCCESS) {
+                       printf("tc09_DrmFileMgrPositive_FileAPI_03 DrmSeek failed (SEEK_SET, forward) : key = %d, file = %s, i = %lld, ret = %x\n",
+                                  third_key, pDCF, i, nRet);
                        goto CATCH;
                }
 
                DrmCurOffset = pDcfHandler->DrmTell();
-               if (DrmCurOffset != pDcfHandler->m_DrmCurOffset)
-               {
-                       printf("tc09_DrmFileMgrPositive_FileAPI_03 - DrmCurOffset Comparison failed (SEEK_SET, forward) : origin = %lld, result = %lld, i = %lld\n", DrmCurOffset, pDcfHandler->m_DrmCurOffset, i);
+
+               if (DrmCurOffset != pDcfHandler->m_DrmCurOffset) {
+                       printf("tc09_DrmFileMgrPositive_FileAPI_03 - DrmCurOffset Comparison failed (SEEK_SET, forward) : origin = %lld, result = %lld, i = %lld\n",
+                                  DrmCurOffset, pDcfHandler->m_DrmCurOffset, i);
                        goto CATCH;
                }
        }
-       if (DrmCurOffset != pDcfHandler->m_DrmEndOffset)
-       {
-               printf("tc09_DrmFileMgrPositive_FileAPI_03 DrmSeek failed (SEEK_SET, forward), DrmCurOffset = %lld, RealEndOffset = %lld, %x\n", DrmCurOffset, pDcfHandler->m_DrmEndOffset, nRet);
+
+       if (DrmCurOffset != pDcfHandler->m_DrmEndOffset) {
+               printf("tc09_DrmFileMgrPositive_FileAPI_03 DrmSeek failed (SEEK_SET, forward), DrmCurOffset = %lld, RealEndOffset = %lld, %x\n",
+                          DrmCurOffset, pDcfHandler->m_DrmEndOffset, nRet);
                goto CATCH;
        }
 
-       for (i = pDcfHandler->m_DrmEndOffset ; i >= 0 ; i--)
-       {
+       for (i = pDcfHandler->m_DrmEndOffset; i >= 0; i--) {
                nRet = pDcfHandler->DrmSeek(i, SEEK_SET);
-               if (nRet != TADC_SUCCESS)
-               {
-                       printf("tc09_DrmFileMgrPositive_FileAPI_03 DrmSeek failed (SEEK_SET, backward) : key=%d, file=%s, i=%lld, %x\n", third_key, pDCF, i, nRet);
+
+               if (nRet != TADC_SUCCESS) {
+                       printf("tc09_DrmFileMgrPositive_FileAPI_03 DrmSeek failed (SEEK_SET, backward) : key=%d, file=%s, i=%lld, %x\n",
+                                  third_key, pDCF, i, nRet);
                        goto CATCH;
                }
 
                DrmCurOffset = pDcfHandler->DrmTell();
-               if (DrmCurOffset != pDcfHandler->m_DrmCurOffset)
-               {
-                       printf("tc09_DrmFileMgrPositive_FileAPI_03 - DrmCurOffset Comparison failed (SEEK_SET, backward) : origin = %lld, result = %lld, i = %lld\n", DrmCurOffset, pDcfHandler->m_DrmCurOffset, i);
+
+               if (DrmCurOffset != pDcfHandler->m_DrmCurOffset) {
+                       printf("tc09_DrmFileMgrPositive_FileAPI_03 - DrmCurOffset Comparison failed (SEEK_SET, backward) : origin = %lld, result = %lld, i = %lld\n",
+                                  DrmCurOffset, pDcfHandler->m_DrmCurOffset, i);
                        goto CATCH;
                }
        }
-       if (DrmCurOffset != 0)
-       {
-               printf("tc09_DrmFileMgrPositive_FileAPI_03 DrmSeek failed (SEEK_SET, backward), DrmCurOffset = %lld, %x\n", DrmCurOffset, nRet);
+
+       if (DrmCurOffset != 0) {
+               printf("tc09_DrmFileMgrPositive_FileAPI_03 DrmSeek failed (SEEK_SET, backward), DrmCurOffset = %lld, %x\n",
+                          DrmCurOffset, nRet);
                goto CATCH;
        }
 
-       for (i = 0 ; i <= pDcfHandler->m_DrmEndOffset ; i++)
-       {
+       for (i = 0; i <= pDcfHandler->m_DrmEndOffset; i++) {
                nRet = pDcfHandler->DrmSeek(-i, SEEK_END);
-               if (nRet != TADC_SUCCESS)
-               {
-                       printf("tc09_DrmFileMgrPositive_FileAPI_03 DrmSeek failed (SEEK_END, forward) : key=%d, file=%s, i=%lld, %x\n", third_key, pDCF, i, nRet);
+
+               if (nRet != TADC_SUCCESS) {
+                       printf("tc09_DrmFileMgrPositive_FileAPI_03 DrmSeek failed (SEEK_END, forward) : key=%d, file=%s, i=%lld, %x\n",
+                                  third_key, pDCF, i, nRet);
                        goto CATCH;
                }
 
                DrmCurOffset = pDcfHandler->DrmTell();
-               if (DrmCurOffset != pDcfHandler->m_DrmCurOffset)
-               {
-                       printf("tc09_DrmFileMgrPositive_FileAPI_03 - DrmCurOffset Comparison failed (SEEK_END, forward) : origin = %lld, result = %lld, i = %lld\n", DrmCurOffset, pDcfHandler->m_DrmCurOffset, i);
+
+               if (DrmCurOffset != pDcfHandler->m_DrmCurOffset) {
+                       printf("tc09_DrmFileMgrPositive_FileAPI_03 - DrmCurOffset Comparison failed (SEEK_END, forward) : origin = %lld, result = %lld, i = %lld\n",
+                                  DrmCurOffset, pDcfHandler->m_DrmCurOffset, i);
                        goto CATCH;
                }
        }
-       if (DrmCurOffset != 0)
-       {
-               printf("tc09_DrmFileMgrPositive_FileAPI_03 DrmSeek failed (SEEK_END, forward), DrmCurOffset = %lld, %x\n", DrmCurOffset, nRet);
+
+       if (DrmCurOffset != 0) {
+               printf("tc09_DrmFileMgrPositive_FileAPI_03 DrmSeek failed (SEEK_END, forward), DrmCurOffset = %lld, %x\n",
+                          DrmCurOffset, nRet);
                goto CATCH;
        }
 
-       for (i = pDcfHandler->m_DrmEndOffset ; i >= 0 ; i--)
-       {
+       for (i = pDcfHandler->m_DrmEndOffset; i >= 0; i--) {
                nRet = pDcfHandler->DrmSeek(-i, SEEK_END);
-               if (nRet != TADC_SUCCESS)
-               {
-                       printf("tc09_DrmFileMgrPositive_FileAPI_03 DrmSeek failed (SEEK_END, backward) : key=%d, file=%s, i=%lld, %x\n", third_key, pDCF, i, nRet);
+
+               if (nRet != TADC_SUCCESS) {
+                       printf("tc09_DrmFileMgrPositive_FileAPI_03 DrmSeek failed (SEEK_END, backward) : key=%d, file=%s, i=%lld, %x\n",
+                                  third_key, pDCF, i, nRet);
                        goto CATCH;
                }
 
                DrmCurOffset = pDcfHandler->DrmTell();
-               if (DrmCurOffset != pDcfHandler->m_DrmCurOffset)
-               {
-                       printf("tc09_DrmFileMgrPositive_FileAPI_03 - DrmCurOffset Comparison failed (SEEK_END, backward) : origin = %lld, result = %lld, i = %lld\n", DrmCurOffset, pDcfHandler->m_DrmCurOffset, i);
+
+               if (DrmCurOffset != pDcfHandler->m_DrmCurOffset) {
+                       printf("tc09_DrmFileMgrPositive_FileAPI_03 - DrmCurOffset Comparison failed (SEEK_END, backward) : origin = %lld, result = %lld, i = %lld\n",
+                                  DrmCurOffset, pDcfHandler->m_DrmCurOffset, i);
                        goto CATCH;
                }
        }
-       if (DrmCurOffset != pDcfHandler->m_DrmEndOffset)
-       {
-               printf("tc09_DrmFileMgrPositive_FileAPI_03 DrmSeek failed (SEEK_END, backward), DrmCurOffset = %lld, RealEndOffset = %lld, %x\n", DrmCurOffset, pDcfHandler->m_DrmEndOffset, nRet);
+
+       if (DrmCurOffset != pDcfHandler->m_DrmEndOffset) {
+               printf("tc09_DrmFileMgrPositive_FileAPI_03 DrmSeek failed (SEEK_END, backward), DrmCurOffset = %lld, RealEndOffset = %lld, %x\n",
+                          DrmCurOffset, pDcfHandler->m_DrmEndOffset, nRet);
                goto CATCH;
        }
 
-       for (i = 0 ; i < pDcfHandler->m_DrmEndOffset ; i++)
-       {
+       for (i = 0; i < pDcfHandler->m_DrmEndOffset; i++) {
                nRet = pDcfHandler->DrmSeek(-1, SEEK_CUR);
-               if (nRet != TADC_SUCCESS)
-               {
-                       printf("tc09_DrmFileMgrPositive_FileAPI_03 DrmSeek failed (SEEK_CUR, forward) : key=%d, file=%s, i=%lld, %x\n", third_key, pDCF, i, nRet);
+
+               if (nRet != TADC_SUCCESS) {
+                       printf("tc09_DrmFileMgrPositive_FileAPI_03 DrmSeek failed (SEEK_CUR, forward) : key=%d, file=%s, i=%lld, %x\n",
+                                  third_key, pDCF, i, nRet);
                        goto CATCH;
                }
 
                DrmCurOffset = pDcfHandler->DrmTell();
-               if (DrmCurOffset != pDcfHandler->m_DrmCurOffset)
-               {
-                       printf("tc09_DrmFileMgrPositive_FileAPI_03 - DrmCurOffset Comparison failed : origin=%lld, result=%lld\n", DrmCurOffset, pDcfHandler->m_DrmCurOffset);
+
+               if (DrmCurOffset != pDcfHandler->m_DrmCurOffset) {
+                       printf("tc09_DrmFileMgrPositive_FileAPI_03 - DrmCurOffset Comparison failed : origin=%lld, result=%lld\n",
+                                  DrmCurOffset, pDcfHandler->m_DrmCurOffset);
                        goto CATCH;
                }
        }
-       if (DrmCurOffset != 0)
-       {
-               printf("tc09_DrmFileMgrPositive_FileAPI_03 DrmSeek failed (SEEK_CUR, forward), DrmCurOffset = %lld, %x\n", DrmCurOffset, nRet);
+
+       if (DrmCurOffset != 0) {
+               printf("tc09_DrmFileMgrPositive_FileAPI_03 DrmSeek failed (SEEK_CUR, forward), DrmCurOffset = %lld, %x\n",
+                          DrmCurOffset, nRet);
                goto CATCH;
        }
 
-       for (i = 0 ; i < pDcfHandler->m_DrmEndOffset ; i++)
-       {
+       for (i = 0; i < pDcfHandler->m_DrmEndOffset; i++) {
                nRet = pDcfHandler->DrmSeek(1, SEEK_CUR);
-               if (nRet != TADC_SUCCESS)
-               {
-                       printf("tc09_DrmFileMgrPositive_FileAPI_03 DrmSeek failed (SEEK_CUR, backward) : key=%d, file=%s, i=%lld, %x\n", third_key, pDCF, i, nRet);
+
+               if (nRet != TADC_SUCCESS) {
+                       printf("tc09_DrmFileMgrPositive_FileAPI_03 DrmSeek failed (SEEK_CUR, backward) : key=%d, file=%s, i=%lld, %x\n",
+                                  third_key, pDCF, i, nRet);
                        goto CATCH;
                }
 
                DrmCurOffset = pDcfHandler->DrmTell();
-               if (DrmCurOffset != pDcfHandler->m_DrmCurOffset)
-               {
-                       printf("tc09_DrmFileMgrPositive_FileAPI_03 - DrmCurOffset Comparison failed (SEEK_CUR, backward) : origin = %lld, result = %lld, i = %lld\n", DrmCurOffset, pDcfHandler->m_DrmCurOffset, i);
+
+               if (DrmCurOffset != pDcfHandler->m_DrmCurOffset) {
+                       printf("tc09_DrmFileMgrPositive_FileAPI_03 - DrmCurOffset Comparison failed (SEEK_CUR, backward) : origin = %lld, result = %lld, i = %lld\n",
+                                  DrmCurOffset, pDcfHandler->m_DrmCurOffset, i);
                        goto CATCH;
                }
        }
-       if (DrmCurOffset != pDcfHandler->m_DrmEndOffset)
-       {
-               printf("tc09_DrmFileMgrPositive_FileAPI_03 DrmSeek failed (SEEK_CUR, backward), DrmCurOffset = %lld, %x\n", DrmCurOffset, nRet);
+
+       if (DrmCurOffset != pDcfHandler->m_DrmEndOffset) {
+               printf("tc09_DrmFileMgrPositive_FileAPI_03 DrmSeek failed (SEEK_CUR, backward), DrmCurOffset = %lld, %x\n",
+                          DrmCurOffset, nRet);
                goto CATCH;
        }
 
@@ -1671,7 +1746,7 @@ bool tc10_DrmFileMgrPositive_CloseFileHandler_01(void)
 {
        int nRet = TADC_SUCCESS;
 
-       DrmFileMgrpDrmFileMgr = NULL;
+       DrmFileMgr *pDrmFileMgr = NULL;
        DrmFileHandler *pDcfHandler = NULL;
 
        printf("tc10_DrmFileMgrPositive_CloseFileHandler_01 -------- Started! \n");
@@ -1679,23 +1754,26 @@ bool tc10_DrmFileMgrPositive_CloseFileHandler_01(void)
        pDrmFileMgr = DrmFileMgr::GetInstance();
 
        nRet = pDrmFileMgr->GetFileHandler(first_key, &pDcfHandler);
-       if (nRet != TADC_SUCCESS)
-       {
-               printf("tc10_DrmFileMgrPositive_CloseFileHandler_01 failed : key = %d, ret=%x\n", first_key, nRet);
+
+       if (nRet != TADC_SUCCESS) {
+               printf("tc10_DrmFileMgrPositive_CloseFileHandler_01 failed : key = %d, ret=%x\n",
+                          first_key, nRet);
                goto CATCH;
        }
 
        nRet = pDrmFileMgr->CloseFileHandler(first_key);
-       if (nRet != TADC_SUCCESS)
-       {
-               printf("tc10_DrmFileMgrPositive_CloseFileHandler_01 failed : key = %d, ret=%x\n", first_key, nRet);
+
+       if (nRet != TADC_SUCCESS) {
+               printf("tc10_DrmFileMgrPositive_CloseFileHandler_01 failed : key = %d, ret=%x\n",
+                          first_key, nRet);
                goto CATCH;
        }
 
        nRet = pDrmFileMgr->GetFileHandler(first_key, &pDcfHandler);
-       if (nRet == TADC_SUCCESS)
-       {
-               printf("tc10_DrmFileMgrPositive_CloseFileHandler_01 failed : key = %d\n", first_key);
+
+       if (nRet == TADC_SUCCESS) {
+               printf("tc10_DrmFileMgrPositive_CloseFileHandler_01 failed : key = %d\n",
+                          first_key);
                goto CATCH;
        }
 
@@ -1711,7 +1789,7 @@ bool tc10_DrmFileMgrPositive_CloseFileHandler_02(void)
 {
        int nRet = TADC_SUCCESS;
 
-       DrmFileMgrpDrmFileMgr = NULL;
+       DrmFileMgr *pDrmFileMgr = NULL;
        DrmFileHandler *pDcfHandler = NULL;
 
        printf("tc10_DrmFileMgrPositive_CloseFileHandler_02 -------- Started! \n");
@@ -1719,23 +1797,26 @@ bool tc10_DrmFileMgrPositive_CloseFileHandler_02(void)
        pDrmFileMgr = DrmFileMgr::GetInstance();
 
        nRet = pDrmFileMgr->GetFileHandler(second_key, &pDcfHandler);
-       if (nRet != TADC_SUCCESS)
-       {
-               printf("tc10_DrmFileMgrPositive_CloseFileHandler_02 failed : key = %d, ret=%x\n", second_key, nRet);
+
+       if (nRet != TADC_SUCCESS) {
+               printf("tc10_DrmFileMgrPositive_CloseFileHandler_02 failed : key = %d, ret=%x\n",
+                          second_key, nRet);
                goto CATCH;
        }
 
        nRet = pDrmFileMgr->CloseFileHandler(second_key);
-       if (nRet != TADC_SUCCESS)
-       {
-               printf("tc10_DrmFileMgrPositive_CloseFileHandler_02 failed : key = %d, ret=%x\n", second_key, nRet);
+
+       if (nRet != TADC_SUCCESS) {
+               printf("tc10_DrmFileMgrPositive_CloseFileHandler_02 failed : key = %d, ret=%x\n",
+                          second_key, nRet);
                goto CATCH;
        }
 
        nRet = pDrmFileMgr->GetFileHandler(second_key, &pDcfHandler);
-       if (nRet == TADC_SUCCESS)
-       {
-               printf("tc10_DrmFileMgrPositive_CloseFileHandler_02 failed : key = %d\n", second_key);
+
+       if (nRet == TADC_SUCCESS) {
+               printf("tc10_DrmFileMgrPositive_CloseFileHandler_02 failed : key = %d\n",
+                          second_key);
                goto CATCH;
        }
 
@@ -1751,7 +1832,7 @@ bool tc10_DrmFileMgrPositive_CloseFileHandler_03(void)
 {
        int nRet = TADC_SUCCESS;
 
-       DrmFileMgrpDrmFileMgr = NULL;
+       DrmFileMgr *pDrmFileMgr = NULL;
        DrmFileHandler *pDcfHandler = NULL;
 
        printf("tc10_DrmFileMgrPositive_CloseFileHandler_03 -------- Started! \n");
@@ -1759,23 +1840,26 @@ bool tc10_DrmFileMgrPositive_CloseFileHandler_03(void)
        pDrmFileMgr = DrmFileMgr::GetInstance();
 
        nRet = pDrmFileMgr->GetFileHandler(third_key, &pDcfHandler);
-       if (nRet != TADC_SUCCESS)
-       {
-               printf("tc10_DrmFileMgrPositive_CloseFileHandler_03 failed : key = %d, ret=%x\n", third_key, nRet);
+
+       if (nRet != TADC_SUCCESS) {
+               printf("tc10_DrmFileMgrPositive_CloseFileHandler_03 failed : key = %d, ret=%x\n",
+                          third_key, nRet);
                goto CATCH;
        }
 
        nRet = pDrmFileMgr->CloseFileHandler(third_key);
-       if (nRet != TADC_SUCCESS)
-       {
-               printf("tc10_DrmFileMgrPositive_CloseFileHandler_03 failed : key = %d, ret=%x\n", third_key, nRet);
+
+       if (nRet != TADC_SUCCESS) {
+               printf("tc10_DrmFileMgrPositive_CloseFileHandler_03 failed : key = %d, ret=%x\n",
+                          third_key, nRet);
                goto CATCH;
        }
 
        nRet = pDrmFileMgr->GetFileHandler(third_key, &pDcfHandler);
-       if (nRet == TADC_SUCCESS)
-       {
-               printf("tc10_DrmFileMgrPositive_CloseFileHandler_03 failed : key = %d\n", third_key);
+
+       if (nRet == TADC_SUCCESS) {
+               printf("tc10_DrmFileMgrPositive_CloseFileHandler_03 failed : key = %d\n",
+                          third_key);
                goto CATCH;
        }
 
@@ -1789,19 +1873,19 @@ CATCH:
 
 bool tc11_GetDeviceId_01(void)
 {
-       unsigned char DUID[33] = {0,};
+       unsigned char DUID[33] = {0, };
        int nRet = 0;
 
        printf("tc11_GetDeviceID_01() -------- Started! \n");
 
-       nRet = TADC_IF_GetDUID((char*)DUID);
-       if (nRet !=TADC_SUCCESS)
-       {
+       nRet = TADC_IF_GetDUID((char *)DUID);
+
+       if (nRet != TADC_SUCCESS) {
                printf("tc11_GetDeviceID_01() failed.");
                return false;
        }
 
-       printf("DUID=%s\n", (char*)DUID);
+       printf("DUID=%s\n", (char *)DUID);
        printf("tc11_GetDeviceID_01() finished! -------- success \n");
 
        return true;
@@ -1809,18 +1893,19 @@ bool tc11_GetDeviceId_01(void)
 
 bool tc12_TADC_SetDeviceInfo_01(void)
 {
-       int     nRet = TADC_SUCCESS;
-       T_DEVICE_INFO   t_DeviceInfo;
+       int nRet = TADC_SUCCESS;
+       T_DEVICE_INFO   t_DeviceInfo;
 
        printf("tc12_TADC_SetDeviceInfo_01() -------- Started! \n");
 
        nRet = TADC_SetDeviceInfo(&t_DeviceInfo);
-       if (nRet != TADC_SUCCESS)
-       {
+
+       if (nRet != TADC_SUCCESS) {
                printf("tc12_TADC_SetDeviceInfo_01() failed.\n");
                return false;
        }
-       printf("DUID=%s\n", (char*)t_DeviceInfo.DUID);
+
+       printf("DUID=%s\n", (char *)t_DeviceInfo.DUID);
        printf("tc12_TADC_SetDeviceInfo_01() finished! -------- success \n");
 
        return true;
@@ -1835,6 +1920,7 @@ bool tc13_DTappsInstallLicense_01(void)
        auto buf = _read_ro_file(pFirstRo);
 
        int nRet = DTappsInstallLicense(reinterpret_cast<char *>(buf.data()));
+
        if (nRet != TADC_SUCCESS) {
                printf("tc13_DTappsInstallLicense_01() failed. nRet=%d\n", nRet);
                return false;
@@ -1853,6 +1939,7 @@ bool tc13_DTappsInstallLicense_02(void)
        auto buf = _read_ro_file(pFirstRo);
 
        int nRet = DTappsInstallLicense(reinterpret_cast<char *>(buf.data()));
+
        if (nRet != TADC_SUCCESS) {
                printf("tc13_DTappsInstallLicense_02() failed. nRet=%d\n", nRet);
                return false;
@@ -1871,6 +1958,7 @@ bool tc13_DTappsInstallLicense_03(void)
        auto buf = _read_ro_file(pFirstRo);
 
        int nRet = DTappsInstallLicense(reinterpret_cast<char *>(buf.data()));
+
        if (nRet != TADC_SUCCESS) {
                printf("tc13_DTappsInstallLicense_03() failed. nRet=%d\n", nRet);
                return false;
@@ -1883,454 +1971,490 @@ bool tc13_DTappsInstallLicense_03(void)
 bool
 tc_local_01_drm_tizen_generate_license_request_p(void)
 {
-    bool res = true;
-    int ret_value = DRMTEST_SUCCESS;
-
-    char *purchase_response = NULL;
-    char *req_id = NULL;
-    unsigned int  req_buff_len = 1024*5;
-    char req_buff[req_buff_len] = {0, };
-    unsigned int  url_buff_len = 1024;
-    char url_buff[url_buff_len] = {0, };
-
-    printf("[%s] test started\n", __func__);
-    ret_value = generate_purchase_response(&purchase_response, &req_id);
-    if(ret_value != DRMTEST_SUCCESS) {
-        res = false;
-        goto CATCH;
-    }
-    printf("...purchase_response:\n%s\n", purchase_response);
-
-    ret_value = drm_tizen_generate_license_request(purchase_response, strlen(purchase_response),
-                                             req_buff, &req_buff_len, url_buff, &url_buff_len);
-    if(ret_value != TADC_SUCCESS) {
-        printf("...drm_tizen_generate_license_request failed. ret=%d\n", ret_value);
-        res = false;
-        goto CATCH;
-    }
-    printf("...license_request_url:%s\n", url_buff);
-    printf("...license_request:\n%s\n", req_buff);
-
-    printf("[%s] test ended: result=%d\n", __func__, ret_value);
+       bool res = true;
+       int ret_value = DRMTEST_SUCCESS;
 
-CATCH:
-    if(purchase_response != NULL)
-        free(purchase_response);
-    if(req_id != NULL)
-        free(req_id);
+       char *purchase_response = NULL;
+       char *req_id = NULL;
+       unsigned int  req_buff_len = 1024 * 5;
+       char req_buff[req_buff_len] = {0, };
+       unsigned int  url_buff_len = 1024;
+       char url_buff[url_buff_len] = {0, };
 
-    return res;
-}
+       printf("[%s] test started\n", __func__);
+       ret_value = generate_purchase_response(&purchase_response, &req_id);
 
-bool
-tc_local_01_drm_tizen_full_test_p(void)
-{
-    bool res = true;
-    int ret_value = DRMTEST_SUCCESS;
-
-    char *purchase_response = NULL;
-    char *req_id = NULL;
-    unsigned int  req_buff_len = 1024*5;
-    char req_buff[req_buff_len] = {0, };
-    unsigned int  url_buff_len = 1024;
-    char url_buff[url_buff_len] = {0, };
-
-    char* ro_request_buff = NULL;
-    char* ro_response_buff = NULL;
-    char* dh_key_p = NULL;
-    char* dh_key_g = NULL;
-    char* dh_key_a = NULL;
-
-    unsigned char duid[33] = {0,};
-    const char* cid = "38EIfBurLJ-1.0.2";
-    const char* ro_template_path = TEST_DATA_DIR "/RO/38EIfBurLJ-1.0.2.ro_template";
-
-    const char* encrypted_file_path = TEST_DATA_DIR "/DCF/38EIfBurLJ.tpk";
-    const char* plaintext_file_path = TEST_DATA_DIR "/DecryptedApp/38EIfBurLJ_dec.tpk";
-    const char* decrypted_file_path = "/tmp/38EIfBurLJ.tpk";
-
-    int identical = DRMTEST_NOTIDENTICAL;
-
-    printf("[%s] test started\n", __func__);
-
-    if(ret_value != DRMTEST_SUCCESS) {
-        res = false;
-        goto CATCH;
-    }
-
-    ret_value = generate_purchase_response(&purchase_response, &req_id);
-    if(ret_value != DRMTEST_SUCCESS) {
-        res = false;
-        goto CATCH;
-    }
-    //printf("...purchase_response:\n%s\n", purchase_response);
-
-    ret_value = drm_tizen_generate_license_request(purchase_response, strlen(purchase_response),
-                                             req_buff, &req_buff_len, url_buff, &url_buff_len);
-    if(ret_value != TADC_SUCCESS) {
-        printf("...drm_tizen_generate_license_request failed. ret=%d\n", ret_value);
-        res = false;
-        goto CATCH;
-    }
-    printf("...license_request_url:%s\n", url_buff);
-    printf("...license_request:\n%s\n", req_buff);
-
-    ret_value = get_dh_key_from_ro_request(req_buff, &dh_key_p, &dh_key_g, &dh_key_a);
-    if(ret_value != DRMTEST_SUCCESS) {
-        res = false;
-        goto CATCH;
-    }
-    //printf("...DH key: p=%s, g=%s, a=%s\n", dh_key_p, dh_key_g, dh_key_a);
-
-    ret_value = TADC_IF_GetDUID((char*)duid);
-    if (ret_value != TADC_SUCCESS) {
-        return false;
-    }
-    printf("duid=%s\n", (char*)duid);
-
-    ret_value = generate_right_object_response(dh_key_p, dh_key_g, dh_key_a, req_id,
-                                               cid, ro_template_path, (const char*)duid, &ro_response_buff);
-    if(ret_value != DRMTEST_SUCCESS) {
-        res = false;
-        goto CATCH;
-    }
-    printf("...right_object_response:\n%s\n", ro_response_buff);
-
-    ret_value = drm_tizen_register_license(ro_response_buff, strlen(ro_response_buff));
-    if(ret_value != TADC_SUCCESS) {
-        printf("...drm_tizen_register_license failed. ret=%d\n", ret_value);
-        res = false;
-        goto CATCH;
-    }
-    printf("...drm_tizen_register_license: succeeded\n");
-
-    ret_value = drm_tizen_decrypt_package(encrypted_file_path, strlen(encrypted_file_path),
-                                          decrypted_file_path, strlen(decrypted_file_path));
-    if(ret_value != TADC_SUCCESS) {
-        printf("...drm_tizen_decrypt_package failed. ret=%d\n", ret_value);
-        res = false;
-        goto CATCH;
-    }
-    printf("...drm_tizen_decrypt_package: succeeded\n");
-
-    ret_value = is_identical_files(plaintext_file_path, decrypted_file_path, &identical);
-    if(ret_value != DRMTEST_SUCCESS) {
-        printf("...is_identical_files failed. ret=%d\n", ret_value);
-        res = false;
-        goto CATCH;
-    }
-    if(identical != DRMTEST_IDENTICAL) {
-        printf("...the decrypted file is not same with a original plaintext file .\n");
-        res = false;
-        goto CATCH;
-    }
-    printf("...drm_tizen_decrypt_package: succeeded : the decrypted file is with a original plaintext file.\n");
+       if (ret_value != DRMTEST_SUCCESS) {
+               res = false;
+               goto CATCH;
+       }
+
+       printf("...purchase_response:\n%s\n", purchase_response);
+
+       ret_value = drm_tizen_generate_license_request(purchase_response,
+                               strlen(purchase_response),
+                               req_buff, &req_buff_len, url_buff, &url_buff_len);
+
+       if (ret_value != TADC_SUCCESS) {
+               printf("...drm_tizen_generate_license_request failed. ret=%d\n", ret_value);
+               res = false;
+               goto CATCH;
+       }
+
+       printf("...license_request_url:%s\n", url_buff);
+       printf("...license_request:\n%s\n", req_buff);
+
+       printf("[%s] test ended: result=%d\n", __func__, ret_value);
 
 CATCH:
-    if(purchase_response != NULL)
-        free(purchase_response);
-    if(req_id != NULL)
-        free(req_id);
-    if(ro_request_buff != NULL)
-        free(ro_request_buff);
-    if(ro_response_buff != NULL)
-        free(ro_response_buff);
-
-    return res;
-}
 
+       if (purchase_response != NULL)
+               free(purchase_response);
 
-/*
-bool tc15_DrmTdcDecryptPackge_01(void)
-{
-       int     nRet = TADC_SUCCESS;
+       if (req_id != NULL)
+               free(req_id);
 
+       return res;
 }
-*/
-#endif
 
-int main(int, char *[])
+bool
+tc_local_01_drm_tizen_full_test_p(void)
 {
-       printf(" ---------- Test Tizen DRM core --- Start ....\n");
-       test_drm_core();
-       printf(" ---------- Test Tizen DRM core ---  End  ....\n");
+       bool res = true;
+       int ret_value = DRMTEST_SUCCESS;
 
-#if 1
-       printf(" ---------- Test Tizen DRM v2.0.1 APIs   ---  Start ....    \n");
+       char *purchase_response = NULL;
+       char *req_id = NULL;
+       unsigned int  req_buff_len = 1024 * 5;
+       char req_buff[req_buff_len] = {0, };
+       unsigned int  url_buff_len = 1024;
+       char url_buff[url_buff_len] = {0, };
 
-       int bRet = TADC_SUCCESS;
+       char *ro_request_buff = NULL;
+       char *ro_response_buff = NULL;
+       char *dh_key_p = NULL;
+       char *dh_key_g = NULL;
+       char *dh_key_a = NULL;
 
-       char ReqBuf[1024*5] = {0, };
-       unsigned int ReqBufLen = 0;
+       unsigned char duid[33] = {0, };
+       const char *cid = "38EIfBurLJ-1.0.2";
+       const char *ro_template_path = TEST_DATA_DIR "/RO/38EIfBurLJ-1.0.2.ro_template";
 
-       char RespBuf[1024*10] = {0, };
-       unsigned int RespBufLen = 0;
+       const char *encrypted_file_path = TEST_DATA_DIR "/DCF/38EIfBurLJ.tpk";
+       const char *plaintext_file_path = TEST_DATA_DIR
+                                                                         "/DecryptedApp/38EIfBurLJ_dec.tpk";
+       const char *decrypted_file_path = "/tmp/38EIfBurLJ.tpk";
 
-//     char DecLicenseBuf[1024*10] = {0, };
-//     unsigned int DecLicenseBufLen = 0;
+       int identical = DRMTEST_NOTIDENTICAL;
 
-       char LicenseUrl[1024] = {0, };
-       unsigned int LicenseUrlLen = 0;
+       printf("[%s] test started\n", __func__);
 
-       //2011.03.08
-       //DrmTdcFileHeader TDCFileHeader;
-//     char cid[1024] = {0, };
-//     char riurl[1024] = {0, };
+       if (ret_value != DRMTEST_SUCCESS) {
+               res = false;
+               goto CATCH;
+       }
 
-       char testFileName[256] = {0, };
-       char tempBuf[256] = {0, };
+       ret_value = generate_purchase_response(&purchase_response, &req_id);
 
-       bool isOk = false;
+       if (ret_value != DRMTEST_SUCCESS) {
+               res = false;
+               goto CATCH;
+       }
 
-       //----------------------------------------------------------------------------------------------------
-       // 0. Static TC running
-       //----------------------------------------------------------------------------------------------------
+       //printf("...purchase_response:\n%s\n", purchase_response);
 
-       printf("\n0. Static TC  Start  ----------------------------------------\n");
-/*
-       isOk = tc01_VerifyRoSignature_Positive_01();
-       if (isOk != true)
-       {
-               printf("tc01_VerifyRoSignature_Positive_01 failed!\n");
-       }
+       ret_value = drm_tizen_generate_license_request(purchase_response,
+                               strlen(purchase_response),
+                               req_buff, &req_buff_len, url_buff, &url_buff_len);
 
-       isOk = tc01_VerifyRoSignature_Positive_02();
-       if (isOk != true)
-       {
-               printf("tc01_VerifyRoSignature_Positive_02 failed!\n");
+       if (ret_value != TADC_SUCCESS) {
+               printf("...drm_tizen_generate_license_request failed. ret=%d\n", ret_value);
+               res = false;
+               goto CATCH;
        }
 
-       isOk = tc01_VerifyRoSignature_Positive_03();
-       if (isOk != true)
-       {
-               printf("tc01_VerifyRoSignature_Positive_03 failed!\n");
-       }
+       printf("...license_request_url:%s\n", url_buff);
+       printf("...license_request:\n%s\n", req_buff);
 
-       isOk = tc02_VerifyRoSignature_Negative_Cert_01();
-       if (isOk != true)
-       {
-               printf("tc02_VerifyRoSignature_Negative_Cert_01 failed!\n");
-       }
+       ret_value = get_dh_key_from_ro_request(req_buff, &dh_key_p, &dh_key_g,
+                                                                                  &dh_key_a);
 
-       isOk = tc02_VerifyRoSignature_Negative_Cert_02();
-       if (isOk != true)
-       {
-               printf("tc02_VerifyRoSignature_Negative_Cert_02 failed!\n");
+       if (ret_value != DRMTEST_SUCCESS) {
+               res = false;
+               goto CATCH;
        }
 
-       isOk = tc02_VerifyRoSignature_Negative_Cert_03();
-       if (isOk != true)
-       {
-               printf("tc02_VerifyRoSignature_Negative_Cert_03 failed!\n");
-       }
+       //printf("...DH key: p=%s, g=%s, a=%s\n", dh_key_p, dh_key_g, dh_key_a);
 
-       isOk = tc03_VerifyRoSignature_Negative_Signature_01();
-       if (isOk != true)
-       {
-               printf("tc03_VerifyRoSignature_Negative_Signature_01 failed!\n");
-       }
+       ret_value = TADC_IF_GetDUID((char *)duid);
 
-       isOk = tc03_VerifyRoSignature_Negative_Signature_02();
-       if (isOk != true)
-       {
-               printf("tc03_VerifyRoSignature_Negative_Signature_02 failed!\n");
+       if (ret_value != TADC_SUCCESS) {
+               return false;
        }
 
-       isOk = tc03_VerifyRoSignature_Negative_Signature_03();
-       if (isOk != true)
-       {
-               printf("tc03_VerifyRoSignature_Negative_Signature_03 failed!\n");
-       }
+       printf("duid=%s\n", (char *)duid);
 
-       isOk = tc04_isDrmFile_Positive_01();
-       if (isOk != true)
-       {
-               printf("tc04_isDrmFile_Positive_01 failed!\n");
-       }
+       ret_value = generate_right_object_response(dh_key_p, dh_key_g, dh_key_a, req_id,
+                               cid, ro_template_path, (const char *)duid, &ro_response_buff);
 
-       isOk = tc04_isDrmFile_Positive_02();
-       if (isOk != true)
-       {
-               printf("tc04_isDrmFile_Positive_02 failed!\n");
+       if (ret_value != DRMTEST_SUCCESS) {
+               res = false;
+               goto CATCH;
        }
 
-       isOk = tc04_isDrmFile_Positive_03();
-       if (isOk != true)
-       {
-               printf("tc04_isDrmFile_Positive_03 failed!\n");
-       }
+       printf("...right_object_response:\n%s\n", ro_response_buff);
 
-       isOk = tc05_isDrmFile_Negative_01();
-       if (isOk != true)
-       {
-               printf("tc05_isDrmFile_Negative_01 failed!\n");
-       }
+       ret_value = drm_tizen_register_license(ro_response_buff,
+                                                                                  strlen(ro_response_buff));
 
-       isOk = tc05_isDrmFile_Negative_02();
-       if (isOk != true)
-       {
-               printf("tc05_isDrmFile_Negative_02 failed!\n");
+       if (ret_value != TADC_SUCCESS) {
+               printf("...drm_tizen_register_license failed. ret=%d\n", ret_value);
+               res = false;
+               goto CATCH;
        }
 
-       isOk = tc05_isDrmFile_Negative_03();
-       if (isOk != true)
-       {
-               printf("tc05_isDrmFile_Negative_03 failed!\n");
-       }
+       printf("...drm_tizen_register_license: succeeded\n");
 
-       isOk = tc13_DTappsInstallLicense_01();
-       if (isOk != true)
-       {
-               printf("tc13_DTappsInstallLicense_01 failed!\n");
-       }
+       ret_value = drm_tizen_decrypt_package(encrypted_file_path,
+                                                                                 strlen(encrypted_file_path),
+                                                                                 decrypted_file_path, strlen(decrypted_file_path));
 
-       isOk = tc13_DTappsInstallLicense_02();
-       if (isOk != true)
-       {
-               printf("tc13_DTappsInstallLicense_02 failed!\n");
+       if (ret_value != TADC_SUCCESS) {
+               printf("...drm_tizen_decrypt_package failed. ret=%d\n", ret_value);
+               res = false;
+               goto CATCH;
        }
 
-       isOk = tc13_DTappsInstallLicense_03();
-       if (isOk != true)
-       {
-               printf("tc13_DTappsInstallLicense_03 failed!\n");
-       }
+       printf("...drm_tizen_decrypt_package: succeeded\n");
 
-       isOk = tc06_DrmFileHandlerPositive_01();
-       if (isOk != true)
-       {
-               printf("tc06_DrmFileHandlerPositive_01 failed!\n");
-       }
+       ret_value = is_identical_files(plaintext_file_path, decrypted_file_path,
+                                                                  &identical);
 
-       isOk = tc06_DrmFileHandlerPositive_02();
-       if (isOk != true)
-       {
-               printf("tc06_DrmFileHandlerPositive_02 failed!\n");
+       if (ret_value != DRMTEST_SUCCESS) {
+               printf("...is_identical_files failed. ret=%d\n", ret_value);
+               res = false;
+               goto CATCH;
        }
 
-       isOk = tc06_DrmFileHandlerPositive_03();
-       if (isOk != true)
-       {
-               printf("tc06_DrmFileHandlerPositive_03 failed!\n");
+       if (identical != DRMTEST_IDENTICAL) {
+               printf("...the decrypted file is not same with a original plaintext file .\n");
+               res = false;
+               goto CATCH;
        }
 
-       isOk = tc07_DrmFileMgrPositive_01();
-       if (isOk != true)
-       {
-               printf("tc07_DrmFileMgrPositive_01 failed!\b");
-       }
+       printf("...drm_tizen_decrypt_package: succeeded : the decrypted file is with a original plaintext file.\n");
 
-       isOk = tc07_DrmFileMgrPositive_02();
-       if (isOk != true)
-       {
-               printf("tc07_DrmFileMgrPositive_02 failed!\n");
-       }
+CATCH:
 
-       isOk = tc07_DrmFileMgrPositive_03();
-       if (isOk != true)
-       {
-               printf("tc07_DrmFileMgrPositive_03 failed!\n");
-       }
+       if (purchase_response != NULL)
+               free(purchase_response);
 
-       isOk = tc08_DrmFileMgrPositive_GetFileHandler_01();
-       if (isOk != true)
-       {
-               printf("tc08_DrmFileMgrPositive_GetFileHandler_01 failed!\n");
-       }
+       if (req_id != NULL)
+               free(req_id);
 
-       isOk = tc08_DrmFileMgrPositive_GetFileHandler_02();
-       if (isOk != true)
-       {
-               printf("tc08_DrmFileMgrPositive_GetFileHandler_02 failed!\n");
-       }
+       if (ro_request_buff != NULL)
+               free(ro_request_buff);
 
-       isOk = tc08_DrmFileMgrPositive_GetFileHandler_03();
-       if (isOk != true)
-       {
-               printf("tc08_DrmFileMgrPositive_GetFileHandler_03 failed!\n");
-       }
+       if (ro_response_buff != NULL)
+               free(ro_response_buff);
 
-       isOk = tc09_DrmFileMgrPositive_FileAPI_01();
-       if (isOk != true)
-       {
-               printf("tc09_DrmFileMgrPositive_FileAPI_01 failed!\n");
-       }
+       return res;
+}
 
-       isOk = tc09_DrmFileMgrPositive_FileAPI_02();
-       if (isOk != true)
-       {
-               printf("tc09_DrmFileMgrPositive_FileAPI_02 failed!\n");
-       }
 
-       isOk = tc09_DrmFileMgrPositive_FileAPI_03();
-       if (isOk != true)
-       {
-               printf("tc09_DrmFileMgrPositive_FileAPI_03 failed!\n");
-       }
+/*
+bool tc15_DrmTdcDecryptPackge_01(void)
+{
+    int nRet = TADC_SUCCESS;
 
-       isOk = tc10_DrmFileMgrPositive_CloseFileHandler_01();
-       if (isOk != true)
-       {
-               printf("tc10_DrmFileMgrPositive_CloseFileHandler_01 failed!\n");
-       }
+}
+*/
+#endif
 
-       isOk = tc10_DrmFileMgrPositive_CloseFileHandler_02();
-       if (isOk != true)
-       {
-               printf("tc10_DrmFileMgrPositive_CloseFileHandler_02 failed!\n");
-       }
+int main(int, char *[])
+{
+       printf(" ---------- Test Tizen DRM core --- Start ....\n");
+       test_drm_core();
+       printf(" ---------- Test Tizen DRM core ---  End  ....\n");
 
-       isOk = tc10_DrmFileMgrPositive_CloseFileHandler_03();
-       if (isOk != true)
-       {
-               printf("tc10_DrmFileMgrPositive_CloseFileHandler_03 failed!\n");
-       }
+#if 1
+       printf(" ---------- Test Tizen DRM v2.0.1 APIs   ---  Start ....    \n");
 
-       isOk = tc11_GetDeviceId_01();
-       if (isOk != true)
-       {
-               printf("tc11_GetDeviceId_01 failed!\n");
-       }
+       int bRet = TADC_SUCCESS;
 
-       isOk = tc12_TADC_SetDeviceInfo_01();
-       if (isOk != true)
-       {
-               printf("tc12_TADC_SetDeviceInfo_01 failed!\n");
-       }
+       char ReqBuf[1024 * 5] = {0, };
+       unsigned int ReqBufLen = 0;
+
+       char RespBuf[1024 * 10] = {0, };
+       unsigned int RespBufLen = 0;
+
+       //  char DecLicenseBuf[1024*10] = {0, };
+       //  unsigned int DecLicenseBufLen = 0;
+
+       char LicenseUrl[1024] = {0, };
+       unsigned int LicenseUrlLen = 0;
+
+       //2011.03.08
+       //DrmTdcFileHeader TDCFileHeader;
+       //  char cid[1024] = {0, };
+       //  char riurl[1024] = {0, };
+
+       char testFileName[256] = {0, };
+       char tempBuf[256] = {0, };
+
+       bool isOk = false;
+
+       //----------------------------------------------------------------------------------------------------
+       // 0. Static TC running
+       //----------------------------------------------------------------------------------------------------
 
-       isOk = tc11_GetDeviceId_01();
-       if (isOk != true)
-       {
-               printf("tc11_GetDeviceId_01 failed!\n");
+       printf("\n0. Static TC  Start  ----------------------------------------\n");
+       /*
+           isOk = tc01_VerifyRoSignature_Positive_01();
+           if (isOk != true)
+           {
+               printf("tc01_VerifyRoSignature_Positive_01 failed!\n");
+           }
+
+           isOk = tc01_VerifyRoSignature_Positive_02();
+           if (isOk != true)
+           {
+               printf("tc01_VerifyRoSignature_Positive_02 failed!\n");
+           }
+
+           isOk = tc01_VerifyRoSignature_Positive_03();
+           if (isOk != true)
+           {
+               printf("tc01_VerifyRoSignature_Positive_03 failed!\n");
+           }
+
+           isOk = tc02_VerifyRoSignature_Negative_Cert_01();
+           if (isOk != true)
+           {
+               printf("tc02_VerifyRoSignature_Negative_Cert_01 failed!\n");
+           }
+
+           isOk = tc02_VerifyRoSignature_Negative_Cert_02();
+           if (isOk != true)
+           {
+               printf("tc02_VerifyRoSignature_Negative_Cert_02 failed!\n");
+           }
+
+           isOk = tc02_VerifyRoSignature_Negative_Cert_03();
+           if (isOk != true)
+           {
+               printf("tc02_VerifyRoSignature_Negative_Cert_03 failed!\n");
+           }
+
+           isOk = tc03_VerifyRoSignature_Negative_Signature_01();
+           if (isOk != true)
+           {
+               printf("tc03_VerifyRoSignature_Negative_Signature_01 failed!\n");
+           }
+
+           isOk = tc03_VerifyRoSignature_Negative_Signature_02();
+           if (isOk != true)
+           {
+               printf("tc03_VerifyRoSignature_Negative_Signature_02 failed!\n");
+           }
+
+           isOk = tc03_VerifyRoSignature_Negative_Signature_03();
+           if (isOk != true)
+           {
+               printf("tc03_VerifyRoSignature_Negative_Signature_03 failed!\n");
+           }
+
+           isOk = tc04_isDrmFile_Positive_01();
+           if (isOk != true)
+           {
+               printf("tc04_isDrmFile_Positive_01 failed!\n");
+           }
+
+           isOk = tc04_isDrmFile_Positive_02();
+           if (isOk != true)
+           {
+               printf("tc04_isDrmFile_Positive_02 failed!\n");
+           }
+
+           isOk = tc04_isDrmFile_Positive_03();
+           if (isOk != true)
+           {
+               printf("tc04_isDrmFile_Positive_03 failed!\n");
+           }
+
+           isOk = tc05_isDrmFile_Negative_01();
+           if (isOk != true)
+           {
+               printf("tc05_isDrmFile_Negative_01 failed!\n");
+           }
+
+           isOk = tc05_isDrmFile_Negative_02();
+           if (isOk != true)
+           {
+               printf("tc05_isDrmFile_Negative_02 failed!\n");
+           }
+
+           isOk = tc05_isDrmFile_Negative_03();
+           if (isOk != true)
+           {
+               printf("tc05_isDrmFile_Negative_03 failed!\n");
+           }
+
+           isOk = tc13_DTappsInstallLicense_01();
+           if (isOk != true)
+           {
+               printf("tc13_DTappsInstallLicense_01 failed!\n");
+           }
+
+           isOk = tc13_DTappsInstallLicense_02();
+           if (isOk != true)
+           {
+               printf("tc13_DTappsInstallLicense_02 failed!\n");
+           }
+
+           isOk = tc13_DTappsInstallLicense_03();
+           if (isOk != true)
+           {
+               printf("tc13_DTappsInstallLicense_03 failed!\n");
+           }
+
+           isOk = tc06_DrmFileHandlerPositive_01();
+           if (isOk != true)
+           {
+               printf("tc06_DrmFileHandlerPositive_01 failed!\n");
+           }
+
+           isOk = tc06_DrmFileHandlerPositive_02();
+           if (isOk != true)
+           {
+               printf("tc06_DrmFileHandlerPositive_02 failed!\n");
+           }
+
+           isOk = tc06_DrmFileHandlerPositive_03();
+           if (isOk != true)
+           {
+               printf("tc06_DrmFileHandlerPositive_03 failed!\n");
+           }
+
+           isOk = tc07_DrmFileMgrPositive_01();
+           if (isOk != true)
+           {
+               printf("tc07_DrmFileMgrPositive_01 failed!\b");
+           }
+
+           isOk = tc07_DrmFileMgrPositive_02();
+           if (isOk != true)
+           {
+               printf("tc07_DrmFileMgrPositive_02 failed!\n");
+           }
+
+           isOk = tc07_DrmFileMgrPositive_03();
+           if (isOk != true)
+           {
+               printf("tc07_DrmFileMgrPositive_03 failed!\n");
+           }
+
+           isOk = tc08_DrmFileMgrPositive_GetFileHandler_01();
+           if (isOk != true)
+           {
+               printf("tc08_DrmFileMgrPositive_GetFileHandler_01 failed!\n");
+           }
+
+           isOk = tc08_DrmFileMgrPositive_GetFileHandler_02();
+           if (isOk != true)
+           {
+               printf("tc08_DrmFileMgrPositive_GetFileHandler_02 failed!\n");
+           }
+
+           isOk = tc08_DrmFileMgrPositive_GetFileHandler_03();
+           if (isOk != true)
+           {
+               printf("tc08_DrmFileMgrPositive_GetFileHandler_03 failed!\n");
+           }
+
+           isOk = tc09_DrmFileMgrPositive_FileAPI_01();
+           if (isOk != true)
+           {
+               printf("tc09_DrmFileMgrPositive_FileAPI_01 failed!\n");
+           }
+
+           isOk = tc09_DrmFileMgrPositive_FileAPI_02();
+           if (isOk != true)
+           {
+               printf("tc09_DrmFileMgrPositive_FileAPI_02 failed!\n");
+           }
+
+           isOk = tc09_DrmFileMgrPositive_FileAPI_03();
+           if (isOk != true)
+           {
+               printf("tc09_DrmFileMgrPositive_FileAPI_03 failed!\n");
+           }
+
+           isOk = tc10_DrmFileMgrPositive_CloseFileHandler_01();
+           if (isOk != true)
+           {
+               printf("tc10_DrmFileMgrPositive_CloseFileHandler_01 failed!\n");
+           }
+
+           isOk = tc10_DrmFileMgrPositive_CloseFileHandler_02();
+           if (isOk != true)
+           {
+               printf("tc10_DrmFileMgrPositive_CloseFileHandler_02 failed!\n");
+           }
+
+           isOk = tc10_DrmFileMgrPositive_CloseFileHandler_03();
+           if (isOk != true)
+           {
+               printf("tc10_DrmFileMgrPositive_CloseFileHandler_03 failed!\n");
+           }
+
+           isOk = tc11_GetDeviceId_01();
+           if (isOk != true)
+           {
+               printf("tc11_GetDeviceId_01 failed!\n");
+           }
+
+           isOk = tc12_TADC_SetDeviceInfo_01();
+           if (isOk != true)
+           {
+               printf("tc12_TADC_SetDeviceInfo_01 failed!\n");
+           }
+
+           isOk = tc11_GetDeviceId_01();
+           if (isOk != true)
+           {
+               printf("tc11_GetDeviceId_01 failed!\n");
+           }
+       */
+       isOk = tc_local_01_drm_tizen_full_test_p();
+
+       if (isOk != true) {
+               printf("tc_local_01_drm_tizen_full_test_p failed!\n");
        }
-*/
-    isOk = tc_local_01_drm_tizen_full_test_p();
-    if (isOk != true)
-    {
-        printf("tc_local_01_drm_tizen_full_test_p failed!\n");
-    }
 
        //----------------------------------------------------------------------------------------------------
        // 1. Check is drm file
        //----------------------------------------------------------------------------------------------------
 
        printf("===============================================================================\n");
-       printf ("Enter test file name  -->  ");
+       printf("Enter test file name  -->  ");
 
        isOk = scanf("%s", testFileName);
-       if (isOk < 1)
-       {
-               printf ("Input value wrong! scanf() failed!!");
+
+       if (isOk < 1) {
+               printf("Input value wrong! scanf() failed!!");
                return 0;
        }
+
        printf("\n1. drm_tizen_is_drm_file  Start  ----------------------------------------\n");
 
        bRet = drm_tizen_is_drm_file(testFileName, strlen(testFileName));
-       if (bRet != TADC_SUCCESS)
-       {
+
+       if (bRet != TADC_SUCCESS) {
                printf("drm_tizen_is_drm_file Error! ret = %d\n", bRet);
                return 0;
        }
+
        printf("%s file is TADC file!\n", testFileName);
 
        //----------------------------------------------------------------------------------------------------
@@ -2343,28 +2467,30 @@ int main(int, char *[])
        ReqBufLen = sizeof(ReqBuf);
        LicenseUrlLen = sizeof(LicenseUrl);
 
-       bRet = drm_tizen_generate_purchase_request(testFileName, ReqBuf, &ReqBufLen, LicenseUrl, &LicenseUrlLen);
-       if (bRet == false)
-       {
+       bRet = drm_tizen_generate_purchase_request(testFileName, ReqBuf, &ReqBufLen,
+                       LicenseUrl, &LicenseUrlLen);
+
+       if (bRet == false) {
                printf(" drm_tizen_generate_purchase_request Error!  \n");
                return 0;
        }
 
-       printf("drm_tizen_generate_purchase_request - ReqBufLen : %d,  License Url : %s   \n", ReqBufLen, LicenseUrl);
-       if ((bRet = _write_logfile("Request_1.dat", ReqBuf, ReqBufLen-1)) == false)
-       {
+       printf("drm_tizen_generate_purchase_request - ReqBufLen : %d,  License Url : %s   \n",
+                  ReqBufLen, LicenseUrl);
+
+       if ((bRet = _write_logfile("Request_1.dat", ReqBuf, ReqBufLen - 1)) == false) {
                printf(" drm_tizen_generate_purchase_request _write_logfile Error!  \n");
                return 0;
        }
 
        //break.... HTTP Request & Reaponse Processing...
-       printf ("Enter any key after create Response_1.dat file. -->  ");
+       printf("Enter any key after create Response_1.dat file. -->  ");
        std::cin >> tempBuf;
 
        memset(RespBuf, 0x00, sizeof(RespBuf));
        RespBufLen = sizeof(RespBuf);
-       if ((bRet = _read_logfile("Response_1.dat", RespBuf, &RespBufLen)) == false)
-       {
+
+       if ((bRet = _read_logfile("Response_1.dat", RespBuf, &RespBufLen)) == false) {
                printf(" drm_tizen_generate_purchase_request _read_logfile Error!  \n");
                return 0;
        }
@@ -2379,28 +2505,30 @@ int main(int, char *[])
        ReqBufLen = sizeof(ReqBuf);
        LicenseUrlLen = sizeof(LicenseUrl);
 
-       bRet = drm_tizen_generate_license_request(RespBuf,  RespBufLen, ReqBuf, &ReqBufLen, LicenseUrl, &LicenseUrlLen);
-       if (bRet != TADC_SUCCESS)
-       {
+       bRet = drm_tizen_generate_license_request(RespBuf,  RespBufLen, ReqBuf,
+                       &ReqBufLen, LicenseUrl, &LicenseUrlLen);
+
+       if (bRet != TADC_SUCCESS) {
                printf(" drm_tizen_generate_license_request Error!  \n");
                return 0;
        }
 
-       printf("drm_tizen_generate_license_request - ReqBufLen : %d,  RO Url : %s   \n", ReqBufLen, LicenseUrl);
-       if ((bRet = _write_logfile("Request_2.dat", ReqBuf, ReqBufLen - 1)) == false)
-       {
+       printf("drm_tizen_generate_license_request - ReqBufLen : %d,  RO Url : %s   \n",
+                  ReqBufLen, LicenseUrl);
+
+       if ((bRet = _write_logfile("Request_2.dat", ReqBuf, ReqBufLen - 1)) == false) {
                printf(" drm_tizen_generate_license_request _write_logfile Error!  \n");
                return 0;
        }
 
        //break.... HTTP Request & Reaponse Processing...
-       printf ("Enter any key after create Response_2.dat file. -->  ");
+       printf("Enter any key after create Response_2.dat file. -->  ");
        std::cin >> tempBuf;
 
        memset(RespBuf, 0x00, sizeof(RespBuf));
        RespBufLen = sizeof(RespBuf);
-       if ((bRet = _read_logfile("Response_2.dat", RespBuf, &RespBufLen)) == false)
-       {
+
+       if ((bRet = _read_logfile("Response_2.dat", RespBuf, &RespBufLen)) == false) {
                printf(" drm_tizen_generate_license_request _read_logfile Error! \n");
                return 0;
        }
@@ -2411,8 +2539,8 @@ int main(int, char *[])
        printf("\n4. Decrypt DRM License Start  --------------------------------------------\n");
 
        bRet = drm_tizen_register_license(RespBuf, RespBufLen);
-       if (bRet != TADC_SUCCESS)
-       {
+
+       if (bRet != TADC_SUCCESS) {
                printf(" drm_tizen_register_license  Error!  \n");
                return 0;
        }
@@ -2423,10 +2551,10 @@ int main(int, char *[])
        printf("\n5. Decrypt DRM File Start  -----------------------------------------\n");
 
        sprintf(tempBuf, "%s.dec", testFileName);
-       bRet = drm_tizen_decrypt_package(testFileName, strlen(testFileName), tempBuf, strlen(tempBuf));
+       bRet = drm_tizen_decrypt_package(testFileName, strlen(testFileName), tempBuf,
+                                                                        strlen(tempBuf));
 
-       if (bRet != TADC_SUCCESS)
-       {
+       if (bRet != TADC_SUCCESS) {
                printf(" drm_tizen_decrypt_package  Error!  \n");
                return 0;
        }
index 8fc2182..3c64eb6 100644 (file)
@@ -13,8 +13,6 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License
  *
- */
-/*
  * @file        drm_testcore.cpp
  * @author      Kyungwook Tak(k.tak@samsung.com)
  * @version     1.0
@@ -37,6 +35,7 @@ bool tc_base64(void)
 
        int len = 0;
        unsigned char *decoded = Base64Decode(encoded, &len);
+
        if (len <= 0
                        || static_cast<size_t>(len) != sizeof(in)
                        || memcmp(in, decoded, sizeof(in)) != 0) {
index 0915f9f..7c940e1 100644 (file)
  *  See the License for the specific language governing permissions and
  *  limitations under the License
  *
- */
-/*
  * @file        drm_testcore.h
  * @author      Kyungwook Tak(k.tak@samsung.com)
  * @version     1.0
  * @brief       Test drm library internal core codes
  */
+#ifndef __DRM_TESTCORE_H_
+#define __DRM_TESTCORE_H_
 
 void test_drm_core(void);
+
+#endif //__DRM_TESTCORE_H_
index 75ba0b5..c235c09 100644 (file)
 
 using Binary = std::vector<unsigned char>;
 
-static unsigned char g_baAESKey[32] =
-{
-    0xf8, 0x87, 0x0a, 0xc5, 0xd3, 0x6d, 0x44, 0x49, 0x03, 0x9f, 0xbd, 0x1e, 0xa8, 0x2f, 0xf6, 0xc3,
-    0xdf, 0x3b, 0x02, 0x13, 0x58, 0x1b, 0x12, 0x30, 0x1c, 0xd7, 0xad, 0xa5, 0x1f, 0x5d, 0x01, 0x33
+static unsigned char g_baAESKey[32] = {
+       0xf8, 0x87, 0x0a, 0xc5, 0xd3, 0x6d, 0x44, 0x49,
+       0x03, 0x9f, 0xbd, 0x1e, 0xa8, 0x2f, 0xf6, 0xc3,
+       0xdf, 0x3b, 0x02, 0x13, 0x58, 0x1b, 0x12, 0x30,
+       0x1c, 0xd7, 0xad, 0xa5, 0x1f, 0x5d, 0x01, 0x33
 };
 
 
@@ -55,736 +56,843 @@ int __initialized = _UNINITIALIZED;
 
 void __init_crypto()
 {
-    if(__initialized != _INITIALIZED ) {
-        ERR_load_crypto_strings();
-        OpenSSL_add_all_algorithms();
-        __initialized = _INITIALIZED;
-    }
+       if (__initialized != _INITIALIZED) {
+               ERR_load_crypto_strings();
+               OpenSSL_add_all_algorithms();
+               __initialized = _INITIALIZED;
+       }
 }
 
-int __get_random_bytes(charoutput, int random_len)
+int __get_random_bytes(char *output, int random_len)
 {
-    FILE *fp = fopen("/dev/urandom", "r");
-    auto size = fread(output, 1, random_len, fp);
+       FILE *fp = fopen("/dev/urandom", "r");
+       auto size = fread(output, 1, random_len, fp);
 
        fclose(fp);
 
        if (size != static_cast<size_t>(random_len))
                return DRMTEST_ERR_IO;
 
-    return DRMTEST_SUCCESS;
+       return DRMTEST_SUCCESS;
 }
 
-int __file_copy(const char* target_path, const char* source_path)
+int __file_copy(const char *target_path, const char *source_path)
 {
-    int ret = DRMTEST_SUCCESS;
-    FILE *source = NULL;
-    FILE *target = NULL;
-    size_t l1,l2;
-    unsigned char buffer[8192];
-
-    source = fopen(source_path, "r");
-    if(source == NULL) {
-        ret = DRMTEST_ERR_IO;
-        goto error;
-    }
-
-    target = fopen(target_path, "w");
-    if(target == NULL) {
-        ret = DRMTEST_ERR_IO;
-        goto error;
-    }
-
-    while((l1 = fread(buffer, 1, sizeof buffer, source)) > 0) {
-        l2 = fwrite(buffer, 1, l1, target);
-        if(l2 < l1) {
-            if(ferror(target)) {
-                ret = DRMTEST_ERR_IO;
-                goto error;
-            }
-        }
-    }
+       int ret = DRMTEST_SUCCESS;
+       FILE *source = NULL;
+       FILE *target = NULL;
+       size_t l1, l2;
+       unsigned char buffer[8192];
+
+       source = fopen(source_path, "r");
+
+       if (source == NULL) {
+               ret = DRMTEST_ERR_IO;
+               goto error;
+       }
+
+       target = fopen(target_path, "w");
+
+       if (target == NULL) {
+               ret = DRMTEST_ERR_IO;
+               goto error;
+       }
+
+       while ((l1 = fread(buffer, 1, sizeof buffer, source)) > 0) {
+               l2 = fwrite(buffer, 1, l1, target);
+
+               if (l2 < l1) {
+                       if (ferror(target)) {
+                               ret = DRMTEST_ERR_IO;
+                               goto error;
+                       }
+               }
+       }
 
 error:
-    if(source != NULL)
-        fclose(source);
-    if(target != NULL)
-        fclose(target);
-    return ret;
+
+       if (source != NULL)
+               fclose(source);
+
+       if (target != NULL)
+               fclose(target);
+
+       return ret;
 }
 
-void _base64_encode(const unsigned char* input, int length, char** output)
+void _base64_encode(const unsigned char *input, int length, char **output)
 {
-    *output = Base64Encode((unsigned char*)input, length);
+       *output = Base64Encode((unsigned char *)input, length);
 }
 
-void _base64_decode(const char* input, unsigned char** output, int* out_len)
+void _base64_decode(const char *input, unsigned char **output, int *out_len)
 {
-    *output = Base64Decode((char*)input, out_len);
+       *output = Base64Decode((char *)input, out_len);
 }
 
-char_replace_all(char *s, const char *olds, const char *news)
+char *_replace_all(char *s, const char *olds, const char *news)
 {
-    char *result=NULL, *sr=NULL;
-    size_t i, count = 0;
-    size_t oldlen = strlen(olds); if (oldlen < 1) return s;
-    size_t newlen = strlen(news);
-
-    if (newlen != oldlen) {
-        for (i = 0; s[i] != '\0';) {
-          if (memcmp(&s[i], olds, oldlen) == 0) count++, i += oldlen;
-          else i++;
-        }
-    } else i = strlen(s);
-
-    result = (char *) malloc(i + 1 + count * (newlen - oldlen));
-    if (result == NULL) return NULL;
-
-    sr = result;
-    while (*s) {
-        if (memcmp(s, olds, oldlen) == 0) {
-            memcpy(sr, news, newlen);
-            sr += newlen;
-            s  += oldlen;
-        } else *sr++ = *s++;
-    }
-    *sr = '\0';
-
-    return result;
+       char *result = NULL, *sr = NULL;
+       size_t i, count = 0;
+       size_t oldlen = strlen(olds);
+
+       if (oldlen < 1) return s;
+
+       size_t newlen = strlen(news);
+
+       if (newlen != oldlen) {
+               for (i = 0; s[i] != '\0';) {
+                       if (memcmp(&s[i], olds, oldlen) == 0) count++, i += oldlen;
+                       else i++;
+               }
+       } else {
+               i = strlen(s);
+       }
+
+       result = (char *) malloc(i + 1 + count * (newlen - oldlen));
+
+       if (result == NULL) return NULL;
+
+       sr = result;
+
+       while (*s) {
+               if (memcmp(s, olds, oldlen) == 0) {
+                       memcpy(sr, news, newlen);
+                       sr += newlen;
+                       s  += oldlen;
+               } else {
+                       *sr++ = *s++;
+               }
+       }
+
+       *sr = '\0';
+
+       return result;
 }
 
 Binary _read_ro_file(const char *filename)
 {
-    try {
-        std::ifstream is(filename, std::ifstream::binary);
-        if (!is || !is.is_open())
-            return Binary();
-
-        is.seekg(0, is.end);
-        int length = is.tellg();
-        is.seekg(0, is.beg);
-
-        Binary buffer(length + 1); /* for null-terminated */
-
-        is.read(reinterpret_cast<char *>(buffer.data()), length);
-        if (!is)
-            return Binary();
-
-        return buffer;
-    } catch (...) {
-        std::cerr << "Failed to read ro file: " << filename << std::endl;
-        return Binary();
-    }
+       try {
+               std::ifstream is(filename, std::ifstream::binary);
+
+               if (!is || !is.is_open())
+                       return Binary();
+
+               is.seekg(0, is.end);
+               int length = is.tellg();
+               is.seekg(0, is.beg);
+
+               Binary buffer(length + 1); /* for null-terminated */
+
+               is.read(reinterpret_cast<char *>(buffer.data()), length);
+
+               if (!is)
+                       return Binary();
+
+               return buffer;
+       } catch (...) {
+               std::cerr << "Failed to read ro file: " << filename << std::endl;
+               return Binary();
+       }
 }
 
-int _create_dh_key(const char* dh_key_p_hex, const char* dh_key_g_hex, DH** ppkey)
+int _create_dh_key(const char *dh_key_p_hex, const char *dh_key_g_hex,
+                                  DH **ppkey)
 {
-    int ret = DRMTEST_SUCCESS;
-    DH *pDH = NULL;
+       int ret = DRMTEST_SUCCESS;
+       DH *pDH = NULL;
 
-    if ((pDH = DH_new()) == NULL) {
-        printf("...FAIL: DH_new() error");
-        ret = DRMTEST_ERR_CRYPTO;
-        goto error;
-    }
+       if ((pDH = DH_new()) == NULL) {
+               printf("...FAIL: DH_new() error");
+               ret = DRMTEST_ERR_CRYPTO;
+               goto error;
+       }
 
-    BN_hex2bn(&(pDH->p), dh_key_p_hex);
-    BN_hex2bn(&(pDH->g), dh_key_g_hex);
+       BN_hex2bn(&(pDH->p), dh_key_p_hex);
+       BN_hex2bn(&(pDH->g), dh_key_g_hex);
 
-    /* Set a to run with normal modexp and b to use constant time */
-    pDH->flags &= ~DH_FLAG_NO_EXP_CONSTTIME;
+       /* Set a to run with normal modexp and b to use constant time */
+       pDH->flags &= ~DH_FLAG_NO_EXP_CONSTTIME;
 
-    // Generate DH Key
-    if (!DH_generate_key(pDH)) {
-        printf("...FAIL: DH_generate_key");
-        ret = DRMTEST_ERR_CRYPTO;
-        goto error;
-    }
+       // Generate DH Key
+       if (!DH_generate_key(pDH)) {
+               printf("...FAIL: DH_generate_key");
+               ret = DRMTEST_ERR_CRYPTO;
+               goto error;
+       }
 
-    *ppkey = pDH;
+       *ppkey = pDH;
 error:
-    if(ret != DRMTEST_SUCCESS && pDH != NULL)
-        DH_free(pDH);
 
-    return ret;
+       if (ret != DRMTEST_SUCCESS && pDH != NULL)
+               DH_free(pDH);
+
+       return ret;
 }
 
-int _free_dh_key(DHpkey)
+int _free_dh_key(DH *pkey)
 {
-    if(pkey != NULL)
-        DH_free(pkey);
-    return DRMTEST_SUCCESS;
+       if (pkey != NULL)
+               DH_free(pkey);
+
+       return DRMTEST_SUCCESS;
 }
 
 
-int _get_dh_hex_pubkey(const DH* pkey, char** dh_pubkey)
+int _get_dh_hex_pubkey(const DH *pkey, char **dh_pubkey)
 {
-    *dh_pubkey = BN_bn2hex(pkey->pub_key);
-    return DRMTEST_SUCCESS;
+       *dh_pubkey = BN_bn2hex(pkey->pub_key);
+       return DRMTEST_SUCCESS;
 }
 
-int _get_dh_shared_secret_key(const chardh_hex_pubkey, DH *pkey,
-                              unsigned char** dh_shared_secret_key, int *dh_sec_key_len)
+int _get_dh_shared_secret_key(const char *dh_hex_pubkey, DH *pkey,
+                                                         unsigned char **dh_shared_secret_key, int *dh_sec_key_len)
 {
-    int ret = DRMTEST_SUCCESS;
-
-    BIGNUM  *pPubKey = NULL;
-    unsigned char *secret_key_buff = NULL;
-    unsigned char tmp_buff[DH_size(pkey)] = {0,};
-
-    BN_hex2bn(&pPubKey, dh_hex_pubkey);
-
-    if(DH_compute_key(tmp_buff, pPubKey, pkey) < 0) {
-        ret = DRMTEST_ERR_CRYPTO;
-        goto error;
-    }
-
-    secret_key_buff = (unsigned char *) malloc(DH_size(pkey)/2);
-    if(secret_key_buff == NULL) {
-        ret = DRMTEST_ERR_CRYPTO;
-        goto error;
-    }
-    memset(secret_key_buff, 0, DH_size(pkey)/2);
-
-    printf("APP_DRM TEST: shared secret : ");
-    for(int i=0; i<(DH_size(pkey)/2); i++) {
-        secret_key_buff[i] = tmp_buff[i * 2] ^ tmp_buff[(i * 2) + 1];
-        printf("%02x", secret_key_buff[i]);
-    }
-    printf("\n");
-
-    *dh_shared_secret_key = secret_key_buff;
-    *dh_sec_key_len = DH_size(pkey)/2;
+       int ret = DRMTEST_SUCCESS;
+
+       BIGNUM  *pPubKey = NULL;
+       unsigned char *secret_key_buff = NULL;
+       unsigned char tmp_buff[DH_size(pkey)] = { 0, };
+
+       BN_hex2bn(&pPubKey, dh_hex_pubkey);
+
+       if (DH_compute_key(tmp_buff, pPubKey, pkey) < 0) {
+               ret = DRMTEST_ERR_CRYPTO;
+               goto error;
+       }
+
+       secret_key_buff = (unsigned char *) malloc(DH_size(pkey) / 2);
+
+       if (secret_key_buff == NULL) {
+               ret = DRMTEST_ERR_CRYPTO;
+               goto error;
+       }
+
+       memset(secret_key_buff, 0, DH_size(pkey) / 2);
+
+       printf("APP_DRM TEST: shared secret : ");
+
+       for (int i = 0; i < (DH_size(pkey) / 2); i++) {
+               secret_key_buff[i] = tmp_buff[i * 2] ^ tmp_buff[(i * 2) + 1];
+               printf("%02x", secret_key_buff[i]);
+       }
+
+       printf("\n");
+
+       *dh_shared_secret_key = secret_key_buff;
+       *dh_sec_key_len = DH_size(pkey) / 2;
 error:
-    if(pPubKey != NULL)
-        BN_free(pPubKey);
-    if(ret != DRMTEST_SUCCESS && secret_key_buff != NULL)
-        free(secret_key_buff);
 
-    return ret;
+       if (pPubKey != NULL)
+               BN_free(pPubKey);
+
+       if (ret != DRMTEST_SUCCESS && secret_key_buff != NULL)
+               free(secret_key_buff);
+
+       return ret;
 }
 
 
-int _create_right_object_without_signature(const char* ro_template_path, const char* cid, const char* duid,
-                                char** ro_buff)
+int _create_right_object_without_signature(const char *ro_template_path,
+               const char *cid, const char *duid,
+               char **ro_buff)
 {
-    int ret = DRMTEST_SUCCESS;
-    char *cid_filled = NULL;
-    char *duid_filled = NULL;
+       int ret = DRMTEST_SUCCESS;
+       char *cid_filled = NULL;
+       char *duid_filled = NULL;
 
-    auto buf = _read_ro_file(ro_template_path);
+       auto buf = _read_ro_file(ro_template_path);
 
-    cid_filled = _replace_all(reinterpret_cast<char *>(buf.data()), STR_PLACE_HOLDER_CID, cid);
-    duid_filled = _replace_all(cid_filled, STR_PLACE_HOLDER_DUID, duid);
+       cid_filled = _replace_all(reinterpret_cast<char *>(buf.data()),
+                                                         STR_PLACE_HOLDER_CID, cid);
+       duid_filled = _replace_all(cid_filled, STR_PLACE_HOLDER_DUID, duid);
 
-    *ro_buff = duid_filled;
+       *ro_buff = duid_filled;
 
-    if (cid_filled != NULL)
-        free(cid_filled);
+       if (cid_filled != NULL)
+               free(cid_filled);
 
-    if (ret != DRMTEST_SUCCESS && duid_filled != NULL)
-        free(duid_filled);
+       if (ret != DRMTEST_SUCCESS && duid_filled != NULL)
+               free(duid_filled);
 
-    return ret;
+       return ret;
 }
 
-int _create_ro_signature(const char* ro_buff, const char* signer_prikey_path, char** signature)
+int _create_ro_signature(const char *ro_buff, const char *signer_prikey_path,
+                                                char **signature)
 {
-    int ret = DRMTEST_SUCCESS;
-
-    EVP_PKEY* pkey = NULL;
-    RSA*      prsa = NULL;
-    const char* END_STR = "</CertificateChain>";
-    const char* tmp_end_hash_input = NULL;
-    int hash_input_size = 0;
-    unsigned char hash_value[20];
-    unsigned char sig_value[MAX_CERT_SIZE]; // enough buffer
-    unsigned int sig_len = 0;
-    char* b64_sig_value = NULL;
-
-    FILE *file = NULL;
-
-    // get private key
-    file = fopen(signer_prikey_path, "r");
-    if(file == NULL) {
-        ret = DRMTEST_ERR_IO;
-        goto error;
-    }
-
-    pkey = PEM_read_PrivateKey(file, &pkey, NULL, NULL);
-    if(pkey == NULL) {
-        ret = DRMTEST_ERR_IO;
-        goto error;
-    }
-
-    prsa = EVP_PKEY_get1_RSA(pkey);
-    if(prsa == NULL) {
-        ret = DRMTEST_ERR_CRYPTO;
-        goto error;
-    }
-
-    // get hash input size
-    tmp_end_hash_input = strstr(ro_buff, END_STR);
-    hash_input_size = (tmp_end_hash_input - ro_buff) + strlen(END_STR);
-
-    // get hash value
-    SHA_CTX     alginfo;
-    SHA1_Init(&alginfo);
-    SHA1_Update(&alginfo, ro_buff, hash_input_size);
-    SHA1_Final(hash_value, &alginfo);
-
-    // get signature value
-    if( 1 != RSA_sign(NID_sha1, hash_value, 20, sig_value, &sig_len, prsa) ) {
-        ret = DRMTEST_ERR_CRYPTO;
-        goto error;
-    }
-
-    // convert to base64 string
-    _base64_encode(sig_value, (int) sig_len, &b64_sig_value);
-
-    *signature = b64_sig_value;
+       int ret = DRMTEST_SUCCESS;
+
+       EVP_PKEY *pkey = NULL;
+       RSA      *prsa = NULL;
+       const char *END_STR = "</CertificateChain>";
+       const char *tmp_end_hash_input = NULL;
+       int hash_input_size = 0;
+       unsigned char hash_value[20];
+       unsigned char sig_value[MAX_CERT_SIZE]; // enough buffer
+       unsigned int sig_len = 0;
+       char *b64_sig_value = NULL;
+
+       FILE *file = NULL;
+
+       // get private key
+       file = fopen(signer_prikey_path, "r");
+
+       if (file == NULL) {
+               ret = DRMTEST_ERR_IO;
+               goto error;
+       }
+
+       pkey = PEM_read_PrivateKey(file, &pkey, NULL, NULL);
+
+       if (pkey == NULL) {
+               ret = DRMTEST_ERR_IO;
+               goto error;
+       }
+
+       prsa = EVP_PKEY_get1_RSA(pkey);
+
+       if (prsa == NULL) {
+               ret = DRMTEST_ERR_CRYPTO;
+               goto error;
+       }
+
+       // get hash input size
+       tmp_end_hash_input = strstr(ro_buff, END_STR);
+       hash_input_size = (tmp_end_hash_input - ro_buff) + strlen(END_STR);
+
+       // get hash value
+       SHA_CTX     alginfo;
+       SHA1_Init(&alginfo);
+       SHA1_Update(&alginfo, ro_buff, hash_input_size);
+       SHA1_Final(hash_value, &alginfo);
+
+       // get signature value
+       if (1 != RSA_sign(NID_sha1, hash_value, 20, sig_value, &sig_len, prsa)) {
+               ret = DRMTEST_ERR_CRYPTO;
+               goto error;
+       }
+
+       // convert to base64 string
+       _base64_encode(sig_value, (int) sig_len, &b64_sig_value);
+
+       *signature = b64_sig_value;
 error:
-    if(file != NULL)
-        fclose(file);
-    if(pkey != NULL)
-        EVP_PKEY_free(pkey);
-    if(ret != DRMTEST_SUCCESS && b64_sig_value != NULL)
-        free(b64_sig_value);
-
-    return ret;
+
+       if (file != NULL)
+               fclose(file);
+
+       if (pkey != NULL)
+               EVP_PKEY_free(pkey);
+
+       if (ret != DRMTEST_SUCCESS && b64_sig_value != NULL)
+               free(b64_sig_value);
+
+       return ret;
 }
 
-int _add_signature_to_ro(const char* ro_buff, const char* signature, char** ro_with_signature)
+int _add_signature_to_ro(const char *ro_buff, const char *signature,
+                                                char **ro_with_signature)
 {
-    int ret = DRMTEST_SUCCESS;
-    char *buff = NULL;
-    buff = _replace_all((char*)ro_buff, STR_PLACE_HOLDER_SIGNATURE, signature);
-    *ro_with_signature = buff;
-    return ret;
+       int ret = DRMTEST_SUCCESS;
+       char *buff = NULL;
+       buff = _replace_all((char *)ro_buff, STR_PLACE_HOLDER_SIGNATURE, signature);
+       *ro_with_signature = buff;
+       return ret;
 }
 
-int _encrypt_ro_with_dh_sec_key(const charro_with_signature,
-                                const unsigned char* dh_secret_key, const int dh_sec_key_len,
-                                char **encrypted_ro)
+int _encrypt_ro_with_dh_sec_key(const char *ro_with_signature,
+                                                               const unsigned char *dh_secret_key, const int dh_sec_key_len,
+                                                               char **encrypted_ro)
 {
-    int ret = DRMTEST_SUCCESS;
-    TADC_U8     key[16] = {0, };
-    TADC_U8     iv[16] = {0, };
-    int encrypted_len = 0;
-    unsigned char encrypted_buff[MAX_CERT_SIZE] = {0, };;
+       int ret = DRMTEST_SUCCESS;
+       TADC_U8     key[16] = {0, };
+       TADC_U8     iv[16] = {0, };
+       int encrypted_len = 0;
+       unsigned char encrypted_buff[MAX_CERT_SIZE] = {0, };;
+
+       (void) dh_sec_key_len; // to prevent unused varialbe error
 
-    (void) dh_sec_key_len; // to prevent unused varialbe error
+       TADC_IF_MemCpy(key, dh_secret_key, 16);
+       TADC_IF_MemCpy(iv, (dh_secret_key + 16), 16);
+       ret = TADC_IF_AES_CTR(key, 16, iv, strlen(ro_with_signature),
+                                                 (unsigned char *)ro_with_signature,
+                                                 &encrypted_len, (unsigned char *)encrypted_buff);
 
-    TADC_IF_MemCpy(key, dh_secret_key, 16);
-    TADC_IF_MemCpy(iv, (dh_secret_key+16), 16);
-    ret = TADC_IF_AES_CTR(key, 16, iv, strlen(ro_with_signature), (unsigned char*)ro_with_signature,
-                                    &encrypted_len, (unsigned char*)encrypted_buff);
-    if(ret != 0) {
-        ret = DRMTEST_ERR_CRYPTO;
-        goto error;
-    }
+       if (ret != 0) {
+               ret = DRMTEST_ERR_CRYPTO;
+               goto error;
+       }
 
-    _base64_encode(encrypted_buff, encrypted_len, encrypted_ro);
+       _base64_encode(encrypted_buff, encrypted_len, encrypted_ro);
 
 error:
-    return ret;
+       return ret;
 }
 
-int _create_response_data_in_ro_response(const char* reqid, const char* encrypted_ro, const char* dh_pubkey,
-                                char **response_data)
+int _create_response_data_in_ro_response(const char *reqid,
+               const char *encrypted_ro, const char *dh_pubkey,
+               char **response_data)
 {
-    int ret = DRMTEST_SUCCESS;
-    char tmp_buff[MAX_CERT_SIZE] = {0,};
-    unsigned char hashed_reqid[20]={0,};
-    char hex_hashed_reqid[256] = {0, };
-    unsigned char hash_value[20]={0,};
-    int hmac_len = 0;
-    unsigned char hmac[1024*10] = {0,};
-    char* hmac_base64 = NULL;
-    char* resp_data = NULL;
-
-    // get hashed req_id
-    SHA_CTX alginfoForReqId;
-    SHA1_Init(&alginfoForReqId);
-    SHA1_Update(&alginfoForReqId, reqid, strlen(reqid));
-    SHA1_Final(hashed_reqid, &alginfoForReqId);
-
-    for (size_t i = 0; i < sizeof(hashed_reqid); i++)
-        sprintf(hex_hashed_reqid + i * 2, "%02x", hashed_reqid[i]);
-
-    sprintf(tmp_buff, "reqid=%s;B=%s;license=%s", hex_hashed_reqid, dh_pubkey, encrypted_ro);
-
-    // get hash value
-    SHA_CTX     alginfo;
-    SHA1_Init(&alginfo);
-    SHA1_Update(&alginfo, tmp_buff, strlen(tmp_buff));
-    SHA1_Final(hash_value, &alginfo);
-
-    // encrypt hash value
-    TADC_U8     key[16] = {0, };
-    TADC_U8     iv[16] = {0, };
-
-    TADC_IF_MemCpy(key, g_baAESKey, 16);
-    TADC_IF_MemCpy(iv, (g_baAESKey+16), 16);
-    ret = TADC_IF_AES_CTR(key, 16, iv, 20, hash_value, &hmac_len, hmac);
-    if(ret != 0) {
-        ret = DRMTEST_ERR_CRYPTO;
-        goto error;
-    }
-
-    // base64 encode
-    _base64_encode(hmac, 20, &hmac_base64);
-
-    // add hmac
-    strncat(tmp_buff, ";hmac=", strlen(";hmac="));
-    strncat(tmp_buff, hmac_base64, strlen(hmac_base64));
-
-    // make return value
-    resp_data = (char*) malloc(strlen(tmp_buff)+1);
-    if(resp_data == NULL) {
-        ret = DRMTEST_ERR_MEMORY;
-        goto error;
-    }
-    memset(resp_data, 0, strlen(tmp_buff)+1);
-    strncpy(resp_data, tmp_buff, strlen(tmp_buff));
-
-    *response_data = resp_data;
+       int ret = DRMTEST_SUCCESS;
+       char tmp_buff[MAX_CERT_SIZE] = { 0, };
+       unsigned char hashed_reqid[20] = { 0, };
+       char hex_hashed_reqid[256] = { 0, };
+       unsigned char hash_value[20] = { 0, };
+       int hmac_len = 0;
+       unsigned char hmac[1024 * 10] = { 0, };
+       char *hmac_base64 = NULL;
+       char *resp_data = NULL;
+
+       // get hashed req_id
+       SHA_CTX alginfoForReqId;
+       SHA1_Init(&alginfoForReqId);
+       SHA1_Update(&alginfoForReqId, reqid, strlen(reqid));
+       SHA1_Final(hashed_reqid, &alginfoForReqId);
+
+       for (size_t i = 0; i < sizeof(hashed_reqid); i++)
+               sprintf(hex_hashed_reqid + i * 2, "%02x", hashed_reqid[i]);
+
+       sprintf(tmp_buff, "reqid=%s;B=%s;license=%s", hex_hashed_reqid, dh_pubkey,
+                       encrypted_ro);
+
+       // get hash value
+       SHA_CTX     alginfo;
+       SHA1_Init(&alginfo);
+       SHA1_Update(&alginfo, tmp_buff, strlen(tmp_buff));
+       SHA1_Final(hash_value, &alginfo);
+
+       // encrypt hash value
+       TADC_U8     key[16] = {0, };
+       TADC_U8     iv[16] = {0, };
+
+       TADC_IF_MemCpy(key, g_baAESKey, 16);
+       TADC_IF_MemCpy(iv, (g_baAESKey + 16), 16);
+       ret = TADC_IF_AES_CTR(key, 16, iv, 20, hash_value, &hmac_len, hmac);
+
+       if (ret != 0) {
+               ret = DRMTEST_ERR_CRYPTO;
+               goto error;
+       }
+
+       // base64 encode
+       _base64_encode(hmac, 20, &hmac_base64);
+
+       // add hmac
+       strncat(tmp_buff, ";hmac=", strlen(";hmac="));
+       strncat(tmp_buff, hmac_base64, strlen(hmac_base64));
+
+       // make return value
+       resp_data = (char *) malloc(strlen(tmp_buff) + 1);
+
+       if (resp_data == NULL) {
+               ret = DRMTEST_ERR_MEMORY;
+               goto error;
+       }
+
+       memset(resp_data, 0, strlen(tmp_buff) + 1);
+       strncpy(resp_data, tmp_buff, strlen(tmp_buff));
+
+       *response_data = resp_data;
 
 error:
-    if(hmac_base64 != NULL)
-        free(hmac_base64);
-    if(ret != DRMTEST_SUCCESS && resp_data != NULL)
-        free(resp_data);
-    return ret;
+
+       if (hmac_base64 != NULL)
+               free(hmac_base64);
+
+       if (ret != DRMTEST_SUCCESS && resp_data != NULL)
+               free(resp_data);
+
+       return ret;
 }
 
-int _create_time_stamp(const unsigned char* dh_secret_key, char** time_stamp)
+int _create_time_stamp(const unsigned char *dh_secret_key, char **time_stamp)
 {
-    int ret = DRMTEST_SUCCESS;
-
-    char tmp_time_buff[128] = {0,};
-    unsigned char enc_time_buff[512] = {0,};
-    char *time_base64 = NULL;
-    int enc_time_buff_len = 0;
-    time_t now = time(NULL);
-    const struct tm* gt = gmtime(&now);
-
-    sprintf(tmp_time_buff, "%d-%d-%dT%d:%d:00:Z",
-                           gt->tm_year+1900, gt->tm_mon+1, gt->tm_mday,
-                           gt->tm_hour+1, gt->tm_min+1);
-
-    // encrypt time_stamp
-    TADC_U8     key[16] = {0, };
-    TADC_U8     iv[16] = {0, };
-
-    TADC_IF_MemCpy(key, dh_secret_key, 16);
-    TADC_IF_MemCpy(iv, (dh_secret_key+16), 16);
-    ret = TADC_IF_AES_CTR(key, 16, iv, strlen(tmp_time_buff), (unsigned char*)tmp_time_buff,
-                          &enc_time_buff_len, enc_time_buff);
-    if(ret != 0) {
-        ret = DRMTEST_ERR_CRYPTO;
-        goto error;
-    }
-
-    // convert to base64
-    _base64_encode(enc_time_buff, enc_time_buff_len, &time_base64);
-
-    *time_stamp = time_base64;
+       int ret = DRMTEST_SUCCESS;
+
+       char tmp_time_buff[128] = {0, };
+       unsigned char enc_time_buff[512] = {0, };
+       char *time_base64 = NULL;
+       int enc_time_buff_len = 0;
+       time_t now = time(NULL);
+       const struct tm *gt = gmtime(&now);
+
+       sprintf(tmp_time_buff, "%d-%d-%dT%d:%d:00:Z",
+                       gt->tm_year + 1900, gt->tm_mon + 1, gt->tm_mday,
+                       gt->tm_hour + 1, gt->tm_min + 1);
+
+       // encrypt time_stamp
+       TADC_U8 key[16] = {0, };
+       TADC_U8 iv[16] = {0, };
+
+       TADC_IF_MemCpy(key, dh_secret_key, 16);
+       TADC_IF_MemCpy(iv, (dh_secret_key + 16), 16);
+       ret = TADC_IF_AES_CTR(key, 16, iv, strlen(tmp_time_buff),
+                                                 (unsigned char *)tmp_time_buff,
+                                                 &enc_time_buff_len, enc_time_buff);
+
+       if (ret != 0) {
+               ret = DRMTEST_ERR_CRYPTO;
+               goto error;
+       }
+
+       // convert to base64
+       _base64_encode(enc_time_buff, enc_time_buff_len, &time_base64);
+
+       *time_stamp = time_base64;
 error:
-    if(ret != DRMTEST_SUCCESS && time_base64 != NULL)
-        free(time_base64);
-    return ret;
 
+       if (ret != DRMTEST_SUCCESS && time_base64 != NULL)
+               free(time_base64);
+
+       return ret;
 }
 
-int generate_purchase_response(char** purchase_response_buff, char** req_id)
+int generate_purchase_response(char **purchase_response_buff, char **req_id)
 {
-    int ret = DRMTEST_SUCCESS;
-    char resp_buff[1024*5] = {0, };
-    char *resp = NULL;
-    char *rid = NULL;
-    char random[64] = {0, };
-
-    const char *format1 = "<?xml version=\"1.0\">\n";
-    const char *format2 = "<response result=\"0\" message=\"\">\n";
-    const char *format3 = "    <DRMType>%d</DRMType>\n";
-    const char *format4 = "    <riurl>%s</riurl>\n";
-    const char *format5 = "    <reqid>%s</reqid>\n";
-    const char *format6 = "</response>";
-
-    resp = (char*) malloc(sizeof(resp_buff));
-    if(resp == NULL) {
-        ret = DRMTEST_ERR_MEMORY;
-        goto error;
-    }
-    memset(resp, 0, sizeof(resp_buff));
-
-    __get_random_bytes(random, sizeof(random));
-    rid = (char*) malloc(1024);
-    if(rid == NULL) {
-        ret = DRMTEST_ERR_MEMORY;
-        goto error;
-    }
-    memset(rid, 0, 1024);
-
-    for (size_t i = 0; i < sizeof(random); i++)
-        sprintf(rid + i * 2, "%02x", random[i]);
-
-    strncat(resp_buff, format1, strlen(format1));
-    strncat(resp_buff, format2, strlen(format2));
-    strncat(resp_buff, format3, strlen(format3));
-    strncat(resp_buff, format4, strlen(format4));
-    strncat(resp_buff, format5, strlen(format5));
-    strncat(resp_buff, format6, strlen(format6));
-
-    sprintf(resp, resp_buff, 1, RIURL, rid);
-
-    *purchase_response_buff = resp;
-    *req_id = rid;
+       int ret = DRMTEST_SUCCESS;
+       char resp_buff[1024 * 5] = {0, };
+       char *resp = NULL;
+       char *rid = NULL;
+       char random[64] = {0, };
+
+       const char *format1 = "<?xml version=\"1.0\">\n";
+       const char *format2 = "<response result=\"0\" message=\"\">\n";
+       const char *format3 = "    <DRMType>%d</DRMType>\n";
+       const char *format4 = "    <riurl>%s</riurl>\n";
+       const char *format5 = "    <reqid>%s</reqid>\n";
+       const char *format6 = "</response>";
+
+       resp = (char *) malloc(sizeof(resp_buff));
+
+       if (resp == NULL) {
+               ret = DRMTEST_ERR_MEMORY;
+               goto error;
+       }
+
+       memset(resp, 0, sizeof(resp_buff));
+
+       __get_random_bytes(random, sizeof(random));
+       rid = (char *) malloc(1024);
+
+       if (rid == NULL) {
+               ret = DRMTEST_ERR_MEMORY;
+               goto error;
+       }
+
+       memset(rid, 0, 1024);
+
+       for (size_t i = 0; i < sizeof(random); i++)
+               sprintf(rid + i * 2, "%02x", random[i]);
+
+       strncat(resp_buff, format1, strlen(format1));
+       strncat(resp_buff, format2, strlen(format2));
+       strncat(resp_buff, format3, strlen(format3));
+       strncat(resp_buff, format4, strlen(format4));
+       strncat(resp_buff, format5, strlen(format5));
+       strncat(resp_buff, format6, strlen(format6));
+
+       sprintf(resp, resp_buff, 1, RIURL, rid);
+
+       *purchase_response_buff = resp;
+       *req_id = rid;
 
 error:
-    if(ret != DRMTEST_SUCCESS && resp != NULL)
-        free(resp);
-    if(ret != DRMTEST_SUCCESS && rid != NULL)
-        free(rid);
 
-    return ret;
+       if (ret != DRMTEST_SUCCESS && resp != NULL)
+               free(resp);
+
+       if (ret != DRMTEST_SUCCESS && rid != NULL)
+               free(rid);
+
+       return ret;
 }
 
-int generate_right_object_request(const charlicense_response_buff)
+int generate_right_object_request(const char *license_response_buff)
 {
-    int ret = DRMTEST_SUCCESS;
-    unsigned int  req_buff_len = 1024*5;
-    char url_buff[1024] = {0, };
-    unsigned int  url_buff_len = sizeof(url_buff);
-    char *req_buff = NULL;
-
-    req_buff = (char *)malloc(1024*5);
-    if(req_buff == NULL) {
-        ret = DRMTEST_ERR_MEMORY;
-        goto error;
-    }
-    memset(req_buff, 0, req_buff_len);
-
-    ret = drm_tizen_generate_license_request(license_response_buff, strlen(license_response_buff),
-                                             req_buff, &req_buff_len, url_buff, &url_buff_len);
-    if(ret != 1) {
-        ret = DRMTEST_ERR_TIZDRM;
-        goto error;
-    }
+       int ret = DRMTEST_SUCCESS;
+       unsigned int  req_buff_len = 1024 * 5;
+       char url_buff[1024] = {0, };
+       unsigned int  url_buff_len = sizeof(url_buff);
+       char *req_buff = NULL;
+
+       req_buff = (char *)malloc(1024 * 5);
+
+       if (req_buff == NULL) {
+               ret = DRMTEST_ERR_MEMORY;
+               goto error;
+       }
+
+       memset(req_buff, 0, req_buff_len);
+
+       ret = drm_tizen_generate_license_request(license_response_buff,
+                       strlen(license_response_buff),
+                       req_buff, &req_buff_len, url_buff, &url_buff_len);
+
+       if (ret != 1) {
+               ret = DRMTEST_ERR_TIZDRM;
+               goto error;
+       }
 
 error:
-    if(ret != DRMTEST_SUCCESS && req_buff != NULL)
-        free(req_buff);
-    return ret;
+
+       if (ret != DRMTEST_SUCCESS && req_buff != NULL)
+               free(req_buff);
+
+       return ret;
 }
 
 
-int get_dh_key_from_ro_request(const charro_request_buff,
-                              char** dh_key_p, char** dh_key_g, char** dh_key_a)
+int get_dh_key_from_ro_request(const char *ro_request_buff,
+                                                          char **dh_key_p, char **dh_key_g, char **dh_key_a)
 {
-    int ret = DRMTEST_SUCCESS;
-
-    const char* PFX_P = "p=";
-    const char* PFX_G = ";g=";
-    const char* PFX_A = ";A=";
-    const char* PFX_HMAC = ";hmac=";
-
-    const char * idx_p = strstr(ro_request_buff, PFX_P);
-    const char * idx_g = strstr(ro_request_buff, PFX_G);
-    const char * idx_a = strstr(ro_request_buff, PFX_A);
-    const char * idx_hmac = strstr(ro_request_buff, PFX_HMAC);
-
-    int len_p = idx_g - idx_p - strlen(PFX_P);
-    int len_g = idx_a - idx_g - strlen(PFX_G);
-    int len_a = idx_hmac - idx_a - strlen(PFX_A);
-
-    char* buff_p = NULL;
-    char* buff_g = NULL;
-    char* buff_a = NULL;
-
-    buff_p = (char *)malloc(len_p + 1);
-    if(buff_p == NULL) {
-        ret = DRMTEST_ERR_MEMORY;
-        goto error;
-    }
-    memset(buff_p, 0, len_p + 1);
-    strncpy(buff_p, idx_p + strlen(PFX_P), len_p);
-    *dh_key_p = buff_p;
-
-    buff_g = (char *)malloc(len_g + 1);
-    if(buff_g == NULL) {
-        ret = DRMTEST_ERR_MEMORY;
-        goto error;
-    }
-    memset(buff_g, 0, len_g + 1);
-    strncpy(buff_g, idx_g + strlen(PFX_G), len_g);
-    *dh_key_g = buff_g;
-
-    buff_a = (char *)malloc(len_a + 1);
-    if(buff_a == NULL) {
-        ret = DRMTEST_ERR_MEMORY;
-        goto error;
-    }
-    memset(buff_a, 0, len_a + 1);
-    strncpy(buff_a, idx_a + strlen(PFX_A), len_a);
-    *dh_key_a = buff_a;
+       int ret = DRMTEST_SUCCESS;
+
+       const char *PFX_P = "p=";
+       const char *PFX_G = ";g=";
+       const char *PFX_A = ";A=";
+       const char *PFX_HMAC = ";hmac=";
+
+       const char *idx_p = strstr(ro_request_buff, PFX_P);
+       const char *idx_g = strstr(ro_request_buff, PFX_G);
+       const char *idx_a = strstr(ro_request_buff, PFX_A);
+       const char *idx_hmac = strstr(ro_request_buff, PFX_HMAC);
+
+       int len_p = idx_g - idx_p - strlen(PFX_P);
+       int len_g = idx_a - idx_g - strlen(PFX_G);
+       int len_a = idx_hmac - idx_a - strlen(PFX_A);
+
+       char *buff_p = NULL;
+       char *buff_g = NULL;
+       char *buff_a = NULL;
+
+       buff_p = (char *)malloc(len_p + 1);
+
+       if (buff_p == NULL) {
+               ret = DRMTEST_ERR_MEMORY;
+               goto error;
+       }
+
+       memset(buff_p, 0, len_p + 1);
+       strncpy(buff_p, idx_p + strlen(PFX_P), len_p);
+       *dh_key_p = buff_p;
+
+       buff_g = (char *)malloc(len_g + 1);
+
+       if (buff_g == NULL) {
+               ret = DRMTEST_ERR_MEMORY;
+               goto error;
+       }
+
+       memset(buff_g, 0, len_g + 1);
+       strncpy(buff_g, idx_g + strlen(PFX_G), len_g);
+       *dh_key_g = buff_g;
+
+       buff_a = (char *)malloc(len_a + 1);
+
+       if (buff_a == NULL) {
+               ret = DRMTEST_ERR_MEMORY;
+               goto error;
+       }
+
+       memset(buff_a, 0, len_a + 1);
+       strncpy(buff_a, idx_a + strlen(PFX_A), len_a);
+       *dh_key_a = buff_a;
 
 error:
-    if(ret != DRMTEST_SUCCESS && buff_p != NULL)
-        free(buff_p);
-    if(ret != DRMTEST_SUCCESS && buff_g != NULL)
-        free(buff_g);
-    if(ret != DRMTEST_SUCCESS && buff_a != NULL)
-        free(buff_a);
-
-    return ret;
+
+       if (ret != DRMTEST_SUCCESS && buff_p != NULL)
+               free(buff_p);
+
+       if (ret != DRMTEST_SUCCESS && buff_g != NULL)
+               free(buff_g);
+
+       if (ret != DRMTEST_SUCCESS && buff_a != NULL)
+               free(buff_a);
+
+       return ret;
 }
 
-int generate_right_object_response(const char* dh_key_p, const char* dh_key_g, const char* dh_key_a,
-                              const char* req_id, const char* cid, const char* ro_template_path,
-                              const char* duid, char** ro_response_buff)
+int generate_right_object_response(const char *dh_key_p, const char *dh_key_g,
+                                                                  const char *dh_key_a,
+                                                                  const char *req_id, const char *cid,
+                                                                  const char *ro_template_path,
+                                                                  const char *duid, char **ro_response_buff)
 {
-    int ret = DRMTEST_SUCCESS;
-
-    DH* pkey = NULL;
-    char* dh_pubkey = NULL;
-    unsigned char* dh_shared_secret_key = NULL;
-    int   dh_sec_key_len = 0;
-    char* ro_buff = NULL;
-    char* ro_signature = NULL;
-    char* ro_with_signature = NULL;
-    char* encrypted_ro = NULL;
-    char* response_data = NULL;
-    char* time_stamp = NULL;
-    char* ro_resp_buff = NULL;
-    int   ro_resp_buff_len = 0;
-
-    const char *format = "<?xml version=\"1.0\">\n"
-                         "<response result=\"0\" message=\"\">\n"
-                         "    <responsedata>%s</responsedata>\n"
-                         "    <timeStamp>%s</timeStamp>\n"
-                         "</response>";
-
-    ret = _create_dh_key(dh_key_p, dh_key_g, &pkey);
-    if(ret != DRMTEST_SUCCESS){
-        goto error;
-    }
-
-    ret = _get_dh_hex_pubkey(pkey, &dh_pubkey);
-    if(ret != DRMTEST_SUCCESS){
-        goto error;
-    }
-
-    ret = _get_dh_shared_secret_key(dh_key_a, pkey, &dh_shared_secret_key, &dh_sec_key_len);
-    if(ret != DRMTEST_SUCCESS){
-        goto error;
-    }
-
-    ret = _create_right_object_without_signature(ro_template_path, cid, duid, &ro_buff);
-    if(ret != DRMTEST_SUCCESS){
-        goto error;
-    }
-
-    ret = _create_ro_signature(ro_buff, RO_ISSUER_SIGNER_KEY_FILE, &ro_signature);
-    if(ret != DRMTEST_SUCCESS){
-        goto error;
-    }
-
-    ret = _add_signature_to_ro(ro_buff, ro_signature, &ro_with_signature);
-    if(ret != DRMTEST_SUCCESS){
-        goto error;
-    }
-    //printf("...right object:\n%s\n", ro_with_signature);
-
-    ret = _encrypt_ro_with_dh_sec_key(ro_with_signature, dh_shared_secret_key, dh_sec_key_len,
-                                      &encrypted_ro);
-    if(ret != DRMTEST_SUCCESS){
-        goto error;
-    }
-
-    ret = _create_response_data_in_ro_response(req_id, encrypted_ro, dh_pubkey, &response_data);
-    if(ret != DRMTEST_SUCCESS){
-        goto error;
-    }
-
-    ret = _create_time_stamp( dh_shared_secret_key, &time_stamp);
-    if(ret != DRMTEST_SUCCESS){
-        goto error;
-    }
-
-    ro_resp_buff_len = strlen(format) + strlen(response_data) + strlen(time_stamp) + 1;
-    ro_resp_buff = (char *) malloc(ro_resp_buff_len);
-    if(ro_resp_buff == NULL) {
-        ret = DRMTEST_ERR_MEMORY;
-        goto error;
-    }
-    memset(ro_resp_buff, 0, ro_resp_buff_len);
-    sprintf(ro_resp_buff, format, response_data, time_stamp);
-
-    *ro_response_buff = ro_resp_buff;
+       int ret = DRMTEST_SUCCESS;
+
+       DH *pkey = NULL;
+       char *dh_pubkey = NULL;
+       unsigned char *dh_shared_secret_key = NULL;
+       int   dh_sec_key_len = 0;
+       char *ro_buff = NULL;
+       char *ro_signature = NULL;
+       char *ro_with_signature = NULL;
+       char *encrypted_ro = NULL;
+       char *response_data = NULL;
+       char *time_stamp = NULL;
+       char *ro_resp_buff = NULL;
+       int   ro_resp_buff_len = 0;
+
+       const char *format = "<?xml version=\"1.0\">\n"
+                                                "<response result=\"0\" message=\"\">\n"
+                                                "    <responsedata>%s</responsedata>\n"
+                                                "    <timeStamp>%s</timeStamp>\n"
+                                                "</response>";
+
+       ret = _create_dh_key(dh_key_p, dh_key_g, &pkey);
+
+       if (ret != DRMTEST_SUCCESS) {
+               goto error;
+       }
+
+       ret = _get_dh_hex_pubkey(pkey, &dh_pubkey);
+
+       if (ret != DRMTEST_SUCCESS) {
+               goto error;
+       }
+
+       ret = _get_dh_shared_secret_key(dh_key_a, pkey, &dh_shared_secret_key,
+                                                                       &dh_sec_key_len);
+
+       if (ret != DRMTEST_SUCCESS) {
+               goto error;
+       }
+
+       ret = _create_right_object_without_signature(ro_template_path, cid, duid,
+                       &ro_buff);
+
+       if (ret != DRMTEST_SUCCESS) {
+               goto error;
+       }
+
+       ret = _create_ro_signature(ro_buff, RO_ISSUER_SIGNER_KEY_FILE, &ro_signature);
+
+       if (ret != DRMTEST_SUCCESS) {
+               goto error;
+       }
+
+       ret = _add_signature_to_ro(ro_buff, ro_signature, &ro_with_signature);
+
+       if (ret != DRMTEST_SUCCESS) {
+               goto error;
+       }
+
+       //printf("...right object:\n%s\n", ro_with_signature);
+
+       ret = _encrypt_ro_with_dh_sec_key(ro_with_signature, dh_shared_secret_key,
+                                                                         dh_sec_key_len,
+                                                                         &encrypted_ro);
+
+       if (ret != DRMTEST_SUCCESS) {
+               goto error;
+       }
+
+       ret = _create_response_data_in_ro_response(req_id, encrypted_ro, dh_pubkey,
+                       &response_data);
+
+       if (ret != DRMTEST_SUCCESS) {
+               goto error;
+       }
+
+       ret = _create_time_stamp(dh_shared_secret_key, &time_stamp);
+
+       if (ret != DRMTEST_SUCCESS) {
+               goto error;
+       }
+
+       ro_resp_buff_len = strlen(format) + strlen(response_data) + strlen(
+                                                  time_stamp) + 1;
+       ro_resp_buff = (char *) malloc(ro_resp_buff_len);
+
+       if (ro_resp_buff == NULL) {
+               ret = DRMTEST_ERR_MEMORY;
+               goto error;
+       }
+
+       memset(ro_resp_buff, 0, ro_resp_buff_len);
+       sprintf(ro_resp_buff, format, response_data, time_stamp);
+
+       *ro_response_buff = ro_resp_buff;
 
 error:
-    if(pkey != NULL)
-        _free_dh_key(pkey);
-    if(dh_pubkey != NULL)
-        free(dh_pubkey);
-    if(dh_shared_secret_key != NULL)
-        free(dh_shared_secret_key);
-    if(ro_buff != NULL)
-        free(ro_buff);
-    if(ro_signature != NULL)
-        free(ro_signature);
-    if(ro_with_signature != NULL)
-        free(ro_with_signature);
-    if(encrypted_ro != NULL)
-        free(encrypted_ro);
-    if(response_data != NULL)
-        free(response_data);
-    if(time_stamp != NULL)
-        free(time_stamp);
-    if(ret != DRMTEST_SUCCESS && ro_resp_buff != NULL)
-        free(ro_resp_buff);
-
-    return ret;
+
+       if (pkey != NULL)
+               _free_dh_key(pkey);
+
+       if (dh_pubkey != NULL)
+               free(dh_pubkey);
+
+       if (dh_shared_secret_key != NULL)
+               free(dh_shared_secret_key);
+
+       if (ro_buff != NULL)
+               free(ro_buff);
+
+       if (ro_signature != NULL)
+               free(ro_signature);
+
+       if (ro_with_signature != NULL)
+               free(ro_with_signature);
+
+       if (encrypted_ro != NULL)
+               free(encrypted_ro);
+
+       if (response_data != NULL)
+               free(response_data);
+
+       if (time_stamp != NULL)
+               free(time_stamp);
+
+       if (ret != DRMTEST_SUCCESS && ro_resp_buff != NULL)
+               free(ro_resp_buff);
+
+       return ret;
 }
 
 
-int is_identical_files(const char* file1, const char* file2, int* identical)
+int is_identical_files(const char *file1, const char *file2, int *identical)
 {
-    int ret = DRMTEST_SUCCESS;
-
-    FILE *fp1 = NULL, *fp2 = NULL;
-    int ch1, ch2;
-
-    fp1 = fopen(file1, "r");
-    if(fp1 == NULL) {
-        ret = DRMTEST_ERR_IO;
-        goto error;
-    }
-
-    fp2 = fopen(file2, "r");
-    if(fp2 == NULL) {
-        ret = DRMTEST_ERR_IO;
-        goto error;
-    }
-
-    ch1 = getc(fp1);
-    ch2 = getc(fp2);
-    while ((ch1 != EOF) && (ch2 != EOF) && (ch1 == ch2)) {
-        ch1 = getc(fp1);
-        ch2 = getc(fp2);
-    }
-    if(ch1 == ch2)
-        *identical = DRMTEST_IDENTICAL;
-    else
-        *identical = DRMTEST_NOTIDENTICAL;
+       int ret = DRMTEST_SUCCESS;
+
+       FILE *fp1 = NULL, *fp2 = NULL;
+       int ch1, ch2;
+
+       fp1 = fopen(file1, "r");
+
+       if (fp1 == NULL) {
+               ret = DRMTEST_ERR_IO;
+               goto error;
+       }
+
+       fp2 = fopen(file2, "r");
+
+       if (fp2 == NULL) {
+               ret = DRMTEST_ERR_IO;
+               goto error;
+       }
+
+       ch1 = getc(fp1);
+       ch2 = getc(fp2);
+
+       while ((ch1 != EOF) && (ch2 != EOF) && (ch1 == ch2)) {
+               ch1 = getc(fp1);
+               ch2 = getc(fp2);
+       }
+
+       if (ch1 == ch2)
+               *identical = DRMTEST_IDENTICAL;
+       else
+               *identical = DRMTEST_NOTIDENTICAL;
 
 error:
-    if(fp1 != NULL)
-        fclose(fp1);
-    if(fp2 != NULL)
-        fclose(fp2);
-    return ret;
+
+       if (fp1 != NULL)
+               fclose(fp1);
+
+       if (fp2 != NULL)
+               fclose(fp2);
+
+       return ret;
 }
 
index bd94195..2128eca 100644 (file)
@@ -13,6 +13,8 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+#ifndef __DRM_TESTUTIL_H_
+#define __DRM_TESTUTIL_H_
 
 #include <vector>
 #include <openssl/dh.h>
 #define STR_PLACE_HOLDER_DUID       "PLACE_HOLDER_FOR_DUID"
 #define STR_PLACE_HOLDER_SIGNATURE  "PLACE_HOLDER_FOR_SIGNATURE"
 
-#define MAX_CERT_SIZE      (1024*128)
+#define MAX_CERT_SIZE      (1024 * 128)
 
-#define DRMTEST_SUCCESS       ( 0)
+#define DRMTEST_SUCCESS       (0)
 #define DRMTEST_ERR_CRYPTO    (-1)
 #define DRMTEST_ERR_IO        (-2)
 #define DRMTEST_ERR_MEMORY    (-3)
 #define DRMTEST_ERR_TIZDRM    (-4)
 #define DRMTEST_ERR_PARAM     (-5)
 
-#define DRMTEST_IDENTICAL     ( 0)
+#define DRMTEST_IDENTICAL     (0)
 #define DRMTEST_NOTIDENTICAL  (-1)
 
 #define DRMTEST_TEST_ROOT_CERT (1)
 #define DRMTEST_REAL_ROOT_CERT (2)
 
-#define EVP_SUCCESS 1  // DO NOTCHANGE THIS VALUE
+#define EVP_SUCCESS 1   // DO NOTCHANGE THIS VALUE
 
-int generate_purchase_response(char** purchase_response_buff, char** req_id);
+int generate_purchase_response(char **purchase_response_buff, char **req_id);
 
-int generate_right_object_request(const charlicense_response_buff);
+int generate_right_object_request(const char *license_response_buff);
 
-int get_dh_key_from_ro_request(const char* ro_request_buff,
-                              char** dh_key_p, char** dh_key_g, char** dh_key_a);
+int get_dh_key_from_ro_request(const char *ro_request_buff, char **dh_key_p,
+                                                          char **dh_key_g, char **dh_key_a);
 
-int generate_right_object_response(const char* dh_key_p, const char* dh_key_g, const char* dh_key_a,
-                              const char* req_id, const char* cid, const char* ro_template_path,
-                              const char* duid, char** ro_response_buff);
-int is_identical_files(const char* file1, const char* file2, int* identical);
+int generate_right_object_response(const char *dh_key_p, const char *dh_key_g,
+                                                                  const char *dh_key_a, const char *req_id, const char *cid,
+                                                                  const char *ro_template_path, const char *duid,
+                                                                  char **ro_response_buff);
+int is_identical_files(const char *file1, const char *file2, int *identical);
 
 int switch_root_cert(int target_cert_type);
 
 
-void _base64_encode(const unsigned char* input, int len, char** output);
-void _base64_decode(const char* input, unsigned char** output, int* out_len);
-char_replace_all(char *s, const char *olds, const char *news);
-int _read_text_file(const char* path, char** output);
+void _base64_encode(const unsigned char *input, int len, char **output);
+void _base64_decode(const char *input, unsigned char **output, int *out_len);
+char *_replace_all(char *s, const char *olds, const char *news);
+int _read_text_file(const char *path, char **output);
 
-int _create_dh_key(const char* dh_key_p_hex, const char* dh_key_g_hex, DH** ppkey);
-int _free_dh_key(DH* pkey);
-int _get_dh_hex_pubkey(const DH* pkey, char** dh_pubkey);
-int _get_dh_shared_secret_key(const char* dh_hex_pubkey, DH *pkey,
-                                unsigned char** dh_shared_secret_key, int *dh_sec_key_len);
+int _create_dh_key(const char *dh_key_p_hex, const char *dh_key_g_hex,
+                                  DH **ppkey);
+int _free_dh_key(DH *pkey);
+int _get_dh_hex_pubkey(const DH *pkey, char **dh_pubkey);
+int _get_dh_shared_secret_key(const char *dh_hex_pubkey, DH *pkey,
+                                                         unsigned char **dh_shared_secret_key, int *dh_sec_key_len);
 
-int _create_right_object_without_signature(const char* ro_template_path, const char* cid, const char* duid,
-                               char** ro_buff);
-int _create_ro_signature(const char* ro_buff, const char* signer_prikey_path, char** signature);
-int _add_signature_to_ro(const char* ro_buff, const char* signature, char** ro_with_signature);
-int _encrypt_ro_with_dh_sec_key(const char* ro_with_signature,
-                                const unsigned char* dh_secret_key, const int dh_sec_key_len,
-                                char **encrypted_ro);
+int _create_right_object_without_signature(const char *ro_template_path,
+               const char *cid, const char *duid, char **ro_buff);
+int _create_ro_signature(const char *ro_buff, const char *signer_prikey_path,
+                                                char **signature);
+int _add_signature_to_ro(const char *ro_buff, const char *signature,
+                                                char **ro_with_signature);
+int _encrypt_ro_with_dh_sec_key(const char *ro_with_signature,
+                                                               const unsigned char *dh_secret_key, const int dh_sec_key_len,
+                                                               char **encrypted_ro);
 
-int _create_response_data_in_ro_response(const char* reqid, const char* encrypted_ro, const char* dh_pubkey,
-                                char **response_data);
+int _create_response_data_in_ro_response(const char *reqid,
+               const char *encrypted_ro, const char *dh_pubkey, char **response_data);
 
-int _create_time_stamp(const unsigned char* dh_secret_key, char** time_stamp);
+int _create_time_stamp(const unsigned char *dh_secret_key, char **time_stamp);
 
 
 using Binary = std::vector<unsigned char>;
 Binary _read_ro_file(const char *filename);
+
+#endif //__DRM_TESTUTIL_H_