Back to index

im-sdk  12.3.91
Functions | Variables
CikuOper.c File Reference
#include "PYIM.h"
#include "UDCOper.h"

Go to the source code of this file.

Functions

JINT GbkHz2244ToYjSM (JINT nHzcode)
JINT GbkHz2244ToYj (JINT nHzcode)
UCHARRecovDyz2244 (UCHAR *szDyz2244)
VOID Jword2Uchar (JWORD *pwJword, UCHAR *szUch, JINT nMaxLen)
VOID JwordNCpy (JWORD *pwDst, JWORD *pwSrc, JINT nLen)
JINT JwordValidLen (JWORD *pwJwordArray, JINT nMaxLen)
JINT JwordHanziLen (JWORD *pwJwordArray, JINT nMaxLen)
JINT JwordNCmp (JWORD *pwSrc1, JWORD *pwSrc2, JINT nNum)
JINT IsGbkkkHz (JWORD wHz)
JINT GetCikuData (CHAR *szSysCikuName)
JINT WriteCikuData (CHAR *szSysCikuName, JINT nTimeStamp)
JINT EnumCandi (JINT *pnOrgYj, JINT nLenYj, SysCandi *psc, UdcCandi *puc, JINT *pnSize, JINT nMatchMode, JINT nMode)
VOID InitStructSc (SysCandi *psc)
VOID InitStructUc (UdcCandi *puc)
JINT LookupCiku (JINT *pnOrgYj, JINT nLenYj, JINT nMatchMode, SysCandi *psc, UdcCandi *puc)
VOID SortCandi (SysCandi *psc, UdcCandi *puc)
VOID AdjustFreq (JWORD *pwHz2244, JINT nLenThis)
JINT IsCizuExist (JWORD *pwHz2244, JINT nLenThis)
VOID WarpByte (VOID *pv, JINT n)
VOID WarpIndex (ShIndex *pInt419)
VOID WarpCikuHeader (CikuHeader *pCh)
VOID FreePckAll ()
VOID ProcFreq (SesGuiElement *pSge)

Variables

BYTEpCkAll = NULL
UdcMemAll udcAll
UDCDataudcGB
UDCDataudcGBK

Function Documentation

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;
                     }
              }
       }

}
JINT EnumCandi ( JINT pnOrgYj,
JINT  nLenYj,
SysCandi psc,
UdcCandi puc,
JINT pnSize,
JINT  nMatchMode,
JINT  nMode 
)

Definition at line 345 of file CikuOper.c.

{
       free(pCkAll);
       pCkAll = NULL;
}
JINT GbkHz2244ToYj ( JINT  nHzcode)

