- Optification is done by auto builder now
[gnuplot] / src / gplt_x11.h
1 /* GNUPLOT - gplt_x11.h */
2
3 /*[
4  * Copyright 2000   Thomas Williams, Colin Kelley
5  *
6  * Permission to use, copy, and distribute this software and its
7  * documentation for any purpose with or without fee is hereby granted,
8  * provided that the above copyright notice appear in all copies and
9  * that both that copyright notice and this permission notice appear
10  * in supporting documentation.
11  *
12  * Permission to modify the software is granted, but not the right to
13  * distribute the complete modified source code.  Modifications are to
14  * be distributed as patches to the released version.  Permission to
15  * distribute binaries produced by compiling modified sources is granted,
16  * provided you
17  *   1. distribute the corresponding source modifications from the
18  *    released version in the form of a patch file along with the binaries,
19  *   2. add special version identification to distinguish your version
20  *    in addition to the base release version number,
21  *   3. provide your name and address as the primary contact for the
22  *    support of your modified version, and
23  *   4. retain our contact information in regard to use of the base
24  *    software.
25  * Permission to distribute the released version of the source code along
26  * with corresponding source modifications in the form of a patch file is
27  * granted with same provisions 2 through 4 for binary distributions.
28  *
29  * This software is provided "as is" without express or implied warranty
30  * to the extent permitted by applicable law.
31 ]*/
32
33 #ifndef GNUPLOT_GPLT_X11_H
34 #define GNUPLOT_GPLT_X11_H
35
36 #if defined(HAVE_SYS_SELECT_H) && !defined(VMS)
37 # include <sys/select.h>
38 #endif
39
40 #ifndef FD_SET
41 # define FD_SET(n, p)    ((p)->fds_bits[0] |= (1 << ((n) % 32)))
42 # define FD_CLR(n, p)    ((p)->fds_bits[0] &= ~(1 << ((n) % 32)))
43 # define FD_ISSET(n, p)  ((p)->fds_bits[0] & (1 << ((n) % 32)))
44 # define FD_ZERO(p)      memset((char *)(p), '\0', sizeof(*(p)))
45 #endif /* not FD_SET */
46
47 #define X11_COMMAND_BUFFER_LENGTH 1024
48
49 #if defined(WITH_IMAGE) || defined(BINARY_X11_POLYGON)
50 /* The endian value sent across the pipe can't have '\n' or '\0' within. */
51 #define ENDIAN_VALUE 0x50515253
52 #define X11_GR_CHECK_ENDIANESS  'B'
53 #endif
54
55 #define X11_GR_MAKE_PALETTE     'p'
56 #define X11_GR_RELEASE_PALETTE  'e'
57 #define X11_GR_SET_COLOR        'c'
58 #define X11_GR_SET_RGBCOLOR     'g'
59 #define X11_GR_SET_LINECOLOR    'l'
60 #define X11_GR_FILLED_POLYGON   'f'
61
62 #ifdef WITH_IMAGE
63 #define X11_GR_IMAGE 'i'
64 #endif
65
66 #if defined(WITH_IMAGE) || defined(BINARY_X11_POLYGON)
67 /* One character for function code, and perhaps one or two for the core
68  * routine to do something strange with end of buffer.  So shorten by a
69  * few by trial and error.
70  */
71 #define BINARY_MAX_CHAR_PER_TRANSFER (X11_COMMAND_BUFFER_LENGTH-3)
72
73 /* Encoding character for removing '\n' and '\0' from data stream.
74  * The strategy is as follows, we pick a character half way between
75  * '\0' and '\n'.  Then the encoded characters occupy a range
76  * of 10.  Next, by observing statistics of the occurrances
77  * of the encoded characters in the binary data, the translation
78  * character is chosen so that these encoded characters are moved
79  * to locations having the least occurances of bytes.
80  */
81 #define SET_COLOR_CODE_CHAR      5
82 #define FILLED_POLYGON_CODE_CHAR 5
83 #define IMAGE_CODE_CHAR          1
84
85 /* Translation value for making '\0', '\n' and the CODE_CHAR
86  * less prevalent in the encoded data.
87  */
88 #define SET_COLOR_TRANSLATION_CHAR         3
89 #define FILLED_POLYGON_TRANSLATION_CHAR  -13
90 #define IMAGE_TRANSLATION_CHAR            45
91 #endif
92
93 #ifdef WITH_IMAGE
94 /* Maximum image plane value of data transfer.
95  */
96 #define IMAGE_PALETTE_VALUE_MAX USHRT_MAX
97 #endif
98
99 #endif /* GNUPLOT_GPLT_X11_H */