/util/IMdkit/FrameMgr.h

https://github.com/naota/ibus · C Header · 131 lines · 73 code · 17 blank · 41 comment · 1 complexity · ef0d279f1dba4c4c578835d7d20ce129 MD5 · raw file

  1. /******************************************************************
  2. Copyright 1993, 1994 by Digital Equipment Corporation, Maynard, Massachusetts,
  3. All Rights Reserved
  4. Permission to use, copy, modify, and distribute this software and its
  5. documentation for any purpose and without fee is hereby granted,
  6. provided that the above copyright notice appear in all copies and that
  7. both that copyright notice and this permission notice appear in
  8. supporting documentation, and that the names of Digital or MIT not be
  9. used in advertising or publicity pertaining to distribution of the
  10. software without specific, written prior permission.
  11. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  12. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  13. DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  14. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  15. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  16. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  17. SOFTWARE.
  18. Author: Hiroyuki Miyamoto Digital Equipment Corporation
  19. miyamoto@jrd.dec.com
  20. This version tidied and debugged by Steve Underwood May 1999
  21. ******************************************************************/
  22. #ifndef FRAMEMGR_H
  23. #define FRAMEMGR_H
  24. #include <X11/Xmd.h>
  25. #include <X11/Xlib.h>
  26. #include <stdio.h>
  27. #if defined(VAXC) && !defined(__DECC)
  28. #define xim_externalref globalref
  29. #define xim_externaldef globaldef
  30. #else
  31. #define xim_externalref extern
  32. #define xim_externaldef
  33. #endif
  34. /* Definitions for FrameMgr */
  35. #define COUNTER_MASK 0x10
  36. typedef enum
  37. {
  38. BIT8 = 0x1, /* {CARD8* | INT8*} */
  39. BIT16 = 0x2, /* {CARD16* | INT16*} */
  40. BIT32 = 0x3, /* {CARD32* | INT32*} */
  41. BIT64 = 0x4, /* {CARD64* | INT64*} */
  42. BARRAY = 0x5, /* int*, void* */
  43. ITER = 0x6, /* int* */
  44. POINTER = 0x7, /* specifies next item is a PTR_ITEM */
  45. PTR_ITEM = 0x8, /* specifies the item has a pointer */
  46. /* BOGUS - POINTER and PTR_ITEM
  47. * In the current implementation, PTR_ITEM should be lead by
  48. * POINTER. But actually, it's just redundant logically. Someone
  49. * may remove this redundancy and POINTER from the enum member but he
  50. * should also modify the logic in FrameMgr program.
  51. */
  52. PADDING = 0x9, /* specifies that a padding is needed.
  53. * This requires extra data in data field.
  54. */
  55. EOL = 0xA, /* specifies the end of list */
  56. COUNTER_BIT8 = COUNTER_MASK | 0x1,
  57. COUNTER_BIT16 = COUNTER_MASK | 0x2,
  58. COUNTER_BIT32 = COUNTER_MASK | 0x3,
  59. COUNTER_BIT64 = COUNTER_MASK | 0x4
  60. } XimFrameType;
  61. /* Convenient macro */
  62. #define _FRAME(a) {a, NULL}
  63. #define _PTR(p) {PTR_ITEM, (void *)p}
  64. /* PADDING's usage of data field
  65. * B15-B8 : Shows the number of effective items.
  66. * B7-B0 : Shows padding unit. ex) 04 shows 4 unit padding.
  67. */
  68. #define _PAD2(n) {PADDING, (void*)((n)<<8|2)}
  69. #define _PAD4(n) {PADDING, (void*)((n)<<8|4)}
  70. #define FmCounterByte 0
  71. #define FmCounterNumber 1
  72. #define _BYTE_COUNTER(type, offset) \
  73. {(COUNTER_MASK|type), (void*)((offset)<<8|FmCounterByte)}
  74. #define _NUMBER_COUNTER(type, offset) \
  75. {(COUNTER_MASK|type), (void*)((offset)<<8|FmCounterNumber)}
  76. typedef struct _XimFrame
  77. {
  78. XimFrameType type;
  79. void* data; /* For PTR_ITEM and PADDING */
  80. } XimFrameRec, *XimFrame;
  81. typedef enum
  82. {
  83. FmSuccess,
  84. FmEOD,
  85. FmInvalidCall,
  86. FmBufExist,
  87. FmCannotCalc,
  88. FmNoMoreData
  89. } FmStatus;
  90. typedef struct _FrameMgr *FrameMgr;
  91. FrameMgr FrameMgrInit(XimFrame frame, char* area, Bool byte_swap);
  92. void FrameMgrInitWithData(FrameMgr fm, XimFrame frame, void* area,
  93. Bool byte_swap);
  94. void FrameMgrFree(FrameMgr fm);
  95. FmStatus FrameMgrSetBuffer(FrameMgr, void*);
  96. FmStatus _FrameMgrPutToken(FrameMgr, void*, int);
  97. FmStatus _FrameMgrGetToken(FrameMgr, void*, int);
  98. FmStatus FrameMgrSetSize(FrameMgr, int);
  99. FmStatus FrameMgrSetIterCount(FrameMgr, int);
  100. FmStatus FrameMgrSetTotalSize(FrameMgr, int);
  101. int FrameMgrGetTotalSize(FrameMgr);
  102. int FrameMgrGetSize(FrameMgr);
  103. FmStatus FrameMgrSkipToken(FrameMgr, int);
  104. void FrameMgrReset(FrameMgr);
  105. Bool FrameMgrIsIterLoopEnd(FrameMgr, FmStatus*);
  106. #define FrameMgrPutToken(fm, obj) _FrameMgrPutToken((fm), &(obj), sizeof(obj))
  107. #define FrameMgrGetToken(fm, obj) _FrameMgrGetToken((fm), &(obj), sizeof(obj))
  108. #endif /* FRAMEMGR_H */