OBJ = main.o unistd.o dirent.o stat.o utmpx.o termios.o\r
OBJ += pwd.o syslog.o sys_time.o sys_ioctl.o sys_resource.o\r
OBJ += fcntl.o clocks.o sys_wait.o unistd_crypt.o\r
-OBJ += grp.o\r
+OBJ += grp.o pty.o\r
DEPFILES := $(OBJ:%.o=%.d)\r
BIN = libposix.so\r
\r
--- /dev/null
+/*
+ * Acess2 POSIX Emulation Layer
+ * - By John Hodge
+ *
+ * pty.h
+ * - PTY Management
+ *
+ * BSD Conforming (Non-POSIX)
+ */
+#ifndef _LIBPOSIX__PTY_H_
+#define _LIBPOSIX__PTY_H_
+
+#include <termios.h>
+#include <unistd.h>
+
+extern int openpty(int *amaster, int *aslave, char *name, const struct termios *termp, const struct winsize *winp);
+extern pid_t forkpty(int *amaster, char *name, const struct termios *termp, const struct winsize *winp);
+// - utmp.h?
+extern int login_tty(int fd);
+
+#endif
+
// - crypt.c
extern char *crypt(const char *key, const char *salt);
+// - pty.c
+extern char *ttyname(int fd);
+extern int ttyname_r(int fd, char *buf, size_t buflen);
// signal.h / sys/types.h
extern int kill(pid_t pid, int sig);
--- /dev/null
+/*
+ * Acess2 POSIX Emulation Layer
+ * - By John Hodge
+ *
+ * pty.c
+ * - PTY Management
+ *
+ * BSD Conforming (Non-POSIX)
+ */
+#include <pty.h>
+#include <errno.h>
+#include <unistd.h>
+#include <acess/sys.h>
+#include <acess/devices.h>
+#include <acess/devices/pty.h>
+
+// === CODE ===
+int openpty(int *amaster, int *aslave, char *name, const struct termios *termp, const struct winsize *winp)
+{
+ errno = ENOTIMPL;
+ return -1;
+}
+
+pid_t forkpty(int *amaster, char *name, const struct termios *termp, const struct winsize *winp)
+{
+ int child;
+
+ int ret = openpty(amaster, &child, name, termp, winp);
+ if(ret) return -1;
+
+ pid_t rv = fork();
+ if(rv) return rv;
+
+ login_tty(child);
+
+ // In child
+ dup2(child, 0);
+ dup2(child, 1);
+ dup2(child, 2);
+ close(child);
+
+ return 0;
+}
+
+// - utmp.h?
+int login_tty(int fd)
+{
+ // nop!
+ return 0;
+}
return passbuf;
}
+char *ttyname(int fd)
+{
+ static char ttyname_buf[32];
+ errno = ttyname_r(fd, ttyname_buf, sizeof(ttyname_buf));
+ if(errno) return NULL;
+
+ return ttyname_buf;
+}
+int ttyname_r(int fd, char *buf, size_t buflen)
+{
+ int type = _SysIOCtl(fd, DRV_IOCTL_TYPE, NULL);
+ if( type == -1 )
+ return errno;
+ if( type != DRV_TYPE_TERMINAL )
+ return ENOTTY;
+
+ _SysIOCtl(fd, PTY_IOCTL_GETID, NULL);
+
+ return ENOTIMPL;
+}