VOS_UINT32 At_GetSecondAddr(VOS_UINT8 *pData,VOS_UINT16 usLen, VOS_UINT8** ppDataOut) { VOS_UINT8* pucFirAddr = NULL; VOS_UINT8* pucSecAddr = NULL; VOS_UINT32 ulBasicCmdLen = 0; VOS_UINT8* pcTmp = NULL; /* 比较字符串需要保证字符串后面有\0 */ pcTmp = (VOS_UINT8*)AT_MALLOC(usLen+1); if(NULL == pcTmp) { return ERR_MSP_FAILURE; } PS_MEM_CPY(pcTmp, pData, usLen); pcTmp[usLen] = '\0'; pucFirAddr = At_GetFirstBasicCmdAddr(pcTmp, &ulBasicCmdLen); if(NULL == pucFirAddr) { AT_FREE(pcTmp); return ERR_MSP_FAILURE; } pucSecAddr = At_GetFirstBasicCmdAddr((pucFirAddr + ulBasicCmdLen), &ulBasicCmdLen); if(NULL == pucSecAddr) { *ppDataOut = pData + usLen; } else { *ppDataOut = pData + (pucSecAddr - pcTmp); } AT_FREE(pcTmp); return ERR_MSP_SUCCESS; }
static VOS_VOID atScanDmcmdModifier( VOS_UINT8 *pData, VOS_UINT16 *pLen) { VOS_UINT16 usLen = 0; VOS_UINT8 *pWrite = VOS_NULL_PTR; VOS_UINT8 *pRead = VOS_NULL_PTR; VOS_UINT8 *pTmp = VOS_NULL_PTR; VOS_UINT8 *pDataTmp = VOS_NULL_PTR; VOS_UINT8 aucStr[] = "*99**PPP"; VOS_UINT16 usStrLen = 0; pDataTmp = (VOS_UINT8*)AT_MALLOC(*pLen + 1); if (VOS_NULL_PTR == pDataTmp) { vos_printf("atScanDmcmdModifier(): AT_MALLOC Failed!\n"); return; } atRangeCopy(pDataTmp, pData, (pData + *pLen)); /* 保证字符串有结束符 */ pDataTmp[*pLen] = 0; pRead = pDataTmp; pWrite = pDataTmp; pTmp = (VOS_UINT8*)AT_STRSTR((VOS_CHAR *)pDataTmp,(VOS_CHAR *)aucStr); if(NULL != pTmp) { usStrLen = (VOS_UINT16)AT_STRLEN((VOS_CHAR *)aucStr); /* 检查前一半参数 */ while ( pRead < pTmp ) { /*删除修饰符,',','T','P','!','W','@'*/ if((',' != *pRead) && ('T' != *pRead) && ('P' != *pRead) && ('!' != *pRead) && ('W' != *pRead) && ('@' != *pRead)) { *pWrite++ = *pRead; usLen++; } pRead++; } while( pRead < (pTmp+usStrLen) ) { *pWrite++ = *pRead++; usLen++; } while( pRead < (pDataTmp+(*pLen)) ) { /*删除修饰符,',','T','P','!','W','@'*/ if((',' != *pRead) && ('T' != *pRead) && ('P' != *pRead) && ('!' != *pRead) && ('W' != *pRead) && ('@' != *pRead)) { *pWrite++ = *pRead; usLen++; } pRead++; } } else { /* 输入参数检查 */ while ( pRead < (pDataTmp+(*pLen)) ) { /*删除修饰符,',','T','P','!','W','@'*/ if((',' != *pRead) && ('T' != *pRead) && ('P' != *pRead) && ('!' != *pRead) && ('W' != *pRead) && ('@' != *pRead)) { *pWrite++ = *pRead; usLen++; } pRead++; } } atRangeCopy(pData, pDataTmp, (pDataTmp + *pLen)); *pLen = usLen; AT_FREE(pDataTmp); return; }