Back to index

im-sdk  12.3.91
Defines | Functions
comp-imeinfo.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <iiimp-data.h>
#include "iiimp-dataP.h"

Go to the source code of this file.

Defines

#define IMEINFO_OBJECT_SIZE   4 * 9

Functions

IIIMP_imeinfoiiimp_imeinfo_new (IIIMP_data_s *data_s, IIIMP_card32 enable, IIIMP_string *ime_id, IIIMP_string *imename, IIIMP_string *version, IIIMP_string *description, IIIMP_string *author, IIIMP_string *copyright, IIIMP_string *reserved1, IIIMP_string *reserved2)
void iiimp_imeinfo_delete (IIIMP_data_s *data_s, IIIMP_imeinfo *imeinfo)
void iiimp_imeinfo_list_delete (IIIMP_data_s *data_s, IIIMP_imeinfo *imeinfo)
void iiimp_imeinfo_pack (IIIMP_data_s *data_s, IIIMP_imeinfo *m, size_t *nbyte, uchar_t **ptr)
void iiimp_imeinfo_list_pack (IIIMP_data_s *data_s, IIIMP_imeinfo *m, size_t *nbyte, uchar_t **ptr)
IIIMP_imeinfoiiimp_imeinfo_unpack (IIIMP_data_s *data_s, size_t *nbyte, const uchar_t **ptr, size_t nbyte_max)
IIIMP_imeinfoiiimp_imeinfo_list_unpack (IIIMP_data_s *data_s, size_t *nbyte, const uchar_t **ptr, size_t nbyte_max)

Define Documentation

#define IMEINFO_OBJECT_SIZE   4 * 9

Definition at line 10 of file comp-imeinfo.c.


Function Documentation

void iiimp_imeinfo_delete ( IIIMP_data_s *  data_s,
IIIMP_imeinfo imeinfo 
)

Definition at line 91 of file comp-imeinfo.c.

{
    if (NULL == imeinfo) return;
    iiimp_string_delete(data_s, imeinfo->ime_id);
    iiimp_string_delete(data_s, imeinfo->imename);
    iiimp_string_delete(data_s, imeinfo->version);
    iiimp_string_delete(data_s, imeinfo->description);
    iiimp_string_delete(data_s, imeinfo->author);
    iiimp_string_delete(data_s, imeinfo->copyright);
    iiimp_string_delete(data_s, imeinfo->reserved1);
    iiimp_string_delete(data_s, imeinfo->reserved2);
    free(imeinfo);
    return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void iiimp_imeinfo_list_delete ( IIIMP_data_s *  data_s,
IIIMP_imeinfo imeinfo 
)

Definition at line 107 of file comp-imeinfo.c.

{
    IIIMP_imeinfo *  imeinfo_next;
    for (; NULL != imeinfo; imeinfo = imeinfo_next) {
       imeinfo_next = imeinfo->next;
       iiimp_imeinfo_delete(data_s, imeinfo);
    }
    return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void iiimp_imeinfo_list_pack ( IIIMP_data_s *  data_s,
IIIMP_imeinfo m,
size_t *  nbyte,
uchar_t **  ptr 
)

Definition at line 148 of file comp-imeinfo.c.

{
    size_t    rest;
    uchar_t * p;

    rest = *nbyte;
    p = *ptr;

    for (; NULL != m; m = m->next) {
       iiimp_imeinfo_pack(data_s, m, &rest, &p);
    }

    *nbyte -= rest;
    *ptr = p;

    return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

IIIMP_imeinfo* iiimp_imeinfo_list_unpack ( IIIMP_data_s *  data_s,
size_t *  nbyte,
const uchar_t **  ptr,
size_t  nbyte_max 
)

Definition at line 222 of file comp-imeinfo.c.

{
    IIIMP_imeinfo *    imeinfo;
    size_t              rest;
    const uchar_t *     p;
    IIIMP_imeinfo *    imeinfo_first;
    IIIMP_imeinfo *    imeinfo_last;

    if (nbyte_max == 0) return NULL;

    rest = nbyte_max;
    p = *ptr;
    imeinfo = NULL;
    imeinfo_first = NULL;
    imeinfo_last = NULL;

    if ((*nbyte < rest) || (rest < IMEINFO_OBJECT_SIZE)) {
       data_s->status = IIIMP_DATA_INVALID;
       return NULL;
    }

    while (0 < rest) {
       imeinfo = iiimp_imeinfo_unpack(data_s, &rest, &p, rest);
       if (NULL == imeinfo) {
          /* imeinfo is optional, so it is ok if imeinfo is NULL */
          break;
       } else {
           if (NULL == imeinfo_first) {
              imeinfo_first = imeinfo;
           } else {
              imeinfo_last->next = imeinfo;
           }
           imeinfo_last = imeinfo;
       }
    }

    *nbyte -= (nbyte_max - rest);
    *ptr = p;

    return imeinfo_first;
}

Here is the call graph for this function:

Here is the caller graph for this function:

IIIMP_imeinfo* iiimp_imeinfo_new ( IIIMP_data_s *  data_s,
IIIMP_card32  enable,
IIIMP_string ime_id,
IIIMP_string imename,
IIIMP_string version,
IIIMP_string description,
IIIMP_string author,
IIIMP_string copyright,
IIIMP_string reserved1,
IIIMP_string reserved2 
)

Definition at line 13 of file comp-imeinfo.c.

{
    IIIMP_imeinfo *  imeinfo;

    imeinfo = (IIIMP_imeinfo *)malloc(sizeof (IIIMP_imeinfo));
    if (NULL == imeinfo) {
       data_s->status = IIIMP_DATA_MALLOC_ERROR;
       return NULL;
    }

    imeinfo->nbyte = 4; /* for enable */
    imeinfo->next = NULL;

    if (NULL == ime_id) {
       imeinfo->nbyte += 4;
    } else {
       imeinfo->nbyte += ime_id->nbyte;
    }
    if (NULL == imename) {
       imeinfo->nbyte += 4;
    } else {
       imeinfo->nbyte += imename->nbyte;
    }
    if (NULL == version) {
       imeinfo->nbyte += 4;
    } else {
       imeinfo->nbyte += version->nbyte;
    }
    if (NULL == description) {
       imeinfo->nbyte += 4;
    } else {
       imeinfo->nbyte += description->nbyte;
    }
    if (NULL == author) {
        imeinfo->nbyte += 4;
    } else {
        imeinfo->nbyte += author->nbyte;
    }
    if (NULL == copyright) {
        imeinfo->nbyte += 4;
    } else {
        imeinfo->nbyte += copyright->nbyte;
    }
    if (NULL == reserved1) {
        imeinfo->nbyte += 4;
    } else {
        imeinfo->nbyte += reserved1->nbyte;
    }
    if (NULL == reserved2) {
        imeinfo->nbyte += 4;
    } else {
        imeinfo->nbyte += reserved2->nbyte;
    }

    imeinfo->enable = enable;
    imeinfo->ime_id = ime_id;
    imeinfo->imename = imename;
    imeinfo->version = version;
    imeinfo->description = description;
    imeinfo->author = author;
    imeinfo->copyright = copyright;
    imeinfo->reserved1 = reserved1;
    imeinfo->reserved2 = reserved2;

    return imeinfo;
}

Here is the caller graph for this function:

void iiimp_imeinfo_pack ( IIIMP_data_s *  data_s,
IIIMP_imeinfo m,
size_t *  nbyte,
uchar_t **  ptr 
)

Definition at line 118 of file comp-imeinfo.c.

{
    size_t    rest;
    uchar_t * p;

    rest = *nbyte;
    p = *ptr;

    PUT32(m->enable, rest, p, data_s->byte_swap);
    iiimp_string_pack(data_s, m->ime_id, &rest, &p);
    iiimp_string_pack(data_s, m->imename, &rest, &p);
    iiimp_string_pack(data_s, m->version, &rest, &p);
    iiimp_string_pack(data_s, m->description, &rest, &p);
    iiimp_string_pack(data_s, m->author, &rest, &p);
    iiimp_string_pack(data_s, m->copyright, &rest, &p);
    iiimp_string_pack(data_s, m->reserved1, &rest, &p);
    iiimp_string_pack(data_s, m->reserved2, &rest, &p);

    *nbyte -= rest;
    *ptr = p;

    return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

IIIMP_imeinfo* iiimp_imeinfo_unpack ( IIIMP_data_s *  data_s,
size_t *  nbyte,
const uchar_t **  ptr,
size_t  nbyte_max 
)

Definition at line 172 of file comp-imeinfo.c.

{
    IIIMP_imeinfo *    imeinfo;
    size_t              rest;
    const uchar_t *     p;

    if (nbyte_max == 0) return NULL;

    rest = nbyte_max;
    p = *ptr;

    if ((*nbyte < rest) || (rest < IMEINFO_OBJECT_SIZE)) {
       data_s->status = IIIMP_DATA_INVALID;
       return NULL;
    }

    imeinfo = (IIIMP_imeinfo *)malloc(sizeof (IIIMP_imeinfo));
    if (NULL == imeinfo) {
       data_s->status = IIIMP_DATA_MALLOC_ERROR;
       return NULL;
    }

    memset (imeinfo, 0, sizeof (IIIMP_imeinfo));

    /*
     * the imeinfo is optional, so we don't need to check the following members 
     * are NULL or not.
     */
    GET32(imeinfo->enable, rest, p, data_s->byte_swap);
    imeinfo->ime_id = iiimp_string_unpack(data_s, &rest, &p, rest);
    imeinfo->imename = iiimp_string_unpack(data_s, &rest, &p, rest);
    imeinfo->version = iiimp_string_unpack(data_s, &rest, &p, rest);
    imeinfo->description = iiimp_string_unpack(data_s, &rest, &p, rest);
    imeinfo->author = iiimp_string_unpack(data_s, &rest, &p, rest);
    imeinfo->copyright = iiimp_string_unpack(data_s, &rest, &p, rest);
    imeinfo->reserved1 = iiimp_string_unpack(data_s, &rest, &p, rest);
    imeinfo->reserved2 = iiimp_string_unpack(data_s, &rest, &p, rest);

    *nbyte -= (nbyte_max - rest);
    *ptr = p;

    return imeinfo;
}

Here is the call graph for this function:

Here is the caller graph for this function: