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 To recursively create all Makefiles from Makefile.in files, type the following
in the "xmlterm" directory: in the "xmlterm" directory:
./makemake -r config/makemake -r
The file "config/xmlterm_config.mk" contains XMLterm specific configuration The file "config/xmlterm_config.mk" contains XMLterm specific configuration
information that is needed in addition to any Mozilla configuration information that is needed in addition to any Mozilla configuration

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

@ -69,7 +69,7 @@ DIRS = base tests linetest
else # not STAND_ALONE else # not STAND_ALONE
# XMLterm currently works on Linux and SunOS only (testing on BSD family) # 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 DIRS = base ui scripts doc tests
else # XMLterm not yet been ported to this platform; do nothing else # XMLterm not yet been ported to this platform; do nothing
DIRS = DIRS =

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

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

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

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

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

@ -541,7 +541,15 @@ NS_IMETHODIMP mozLineTerm::Write(const PRUnichar *buf,
if (buf[jLen] == U_LINEFEED) if (buf[jLen] == U_LINEFEED)
newline = true; 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) { if (jLen >= MAXCOL-1) {

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

@ -367,9 +367,17 @@ mozXMLTermKeyListener::KeyPress(nsIDOMEvent* aKeyEvent)
case nsIDOMKeyEvent::DOM_VK_F9: case nsIDOMKeyEvent::DOM_VK_F9:
JSCommand = "F9Key"; JSCommand = "F9Key";
break; break;
default: // ignore event without consuming 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; return NS_OK;
} }
}
} else if ((ctrlKey == PR_TRUE) && (altKey == PR_FALSE) && } else if ((ctrlKey == PR_TRUE) && (altKey == PR_FALSE) &&
(keyChar >= 0x40U) && (keyChar < 0x80U)) { (keyChar >= 0x40U) && (keyChar < 0x80U)) {

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

@ -34,6 +34,7 @@
* CPP options: * CPP options:
* LINUX: for Linux2.0/glibc * LINUX: for Linux2.0/glibc
* SOLARIS: for Solaris2.6 * SOLARIS: for Solaris2.6
* BSDFAMILY: for FreeBSD, ...
* NOERRMSG: for suppressing all error messages * NOERRMSG: for suppressing all error messages
* DEBUG: for printing some debugging output to STDERR * DEBUG: for printing some debugging output to STDERR
*/ */
@ -48,8 +49,11 @@
#ifdef LINUX #ifdef LINUX
#define __USE_BSD 1 #define __USE_BSD 1
#endif
#if defined(LINUX) || defined(BSDFAMILY)
#include <sys/ioctl.h> #include <sys/ioctl.h>
#endif #endif
#include <unistd.h> #include <unistd.h>
#include <sys/stat.h> #include <sys/stat.h>
@ -118,9 +122,11 @@ int pty_create(struct ptys *ptyp, char *const argv[],
/* Open PTY */ /* Open PTY */
if (openPTY(ptyp, noblock) == -1) return -1; if (openPTY(ptyp, noblock) == -1) return -1;
#ifndef BSDFAMILY
/* Set default TTY size */ /* Set default TTY size */
if (pty_resize(ptyp, 24, 80, 0, 0) != 0) if (pty_resize(ptyp, 24, 80, 0, 0) != 0)
return -1; return -1;
#endif
if (errfd >= -1) { if (errfd >= -1) {
/* No STDERR pipe */ /* No STDERR pipe */
@ -162,6 +168,12 @@ int pty_create(struct ptys *ptyp, char *const argv[],
/* Attach child to slave TTY */ /* Attach child to slave TTY */
if (attachToTTY(ptyp, errfd2, noecho) == -1) return -1; 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 */ /* Set default signal handling */
signal(SIGINT, SIG_DFL); signal(SIGINT, SIG_DFL);
signal(SIGQUIT, 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 pty_resize(struct ptys *ptyp, int rows, int cols,
int xpix, int ypix) int xpix, int ypix)
{ {
struct winsize wsize; struct winsize wsize;
int fd = ptyp ? ptyp->ptyFD : 0;
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;
}
/* Set TTY window size */ /* Set TTY window size */
wsize.ws_row = (unsigned short) rows; 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_xpixel = (unsigned short) xpix;
wsize.ws_ypixel = (unsigned short) ypix; 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); pty_error("pty_resize: Failed to set TTY window size", NULL);
return -1; return -1;
} }
@ -405,6 +410,10 @@ static int attachToTTY(struct ptys *ptyp, int errfd, int noecho)
for (fd = 3; fd < fdMax; fd++) for (fd = 3; fd < fdMax; fd++)
close(fd); close(fd);
#ifdef BSDFAMILY
ioctl(0, TIOCSCTTY, 0);
#endif
/* Set process group */ /* Set process group */
tcsetpgrp(0, sid); 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[VMIN] = 1; /* Wait for at least 1 char of input */
tios.c_cc[VTIME] = 0; /* Wait indefinitely (block) */ 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 */ /* Input modes */
tios.c_iflag &= ~IUCLC; /* Disable map of upper case input to lower*/ tios.c_iflag &= ~IUCLC; /* Disable map of upper case input to lower*/
tios.c_iflag &= ~IGNBRK; /* Do not ignore break */ tios.c_iflag &= ~IGNBRK; /* Do not ignore break */
@ -462,6 +477,8 @@ static int setTTYAttr(int ttyFD, int noecho)
/* No output delays */ /* No output delays */
tios.c_oflag &= ~(NLDLY|CRDLY|TABDLY|BSDLY|VTDLY|FFDLY); tios.c_oflag &= ~(NLDLY|CRDLY|TABDLY|BSDLY|VTDLY|FFDLY);
#endif /* !BSDFAMILY */
/* control modes */ /* control modes */
tios.c_cflag |= (CS8 | CREAD); tios.c_cflag |= (CS8 | CREAD);

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

@ -75,7 +75,9 @@ struct ptys { /* PTY structure */
int pty_create(struct ptys *ptyp, char *const argv[], int pty_create(struct ptys *ptyp, char *const argv[],
int errfd, int noblock, int noecho, int noexport, int debug); 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 pty_resize(struct ptys *ptyp, int rows, int cols,
int xpix, int ypix); 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_NOBRKSPACE 0xA0U /* no-break space */
#define U_LATIN1HI 0xFFU /* highest Latin1 extension character */ #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) && \ #define IS_ASCII_LETTER(x) ( (((x) >= (UNICHAR)U_A_CHAR) && \
((x) <= (UNICHAR)U_Z_CHAR)) || \ ((x) <= (UNICHAR)U_Z_CHAR)) || \
(((x) >= (UNICHAR)U_a_CHAR) && \ (((x) >= (UNICHAR)U_a_CHAR) && \

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

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

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

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

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

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

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

@ -51,7 +51,7 @@ endif
# #
# OS dependent options # 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 # Unsupported platform for PTY; use pipes for process communication
NO_PTY = 1 NO_PTY = 1
endif endif
@ -64,6 +64,10 @@ ifeq ($(OS_CONFIG),SunOS5)
DEFINES += -DSOLARIS DEFINES += -DSOLARIS
endif endif
ifeq ($(OS_ARCH),FreeBSD)
DEFINES += -DBSDFAMILY
endif
ifeq ($(MOZ_WIDGET_TOOLKIT),gtk) ifeq ($(MOZ_WIDGET_TOOLKIT),gtk)
USE_GTK_WIDGETS = 1 USE_GTK_WIDGETS = 1
endif endif

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

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

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

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

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

@ -50,7 +50,7 @@
#include <poll.h> #include <poll.h>
#endif #endif
#ifdef LINUX #if defined(LINUX) || defined(BSDFAMILY)
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <sys/poll.h> #include <sys/poll.h>
typedef unsigned int nfds_t; typedef unsigned int nfds_t;
@ -100,7 +100,7 @@ int main(int argc, char *argv[]) {
write( echofd, "Echoing PTYTEST output ...\n", 27); 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) { if (strcmp(argv[1],"pipe") == 0) {
pipeTest(argc-3, argv+3); 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 */ /* Read character from parent STDIN and write to child STDIN */
ch = getchar(); ch = getchar();
/* Exit poll loop if a null (Control-@) is read */ /* Exit poll loop if a Control-] character is read */
if (ch == 0) break; if (ch == 0x1D) break;
if (write(ptyFD, &ch, 1) != 1) { if (write(ptyFD, &ch, 1) != 1) {
fprintf(stderr, "Error in writing to child STDIN\n"); 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 */ /* Read character from parent STDIN and write to child STDIN */
ch = getchar(); ch = getchar();
/* Exit poll loop if a null (Control-@) is read */ /* Exit poll loop if a Control-] is read */
if (ch == 0) break; if (ch == 0x1D) break;
if (write(pipeIN, &ch, 1) != 1) { if (write(pipeIN, &ch, 1) != 1) {
fprintf(stderr, "Error in writing to child STDIN\n"); 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 // Set history buffer count using form entry
function SetHistoryValue() { function SetHistoryValue() {
var field = document.getElementById('InputValue'); var field = document.getElementById('inputvalue');
return SetHistory(field.value); return SetHistory(field.value);
} }
// Set prompt using form entry // Set prompt using form entry
function SetPromptValue() { function SetPromptValue() {
var field = document.getElementById('InputValue'); var field = document.getElementById('inputvalue');
return SetPrompt(field.value); return SetPrompt(field.value);
} }