Back to index

im-sdk  12.3.91
Classes | Defines | Typedefs | Enumerations | Functions
FrameMgr.h File Reference
#include <X11/Xmd.h>
#include <X11/Xlib.h>
#include <stdio.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _XimFrame

Defines

#define xim_externalref   extern
#define xim_externaldef
#define COUNTER_MASK   0x10
#define _FRAME(a)   {a, NULL}
#define _PTR(p)   {PTR_ITEM, (void *)p}
#define _PAD2(n)   {PADDING, (void*)((n)<<8|2)}
#define _PAD4(n)   {PADDING, (void*)((n)<<8|4)}
#define FmCounterByte   0
#define FmCounterNumber   1
#define _BYTE_COUNTER(type, offset)   {(COUNTER_MASK|type), (void*)((offset)<<8|FmCounterByte)}
#define _NUMBER_COUNTER(type, offset)   {(COUNTER_MASK|type), (void*)((offset)<<8|FmCounterNumber)}
#define FrameMgrPutToken(fm, obj)   _FrameMgrPutToken((fm), &(obj), sizeof(obj))
#define FrameMgrGetToken(fm, obj)   _FrameMgrGetToken((fm), &(obj), sizeof(obj))

Typedefs

typedef struct _XimFrame XimFrameRec
typedef struct _XimFrameXimFrame
typedef struct _FrameMgrFrameMgr

Enumerations

enum  XimFrameType {
  BIT8 = 0x1, BIT16 = 0x2, BIT32 = 0x3, BARRAY = 0x4,
  ITER = 0x5, POINTER = 0x6, PTR_ITEM = 0x7, PADDING = 0x8,
  EOL = 0x9, COUNTER_BIT8 = COUNTER_MASK|0x1, COUNTER_BIT16 = COUNTER_MASK|0x2, COUNTER_BIT32 = COUNTER_MASK|0x3,
  BIT8 = 0x1, BIT16 = 0x2, BIT32 = 0x3, BARRAY = 0x4,
  ITER = 0x5, POINTER = 0x6, PTR_ITEM = 0x7, PADDING = 0x8,
  EOL = 0x9, COUNTER_BIT8 = COUNTER_MASK|0x1, COUNTER_BIT16 = COUNTER_MASK|0x2, COUNTER_BIT32 = COUNTER_MASK|0x3
}
enum  FmStatus {
  FmSuccess, FmEOD, FmInvalidCall, FmBufExist,
  FmCannotCalc, FmNoMoreData, FmSuccess, FmEOD,
  FmInvalidCall, FmBufExist, FmCannotCalc, FmNoMoreData
}

Functions

FrameMgr FrameMgrInit (XimFrame frame, char *area, Bool byte_swap)
void FrameMgrInitWithData (FrameMgr fm, XimFrame frame, void *area, Bool byte_swap)
void FrameMgrFree (FrameMgr fm)
FmStatus FrameMgrSetBuffer (FrameMgr, void *)
FmStatus _FrameMgrPutToken (FrameMgr, void *, int)
FmStatus _FrameMgrGetToken (FrameMgr, void *, int)
FmStatus FrameMgrSetSize (FrameMgr, int)
FmStatus FrameMgrSetIterCount (FrameMgr, int)
FmStatus FrameMgrSetTotalSize (FrameMgr, int)
int FrameMgrGetTotalSize (FrameMgr)
int FrameMgrGetSize (FrameMgr)
FmStatus FrameMgrSkipToken (FrameMgr, int)
void FrameMgrReset (FrameMgr)
Bool FrameMgrIsIterLoopEnd (FrameMgr, FmStatus *)

Class Documentation

struct _XimFrame

Definition at line 148 of file FrameMgr.h.

Class Members
void * data
XimFrameType type
int type

Define Documentation

#define _BYTE_COUNTER (   type,
  offset 
)    {(COUNTER_MASK|type), (void*)((offset)<<8|FmCounterByte)}

Definition at line 83 of file FrameMgr.h.

#define _FRAME (   a)    {a, NULL}

Definition at line 71 of file FrameMgr.h.

#define _NUMBER_COUNTER (   type,
  offset 
)    {(COUNTER_MASK|type), (void*)((offset)<<8|FmCounterNumber)}

Definition at line 86 of file FrameMgr.h.

#define _PAD2 (   n)    {PADDING, (void*)((n)<<8|2)}

Definition at line 77 of file FrameMgr.h.

#define _PAD4 (   n)    {PADDING, (void*)((n)<<8|4)}

Definition at line 78 of file FrameMgr.h.

#define _PTR (   p)    {PTR_ITEM, (void *)p}

Definition at line 72 of file FrameMgr.h.

#define COUNTER_MASK   0x10

Definition at line 43 of file FrameMgr.h.

#define FmCounterByte   0

Definition at line 80 of file FrameMgr.h.

#define FmCounterNumber   1

Definition at line 81 of file FrameMgr.h.

#define FrameMgrGetToken (   fm,
  obj 
)    _FrameMgrGetToken((fm), &(obj), sizeof(obj))

Definition at line 122 of file FrameMgr.h.

#define FrameMgrPutToken (   fm,
  obj 
)    _FrameMgrPutToken((fm), &(obj), sizeof(obj))

Definition at line 121 of file FrameMgr.h.

#define xim_externaldef

Definition at line 38 of file FrameMgr.h.

#define xim_externalref   extern

Definition at line 37 of file FrameMgr.h.


Typedef Documentation

typedef struct _FrameMgr* FrameMgr

Definition at line 103 of file FrameMgr.h.

typedef struct _XimFrame * XimFrame
typedef struct _XimFrame XimFrameRec

Enumeration Type Documentation

enum FmStatus
Enumerator:
FmSuccess 
FmEOD 
FmInvalidCall 
FmBufExist 
FmCannotCalc 
FmNoMoreData 
FmSuccess 
FmEOD 
FmInvalidCall 
FmBufExist 
FmCannotCalc 
FmNoMoreData 

Definition at line 94 of file FrameMgr.h.

Enumerator:
BIT8 
BIT16 
BIT32 
BARRAY 
ITER 
POINTER 
PTR_ITEM 
PADDING 
EOL 
COUNTER_BIT8 
COUNTER_BIT16 
COUNTER_BIT32 
BIT8 
BIT16 
BIT32 
BARRAY 
ITER 
POINTER 
PTR_ITEM 
PADDING 
EOL 
COUNTER_BIT8 
COUNTER_BIT16 
COUNTER_BIT32 

Definition at line 45 of file FrameMgr.h.

             {
    BIT8     = 0x1,       /* {CARD8* | INT8*} */
    BIT16    = 0x2,       /* {CARD16* | INT16*} */
    BIT32    = 0x3,       /* {CARD32* | INT32*} */
    BARRAY   = 0x4,       /* int*, void* */
    ITER     = 0x5,       /* int* */
    POINTER  = 0x6,       /* specifies next item is a PTR_ITEM */
    PTR_ITEM = 0x7,       /* specifies the item has a pointer */
    /* BOGUS - POINTER and PTR_ITEM
     *   In the current implementation, PTR_ITEM should be lead by
     *   POINTER.  But actually, it's just redundant logically.  Someone 
     *   may remove this redundancy and POINTER from the enum member but he
     *   should also modify the logic in FrameMgr program.
     */
    PADDING  = 0x8,       /* specifies that a padding is needed.
                         * This requires extra data in data field.
                         */
    EOL      = 0x9,       /* specifies the end of list */

    COUNTER_BIT8  = COUNTER_MASK|0x1,
    COUNTER_BIT16 = COUNTER_MASK|0x2,
    COUNTER_BIT32 = COUNTER_MASK|0x3

} XimFrameType;

Function Documentation

FmStatus _FrameMgrGetToken ( FrameMgr  ,
void *  ,
int   
)

Definition at line 347 of file FrameMgr.c.

{
    XimFrameType type;
    static XimFrameTypeInfoRec info; /* memory */
    FrameIter fitr;

    if (fm->total_size != NO_VALUE && fm->idx >= fm->total_size)
       return FmNoMoreData;

    type = FrameInstGetNextType(fm->fi, &info);

    if (type & COUNTER_MASK) {
       int end = 0;
       FrameIter client_data;

       type &= ~COUNTER_MASK;
       if (type == BIT8) {
           end = *(CARD8*)(fm->area + fm->idx);
       }
       else if (type == BIT16) {
           end = Swap16(fm, *(CARD16*)(fm->area + fm->idx));
       }
       else if (type == BIT32) {
           end = Swap32(fm, *(CARD32*)(fm->area + fm->idx));
       }
       if ((client_data = _FrameMgrAppendIter(fm, info.counter.iter, end))) {
           IterSetStarter(info.counter.iter);
           IterSetStartWatch(info.counter.iter, 
                           _IterStartWatch, (void*)client_data);
       }
    }

    type &= ~COUNTER_MASK;
    if (type == BIT8) {
       if (data_size == sizeof(unsigned char)) {
           *(unsigned char*)data = *(CARD8*)(fm->area + fm->idx);
       } else if (data_size == sizeof(unsigned short)) {
           *(unsigned short*)data = *(CARD8*)(fm->area + fm->idx);
       } else if (data_size == sizeof(unsigned int)) {
           *(unsigned int*)data = *(CARD8*)(fm->area + fm->idx);
       } else if (data_size == sizeof(unsigned long)) {
           *(unsigned long*)data = *(CARD8*)(fm->area + fm->idx);
       } else {
           ;/* Should never reached */
       }
       fm->idx++;
       if ((fitr = _FrameIterCounterIncr(fm->iters, 1/*BIT8*/))) {
           _FrameMgrRemoveIter(fm, fitr);
       }
       return FmSuccess;
    } else if (type == BIT16) {
       if (data_size == sizeof(unsigned char)) {
           *(unsigned char*)data =
              Swap16(fm, *(CARD16*)(fm->area + fm->idx));
       } else if (data_size == sizeof(unsigned short)) {
           *(unsigned short*)data =
              Swap16(fm, *(CARD16*)(fm->area + fm->idx));
       } else if (data_size == sizeof(unsigned int)) {
           *(unsigned int*)data =
              Swap16(fm, *(CARD16*)(fm->area + fm->idx));
       } else if (data_size == sizeof(unsigned long)) {
           *(unsigned long*)data =
              Swap16(fm, *(CARD16*)(fm->area + fm->idx));
       } else {
           ;/* Should never reached */
       }
       fm->idx += 2;
       if ((fitr = _FrameIterCounterIncr(fm->iters, 2/*BIT16*/))) {
           _FrameMgrRemoveIter(fm, fitr);
       }
       return FmSuccess;
    } else if (type == BIT32) {
       if (data_size == sizeof(unsigned char)) {
           *(unsigned char*)data =
              Swap32(fm, *(CARD32*)(fm->area + fm->idx));
       } else if (data_size == sizeof(unsigned short)) {
           *(unsigned short*)data =
              Swap32(fm, *(CARD32*)(fm->area + fm->idx));
       } else if (data_size == sizeof(unsigned int)) {
           *(unsigned int*)data =
              Swap32(fm, *(CARD32*)(fm->area + fm->idx));
       } else if (data_size == sizeof(unsigned long)) {
           *(unsigned long*)data =
              Swap32(fm, *(CARD32*)(fm->area + fm->idx));
       } else {
           ;/* Should never reached */
       }
       fm->idx += 4;
       if ((fitr = _FrameIterCounterIncr(fm->iters, 4/*BIT32*/))) {
           _FrameMgrRemoveIter(fm, fitr);
       }
       return FmSuccess;
    }
      else if (type == BARRAY && info.num != NO_VALUE) {
       if (info.num > 0) {
           *(char**)data = fm->area + fm->idx;
           fm->idx += info.num;
           if ((fitr = _FrameIterCounterIncr(fm->iters, info.num))) {
              _FrameMgrRemoveIter(fm, fitr);
           }
       } else {
           *(char**)data = NULL;
       }
       return FmSuccess;
    } else if (type == BARRAY && info.num == NO_VALUE) {
       return FmInvalidCall;
    } else if (type == PADDING && info.num != NO_VALUE) {
        fm->idx += info.num;
       if ((fitr = _FrameIterCounterIncr(fm->iters, info.num))) {
           _FrameMgrRemoveIter(fm, fitr);
       }
       return _FrameMgrGetToken(fm, data, data_size);
    } else if (type == PADDING && info.num == NO_VALUE) {
        return FmInvalidCall;
    } else if (type == ITER) {
       return FmInvalidCall;       /* if comes here, it's a bug! */
    } else if (type == EOL) {
       return FmEOD;
    } else {
       ; /* Should never be reached */
    }
    return FmInvalidCall;
}

Here is the call graph for this function:

Here is the caller graph for this function:

FmStatus _FrameMgrPutToken ( FrameMgr  ,
void *  ,
int   
)

Definition at line 231 of file FrameMgr.c.

