xref: /dflybsd-src/contrib/gdb-7/readline/rldefs.h (revision 16003dcfd2baa152f5dd24794ec9f36e139eaeb8)
1*6b445a62SJohn Marino /* rldefs.h -- an attempt to isolate some of the system-specific defines
2*6b445a62SJohn Marino    for readline.  This should be included after any files that define
3*6b445a62SJohn Marino    system-specific constants like _POSIX_VERSION or USG. */
4*6b445a62SJohn Marino 
5*6b445a62SJohn Marino /* Copyright (C) 1987-2009 Free Software Foundation, Inc.
6*6b445a62SJohn Marino 
7*6b445a62SJohn Marino    This file is part of the GNU Readline Library (Readline), a library
8*6b445a62SJohn Marino    for reading lines of text with interactive input and history editing.
9*6b445a62SJohn Marino 
10*6b445a62SJohn Marino    Readline is free software: you can redistribute it and/or modify
11*6b445a62SJohn Marino    it under the terms of the GNU General Public License as published by
12*6b445a62SJohn Marino    the Free Software Foundation, either version 3 of the License, or
13*6b445a62SJohn Marino    (at your option) any later version.
14*6b445a62SJohn Marino 
15*6b445a62SJohn Marino    Readline is distributed in the hope that it will be useful,
16*6b445a62SJohn Marino    but WITHOUT ANY WARRANTY; without even the implied warranty of
17*6b445a62SJohn Marino    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*6b445a62SJohn Marino    GNU General Public License for more details.
19*6b445a62SJohn Marino 
20*6b445a62SJohn Marino    You should have received a copy of the GNU General Public License
21*6b445a62SJohn Marino    along with Readline.  If not, see <http://www.gnu.org/licenses/>.
22*6b445a62SJohn Marino */
23*6b445a62SJohn Marino 
24*6b445a62SJohn Marino #if !defined (_RLDEFS_H_)
25*6b445a62SJohn Marino #define _RLDEFS_H_
26*6b445a62SJohn Marino 
27*6b445a62SJohn Marino #if defined (HAVE_CONFIG_H)
28*6b445a62SJohn Marino #  include "config.h"
29*6b445a62SJohn Marino #endif
30*6b445a62SJohn Marino 
31*6b445a62SJohn Marino #include "rlstdc.h"
32*6b445a62SJohn Marino 
33*6b445a62SJohn Marino #if defined (STRCOLL_BROKEN)
34*6b445a62SJohn Marino #  undef HAVE_STRCOLL
35*6b445a62SJohn Marino #endif
36*6b445a62SJohn Marino 
37*6b445a62SJohn Marino #if defined (_POSIX_VERSION) && !defined (TERMIOS_MISSING)
38*6b445a62SJohn Marino #  define TERMIOS_TTY_DRIVER
39*6b445a62SJohn Marino #else
40*6b445a62SJohn Marino #  if defined (HAVE_TERMIO_H)
41*6b445a62SJohn Marino #    define TERMIO_TTY_DRIVER
42*6b445a62SJohn Marino #  else
43*6b445a62SJohn Marino #    if !defined (__MINGW32__)
44*6b445a62SJohn Marino #      define NEW_TTY_DRIVER
45*6b445a62SJohn Marino #    else
46*6b445a62SJohn Marino #      define NO_TTY_DRIVER
47*6b445a62SJohn Marino #    endif
48*6b445a62SJohn Marino #  endif
49*6b445a62SJohn Marino #endif
50*6b445a62SJohn Marino 
51*6b445a62SJohn Marino /* Posix macro to check file in statbuf for directory-ness.
52*6b445a62SJohn Marino    This requires that <sys/stat.h> be included before this test. */
53*6b445a62SJohn Marino #if defined (S_IFDIR) && !defined (S_ISDIR)
54*6b445a62SJohn Marino #  define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR)
55*6b445a62SJohn Marino #endif
56*6b445a62SJohn Marino 
57*6b445a62SJohn Marino /* Decide which flavor of the header file describing the C library
58*6b445a62SJohn Marino    string functions to include and include it. */
59*6b445a62SJohn Marino 
60*6b445a62SJohn Marino #if defined (HAVE_STRING_H)
61*6b445a62SJohn Marino #  include <string.h>
62*6b445a62SJohn Marino #else /* !HAVE_STRING_H */
63*6b445a62SJohn Marino #  include <strings.h>
64*6b445a62SJohn Marino #endif /* !HAVE_STRING_H */
65*6b445a62SJohn Marino 
66*6b445a62SJohn Marino #if !defined (strchr) && !defined (__STDC__)
67*6b445a62SJohn Marino extern char *strchr (), *strrchr ();
68*6b445a62SJohn Marino #endif /* !strchr && !__STDC__ */
69*6b445a62SJohn Marino 
70*6b445a62SJohn Marino #if defined (PREFER_STDARG)
71*6b445a62SJohn Marino #  include <stdarg.h>
72*6b445a62SJohn Marino #else
73*6b445a62SJohn Marino #  if defined (PREFER_VARARGS)
74*6b445a62SJohn Marino #    include <varargs.h>
75*6b445a62SJohn Marino #  endif
76*6b445a62SJohn Marino #endif
77*6b445a62SJohn Marino 
78*6b445a62SJohn Marino #if defined (HAVE_STRCASECMP)
79*6b445a62SJohn Marino #define _rl_stricmp strcasecmp
80*6b445a62SJohn Marino #define _rl_strnicmp strncasecmp
81*6b445a62SJohn Marino #else
82*6b445a62SJohn Marino extern int _rl_stricmp PARAMS((char *, char *));
83*6b445a62SJohn Marino extern int _rl_strnicmp PARAMS((char *, char *, int));
84*6b445a62SJohn Marino #endif
85*6b445a62SJohn Marino 
86*6b445a62SJohn Marino #if defined (HAVE_STRPBRK) && !defined (HAVE_MULTIBYTE)
87*6b445a62SJohn Marino #  define _rl_strpbrk(a,b)	strpbrk((a),(b))
88*6b445a62SJohn Marino #else
89*6b445a62SJohn Marino extern char *_rl_strpbrk PARAMS((const char *, const char *));
90*6b445a62SJohn Marino #endif
91*6b445a62SJohn Marino 
92*6b445a62SJohn Marino #if !defined (emacs_mode)
93*6b445a62SJohn Marino #  define no_mode -1
94*6b445a62SJohn Marino #  define vi_mode 0
95*6b445a62SJohn Marino #  define emacs_mode 1
96*6b445a62SJohn Marino #endif
97*6b445a62SJohn Marino 
98*6b445a62SJohn Marino #if !defined (RL_IM_INSERT)
99*6b445a62SJohn Marino #  define RL_IM_INSERT		1
100*6b445a62SJohn Marino #  define RL_IM_OVERWRITE	0
101*6b445a62SJohn Marino #
102*6b445a62SJohn Marino #  define RL_IM_DEFAULT		RL_IM_INSERT
103*6b445a62SJohn Marino #endif
104*6b445a62SJohn Marino 
105*6b445a62SJohn Marino /* If you cast map[key].function to type (Keymap) on a Cray,
106*6b445a62SJohn Marino    the compiler takes the value of map[key].function and
107*6b445a62SJohn Marino    divides it by 4 to convert between pointer types (pointers
108*6b445a62SJohn Marino    to functions and pointers to structs are different sizes).
109*6b445a62SJohn Marino    This is not what is wanted. */
110*6b445a62SJohn Marino #if defined (CRAY)
111*6b445a62SJohn Marino #  define FUNCTION_TO_KEYMAP(map, key)	(Keymap)((int)map[key].function)
112*6b445a62SJohn Marino #  define KEYMAP_TO_FUNCTION(data)	(rl_command_func_t *)((int)(data))
113*6b445a62SJohn Marino #else
114*6b445a62SJohn Marino #  define FUNCTION_TO_KEYMAP(map, key)	(Keymap)(map[key].function)
115*6b445a62SJohn Marino #  define KEYMAP_TO_FUNCTION(data)	(rl_command_func_t *)(data)
116*6b445a62SJohn Marino #endif
117*6b445a62SJohn Marino 
118*6b445a62SJohn Marino #ifndef savestring
119*6b445a62SJohn Marino #define savestring(x) strcpy ((char *)xmalloc (1 + strlen (x)), (x))
120*6b445a62SJohn Marino #endif
121*6b445a62SJohn Marino 
122*6b445a62SJohn Marino /* Possible values for _rl_bell_preference. */
123*6b445a62SJohn Marino #define NO_BELL 0
124*6b445a62SJohn Marino #define AUDIBLE_BELL 1
125*6b445a62SJohn Marino #define VISIBLE_BELL 2
126*6b445a62SJohn Marino 
127*6b445a62SJohn Marino /* Definitions used when searching the line for characters. */
128*6b445a62SJohn Marino /* NOTE: it is necessary that opposite directions are inverses */
129*6b445a62SJohn Marino #define	FTO	 1		/* forward to */
130*6b445a62SJohn Marino #define BTO	-1		/* backward to */
131*6b445a62SJohn Marino #define FFIND	 2		/* forward find */
132*6b445a62SJohn Marino #define BFIND	-2		/* backward find */
133*6b445a62SJohn Marino 
134*6b445a62SJohn Marino /* Possible values for the found_quote flags word used by the completion
135*6b445a62SJohn Marino    functions.  It says what kind of (shell-like) quoting we found anywhere
136*6b445a62SJohn Marino    in the line. */
137*6b445a62SJohn Marino #define RL_QF_SINGLE_QUOTE	0x01
138*6b445a62SJohn Marino #define RL_QF_DOUBLE_QUOTE	0x02
139*6b445a62SJohn Marino #define RL_QF_BACKSLASH		0x04
140*6b445a62SJohn Marino #define RL_QF_OTHER_QUOTE	0x08
141*6b445a62SJohn Marino 
142*6b445a62SJohn Marino /* Default readline line buffer length. */
143*6b445a62SJohn Marino #define DEFAULT_BUFFER_SIZE 256
144*6b445a62SJohn Marino 
145*6b445a62SJohn Marino #if !defined (STREQ)
146*6b445a62SJohn Marino #define STREQ(a, b)	(((a)[0] == (b)[0]) && (strcmp ((a), (b)) == 0))
147*6b445a62SJohn Marino #define STREQN(a, b, n)	(((n) == 0) ? (1) \
148*6b445a62SJohn Marino 				    : ((a)[0] == (b)[0]) && (strncmp ((a), (b), (n)) == 0))
149*6b445a62SJohn Marino #endif
150*6b445a62SJohn Marino 
151*6b445a62SJohn Marino #if !defined (FREE)
152*6b445a62SJohn Marino #  define FREE(x)	if (x) free (x)
153*6b445a62SJohn Marino #endif
154*6b445a62SJohn Marino 
155*6b445a62SJohn Marino #if !defined (SWAP)
156*6b445a62SJohn Marino #  define SWAP(s, e)  do { int t; t = s; s = e; e = t; } while (0)
157*6b445a62SJohn Marino #endif
158*6b445a62SJohn Marino 
159*6b445a62SJohn Marino /* CONFIGURATION SECTION */
160*6b445a62SJohn Marino #include "rlconf.h"
161*6b445a62SJohn Marino 
162*6b445a62SJohn Marino #endif /* !_RLDEFS_H_ */
163