forked from kfish/xsel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
xsel.h
98 lines (83 loc) · 2.51 KB
/
xsel.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*
* xsel -- manipulate the X selection
* Copyright (C) 2001 Conrad Parker <[email protected]>
*
* Permission to use, copy, modify, distribute, and sell this software and
* its documentation for any purpose is hereby granted without fee, provided
* that the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation. No representations are made about the suitability of this
* software for any purpose. It is provided "as is" without express or
* implied warranty.
*/
#define AUTHOR "Conrad Parker <[email protected]>"
/* Default debug level (ship at 0) */
#define DEBUG_LEVEL 0
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define empty_string(s) (s==NULL||s[0]=='\0')
#define free_string(s) { free(s); s=NULL; }
/* Maximum line length for error messages */
#define MAXLINE 4096
/* Maximum filename length */
#define MAXFNAME 1024
/* Maximum incremental selection size. (Ripped from Xt) */
#define MAX_SELECTION_INCR(dpy) (((65536 < XMaxRequestSize(dpy)) ? \
(65536 << 2) : (XMaxRequestSize(dpy) << 2))-100)
/*
* Debug levels (for print_debug()):
*
* 0 - Fatal errors (default/unmaskable)
* 1 - Non-fatal warning (essential debugging info)
* 2 - Informative (generally useful debugging info)
* 3 - Obscure (more detailed debugging info)
* 4 - Trace (sequential trace of progress)
*/
#define D_FATAL 0
#define D_WARN 1
#define D_INFO 2
#define D_OBSC 3
#define D_TRACE 4
/* An instance of a MULTIPLE SelectionRequest being served */
typedef struct _MultTrack MultTrack;
struct _MultTrack {
MultTrack * mparent;
Display * display;
Window requestor;
Atom property;
Atom selection;
Time time;
Atom * atoms;
unsigned long length;
unsigned long index;
unsigned char * sel;
};
/* Selection serving states */
typedef enum {
S_NULL=0,
S_INCR_1,
S_INCR_2
} IncrState;
/* An instance of a selection being served */
typedef struct _IncrTrack IncrTrack;
struct _IncrTrack {
MultTrack * mparent;
IncrTrack * prev, * next;
IncrState state;
Display * display;
Window requestor;
Atom property;
Atom selection;
Time time;
Atom target;
int format;
unsigned char * data;
int nelements; /* total */
int offset, chunk, max_elements; /* all in terms of nelements */
};
/* Status of request handling */
typedef int HandleResult;
#define HANDLE_OK 0
#define HANDLE_ERR (1<<0)
#define HANDLE_INCOMPLETE (1<<1)
#define DID_DELETE (1<<2)