exp2l: Work around a NetBSD 10.0/i386 bug.
[gnulib.git] / lib / termcap.h
blob0cd472d0d3921f394368446bbc5b1f95544875a7
1 /* Information about terminal capabilities.
2 Copyright (C) 2006-2024 Free Software Foundation, Inc.
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation, either version 3 of the
7 License, or (at your option) any later version.
9 This file 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 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 /* Written by Bruno Haible <bruno@clisp.org>, 2006. */
19 #ifndef _TERMCAP_H
20 #define _TERMCAP_H
22 /* This file uses HAVE_TERMCAP, HAVE_TERMINFO, HAVE_TPARAM. */
23 #if !_GL_CONFIG_H_INCLUDED
24 #error "Please include config.h first."
25 #endif
27 /* Including <curses.h> or <term.h> is dangerous, because it also declares
28 a lot of junk, such as variables PC, UP, and other. */
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
34 #if HAVE_TERMCAP
36 /* Gets the capability information for terminal type TYPE.
37 BP must point to a buffer, at least 2048 bytes large.
38 Returns 1 if successful, 0 if TYPE is unknown, -1 on other error. */
39 extern int tgetent (char *bp, const char *type);
41 /* Retrieves the value of a numerical capability.
42 Returns -1 if it is not available. */
43 extern int tgetnum (const char *id);
45 /* Retrieves the value of a boolean capability.
46 Returns 1 if it available, 0 otherwise. */
47 extern int tgetflag (const char *id);
49 /* Retrieves the value of a string capability.
50 Returns NULL if it is not available.
51 Also, if AREA != NULL, stores it at *AREA and advances *AREA. */
52 extern const char * tgetstr (const char *id, char **area);
54 #endif
56 #if HAVE_TERMINFO
58 /* Gets the capability information for terminal type TYPE and prepares FD.
59 Returns 0 if successful, -1 upon error. If ERRP is non-NULL, also returns
60 an error indicator in *ERRP; otherwise an error is signalled. */
61 extern int setupterm (const char *type, int fd, int *errp);
63 /* Retrieves the value of a numerical capability.
64 Returns -1 if it is not available, -2 if ID is invalid. */
65 extern int tigetnum (const char *id);
67 /* Retrieves the value of a boolean capability.
68 Returns 1 if it available, 0 if not available, -1 if ID is invalid. */
69 extern int tigetflag (const char *id);
71 /* Retrieves the value of a string capability.
72 Returns NULL if it is not available, (char *)(-1) if ID is invalid. */
73 extern const char * tigetstr (const char *id);
75 #endif
77 #if HAVE_TPARAM
79 /* API provided by GNU termcap in <termcap.h>. */
81 /* Instantiates a string capability with format strings.
82 BUF must be a buffer having room for BUFSIZE bytes.
83 The return value is either equal to BUF or freshly malloc()ed. */
84 extern char * tparam (const char *str, void *buf, int bufsize, ...);
86 #else
88 /* API provided by
89 - GNU ncurses in <term.h>, <curses.h>, <ncurses.h>,
90 - OSF/1 curses in <term.h>, <curses.h>,
91 - Solaris, AIX, HP-UX, IRIX curses in <term.h>,
92 - gnulib's replacement. */
94 /* Instantiates a string capability with format strings.
95 The return value is statically allocated and must not be freed. */
96 extern char * tparm (const char *str, ...);
98 #endif
100 #if HAVE_TERMCAP || HAVE_TERMINFO
102 /* Retrieves a string that causes cursor positioning to (column, row).
103 This function is necessary because the string returned by tgetstr ("cm")
104 is in a special format. */
105 extern const char * tgoto (const char *cm, int column, int row);
107 #endif
109 /* Retrieves the value of a string capability.
110 OUTCHARFUN is called in turn for each 'char' of the result.
111 This function is necessary because string capabilities can contain
112 padding commands. */
113 extern void tputs (const char *cp, int affcnt, int (*outcharfun) (int));
115 /* The ncurses functions for color handling (see ncurses/base/lib_color.c)
116 are overkill: Most terminal emulators support only a fixed, small number
117 of colors. */
119 #ifdef __cplusplus
121 #endif
123 #endif /* _TERMCAP_H */