Back to index

im-sdk  12.3.91
Defines | Functions | Variables
SunIMConf.c File Reference
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <dlfcn.h>
#include "SunIM.h"

Go to the source code of this file.

Defines

#define PATHNAME_MAX   1024
#define PROCNAME   "if_GetIfInfo"
#define HOTKEY_PROCNAME   "if_GetHotKeyInfo"
#define OPENWINHOME   "/usr/openwin"

Functions

Public iml_methods_t_iml_dup_iml_methods ()
Public iml_methods_wrapper_t_iml_dup_iml_methods_wrapper ()
Private void * open_le_module (char *)
Public void close_le_module (void *)
Private Bool get_ifinfo (const char *, iml_if_t *, void *)
Public Bool if_configure (iml_if_t *If, const char *iiimf_home, const char *if_name, const char *locale_, Bool call_openif)

Variables

if_methods_t sunim_default_methods

Define Documentation

#define HOTKEY_PROCNAME   "if_GetHotKeyInfo"

Definition at line 86 of file SunIMConf.c.

#define OPENWINHOME   "/usr/openwin"

Definition at line 88 of file SunIMConf.c.

#define PATHNAME_MAX   1024

Definition at line 82 of file SunIMConf.c.

#define PROCNAME   "if_GetIfInfo"

Definition at line 85 of file SunIMConf.c.


Function Documentation

Definition at line 974 of file SunIMSubr.c.

{
    iml_methods_t *m = (iml_methods_t *) malloc(sizeof(_iml_methods));
    memcpy(m, &_iml_methods, sizeof(_iml_methods));
    return m;
}

Here is the caller graph for this function:

Definition at line 94 of file SunIMSubr2.c.

{
  iml_methods_wrapper_t *m_wrapper = (iml_methods_wrapper_t *) 
                                     malloc (sizeof (iml_methods_wrapper_t));
  memcpy (m_wrapper, &_iml_methods_wrapper, sizeof (iml_methods_wrapper_t));

  return m_wrapper;
}

Here is the caller graph for this function:

Public void close_le_module ( void *  module)

Definition at line 129 of file SunIMConf.c.

{
#ifndef       WIN32
  if(module && dlclose((void*)module) != 0){
    fprintf(stderr, dlerror());
    fprintf(stderr, "\n");
  }
#else
  FreeLibrary((HINSTANCE) module);
#endif
}

Here is the caller graph for this function:

Private Bool get_ifinfo ( const char *  iiimf_home,
iml_if_t If,
void *  module 
)

Definition at line 142 of file SunIMConf.c.

{
  void *(*get_le_info) ();
  IMHotkeyManagerStruct *(*get_hotkey_info) (IMLEName*);
  int count;
  int if_version_idx, if_lename_idx, if_locales_idx, if_objects_idx, if_keyrelease_idx;
  int if_methods_idx, if_thread_lock_idx, if_imeinfo_idx;
#ifdef USE_SUNIM_ADAPTER
  int if_locale_dependency_idx;
#endif
#ifdef ENABLE_EIMIL
  int if_EIMIL_handle_idx;
#endif
  IMArg p[11] ; /* XXX FIXME Magic number */
    
#ifndef       WIN32
  get_le_info = (void *(*) ()) dlsym(module, PROCNAME);
#else
  get_le_info = (void *(*) ()) GetProcAddress((HINSTANCE) module, TEXT(PROCNAME));
#endif
    
  if (get_le_info == NULL) {
    return False;
  }
  count = 0;
  IMSetArg(p[count], IF_VERSION, NULL); if_version_idx = count++;
  IMSetArg(p[count], IF_LE_NAME, NULL); if_lename_idx = count++;
  IMSetArg(p[count], IF_SUPPORTED_LOCALES, NULL); if_locales_idx = count++;
  IMSetArg(p[count], IF_SUPPORTED_OBJECTS, NULL); if_objects_idx = count++;
  IMSetArg(p[count], IF_METHOD_TABLE, NULL); if_methods_idx = count++;
  IMSetArg(p[count], IF_NEED_THREAD_LOCK, NULL); if_thread_lock_idx = count++;
#ifdef USE_SUNIM_ADAPTER
  IMSetArg(p[count], IF_HAVE_LOCALE_DEPENDENCY, NULL);
  if_locale_dependency_idx = count++;
#endif
#ifdef ENABLE_EIMIL
  IMSetArg(p[count], IF_EIMIL_HANDLE, EIMIL_VOID_HANDLE);
  if_EIMIL_handle_idx = count++;
  setenv(IFPATH_ENV, iiimf_home, 1);
#endif
  IMSetArg(p[count], IF_SUPPORTED_KEYRELEASE, NULL); if_keyrelease_idx = count++;
  IMSetArg(p[count], IF_SUPPORTED_IMEINFO, NULL); if_imeinfo_idx = count++;

  (*get_le_info) (p, count);
    
  If->if_version = (char *) p[if_version_idx].value;
  If->ifm = (if_methods_t *) p[if_methods_idx].value;
  If->lename = (IMLEName *) p[if_lename_idx].value;
  If->locale_list = (IMLocale *) p[if_locales_idx].value;
  If->object_list = (IMObjectDescriptorStruct *) p[if_objects_idx].value;
  If->need_thread_lock = (Bool) p[if_thread_lock_idx].value;
  If->need_keyrelease = (Bool) p[if_keyrelease_idx].value;
  If->imeinfo_list = (IMEInfo *) p[if_imeinfo_idx].value;

  /* hotkey infomation */
  get_hotkey_info = (void *(*) ()) dlsym(module, HOTKEY_PROCNAME);
  if (get_hotkey_info) {
    If->hkm = (*get_hotkey_info)(If->lename);
  } else
    If->hkm = NULL;
  
#ifdef USE_SUNIM_ADAPTER
#ifndef       WIN32
  If->need_adapter = (Bool) p[if_locale_dependency_idx].value;
  if (If->need_adapter == True) {
    If->need_thread_lock = True;
  }
#else
  If->need_adapter = False;
#endif
#endif /* USE_SUNIM_ADAPTER */

#ifdef ENABLE_EIMIL
  If->eh = (EIMIL_handle) p[if_EIMIL_handle_idx].value;
#endif

  if (!If->ifm || !If->lename || !If->locale_list) {
    return False;
  }
  return True;
}

