XIint.h revision c27c18e8
1/* $XFree86: xc/lib/Xi/XIint.h,v 3.2 2003/07/07 15:34:22 eich Exp $ */ 2 3/* 4 * XIint.h - Header definition and support file for the internal 5 * support routines used by the Xi library. 6 */ 7 8#ifndef _XIINT_H_ 9#define _XIINT_H_ 10#include <X11/extensions/XI.h> 11 12extern XExtDisplayInfo *XInput_find_display(Display *); 13 14extern int _XiCheckExtInit(Display *, int, XExtDisplayInfo *); 15 16extern XExtensionVersion *_XiGetExtensionVersion(Display *, _Xconst char *, XExtDisplayInfo *); 17extern Status _xiQueryVersion(Display *dpy, int*, int*, XExtDisplayInfo *); 18 19extern Status _XiEventToWire( 20 register Display * /* dpy */, 21 register XEvent * /* re */, 22 register xEvent ** /* event */, 23 register int * /* count */ 24); 25 26typedef struct _XInputData 27{ 28 XEvent data; 29 XExtensionVersion *vers; 30} XInputData; 31 32 33/** 34 * Returns the next valid memory block of the given size within the block 35 * previously allocated. 36 * Use letting pointers inside a struct point to bytes after the same 37 * struct, e.g. during protocol parsing etc. 38 * 39 * Caller is responsible for allocating enough memory. 40 * 41 * Example: 42 * void *ptr; 43 * struct foo { 44 * int num_a; 45 * int num_b; 46 * int *a; 47 * int *b; 48 * } bar; 49 * 50 * ptr = malloc(large_enough); 51 * bar = next_block(&ptr, sizeof(struct foo)); 52 * bar->num_a = 10; 53 * bar->num_b = 20; 54 * bar->a = next_block(&ptr, bar->num_a); 55 * bar->b = next_block(&ptr, bar->num_b); 56 */ 57static inline void* 58next_block(void **ptr, int size) { 59 void *ret = *ptr; 60 61 if (!*ptr) 62 return NULL; 63 64 *(unsigned char**)ptr += size; 65 66 return ret; 67} 68 69#endif 70