Definition at line 1640 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 >= 0x81) && (hi <= 0xA0) && (low >= 0x40) && (low <= 0xFE))
       {
              t1 = (hi - 0x81) * 191 + (low - 0x40) + 1;
              t2 = (t1 * 9 - 1) / 32;
              t3 = ((t1 - 1) * 9 - 1) / 32;
              t4 = (t1 * 9) % 32;

              if (t2 > t3)
                     res = (JINT)( (GBKHZCODETOYJ[t2] >> (32 - t4)) & 0x01FF ) + 
                           (JINT)( (GBKHZCODETOYJ[t3] << t4) & 0x01FF );
              else if (t2 == t3)
                     res = (JINT)( GBKHZCODETOYJ[t2] >> (32 - t4) ) & 0x01FF;
       }
       else if ((hi >= 0xAA) && (hi <= 0xFE) && (low >= 0x40) && (low <= 0xFE))
       {
              t1 = (hi - 0xAA) * 191 + (low - 0x40) + 1;
              t2 = (t1 * 9 - 1) / 32;
              t3 = ((t1 - 1) * 9 - 1) / 32;
              t4 = (t1 * 9) % 32;

              if (t2 > t3)
                     res = (JINT)( (GBKHZCODETOYJ[t2 + (9 * 191)] >> (32 - t4)) & 0x01FF ) + 
                           (JINT)( (GBKHZCODETOYJ[t3 + (9 * 191)] << t4) & 0x01FF );
              else if (t2 == t3)
                     res = (JINT)( GBKHZCODETOYJ[t2 + (9 * 191)] >> (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;

       if (res == 0x01FF)
              res = 0xFFFF;
              
       return (res);
}
JINT GbkHz2244ToYjSM ( JINT  nHzcode)

Definition at line 1706 of file PyBasic.c.

{
       JINT    nTmpRes;
       JINT    nRet;
       
       nTmpRes = GbkHz2244ToYj(nHzcode);

       if (nTmpRes != 0xFFFF)
       {
              if ((nTmpRes >= 38) && (nTmpRes < 57 ))        /* "ch" */
                     nRet =  3 + 450;
              else if ((nTmpRes >= 301) && (nTmpRes < 320))  /* "sh" */
                     nRet = 19 + 450;
              else if ((nTmpRes >= 395) && (nTmpRes < 415))  /* "zh" */
                     nRet = 25 + 450;
              else
                     nRet = INDEXMAGIC[(JINT)(YINJIESTR_CSZ[nTmpRes][0] - 'a')] + 450;
                     
              return nRet;
       }

       return 0xFFFF;
}
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;
}

Definition at line 892 of file CikuOper.c.

{
       JINT    i;
       
       for(i = 0; i < 9; i++)
              psc->nOrgYj[i]     = 0x00000000;

       psc->nLenYj       = 0;
       psc->nNumShCandi  = 0;
       psc->nNumDhCandi  = 0;
       psc->nNumMhCandi  = 0;
       psc->nNumGbkCandi = 0;
       
       psc->nSizShCandi  = 0;
       psc->nSizDhCandi  = 0;
       psc->nSizMhCandi  = 0;
       psc->nSizGbkCandi = 0;
       
       free (psc->pwShCandi);
       free (psc->pwDhCandi);
       free (psc->pwMhCandi);
       free (psc->pwGbkCandi);
       psc->pwShCandi   = NULL;
       psc->pwDhCandi   = NULL;
       psc->pwMhCandi   = NULL;
       psc->pwGbkCandi  = NULL;
}

Definition at line 1017 of file UdCikuOper.c.

{
       JINT    i;

       puc->nNumSpecCandi   = 0;
       puc->nNumUdc28Candi  = 0;
       puc->nSizUdc28Candi  = 0;

       for (i = 0; i < 6; i++)
              puc->pwSpecCandi[i] = 0x0000;

       free (puc->pwUdc28Candi);
       puc->pwUdc28Candi    = NULL;
}
JINT IsCizuExist ( JWORD pwHz2244,
JINT  nLenThis 
)

Definition at line 1393 of file CikuOper.c.

{
       JINT    nFindFlag;
       
       JINT    nYjFirst;
       JINT    nCzLen, i, k;
       JINT    nFromOff, nToOff;
       JWORD   wMhLenFreq, wFreq;
       UCHAR   pchHz2244[20];     /* Max is 9 Hanzi!! */
       JINT    nCurSize, nUdc28FreqLen, nUdc28Len;

       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);

       nFindFlag = NON_EXIST_CIZU;
       memset(pchHz2244, '\0', 20);
       Jword2Uchar(pwHz2244, pchHz2244, nLenThis);
       
       /* 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, Set nFindFlag and return */
                     if ((nCzLen == nLenThis) &&
                            (strncmp((CHAR*)(&pMhArea[k]), (CHAR*)pchHz2244, 2 * nCzLen) == 0) )
                     {
                            nFindFlag  = SYS_EXIST_CIZU;
                            return nFindFlag;
                     }
                     /* Just Skip this Mh Word */
                     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)
                     {
                            nFindFlag  = SYS_EXIST_CIZU;
                            return nFindFlag;
                     }
                     /* Just Skip this Dh Cizu */
                     else
                            k += 2 * nCzLen;
              }
       }
       
       else if (nLenThis == 1)
       {
              nFindFlag = SYS_EXIST_CIZU;
              return nFindFlag;
       }
       
       if (nFindFlag == NON_EXIST_CIZU)
       {
              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. 
                     **
                     **  A Small & Big BUG was Arrested!! aHa!! 97-12-28!!
                     **  This bug appear in INTEL x86 CPU!!
                     if ((nUdc28Len == nLenThis) &&
                            (strncmp((CHAR*)&(udcAll.pwUdc28[nYjFirst][i]), (CHAR*)pchHz2244, 2 * nUdc28Len) == 0) )
                     */
                     if ((nUdc28Len == nLenThis) &&
                            (JwordNCmp(&(udcAll.pwUdc28[nYjFirst][i]), pwHz2244, nUdc28Len) == 0) )
                     {
                            nFindFlag  = UDC_EXIST_CIZU;
                            return nFindFlag;
                     }
                     else
                            i += nUdc28Len;
              }
       }
       
       return nFindFlag;      /* Must be NON_EXIST_CIZU HERE. */
}

