Back to index

im-sdk  12.3.91
Classes | Defines | Functions | Variables
SunIMSubr.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/param.h>
#include "SunIM.h"
#include "SunIMLock.h"

Go to the source code of this file.

Classes

struct  _iml_inst_mem_block_list
struct  _iml_inst_mem_elem_list

Defines

#define ALIGN16(p)   (((p) & 0x0f) ? (((p) & ~(0x0f)) + 0x10) : (p))
#define MEM_BLOCK_SIZE   (128 * 1024)
#define MEM_BLOCK_HEADER_SIZE   (ALIGN16(sizeof (iml_inst_mem_block_list_t)))
#define MEM_BLOCK_MAX_SIZE   (MEM_BLOCK_SIZE - MEM_BLOCK_HEADER_SIZE)
#define MEM_ELEM_HEADER_SIZE   (ALIGN16(sizeof (iml_inst_mem_elem_list_t)))

Functions

Private iml_instiml_make_preedit_start_inst (iml_session)
Private iml_instiml_make_preedit_draw_inst (iml_session, IMText *)
Private iml_instiml_make_preedit_draw_with_caret_inst (iml_session, IMText *, int)
Private iml_instiml_make_preedit_draw_with_chgpos_inst (iml_session_t *, IMText *, int, int, int)
Private iml_instiml_make_preedit_erase_inst (iml_session_t *)
Private iml_instiml_make_preedit_caret_inst (iml_session_t *, int)
Private iml_instiml_make_preedit_done_inst (iml_session_t *)
Private iml_instiml_make_status_start_inst (iml_session_t *)
Private iml_instiml_make_status_draw_inst (iml_session_t *, IMText *)
Private iml_instiml_make_status_done_inst (iml_session_t *)
Private iml_instiml_make_lookup_start_inst (iml_session_t *, IMLookupStartCallbackStruct *)
Private iml_instiml_make_lookup_draw_inst (iml_session_t *, IMLookupDrawCallbackStruct *)
Private iml_instiml_make_lookup_done_inst (iml_session_t *)
Private iml_instiml_make_aux_start_inst (iml_session_t *, IMAuxStartCallbackStruct *)
Private iml_instiml_make_aux_draw_inst (iml_session_t *, IMAuxDrawCallbackStruct *)
Private iml_instiml_make_aux_done_inst (iml_session_t *, IMAuxDoneCallbackStruct *)
Private iml_instiml_make_start_conversion_inst (iml_session_t *)
Private iml_instiml_make_end_conversion_inst (iml_session_t *)
Private iml_instiml_make_commit_inst (iml_session_t *, IMText *)
Private iml_instiml_make_keypress_inst (iml_session_t *, IMKeyEventStruct *)
Private iml_instiml_link_inst_tail (iml_inst **, iml_inst *)
Public iml_instiml_execute_iml_wrapper (iml_session_t *, iml_inst **)
Private void * iml_new (iml_session_t *, int)
Private void * iml_new2 (iml_session_t *, int)
Private void * iml_delete (iml_session_t *)
Private void * iml_delete2 (iml_session_t *)
Public int iml_add_listener (iml_session_t *, char *, void *, void *)
Public int iml_delete_listener (iml_session_t *, int)
Private void iml_ns_listener_ahead (iml_session_t *, int, void *)
Private iml_instiml_make_nop_inst (iml_session_t *)
Private int lookup_config_for_listener (char *, void *)
char * secure_pathname (char *)
Private iml_instiml_make_preedit_start_inst (iml_session_t *s)
static Bool compare_feedbacks (IMFeedbackList *, IMFeedbackList *)
Private iml_instiml_make_preedit_draw_with_caret_inst (iml_session_t *s, IMText *text, int caret)
Private iml_instiml_make_preedit_draw_inst (iml_session_t *s, IMText *text)
Public iml_methods_t_iml_dup_iml_methods ()
Private void * slot_manager_alloc_small (iml_session_t *s, int size)
Private void * slot_manager_alloc_mem_elem (iml_session_t *s, int size)
Private void * slot_manager_alloc_mem_elem2 (iml_session_t *s, int size)
Private void * slot_manager_free (iml_session_t *s)
Private void * slot_manager_free2 (iml_session_t *s)
Public void sunim_slot_manager_init ()

Variables

Public iml_methods_t _iml_methods
pthread_mutex_t memory_block_mutex
static iml_inst_mem_block_list_t * memory_block_list

Class Documentation

struct _iml_inst_mem_block_list

Definition at line 987 of file SunIMSubr.c.

Collaboration diagram for _iml_inst_mem_block_list:
Class Members
struct _iml_inst_mem_block_list * next
size_t rest
size_t size
size_t used
struct _iml_inst_mem_elem_list

Definition at line 997 of file SunIMSubr.c.

Collaboration diagram for _iml_inst_mem_elem_list:
Class Members
struct _iml_inst_mem_elem_list * next

Define Documentation

#define ALIGN16 (   p)    (((p) & 0x0f) ? (((p) & ~(0x0f)) + 0x10) : (p))

Definition at line 981 of file SunIMSubr.c.