Here is the caller graph for this function:

Public Bool if_configure ( iml_if_t If,
const char *  iiimf_home,
const char *  if_name,
const char *  locale_,
Bool  call_openif 
)

Definition at line 230 of file SunIMConf.c.

{
  const char *locale = locale_;
  char if_path[PATHNAME_MAX];
    
  void *if_so = (void *) NULL;
  If->xsunim = False;

  /* If OpenDesktop() fails, use this default engine */
  if(!strcmp(if_name, "sunim_default")){
    If->ifm = &sunim_default_methods;
    goto sunim_default;
  }

#ifndef       WIN32
  sprintf(if_path, "%s/%s.so", iiimf_home, if_name);
    
  if_so = open_le_module(if_path);
    
  if (if_so) {
    if (get_ifinfo(iiimf_home, If, if_so) == False) {
      fprintf(stderr, "if_configure: get_method_table() failed\n");
      close_le_module(if_so);
      if_so = NULL;
    } else {
#ifdef USE_SUNIM_ADAPTER
      if (If->need_adapter == True && call_openif == True) {
       if (dl_module_sunimadapter == 0) {
         sprintf(if_path, "%s/%s.so", iiimf_home, SUNIMADAPTER_MODULE);
         dl_module_sunimadapter = open_le_module(if_path);
       }
       if (dl_module_sunimadapter) {
         If->ifm = (if_methods_t *) dlsym(dl_module_sunimadapter, SUNIMADAPTER_METHOD);
       }
      }
#endif /* SUNIM_ADAPTER */
    }
  }

#ifdef USE_XSUNIM_ADAPTER
  if (if_so == NULL) {
    sprintf(if_path, "%s/lib/locale/%s/xim/%s.so", OPENWINHOME, locale, if_name);
    if (!access(if_path, F_OK)) {
      If->xsunim = True;
    } else {
      sprintf(if_path, "%s/lib/locale/common/xim/%s.so", OPENWINHOME, if_name);
      if (!access(if_path, F_OK)) {
       If->xsunim = True;
      }
    }
    if (If->xsunim == True) {
      if (dl_module_xsunimadapter == 0) {
       sprintf(if_path, "%s/%s.so", iiimf_home, XSUNIMADAPTER_MODULE);
       dl_module_xsunimadapter = open_le_module(if_path);
      }
      if (dl_module_xsunimadapter) {
       If->ifm = (if_methods_t *) dlsym(dl_module_xsunimadapter, XSUNIMADAPTER_METHOD);
       If->lename = (IMLEName *) 0;
       If->locale_list = (IMLocale *) 0;
       If->object_list = (IMObjectDescriptorStruct *) 0;
       If->hkm = (IMHotkeyManagerStruct *) 0;
       If->need_thread_lock = True;
       If->need_keyrelease = False;
      }
    }
  }
#endif
    
  If->dl_module = if_so;
#else /* WIN32 */
  sprintf(if_path, "%s\\%s.dll", iiimf_home, if_name);
  if_so = open_le_module(if_path);
  if (if_so) {
    get_ifinfo(iiimf_home, If, if_so);
    if (If->ifm == NULL) {
#ifdef DEBUG
      printf("if_configure: get_method_table() failed\n");
#endif
      close_le_module(if_so);
      if_so = NULL;
    }
  } else {
    printf("open_le_module failed\n");
  }
#endif /* WIN32 */
    
  if (!If->ifm) {
    fprintf(stderr, "Fatal error in dynamic LE i/f loader -  A library is missing in your system. Please call your system administrator.\n");
    If->ifm = &sunim_default_methods;
  }

 sunim_default:
  If->locale = strdup(locale);
  If->if_name = strdup(if_name);
  If->ifpath_name = strdup(iiimf_home);
  If->m = _iml_dup_iml_methods();
  If->m_wrapper = _iml_dup_iml_methods_wrapper();
#ifdef DEBUG
  printf("try to call if_OpenIF() with locale=%s if_name=%s if_path=%s\n",
        If->locale, If->if_name, if_path);
#endif

  if (call_openif == True) {
    if (If->ifm->if_OpenIF(If) == False) {
      If->ifm = &sunim_default_methods;
      If->ifm->if_OpenIF(If);
    }
  }
  return True;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Private void * open_le_module ( char *  if_path)

Definition at line 107 of file SunIMConf.c.

{
#ifndef       WIN32
  void *pr;
  char *perr;
  if (access(if_path, F_OK) == -1) {
    return (void *) 0;
  }
  pr = dlopen(if_path, RTLD_LAZY);
  if (!pr) {
    perr = dlerror();
    if (perr) fprintf(stderr, "dlopen() failed:%s\n", perr);
  }
  return pr;
#else
  return (void *) LoadLibrary(if_path);
#endif
}

Here is the caller graph for this function:


Variable Documentation

Definition at line 63 of file SunIMConf2.c.