Back to index

im-sdk  12.3.91
CikuOper.h
Go to the documentation of this file.
00001 /*
00002 Copyright 1990-2001 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 #ifndef _CIKU_OPER_H
00043 #define _CIKU_OPER_H
00044 
00045 #include "GeneType.h"
00046 #include "PyBasic.h"
00047 
00048 #define MAX_CIZU_ITEMS     64000
00049 #define CIZU_ITEM_LEN        126
00050 #define MAX_CIZU_HZ_NUM        9
00051 
00052 #define ENUM_FULL              4
00053 #define ENUM_SIMP              0
00054 #define ENUM_SIMP_W            1
00055 
00056 #define F_PRINT                1
00057 #define F_NOPRINT              0
00058 
00059 #define READ_RAW_CIZU          1
00060 #define READ_SORTED_CIZU       2
00061 
00062 #define SINGLEHZ_DSP_NONE      0
00063 #define SINGLEHZ_DSP_SIMP      1
00064 #define SINGLEHZ_DSP_FULL      2
00065 
00066 
00067 typedef struct _CizuItem {
00068        UCHAR     szLine[CIZU_ITEM_LEN];           /* Org Line read from file */
00069        UCHAR     szHz[2 * MAX_CIZU_HZ_NUM];
00070        UCHAR     szHz2244[2 * MAX_CIZU_HZ_NUM];   /* Notice: may also contain 0x2001 ~ 0x2244, means DuoYinZi */
00071        JINT      nHzNum;
00072        JINT      nYj[MAX_CIZU_HZ_NUM];            /* nHzNum may be diff from nYjNum */
00073        JINT      nYjNum;
00074        JINT      nFreq;
00075        JINT      nbIsXianForm;
00076        JINT      nbIsFanganForm;
00077        JINT      nbIsEnaoForm;
00078        JINT      nXianFormYj[MAX_CIZU_HZ_NUM];
00079        JINT      nFanganFormYj[MAX_CIZU_HZ_NUM];
00080 } CizuItem;          /* Max Array Size is MAX_CIZU_ITEMS(64000) */
00081 
00082 
00083 typedef struct _SingleHanziByYj {
00084        UCHAR     szHanzi[256];
00085        JINT      nHzNum;                          /* don't include nXianFormNum */
00086        JINT      nXianFormNum;
00087        UCHAR     szXianFormList[64];              /* Seperated by 0x0909 */
00088 } SingleHanziByYj;  /* Max Array Size is NUM_YINJIE(415) */
00089 
00090 
00091 /* 1300: beacause "yi" have max nNumFirstYjIs = 1019 */
00092 typedef struct _CizuGroupByYj {
00093        JINT      nNumFirstYjIs;                /* Number of Cizu which start by this Yinjie Code */
00094        JINT      nNum2ndYjIs[NUM_YINJIE];      /* Number of Cizu whose second Yinjie is 0~414. Sum of this array is nNumFirstYjIs */
00095        JINT      nIdxItem[1300];               /* Index to CizuItem, sorted by nNum2ndYjIs, include also nFanganForm */
00096        JINT      nIdxFanganItem[60];           /* Index to CizuItem which is a Fangan Form, sorted by nIdxItem[1300] */
00097        JINT      nSizePureCizu;                /* Pure Hanzi Number by this Yinjie. Space is 2 * nSizePureCizu */
00098 } CizuGroupByYj;      /* Max Array Size is NUM_YINJIE(415) */
00099 
00100 typedef struct _CikuHeader {
00101        JINT      nMagicDescHi;     /* "PY" ==> 0x5059 ==> 0x35303539 */
00102        JINT      nMagicDescLow;    /* "CK" ==> 0x434B ==> 0x34333442 */
00103        JINT      nSize;            /* Size of this structure: 128 */
00104        JINT      nFileSize;        /* Size of this file */
00105        CHAR      szName[32];       /* Name of this ciku file */
00106        CHAR      szCopyright[48];  /* Copyright info of this file */
00107        JINT      nVersion;         /* Hi(nVersion) is main version, Low() is reversion */
00108        JINT      nLatestTime;      /* Last Create time by seconds from 1970.1.1.0.0.0 */
00109        JINT      nIdxShPos;        /* Index Position from file header of Single Hanzi */
00110        JINT      nIdxDhPos;        /* Index Position from file header of Double Hanzi */
00111        JINT      nIdxMhPos;        /* Index Position from file header of Multi Hanzi  */
00112        JINT      nIdxGbkPos;       /* Index Position from file header of GBK Single Hanzi. MXL 97.12.21 */
00113        JINT      nReserve2;        /* Reserves(2.3) for future development */
00114        JINT      nReserve3;
00115 } CikuHeader;
00116                      
00117 typedef struct _ShIndex {       /* SINGLE HANZI */
00118        JINT      nSize;            /* Size of this structure */
00119        JINT      nStartPos;        /* First position of Single Hanzi Data Area */
00120        JINT      nEndPos;          /* End position of Single Hanzi Data Area */
00121        JINT      nYjOff[NUM_YINJIE + 1];  /* Offset of each Yj relative to this nStartPos  */
00122 } ShIndex;
00123 
00124 typedef struct _DhIndex {       /* DOUBLE HANZI CIZU */
00125        JINT     nSize;
00126        JINT     nStartPos;
00127        JINT     nEndPos;
00128        JINT     nYjOff[NUM_YINJIE + 1];   /* Offset of each Yj relative to this nStartPos */
00129 } DhIndex;
00130 
00131 typedef struct _MhIndex {       /* MULTIPLE HANZI CIZU ( > 3 ) */
00132        JINT     nSize;
00133        JINT     nStartPos;
00134        JINT     nEndPos;
00135        JINT     nYjOff[NUM_YINJIE + 1];  /* Offset of each Yj relative to this nStartPos */
00136 } MhIndex;
00137 
00138 typedef struct _GbkIndex {      /* Single Hanzi of Only GBKKKK!! */
00139        JINT     nSize;
00140        JINT     nStartPos;
00141        JINT     nEndPos;
00142        JINT     nYjOff[NUM_YINJIE + 1];   /* Offset of each Yj relative to this nStartPos */
00143 } GbkIndex;
00144 
00145 typedef struct _SysCandi {      /* Candidates come from System Ciku */
00146                                    /* SINGLE HANZI WAS SORTED BY FREQUENCE */
00147        JINT    nOrgYj[9];          /* Original YinjieCode Array of 0~414 & 450~475 */
00148        JINT    nLenYj;
00149        JINT    nNumShCandi;        /* Number of Single Hanzi Candidates, High 8 bits indicates XianNum */
00150        JINT    nSizShCandi;        /* In JWORD */
00151        JWORD*  pwShCandi;          /* Pointer of Single Hanzi Area : Encoded in GB2244 */
00152 
00153        JINT    nNumDhCandi;        /* Number of Double Hanzi Candidates */
00154        JINT    nSizDhCandi;        /* In JWORD */
00155        JWORD*  pwDhCandi;          /* Pointer of Double Hanzi Area:  Encoded in GB2244, sorted by Freq, with
00156                                       a Word (Not Byte!!!) in front of each Candi to indicates Frequence */
00157 
00158        JINT    nNumMhCandi;        /* Number of Multiple Hanzi Candidates */
00159        JINT    nSizMhCandi;        /* In JWORD */
00160        JWORD*  pwMhCandi;          /* Pointer of Multiple Hanzi Area: Encoded in GB2244, Sorted by Length and Freq,
00161                                    ** With a word (Not Byte!!!) in front of each Candi to indicates Length and Freq!
00162                                    ** Contain a 0x0000 in the end of each candidate. */
00163 
00164        JINT    nNumGbkCandi;       /* Number of GBK Single Hanzi Candidates */
00165        JINT    nSizGbkCandi;       /* In JWORD */
00166        JWORD*  pwGbkCandi;         /* Pointer of GBK Single Hanzi Area */
00167 } SysCandi;
00168 
00169 
00170 /* nMode */
00171 #define LU_CANDI_CALC       1
00172 #define LU_CANDI_WRITE      2
00173 
00174 /* nMatchMode */
00175 #define LU_MATCH_STRICT     1
00176 #define LU_MATCH_WIDELY     2
00177 
00178 /* Not Existing in either System or User Defined Ciku */
00179 #define NON_EXIST_CIZU      0
00180 /* Existing in System Ciku */
00181 #define SYS_EXIST_CIZU      1
00182 /* Existing in User Defined Ciku */
00183 #define UDC_EXIST_CIZU      2
00184 
00185 #ifndef _DRAW_IM_WIN_H
00186 static  CHAR   szSysCiku_Gb[]  = "/data/PyCiku.dat";
00187 static  CHAR   szSysCiku_Gbk[] = "/data/PyCiku.dat";
00188 static  CHAR   szSysCiku_Gbk_WIN32[] = "\\data\\PyCiku.dat";
00189 #else
00190 static  CHAR   szSysCiku_Gb[]  = "PyCiku.dat";
00191 static  CHAR   szSysCiku_Gbk[] = "PyCiku.dat";
00192 #endif
00193 
00194 static  CHAR   szSysCikuBak[]  = "/PyCiku.dat";
00195 
00196 
00197 /*****************************************************************************************
00198 ********************                                          ****************************
00199 ******************** Following is Definition for UdCikuOper.c ****************************
00200 ********************                                          ****************************
00201 *****************************************************************************************/
00202 
00203 /* Minimum Unit for Udc Data */
00204 #define    UDCMEM_ALIGN      128
00205 
00206 typedef struct _UdCikuHeader {
00207        JINT      nMagicDescHi;     /* "PY" ==> 0x5059 ==> 0x35303539 */
00208        JINT      nMagicDescLow;    /* "CK" ==> 0x434B ==> 0x34333442 */
00209        JINT      nSize;            /* Size of this structure: 128 */
00210        JINT      nFileSize;        /* Size of this file */
00211        CHAR      szName[32];       /* Name of this ciku file */
00212        CHAR      szCopyright[48];  /* Copyright info of this file */
00213        JINT      nVersion;         /* Hi(nVersion) is main version, Low() is reversion */
00214        JINT      nLatestTime;      /* Last Create time by seconds from 1970.1.1.0.0.0 */
00215                                    /* Spec Hanzi include UDSINGLEHZ which defined in <PyBasic.h> */
00216        JINT      nSpecHzStartPos;  /* Offset of SpecHz Data Area */
00217        JINT      nSizeSpecHz;      /* 2048 is ENOUGH!! */
00218        JINT      nIdxUdcPos;       /* Index Position from file header of Multi Hanzi */
00219        JINT      nReserve1;        /* Reserves(1.2.3) for future development */
00220        JINT      nReserve2;
00221        JINT      nReserve3;
00222 } UdCikuHeader;
00223                      
00224 
00225 typedef struct _UdcIndex {      /* Index of User Defined Cizu */
00226        JINT     nSize;          
00227        JINT     nStartPos;
00228        JINT     nEndPos;
00229        JINT     nYjOff[NUM_YINJIE + 1];  /* Offset of each Yj relative to this nStartPos */
00230 } UdcIndex;
00231 
00232 
00233 typedef struct _UdcMemAll {     /* Structure of All Udc Data in Memory */
00234        UdCikuHeader    udcfh;
00235        UdcIndex        udci;
00236        JWORD          *pwUdcSh;
00237        JWORD          *pwUdc28[NUM_YINJIE];
00238 } UdcMemAll;
00239 
00240 
00241 typedef struct _UdcCandi {      /* Candidates come from User Defined Ciku */
00242        JINT    nNumSpecCandi;      /* Number of SpecHz Candi. */
00243        JWORD   pwSpecCandi[6];     /* 6 is enough!! */
00244 
00245        JINT    nNumUdc28Candi;     /* Number of UdCandi which length in 2 ~ 8 */
00246        JINT    nSizUdc28Candi;     /* In JWORD */
00247        JWORD*  pwUdc28Candi;       /* Pointer of Udc28 Area: Encoded in GB2244, Sorted by Length and Freq,
00248                                    ** With a word (Not Byte!!!) in front of each Candi to indicates Length and Freq!
00249                                    ** Contain a 0x0000 in the end of each candidate.
00250                                    */
00251 } UdcCandi;
00252 
00253 #ifndef _DRAW_IM_WIN_H
00254 static  CHAR   szUdcCiku_Gb[]  = "/data/UdCiku.dat";
00255 static  CHAR   szUdcCiku_Gbk[] = "/data/UdCiku.dat";
00256 static  CHAR   szUdcCiku_Gbk_WIN32[] = "\\..\\locale\\zh_CN\\newpy\\data\\UdCiku.dat";
00257 #else
00258 static  CHAR   szUdcCiku_Gb[]  = "UdCiku.dat";
00259 static  CHAR   szUdcCiku_Gbk[] = "UdCiku.dat";
00260 #endif
00261 
00262 static  CHAR   szUdcCikuBak[]  = "/UdCiku.dat";
00263 
00264 #endif   /* End of _CIKU_OPER_H */
00265 
00266