Back to index

im-sdk  12.3.91
Defines | Functions | Variables
NewPYLE.c File Reference
#include "NewPY.h"
#include "PYIM.h"
#include <assert.h>

Go to the source code of this file.

Defines

#define PUNCTUATION_STATUS   1
#define SOFTKEYBOARD_LAYOUT   2
#define GBKSWITCH_STATUS   3
#define SKB_QUANPIN   0
#define SKB_SPZRM   1
#define SKB_SPCSTAR   2
#define SKB_SPABC   3
#define SKB_SYMBSCIENT   0
#define SKB_SERIESONE   1
#define SKB_SERIESTWO   2
#define SKB_SERIESTHREE   3
#define SKB_SERIESFOUR   4
#define SKB_GREECE   5
#define SKB_RUSSIAN   6
#define SKB_PYSYM   7
#define SKB_JAPPIN   8
#define SKB_JAPPIAN   9
#define SKB_TABSYMB   10
#define SKB_GBKEXTSYM1   11
#define SKB_GBKEXTSYM2   12
#define SKB_QP_MODE   13
#define SKB_SP_MODE   14
#define SKB_FULLWID_ENG   15
#define PUNCT_CHINESE   0
#define PUNCT_ENGLISH   1

Functions

ImToXSunCharIM_trans (JINT nSesID, JINT nXKey, JINT nAsciiKey, JINT nSpecKey)
ImToXSunCharConvImToXSun (ImToXSun *pIeh)
ImToXSunImTrans (JINT nSesID, JINT *pKsThis, JINT nSpecKeyState)
VOID JwordInfo (JWORD *pwJwordArray, JINT nMaxLen)
VOID Jword2Uchar (JWORD *pwJword, UCHAR *szUch, JINT nMaxLen)
JINT JwordValidLen (JWORD *pwJwordArray, JINT nMaxLen)
VOID ProcFreq (SesGuiElement *pSge)
VOID ProcUdCizu (SesGuiElement *pSge)
VOID IM_close (JINT nSesID)
VOID InitSge (SesGuiElement *pSgeStruct)
VOID IehReturn (ImToXSun *pieh, JINT nCaseFlag)
JINT IsQuitKeysym (JINT *pks)
JINT IsQpSpSwitchKeysym (JINT *pks)
JINT IsWantedKeysym (JINT *pks)
JINT IsPyKeysym (JINT *pks)
JINT IsPageKeysym (JINT *pks)
JINT IsSelectKeysym (JINT *pks)
JWORD GetQuanjiaoSymbol (JINT *pks, JINT IsChnPunc, JINT IsChnAscii)
VOID ProcAllKeysym (JINT *pKsThis, SesGuiElement *pSge)
VOID DrawImToXSun (ImToXSun *pIeh, SesGuiElement *pSge)
VOID GetIehFromSge (ImToXSun *pIeh, SesGuiElement *pSge)
VOID GetLookupChoiceFromCandi (ImToXSun *pIeh, JWORD *pwCandi)
JINT GetCikuData (CHAR *szSysCikuName)
JINT WriteCikuData (CHAR *szSysCikuName, JINT nTimeStamp)
VOID FreePckAll ()
VOID InitStructSc (SysCandi *psc)
VOID AdjustFreq (JWORD *pwHz2244, JINT nLenThis)
VOID InitStructUc (UdcCandi *puc)
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 ProcSymbIMKey (SesGuiElement *pSge, JINT nSymbType, JINT *pNextKeysym, ImToXSun *pIeh)
ImToXSunCharIM_setAuxValue (JINT nSesID, JINT nWhichBmp, JINT nBmpValue)
VOID IM_init (JINT nSesID)
VOID IM_setValue (int arg, void *value)

Variables

SesGuiElementpSge [512]
SesGuiElementpCurSge
BYTEpCkAll
UdcMemAll udcAll
CHARpszUserName = NULL
CHARpszEnginePath = NULL

Define Documentation

#define GBKSWITCH_STATUS   3

Definition at line 97 of file NewPYLE.c.

#define PUNCT_CHINESE   0

Definition at line 121 of file NewPYLE.c.

#define PUNCT_ENGLISH   1

Definition at line 122 of file NewPYLE.c.

#define PUNCTUATION_STATUS   1

Definition at line 95 of file NewPYLE.c.

#define SKB_FULLWID_ENG   15

Definition at line 119 of file NewPYLE.c.

#define SKB_GBKEXTSYM1   11

Definition at line 115 of file NewPYLE.c.

#define SKB_GBKEXTSYM2   12

Definition at line 116 of file NewPYLE.c.

#define SKB_GREECE   5

Definition at line 109 of file NewPYLE.c.

#define SKB_JAPPIAN   9

Definition at line 113 of file NewPYLE.c.

#define SKB_JAPPIN   8

Definition at line 112 of file NewPYLE.c.

#define SKB_PYSYM   7

Definition at line 111 of file NewPYLE.c.

#define SKB_QP_MODE   13

Definition at line 117 of file NewPYLE.c.

#define SKB_QUANPIN   0

Definition at line 99 of file NewPYLE.c.

#define SKB_RUSSIAN   6

Definition at line 110 of file NewPYLE.c.

#define SKB_SERIESFOUR   4

Definition at line 108 of file NewPYLE.c.

#define SKB_SERIESONE   1

Definition at line 105 of file NewPYLE.c.

#define SKB_SERIESTHREE   3

Definition at line 107 of file NewPYLE.c.

#define SKB_SERIESTWO   2

Definition at line 106 of file NewPYLE.c.

#define SKB_SP_MODE   14

Definition at line 118 of file NewPYLE.c.

#define SKB_SPABC   3

Definition at line 102 of file NewPYLE.c.

#define SKB_SPCSTAR   2

Definition at line 101 of file NewPYLE.c.

#define SKB_SPZRM   1

Definition at line 100 of file NewPYLE.c.

#define SKB_SYMBSCIENT   0

Definition at line 104 of file NewPYLE.c.

#define SKB_TABSYMB   10

Definition at line 114 of file NewPYLE.c.

#define SOFTKEYBOARD_LAYOUT   2

Definition at line 96 of file NewPYLE.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;
}

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

}

Definition at line 732 of file NewPYLE.c.

{
       JINT   i, j, nHz;
       JINT   nNumDollar;   /* Number of Numsign and Dollar before Caret */
       static ImToXSunChar  iehc;
       
       for (i = 0; i < 256; i++)
              iehc.szPreedit[i]   = '\0';
              
       for (i = 0; i < 10; i++)
              for (j = 0; j < 48; j++)
                     iehc.szLookupChoice[i][j] = '\0';
                     
       for (i = 0; i < 512; i++)
              iehc.szCommit[i]    = '\0';
              
       for (i = 0; i < 32; i++)
              iehc.szStatus[i]    = '\0';
              
       /* One Hanzi is  2 Bytes */
       nHz = 0;
       for (i = 0; (pIeh->pwPreedit[i] >= 0x8140); i++)
              nHz++;
              
       iehc.nType        = pIeh->nType;
       iehc.nErrorCode   = pIeh->nErrorCode;
       iehc.nChoiceNum   = pIeh->nChoiceNum;
       iehc.nLabelType   = LABELTYPE_1234567;
       
       nNumDollar = 0;
       j = 0;
       for (i = 0; pIeh->pwPreedit[i] != 0x0000; i++)
       {
              if ((pIeh->pwPreedit[i] != (JWORD)'#') && (pIeh->pwPreedit[i] != (JWORD)'$'))
              {
                     pIeh->pwPreedit[j++] = pIeh->pwPreedit[i];
              }
              else  /* '#' and '$' before pIeh->nCaretPos should be counted!! */
              {
                     if (i < pIeh->nCaretPos)
                            nNumDollar ++;
              }
       }
       for (; j < 128; j++)
              pIeh->pwPreedit[j++] = 0x0000;
       
       iehc.nCaretPos    = pIeh->nCaretPos + nHz - nNumDollar;
       
       Jword2Uchar(pIeh->pwPreedit, iehc.szPreedit, 128);
       Jword2Uchar(pIeh->pwCommit,  iehc.szCommit,  256);
       Jword2Uchar(pIeh->pwStatus,  iehc.szStatus,   16);
       
       for(i = 0; i < 8; i++)
              Jword2Uchar(pIeh->pwLookupChoice[i], iehc.szLookupChoice[i],  24);
       
       return (&iehc);
}

Here is the call graph for this function:

Here is the caller graph for this function:

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;
}
VOID DrawImToXSun ( ImToXSun pIeh,
SesGuiElement pSge 
)

Here is the caller graph for this function:

Definition at line 343 of file CikuOper.c.

{
       free(pCkAll);
       pCkAll = NULL;
}

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 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;
}
VOID GetIehFromSge ( ImToXSun pIeh,
SesGuiElement pSge 
)

Definition at line 676 of file NewPYLE.c.

{
       JINT   i, j;
       
       for (i = 0; i < 128; i++)
              pIeh->pwPreedit[i] = pSge->pwViewPe[i];
              
       pIeh->nCaretPos  = pSge->nViewCaretPos;
       
       pIeh->nChoiceNum = pSge->nViewCandiEnd - pSge->nViewCandiStart;
       for (i = 0; i < 8; i++)
              for (j = 0; j < 24; j++)
                     pIeh->pwLookupChoice[i][j] = 0x0000;
       
       GetLookupChoiceFromCandi(pIeh, pSge->pwViewCandi);
       
       for (i = 0; i < 16; i++)
              pIeh->pwStatus[i] = pSge->pwStatus[i];
       
       /* Because nErrorCode was cleared before each new KeySym Process */
       if (pSge->nErrorCode != 0)
       {
              pIeh->nType = IMXSUN_TYPE_ERROR;
              pIeh->nErrorCode = pSge->nErrorCode;
       }
}

Here is the caller graph for this function:

VOID GetLookupChoiceFromCandi ( ImToXSun pIeh,
JWORD pwCandi 
)

Definition at line 704 of file NewPYLE.c.

{
       JINT    i, j, k, nLen;
       JINT    nbStartCandi;
       
       nLen = JwordValidLen(pwCandi, 128);
       
       i = j = k = nbStartCandi = 0;
       for (i = 0; i < nLen; i++)
       {
              if (pwCandi[i] >= 0x8140)   /* First Hanzi in GBK */
              {
                     nbStartCandi = 1;
                     pIeh->pwLookupChoice[j][k++] = pwCandi[i];
                     while(pwCandi[++i] >= 0x8140)
                            pIeh->pwLookupChoice[j][k++] = pwCandi[i];
                     j++;
                     k = 0;
                     nbStartCandi = 0;
              }
       }
       pIeh->nChoiceNum = j;
}

Here is the call graph for this function:

Here is the caller graph for this function:

JWORD GetQuanjiaoSymbol ( JINT pks,
JINT  IsChnPunc,
JINT  IsChnAscii 
)

Definition at line 254 of file KeysymType.c.

{
       JWORD   wTmp;
       JWORD   wRet;
       
       wRet = 0x0000;
       if ((pks[0] < 0x20) || (pks[0] >= 0x7F))
              return wRet;
       
       if ( ((IsChnPunc == TRUE) && (IsChnAscii == TRUE))  || 
           ((IsChnPunc == TRUE) && (IsChnAscii != TRUE) && (IsAlphaNum(pks) == FALSE)) ||  /* Chinese Punctation Only */
           ((IsChnPunc != TRUE) && (IsChnAscii == TRUE) && (IsAlphaNum(pks) == TRUE)) )    /* Chinese Ascii Only */
       {
              wRet = pwPuncArray[0][pks[0] - 0x20];
              
              wTmp = pwPuncArray[0][pks[0] - 0x20];
              pwPuncArray[0][pks[0] - 0x20] = pwPuncArray[1][pks[0] - 0x20];
              pwPuncArray[1][pks[0] - 0x20] = wTmp;
       }
       else
              wRet = 0x0000;
              
       return wRet;
}
VOID IehReturn ( ImToXSun pieh,
JINT  nCaseFlag 
)