{
    XimFrameType type;
    XimFrameTypeInfoRec info;

    if (fm->total_size != NO_VALUE && fm->idx >= fm->total_size)
       return FmNoMoreData;

    type = FrameInstGetNextType(fm->fi, &info);

    if (type & COUNTER_MASK) {
       unsigned long input_length;

       if (info.counter.is_byte_len) {
           if ((input_length = IterGetTotalSize(info.counter.iter))
              == NO_VALUE) {
              return FmCannotCalc;
           }
       } else {
           if ((input_length = IterGetIterCount(info.counter.iter))
              == NO_VALUE) {
              return FmCannotCalc;
           }
       }
       if (type == COUNTER_BIT8) {
           *(CARD8*)(fm->area + fm->idx) = input_length;
           fm->idx++;
       } else if (type == COUNTER_BIT16) {
           *(CARD16*)(fm->area + fm->idx) = Swap16(fm, input_length);
           fm->idx += 2;
       } else if (type == COUNTER_BIT32) {
           *(CARD32*)(fm->area + fm->idx) = Swap32(fm, input_length);
           fm->idx += 4;
       }
       _FrameMgrPutToken(fm, data, data_size);
       return FmSuccess;
    }

    if (type == BIT8) {
       if (data_size == sizeof(unsigned char)) {
           unsigned long num = *(unsigned char*)data;
           *(CARD8*)(fm->area + fm->idx) = num;
       } else if (data_size == sizeof(unsigned short)) {
           unsigned long num = *(unsigned short*)data;
           *(CARD8*)(fm->area + fm->idx) = num;
       } else if (data_size == sizeof(unsigned int)) {
           unsigned long num = *(unsigned int*)data;
           *(CARD8*)(fm->area + fm->idx) = num;
       } else if (data_size == sizeof(unsigned long)) {
           unsigned long num = *(unsigned long*)data;
           *(CARD8*)(fm->area + fm->idx) = num;
       } else {
           ;/* Should never reached */
       }
       fm->idx++;
       return FmSuccess;
    } else if (type == BIT16) {
       if (data_size == sizeof(unsigned char)) {
           unsigned long num = *(unsigned char*)data;
           *(CARD16*)(fm->area + fm->idx) = Swap16(fm, num);
       } else if (data_size == sizeof(unsigned short)) {
           unsigned long num = *(unsigned short*)data;
           *(CARD16*)(fm->area + fm->idx) = Swap16(fm, num);
       } else if (data_size == sizeof(unsigned int)) {
           unsigned long num = *(unsigned int*)data;
           *(CARD16*)(fm->area + fm->idx) = Swap16(fm, num);
       } else if (data_size == sizeof(unsigned long)) {
           unsigned long num = *(unsigned long*)data;
           *(CARD16*)(fm->area + fm->idx) = Swap16(fm, num);
       } else {
           ;/* Should never reached */
       }
       fm->idx += 2;
       return FmSuccess;
    } else if (type == BIT32) {
       if (data_size == sizeof(unsigned char)) {
           unsigned long num = *(unsigned char*)data;
           *(CARD32*)(fm->area + fm->idx) = Swap32(fm, num);
       } else if (data_size == sizeof(unsigned short)) {
           unsigned long num = *(unsigned short*)data;
           *(CARD32*)(fm->area + fm->idx) = Swap32(fm, num);
       } else if (data_size == sizeof(unsigned int)) {
           unsigned long num = *(unsigned int*)data;
           *(CARD32*)(fm->area + fm->idx) = Swap32(fm, num);
       } else if (data_size == sizeof(unsigned long)) {
           unsigned long num = *(unsigned long*)data;
           *(CARD32*)(fm->area + fm->idx) = Swap32(fm, num);
       } else {
           ;/* Should never reached */
       }
       fm->idx += 4;
       return FmSuccess;
    }
     else if (type == BARRAY && info.num != NO_VALUE) {
       if (info.num > 0) {
           bcopy(*(char**)data, fm->area + fm->idx, info.num);
           fm->idx += info.num;
       }
       return FmSuccess;
    } else if (type == BARRAY && info.num == NO_VALUE) {
       return FmInvalidCall;
    } else if (type == PADDING && info.num != NO_VALUE) {
        fm->idx += info.num;
       return _FrameMgrPutToken(fm, data, data_size);
    } else if (type == PADDING && info.num == NO_VALUE) {
        return FmInvalidCall;
    } else if (type == ITER) {
       return FmInvalidCall;
    } else if (type == EOL) {
       return FmEOD;
    } else {
       ; /* Should never be reached */
    }
    return FmInvalidCall;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void FrameMgrFree ( FrameMgr  fm)

Definition at line 216 of file FrameMgr.c.

{
    FrameInstFree(fm->fi);
    Xfree(fm);
}

Here is the call graph for this function:

Definition at line 503 of file FrameMgr.c.

{
    register int ret_size;

    ret_size = FrameInstGetSize(fm->fi);
    if (ret_size == NO_VALID_FIELD)
       return NO_VALUE;

    return ret_size;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 497 of file FrameMgr.c.

{
    return FrameInstGetTotalSize(fm->fi);
}

Here is the call graph for this function:

FrameMgr FrameMgrInit ( XimFrame  frame,
char *  area,
Bool  byte_swap 
)

Definition at line 188 of file FrameMgr.c.

{
    FrameMgr fm;

    fm = (FrameMgr)Xmalloc(sizeof(FrameMgrRec));

    fm->frame = frame;
    fm->fi = FrameInstInit(frame);
    fm->area = (char *)area;
    fm->idx = 0;
    fm->byte_swap = byte_swap;
    fm->total_size = NO_VALUE;
    fm->iters = NULL;

    return fm;
}

Here is the call graph for this function:

void FrameMgrInitWithData ( FrameMgr  fm,
XimFrame  frame,
void *  area,
Bool  byte_swap 
)

Definition at line 205 of file FrameMgr.c.

{
    fm->frame = frame;
    fm->fi = FrameInstInit(frame);
    fm->area = (char *)area;
    fm->idx = 0;
    fm->byte_swap = byte_swap;
    fm->total_size = NO_VALUE;
}

Here is the call graph for this function:

Definition at line 563 of file FrameMgr.c.

{
    do {
       if (_FrameMgrIsIterLoopEnd(fm)) {
           return(True);
       }
    } while (_FrameMgrProcessPadding(fm, status));
    
    return(False);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void FrameMgrReset ( FrameMgr  )

Definition at line 556 of file FrameMgr.c.

{
    fm->idx = 0;
    FrameInstReset(fm->fi);
}

Here is the call graph for this function:

FmStatus FrameMgrSetBuffer ( FrameMgr  ,
void *   
)

Definition at line 222 of file FrameMgr.c.

{
    if (fm->area) {
       return FmBufExist;
    }
    fm->area = (char *)area;
    return FmSuccess;
}

Definition at line 481 of file FrameMgr.c.

{
    if (FrameInstSetIterCount(fm->fi, count) == FmSuccess)
       return FmSuccess;
    else
       return FmNoMoreData;
}

Here is the call graph for this function:

Here is the caller graph for this function:

FmStatus FrameMgrSetSize ( FrameMgr  ,
int   
)

Definition at line 472 of file FrameMgr.c.

{
    if (FrameInstSetSize(fm->fi, barray_size) == FmSuccess)
       return FmSuccess;
    else
       return FmNoMoreData;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 490 of file FrameMgr.c.

Definition at line 515 of file FrameMgr.c.

{
    XimFrameType type;
    XimFrameTypeInfoRec info;
    register int i;

    if (fm->total_size != NO_VALUE && fm->idx >= fm->total_size)
       return FmNoMoreData;

    for (i = 0; i < skip_count; i++) {
       type = FrameInstGetNextType(fm->fi, &info);
       type &= ~COUNTER_MASK;

       if (type == BIT8) {
           fm->idx++;
       } else if (type == BIT16) {
           fm->idx += 2;
       } else if (type == BIT32) {
           fm->idx += 4;
       }
         else if (type == BARRAY && info.num != NO_VALUE) {
           fm->idx += info.num;
       } else if (type == BARRAY && info.num == NO_VALUE) {
           return FmInvalidCall;
       } else if (type == PADDING && info.num != NO_VALUE) {
           fm->idx += info.num;
           return FrameMgrSkipToken(fm, skip_count);
       } else if (type == PADDING && info.num == NO_VALUE) {
           return FmInvalidCall;
       } else if (type == ITER) {
           return FmInvalidCall;
       } else if (type == EOL) {
           return FmEOD;
       } else {
           ; /* Should never be reached */
       }
    }
    return FmSuccess;
}

Here is the call graph for this function:

Here is the caller graph for this function: