/**
* __VMsgGetName() compares the string and vMsg type, parameter name.
*
- * @param szString Name which will compare
+ * @param szString Name which will compare
* @param pszList[] Name list of vMsg type and param
- * @param size Number of total element of list
+ * @param size Number of total element of list
*
- * @return index The index in the list
+ * @return index The index in the list
*/
int
__VMsgGetName(char* szString, char* pszList[], int size)
/**
* __VMsgGetValue() compares the string and vMsg type, parameter value.
*
- * @param szString Value which will compare
+ * @param szString Value which will compare
* @param list[] Value list of vMsg param
- * @param size Number of total element of list
+ * @param size Number of total element of list
*
- * @return flag The value's flag.
+ * @return flag The value's flag.
*/
int
__VMsgGetValue(char* szString, const ValueObj list[], int size)
* __VMsgGetTypeName() fine the type name and returns the index number
*
* @param pVMsgRaw The raw data
- * @param pStatus Decoder status
+ * @param pStatus Decoder status
* @param pDLen retrived length
*
- * @return res The index in type list
+ * @return res The index in type list
*/
int
__VMsgGetTypeName(char* pVMsgRaw, int* pStatus, int* pDLen)
* __VMsgGetParamName() fine the param name and returns the index number
*
* @param pVMsgRaw The raw data
- * @param pStatus Decoder status
+ * @param pStatus Decoder status
* @param pDLen retrived length
*
- * @return res The index in type list
+ * @return res The index in type list
*/
int
__VMsgGetParamName(char* pVMsgRaw, int* pStatus, int* pDLen)
TRIM(name);
UPPER(name, i, index);
res = __VMsgGetName(name, (char**)pszMsgParamList, VMSG_PARAM_NUM);
- if (res == UNKNOWN_NAME) {
+ if (res == UNKNOWN_NAME)
(*pDLen) = 0;
- }
*pStatus = VMSG_PARAM_VALUE_STATUS;
break;
}
pNextObj = pCurObj->pSibling;
count = pCurObj->valueCount;
- for (i = 0; i < count; i++) {
+ for (i = 0; i < count; i++)
VFREE(pCurObj->pszValue[i]);
- }
if (pCurObj->pParam) {
* __VMsgGetParamVal() fine the param value and returns value.
*
* @param pVMsgRaw The raw data
- * @param pStatus Decoder status
+ * @param pStatus Decoder status
* @param pDLen retrived length
*
- * @return buffer The result value
+ * @return buffer The result value
*/
char*
__VMsgGetParamVal(char* pVMsgRaw, int* pStatus, int* pDLen)
GO_NEXT_CHAR(c, pVMsgRaw, pDLen);
len++;
switch (c) {
- case VTYPE_TOKEN_SEMICOLON:
- *pStatus = VMSG_PARAM_NAME_STATUS;
- break;
- case VTYPE_TOKEN_COLON:
- *pStatus = VMSG_TYPE_VALUE_STATUS;
- break;
- case VTYPE_TOKEN_COMMA:
- *pStatus = VMSG_PARAM_VALUE_STATUS;
- break;
+ case VTYPE_TOKEN_SEMICOLON:
+ *pStatus = VMSG_PARAM_NAME_STATUS;
+ break;
+ case VTYPE_TOKEN_COLON:
+ *pStatus = VMSG_TYPE_VALUE_STATUS;
+ break;
+ case VTYPE_TOKEN_COMMA:
+ *pStatus = VMSG_PARAM_VALUE_STATUS;
+ break;
}
if (c == VTYPE_TOKEN_SEMICOLON
|| c == VTYPE_TOKEN_COLON
/**
* __VMsgGetTypeVal() fine the type value and returns value.
*
- * @param pVMsgRaw The raw data
+ * @param pVMsgRaw The raw data
* @param status Decoder status
- * @return buffer The result value
+ * @return buffer The result value
*/
char*
__VMsgGetTypeVal(char* pVMsgRaw, int* pStatus, int* pDLen, int enc, VObject* pType)
int param_status = false;
int numberedParam = 0;
int enc = 0;
- int start_status = 0;
char* temp = NULL;
char* pVTree = NULL;
bool vmsg_ended = false;
break;
switch (status) {
- case VMSG_TYPE_NAME_STATUS:
- dLen = 0;
- type = __VMsgGetTypeName(pMsgRaw, &status, &dLen);
-
- if (type == VMSG_TYPE_BEGIN)
- pVTree = pMsgRaw;
-
- pMsgRaw += dLen;
-
- if (type == -1)
- break;
-
- switch (type) {
- case VMSG_TYPE_BEGIN:
- dLen = 0;
- enc = 0;
- szMsgBegin = __VMsgGetTypeVal(pMsgRaw, &status, &dLen, enc, NULL);
- pMsgRaw += dLen;
+ case VMSG_TYPE_NAME_STATUS:
+ dLen = 0;
+ type = __VMsgGetTypeName(pMsgRaw, &status, &dLen);
- if (szMsgBegin == NULL)
- goto CATCH;
+ if (type == VMSG_TYPE_BEGIN)
+ pVTree = pMsgRaw;
- if (!strncmp(szMsgBegin, "VCARD", strlen("VCARD"))) {
- VDATA_TRACE("pVTree: %s", pVTree);
- pVCard = vcard_decode(pVTree);
- pCurrent->pNext = pVCard;
- pCurrent = pVCard;
-
- dLen = ((strstr(pMsgRaw, "END:VCARD") + 9) - pMsgRaw);
- pMsgRaw += dLen;
- } else {
-
- if (start_status == 1)
- goto CATCH;
-
-
- if (!strncmp(szMsgBegin, "VMSG", strlen("VMSG"))) {
- if ((pVMsg = (VTree*)calloc(1, sizeof(VTree))) == NULL) {
- start_status = 1;
- goto CATCH;
- }
- memset(pVMsg, 0x00, sizeof(VTree));
-
- pVMsg->treeType = VMESSAGE;
- pVMsg->pTop = NULL;
- pVMsg->pCur = NULL;
- pVMsg->pNext = NULL;
- pCurrent = pVMsg;
- } else if (!strncmp(szMsgBegin, "VBODY", strlen("VBODY"))) {
- if ((pVBody = (VTree*)calloc(1, sizeof(VTree))) == NULL) {
- start_status = 1;
- goto CATCH;
- }
-
- memset(pVBody, 0x00, sizeof(VTree));
- pVBody->treeType = VBODY;
- pVBody->pTop = NULL;
- pVBody->pCur = NULL;
- pVBody->pNext = NULL;
- pCurrent->pNext = pVBody;
- pCurrent = pVBody;
- }
- }
+ pMsgRaw += dLen;
- VFREE(szMsgBegin);
- break;
+ if (type == -1)
+ break;
- case VMSG_TYPE_END:
- dLen = 0;
- enc = 0;
- //szMsgBegin = __VMsgGetTypeVal(pMsgRaw, &status, &dLen, enc, NULL);
-
- if (!strncmp(pMsgRaw, "VMSG", strlen("VMSG"))) {
- done = true;
- vmsg_ended = true;
- } else {
- status = VMSG_TYPE_NAME_STATUS;
- //pMsgRaw += dLen;
- }
- VDATA_TRACE("pMsgRaw:%s", pMsgRaw);
- pMsgRaw += dLen;
- break;
+ switch (type) {
+ case VMSG_TYPE_BEGIN:
+ dLen = 0;
+ enc = 0;
+ szMsgBegin = __VMsgGetTypeVal(pMsgRaw, &status, &dLen, enc, NULL);
+ pMsgRaw += dLen;
- case UNKNOWN_NAME:
- break;
+ if (szMsgBegin == NULL)
+ goto CATCH;
- default:
- if (UNKNOWN_NAME == type || type < 0) {
- status = VMSG_TYPE_NAME_STATUS;
- break;
- }
+ if (!strncmp(szMsgBegin, "VCARD", strlen("VCARD"))) {
+ VDATA_TRACE("pVTree: %s", pVTree);
+ pVCard = vcard_decode(pVTree);
+ if (pCurrent) {
+ pCurrent->pNext = pVCard;
+ }
+ pCurrent = pVCard;
- if ((pTemp = (VObject*)calloc(1, sizeof(VObject))) == NULL) {
+ dLen = ((strstr(pMsgRaw, "END:VCARD") + 9) - pMsgRaw);
+ pMsgRaw += dLen;
+ } else {
+ if (!strncmp(szMsgBegin, "VMSG", strlen("VMSG"))) {
+ if ((pVMsg = (VTree*)calloc(1, sizeof(VTree))) == NULL) {
goto CATCH;
}
-
- memset(pTemp, 0, sizeof(VObject));
- pTemp->property = type;
-
- if (pCurrent->pTop == NULL) {
- pCurrent->pTop = pTemp;
- pCurrent->pCur = pTemp;
- } else {
- pCurrent->pCur->pSibling = pTemp;
- pCurrent->pCur = pTemp;
+ memset(pVMsg, 0x00, sizeof(VTree));
+
+ pVMsg->treeType = VMESSAGE;
+ pVMsg->pTop = NULL;
+ pVMsg->pCur = NULL;
+ pVMsg->pNext = NULL;
+ pCurrent = pVMsg;
+ } else if (!strncmp(szMsgBegin, "VBODY", strlen("VBODY"))) {
+ if ((pVBody = (VTree*)calloc(1, sizeof(VTree))) == NULL) {
+ goto CATCH;
}
- break;
+ memset(pVBody, 0x00, sizeof(VTree));
+ pVBody->treeType = VBODY;
+ pVBody->pTop = NULL;
+ pVBody->pCur = NULL;
+ pVBody->pNext = NULL;
+ if (pCurrent)
+ pCurrent->pNext = pVBody;
+ pCurrent = pVBody;
+ }
}
- numberedParam = 0;
- param_status = false;
- valueCount = 0;
+ VFREE(szMsgBegin);
break;
- case VMSG_PARAM_NAME_STATUS:
- {
+ case VMSG_TYPE_END:
dLen = 0;
- param = __VMsgGetParamName(pMsgRaw, &status, &dLen);
+ enc = 0;
+ /* szMsgBegin = __VMsgGetTypeVal(pMsgRaw, &status, &dLen, enc, NULL); */
+
+ if (!strncmp(pMsgRaw, "VMSG", strlen("VMSG"))) {
+ done = true;
+ vmsg_ended = true;
+ } else {
+ status = VMSG_TYPE_NAME_STATUS;
+ /* pMsgRaw += dLen; */
+ }
+ VDATA_TRACE("pMsgRaw:%s", pMsgRaw);
pMsgRaw += dLen;
+ break;
- if (param_status != true) {
+ case UNKNOWN_NAME:
+ break;
- if ((pTmpParam = (VParam*)calloc(1, sizeof(VParam))) == NULL)
- goto CATCH;
+ default:
+ if (UNKNOWN_NAME == type || type < 0) {
+ status = VMSG_TYPE_NAME_STATUS;
+ break;
+ }
- param_status = true;
- pCurrent->pCur->pParam = pTmpParam;
- memset(pTmpParam, 0x00, sizeof(VParam));
- VDATA_TRACE("pTmpParam : %p", pTmpParam);
- } else {
- if ((pTmpParam->pNext = (VParam*)calloc(1, sizeof(VParam))) == NULL)
- goto CATCH;
+ if ((pTemp = (VObject*)calloc(1, sizeof(VObject))) == NULL)
+ goto CATCH;
- pTmpParam = pTmpParam->pNext;
- memset(pTmpParam, 0x00, sizeof(VParam));
- VDATA_TRACE("pTmpParam : %p", pTmpParam);
+ memset(pTemp, 0, sizeof(VObject));
+ pTemp->property = type;
+
+ if (pCurrent) {
+ if (pCurrent->pTop == NULL) {
+ pCurrent->pTop = pTemp;
+ pCurrent->pCur = pTemp;
+ } else {
+ pCurrent->pCur->pSibling = pTemp;
+ pCurrent->pCur = pTemp;
+ }
}
- pTmpParam->parameter = param;
break;
}
- case VMSG_PARAM_VALUE_STATUS:
- dLen = 0;
- numberedParam = 0;
- switch (pTmpParam->parameter) {
- case VMSG_PARAM_TYPE:
- szValue = __VMsgGetParamVal(pMsgRaw, &status, &dLen);
- numberedParam |= __VMsgGetValue(szValue, pMsgTypeList, VMSG_TYPE_PARAM_NUM);
- break;
- case VMSG_PARAM_VALUE:
- szValue = __VMsgGetParamVal(pMsgRaw, &status, &dLen);
- numberedParam |= __VMsgGetValue(szValue, pMsgValueList, VMSG_VALUE_PARAM_NUM);
- break;
- case VMSG_PARAM_ENCODING:
- szValue = __VMsgGetParamVal(pMsgRaw, &status, &dLen);
- numberedParam |= __VMsgGetValue(szValue, pMsgEncList, VMSG_ENCODE_PARAM_NUM);
- enc = numberedParam;
- break;
- case VMSG_PARAM_CHARSET:
- szValue = __VMsgGetParamVal(pMsgRaw, &status, &dLen);
- numberedParam |= __VMsgGetValue(szValue, pMsgCharsetList, VMSG_CHARSET_PARAM_NUM);
- break;
- case VMSG_PARAM_CONTEXT:
- case VMSG_PARAM_LANGUAGE:
- // prevent 7605 08.03.13
- szValue = __VMsgGetParamVal(pMsgRaw, &status, &dLen);
- numberedParam = 0;
- break;
- default:
- szValue = __VMsgGetParamVal(pMsgRaw, &status, &dLen);
- SET_PARAM_VALUE(numberedParam, szValue, pMsgTypeList, VMSG_TYPE_PARAM_NUM, pTmpParam, VMSG_PARAM_TYPE, enc);
- SET_PARAM_VALUE(numberedParam, szValue, pMsgValueList, VMSG_VALUE_PARAM_NUM, pTmpParam, VMSG_PARAM_VALUE, enc);
- SET_PARAM_VALUE(numberedParam, szValue, pMsgEncList, VMSG_ENCODE_PARAM_NUM, pTmpParam, VMSG_PARAM_ENCODING, enc);
- SET_PARAM_VALUE(numberedParam, szValue, pMsgCharsetList, VMSG_CHARSET_PARAM_NUM, pTmpParam, VMSG_PARAM_CHARSET, enc);
+ numberedParam = 0;
+ param_status = false;
+ valueCount = 0;
+ break;
- numberedParam = 0;
- pMsgRaw += dLen;
- dLen = 0;
+ case VMSG_PARAM_NAME_STATUS:
+ {
+ dLen = 0;
+ param = __VMsgGetParamName(pMsgRaw, &status, &dLen);
+ pMsgRaw += dLen;
- break;
- }
+ if (param_status != true) {
- VDATA_TRACE("%d, %s, %p", numberedParam, szValue, pTmpParam);
- pTmpParam->paramValue = numberedParam;
- pTmpParam->pNext = NULL;
- VFREE(szValue);
- pMsgRaw += dLen;
+ if ((pTmpParam = (VParam*)calloc(1, sizeof(VParam))) == NULL)
+ goto CATCH;
+
+ param_status = true;
+ if (pCurrent)
+ pCurrent->pCur->pParam = pTmpParam;
+ memset(pTmpParam, 0x00, sizeof(VParam));
+ VDATA_TRACE("pTmpParam : %p", pTmpParam);
+ } else {
+ if ((pTmpParam->pNext = (VParam*)calloc(1, sizeof(VParam))) == NULL)
+ goto CATCH;
+
+ pTmpParam = pTmpParam->pNext;
+ memset(pTmpParam, 0x00, sizeof(VParam));
+ VDATA_TRACE("pTmpParam : %p", pTmpParam);
+ }
+
+ pTmpParam->parameter = param;
+ break;
+ }
+ case VMSG_PARAM_VALUE_STATUS:
+ dLen = 0;
+ numberedParam = 0;
+ switch (pTmpParam->parameter) {
+ case VMSG_PARAM_TYPE:
+ szValue = __VMsgGetParamVal(pMsgRaw, &status, &dLen);
+ numberedParam |= __VMsgGetValue(szValue, pMsgTypeList, VMSG_TYPE_PARAM_NUM);
break;
- case VMSG_TYPE_VALUE_STATUS:
- dLen = 0;
- temp = __VMsgGetTypeVal(pMsgRaw, &status, &dLen, enc, pCurrent->pCur);
+ case VMSG_PARAM_VALUE:
+ szValue = __VMsgGetParamVal(pMsgRaw, &status, &dLen);
+ numberedParam |= __VMsgGetValue(szValue, pMsgValueList, VMSG_VALUE_PARAM_NUM);
+ break;
+ case VMSG_PARAM_ENCODING:
+ szValue = __VMsgGetParamVal(pMsgRaw, &status, &dLen);
+ numberedParam |= __VMsgGetValue(szValue, pMsgEncList, VMSG_ENCODE_PARAM_NUM);
+ enc = numberedParam;
+ break;
+ case VMSG_PARAM_CHARSET:
+ szValue = __VMsgGetParamVal(pMsgRaw, &status, &dLen);
+ numberedParam |= __VMsgGetValue(szValue, pMsgCharsetList, VMSG_CHARSET_PARAM_NUM);
+ break;
+ case VMSG_PARAM_CONTEXT:
+ case VMSG_PARAM_LANGUAGE:
+ /* prevent 7605 08.03.13 */
+ szValue = __VMsgGetParamVal(pMsgRaw, &status, &dLen);
+ numberedParam = 0;
+ break;
+ default:
+ szValue = __VMsgGetParamVal(pMsgRaw, &status, &dLen);
- if (valueCount < VDATA_VALUE_COUNT_MAX) {
- pCurrent->pCur->pszValue[valueCount] = temp;
- valueCount++;
- pCurrent->pCur->valueCount = valueCount;
- VDATA_TRACE("object property: %d, value: %s", pCurrent->pCur->property, pCurrent->pCur->pszValue[valueCount - 1]);
- } else
- VFREE(temp);
+ SET_PARAM_VALUE(numberedParam, szValue, pMsgTypeList, VMSG_TYPE_PARAM_NUM, pTmpParam, VMSG_PARAM_TYPE, enc);
+ SET_PARAM_VALUE(numberedParam, szValue, pMsgValueList, VMSG_VALUE_PARAM_NUM, pTmpParam, VMSG_PARAM_VALUE, enc);
+ SET_PARAM_VALUE(numberedParam, szValue, pMsgEncList, VMSG_ENCODE_PARAM_NUM, pTmpParam, VMSG_PARAM_ENCODING, enc);
+ SET_PARAM_VALUE(numberedParam, szValue, pMsgCharsetList, VMSG_CHARSET_PARAM_NUM, pTmpParam, VMSG_PARAM_CHARSET, enc);
+ numberedParam = 0;
pMsgRaw += dLen;
+ dLen = 0;
+
break;
+ }
+
+ VDATA_TRACE("%d, %s, %p", numberedParam, szValue, pTmpParam);
+ pTmpParam->paramValue = numberedParam;
+ pTmpParam->pNext = NULL;
+ VFREE(szValue);
+ pMsgRaw += dLen;
+ break;
+ case VMSG_TYPE_VALUE_STATUS:
+ dLen = 0;
+ temp = __VMsgGetTypeVal(pMsgRaw, &status, &dLen, enc, pCurrent->pCur);
+
+ if (valueCount < VDATA_VALUE_COUNT_MAX) {
+ pCurrent->pCur->pszValue[valueCount] = temp;
+ valueCount++;
+ pCurrent->pCur->valueCount = valueCount;
+ VDATA_TRACE("object property: %d, value: %s", pCurrent->pCur->property, pCurrent->pCur->pszValue[valueCount - 1]);
+ } else
+ VFREE(temp);
+
+ pMsgRaw += dLen;
+ break;
}
}
VDATA_TRACE("pMsgRawTmp: %s", pMsgRawTmp);
- //VFREE(pMsgRawTmp);
+ /* VFREE(pMsgRawTmp); */
- if (pVMsg->pTop == NULL) {
+ if (pVMsg && pVMsg->pTop == NULL) {
VDATA_TRACE("pVMsg->Top: NULL");
goto CATCH;
}
goto CATCH1;
}
VDATA_TRACE_END
+ VFREE(pTemp);
+ VFREE(pTmpParam);
+ VFREE(pVBody);
return pVMsg;
CATCH:
VFREE(pTemp);
CATCH1:
+ VFREE(pTemp);
VFREE(szMsgBegin);
VFREE(pMsgRawTmp);
+ VFREE(pTmpParam);
+ VFREE(pVBody);
vmsg_free_vtree_memory(pVMsg);
VDATA_TRACE_END
return NULL;
char* pTemp = NULL;
int len;
int total = 0;
- int cnt = 0;
+ int cnt = 0;
+
+ if (!pVMsgRaw || !pVMsgRaw->pTop) {
+ return NULL;
+ }
for (; cnt < pVMsgRaw->pTop->valueCount; cnt++) {
while (true) {
switch (pTmpTree->treeType) {
- case VMESSAGE:
- if (pVMsgRes) {
- free(pVMsgRes);
- pVMsgRes = NULL;
- }
+ case VMESSAGE:
+ if (pVMsgRes) {
+ free(pVMsgRes);
+ pVMsgRes = NULL;
+ }
- if ((pVMsgRes = (char *)calloc(1, sizeof(char) * (total += 13))) == NULL) {
- VDATA_TRACE("vmsg_encode:calloc failed\n");
- VDATA_TRACE_END
- return NULL;
- }
- memcpy(pVMsgRes, "BEGIN:VMSG\r\n", 13);
- break;
+ if ((pVMsgRes = (char *)calloc(1, sizeof(char) * (total += 13))) == NULL) {
+ VDATA_TRACE("vmsg_encode:calloc failed\n");
+ VDATA_TRACE_END
+ return NULL;
+ }
+ memcpy(pVMsgRes, "BEGIN:VMSG\r\n", 13);
+ break;
- case VBODY:
- if ((pTmpVMsgRes = (char *)realloc(pVMsgRes, sizeof(char) * (total += 14))) == NULL) {
- VDATA_TRACE("vmsg_encode:realloc failed\n");
- VFREE(pVMsgRes);
- VDATA_TRACE_END
- return NULL;
- }
+ case VBODY:
+ if ((pTmpVMsgRes = (char *)realloc(pVMsgRes, sizeof(char) * (total += 14))) == NULL) {
+ VDATA_TRACE("vmsg_encode:realloc failed\n");
+ VFREE(pVMsgRes);
+ VDATA_TRACE_END
+ return NULL;
+ }
- pVMsgRes = pTmpVMsgRes;
- g_strlcat(pVMsgRes, "BEGIN:VBODY\r\n", 13);
- break;
+ pVMsgRes = pTmpVMsgRes;
+ g_strlcat(pVMsgRes, "BEGIN:VBODY\r\n", 13);
+ break;
- case VCARD:
- break;
+ case VCARD:
+ break;
}
while (true) {
len = strlen(encoded);
- if ((pTmpVMsgRes = (char*)realloc(pVMsgRes, (total += len+10))) == NULL) {
+ if ((pTmpVMsgRes = (char*)realloc(pVMsgRes, (total += len+10))) == NULL) {
VDATA_TRACE("vmsg_encode():realloc failed\n");
VFREE(pTemp);
VFREE(encoded);
break;
}
}
-
-
}
switch (pTmpTree->treeType) {
- case VBODY:
- if ((pTmpVMsgRes = (char *)realloc(pVMsgRes, (total += 12))) == NULL) {
- VFREE(pVMsgRes);
- VDATA_TRACE("vcal_encode():realloc failed\n");
- return NULL;
- }
+ case VBODY:
+ if ((pTmpVMsgRes = (char *)realloc(pVMsgRes, (total += 12))) == NULL) {
+ VFREE(pVMsgRes);
+ VDATA_TRACE("vcal_encode():realloc failed\n");
+ return NULL;
+ }
- pVMsgRes = pTmpVMsgRes;
- g_strlcat(pVMsgRes, "END:VBODY\r\n", 12);
- break;
+ pVMsgRes = pTmpVMsgRes;
+ g_strlcat(pVMsgRes, "END:VBODY\r\n", 12);
+ break;
- case VCARD:
- break;
+ case VCARD:
+ break;
- case VMESSAGE:
- break;
+ case VMESSAGE:
+ break;
}
char *pszVmsgBegin = "BEGIN:VMSG";
switch (mode) {
- case CHECK_START:
- for (i = 0; i < 10; i++)
- if (*pszVmsgBegin++ != *pMsgRaw++)
- rtnValue = false;
- break;
-
- default:
- rtnValue = false;
+ case CHECK_START:
+ for (i = 0; i < 10; i++)
+ if (*pszVmsgBegin++ != *pMsgRaw++)
+ rtnValue = false;
+ break;
+
+ default:
+ rtnValue = false;
}
VDATA_TRACE_END
return rtnValue;
int len;
char* pTemp = NULL;
char* szTypeValue = NULL;
+ char* szTemp = NULL;
int i;
int enc = 0;
char* pEncode = NULL;
pTemp = __VMsgParamEncode(pTypeObj, &enc);
if (pTemp != NULL) {
len = strlen(pTemp);
- if ((szTypeValue = (char *)realloc(szTypeValue, (total += len))) == NULL) {
+ if ((szTemp = (char *)realloc(szTypeValue, (total += len))) == NULL) {
VDATA_TRACE("__VMsgTypeEncode():realloc failed\n");
VFREE(pTemp);
- pTemp = NULL
- VDATA_TRACE_END;
+ pTemp = NULL;
+ VFREE(szTypeValue);
+ VDATA_TRACE_END
return NULL;
+ } else {
+ szTypeValue = szTemp;
}
g_strlcat(szTypeValue, pTemp, len);
VFREE(pTemp);
pTemp = NULL;
}
- if ((szTypeValue = (char *)realloc(szTypeValue, (total += 2))) == NULL) {
+ if ((szTemp = (char *)realloc(szTypeValue, (total += 2))) == NULL) {
+ VFREE(szTypeValue);
VDATA_TRACE_END
return NULL;
+ } else {
+ szTypeValue = szTemp;
}
g_strlcat(szTypeValue, ":", 2);
if (pTypeObj->pszValue[i] != NULL)
len += strlen(pTypeObj->pszValue[i]);
- }
+ }
} else
len += biLen;
}
}
- if ((pRes = (char *)realloc(pRes, strlen(pRes) + 3)) == NULL) {
+ if ((szTemp = (char *)realloc(pRes, strlen(pRes) + 3)) == NULL) {
VFREE(pEncode);
VFREE(szTypeValue);
+ VFREE(pRes);
VDATA_TRACE_END
return NULL;
+ } else {
+ pRes = szTemp;
}
g_strlcat(pRes, "\r\n", strlen(pRes) + 2);
len = strlen(pRes);
- if ((szTypeValue = (char *)realloc(szTypeValue, (total += (len+3)))) == NULL) {
+ if ((szTemp = (char *)realloc(szTypeValue, (total += (len+3)))) == NULL) {
VFREE(pEncode);
VFREE(pRes);
+ VFREE(szTypeValue);
VDATA_TRACE_END
return NULL;
+ } else {
+ szTypeValue = szTemp;
}
g_strlcat(szTypeValue, pRes, total - 1);
int shift = 0;
bool bSupported;
char* szParam = NULL;
+ char* szTemp = NULL;
VParam* pTemp = NULL;
ValueObj* pList = NULL;
bSupported = false;
/** Expand szParam string. For appending.*/
- if ((szParam = (char *)realloc(szParam, len += 15)) == NULL) {
+ if ((szTemp = (char *)realloc(szParam, len += 15)) == NULL) {
+ VFREE(szParam);
VDATA_TRACE_END
return NULL;
+ } else {
+ szParam = szTemp;
}
/** appending paramter name. */
/** Set Parameter Value name. */
switch (pTemp->parameter) {
- case VMSG_PARAM_ENCODING:
- *pEnc = pMsgEncList[pTemp->paramValue].flag;
- shift = VMSG_ENCODE_PARAM_NUM;
- pList = pMsgEncList; bSupported = true;
- break;
- case VMSG_PARAM_TYPE:
- shift = VMSG_TYPE_PARAM_NUM;
- pList = pMsgTypeList; bSupported = true;
- break;
- case VMSG_PARAM_VALUE:
- shift = VMSG_VALUE_PARAM_NUM;
- pList = pMsgValueList; bSupported = true;
- break;
- case VMSG_PARAM_CHARSET:
- shift = VMSG_CHARSET_PARAM_NUM;
- pList = pMsgCharsetList; bSupported = true;
- break;
- default:
- if ((szParam = (char*)realloc(szParam, 5)) == NULL) {
- VDATA_TRACE_END
- return NULL;
- }
- g_strlcat(szParam, "NONE", strlen("NONE"));
+ case VMSG_PARAM_ENCODING:
+ *pEnc = pMsgEncList[pTemp->paramValue].flag;
+ shift = VMSG_ENCODE_PARAM_NUM;
+ pList = pMsgEncList; bSupported = true;
+ break;
+ case VMSG_PARAM_TYPE:
+ shift = VMSG_TYPE_PARAM_NUM;
+ pList = pMsgTypeList; bSupported = true;
+ break;
+ case VMSG_PARAM_VALUE:
+ shift = VMSG_VALUE_PARAM_NUM;
+ pList = pMsgValueList; bSupported = true;
+ break;
+ case VMSG_PARAM_CHARSET:
+ shift = VMSG_CHARSET_PARAM_NUM;
+ pList = pMsgCharsetList; bSupported = true;
+ break;
+ default:
+ if ((szTemp = (char*)realloc(szParam, 5)) == NULL) {
+ VFREE(szParam);
+ VDATA_TRACE_END
+ return NULL;
+ } else {
+ szParam = szTemp;
+ }
+ g_strlcat(szParam, "NONE", strlen("NONE"));
}
/** exchage parameter value's to string.*/
for (i = 0, sNum = 0x00000001; i < shift; i++) {
if (pList[pTemp->paramValue].flag & sNum) {
- if ((szParam = (char *)realloc(szParam, (len += (strlen(pList[i].szName) + 2)))) == NULL) {
+ if ((szTemp = (char *)realloc(szParam, (len += (strlen(pList[i].szName) + 2)))) == NULL) {
+ VFREE(szParam);
VDATA_TRACE_END
return NULL;
+ } else {
+ szParam = szTemp;
}
g_strlcat(szParam, pList[i].szName, len);