Back to index

im-sdk  12.3.91
Classes | Defines | Enumerations | Functions | Variables
XimpParser.c File Reference
#include <stdio.h>
#include <X11/Xlibint.h>
#include <X11/Xos.h>
#include <X11/Sunkeysym.h>
#include "composeIM.h"

Go to the source code of this file.

Classes

struct  StateKeyWordRec
struct  AttribKeyWordRec

Defines

#define __XLIBINT_HH
#define RmTop   (1 << 0)
#define RmBottom   (1 << 1)
#define RmLeft   (1 << 2)
#define RmRight   (1 << 3)
#define RmOverTheSpot   (1 << 5)
#define RmCenterOfScreen   (1 << 6)
#define ENDOFFILE   0
#define ENDOFLINE   1
#define COLON   2
#define LESS   3
#define GREATER   4
#define EXCLAM   5
#define TILDE   6
#define STRING   7
#define KEY   8
#define ERROR   9
#define RIGHT_BRACKET   10
#define LEFT_BRACKET   11
#define ATTRIBUTES   12
#define T_STATE   101
#define T_END_STATE   102
#define T_SWITCH_STATE_TO   103
#define T_ATTRIBUTES   104
#define T_END_ATTRIBUTES   105
#define T_ACTIONS   106
#define T_END_ACTIONS   107
#define T_DO_CONV   108
#define T_NEXT_PAGE   109
#define T_PREV_PAGE   110
#define T_TOP_PAGE   111
#define T_LAST_PAGE   112
#define T_STATE_TYPE   113
#define T_COMPOSE_STATE   114
#define T_CODE_INPUT_STATE   115
#define T_LOOKUP_STATE   116
#define T_TABLELOOKUP   117
#define T_REMOTE_IM_STATE   151 /* Added for remote IM */
#define T_LANGUAGE   152
#define ATTRIBUTE_TOKEN   200
#define A_MAX_INPUT_LENGTH   201
#define A_TYPE_OF_INPUT   202
#define A_MAX_NUMBER_OF_ROWS   203
#define A_MAX_NUMBER_OF_COLUMNS   204
#define A_MAX_NUMBER_OF_CANDIDATES   205
#define A_TITLE_STRING   206
#define A_CODE_RANGE   207
#define A_FONTSET   208
#define A_POSITION   209
#define A_PLACEMENT   210
#define EMPTY_GLYPH_CHAR   0x3f
#define MAXSTRLEN   100
#define isalnum(c)
#define ishexch(c)
#define AllMask   (ShiftMask | LockMask | ControlMask | Mod1Mask | Mod2Mask)
#define LOCAL_WC_BUFSIZE   128
#define SEQUENCE_MAX   10

Enumerations

enum  RmWindowPosition { RmScreen = 107, RmClient = 108, RmCursor = 109, RmSpotLocation = 110 }
enum  AttribType { StringAttr, IntegerAttr, LiteralAttr }

Functions

static int nextch (FILE *fp)
static void putbackch (int c)
static int check_quoted_string (FILE *fp)
static int get_statetoken (char *w)
static int get_attributetoken (char *w)
static int nexttoken (FILE *fp)
static long modmask (char *name)
static LocalIMStatecreate_state (Ximp_XIM xim, char *name)
static StateAttribnew_attribute ()
static int parseline (FILE *fp, XimCommon im, LocalIMState **state)
static int set_change_state_info (Ximp_XIM xim, DefTree *p)
int Ximp_ParseStringFile (FILE *fp, XimCommon im)

Variables

static StateKeyWordRec keyword_tbl []
static AttribKeyWordRec attr_tbl []
static int lastch = 0
static char tokenbuf [MAXSTRLEN]

Class Documentation

struct StateKeyWordRec

Definition at line 181 of file XimpParser.c.

Class Members
char * name
int val
struct AttribKeyWordRec

Definition at line 222 of file XimpParser.c.

Class Members
char * name
AttribType type
int val

Define Documentation

#define __XLIBINT_HH

Definition at line 82 of file XimpParser.c.

#define A_CODE_RANGE   207

Definition at line 174 of file XimpParser.c.

#define A_FONTSET   208

Definition at line 175 of file XimpParser.c.

#define A_MAX_INPUT_LENGTH   201

Definition at line 168 of file XimpParser.c.

#define A_MAX_NUMBER_OF_CANDIDATES   205

