Back to index

im-sdk  12.3.91
Defines | Functions | Variables
iiimpIM.c File Reference
#include "iiimpIM.h"
#include "iiimpIC.h"
#include "iiimpAuxP.h"
#include <stdio.h>
#include <unistd.h>
#include <locale.h>
#include <langinfo.h>
#include <ctype.h>
#include "trace_message.h"
#include "iiimpSwitcher.h"
#include "XIM.h"

Go to the source code of this file.

Defines

#define IMLIBDIR   IIIMLIBDIR
#define iscomment(ch)   ((ch) == '\0' || (ch) == '#')
#define MODIFIER   "@im="

Functions

Status IIIMP_OpenIM_SWITCH (XIM xim, XLCd lcd, Display *dpy)
static Status IIIMP_CloseIM (XIM xim)
char * IIIMP_SetIMValues (XIM xim, XIMArg *arg)
char * IIIMP_GetIMValues (XIM xim, XIMArg *arg)
static XIC IIIMP_CreateIC (XIM xim, XIMArg *arg)
int _Ximp_ctstombs (XIM xim, char *from, int from_len, char *to, int to_len, Status *state)
int _Ximp_ctstowcs (XIM xim, char *from, int from_len, wchar_t *to, int to_len, Status *state)
IIIMF_status IMCreateHandle (XimCommon im)
static XIMMethods get_iiimp_im_methods ()
static Status SWITCH_CloseIM (XIM xim)
static XIMMethods get_switch_im_methods ()
static int parseLine (char *line, char **argv, size_t argsize)
static void parseAliasFile (XimCommon im, FILE *fp)
static void free_langalias (XimCommon im)
static char * getIMLangName (XimCommon im, const char *src_name)
char * im_canonicalize_langname (XimCommon im)
IIIMCF_language get_IM_language (XimCommon im)
static void initialize ()
static void uninitialize ()
void UpdateIMCharacterSubset (XimCommon)
XIM _IIIMP_OpenIM (XLCd lcd, Display *dpy, XrmDatabase rdb, char *res_name, char *res_class)
Bool _XInitIIIMP (XLCd lcd)

Variables

static XIMStyle im_styles []
static im_locale_pair g_locale_list []
static int inited = 0

Define Documentation

#define IMLIBDIR   IIIMLIBDIR

Definition at line 191 of file iiimpIM.c.

#define iscomment (   ch)    ((ch) == '\0' || (ch) == '#')

Definition at line 193 of file iiimpIM.c.

#define MODIFIER   "@im="

Function Documentation

XIM _IIIMP_OpenIM ( XLCd  lcd,
Display *  dpy,
XrmDatabase  rdb,
char *  res_name,
char *  res_class 
)

Definition at line 593 of file iiimpIM.c.

{
    XimCommon im = 0;

    im = Xmalloc(sizeof(XimCommonRec));
    if (!im) goto Set_Error;
    memset(im, 0, sizeof(XimCommonRec));

    if (!CommonOpenIM((XIM)im, lcd, dpy, rdb, res_name, res_class))
       goto Set_Error;

    im->methods = get_iiimp_im_methods();

    if (!IIIMP_OpenIM_SWITCH((XIM)im, lcd, dpy)) goto Set_Error;
    return (XIM)im;

Set_Error:
    if (im) Xfree(im);
    return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int _Ximp_ctstombs ( XIM  xim,
char *  from,
int  from_len,
char *  to,
int  to_len,
Status *  state 
)

Definition at line 238 of file XimpConv.c.

{
    Ximp_XIM   im = (Ximp_XIM)xim;
    XlcConv    conv = im->ximp_impart->ctom_conv;
    int               from_left;
    int               to_left;
    int               from_savelen;
    int               to_savelen;
    int               from_cnvlen;
    int               to_cnvlen;
    char      *from_buf;
    char      *to_buf, *tmp_buf;
    Status     tmp_state;
  
    if (!state)
       state = &tmp_state;

    if (!conv || !from || !from_len) {
       *state = XLookupNone;
       return 0;
    }

    if (to && to_len) {
       from_left = from_len;
#ifdef sun
       to_left = to_len;
#else
       to_left = to_len - 1;
#endif
       from_cnvlen = 0;
       to_cnvlen = 0;
       for (;;) {
           from_savelen = from_left;
           to_savelen = to_left;
           from_buf = &from[from_cnvlen];
           to_buf = &to[to_cnvlen];
           if (_XlcConvert(conv, (XPointer *)&from_buf, &from_left,
                             (XPointer *)&to_buf, &to_left, NULL, 0) < 0) {
              *state = XLookupNone;
              return 0;
           }
           from_cnvlen += (from_savelen - from_left);
           to_cnvlen += (to_savelen - to_left);
           if (from_left == 0) {
              if (to_cnvlen > 0) {
#ifndef sun
                  to[to_cnvlen] = '\0';
#endif
                  *state = XLookupChars;
              } else {
                  *state = XLookupNone;
              }
              return to_cnvlen;
           }
           if (to_left == 0)
              break;
           /* Overflow : the to_left length is so small that it cannot 
              accomodate the first mb character in the next conversion block */
           if (to_left < MB_CUR_MAX)
              break;
       }
    }

    from_left = from_len;
    from_cnvlen = 0;
    to_cnvlen = 0;
    /* BugId : 4253988. In case the from_buf is bigger than the to_buffer,
       we need to return the required buffer size and status as XBufferOverflow.       We create a tmp buffer equals 8 times the from_len and do conversion.
    */ 
    to_left = (8 * from_len) ;
    tmp_buf = (char *)malloc(to_left);
    for (;;) {
       from_savelen = from_left;
       from_buf = &from[from_cnvlen];
       to_savelen = to_left;
       to_buf = &tmp_buf[to_cnvlen];
       if (_XlcConvert(conv, (XPointer *)&from_buf, &from_left,
                             (XPointer *)&to_buf, &to_left, NULL, 0) < 0) {
           *state = XLookupNone;
           return 0;
       }
       from_cnvlen += (from_savelen - from_left);
       to_cnvlen += (to_savelen - to_left);
       if (from_left == 0) {
           if (to_cnvlen > 0)
              *state = XBufferOverflow;
           else
              *state = XLookupNone;
           break;
       }
    }
    free(tmp_buf);
    return to_cnvlen;
}
int _Ximp_ctstowcs ( XIM  xim,
char *  from,
int  from_len,
wchar_t *  to,
int  to_len,
Status *  state 
)

Definition at line 340 of file XimpConv.c.

{
    Ximp_XIM   im = (Ximp_XIM)xim;
    XlcConv    conv = im->ximp_impart->ctow_conv;
    int               from_left;
    int               to_left;
    int               from_savelen;
    int               to_savelen;
    int               from_cnvlen;
    int               to_cnvlen;
    char      *from_buf;
    wchar_t   *to_buf, *tmp_buf;
    Status     tmp_state;

    if (!state)
       state = &tmp_state;

    if (!conv || !from || !from_len) {
       *state = XLookupNone;
       return 0;
    }

    if (to && to_len) {
       from_left = from_len;
#ifdef sun
       to_left = to_len;
#else
       to_left = to_len - 1;
#endif
       from_cnvlen = 0;
       to_cnvlen = 0;
       for (;;) {
           from_savelen = from_left;
           to_savelen = to_left;
           from_buf = &from[from_cnvlen];
           to_buf = &to[to_cnvlen];
           if (_XlcConvert(conv, (XPointer *)&from_buf, &from_left,
                             (XPointer *)&to_buf, &to_left, NULL, 0) < 0) {
              *state = XLookupNone;
              return 0;
           }
           from_cnvlen += (from_savelen - from_left);
           to_cnvlen += (to_savelen - to_left);
           if (from_left == 0) {
              if (to_cnvlen > 0) {
#ifndef sun
                  to[to_cnvlen] = (wchar_t)'\0';
#endif
                  *state = XLookupChars;
              } else {
                  *state = XLookupNone;
              }
              return to_cnvlen;
           }
           if (to_left == 0)
              break;
           /* Overflow : the to_left length is so small that it cannot 
              accomodate the first mb character in the next conversion block */
           if (to_left < sizeof(wchar_t)) {
              break;
           }
       }
    }
              
    from_left = from_len;
    from_cnvlen = 0;
    to_cnvlen = 0;
    /* BugId : 4253988. In case the from_buf is bigger than the to_buffer,
       we need to return the required buffer size and status as XBufferOverflow.       We create a tmp buffer equals 8 times the from_len and do conversion.
    */ 
    to_left = (8 * from_len) ;
    tmp_buf = (wchar_t *)malloc(to_left * sizeof(wchar_t));
    for (;;) {
       from_savelen = from_left;
       from_buf = &from[from_cnvlen];
       to_savelen = to_left;
       to_buf = &tmp_buf[to_cnvlen];
       if (_XlcConvert(conv, (XPointer *)&from_buf, &from_left,
                             (XPointer *)&to_buf, &to_left, NULL, 0) < 0) {
           *state = XLookupNone;
           return 0;
       }
       from_cnvlen += (from_savelen - from_left);
       to_cnvlen += (MAXINT - to_left);
       if (from_left == 0) {
           if (to_cnvlen > 0)
              *state = XBufferOverflow;
           else
              *state = XLookupNone;
           break;
       }
    }
    free(tmp_buf);
    return to_cnvlen;
}
Bool _XInitIIIMP ( XLCd  lcd)

Definition at line 743 of file iiimpIM.c.

{
    if (lcd == (XLCd)NULL)
       return False;

    lcd->methods->open_im = _IIIMP_OpenIM;
    lcd->methods->register_callback = NULL;
    lcd->methods->unregister_callback = NULL;

    return True;
}

Here is the call graph for this function:

static void free_langalias ( XimCommon  im) [static]

Definition at line 270 of file iiimpIM.c.

{
    im_locale_pair *p1, *p;

    p1 = XIM_IIIMP(im, lang_alias);
    if (p1) {
       for (p = p1; p->canonical; p++) {
           if (p->alias) Xfree(p->alias);
           if (p->canonical) Xfree(p->canonical);
       }
       Xfree(p1);
    }
}

Here is the caller graph for this function:

static XIMMethods get_iiimp_im_methods ( ) [static]

Definition at line 123 of file iiimpIM.c.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 354 of file iiimpIM.c.

{
    int i, n;
    const char *ll;
    char *lang;
    char *p;
    IIIMCF_language *plangs;
    IIIMF_status st;

    if (XIM_IIIMP(im, primary_locale)) {
       lang = strdup(XIM_IIIMP(im, primary_locale));
    } else {
       lang = im_canonicalize_langname(im);
    }

    if (!lang) return NULL;

    if (iiimcf_get_supported_languages(XIM_IIIMP(im, handle), &n, &plangs)
       != IIIMF_STATUS_SUCCESS)
       return NULL;
    for (i = 0; i < n; i++) {
       st = iiimcf_get_language_id(plangs[i], &ll);
       if (st != IIIMF_STATUS_SUCCESS)
           continue;
       if (strcmp(lang, ll) == 0) {
           free(lang);
           return plangs[i];
       }
    }
    /* try to find the supported language again with no charset locale. */
    p = strchr (lang, '@');
    if (p)
       *p = 0;
    p = strchr (lang, '.');
    if (p)
       *p = 0;

    for (i = 0; i < n; i++) {
       st = iiimcf_get_language_id(plangs[i], &ll);
       if (st != IIIMF_STATUS_SUCCESS)
           continue;
       if (strcmp(lang, ll) == 0) {
           free(lang);
           return plangs[i];
       }
    }
    /* finally try to take care of the locale, such as en */
    p = strchr (lang, '_');
    if (p)
       *p = 0;

    for (i = 0; i < n; i++) {
       st = iiimcf_get_language_id(plangs[i], &ll);
       if (st != IIIMF_STATUS_SUCCESS)
           continue;
       if (strcmp(lang, ll) == 0) {
           free(lang);
           return plangs[i];
       }
    }
    free(lang);

      /*
       still cannot find a match. Just take one for "en" as
       a default.
      */
    for (i = 0; i < n; i++) {
       st = iiimcf_get_language_id (plangs[i], &ll);
       if (st != IIIMF_STATUS_SUCCESS)
           continue;
       if (strncmp (ll, "en", 2) == 0)
           return plangs[i];
    }

    return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static XIMMethods get_switch_im_methods ( ) [static]

Definition at line 143 of file iiimpIM.c.

{
  static XIMMethodsRec imm;
  if (!imm.close) {
    imm.close = SWITCH_CloseIM;
  }
  return &imm;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static char* getIMLangName ( XimCommon  im,
const char *  src_name 
) [static]

Definition at line 287 of file iiimpIM.c.

{
    im_locale_pair *p;

    if (!XIM_IIIMP(im, lang_alias)) {
       /*  open 'alias' file*/
       FILE *fp;
       const char *dir = getenv ("IIIMFHOME");
       const char *base = "language.alias";

       if (dir == NULL)
           dir = IMLIBDIR;

       {
           size_t dir_len = strlen (dir);
           size_t base_len = strlen (base);
           size_t name_len = dir_len + 1 + base_len + 1;

           char *file_name = Xmalloc(name_len + 1);
           if (file_name) {
              strncpy(file_name, dir, dir_len);
              file_name[dir_len] = '/';
              file_name[dir_len + 1] = 0;
              strncat(file_name, base, base_len);
              file_name[dir_len + 1 + base_len] = 0;

              if ((fp = fopen (file_name, "r"))) {
                  parseAliasFile(im, fp);
                  fclose(fp);
              }
                Xfree(file_name);
           }
       }
    }

    p = (XIM_IIIMP(im, lang_alias) ? XIM_IIIMP(im, lang_alias) : g_locale_list);

    for (; p->canonical != 0; p++)
       if (!strcmp(p->alias, src_name))
           return p->canonical;

    return (char*)0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static Status IIIMP_CloseIM ( XIM  xim) [static]

Definition at line 457 of file iiimpIM.c.

{
    CommonCloseIM(xim);
    SWITCH_CloseIM(xim);
    
    return True;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static XIC IIIMP_CreateIC ( XIM  xim,
XIMArg arg 
) [static]

Definition at line 468 of file iiimpIM.c.

{
    return (XIC)CreateIC((XimCommon)xim, arg);
}

Here is the call graph for this function:

Here is the caller graph for this function:

char * IIIMP_GetIMValues ( XIM  xim,
XIMArg arg 
)

Definition at line 514 of file iiimpIM.c.

{
    XIMArg *p;
    int i;
    XimCommon im = (XimCommon)xim;

    if (!xim) return arg->name;    /* nothing to do */

    for (p = arg; p->name != NULL; p++) {
       TRACE_MESSAGE('v', ("  %s\n", p->name));
       if (!strcmp(p->name, XNQueryInputStyle)) {
           XIMStyles **value;
           XIMStyles *styles;
           size_t count = sizeof(im_styles)/sizeof(im_styles[0]);
           if ((styles = (XIMStyles*)
               Xmalloc(sizeof(XIMStyles) +
                      sizeof(XIMStyle) * count)) == NULL) {
              break;
           }
           styles->count_styles = count;
           styles->supported_styles = (XIMStyle *)(&styles[1]);

           for (i = 0; i < (int)(styles->count_styles); i++) {
              styles->supported_styles[i] = im_styles[i];
           }
           value = (XIMStyles **)p->value;
           *value = styles;
       } else if (!strcmp(p->name, XNMultiLingualInput)) {
           *((Bool*)(p->value)) = ((XimCommon)xim)->isUnicode;
       } else if (!strcmp(p->name, XNQueryExtensionVersion)) {
           *((int*)(p->value)) = XIIIMP_MULTILINGUAL_EXTENSION_VERSION;
       } else if (!strcmp(p->name, XNQueryUnicodeCharacterSubset)) {
           XIMUnicodeCharacterSubsets **value;
           XIMUnicodeCharacterSubsets *sub_sets;
           XIMUnicodeCharacterSubsets *im_subset;
           size_t count = 0;

           /* 
              when GIMLET is present, we don't let applications
              have their own choice windows, based on XLC_LOCALE
           */
           if (im_switcher_active(im))
             return p->name;

           /* RECONSIDER!!! */
           UpdateIMCharacterSubset(im);

           if (!im->unicode_char_subsets) break;

           im_subset = im->unicode_char_subsets;

           count = im_subset->count_subsets;

           if ((sub_sets = (XIMUnicodeCharacterSubsets*)
               Xmalloc(sizeof(XIMUnicodeCharacterSubsets) +
                      sizeof(XIMUnicodeCharacterSubset) * count)) == NULL) {
              break;
           }
           sub_sets->count_subsets = count;
           sub_sets->supported_subsets =
              (XIMUnicodeCharacterSubset*)(&sub_sets[1]);

           for (i = 0; i < (int)(sub_sets->count_subsets); i++) {
              sub_sets->supported_subsets[i] = im_subset->supported_subsets[i];
           }
           value = (XIMUnicodeCharacterSubsets **)p->value;
           *value = sub_sets;
      
       } else {
           break;
       }
    }
    return p->name;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Status IIIMP_OpenIM_SWITCH ( XIM  xim,
XLCd  lcd,
Display *  dpy 
)

Definition at line 621 of file iiimpIM.c.

{
    XimCommon im = (XimCommon)xim;
    XIMIIimpIM im_private = 0;
    char *mod, buf[BUFSIZE];
    int mod_len;

    initialize();

    im_private = Xmalloc(sizeof(XIMIIimpIMRec));
    if (!im_private) goto Set_Error;
    memset(im_private, 0, sizeof (XIMIIimpIMRec));
    im->iiimp_impart = im_private;

    XIM_IIIMP(im, cb_window) = None;
    XIM_IIIMP(im, switch_methods) = get_switch_im_methods();

    buf[0] = '\0';
    mod_len = 0;

    im->core.im_name = 0;
    if ((lcd->core->modifiers) && (*lcd->core->modifiers)) {
#define       MODIFIER "@im="
       mod = strstr(lcd->core->modifiers, MODIFIER);
       if (mod) {
           mod += strlen(MODIFIER);

           if (!strncmp(mod, "iiimp/", 6) || !strncmp(mod, "IIIMP/", 6)) {
              mod += 6;

              if (index(mod, ':')) {
                  while (*mod && *mod != '@' && mod_len < BUFSIZE - 1) {
                     buf[mod_len++] = *mod++;
                  }
                  buf[mod_len] = '\0';
                  im->core.im_name = Xmalloc(mod_len+1);
                  if (!im->core.im_name) goto Set_Error;

                  strcpy(im->core.im_name, buf);
              }
           }
       }
#undef MODIFIER
    }

    if (IMCreateHandle(im) != IIIMF_STATUS_SUCCESS)
       goto Set_Error;


#if 0 /* The following is required for asych. message handling.  */
    XIM_IIIMP(im, cb_window) =
       XCreateSimpleWindow(im->core.display,
                         DefaultRootWindow(im->core.display),
                         0, 0, 1, 1, 0, 0, 0);
    if (None != XIM_IIIMP(im, cb_window)) {
       _XRegisterFilterByType(im->core.display, XIM_IIIMP(im, cb_window),
                            ClientMessage, ClientMessage,
                            IMCBFilter, (XPointer)im);
    }
#endif

    return True;

Set_Error:
    if (im_private) {
       Xfree(im_private);
       im->iiimp_impart = NULL;
    }
    IIIMP_CloseIM((XIM)im);
    return False;
}

Here is the call graph for this function:

Here is the caller graph for this function:

char * IIIMP_SetIMValues ( XIM  xim,
XIMArg arg 
)

Definition at line 477 of file iiimpIM.c.

{
    XIMArg *p;
    char *return_name = NULL;
    XimCommon im = (XimCommon)xim;

    if (!xim) return arg->name;    /* nothing to do */

    for (p = arg; p->name != NULL; p++) {
       if (!strcmp(p->name, "engineInterfaceName")) {
           XIM_IIIMP(im, engine_name) = (char*)p->value;
       } else if (!strcmp(p->name, "applicationType")) {
           IMChangeClientType(im, (char*) p->value);
       } else if (!strcmp(p->name, "defaultFontName")) {
           XIM_IIIMP(im, default_font_name) = (char*)p->value;
       } else if (!strcmp(p->name, "primaryLocale")) {
           XIM_IIIMP(im, primary_locale) = (char*)p->value;
       } else if (!strcmp(p->name, XNDestroyCallback)) {
           im->core.destroy_callback.client_data = 
              ((XIMCallback *)p->value)->client_data;
           im->core.destroy_callback.callback = 
              ((XIMCallback *)p->value)->callback;
       } else {
           return_name = arg->name;
           break;
       }
    }

    return return_name;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 335 of file iiimpIM.c.

{
    char *canonical, *p;
    const char *localename = setlocale(LC_CTYPE, NULL);

    canonical = getIMLangName(im, localename);
    if (canonical) return strdup(canonical);

    canonical = strdup(localename);
    if (!canonical) return NULL;
    p = strchr(canonical, '.');
    if (p) *p = '\0';

    return canonical;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 689 of file iiimcfFun.c.

{
    IIIMF_status st;
    IIIMCF_attr attr;
    char *address, *service;
    Atom iiimd;
    Window iiimx;
    Atom type;
    int format;
    unsigned long length;
    unsigned long nitem;
    unsigned char *prop;

    address = NULL;
    service = NULL;
    prop = NULL;

    st = iiimcf_create_attr(&attr);
    if (st != IIIMF_STATUS_SUCCESS) return st;
    if (!XIM_IIIMP(im, client_type)) {
       XIM_IIIMP(im, client_type) = IIIMP_CLIENT_TYPE; /* default */
    }
    st = iiimcf_attr_put_string_value(attr, IIIMCF_ATTR_CLIENT_TYPE,
                                  XIM_IIIMP(im, client_type));
    if (st != IIIMF_STATUS_SUCCESS) goto cleanup;
    if (im->core.display) {
       Display *dpy = im->core.display;

       st = iiimcf_attr_put_string_value(attr, IIIMCF_ATTR_CLIENT_X_DISPLAY_NAME,
                                     XDisplayString(dpy));
       if (st != IIIMF_STATUS_SUCCESS) goto cleanup;
       st = iiimcf_attr_put_string_value(attr, IIIMCF_ATTR_CLIENT_X_SERVER_VENDOR,
                                     XServerVendor(dpy));
       if (st != IIIMF_STATUS_SUCCESS) goto cleanup;
    }

    if (NULL != im->core.display) {
       iiimd = XInternAtom (im->core.display, "IIIM_SERVER", True);
       if (None != iiimd) {
           iiimx = XGetSelectionOwner (im->core.display, iiimd);
       } else {
           iiimx = None;
       }
       if (None != iiimx) {
           XGetWindowProperty(im->core.display, iiimx, iiimd,
                            0, INT_MAX, False, XA_STRING,
                            &type, &format, &nitem, &length, &prop);
           if (NULL == prop) {
           } else if (0 == strncmp("uds:", (char *)prop, 4)) {
              address = strdup((prop + 4));
              service = "";
              if (NULL == address) goto cleanup;
           } else {
           }
       }
    }
    if ((NULL == address) && (im->core.im_name)) {
       address = strdup(im->core.im_name);
       if (!address) goto cleanup;
       service = index(address, ':');
       if (service) {
           *service = '\0';
           service++;
       }
    }

    if (NULL != address) {
       st = iiimcf_attr_put_string_value(attr, IIIMCF_ATTR_SERVER_ADDRESS,
                                     address);
       if (st != IIIMF_STATUS_SUCCESS) goto cleanup;
       if (service) {
           st = iiimcf_attr_put_string_value(attr, IIIMCF_ATTR_SERVER_SERVICE,
                                         service);
           if (st != IIIMF_STATUS_SUCCESS) goto cleanup;
       }
    }
    st = iiimcf_create_handle(attr, &XIM_IIIMP(im, handle));
    if (st != IIIMF_STATUS_SUCCESS) goto cleanup;
    init_langlist(im);
    RegisterTriggerKeys(im);
    IMSetupAuxObject(im);

cleanup:
    iiimcf_destroy_attr(attr);
    if (address) free(address);
    if (NULL != prop) XFree(prop);
    return st;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void initialize ( ) [static]

Definition at line 440 of file iiimpIM.c.

Here is the call graph for this function:

static void parseAliasFile ( XimCommon  im,
FILE *  fp 
) [static]

Definition at line 225 of file iiimpIM.c.

{
    char buf[BUFSIZ];
    size_t alias_num = 0;
    im_locale_pair *lang_alias = 0;

    while (fgets(buf, BUFSIZ, fp) != NULL) {
       char *p = buf;
       int n;
       char *args[2];
       while (isspace(*p))
           ++p;
       if (iscomment(*p))
           continue;

       n = parseLine(p, args, 2);
       if (n == 2) {
           if (alias_num == 0)
              lang_alias = Xmalloc(sizeof(im_locale_pair));
           else
              lang_alias = Xrealloc((void*)lang_alias,
                                  sizeof(im_locale_pair) * (alias_num + 1));
           if (!lang_alias)
              return;
           lang_alias[alias_num].alias = strdup(args[0]);
           lang_alias[alias_num].canonical = strdup(args[1]);
           alias_num++;
       }
    }
    /* null terminate */
    lang_alias = Xrealloc((void*)lang_alias,
                       sizeof(im_locale_pair) * (alias_num + 1));
    if (!lang_alias)
       return;
    lang_alias[alias_num].alias = 0;
    lang_alias[alias_num].canonical = 0;

    XIM_IIIMP(im, lang_alias) = lang_alias;
    return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int parseLine ( char *  line,
char **  argv,
size_t  argsize 
) [static]

Definition at line 196 of file iiimpIM.c.

{
    int argc = 0;
    char *p = line;

    while (argc < argsize) {
       while (isspace(*p)) {
           ++p;
       }
       if (iscomment(*p)){
           break;
       }
       argv[argc++] = p;
       while (!isspace(*p)) {
           ++p;
       }
       if (iscomment(*p)) {
           break;
       }
       *p++ = '\0';
    }
    return argc;
}

Here is the caller graph for this function:

static Status SWITCH_CloseIM ( XIM  xim) [static]

Definition at line 699 of file iiimpIM.c.

{
    XimCommon im = (XimCommon)xim;

    IIimpFreeAllAuxData();

    if (im->core.im_name)
       Xfree(im->core.im_name);

    if (!im->iiimp_impart) return True;

#if 0 /* The following is required for asych. message handling.  */
    if (None != XIM_IIIMP(im, cb_window)) {
       _XUnregisterFilter(im->core.display, XIM_IIIMP(im, cb_window),
                        IMCBFilter, (XPointer)im);
       XDestroyWindow(im->core.display, XIM_IIIMP(im, cb_window));
    }
#endif
    if (XIM_IIIMP(im, handle)) {
       iiimcf_destroy_handle(XIM_IIIMP(im, handle));
    }
    IM_free_langlist(im);
    free_langalias(im);
    if (XIM_IIIMP(im, pkev_on)) {
       Xfree(XIM_IIIMP(im, pkev_on));
    }
    if (XIM_IIIMP(im, pkev_off)) {
       Xfree(XIM_IIIMP(im, pkev_off));
    }

    Xfree(im->iiimp_impart);
    im->iiimp_impart = 0;
    uninitialize();
    im_switcher_shutdown (im);
    return True;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void uninitialize ( ) [static]

Definition at line 448 of file iiimpIM.c.

{
    if (inited == 0) return;
    inited--;
    if (inited == 0)
       iiimcf_finalize();
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 788 of file popupIM.c.

                                       {
  XIMUnicodeCharacterSubsets *im_sub_sets;
  unsigned short n;
  unsigned short count = 0;

  /* already set */
  if (xim->unicode_char_subsets) return;

  if (XIM_IS_COMPOSE(xim)) {
    XIMComposeIM lim = xim->local_impart;
    LocalIMState *state = lim->top_state;

    while (state) {
      if (state->type == RemoteIMState) {
       state = state->next;
       continue;
      }
      count++;
      state = state->next;
    }
  }
  if (XIM_IS_IIIMP(xim)) {
    count += XIM_IIIMP(xim, count_languages);
  }

  if ((im_sub_sets = (XIMUnicodeCharacterSubsets*)
       Xmalloc(sizeof(XIMUnicodeCharacterSubsets) +
              sizeof(XIMUnicodeCharacterSubset) * count)) == NULL) {
    return;
  }
  im_sub_sets->count_subsets = count;
  im_sub_sets->supported_subsets =
    (XIMUnicodeCharacterSubset*)(&im_sub_sets[1]);

  n = 0;
  if (XIM_IS_COMPOSE(xim)) {
    XIMComposeIM lim = xim->local_impart;
    LocalIMState *state = lim->top_state;

    while (state) {
      if (state->type == RemoteIMState) {
       state = state->next;
       continue;
      }
      im_sub_sets->supported_subsets[n].index = n;
      im_sub_sets->supported_subsets[n].subset_id = 0; /* not yet */
      im_sub_sets->supported_subsets[n].name = state->name;
      im_sub_sets->supported_subsets[n].is_active = True;
      n++;
      state = state->next;
    }
  }
  if (XIM_IS_IIIMP(xim)) {
    XIMText *language_list = XIM_IIIMP(xim, supported_languages);
    int number = XIM_IIIMP(xim, count_languages);
    if (language_list) {
      XIMText *p;
      for (p = language_list; p < &language_list[number]; p++) {
        char *display_lang =
         getDisplayLanguageFromState(xim,
                                  p->string.multi_byte);
       if (!display_lang) {
         display_lang = convertToDisplayLanguage(p->string.multi_byte);
       }
       im_sub_sets->supported_subsets[n].index = n;
       im_sub_sets->supported_subsets[n].subset_id = 0; /* not yet */
       im_sub_sets->supported_subsets[n].name = display_lang;
       im_sub_sets->supported_subsets[n].is_active = True;
       n++;
      }
    }
  }
  xim->unicode_char_subsets = im_sub_sets;

  return;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Definition at line 156 of file iiimpIM.c.

XIMStyle im_styles[] [static]
Initial value:
 {
       XIMPreeditCallbacks |XIMStatusCallbacks,
       XIMPreeditCallbacks | XIMStatusArea,
       XIMPreeditCallbacks | XIMStatusNothing,
       XIMPreeditPosition  | XIMStatusCallbacks,
       XIMPreeditPosition  | XIMStatusArea,
       XIMPreeditPosition  | XIMStatusNothing,
       XIMPreeditArea      | XIMStatusCallbacks,
       XIMPreeditArea      | XIMStatusArea,
       XIMPreeditArea      | XIMStatusNothing,
       XIMPreeditNothing   | XIMStatusCallbacks,
       XIMPreeditNothing   | XIMStatusArea,
       XIMPreeditNothing   | XIMStatusNothing,
       XIMPreeditCallbacks | XIMStatusNone,
       XIMPreeditPosition  | XIMStatusNone,
       XIMPreeditArea      | XIMStatusNone,
       XIMPreeditNothing   | XIMStatusNone,
       XIMPreeditNone       | XIMStatusCallbacks,
       XIMPreeditNone      | XIMStatusArea,
       XIMPreeditNone      | XIMStatusNothing,
       XIMPreeditNone      | XIMStatusNone,
}

Definition at line 56 of file iiimpIM.c.

int inited = 0 [static]

Definition at line 437 of file iiimpIM.c.