#define MEM_BLOCK_HEADER_SIZE   (ALIGN16(sizeof (iml_inst_mem_block_list_t)))

Definition at line 983 of file SunIMSubr.c.

Definition at line 984 of file SunIMSubr.c.

#define MEM_BLOCK_SIZE   (128 * 1024)

Definition at line 982 of file SunIMSubr.c.

#define MEM_ELEM_HEADER_SIZE   (ALIGN16(sizeof (iml_inst_mem_elem_list_t)))

Definition at line 985 of file SunIMSubr.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:

static Bool compare_feedbacks ( IMFeedbackList fbla,
IMFeedbackList fblb 
) [static]

Definition at line 159 of file SunIMSubr.c.

{
    int la = IM_FEEDBACK_COUNT(fbla);
    IMFeedback *fba = fbla->feedbacks;
    int lb = IM_FEEDBACK_COUNT(fblb);
    IMFeedback *fbb = fblb->feedbacks;
    IMFeedback *fa, *fb;
    int i, j, type, value;
    int exist;
    
    /* return False if lengths are not same */
    if (la != lb) {
        return False;
    }
    /* compare each feedback */
    for (i = 0; i < la; i++) {
        fa = &fba[i];
        type = IM_FEEDBACK_TYPE(fa);
        value = IM_FEEDBACK_VALUE(fa);
        exist = 0;
        for (j = 0; j < lb; j++) {
            fb = &fbb[j];
            if (type == IM_FEEDBACK_TYPE(fb)) {
                if (value != IM_FEEDBACK_VALUE(fb)) {
                    return False;
                }
                exist = 1;
            }
        }
        /* type does not exist in b */
        if (exist == 0) {
            return False;
        }
    }
    return True;
}

Here is the caller graph for this function:

Public int iml_add_listener ( iml_session_t s,
char *  attribute,
void *  listener,
void *  value 
)

Definition at line 1245 of file SunIMSubr.c.

{
    int hotkeyconf;
    int unique_listener_id = 0;

    hotkeyconf = lookup_config_for_listener(attribute, value);
    if (hotkeyconf == NS_REMOTE) { 
      unique_listener_id = s->desktop->addListenerToDesktop (s, listener, value);
      iml_ns_listener_ahead(s, unique_listener_id, value); 
    }
    return unique_listener_id;
}

Here is the call graph for this function:

Private void * iml_delete ( iml_session_t s)

Definition at line 1035 of file SunIMSubr.c.

{
    return slot_manager_free(s);
}

Here is the call graph for this function:

Public void * iml_delete2 ( iml_session_t s)

Definition at line 1043 of file SunIMSubr.c.

{
    return slot_manager_free2(s);
}

Here is the call graph for this function:

Public int iml_delete_listener ( iml_session_t s,
int  listener_id 
)

Definition at line 1268 of file SunIMSubr.c.

{
    return listener_id;
}

Definition at line 662 of file LE.cpp.

{
    IMLExec *pimlex = (IMLExec*) s->SessionContext;

#ifdef DEBUG
    {
       int op;
       iml_inst *pcur;

       for (pcur = *rrv; pcur != (iml_inst*)0; pcur = pcur->next) {
           op = pcur->opcode & ~IMM_CB_RESULT_REQUIRED;
           if (!pimlex)
              LOG_DEBUG("Missing IML inst. (%d)", op);
           else
              LOG_DEBUG("Issuing IML inst. (%d)", op);
       }
    }
#endif

    if (!pimlex) return NULL;
    return pimlex->push_insts(rrv);
}

Definition at line 929 of file SunIMSubr.c.

{
    register iml_inst *clp = *rrv;
    
    if (!(*rrv)) {
        *rrv = lp;
    } else {
        if (clp) {
            while (clp->next) {
                clp = clp->next;
            }
            clp->next = lp;
        } else {
            clp = lp;
        }
    }
    return *rrv;
}

Definition at line 702 of file SunIMSubr.c.

{
    iml_inst *lp = (iml_inst *) 0;
    IMAuxDoneCallbackStruct *ls;
    lp = (iml_inst *) s->If->m->iml_new(s, sizeof(iml_inst) +
                                   sizeof(IMAuxDoneCallbackStruct));
    lp->opcode = IMM_AUX_DONE_2;
    lp->next = NULL;
    ls = (IMAuxDoneCallbackStruct *) & lp->operand;
    
    ls->aux_name = (char *) a->aux_name;
    ls->aux_index = a->aux_index;
    
    return lp;
}

Definition at line 678 of file SunIMSubr.c.

Definition at line 661 of file SunIMSubr.c.

{
    iml_inst *lp = (iml_inst *) 0;
    IMAuxStartCallbackStruct *ls;
    lp = (iml_inst *) s->If->m->iml_new(s, sizeof(iml_inst) + sizeof(IMAuxStartCallbackStruct));
    lp->opcode = IMM_AUX_START_2;
    lp->next = NULL;
    ls = (IMAuxStartCallbackStruct *) & lp->operand;
    ls->aux_name = (char *) a->aux_name;
    ls->aux_index = a->aux_index;
    return lp;
}

Definition at line 802 of file SunIMSubr.c.

{
    iml_inst *rv;
    IMText *cs;
    
    if (!text || text->text.utf_chars == NULL || text->char_length <= 0) {
        return iml_make_nop_inst(s);
    }

    if(text->encoding != UTF16_CODESET){
        return iml_make_nop_inst(s);
    }

    if (text->char_length == 1 &&
       (text->text.utf_chars[0] < 0x20 || text->text.utf_chars[0] == 0x7f)) {
        IMKeyEventStruct *key = (IMKeyEventStruct *) s->If->m->iml_new(s, sizeof(IMKeyEventStruct));
        key->keyCode = text->text.utf_chars[0];
        key->keyChar = text->text.utf_chars[0];
        key->modifier = 0;
        key->time_stamp = 0;
        return iml_make_keypress_inst(s, key);
    }
    rv = (iml_inst *) s->If->m->iml_new(s, sizeof(iml_inst) + sizeof(IMText));
    rv->opcode = IMM_COMMIT;
    rv->next = NULL;
    rv->size_of_operand = sizeof(IMText);
    cs = (IMText *) & rv->operand;
    cs->encoding = UTF16_CODESET;
    cs->char_length = text->char_length;
    cs->text.utf_chars = text->text.utf_chars;
    cs->feedback = text->feedback;
    cs->count_annotations = text->count_annotations;
    cs->annotations = text->annotations;

    if (text->text.utf_chars[text->char_length - 1] < 0x20) {
        IMText *achar = (IMText *) s->If->m->iml_new(s, sizeof(IMText));
        achar->encoding = UTF16_CODESET;
        achar->char_length = 1;
        achar->text.utf_chars = (UTFCHAR *) s->If->m->iml_new(s, sizeof(UTFCHAR));
        achar->text.utf_chars[0] = text->text.utf_chars[text->char_length - 1];
        achar->feedback = NULL;
        achar->count_annotations = 0;
        achar->annotations = NULL;
        cs->char_length--;
        rv->next = s->If->m->iml_make_commit_inst(s, achar);
    }

    return rv;
}

Here is the call graph for this function:

Definition at line 876 of file SunIMSubr.c.

{
    iml_status_t *status;
    iml_inst *lp;
    s->public_status &= ~IMLSTATUS_Henkan_Mode;
    lp = (iml_inst *) s->If->m->iml_new(s, sizeof(iml_inst) + sizeof(iml_status_t));
    lp->opcode = IMM_SET_STATUS;
    lp->next = NULL;
    status = (iml_status_t *) & (lp->operand);
    *status = s->public_status;
    return lp;
}

Definition at line 895 of file SunIMSubr.c.

{
    iml_inst *rv;
    int sz = sizeof(IMKeyEventStruct) + 1;
    IMKeyEventStruct *kp;
    
    rv = (iml_inst *) s->If->m->iml_new(s, sizeof(iml_inst) + sz);
    rv->opcode = IMM_KEYPRESS;
    rv->next = NULL;
    rv->size_of_operand = sz;
    
    kp = (IMKeyEventStruct *) & rv->operand;
    
#ifdef DEBUG
    printf("iml_make_keypress_inst() keycode=%x\n", key->keyCode);
#endif
    
    kp->keyCode = key->keyCode;
    kp->keyChar = key->keyChar;
    kp->modifier = key->modifier;
    kp->time_stamp = key->time_stamp;
    
    return rv;
}

Here is the caller graph for this function:

Definition at line 787 of file SunIMSubr.c.

{
    iml_inst *lp;
    
    lp = (iml_inst *) s->If->m->iml_new(s, sizeof(iml_inst));
    lp->opcode = IMM_LOOKUP_DONE;
    lp->next = NULL;
    lp->size_of_operand = 0;
    INACTIVATE_REGION(s, LOOKUP);
    return lp;
}

Definition at line 751 of file SunIMSubr.c.

{
    iml_inst *lp;
    register IMLookupDrawCallbackStruct *ld;
    int i;
    
    if (draw == NULL) {
        return iml_make_nop_inst(s);
    }
    lp = (iml_inst *) s->If->m->iml_new(s,
                                   sizeof(iml_inst) + sizeof(IMLookupDrawCallbackStruct));
    lp->opcode = IMM_LOOKUP_DRAW;
    lp->next = NULL;
    ld = (IMLookupDrawCallbackStruct *) & lp->operand;
    
    ld->n_choices = draw->n_choices;
    ld->index_of_first_candidate = draw->index_of_first_candidate;
    ld->index_of_last_candidate = ld->n_choices - 1;
    ld->index_of_last_candidate = draw->index_of_last_candidate;
    ld->index_of_current_candidate = draw->index_of_current_candidate;
    ld->choices = (IMChoiceObject *) s->If->m->iml_new(s, ld->n_choices * sizeof(IMChoiceObject));
    ld->max_len = draw->max_len;
    ld->title = draw->title;
    
    for (i = 0; i < ld->n_choices; i++) {
        (ld->choices)[i].value = (draw->choices)[i].value;
        (ld->choices)[i].label = draw->choices[i].label;
    }
    
    return lp;
}

Here is the call graph for this function:

Definition at line 726 of file SunIMSubr.c.

{
    iml_inst *lp;
    IMLookupStartCallbackStruct *ls;
    if (start == NULL) {
        lp = iml_make_nop_inst(s);
        return lp;
    }
    lp = (iml_inst *) s->If->m->iml_new(s, sizeof(iml_inst) +
                                   sizeof(IMLookupStartCallbackStruct));
    lp->opcode = IMM_LOOKUP_START | IMM_CB_RESULT_REQUIRED;
    lp->next = NULL;
    ACTIVATE_REGION(s, LOOKUP);
    ls = (IMLookupStartCallbackStruct *) & lp->operand;
    ls->event = NULL;
    ls->whoIsMaster = start->whoIsMaster;
    ls->IMPreference = start->IMPreference;
    ls->CBPreference = NULL;
    return lp;
}

Here is the call graph for this function:

Definition at line 956 of file SunIMSubr.c.

{
    iml_inst *lp;
    
    lp = (iml_inst *) s->If->m->iml_new(s, sizeof(iml_inst));
    lp->opcode = IMM_NOP;
    lp->next = NULL;
    lp->size_of_operand = 0;
    return lp;
}

Here is the caller graph for this function:

Definition at line 508 of file SunIMSubr.c.

{
    IMPreeditDrawCallbackStruct *p;
    iml_inst *lp;
    lp = (iml_inst *) s->If->m->iml_new(s, sizeof(iml_inst) + sizeof(IMPreeditDrawCallbackStruct));
    lp->opcode = IMM_PREEDIT_DRAW;
    lp->next = NULL;
    
    p = (IMPreeditDrawCallbackStruct *) & (lp->operand);
    p->text = NULL;         /* delete */
    p->chg_first = 0;
    p->chg_length = 0;             /* nothing will be changed */
    p->caret = caret;              /* only set caret position */
    
    return lp;
}

Definition at line 557 of file SunIMSubr.c.

{
    iml_inst *lp;
    
    lp = (iml_inst *) s->If->m->iml_new(s, sizeof(iml_inst));
    lp->opcode = IMM_PREEDIT_DONE;
    lp->next = NULL;
    lp->size_of_operand = 0;
    INACTIVATE_REGION(s, PREEDIT);
    return lp;
}

Definition at line 386 of file SunIMSubr.c.

{
    if (text && text->encoding != UTF16_CODESET) {
        return (iml_make_nop_inst(s));
    }
    return iml_make_preedit_draw_with_caret_inst(s, text, -1);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 200 of file SunIMSubr.c.

{
    iml_inst *lp;
    IMPreeditDrawCallbackStruct *p;
    
    UTFCHAR *cws;           /* current str */
    IMFeedbackList *cfb;    /* current feedback */
    UTFCHAR *pws;           /* prev str */
    int pwl;                /* prev len */
    IMFeedbackList *pfb;    /* prev fb */
    int cwl;                /* current len */
    int si;                 /* str index */
    int sri;                /* str reverse index */
    int fbi;                /* fb index */
    int fbri;               /* fb reverse index */
    int i;                  /* index */
    int j;
    int ri;
    
    if (text && text->encoding != UTF16_CODESET) {
        return (iml_make_nop_inst(s));
    }
    if (!text || text->char_length <= 0) {
        return (iml_make_preedit_erase_inst(s));
    }
    cws = text->text.utf_chars;
    cwl = text->char_length;
    cfb = text->feedback;
    
    if (!cfb) {
        return (iml_make_nop_inst(s));
    }
    pws = s->PreEditTextInfo.text->text.utf_chars;
    pwl = s->PreEditTextInfo.text->char_length;
    pfb = s->PreEditTextInfo.text->feedback;
    
#ifdef DEBUG
    printf("## CWS ##\n");
    //list_imtext(text);
    
    printf("## PWS ##\n");
    //list_imtext(s->PreEditTextInfo.text);
#endif
    
    ri = pwl;
    
    /* Compare by utf_chars */
    for (si = 0; si < pwl; si++) {
        if (pws[si] != cws[si]) {
            break;
        }
    }
    
    if (cwl && (pwl == cwl)) {
        for (sri = pwl - 1; sri >= 0; sri--) {
            if (pws[sri] != cws[sri]) {
                break;
            }
        }
        for (fbri = pwl - 1; fbri >= 0; fbri--) {
            if (compare_feedbacks(&pfb[fbri], &cfb[fbri]) == False) {
                break;
            }
        }
        ri = _MAX(sri, fbri);
    }
#ifdef DEBUG
    printf("## PWS ##\n");
    //list_feedback(pwl, pfb);
    
    printf("## CWS ##\n");
    //list_feedback(pwl, cfb);
#endif
    
    for (fbi = 0; fbi < pwl; fbi++) {
        if (compare_feedbacks(&pfb[fbi], &cfb[fbi]) == False) {
            break;
        }
    }
    
    i = _MIN(si, fbi);
    
    if (caret == -1 && pwl == cwl && i == cwl) {
        /*
        * Current preedit is the same as previous
        */
        return (iml_make_nop_inst(s));
    }

    lp = (iml_inst *) s->If->m->iml_new(s,
                                   sizeof(iml_inst)
                                   + sizeof(IMPreeditDrawCallbackStruct));
    lp->opcode = IMM_PREEDIT_DRAW;
    lp->next = NULL;
    
    p = (IMPreeditDrawCallbackStruct *) & (lp->operand);
    p->text = (IMText *) s->If->m->iml_new(s, sizeof(IMText));
    p->text->encoding = UTF16_CODESET;
    p->text->feedback = cfb + i;
    p->text->count_annotations = 0;
    p->text->annotations = 0;
    if ((p->text->char_length = cwl - i) <= 0) {
        if (cwl < pwl) {
            p->text = NULL;
        } else {
            p->text->text.utf_chars = NULL;
        }
    } else {
        p->text->text.utf_chars = cws + i;
    }
    p->chg_first = i;
    p->chg_length = pwl - i;
    
    if (caret == -1) {
        p->caret = cwl;            /* iml_make_preedit_draw_inst() */
    } else {
        p->caret = caret;   /* caret is specified */
    }
    
#ifdef DEBUG
    printf("iml_make_preedit_draw_with_caret_inst()\n");
    printf("  chg_first=%d\n", p->chg_first);
    printf("  chg_length=%d\n", p->chg_length);
    printf("  caret=%d\n", p->caret);
#endif
    
#ifdef IML_API_TEST
    /*
     * testing for text deletion and insertion
     */
    return iml_make_preedit_draw_with_chgpos_inst(
        s,
        p->text,
        p->chg_first,
        p->chg_length,
        p->caret);
#endif
    
    /* buffer overflow */
    if ((cwl + 1) > s->PreEditTextBufferSize) {
        IMFeedbackList *flist;
        free(s->PreEditTextInfo.text->text.utf_chars);
        free(s->PreEditTextInfo.text->feedback);
        for (i = 0; i < s->PreEditTextBufferSize; i++) {
            flist = &s->PreEditTextInfo.text->feedback[i];
            if (flist) {
                free(flist->feedbacks);
            }
        }
        free(s->PreEditTextInfo.text->feedback);
        s->PreEditTextInfo.text->text.utf_chars = (UTFCHAR *) calloc(1, sizeof(UTFCHAR) * (cwl + 1));
        
        s->PreEditTextInfo.text->feedback = (IMFeedbackList *) calloc(1, sizeof(IMFeedbackList) * (cwl + 1));
        for (i = 0; i < cwl + 1; i++) {
            flist = &s->PreEditTextInfo.text->feedback[i];
            flist->feedbacks = (IMFeedback *) calloc(1, sizeof(IMFeedback) * DEFAULTFeedbackSize);
        }
        
        s->PreEditTextBufferSize = cwl + 1;
        s->PreEditAttrBufferSize = cwl + 1;
    }
    s->PreEditTextInfo.text->char_length = cwl;
    memcpy(s->PreEditTextInfo.text->text.utf_chars, cws, cwl * sizeof(UTFCHAR));
    
    /*
     * save current string as previous string
     */
    for (i = 0; i < cwl; i++) {
        IMFeedbackList *fblp = &s->PreEditTextInfo.text->feedback[i];
        IMFeedbackList *fblc = &cfb[i];
        fblp->count_feedbacks = fblc->count_feedbacks;
        for (j = 0; j < fblc->count_feedbacks; j++) {
            IMFeedback *fbp = &fblp->feedbacks[j];
            IMFeedback *fbc = &fblc->feedbacks[j];
            IM_FEEDBACK_TYPE(fbp) = IM_FEEDBACK_TYPE(fbc);
            IM_FEEDBACK_VALUE(fbp) = IM_FEEDBACK_VALUE(fbc);
        }
    }
    return lp;
}

Here is the call graph for this function:

Private iml_inst * iml_make_preedit_draw_with_chgpos_inst ( iml_session_t s,
IMText text,
int  chg_pos,
int  chg_len,
int  caret 
)

Definition at line 398 of file SunIMSubr.c.

{
    iml_inst *lp;
    IMPreeditDrawCallbackStruct *p;
    UTFCHAR *preedit_buf;
    IMFeedbackList *feedback_buf;
    int cwl;                /* current len */
    int i = 0;
    int j;
    
    if (text && text->encoding != UTF16_CODESET) {
        return (iml_make_nop_inst(s));
    }
    lp = (iml_inst *) s->If->m->iml_new(s, sizeof(iml_inst) + sizeof(IMPreeditDrawCallbackStruct));
    lp->opcode = IMM_PREEDIT_DRAW;
    lp->next = NULL;
    
    p = (IMPreeditDrawCallbackStruct *) & (lp->operand);
    p->text = (IMText *) s->If->m->iml_new(s, sizeof(IMText));
    
    if (text == NULL) {
        /*
        * deletion
        */
        p->text = NULL;
    } else {
        /* feedback is required */
        if (!text->feedback) {
            return (iml_make_nop_inst(s));
        }
        p->text->encoding = UTF16_CODESET;
        p->text->text.utf_chars = text->text.utf_chars;
        p->text->char_length = text->char_length;
        p->text->feedback = text->feedback;
        p->text->count_annotations = text->count_annotations;
        p->text->annotations = text->annotations;
    }
    
    p->chg_first = chg_pos;
    p->chg_length = chg_len;
    p->caret = caret;
    
#ifdef DEBUG
    printf("iml_make_preedit_draw_with_chgpos_inst()\n");
    if (text != NULL) {
        printf("     utf_char_length=%d\n", p->text->char_length);
    }
    printf("  chg_first=%d\n", p->chg_first);
    printf("  chg_length=%d\n", p->chg_length);
    printf("  caret=%d\n", p->caret);
#endif
    
    preedit_buf = (UTFCHAR *) s->If->m->iml_new(s, sizeof(UTFCHAR) * DEFAULTPreEditTextBufferSize);
    feedback_buf = (IMFeedbackList *) s->If->m->iml_new(s, sizeof(IMFeedbackList) * DEFAULTPreEditAttrBufferSize);
    
    cwl = 0;
    
    for (i = 0; i < p->chg_first; i++, cwl++) {
        preedit_buf[cwl] = s->PreEditTextInfo.text->text.utf_chars[i];
        feedback_buf[cwl] = s->PreEditTextInfo.text->feedback[i];
    }
    if (text != NULL) {
        for (i = 0; i < p->text->char_length; i++, cwl++) {
            preedit_buf[cwl] = p->text->text.utf_chars[i];
            feedback_buf[cwl] = p->text->feedback[i];
        }
    }
    for (i = p->chg_first + p->chg_length; i < s->PreEditTextInfo.text->char_length; i++, cwl++) {
        preedit_buf[cwl] = s->PreEditTextInfo.text->text.utf_chars[i];
        feedback_buf[cwl] = s->PreEditTextInfo.text->feedback[i];
    }
    preedit_buf[cwl] = 0;
    
    /*
     * save current string as previous string
     */
    if ((cwl + 1) > s->PreEditTextBufferSize) {
        free(s->PreEditTextInfo.text->text.utf_chars);
        free(s->PreEditTextInfo.text->feedback);
        s->PreEditTextInfo.text->text.utf_chars = (UTFCHAR *) calloc(sizeof(UTFCHAR), cwl + 1);
        s->PreEditTextInfo.text->feedback = (IMFeedbackList *) calloc(sizeof(IMFeedbackList), cwl);
        s->PreEditTextBufferSize = cwl + 1;
        s->PreEditAttrBufferSize = cwl + 1;
    }
    s->PreEditTextInfo.text->char_length = cwl;
    
    memcpy(s->PreEditTextInfo.text->text.utf_chars, preedit_buf,
          cwl * sizeof(UTFCHAR));

    for (i = 0; i < cwl; i++) {
        IMFeedbackList *fblp = &s->PreEditTextInfo.text->feedback[i];
        IMFeedbackList *fblc = &feedback_buf[i];
        fblp->count_feedbacks = fblc->count_feedbacks;
        for (j = 0; j < fblc->count_feedbacks; j++) {
            IMFeedback *fbp = &fblp->feedbacks[j];
            IMFeedback *fbc = &fblc->feedbacks[j];
            IM_FEEDBACK_TYPE(fbp) = IM_FEEDBACK_TYPE(fbc);
            IM_FEEDBACK_VALUE(fbp) = IM_FEEDBACK_VALUE(fbc);
        }
    }
    return lp;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 529 of file SunIMSubr.c.

{
    IMPreeditDrawCallbackStruct *p;
    iml_inst *lp;
    
    lp = (iml_inst *) s->If->m->iml_new(s, sizeof(iml_inst) + sizeof(IMPreeditDrawCallbackStruct));
    lp->opcode = IMM_PREEDIT_DRAW;
    lp->next = NULL;
    p = (IMPreeditDrawCallbackStruct *) & (lp->operand);
    p->chg_first = 0;
    p->text = (IMText *) s->If->m->iml_new(s, sizeof(IMText));
    
    p->text->encoding = UTF16_CODESET;
    p->text->text.utf_chars = NULL;
    p->text->char_length = 0;
    p->text->feedback = NULL;
    p->text->count_annotations = 0;
    p->text->annotations = NULL;
    
    p->chg_length = s->PreEditTextInfo.text->char_length;      /* previous length */
    s->PreEditTextInfo.text->char_length = 0;
    p->caret = 0;
    return lp;
}

Here is the caller graph for this function:

Definition at line 141 of file SunIMSubr.c.

{
    iml_inst *lp;
    lp = (iml_inst *) s->If->m->iml_new(s, sizeof(iml_inst));
    ACTIVATE_REGION(s, PREEDIT);
    lp->opcode = IMM_PREEDIT_START;
    lp->next = NULL;
    lp->size_of_operand = 0;
    return lp;
}

Definition at line 860 of file SunIMSubr.c.

{
    iml_status_t *status;
    iml_inst *lp;
    s->public_status |= IMLSTATUS_Henkan_Mode;
    lp = (iml_inst *) s->If->m->iml_new(s, sizeof(iml_inst) + sizeof(iml_status_t));
    lp->opcode = IMM_SET_STATUS;
    lp->next = NULL;
    status = (iml_status_t *) & (lp->operand);
    *status = s->public_status;
    return lp;
}

Definition at line 643 of file SunIMSubr.c.

{
    iml_inst *lp;
    
    lp = (iml_inst *) s->If->m->iml_new(s, sizeof(iml_inst));
    lp->opcode = IMM_STATUS_DONE;
    lp->next = NULL;
    lp->size_of_operand = 0;
    INACTIVATE_REGION(s, STATUS);
    return lp;
}

Definition at line 589 of file SunIMSubr.c.

{
    int i, j;
    iml_inst *lp;
    IMStatusDrawCallbackStruct *q;

    if (text == NULL) {
        return iml_make_nop_inst(s);
    }

    if (text->encoding != UTF16_CODESET) {
        return iml_make_nop_inst(s);
    }
    
    lp = (iml_inst *) s->If->m->iml_new(s, sizeof(iml_inst) + sizeof(IMStatusDrawCallbackStruct));
    
    lp->opcode = IMM_STATUS_DRAW;
    lp->next = NULL;

    q = (IMStatusDrawCallbackStruct *) & lp->operand;
    q->text = (IMText *) s->If->m->iml_new(s, sizeof(IMText));
    
    q->text->encoding = UTF16_CODESET;
    q->text->text.utf_chars = text->text.utf_chars;
    q->text->char_length = text->char_length;
    q->text->feedback = text->feedback;
    q->text->count_annotations = 0;
    q->text->annotations = NULL;
    
    /* copy feedback */
    for (i = 0; i < text->char_length; i++) {
        IMFeedbackList *fblfrom = &text->feedback[i];
        IMFeedbackList *fblto = &s->status_cache.text->feedback[i];
        int fcount = IM_FEEDBACK_COUNT(fblfrom);
       IM_FEEDBACK_COUNT(fblto) = IM_FEEDBACK_COUNT(fblfrom);
        for (j = 0; j < fcount; j++) {
            IMFeedback *fbfrom = &fblfrom->feedbacks[j];
            IMFeedback *fbto = &fblto->feedbacks[j];
           IM_FEEDBACK_TYPE(fbto) = IM_FEEDBACK_TYPE(fbfrom);
           IM_FEEDBACK_VALUE(fbto) = IM_FEEDBACK_VALUE(fbfrom);
        }
    }
    memcpy(s->status_cache.text->text.utf_chars,
          text->text.utf_chars,
          sizeof(UTFCHAR) * text->char_length);
    s->status_cache.text->char_length = text->char_length;
    
    return lp;
}

Here is the call graph for this function:

Definition at line 575 of file SunIMSubr.c.

{
    iml_inst *lp;
    lp = (iml_inst *) s->If->m->iml_new(s, sizeof(iml_inst));
    ACTIVATE_REGION(s, STATUS);
    lp->opcode = IMM_STATUS_START;
    lp->next = NULL;
    lp->size_of_operand = 0;
    return lp;
}
Private void * iml_new ( iml_session_t s,
int  size 
)

Definition at line 1011 of file SunIMSubr.c.

{
    size = ALIGN16(size);
    if (MEM_BLOCK_MAX_SIZE < size) {
       return slot_manager_alloc_mem_elem(s, size);
    } else {
       return slot_manager_alloc_small(s, size);
    }
}

Here is the call graph for this function:

Private void * iml_new2 ( iml_session_t s,
int  size 
)

Definition at line 1025 of file SunIMSubr.c.

{
    size = ALIGN16(size);
    return slot_manager_alloc_mem_elem2(s, size);
}

Here is the call graph for this function:

Private void iml_ns_listener_ahead ( iml_session_t s,
int  ulid,
void *  value 
)

Definition at line 1222 of file SunIMSubr.c.

{
    IMNSListenerStruct *nsl;
    iml_inst *lp;
    iml_nsl *p = (iml_nsl *)value ;

    lp = (iml_inst *) s->If->m->iml_new(s, sizeof(iml_inst) + sizeof(IMNSListenerStruct));

    lp->opcode = IMM_NS_LISTENER; lp->next = NULL; 
    nsl = (IMNSListenerStruct *) & (lp->operand); 
    nsl->self = nsl ; /* paranoia */
    nsl->listener_id = ulid;
    nsl->filename = secure_pathname(p->path_name);
    (iml_inst *) s->If->m->iml_execute(s, &lp);
    (iml_inst *) s->If->m->iml_delete(s);

}

Here is the call graph for this function:

Here is the caller graph for this function:

Private int lookup_config_for_listener ( char *  attr,
void *  value 
)

Definition at line 1277 of file SunIMSubr.c.

{
    /* TODO!! This also needs to be modified the same way as NS based I/O APIs */
    return NS_REMOTE; 
}

Here is the caller graph for this function:

char* secure_pathname ( char *  )

Definition at line 725 of file SunIM.c.

{
    char *q ;
    int index = 0;

    while (*p) {
        if ((q = (strstr(p, "../")))) {
            index = p - q;
            if (index < 0)
                index = -index;
            strcpy(p+index, p+index+3);
        } else if ((q = (strstr(p, "//")))) {
            index = p - q;
            if (index < 0)
                index = -index;
            strcpy(p+index, p+index+1);
        } else if ((q = (strstr(p, "./")))) {
            index = p - q;
            if (index < 0)
                index = -index;
            strcpy(p+index, p+index+2);
        } else {
            break ;
        }
    }
    return p;
}

Here is the caller graph for this function:

Private void * slot_manager_alloc_mem_elem ( iml_session_t s,
int  size 
)

Definition at line 1125 of file SunIMSubr.c.

{
    iml_inst_mem_elem_list_t * mel;

    size += MEM_ELEM_HEADER_SIZE;

    mel = malloc(size);
    if (NULL == mel) {
       return NULL;
    }

    mel->next = s->mem_elem_short_term;
    s->mem_elem_short_term = mel;

    return (((char *)mel) + MEM_ELEM_HEADER_SIZE);
}

Here is the caller graph for this function:

Private void * slot_manager_alloc_mem_elem2 ( iml_session_t s,
int  size 
)

Definition at line 1146 of file SunIMSubr.c.

{
    iml_inst_mem_elem_list_t * mel;

    size += MEM_ELEM_HEADER_SIZE;

    mel = malloc(size);
    if (NULL == mel) {
       return NULL;
    }

    mel->next = s->mem_elem_long_term;
    s->mem_elem_long_term = mel;

    return (((char *)mel) + MEM_ELEM_HEADER_SIZE);
}

Here is the caller graph for this function:

Private void * slot_manager_alloc_small ( iml_session_t s,
int  size 
)

Definition at line 1074 of file SunIMSubr.c.

{
    iml_inst_mem_block_list_t * mbl;
    void * retp;

    mbl = s->mem_block_short_term_small;
    while (NULL != mbl) {
       if (size <= mbl->rest) {
           if (mbl->rest < 1024) {
              retp = 0;
           }
           retp = (((char *)mbl) + mbl->used);

           mbl->used += size;
           mbl->rest -= size;

           return retp;
       }

       mbl = mbl->next;
    }

    SUNIM_LOCK(memory_block_mutex);

    if (NULL == memory_block_list) {
       SUNIM_UNLOCK(memory_block_mutex);

       mbl = malloc(MEM_BLOCK_SIZE);
       if (NULL == mbl) {
           return NULL;
       }
    } else {
       mbl = memory_block_list;
       memory_block_list = mbl->next;

       SUNIM_UNLOCK(memory_block_mutex);
    }

    mbl->used = MEM_BLOCK_HEADER_SIZE;
    mbl->size = (MEM_BLOCK_SIZE - mbl->used);
    mbl->rest = (MEM_BLOCK_SIZE - mbl->used);
    mbl->next = s->mem_block_short_term_small;
    s->mem_block_short_term_small = mbl;

    return slot_manager_alloc_small(s, size);
}

Here is the caller graph for this function:

Definition at line 1167 of file SunIMSubr.c.

{
    iml_inst_mem_block_list_t * mbl;
    iml_inst_mem_elem_list_t * mel;
    iml_inst_mem_elem_list_t * mel_n;

    mbl = s->mem_block_short_term_small;
    if (NULL != mbl) {
       while ((NULL != mbl->next)) {
           mbl = mbl->next;
       }

       SUNIM_LOCK(memory_block_mutex);
       mbl->next = memory_block_list;
       memory_block_list = s->mem_block_short_term_small;
       SUNIM_UNLOCK(memory_block_mutex);

       s->mem_block_short_term_small = NULL;
    }

    mel = s->mem_elem_short_term;
    while (NULL != mel) {
       mel_n = mel->next;
       free(mel);
       mel = mel_n;
    }

    s->mem_elem_short_term = NULL;

    return NULL;
}

Here is the caller graph for this function:

Definition at line 1202 of file SunIMSubr.c.

{
    iml_inst_mem_elem_list_t * mel;
    iml_inst_mem_elem_list_t * mel_n;

    mel = s->mem_elem_long_term;
    while (NULL != mel) {
       mel_n = mel->next;
       free(mel);
       mel = mel_n;
    }

    s->mem_elem_long_term = NULL;

    return NULL;
}

Here is the caller graph for this function:

Definition at line 1059 of file SunIMSubr.c.

{
#ifdef sun
#elif   WIN32
    if ((memory_block_mutex = CreateMutex(NULL, FALSE, NULL)) == 0) {
        printf("WIN32 Thread: CreateMutex() ERROR\n");
        return;
    }
#else  /* Linux */
#endif
}

Variable Documentation

Definition at line 98 of file SunIMSubr.c.

iml_inst_mem_block_list_t* memory_block_list [static]

Definition at line 1071 of file SunIMSubr.c.

pthread_mutex_t memory_block_mutex

Definition at line 1055 of file SunIMSubr.c.