Back to index

im-sdk  12.3.91
Functions
iiimpConv.h File Reference
#include "iiimpIM.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

IIIMF_status IIimpConvertToXIMText (IIIMCF_text text, XIMText *pxt, IMFeedbackList **ppfeedbacks, Bool useUnicode)
IIIMF_status IIimpUTF16ToString (const IIIMP_card16 *ucstr, Bool useUnicode, char **pstr)

Function Documentation

IIIMF_status IIimpConvertToXIMText ( IIIMCF_text  text,
XIMText *  pxt,
IMFeedbackList **  ppfeedbacks,
Bool  useUnicode 
)

Definition at line 617 of file iiimpConv.c.

{
    IIIMF_status st;
    IIIMP_card16 ch;
    const IIIMP_card32 *pids, *pfbs;
    XIMFeedback *ximfb = NULL, *ximfb_top = NULL;
    IMFeedbackList *pfl = NULL, *pfl2 = NULL;
    IMFeedback *pfb, *pfb2;
    int i, len;
    int j, nfb;
    Bool has_feedback = False;

    memset(pxt, 0, sizeof(*pxt));
    st = iiimcf_get_text_length(text, &len); 
    if (st != IIIMF_STATUS_SUCCESS) goto error;
    if (len == 0) {
       if (ppfeedbacks) *ppfeedbacks = NULL;
       return IIIMF_STATUS_SUCCESS;
    }

    pfl = pfl2 = NULL;
    ximfb_top = ximfb = (XIMFeedback*) Xmalloc(sizeof(*ximfb) * len);
    memset(ximfb, 0, sizeof(*ximfb) * len);
    if (!ximfb) goto memory_error;
    if (ppfeedbacks) {
       pfl = pfl2 = (IMFeedbackList*) Xmalloc(sizeof(*pfl) * len);
       if (!pfl) goto memory_error;
       memset(pfl, 0, sizeof(*pfl) * len);
    }
    pxt->feedback = ximfb;
    pxt->length = len;

    for (i = 0; i < len; i++, ximfb++) {
       st = iiimcf_get_char_with_feedback(text, i, &ch, &nfb, &pids, &pfbs);
       if (st != IIIMF_STATUS_SUCCESS) goto error;
       if (pfl) {
           int count_nfb = 0;
           pfb = pfb2 = (IMFeedback*) Xmalloc(sizeof(IMFeedback) * nfb);
           if (!pfb) goto memory_error;
           for (j = 0; j < nfb; j++, pids++, pfbs++) {
              if (*pids == 0)
                *ximfb = *pfbs;
              else {
                has_feedback = True;
                pfb2->type = *pids;
                pfb2->value = *pfbs;
                pfb2++;
                count_nfb++;
              }
           }
           pfl2->count_feedbacks = count_nfb;
           pfl2->feedbacks = pfb;
           pfl2++;
       } else {
           for (j = 0; j < nfb; j++, pids++) {
              if (*pids == 0) {
                  *ximfb = pfbs[j];
                  break;
              }
           }
       }
    }

    st = IIimpConvertToString(text, useUnicode, &pxt->string.multi_byte);
    if (st != IIIMF_STATUS_SUCCESS) goto error;

    if (ppfeedbacks) {
      if (!has_feedback) {
       FreeFeedbackList(pfl, len);
        pfl = NULL;
      }
      *ppfeedbacks = pfl;
    }

    return IIIMF_STATUS_SUCCESS;

memory_error:
    st = IIIMF_STATUS_MALLOC;
error:
    if (ximfb_top) free(ximfb_top);
    if (pfl) FreeFeedbackList(pfl, len);
    if (pxt->string.multi_byte) free(pxt->string.multi_byte);

    return st;
}

Here is the call graph for this function:

Here is the caller graph for this function:

IIIMF_status IIimpUTF16ToString ( const IIIMP_card16 ucstr,
Bool  useUnicode,
char **  pstr 
)

Definition at line 581 of file iiimpConv.c.

{
    int len;

    for (len = 0; ucstr[len]; len++);
    return UTF16ToString(len, ucstr, useUnicode, pstr);
}

Here is the call graph for this function:

Here is the caller graph for this function: