rldefs.h 4.6 KB

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