Back to index

im-sdk  12.3.91
FrameMgr.h
Go to the documentation of this file.
00001 /******************************************************************
00002 Copyright 1993, 1994 by Digital Equipment Corporation, Maynard, Massachusetts,
00003 
00004                         All Rights Reserved
00005 
00006 Permission to use, copy, modify, and distribute this software and its 
00007 documentation for any purpose and without fee is hereby granted, 
00008 provided that the above copyright notice appear in all copies and that
00009 both that copyright notice and this permission notice appear in 
00010 supporting documentation, and that the names of Digital or MIT not be
00011 used in advertising or publicity pertaining to distribution of the
00012 software without specific, written prior permission.  
00013 
00014 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
00015 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
00016 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
00017 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
00018 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
00019 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
00020 SOFTWARE.
00021 
00022   Author: Hiroyuki Miyamoto  Digital Equipment Corporation
00023                              miyamoto@jrd.dec.com
00024 ******************************************************************/
00025 
00026 #ifndef FRAMEMGR_H
00027 #define FRAMEMGR_H
00028 
00029 #include <X11/Xmd.h>
00030 #include <X11/Xlib.h>
00031 #include <stdio.h>
00032 
00033 #if defined(VAXC) && !defined(__DECC)
00034 #define xim_externalref globalref
00035 #define xim_externaldef globaldef
00036 #else
00037 #define xim_externalref extern
00038 #define xim_externaldef
00039 #endif
00040 
00041 /* Definitions for FrameMgr */
00042 
00043 #define COUNTER_MASK 0x10
00044 
00045 typedef enum {
00046     BIT8     = 0x1,       /* {CARD8* | INT8*} */
00047     BIT16    = 0x2,       /* {CARD16* | INT16*} */
00048     BIT32    = 0x3,       /* {CARD32* | INT32*} */
00049     BARRAY   = 0x4,       /* int*, void* */
00050     ITER     = 0x5,       /* int* */
00051     POINTER  = 0x6,       /* specifies next item is a PTR_ITEM */
00052     PTR_ITEM = 0x7,       /* specifies the item has a pointer */
00053     /* BOGUS - POINTER and PTR_ITEM
00054      *   In the current implementation, PTR_ITEM should be lead by
00055      *   POINTER.  But actually, it's just redundant logically.  Someone 
00056      *   may remove this redundancy and POINTER from the enum member but he
00057      *   should also modify the logic in FrameMgr program.
00058      */
00059     PADDING  = 0x8,       /* specifies that a padding is needed.
00060                          * This requires extra data in data field.
00061                          */
00062     EOL      = 0x9,       /* specifies the end of list */
00063 
00064     COUNTER_BIT8  = COUNTER_MASK|0x1,
00065     COUNTER_BIT16 = COUNTER_MASK|0x2,
00066     COUNTER_BIT32 = COUNTER_MASK|0x3
00067 
00068 } XimFrameType;
00069 
00070 /* Convenient macro */
00071 #define _FRAME(a) {a, NULL}
00072 #define _PTR(p)   {PTR_ITEM, (void *)p}
00073 /* PADDING's usage of data field
00074  * B15-B8  : Shows the number of effective items.
00075  * B7-B0   : Shows padding unit.  ex) 04 shows 4 unit padding.
00076  */
00077 #define _PAD2(n)   {PADDING, (void*)((n)<<8|2)}
00078 #define _PAD4(n)   {PADDING, (void*)((n)<<8|4)}
00079 
00080 #define FmCounterByte 0
00081 #define FmCounterNumber 1
00082     
00083 #define _BYTE_COUNTER(type, offset) \
00084                {(COUNTER_MASK|type), (void*)((offset)<<8|FmCounterByte)}
00085 
00086 #define _NUMBER_COUNTER(type, offset) \
00087                {(COUNTER_MASK|type), (void*)((offset)<<8|FmCounterNumber)}
00088 
00089 typedef struct _XimFrame {
00090     XimFrameType type;
00091     void* data;       /* For PTR_ITEM and PADDING */
00092 } XimFrameRec, *XimFrame;
00093 
00094 typedef enum {
00095     FmSuccess, 
00096     FmEOD,
00097     FmInvalidCall,
00098     FmBufExist,
00099     FmCannotCalc,
00100     FmNoMoreData
00101 } FmStatus;
00102 
00103 typedef struct _FrameMgr *FrameMgr;
00104 
00105 FrameMgr FrameMgrInit(XimFrame frame, char* area, Bool byte_swap);
00106 void FrameMgrInitWithData(FrameMgr fm, XimFrame frame, void* area,
00107                        Bool byte_swap);
00108 void FrameMgrFree(FrameMgr fm);
00109 FmStatus FrameMgrSetBuffer(FrameMgr, void*);
00110 FmStatus _FrameMgrPutToken(FrameMgr, void*, int);
00111 FmStatus _FrameMgrGetToken(FrameMgr, void*, int);
00112 FmStatus FrameMgrSetSize(FrameMgr, int);
00113 FmStatus FrameMgrSetIterCount(FrameMgr, int);
00114 FmStatus FrameMgrSetTotalSize(FrameMgr, int);
00115 int FrameMgrGetTotalSize(FrameMgr);
00116 int FrameMgrGetSize(FrameMgr);
00117 FmStatus FrameMgrSkipToken(FrameMgr, int);
00118 void FrameMgrReset(FrameMgr);
00119 Bool FrameMgrIsIterLoopEnd(FrameMgr, FmStatus*);
00120 
00121 #define FrameMgrPutToken(fm, obj) _FrameMgrPutToken((fm), &(obj), sizeof(obj))
00122 #define FrameMgrGetToken(fm, obj) _FrameMgrGetToken((fm), &(obj), sizeof(obj))
00123 
00124 #endif /* FRAMEMGR_H */