Back to index

im-sdk  12.3.91
Functions | Variables
ciku.c File Reference
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "GeneType.h"
#include "PyBasic.h"
#include "ciku.h"

Go to the source code of this file.

Functions

VOID ProcGbkHz (VOID)
VOID CreateUdCikuFile ()
JINT ReadUdcData (CHAR *szUdcName)
JINT WriteUdcData (CHAR *szUdcName, JINT nTimeStamp)
JINT AddUdc (JWORD *pwHz2244, JINT nLen)
JINT DelUdc (JWORD *pwHz2244, JINT nLen)
JINT PureUdc (VOID)
VOID ParseSample (VOID)
VOID ListSysCandiInfo (SysCandi *psc)
JINT GetXrdCandi (SysCandi *psc, JINT nXrd, JWORD *pwOneCandi)
VOID ParseRawInputStr (CHAR *szPreedit, JINT *pnOutPreedit)
VOID DecompPeIntArray (JINT *pnOutPreedit, CHAR *szDspPreedit)
JINT HzcodeToYjcode (JINT nHzcode)
JINT Hzcode2244ToYjcode (JINT nHzcode)
JINT GetDyzInfo (JINT nHzcode, JINT *pnDyzYjCode)
JINT EncodeDyzTo2244 (JINT nHzcode, JINT nYjcode)
JINT FastMatchYinJieStr (CHAR *szPystr)
UCHARRecovDyz2244 (UCHAR *szDyz2244)
CHAR LastChar (JINT nYinjieCode)
CHAR FirstChar (JINT nYinjieCode)
JINT ValidButLastChar (JINT nYinjieCode)
JINT ValidButFirstChar (JINT nYinjieCode)
JINT ValidAddChar (CHAR ch, JINT nYinjieCode)
VOID InitCizuItem (JINT nItems)
VOID InitSingleHanziByYj (JINT nArraySize)
VOID InitCizuGroupByYj (JINT nArraySize)
VOID CopyStructCZ (CizuItem *pThisCZ, CizuItem *pNewCZ)
VOID GetAllCizuItems (JINT nMode)
VOID GetAllCizuItems_CZPY (JINT nMode)
JINT GetNextLine (FILE *pfFile, CHAR *szBuf)
VOID FilterVtoU (UCHAR *pszLine)
VOID GetHzInfo (UCHAR *pszLine, UCHAR *pszHz, JINT *pnYj, JINT *pnHzNum, JINT *pnYjNum)
VOID GetYjInfo (UCHAR *pszLine, UCHAR *pszHz, JINT *pnYj, UCHAR *pszHz2244)
JINT EnumFanganForm (UCHAR *pszHz, JINT *pnYj, JINT nYjNum, JINT *pnbFanganFlag, JINT *pnFanganYj, JINT nMode, JINT nDspMode)
JINT EnumEnaoForm (UCHAR *pszHz, JINT *pnYj, JINT nYjNum, JINT *pnbEnaoFlag, JINT *pnFanganYj, JINT nMode, JINT nDspMode)
JINT EnumXianForm (UCHAR *pszHz, JINT *pnYj, JINT nYjNum, JINT *pnbXianFlag, JINT *pnXianYj, JINT nMode, JINT nDspMode)
VOID BuildSingleHzDB (JINT nDspMode)
JINT CompIntArray (JINT *pnArray1, JINT *pnArray2)
VOID QuickSort (JINT nFirst, JINT nLast)
VOID CreateAllData ()
VOID CreateCikuFile ()
VOID SetCkh (CikuHeader *pCkh)
VOID SetShi (ShIndex *pShi)
VOID SetDhi (DhIndex *pDhi)
VOID SetMhi (MhIndex *pMhi)
JINT WriteCikuData (CHAR *szSysCikuName, JINT nTimeStamp)
JINT GetCikuData (CHAR *szSysCikuName)
SysCandiLookupSysCiku (JINT *pnOrgYj, JINT nLenYj, JINT nMatchMode)
VOID AdjustFreq (JWORD *pwHz2244, JINT nLenThis)
VOID BuildSingleHzDB_Old (JINT nDspMode)
VOID ParseSample ()
int main (int argc, char **argv)

Variables

JINT nItemNum
JINT nSortNumber
CizuItem czCZ [MAX_CIZU_ITEMS]
SingleHanziByYj shSH [NUM_YINJIE]
CizuGroupByYj cgCG [NUM_YINJIE]

Function Documentation

JINT AddUdc ( JWORD pwHz2244,
JINT  nLen 
)

Definition at line 792 of file UdCikuOper.c.

{
       JINT    i, nTmp1, nTmp2;
       JINT    nCurSize;
       JINT    nFreqLen, nTmpLen;
       JINT    nFirstYj;

       if (nLen <= 1)
              return FALSE;

       nFirstYj = GbkHz2244ToYj(pwHz2244[0]);
       if (nFirstYj == 0xFFFF)
       {
              fprintf(stderr, "Error in AddUdc.\n");
              return FALSE;
       }

       /* 
       **  STEP1: Is it necessary to realloc() for this Yinjie's space? 
       */
       nCurSize = udcAll.udci.nYjOff[nFirstYj + 1] - udcAll.udci.nYjOff[nFirstYj];    /* In BYTE */
       nTmp1    = ((nCurSize + UDCMEM_ALIGN) / UDCMEM_ALIGN) * UDCMEM_ALIGN;
       nTmp2    = ((nCurSize + ((nLen + 1) * sizeof(JWORD)) + UDCMEM_ALIGN) / UDCMEM_ALIGN) * UDCMEM_ALIGN;
       if (nTmp2 > nTmp1)
       {
              udcAll.pwUdc28[nFirstYj] = (JWORD*)realloc(udcAll.pwUdc28[nFirstYj], nTmp2);
              if (udcAll.pwUdc28[nFirstYj] == NULL)
              {
                     fprintf(stderr, "Failed to realloc() in AddUdc().\n");
                     return FALSE;
              }
              for(i = 0; i < (UDCMEM_ALIGN) / 2; i++)
                     udcAll.pwUdc28[nFirstYj][nTmp1 + i] = 0x0000;
       }

       /*
       ** STEP2:  Reduce the Frequence of other Udc for FUTURE FUNCTION: DiscardUdc().
       ** Notice: Cannot DiscardUdc() here, that will make the LOGIC confusion.
       */
       /* NO i++ in this FOR sentence */
       for (i = 0; i < nCurSize / 2; )
       {
              nFreqLen = (JINT)udcAll.pwUdc28[nFirstYj][i];
              nTmpLen  = (nFreqLen & 0x0007) + 2;
              if (nFreqLen >= 0x0010)
                     udcAll.pwUdc28[nFirstYj][i] -= 8;
              i += (nTmpLen + 1);
       }

       /*
       ** STEP3:  Append this pwHz2244 just after pwUdc28[nFirstYj][nCurSize / 2]
       ** Set the Frequence of this pwHz2244 to the Highest: 11111xxx.
       ** xxx from 000 to 111, indicates length from 2 to 9
       */
       nFreqLen = 0x00F8 + (nLen - 2);
       udcAll.pwUdc28[nFirstYj][nCurSize / 2] = (JWORD)nFreqLen;
       for (i = 0; i < nLen; i++)
              udcAll.pwUdc28[nFirstYj][(nCurSize / 2) + 1 + i] = pwHz2244[i];

       /*
       ** STEP4:  Adjust udcAll.udci.nYjOff[nFirstYj + 1] to nYjOff[NUM_YINJIE]
       */
       for (i = nFirstYj; i < NUM_YINJIE; i++)
              udcAll.udci.nYjOff[i + 1] += 2 * (nLen + 1);

       return TRUE;
}

Here is the call graph for this function:

VOID AdjustFreq ( JWORD pwHz2244,
JINT  nLenThis 
)

Definition at line 1128 of file CikuOper.c.

{
       JINT    nYjFirst;
       JINT    nCzLen, i, k, m, t;
       JINT    nFromOff, nToOff;
       JWORD   wCzHz, wMhLenFreq, wFreq;
       JINT    nEqualFlag;
       CHAR    szDhYj1[14], szDhYj2[14];
       UCHAR   pchHz2244[20];     /* Max is 9 Hanzi!! */
       JINT    nFindFlag;
       JINT    nUdc28FreqLen, nUdc28Len;
       JINT    nCurSize;
       JINT    nXianNum, nPos;
       BYTE    *pbAreaBase;

       CikuHeader  *pCkh;
       ShIndex     *pShi;
       DhIndex     *pDhi;
       MhIndex     *pMhi;
       GbkIndex    *pGbki;
       BYTE        *pShArea;
       BYTE        *pDhArea;
       BYTE        *pMhArea;
       BYTE        *pGbkArea;

       pCkh     = (CikuHeader *)pCkAll;
       pShi     = (ShIndex  *)(pCkAll + pCkh->nIdxShPos);
       pDhi     = (DhIndex  *)(pCkAll + pCkh->nIdxDhPos);
       pMhi     = (MhIndex  *)(pCkAll + pCkh->nIdxMhPos);
       pGbki    = (GbkIndex *)(pCkAll + pCkh->nIdxGbkPos);
       
       pShArea  = (BYTE *)(pCkAll + pShi->nStartPos);
       pDhArea  = (BYTE *)(pCkAll + pDhi->nStartPos);
       pMhArea  = (BYTE *)(pCkAll + pMhi->nStartPos);
       pGbkArea = (BYTE *)(pCkAll + pGbki->nStartPos);

       memset(pchHz2244, '\0', 20);
       Jword2Uchar(pwHz2244, pchHz2244, nLenThis);
       
       nFindFlag = FALSE;
       /* nYjFirst must be in range 0~414 */
       nYjFirst = GbkHz2244ToYj((JINT)pwHz2244[0]);

       if (nLenThis >= 3)
       {
              /*
              **  Determine the FromOff and ToOff which to used for searching by the pnOrgYj[0].
              */
              nFromOff = pMhi->nYjOff[ nYjFirst ];
              nToOff   = pMhi->nYjOff[ nYjFirst + 1];
              
              /* !! DON'T add k++ in this FOR sentence !! */
              for (k = nFromOff; k < nToOff; )
              {
                     wMhLenFreq = (JWORD)*(pMhArea + k);
                     nCzLen     = 2 + ((UCHAR)*(pMhArea + k) & 0x07);
                     k++;

                     /*  It is just this Cizu, Increase its frequence here. */
                     if ((nCzLen == nLenThis) &&
                            (strncmp((CHAR*)(&pMhArea[k]), (CHAR*)pchHz2244, 2 * nCzLen) == 0) )
                     {
                            /* Just set Frequence to highest. */
                            *(pMhArea + k - 1) = (BYTE)(0xF8 + (nCzLen - 2));
                            k += (2 * nCzLen);
                            nFindFlag = TRUE;
                     }
                     /*
                     **  Have the same length. Is it also have same Yjcode? If yes, 
                     **  reduce the frequence.
                     */
                     else if ((nCzLen == nLenThis) &&
                             (strncmp((CHAR*)(&pMhArea[k]), (CHAR*)pchHz2244, 2 * nCzLen) != 0) )
                     {
                            nEqualFlag = TRUE;

                            /*
                            ** Compare from the second Hanzi, because the first Hanzi must
                            ** same Yjcode. So, skip the first by adding t += 2.
                            */
                            t = k;
                            t += 2;
                            for (m = 1; m < nCzLen; m++)
                            {
                                   wCzHz   = (JWORD)(*(pMhArea + t + 1) + ((*(pMhArea + t)) << 8));
                                   t += 2;

                                   if ( GbkHz2244ToYj((JINT)pwHz2244[1]) != GbkHz2244ToYj((JINT)wCzHz) )
                                   {
                                          nEqualFlag = FALSE;
                                          break;
                                   }
                            }

                            /* Have same Yjcodes in every Hanzi, reduce its Frequence Here. */
                            if (nEqualFlag == TRUE)
                            {
                                   wMhLenFreq = (JWORD)*(pMhArea + k - 1);
                                   /*
                                   ** Length bits have the lowest 3 bits.  -8 means reduce the Frequence
                                   ** by ONE level. if its Freq Level is 1, no reduce needed.
                                   */
                                   if (wMhLenFreq >= 16)
                                          *(pMhArea + k - 1) -= 8;
                            }

                            k += (2 * nCzLen);
                     }
                     /* If it doesn't have the same length, just skip this cizu. */
                     else
                            k += (2 * nCzLen);
              }
       }
       
       else if (nLenThis == 2)
       {
              /*
              **  Determine the FromOff and ToOff which to used for searching by the pnOrgYj[0].
              */
              nFromOff = pDhi->nYjOff[ nYjFirst ];
              nToOff   = pDhi->nYjOff[ nYjFirst + 1];
              
              /* !! DON'T add k++ in this FOR sentence !! */
              for (k = nFromOff; k < nToOff; )
              {
                     wFreq   = (JWORD)*(pDhArea + k);
                     nCzLen  = 2;
                     k++;

                     /*  It is just this Cizu, Increase its frequence here. */
                     if (strncmp((CHAR*)(&pDhArea[k]), (CHAR*)pchHz2244, 4) == 0)
                     {
                            *(pDhArea + k - 1) = 0xFF;
                            k += 4;
                            nFindFlag = TRUE;
                     }
                     /*
                     **  Have the same length. Is it also have same Yjcode? If yes, 
                     **  reduce the frequence.
                     */
                     else
                     {
                            for(i = 0; i < 14; i++)
                                   szDhYj1[i] = szDhYj2[i] = '\0';

                            /* Cat total YinjieString into szDhYj1 */
                            strcat( strcat(szDhYj1, YINJIESTR_CSZ[nYjFirst]),       
                                                    YINJIESTR_CSZ[GbkHz2244ToYj((JINT)pwHz2244[1])] );

                            t = k;
                            wCzHz   = (JWORD)(*(pDhArea + t + 1) + ((*(pDhArea + t)) << 8));
                            strcat(szDhYj2, YINJIESTR_CSZ[GbkHz2244ToYj((JINT)wCzHz)]);

                            t += 2;
                            wCzHz   = (JWORD)(*(pDhArea + t + 1) + ((*(pDhArea + t)) << 8));
                            strcat(szDhYj2, YINJIESTR_CSZ[GbkHz2244ToYj((JINT)wCzHz)]);

                            nEqualFlag = TRUE;
                            if (strcmp(szDhYj1, szDhYj2) != 0)
                                   nEqualFlag = FALSE;

                            /* Have same Yjcodes in every Hanzi, reduce its Frequence Here. */
                            if (nEqualFlag == TRUE)
                            {
                                   wFreq = (JWORD)*(pDhArea + k - 1);
                                   /*
                                   ** Decrease by ONE Level.
                                   */
                                   if (wFreq >= 2)
                                          *(pDhArea + k - 1) -= 1;
                            }
                            k += 4;

                     }
              }
       }

       /* nLenThis == 1, GB and GBK */
       else if (nLenThis == 1)
       {
              if (IsGbkkkHz(pwHz2244[0]) == TRUE)   /* GbKkk */
              {
                     nFromOff   = pGbki->nYjOff[ nYjFirst ];
                     nToOff     = pGbki->nYjOff[ nYjFirst + 1 ];
                     pbAreaBase = pGbkArea;
              }
              else    /* Normal GB */
              {
                     nXianNum   = (pShi->nYjOff[nYjFirst + 1] & 0x0F000000) >> 24;
                     nFromOff   = pShi->nYjOff[nYjFirst] & 0x00FFFFFF;
                     nToOff     = (pShi->nYjOff[nYjFirst + 1] & 0x00FFFFFF) - (4 * nXianNum);
                     pbAreaBase = pShArea;
              }
              
              nPos = 0;
              for (k = nFromOff; k < nToOff; k += 2)
              {
                     if (strncmp((CHAR*)(&pbAreaBase[k]), (CHAR*)pchHz2244, 2) == 0)
                     {
                            nPos = (k - nFromOff) / 2;
                            break;
                     }
              }
              
              /*
              **  If NOT the first Hanzi in ShArea[nYj] or GbkArea[nYj], move this Hanzi
              **  forward by (nPos / 4  + 1)
              */
              if (nPos > 0)
              {
                     m = 0;
                     for (k = nFromOff + (2 * nPos); m < (nPos / 4  + 1); )
                     {
                            pbAreaBase[k + 1] = pbAreaBase[k - 1];
                            pbAreaBase[k]     = pbAreaBase[k - 2];
                            k -= 2;
                            m++;
                     }
                     pbAreaBase[k + 1] = pchHz2244[1];
                     pbAreaBase[k]     = pchHz2244[0];
              }
       }

       /*
       **  Otherwise, this must be an UserDefinedCizu.
       */
       if ((nLenThis >= 2) && (nFindFlag == FALSE))
       {
              nCurSize   = udcAll.udci.nYjOff[nYjFirst + 1] - udcAll.udci.nYjOff[nYjFirst];      /* In BYTE */

              /* NO i++ in this FOR sentence */
              for (i = 0; i < nCurSize / 2; )
              {
                     nUdc28FreqLen =  udcAll.pwUdc28[nYjFirst][i] & 0x00FF;
                     nUdc28Len     = (udcAll.pwUdc28[nYjFirst][i] & 0x0007) + 2;
                     i++;

                     /*  It is just this Cizu, Increase its frequence here. */
                     if ((nUdc28Len == nLenThis) &&
                            (strncmp((CHAR*)&(udcAll.pwUdc28[nYjFirst][i]), (CHAR*)pchHz2244, 2 * nUdc28Len) == 0) )
                     {
                            /* Just set Frequence to highest. */
                            udcAll.pwUdc28[nYjFirst][i - 1] = (BYTE)(0xF8 + (nUdc28Len - 2));
                            i += nUdc28Len;
                            nFindFlag = TRUE;
                     }
                     else
                     {
                            if (nUdc28FreqLen >= 0x0010)
                                   udcAll.pwUdc28[nYjFirst][i - 1] -= 8;
                            i += nUdc28Len;
                     }
              }
       }

}

