Back to index

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

Go to the source code of this file.

Defines

#define SLCT_TYPE_INVALID   0 /* Invalid Selection */
#define SLCT_TYPE_NONLINK   1 /* One of Non Link Hanzi */
#define SLCT_TYPE_PRELINK   2 /* One of Pre Link Hanzi */
#define SLCT_TYPE_SUFLINK   3 /* One of Suf Link Hanzi */
#define SLCT_TYPE_NORMHZ   4 /* Normal Single Hanzi */
#define SLCT_TYPE_TWOHZ   5 /* Two Hanzi */
#define SLCT_TYPE_THREEHZ   6 /* Three Hanzi */
#define SLCT_TYPE_MFOURHZ   7 /* >= 4 Hanzi */

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 JwordNCmp (JWORD *pwSrc1, JWORD *pwSrc2, JINT nNum)
JINT JwordValidLen (JWORD *pwJwordArray, JINT nMaxLen)
JINT JwordHanziLen (JWORD *pwJwordArray, JINT nMaxLen)
VOID ProcUdCizu (SesGuiElement *pSge)
VOID UniformSlctHz (SesGuiElement *pSge)
JINT GetNSelect (JINT nXrd, JINT nTotalStep, JWORD *pwSlctHz, JWORD *pwUdcUnit)
VOID AdjustFreq (JWORD *pwHz2244, JINT nLenThis)
JINT IsCizuExist (JWORD *pwHz2244, JINT nLenThis)
VOID JwordInfo (JWORD *pwJwordArray, JINT nMaxLen)
VOID WarpByte (VOID *pv, JINT n)
VOID WarpIndex (ShIndex *pInt419)
VOID WarpCikuHeader (CikuHeader *pCh)
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 FreeUdcData ()
VOID InitStructUc (UdcCandi *puc)
JINT HasNonLinkHz (JWORD *pwSlctHz, JINT nTotalSteps)
JINT IsXrdNonLinkHz (JINT nXrd, JWORD *pwSlctHz, JINT nTotalSteps)
JINT IsXrdPreLinkHz (JINT nXrd, JWORD *pwSlctHz, JINT nTotalSteps)
JINT IsXrdSufLinkHz (JINT nXrd, JWORD *pwSlctHz, JINT nTotalSteps)
JINT TypeOfNSelect (JINT nXrd, JWORD *pwSlctHz, JINT nTotalSteps)

Variables

UdcMemAll udcAll

Define Documentation

#define SLCT_TYPE_INVALID   0 /* Invalid Selection */

Definition at line 81 of file UdCikuOper.c.

#define SLCT_TYPE_MFOURHZ   7 /* >= 4 Hanzi */

Definition at line 88 of file UdCikuOper.c.

#define SLCT_TYPE_NONLINK   1 /* One of Non Link Hanzi */

Definition at line 82 of file UdCikuOper.c.

#define SLCT_TYPE_NORMHZ   4 /* Normal Single Hanzi */

Definition at line 85 of file UdCikuOper.c.

#define SLCT_TYPE_PRELINK   2 /* One of Pre Link Hanzi */

Definition at line 83 of file UdCikuOper.c.

#define SLCT_TYPE_SUFLINK   3 /* One of Suf Link Hanzi */

Definition at line 84 of file UdCikuOper.c.

#define SLCT_TYPE_THREEHZ   6 /* Three Hanzi */

Definition at line 87 of file UdCikuOper.c.

#define SLCT_TYPE_TWOHZ   5 /* Two Hanzi */

Definition at line 86 of file UdCikuOper.c.


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

Definition at line 772 of file UdCikuOper.c.

{
       JINT    i;

       free (udcAll.pwUdcSh);
       udcAll.pwUdcSh = NULL;

       for (i = 0; i < NUM_YINJIE; i++)
       {
              free (udcAll.pwUdc28[i]);
              udcAll.pwUdc28[i] = NULL;
       }
}

Here is the caller graph for this function:

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

Here is the call graph for this function:

JINT GetNSelect ( JINT  nXrd,
JINT  nTotalStep,
JWORD pwSlctHz,
JWORD pwUdcUnit 
)
JINT HasNonLinkHz ( JWORD pwSlctHz,
JINT  nTotalSteps 
)

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

Here is the caller graph for this function:

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:

Here is the caller graph for this function:

JINT IsXrdNonLinkHz ( JINT  nXrd,
JWORD pwSlctHz,
JINT  nTotalSteps 
)
JINT IsXrdPreLinkHz ( JINT  nXrd,
JWORD pwSlctHz,
JINT  nTotalSteps 
)
JINT IsXrdSufLinkHz ( JINT  nXrd,
JWORD pwSlctHz,
JINT  nTotalSteps 
)
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;
}
VOID JwordInfo ( JWORD pwJwordArray,
JINT  nMaxLen 
)

