Back to index

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

Go to the source code of this file.

Defines

#define UDCMEM_ALIGN   128

Functions

JINT Hzcode2244ToYjcode (JINT nHzcode)
JINT JwordNCmp (JWORD *pwSrc1, JWORD *pwSrc2, JINT nNum)
VOID SetUdcfh (UdCikuHeader *pUdcfh)
VOID SetSpecHzData (JWORD *pwSpecHz, JINT nMaxLen)
VOID SetUdcIndex (UdcIndex *pUdci)
VOID CreateUdCikuFile ()
JINT ReadUdcData (CHAR *szUdcName)
JINT WriteUdcData (CHAR *szUdcName, JINT nTimeStamp)
JINT AddUdc (JWORD *pwHz2244, JINT nLen)
JINT DelUdc (JWORD *pwHz2244, JINT nLen)
JINT PureUdc (VOID)

Variables

UdcMemAll udcAll

Define Documentation

#define UDCMEM_ALIGN   128

Definition at line 8 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;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 533 of file UdCikuOper.c.

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

       UdCikuHeader    udcfh;
       UdcIndex        udci;

       SetUdcfh(&udcfh);

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

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

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

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

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

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

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

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

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

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

       fclose(pfUdCiku);

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

}

Here is the call graph for this function:

Here is the caller graph for this function:

JINT DelUdc ( JWORD pwHz2244,
JINT  nLen 
)

Definition at line 866 of file UdCikuOper.c.

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

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

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

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

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

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

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

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

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

       return TRUE;
}

Here is the call graph for this function:

Definition at line 428 of file PyBasic.c.

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

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

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

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

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

       return (res);
}
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;
}

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 call graph for this function:

Here is the caller graph for this function:

VOID SetSpecHzData ( JWORD pwSpecHz,
JINT  nMaxLen 
)

Definition at line 472 of file UdCikuOper.c.

{
       JINT   nHzcode, nYjcode;
       JINT   i, k, m, nLen, nOff;

       JWORD  wSpecYjHanzi[NUM_YINJIE][6];
       JINT   nSpecCount[NUM_YINJIE];

/*     UCHAR  szTmp[20], nTmpYj, nFlag; */

       UCHAR   szSpecHz[400] =
       "之节或子出也能对大百太且用及过无才开到于下不来占此小学少最虽叫只因加边同由则几必然名多反后年可长秒向第并前半间曾好会全个从化给比让说以各有为门要人经是的了而你我他与其就和在这那每某本总如被更但将仅应该很都性上中内外分原";
/*    1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 */

       memset(wSpecYjHanzi, 0x00, sizeof(JWORD) * NUM_YINJIE * 6);
       memset(nSpecCount,   0x00, sizeof(JINT) * NUM_YINJIE);

       /* 是0xCAC7 不0xB2BB */
       nLen = strlen((CHAR*)szSpecHz);
       for (i = 0; (i < nLen / 2) && (i < nMaxLen); i++)
       {
              nHzcode = (szSpecHz[2 * i] << 8) + szSpecHz[2 * i + 1];
              nYjcode = Hzcode2244ToYjcode(nHzcode);

              wSpecYjHanzi[nYjcode][nSpecCount[nYjcode]] = (JWORD)nHzcode;
              nSpecCount[nYjcode]++;
       }

       k = 0;
       for (i = 0; i < NUM_YINJIE; i++)
       {
              pwSpecHz[k++] = 0x0000;
              for (m = 0; m < nSpecCount[i]; m++)
                     pwSpecHz[k++] = wSpecYjHanzi[i][m];
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

VOID SetUdcfh ( UdCikuHeader pUdcfh)

Definition at line 429 of file UdCikuOper.c.

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

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

       pUdcfh->nMagicDescHi = 0x35303539;
       pUdcfh->nMagicDescLow       = 0x34333442;
       pUdcfh->nSize        = sizeof(UdCikuHeader);
       pUdcfh->nFileSize    = 0;

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

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

       pUdcfh->nVersion     = 0x00010000;        /* Version 1.0 */
       pUdcfh->nLatestTime  = 0;

       pUdcfh->nSpecHzStartPos = 0;
       pUdcfh->nSizeSpecHz  = 0;           /* 2 KiloBytes for all spec Hanzi, each seperated by a 0x0000(JWORD) */
       pUdcfh->nIdxUdcPos   = 0;           /* Index Position of User defined 2 ~ 8 Hanzi Cizu */

       pUdcfh->nReserve1    = 0;
       pUdcfh->nReserve2    = 0;
       pUdcfh->nReserve3    = 0;

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

Here is the caller graph for this function:

VOID SetUdcIndex ( UdcIndex pUdci)

Definition at line 510 of file UdCikuOper.c.

{
       JINT   i, k;
       JINT   nM28Len[NUM_YINJIE];

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

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

       /* Assume that there is a FreqLen(JWORD), and a 0xBBBB(换) and 0xCCCC (烫) */
       for (i = 0; i < NUM_YINJIE; i++)
              nM28Len[i] = 0;

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

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

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

Here is the caller graph for this function:


Variable Documentation

Definition at line 9 of file UdCikuOper.c.