Definition at line 575 of file NewPYLE.c.

{
       JINT   i, j;
       
       pIeh->nType      = IMXSUN_TYPE_ERROR;
       pIeh->nErrorCode = nCaseFlag;

       if (nCaseFlag == SWITCH_BEWTEEN_QPSP)
              pIeh->nCaretPos = 0;
       else
              pIeh->nCaretPos = -1;

       for (i = 0; i < 128; i++)
              pIeh->pwPreedit[i] = 0x0000;
       for (i = 0; i < 8; i++)
              for (j = 0; j < 24; j++)
                     pIeh->pwLookupChoice[i][j] = 0x0000;
       pIeh->nChoiceNum  = 0;
}

Here is the caller graph for this function:

VOID IM_close ( JINT  nSesID)

Definition at line 170 of file NewPYLE.c.

{
       IM_trans (nSesID, (JINT)IMXK_QUIT_PYIM, (JINT)IMXK_QUIT_PYIM, 0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

VOID IM_init ( JINT  nSesID)

Definition at line 175 of file NewPYLE.c.

{
       IM_trans (nSesID, (JINT)IMXK_Escape, (JINT)IMXK_Escape, 0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

ImToXSunChar* IM_setAuxValue ( JINT  nSesID,
JINT  nWhichBmp,
JINT  nBmpValue 
)

Definition at line 127 of file NewPYLE.c.

{
       ImToXSunChar*   pImxsun;
       
       if (pSge[nSesID] == NULL)
       {
              IM_trans (nSesID, (JINT)IMXK_Escape, (JINT)IMXK_Escape, 0);
       }
       
       if ((nWhichBmp == PUNCTUATION_STATUS) && (nBmpValue >= 0) && (nBmpValue <= 1)) {
              if (pSge[nSesID]->nPunctMode == nBmpValue) return NULL;
              pSge[nSesID]->nPunctMode  = nBmpValue;
       }
       else if ((nWhichBmp == GBKSWITCH_STATUS) && (nBmpValue >= 0) && (nBmpValue <= 1)) {
              if (pSge[nSesID]->nGBKMode == nBmpValue) return NULL;
              pSge[nSesID]->nGBKMode =  nBmpValue;

              if(pSge[nSesID]->nKeyLayMode >= SKB_QP_MODE) InitSge(pSge[nSesID]);

       }
       else if ((nWhichBmp == SOFTKEYBOARD_LAYOUT) && (nBmpValue >= 0) && (nBmpValue <= 15))
       {
              if (pSge[nSesID]->nKeyLayMode == nBmpValue) return NULL;

              if ((nBmpValue == SKB_QP_MODE) || (nBmpValue == SKB_SP_MODE) || (nBmpValue == SKB_FULLWID_ENG))
              {
                  if(nBmpValue == SKB_SP_MODE) {
                     pSge[nSesID]->nPinyinType = 0; 
                  }         
                  else {
                     pSge[nSesID]->nPinyinType = KEYLAYMODE_NEWPY;
                  }
                  InitSge(pSge[nSesID]);
              }
              pSge[nSesID]->nKeyLayMode = nBmpValue;
       }
       else printf("Invalid nWhichBmp[%d] or nBmpValue[%d]\n", nWhichBmp, nBmpValue);
       
       pImxsun = IM_trans (nSesID, (JINT)IMXK_Clear, (JINT)IMXK_Clear, 0);
       return (pImxsun);
}

Here is the call graph for this function:

Here is the caller graph for this function:

VOID IM_setValue ( int  arg,
void *  value 
)

Definition at line 180 of file NewPYLE.c.

{
    if (arg == USER_NAME) {
       pszUserName = (CHAR*) strdup(value);
#ifdef DEBUG
       printf("pszUserName = %s\n",pszUserName);
#endif
    } else if(arg == ENGINE_PATH) {
       pszEnginePath = (CHAR*) strdup(value);
#ifdef DEBUG
       printf("pszEnginePath = %s\n",pszEnginePath);
#endif
    }
}

Here is the caller graph for this function:

ImToXSunChar * IM_trans ( JINT  nSesID,
JINT  nXKey,
JINT  nAsciiKey,
JINT  nSpecKey 
)

Definition at line 195 of file NewPYLE.c.

{
       JINT    i;
       JINT    ksThis[5];
       JINT    nSpecKey;
       
       for(i = 0; i < 5; i++)
              ksThis[i] = 0x00000000;
       if ((nAsciiKey >= 0x20) && (nAsciiKey <= 0x7E))
              ksThis[0] = nAsciiKey;
       else
              ksThis[0] = nXKey;
       
       /* PATCH for ^p and ^n: Scott Ma: 98-04-28 */
       nSpecKey = nSpecKeyState;
       if ((nAsciiKey == 0x000e) && (nSpecKeyState == 4))
       {
              ksThis[0] = (JINT)IMXK_MOUSENEXT;
              nSpecKey  = 0;
       }
       if ((nAsciiKey == 0x0010) && (nSpecKeyState == 4))
       {
              ksThis[0] = (JINT)IMXK_MOUSEPREV;
              nSpecKey  = 0;
       }
       
       bShiftIsPressed  = (JSHORT)((nSpecKey & SPEC_KEY_SHIFT)    / SPEC_KEY_SHIFT);
       bCapsIsPressed   = (JSHORT)((nSpecKey & SPEC_KEY_CAPSLOCK) / SPEC_KEY_CAPSLOCK); /* ??? Not Certain. MXL */
       bCapsIsPressed   = (JSHORT)0;
       bCtrlIsPressed   = (JSHORT)((nSpecKey & SPEC_KEY_CONTROL)  / SPEC_KEY_CONTROL);
       bAltIsPressed    = (JSHORT)((nSpecKey & SPEC_KEY_ALT)      / SPEC_KEY_ALT);
       bAltGrIsPressed  = (JSHORT)((nSpecKey & SPEC_KEY_ALTGRAPH) / SPEC_KEY_ALTGRAPH);
       bCompIsPressed   = (JSHORT)((nSpecKey & SPEC_KEY_COMPOSE)  / SPEC_KEY_COMPOSE);  /* ??? Not Certain. MXL */
       bCompIsPressed   = (JSHORT)0;
       bMetaIsPressed   = (JSHORT)((nSpecKey & SPEC_KEY_DIAMOND)  / SPEC_KEY_DIAMOND);

       return ( ConvImToXSun( ImTrans(nSesID, ksThis, nSpecKey) ) );
}

Here is the call graph for this function:

Here is the caller graph for this function:

ImToXSun * ImTrans ( JINT  nSesID,
JINT pKsThis,
JINT  nSpecKeyState 
)

Definition at line 235 of file NewPYLE.c.

{
       JINT    i, nLen, nTmpRes, nTmp1, nTmp2;
       static  ImToXSun ieh;
       static  JINT     nActiveSesNum = 0;
       static  JINT     pnSesIDArray[512];
       CHAR    pszHome[128];
       CHAR    szPath[128];
       
       JWORD   wPuncAscii;      /* For Chinese Punctation and Alpha Char */
       JINT    FlagChnPunc, FlagChnAscii;

       /* 
       ** 在正式版本中, 应该先读szSysCikuBak & szUdcCikuBak, 
       ** 如果失败, 再读szSysCiku & szUdcCiku!!      MXL 97-12-14
       */
       if (pCkAll == NULL)
       {
              memset(szPath, '\0', 128);

              strcpy(szPath, pszEnginePath);
              nTmpRes = GetCikuData(szPath);

              if(nTmpRes == FALSE) {
                     memset(szPath, '\0', 128);
                     strcpy(szPath, pszEnginePath);
#ifndef WIN32
                     strcat(szPath, szSysCiku_Gbk);
#else
                     strcat(szPath, szSysCiku_Gbk_WIN32);
#endif
                     nTmpRes = GetCikuData(szPath);
              }
              if (nTmpRes == FALSE)
              {
                     fprintf (stderr, "IME Error: Failed to Open System Ciku < PyCiku.dat >\n");
                     return NULL;
              }

              /* Read in UdCiku.dat Data */
              memset (szPath, '\0', 128);

              strcpy(szPath, pszEnginePath);
              nTmpRes = ReadUdcData(szPath);

              if(nTmpRes == FALSE) {
                     memset(szPath, '\0', 128);
                     strcpy(szPath, pszEnginePath);
#ifndef WIN32
                     strcat(szPath, szUdcCiku_Gbk);
#else
                     strcat(szPath, szUdcCiku_Gbk_WIN32);
#endif
                     nTmpRes = ReadUdcData(szPath);
              }
              if (nTmpRes == FALSE) {
                     fprintf (stderr, "IME Error: Failed to Open User Defined Ciku < UdCiku.dat >\n");
                     return NULL;
              }
       }

       if (nActiveSesNum == 0)
       {
              for (i = 0; i < MAX_SES_NUM; i++)
                     pnSesIDArray[i] = 0x0000;
       }
       
       if (pnSesIDArray[nSesID] == 0x0000)       /* New Session */
              nActiveSesNum++;
       
       if (nActiveSesNum > MAX_SES_NUM)   /* Return: Too many sessions */
       {
              nActiveSesNum--;
              IehReturn(&ieh, TOO_MANY_SESSION);
              return (&ieh);
       }

       if (pnSesIDArray[nSesID] == 0x0000)       /* New Session */
       {
              pnSesIDArray[nSesID] = (0xF000 + nSesID);
              pSge[nSesID] = (SesGuiElement*) malloc(sizeof(SesGuiElement));
              if (pSge[nSesID] == NULL)
              {
                     IehReturn(&ieh, FAILED_ALLOC_MEM);    /* Failed to Alloc Memory */
                     pnSesIDArray[nSesID] = 0x0000;
                     nActiveSesNum--;
                     return (&ieh);
              }
              pSge[nSesID]->scSysCandi.pwMhCandi  = NULL;
              pSge[nSesID]->scSysCandi.pwDhCandi  = NULL;
              pSge[nSesID]->scSysCandi.pwShCandi  = NULL;
              pSge[nSesID]->scSysCandi.pwGbkCandi = NULL;
              pSge[nSesID]->ucUdcCandi.pwUdc28Candi = NULL;
              InitSge(pSge[nSesID]);
       }
       pCurSge = pSge[nSesID];
       
       if (IsQuitKeysym(pKsThis))
       {
              /* Free Space Occupied by struct SysCandi */
              free (pSge[nSesID]->scSysCandi.pwMhCandi);
              free (pSge[nSesID]->scSysCandi.pwDhCandi);
              free (pSge[nSesID]->scSysCandi.pwShCandi);
              free (pSge[nSesID]->scSysCandi.pwGbkCandi);
              free (pSge[nSesID]->ucUdcCandi.pwUdc28Candi);

              pSge[nSesID]->scSysCandi.pwMhCandi  = NULL;
              pSge[nSesID]->scSysCandi.pwDhCandi  = NULL;
              pSge[nSesID]->scSysCandi.pwShCandi  = NULL;
              pSge[nSesID]->scSysCandi.pwGbkCandi = NULL;
              pSge[nSesID]->ucUdcCandi.pwUdc28Candi = NULL;
              
              free (pSge[nSesID]);
              pSge[nSesID] = NULL;
              pnSesIDArray[nSesID] = 0x0000;
              nActiveSesNum--;
              IehReturn(&ieh, QUIT_THIS_IM);     /* Application Quit or Switch to other IM */
              
              /*
              **  If nActiveSesNum == 0, means No any Application is still using this IM, SO,
              **  Must Write these Adjuested Ciku Data back to File!!!!
              */
              if(nActiveSesNum == 0)
              {
/* Do not rewrite Ciku */
/*
                     strcpy(pszHome,"/home/");
                     strcat(pszHome, pszUserName);
                     nLen    = strlen(pszHome);
                     
                     memset (szPath, '\0', 128);
                     strcat (szPath, pszHome);
                     if (szPath[nLen - 1] == '/')
                            szPath[nLen - 1] = '\0';
                     strcat (szPath, szSysCikuBak);
              
                     WriteCikuData(szPath, 0);
*/

                     FreePckAll();
                     pCkAll = NULL;
/*
                     memset (szPath, '\0', 128);
                     strcat (szPath, pszHome);
                     if (szPath[nLen - 1] == '/')
                            szPath[nLen - 1] = '\0';
                     strcat (szPath, szUdcCikuBak);
                     
                     WriteUdcData (szPath, 0);
*/
                     FreeUdcData();
              }
              return (&ieh);
       }
       
       else if (IsQpSpSwitchKeysym(pKsThis))
       {
              nQpSpFlag[nSesID] = 1 - nQpSpFlag[nSesID];
/*
              nGlobalSpMode = 4 - nGlobalSpMode;
*/
              IehReturn(&ieh, SWITCH_BEWTEEN_QPSP);     /* Application Quit or Switch to other IM */
              
              /* Initialize pSge[nSesID] */
              InitSge(pSge[nSesID]);
              return (&ieh);
       }
       
       else if (IsWantedKeysym(pKsThis))
       {
              if ((pCurSge->nKeyLayMode >= 0) && (pCurSge->nKeyLayMode <= 12))
              {
                     ProcSymbIMKey(pCurSge, pCurSge->nKeyLayMode, pKsThis, &ieh);
#ifdef _DRAW_IM_WIN_H
                     DrawImToXSun(&ieh, pCurSge);
                     if (ieh.nType == IMXSUN_TYPE_COMMITSYMBOL)
                            JwordInfo(ieh.pwCommit, 256);
#endif
                     return (&ieh);
              }
              
              /*
              **  Determine if this keySym is really valid for current pSge enviroment (GUI Logic).
              **  If NO, return!!
              **  Some KeySyms that is not useful during PYIM's Input GUI Logic,
              **       although that is defined in IsWantedkeysym().
              **       IMXSUN_TYPE_BOUNCEKEY 0x0002 was defined in file CmSo.h
              */
              
              /* NULL in preedit line, enter symbol now */
              if ( (JwordValidLen(pCurSge->pwMixPeStr, UONE) == 0)  && 
                     ((pCurSge->nKeyLayMode == SKB_QP_MODE) || 
                      (pCurSge->nKeyLayMode == SKB_SP_MODE) || 
                      (pCurSge->nKeyLayMode == SKB_FULLWID_ENG)) &&
                     (((pKsThis[0] >= 0x20) && (pKsThis[0] <= 0x7E)) || (pKsThis[0] == IMXK_Clear)) )
              {
                     if (pKsThis[0] == IMXK_Clear)                    
                     {
                            nTmp1 = pCurSge->nPunctMode;
                            nTmp2 = pCurSge->nKeyLayMode;
                            InitSge(pCurSge);
                            pCurSge->nPunctMode  = nTmp1;
                            pCurSge->nKeyLayMode = nTmp2;
                            
                            pCurSge->nPrevKeyLayMode = pCurSge->nKeyLayMode;

                            memset(&ieh, 0x00, sizeof(ImToXSun));
                            ieh.nType = IMXSUN_TYPE_NORMAL;
#ifdef _DRAW_IM_WIN_H
                            DrawImToXSun(&ieh, pCurSge);
#endif
                            return (&ieh);
                     }
                            
                     pCurSge->nPrevKeyLayMode = pCurSge->nKeyLayMode;
                     if (pCurSge->nPunctMode == PUNCT_CHINESE)
                            FlagChnPunc = TRUE;
                     else 
                            FlagChnPunc = FALSE;
                            
                     if (pCurSge->nKeyLayMode == SKB_FULLWID_ENG)
                            FlagChnAscii = TRUE;
                     else
                            FlagChnAscii = FALSE;

                     wPuncAscii = GetQuanjiaoSymbol(pKsThis, FlagChnPunc, FlagChnAscii);
                     if (wPuncAscii != 0x0000)
                     {
                            ieh.nType = IMXSUN_TYPE_COMMIT;
                            memset(ieh.pwCommit, 0x00, sizeof(JWORD) * UONE);
                            ieh.pwCommit[0] = wPuncAscii;
#ifdef _DRAW_IM_WIN_H
                            JwordInfo(ieh.pwCommit, 256);
#endif
                            return (&ieh);
                     }
              }
              
#ifndef _DRAW_IM_WIN_H
              if(   bCapsIsPressed  || bCtrlIsPressed || bAltIsPressed  ||
                    bAltGrIsPressed || bCompIsPressed || bMetaIsPressed || 
                  ( (JwordValidLen(pCurSge->pwMixPeStr, UONE) == 0) && 
                    ( (IsPageKeysym(pKsThis)) || (IsSelectKeysym(pKsThis)) || (!IsPyKeysym(pKsThis)) )
                  )
                )
              {
                     ieh.nType = IMXSUN_TYPE_BOUNCEKEY;
                     return (&ieh);
              }
#endif
              
              pCurSge->nErrorCode = 0;                /* Clear All Error Message before a KeySym */
              ieh.nType   = IMXSUN_TYPE_NORMAL;
              for(i = 0; i < UONE; i++)
                     pCurSge->pwCommit[i] = ieh.pwCommit[i] = 0x0000;
              
              ProcAllKeysym(pKsThis, pCurSge);
              
              /*
              **  Determine if there is any other English chars in the end of pwMixPeStr[256].
              **  If there is no char lefted, indicates all is committed, pass it to IMToXSun,
              **  and InitSge(pCurSge) again. 
              **
              **  If pwMixPeStr[nLen - 1] is ['], How to deal it???
              **
              **  To create User defined Cizu HERE!!! Only after a committment.   97.11.08 MXL
              */
              nLen = JwordValidLen(pCurSge->pwMixPeStr, 256);
              if (pCurSge->pwMixPeStr[nLen - 1] >= 0x8140)      /* First Char defined in GBK */
              {
                     for (i = 0; i < UONE; i++)
                            pCurSge->pwCommit[i] = ieh.pwCommit[i] = 0x0000;
                     for (i = 0; i < nLen; i++)
                     {
                            /*
                            ** The following line was commented ONLY Because For SUN's HTT!!
                            pCurSge->pwCommit[i] = pCurSge->pwMixPeStr[i];
                            */
                            ieh.pwCommit[i] = pCurSge->pwMixPeStr[i];
                     }
                     ieh.nType = IMXSUN_TYPE_COMMIT;
                     ProcFreq(pCurSge);
                     ProcUdCizu(pCurSge);
                     
                     nTmp1 = pCurSge->nPunctMode;
                     InitSge(pCurSge);
                     pCurSge->nPunctMode = nTmp1;
                     GetIehFromSge(&ieh, pCurSge);
                     
#ifdef _DRAW_IM_WIN_H
                     DrawImToXSun(&ieh, pCurSge);
                     JwordInfo(ieh.pwCommit, 256);
                     
                     /* Write Ciku File After each Committment */
                     strcpy(pszHome,"/home/");
                     strcat(pszHome, pszUserName);
                     nLen    = strlen(pszHome);
                     
                     memset (szPath, '\0', 128);
                     strcat (szPath, pszHome);
                     if (szPath[nLen - 1] == '/')
                            szPath[nLen - 1] = '\0';
                     strcat (szPath, szSysCikuBak);
              
                     WriteCikuData(szPath, 0);

                     memset (szPath, '\0', 128);
                     strcat (szPath, pszHome);
                     if (szPath[nLen - 1] == '/')
                            szPath[nLen - 1] = '\0';
                     strcat (szPath, szUdcCikuBak);
                     
                     WriteUdcData (szPath, 0);
#endif
              }
              else
              {
                     GetIehFromSge(&ieh, pCurSge);
                     
#ifdef _DRAW_IM_WIN_H
                     DrawImToXSun(&ieh, pCurSge);
#endif
              }
              return (&ieh);
       }
       
       /*
       **  Bounce Other KeySym which is not in the range of above wanted key.
       */
       else
       {
              ieh.nType = IMXSUN_TYPE_BOUNCEKEY;  /* In CmSo.h:  IMXSUN_TYPE_BOUNCEKEY 0x0002 */
              return (&ieh);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

VOID InitSge ( SesGuiElement pSgeStruct)

Definition at line 599 of file NewPYLE.c.

{
       JINT    i;
       
       pSgeStruct->nSpRawCaretPos    = 0;

       for (i = 0; i < 40; i++)
              pSgeStruct->pwSpRawPyStr[i]  = 0x0000;
       for (i = 0; i < UONE; i++)
              pSgeStruct->pwSpMixPeStr[i]  = 0x0000;
       for (i = 0; i < UTWO; i++)
              pSgeStruct->pwSpSlctRawPy[i] = 0x0000;
       
       for (i = 0; i < UONE; i++)
       {
              pSgeStruct->pwRawPyStr[i]    = 0x0000;
              pSgeStruct->pwMixPeStr[i]    = 0x0000;
              pSgeStruct->nPrsPyYjCode[i]  = 0;
              pSgeStruct->pwCommit[i]      = 0x0000;
       }
       
       for (i = 0; i < UTWO; i++)
       {
              pSgeStruct->pwPrsPyStr[i]    = 0x0000;
              pSgeStruct->pwPrsMixStr[i]   = 0x0000;
              pSgeStruct->pwSlctHz[i]      = 0x0000;
              pSgeStruct->pwSlctRawPy[i]   = 0x0000;
       }
       
       for (i = 0; i < UHLF; i++)
       {
              pSgeStruct->pwViewPe[i]      = 0x0000;
              pSgeStruct->pwViewCandi[i]   = 0x0000;
       }
       
/*
       pSgeStruct->nPinyinType       = -1;
*/
       pSgeStruct->nPrevKeyLayMode   = pSgeStruct->nKeyLayMode;
/*
       pSgeStruct->nPunctMode        = 0;   
*/
       
       pSgeStruct->nRawCaretPos      = 0;
       pSgeStruct->nViewCaretPos     = 0;
       pSgeStruct->nViewPage         = 0;
       pSgeStruct->nViewPeStart      = 0;
       pSgeStruct->nViewPeEnd        = 0;
       pSgeStruct->nViewCandiStart   = 0;
       pSgeStruct->nViewCandiEnd     = 0;
       pSgeStruct->nSlctSteps        = 0;

       for (i = 0; i < 16; i++)
              pSgeStruct->pwStatus[i]   = 0x0000;
       pSgeStruct->nErrorCode        = 0;

       pSgeStruct->nIconFlag = F_HALFWIDTH | F_SETUP;
       
       InitStructSc(&(pSgeStruct->scSysCandi));
       InitStructUc(&(pSgeStruct->ucUdcCandi));

       /* The following 3 items were added to Fix Bug 4165549: Scott Ma, 12/8, 1998 */
       pSgeStruct->nPrevMatchMode       = -1;
       for (i = 0; i < 9; i++)
       {
              pSgeStruct->pnCurChoiceYjNew[i] = 1;
              pSgeStruct->pnCurChoiceYjOld[i] = 0;
       }
}

Here is the caller graph for this function:

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 IsPageKeysym ( JINT pks)

Definition at line 175 of file KeysymType.c.

{
       JINT   i, nLen;
       
       nLen = 0;
       for (i = 0; (i < SUN_NUM_KEYSYM) && (pks[i] != 0x0L); i++)
              nLen ++;
              
       if (nLen == 0)
              return FALSE;
       
       if( (pks[0] == IMXK_minus)      ||
           (pks[0] == IMXK_equal)          ||
           (pks[0] == IMXK_bracketleft)    ||
           (pks[0] == IMXK_bracketright)   ||
           (pks[0] == IMXK_comma)          ||
           (pks[0] == IMXK_MOUSEPREV)      ||
           (pks[0] == IMXK_MOUSENEXT)      ||
           (pks[0] == IMXK_period)         ||
           (pks[0] == IMXK_Return) )
              return TRUE;
       return FALSE;
}
JINT IsPyKeysym ( JINT pks)

Definition at line 148 of file KeysymType.c.

{
       JINT   i, nLen;
       
       nLen = 0;
       for (i = 0; (i < SUN_NUM_KEYSYM) && (pks[i] != 0x0L); i++)
              nLen ++;
              
       if (nLen == 0)
              return FALSE;
       
       /*
       **  The following range is fetched from file "IMWantedKey.h"
       **  There maybe some ingoration about "IMXK_KP_xxx". Check it later.
       **
       **  Notice: A Self defined Keysym IMXK_REDRAW_INTERNAL was added! 0xEEEE
       */
       if( (pks[0] == IMXK_Escape)      ||
           (pks[0] == IMXK_quoteright)  ||
           (pks[0] == IMXK_REDRAW_INTERNAL)      ||
           ((pks[0] >= IMXK_a) && (pks[0] <= IMXK_z)) 
         )
              return TRUE;
       return FALSE;
}

Definition at line 66 of file KeysymType.c.

{
       if (pks[0] == IMXK_ALT_QP_SP)
              return TRUE;
       return FALSE; 
}
JINT IsQuitKeysym ( JINT pks)

Definition at line 58 of file KeysymType.c.

{
       if (pks[0] == IMXK_QUIT_PYIM)
              return TRUE;
       return FALSE; 
}
JINT IsSelectKeysym ( JINT pks)

Definition at line 200 of file KeysymType.c.

{
       JINT   i, nLen;
       
       nLen = 0;
       for (i = 0; (i < SUN_NUM_KEYSYM) && (pks[i] != 0x0L); i++)
              nLen ++;
              
       if (nLen == 0)
              return FALSE;
       
       if( (pks[0] == IMXK_space)  ||
           ((pks[0] >= IMXK_0) && (pks[0] <= IMXK_9)) )
              return TRUE;
       return FALSE;
}
JINT IsWantedKeysym ( JINT pks)

Definition at line 74 of file KeysymType.c.

{
       JINT   i, nLen;
       
       nLen = 0;
       for (i = 0; (i < SUN_NUM_KEYSYM) && (pks[i] != 0x0L); i++)
              nLen ++;
              
       if (nLen == 0)
              return FALSE;
       
       /*
       **  The following range is fetched from file "IMKeyMap.h"
       **  There maybe some ingoration about "IMXK_KP_xxx". Check it later.
       **
       **  Notice: Internal pesudo_keysym REDRAW_INTERNAL was added !!!! 0xEEEE
       */
       if( ( pks[0] == IMXK_BackSpace)     ||
           ( pks[0] == IMXK_Linefeed)   ||
           ( pks[0] == IMXK_Return)     ||
           ( pks[0] == IMXK_Escape)     ||
           ( pks[0] == IMXK_Multi_key)  ||
           ( pks[0] == IMXK_MOUSEPREV)  ||
           ( pks[0] == IMXK_MOUSENEXT)  ||
           ( pks[0] == IMXK_Clear)        ||
           ((pks[0] >= IMXK_Home) && (pks[0] <= IMXK_Begin))           ||
           ((pks[0] >= IMSunXK_AltGraph) && (pks[0] <= IMXK_KP_Space)) ||
           ((pks[0] >= IMXK_KP_Home) && (pks[0] <= IMXK_KP_Begin))     ||
           ( pks[0] == IMXK_KP_Delete)  ||
           ((pks[0] >= IMXK_KP_Multiply) && (pks[0] <= IMXK_KP_9))     ||
           ((pks[0] >= IMXK_Shift_L) && (pks[0] <= IMXK_Alt_R))        ||
           ((pks[0] >= IMXK_space) && (pks[0] <= IMXK_asciitilde))     ||
           ( pks[0] == IMXK_Delete)        ||
           ( pks[0] == IMXK_REDRAW_INTERNAL)     
         )
              return TRUE;
              
       return FALSE;
}
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);
       }
}
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));   */
}
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;
}
VOID ProcAllKeysym ( JINT pKsThis,
SesGuiElement pSge 
)

