📄 de_api.c
字号:
if(i > 0)
{
long n = 0;
// unsigned char* pTemp = buf + i;
while(buf[i + n] < 0x80)
++n;
if(n > 0)
{
long t = 0;
long nCurPos;
nAntonymNum = SingleFindWordNumInSameType(buf + i, nLen - i);
*pContentLen += (DWORD)((DWORD)(nAntonymNum + 1) * sizeof(DESTR));
*pContentLen = AlignSize(*pContentLen);
//pContent->pAntonym = (DESTR*)MyVirtualMalloc(ppBufContent,
// (nAntonymNum + 1) * sizeof(DESTR));
nCurPos = i;
//pContent->numofAntonym = nAntonymNum;
while(t < nAntonymNum)
{
long nWordLen = SingleFindNextWordInSameType(buf + nCurPos, nLen - nCurPos);
*pContentLen += (DWORD)(2 * nWordLen + 2);
*pContentLen = AlignSize(*pContentLen);
//pContent->pAntonym[t] = (DESTR)MyVirtualMalloc(ppBufContent,
// 2 * nWordLen + 2);
//SingleUCMemcpy(pContent->pAntonym[t], buf + nCurPos, nWordLen);
t ++;
nCurPos += nWordLen + 1;
}
//pContent->pAntonym[nAntonymNum] = 0x00;
}
}
/*
fill synonym
*/
i = FindUCCh(buf, nLen, CH_TYC);
if(i > 0)
{
long n = 0;
// unsigned char* pTemp = buf + i;
while(buf[i + n] < 0x80)
++n;
if(n > 0)
{
long t = 0;
long nCurPos;
nSynonymNum = SingleFindWordNumInSameType(buf + i, nLen - i);
*pContentLen += (DWORD)((DWORD)(nSynonymNum + 1) * sizeof(DESTR));
*pContentLen = AlignSize(*pContentLen);
//pContent->pSynonym = (DESTR*)MyVirtualMalloc(ppBufContent,
// (nSynonymNum + 1) * sizeof(DESTR));
nCurPos = i;
//pContent->numofSynonym = nSynonymNum;
while(t < nSynonymNum)
{
long nWordLen = SingleFindNextWordInSameType(buf + nCurPos, nLen - nCurPos);
*pContentLen += (DWORD)(2 * nWordLen + 2);
*pContentLen = AlignSize(*pContentLen);
//pContent->pSynonym[t] = (DESTR)MyVirtualMalloc(ppBufContent,
// 2 * nWordLen + 2);
//SingleUCMemcpy(pContent->pSynonym[t], buf + nCurPos, nWordLen);
t ++;
nCurPos += nWordLen + 1;
}
//pContent->pSynonym[nSynonymNum] = 0x00;
}
}
/*
fill explanation
*/
i = FindUCCh(buf, nLen, CH_JS);
*pContentLen += sizeof(ONEEXP);
*pContentLen = AlignSize(*pContentLen);
//pContent->explanation = (ONEEXP*)MyVirtualMalloc(ppBufContent, sizeof(ONEEXP));
GetExpSize((BYTE*)buf + i, nLen - i, pContentLen);
}
static void FillCEBufInStruct(LPDEData pData, unsigned char* buf, long nLen, ONECONT* pContent, char** ppBufContent)
{
LPDEGlobalData lpGlobal = (LPDEGlobalData)pData->pRAM;
long i;
long nPos, nLastPos;
long nWordNum = 0;
WORDLIST* pWordList;
DESTR pPinyin;
DECHAR ushPinyinTemp[MAX_WORD_SIZE];
pContent->numofAntonym = 0;
pContent->numofIrregular = 0;
pContent->numofSynonym = 0;
pContent->pIrregular = NULL;
pContent->pAntonym = NULL;
pContent->pSynonym = NULL;
//pContent->phoneSym = NULL;
pContent->pronunciation = NULL;
if(lpGlobal->pinyinbuflen > 0)
pContent->phoneSym = (DESTR)MyVirtualMalloc(ppBufContent, (long)(lpGlobal->pinyinbuflen));
else
pContent->phoneSym = 0;
pPinyin = pContent->phoneSym;
i = 0;
if(buf[i] == CH_PINYIN)
{
++i;
while(buf[i] != CH_JS)
{
int nPZLen;
GetPinyinBuf(pData, (WORD)(GetUShortFromBuf((BYTE*)buf + i) - 0x5000), ushPinyinTemp);
nPZLen = SJTU_strlenW(ushPinyinTemp);
pPinyin = SJTU_strcpyW(pPinyin, ushPinyinTemp);
pPinyin[nPZLen] = ' ';
pPinyin += nPZLen + 1;
i += 2;
}
pPinyin[0] = 0x00;
}
nPos = ++i;
for(; i < nLen; i ++)
{
if(buf[i] == CH_COMPART)
nWordNum ++;
}
++nWordNum;
pContent->explanation = (ONEEXP*)MyVirtualMalloc(ppBufContent, sizeof(ONEEXP));
pContent->explanation->typeofword = 0;
pContent->explanation->pNext = NULL;
pContent->explanation->interpretation = (WORDLIST*)MyVirtualMalloc(ppBufContent, sizeof(WORDLIST));
i = 0;
pWordList = pContent->explanation->interpretation;
nLastPos = nPos;
while(i < nWordNum)
{
long j = 0;
while(buf[nPos] != CH_COMPART && nPos < nLen)
{
++ j;
++ nPos;
}
pWordList->pWord = (DESTR)MyVirtualMalloc(ppBufContent, 2 * j + 2);
++nPos;
pWordList->pWord[j] = 0; /* '\0' */
while(j > 0)
{
pWordList->pWord[j - 1] = (unsigned short)buf[nLastPos + j - 1];
--j;
}
nLastPos = nPos;
if(i < nWordNum - 1)
{
pWordList->pNext = (WORDLIST*)MyVirtualMalloc(ppBufContent, sizeof(WORDLIST));
pWordList = pWordList->pNext;
}
else
pWordList->pNext = NULL;
++i;
}
}
static unsigned short TransYB(unsigned char ch)
//static unsigned char TransYB(unsigned char ch)
{
return ch;
switch(ch)
{
case 0x01:
return '1';
//return 0x026a;
case 0x02:
return '2';
//return 0x025b;
case 0x03:
return '3';
//return 0x00e6;
case 0x04:
return '4';
//return 0x0251;
case 0x06:
return '5';
//return 0x0254;
case 0x0b:
return '6';
//return 0x0275;
case 0x0f:
return '7';
//return 0x028c;
case 0x10:
return '8';
//return 0x0259;
case 0x19:
return '9';
//return 0x014b;
case 0x1c:
return '0';
//return 0x00f0;
case 0x1d:
return '<';
//return 0x0283;
case 0x1e:
return '>';
//return 0x0292;
case 0x1f:
return '|';
//return 0x02cf;
default:
return (unsigned short)ch;
}
}
static void UCMemcpy(unsigned short* pDes, unsigned char* pSrc, long nLen)
{
long i = 0;
unsigned char* p = pSrc;
while(i < nLen - 1)
{
*pDes++ = (unsigned short)(((unsigned short)p[i] << 8) | p[i + 1]);
i += 2;
}
*pDes = 0x00;
}
static void SingleUCMemcpy(unsigned short* pDes, unsigned char* pSrc, long nLen)
{
long i = 0;
while(i < nLen)
{
*pDes++ = (unsigned short)pSrc[i++];
}
*pDes = 0x00;
}
static void FillExp(unsigned char* buf, long nLen, ONEEXP* pOneExp, char** ppBufContent)
{
ONEEXP* pExp = pOneExp;
long nCurPos = 0;
long nTypeNum = FindTypeNumInExp(buf, nLen);
long nType = 0;
while(nType < nTypeNum)
{
WORDLIST* pWord;
long nWordNum = FindWordNumInSameType(buf + nCurPos, nLen - nCurPos);
long nWord = 0;
long nOffset;
pExp->interpretation = (WORDLIST*)MyVirtualMalloc(ppBufContent, sizeof(WORDLIST));
pWord = pExp->interpretation;
if(buf[nCurPos] == 0x00 && buf[nCurPos + 1] <= TYPE_ABBR)
{
pExp->typeofword = (BYTE)buf[nCurPos + 1];
nCurPos += 2;
}
else
pExp->typeofword = 0x00;
nOffset = nCurPos;
while(nWord < nWordNum)
{
long nWordLen = FindNextWordInSameType(buf + nOffset, nLen - nOffset);
pWord->pWord = (DESTR)MyVirtualMalloc(ppBufContent, nWordLen + 2);
UCMemcpy(pWord->pWord, buf + nOffset, nWordLen);
if(nWord < nWordNum - 1)
{
pWord->pNext = (WORDLIST*)MyVirtualMalloc(ppBufContent, sizeof(WORDLIST));
pWord = pWord->pNext;
nOffset += nWordLen + 2;
}
else
{
pWord->pNext = NULL;
nOffset += nWordLen;
}
++nWord;
}
if(nType < nTypeNum - 1)
{
pExp->pNext = (ONEEXP*)MyVirtualMalloc(ppBufContent, sizeof(ONEEXP));
pExp = pExp->pNext;
}
else
pExp->pNext = NULL;
//nCurPos = nOffset + 2;
nCurPos = nOffset;
++nType;
}
}
static void FillECBufInStruct(unsigned char* buf, long nLen, ONECONT* pContent, char** ppBufContent)
{
long nIrregularNum;
long nAntonymNum;
long nSynonymNum;
// unsigned char* p = buf;
long i;
/*
fill phoneSym
*/
long t = 0;
i = FindUCCh(buf, nLen, CH_YB);
if(i > 0)
{
long n = 0;
// unsigned char* pTemp = buf + i;
while(buf[i + n] < 0x80)
++n;
if(n > 0)
{
pContent->phoneSym = (DESTR)MyVirtualMalloc(ppBufContent, 2 * n + 2);
/*
for(t = 0; t < n; t ++)
buf[i + t] = TransYB(buf[i + t]);
*/
for(t = 0; t < n; t ++)
pContent->phoneSym[t] = TransYB(buf[i + t]);
pContent->phoneSym[t] = 0x00;
//SingleUCMemcpy(pContent->phoneSym, buf + i , n);
}
else
pContent->phoneSym = NULL;
}
else
pContent->phoneSym = NULL;
/*
fill pronunciation
*/
i = FindUCCh(buf, nLen, CH_FY);
if(i > 0)
{
long n = 0;
// unsigned char* pTemp = buf + i;
while(buf[i + n] < 0x80)
++n;
if(n > 0)
{
pContent->pronunciation = (DESTR)MyVirtualMalloc(ppBufContent, 2 * n + 2);
SingleUCMemcpy(pContent->pronunciation, buf + i, n);
}
else
pContent->pronunciation = NULL;
}
else
pContent->pronunciation = NULL;
/*
fill irregular
*/
i = FindUCCh(buf, nLen, CH_BGZ);
if(i > 0)
{
long n = 0;
// unsigned char* pTemp = buf + i;
while(buf[i + n] < 0x80)
++n;
if(n > 0)
{
long nCurPos;
t = 0;
nIrregularNum = SingleFindWordNumInSameType(buf + i, nLen - i);
pContent->pIrregular = (DESTR*)MyVirtualMalloc(ppBufContent,
(nIrregularNum + 1) * (long)(sizeof(DESTR)));
nCurPos = i;
pContent->numofIrregular = (unsigned char)nIrregularNum;
while(t < nIrregularNum)
{
long nWordLen = SingleFindNextWordInSameType(buf + nCurPos, nLen - nCurPos);
pContent->pIrregular[t] = (DESTR)MyVirtualMalloc(ppBufContent,
2 * nWordLen + 2);
SingleUCMemcpy(pContent->pIrregular[t], buf + nCurPos, nWordLen);
t ++;
nCurPos += nWordLen + 1;
}
pContent->pIrregular[nIrregularNum] = 0x00;
}
}
else
{
pContent->pIrregular = NULL;
pContent->numofIrregular = 0;
}
/*
fill antonym
*/
i = FindUCCh(buf, nLen, CH_FYC);
if(i > 0)
{
long n = 0;
// unsigned char* pTemp = buf + i;
while(buf[i + n] < 0x80)
++n;
if(n > 0)
{
long nCurPos;
t = 0;
nAntonymNum = SingleFindWordNumInSameType(b
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -