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