Definition at line 89 of file Jword.c.

{
       JINT    i, j, nLen;
       JWORD   wTmp;
       UCHAR   szStr[1024];
       
       nLen = JwordValidLen(pwJwordArray, nMaxLen);

       memset(szStr, '\0', 1024);

       i = j = 0;
       for (i = 0; i < nLen; i++)
       {
              wTmp = *(pwJwordArray + i);
              if ( (wTmp & 0xFF00) > 0)
              {
                     *(szStr + j) = (UCHAR)(( wTmp & 0xFF00) >> 8);
                     j++;
                     
                     *(szStr + j) = (UCHAR)(wTmp & 0x00FF);
                     j++;
              }
              else if ((wTmp < 0x0080) && (wTmp != 0x0009))
              {
                     *(szStr + j)  = (UCHAR)(wTmp & 0x00FF);
                     j++;
              }
       }
       
       fprintf (stderr, "%d  %s\n", j, szStr);
/*     fprintf (stderr, "%d  %s\n", j, RecovDyz2244(szStr));   */
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 111 of file UdCikuOper.c.

{
       JINT    i, j, k, m, w;
       JINT    nOrgStep, nUnifStep;
       JWORD   wTmp[10], wTmpBak[20];
       JINT    nTmpLen, nHzNum;
       JINT    nTypeSlct[8];              /* Max Length of User defined Cizu is 8 */

       nOrgStep   = pSge->nSlctSteps;
       /* Uniform pwSlctHz */
       UniformSlctHz(pSge);
       nUnifStep  = pSge->nSlctSteps;
       
       /* NOT JwordValidLen() Here. Don't count 0x0009 */
       nHzNum     = JwordHanziLen(pSge->pwSlctHz, UTWO);
       
       assert(nUnifStep != 0);
       
       /*
       **  以下 IF...ELSE... 逻辑中有重叠的情况, 为清晰起见, 分别列出. 
       **  如果归一为一个选择, 则立即返回.
       */
       if (nUnifStep <= 1)
              return;
       
       if ((nOrgStep == nHzNum) && (nHzNum <= 8) && (nUnifStep > 1))
       {
              memset (wTmp, '\0', 10 * sizeof(JWORD));
              nTmpLen  = 0;
              for (i = 0; i < nUnifStep; i++)
                     nTmpLen += GetNSelect(i, nUnifStep, pSge->pwSlctHz, &(wTmp[nTmpLen]));

              AddUdc (wTmp, nHzNum);
              return;
       }
       
       /*
       **  All condition OF  nHzNum <= 4, except that ((nHzNum == 4) && (HasNonLinkHz))
       **                AND nHzNum > 5, except nUnifStep is not two small.
       **  在不被归一为单个词组的情况下=> 双字和三字一定构成词,
       **                                 没有NONLINKHZ的四字也一定被定义为词.
       **                                 5 ~ 8字时,如果其中最多只有一个双字词, 即, 没有三字的情况, 
       **                                           其他均为单字, 且不是NONLINKHZ, 也被定义为词. 
       **  否则, 进入后面的处理过程.
       */
       if ( (nHzNum <= 3)                                                           || 
            ((nHzNum == 4)  && (!HasNonLinkHz(pSge->pwSlctHz, pSge->nSlctSteps)))   || 
            (((nHzNum >= 5) && (nHzNum <= 8))&& (nOrgStep >= (nHzNum - 1)) && 
            (nUnifStep >= (nHzNum - 1)) && (!HasNonLinkHz(pSge->pwSlctHz, pSge->nSlctSteps)))
          )
       {
              memset (wTmp, '\0', 10 * sizeof(JWORD));
              nTmpLen  = 0;
              for (i = 0; i < nUnifStep; i++)
                     nTmpLen += GetNSelect(i, nUnifStep, pSge->pwSlctHz, &(wTmp[nTmpLen]));
       
              AddUdc (wTmp, nHzNum);
              return;
       }

       /*
       **  此处处理包括: 四字中有NONLINKHZ的情况,
       **                5 ~ 8字中有多个双字词, 或有三字词的情况, 或有NONLINKHZ的情况, 
       **                以及在更长的其他所有情况.
       **
       **  NONLINKHZ  PRELINKHZ  SUFLINKHZ  NORMLINKHZ
       **  HZ2CIZU    HZ3CIZU    HZ48CIZU
       **  处理办法:     STEP1: 首先取最长8个字, 或者以NONLINKHZ分开, 或者以大于等于四字的已有词分开.
       **                       规定: PRELINKHZ不可与前面的四字以上已有词联结, SUFLINKHZ不可与后面的
       **                             四字以上已有词联结, 即, 划分出的任何单元中, 任何单字的前后四字
       **                             以上已有词或NONLINKHZ.
       **                       如果第一个为PRELINK, 则继续跳过, 如果第一个为SUFLINK, 则一定取下一个,
       **                             除非下一个为四字以上已有词, 否则双双跳过.
       **                STEP2: 从前往后进行处理, 如果第一个是单字, 第二个为双字或三字已有词, 则
       **  #define NUM_NONLINKHZ   16
       **  #define NUM_PRELINKHZ   22
       **  #define NUM_SUFLINKHZ   36
       */
       for (i = 0; i < nUnifStep;  )
       {
              /* Get maximum 8 types of the following selections */
              for (j = 0; j < 8; j++)
                     nTypeSlct[j] = TypeOfNSelect (i + j, pSge->pwSlctHz, nUnifStep);
                     
              /* >= 4 Phrase or NonLinkHz */
              if ((nTypeSlct[0] == SLCT_TYPE_MFOURHZ) || (nTypeSlct[0] == SLCT_TYPE_NONLINK))
              {
                     i++;
                     continue;
              }
              
              else if ((nTypeSlct[0] == SLCT_TYPE_PRELINK) || (nTypeSlct[0] == SLCT_TYPE_SUFLINK) 
                     || (nTypeSlct[0] == SLCT_TYPE_NORMHZ))
              {
                     m = k = 1;      /* Count for single Hanzi */
                     for (j = 1; j < 8; j++)
                     {
                            if ((nTypeSlct[j] == SLCT_TYPE_PRELINK) || (nTypeSlct[j] == SLCT_TYPE_SUFLINK) 
                                   || (nTypeSlct[j] == SLCT_TYPE_NORMHZ))
                            {
                                   m++;
                                   k++;
                            }
                            else
                            {
                                   if (nTypeSlct[j - 1] == SLCT_TYPE_SUFLINK)
                                   {
                                          if (k > 0)
                                                 k--;
                                   }
                                   break;
                            }
                     }
              
                     /* Only a single Hanzi before other */
                     if (m == 1)      /* Both (k == 0) || (k == 1) */
                     {
                            if ((nTypeSlct[1] == SLCT_TYPE_TWOHZ) || (nTypeSlct[1] == SLCT_TYPE_THREEHZ))
                            {
                                   memset (wTmp, '\0', 10 * sizeof(JWORD));
                                   nTmpLen  = 0;
                                   nTmpLen += GetNSelect(i, nUnifStep, pSge->pwSlctHz, &(wTmp[nTmpLen]));
                                   nTmpLen += GetNSelect(i + 1, nUnifStep, pSge->pwSlctHz, &(wTmp[nTmpLen]));
                                   
                                   AddUdc (wTmp, nTmpLen);
                            }
                            
                            i++;
                            continue;
                     }
                     
                     /* Multiple Single Hanzi Connected!! Concentrated them into a single Phrase */
                     memset (wTmp, '\0', 10 * sizeof(JWORD));
                     nTmpLen  = 0;
                     for (j = i; j < (i + k); j++)
                            nTmpLen += GetNSelect(j, nUnifStep, pSge->pwSlctHz, &(wTmp[nTmpLen]));
                     
                     AddUdc (wTmp, nTmpLen);
                     i += k;
                     continue;
              }
              else if ((nTypeSlct[0] == SLCT_TYPE_TWOHZ) || (nTypeSlct[0] == SLCT_TYPE_THREEHZ))
              {
                     if (nTypeSlct[1] == SLCT_TYPE_PRELINK)
                     {
                            memset (wTmp, '\0', 10 * sizeof(JWORD));
                            nTmpLen  = 0;
                            nTmpLen += GetNSelect(i, nUnifStep, pSge->pwSlctHz, &(wTmp[nTmpLen]));
                            nTmpLen += GetNSelect(i + 1, nUnifStep, pSge->pwSlctHz, &(wTmp[nTmpLen]));

                            AddUdc (wTmp, nTmpLen);

                            i += 2;
                            continue;
                     }
                     else if (nTypeSlct[1] == SLCT_TYPE_NORMHZ)
                     {
                            memset (wTmp, '\0', 10 * sizeof(JWORD));
                            nTmpLen  = 0;
                            nTmpLen += GetNSelect(i, nUnifStep, pSge->pwSlctHz, &(wTmp[nTmpLen]));
                            nTmpLen += GetNSelect(i + 1, nUnifStep, pSge->pwSlctHz, &(wTmp[nTmpLen]));

                            AddUdc (wTmp, nTmpLen);

                            i++;
                            continue;
                     }
                     else
                     {
                            i++;
                            continue;
                     }
              }
              else
              {
                     i++;
                     continue;
              }
       }
       
       return;
}

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;
}
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;
}
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);
}
JINT TypeOfNSelect ( JINT  nXrd,
JWORD pwSlctHz,
JINT  nTotalSteps 
)
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;
}

Here is the caller graph for this function:

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:

Here is the caller 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:

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 90 of file UdCikuOper.c.