blob: dab1beba1d72fbc6288f361b8c59fe2e3c78582e [file] [log] [blame]
Jari Aalto726f6381996-08-26 18:22:31 +00001/* rldefs.h -- an attempt to isolate some of the system-specific defines
2 for readline. This should be included after any files that define
3 system-specific constants like _POSIX_VERSION or USG. */
4
Chet Rameyac50fba2014-02-26 09:36:43 -05005/* Copyright (C) 1987-2011 Free Software Foundation, Inc.
Jari Aalto726f6381996-08-26 18:22:31 +00006
Jari Aalto31859422009-01-12 13:36:28 +00007 This file is part of the GNU Readline Library (Readline), a library
8 for reading lines of text with interactive input and history editing.
Jari Aalto726f6381996-08-26 18:22:31 +00009
Jari Aalto31859422009-01-12 13:36:28 +000010 Readline is free software: you can redistribute it and/or modify
Jari Aalto726f6381996-08-26 18:22:31 +000011 it under the terms of the GNU General Public License as published by
Jari Aalto31859422009-01-12 13:36:28 +000012 the Free Software Foundation, either version 3 of the License, or
13 (at your option) any later version.
Jari Aalto726f6381996-08-26 18:22:31 +000014
Jari Aalto31859422009-01-12 13:36:28 +000015 Readline is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
Jari Aalto726f6381996-08-26 18:22:31 +000019
Jari Aalto31859422009-01-12 13:36:28 +000020 You should have received a copy of the GNU General Public License
21 along with Readline. If not, see <http://www.gnu.org/licenses/>.
22*/
Jari Aalto726f6381996-08-26 18:22:31 +000023
Jari Aaltoccc6cda1996-12-23 17:02:34 +000024#if !defined (_RLDEFS_H_)
25#define _RLDEFS_H_
Jari Aalto726f6381996-08-26 18:22:31 +000026
27#if defined (HAVE_CONFIG_H)
28# include "config.h"
29#endif
30
Jari Aalto28ef6c32001-04-06 19:14:31 +000031#include "rlstdc.h"
32
Jari Aalto31859422009-01-12 13:36:28 +000033#if defined (STRCOLL_BROKEN)
34# undef HAVE_STRCOLL
35#endif
36
Jari Aaltoccc6cda1996-12-23 17:02:34 +000037#if defined (_POSIX_VERSION) && !defined (TERMIOS_MISSING)
38# define TERMIOS_TTY_DRIVER
39#else
40# if defined (HAVE_TERMIO_H)
Jari Aalto726f6381996-08-26 18:22:31 +000041# define TERMIO_TTY_DRIVER
Jari Aaltoccc6cda1996-12-23 17:02:34 +000042# else
Jari Aalto95732b42005-12-07 14:08:12 +000043# if !defined (__MINGW32__)
44# define NEW_TTY_DRIVER
45# else
46# define NO_TTY_DRIVER
47# endif
Jari Aaltoccc6cda1996-12-23 17:02:34 +000048# endif
Jari Aalto726f6381996-08-26 18:22:31 +000049#endif
50
Jari Aalto726f6381996-08-26 18:22:31 +000051/* Posix macro to check file in statbuf for directory-ness.
52 This requires that <sys/stat.h> be included before this test. */
53#if defined (S_IFDIR) && !defined (S_ISDIR)
54# define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR)
55#endif
56
57/* Decide which flavor of the header file describing the C library
58 string functions to include and include it. */
59
Jari Aalto726f6381996-08-26 18:22:31 +000060#if defined (HAVE_STRING_H)
61# include <string.h>
62#else /* !HAVE_STRING_H */
63# include <strings.h>
64#endif /* !HAVE_STRING_H */
65
66#if !defined (strchr) && !defined (__STDC__)
67extern char *strchr (), *strrchr ();
68#endif /* !strchr && !__STDC__ */
69
Jari Aaltoccc6cda1996-12-23 17:02:34 +000070#if defined (PREFER_STDARG)
71# include <stdarg.h>
72#else
73# if defined (PREFER_VARARGS)
74# include <varargs.h>
75# endif
Jari Aalto726f6381996-08-26 18:22:31 +000076#endif
77
Jari Aaltoccc6cda1996-12-23 17:02:34 +000078#if defined (HAVE_STRCASECMP)
79#define _rl_stricmp strcasecmp
80#define _rl_strnicmp strncasecmp
81#else
Chet Rameyac50fba2014-02-26 09:36:43 -050082extern int _rl_stricmp PARAMS((const char *, const char *));
83extern int _rl_strnicmp PARAMS((const char *, const char *, int));
Jari Aaltof73dda02001-11-13 17:56:06 +000084#endif
85
Jari Aaltob80f6442004-07-27 13:29:18 +000086#if defined (HAVE_STRPBRK) && !defined (HAVE_MULTIBYTE)
Jari Aaltof73dda02001-11-13 17:56:06 +000087# define _rl_strpbrk(a,b) strpbrk((a),(b))
88#else
89extern char *_rl_strpbrk PARAMS((const char *, const char *));
Jari Aaltoccc6cda1996-12-23 17:02:34 +000090#endif
Jari Aalto726f6381996-08-26 18:22:31 +000091
92#if !defined (emacs_mode)
93# define no_mode -1
94# define vi_mode 0
95# define emacs_mode 1
96#endif
97
Jari Aalto7117c2d2002-07-17 14:10:11 +000098#if !defined (RL_IM_INSERT)
99# define RL_IM_INSERT 1
100# define RL_IM_OVERWRITE 0
101#
102# define RL_IM_DEFAULT RL_IM_INSERT
103#endif
104
Jari Aalto726f6381996-08-26 18:22:31 +0000105/* If you cast map[key].function to type (Keymap) on a Cray,
106 the compiler takes the value of map[key].function and
107 divides it by 4 to convert between pointer types (pointers
108 to functions and pointers to structs are different sizes).
109 This is not what is wanted. */
110#if defined (CRAY)
111# define FUNCTION_TO_KEYMAP(map, key) (Keymap)((int)map[key].function)
Jari Aalto28ef6c32001-04-06 19:14:31 +0000112# define KEYMAP_TO_FUNCTION(data) (rl_command_func_t *)((int)(data))
Jari Aalto726f6381996-08-26 18:22:31 +0000113#else
114# define FUNCTION_TO_KEYMAP(map, key) (Keymap)(map[key].function)
Jari Aalto28ef6c32001-04-06 19:14:31 +0000115# define KEYMAP_TO_FUNCTION(data) (rl_command_func_t *)(data)
Jari Aalto726f6381996-08-26 18:22:31 +0000116#endif
117
118#ifndef savestring
Jari Aaltof73dda02001-11-13 17:56:06 +0000119#define savestring(x) strcpy ((char *)xmalloc (1 + strlen (x)), (x))
Jari Aalto726f6381996-08-26 18:22:31 +0000120#endif
121
122/* Possible values for _rl_bell_preference. */
123#define NO_BELL 0
124#define AUDIBLE_BELL 1
125#define VISIBLE_BELL 2
126
Jari Aaltoccc6cda1996-12-23 17:02:34 +0000127/* Definitions used when searching the line for characters. */
128/* NOTE: it is necessary that opposite directions are inverses */
129#define FTO 1 /* forward to */
130#define BTO -1 /* backward to */
131#define FFIND 2 /* forward find */
132#define BFIND -2 /* backward find */
133
134/* Possible values for the found_quote flags word used by the completion
135 functions. It says what kind of (shell-like) quoting we found anywhere
136 in the line. */
Jari Aalto7117c2d2002-07-17 14:10:11 +0000137#define RL_QF_SINGLE_QUOTE 0x01
138#define RL_QF_DOUBLE_QUOTE 0x02
139#define RL_QF_BACKSLASH 0x04
140#define RL_QF_OTHER_QUOTE 0x08
Jari Aaltoccc6cda1996-12-23 17:02:34 +0000141
142/* Default readline line buffer length. */
143#define DEFAULT_BUFFER_SIZE 256
144
145#if !defined (STREQ)
146#define STREQ(a, b) (((a)[0] == (b)[0]) && (strcmp ((a), (b)) == 0))
Jari Aaltobb706242000-03-17 21:46:59 +0000147#define STREQN(a, b, n) (((n) == 0) ? (1) \
148 : ((a)[0] == (b)[0]) && (strncmp ((a), (b), (n)) == 0))
Jari Aaltoccc6cda1996-12-23 17:02:34 +0000149#endif
150
Chet Rameyac50fba2014-02-26 09:36:43 -0500151#if !defined (RL_STRLEN)
152# define RL_STRLEN(s) (((s) && (s)[0]) ? ((s)[1] ? ((s)[2] ? strlen(s) : 2) : 1) : 0)
153#endif
154
Jari Aaltoccc6cda1996-12-23 17:02:34 +0000155#if !defined (FREE)
156# define FREE(x) if (x) free (x)
157#endif
158
Jari Aalto7117c2d2002-07-17 14:10:11 +0000159#if !defined (SWAP)
160# define SWAP(s, e) do { int t; t = s; s = e; e = t; } while (0)
161#endif
162
Jari Aalto726f6381996-08-26 18:22:31 +0000163/* CONFIGURATION SECTION */
164#include "rlconf.h"
165
Jari Aaltoccc6cda1996-12-23 17:02:34 +0000166#endif /* !_RLDEFS_H_ */