Leonid Plyushch
6 years ago
27 changed files with 50 additions and 121 deletions
@ -1,9 +1,10 @@ |
|||
TERMUX_PKG_HOMEPAGE=http://joe-editor.sourceforge.net |
|||
TERMUX_PKG_DESCRIPTION="Wordstar like text editor" |
|||
TERMUX_PKG_LICENSE="GPL-2.0" |
|||
TERMUX_PKG_DEPENDS="ncurses, libutil" |
|||
TERMUX_PKG_DEPENDS="ncurses" |
|||
TERMUX_PKG_CONFLICTS="jupp" |
|||
TERMUX_PKG_VERSION=4.6 |
|||
TERMUX_PKG_REVISION=1 |
|||
TERMUX_PKG_SHA256=495a0a61f26404070fe8a719d80406dc7f337623788e445b92a9f6de512ab9de |
|||
TERMUX_PKG_SRCURL=https://sourceforge.net/projects/joe-editor/files/JOE%20sources/joe-${TERMUX_PKG_VERSION}/joe-${TERMUX_PKG_VERSION}.tar.gz |
|||
TERMUX_PKG_EXTRA_CONFIGURE_ARGS="--disable-termcap" |
|||
|
@ -1,11 +0,0 @@ |
|||
TERMUX_PKG_HOMEPAGE=https://refspecs.linuxbase.org/LSB_2.1.0/LSB-generic/LSB-generic/libutil.html |
|||
TERMUX_PKG_DESCRIPTION="Library with terminal functions" |
|||
TERMUX_PKG_LICENSE="NCSA" # same as ndk-sysroot |
|||
TERMUX_PKG_VERSION=0.4 |
|||
TERMUX_PKG_BUILD_IN_SRC=yes |
|||
|
|||
termux_step_make_install() { |
|||
CPPFLAGS+=" -std=c11 -Wall -Werror" |
|||
$CC $CPPFLAGS $CFLAGS -c -fPIC $TERMUX_PKG_BUILDER_DIR/pty.c -o pty.o |
|||
$CC -shared -fPIC $LDFLAGS -o $TERMUX_PREFIX/lib/libutil.so pty.o |
|||
} |
@ -1,68 +0,0 @@ |
|||
#include <fcntl.h> |
|||
#include <sys/ioctl.h> |
|||
#include <sys/param.h> |
|||
#include <sys/types.h> |
|||
#include <stdlib.h> |
|||
#include <termios.h> |
|||
#include <unistd.h> |
|||
|
|||
|
|||
int openpty(int* amaster, int* aslave, char* name, const struct termios* termp, const struct winsize* winp) |
|||
{ |
|||
char buf[512]; |
|||
|
|||
int master = open("/dev/ptmx", O_RDWR); |
|||
if (master == -1) return -1; |
|||
if (grantpt(master) || unlockpt(master) || ptsname_r(master, buf, sizeof buf)) goto fail; |
|||
|
|||
int slave = open(buf, O_RDWR | O_NOCTTY); |
|||
if (slave == -1) goto fail; |
|||
|
|||
/* XXX Should we ignore errors here? */ |
|||
if (termp) tcsetattr(slave, TCSAFLUSH, termp); |
|||
if (winp) ioctl(slave, TIOCSWINSZ, winp); |
|||
|
|||
*amaster = master; |
|||
*aslave = slave; |
|||
if (name != NULL) strcpy(name, buf); |
|||
return 0; |
|||
|
|||
fail: |
|||
close(master); |
|||
return -1; |
|||
} |
|||
|
|||
|
|||
int login_tty(int fd) |
|||
{ |
|||
setsid(); |
|||
if (ioctl(fd, TIOCSCTTY, NULL) == -1) return -1; |
|||
dup2(fd, 0); |
|||
dup2(fd, 1); |
|||
dup2(fd, 2); |
|||
if (fd > 2) close(fd); |
|||
return 0; |
|||
} |
|||
|
|||
|
|||
int forkpty(int* amaster, char* name, const struct termios* termp, const struct winsize* winp) |
|||
{ |
|||
int master, slave; |
|||
if (openpty(&master, &slave, name, termp, winp) == -1) { |
|||
return -1; |
|||
} |
|||
|
|||
int pid; |
|||
switch (pid = fork()) { |
|||
case -1: |
|||
return -1; |
|||
case 0: |
|||
close(master); |
|||
if (login_tty(slave)) _exit(1); |
|||
return 0; |
|||
default: |
|||
*amaster = master; |
|||
close (slave); |
|||
return pid; |
|||
} |
|||
} |
Loading…
Reference in new issue