Definition at line 107 of file OnKeySym.c.

{
       JINT    i;
       JINT    nKsLen;
       
       nKsLen = 0;
       /* for (i = 0; (i < SUN_NUM_KEYSYM) && (pKsThis[i] != 0x0L); i++) */
       for (i = 0; (i < 1) && (pKsThis[i] != 0x0L); i++)
              nKsLen ++;
       if (nKsLen >= 1) 
       {
              if ((pKsThis[0] == IMXK_Shift_L) || (pKsThis[0] == IMXK_Shift_R))
                     bShiftIsPressed = (JSHORT)(1 - bShiftIsPressed);
              else if (pKsThis[0] == IMXK_Caps_Lock)
                     bCapsIsPressed  = (JSHORT)(1 - bCapsIsPressed);
                     
              else if ((pKsThis[0] == IMXK_Alt_L) ||
                      (pKsThis[0] == IMXK_Alt_L) )
                     bAltIsPressed = (JSHORT)(1 - bAltIsPressed);
                     
              /* The Following Key is used as Switcher of Ime Window */
              else if ((pKsThis[0] == IMXK_Control_L) || 
                      (pKsThis[0] == IMXK_Control_R) )
                     bCtrlIsPressed = (JSHORT)(1 - bCtrlIsPressed);
                     
              else if ((pKsThis[0] == IMXK_Meta_L) ||
                      (pKsThis[0] == IMXK_Meta_R) )
                     bMetaIsPressed = (JSHORT)(1 - bMetaIsPressed);
                     
              else if ((pKsThis[0] == IMSunXK_AltGraph) ||
                      (pKsThis[0] == IMXK_Mode_switch) )
                     bAltGrIsPressed = (JSHORT)(1 - bAltGrIsPressed);
                     
              else if ((pKsThis[0] == IMSunXK_Compose) ||
                      (pKsThis[0] == IMXK_Multi_key) )
                     bCompIsPressed = (JSHORT)(1 - bCompIsPressed);
                     
              /* 
              ** If some other key is combined with the above switcher(s),
              ** These switcher is turn Off and be send as a fully key
              ** to application. (Committed)
              */
              else if ((bCtrlIsPressed == 1 ) || (bMetaIsPressed == 1) ||
                      (bAltGrIsPressed == 1) || (bCompIsPressed == 1))
              {
              }
              
              /*
              ** Alt is used to Switch IM (QuanPin, ShuangPin, WuBi...)
              ** Other combination besides IM switcher is committed out.
              ** To avoid conflict with Application, Alt + 1, 2, 3, 4 is preferred.
              */
              else if (bAltIsPressed == 1)
              {
              }
                     
              /*
              **  Normal single Key is transferred to IM_trans.
              */
              else if ((bShiftIsPressed == 0) && (bCapsIsPressed == 0))
              {
                     if ((pKsThis[0] >= IMXK_A) && (pKsThis[0] <= IMXK_Z))
                            pKsThis[0] += (IMXK_a - IMXK_A);

                     IMPinyinTrans(pKsThis, pSge);  
              }
              
              else if ((bShiftIsPressed == 1) && (bCapsIsPressed == 1))
              {
                     /* Bounce Keyevent directly back application */
                     if ((pKsThis[0] >= IMXK_A) && (pKsThis[0] <= IMXK_Z))
                            pKsThis[0] += (IMXK_a - IMXK_A);
              }
              else if ((bShiftIsPressed == 0) && (bCapsIsPressed == 1))
              {
                     if (nKsLen > 1)
                            pKsThis[0] = pKsThis[1];
              }
              else if ((bShiftIsPressed == 1) && (bCapsIsPressed == 0))
              {
                     if (nKsLen > 1)
                            pKsThis[0] = pKsThis[1];
              }
       }
}

