int CXPack::EncodeRow(const ST_PACKHEAD *phead, const void *pdata, void *ebuf, int ebsize) { int rtn; if (pdata==NULL /* ****** Updated by CHENYH at 2005-11-12 16:53:01 ****** ||phead->recCount<=0 *******************************************************/ ) return(0); rtn = phandle.EncodeRow(phead->ParmBits,pdata,ebuf,ebsize); if (rtn==0) { /* ****** Updated by CHENYH at 2004-10-14 15:23:34 ****** if ((int)(phead->recCount)>ebsize) return(-11); // 被编码的数据超过用于编码的缓冲区长度 if (phead->recCount>0) { memcpy(ebuf,pdata,phead->recCount); } return(phead->recCount); */ ST_SDPACK *psd=(ST_SDPACK *)pdata; rtn = psd->usDataLength+sizeof(psd->usDataLength); if (rtn>ebsize||rtn>phandle.GetPackLength()) return(-11); memcpy(ebuf,pdata,rtn); HostByteOrder(ebuf,sizeof(psd->usDataLength)); return(rtn); } else { return(rtn); } }
int StringFromGUID2(const GUID& guid, OMCHAR* buffer, int bufferSize) { if (HostByteOrder() == 'L') { guidMap = &idMapLittle[0]; } else { guidMap = &idMapBig[0]; } const unsigned char* ip = (const unsigned char*) &guid; // input pointer OMCHAR* op = buffer; // output pointer *op++ = L'{'; for (size_t i = 0; i < sizeof(idMapLittle); i++) { if (guidMap[i] == '-') { *op++ = L'-'; } else { *op++ = digits[ (ip[guidMap[i]] & 0xF0) >> 4 ]; *op++ = digits[ (ip[guidMap[i]] & 0x0F) ]; } } *op++ = L'}'; *op = L'\0'; return GUIDSTRMAX; }
int CXPack::DecodeRow(const ST_PACKHEAD *phead, const void *ebuf, int eblen, void *pdata) { int rtn; rtn = phandle.DecodeRow(phead->ParmBits,ebuf,eblen,pdata); if (rtn==0) { /* ****** Updated by CHENYH at 2004-10-14 15:39:24 ****** if (phead->recCount>0) { memcpy(pdata,ebuf,phead->recCount); } return(phead->recCount); */ ST_SDPACK *psd=(ST_SDPACK *)pdata; memcpy(pdata,ebuf,sizeof(psd->usDataLength)); HostByteOrder(pdata,sizeof(psd->usDataLength)); /* ****** Updated by CHENYH at 2006-2-22 12:31:30 ****** 因为出现了传入数据不正确导致这里异常 *******************************************************/ if (eblen<(int)(sizeof(psd->usDataLength)+psd->usDataLength)) { psd->usDataLength = 0; return(-10); // 是不eblen传入参数错 } ////////////////////////////////////////////////////////////////////////// if (psd->usDataLength>0) memcpy(psd->data,((char *)ebuf)+sizeof(psd->usDataLength),psd->usDataLength); return(psd->usDataLength+sizeof(psd->usDataLength)); } else return(rtn); }