Here is the call graph for this function:

JINT IsGbkkkHz ( JWORD  wHz)

Definition at line 339 of file Jword.c.

{
       JINT    nRet;
       JINT    nHi, nLow;
    
       nHi  = (wHz & 0xFF00) >> 8;
       nLow = wHz & 0x00FF;
    
       nRet = TRUE;
       if ((wHz >= 0x2001) && (wHz <= 0x2244))
              nRet = FALSE;
       else if ((nHi >= 0xB0) && (nHi <= 0xF7) && (nLow >= 0xA1) && (nLow <= 0xFE))
              nRet = FALSE;
              
       return nRet;
}
VOID Jword2Uchar ( JWORD pwJword,
UCHAR szUch,
JINT  nMaxLen 
)

Definition at line 275 of file Jword.c.

{
       JINT     i, j;
       
       j = 0;
       for(i = 0; i < nMaxLen; i++)
       {
              if(pwJword[i] >= 0x0100)           /* OR 0x8140: First char defined in GBK */
              {
                     szUch[j++] = (UCHAR)((pwJword[i] & 0xFF00) >> 8);
                     szUch[j++] = (UCHAR)(pwJword[i] & 0x00FF);
              }
              else
                     szUch[j++] = (UCHAR)(pwJword[i] & 0x00FF);
       }
}
JINT JwordHanziLen ( JWORD pwJwordArray,
JINT  nMaxLen 
)

Definition at line 228 of file Jword.c.

{
       JINT   i, nValidLen;
       
       i = 0;
       nValidLen = 0;
       while ((i < nMaxLen) && (pwJwordArray[i] != 0))
       {
              i++;
              if (pwJwordArray[i] != 0x0009)
                     nValidLen++;
       }
              
       return nValidLen;
}
JINT JwordNCmp ( JWORD pwSrc1,
JWORD pwSrc2,
JINT  nNum 
)

Definition at line 303 of file Jword.c.

{
       JINT    i;
       JINT    nRet;

       nRet = 0;
       for(i = 0; (i < nNum) && (nRet == 0); i++)
       {
              if(pwSrc1[i] > pwSrc2[i])
              {
                     nRet = 1;
                     break;
              }
              else if(pwSrc1[i] < pwSrc2[i])
              {
                     nRet = -1;
                     break;
              }
       }

       return nRet;
}
VOID JwordNCpy ( JWORD pwDst,
JWORD pwSrc,
JINT  nLen 
)

Definition at line 327 of file Jword.c.

{
       JINT    i;
       
       for (i = 0; i < nLen; i++)
              pwDst[i] = pwSrc[i];
}
JINT JwordValidLen ( JWORD pwJwordArray,
JINT  nMaxLen 
)

Definition at line 206 of file Jword.c.

{
       JINT   i, nValidLen;
       
       i = 0;
       nValidLen = 0;
       while ((i < nMaxLen) && (*(pwJwordArray + i) != 0))
       {
              i++;
              nValidLen++;
       }
              
       return nValidLen;
}
JINT LookupCiku ( JINT pnOrgYj,
JINT  nLenYj,
JINT  nMatchMode,
SysCandi psc,
UdcCandi puc 
)

Definition at line 930 of file CikuOper.c.

