Made changes to lineterm, especially the PTY code, to get it to compile on
FreeBSD (bug 32923). Now it does compile and run on FreeBSD. There still a few
glitches though; PTY resizing fails in FreeBSD, for example.
This commit is contained in:
svn%xmlterm.org 2000-04-01 23:42:18 +00:00
Родитель 845e5add3f
Коммит 70cdc123b5
17 изменённых файлов: 106 добавлений и 51 удалений

Просмотреть файл

@ -52,7 +52,7 @@ to the right place.
To recursively create all Makefiles from Makefile.in files, type the following
in the "xmlterm" directory:
./makemake -r
config/makemake -r
The file "config/xmlterm_config.mk" contains XMLterm specific configuration
information that is needed in addition to any Mozilla configuration

Просмотреть файл

@ -69,7 +69,7 @@ DIRS = base tests linetest
else # not STAND_ALONE
# XMLterm currently works on Linux and SunOS only (testing on BSD family)
ifneq (,$(filter Linux SunOS BSD,$(OS_ARCH)))
ifneq (,$(filter Linux SunOS FreeBSD,$(OS_ARCH)))
DIRS = base ui scripts doc tests
else # XMLterm not yet been ported to this platform; do nothing
DIRS =

Просмотреть файл

@ -439,11 +439,8 @@ int lterm_open(int lterm, char *const argv[],
"lterm_open: Error - PTY creation failed\n")
}
/* Resize TTY */
if (pty_resize(&ptyStruc, lts->nRows, lts->nCols, 0, 0) != 0) {
LTERM_OPEN_ERROR_RETURN(lterm,lts,
"lterm_open: Error - PTY resizing failed\n")
}
/* Resize TTY (fails on BSD?) */
pty_resize(&ptyStruc, lts->nRows, lts->nCols, 0, 0);
#endif /* !NO_PTY */
/* Copy PTY structure */
@ -1275,8 +1272,11 @@ static int ltermCreateProcess(struct LtermProcess *ltp,
LTERM_LOG(ltermCreateProcess,20,("Creating process %s, nostderr=%d, noexport=%d\n", argv[0], nostderr, noexport));
stdERR= NULL_FILEDESC;
if (!nostderr) {
if (nostderr) {
/* No STDERR pipe */
ltp->processERR = NULL_FILEDESC;
stdERR= NULL_FILEDESC;
} else {
/* Create STDERR pipe: needs clean-up */
FILEDESC pipeFD[2];

Просмотреть файл

@ -36,6 +36,7 @@
* CPP options:
* LINUX: for Linux2.0/glibc
* SOLARIS: for Solaris2.6
* BSDFAMILY: for FreeBSD, ...
* DEBUG: to enable some debugging output
* NO_PTY: force use of pipes rather than PTY for process
* communication
@ -105,10 +106,6 @@
#ifdef USE_NSPR_IO /* Use NSPR I/O API (no PTY implementation) */
#ifdef LINUX
#include <sys/poll.h>
#endif
typedef PRFileDesc *FILEDESC;
#define NULL_FILEDESC 0
#define VALID_FILEDESC(x) (x != 0)
@ -144,7 +141,7 @@ typedef PRFileDesc FILESTREAM;
#if defined(SOLARIS)
#include <poll.h>
#elif defined(LINUX)
#else
#include <sys/poll.h>
#endif

Просмотреть файл

@ -541,7 +541,15 @@ NS_IMETHODIMP mozLineTerm::Write(const PRUnichar *buf,
if (buf[jLen] == U_LINEFEED)
newline = true;
ubuf[jLen++] = (UNICHAR) buf[jLen];
ubuf[jLen] = (UNICHAR) buf[jLen];
if (ubuf[jLen] == U_PRIVATE0) {
// Hack to handle input of NUL characters in NUL-terminated strings
// See also: mozXMLTermKeyListener::KeyPress
ubuf[jLen] = U_NUL;
}
jLen++;
}
if (jLen >= MAXCOL-1) {

Просмотреть файл

@ -367,8 +367,16 @@ mozXMLTermKeyListener::KeyPress(nsIDOMEvent* aKeyEvent)
case nsIDOMKeyEvent::DOM_VK_F9:
JSCommand = "F9Key";
break;
default: // ignore event without consuming
return NS_OK;
default:
if ( (ctrlKey && (keyCode ==nsIDOMKeyEvent::DOM_VK_SPACE)) ||
(ctrlKey && shiftKey && (keyCode ==nsIDOMKeyEvent::DOM_VK_2)) ) {
// Hack to handle input of NUL characters in NUL-terminated strings
// See also: mozLineTerm::Write
keyChar = U_PRIVATE0;
} else {
// ignore event without consuming
return NS_OK;
}
}
} else if ((ctrlKey == PR_TRUE) && (altKey == PR_FALSE) &&

Просмотреть файл

@ -32,10 +32,11 @@
/* ptystream.c: pseudo-TTY stream implementation
* CPP options:
* LINUX: for Linux2.0/glibc
* SOLARIS: for Solaris2.6
* NOERRMSG: for suppressing all error messages
* DEBUG: for printing some debugging output to STDERR
* LINUX: for Linux2.0/glibc
* SOLARIS: for Solaris2.6
* BSDFAMILY: for FreeBSD, ...
* NOERRMSG: for suppressing all error messages
* DEBUG: for printing some debugging output to STDERR
*/
/* system header files */
@ -48,8 +49,11 @@
#ifdef LINUX
#define __USE_BSD 1
#endif
#if defined(LINUX) || defined(BSDFAMILY)
#include <sys/ioctl.h>
#endif
#include <unistd.h>
#include <sys/stat.h>
@ -118,9 +122,11 @@ int pty_create(struct ptys *ptyp, char *const argv[],
/* Open PTY */
if (openPTY(ptyp, noblock) == -1) return -1;
#ifndef BSDFAMILY
/* Set default TTY size */
if (pty_resize(ptyp, 24, 80, 0, 0) != 0)
return -1;
#endif
if (errfd >= -1) {
/* No STDERR pipe */
@ -162,6 +168,12 @@ int pty_create(struct ptys *ptyp, char *const argv[],
/* Attach child to slave TTY */
if (attachToTTY(ptyp, errfd2, noecho) == -1) return -1;
#ifdef BSDFAMILY
/* Set default TTY size */
if (pty_resize(NULL, 24, 80, 0, 0) != 0)
return -1;
#endif
/* Set default signal handling */
signal(SIGINT, SIG_DFL);
signal(SIGQUIT, SIG_DFL);
@ -233,21 +245,14 @@ int pty_close(struct ptys *ptyp)
}
/* resizes a pseudo-TTY */
/* resizes a PTY; if ptyp is null, resizes file desciptor 0,
* returning 0 on success and -1 on error.
*/
int pty_resize(struct ptys *ptyp, int rows, int cols,
int xpix, int ypix)
{
struct winsize wsize;
if (!ptyp) {
pty_error("pty_resize: NULL value for PTY structure", NULL);
return -1;
}
if (ioctl(ptyp->ptyFD, TIOCGWINSZ, &wsize ) == -1) {
pty_error("pty_resize: Failed to get TTY window size", NULL);
return -1;
}
int fd = ptyp ? ptyp->ptyFD : 0;
/* Set TTY window size */
wsize.ws_row = (unsigned short) rows;
@ -255,7 +260,7 @@ int pty_resize(struct ptys *ptyp, int rows, int cols,
wsize.ws_xpixel = (unsigned short) xpix;
wsize.ws_ypixel = (unsigned short) ypix;
if (ioctl(ptyp->ptyFD, TIOCSWINSZ, &wsize ) == -1) {
if (ioctl(fd, TIOCSWINSZ, &wsize ) == -1) {
pty_error("pty_resize: Failed to set TTY window size", NULL);
return -1;
}
@ -405,6 +410,10 @@ static int attachToTTY(struct ptys *ptyp, int errfd, int noecho)
for (fd = 3; fd < fdMax; fd++)
close(fd);
#ifdef BSDFAMILY
ioctl(0, TIOCSCTTY, 0);
#endif
/* Set process group */
tcsetpgrp(0, sid);
@ -450,6 +459,12 @@ static int setTTYAttr(int ttyFD, int noecho)
tios.c_cc[VMIN] = 1; /* Wait for at least 1 char of input */
tios.c_cc[VTIME] = 0; /* Wait indefinitely (block) */
#ifdef BSDFAMILY
tios.c_iflag = (BRKINT | IGNPAR | ICRNL | IXON
| IMAXBEL);
tios.c_oflag = (OPOST | ONLCR);
#else /* !BSDFAMILY */
/* Input modes */
tios.c_iflag &= ~IUCLC; /* Disable map of upper case input to lower*/
tios.c_iflag &= ~IGNBRK; /* Do not ignore break */
@ -462,6 +477,8 @@ static int setTTYAttr(int ttyFD, int noecho)
/* No output delays */
tios.c_oflag &= ~(NLDLY|CRDLY|TABDLY|BSDLY|VTDLY|FFDLY);
#endif /* !BSDFAMILY */
/* control modes */
tios.c_cflag |= (CS8 | CREAD);

Просмотреть файл

@ -75,7 +75,9 @@ struct ptys { /* PTY structure */
int pty_create(struct ptys *ptyp, char *const argv[],
int errfd, int noblock, int noecho, int noexport, int debug);
/* resizes the PTY, returning 0 on success and -1 on error */
/* resizes a PTY; if ptyp is null, resizes file desciptor 0,
* returning 0 on success and -1 on error.
*/
int pty_resize(struct ptys *ptyp, int rows, int cols,
int xpix, int ypix);

Просмотреть файл

@ -324,6 +324,8 @@ size_t ucscspn(const UNICHAR* str, const UNICHAR* chars);
#define U_NOBRKSPACE 0xA0U /* no-break space */
#define U_LATIN1HI 0xFFU /* highest Latin1 extension character */
#define U_PRIVATE0 0xE000U /* first private use Unicode character */
#define IS_ASCII_LETTER(x) ( (((x) >= (UNICHAR)U_A_CHAR) && \
((x) <= (UNICHAR)U_Z_CHAR)) || \
(((x) >= (UNICHAR)U_a_CHAR) && \

Просмотреть файл

@ -32,6 +32,8 @@
# autoconf.mk: autoconf info for stand-alone LineTerm only
OS_ARCH := $(shell uname)
# C compiler
CC = gcc

Просмотреть файл

@ -56,6 +56,11 @@ LIB_SUFFIX = a
RANLIB = /bin/true
endif
ifeq ($(OS_ARCH),FreeBSD)
LIB_SUFFIX = a
RANLIB = /usr/bin/ranlib
endif
# C++ compiler
CCC = $(CXX)

Просмотреть файл

@ -17,7 +17,7 @@ foreach makefile ($makelist)
echo $wd
set top_srcdir = ""
while (${wd:t} != "mozilla")
while (("$wd" != "") && (${wd:t} != "mozilla"))
if ("$top_srcdir" == "") then
set top_srcdir = ".."
else
@ -27,8 +27,12 @@ foreach makefile ($makelist)
end
/bin/cp Makefile.in Makefile
globsub @srcdir@ @srcdir@ . Makefile
globsub @top_srcdir@ @top_srcdir@ $top_srcdir Makefile
ex -s Makefile << /EOF
set nomagic
g%@srcdir@%s%@srcdir@%.%gp
g%@top_srcdir@%s%@top_srcdir@%${top_srcdir}%gp
wq
/EOF
popd
end

Просмотреть файл

@ -51,7 +51,7 @@ endif
#
# OS dependent options
#
ifneq (,$(filter-out Linux2.0 Linux2.2 SunOS5,$(OS_CONFIG)))
ifneq (,$(filter-out Linux SunOS FreeBSD,$(OS_ARCH)))
# Unsupported platform for PTY; use pipes for process communication
NO_PTY = 1
endif
@ -64,6 +64,10 @@ ifeq ($(OS_CONFIG),SunOS5)
DEFINES += -DSOLARIS
endif
ifeq ($(OS_ARCH),FreeBSD)
DEFINES += -DBSDFAMILY
endif
ifeq ($(MOZ_WIDGET_TOOLKIT),gtk)
USE_GTK_WIDGETS = 1
endif

Просмотреть файл

@ -56,10 +56,16 @@ SIMPLE_PROGRAMS = lterm ptytest unitest utf8conv
DEFINES =
# Libraries to be linked
ifdef USE_NCURSES
LIBS = -lncurses -lxmlterm -lpthread
ifeq ($(OS_ARCH),FreeBSD)
PTHREADLIBOPT = -pthread
else
LIBS = -lxmlterm -lpthread
PTHREADLIBOPT = -lpthread
endif
ifdef USE_NCURSES
LIBS = -lncurses -lxmlterm $(PTHREADLIBOPT)
else
LIBS = -lxmlterm $(PTHREADLIBOPT)
endif
include $(topsrcdir)/config/config.mk

Просмотреть файл

@ -461,8 +461,8 @@ void input_handler(int *plterm)
/* fprintf(stderr, "input_handler-00: ch=%d\n", ch); */
if (ch == 0) {
fprintf(stderr, "input_handler-00: NUL character read; terminating\n");
if (ch == 0x1D) {
fprintf(stderr, "input_handler-00: C-] character read; terminating\n");
break;
}

Просмотреть файл

@ -50,7 +50,7 @@
#include <poll.h>
#endif
#ifdef LINUX
#if defined(LINUX) || defined(BSDFAMILY)
#include <sys/ioctl.h>
#include <sys/poll.h>
typedef unsigned int nfds_t;
@ -100,7 +100,7 @@ int main(int argc, char *argv[]) {
write( echofd, "Echoing PTYTEST output ...\n", 27);
}
fprintf(stderr, "Type Control-@ (NUL) to terminate input\n");
fprintf(stderr, "Type Control-] to terminate input\n");
if (strcmp(argv[1],"pipe") == 0) {
pipeTest(argc-3, argv+3);
@ -152,8 +152,8 @@ void ptyTest(int argc, char *argv[])
/* Read character from parent STDIN and write to child STDIN */
ch = getchar();
/* Exit poll loop if a null (Control-@) is read */
if (ch == 0) break;
/* Exit poll loop if a Control-] character is read */
if (ch == 0x1D) break;
if (write(ptyFD, &ch, 1) != 1) {
fprintf(stderr, "Error in writing to child STDIN\n");
@ -293,8 +293,8 @@ void pipeTest(int argc, char *argv[])
/* Read character from parent STDIN and write to child STDIN */
ch = getchar();
/* Exit poll loop if a null (Control-@) is read */
if (ch == 0) break;
/* Exit poll loop if a Control-] is read */
if (ch == 0x1D) break;
if (write(pipeIN, &ch, 1) != 1) {
fprintf(stderr, "Error in writing to child STDIN\n");

Просмотреть файл

@ -537,13 +537,13 @@ function HandleEvent(eventObj, eventType, targetType, entryNumber,
// Set history buffer count using form entry
function SetHistoryValue() {
var field = document.getElementById('InputValue');
var field = document.getElementById('inputvalue');
return SetHistory(field.value);
}
// Set prompt using form entry
function SetPromptValue() {
var field = document.getElementById('InputValue');
var field = document.getElementById('inputvalue');
return SetPrompt(field.value);
}