1 /* Substitute for and wrapper around <pty.h>.
2 Copyright (C) 2010-2025 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 2.1 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 #ifndef _@GUARD_PREFIX@_PTY_H
20 @PRAGMA_SYSTEM_HEADER@
24 /* The include_next requires a split double-inclusion guard. */
26 # @INCLUDE_NEXT@ @NEXT_PTY_H@
29 #ifndef _@GUARD_PREFIX@_PTY_H
30 #define _@GUARD_PREFIX@_PTY_H
32 /* This file uses GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */
33 #if !_GL_CONFIG_H_INCLUDED
34 #error "Please include config.h first."
37 /* Some platforms declare this in a different header than glibc. */
42 /* <sys/types.h> is a prerequisite of <libutil.h> on FreeBSD 8.0. */
43 # include <sys/types.h>
47 /* Get 'struct termios', if available, and 'struct winsize'. */
50 # include <sys/ioctl.h>
52 /* Mingw lacks 'struct termios', but a forward declaration of an opaque type is
53 sufficient to allow compilation of a stub openpty(). */
56 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
58 /* The definition of _GL_WARN_ON_USE is copied here. */
61 /* Declare overridden functions. */
64 /* Create pseudo tty master slave pair and set terminal attributes
65 according to TERMP and WINP. Fork a child process attached to the
66 slave end. Return a handle for the master end in *AMASTER, and
67 return the name of the slave end in NAME. */
68 # if @REPLACE_FORKPTY@
69 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
71 # define forkpty rpl_forkpty
73 _GL_FUNCDECL_RPL (forkpty
, int,
74 (int *amaster
, char *name
,
75 struct termios
const *termp
, struct winsize
const *winp
), );
76 _GL_CXXALIAS_RPL (forkpty
, int,
77 (int *amaster
, char *name
,
78 struct termios
const *termp
, struct winsize
const *winp
));
81 _GL_FUNCDECL_SYS (forkpty
, int,
82 (int *amaster
, char *name
,
83 struct termios
const *termp
, struct winsize
const *winp
), );
85 _GL_CXXALIAS_SYS (forkpty
, int,
86 (int *amaster
, char *name
,
87 struct termios
const *termp
, struct winsize
const *winp
));
89 _GL_CXXALIASWARN (forkpty
);
90 #elif defined GNULIB_POSIXCHECK
92 # if HAVE_RAW_DECL_FORKPTY
93 _GL_WARN_ON_USE (forkpty
, "forkpty is not declared consistently - "
94 "use gnulib module forkpty for portability");
99 /* Create pseudo tty master slave pair and set terminal attributes
100 according to TERMP and WINP. Return handles for both ends in
101 *AMASTER and *ASLAVE, and return the name of the slave end in NAME. */
102 # if @REPLACE_OPENPTY@
103 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
105 # define openpty rpl_openpty
107 _GL_FUNCDECL_RPL (openpty
, int,
108 (int *amaster
, int *aslave
, char *name
,
109 struct termios
const *termp
, struct winsize
const *winp
), );
110 _GL_CXXALIAS_RPL (openpty
, int,
111 (int *amaster
, int *aslave
, char *name
,
112 struct termios
const *termp
, struct winsize
const *winp
));
115 _GL_FUNCDECL_SYS (openpty
, int,
116 (int *amaster
, int *aslave
, char *name
,
117 struct termios
const *termp
, struct winsize
const *winp
), );
119 _GL_CXXALIAS_SYS (openpty
, int,
120 (int *amaster
, int *aslave
, char *name
,
121 struct termios
const *termp
, struct winsize
const *winp
));
123 _GL_CXXALIASWARN (openpty
);
124 #elif defined GNULIB_POSIXCHECK
126 # if HAVE_RAW_DECL_OPENPTY
127 _GL_WARN_ON_USE (openpty
, "openpty is not declared consistently - "
128 "use gnulib module openpty for portability");
133 #endif /* _@GUARD_PREFIX@_PTY_H */
134 #endif /* _@GUARD_PREFIX@_PTY_H */