Back to index

im-sdk  12.3.91
codetable.h
Go to the documentation of this file.
00001 /*
00002   Copyright 2002-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 #ifndef _CODETABLE_H_
00043 #define _CODETABLE_H_
00044 
00045 /* Limit Constant Defination */
00046 #define MAX_CHNAME_LEN             256 
00047 #define MAX_USEDCODES_NUM   126 
00048 #define MAX_WILDCHAR_NUM  4
00049 
00050 /* Limit of Key Prompt */
00051 #define MAX_KEYPROMPT_LEN   4 
00052 
00053 /* Limit of Function Key */
00054 #define MAX_FUNCTIONKEY_LEN 6
00055 
00056 /* CodeTable File Distinguishment Flag */
00057 #define CODETABLE_FLAG             "CODETABLE"
00058 
00059 /* Version Defination */
00060 #define CODETABLE_VERSION   1
00061 
00062 /* Section Constant */
00063 enum _Section_List {
00064   DEFAULT_SECTION = 0,
00065   DESCRIPTION_SECTION,
00066   COMMENT_SECTION    ,
00067   KEYPROMPT_SECTION,
00068   FUNCTIONKEY_SECTION,
00069   PHRASE_SECTION     ,
00070   SINGLE_SECTION     ,
00071   OPTIONS_SECTION    ,
00072   MAX_SECTION_NUM
00073 };
00074 
00075 /* Function Key Defination */
00076 enum _Function_Key_ID {
00077   PAGEUP_KEY_ID = 0,
00078   PAGEDOWN_KEY_ID,
00079   BACKSPACE_KEY_ID,
00080   CLEARALL_KEY_ID    ,
00081   MAX_FUNCTIONKEY_NUM
00082 };
00083 
00084 /* Options Mode Defination */
00085 enum _Option_Mode {
00086   OFF_MODE = 0,
00087   ON_MODE     ,
00088 };
00089 
00090 /* SelectKey Mode Defination */
00091 enum _Select_Key_Mode {
00092   NUMBER_MODE = 0,
00093   LOWER_MODE,
00094   UPPER_MODE,
00095 };
00096 
00097 /* Phrase Seperate Tag */
00098 #define HZ_PHRASE_TAG              '\001'
00099 
00100 /* Bit Operations */
00101 #define BITMASK(i)          (1 << (i))
00102 #define BITSET(a, i)               ((a) |= BITMASK(i))
00103 #define BITCLEAR(a, i)             ((a) &= ~BITMASK(i))
00104 #define GETBIT(a, i)               ((a) & BITMASK(i))
00105 
00106 typedef struct _tableNode {
00107   unsigned char      key;   /* key of this node */
00108   unsigned char   num_NextKeys;    /* number of possible next input key */
00109   unsigned short     num_HZchoice;        /* number of HZ choices */
00110   unsigned int       pos_NextKey;  /* table node pos of next key */
00111   unsigned int       pos_HZidx;    /* index of HZ list */
00112 } tableNode;
00113        
00114 typedef struct _keyPrompt {
00115   unsigned char      prompt[MAX_KEYPROMPT_LEN + 1];
00116 } keyPrompt;
00117 
00118 typedef struct _functionKey {
00119   unsigned char      keylist[MAX_FUNCTIONKEY_LEN + 1];
00120 } functionKey;
00121 
00122 /* codetable file header structure */
00123 typedef struct {
00124   char        Encode;                            /* UTF-8 or native: encode of dict */     
00125   unsigned char   Lname[MAX_CHNAME_LEN];
00126   unsigned char      Cname[MAX_CHNAME_LEN];      /* IM Name */
00127   char               UsedCodes[MAX_USEDCODES_NUM];   /* Characters for valid input */
00128   unsigned char   WildChar[MAX_WILDCHAR_NUM]; /* Characters for WildChar */
00129   char               MaxCodes;                   /* Max number of extern codes */
00130 
00131   char        bSectionsFlag;                     /* sections exist flag */
00132 
00133   char        Output_Encode;                     /* encode of output */
00134   unsigned    nKeyByKeyMode               :1;
00135   unsigned    nHelpInfoMode               :1;
00136   unsigned    nAutoSelectMode      :1;
00137   unsigned    nKeyPromptMode              :1;
00138   unsigned    nDisplayOnSpotMode   :1;
00139   unsigned    nSelectKeyMode              :2;
00140   unsigned    nReserved            :1;
00141 
00142   unsigned int       sizeHZList;                 /* size of whole hz list */
00143   unsigned int       sizeNodeList;               /* size of whole node list */
00144   unsigned char      *hzList;                    /* pointer of characters list */
00145   tableNode   *nodeList;                  /* pointer of Tree Node List */
00146        
00147   keyPrompt   *keyprompt;                 /* prompt list of keys */
00148   functionKey *functionkey;               /* Functions key defination list */
00149               
00150 } CodeTableStruct;
00151 
00152 int LoadCodeTableHeader(char *file_name, CodeTableStruct *hztbl);
00153 int LoadCodeTable(char *file_name, CodeTableStruct *hztbl);
00154 void UnloadCodeTable(CodeTableStruct *hztbl);
00155 int codetable_search(CodeTableStruct *hztbl, int *inbuf, int inlen, unsigned char **outbuf, unsigned char **attrbuf, int pos, int num);
00156 int Is_Wildchar_Key(CodeTableStruct *hztbl, int key);
00157 
00158 #endif    /*  _CODETABLE_H_  */
00159