Initial git import
[sxemacs] / src / ui / TTY / terminfo.c
1 /* Interface from Emacs to terminfo.
2    Copyright (C) 1985, 1986, 1993 Free Software Foundation, Inc.
3
4 This file is part of SXEmacs
5
6 SXEmacs is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 SXEmacs 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
16 You should have received a copy of the GNU General Public License
17 along with this program.  If not, see <http://www.gnu.org/licenses/>. */
18
19
20 /* Synched up with: FSF 19.30. */
21
22 #include <config.h>
23
24 #include <string.h>
25
26
27
28 /* Every little bit of this God-damned file has caused all manner
29    of headaches due to inconsistent and incorrect header files
30    on one system or other, and we don't currently need anything here,
31    so just comment the whole damn lot out!!! */
32
33 #ifndef HAVE_TERMIOS
34 #ifdef AIX
35 #include <termio.h>
36 #endif                          /* AIX */
37 #endif
38
39 /* Interface to curses/terminfo library.
40    Turns out that all of the terminfo-level routines look
41    like their termcap counterparts except for tparm, which replaces
42    tgoto.  Not only is the calling sequence different, but the string
43    format is different too.
44 */
45
46 #ifdef HAVE_CURSES_H
47 #ifdef CURSES_H_FILE
48 #include CURSES_H_FILE
49 #endif
50 #endif
51
52 #ifdef HAVE_TERMCAP_H
53 #ifdef TERMCAP_H_FILE
54 #include TERMCAP_H_FILE
55 #endif
56 #endif
57
58 /* Sun, in their infinite lameness, supplies (possibly) broken headers
59    even under Solaris.  GCC feels it necessary to correct things by
60    supplying its own headers.  Unfortunately, if you build GCC under
61    one version of Solaris and then upgrade your Solaris, you may get
62    screwed because Sun in their continuing lameness changes curses.h
63    in such a way that the "fixed" GCC headers are now broken. (GCC
64    is equally lame in that it supplies "fixed" headers for curses.h
65    but not term.h.) However, it seems to work to just not include
66    term.h under Solaris, so we try that.  KLUDGE! */
67 #ifdef TERN_H_FILE
68 #if !(defined (__GNUC__) && defined (SOLARIS2))
69 #include TERM_H_FILE
70 #endif
71 #endif
72
73 extern void *xmalloc_atomic(int size);
74
75 #if 0                           /* If this isn't declared somewhere, too bad */
76 extern char *tparm(const char *string, int arg1, int arg2, int arg3,
77                    int arg4, int arg5, int arg6, int arg7, int arg8, int arg9);
78 #endif
79
80 /* XEmacs: renamed this function because just tparam() conflicts with
81    ncurses (We don't use this function anyway!) */
82 char *emacs_tparam(const char *string, char *outstring, int len, int arg1,
83                    int arg2, int arg3, int arg4, int arg5, int arg6, int arg7,
84                    int arg8, int arg9)
85 {
86         char *temp;
87
88         temp = (char *)tparm(string, arg1, arg2, arg3, arg4, arg5, arg6, arg7,
89                              arg8, arg9);
90         if (outstring == 0) {
91                 outstring = (char *)xmalloc_atomic(strlen(temp) + 1);
92         }
93         strcpy(outstring, temp);
94         return outstring;
95 }
96