diff options
Diffstat (limited to 'mobicore/rootpa/Code/Common/contentmanager.c')
-rw-r--r-- | mobicore/rootpa/Code/Common/contentmanager.c | 94 |
1 files changed, 47 insertions, 47 deletions
diff --git a/mobicore/rootpa/Code/Common/contentmanager.c b/mobicore/rootpa/Code/Common/contentmanager.c index 2f3c029..6a2ffeb 100644 --- a/mobicore/rootpa/Code/Common/contentmanager.c +++ b/mobicore/rootpa/Code/Common/contentmanager.c @@ -1,33 +1,33 @@ /* -Copyright © Trustonic Limited 2013 - -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - 3. Neither the name of the Trustonic Limited nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED -OF THE POSSIBILITY OF SUCH DAMAGE. -*/ + * Copyright (c) 2013 TRUSTONIC LIMITED + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ #include <string.h> #include <stdlib.h> @@ -58,7 +58,7 @@ rootpaerror_t openCmtlSession() { closeCmtlSession(); } - + handle_=tltChannelOpen(sizeOfCmp(), &error); if(NULL==handle_) { @@ -70,20 +70,20 @@ rootpaerror_t openCmtlSession() { ret=ROOTPA_ERROR_MOBICORE_CONNECTION; } - } + } return ret; } rootpaerror_t executeOneCmpCommand(CMTHANDLE handle, CmpMessage* commandP, CmpMessage* responseP); rootpaerror_t executeContentManagementCommands(int numberOfCommands, CmpMessage* commandsP, CmpMessage* responsesP, uint32_t* internalError) -{ +{ rootpaerror_t ret=ROOTPA_OK ; rootpaerror_t iRet=ROOTPA_OK ; bool selfOpened=false; CMTHANDLE handle; LOGD(">>executeContentManagementCommands"); - + *internalError=0; if(handle_==NULL) @@ -94,8 +94,8 @@ rootpaerror_t executeContentManagementCommands(int numberOfCommands, CmpMessage* ret=openCmtlSession(); selfOpened=true; } - handle=handle_; - + handle=handle_; + if (handle) { int i; @@ -103,7 +103,7 @@ rootpaerror_t executeContentManagementCommands(int numberOfCommands, CmpMessage* { responsesP[i].hdr.id=commandsP[i].hdr.id; // match the id; responsesP[i].hdr.ignoreError=commandsP[i].hdr.ignoreError; - + if(commandsP[i].length>0) { if(((iRet=executeOneCmpCommand(handle, &commandsP[i], &responsesP[i]))!=ROOTPA_OK)) @@ -114,7 +114,7 @@ rootpaerror_t executeContentManagementCommands(int numberOfCommands, CmpMessage* { responsesP[i].hdr.ret=ret; } - + if(commandsP[i].hdr.ignoreError==false) { LOGE("executeContentManagementCommands, ignoreError==false, returning %d", ret); @@ -125,7 +125,7 @@ rootpaerror_t executeContentManagementCommands(int numberOfCommands, CmpMessage* else { LOGE("executeContentManagementCommands, empty command"); - } + } } if(ret!=ROOTPA_OK) @@ -164,7 +164,7 @@ rootpaerror_t executeOneCmpCommand(CMTHANDLE handle, CmpMessage* commandP, CmpMe rootpaerror_t ret; uint32_t neededBytes; LOGD(">>executeOneCmpCommand"); - if (unlikely( bad_write_ptr(handle,sizeof(CMTSTRUCT)))) + if (unlikely( bad_write_ptr(handle,sizeof(CMTSTRUCT)))) { return ROOTPA_ERROR_INTERNAL; } @@ -175,7 +175,7 @@ rootpaerror_t executeOneCmpCommand(CMTHANDLE handle, CmpMessage* commandP, CmpMe mcRet=MC_DRV_OK; commandId=getCmpCommandId(commandP->contentP); - + handle->mappedSize=getTotalMappedBufferSize(commandP); if(0==handle->mappedSize) { @@ -184,7 +184,7 @@ rootpaerror_t executeOneCmpCommand(CMTHANDLE handle, CmpMessage* commandP, CmpMe } ret=ROOTPA_OK; - while(true) + while(true) { handle->mappedP=(uint8_t*)malloc((size_t) handle->mappedSize); if(NULL==handle->mappedP) @@ -224,15 +224,15 @@ rootpaerror_t executeOneCmpCommand(CMTHANDLE handle, CmpMessage* commandP, CmpMe break; } - if(-1==neededBytes) + if((uint32_t)-1==neededBytes) { - ret=ROOTPA_ERROR_MOBICORE_CONNECTION; + ret=ROOTPA_ERROR_MOBICORE_CONNECTION; break; } if(neededBytes <= handle->mappedSize) { - LOGE("executeOneCmpCommand, there is something wrong. CMTL is requesting smaller buffer than we originally had. Command: %d, original %d requested %d", + LOGE("executeOneCmpCommand, there is something wrong. CMTL is requesting smaller buffer than we originally had. Command: %d, original %d requested %d", commandId, handle->mappedSize, neededBytes); ret=ROOTPA_ERROR_MOBICORE_CONNECTION; break; @@ -270,10 +270,10 @@ rootpaerror_t executeOneCmpCommand(CMTHANDLE handle, CmpMessage* commandP, CmpMe LOGE("executeOneCmpCommand not able to free mapped memory %d", mcRet); ret=ROOTPA_ERROR_MOBICORE_CONNECTION; } - LOGD("freeing mapped memory %ld", (long int) handle->mappedP); - free(handle->mappedP); + LOGD("freeing mapped memory %ld", (long int) handle->mappedP); + free(handle->mappedP); if(commandP->hdr.ret==ROOTPA_OK) commandP->hdr.ret=ret; - if(responseP->hdr.ret==ROOTPA_OK) responseP->hdr.ret=ret; + if(responseP->hdr.ret==ROOTPA_OK) responseP->hdr.ret=ret; LOGD("<<executeOneCmpCommand %d %d",commandId, ret); return ret; } |