xsel

Program for manipulating the X clipboard
git clone https://git.sinitax.com/kfish/xsel
Log | Files | Refs | README | LICENSE | sfeed.txt

xsel.h (2570B)


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