Back to index

im-sdk  12.3.91
Functions
attr.c File Reference
#include "iiimcfint.h"

Go to the source code of this file.

Functions

IIIMF_status iiimcf_create_attr (IIIMCF_attr *pattr)
IIIMF_status iiimcf_destroy_attr (IIIMCF_attr attr)
static IIIMCF_attr_slotfind_slot (IIIMCF_attr_rec *pa, int property)
static IIIMCF_attr_slotalloc_slot (IIIMCF_attr_rec *pa, int property)
IIIMF_status iiimcf_attr_put_string_value (IIIMCF_attr attr, int property, const char *str)
IIIMF_status iiimcf_attr_get_string_value (IIIMCF_attr attr, int property, const char **pstr)
IIIMF_status iiimcf_attr_put_integer_value (IIIMCF_attr attr, int property, int number)
IIIMF_status iiimcf_attr_get_integer_value (IIIMCF_attr attr, int property, int *pnumber)
IIIMF_status iiimcf_attr_put_ptr_value (IIIMCF_attr attr, int property, void *ptr)
IIIMF_status iiimcf_attr_get_ptr_value (IIIMCF_attr attr, int property, void **pptr)

Function Documentation

static IIIMCF_attr_slot* alloc_slot ( IIIMCF_attr_rec pa,
int  property 
) [static]

Definition at line 73 of file attr.c.

{
    int i, size;
    IIIMCF_attr_slot *pst;

    size = pa->nprops;
    pst = pa->pslots;
    for (i = 0; i < size; i++, pst++) {
       if (pst->idx == property) {
           return pst;
       }
    }

    pst = (IIIMCF_attr_slot*) realloc(pa->pslots, sizeof(*pst) * (size + 1));
    if (!pst) return NULL;
    pa->pslots = pst;
    pst += size;
    memset(pst, 0, sizeof(*pst));
    pa->nprops++;
    pst->idx = property;

    return pst;
}

Here is the caller graph for this function:

static IIIMCF_attr_slot* find_slot ( IIIMCF_attr_rec pa,
int  property 
) [static]

Definition at line 50 of file attr.c.

{
    int i, size;
    IIIMCF_attr_slot *pst;

    if (!pa) return NULL;
    size = pa->nprops;
    pst = pa->pslots;
    for (i = 0; i < size; i++, pst++) {
       if (pst->idx == property) {
           return pst;
       }
    }

    return NULL;
}

Here is the caller graph for this function:

IIIMF_status iiimcf_attr_get_integer_value ( IIIMCF_attr  attr,
int  property,
int *  pnumber 
)

Definition at line 163 of file attr.c.

{
    IIIMCF_attr_slot *ps;
    IIIMCF_attr_rec *pa = (IIIMCF_attr_rec*) attr;

    ps = find_slot(pa, property);
    if (!ps) return IIIMF_STATUS_NO_ATTR_VALUE;
    if (ps->type != IIIMCF_ATTR_TYPE_INTEGER)
       return IIIMF_STATUS_ARGUMENT;

    *pnumber = ps->v.number;

    return IIIMF_STATUS_SUCCESS;
}

Here is the call graph for this function:

Here is the caller graph for this function:

IIIMF_status iiimcf_attr_get_ptr_value ( IIIMCF_attr  attr,
int  property,
void **  pptr 
)

Definition at line 204 of file attr.c.

{
    IIIMCF_attr_slot *ps;
    IIIMCF_attr_rec *pa = (IIIMCF_attr_rec*) attr;

    ps = find_slot(pa, property);
    if (!ps) return IIIMF_STATUS_NO_ATTR_VALUE;
    if (ps->type != IIIMCF_ATTR_TYPE_POINTER)
       return IIIMF_STATUS_ARGUMENT;

    *pptr = ps->v.ptr;

    return IIIMF_STATUS_SUCCESS;
}

Here is the call graph for this function:

Here is the caller graph for this function:

IIIMF_status iiimcf_attr_get_string_value ( IIIMCF_attr  attr,
int  property,
const char **  pstr 
)

Definition at line 122 of file attr.c.

{
    IIIMCF_attr_slot *ps;
    IIIMCF_attr_rec *pa = (IIIMCF_attr_rec*) attr;

    ps = find_slot(pa, property);
    if (!ps) return IIIMF_STATUS_NO_ATTR_VALUE;
    if (ps->type != IIIMCF_ATTR_TYPE_STRING)
       return IIIMF_STATUS_ARGUMENT;

    *pstr = ps->v.str;

    return IIIMF_STATUS_SUCCESS;
}

Here is the call graph for this function:

Here is the caller graph for this function:

IIIMF_status iiimcf_attr_put_integer_value ( IIIMCF_attr  attr,
int  property,
int  number 
)

Definition at line 142 of file attr.c.

{
    IIIMCF_attr_slot *ps;
    IIIMCF_attr_rec *pa = (IIIMCF_attr_rec*) attr;

    ps = alloc_slot(pa, property);
    if (!ps) return IIIMF_STATUS_MALLOC;
    if ((ps->type != IIIMCF_ATTR_TYPE_NONE) 
       && (ps->type != IIIMCF_ATTR_TYPE_INTEGER))
       return IIIMF_STATUS_ARGUMENT;
    ps->type = IIIMCF_ATTR_TYPE_INTEGER;
    ps->v.number = number;

    return IIIMF_STATUS_SUCCESS;
}

Here is the call graph for this function:

Here is the caller graph for this function:

IIIMF_status iiimcf_attr_put_ptr_value ( IIIMCF_attr  attr,
int  property,
void *  ptr 
)

Definition at line 183 of file attr.c.

{
    IIIMCF_attr_slot *ps;
    IIIMCF_attr_rec *pa = (IIIMCF_attr_rec*) attr;

    ps = alloc_slot(pa, property);
    if (!ps) return IIIMF_STATUS_MALLOC;
    if ((ps->type != IIIMCF_ATTR_TYPE_NONE) 
       && (ps->type != IIIMCF_ATTR_TYPE_POINTER))
       return IIIMF_STATUS_ARGUMENT;
    ps->type = IIIMCF_ATTR_TYPE_POINTER;
    ps->v.ptr = ptr;

    return IIIMF_STATUS_SUCCESS;
}

Here is the call graph for this function:

Here is the caller graph for this function:

IIIMF_status iiimcf_attr_put_string_value ( IIIMCF_attr  attr,
int  property,
const char *  str 
)

Definition at line 101 of file attr.c.

{
    IIIMCF_attr_slot *ps;
    IIIMCF_attr_rec *pa = (IIIMCF_attr_rec*) attr;

    ps = alloc_slot(pa, property);
    if (!ps) return IIIMF_STATUS_MALLOC;
    if ((ps->type != IIIMCF_ATTR_TYPE_NONE) 
       && (ps->type != IIIMCF_ATTR_TYPE_STRING))
       return IIIMF_STATUS_ARGUMENT;
    ps->type = IIIMCF_ATTR_TYPE_STRING;
    ps->v.str = str;

    return IIIMF_STATUS_SUCCESS;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 20 of file attr.c.

{
    IIIMCF_attr_rec *pa;

    pa = (IIIMCF_attr_rec*) malloc(sizeof(*pa));
    if (!pa) return IIIMF_STATUS_MALLOC;
    memset(pa, 0, sizeof(*pa));

    *pattr = pa;

    return IIIMF_STATUS_SUCCESS;
}

Here is the caller graph for this function:

Definition at line 36 of file attr.c.

{
    IIIMCF_attr_rec *pa = (IIIMCF_attr_rec*) attr;

    if (pa->pslots) free(pa->pslots);
    free(pa);
    return IIIMF_STATUS_SUCCESS;
}

Here is the caller graph for this function: