diff options
Diffstat (limited to 'historic')
-rw-r--r-- | historic/makehole.8 | 44 | ||||
-rw-r--r-- | historic/makehole.c | 140 | ||||
-rw-r--r-- | historic/makeinfo.sh | 2 | ||||
-rw-r--r-- | historic/selection/Makefile | 58 | ||||
-rw-r--r-- | historic/selection/README.selection | 151 | ||||
-rw-r--r-- | historic/selection/mouse.c | 367 | ||||
-rw-r--r-- | historic/selection/mouse.h | 34 | ||||
-rw-r--r-- | historic/selection/selection.1 | 142 | ||||
-rw-r--r-- | historic/selection/selection.c | 237 | ||||
-rw-r--r-- | historic/selection/test-mouse.c | 67 | ||||
-rw-r--r-- | historic/sync.c | 14 | ||||
-rw-r--r-- | historic/update.8 | 25 | ||||
-rw-r--r-- | historic/update.c | 45 |
13 files changed, 1326 insertions, 0 deletions
diff --git a/historic/makehole.8 b/historic/makehole.8 new file mode 100644 index 00000000..5b5c63be --- /dev/null +++ b/historic/makehole.8 @@ -0,0 +1,44 @@ +.\" Copyright 1992 Rickard E. Faith (faith@cs.unc.edu) +.\" May be distributed under the GNU General Public License +.TH MAKEHOLE 8 "20 November 1993" "Linux 0.99" "Linux Programmer's Manual" +.SH NAME +makehole \- a program to make filesystem "holes" in pure executables +.SH SYNOPSIS +.B makehole +Imagefile +.SH DESCRIPTION +.B makehole +copies the +.IR Imagefile , +using +.BR lseek (2) +to skip over sections of the file which contain all zeros. If the file +system is smart enough to recognize this use of +.BR lseek (2), +then it will store the file in a more efficient fashion. + +The logical length of the file will +.I not +be changed, only the way it is stored in the filesystem. This can save a +lot of space if the file contains large blocks of zeros. +.BR cp (3) +will not similar "hole creation," but it does not seem to be as extensive +(see the GNU source code for details). +.BR dd (3) +will +.I not +create holes, and should be used when holes are not desired (i.e., for the +.BR shoelace (8) +boot image). +.SH "SEE ALSO" +.BR lseek (2), +.BR cp (3), +.BR dd (3) +.SH BUGS +Must be root to run. +.br +The +.I Imagefile +must be a pure exectuable. +.SH AUTHOR +HJ Lu diff --git a/historic/makehole.c b/historic/makehole.c new file mode 100644 index 00000000..6c337db0 --- /dev/null +++ b/historic/makehole.c @@ -0,0 +1,140 @@ +/* makehole.c - original by HJ Lu */ + +/* Patched by faith@cs.unc.edu, Wed Oct 6 18:01:39 1993 based on + information from Michael Bischoff <mbi@mo.math.nat.tu-bs.de> (Fri, 18 + Jun 93 10:10:19 +0200). */ + +#include <unistd.h> +#include <fcntl.h> +#include <stdlib.h> +#include <stdio.h> +#include <errno.h> +#include <a.out.h> + +#define BUFSIZE 1024 +#undef DEBUG + +void usage(char *name, char *message) +{ + if (message) + fprintf(stderr, "%s: %s\n", name, message); + + if (errno) + perror(name); + + fprintf(stderr, "Usage:%s Imagefile\n", name); + exit(1); +} + +int ishole(char *buf, int size) +{ + int i; + + for (i = 0; i < size; i++) + if (buf[i]) + return 0; + + return 1; +} + +void main(int argc, char *argv[]) +{ + char buf[BUFSIZE]; + char tmp_file[64]; + int fdin, fdout; + int ret; + int abs_offset; + int hole; + struct exec *header = (struct exec *) buf; + +#ifndef DEBUG + if (geteuid()) { + fprintf(stderr, "%s: must be root to run!\n", *argv); + exit(1); + } +#endif + + switch (argc) { + case 2: + break; + default: + usage(*argv, NULL); + } + + errno = 0; + + sprintf( tmp_file, "hole%d", getpid() ); + if (tmp_file == NULL) { + usage(*argv, "Unable to get a temporary image filename!"); + } +#ifdef DEBUG + else { + fprintf(stderr, "Temparory image file: %s\n", tmp_file); + } +#endif + + errno = 0; + fdin = open(argv[1], O_RDONLY); + if (fdin == -1) { + usage(*argv, "unable to open file."); + } + fprintf(stderr, "Making holes in %s...\n", argv[1]); + + errno = 0; + + if ((ret = read(fdin, header, BUFSIZE)) != BUFSIZE + || N_MAGIC(*header) != ZMAGIC) { + usage(*argv, "file must be pure executable."); + } + + fdout = creat(tmp_file, 0555); + if (fdout == -1) { + perror("Unable to create the temparory image file!"); + exit(1); + } + if (write(fdout, header, ret) != ret) { + perror("Fail to write header to the temparory image file!"); + unlink(tmp_file); + exit(1); + } + abs_offset = ret; + hole = 0; + while ((ret = read(fdin, buf, BUFSIZE)) > 0) { + abs_offset += ret; + if (ishole(buf, ret)) { +#ifdef DEBUG + fprintf(stderr, "There is a %d byte hole from 0x%x to 0x%x.\n", ret, abs_offset - ret, abs_offset); +#endif + hole += ret; + if (lseek(fdout, abs_offset, SEEK_SET) != abs_offset) { + perror("Fail to make a hole in the temparory image file!"); + unlink(tmp_file); + exit(1); + } + } else { +#ifdef DEBUG + fprintf(stderr, "Writing %d bytes from 0x%x to 0x%x.\n", ret, abs_offset - ret, abs_offset); +#endif + if (write(fdout, buf, ret) != ret) { + perror("Fail to write the temparory image file!"); + unlink(tmp_file); + exit(1); + } + } + } + + if (ftruncate(fdout, abs_offset)) { + perror("Fail to truncate the temparory image file!"); + unlink(tmp_file); + exit(1); + } + close(fdout); + close(fdin); + + if (rename(tmp_file, argv[1])) { + perror("Fail to rename the temparory image file to the old image file!"); + unlink(tmp_file); + exit(1); + } + fprintf(stderr, "There are %d byte holes out of %d bytes in `%s'.\n", hole, abs_offset, argv[1]); +} diff --git a/historic/makeinfo.sh b/historic/makeinfo.sh new file mode 100644 index 00000000..9061c833 --- /dev/null +++ b/historic/makeinfo.sh @@ -0,0 +1,2 @@ +#!/bin/sh +emacs -batch $* -f texinfo-format-buffer -f save-buffer diff --git a/historic/selection/Makefile b/historic/selection/Makefile new file mode 100644 index 00000000..ec78fbcd --- /dev/null +++ b/historic/selection/Makefile @@ -0,0 +1,58 @@ +# Makefile for selection utility +# Andrew Haylett, 17th June 1993 +# Minor modifications by Rik Faith (faith@cs.unc.edu), Sat Nov 20 09:47:59 1993 + +# bump .., since we live in historic now +include ../../MCONFIG +BINDIR = $(USRBINDIR) +MANEXT = 1 + +all: selection test-mouse + +selection: selection.o mouse.o + $(CC) $(LDFLAGS) -o selection selection.o mouse.o + +test-mouse: test-mouse.o mouse.o + $(CC) $(LDFLAGS) -o test-mouse test-mouse.o mouse.o + +mouse.o: mouse.c mouse.h + +selection.o: selection.c mouse.h Makefile + +test-mouse.o: test-mouse.c mouse.h + +selection.man: selection.1 + nroff -man selection.1 > selection.man + +install: selection # selection.man + install -m 755 selection $(BINDIR)/selection + install -m 644 selection.1 $(MANDIR)/man$(MANEXT)/selection.$(MANEXT) + +DIST = selection-1.5 +DATE = 17th June 1993 +PATCH = patch-0.99.10 +SRC = README Makefile selection.1 mouse.c mouse.h selection.c test-mouse.c +DFILES = $(SRC) selection.man $(PATCH) +DIFF = diff +DFLAGS = -u + +patch: + (cd /usr/src/linux; \ + $(DIFF) -c0 $(DFLAGS) config.in~ config.in; \ + $(DIFF) $(DFLAGS) kernel/chr_drv/tty_ioctl.c~ kernel/chr_drv/tty_ioctl.c; \ + $(DIFF) $(DFLAGS) kernel/chr_drv/console.c~ kernel/chr_drv/console.c) \ + > $(PATCH); true + +update: + perl -pi -e 's/\d+\S+ \S+ 199[3]/$(DATE)/' $(SRC) + +dist: update patch $(DFILES) + rm -fr $(DIST) + mkdir $(DIST) + cp $(DFILES) $(DIST) + tar cf - $(DIST) | gzip -c > $(DIST).tar.z + rm -fr $(DIST) + +clean: + rm -f selection.o mouse.o test-mouse.o selection test-mouse \ + selection.man *~ diff --git a/historic/selection/README.selection b/historic/selection/README.selection new file mode 100644 index 00000000..7435161d --- /dev/null +++ b/historic/selection/README.selection @@ -0,0 +1,151 @@ + selection 1.5: Copy and paste for Linux Virtual Consoles using mouse + -------------------------------------------------------------------- + +This package implements mouse-driven selection of text from a VC and pasting +of the text into the same or a different VC, the user interface being based +loosely on the equivalent xterm facility. + +Version 1.5 +----------- + - fixed support for bus mice. + - added support for PS/2 and Mouse Systems 3-byte mice. + - command line options added. + - updated for kernel version 0.99.pl10. + - cooperates with XFree86 1.2, for serial mice at least. + - enabled as part of normal kernel configuration process. + +Version 1.4 +----------- + - added manual page. + - updated for kernel version 0.99.pl0. + +Version 1.3 +----------- + - improved support for Logitech mice (speed set correctly). + - optional flag for left-handed users. + - corrected bug in Mouse Systems handling code. + +Version 1.2 +----------- + - disabled when console in graphics mode, eg. under X11 or MGR. + - uses default screen size if ioctl TIOCGWINSZ fails. + +Version 1.1 +----------- + - support for some common mouse types. + - selection by word or line as well as by character. + - changes in the interface to make it behave more like xterm. + +Manifest +-------- + README + Makefile + selection.1 manual page + selection.man formatted manual page + patch-0.99.10 patches to kernel + mouse.c source for mouse driver + mouse.h mouse driver interface + selection.c source for selection manager + test-mouse.c test code for mouse compatibility + +Mouse support +------------- + +The following types of mouse are supported. + + - Microsoft + - MouseSystems 3-byte and 5-byte + - MM Series + - Logitech + - BusMouse + - PS/2 + +The code has been tested with various types of mice, including +Microsoft-compatible and Logitech, a three-button Mouse Systems, and with bus +and PS/2 mice; please tell me if it doesn't work with yours and you think it +ought to. + +Installation +------------ + +1. Check it out +--------------- + + - Make the mouse device. If you have a serial mouse, either use `mknod' to + make /dev/mouse reference the appropriate serial driver or create a + symbolic link from /dev/ttys? to /dev/mouse. If you have a bus mouse, + use `mknod' to create the bus mouse device if it doesn't already exist. + Make sure that your kernel is configured to support the appropriate + bus mouse device (specified during `make config'). + +e.g. mknod /dev/mouse c 4 64 +or ln -s /dev/ttys1 /dev/mouse (for serial mouse) + + mknod /dev/busmouse c 10 0 (for Logitech bus mouse) + + - Test your mouse for compatibility by using the test-mouse facility + supplied. Build it by typing `make test-mouse', then run `test-mouse'. + You may need to supply it with certain options; try `test-mouse -?'. + If your mouse device is not /dev/mouse, use the -m option. You should + be able to move the cursor over the entire screen, and draw + asterisks in different colours by moving the mouse while pressing + different buttons. Press both the left and right buttons while the mouse + is not moving to quit the program. The options that you find work with + `test-mouse' should also work with `selection'. + +2. Patch the kernel +------------------- + + [ NOTE: Precompiled versions of the kernel supplied with the SLS + package should already have the patch applied, in which case this + section may be skipped. ] + + - Apply the kernel patches, by going into the directory in which the + kernel source is located (eg. /usr/src/linux) and typing: + + patch < patch-0.99.10 + + The patches were generated against the standard 0.99.pl10 kernel. + +The following files are patched: + + config.in to add the selection mechanism as a + configuration option. + + kernel/chr_drv/tty_ioctl.c to provide the interface to the selection + mechanism via ioctl(..., TCIOLINUX, ...). + + kernel/chr_drv/console.c to implement the selection mechanism itself. + + - Reconfigure the kernel by typing 'make config', remembering to include + the selection mechanism by answering 'y' to the appropriate question. + + - To be safe, rebuild the kernel dependencies using 'make dep'. + + - Rebuild the kernel and reboot. + + - Make sure you have the /dev/tty0 (current VC) device. If not, make it using + + mknod /dev/tty0 c 4 0 + +3. Build the program +-------------------- + + - Type `make' in the directory in which you unpacked the selection code; + this will build the `selection' executable. It has been tested with + gcc 2.3.3 and libc.so.4.3.3. + + - Run `selection &' to test it out. Use `selection -?' to see what + options are supported. Then type `make install', which installs the + executable in /etc and the manual page in /usr/man, and start it up + from /etc/rc.local. Consult the manual page for usage. It should + work with text screens of various sizes, e.g. 80x28, 80x50, etc. + +The default size of the paste buffer is 2048 bytes. This may be changed by +altering the value of SEL_BUFFER_SIZE in kernel/chr_drv/console.c. + +And that's all there is to it, hopefully. See the manual page for a more +detailed description of operation. Please let me know of any problems, +suggestions for enhancements, etc, etc. + +Andrew Haylett <ajh@gec-mrc.co.uk>, 17th June 1993 diff --git a/historic/selection/mouse.c b/historic/selection/mouse.c new file mode 100644 index 00000000..87e9d06e --- /dev/null +++ b/historic/selection/mouse.c @@ -0,0 +1,367 @@ +/* simple driver for serial mouse */ +/* Andrew Haylett, 17th June 1993 */ + +#include <unistd.h> +#include <stdlib.h> +#include <termios.h> +#include <fcntl.h> +#include <stdio.h> +#include <string.h> + +#include "mouse.h" + +#define DEF_MDEV "/dev/mouse" +#define DEF_MTYPE P_MS +#define DEF_MBAUD 1200 +#define DEF_MSAMPLE 100 +#define DEF_MDELTA 25 +#define DEF_MACCEL 2 +#define DEF_SLACK -1 + +/* thse settings may be altered by the user */ +static char *mdev = DEF_MDEV; /* mouse device */ +static mouse_type mtype = DEF_MTYPE; /* mouse type */ +static int mbaud = DEF_MBAUD; /* mouse device baud rate */ +static int msample = DEF_MSAMPLE; /* sample rate for Logitech mice */ +static int mdelta = DEF_MDELTA; /* x+y movements more than mdelta pixels..*/ +static int maccel = DEF_MACCEL; /* ..are multiplied by maccel. */ +static int slack = DEF_SLACK; /* < 0 ? no wraparound : amount of slack */ +int ms_copy_button = MS_BUTLEFT, + ms_paste_button = MS_BUTRIGHT; + +static char *progname; + +static void +ms_usage() +{ + printf( + "Selection version 1.5, 17th June 1993\n" + "Usage: %s [-a accel] [-b baud-rate] [-c l|m|r] [-d delta]\n" + " [-m mouse-device] [-p l|m|r] [-s sample-rate] [-t mouse-type]\n" + " [-w slack]\n\n", progname); + printf( + " -a accel sets the acceleration (default %d)\n" + " -b baud-rate sets the baud rate (default %d)\n" + " -c l|m|r sets the copy button (default `l')\n" + " -d delta sets the delta value (default %d)\n" + " -m mouse-device sets mouse device (default `%s')\n" + " -p l|m|r sets the paste button (default `r')\n" + " -s sample-rate sets the sample rate (default %d)\n" + " -t mouse-type sets mouse type (default `ms')\n" + " Microsoft = `ms', Mouse Systems Corp = `msc',\n" + " MM Series = `mm', Logitech = `logi', BusMouse = `bm',\n" + " MSC 3-bytes = `sun', PS/2 = `ps2')\n" + " -w slack turns on wrap-around and specifies slack (default off)\n", + DEF_MACCEL, DEF_MBAUD, DEF_MDELTA, DEF_MDEV, DEF_MSAMPLE); + exit(1); +} + +extern int optind; +extern char *optarg; + +void +ms_params(int argc, char *argv[]) +{ + int opt; + + progname = (rindex(argv[0], '/')) ? rindex(argv[0], '/') + 1 : argv[0]; + while ((opt = getopt(argc, argv, "a:b:c:d:m:p:s:t:w:")) != -1) + { + switch (opt) + { + case 'a': + maccel = atoi(optarg); + if (maccel < 2) + ms_usage(); + break; + case 'b': + mbaud = atoi(optarg); + break; + case 'c': + switch (*optarg) + { + case 'l': ms_copy_button = MS_BUTLEFT; break; + case 'm': ms_copy_button = MS_BUTMIDDLE; break; + case 'r': ms_copy_button = MS_BUTRIGHT; break; + default: ms_usage(); break; + } + break; + case 'd': + mdelta = atoi(optarg); + if (mdelta < 2) + ms_usage(); + break; + case 'm': + mdev = optarg; + break; + case 'p': + switch (*optarg) + { + case 'l': ms_paste_button = MS_BUTLEFT; break; + case 'm': ms_paste_button = MS_BUTMIDDLE; break; + case 'r': ms_paste_button = MS_BUTRIGHT; break; + default: ms_usage(); break; + } + break; + case 's': + msample = atoi(optarg); + break; + case 't': + if (!strcmp(optarg, "ms")) + mtype = P_MS; + else if (!strcmp(optarg, "sun")) + mtype = P_SUN; + else if (!strcmp(optarg, "msc")) + mtype = P_MSC; + else if (!strcmp(optarg, "mm")) + mtype = P_MM; + else if (!strcmp(optarg, "logi")) + mtype = P_LOGI; + else if (!strcmp(optarg, "bm")) + mtype = P_BM; + else if (!strcmp(optarg, "ps2")) + mtype = P_PS2; + else + ms_usage(); + break; + case 'w': + slack = atoi (optarg); + break; + default: + ms_usage(); + break; + } + } +} + +#define limit(n,l,u,s) n = ((s) < 0 ? \ + (((n) < (l) ? (l) : ((n) > (u) ? (u) : (n)))) : \ + (((n) < (l-s) ? (u) : ((n) > (u+s) ? (l) : (n))))) + +static int mx = 32767; +static int my = 32767; +static int x, y; +static int mfd = -1; + +static const unsigned short cflag[NR_TYPES] = +{ + (CS7 | CREAD | CLOCAL | HUPCL ), /* MicroSoft */ + (CS8 | CSTOPB | CREAD | CLOCAL | HUPCL ), /* MouseSystems 3 */ + (CS8 | CSTOPB | CREAD | CLOCAL | HUPCL ), /* MouseSystems 5 */ + (CS8 | PARENB | PARODD | CREAD | CLOCAL | HUPCL ), /* MMSeries */ + (CS8 | CSTOPB | CREAD | CLOCAL | HUPCL ), /* Logitech */ + 0, /* BusMouse */ + 0 /* PS/2 */ +}; + +static const unsigned char proto[NR_TYPES][5] = +{ + /* hd_mask hd_id dp_mask dp_id nobytes */ + { 0x40, 0x40, 0x40, 0x00, 3 }, /* MicroSoft */ + { 0xf8, 0x80, 0x00, 0x00, 3 }, /* MouseSystems 3 (Sun) */ + { 0xf8, 0x80, 0x00, 0x00, 5 }, /* MouseSystems 5 */ + { 0xe0, 0x80, 0x80, 0x00, 3 }, /* MMSeries */ + { 0xe0, 0x80, 0x80, 0x00, 3 }, /* Logitech */ + { 0xf8, 0x80, 0x00, 0x00, 5 }, /* BusMouse */ + { 0xcc, 0x00, 0x00, 0x00, 3 } /* PS/2 */ +}; + +static void +ms_setspeed(const int old, const int new, + const unsigned short c_cflag) +{ + struct termios tty; + char *c; + + tcgetattr(mfd, &tty); + + tty.c_iflag = IGNBRK | IGNPAR; + tty.c_oflag = 0; + tty.c_lflag = 0; + tty.c_line = 0; + tty.c_cc[VTIME] = 0; + tty.c_cc[VMIN] = 1; + + switch (old) + { + case 9600: tty.c_cflag = c_cflag | B9600; break; + case 4800: tty.c_cflag = c_cflag | B4800; break; + case 2400: tty.c_cflag = c_cflag | B2400; break; + case 1200: + default: tty.c_cflag = c_cflag | B1200; break; + } + + tcsetattr(mfd, TCSAFLUSH, &tty); + + switch (new) + { + case 9600: c = "*q"; tty.c_cflag = c_cflag | B9600; break; + case 4800: c = "*p"; tty.c_cflag = c_cflag | B4800; break; + case 2400: c = "*o"; tty.c_cflag = c_cflag | B2400; break; + case 1200: + default: c = "*n"; tty.c_cflag = c_cflag | B1200; break; + } + + write(mfd, c, 2); + usleep(100000); + tcsetattr(mfd, TCSAFLUSH, &tty); +} + +int +ms_init(const int maxx, const int maxy) +{ + if ((mfd = open(mdev, O_RDWR)) < 0) + { + char buf[32]; + sprintf(buf, "ms_init: %s", mdev); + perror(buf); + return -1; + } + + if (mtype != P_BM && mtype != P_PS2) + { + ms_setspeed(9600, mbaud, cflag[mtype]); + ms_setspeed(4800, mbaud, cflag[mtype]); + ms_setspeed(2400, mbaud, cflag[mtype]); + ms_setspeed(1200, mbaud, cflag[mtype]); + + if (mtype == P_LOGI) + { + write(mfd, "S", 1); + ms_setspeed(mbaud, mbaud, cflag[P_MM]); + } + + if (msample <= 0) write(mfd, "O", 1); + else if (msample <= 15) write(mfd, "J", 1); + else if (msample <= 27) write(mfd, "K", 1); + else if (msample <= 42) write(mfd, "L", 1); + else if (msample <= 60) write(mfd, "R", 1); + else if (msample <= 85) write(mfd, "M", 1); + else if (msample <= 125) write(mfd, "Q", 1); + else write(mfd, "N", 1); + } + + mx = maxx; + my = maxy; + x = mx / 2; + y = my / 2; + return 0; +} + +int +get_ms_event(struct ms_event *ev) +{ + unsigned char buf[5]; + char dx, dy; + int i, acc; + + if (mfd == -1) + return -1; + if (mtype != P_BM) + { + if (read(mfd, &buf[0], 1) != 1) + return -1; +restart: + /* find a header packet */ + while ((buf[0] & proto[mtype][0]) != proto[mtype][1]) + { + if (read(mfd, &buf[0], 1) != 1) + { + perror("get_ms_event: read"); + return -1; + } + } + + /* read in the rest of the packet */ + for (i = 1; i < proto[mtype][4]; ++i) + { + if (read(mfd, &buf[i], 1) != 1) + { + perror("get_ms_event: read"); + return -1; + } + /* check whether it's a data packet */ + if (mtype != P_PS2 && ((buf[i] & proto[mtype][2]) != proto[mtype][3] + || buf[i] == 0x80)) + goto restart; + } + } + else /* bus mouse */ + { + while ((i = read(mfd, buf, 3)) != 3 && errno == EAGAIN) + usleep(40000); + if (i != 3) + { + perror("get_ms_event: read"); + return -1; + } + } + +/* construct the event */ + switch (mtype) + { + case P_MS: /* Microsoft */ + default: + ev->ev_butstate = ((buf[0] & 0x20) >> 3) | ((buf[0] & 0x10) >> 4); + dx = (char)(((buf[0] & 0x03) << 6) | (buf[1] & 0x3F)); + dy = (char)(((buf[0] & 0x0C) << 4) | (buf[2] & 0x3F)); + break; + case P_SUN: /* Mouse Systems 3 byte as used in Sun workstations */ + ev->ev_butstate = (~buf[0]) & 0x07; + dx = (char)(buf[1]); + dy = -(char)(buf[2]); + break; + case P_MSC: /* Mouse Systems Corp (5 bytes, PC) */ + ev->ev_butstate = (~buf[0]) & 0x07; + dx = (char)(buf[1]) + (char)(buf[3]); + dy = - ((char)(buf[2]) + (char)(buf[4])); + break; + case P_MM: /* MM Series */ + case P_LOGI: /* Logitech */ + ev->ev_butstate = buf[0] & 0x07; + dx = (buf[0] & 0x10) ? buf[1] : - buf[1]; + dy = (buf[0] & 0x08) ? - buf[2] : buf[2]; + break; + case P_BM: /* BusMouse */ + ev->ev_butstate = (~buf[0]) & 0x07; + dx = (char)buf[1]; + dy = - (char)buf[2]; + break; + case P_PS2: /* PS/2 Mouse */ + ev->ev_butstate = 0; + if (buf[0] & 0x01) + ev->ev_butstate |= MS_BUTLEFT; + if (buf[0] & 0x02) + ev->ev_butstate |= MS_BUTRIGHT; + dx = (buf[0] & 0x10) ? buf[1]-256 : buf[1]; + dy = - ((buf[0] & 0x20) ? buf[2]-256 : buf[2]); + break; + } + + acc = (abs(ev->ev_dx) + abs(ev->ev_dy) > mdelta) ? maccel : 1; + ev->ev_dx = dx * acc; + ev->ev_dy = dy * acc; + x += ev->ev_dx; + y += ev->ev_dy; + limit(x, 0, mx, (int) (slack * mx / my)); + limit(y, 0, my, slack); + ev->ev_x = x; + ev->ev_y = y; + limit(ev->ev_x, 0, mx, -1); + limit(ev->ev_y, 0, my, -1); + if (dx || dy) + { + if (ev->ev_butstate) + ev->ev_code = MS_DRAG; + else + ev->ev_code = MS_MOVE; + } + else + { + if (ev->ev_butstate) + ev->ev_code = MS_BUTDOWN; + else + ev->ev_code = MS_BUTUP; + } + return 0; +} diff --git a/historic/selection/mouse.h b/historic/selection/mouse.h new file mode 100644 index 00000000..b8014dbd --- /dev/null +++ b/historic/selection/mouse.h @@ -0,0 +1,34 @@ +/* interface file for mouse driver */ +/* Andrew Haylett, 17th June 1993 */ + +#ifndef MOUSE_H +#define MOUSE_H + +#define MS_BUTLEFT 4 +#define MS_BUTMIDDLE 2 +#define MS_BUTRIGHT 1 + +typedef enum { + P_MS = 0, + P_SUN = 1, + P_MSC = 2, + P_MM = 3, + P_LOGI = 4, + P_BM = 5, + P_PS2 = 6 +} mouse_type; + +#define NR_TYPES 7 /* keep in step with mouse_type! */ + +struct ms_event { + enum { MS_NONE, MS_BUTUP, MS_BUTDOWN, MS_MOVE, MS_DRAG } ev_code; + char ev_butstate; + int ev_x, ev_y; + int ev_dx, ev_dy; +}; + +void ms_params(int argc, char *argv[]); +int ms_init(const int maxx, const int maxy); +int get_ms_event(struct ms_event *ev); + +#endif /* MOUSE_H */ diff --git a/historic/selection/selection.1 b/historic/selection/selection.1 new file mode 100644 index 00000000..450c9fab --- /dev/null +++ b/historic/selection/selection.1 @@ -0,0 +1,142 @@ +.\" +.\" selection.1 - the cut and paste utility for Linux virtual consoles +.\" +.\" Modified by faith@cs.unc.edu +.\" +.TH SELECTION 1 "20 November 1993" "Linux 0.99" "Linux Programmer's Manual" +.SH NAME +selection - the cut and paste utility for Linux virtual consoles +.SH SYNTAX +\fBselection [-a accel] [-b baud-rate] [-c l|m|r] [-d delta] [-m mouse-device] [-p l|m|r] [-s sample-rate] [-t mouse-type] [-r slack]\fR +.SH DESCRIPTION +\fBselection\fR is a utility that allows characters to be selected from the +current Linux virtual console using the mouse and pasted into the current +console. \fBselection\fR is normally invoked at boot time from /etc/rc.local, +and runs as a background process. +.SH OPTIONS +.IP \fB\-a\fP\fIaccel\fP +movements of more than \fIdelta\fP pixels are multiplied by \fIaccel\fP (default 2) +.IP \fB\-b\fP\fIbaud-rate\fP +set the baud rate of the mouse (default 1200 baud) +.IP \fB\-c\fP\fIl|m|r\fP +set the copy button to be the left, middle or right button (default left) +.IP \fB\-d\fP\fIdelta\fP +movements of more than \fIdelta\fP pixels are multiplied by \fIaccel\fP +(default 25) +.IP \fB\-m\fP\fImouse-device\fP +specify the mouse device (default /dev/mouse) +.IP \fB\-p\fP\fIl|m|r\fP +set the paste button to be the left, middle or right button (default right) +.IP \fB\-s\fP\fIsample-rate\fP +set the sample rate of the mouse (default 100) +.IP \fB\-t\fP\fImouse-type\fP +specify the mouse type (Microsoft = `ms', Mouse Systems Corp = `msc', +MM Series = `mm', Logitech = `logi', BusMouse = `bm', +MSC 3-bytes = `sun', PS/2 = `ps2'; default = ms) +.IP \fB\-w\fP\fIslack\fP +turn on wrap-around, specifying the amount of slack before the pointer +reappears at the other side of the screen (default off) +.SH OPERATION +To invoke the selection mechanism, press and release the copy button +(the meaning of the buttons may be set at startup as above). A highlighted +block will start moving around the screen, correlated with the movement of the +mouse. +.PP +Move the block to the first character of the selection, then press and hold +down the copy button. +.PP +Drag out the selection; the selected text will be highlighted. Then release +the copy button. You can take the end of the selection to before the start of +the selection if necessary. +.PP +Double-clicking the copy button while the highlighted block is on the +screen selects text by word boundaries; treble-clicking selects by entire +lines. If the button is held down after double- or treble-clicking, multiple +words or lines may be selected. A word consists of a set of alphanumeric +characters and underscores. +.PP +If a trailing space after the contents of a line is highlighted, and if there +is no other text on the remainder of the line, the rest of the line will be +selected automatically. If a number of lines are selected, highlighted +trailing spaces on each line will be removed from the selection buffer. +.PP +Pressing the paste button in any virtual console pastes the +selected text into the read queue of the associated tty. +.PP +Any output on the virtual console holding the selection will clear the +highlighted selection from the screen, to maintain integrity of the display, +although the contents of the paste buffer will be unaffected. +.PP +The selection mechanism is disabled if the controlling virtual console is +placed in graphics mode, for example when running X11, and is re-enabled when +text mode is resumed. (But see BUGS section below.) +.SH FILES +/dev/mouse - default mouse device +.br +/dev/console - current VC device +.SH DIAGNOSTICS +\fBselection\fR complains if any of the devices it requires cannot be located. +.SH BUGS +The size of the paste buffer is set at 2048 bytes by default. This may be +changed at compile time; consult the installation notes. +.PP +The selection mechanism doesn't work very well with graphics characters, or +indeed with any characters where a mapping between the typed character and +the displayed character is performed by the console driver. The selection +mechanism pastes into the input buffer the character codes as they are +displayed on the screen, not those originally typed in by the user. +.PP +Because of the way that the kernel bus mouse drivers work, allowing only one +process to have the mouse device open at once, \fBselection\fR cannot +co-exist with X11 using ATI XL, Logitech and Microsoft bus mice or with a +PS/2 mouse. The X server will not start while \fBselection\fR is running. +This problem is not present with serial mice. +.SH AUTHOR +.nf +Andrew Haylett <ajh@gec-mrc.co.uk> +.SH ACKNOWLEDGEMENTS +.nf +Lefty patches originally suggested by: +.ti +4 +Sotiris C. Vassilopoulos <scv2f@edu.Virginia.acc.honi4> +.br +Logitech patches from: +.ti +4 +Jim Winstead Jr <jwinstea@jarthur.Claremont.EDU> +.br +Command line options based on those from: +.ti +4 +Peter Macdonald <pmacdona@sanjuan> +.br +Patches for bus mouse from: +.br +.ti +4 +Erik Troan <ewtroan@eos.ncsu.edu> +.br +.ti +4 +Christoph Niemann <niemann@rubdv15.etdv.ruhr-uni-bochum.de> +.br +.ti +4 +Koen Gadeyne <kmg@barco.be> +.br +Patches for PS/2 mouse from: +.br +.ti +4 +Hans D. Fink +.br +Patches for Sun mouse from: +.br +.ti +4 +Michael Haardt <michael@gandalf.moria> +.br +Run-time configurable mouse buttons suggested by: +.br +.ti +4 +Charlie Brady <charlieb@au.oz.tpl.tplrd> +.br +Setsid patches by: +.bt +.ti +4 +Rick Sladkey <jrs@world.std.com> +.sp +Apologies to any contributors whose names I have omitted. diff --git a/historic/selection/selection.c b/historic/selection/selection.c new file mode 100644 index 00000000..058936fc --- /dev/null +++ b/historic/selection/selection.c @@ -0,0 +1,237 @@ +/* implement copying and pasting in Linux virtual consoles */ +/* Andrew Haylett, 17th June 1993 */ +/* Wed Feb 15 09:33:16 1995, faith@cs.unc.edu changed tty0 to console, since + most systems don't have a tty0 any more. */ + +#include <unistd.h> +#include <stdio.h> +#include <termios.h> +#include <fcntl.h> +#include <signal.h> +#include <errno.h> +#include <sys/kd.h> +#include <sys/ioctl.h> +#include <sys/time.h> + +#include "mouse.h" + +extern int ms_copy_button, ms_paste_button; + +static const int SCALE = 10; +static const long CLICK_INTERVAL = 250; /* msec */ +static const char *console = "/dev/console"; + +typedef enum { character = 0, word = 1, line = 2 } sel_mode; + +static int open_console(const int mode); +static void set_sel(const int xs, const int ys, const int xe, + const int ye, const sel_mode mode); +static void paste(void); +static long interval(const struct timeval *t1, const struct timeval *t2); +static int check_mode(void); + +int +main(int argc, char *argv[]) +{ + struct ms_event ev; + struct winsize win; + struct timeval tv1, tv2; + int xs, ys, xe, ye, x1, y1, fd, clicks = 0; + sel_mode mode; + + fd = open_console(O_RDONLY); + ioctl(fd, TIOCGWINSZ, &win); + close(fd); + if (! win.ws_col || ! win.ws_row) + { + fprintf(stderr, "selection: zero screen dimension, assuming 80x25.\n"); + win.ws_col = 80; + win.ws_row = 25; + } + + ms_params(argc, argv); + + if (ms_init(win.ws_col * SCALE - 1, win.ws_row * SCALE - 1)) + exit(1); + + if (fork() > 0) + exit(0); + setsid(); + + gettimeofday(&tv1, (struct timezone *)NULL); + +restart: + while (1) + { + if (check_mode()) + goto restart; + if (get_ms_event(&ev)) + exit(1); + if (ev.ev_butstate == ms_copy_button) + { + ++clicks; + gettimeofday(&tv2, (struct timezone *)NULL); + xs = ev.ev_x / SCALE + 1; + ys = ev.ev_y / SCALE + 1; + if (interval(&tv1, &tv2) < CLICK_INTERVAL && clicks == 1) + { + mode = word; + set_sel(xs, ys, xs, ys, mode); + } + else if (interval(&tv1, &tv2) < CLICK_INTERVAL && clicks == 2) + { + mode = line; + set_sel(xs, ys, xs, ys, mode); + } + else + { + mode = character; + clicks = 0; + do /* wait for left button up */ + { + if (check_mode()) + goto restart; + if (get_ms_event(&ev)) + exit(1); + } while (ev.ev_butstate); + x1 = y1 = 0; + do /* track start selection until left button down */ + { + xs = ev.ev_x / SCALE + 1; + ys = ev.ev_y / SCALE + 1; + if (xs != x1 || ys != y1) + { + set_sel(xs, ys, xs, ys, mode); + x1 = xs; y1 = ys; + } + if (check_mode()) + goto restart; + if (get_ms_event(&ev)) + exit(1); + } while (ev.ev_butstate != ms_copy_button); + } + x1 = y1 = 0; + gettimeofday(&tv1, (struct timezone *)NULL); + do /* track end selection until left button up */ + { + xe = ev.ev_x / SCALE + 1; + ye = ev.ev_y / SCALE + 1; + if (xe != x1 || ye != y1) + { + set_sel(xs, ys, xe, ye, mode); + x1 = xe; y1 = ye; + } + if (check_mode()) + goto restart; + if (get_ms_event(&ev)) + exit(1); + } while (ev.ev_butstate == ms_copy_button); + } else if (ev.ev_butstate == ms_paste_button) + { /* paste selection */ + paste(); + do /* wait for right button up */ + { + if (check_mode()) + goto restart; + if (get_ms_event(&ev)) + exit(1); + } while (ev.ev_butstate); + gettimeofday(&tv1, (struct timezone *)NULL); + clicks = 0; + } + } +} + +/* We have to keep opening and closing the console because (a) /dev/tty0 + changed its behaviour at some point such that the current VC is fixed + after the open(), rather than being re-evaluated at each write(), and (b) + because we seem to lose our grip on /dev/tty? after someone logs in if + this is run from /etc/rc. */ + +static int +open_console(const int mode) +{ + int fd; + + if ((fd = open(console, mode)) < 0) + { + perror("selection: open_console()"); + exit(1); + } + return fd; +} + +/* mark selected text on screen. */ +static void +set_sel(const int xs, const int ys, + const int xe, const int ye, const sel_mode mode) +{ + unsigned char buf[sizeof(char) + 5 * sizeof(short)]; + unsigned short *arg = (unsigned short *)(buf + 1); + int fd; + + buf[0] = 2; + + arg[0] = xs; + arg[1] = ys; + arg[2] = xe; + arg[3] = ye; + arg[4] = mode; + + fd = open_console(O_WRONLY); + if (ioctl(fd, TIOCLINUX, buf) < 0) + { + perror("selection: ioctl(..., TIOCLINUX, ...)"); + exit(1); + } + close(fd); +} + +/* paste contents of selection buffer into console. */ +static void +paste(void) +{ + char c = 3; + int fd; + + fd = open_console(O_WRONLY); + if (ioctl(fd, TIOCLINUX, &c) < 0) + { + perror("selection: ioctl(..., TIOCLINUX, ...)"); + exit(1); + } + close(fd); +} + +/* evaluate interval between times. */ +static long +interval(const struct timeval *t1, const struct timeval *t2) +{ + return (t2->tv_sec - t1->tv_sec) * 1000 + + (t2->tv_usec - t1->tv_usec) / 1000; +} + +/* Check whether console is in graphics mode; if so, wait until it isn't. */ +static int +check_mode(void) +{ + int fd, ch = 0; + long kd_mode; + + do + { + fd = open_console(O_RDONLY); + if (ioctl(fd, KDGETMODE, &kd_mode) < 0) + { + perror("selection: ioctl(..., KDGETMODE, ...)"); + exit(1); + } + close(fd); + if (kd_mode != KD_TEXT) + { + ++ch; + sleep(2); + } + } while (kd_mode != KD_TEXT); + return (ch > 0); +} diff --git a/historic/selection/test-mouse.c b/historic/selection/test-mouse.c new file mode 100644 index 00000000..fd80989b --- /dev/null +++ b/historic/selection/test-mouse.c @@ -0,0 +1,67 @@ +/* + * test-mouse: exercise rodent to test compatibility. + * Any button to draw asterisks of different + * colour. Left and right buttons (while mouse is stationary) to quit. + * Andrew Haylett, 17th June 1993 + */ + +#include <stdio.h> +#include <unistd.h> +#include <termios.h> +#include <errno.h> +#include <sys/ioctl.h> + +#include "mouse.h" + +#define SCALE 10 + +int +main(int argc, char *argv[]) +{ + struct ms_event ev; + struct winsize win; + + ms_params(argc, argv); + ioctl(fileno(stdout), TIOCGWINSZ, &win); + if (! win.ws_col || ! win.ws_row) + { + fprintf(stderr, "selection: zero screen dimension: assuming 80x25.\n"); + win.ws_col = 80; + win.ws_row = 25; + } + + printf("\033[2J\033[%d;%dH", win.ws_row / 2, win.ws_col / 2); + fflush(stdout); + if (ms_init((win.ws_col + 1) * SCALE - 1, (win.ws_row + 1) * SCALE - 1)) + { + perror("ms_init"); + exit(1); + } + while (1) + { + if (get_ms_event(&ev)) + { + perror("get_ms_event"); + exit(1); + } + if (ev.ev_code == MS_BUTDOWN && ev.ev_butstate == (MS_BUTLEFT | MS_BUTRIGHT)) + { + printf("\033[;H\033[2J\033[m"); + exit(0); + } + else if (ev.ev_code == MS_MOVE || ev.ev_code == MS_DRAG) + { + printf("\033[%d;%dH", ev.ev_y / SCALE, ev.ev_x / SCALE); + if (ev.ev_code == MS_DRAG) + { + if (ev.ev_butstate == MS_BUTLEFT) + printf("\033[31m*\033[D"); /* red */ + else if (ev.ev_butstate == MS_BUTRIGHT) + printf("\033[35m*\033[D"); /* purple */ + else + printf("\033[34m*\033[D"); /* blue */ + } + } + fflush(stdout); + } +} diff --git a/historic/sync.c b/historic/sync.c new file mode 100644 index 00000000..76e0b622 --- /dev/null +++ b/historic/sync.c @@ -0,0 +1,14 @@ +/* + * sync.c - flush Linux filesystem buffers + * + * Copyright 1992 Linus Torvalds. + * This file may be redistributed as per the GNU copyright. + */ + +#include <unistd.h> +#include <stdlib.h> + +int main(int argc, char **argv) { + sync(); + return 0; +} diff --git a/historic/update.8 b/historic/update.8 new file mode 100644 index 00000000..e6887a73 --- /dev/null +++ b/historic/update.8 @@ -0,0 +1,25 @@ +.\" Copyright 1992 Rickard E. Faith (faith@cs.unc.edu) +.\" May be distributed under the GNU General Public License +.TH UPDATE 8 "20 November 1993" "Linux 0.99" "Linux Programmer's Manual" +.SH NAME +update \- periodically flush Linux filesystem buffers +.SH SYNOPSIS +.B update [ interval ] +.SH DESCRIPTION +.B update +executes +.BR sync (2) +every +.I interval +seconds. By default, the +.I interval +is 30 seconds. It is generally started at boot time in +.IR /etc/rc . +.SH "SEE ALSO" +.BR sync (2), +.BR sync (8), +.BR init (8) +.SH AUTHOR +Linus Torvalds (torvalds@cs.helsinki.fi) +.br +With modifications by Rick Sladkey (jrs@world.std.com) diff --git a/historic/update.c b/historic/update.c new file mode 100644 index 00000000..0506df87 --- /dev/null +++ b/historic/update.c @@ -0,0 +1,45 @@ +/* + * update.c -- periodically sync the filesystems to disk + */ + +#include <sys/types.h> +#include <unistd.h> +#include <limits.h> +#include <signal.h> + +void alarm_handler(int sig) +{ +} + +int main(int argc, char *argv[]) +{ + int i; + int interval; + struct sigaction sa; + sigset_t empty_set; + sigset_t alarm_set; + + interval = (argc > 1) ? atoi(argv[1]) : 30; + if (fork() > 0) + exit(0); + chdir("/"); + for (i = 0; i < OPEN_MAX; i++) + close(i); + setsid(); + sa.sa_handler = SIG_IGN; + sigemptyset(&sa.sa_mask); + sa.sa_flags = 0; + sigaction(SIGTERM, &sa, NULL); + sigaction(SIGINT, &sa, NULL); + sa.sa_handler = alarm_handler; + sigaction(SIGALRM, &sa, NULL); + sigemptyset(&empty_set); + sigemptyset(&alarm_set); + sigaddset(&alarm_set, SIGALRM); + sigprocmask(SIG_BLOCK, &alarm_set, NULL); + for (;;) { + alarm(interval); + sigsuspend(&empty_set); + sync(); + } +} |