stub-termcap.c 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /* A very minimal do-nothing termcap emulation stub.
  2. Copyright (C) 2005-2022 Free Software Foundation, Inc.
  3. Contributed by CodeSourcery, LLC.
  4. This file is part of GDB.
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 3 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  15. #include "defs.h"
  16. extern "C" {
  17. /* -Wmissing-prototypes */
  18. extern int tgetent (char *buffer, char *termtype);
  19. extern int tgetnum (char *name);
  20. extern int tgetflag (char *name);
  21. extern char* tgetstr (char *name, char **area);
  22. extern int tputs (char *string, int nlines, int (*outfun) (int));
  23. extern char *tgoto (const char *cap, int col, int row);
  24. }
  25. /* These globals below are global termcap variables that readline
  26. references.
  27. Actually, depending on preprocessor conditions that we don't want
  28. to mirror here (as they may change depending on readline versions),
  29. readline may define these globals as well, relying on the linker
  30. merging them if needed (-fcommon). That doesn't work with
  31. -fno-common or C++, so instead we define the symbols as weak.
  32. Don't do this on Windows though, as MinGW gcc 3.4.2 doesn't support
  33. weak (later versions, e.g., 4.8, do support it). Given this stub
  34. file originally was Windows only, and we only needed this when we
  35. made it work on other hosts, it should be OK. */
  36. #ifndef __MINGW32__
  37. char PC __attribute__((weak));
  38. char *BC __attribute__((weak));
  39. char *UP __attribute__((weak));
  40. #endif
  41. /* Each of the files below is a minimal implementation of the standard
  42. termcap function with the same name, suitable for use in a Windows
  43. console window, or when a real termcap/curses library isn't
  44. available. */
  45. int
  46. tgetent (char *buffer, char *termtype)
  47. {
  48. return -1;
  49. }
  50. int
  51. tgetnum (char *name)
  52. {
  53. return -1;
  54. }
  55. int
  56. tgetflag (char *name)
  57. {
  58. return -1;
  59. }
  60. char *
  61. tgetstr (char *name, char **area)
  62. {
  63. return NULL;
  64. }
  65. int
  66. tputs (char *string, int nlines, int (*outfun) (int))
  67. {
  68. while (*string)
  69. outfun (*string++);
  70. return 0;
  71. }
  72. char *
  73. tgoto (const char *cap, int col, int row)
  74. {
  75. return NULL;
  76. }