Back to index

im-sdk  12.3.91
Defines | Typedefs | Functions | Variables
xaux_ext_common.c File Reference
#include <locale.h>
#include <stdlib.h>
#include <stdio.h>
#include <limits.h>
#include <X11/X.h>
#include <X11/Xatom.h>
#include "trace_message.h"
#include "iiimpAux.h"
#include "xaux_common.h"
#include "xaux_ext_common.h"
#include <langinfo.h>
#include <strings.h>
#include <dlfcn.h>
#include "csconv.h"

Go to the source code of this file.

Defines

#define USE_CSCONV
#define UTF16_STRLEN   4096
#define CSC_OPEN_LOCALE   "csconv_open_locale"
#define CSC_OPEN   "csconv_open"
#define CSC_CONV   "csconv"
#define CSC_CLOSE   "csconv_close"

Typedefs

typedef csconv_t(* csc_open_locale_t )(const char *, const char *, const char *)
typedef csconv_t(* csc_open_t )(const char *, const char *)
typedef size_t(* csc_conv_t )(csconv_t, const char **, size_t *, char **, size_t *)
typedef int(* csc_close_t )(csconv_t)

Functions

size_t utf16_mb (const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft)
size_t mb_utf16 (const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft)
static Bool xaux_xs_get_sowin (xaux_class_t *xc, Display *display)
static Bool xaux_xs_send_property (Display *display, xaux_class_t *xc, int im_id, int ic_id, const unsigned char *p, int len)
Bool xaux_xs_send_message (Display *display, xaux_class_t *xc, int im_id, int ic_id, aux_ext_data_type_t type, Atom atom)
static Bool xaux_ext_process_property_update (Display *display, Window window, Atom atom)
Bool xaux_ext_process_client_message (Display *display, XClientMessageEvent *event)
Bool xaux_ext_init_classes (Display *display, xaux_class_t *p, Window extwin)
Bool xaux_ext_SetValue (Display *display, xaux_class_t *xc, aux_ext_data_t *aux_ext_data)
void HelpInvoke (char *path)
static void dlopen_csconv ()
int IIimpConvertToUTF16 (char *from_buf, size_t from_left, char **to_buf, size_t *to_left)
int IIimpConvertFromUTF16 (char *from_buf, size_t from_left, char **to_buf, size_t *to_left)

Variables

static void * csc_handle
static csc_open_locale_t csc_open_locale
static csc_open_t csc_open
static csc_conv_t csc_conv
static csc_close_t csc_close
static char * current_locale = 0

Define Documentation

#define CSC_CLOSE   "csconv_close"

Definition at line 908 of file xaux_ext_common.c.

#define CSC_CONV   "csconv"

Definition at line 907 of file xaux_ext_common.c.

#define CSC_OPEN   "csconv_open"

Definition at line 906 of file xaux_ext_common.c.

#define CSC_OPEN_LOCALE   "csconv_open_locale"

Definition at line 905 of file xaux_ext_common.c.

#define USE_CSCONV

Definition at line 880 of file xaux_ext_common.c.

#define UTF16_STRLEN   4096

Definition at line 900 of file xaux_ext_common.c.


Typedef Documentation

typedef int(* csc_close_t)(csconv_t)

Definition at line 915 of file xaux_ext_common.c.

typedef size_t(* csc_conv_t)(csconv_t, const char **, size_t *, char **, size_t *)

Definition at line 913 of file xaux_ext_common.c.

typedef csconv_t(* csc_open_locale_t)(const char *, const char *, const char *)

Definition at line 910 of file xaux_ext_common.c.

typedef csconv_t(* csc_open_t)(const char *, const char *)

Definition at line 912 of file xaux_ext_common.c.


Function Documentation

static void dlopen_csconv ( ) [static]

Definition at line 934 of file xaux_ext_common.c.

{
      csc_handle = dlopen(CSC_PATH, RTLD_LAZY);
      if (NULL == csc_handle) {
        csc_handle = (void *)(-1);
       return;
      }

      csc_open_locale = (csc_open_locale_t)dlsym(csc_handle, CSC_OPEN_LOCALE);
      csc_open = (csc_open_t)dlsym(csc_handle, CSC_OPEN);
      csc_conv = (csc_conv_t)dlsym(csc_handle, CSC_CONV);
      csc_close = (csc_close_t)dlsym(csc_handle, CSC_CLOSE);

      if ((NULL == csc_open_locale) || (NULL == csc_open) ||
         (NULL == csc_conv) || (NULL == csc_close)) {
        dlclose(csc_handle);
       csc_handle = (void *)(-1);
       return;
      }
}

Here is the caller graph for this function:

void HelpInvoke ( char *  path)

Definition at line 822 of file xaux_ext_common.c.

{
    char *browser;
    char *basepath;

    pid_t pid, pid2;

    if (!path) {
      return;
    }

#ifdef linux
    pid = fork();
#else
    pid = fork1();
#endif

    if (getenv("HTT_HELP_BROWSER")){
      browser = getenv("HTT_HELP_BROWSER");
    } else {
      browser = "/usr/bin/netscape";
    }

    if (getenv("HTT_HELP_PATH")){
      basepath = getenv("HTT_HELP_PATH");
    } else {
      basepath = DEFAULT_HELP_PATH;
    }

    if (pid == (pid_t) (-1)) {
        return;
    } else if (0 == pid) {
        pid2 = fork();
        if(pid2 == -1) {
            _exit(1);
        } else if(pid2 == 0) {
           char *help = (char*)malloc(strlen(basepath) + strlen(path) +1 );
           sprintf(help, "%s%s", basepath, path);
           execl(browser, browser, help, NULL);
           free(help);
            _exit(1);
        } else {
            _exit(0);
        }
    } else {
        waitpid(pid, NULL, 0);
    }
    return;
}

Here is the caller graph for this function:

int IIimpConvertFromUTF16 ( char *  from_buf,
size_t  from_left,
char **  to_buf,
size_t *  to_left 
)

Definition at line 1084 of file xaux_ext_common.c.

                                                     {
  size_t src_len, dst_len;
  char *src, *dst;
#ifndef USE_CSCONV
  const char *ip;
  size_t ileft;
  char *op;
  size_t oleft;
  char buffer[UTF16_STRLEN];       /* Fix me! */
#endif /* !USE_CSCONV */
  const size_t buf_len = UTF16_STRLEN;
  size_t ret = 0;

#ifdef USE_CSCONV
  static csconv_t csconv_cd = NULL;
#endif

#ifdef USE_CSCONV
  if (current_locale == NULL){
    current_locale = (char*)strdup(setlocale(LC_CTYPE, NULL));
  }
  do {
    if (((void *)(-1) == csc_handle) ||
       ((csconv_t)(-1) == csconv_cd)) {
      continue;
    }
    if (NULL == csc_handle) {
      dlopen_csconv();
      if ((void *)(-1) == csc_handle) {
       continue;
      }
    }
    if (NULL == csconv_cd) {

      csconv_cd = (csc_open_locale)(current_locale, "MultiByte", "UTF-16");
      
      if ((csconv_t)(-1) == csconv_cd) {
       continue;
      }
    }

    dst = *((char **)to_buf);

    ret = csc_conv(csconv_cd,
                 (const char **)&from_buf, &from_left, &dst, to_left);
    return ret;
  } while (0);
#endif

#ifdef USE_ICONV
  if (i_conv1_FromUTF16 == (iconv_t)-1 ||
      i_conv2_FromUTF16 == (iconv_t)-1) {
    goto done;
  }

  if (i_conv2_FromUTF16 == NULL && !skip_native_to_utf8_conv) {
    char *encoding = nl_langinfo(CODESET);
    if (!strcmp(encoding, "UTF-8")) {
      skip_native_to_utf8_conv = True;
    } else {
      if ((i_conv2_FromUTF16 = iconv_open(encoding, "UTF-8"))
         == (iconv_t) - 1) {
       goto done;
      }
    }
  }
  if (i_conv1_FromUTF16 == NULL) {
    if ((i_conv1_FromUTF16 = iconv_open("UTF-8", "UCS-2"))
       == (iconv_t) - 1) {
      goto done;
    }
  }

  if (skip_native_to_utf8_conv) {
    src = from_buf;
    src_len = from_left;    /* don't stop at '\0' in case of ascii */
    dst = *((char **) to_buf);

    ret = iconv(i_conv1_FromUTF16, (const char**)&src, &src_len,
              (char**)&dst, to_left);
  } else {
    ip = (const char *)from_buf;
    ileft = from_left;

    op = *((char **)to_buf);
    oleft = *to_left;

    while ((0 < ileft) && (0 < oleft)) {
      dst = buffer;
      dst_len = buf_len;
      ret = iconv(i_conv1_FromUTF16, &ip, &ileft, (char**)&dst, &dst_len);
      if ((ret != 0) && (E2BIG != errno)) {
       goto done;
      }

      src = buffer;
      src_len = buf_len - dst_len;

      ret = iconv(i_conv2_FromUTF16, (const char**)&src, &src_len,
                &op, &oleft);
      if (ret != 0) goto done;
    }

    *to_left = oleft;
  }
done:
#endif /* USE_ICONV */
  return(ret);
}

Here is the call graph for this function:

int IIimpConvertToUTF16 ( char *  from_buf,
size_t  from_left,
char **  to_buf,
size_t *  to_left 
)

Definition at line 957 of file xaux_ext_common.c.

                                                  {
  size_t src_len, dst_len;
  char *src, *dst;
#ifndef USE_CSCONV
  const char *ip;
  size_t ileft;
  char *op;
  size_t oleft;
  char buffer[UTF16_STRLEN];              /* Fix me! */
#endif /* !USE_CSCONV */
  const size_t buf_len = UTF16_STRLEN;
  size_t ret = 0;
#ifdef USE_CSCONV
  static csconv_t csconv_cd = NULL;

#endif

#ifdef USE_CSCONV
  if (current_locale == NULL){
    current_locale = (char*)strdup(setlocale(LC_CTYPE, NULL));
  }

  do {
    if (((void *)(-1) == csc_handle) ||
       ((csconv_t)(-1) == csconv_cd)) {
      continue;
    }
    if (NULL == csc_handle) {
      dlopen_csconv();
      if ((void *)(-1) == csc_handle) {
       continue;
      }
    }
    if (NULL == csconv_cd) {

      csconv_cd = (csc_open_locale)(current_locale, "UTF-16", "MultiByte");
      
      if ((csconv_t)(-1) == csconv_cd) {
       continue;
      }
    }

    dst = *((char **)to_buf);

    ret = csc_conv(csconv_cd,
                 (const char **)&from_buf, &from_left,
                 &dst, to_left);
    return ret;
  } while (0);
#endif

#ifdef USE_ICONV
  if (i_conv1 == (iconv_t)-1 || i_conv2 == (iconv_t)-1){
    goto done;
  }

  if (i_conv1 == NULL && !skip_native_to_utf8_conv) {
    char *encoding = nl_langinfo(CODESET);
    if (!strcmp(encoding, "UTF-8")) {
      skip_native_to_utf8_conv = True;
    } else {
      if ((i_conv1 = iconv_open("UTF-8", encoding))
         == (iconv_t)-1) {
       goto done;
      }
    }
  }

  if (i_conv2 == NULL){
    if ((i_conv2 = iconv_open("UCS-2",
                           "UTF-8")) == (iconv_t)-1)
      goto done;
  }

  if (!skip_native_to_utf8_conv) {
    ip = (const char *)from_buf;
    ileft = from_left;

    op = *((char **)to_buf);
    oleft = *to_left;

    while ((0 < ileft) && (0 < oleft)) {
      dst = buffer;
      dst_len = buf_len;
      ret = iconv(i_conv1, &ip, &ileft, (char**)&dst, &dst_len);
      if ((ret != 0) && (E2BIG != errno)) {
       goto done;
      }

      src = buffer;
      src_len = buf_len - dst_len;

      ret = iconv(i_conv2, (const char**)&src, &src_len, &op, &oleft);
      if (ret != 0) goto done;
    }

    dst_len = oleft;

  } else {
    src = from_buf;
    src_len = from_left;
    dst = *to_buf;
    dst_len = *to_left;

    ret = iconv(i_conv2, (const char**)&src, &src_len, (char**)&dst, &dst_len);
  }

  if (0xFEFF == **((CARD16 **)to_buf)) {
    memmove(*to_buf, *to_buf + 2, *to_left - dst_len - 2);
    *to_left = (dst_len + 2);
  } else {
    *to_left = dst_len;
  }
done:
#endif /* USE_ICONV */
  return(ret);
}

Here is the call graph for this function:

size_t mb_utf16 ( const char **  inbuf,
size_t *  inbytesleft,
char **  outbuf,
size_t *  outbytesleft 
)

Definition at line 74 of file xaux_ext_common.c.

{
        int     r;

        r = IIimpConvertToUTF16((char *)(*inbuf), *inbytesleft,
                                  outbuf, outbytesleft);
        return (size_t)r;
}
size_t utf16_mb ( const char **  inbuf,
size_t *  inbytesleft,
char **  outbuf,
size_t *  outbytesleft 
)

Definition at line 60 of file xaux_ext_common.c.

{
        int     r;

        r = IIimpConvertFromUTF16((char *)(*inbuf), *inbytesleft,
                                  outbuf, outbytesleft);
        return (size_t)r;
}

Here is the caller graph for this function:

Bool xaux_ext_init_classes ( Display *  display,
xaux_class_t p,
Window  extwin 
)

Definition at line 427 of file xaux_ext_common.c.

{
       char          buf[1024];
       int           i;

       p->atom_classname = XInternAtom(display, p->classname, False);

       sprintf(buf, "%s%s", p->classname, XAUX_SOWIN_SUFFIX);
       p->atom_sowin = XInternAtom(display, buf, False);

       sprintf(buf, "%s%s", p->classname, XAUX_EXTWIN_SUFFIX);
       p->atom_extwin = XInternAtom(display, buf, False);

       for (i = 0; i < XAUX_SX_NATOMS; i++) {
              sprintf(buf, "%s%s_%d", p->classname, XAUX_SX_SUFFIX, i);
              p->atom_sx[i] = XInternAtom(display, buf, False);
       }

       p->atom_sx_idx = 1;

       for (i = 0; i < XAUX_XS_NATOMS; i++) {
              sprintf(buf, "%s%s_%d", p->classname, XAUX_XS_SUFFIX, i);
              p->atom_xs[i] = XInternAtom(display, buf, False);
       }

       p->atom_xs_idx = 1;

       p->sowin = (Window)0;

       p->extwin = extwin;

       if (XGetSelectionOwner(display, p->atom_extwin) != None) {
#if defined(DEBUG_XAUX)
              fprintf(stderr, "%s: %s already exists.[%s](1)\n",
                     ME_EXT, ME_EXT, p->classname);
#endif /* defined(DEBUG_XAUX) */
              return False;
       }

       XSetSelectionOwner(display, p->atom_extwin, p->extwin, CurrentTime);

       if (XGetSelectionOwner(display, p->atom_extwin) != p->extwin) {
#if defined(DEBUG_XAUX)
              fprintf(stderr, "%s: %s already exists.[%s](2)\n",
                     ME_EXT, ME_EXT, p->classname);
#endif /* defined(DEBUG_XAUX) */
              XDestroyWindow(display, p->extwin);
              p->extwin = (Window)0;
              return False;
       }

       /* process sx properties which has been put on sowin before
          extwin is prepared */
       if (xaux_xs_get_sowin(p, display) == True) {
              for (i = p->atom_sx_idx; i < XAUX_SX_NATOMS; i++) {
                     if (xaux_ext_process_property_update(
                            display, p->sowin, p->atom_sx[i]) == False) {
                            break;
                     }
              }
       }
       return True;
}

Here is the call graph for this function:

Bool xaux_ext_process_client_message ( Display *  display,
XClientMessageEvent *  event 
)

Definition at line 372 of file xaux_ext_common.c.

{
       aux_ext_data_t       aux_ext_data_;
       aux_ext_data_t       *aux_ext_data = &(aux_ext_data_);
       aux_ext_data_type_t  type;
       xaux_class_t  *xc = &xaux_class;

       if (event->data.l[0] != xc->atom_classname) {
              return False;
       }

       if (event->message_type != xc->atom_sx[0]) {
              return False;
       }

       if (event->window != xc->extwin) {
              return False;
       }

       aux_ext_data->im = ((CARD32)(event->data.l[1])) >> 16;
       aux_ext_data->ic = ((CARD32)(event->data.l[1])) & 0xffff;
       aux_ext_data->aux_index = (CARD32)(event->data.l[2]);

       type = (CARD32)(event->data.l[3]);

       switch (type) {
       case AUX_EXT_DATA_START:
#if defined(DEBUG_XAUX)
              fprintf(stderr, "[%s] received START via ClientMessage\n",
                     xc->classname);
#endif /* defined(DEBUG_XAUX) */
              return xaux_ext_Start(xc, aux_ext_data);
              break;
       case AUX_EXT_DATA_DRAW:
#if defined(DEBUG_XAUX)
              fprintf(stderr, "[%s] notified DRAW via ClientMessage\n",
                     xc->classname);
#endif /* defined(DEBUG_XAUX) */
              return xaux_ext_process_property_update(
                     display, xc->extwin, (Atom)(CARD32)(event->data.l[4]));
       case AUX_EXT_DATA_DONE:
#if defined(DEBUG_XAUX)
              fprintf(stderr, "[%s] received DONE via ClientMessage\n",
                     xc->classname);
#endif /* defined(DEBUG_XAUX) */
              return xaux_ext_Done(xc, aux_ext_data);
              break;
       default:
              return False;
       }
}

Here is the call graph for this function:

static Bool xaux_ext_process_property_update ( Display *  display,
Window  window,
Atom  atom 
) [static]

Definition at line 177 of file xaux_ext_common.c.

{
       Atom          actual_type_return;
       int           actual_format_return;
       unsigned long nitem_return;
       unsigned long bytes_after_return;
       unsigned char *      prop_return;
       int           r;
       int           imid;
       int           size;
       aux_ext_data_t       aux_ext_data_;
       aux_ext_data_t *     aux_ext_data = &(aux_ext_data_);
       unsigned char *      p;
       int           i;
       int           n=0;
       xaux_class_t  *xc = &xaux_class;
       XPoint        point;
       Bool          rv;
       int           type;
       char *        outbuf_ = NULL;

       if (window != xc->extwin && window != xc->sowin) {
              return False;
       }

       r = XGetWindowProperty(display, window,
                            atom, 0, INT_MAX, False,
                            AnyPropertyType, &actual_type_return,
                            &actual_format_return, &nitem_return,
                            &bytes_after_return, &prop_return);

       if (r != Success || actual_type_return == 0) {
              return False;
       }

       type = SX_PROP_TYPE(prop_return);

       /* ClientMessage detoured to property, due to extwin not
          available yet */
       if (type == AUX_DATA_START || type == AUX_DATA_DONE) {
              aux_ext_data_t       aux_ext_data_;
              aux_ext_data_t       *aux_ext_data = &(aux_ext_data_);
              xaux_class_t  *xc = &xaux_class;

              if (SX_PROP_ATOM_AUX_NAME(prop_return) != xc->atom_classname) {
                     return False;
              }

              aux_ext_data->im = SX_PROP_IMID(prop_return);
              aux_ext_data->ic = SX_PROP_ICID(prop_return);
              aux_ext_data->aux_index = SX_PROP_INDEX(prop_return);

              switch (type) {
              case AUX_EXT_DATA_START:
#if defined(DEBUG_XAUX)
                     fprintf(stderr, "[%s] received START via property\n",
                            xc->classname);
#endif /* defined(DEBUG_XAUX) */
                     return xaux_ext_Start(xc, aux_ext_data);
                     break;
              case AUX_EXT_DATA_DONE:
#if defined(DEBUG_XAUX)
                     fprintf(stderr, "[%s] received DONE via property\n",
                            xc->classname);
#endif /* defined(DEBUG_XAUX) */
                     return xaux_ext_Done(xc, aux_ext_data);
                     break;
              default:
                     return False;
              }
       }

       /* header */

       aux_ext_data->type = AUX_EXT_DATA_DRAW;
       aux_ext_data->im = SX_PROP_IMID(prop_return);
       aux_ext_data->ic = SX_PROP_ICID(prop_return);
       aux_ext_data->aux_index = xc->index;
       aux_ext_data->aux_name = (unsigned char *)xc->classname;
       aux_ext_data->aux_name_length =
              strlen((const char *)aux_ext_data->aux_name);

       /* int values */

       aux_ext_data->integer_count = SX_PROP_INT_COUNT(prop_return);

       if (aux_ext_data->integer_count > 0) {
              aux_ext_data->integer_list =
                     (int *)SX_PROP_INT_LIST(prop_return);
       } else {
              aux_ext_data->integer_list = NULL;
       }

       /* string values */

       aux_ext_data->string_count = SX_PROP_STR_COUNT(prop_return);

       if (aux_ext_data->string_count > 0) {
              unsigned char * prop_str = SX_PROP_STR_LIST(prop_return);
              char *        outbuf;
              size_t        outbufsiz, c;

              if ((aux_ext_data->string_list =
                     (aux_ext_string_t *)malloc(sizeof (aux_ext_string_t) *
                            aux_ext_data->string_count)) == NULL) {
                            XFree(prop_return);
                            return False;
              }

              /*
               * to make calcuration easier, assume no padding
               * so allocated area can be larger than needed
               */
              /* total bytes of the property */
              c  = nitem_return; 
              /* total bytes used for string_values in the property  */
              c -= SX_PROP_STR_LIST(prop_return) - prop_return;
              /* eliminate area for length values */
              c -= aux_ext_data->string_count * sizeof(CARD16);
              /* if all of the area is filled with UTF-16.... */
              c /= sizeof (CARD16);
              /* multiply with MB_CUR_MAX */
              c *= MB_CUR_MAX;
              /* for null termination of each string */
              c += aux_ext_data->string_count;
              outbufsiz = c;

              /* allocate outbuf_ */
              if ((outbuf_ = (char *)malloc(outbufsiz)) == NULL) {
                     free(aux_ext_data->string_list);
                     XFree(prop_return);
                     return False;
              }

              outbuf = &(outbuf_[0]);

              for(i = 0; i < aux_ext_data->string_count; i++) {
                     char *        ib;
                     char *        ob;
                     size_t        ibl;
                     size_t        obl = outbufsiz;
                     size_t        obl_save;

                     /* assign length of a string to ibl */
                     ibl = (size_t)*((CARD16 *)(prop_str));
                     /* move prop_str to point head of the string */
                     prop_str += sizeof(CARD16);
                     /* assign head of the string to ib */
                     ib = (char *)prop_str;
                     /* move prop_str to point lenght of next string */
                     prop_str += (ibl + padding[(sizeof(CARD16) + ibl) % 4]);

                     ob = outbuf;
                     obl_save = obl;

                     aux_ext_data->string_list[i].ptr = (unsigned char *)ob;

                     utf16_mb((const char **)&ib, &ibl, &ob, &obl);

                     aux_ext_data->string_list[i].length = obl_save - obl;
                     outbuf = ob + aux_ext_data->string_list[i].length;

                     /* null termination */
                     *(outbuf++) = '\0';
              }
       } else {
              aux_ext_data->string_list = NULL;
       }

       aux_ext_data->string_ptr = NULL;

       aux_ext_data->clientwin = SX_PROP_CLIENTWIN(prop_return);
       aux_ext_data->point.x = SX_PROP_POSX(prop_return);
       aux_ext_data->point.y = SX_PROP_POSY(prop_return);
       aux_ext_data->focuswin = SX_PROP_FOCUSWIN(prop_return);

#if defined(DEBUG_XAUX)
       fprintf(stderr, "[%s] received DRAW via property\n",
              xc->classname);
#endif /* defined(DEBUG_XAUX) */
       rv = xaux_ext_Draw(xc, aux_ext_data);

       free(aux_ext_data->string_list);
       if (outbuf_ != NULL) {
              free(outbuf_);
       }
       XFree(prop_return);

       return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Bool xaux_ext_SetValue ( Display *  display,
xaux_class_t xc,
aux_ext_data_t aux_ext_data 
)

Definition at line 495 of file xaux_ext_common.c.

{
       static char   *string_buf = NULL;
       static size_t bufsize = 0;
       size_t        i;
       size_t        total = 0;
       int           *ip;
       char          *sp;
       Bool          rv = True;

       if (aux_ext_data == NULL) {
              /* reset; free string_buf */
              if (string_buf != NULL) {
                     free(string_buf);
                     string_buf = NULL;
              }
              bufsize = 0;
              return True;
       }

       total = XS_SIZE_PROP_HEADER_SETVALUE
              + (sizeof (CARD32) * aux_ext_data->integer_count);

       if (aux_ext_data->string_count > 0) {
              for (i = 0; i < aux_ext_data->string_count; i++) {
                     size_t len;

                     len = aux_ext_data->string_list[i].length
                            * sizeof (CARD16);
                     total += ((sizeof (CARD16) + len + 3) / 4) * 4;
              }

              /*
               * "+1" is required by mb_utf16() method.
               * The method uses the area for BOM.
               */
              total += sizeof (CARD16);
       }

       /* tentatively use realloc(); may replace with malloc() later */
       /* othewise, cleanup (freeing) routine should be provided */
       if (total > bufsize) {
              string_buf = realloc(string_buf, total);
              if (string_buf == NULL) {
                     bufsize = 0;
                     return False;
              }
              bufsize = total;
       }

       XS_PROP_ATOM_AUX_NAME(string_buf) = xc->atom_classname;
       XS_PROP_IMID(string_buf) = aux_ext_data->im;
       XS_PROP_ICID(string_buf) = aux_ext_data->ic;

       XS_PROP_INT_COUNT(string_buf) = aux_ext_data->integer_count;
       XS_PROP_STR_COUNT(string_buf) = aux_ext_data->string_count;


       ip = (int *)XS_PROP_INT_LIST(string_buf);

       if (aux_ext_data->integer_count > 0) {

              for (i = 0; i < aux_ext_data->integer_count; i++) {
                     *ip++ = aux_ext_data->integer_list[i];
              }
       }

       sp = (char *)XS_PROP_STR_LIST(string_buf);

       if (aux_ext_data->string_count > 0) {
              char * ob;
              size_t obl;

              ob = sp;
              obl = total - XS_SIZE_PROP_HEADER_SETVALUE
                     - (sizeof (CARD16) * aux_ext_data->integer_count);

              for (i = 0; i < aux_ext_data->string_count; i++) {
                     char *        ib;
                     size_t        ibl;
                     size_t        obl_save;
                     int           pn;
                     CARD16 *      plen;
                     int           j;

                     ib = (char *)(aux_ext_data->string_list[i].ptr);
                     ibl = (size_t)aux_ext_data->string_list[i].length;

                     /* remember area for length, then skip the area */
                     plen = (CARD16 *)ob;
                     ob += sizeof (CARD16);
                     obl -= sizeof (CARD16);

                     obl_save = obl;

                     mb_utf16((const char **)&ib, &ibl, &ob, &obl);

                     /* store length */
                     *plen = obl_save - obl;

                     /* move ob to tail of the string */
                     ob += *plen;

                     /* padding */
                     pn = padding[(sizeof(CARD16) + *plen) % 4];
                     for (j = 0; j < pn; j++) {
                            *ob++ = 0;
                     }
                     sp = ob;
              }
       }

#if defined(DEBUG_XAUX)
       fprintf(stderr, "ext_SetValue[%s] im:0x%x ic:0x%x in=%d sn=%d\n",
              xc->classname, aux_ext_data->im, aux_ext_data->ic,
              aux_ext_data->integer_count, aux_ext_data->string_count);
#endif /* defined(DEBUG_XAUX) */

       if (aux_ext_data->integer_count != 0 ||
              aux_ext_data->string_count != 0) {
              rv = xaux_xs_send_property(display, xc,
                     aux_ext_data->im, aux_ext_data->ic,
                     (unsigned char *)string_buf, (sp - &(string_buf[0])));
       }

       return (rv);
}

Here is the call graph for this function:

static Bool xaux_xs_get_sowin ( xaux_class_t xc,
Display *  display 
) [static]

Definition at line 89 of file xaux_ext_common.c.

{
       size_t        i;


       xc->sowin = XGetSelectionOwner(display, xc->atom_sowin);

       if (xc->sowin == None)
              return False;
       else
              return True;
}

Here is the caller graph for this function:

Bool xaux_xs_send_message ( Display *  display,
xaux_class_t xc,
int  im_id,
int  ic_id,
aux_ext_data_type_t  type,
Atom  atom 
)

Definition at line 136 of file xaux_ext_common.c.

{
       XClientMessageEvent  event;

       if ((xc->sowin == None) &&
              (xaux_xs_get_sowin(xc, display) == False)) {
              return False;
       }
              
       event.type = ClientMessage;
       event.serial = 0;
       event.send_event = True;
       event.display = display;
       event.window = xc->sowin;
       event.message_type = xc->atom_xs[0];
       event.format = 32;

       event.data.l[0] = xc->atom_classname;
       event.data.l[1] = ((CARD16)im_id << 8) | ((CARD16)ic_id & 0xffff);
       event.data.l[2] = xc->index;
       event.data.l[3] = type;
       if (type == AUX_EXT_DATA_SETVALUE) {
              event.data.l[4] = atom;
       } else {
              event.data.l[4] = 0; /* unused */
       }

       XSendEvent(display, xc->sowin, True, 0, (XEvent *)(&event));

       XFlush(display);

       return True;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static Bool xaux_xs_send_property ( Display *  display,
xaux_class_t xc,
int  im_id,
int  ic_id,
const unsigned char *  p,
int  len 
) [static]

Definition at line 105 of file xaux_ext_common.c.

{
       if ((xc->sowin == None) &&
              (xaux_xs_get_sowin(xc, display) == False)) {
              return False;
       }

       XChangeProperty(display, xc->sowin,
              xc->atom_xs[xc->atom_xs_idx], XA_STRING,
              8, PropModeReplace, (unsigned char *)p, len);

       if (xaux_xs_send_message(display, xc, im_id, ic_id,
              AUX_EXT_DATA_SETVALUE, xc->atom_xs[xc->atom_xs_idx]) == False) {
                     return False;
       }

       /* XFlush() has been called in xaux_xs_send_message() */

       if (++xc->atom_xs_idx == XAUX_XS_NATOMS)
              xc->atom_xs_idx = 1;
       
       return True;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Definition at line 921 of file xaux_ext_common.c.

csc_conv_t csc_conv [static]

Definition at line 920 of file xaux_ext_common.c.

void* csc_handle [static]

Definition at line 917 of file xaux_ext_common.c.

csc_open_t csc_open [static]

Definition at line 919 of file xaux_ext_common.c.

Definition at line 918 of file xaux_ext_common.c.

char* current_locale = 0 [static]

Definition at line 923 of file xaux_ext_common.c.