XIint.h revision 3e256790
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 XExtensionVersion* _XiGetExtensionVersionRequest(Display *dpy, _Xconst char *name, int xi_opcode);
18extern Status _xiQueryVersion(Display *dpy, int*, int*, XExtDisplayInfo *);
19
20extern Status _XiEventToWire(
21    register Display *		/* dpy */,
22    register XEvent *		/* re */,
23    register xEvent **		/* event */,
24    register int *		/* count */
25);
26
27typedef struct _XInputData
28{
29    XEvent data;
30    XExtensionVersion *vers;
31} XInputData;
32
33
34/**
35 * Returns the next valid memory block of the given size within the block
36 * previously allocated.
37 * Use letting pointers inside a struct point to bytes after the same
38 * struct, e.g. during protocol parsing etc.
39 *
40 * Caller is responsible for allocating enough memory.
41 *
42 * Example:
43 *    void *ptr;
44 *    struct foo {
45 *       int num_a;
46 *       int num_b;
47 *       int *a;
48 *       int *b;
49 *    } bar;
50 *
51 *    ptr = malloc(large_enough);
52 *    bar = next_block(&ptr, sizeof(struct foo));
53 *    bar->num_a = 10;
54 *    bar->num_b = 20;
55 *    bar->a = next_block(&ptr, bar->num_a);
56 *    bar->b = next_block(&ptr, bar->num_b);
57 */
58static inline void*
59next_block(void **ptr, int size) {
60    void *ret = *ptr;
61
62    if (!*ptr)
63        return NULL;
64
65    *(unsigned char**)ptr += size;
66
67    return ret;
68}
69
70#endif
71