Back to index

im-sdk  12.3.91
Functions
comp-language.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.

Functions

IIIMP_languageiiimp_language_new (IIIMP_data_s *data_s, IIIMP_string *hrn, IIIMP_string *id)
void iiimp_language_delete (IIIMP_data_s *data_s, IIIMP_language *language)
void iiimp_language_list_delete (IIIMP_data_s *data_s, IIIMP_language *language)
void iiimp_language_pack (IIIMP_data_s *data_s, IIIMP_language *m, size_t *nbyte, uchar_t **ptr)
void iiimp_language_list_pack (IIIMP_data_s *data_s, IIIMP_language *m, size_t *nbyte, uchar_t **ptr)
IIIMP_languageiiimp_language_unpack (IIIMP_data_s *data_s, size_t *nbyte, const uchar_t **ptr, size_t nbyte_max)
IIIMP_languageiiimp_language_list_unpack (IIIMP_data_s *data_s, size_t *nbyte, const uchar_t **ptr, size_t nbyte_max)
void iiimp_language_print (IIIMP_data_s *data_s, IIIMP_language *m)

Function Documentation

void iiimp_language_delete ( IIIMP_data_s *  data_s,
IIIMP_language language 
)

Definition at line 47 of file comp-language.c.

{
    if (NULL == language) return;
    iiimp_string_delete(data_s, language->hrn);
    iiimp_string_delete(data_s, language->id);
    free(language);
    return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void iiimp_language_list_delete ( IIIMP_data_s *  data_s,
IIIMP_language language 
)

Definition at line 58 of file comp-language.c.

{
    IIIMP_language * lang_next;
    for (; NULL != language; language = lang_next) {
       lang_next = language->next;
       iiimp_language_delete(data_s, language);
    }
    return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void iiimp_language_list_pack ( IIIMP_data_s *  data_s,
IIIMP_language m,
size_t *  nbyte,
uchar_t **  ptr 
)

Definition at line 93 of file comp-language.c.

{
    size_t    rest;
    uchar_t * p;

    rest = *nbyte;
    p = *ptr;

    for (; NULL != m; m = m->next) {
       iiimp_language_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_language* iiimp_language_list_unpack ( IIIMP_data_s *  data_s,
size_t *  nbyte,
const uchar_t **  ptr,
size_t  nbyte_max 
)

Definition at line 166 of file comp-language.c.

{
    IIIMP_language * lang;
    size_t           rest;
    const uchar_t *  p;
    IIIMP_language * lang_first;
    IIIMP_language * lang_last;

    rest = nbyte_max;
    p = *ptr;
    lang = NULL;
    lang_first = NULL;
    lang_last = NULL;

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

    while (0 < rest) {
       lang = iiimp_language_unpack(data_s, &rest, &p, rest);
       if (NULL == lang) {
           iiimp_language_list_delete(data_s, lang_first);
           return NULL;
       } else {
           if (NULL == lang_first) {
              lang_first = lang;
           } else {
              lang_last->next = lang;
           }
           lang_last = lang;
       }
    }

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

    return lang_first;
}

Here is the call graph for this function:

Here is the caller graph for this function:

IIIMP_language* iiimp_language_new ( IIIMP_data_s *  data_s,
IIIMP_string hrn,
IIIMP_string id 
)

Definition at line 12 of file comp-language.c.

{
    IIIMP_language * lang;

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

    lang->nbyte = 0;
    lang->next = NULL;

    if (NULL == hrn) {
       lang->nbyte += 4;
    } else {
       lang->nbyte += hrn->nbyte;
    }
    if (NULL == id) {
       lang->nbyte += 4;
    } else {
       lang->nbyte += id->nbyte;
    }

    lang->hrn = hrn;
    lang->id = id;

    return lang;
}

Here is the caller graph for this function:

void iiimp_language_pack ( IIIMP_data_s *  data_s,
IIIMP_language m,
size_t *  nbyte,
uchar_t **  ptr 
)

Definition at line 70 of file comp-language.c.

{
    size_t    rest;
    uchar_t * p;

    rest = *nbyte;
    p = *ptr;

    iiimp_string_pack(data_s, m->hrn, &rest, &p);
    iiimp_string_pack(data_s, m->id, &rest, &p);

    *nbyte -= rest;
    *ptr = p;

    return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void iiimp_language_print ( IIIMP_data_s *  data_s,
IIIMP_language m 
)

Definition at line 212 of file comp-language.c.

{
    if (NULL == m) return;

    iiimp_string_print(data_s, m->hrn);
    (void)fputc(' ', data_s->print_fp);
    iiimp_string_print(data_s, m->id);
}

Here is the call graph for this function:

Here is the caller graph for this function:

IIIMP_language* iiimp_language_unpack ( IIIMP_data_s *  data_s,
size_t *  nbyte,
const uchar_t **  ptr,
size_t  nbyte_max 
)

Definition at line 117 of file comp-language.c.

{
    IIIMP_language * lang;
    size_t           rest;
    const uchar_t *  p;

    rest = nbyte_max;
    p = *ptr;

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

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

    lang->nbyte = 0;
    lang->hrn = NULL;
    lang->id = NULL;
    lang->next = NULL;

    lang->hrn = iiimp_string_unpack(data_s, &rest, &p, rest);
    if (NULL == lang->hrn) {
       iiimp_language_delete(data_s, lang);
       return NULL;
    }

    lang->id = iiimp_string_unpack(data_s, &rest, &p, rest);
    if (NULL == lang->id) {
       iiimp_language_delete(data_s, lang);
       return NULL;
    }

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

    return lang;
}

Here is the call graph for this function:

Here is the caller graph for this function: