Commit 19e2cbbe authored by Christian Persch's avatar Christian Persch

pty: Remove deprecated _vte_pty_* functions

Conflicts:
	src/pty.h
parent 64399a47
......@@ -5,7 +5,7 @@ EXTRA_DIST = iso2022.txt
# The library
headerdir = $(includedir)/vte-$(VTE_API_VERSION)/vte
header_HEADERS = pty.h reaper.h vte.h vteaccess.h vtepty.h vtetypebuiltins.h vteversion.h vtedeprecated.h
header_HEADERS = reaper.h vte.h vteaccess.h vtepty.h vtetypebuiltins.h vteversion.h vtedeprecated.h
lib_LTLIBRARIES = libvte-@VTE_API_MAJOR_VERSION@.@VTE_API_MINOR_VERSION@.la
......@@ -44,7 +44,6 @@ libvte_@VTE_API_MAJOR_VERSION@_@VTE_API_MINOR_VERSION@_la_SOURCES = \
matcher.c \
matcher.h \
pty.c \
pty.h \
reaper.c \
reaper.h \
ring.c \
......@@ -106,7 +105,7 @@ libvte_@VTE_API_MAJOR_VERSION@_@VTE_API_MINOR_VERSION@_la_LIBADD = $(VTE_LIBS)
libvte_@VTE_API_MAJOR_VERSION@_@VTE_API_MINOR_VERSION@_la_LDFLAGS = \
$(VTE_LDFLAGS) \
-version-info $(LT_VERSION_INFO) \
-export-symbols-regex "^vte_terminal_.*|^vte_pty_.*|^vte_get_.*|^_vte_pty_.*|^vte_reaper_.*|_vte_debug_.*" \
-export-symbols-regex "^vte_terminal_.*|^vte_pty_.*|^vte_get_.*|^vte_reaper_.*|_vte_debug_.*" \
@LIBTOOL_EXPORT_OPTIONS@ @LIBTOOL_FLAGS@ \
$(AM_LDFLAGS)
......
......@@ -1926,216 +1926,3 @@ vte_pty_set_term (VtePty *pty,
priv->term = emulation;
g_object_notify(G_OBJECT(pty), "term");
}
/* Reimplementation of the ugly deprecated APIs _vte_pty_*() */
#ifndef VTE_DISABLE_DEPRECATED_SOURCE
static GHashTable *fd_to_pty_hash = NULL;
static VtePty *
get_vte_pty_for_fd (int fd)
{
VtePty *pty;
if (fd_to_pty_hash != NULL &&
(pty = g_hash_table_lookup(fd_to_pty_hash, &fd)) != NULL)
return pty;
g_warning("No VtePty found for fd %d!\n", fd);
return NULL;
}
/**
* _vte_pty_open:
* @child: location to store the new process's ID
* @env_add: a list of environment variables to add to the child's environment
* @command: name of the binary to run
* @argv: arguments to pass to @command
* @directory: directory to start the new command in, or %NULL
* @columns: desired window columns
* @rows: desired window rows
* @lastlog: %TRUE if the lastlog should be updated
* @utmp: %TRUE if the utmp or utmpx log should be updated
* @wtmp: %TRUE if the wtmp or wtmpx log should be updated
*
* Starts a new copy of @command running under a psuedo-terminal, optionally in
* the supplied @directory, with window size set to @rows x @columns
* and variables in @env_add added to its environment. If any combination of
* @lastlog, @utmp, and @wtmp is set, then the session is logged in the
* corresponding system files.
*
* Returns: an open file descriptor for the pty master, -1 on failure
*
* Deprecated: 0.26: Use #VtePty together with fork() or the g_spawn_async() family of functions instead
*/
int
_vte_pty_open(pid_t *child,
char **env_add,
const char *command,
char **argv,
const char *directory,
int columns,
int rows,
gboolean lastlog,
gboolean utmp,
gboolean wtmp)
{
VtePty *pty;
GPid pid;
gboolean ret;
pty = vte_pty_new(__vte_pty_get_pty_flags (lastlog, utmp, wtmp), NULL);
if (pty == NULL)
return -1;
if (command != NULL) {
char **real_argv;
GSpawnFlags spawn_flags;
spawn_flags = G_SPAWN_CHILD_INHERITS_STDIN |
G_SPAWN_SEARCH_PATH;
real_argv = __vte_pty_get_argv(command, argv, &spawn_flags);
ret = __vte_pty_spawn(pty,
directory,
real_argv,
env_add,
spawn_flags,
NULL, NULL,
&pid,
NULL);
g_strfreev(real_argv);
} else {
ret = __vte_pty_fork(pty, &pid, NULL);
}
if (!ret) {
g_object_unref(pty);
return -1;
}
vte_pty_set_size(pty, rows, columns, NULL);
/* Stash the pty in the hash so we can later retrieve it by FD */
if (fd_to_pty_hash == NULL) {
fd_to_pty_hash = g_hash_table_new_full(g_int_hash,
g_int_equal,
NULL,
(GDestroyNotify) g_object_unref);
}
g_hash_table_insert(fd_to_pty_hash, &pty->priv->pty_fd, pty /* adopt refcount */);
if (child)
*child = (pid_t) pid;
return vte_pty_get_fd(pty);
}
/**
* _vte_pty_get_size:
* @master: the file descriptor of the PTY master
* @columns: a place to store the number of columns
* @rows: a place to store the number of rows
*
* Attempts to read the pseudo terminal's window size.
*
* Returns: 0 on success, -1 on failure.
*
* Deprecated: 0.26: Use #VtePty and vte_pty_get_size() instead
*/
int
_vte_pty_get_size(int master,
int *columns,
int *rows)
{
VtePty *pty;
if ((pty = get_vte_pty_for_fd(master)) == NULL)
return -1;
if (vte_pty_get_size(pty, rows, columns, NULL))
return 0;
return -1;
}
/**
* _vte_pty_set_size:
* @master: the file descriptor of the PTY master
* @columns: the desired number of columns
* @rows: the desired number of rows
*
* Attempts to resize the pseudo terminal's window size. If successful, the
* OS kernel will send #SIGWINCH to the child process group.
*
* Returns: 0 on success, -1 on failure.
*
* Deprecated: 0.26: Use #VtePty and vte_pty_set_size() instead
*/
int
_vte_pty_set_size(int master,
int columns,
int rows)
{
VtePty *pty;
if ((pty = get_vte_pty_for_fd(master)) == NULL)
return -1;
if (vte_pty_set_size(pty, rows, columns, NULL))
return 0;
return -1;
}
/**
* _vte_pty_set_utf8:
* @pty: The pty master descriptor.
* @utf8: Whether or not the pty is in UTF-8 mode.
*
* Tells the kernel whether the terminal is UTF-8 or not, in case it can make
* use of the info. Linux 2.6.5 or so defines IUTF8 to make the line
* discipline do multibyte backspace correctly.
*
* Deprecated: 0.26: Use #VtePty and vte_pty_set_utf8() instead
*/
void _vte_pty_set_utf8(int master,
gboolean utf8)
{
VtePty *pty;
if ((pty = get_vte_pty_for_fd(master)) == NULL)
return;
vte_pty_set_utf8(pty, utf8, NULL);
}
/**
* _vte_pty_close:
* @pty: the pty master descriptor.
*
* Cleans up the PTY associated with the descriptor, specifically any logging
* performed for the session. The descriptor itself remains open.
*
* Deprecated: 0.26: Use #VtePty and vte_pty_close() instead
*/
void _vte_pty_close(int master)
{
VtePty *pty;
if ((pty = get_vte_pty_for_fd(master)) == NULL)
return;
/* Prevent closing the FD */
pty->priv->pty_fd = -1;
g_hash_table_remove(fd_to_pty_hash, &master);
if (g_hash_table_size(fd_to_pty_hash) == 0) {
g_hash_table_destroy(fd_to_pty_hash);
fd_to_pty_hash = NULL;
}
}
#endif /* !VTE_DISABLE_DEPRECATED_SOURCE */
/*
* Copyright (C) 2001,2002 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef VTE_DISABLE_DEPRECATED
#ifndef vte_pty_h_included
#define vte_pty_h_included
#include <sys/types.h>
G_BEGIN_DECLS
/* Start up the given binary (exact path, not interpreted at all) in a
* pseudo-terminal of its own, returning the descriptor for the master
* side of the PTY pair, logging the session to the specified files, and
* storing the child's PID in the given argument. */
int _vte_pty_open(pid_t *child, char **env_add,
const char *command, char **argv, const char *directory,
int columns, int rows,
gboolean lastlog, gboolean utmp, gboolean wtmp);
/* Set or read the size of a terminal. Returns 0 on success, -1 on failure,
* with errno set to defined return codes from ioctl(). */
int _vte_pty_get_size(int master, int *columns, int *rows);
int _vte_pty_set_size(int master, int columns, int rows);
/* Try to let the kernel know that the terminal is or is not UTF-8. */
void _vte_pty_set_utf8(int pty, gboolean utf8);
/* Close a pty. */
void _vte_pty_close(int pty);
G_END_DECLS
#endif /* vte_pty_h_included */
#endif /* !VTE_DISABLE_DEPRECATED */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment