Back to index

im-sdk  12.3.91
CikuOper.h
Go to the documentation of this file.
00001 /*
00002 Copyright 1990-2003 Sun Microsystems, Inc. All Rights Reserved.
00003 
00004 Permission is hereby granted, free of charge, to any person obtaining a
00005 copy of this software and associated documentation files (the
00006 "Software"), to deal in the Software without restriction, including
00007 without limitation the rights to use, copy, modify, merge, publish,
00008 distribute, sublicense, and/or sell copies of the Software, and to
00009 permit persons to whom the Software is furnished to do so, subject to
00010 the following conditions: The above copyright notice and this
00011 permission notice shall be included in all copies or substantial
00012 portions of the Software.
00013 
00014 
00015 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00016 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00017 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00018 IN NO EVENT SHALL THE OPEN GROUP OR SUN MICROSYSTEMS, INC. BE LIABLE
00019 FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
00020 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
00021 THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE EVEN IF
00022 ADVISED IN ADVANCE OF THE POSSIBILITY OF SUCH DAMAGES.
00023 
00024 
00025 Except as contained in this notice, the names of The Open Group and/or
00026 Sun Microsystems, Inc. shall not be used in advertising or otherwise to
00027 promote the sale, use or other dealings in this Software without prior
00028 written authorization from The Open Group and/or Sun Microsystems,
00029 Inc., as applicable.
00030 
00031 
00032 X Window System is a trademark of The Open Group
00033 
00034 OSF/1, OSF/Motif and Motif are registered trademarks, and OSF, the OSF
00035 logo, LBX, X Window System, and Xinerama are trademarks of the Open
00036 Group. All other trademarks and registered trademarks mentioned herein
00037 are the property of their respective owners. No right, title or
00038 interest in or to any trademark, service mark, logo or trade name of
00039 Sun Microsystems, Inc. or its licensors is granted.
00040 
00041 */
00042 
00043 #ifndef _CIKU_OPER_H
00044 #define _CIKU_OPER_H
00045 
00046 #include "GeneType.h"
00047 #include "PyBasic.h"
00048 
00049 #define MAX_CIZU_ITEMS     85000
00050 #define CIZU_ITEM_LEN        126
00051 #define MAX_CIZU_HZ_NUM        9
00052 
00053 #define ENUM_FULL              4
00054 #define ENUM_SIMP              0
00055 #define ENUM_SIMP_W            1
00056 
00057 #define F_PRINT                1
00058 #define F_NOPRINT              0
00059 
00060 #define READ_RAW_CIZU          1
00061 #define READ_SORTED_CIZU       2
00062 
00063 #define SINGLEHZ_DSP_NONE      0
00064 #define SINGLEHZ_DSP_SIMP      1
00065 #define SINGLEHZ_DSP_FULL      2
00066 
00067 
00068 typedef struct _CizuItem {
00069        UCHAR     szLine[CIZU_ITEM_LEN];           /* Org Line read from file */
00070        UCHAR     szHz[2 * MAX_CIZU_HZ_NUM];
00071        UCHAR     szHz2244[2 * MAX_CIZU_HZ_NUM];   /* Notice: may also contain 0x2001 ~ 0x2244, means DuoYinZi */
00072        JINT      nHzNum;
00073        JINT      nYj[MAX_CIZU_HZ_NUM];            /* nHzNum may be diff from nYjNum */
00074        JINT      nYjNum;
00075        JINT      nFreq;
00076        JINT      nbIsXianForm;
00077        JINT      nbIsFanganForm;
00078        JINT      nbIsEnaoForm;
00079        JINT      nXianFormYj[MAX_CIZU_HZ_NUM];
00080        JINT      nFanganFormYj[MAX_CIZU_HZ_NUM];
00081 } CizuItem;          /* Max Array Size is MAX_CIZU_ITEMS(64000) */
00082 
00083 
00084 typedef struct _SingleHanziByYj {
00085        UCHAR     szHanzi[256];
00086        JINT      nHzNum;                          /* don't include nXianFormNum */
00087        JINT      nXianFormNum;
00088        UCHAR     szXianFormList[64];              /* Seperated by 0x0909 */
00089 } SingleHanziByYj;  /* Max Array Size is NUM_YINJIE(415) */
00090 
00091 
00092 /* 1300: beacause "yi" have max nNumFirstYjIs = 1019 */
00093 typedef struct _CizuGroupByYj {
00094        JINT      nNumFirstYjIs;                /* Number of Cizu which start by this Yinjie Code */
00095        JINT      nNum2ndYjIs[NUM_YINJIE];      /* Number of Cizu whose second Yinjie is 0~414. Sum of this array is nNumFirstYjIs */
00096        JINT      nIdxItem[1300];               /* Index to CizuItem, sorted by nNum2ndYjIs, include also nFanganForm */
00097        JINT      nIdxFanganItem[60];           /* Index to CizuItem which is a Fangan Form, sorted by nIdxItem[1300] */
00098        JINT      nSizePureCizu;                /* Pure Hanzi Number by this Yinjie. Space is 2 * nSizePureCizu */
00099 } CizuGroupByYj;      /* Max Array Size is NUM_YINJIE(415) */
00100 
00101 typedef struct _CikuHeader {
00102        JINT      nMagicDescHi;     /* "PY" ==> 0x5059 ==> 0x35303539 */
00103        JINT      nMagicDescLow;    /* "CK" ==> 0x434B ==> 0x34333442 */
00104        JINT      nSize;            /* Size of this structure: 128 */
00105        JINT      nFileSize;        /* Size of this file */
00106        CHAR      szName[32];       /* Name of this ciku file */
00107        CHAR      szCopyright[48];  /* Copyright info of this file */
00108        JINT      nVersion;         /* Hi(nVersion) is main version, Low() is reversion */
00109        JINT      nLatestTime;      /* Last Create time by seconds from 1970.1.1.0.0.0 */
00110        JINT      nIdxShPos;        /* Index Position from file header of Single Hanzi */
00111        JINT      nIdxDhPos;        /* Index Position from file header of Double Hanzi */
00112        JINT      nIdxMhPos;        /* Index Position from file header of Multi Hanzi  */
00113        JINT      nIdxGbkPos;       /* Index Position from file header of GBK Single Hanzi. MXL 97.12.21 */
00114        JINT      nReserve2;        /* Reserves(2.3) for future development */
00115        JINT      nReserve3;
00116 } CikuHeader;
00117                      
00118 typedef struct _ShIndex {       /* SINGLE HANZI */
00119        JINT      nSize;            /* Size of this structure */
00120        JINT      nStartPos;        /* First position of Single Hanzi Data Area */
00121        JINT      nEndPos;          /* End position of Single Hanzi Data Area */
00122        JINT      nYjOff[NUM_YINJIE + 1];  /* Offset of each Yj relative to this nStartPos  */
00123 } ShIndex;
00124 
00125 typedef struct _DhIndex {       /* DOUBLE HANZI CIZU */
00126        JINT     nSize;
00127        JINT     nStartPos;
00128        JINT     nEndPos;
00129        JINT     nYjOff[NUM_YINJIE + 1];   /* Offset of each Yj relative to this nStartPos */
00130 } DhIndex;
00131 
00132 typedef struct _MhIndex {       /* MULTIPLE HANZI CIZU ( > 3 ) */
00133        JINT     nSize;
00134        JINT     nStartPos;
00135        JINT     nEndPos;
00136        JINT     nYjOff[NUM_YINJIE + 1];  /* Offset of each Yj relative to this nStartPos */
00137 } MhIndex;
00138 
00139 typedef struct _GbkIndex {      /* Single Hanzi of Only GBKKKK!! */
00140        JINT     nSize;
00141        JINT     nStartPos;
00142        JINT     nEndPos;
00143        JINT     nYjOff[NUM_YINJIE + 1];   /* Offset of each Yj relative to this nStartPos */
00144 } GbkIndex;
00145 
00146 typedef struct _SysCandi {      /* Candidates come from System Ciku */
00147                                    /* SINGLE HANZI WAS SORTED BY FREQUENCE */
00148        JINT    nOrgYj[9];          /* Original YinjieCode Array of 0~414 & 450~475 */
00149        JINT    nLenYj;
00150        JINT    nNumShCandi;        /* Number of Single Hanzi Candidates, High 8 bits indicates XianNum */
00151        JINT    nSizShCandi;        /* In JWORD */
00152        JWORD*  pwShCandi;          /* Pointer of Single Hanzi Area : Encoded in GB2244 */
00153 
00154        JINT    nNumDhCandi;        /* Number of Double Hanzi Candidates */
00155        JINT    nSizDhCandi;        /* In JWORD */
00156        JWORD*  pwDhCandi;          /* Pointer of Double Hanzi Area:  Encoded in GB2244, sorted by Freq, with
00157                                       a Word (Not Byte!!!) in front of each Candi to indicates Frequence */
00158 
00159        JINT    nNumMhCandi;        /* Number of Multiple Hanzi Candidates */
00160        JINT    nSizMhCandi;        /* In JWORD */
00161        JWORD*  pwMhCandi;          /* Pointer of Multiple Hanzi Area: Encoded in GB2244, Sorted by Length and Freq,
00162                                    ** With a word (Not Byte!!!) in front of each Candi to indicates Length and Freq!
00163                                    ** Contain a 0x0000 in the end of each candidate. */
00164 
00165        JINT    nNumGbkCandi;       /* Number of GBK Single Hanzi Candidates */
00166        JINT    nSizGbkCandi;       /* In JWORD */
00167        JWORD*  pwGbkCandi;         /* Pointer of GBK Single Hanzi Area */
00168 } SysCandi;
00169 
00170 
00171 /* nMode */
00172 #define LU_CANDI_CALC       1
00173 #define LU_CANDI_WRITE      2
00174 
00175 /* nMatchMode */
00176 #define LU_MATCH_STRICT     1
00177 #define LU_MATCH_WIDELY     2
00178 
00179 /* Not Existing in either System or User Defined Ciku */
00180 #define NON_EXIST_CIZU      0
00181 /* Existing in System Ciku */
00182 #define SYS_EXIST_CIZU      1
00183 /* Existing in User Defined Ciku */
00184 #define UDC_EXIST_CIZU      2
00185 
00186 #ifndef _DRAW_IM_WIN_H
00187 static  CHAR   szSysCiku[] = "PyCiku.dat";
00188 #else
00189 static  CHAR   szSysCiku_Gb[]  = "PyCiku.dat";
00190 static  CHAR   szSysCiku_Gbk[] = "PyCiku.dat";
00191 #endif
00192 
00193 static  CHAR   szSysCikuBak[]  = "/.Xlocale/PyCiku.dat";
00194 
00195 
00196 /*****************************************************************************************
00197 ********************                                          ****************************
00198 ******************** Following is Definition for UdCikuOper.c ****************************
00199 ********************                                          ****************************
00200 *****************************************************************************************/
00201 
00202 /* Minimum Unit for Udc Data */
00203 #define    UDCMEM_ALIGN      1024
00204 
00205 typedef struct _UdCikuHeader {
00206        JINT      nMagicDescHi;     /* "PY" ==> 0x5059 ==> 0x35303539 */
00207        JINT      nMagicDescLow;    /* "CK" ==> 0x434B ==> 0x34333442 */
00208        JINT      nSize;            /* Size of this structure: 128 */
00209        JINT      nFileSize;        /* Size of this file */
00210        CHAR      szName[32];       /* Name of this ciku file */
00211        CHAR      szCopyright[48];  /* Copyright info of this file */
00212        JINT      nVersion;         /* Hi(nVersion) is main version, Low() is reversion */
00213        JINT      nLatestTime;      /* Last Create time by seconds from 1970.1.1.0.0.0 */
00214                                    /* Spec Hanzi include UDSINGLEHZ which defined in <PyBasic.h> */
00215        JINT      nSpecHzStartPos;  /* Offset of SpecHz Data Area */
00216        JINT      nSizeSpecHz;      /* 2048 is ENOUGH!! */
00217        JINT      nIdxUdcPos;       /* Index Position from file header of Multi Hanzi */
00218        JINT      nReserve1;        /* Reserves(1.2.3) for future development */
00219        JINT      nReserve2;
00220        JINT      nReserve3;
00221 } UdCikuHeader;
00222                      
00223 
00224 typedef struct _UdcIndex {      /* Index of User Defined Cizu */
00225        JINT     nSize;          
00226        JINT     nStartPos;
00227        JINT     nEndPos;
00228        JINT     nYjOff[NUM_YINJIE + 1];  /* Offset of each Yj relative to this nStartPos */
00229 } UdcIndex;
00230 
00231 
00232 typedef struct _UdcMemAll {     /* Structure of All Udc Data in Memory */
00233        UdCikuHeader    udcfh;
00234        UdcIndex        udci;
00235        JWORD          *pwUdcSh;
00236        JWORD          *pwUdc28[NUM_YINJIE];
00237 } UdcMemAll;
00238 
00239 
00240 typedef struct _UdcCandi {      /* Candidates come from User Defined Ciku */
00241        JINT    nNumSpecCandi;      /* Number of SpecHz Candi. */
00242        JWORD   pwSpecCandi[6];     /* 6 is enough!! */
00243 
00244        JINT    nNumUdc28Candi;     /* Number of UdCandi which length in 2 ~ 8 */
00245        JINT    nSizUdc28Candi;     /* In JWORD */
00246        JWORD*  pwUdc28Candi;       /* Pointer of Udc28 Area: Encoded in GB2244, Sorted by Length and Freq,
00247                                    ** With a word (Not Byte!!!) in front of each Candi to indicates Length and Freq!
00248                                    ** Contain a 0x0000 in the end of each candidate.
00249                                    */
00250 } UdcCandi;
00251 
00252 #ifndef _DRAW_IM_WIN_H
00253 static  CHAR   szUdcCiku[] = "UdCiku.dat";  
00254 #else
00255 static  CHAR   szUdcCiku_Gb[]  = "UdCiku.dat";
00256 static  CHAR   szUdcCiku_Gbk[] = "UdCiku.dat";
00257 #endif
00258 
00259 static  CHAR   szUdcCikuBak[]  = "/.Xlocale/UdCiku.dat";
00260 
00261 #endif   /* End of _CIKU_OPER_H */
00262 
00263