Here is the call graph for this function:

Here is the caller graph for this function:

VOID BuildSingleHzDB ( JINT  nDspMode)

Definition at line 773 of file ciku.c.

{
       FILE*  pfShFile;
       CHAR   szShName[] = "SingleHz.txt";
       UCHAR  *chFileBuf;
       JINT   nSize, nRes, nLen, i, j, t1;
       UCHAR  szLineBuf[256];
       UCHAR  szPyStr[8];
       JINT   nCurYj;
       JINT   nHzcode;


       pfShFile = fopen(szShName, "rb");
       if (pfShFile == NULL)
       {
              fprintf(stderr, "Failed to open File < %s >.\n", szShName);
              exit(FALSE);
       }

       fseek(pfShFile, 0, SEEK_END);
       nSize = (JINT)ftell(pfShFile);

       fseek(pfShFile, 0, SEEK_SET);

       nCurYj = -1;
       for(t1 = 1; t1 == 1; )
       {
              memset(szLineBuf, 0, 256);
              t1 = GetNextLine(pfShFile, (CHAR*)szLineBuf);
              nLen = strlen((CHAR*)szLineBuf);

              i = 0;
              if((nLen >= 1) && (szLineBuf[0] == '['))
              {
                     /* Lines Start with '[' */
                     memset(szPyStr, 0, 8);
                     for(i = 0; ((i < 6) && (szLineBuf[i + 1] != ']')); i++ )
                            szPyStr[i] = szLineBuf[i + 1];

                     nRes = FastMatchYinJieStr((CHAR*)szPyStr);
                     if ((nRes >= 0) && (nRes <= 414))
                            nCurYj = nRes;
                     else
                            nCurYj = -1;
              }
              else if ((nLen >= 1) && (szLineBuf[0] == '#'))
              {
                     /* Just skip Lines start with '#' */
              }
              else if (nLen >= 1)
              {
                     /* Normal Lines */
                     if((nCurYj >= 0) && (nCurYj <= 414))
                     {
                            for(i = 0; i < nLen;  )
                            {
                                   if ((szLineBuf[i] >= 0xA1) && (szLineBuf[i + 1] >= 0xA1))    /* It is a MSB of Chinese */
                                   {
                                          nHzcode = 0;
                                          nHzcode = (szLineBuf[i] << 8) + szLineBuf[i + 1];
                                          nRes = EncodeDyzTo2244(nHzcode, nCurYj);
                                          if(nRes != 0xFFFF)     /* It is really a DuoYinZi!! */
                                                 nHzcode = nRes;

                                          shSH[nCurYj].szHanzi[2 * shSH[nCurYj].nHzNum]      = (UCHAR)((nHzcode & 0xFF00) >> 8);
                                          shSH[nCurYj].szHanzi[2 * shSH[nCurYj].nHzNum + 1] = (UCHAR)(nHzcode & 0x00FF);
                                          shSH[nCurYj].nHzNum ++;
                                          i += 2;
                                   }
                                   else
                                          i++;
                            }
                     }
              }
              else
              {
                     /* NULL Lines, just skip it */
              }
       }

       fclose(pfShFile);

       if ((nDspMode == SINGLEHZ_DSP_SIMP) || (nDspMode == SINGLEHZ_DSP_FULL))
       {
              for (i = 0; i < 83; i++)
              {
                     for (j = 0; j < 5; j++)
                            printf ("[%6s] %3d  ", YINJIESTR_CSZ[i * 5 + j], shSH[i * 5 + j].nHzNum);
                     printf ("\n");
              }
       }

       if (nDspMode == SINGLEHZ_DSP_FULL)
       {
              for (i = 0; i < 415; i++)
                     printf ("[%s] %3d\n%s\n\n", YINJIESTR_CSZ[i], shSH[i].nHzNum, RecovDyz2244(shSH[i].szHanzi));
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

VOID BuildSingleHzDB_Old ( JINT  nDspMode)

Definition at line 711 of file ciku.c.

{
       JINT   i, j, k;
       JINT   nHzcode, nYjcode;

       k = 0;
       for (i = 0xB0; i <= 0xF7; i++)
       {
              for (j = 0xA1; j <= 0xFE; j++)
              {
                     if (!( (i == 0xD7) && (j >= 0xFA) ))
                     {
                            nHzcode = (i << 8) + j;
                            nYjcode = Hzcode2244ToYjcode(nHzcode);

                            if ((nYjcode >= 0) && (nYjcode <= 414))
                            {
                                   shSH[nYjcode].szHanzi[2 * shSH[nYjcode].nHzNum]      = (UCHAR)i;
                                   shSH[nYjcode].szHanzi[2 * shSH[nYjcode].nHzNum + 1] = (UCHAR)j;
                                   shSH[nYjcode].nHzNum ++;
                            }
                     }
              }
       }

       k = 0;
       for (i = 0x2001; i <= 0x2244; i++)
       {
              nYjcode = Hzcode2244ToYjcode(i);
              if ((nYjcode >= 0) && (nYjcode <= 414))
              {
                     shSH[nYjcode].szHanzi[2 * shSH[nYjcode].nHzNum]      = (UCHAR)((i >> 8) & 0x00FF);
                     shSH[nYjcode].szHanzi[2 * shSH[nYjcode].nHzNum + 1] = (UCHAR)(i & 0x00FF);

                     shSH[nYjcode].nHzNum ++;
              }
       }

       if ((nDspMode == SINGLEHZ_DSP_SIMP) || (nDspMode == SINGLEHZ_DSP_FULL))
       {
              for (i = 0; i < 83; i++)
              {
                     for (j = 0; j < 5; j++)
                            printf ("[%6s] %3d  ", YINJIESTR_CSZ[i * 5 + j], shSH[i * 5 + j].nHzNum);
                     printf ("\n");
              }
       }

       if (nDspMode == SINGLEHZ_DSP_FULL)
       {
              for (i = 0; i < 415; i++)
                     printf ("[%s] %3d\n%s\n\n", YINJIESTR_CSZ[i], shSH[i].nHzNum, RecovDyz2244(shSH[i].szHanzi));
       }
}

Here is the call graph for this function:

JINT CompIntArray ( JINT pnArray1,
JINT pnArray2 
)

Definition at line 684 of file ciku.c.

{
       JINT   i = 0;
       while ((pnArray1[i] == pnArray2[i]) && (pnArray1[i] != 0xFFFF))
       {
              i++;
       }

       if ((pnArray1[i] > pnArray2[i]) && (pnArray1[i] != 0xFFFF))
              return 1;
       if ((pnArray1[i] > pnArray2[i]) && (pnArray1[i] == 0xFFFF))
              return -1;
       if ((pnArray2[i] > pnArray1[i]) && (pnArray2[i] != 0xFFFF))
              return -1;
       if ((pnArray2[i] > pnArray1[i]) && (pnArray2[i] == 0xFFFF))
              return 1;

       return 0;
}

Here is the caller graph for this function:

VOID CopyStructCZ ( CizuItem pThisCZ,
CizuItem pNewCZ 
)

Definition at line 104 of file ciku.c.

{
       JINT   i, nSiz;

       nSiz = sizeof(CizuItem);

       for (i = 0; i < nSiz; i++)
              *((UCHAR*)pNewCZ + i) = *((UCHAR*)pThisCZ + i);
}

Here is the caller graph for this function:

Definition at line 53 of file CreateData.c.

{
       JINT   i, j, k, t;
       JINT   nTmpRes;
       JINT   nFanganNum, nEnaoNum, nXianNum, nXianNum2;
       JINT   nFrom, nTo;
       JINT   nFlag[MAX_CIZU_ITEMS];

       InitCizuItem (MAX_CIZU_ITEMS);
       InitSingleHanziByYj (NUM_YINJIE);
       InitCizuGroupByYj (NUM_YINJIE);

       GetAllCizuItems(READ_RAW_CIZU);

       for(i = 0; i < nItemNum; i++)
       {
              FilterVtoU(czCZ[i].szLine);
              GetHzInfo (czCZ[i].szLine, czCZ[i].szHz, czCZ[i].nYj, &(czCZ[i].nHzNum), &(czCZ[i].nYjNum));
              GetYjInfo (czCZ[i].szLine, czCZ[i].szHz, czCZ[i].nYj, czCZ[i].szHz2244);
       }

       nFanganNum = 0;
       for(i = 0; i < nItemNum; i++)
       {
              nTmpRes = EnumFanganForm(czCZ[i].szHz, czCZ[i].nYj, czCZ[i].nYjNum, &(czCZ[i].nbIsFanganForm), czCZ[i].nFanganFormYj, ENUM_SIMP, F_NOPRINT);
              if (nTmpRes == TRUE)
              {
                     t = nItemNum + nFanganNum;
                     CopyStructCZ(&(czCZ[i]), &(czCZ[t]));
                     EnumFanganForm(czCZ[t].szHz, czCZ[t].nYj, czCZ[t].nYjNum, &(czCZ[t].nbIsFanganForm), czCZ[t].nFanganFormYj, ENUM_SIMP_W, F_PRINT);
                     nFanganNum ++;
              }
       }
       nItemNum += nFanganNum;
       printf ("%d FanganForm Added. nItemNum is %d\n", nFanganNum, nItemNum);

       nEnaoNum = 0;
       for (i = 0; i < nItemNum; i++)
       {
              nTmpRes = EnumEnaoForm(czCZ[i].szHz, czCZ[i].nYj, czCZ[i].nYjNum, &(czCZ[i].nbIsEnaoForm), czCZ[i].nFanganFormYj, ENUM_SIMP, F_NOPRINT);
              if (nTmpRes == TRUE)
              {
                     t = nItemNum + nEnaoNum;
                     CopyStructCZ(&(czCZ[i]), &(czCZ[t]));
                     EnumEnaoForm(czCZ[t].szHz, czCZ[t].nYj, czCZ[t].nYjNum, &(czCZ[t].nbIsEnaoForm), czCZ[t].nFanganFormYj, ENUM_SIMP_W, F_PRINT);
                     nEnaoNum ++;
              }
       }
       nItemNum += nEnaoNum;
       printf ("%d EnaoForm Added. nItemNum is %d\n", nEnaoNum, nItemNum);

       nXianNum  = 0;
       nXianNum2 = 0;
       for (i = 0; i < nItemNum; i++)
       {
              nTmpRes = EnumXianForm(czCZ[i].szHz, czCZ[i].nYj, czCZ[i].nYjNum, &(czCZ[i].nbIsXianForm), czCZ[i].nXianFormYj, ENUM_SIMP, F_NOPRINT);
              if (nTmpRes == TRUE)
              {
                     t = nItemNum + nXianNum;
                     if (czCZ[i].nYjNum == 2)
                     {
                            EnumXianForm(czCZ[i].szHz, czCZ[i].nYj, czCZ[i].nYjNum, &(czCZ[i].nbIsXianForm), czCZ[i].nXianFormYj, ENUM_SIMP_W, F_PRINT);
                            nXianNum2 ++;
                     }
              }
       }
       nItemNum += nXianNum;
       printf ("%d XianForm Added. nItemNum is %d [nXianNum2 is %d]\n", nXianNum, nItemNum, nXianNum2);

       nFrom = 0;
       nTo   = nItemNum - 1;
       nSortNumber = 0;
       fprintf (stderr, "SortNum:    ");
       QuickSort (nFrom, nTo);
       fprintf (stderr, "\b\b\b\b\b\b\b%07d", nSortNumber);
       fprintf (stderr, "\n\n\n");

       /* Filter these duplicated Items: Scott Ma 1998-08-12 */
       memset(nFlag, 0x00, sizeof(JINT) * MAX_CIZU_ITEMS);

       for (i = 0; i < nItemNum; i++)
              nFlag[i] = 1;
       k = 0;
       for (i = 0; i < nItemNum; i++)
       {
              for (j = i + 1; j < nItemNum; j++)
              {
                     if ( (czCZ[i].nHzNum == czCZ[j].nHzNum) && (czCZ[i].nYjNum == czCZ[j].nYjNum) &&
                          (strncmp((CHAR*)(czCZ[i].szHz2244), (CHAR*)(czCZ[j].szHz2244), 2 * czCZ[i].nHzNum) == 0) &&
                          (CompIntArray(czCZ[i].nYj, czCZ[j].nYj) == 0) )
                     {
                            printf("!!! Duplicated Cizu Item to be deleted ==>[%2d]%s\n", strlen((char*)(czCZ[j].szHz2244)), RecovDyz2244(czCZ[j].szHz2244));
                            fflush(stdout);
                            k++;
                            nFlag[j] = 0;
                     }
                     else
                     {
                            break;
                     }
              }
       }
       printf("Warning: Totally %d duplicated Cizu Items were deleted!\n", k);

       i = j = k = 0;
       for (i = 0; i < nItemNum; i++)
       {
              if (nFlag[i] == 1)
              {
                     CopyStructCZ(&(czCZ[i]), &(czCZ[j]));
                     j++;
              }
              else
                     k++;
       }
       printf("Warning: Totally %d duplicated Cizu Items were deleted!\n", k);
       nItemNum -= k;

       /**************************************************************************/

       BuildSingleHzDB(SINGLEHZ_DSP_NONE);
       ProcGbkHz();

       for (i = 0; i < nItemNum; i++)
       {
              if (!(czCZ[i].nbIsXianForm))
              {
                     cgCG[czCZ[i].nYj[0]].nNum2ndYjIs[czCZ[i].nYj[1]] ++;
                     cgCG[czCZ[i].nYj[0]].nIdxItem[ cgCG[czCZ[i].nYj[0]].nNumFirstYjIs ] = i;
                     cgCG[czCZ[i].nYj[0]].nNumFirstYjIs++;
              }
              else if (czCZ[i].nbIsXianForm)
              {
                     cgCG[czCZ[i].nXianFormYj[0]].nNum2ndYjIs[czCZ[i].nXianFormYj[1]] ++;
                     cgCG[czCZ[i].nXianFormYj[0]].nIdxItem[ cgCG[czCZ[i].nXianFormYj[0]].nNumFirstYjIs ] = i;
                     cgCG[czCZ[i].nXianFormYj[0]].nNumFirstYjIs++;
              }
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 356 of file CreateData.c.

{
       JINT   nFileSize;
       BYTE*  pbAllData;
       JINT   i, k, m, nTmp, nt1, nAll;
       FILE*  pfCiku;

       CikuHeader    ckh;
       ShIndex             shi;
       DhIndex             dhi;
       MhIndex             mhi;
       GbkIndex      gbki;

       SetCkh(&ckh);
       SetShi(&shi);
       SetDhi(&dhi);
       SetMhi(&mhi);
       SetGbki(&gbki);

       nFileSize  = sizeof(CikuHeader) + sizeof(ShIndex) + sizeof(DhIndex) + sizeof(MhIndex) + sizeof(GbkIndex)
                 + shi.nYjOff[NUM_YINJIE] + dhi.nYjOff[NUM_YINJIE] + mhi.nYjOff[NUM_YINJIE] + gbki.nYjOff[NUM_YINJIE];

       printf("\n\n=========================================\n");
       printf("nFileSize is   %d[0x%X]\n", nFileSize, nFileSize);

       ckh.nFileSize = nFileSize;
       ckh.nIdxShPos = sizeof(CikuHeader);
       ckh.nIdxDhPos = ckh.nIdxShPos + sizeof(ShIndex);
       ckh.nIdxMhPos = ckh.nIdxDhPos + sizeof(DhIndex);
       ckh.nIdxGbkPos       = ckh.nIdxMhPos + sizeof(MhIndex);

       shi.nStartPos = ckh.nIdxGbkPos + sizeof(GbkIndex);
       shi.nEndPos    += shi.nStartPos;

       dhi.nStartPos = shi.nEndPos;
       dhi.nEndPos    += dhi.nStartPos;

       mhi.nStartPos = dhi.nEndPos;
       mhi.nEndPos    += mhi.nStartPos;

       gbki.nStartPos       = mhi.nEndPos;
       gbki.nEndPos   += gbki.nStartPos;

       pbAllData = (BYTE*)malloc(nFileSize);
       if (pbAllData == NULL)
       {
              fprintf(stderr, "Failed to Alloc memory for pbAllData\n");
              exit(FALSE);
       }

       memset (pbAllData, '\0', nFileSize);

       nAll = 0;
       nTmp = sizeof(CikuHeader);
       for (i = 0; i < nTmp; i++)
              pbAllData[nAll++]  = (BYTE)*((BYTE*)(&ckh) + i);

       nTmp = sizeof(ShIndex);
       for (i = 0; i < nTmp; i++)
              pbAllData[nAll++]  = (BYTE)*((BYTE*)(&shi) + i);

       nTmp = sizeof(DhIndex);
       for (i = 0; i < nTmp; i++)
              pbAllData[nAll++]  = (BYTE)*((BYTE*)(&dhi) + i);

       nTmp = sizeof(MhIndex);
       for (i = 0; i < nTmp; i++)
              pbAllData[nAll++]  = (BYTE)*((BYTE*)(&mhi) + i);

       nTmp = sizeof(GbkIndex);
       for (i = 0; i < nTmp; i++)
              pbAllData[nAll++]  = (BYTE)*((BYTE*)(&gbki) + i);

       /* Single Hanzi Area */
       for (i = 0; i < NUM_YINJIE; i++)
       {
              for (k = 0; k < (2 * shSH[i].nHzNum); k++)
                     pbAllData[nAll++] = (BYTE)(shSH[i].szHanzi[k] ^ ((i + 56) / 2));

              for (k = 0; k < (4 * shSH[i].nXianFormNum); k++)
                     pbAllData[nAll++] = (BYTE)(shSH[i].szXianFormList[k] ^ ((i + 56) / 2));
       }

       /* Double Hanzi Area */
       for (i = 0; i < NUM_YINJIE; i++)
       {
              for (k = 0; k < cgCG[i].nNumFirstYjIs; k++)
              {
                     nt1 = czCZ[ cgCG[i].nIdxItem[k] ].nHzNum;
                     if (nt1 == 2)
                     {
                            pbAllData[nAll++] = (BYTE) ( ((czCZ[cgCG[i].nIdxItem[k]].nFreq) * 8) ^ ((i + 56) / 2));           /* Freq */
                            for (m = 0; m < (2 * nt1); m++)
                                   pbAllData[nAll++] = (BYTE) ((czCZ[cgCG[i].nIdxItem[k]].szHz2244[m]) ^ ((i + 56) / 2));     /* Data */
                     }
              }
       }

       /*
       **  Multiple Hanzi Area
       **
       **  ABOUT Freq and Length BYTE:     7 |<== 5 Bits Freq ==>|<= 3 Bits Length =>| 0
       **  3 Bits (000 ~ 111) indicates the length of this Cizu is (2 ~ 9).
       **  5 Bits (00000 ~ 11111) indicates the freqence of this cizu is (0 ~ 31). (Default is 0 ~ 15)
       */
       for (i = 0; i < NUM_YINJIE; i++)
       {
              for (k = 0; k < cgCG[i].nNumFirstYjIs; k++)
              {
                     nt1 = czCZ[ cgCG[i].nIdxItem[k] ].nHzNum;
                     if (nt1 > 2)
                     {
                            nTmp = ((czCZ[cgCG[i].nIdxItem[k]].nFreq) << 3) + (nt1 - 2);
                            pbAllData[nAll++] = (BYTE) (nTmp ^ ((i + 56) / 2));                   /* Freq and Length */

                            for (m = 0; m < (2 * nt1); m++)
                                   pbAllData[nAll++] = (BYTE) ((czCZ[cgCG[i].nIdxItem[k]].szHz2244[m]) ^ ((i + 56) / 2));     /* Data */
                     }
              }
       }

       /* GBK Single Hanzi Area */
       for (i = 0; i < NUM_YINJIE; i++)
       {
              for (k = 0; k < nGbkNumByYj[i]; k++)
              {
                     pbAllData[nAll++] = (BYTE)( (((JINT)wGbkHzByYj[i][k] & 0xFF00) >> 8) ^ ((i + 56) / 2));
                     pbAllData[nAll++] = (BYTE)(  ((JINT)wGbkHzByYj[i][k] & 0x00FF)  ^ ((i + 56) / 2));
              }
       }

       pfCiku = fopen("PyCiku.dat", "wb");
       if (pfCiku == NULL)
       {
              fprintf (stderr, "Failed to Create System Ciku [PyCiku.dat]\n");
              exit (FALSE);
       }

       for (i = 0; i < nFileSize; i++)
              fprintf (pfCiku, "%c", pbAllData[i]);

       fclose(pfCiku);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 533 of file UdCikuOper.c.

{
       JINT   i, nTmp;
       JINT   nFileSize;
       JWORD  wSpecHz[1024];
       FILE*  pfUdCiku;
       JWORD* pwUdCizu[NUM_YINJIE];

       UdCikuHeader    udcfh;
       UdcIndex        udci;

       SetUdcfh(&udcfh);

       memset(wSpecHz, '\0', 1024 * sizeof(JWORD));
       SetSpecHzData(wSpecHz, 1024);
       SetUdcIndex(&udci);

       nFileSize = sizeof(UdCikuHeader) + sizeof(UdcIndex) + (1024 * sizeof(JWORD)) + udci.nEndPos;
       udcfh.nFileSize            = nFileSize;
       fprintf (stderr, "File Size of UdCiku.dat should be %d 0x%X\n", nFileSize, nFileSize);

       udcfh.nSpecHzStartPos  = sizeof(UdCikuHeader) + sizeof(UdcIndex);
       udcfh.nSizeSpecHz      = 1024 * sizeof(JWORD);        /* 2 KiloBytes for all spec Hanzi, each seperated by a 0x0000(JWORD) */
       udcfh.nIdxUdcPos       = sizeof(UdCikuHeader);        /* Index Position of User defined 2 ~ 8 Hanzi Cizu */

       udci.nStartPos             += sizeof(UdCikuHeader) + sizeof(UdcIndex) + (1024 * sizeof(JWORD));
       udci.nEndPos        += sizeof(UdCikuHeader) + sizeof(UdcIndex) + (1024 * sizeof(JWORD));

       pfUdCiku = fopen("UdCiku.dat", "wb");
       if (pfUdCiku == NULL)
       {
              fprintf (stderr, "Failed to Create User Defined Ciku [UdCiku.dat]\n");
              exit (FALSE);
       }

       /* Alloc for each Yinjie 64 * 2 bytes space to contain User Defined Cizu */
       for (i = 0; i < NUM_YINJIE; i++)
       {
              pwUdCizu[i] = (JWORD*)malloc(64 * sizeof(JWORD));
              if (pwUdCizu == NULL)
              {
                     printf("Failed to alloc mem in CreateUdCikuFile().\n");
                     exit (FALSE);
              }
       }

       /* WriteData to file */
       if ((JINT)fwrite (&udcfh, 1, sizeof(UdCikuHeader), pfUdCiku) != sizeof(UdCikuHeader) )
       {
              fprintf(stderr, "Failed to fwrite() Ud Ciku File11.\n");
              exit (FALSE);
       }

       if ((JINT)fwrite (&udci,  1, sizeof(UdcIndex), pfUdCiku) != sizeof(UdcIndex) )
       {
              fprintf(stderr, "Failed to fwrite() Ud Ciku File22.\n");
              exit (FALSE);
       }

       if ((JINT)fwrite (wSpecHz,  sizeof(JWORD), 1024, pfUdCiku) != 1024 )
       {
              fprintf(stderr, "Failed to fwrite() Ud Ciku File33.\n");
              exit (FALSE);
       }

       for(i = 0; i < NUM_YINJIE; i++)
       {
              nTmp = (udci.nYjOff[i + 1] - udci.nYjOff[i]) / 2;
              if ((JINT)fwrite (pwUdCizu[i], sizeof(JWORD), nTmp, pfUdCiku) != nTmp )
              {
                     fprintf(stderr, "Failed to fwrite() Ud Ciku File44.\n");
                     exit (FALSE);
              }
       }

       fclose(pfUdCiku);

       for(i = 0; i < NUM_YINJIE; i++)
              free (pwUdCizu[i]);

}

Here is the call graph for this function:

Here is the caller graph for this function:

VOID DecompPeIntArray ( JINT pnOutPreedit,
CHAR szDspPreedit 
)

Definition at line 63 of file ParsePreedit.c.

{
       JINT    i, j, tmp;
       JINT    nHalfMatchLen, nIUVetc, nYJCode;
       CHAR    szHalfMatch[7];
       
       i   = 0;
       tmp = 1;

       for (i = 0; i < 256; i++)
              szDspPreedit[i] = '\0';
              
       for (i = 0; pnOutPreedit[i] != 0; )
       {
              tmp = pnOutPreedit[i];
              nYJCode = tmp & 0x01FF;
              nIUVetc = (tmp >> 9) & 0x07;
              nHalfMatchLen = (tmp >> 12) & 0x0F;
              
              if (nIUVetc != 0)
              {
                     if (nIUVetc == 6)                        /* [$] */
                     {
                            strcat (szDspPreedit, "$");
                            i++;
                     }
                     else if (nIUVetc == 5)                   /* [#] */
                     {
                            strcat (szDspPreedit, "#");
                            i++;
                     }
                     else if (nIUVetc == 4)                   /* ['] */
                     {
                            strcat (szDspPreedit, "\'");
                            i++;
                     }
                     else                                      /* [i u v] */
                     {
                            /*
                            **  Add a space before [iuv] except that this is 
                            **  the first CHAR in Preedit string or a ['ivu]
                            **  ahead it.
                            **  MakeOPE(0, 1, 0) is 0000 001 000000000 = 0x0200 [i]
                            **  MakeOPE(0, 2, 0) is 0000 010 000000000 = 0x0400 [u]
                            **  MakeOPE(0, 3, 0) is 0000 011 000000000 = 0x0600 [v]
                            **  MakeOPE(0, 4, 0) is 0000 100 000000000 = 0x0800 [']
                            **
                            **  [#] and [$] don't affect [SPACE]
                            **
                            **  MakeOPE(0, 5, 0) is 0000 101 000000000 = 0x0A00 [#]
                            **  MakeOPE(0, 6, 0) is 0000 110 000000000 = 0x0C00 [$]
                            */
                            if ( (i > 0) && (pnOutPreedit[i-1] != 0x0200)    \
                                         && (pnOutPreedit[i-1] != 0x0400)    \
                                         && (pnOutPreedit[i-1] != 0x0600)    \
                                         && (pnOutPreedit[i-1] != 0x0800) )
                                   strcat (szDspPreedit, " ");
                            
                            if (nIUVetc == 1)
                                   strcat (szDspPreedit, "i");
                            else  if (nIUVetc == 2)
                                   strcat (szDspPreedit, "u");
                            else  if (nIUVetc == 3)
                                   strcat (szDspPreedit, "v");
                            i++;
                     }
              }
              
              else if ((nIUVetc == 0) && (nHalfMatchLen == 6))
              {
                     /*
                     ** A valid Yinjie code. Add a SPACE before
                     ** Yinjie string expect that there is a ['] ahead or it is the first.
                     ** MakeOPE(0, 4, 0) is 0000 100 000000000 = 0x0800
                     */
                     if ((i > 0) && (pnOutPreedit[i-1] != 0x0800))
                            strcat (szDspPreedit, " ");
                     
                     if (nYJCode >= 450)
                            strcat (szDspPreedit, SHENGMUSTR[nYJCode - 450]);
                     else if (nYJCode < 450)
                            strcat (szDspPreedit, YINJIESTR_CSZ[nYJCode]);
                            
                     i++;
              }
              
              else if ((nHalfMatchLen > 0) && (nHalfMatchLen < 6) && (nIUVetc == 0))
              {
                     for (j = 0; j < nHalfMatchLen; j++)
                            szHalfMatch[j] = (char)pnOutPreedit[i + j + 1];
                     szHalfMatch[j] = '\0';
                     if ((i > 0) && (pnOutPreedit[i-1] != 0x0800))
                            strcat (szDspPreedit, " ");
                     strcat (szDspPreedit, szHalfMatch);
                     i += (j + 1);
              }
              else
              {
                     i++;
                     fprintf (stderr, "Error in DecompPeIntArray()\n");
              }
       }
       
}
JINT DelUdc ( JWORD pwHz2244,
JINT  nLen 
)

Definition at line 866 of file UdCikuOper.c.

{
       JINT    i, k, nTmp1, nTmp2;
       JINT    nCurSize;
       JINT    nFreqLen, nTmpLen;
       JINT    nFirstYj;
       JINT    nFindFlag;

       if (nLen <= 1)
       {
#ifdef _DRAW_IM_WIN_H
              XBell (pDspIme, 100);
#endif
              return FALSE;
       }

       nFirstYj = GbkHz2244ToYj(pwHz2244[0]);
       if (nFirstYj == 0xFFFF)
       {
              fprintf(stderr, "Error in DelUdc.\n");
              return FALSE;
       }

       /*
       **  STEP1: Find this pwHz2244, Forward other Udcdata to (nLen + 1) JWORD.
       */
       nFindFlag = FALSE;
       nCurSize  = udcAll.udci.nYjOff[nFirstYj + 1] - udcAll.udci.nYjOff[nFirstYj];    /* In BYTE */

       /* NO i++ in this FOR sentence */
       for (i = 0; i < nCurSize / 2; )
       {
              nFreqLen = (JINT)udcAll.pwUdc28[nFirstYj][i];
              nTmpLen  = (nFreqLen & 0x0007) + 2;
              /* DON'T exchange the sequence of two judgement in the following IF sentence */
              if ((nTmpLen == nLen) && (JwordNCmp(pwHz2244, &(udcAll.pwUdc28[nFirstYj][i + 1]), nTmpLen) == 0))
              {
                     nFindFlag = TRUE;
                     for (k = i; k < (nCurSize / 2) - (nTmpLen + 1); k++)
                            udcAll.pwUdc28[nFirstYj][k] = udcAll.pwUdc28[nFirstYj][k + nTmpLen + 1];
                     for (k = (nCurSize / 2) - (nTmpLen + 1); k < nCurSize / 2; k++)
                            udcAll.pwUdc28[nFirstYj][k] = 0x0000;

                     break;        /* BREAK OUT FOR_i sentence */
              }
              i += (nTmpLen + 1);
       }

       if (nFindFlag == FALSE)
       {
#ifdef _DRAW_IM_WIN_H
              XBell (pDspIme, 100);
#endif
              return FALSE;
       }

       /* 
       **  STEP2: Is it necessary to realloc() for this Yinjie's space? 
       */
       nTmp1     = ((nCurSize + UDCMEM_ALIGN) / UDCMEM_ALIGN) * UDCMEM_ALIGN;
       nTmp2     = ((nCurSize - ((nLen + 1) * sizeof(JWORD)) + UDCMEM_ALIGN) / UDCMEM_ALIGN) * UDCMEM_ALIGN;
       if (nTmp2 < nTmp1)
       {
              udcAll.pwUdc28[nFirstYj] = (JWORD*)realloc(udcAll.pwUdc28[nFirstYj], nTmp2);
              if (udcAll.pwUdc28[nFirstYj] == NULL)
              {
                     fprintf(stderr, "Failed to realloc() in DelUdc().\n");
                     return FALSE;
              }
       }

       /*
       ** STEP3:  Adjust udcAll.udci.nYjOff[nFirstYj + 1] to nYjOff[NUM_YINJIE]
       */
       for (i = nFirstYj; i < NUM_YINJIE; i++)
              udcAll.udci.nYjOff[i + 1] -= 2 * (nLen + 1);

       return TRUE;
}

Here is the call graph for this function:

JINT EncodeDyzTo2244 ( JINT  nHzcode,
JINT  nYjcode 
)

Definition at line 1769 of file PyBasic.c.

{
       JINT    nHiHzPos, nLowHz;
       JINT    i;
       
       nHiHzPos = ((nHzcode & 0xFF00) >> 8) - 0xB0;
       if ((nHiHzPos < 0) || (nHiHzPos > (0xF7 - 0xB0)))
              return 0xFFFF;

       nLowHz = nHzcode & 0x00FF;
       
       for (i = INDEXOFDYZLIST[nHiHzPos]; i < INDEXOFDYZLIST[nHiHzPos + 1]; i++)
       {
              if ( ((DYZLIST[i] & 0x00FF) == nLowHz) && (DYZYJCODE[i] == nYjcode) )
                     return (i + 0x2001);
       }
       
       return 0xFFFF;
}
JINT EnumEnaoForm ( UCHAR pszHz,
JINT pnYj,
JINT  nYjNum,
JINT pnbEnaoFlag,
JINT pnFanganYj,
JINT  nMode,
JINT  nDspMode 
)

Definition at line 546 of file ciku.c.

{
       JINT   i, j, k, tmp1, tmp2;
       CHAR   ch1, ch2;
       JINT   res1, res2;
       JINT   nGNRAOEIUVnum = 0;

       CHAR   szTmp1[43], szTmp2[7];
       JINT   nYjNumAlt;

       if ((nMode == ENUM_SIMP) || (nMode == ENUM_SIMP_W))            /* Simple Mode */
              nYjNumAlt = 2;
       else
              nYjNumAlt = nYjNum;

       for (i = 0; (i < (nYjNumAlt - 1)) && (nYjNumAlt >= 2); i++)
       {
              /* Get Last char of first Yinjie string and first char of second Yinjie string */
              ch1 = LastChar (pnYj[i]);
              ch2 = FirstChar(pnYj[i + 1]);
              res1 = res2 = 0xFFFF;

              tmp1 = strcmp("a", YINJIESTR_CSZ[ pnYj[i] ]);
              tmp2 = strcmp("e", YINJIESTR_CSZ[ pnYj[i] ]);
              if ( ((tmp1 == 0) || (tmp2 == 0)) && (ch2 == 'n') )
              {
                     res2 = ValidButFirstChar(pnYj[i + 1]);

                     if (res2 != 0xFFFF)
                     {
                            if (tmp1 == 0)
                                   res1 = 2;     /* "an" in YINJIESTR_CSZ */
                            else if (tmp2 == 0)
                                   res1 = 81;    /* "en" in YINJIESTR_CSZ */

                            if (nDspMode == F_PRINT)
                            {
                            /***********************LIST ENAO FORM ITEMS**************************/
                            printf ("%-8s  ", pszHz);

                            for (k = 0; k < 43; k++)
                                   szTmp1[k] = '\0';
                            for (k = 0; k < 7; k++)
                                   szTmp2[k] = '\0';

                            for (k = 0; k < nYjNum; k++)
                            {
                                   for (j = 0; j < 7; j++)
                                          szTmp2[j] = '\0';
                                   strcat(szTmp2, YINJIESTR_CSZ[pnYj[k]]);
                                   strcat(szTmp2, " ");
                                   strcat(szTmp1, szTmp2);
                            }
                            printf ("%-20s | ", szTmp1);

                            for (k = 0; k < 43; k++)
                                   szTmp1[k] = '\0';
                            for (k = 0; k < 7; k++)
                                   szTmp2[k] = '\0';
                            for (k = 0; k < nYjNum; k++)
                            {
                                   for (j = 0; j < 7; j++)
                                          szTmp2[j] = '\0';

                                   if (k == i)
                                          strcat(szTmp2, YINJIESTR_CSZ[res1]);
                                   else if (k == (i + 1))
                                          strcat(szTmp2, YINJIESTR_CSZ[res2]);
                                   else
                                          strcat(szTmp2, YINJIESTR_CSZ[pnYj[k]]);

                                   strcat(szTmp2, " ");
                                   strcat(szTmp1, szTmp2);
                            }
                            printf ("%-20s \n", szTmp1);
                            /************************END LISTING HERE*****************************/
                            }

                            if (nMode == ENUM_SIMP_W)
                            {
                                   pnYj[i]           = res1;
                                   pnYj[i + 1] = res2;
                            }

                            *pnbEnaoFlag = TRUE;
                     }
              }
       }
       return (*pnbEnaoFlag);
}

Here is the call graph for this function:

Here is the caller graph for this function:

JINT EnumFanganForm ( UCHAR pszHz,
JINT pnYj,
JINT  nYjNum,
JINT pnbFanganFlag,
JINT pnFanganYj,
JINT  nMode,
JINT  nDspMode 
)

Definition at line 443 of file ciku.c.

{
       JINT   i, j, k;
       CHAR   ch1, ch2;
       JINT   res1, res2;
       JINT   nGNRAOEIUVnum = 0;

       CHAR   szTmp1[43], szTmp2[7];
       JINT   nYjNumAlt;

       JINT   nRet = FALSE;

       if ((nMode == ENUM_SIMP) || (nMode == ENUM_SIMP_W))            /* Simple Mode */
              nYjNumAlt = 2;
       else
              nYjNumAlt = nYjNum;

       for (i = 0; (i < (nYjNumAlt - 1)) && (nYjNumAlt >= 2); i++)
       {
              /* Get Last char of first Yinjie string and first char of second Yinjie string */
              ch1 = LastChar (pnYj[i]);
              ch2 = FirstChar(pnYj[i + 1]);

              res1 = res2 = 0xFFFF;
              /*
              **  Not include "an" "en" of first Yinjie
              */
              if( ((ch1 == 'g') && ((ch2 == 'a') || (ch2 == 'e') ||   \
                                  (ch2 == 'o') || (ch2 == 'u') ))     \
              ||  ((ch1 == 'r') && ((ch2 == 'a') || (ch2 == 'e') ||   \
                                  (ch2 == 'i') || (ch2 == 'o') ||     \
                                  (ch2 == 'u') ))                     \
              || (((ch1 == 'n') && ((ch2 == 'a') || (ch2 == 'e') ||   \
                                  (ch2 == 'i') || (ch2 == 'o') ||     \
                                  (ch2 == 'u') || (ch2 == 'v') ))     \
                  && ( strcmp ( "an", YINJIESTR_CSZ[ pnYj[i] ] ) != 0 )      \
                  && ( strcmp ( "en", YINJIESTR_CSZ[ pnYj[i] ] ) != 0 ) ))
              {
                     res1 = ValidButLastChar (pnYj[i]);
                     res2 = ValidAddChar (ch1, pnYj[i + 1]);
                     if ((res1 != 0xFFFF) && (res2 != 0xFFFF))
                     {
                            if (nDspMode == F_PRINT)
                            {
                            /***********************LIST FANGAN FORM ITEMS************************/
                            printf ("%-8s  ", pszHz);

                            for (k = 0; k < 43; k++)
                                   szTmp1[k] = '\0';
                            for (k = 0; k < 7; k++)
                                   szTmp2[k] = '\0';

                            for (k = 0; k < nYjNum; k++)
                            {
                                   for (j = 0; j < 7; j++)
                                          szTmp2[j] = '\0';
                                   strcat(szTmp2, YINJIESTR_CSZ[pnYj[k]]);
                                   strcat(szTmp2, " ");
                                   strcat(szTmp1, szTmp2);
                            }
                            printf ("%-20s | ", szTmp1);

                            for (k = 0; k < 43; k++)
                                   szTmp1[k] = '\0';
                            for (k = 0; k < 7; k++)
                                   szTmp2[k] = '\0';
                            for (k = 0; k < nYjNum; k++)
                            {
                                   for (j = 0; j < 7; j++)
                                          szTmp2[j] = '\0';

                                   if (k == i)
                                          strcat(szTmp2, YINJIESTR_CSZ[res1]);
                                   else if (k == (i + 1))
                                          strcat(szTmp2, YINJIESTR_CSZ[res2]);
                                   else
                                          strcat(szTmp2, YINJIESTR_CSZ[pnYj[k]]);

                                   strcat(szTmp2, " ");
                                   strcat(szTmp1, szTmp2);
                            }
                            printf ("%-20s \n", szTmp1);
                            /************************END LISTING HERE*****************************/
                            }

                            if (nMode == ENUM_SIMP_W)
                            {
                                   pnYj[i]           = res1;
                                   pnYj[i + 1] = res2;
                                   *pnbFanganFlag = TRUE;
                            }
                            nRet       = TRUE;
                     }
              }
       }
       return (nRet);
}

Here is the call graph for this function:

Here is the caller graph for this function:

JINT EnumXianForm ( UCHAR pszHz,
JINT pnYj,
JINT  nYjNum,
JINT pnbXianFlag,
JINT pnXianYj,
JINT  nMode,
JINT  nDspMode 
)

Definition at line 876 of file ciku.c.

{
       JINT   j, t2;
       JINT   res1;
       CHAR   szCombYJ[20];

       for (j = 0; j < 20; j++)
              szCombYJ[j] = '\0';

       if( (pnYj[0] != 0xFFFF) && (pnYj[1] != 0xFFFF) )
              strcat( strcat(szCombYJ, YINJIESTR_CSZ[pnYj[0]]),
                                    YINJIESTR_CSZ[pnYj[1]]);

       if (strlen(szCombYJ) <= 6 )
       {
              res1 = FastMatchYinJieStr (szCombYJ);
              if (res1 != -1)
              {
                     if (nMode == ENUM_SIMP_W)
                     {
                            if (nYjNum > 2)
                            {
                                   *pnbXianFlag = 1;
                                   pnXianYj[0] = res1;
                                   for (j = 2; j < MAX_CIZU_HZ_NUM; j++)
                                          pnXianYj[j - 1] = pnYj[j];
                            }

                            if (nYjNum == 2)
                            {
                                   t2 = shSH[res1].nXianFormNum;
                                   shSH[res1].szXianFormList[4 * t2 + 0] = (UCHAR)pszHz[0];
                                   shSH[res1].szXianFormList[4 * t2 + 1] = (UCHAR)pszHz[1];
                                   shSH[res1].szXianFormList[4 * t2 + 2] = (UCHAR)pszHz[2];
                                   shSH[res1].szXianFormList[4 * t2 + 3] = (UCHAR)pszHz[3];
                                   shSH[res1].nXianFormNum ++;
                            }
                     }

                     if (nDspMode == F_PRINT)
                            printf ("%s\n", pszHz);

                     return TRUE;
              }
       }
       return FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

JINT FastMatchYinJieStr ( CHAR szPystr)

Definition at line 1794 of file PyBasic.c.

{
       JINT    i, j, nLen;
       CHAR    chFirst;
       JINT    nFromYJStr, nToYJStr, nShengmuIndex;     
       
       i = 0;
       nLen = (JINT)strlen(szPystr);
       
       j = 0;
       if (nLen > 0)
       {
              chFirst    = szPystr[0];
              nFromYJStr = INDEXSMTOYINJIE[ INDEXMAGIC[(JINT)(chFirst - 'a')] ];
              nToYJStr   = INDEXSMTOYINJIE[ INDEXMAGIC[(JINT)(chFirst - 'a')] + 1];
              nShengmuIndex = INDEXMAGIC[(JINT)(chFirst - 'a')];
              
              if ((chFirst == 'c') && (nLen > 1) && (szPystr[1] == 'h'))
              {
                     nFromYJStr = INDEXSMTOYINJIE[3];
                     nToYJStr   = INDEXSMTOYINJIE[4];
                     nShengmuIndex = 3;
              }
              else if ((chFirst == 's') && (nLen > 1) && (szPystr[1] == 'h'))
              {
                     nFromYJStr = INDEXSMTOYINJIE[19];
                     nToYJStr   = INDEXSMTOYINJIE[20];
                     nShengmuIndex = 19;
              }
              else if ((chFirst == 'z') && (nLen > 1) && (szPystr[1] == 'h'))
              {
                     nFromYJStr = INDEXSMTOYINJIE[25];
                     nToYJStr   = INDEXSMTOYINJIE[26];
                     nShengmuIndex = 25;
              }

              i = nFromYJStr;
              do {
                     j = strcmp (YINJIESTR_CSZ[i], szPystr);
                     i++;
              } while ((i < nToYJStr) && (j != 0));
       }
       
       if (j == 0)
              return (i - 1);
       else
              return (-1);
}
VOID FilterVtoU ( UCHAR pszLine)

Definition at line 292 of file ciku.c.

{
       JINT   i;
       UCHAR  ch;

       for (i = 0; pszLine[i] != '\0'; i++)
       {
              ch = pszLine[i];
              if (ch == 'v')
              {
                     if ( i > 0 && ((pszLine[i-1] == 'l') || (pszLine[i-1] == 'n')) &&     \
                            ((pszLine[i+1] < 'a')  || (pszLine[i+1] > 'z')) )
                     {
                            pszLine[i] = 'v';
                     }
                     else
                            pszLine[i] = 'u';
              }
       }
}

Here is the caller graph for this function:

CHAR FirstChar ( JINT  nYinjieCode)

Definition at line 1866 of file PyBasic.c.

{
       CHAR   res = ' ';           /* SPACE */
       
       if ((nYinjieCode >= 0) && (nYinjieCode <= 414))
              res = YINJIESTR_CSZ[nYinjieCode][0];
       return res;
}

Definition at line 148 of file ciku.c.

{
       FILE   *pfCneFile;
       CHAR   szCneCiku[] = "PyCiku.txt";
       JINT   i, j, m, k, t2, t3, nLen;
       UCHAR  szTmp[256];
       CHAR   szFreq[8];
       JINT   nFreq, nFlag;

       pfCneFile = fopen (szCneCiku, "rb");
       if (pfCneFile == NULL)
       {
              printf ("Failed to Open File %s\n", szCneCiku);
              exit (FALSE);
       }

       k = 0;
       for (t2 = 1; t2 == 1;  )
       {
              memset(szTmp, '\0', 256);
              t2 = GetNextLine(pfCneFile, (CHAR*)szTmp);
              t3 = strlen((CHAR*)szTmp);

              if (t3 > 3)
              {
                     for (m = 0; m < t3; m++)
                            czCZ[k].szLine[m] = szTmp[m];
                     k++;
              }
       }

       fclose (pfCneFile);

       nItemNum = k;
       printf("nItemNum is %d\n", nItemNum);

       for (i = 0; i < nItemNum; i++)
       {
              memset (szFreq, '\0', 8);
              nLen  = strlen ((CHAR*)czCZ[i].szLine);

              nFlag = 0;
              k     = 0;

              for (j = 0; j < nLen; j++)
              {
                     if( (czCZ[i].szLine[j] >= '0') && (czCZ[i].szLine[j] <= '9') )
                     {
                            nFlag = 1;
                            szFreq[k++] = czCZ[i].szLine[j];
                     }
                     else if (nFlag == 1)
                            break;
              }

              nFreq = atoi(szFreq);
              if (nFreq > 127)
                     nFreq = 127;
              if (nFreq < 1)
                     nFreq = 1;

              czCZ[i].nFreq = 1 + ((nFreq - 1) / 9);         /* Between [1 ~ 15] */
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 218 of file ciku.c.

{
       CHAR   szFileName[20];
       FILE*  pfRawFile;
       JINT   i, k, m, nTmp;
       JINT   t1, t2, t3;
       CHAR   szTmp[100];

       k = nItemNum = 0;
       if (nMode == READ_RAW_CIZU)
              nTmp = 56;
       else
              nTmp = 1;

       for (i = 1; i <= nTmp; i++)
       {
              t1 = t2 = t3 = 0;

              t1 = 15 - ((i+3)/4);               /* Freq number.       From 15 ~ 1 */
              if (nMode == READ_RAW_CIZU)
                     sprintf (szFileName, "./CZPY/CZPY%02d.TXT", i);
              else
                     sprintf (szFileName, "./CZPY/allcizu.txt");

              pfRawFile = fopen (szFileName , "rb");
              if (pfRawFile == NULL)
              {
                     printf ("Failed to Open File %s\n", szFileName);
                     exit (0);
              }

              for (t2 = 1; t2 == 1;  )
              {
                     t2 = GetNextLine(pfRawFile, szTmp);
                     t3 = strlen(szTmp);

                     if (t3 > 3)
                     {
                            for (m = 0; m < t3; m++)
                                   czCZ[k].szLine[m] = szTmp[m];
                            czCZ[k].nFreq = t1;
                            k++;
                     }
              }
              fclose (pfRawFile);
       }

       nItemNum = k;
       printf("nItemNum is %d\n", nItemNum);
}

Here is the call graph for this function:

JINT GetCikuData ( CHAR szSysCikuName)

Definition at line 135 of file CikuOper.c.

{
       FILE*   pfCiku;
       JINT    i, k;
       JINT    nFileSize;
       JINT    nWarpFlag;     /* Flag to indicate whether it is necessary to */
       
       CikuHeader  *pCkh;
       ShIndex     *pShi;
       DhIndex     *pDhi;
       MhIndex     *pMhi;
       GbkIndex    *pGbki;
       BYTE        *pShArea;
       BYTE        *pDhArea;
       BYTE        *pMhArea;
       BYTE        *pGbkArea;
       
       nWarpFlag = FALSE;
       
       pfCiku = fopen(szSysCikuName, "rb");
       if (pfCiku == NULL)
       {
              return FALSE;
       }
       
       pCkh = (CikuHeader*)malloc(sizeof(CikuHeader));
       if (pCkh == NULL)
       {
              return FALSE;
       }
       
       fseek(pfCiku, 0, SEEK_SET);
       if (fread (pCkh, 1, sizeof(CikuHeader), pfCiku) != sizeof(CikuHeader) )
       {
              return FALSE;
       }
       
       /* Check Magic Word in Header */
       if ((pCkh->nMagicDescHi != 0x35303539) || (pCkh->nMagicDescLow != 0x34333442))
       {
              /* Is SPARC or x86 File? */
              if ((pCkh->nMagicDescHi == 0x39353035) && (pCkh->nMagicDescLow == 0x42343334))
              {
                     nWarpFlag = TRUE;
              }
              else
                     return FALSE;
       }
       
       if (nWarpFlag == TRUE)
              WarpCikuHeader(pCkh);
       
       nFileSize = pCkh->nFileSize;
       
       fseek(pfCiku, 0, SEEK_END);
       if (nFileSize != ftell(pfCiku))
       {
              return FALSE;
       }
       
       free(pCkh);
       pCkh = NULL;
       
       pCkAll = (BYTE*)malloc(nFileSize);
       if (pCkAll == NULL)
       {
              fprintf(stderr, "Failed to malloc() for pCkAll in GetCikuInfo.\n");
              return FALSE;
       }
       
       fseek(pfCiku, 0, SEEK_SET);
       if ((JINT)fread (pCkAll, 1, nFileSize, pfCiku) != nFileSize )
       {
              fprintf(stderr, "Failed to fread() System Ciku File.\n");
              return FALSE;
       }
       fclose(pfCiku);
       
       pCkh     = (CikuHeader *)pCkAll;
       if (nWarpFlag == TRUE)
              WarpCikuHeader(pCkh);

       pShi     = (ShIndex  *)(pCkAll + pCkh->nIdxShPos);
       pDhi     = (DhIndex  *)(pCkAll + pCkh->nIdxDhPos);
       pMhi     = (MhIndex  *)(pCkAll + pCkh->nIdxMhPos);
       pGbki    = (GbkIndex *)(pCkAll + pCkh->nIdxGbkPos);
       
       if (nWarpFlag == TRUE)
       {
              WarpIndex((ShIndex *)pShi);
              WarpIndex((ShIndex *)pDhi);
              WarpIndex((ShIndex *)pMhi);
              WarpIndex((ShIndex *)pGbki);
       }
       
       pShArea  = (BYTE *)(pCkAll + pShi->nStartPos);
       pDhArea  = (BYTE *)(pCkAll + pDhi->nStartPos);
       pMhArea  = (BYTE *)(pCkAll + pMhi->nStartPos);
       pGbkArea = (BYTE *)(pCkAll + pGbki->nStartPos);
       
       for(i = 0; i < NUM_YINJIE; i++)
              for(k = (pShi->nYjOff[i] & 0x00FFFFFF); k < (pShi->nYjOff[i + 1] & 0x00FFFFFF); k++)
                     *(pShArea + k) ^= (BYTE)((i + 56) / 2);

       for(i = 0; i < NUM_YINJIE; i++)
              for(k = pDhi->nYjOff[i]; k < pDhi->nYjOff[i + 1]; k++)
                     *(pDhArea + k) ^= (BYTE)((i + 56) / 2);

       for(i = 0; i < NUM_YINJIE; i++)
              for(k = pMhi->nYjOff[i]; k < pMhi->nYjOff[i + 1]; k++)
                     *(pMhArea + k) ^= (BYTE)((i + 56) / 2);

       for(i = 0; i < NUM_YINJIE; i++)
              for(k = pGbki->nYjOff[i]; k < pGbki->nYjOff[i + 1]; k++)
                     *(pGbkArea + k) ^= (BYTE)((i + 56) / 2);

       return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

JINT GetDyzInfo ( JINT  nHzcode,
JINT pnDyzYjCode 
)

Definition at line 1739 of file PyBasic.c.

{
       JINT    nHiHzPos, nLowHz;
       JINT    i, j;
       
       nHiHzPos = ((nHzcode & 0xFF00) >> 8) - 0xB0;
       nLowHz   = nHzcode & 0x00FF;
       
       j = 0;
       if ((nHiHzPos < 0) || (nHiHzPos > (0xF7 - 0xB0)))
              return j;

       for (i = INDEXOFDYZLIST[nHiHzPos]; i < INDEXOFDYZLIST[nHiHzPos + 1]; i++)
       {
              if( (DYZLIST[i] & 0x00FF) == nLowHz )
              {
                     pnDyzYjCode[j] = DYZYJCODE[i];
                     j++;
              }
       }
       return j;
}
VOID GetHzInfo ( UCHAR pszLine,
UCHAR pszHz,
JINT pnYj,
JINT pnHzNum,
JINT pnYjNum 
)

Definition at line 317 of file ciku.c.

{
       JINT   i, t1;
       UCHAR  ch, chHigh, chLow;
       JINT   nHanziFlag;
       JINT   nThisHz;

       *pnHzNum = 0;
       *pnYjNum = 0;
       i = t1 = 0;
       nHanziFlag = 0;
       chHigh = chLow = '\0';

       for (i = 0; pszLine[i] != '\0'; i++)
       {
              ch = pszLine[i];

              if ((ch >= 0xB0) && (ch <= 0xF7) && (nHanziFlag == 0))
              {
                     nHanziFlag        = 1;
                     chHigh            = ch;
              }
              else if ((ch >= 0xA1) && (ch <= 0xFE) && (nHanziFlag == 1))
              {
                     nHanziFlag        = 0;
                     chLow             = ch;

                     pszHz[2 * t1]     = chHigh;
                     pszHz[(2 * t1) + 1] = chLow;
                     (*pnHzNum)++;

                     nThisHz                  = (JINT)((chHigh << 8) + chLow);
                     pnYj[t1]          = HzcodeToYjcode(nThisHz);
                     (*pnYjNum)++;
                     t1 ++;
              }
       }

       if (nHanziFlag)
              fprintf (stderr, "Error in GetHzInfo: %s\n", pszLine);
}

Here is the call graph for this function:

Here is the caller graph for this function:

JINT GetNextLine ( FILE *  pfFile,
CHAR szBuf 
)

Definition at line 889 of file NewPY.c.

{
       JINT    i = 0;
       
       do
       {
              fread (&szBuf[i], 1, 1, pfFile);
              i ++;
       } while (!feof(pfFile) && (szBuf[i-1] != 0x0A));
       
       szBuf[i-1] = '\0';
       if ((i >= 2) && (szBuf[i-2] == 0x0D))
              szBuf[i-2] = '\0';
       
       if (!feof(pfFile))
              return 1;
       else
              return 0;
}
JINT GetXrdCandi ( SysCandi psc,
JINT  nXrd,
JWORD pwOneCandi 
)

Definition at line 1103 of file ciku.c.

{
       JINT   i, k, m, nTmp;
       JINT   nRet;

       nRet  = 0;
       nTmp  = psc->nNumMhCandi + psc->nNumDhCandi + psc->nNumShCandi;

       if ((nXrd < 0) || (nXrd > (nTmp - 1)))
              return nRet;

       if (nXrd < psc->nNumMhCandi)
       {
              m = 0;                                             /* [0 ~ (nNumMhCandi - 1)] */
              for (k = 0; k < psc->nSizMhCandi; k++)
              {
                     if (m == nXrd)
                     {
                            k++;
                            for(i = 0; psc->pwMhCandi[k] != 0x0000;    )
                                   pwOneCandi[i++] = psc->pwMhCandi[k++];
                            nRet = i;
                            break;
                     }
                     else if (psc->pwMhCandi[k] == 0x0000)
                            m++;
              }
       }
       else if ( (nXrd >= psc->nNumMhCandi) && (nXrd < (psc->nNumMhCandi + psc->nNumDhCandi)) )
       {
              m = psc->nNumMhCandi;                /* [nNumMhCandi ~ (nNumMhCandi + nNumDhCandi - 1)] */
              for (k = 0; k < psc->nSizDhCandi; k++)
              {
                     if (m == nXrd)
                     {
                            k++;
                            for(i = 0; psc->pwDhCandi[k] != 0x0000;    )
                                   pwOneCandi[i++] = psc->pwDhCandi[k++];
                            nRet = i;
                            break;
                     }
                     else if (psc->pwDhCandi[k] == 0x0000)
                            m++;
              }
              nRet  = 2;
       }
       /*
       **  Special Consideration for Single Hanzi Area: Because there is 'Xian' Question
       **  Here!!!! nRet may be 2.
       */
       else      /* Single Hanzi Area */
       {
              m = psc->nNumMhCandi + psc->nNumDhCandi;
              for (k = 0; k < psc->nSizShCandi; k++)
              {
                     if (m == nXrd)
                     {
                            for(i = 0; psc->pwShCandi[k] != 0x0000;    )
                                   pwOneCandi[i++] = psc->pwShCandi[k++];
                            nRet = i;
                            break;
                     }
                     else if (psc->pwShCandi[k] == 0x0000)
                            m++;
              }
       }

       return nRet;
}
VOID GetYjInfo ( UCHAR pszLine,
UCHAR pszHz,
JINT pnYj,
UCHAR pszHz2244 
)

Definition at line 366 of file ciku.c.

{
       JINT   i, j, t1, t2, t3, t4;
       JINT   nPyFlag;
       CHAR   ch;
       CHAR   szYjStr[MAX_CIZU_HZ_NUM][7];
       JINT   nThisHz, nDyzYjCode[5], nbCorrectDyz;

       for (i = 0; i < MAX_CIZU_HZ_NUM; i++)
              for (j = 0; j < 7; j++)
                     szYjStr[i][j] = '\0';

       t2 = t3 = nPyFlag = 0;
       for (i = 0; pszLine[i] != '\0'; i++)
       {
              ch = pszLine[i];

              if (((ch >= 'a') && (ch <= 'z')) || ((ch >= 'A') && (ch <= 'Z')))
              {
                     nPyFlag              = 1;
                     szYjStr[t2][t3] = ch;
                     t3 ++;
              }
              else if ((ch == ' ') && (nPyFlag == 1))
              {
                     nPyFlag              = 0;
                     t2 ++;
                     t3 = 0;
              }
       }
       nPyFlag = 0;

       for (i = 0; i < (2 * MAX_CIZU_HZ_NUM); i++)
              pszHz2244[i] = pszHz[i];

       /* Check if it is a DyoYinZi, Is this given Yjcode correct? */
       for (i = 0; (i < MAX_CIZU_HZ_NUM) && (strlen(szYjStr[i]) > 0); i++)
       {
              t1 = FastMatchYinJieStr (szYjStr[i]);
              t2 = pnYj[i];

              /* Is t1 a Valid Yjcode? Is it as same as Yjcode in pnYj? */
              if ((t1 != -1) && (t1 != t2))
              {
                     nThisHz = ((JINT)(pszHz[2*i]) << 8) + (JINT)pszHz[2*i + 1];
                     t3     = GetDyzInfo(nThisHz, nDyzYjCode);

                     nbCorrectDyz = 1;
                     for (j = 0; (j < t3) && (nbCorrectDyz == 1); j++)
                     {
                            if (t1 == nDyzYjCode[j])
                            {
                                   nbCorrectDyz = 0;
                                   pnYj[i]            = t1;
                                   t4 = EncodeDyzTo2244(nThisHz, t1);
                                   if (t4 != 0xFFFF)
                                   {
                                          pszHz2244[2*i]          = (UCHAR)((t4 & 0xFF00) >> 8);
                                          pszHz2244[2*i + 1] = (UCHAR)(t4 & 0x00FF);
                                   }
                            }
                            else
                                   nbCorrectDyz = 1;
                     }
                     if ((t3 > 0) && (nbCorrectDyz == 1))
                            printf ("GetYjInfo Error. No this DYZ YjCode.[%s] %s\n", pszLine, &(pszHz[2*i]));
              }
              else if (t1 == -1)
                     printf ("GetYjInfo Error. Invalid Yinjie String.[%s]\n", pszLine);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 428 of file PyBasic.c.

{
       JINT   hi, low;
       JINT   res;
       JINT   t1, t2, t3, t4;

       hi = (nHzcode >> 8) & 0x00FF;
       low = nHzcode & 0x00FF;
       t1 = t2 = t3 = t4 = 0;
       res = 0xFFFF;

       if ((hi >= 0xB0) && (hi <= 0xF7) && (low >= 0xA1) && (low <= 0xFE))
       {
              t1 = (hi - 0xB0) * 94 + (low - 0xA1) + 1;
              t2 = (t1 * 9 - 1) / 32;
              t3 = ((t1 - 1) * 9 - 1) / 32;
              t4 = (t1 * 9) % 32;

              if (t2 > t3)
                     res = (int)( (GBHZCODETOYJ[t2] >> (32 - t4)) & 0x01FF ) +
                           (int)( (GBHZCODETOYJ[t3] << t4) & 0x01FF );
              else if (t2 == t3)
                     res = (int)( GBHZCODETOYJ[t2] >> (32 - t4) ) & 0x01FF;
       }
       else if ((nHzcode >= 0x2001) && (nHzcode <= 0x2244))
       {
              t1 = nHzcode - 0x2000;
              t2 = (t1 * 9 - 1) / 32;
              t3 = ((t1 - 1) * 9 - 1) / 32;
              t4 = (t1 * 9) % 32;

              if (t2 > t3)
                     res = (int)( (DYZCODETOYJ[t2] >> (32 - t4)) & 0x01FF ) +
                           (int)( (DYZCODETOYJ[t3] << t4) & 0x01FF );
              else if (t2 == t3)
                     res = (int)( DYZCODETOYJ[t2] >> (32 - t4) ) & 0x01FF;
       }
       else
              res = 0xFFFF;

       return (res);
}

Here is the caller graph for this function:

JINT HzcodeToYjcode ( JINT  nHzcode)

Definition at line 28 of file PyBasic.c.

{
       JINT   hi, low;
       JINT   res;
       JINT   t1, t2, t3, t4;

       hi  = (nHzcode >> 8) & 0x00FF;
       low = nHzcode & 0x00FF;
       t1  = t2 = t3 = t4 = 0;

       res = 0xFFFF;

       if ((hi == 0xD7) && (low >= 0xFA) && (low <= 0xFE))
              res = 0xFFFF;
       else if ((hi >= 0xB0) && (hi <= 0xF7) && (low >= 0xA1) && (low <= 0xFE))
       {
              t1 = (hi - 0xB0) * 94 + (low - 0xA1) + 1;
              t2 = (t1 * 9 - 1) / 32;
              t3 = ((t1 - 1) * 9 - 1) / 32;
              t4 = (t1 * 9) % 32;

              if (t2 > t3)
                     res = (JINT)( (GBHZCODETOYJ[t2] >> (32 - t4)) & 0x01FF ) +
                           (JINT)( (GBHZCODETOYJ[t3] << t4) & 0x01FF );
              else if (t2 == t3)
                     res = (JINT)( GBHZCODETOYJ[t2] >> (32 - t4) ) & 0x01FF;
       }
       else if ((nHzcode >= 0x2001) && (nHzcode <= 0x2244))
       {
              t1 = nHzcode - 0x2000;
              t2 = (t1 * 9 - 1) / 32;
              t3 = ((t1 - 1) * 9 - 1) / 32;
              t4 = (t1 * 9) % 32;

              if (t2 > t3)
                     res = (JINT)( (DYZCODETOYJ[t2] >> (32 - t4)) & 0x01FF ) +
                           (JINT)( (DYZCODETOYJ[t3] << t4) & 0x01FF );
              else if (t2 == t3)
                     res = (JINT)( DYZCODETOYJ[t2] >> (32 - t4) ) & 0x01FF;
       }
       else
              res = 0xFFFF;

       return (res);
}

Here is the caller graph for this function:

VOID InitCizuGroupByYj ( JINT  nArraySize)

Definition at line 130 of file ciku.c.

{
       JINT   i, j;

       for (i = 0; i < nArraySize; i++)
       {
              cgCG[i].nNumFirstYjIs         = 0;
              for(j = 0; j < NUM_YINJIE; j++)
                     cgCG[i].nNum2ndYjIs[j]           = 0;
              for(j = 0; j < 1300; j++)
                     cgCG[i].nIdxItem[j]       = 0;
              for(j = 0; j < 60; j++)
                     cgCG[i].nIdxFanganItem[j]    = 0;
              cgCG[i].nSizePureCizu         = 0;
       }
}

Here is the caller graph for this function:

VOID InitCizuItem ( JINT  nItems)

Definition at line 72 of file ciku.c.

{
       JINT   i, j;

       for (i = 0; i < nItems; i++)
       {
              for (j = 0; j < CIZU_ITEM_LEN; j++)
                     czCZ[i].szLine[j]       = '\0';

              for (j = 0; j < (2 * MAX_CIZU_HZ_NUM); j++)
              {
                     czCZ[i].szHz[j]                = '\0';
                     czCZ[i].szHz2244[j]     = '\0';
              }

              for (j = 0; j < MAX_CIZU_HZ_NUM; j++)
              {
                     czCZ[i].nYj[j]                 = 0xFFFF;
                     czCZ[i].nXianFormYj[j]         = 0xFFFF;
                     czCZ[i].nFanganFormYj[j]   = 0xFFFF;
              }

              czCZ[i].nHzNum              = 0;
              czCZ[i].nYjNum              = 0;
              czCZ[i].nFreq        = 0;
              czCZ[i].nbIsXianForm   = 0;
              czCZ[i].nbIsFanganForm = 0;
              czCZ[i].nbIsEnaoForm   = 0;
       }
}

Here is the caller graph for this function:

VOID InitSingleHanziByYj ( JINT  nArraySize)

Definition at line 115 of file ciku.c.

{
       JINT   i, j;

       for (i = 0; i < nArraySize; i++)
       {
              for (j = 0; j < 256; j++)
                     shSH[i].szHanzi[j]         = '\0';
              for (j = 0; j < 64; j++)
                     shSH[i].szXianFormList[j]     = '\0';
              shSH[i].nHzNum = shSH[i].nXianFormNum = 0;
       }
}

Here is the caller graph for this function:

CHAR LastChar ( JINT  nYinjieCode)

Definition at line 1848 of file PyBasic.c.

{
       CHAR   res = ' ';           /* SPACE */
       JINT   i = 0;
       
       if ((nYinjieCode >= 0) && (nYinjieCode <= 414))
       {
              while (YINJIESTR_CSZ[nYinjieCode][i] != '\0')
                     i++;
              res = YINJIESTR_CSZ[nYinjieCode][i-1];
       }
       return res;
}

Definition at line 1022 of file ciku.c.

{
       JINT   i, k, m, n;
       JWORD  wMh[9], wDh[3], wSh[2];

       for(i = 0; i < psc->nLenYj; i++)
       {
              if ((psc->nOrgYj[i] >= 450) && (psc->nOrgYj[i] <= 475) )
                     printf("%s ", SHENGMUSTR[psc->nOrgYj[i] - 450]);
              else if ((psc->nOrgYj[i] >= 0) && (psc->nOrgYj[i] < 415) )
                     printf("%s ", YINJIESTR_CSZ[psc->nOrgYj[i]]);
       }
       printf("\n\n");

       for(n = 0; n < 9; n++)
              *(wMh + n) = 0x0000;
       for(n = 0; n < 3; n++)
              *(wDh + n) = 0x0000;
       for(n = 0; n < 2; n++)
              *(wSh + n) = 0x0000;

       i = m = 0;
       for(k = 1; i < psc->nNumMhCandi; k++)
       {
              if (psc->pwMhCandi[k] == 0x0000)
              {
                     printf( "%s\n", RecovDyz2244((UCHAR*)wMh) );
                     i++;
                     k++;
                     m = 0;
                     for(n = 0; n < 9; n++)
                            *(wMh + n) = 0x0000;
              }
              else
                     wMh[m++] = psc->pwMhCandi[k];
       }
       printf("\n");

       i = m = 0;
       for(k = 1; i < psc->nNumDhCandi; k++)
       {
              if (psc->pwDhCandi[k] == 0x0000)
              {
                     printf( "%s\n", RecovDyz2244((UCHAR*)wDh) );
                     i++;
                     k++;
                     m = 0;
                     for(n = 0; n < 3; n++)
                            *(wDh + n) = 0x0000;
              }
              else
                     wDh[m++] = psc->pwDhCandi[k];
       }
       printf("\n");

       i = m = 0;
       for(k = 0; i < psc->nNumShCandi; k++)
       {
              if (psc->pwShCandi[k] == 0x0000)
              {
                     printf( "%s  ", RecovDyz2244((UCHAR*)wSh) );
                     i++;
                     m = 0;
                     for(n = 0; n < 2; n++)
                            *(wSh + n) = 0x0000;
              }
              else
                     wSh[m++] = psc->pwShCandi[k];
       }
       printf("\n\n");
}

Here is the call graph for this function:

SysCandi * LookupSysCiku ( JINT pnOrgYj,
JINT  nLenYj,
JINT  nMatchMode 
)

Definition at line 551 of file TestCk.c.

{
       JINT      nSize, i;
       SysCandi  *pscSC;
       static  JWORD  *pwCandiBuf;

       pscSC = (SysCandi*)malloc(sizeof(SysCandi));
       if(pscSC == NULL)
       {
              fprintf(stderr, "Failed to alloc memory for struct pscSC in LookupSysCiku().\n");
              exit(FALSE);
       }

       nSize = 0;
       InitStructSc(pscSC);
       if (pwCandiBuf != NULL)
              free(pwCandiBuf);
       
       EnumSysCandi(pnOrgYj, nLenYj, pscSC, &nSize, pwCandiBuf, nMatchMode, LU_SYSCANDI_CALC);
       
       pwCandiBuf = (JWORD *)malloc(nSize * sizeof(JWORD));
       if (pwCandiBuf == NULL)
       {
              fprintf(stderr, "Error!! Failed to Malloc() in Function LookupSysCiku().\n");
              exit(FALSE);
       }
       for(i = 0; i < nSize; i++)
              *(pwCandiBuf + i) = 0x0000;
       
       printf("MhCandi[%d]  DhCandi[%d]  ShCandi[%d]. TotalSize in JWORD[%d]\n", 
              pscSC->nNumMhCandi, pscSC->nNumDhCandi, pscSC->nNumShCandi, nSize);
       
       EnumSysCandi(pnOrgYj, nLenYj, pscSC, &nSize, pwCandiBuf, nMatchMode, LU_SYSCANDI_WRITE);
       
       /* Sort Candidates in struct SysCandi by Frequence */
       SortSysCandi(pscSC);
       
       return (pscSC);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int main ( int  argc,
char **  argv 
)

Definition at line 1174 of file ciku.c.

{
       CHAR    szSysCikuName[40] = "PyCiku.dat";

       CHAR    szUdcName[40] = "UdCiku.dat";
       JINT    nRes;

       CreateUdCikuFile();

       nRes = ReadUdcData(szUdcName);
       if (nRes != TRUE)
              printf("Failed in ReadUdcData().\n");

       nRes = WriteUdcData(szUdcName, 0);
       if (nRes != TRUE)
              printf("Failed in WriteUdcData().\n");

       CreateAllData();
       CreateCikuFile();
       exit(0);

       /*
       GetCikuData (szSysCikuName);
       ParseSample();
       WriteCikuData (szSysCikuName, 0);
       */
}

Here is the call graph for this function:

VOID ParseRawInputStr ( CHAR szPreedit,
JINT pnOutPreedit 
)

Definition at line 926 of file ciku.c.

{
       CHAR   szSampleName[40] = "Sample.txt";
       FILE*  pf;
       JINT   t, m, k, nTmp;
       CHAR   szLine[256];
       JINT   nOutYj[256];
       CHAR   szDecomp[512];
       JINT   nLuNine[9];
       SysCandi *psc;
       JWORD  wOneCandi[9];

       pf = fopen(szSampleName, "rb");
       if (pf == NULL)
       {
              fprintf(stderr, "Failed to open Sample File.\n");
              exit(FALSE);
       }

       for (t = 1; t == 1;  )
       {
              for(m = 0; m < 256; m++)
              {
                     szLine[m] = '\0';
                     nOutYj[m] = 0xFFFF;
              }

              t = GetNextLine(pf, szLine);
              ParseRawInputStr(szLine, nOutYj);
              for(m = 0; m < 512; m++)
                     szDecomp[m] = '\0';
              DecompPeIntArray (nOutYj, szDecomp);
              printf("[Decomp] is %s\n", szDecomp);

              for(m = 0; m < 9; m++)
                     nLuNine[m] = 0xFFFF;

              for(m = 0; (m < 9) && (nOutYj[m] != 0); m++)
              {
                     nLuNine[m] = (nOutYj[m] & 0x01FF);

                     if ((nLuNine[m] < 0) || (nLuNine[m] > 475))
                     {
                            printf("Error!! in nLuNine\n");
                            exit(FALSE);
                     }
              }

              psc = LookupSysCiku(nLuNine, m, LU_MATCH_WIDELY);
              AdjustFreq((JWORD*)&(psc->pwDhCandi[psc->nSizDhCandi - 4]), 2);

              printf("\nStruct psc Info for String[%s]\n", szLine);
              printf("====================================================\n");

              for (k = 0; k < psc->nNumMhCandi; k++)
              {
                     for (m = 0; m < 9; m++)
                            wOneCandi[m] = 0x0000;
                     nTmp = GetXrdCandi(psc, k, wOneCandi);

                     printf( "%d %s\n", nTmp, RecovDyz2244((UCHAR*)wOneCandi) );
              }
              printf("==============\n");

              for (k = psc->nNumMhCandi; k < (psc->nNumMhCandi + psc->nNumDhCandi); k++)
              {
                     for (m = 0; m < 9; m++)
                            wOneCandi[m] = 0x0000;
                     nTmp = GetXrdCandi(psc, k, wOneCandi);
                     printf( "%d %s\n", nTmp, RecovDyz2244((UCHAR*)wOneCandi) );
              }
              printf("=============\n");

              for ( k = (psc->nNumMhCandi + psc->nNumDhCandi);
                     k < (psc->nNumMhCandi + psc->nNumDhCandi + psc->nNumShCandi); k++ )
              {
                     for (m = 0; m < 9; m++)
                            wOneCandi[m] = 0x0000;
                     nTmp = GetXrdCandi(psc, k, wOneCandi);
                     printf( "%d%s  ", nTmp, RecovDyz2244((UCHAR*)wOneCandi) );
                     if ( (k - psc->nNumMhCandi - psc->nNumDhCandi) % 20 == 0)
                            printf("\n");
              }
              printf("\n************\n");
              /*
              ListSysCandiInfo(psc);
              */
       }

       fclose (pf);
}

Here is the call graph for this function:

CreateGbkHzcodeToYj(); TestGbkHzcodeToYj();

CreateGbkHzcodeToYj(); TestGbkHzcodeToYj();

Definition at line 27 of file ProcGbk.c.

{
       JINT   i, nTmp, nTmp2, nTmp3;

       ReadGbkLine();

       memset (nGbkNumByYj, '\0', NUM_YINJIE * sizeof(JINT));
       for (i = 0; i < NUM_YINJIE; i++)
              memset (wGbkHzByYj[i], '\0', 400 * sizeof(JWORD));

       nTmp2 = nTmp3 = 0;
       nTmp = 0;
       for (i = 0; i < nGbkLine; i++)
       {
              if (nGbkYj[i] != 0xFFFF)
              {
                     /* From 0xB0A1 to 0xF7FF was processed as Normal GB2312 Hanzi */
                     if( (wGbkCode[i] >= 0x8140) && ( ! ( ((wGbkCode[i] & 0xFF00) >= 0xB000) && ((wGbkCode[i] & 0xFF00) <= 0xF700)
                                                   && ((wGbkCode[i] & 0x00FF) >= 0x00A1))) )
                     {
                            wGbkHzByYj[nGbkYj[i]][nGbkNumByYj[nGbkYj[i]]] = wGbkCode[i];
                            nGbkNumByYj[nGbkYj[i]] ++;
                            nTmp2 ++;
                     }
              }
              else
              {
              /*     printf ("!!%s", szGbkLine[i]);     */
                     nTmp ++;
              }
       }
       printf ("Total %d Non_Standard Yinjie in < GBK.txt >\n", nTmp);

       for (i = 0; i < NUM_YINJIE; i++)
       {
              if ((i != 0) && (i % 5 == 0))
                     printf ("\n");
              printf("%3d|%-6s[%3d] ", i, YINJIESTR_CSZ[i], nGbkNumByYj[i]);
       }
       printf("\n");

}

Here is the call graph for this function:

Here is the caller graph for this function:

JINT PureUdc ( VOID  )

Definition at line 952 of file UdCikuOper.c.

{
       JINT    i, k, nYj, nTmp1, nTmp2;
       JINT    nCurSize;
       JINT    nTmpFreq, nTmpLen;
       JINT    nPuredSize;

       JINT    nPureNum;
       nPureNum = 0;

       for (nYj = 0; nYj < NUM_YINJIE; nYj++)
       {
              nCurSize   = udcAll.udci.nYjOff[nYj + 1] - udcAll.udci.nYjOff[nYj];      /* In BYTE */
              nTmp1      = ((nCurSize + UDCMEM_ALIGN) / UDCMEM_ALIGN) * UDCMEM_ALIGN;  /* Old Buf Size */
              
              nPuredSize = 0;
              /* NO i++ in this FOR sentence */
              for (i = 0; i < nCurSize / 2; )
              {
                     nTmpFreq = (JUINT)udcAll.pwUdc28[nYj][i] & 0x00F8;
                     nTmpLen  = (udcAll.pwUdc28[nYj][i] & 0x0007) + 2;

                     if (nTmpFreq == 0x0008)     /* Lowest Frequence */
                     {
                            for (k = i; k < (nCurSize / 2) - (nTmpLen + 1); k++)
                                   udcAll.pwUdc28[nYj][k] = udcAll.pwUdc28[nYj][k + nTmpLen + 1];
                            for (k = (nCurSize / 2) - (nTmpLen + 1); k < nCurSize / 2; k++)
                                   udcAll.pwUdc28[nYj][k] = 0x0000;

                            nPureNum   += 1;
                            nCurSize   -= 2 * (nTmpLen + 1);
                            nPuredSize += 2 * (nTmpLen + 1);
                     }
                     else    /* If an Udcizu is already deleted, DON'T CHANGE i HERE!! MXL */
                            i += (nTmpLen + 1);
              }

              /* Adjust udcAll.udci.nYjOff[nFirstYj + 1] to nYjOff[NUM_YINJIE] */
              for (k = nYj; k < NUM_YINJIE; k++)
                     udcAll.udci.nYjOff[k + 1] -= nPuredSize;

              /* Is it necessary to resize the buffer allocated for udcAll.pwUdc28[nYj] ? */
              nTmp2     = ((nCurSize + UDCMEM_ALIGN) / UDCMEM_ALIGN) * UDCMEM_ALIGN;  /* New Buf Size */
              if (nTmp2 < nTmp1)
              {
                     udcAll.pwUdc28[nYj] = (JWORD*)realloc(udcAll.pwUdc28[nYj], nTmp2);
                     if (udcAll.pwUdc28[nYj] == NULL)
                     {
                            fprintf(stderr, "Failed to realloc() in PureUdc().\n");
                            return FALSE;
                     }
              }
       }

#ifdef _DEBUG
       fprintf (stderr, "PureNum is %d\n", nPureNum);
#endif

       return TRUE;
}
VOID QuickSort ( JINT  nFirst,
JINT  nLast 
)

Definition at line 638 of file ciku.c.

{
       JINT   nLow, nHigh, t1;

       CizuItem   czTmp, czMidSeptor;

       nLow  = nFirst;
       nHigh = nLast;
       t1 = (nFirst + nLast) /2;

       CopyStructCZ(&(czCZ[t1]), &(czMidSeptor));

       do
       {
              while( CompIntArray(czCZ[nLow].nYj,  czMidSeptor.nYj) < 0)
                     nLow ++;

              while( CompIntArray(czCZ[nHigh].nYj, czMidSeptor.nYj) > 0)
                     nHigh --;

              if (nLow <= nHigh)
              {
                     nSortNumber++;
                     if (nSortNumber % 1000 == 0)
                            fprintf (stderr, "\b\b\b\b\b\b\b%07d", nSortNumber);

                     CopyStructCZ(&(czCZ[nLow]),  &czTmp );
                     CopyStructCZ(&(czCZ[nHigh]), &(czCZ[nLow]) );
                     CopyStructCZ(&(czTmp),           &(czCZ[nHigh]) );

                     nLow++;
                     nHigh--;
              }
       } while (nLow < nHigh);

       if (nFirst < nHigh)
              QuickSort (nFirst, nHigh);
       if (nLow < nLast)
              QuickSort (nLow, nLast);
}

Here is the call graph for this function:

Here is the caller graph for this function:

JINT ReadUdcData ( CHAR szUdcName)

Definition at line 572 of file UdCikuOper.c.

{
       FILE*   pfUdc;
       JINT    i, k, nTmp;
       JINT    nFileSize;
       JINT    nWarpFlag;     /* Flag to indicate whether it is necessary to */
       
       nWarpFlag = FALSE;

       pfUdc = fopen(szUdcName, "rb");
       if (pfUdc == NULL)
       {
              return FALSE;
       }
       
       fseek(pfUdc, 0, SEEK_SET);
       if ((JINT)fread (&(udcAll.udcfh), 1, sizeof(UdCikuHeader), pfUdc) != sizeof(UdCikuHeader) )
       {
              fclose(pfUdc);
              return FALSE;
       }
       
       /* Check Magic Word in Header */
       if ((udcAll.udcfh.nMagicDescHi != 0x35303539) || (udcAll.udcfh.nMagicDescLow != 0x34333442))
       {
              /* Is SPARC or x86 File? */
              if ((udcAll.udcfh.nMagicDescHi == 0x39353035) && (udcAll.udcfh.nMagicDescLow == 0x42343334))
              {
                     nWarpFlag = TRUE;
              }
              else
              {
                     fclose(pfUdc);
                     return FALSE;
              }
       }

       if (nWarpFlag == TRUE)
              WarpCikuHeader((CikuHeader *)&(udcAll.udcfh));

       nFileSize = udcAll.udcfh.nFileSize;
       
       fseek(pfUdc, 0, SEEK_END);
       if (nFileSize != ftell(pfUdc))
       {
              fclose(pfUdc);
              return FALSE;
       }
       
       /* Read in UdcIndex Data */
       nTmp = udcAll.udcfh.nIdxUdcPos;
       fseek(pfUdc, nTmp, SEEK_SET);
       if ((JINT)fread (&(udcAll.udci), 1, sizeof(UdcIndex), pfUdc) != sizeof(UdcIndex))
       {
              fclose(pfUdc);
              return FALSE;
       }
       
       if (nWarpFlag == TRUE)
              WarpIndex( (ShIndex *)(&(udcAll.udci)) );

       /* Alloc Memory for SpecHz, and fill these data to it */
       nTmp = udcAll.udcfh.nSizeSpecHz;   /* In BYTE */
       udcAll.pwUdcSh = (JWORD*)malloc(nTmp);
       if (udcAll.pwUdcSh == NULL)
       {
              fclose(pfUdc);
              return FALSE;
       }
       
       nTmp = (udcAll.udcfh.nSizeSpecHz) / sizeof(JWORD);   /* In JWORD */
       fseek(pfUdc, udcAll.udcfh.nSpecHzStartPos, SEEK_SET);
       if ((JINT)fread (udcAll.pwUdcSh, sizeof(JWORD), nTmp, pfUdc) != nTmp )
       {
              fclose(pfUdc);
              return FALSE;
       }
       
       /* Warp pwUdcSh if necessary */
       if (nWarpFlag == TRUE)
       {
              for (i = 0; i < nTmp; i++)
                     WarpByte ( (VOID*)((JWORD*)(udcAll.pwUdcSh) + i), 2);
       }

       /* Alloc Memory for pwUdc28[NUM_YINJIE], align each with UDCMEM_ALIGN BYTE (64 JWORD) */
       for (i = 0; i < NUM_YINJIE; i++)
       {
              /* Get the Actual Size to nTmp and upper align it to UDCMEM_ALIGN */
              nTmp = udcAll.udci.nYjOff[i + 1] - udcAll.udci.nYjOff[i];
              nTmp = ((nTmp + UDCMEM_ALIGN) / UDCMEM_ALIGN) * UDCMEM_ALIGN;
              udcAll.pwUdc28[i] = (JWORD*)malloc(nTmp);
       }

       /* Is there any failure in Memory Allocation? If no, Init it to 0x0000 */
       for (i = 0; i < NUM_YINJIE; i++)
       {
              if (udcAll.pwUdc28[i] == NULL)
              {
                     for(k = 0; k < NUM_YINJIE; k++)
                     {
                            free (udcAll.pwUdc28[i]);
                            udcAll.pwUdc28[i] = NULL;
                     }
                     fprintf(stderr, "Failed in Alloc Mem for pwUdc28. %d\n", i);
                     return FALSE;
              }

              nTmp = udcAll.udci.nYjOff[i + 1] - udcAll.udci.nYjOff[i];
              nTmp = ((nTmp + UDCMEM_ALIGN) / UDCMEM_ALIGN) * UDCMEM_ALIGN;
              for (k = 0; k < (nTmp / 2); k++)
                     udcAll.pwUdc28[i][k] = 0x0000;
       }

       /* Read in pwUdc28 data */
       nTmp = udcAll.udci.nStartPos;
       fseek(pfUdc, nTmp, SEEK_SET);

       for(i = 0; i < NUM_YINJIE; i++)
       {
              nTmp = (udcAll.udci.nYjOff[i + 1] - udcAll.udci.nYjOff[i]) / sizeof(JWORD);
              if ((JINT)fread (udcAll.pwUdc28[i], sizeof(JWORD), nTmp, pfUdc) != nTmp)
              {
                     fclose(pfUdc);
                     return FALSE;
              }
              
              if (nWarpFlag == TRUE)
              {
                     for (k = 0; k < nTmp; k++)
                            WarpByte ( (VOID*)((JWORD*)(udcAll.pwUdc28[i]) + k), 2);
              }
       }
       
       fclose(pfUdc);
       return TRUE;
}

Here is the call graph for this function:

UCHAR* RecovDyz2244 ( UCHAR szDyz2244)

Definition at line 1972 of file PyBasic.c.

{
       JINT    i, j, nLen, nHlfLen;
       JINT    nDyzCode, nNormCode;
       static  UCHAR*  szNorm = NULL; 
   
       nLen = strlen((CHAR*)szDyz2244);
       nHlfLen = nLen / 2;

       if(szNorm != NULL)
              free(szNorm);

       szNorm = (UCHAR*)malloc(nLen + MALIGN);
       if (szNorm == NULL)
       {
              fprintf(stderr, "Failed to alloc Memory in function RecovDyz2244()\n");
              return (szNorm);
       }
       memset(szNorm, '\0', (nLen + MALIGN));
       
       j = 0;
       for (i = 0; i < nHlfLen; i++)
       {
              nDyzCode = szDyz2244[(2 * i) + 1] + ((JINT)szDyz2244[2 * i] << 8);
              if ((nDyzCode >= 0x2001) && (nDyzCode <= 0x2244))
              {
                     nNormCode         = DYZLIST[nDyzCode - 0x2001];
                     szNorm[2 * i]     = (UCHAR)((nNormCode & 0xFF00) >> 8);
                     szNorm[2 * i + 1] = (UCHAR)(nNormCode & 0x00FF);
              }
              else
              {
                     szNorm[2 * i]      = szDyz2244[2 * i];
                     szNorm[2 * i + 1]  = szDyz2244[2 * i + 1];
              }
       }
       
       return (szNorm);
}
VOID SetCkh ( CikuHeader pCkh)

Definition at line 194 of file CreateData.c.

{
       JINT   i, nLen;
       CHAR   szName[] = " SUN TDC P.R.C. 汉语拼音词库 1.0";
       CHAR   szCopyright[] = "版权所有(C) 太阳计算机系统(中国)有限公司 1997_11";

       for (i = 0; i < 32; i++)
              pCkh->szName[i]           = '\0';
       for (i = 0; i < 48; i++)
              pCkh->szCopyright[i] = '\0';

       pCkh->nMagicDescHi    = 0x35303539;
       pCkh->nMagicDescLow   = 0x34333442;
       pCkh->nSize         = sizeof(CikuHeader);
       pCkh->nFileSize            = 0;

       nLen = strlen(szName);
       for (i = 0; i < nLen; i++)
              pCkh->szName[i]           = szName[i];

       nLen = strlen(szCopyright);
       for (i = 0; i < nLen; i++)
              pCkh->szCopyright[i] = szCopyright[i];

       pCkh->nVersion             = 0x00010000;         /* Version 1.0 */
       pCkh->nLatestTime     = 0;
       pCkh->nIdxShPos            = 0;
       pCkh->nIdxDhPos            = 0;
       pCkh->nIdxMhPos            = 0;
       pCkh->nIdxGbkPos      = 0;
       pCkh->nReserve2            = 0;
       pCkh->nReserve3            = 0;

       printf("Sizeof this structure is %d\n", sizeof(CikuHeader));
}

Here is the caller graph for this function:

VOID SetDhi ( DhIndex pDhi)

Definition at line 259 of file CreateData.c.

{
       JINT   i, k, nt1, nTmp;
       JINT   nD2Num[NUM_YINJIE];

       pDhi->nSize         = sizeof(DhIndex);
       pDhi->nStartPos            = 0;                      /* To be added by a BaseOffset */

       for (i = 0; i < (NUM_YINJIE + 1); i++)
              pDhi->nYjOff[i]       = 0;

       for (i = 0; i < NUM_YINJIE; i++)
              nD2Num[i]      = 0;

       for (i = 0; i < NUM_YINJIE; i++)
       {
              for (k = 0; k < cgCG[i].nNumFirstYjIs; k++)
              {
                     nt1 = czCZ[ cgCG[i].nIdxItem[k] ].nHzNum;
                     if (nt1 == 2)
                            nD2Num[i] ++;
              }
       }

       for (i = 0; i < NUM_YINJIE; i++)
       {
              nTmp = 5 * nD2Num[i];                            /* 4 + 1(nFreqData) */
              for (k = i; k < NUM_YINJIE; k++)
                     pDhi->nYjOff[k + 1] += nTmp;
       }

       pDhi->nEndPos       = pDhi->nYjOff[NUM_YINJIE];  /* To be added by a BaseOffset */
       printf("Total Size of Double Hanzi Area is %d\n", pDhi->nEndPos);
}

Here is the caller graph for this function:

VOID SetMhi ( MhIndex pMhi)

Definition at line 295 of file CreateData.c.

{
       JINT   i, k, nt1;
       JINT   nM3Num[NUM_YINJIE], nM3Len[NUM_YINJIE];

       pMhi->nSize         = sizeof(MhIndex);
       pMhi->nStartPos            = 0;

       for (i = 0; i < (NUM_YINJIE + 1); i++)
              pMhi->nYjOff[i]       = 0;

       for (i = 0; i < NUM_YINJIE; i++)
       {
              nM3Num[i]     = 0;
              nM3Len[i]     = 0;
       }

       for (i = 0; i < NUM_YINJIE; i++)
       {
              for (k = 0; k < cgCG[i].nNumFirstYjIs; k++)
              {
                     nt1 = czCZ[ cgCG[i].nIdxItem[k] ].nHzNum;
                     if (nt1 > 2)
                     {
                            nM3Num[i] ++;
                            nM3Len[i] += (2 * nt1) + 1;
                     }
              }
       }

       for (i = 0; i < NUM_YINJIE; i++)
              for (k = i; k < NUM_YINJIE; k++)
                     pMhi->nYjOff[k + 1] += nM3Len[i];

       pMhi->nEndPos       = pMhi->nYjOff[NUM_YINJIE];  /* To be added by a BaseOffset */

       printf("Total Size of Multiple (>=3) Hanzi Area is %d\n", pMhi->nEndPos);
}

Here is the caller graph for this function:

VOID SetShi ( ShIndex pShi)

Definition at line 231 of file CreateData.c.

{
       JINT   i, k, nTmp;

       pShi->nSize         = sizeof(ShIndex);
       pShi->nStartPos            = 0;                                /* To be added by a BaseOffset */

       for (i = 0; i < (NUM_YINJIE + 1); i++)
              pShi->nYjOff[i]       = 0;

       /*
       ** Each pShi->nYjOff[i] is less than 0x00FFFFFF. Highest 8 bit contains
       ** the number of nXianFormNum.
       */
       for (i = 0; i < NUM_YINJIE; i++)
       {
              nTmp = (2 * shSH[i].nHzNum) + (4 * shSH[i].nXianFormNum);
              for (k = i; k < NUM_YINJIE; k++)
                     pShi->nYjOff[k + 1] += nTmp;
              pShi->nYjOff[i + 1] += (shSH[i].nXianFormNum << 24);
       }

       pShi->nEndPos       = pShi->nYjOff[NUM_YINJIE] & 0x00FFFFFF;     /* To be added by a BaseOffset */

       printf("sizeof(ShIndex) is %d, Total Single Hanzi Data area size is %d\n", sizeof(ShIndex), pShi->nEndPos );
}

Here is the caller graph for this function:

JINT ValidAddChar ( CHAR  ch,
JINT  nYinjieCode 
)

Definition at line 1909 of file PyBasic.c.

{
       JINT    i, nTmpRes;
       CHAR    szStr[7];
       
       for (i = 0; i < 7; i++)
              szStr[i] = '\0';

       szStr[0] = ch;
       if ((nYinjieCode >= 0) && (nYinjieCode <= 414))
       {
              i = 0; 
              while (YINJIESTR_CSZ[nYinjieCode][i])
              {
                     szStr[i + 1] = YINJIESTR_CSZ[nYinjieCode][i];
                     i++;
              }
                     
              nTmpRes = FastMatchYinJieStr(szStr);
              if(nTmpRes != -1)
                     return nTmpRes;
       }
       
       return 0xFFFF;
}
JINT ValidButFirstChar ( JINT  nYinjieCode)

Definition at line 1940 of file PyBasic.c.

{
       JINT    i, nTmpRes;
       CHAR    szStr[7];
       
       for (i = 0; i < 7; i++)
              szStr[i] = '\0';
       
       if ((nYinjieCode >= 0) && (nYinjieCode <= 414))
       {
              i = 0; 
              while (YINJIESTR_CSZ[nYinjieCode][i+1])
              {
                     szStr[i] = YINJIESTR_CSZ[nYinjieCode][i+1];
                     i++;
              }
                     
              nTmpRes = FastMatchYinJieStr(szStr);
              if(nTmpRes != -1)
                     return nTmpRes;
       }
       
       return 0xFFFF;
}
JINT ValidButLastChar ( JINT  nYinjieCode)

Definition at line 1880 of file PyBasic.c.

{
       JINT    i, nTmpRes;
       CHAR    szStr[7];
       
       for (i = 0; i < 7; i++)
              szStr[i] = '\0';
       
       if ((nYinjieCode >= 0) && (nYinjieCode <= 414))
       {
              i = 0; 
              while (YINJIESTR_CSZ[nYinjieCode][i+1])
              {
                     szStr[i] = YINJIESTR_CSZ[nYinjieCode][i];
                     i++;
              }
                     
              nTmpRes = FastMatchYinJieStr(szStr);
              if(nTmpRes != -1)
                     return nTmpRes;
       }
       return 0xFFFF;
}
JINT WriteCikuData ( CHAR szSysCikuName,
JINT  nTimeStamp 
)

Definition at line 255 of file CikuOper.c.

{
       FILE*   pfCiku;
       JINT    i, k;
       JINT    nFileSize, nTmp;
       
       CikuHeader  *pCkh;
       ShIndex     *pShi;
       DhIndex     *pDhi;
       MhIndex     *pMhi;
       GbkIndex    *pGbki;
       BYTE        *pShArea;
       BYTE        *pDhArea;
       BYTE        *pMhArea;
       BYTE        *pGbkArea;

       pCkh     = (CikuHeader *)pCkAll;
       pShi     = (ShIndex  *)(pCkAll + pCkh->nIdxShPos);
       pDhi     = (DhIndex  *)(pCkAll + pCkh->nIdxDhPos);
       pMhi     = (MhIndex  *)(pCkAll + pCkh->nIdxMhPos);
       pGbki    = (GbkIndex *)(pCkAll + pCkh->nIdxGbkPos);
       
       pShArea  = (BYTE *)(pCkAll + pShi->nStartPos);
       pDhArea  = (BYTE *)(pCkAll + pDhi->nStartPos);
       pMhArea  = (BYTE *)(pCkAll + pMhi->nStartPos);
       pGbkArea = (BYTE *)(pCkAll + pGbki->nStartPos);
       
       pCkh->nLatestTime = nTimeStamp;
       
       /* Write These data back to file */
       pfCiku = fopen(szSysCikuName, "wb");
       if (pfCiku == NULL)
       {
              fprintf(stderr, "Failed to Create System Ciku File: %s\n", szSysCikuName);
              return FALSE;
       }
       
       for(i = 0; i < NUM_YINJIE; i++)
              for(k = (pShi->nYjOff[i] & 0x00FFFFFF); k < (pShi->nYjOff[i + 1] & 0x00FFFFFF); k++)
                     *(pShArea + k) ^= (BYTE)((i + 56) / 2);

       for(i = 0; i < NUM_YINJIE; i++)
              for(k = pDhi->nYjOff[i]; k < pDhi->nYjOff[i + 1]; k++)
                     *(pDhArea + k) ^= (BYTE)((i + 56) / 2);

       for(i = 0; i < NUM_YINJIE; i++)
              for(k = pMhi->nYjOff[i]; k < pMhi->nYjOff[i + 1]; k++)
                     *(pMhArea + k) ^= (BYTE)((i + 56) / 2);
       
       for(i = 0; i < NUM_YINJIE; i++)
              for(k = pGbki->nYjOff[i]; k < pGbki->nYjOff[i + 1]; k++)
                     *(pGbkArea + k) ^= (BYTE)((i + 56) / 2);

       nFileSize = pCkh->nFileSize;

       fseek(pfCiku, 0, SEEK_SET);
       nTmp = (JINT)fwrite (pCkAll, nFileSize, 1, pfCiku);
       
       for(i = 0; i < NUM_YINJIE; i++)
              for(k = (pShi->nYjOff[i] & 0x00FFFFFF); k < (pShi->nYjOff[i + 1] & 0x00FFFFFF); k++)
                     *(pShArea + k) ^= (BYTE)((i + 56) / 2);

       for(i = 0; i < NUM_YINJIE; i++)
              for(k = pDhi->nYjOff[i]; k < pDhi->nYjOff[i + 1]; k++)
                     *(pDhArea + k) ^= (BYTE)((i + 56) / 2);

       for(i = 0; i < NUM_YINJIE; i++)
              for(k = pMhi->nYjOff[i]; k < pMhi->nYjOff[i + 1]; k++)
                     *(pMhArea + k) ^= (BYTE)((i + 56) / 2);
       
       for(i = 0; i < NUM_YINJIE; i++)
              for(k = pGbki->nYjOff[i]; k < pGbki->nYjOff[i + 1]; k++)
                     *(pGbkArea + k) ^= (BYTE)((i + 56) / 2);

       if (nTmp != 1)
       {
              fprintf(stderr, "Failed to fwrite() System Ciku File.\n");
              return FALSE;
       }
       
       fclose (pfCiku);
       return TRUE;
}

Here is the caller graph for this function:

JINT WriteUdcData ( CHAR szUdcName,
JINT  nTimeStamp 
)

Definition at line 711 of file UdCikuOper.c.

{
       FILE*   pfUdc;
       JINT    i, nTmp;
       JINT    nFileSize;

       udcAll.udcfh.nLatestTime  = nTimeStamp;

       nFileSize = sizeof(UdCikuHeader) + sizeof(UdcIndex) + 
                   udcAll.udcfh.nSizeSpecHz + udcAll.udci.nYjOff[NUM_YINJIE];
       udcAll.udcfh.nFileSize    = nFileSize;
       udcAll.udci.nStartPos     = sizeof(UdCikuHeader) + sizeof(UdcIndex) + udcAll.udcfh.nSizeSpecHz;
       udcAll.udci.nEndPos       = sizeof(UdCikuHeader) + sizeof(UdcIndex) + 
                   udcAll.udcfh.nSizeSpecHz + udcAll.udci.nYjOff[NUM_YINJIE];

       /* Write These data back to file */
       pfUdc = fopen(szUdcName, "wb");
       if (pfUdc == NULL)
       {
              fprintf(stderr, "Failed to Open UdCiku File to Write.\n");
              return FALSE;
       }
       
       if ((JINT)fwrite (&(udcAll.udcfh), 1, sizeof(UdCikuHeader), pfUdc) != sizeof(UdCikuHeader) )
       {
              fprintf(stderr, "Failed to fwrite() Ud Ciku File11.\n");
              return FALSE;
       }

       if ((JINT)fwrite (&(udcAll.udci),  1, sizeof(UdcIndex), pfUdc) != sizeof(UdcIndex) )
       {
              fprintf(stderr, "Failed to fwrite() Ud Ciku File22.\n");
              return FALSE;
       }

       nTmp = (udcAll.udcfh.nSizeSpecHz) / sizeof(JWORD);
       if ((JINT)fwrite (udcAll.pwUdcSh, sizeof(JWORD), nTmp, pfUdc) != nTmp )
       {
              fprintf(stderr, "Failed to fwrite() Ud Ciku File33.\n");
              return FALSE;
       }
       
       for(i = 0; i < NUM_YINJIE; i++)
       {
              nTmp = (udcAll.udci.nYjOff[i + 1] - udcAll.udci.nYjOff[i]) / sizeof(JWORD);
              if ((JINT)fwrite (udcAll.pwUdc28[i], sizeof(JWORD), nTmp, pfUdc) != nTmp )
              {
                     fprintf(stderr, "Failed to fwrite() Ud Ciku File44.\n");
                     return FALSE;
              }
       }
       
       fclose(pfUdc);
       return TRUE;
}

Variable Documentation

Definition at line 69 of file ciku.c.

Definition at line 67 of file ciku.c.

Definition at line 65 of file ciku.c.

Definition at line 66 of file ciku.c.

Definition at line 68 of file ciku.c.