Here is the caller graph for this function:

Definition at line 1535 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++;
              }
       }
}
VOID ProcSymbIMKey ( SesGuiElement pSge,
JINT  nSymbType,
JINT pNextKeysym,
ImToXSun pIeh 
)

Definition at line 2595 of file OnKeySym.c.

{
       JWORD  wThisSel[9];
       JINT   i, nCurCandiNum, nChoiceMark, nXrd, nLenThisSel;
       
       GetIehFromSge(pIeh, pSge);
       pIeh->nType = IMXSUN_TYPE_NORMAL;
       memset(pIeh->pwCommit, 0x00, UONE * sizeof(JWORD));
       
       if ((nSymbType != pSge->nKeyLayMode) || (pSge->nKeyLayMode != pSge->nPrevKeyLayMode))
       {
              PrepareSymbolSge(pSge, nSymbType);
              GetIehFromSge(pIeh, pSge);
              
              pIeh->nType = IMXSUN_TYPE_NORMAL;
              pSge->nKeyLayMode     = nSymbType;
              pSge->nPrevKeyLayMode = pSge->nKeyLayMode;
       }
       
       if (IsPageKeysym(pNextKeysym) == TRUE)
       {
              OnPageKeysym(pNextKeysym, pSge);
              GetIehFromSge(pIeh, pSge);
              pIeh->nType = IMXSUN_TYPE_NORMAL;
       }
       else if (IsSelectKeysym(pNextKeysym) == TRUE)
       {
              nCurCandiNum = pSge->nViewCandiEnd - pSge->nViewCandiStart;
              if (pNextKeysym[0] == IMXK_space)
                     pNextKeysym[0] = IMXK_1;
                     
              if ((pNextKeysym[0] > IMXK_0) && (pNextKeysym[0] <= (IMXK_0 + nCurCandiNum)))
              {
                     memset(wThisSel, 0x00, 9 * 2);
                     nChoiceMark     = pNextKeysym[0] - IMXK_0;
                     nXrd            = pSge->nViewCandiStart + nChoiceMark - 1;
                     nLenThisSel     = GetXrdCandi(&(pSge->scSysCandi), &(pSge->ucUdcCandi), nXrd, wThisSel, pSge->nGBKMode);
                     memset(pIeh->pwCommit, 0x00, 256 * 2);
                     assert(nLenThisSel == 1);
                     GetIehFromSge(pIeh, pSge);
                     for (i = 0; i < nLenThisSel; i++)
                            pIeh->pwCommit[i] = wThisSel[i];
                     pIeh->nType = IMXSUN_TYPE_COMMITSYMBOL;
              }
              else
              {
                     NULL;
#ifdef _DRAW_IM_WIN_H
                     XBell (pDspIme, 100);
#endif
              }
       }
       else if ( (IsPageKeysym(pNextKeysym) != TRUE) || (IsSelectKeysym(pNextKeysym) != TRUE) )
       {
              NULL;
#ifdef _DRAW_IM_WIN_H
              XBell (pDspIme, 100);
#endif
       }
       return;
}

Here is the caller graph for this function:

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

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

Here is the caller graph for this function:


Variable Documentation

Definition at line 70 of file CikuOper.c.

Definition at line 47 of file NewPYLE.c.

Definition at line 46 of file NewPYLE.c.

Definition at line 125 of file NewPYLE.c.

Definition at line 124 of file NewPYLE.c.

Definition at line 89 of file UdCikuOper.c.