Definition at line 172 of file XimpParser.c.

#define A_MAX_NUMBER_OF_COLUMNS   204

Definition at line 171 of file XimpParser.c.

#define A_MAX_NUMBER_OF_ROWS   203

Definition at line 170 of file XimpParser.c.

#define A_PLACEMENT   210

Definition at line 177 of file XimpParser.c.

#define A_POSITION   209

Definition at line 176 of file XimpParser.c.

#define A_TITLE_STRING   206

Definition at line 173 of file XimpParser.c.

#define A_TYPE_OF_INPUT   202

Definition at line 169 of file XimpParser.c.

#define AllMask   (ShiftMask | LockMask | ControlMask | Mod1Mask | Mod2Mask)

Definition at line 530 of file XimpParser.c.

#define ATTRIBUTE_TOKEN   200

Definition at line 167 of file XimpParser.c.

#define ATTRIBUTES   12

Definition at line 138 of file XimpParser.c.

#define COLON   2

Definition at line 128 of file XimpParser.c.

#define EMPTY_GLYPH_CHAR   0x3f

Definition at line 179 of file XimpParser.c.

#define ENDOFFILE   0

Definition at line 126 of file XimpParser.c.

#define ENDOFLINE   1

Definition at line 127 of file XimpParser.c.

#define ERROR   9

Definition at line 135 of file XimpParser.c.

#define EXCLAM   5

Definition at line 131 of file XimpParser.c.

#define GREATER   4

Definition at line 130 of file XimpParser.c.

#define isalnum (   c)
Value:
(('0' <= (c) && (c) <= '9')  || \
     ('A' <= (c) && (c) <= 'Z')  || \
     ('a' <= (c) && (c) <= 'z'))

Definition at line 277 of file XimpParser.c.

#define ishexch (   c)
Value:
(((c) >= '0' && (c) <= '9') || \
                  ((c) >= 'A' && (c) <= 'F') || \
                  ((c) >= 'a' && (c) <= 'f'))
#define KEY   8

Definition at line 134 of file XimpParser.c.

#define LEFT_BRACKET   11

Definition at line 137 of file XimpParser.c.

#define LESS   3

Definition at line 129 of file XimpParser.c.

#define LOCAL_WC_BUFSIZE   128

Definition at line 531 of file XimpParser.c.

#define MAXSTRLEN   100

Definition at line 241 of file XimpParser.c.

#define RIGHT_BRACKET   10

Definition at line 136 of file XimpParser.c.

#define RmBottom   (1 << 1)

Definition at line 90 of file XimpParser.c.

#define RmCenterOfScreen   (1 << 6)

Definition at line 94 of file XimpParser.c.

#define RmLeft   (1 << 2)

Definition at line 91 of file XimpParser.c.

#define RmOverTheSpot   (1 << 5)

Definition at line 93 of file XimpParser.c.

#define RmRight   (1 << 3)

Definition at line 92 of file XimpParser.c.

#define RmTop   (1 << 0)

Definition at line 89 of file XimpParser.c.

#define SEQUENCE_MAX   10

Definition at line 532 of file XimpParser.c.

#define STRING   7

Definition at line 133 of file XimpParser.c.

#define T_ACTIONS   106

Definition at line 145 of file XimpParser.c.

#define T_ATTRIBUTES   104

Definition at line 143 of file XimpParser.c.

#define T_CODE_INPUT_STATE   115

Definition at line 154 of file XimpParser.c.

#define T_COMPOSE_STATE   114

Definition at line 153 of file XimpParser.c.

#define T_DO_CONV   108

Definition at line 147 of file XimpParser.c.

#define T_END_ACTIONS   107

Definition at line 146 of file XimpParser.c.

#define T_END_ATTRIBUTES   105

Definition at line 144 of file XimpParser.c.

#define T_END_STATE   102

Definition at line 141 of file XimpParser.c.

#define T_LANGUAGE   152

Definition at line 158 of file XimpParser.c.

#define T_LAST_PAGE   112

Definition at line 151 of file XimpParser.c.

#define T_LOOKUP_STATE   116

Definition at line 155 of file XimpParser.c.

#define T_NEXT_PAGE   109

Definition at line 148 of file XimpParser.c.

#define T_PREV_PAGE   110

Definition at line 149 of file XimpParser.c.

#define T_REMOTE_IM_STATE   151 /* Added for remote IM */

Definition at line 157 of file XimpParser.c.

#define T_STATE   101

Definition at line 140 of file XimpParser.c.

#define T_STATE_TYPE   113

Definition at line 152 of file XimpParser.c.

#define T_SWITCH_STATE_TO   103

Definition at line 142 of file XimpParser.c.

#define T_TABLELOOKUP   117

Definition at line 156 of file XimpParser.c.

#define T_TOP_PAGE   111

Definition at line 150 of file XimpParser.c.

#define TILDE   6

Definition at line 132 of file XimpParser.c.


Enumeration Type Documentation

enum AttribType
Enumerator:
StringAttr 
IntegerAttr 
LiteralAttr 

Definition at line 216 of file XimpParser.c.

Enumerator:
RmScreen 
RmClient 
RmCursor 
RmSpotLocation 

Definition at line 96 of file XimpParser.c.

             {
    RmScreen         = 107,
    RmClient         = 108,
    RmCursor         = 109,
    RmSpotLocation      = 110 
} RmWindowPosition;

Function Documentation

static int check_quoted_string ( FILE *  fp) [static]

Definition at line 286 of file XimpParser.c.

{
    int i, j;
    char      *p;
    int              c;
    int              token;

    p = tokenbuf;
    while ((c = nextch(fp)) != '"') {
        if (c == '\n' || c == EOF) {
           putbackch(c);
           token = ERROR;
           goto string_error;
        } else if (c == '\\') {
           c = nextch(fp);
           switch (c) {
             case '\\':
             case '"':
               *p++ = c;
               break;
             case '0':
             case '1':
             case '2':
             case '3':
             case '4':
             case '5':
             case '6':
             case '7':
               i = c - '0';
               c = nextch(fp);
               for (j = 0; j < 2 && c >= '0' && c <= '7'; j++) {
                     i <<= 3;
                     i += c - '0';
                     c = nextch(fp);
               }
               putbackch(c);
               *p++ = (char)i;
               break;
             case 'X':
             case 'x':
               i = 0;
               c = nextch(fp);
#define ishexch(c) (((c) >= '0' && (c) <= '9') || \
                  ((c) >= 'A' && (c) <= 'F') || \
                  ((c) >= 'a' && (c) <= 'f'))
               for (j = 0; j < 2 && ishexch(c); j++) {
                     i <<= 4;
                     if (c >= '0' && c <= '9') {
                         i += c - '0';
                     } else if (c >= 'A' && c <= 'F') {
                         i += c - 'A' + 10;
                     } else {
                         i += c - 'a' + 10;
                     }
                     c = nextch(fp);
               }
               if (j == 0) {
                      token = ERROR;
                      goto string_error;
               }
               putbackch(c);
               *p++ = (char)i;
#undef ishexch
               break;
             case '\n':
             case EOF:
               putbackch(c);
               token = ERROR;
               goto string_error;
               /* break; */
             default:
               *p++ = c;
               break;
           }
       } else {
              *p++ = c;
       }
    }

    *p = '\0';
    token = STRING;

string_error:
    return (token);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static LocalIMState* create_state ( Ximp_XIM  xim,
char *  name 
) [static]

Definition at line 535 of file XimpParser.c.

{
    XimCommon im = (XimCommon)xim;
    LocalIMState  *tmps = im->local_impart->top_state;
    LocalIMState  *lasts = 0;

    while(tmps) {
       if(!strcmp(tmps->name, tokenbuf)) {
              return 0;
       }
       lasts = tmps;
       tmps = tmps->next;
    }

    tmps = (LocalIMState*)Xmalloc(sizeof(LocalIMState));
    memset(tmps, 0, sizeof(LocalIMState));
    tmps->name = (char*)Xmalloc(strlen(name) +1);
    tmps->type = ComposeState;
    strcpy(tmps->name, name);

    if(!lasts)
       im->local_impart->top_state = tmps;
    else
       lasts->next = tmps;
              
    return (tmps);
}

Here is the caller graph for this function:

static int get_attributetoken ( char *  w) [static]

Definition at line 392 of file XimpParser.c.

{
    AttribKeyWordRec *k = attr_tbl;

    if(w == 0 || *w == 0)
       return (-1);

    for ( ; k->name; k++) {
       if(!strcmp(k->name, w)) {
              return (k->val);
       }      
    }

    return (-1);
}

Here is the caller graph for this function:

static int get_statetoken ( char *  w) [static]

Definition at line 374 of file XimpParser.c.

{
    StateKeyWordRec  *k = keyword_tbl;

    if(w == 0 || *w == 0)
       return (-1);

    for ( ; k->name; k++) {
       if(!strcmp(k->name, w)) {
              return (k->val);
       }      
    }

    return (-1);
}

Here is the caller graph for this function:

static long modmask ( char *  name) [static]

Definition at line 498 of file XimpParser.c.

{
    long mask;

    struct _modtbl {
       char *name;
       long mask;
    };
    struct _modtbl *p;

    static struct _modtbl tbl[] = {
       { "Ctrl",     ControlMask   },
        { "Lock",    LockMask      },
        { "Caps",    LockMask      },
        { "Shift",   ShiftMask     },
        { "Alt",     Mod1Mask      },
        { "Meta",    Mod1Mask      },
        { "AltGraph",       Mod2Mask      },
        { NULL,             0             }};

    p = tbl;
    mask = 0;
    for (p = tbl; p->name != NULL; p++) {
       if (strcmp(name, p->name) == 0) {
           mask = p->mask;
           break;
       }
    }
    return(mask);
}

Here is the caller graph for this function:

static StateAttrib* new_attribute ( ) [static]

Definition at line 566 of file XimpParser.c.

{
       return (StateAttrib *)Xmalloc(sizeof(StateAttrib));
}

Here is the caller graph for this function:

static int nextch ( FILE *  fp) [static]

Definition at line 246 of file XimpParser.c.

{
    int c;

    if (lastch != 0) {
       c = lastch;
       lastch = 0;
    } else {
       c = getc(fp);
       if (c == '\\') {
           c = getc(fp);
           if (c == '\n') {
              c = getc(fp);
           } else {
              ungetc(c, fp);
              c = '\\';
           }
       }
    }
    return(c);
}

Here is the caller graph for this function:

static int nexttoken ( FILE *  fp) [static]

Definition at line 410 of file XimpParser.c.