{
       JINT    nSize, i;

       nSize = 0;

       InitStructSc(psc);
       InitStructUc(puc);
       
       /* 
       ** Set the content of psc->nOrgYj and pscYj->nLenYj    AND 
       ** Filter those Yjcode which start with a [']. 
       */
       for(i = 0; i < nLenYj; i++)
       {
              psc->nOrgYj[i]  = pnOrgYj[i];
              pnOrgYj[i]     &= 0x0000FFFF;
       }
       psc->nLenYj  = nLenYj;
       
       EnumCandi(pnOrgYj, nLenYj, psc, puc, &nSize, nMatchMode, LU_CANDI_CALC);
       
       psc->pwMhCandi    = (JWORD*)malloc((psc->nSizMhCandi  + MALIGN) * sizeof(JWORD));
       psc->pwDhCandi    = (JWORD*)malloc((psc->nSizDhCandi  + MALIGN) * sizeof(JWORD));
       psc->pwShCandi    = (JWORD*)malloc((psc->nSizShCandi  + MALIGN) * sizeof(JWORD));
       psc->pwGbkCandi   = (JWORD*)malloc((psc->nSizGbkCandi + MALIGN) * sizeof(JWORD));
       puc->pwUdc28Candi = (JWORD*)malloc((puc->nSizUdc28Candi + MALIGN) * sizeof(JWORD));

       if ((psc->pwMhCandi == NULL)  || (psc->pwDhCandi == NULL) || (psc->pwShCandi == NULL) || 
              (psc->pwGbkCandi == NULL) || (puc->pwUdc28Candi == NULL) )
       {
              fprintf(stderr, "Error!! Failed to Malloc() in Function LookupCiku().\n");
              return FALSE;
       }

       memset(psc->pwMhCandi,  '\0', (psc->nSizMhCandi  + MALIGN) * sizeof(JWORD));
       memset(psc->pwDhCandi,  '\0', (psc->nSizDhCandi  + MALIGN) * sizeof(JWORD));
       memset(psc->pwShCandi,  '\0', (psc->nSizShCandi  + MALIGN) * sizeof(JWORD));
       memset(psc->pwGbkCandi, '\0', (psc->nSizGbkCandi + MALIGN) * sizeof(JWORD));
       memset(puc->pwUdc28Candi, '\0', (puc->nSizUdc28Candi + MALIGN) * sizeof(JWORD));
       
       EnumCandi(pnOrgYj, nLenYj, psc, puc, &nSize, nMatchMode, LU_CANDI_WRITE);
       
       /* Additional Process for Spec Hanzi Candi, MXL 98.01.12 */
       if (0 == (psc->nNumMhCandi + psc->nNumDhCandi + puc->nNumUdc28Candi))
              puc->nNumSpecCandi = 0;
       
       /* Sort Candidates in structure SysCandi and UdcCandi by Frequence */
       SortCandi(psc, puc);
       
       return TRUE;
}

Here is the call graph for this function:

Definition at line 1595 of file CikuOper.c.

{
       JINT    i, k, m;
       JWORD   wThisSel[9];        /* Contain Hz2244 Cizu Item */
       JINT    nLenThis;

       k = 0;
       nLenThis = 0;
       for(m = 0; m < 9; m++)
              wThisSel[m] = 0x0000;

       /* Don't add i++ and k++ in this FOR sentence */
       for (i = 0; (i < pSge->nSlctSteps) && (k < UTWO); )
       {
              if (pSge->pwSlctHz[k] == 0x0009)
              {
                     k++;
                     i++;
                     AdjustFreq(wThisSel, nLenThis);
                     for(m = 0; m < 9; m++)
                            wThisSel[m] = 0x0000;
                     nLenThis = 0;
              }
              else
              {
                     wThisSel[nLenThis] = pSge->pwSlctHz[k];
                     nLenThis++;
                     k++;
              }
       }
}

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 SortCandi ( SysCandi psc,
UdcCandi puc 
)
VOID WarpByte ( VOID pv,
JINT  n 
)

Definition at line 79 of file CikuOper.c.

{
       JINT    nInt;
       JWORD   wWord;
       
       nInt = wWord = 0;
       if (n == 4)
       {
              nInt = *((JINT*)pv);
              *((JINT*)pv) = ((nInt & 0x000000FF) << 24) + ((nInt & 0x0000FF00) << 8) +
                             ((nInt & 0xFF000000) >> 24) + ((nInt & 0x00FF0000) >> 8);
       }
       else if (n == 2)
       {
              wWord = *((JWORD*)pv);
              *((JWORD*)pv) = (JWORD)( ((wWord & 0x00FF) << 8) + ((wWord & 0xFF00) >> 8) );
       }
       else
              return;
}

Definition at line 103 of file CikuOper.c.

{
       JINT    i;
       
       for (i = 0; i < 4; i++)
       {
              WarpByte( (VOID*)((JINT*)pCh + i), 4);
       }
       
       for (i = 24; i < 32; i++)
       {
              WarpByte( (VOID*)((JINT*)pCh + i), 4);
       }
}

Here is the call graph for this function:

VOID WarpIndex ( ShIndex pInt419)

Definition at line 121 of file CikuOper.c.

{
       JINT    i;
       
       for (i = 0; i < 419; i++)
       {
              WarpByte( (VOID*)((JINT*)pInt419 + i), 4);
       }
}

Here is the call graph for this function:

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;
}

Variable Documentation

Definition at line 72 of file CikuOper.c.

Definition at line 89 of file UdCikuOper.c.

Definition at line 48 of file UDCOper.c.

Definition at line 48 of file UDCOper.c.