chris@umcp-cs.UUCP (08/22/83)
: Run this shell script with "sh" not "csh" PATH=:/bin:/usr/bin:/usr/ucb export PATH all=FALSE if [ $1x = -ax ]; then all=TRUE fi /bin/echo 'Extracting newproc.ml' sed 's/^X//' <<'//go.sysin dd *' >newproc.ml (declare-global last-line) (declare-buffer-specific last-line) (if (! (is-bound lisp-prompt)) (setq-default lisp-prompt "[0-9][0-9]*_\\|[0-9][0-9]*<[0-9][0-9]*> \\|<[0-9]*>: ") ) (declare-buffer-specific lisp-prompt) (if (! (is-bound shell-prompt)) (setq-default shell-prompt "% ")) (declare-buffer-specific shell-prompt) (defun (pr-newline (end-of-line) (if (eobp) (newline) (progn com (beginning-of-line) (if (looking-at shell-prompt) (region-around-match 0) (looking-at lisp-prompt) (region-around-match 0)) (set-mark) (end-of-line) (forward-character) (setq com (region-to-string)) (end-of-file) (set-mark) (insert-string com) ) ) (setq last-line (region-to-string)) (region-to-process (active-process)) (set-mark) ) ) (defun (pr-output samebuf oldbuf sameplace (setq samebuf (= (setq oldbuf (current-buffer-name)) MPX-process)) (temp-use-buffer MPX-process) (setq sameplace (= (dot) (mark))) (exchange-dot-and-mark) (insert-string (process-output)) (if sameplace (set-mark)) (exchange-dot-and-mark) (temp-use-buffer oldbuf) (if samebuf (sit-for 0)) ) ) (defun (stop-shell (stop-process "shell"))) (defun (shell old-ucof (pop-to-buffer "shell") (setq needs-checkpointing 0) (setq old-ucof use-csh-option-f) (setq use-csh-option-f 1) (if (< (process-status "shell") 0) (start-filtered-process "exec csh -i" "shell" "pr-output")) (setq use-csh-option-f old-ucof) (local-bind-to-key "pr-newline" '^m') (local-bind-to-key "send-eot" '') (local-bind-to-key "send-int-signal" '\177') (local-bind-to-key "send-quit-signal" '^\') (local-bind-to-key "grab-last-line" "\e=") (local-bind-to-key "stop-shell" "\e\^Z") (end-of-file) (set-mark) (novalue) ) ) (defun (new-shell name old-ucof (setq name (arg 1 ": new-shell (buffer name) ")) (pop-to-buffer name) (use-abbrev-table "shell") (use-syntax-table "shell") (setq abbrev-mode 1) (setq needs-checkpointing 0) (setq old-ucof use-csh-option-f) (setq use-csh-option-f 1) (if (< (process-status name) 0) (start-filtered-process "exec csh -i" name "pr-output")) (setq use-csh-option-f old-ucof) (local-bind-to-key "pr-newline" '^m') (local-bind-to-key "send-eot" '') (local-bind-to-key "send-int-signal" '\177') (local-bind-to-key "send-quit-signal" '^\') (local-bind-to-key "grab-last-line" "\e=") (local-bind-to-key "stop-shell" "\e\^Z") (end-of-file) (set-mark) (novalue) ) ) (defun (send-eot (if (eobp) (eot-process (active-process)) (delete-next-character) ) ) ) (defun (send-int-signal (int-process (active-process)))) (defun (send-quit-signal (quit-process (active-process)))) (defun (lisp-kill-output (end-of-file) (beginning-of-line) (set-mark) (previous-line) (re-search-reverse "^[0-9][0-9]*\.") (next-line) (erase-region) (backward-character) (insert-string " [output flushed]") (end-of-file) (set-mark) )) (defun (lisp old-ucof (pop-to-buffer "lisp") (setq needs-checkpointing 0) (if (bobp) (progn (electric-lisp-mode) (local-bind-to-key "lisp-kill-output" "\^X\^K"))) (setq old-ucof use-csh-option-f) (setq use-csh-option-f 1) (if (< (process-status "lisp") 0) (start-filtered-process "exec /usr/local/lisp" "lisp" "pr-output")) (setq use-csh-option-f old-ucof) (local-bind-to-key "pr-newline" '^m') (local-bind-to-key "send-eot" '') (local-bind-to-key "send-int-signal" '\177') (local-bind-to-key "send-quit-signal" '^\') (local-bind-to-key "grab-last-line" "\e=") (end-of-file) (set-mark) (novalue) ) ) (defun (grab-last-line (end-of-file) (set-mark) (insert-string last-line) (delete-previous-character) ) ) (defun (shell-cd (if (= (- (dot) (mark)) 2) (progn (cd (get-tty-string ": cd ")) (insert-string " " (working-directory)) (pr-newline) 0) 1))) (save-excursion (temp-use-buffer "shell") (use-abbrev-table "shell") (setq abbrev-mode 1) (define-local-abbrev "~" (getenv "HOME")) (define-hooked-local-abbrev "cd" "cd" "shell-cd") (use-syntax-table "shell") (modify-syntax-entry "w ~") (novalue)) //go.sysin dd * made=TRUE if [ $made = TRUE ]; then /bin/chmod 664 newproc.ml /bin/echo -n ' '; /bin/ls -ld newproc.ml fi /bin/echo 'Extracting mtyconnect.c' sed 's/^X//' <<'//go.sysin dd *' >mtyconnect.c X/* mtyconnect.c - connect to a tty under the control of 4.1 bsd Emacs */ #include <signal.h> #include <sys/types.h> #include <sys/stat.h> X/* This is the other side of the unexpected process handling system for use with Gosling Emacs. This routine should be loaded in with a program that wants to access another terminal while the user of that terminal is running Emacs. usage: char *ttyptr; if ((fd = ttyconnnect (ttyptr)) == -1) { perror (ttyptr); return; } If ttyconnect() doesn't return -1, then it returns a valid fd. You can use this descriptor for read()s and write()s. To close the connection, just close() it. */ static alf; static al () { alf++; } #define ALWAIT 10 ttyconnect (tty) char *tty; { register fd; char mpxf[40]; struct stat s; int otime; int (*ofunc) (), (*signal ()) (); strcpy (mpxf, "/tmp"); strcat (mpxf, tty); mpxf[8] = '_'; /* NOTE: ASSUMES THAT tty IS OF THE FORM /dev/ttyXX */ if (stat (mpxf, &s) == 0 && ((s & S_IFMT) == S_IFMPC)) { otime = alarm (0); alf = 0; ofunc = signal (SIGALRM, al); alarm (ALWAIT); fd = open (mpxf, 2); signal (SIGALRM, ofunc); if (fd < 0 && alf) { /* open failed, alarm went off */ alarm (otime > ALWAIT ? otime - ALWAIT : 1); return -1; } alarm (otime); return fd; } return -1; } //go.sysin dd * made=TRUE if [ $made = TRUE ]; then /bin/chmod 644 mtyconnect.c /bin/echo -n ' '; /bin/ls -ld mtyconnect.c fi /bin/echo 'Extracting ttyconnect.c' sed 's/^X//' <<'//go.sysin dd *' >ttyconnect.c X/* ttyconnect.c - connect to a tty under the control of 4.1a bsd Emacs */ #include <stdio.h> #include <errno.h> #include <signal.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/socket.h> #ifndef BSD41c #include <net/in.h> #else BSD41c #include <netinet/in.h> #endif BSD41c X/* This is the other side of the unexpected process handling system for use with Gosling Emacs. This routine should be loaded in with a program that wants to access another terminal while the user of that terminal is running Emacs. usage: char *ttyptr; if ((fd = ttyconnnect (ttyptr)) == -1) { perror (ttyptr); return; } If ttyconnect() doesn't return -1, then it returns a valid fd. You can use this descriptor for read()s and write()s. To close the connection, just close() it. One warning: the file descriptor returned acts much like one returned from a pipe() call. Hence lseek()s won't work, and if the other side closes the connection and you try and write to it, SIGPIPE is generated. */ #ifdef BSD41c X/* Modified for 4.1cBSD 27 June 1983 by Chris Kent */ #endif BSD41c #ifndef BSD41c #define SO_OPTIONS (SO_DONTLINGER | SO_KEEPALIVE) #endif BSD41c #define IPPORT_EMACS 010000 #ifndef BSD41c #define htons(x) (((x << 8) & 0xff00) | ((x >> 8) & 0xff)) #define ntohs(x) (((x << 8) & 0xff00) | ((x >> 8) & 0xff)) #endif BSD41c #define ATIME ((unsigned) 20) #define NOTOK (-1) X/* */ extern int errno; int *alrmser (); int ttyconnect (ttyptr) char *ttyptr; { int sd, tty_port, timer; int (*astat) (); char localname[BUFSIZ], *localptr = localname; long iaddr; struct sockaddr_in tty_socket, *tsock = &tty_socket, emacs_socket, *esock = &emacs_socket; struct stat st; if (stat (ttyptr, &st) == NOTOK) return NOTOK; if ((st.st_mode & S_IFMT) != S_IFCHR) { errno = ENOTTY; return NOTOK; } tty_port = IPPORT_EMACS | minor (st.st_rdev); gethostname (localname, sizeof localname); if ((iaddr = rhost (&localptr)) == NOTOK) { errno = ENETDOWN; return NOTOK; } tsock -> sin_family = AF_INET; tsock -> sin_port = 0; #ifdef vax tsock -> sin_port = htons (tsock -> sin_port); #endif #ifndef BSD41c tsock -> sin_addr.s_addr = (u_long) 0; if ((sd = socket (SOCK_STREAM, NULL, tsock, SO_OPTIONS)) == NOTOK) #else BSD41c tsock -> sin_addr.s_addr = (u_long) INADDR_ANY; if ((sd = socket(AF_INET, SOCK_STREAM, 0)) < 0) #endif BSD41c return NOTOK; #ifdef BSD41c if(bind(sd, tsock, sizeof(*tsock)) < 0) return NOTOK; #endif BSD41c #ifdef vax tsock -> sin_port = ntohs (tsock -> sin_port); #endif esock -> sin_family = AF_INET; esock -> sin_port = tty_port; #ifdef vax esock -> sin_port = htons (esock -> sin_port); #endif esock -> sin_addr.s_addr = (u_long) iaddr; astat = signal (SIGALRM, alrmser); if ((timer = alarm (ATIME)) > 0) if ((timer -= ATIME) < 0) timer = 1; #ifndef BSD41c if (connect (sd, esock) == NOTOK) #else BSD41c if (connect (sd, esock, sizeof(*esock)) == NOTOK) #endif BSD41c switch (errno) { default: perror ("unable to complete socket"); case EINTR: case EISCONN: case ETIMEDOUT: case ECONNREFUSED: close (sd); signal (SIGALRM, astat); alarm (timer); return NOTOK; } #ifdef vax esock -> sin_port = ntohs (esock -> sin_port); #endif signal (SIGALRM, astat); alarm (timer); return sd; } X/* ARGSUSED */ static int *alrmser (sig) int sig; { } //go.sysin dd * made=TRUE if [ $made = TRUE ]; then /bin/chmod 664 ttyconnect.c /bin/echo -n ' '; /bin/ls -ld ttyconnect.c fi /bin/echo 'Extracting dsp.c' sed 's/^X//' <<'//go.sysin dd *' >dsp.c X/* Display routines */ X/* Copyright (c) 1981,1980 James Gosling */ #include "config.h" #include "keyboard.h" #include "buffer.h" #include "window.h" #include "display.h" #include <sys/ioctl.h> #include <sgtty.h> #include <stdio.h> extern QuitDoRstDsp; /* Set while in raw */ struct sgttyb old; /* The initial tty mode bits */ InitDsp () { struct sgttyb sg; extern char _sobuf[]; gtty (0, &old); sg = old; QuitDoRstDsp++; sg.sg_flags = (sg.sg_flags & ~(ECHO | CRMOD | XTABS)) | RAW; stty (0, &sg); ScreenGarbaged = 1; setbuf (stdout, _sobuf); term_init (); if (tt.t_window) (*tt.t_window) (0); } RstDsp () { if (tt.t_window) (*tt.t_window) (0); (*tt.t_topos) (ScreenLength, 1); (*tt.t_wipeline) (0, ScreenWidth); (*tt.t_cleanup) (); fflush (stdout); stty (0, &old); QuitDoRstDsp = 0; } //go.sysin dd * made=TRUE if [ $made = TRUE ]; then /bin/chmod 664 dsp.c /bin/echo -n ' '; /bin/ls -ld dsp.c fi /bin/echo 'Extracting sleep.c' sed 's/^X//' <<'//go.sysin dd *' >sleep.c X/* Version of sleep() that uses new signal mechanism */ X/* ACT 5-Nov-1982 */ #include <signal.h> static alarmed; int (*sigset())(); sleep(n) unsigned n; { int sleepx(); unsigned altime; int (*alsig)(); if (n==0) return; altime = alarm(1000); /* time to maneuver */ if (altime) { /* alarm already set */ if (altime > n) altime -= n;/* alarm should go off again later */ else { n = altime;/* sleep ends early */ altime = 1;/* and alarm goes off again later */ } } alsig = sigset(SIGALRM, sleepx); alarmed = 0; alarm(n); while (!alarmed) pause(); sigset(SIGALRM, alsig); alarm(altime); } static sleepx() { alarmed++; } //go.sysin dd * made=TRUE if [ $made = TRUE ]; then /bin/chmod 664 sleep.c /bin/echo -n ' '; /bin/ls -ld sleep.c fi -- In-Real-Life: Chris Torek, Univ of MD Comp Sci UUCP: {seismo,allegra,brl-bmd}!umcp-cs!chris CSNet: chris@umcp-cs ARPA: chris.umcp-cs@UDel-Relay