{
    int c;
    int token, state_token, attr_token;
    char *p;

    while ((c = nextch(fp)) == ' ' || c == '\t') {
    }
    switch (c) {
      case EOF:
       token = ENDOFFILE;
       break;
      case '\n':
       token = ENDOFLINE;
       break;
      case '<':
       token = LESS;
       break;
      case '[':
       token = LEFT_BRACKET;
       break;
      case ']':
       token = RIGHT_BRACKET;
       break;
      case '>':
       token = GREATER;
       break;
      case ':':
       token = COLON;
       break;
      case '!':
       token = EXCLAM;
       break;
      case '~':
       token = TILDE;
       break;
      case '"':
       token = check_quoted_string(fp);
       break;
      case '#':
       p = tokenbuf;
       *p++ = c;
       c = nextch(fp);
       while (isalnum(c) || c == ' ') {
           *p++ = c;
           c = nextch(fp);
       }
       *p = '\0';
       putbackch(c);
       if((state_token = get_statetoken(tokenbuf)) > 0) {
           return (state_token);

       } else {
           while ((c = nextch(fp)) != '\n' && c != EOF) {
           }
           if (c == '\n') {
              token = ENDOFLINE;
           } else {
              token = ENDOFFILE;
           }
        }
       break;
      default:
       if (isalnum(c) || c == '_' || c == '-') {
           p = tokenbuf;
           *p++ = c;
           c = nextch(fp);
           while (isalnum(c) || c == '_' || c == '-') {
              *p++ = c;
              c = nextch(fp);
           }
           *p = '\0';
           putbackch(c);
           token = KEY;
           if((state_token = get_statetoken(tokenbuf)) > 0)
              return (state_token);
            if((attr_token = get_attributetoken(tokenbuf)) > 0)
                return (attr_token);
       } else {
           token = ERROR;
       }
       break;
    }
    return(token);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int parseline ( FILE *  fp,
XimCommon  im,
LocalIMState **  state 
) [static]

Definition at line 572 of file XimpParser.c.

{
    int token, prev_token;
    unsigned modifier_mask;
    unsigned modifier;
    unsigned tmp;
    KeySym keysym;
    DefTree *p = NULL;
    Bool exclam, tilde;
    KeySym rhs_keysym =  (KeySym)NoSymbol;
    char *rhs_string_mb = NULL;
    DefTree   **top;
    char *rhs_target_name = NULL, *ret;
    char *range_name = NULL;

    struct DefBuffer {
       unsigned modifier_mask;
       unsigned modifier;
       KeySym keysym;
       int keycode;
    };

    struct DefBuffer buf[SEQUENCE_MAX];
    int i, n;

    ActionType act = NoAction;

    do {
       token = nexttoken(fp);
    } while (token == ENDOFLINE);
    
    if (token == ENDOFFILE) {
       return(-1);
    }

    switch (token) {
       case T_STATE: {      /* begin state */
              if(*state)
                     goto error;

              token = nexttoken(fp);
              if(token != STRING)
                     goto error;

              *state = create_state((Ximp_XIM)im, tokenbuf);
              if(!(*state))
                     goto error;
              return (0);
               /* break; */
       }
       case T_END_STATE:
              if(!(*state))
                     goto error;
              *state = 0;
              return(0);
               /* break; */
       case T_ATTRIBUTES:
              if(!(*state) || (*state)->attrflag) 
                     goto error;
              (*state)->attr = new_attribute();
              if ( (*state)->attr == NULL ) goto error;
              memset((*state)->attr, 0, sizeof(StateAttrib));
              (*state)->attrflag = True;
                return(0);
               /* break; */
       case T_END_ATTRIBUTES:
              if(!(*state) || !(*state)->attrflag) 
                     goto error;
              (*state)->attrflag = False;
                return(0);
               /* break; */
       case T_ACTIONS:
              if(!(*state) || (*state)->actionflag) 
                     goto error;
              (*state)->actionflag = True;
                return(0);
               /* break; */
       case T_END_ACTIONS:
              if(!(*state) || !(*state)->actionflag) 
                     goto error;
              (*state)->actionflag = False;
                return(0);
               /* break; */
       case T_STATE_TYPE:
              if(!(*state)) 
                     goto error;

              token = nexttoken(fp);
              if(token != COLON)
                 goto error;

              token = nexttoken(fp);
              if (token == T_LOOKUP_STATE) {
                     (*state)->type = LookupState;
              } else if (token == T_CODE_INPUT_STATE) {
                     (*state)->type = CodeInputState;
              } else if (token == T_REMOTE_IM_STATE) {
                     (*state)->type = RemoteIMState;
              }
                return(0);
               /* break; */
       case T_LANGUAGE:
              if(!(*state)) 
                     goto error;

              token = nexttoken(fp);
              if(token != COLON)
                 goto error;

              token = nexttoken(fp);
              if (( (*state)->language = (char *)Xmalloc(strlen(tokenbuf)+1)) == NULL)
                 goto error;
              memset((*state)->language, 0, strlen(tokenbuf)+1);
              strcpy((*state)->language, tokenbuf);
              return(0);
           /* break; */
       default:
              break;
    }

    n = 0;
    prev_token = 0;
    do {
       if ((token == KEY) && (strcmp("None", tokenbuf) == 0)) {
           modifier = 0;
           modifier_mask = AllMask;
           token = nexttoken(fp);
       } else if (token > ATTRIBUTE_TOKEN) {
            if ( ! (*state)->attrflag ) goto error;
           prev_token = token;
           token = nexttoken(fp);
           continue;
        } else if ( token == STRING ){
            if ( ! (*state)->attrflag ) goto error;

           if ((range_name = (char*)Xmalloc(strlen(tokenbuf) + 1)) == NULL )
              goto error;
           memset(range_name, 0, strlen(tokenbuf)+1);
           strcpy(range_name, tokenbuf);
           prev_token = A_CODE_RANGE;
           token = nexttoken(fp);
           continue;
       } else {
           modifier = 0;
           modifier_mask = AllMask;
           exclam = False;
           if (token == EXCLAM) {
              exclam = True;
              token = nexttoken(fp);
           }
           while (token == TILDE || token == KEY) {
              tilde = False;
              if (token == TILDE) {
                  token = nexttoken(fp);
                  tilde = True;
                  if (token != KEY)
                     goto error;
              }
              token = nexttoken(fp);
              tmp = modmask(tokenbuf);
              if (!tmp) {
                  goto error;
              }
              modifier_mask |= tmp;
              if (tilde) {
                  modifier &= ~tmp;
              } else {
                  modifier |= tmp;
              }
           }
           if (exclam) {
              modifier_mask = AllMask;
           }
       }

       if (token != LESS && token != LEFT_BRACKET) {
           goto error;
       }
       prev_token = token;

       token = nexttoken(fp);
       if (token != KEY) {
           goto error;
       }

       token = nexttoken(fp);
       if (!(prev_token == LESS && token == GREATER)
           && !(prev_token == LEFT_BRACKET && token == RIGHT_BRACKET)) {
           goto error;
       }

       if (prev_token == LESS) {
           keysym = XStringToKeysym(tokenbuf);
           if (keysym == NoSymbol) {
              goto error;
           }
           buf[n].keysym = keysym;
           buf[n].keycode = 0;     /* default */
           buf[n].modifier = modifier;
           buf[n].modifier_mask = modifier_mask;
           n++;
           if( n >= SEQUENCE_MAX )
              goto error;
       } else /* PREV_TOKEN == LEFT_BRACKET */ {
           int keycode = atoi(tokenbuf);
           if (n < 1) goto error; /* hopefully never happened */
           buf[n - 1].keycode = keycode;
           SET_KEYCODEINFO(*state);
       }
       token = nexttoken(fp);
    } while (token != COLON);

    token = nexttoken(fp);
    if ( prev_token > ATTRIBUTE_TOKEN ) {
       switch ((*state)->type) {
       case CodeInputState:
         if ( (*state)->attr == NULL ) goto error;
         switch (prev_token) {
         case A_MAX_INPUT_LENGTH:
           (*state)->attr->_attr_u.CIstruct.max_input_len = atoi(tokenbuf);
           return(0);
           /* break; */
         case A_TYPE_OF_INPUT:
           if ( !strcmp(tokenbuf, "HEX") ) {
             (*state)->attr->_attr_u.CIstruct.type_of_input = HEX;
           } else if ( !strcmp(tokenbuf, "OCTET") ) {
             (*state)->attr->_attr_u.CIstruct.type_of_input = OCTET;
           } else goto error;
           return(0);
           /* break; */
         default:
           goto error;
           /* break; */
         }
         /* break; */
       case LookupState:
         if ( (*state)->attr == NULL ) goto error;
         switch ( prev_token ) {
         case A_MAX_NUMBER_OF_ROWS:
           (*state)->attr->_attr_u.LUstruct.num_of_rows = atoi(tokenbuf);
           return(0);
           /* break; */
         case A_MAX_NUMBER_OF_COLUMNS:
           (*state)->attr->_attr_u.LUstruct.num_of_cols = atoi(tokenbuf);
           return(0);
           /* break; */
         case A_MAX_NUMBER_OF_CANDIDATES:
           (*state)->attr->_attr_u.LUstruct.num_of_cands = atoi(tokenbuf);
           return(0);
           /* break; */
         case A_CODE_RANGE:
           {
             LuRange *rangep = (*state)->attr->_attr_u.LUstruct.range;
             int nrange = (*state)->attr->_attr_u.LUstruct.nrange;

             if (rangep == NULL )
              rangep = (LuRange *)Xmalloc(sizeof(LuRange));
             else
              rangep = (LuRange *)Xrealloc(rangep,
                                        sizeof(LuRange)* (nrange + 1));
             rangep[nrange].start_range = strtol(tokenbuf, &ret, 0);
             token = nexttoken(fp);
             rangep[nrange].end_range = strtol(tokenbuf, &ret, 0);
             memset(rangep[nrange].RangeName, 0, sizeof(char) * 80);
             strcpy(rangep[nrange].RangeName, range_name);
             (*state)->attr->_attr_u.LUstruct.nrange++;
             (*state)->attr->_attr_u.LUstruct.range = rangep;
             Xfree(range_name);
             return(0);
             /* break; */
           }
         case A_TITLE_STRING:
           (*state)->attr->_attr_u.LUstruct.title = (char *)Xmalloc(strlen(tokenbuf)+1);
           strcpy((*state)->attr->_attr_u.LUstruct.title, tokenbuf);
           return(0);
           /* break; */
         case A_FONTSET:
           return(0);
           /* break; */
         case A_PLACEMENT:
           return(0);
           /* break; */
         case A_POSITION:
           return(0);
           /* break; */
         default:
           goto error;
           /* break; */
         }
         /* break; */
       default:
         goto error;
         /* break; */
       }
    } else if (token == STRING) {
       if( (rhs_string_mb = Xmalloc(strlen(tokenbuf) + 1)) == NULL )
           goto error;
       memset(rhs_string_mb, 0, strlen(tokenbuf)+1);
       strcpy(rhs_string_mb, tokenbuf);
       token = nexttoken(fp);
       if (token == KEY) {
           rhs_keysym = XStringToKeysym(tokenbuf);
           if (rhs_keysym == NoSymbol) {
              Xfree(rhs_string_mb);
              rhs_string_mb = NULL;
              goto error;
           }
           token = nexttoken(fp);
       }
       if (token != ENDOFLINE && token != ENDOFFILE) {
           Xfree(rhs_string_mb);
           rhs_string_mb = NULL;
           goto error;
       }
    } else if (token == KEY) {
       rhs_keysym = XStringToKeysym(tokenbuf);
       if (rhs_keysym == NoSymbol) {
           goto error;
       }
       token = nexttoken(fp);
       if (token != ENDOFLINE && token != ENDOFFILE) {
           goto error;
       }
       if( (rhs_string_mb = Xmalloc(1)) == NULL ) {
           goto error;
       }
       memset(rhs_string_mb, 0, 1);
    } else if (token == T_SWITCH_STATE_TO) {
       token = nexttoken(fp);
       if(token == STRING) {
           if((rhs_target_name = Xmalloc(strlen(tokenbuf) + 1)) == NULL){
              goto error;
           }
           memset(rhs_target_name, 0, strlen(tokenbuf)+1);
           strcpy(rhs_target_name, tokenbuf);
           act = SwitchTo;
       } else {
              goto error;
       }
    } else if (token == T_DO_CONV) {
       act = DoConv;
    } else if (token == T_TABLELOOKUP) {
       act = DoLookup;
    } else if (token == T_NEXT_PAGE) {
       act = NextPage;
    } else if (token == T_PREV_PAGE) {
       act = PrevPage;
    } else if (token == T_TOP_PAGE) {
       act = TopPage;
    } else if (token == T_LAST_PAGE) {
       act = LastPage;
#ifdef USE_CAND_SELECTION
    } else if (token == T_NEXT_CAND) {
       act = NextCand;
    } else if (token == T_PREV_CAND) {
       act = PrevCand;
    } else if (token == T_UP_CAND) {
       act = UpCand;
    } else if (token == T_DOWN_CAND) {
       act = DownCand;
    } else if (token == T_SELECT_CAND) {
       act = SelectCand;
#endif
    } else {
       goto error;
    }

    if(!(*state)) {
       *state = create_state((Ximp_XIM)im, "");
       if(!(*state))
              goto error;
    }

    if ( n == 0 ) return(0);

    top = &((*state)->parser);

    for (i = 0; i < n; i++) {
       for (p = *top; p; p = p->next) {
           if (buf[i].keysym        == p->keysym &&
              buf[i].keycode       == p->keycode &&
              buf[i].modifier      == p->modifier &&
              buf[i].modifier_mask == p->modifier_mask) {
              break;
           }
       }
       if (p) {
           top = &p->succession;
       } else {
           if( (p = (DefTree*)Xmalloc(sizeof(DefTree))) == NULL ) {
              if ( rhs_string_mb ) Xfree( rhs_string_mb );
              rhs_string_mb = NULL;
              goto error;
           }
           memset(p, 0, sizeof(DefTree));
           p->keysym        = buf[i].keysym;
           p->keycode       = buf[i].keycode;
           p->modifier      = buf[i].modifier;
           p->modifier_mask = buf[i].modifier_mask;
           p->succession    = NULL;
           p->next          = *top;
           p->mb            = NULL;
           p->keysym_return = NoSymbol;
           p->action      = NoAction;
           p->target_name   = NULL;
           p->target      = NULL;
           *top = p;
           top = &p->succession;
       }
    }

    if( p->mb != NULL ) {
       Xfree( p->mb );
       p->mb = NULL;
    }
    if( p->target_name != NULL ) {
       Xfree( p->target_name );
       p->target_name = NULL;
    }
    if( p->target != NULL ) {
       Xfree( p->target );
       p->target = NULL;
    }

    p->action = act;

    if(rhs_target_name == NULL){
       p->mb = NULL;
       if (p->action == SwitchTo) {
           if ( rhs_string_mb ) Xfree(rhs_string_mb);
       } else {
           if ( rhs_string_mb ) {
              p->mb = rhs_string_mb;
           }
           p->keysym_return = rhs_keysym;
       }
    } else{
       p->target_name = rhs_target_name;
    }
    return(n);

error:
    while (token != ENDOFLINE && token != ENDOFFILE) {
       token = nexttoken(fp);
    }
    return(0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void putbackch ( int  c) [static]

Definition at line 270 of file XimpParser.c.

{
    lastch = c;
}

Here is the caller graph for this function:

static int set_change_state_info ( Ximp_XIM  xim,
DefTree p 
) [static]

Definition at line 1024 of file XimpParser.c.

{
    XimCommon im = (XimCommon)xim;
    LocalIMState     *state;

    /* next */
    if (p->next) {
      if (set_change_state_info((Ximp_XIM)im, p->next) == -1)
       return -1;
    }

    /* succession */
    if (p->succession)
      return set_change_state_info((Ximp_XIM)im, p->succession);

    /* self */
    if (p->target_name == NULL)
      return 0;

    state = im->local_impart->top_state;

    while(state) {
      if (!strcmp(state->name, p->target_name)){
       p->target = state;
       break;
      }
      state = state->next;
    }
    if (state != NULL)
      return 0;
    else
      return -1;
}

Here is the caller graph for this function:

int Ximp_ParseStringFile ( FILE *  fp,
XimCommon  im 
)

Definition at line 1061 of file XimpParser.c.

{
    int max_ev_seq = 0, i;
    LocalIMState *state = 0;

    memset(tokenbuf, 0, sizeof(tokenbuf));
    while ((i = parseline(fp, im, &state)) >= 0) {
       if (i > max_ev_seq) max_ev_seq = i;
    }

    state = im->local_impart->top_state;
    while(state) {
      if (set_change_state_info((Ximp_XIM)im, state->parser) == -1)
       return (-1);
      state = state->next;
    }

    return (max_ev_seq);
}

Here is the call graph for this function:


Variable Documentation

Initial value:
 {
    {"MAX_INPUT_LENGTH", A_MAX_INPUT_LENGTH, IntegerAttr},
    {"TYPE_OF_INPUT", A_TYPE_OF_INPUT, LiteralAttr},
    {"MAX_NUMBER_OF_ROWS", A_MAX_NUMBER_OF_ROWS, IntegerAttr},
    {"MAX_NUMBER_OF_COLUMNS", A_MAX_NUMBER_OF_COLUMNS, IntegerAttr},
    {"MAX_NUMBER_OF_CANDIDATES", A_MAX_NUMBER_OF_CANDIDATES},
    {"TITLE_STRING", A_TITLE_STRING, StringAttr},
    {"FONTSET", A_FONTSET, StringAttr},
    {"POSITION", A_POSITION, LiteralAttr},
    {"PLACEMENT", A_PLACEMENT, LiteralAttr},
    {NULL, 0, 0}
}

Definition at line 228 of file XimpParser.c.

Initial value:
 {
    {"STATE", T_STATE},
    {"END_STATE", T_END_STATE},
    {"STATE_TYPE", T_STATE_TYPE},
    {"SWITCH_STATE_TO", T_SWITCH_STATE_TO},
    {"#attributes", T_ATTRIBUTES},
    {"#end of attributes", T_END_ATTRIBUTES},
    {"#actions", T_ACTIONS},
    {"#end of actions", T_END_ACTIONS},
    {"DO_CONV", T_DO_CONV},
    {"NEXT_PAGE", T_NEXT_PAGE},
    {"PREV_PAGE", T_PREV_PAGE},
    {"TOP_PAGE", T_TOP_PAGE},
    {"LAST_PAGE", T_LAST_PAGE},







    {"COMPOSE", T_COMPOSE_STATE},
    {"LOOKUP", T_LOOKUP_STATE},
    {"DO_LOOKUP", T_TABLELOOKUP},
    {"CODE_INPUT", T_CODE_INPUT_STATE},
    {"REMOTE_IM", T_REMOTE_IM_STATE},
    {"LANGUAGE", T_LANGUAGE},
    {NULL, 0}
}

Definition at line 186 of file XimpParser.c.

int lastch = 0 [static]

Definition at line 243 of file XimpParser.c.

char tokenbuf[MAXSTRLEN] [static]

Definition at line 283 of file XimpParser.c.