Update to use new calling conventions

This commit is contained in:
Paul Traina 1995-02-25 20:14:31 +00:00
parent 77f77631e7
commit cb95dc2435
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=6713
2 changed files with 17 additions and 59 deletions

View File

@ -46,8 +46,8 @@ For more info see
.It Fl t .It Fl t
Print the date and time when observation of a given tty is started. Print the date and time when observation of a given tty is started.
.It Ar tty .It Ar tty
Tty may be specified as a remote pseudo tty device, a virtual console, or Tty may be specified as an tty-style device, such as a pseudo tty device,
a serial line. a virtual console, or a serial line, etc.
Names may be preceded by "/dev/". Names may be preceded by "/dev/".
.Sh OPERATION .Sh OPERATION
While running in interactive mode, all user input is discarded except for: While running in interactive mode, all user input is discarded except for:

View File

@ -18,6 +18,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <signal.h> #include <signal.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h> #include <sys/time.h>
#include <sys/select.h> #include <sys/select.h>
#include <sys/fcntl.h> #include <sys/fcntl.h>
@ -27,12 +28,12 @@
#define MSG_INIT "Snoop started." #define MSG_INIT "Snoop started."
#define MSG_OFLOW "Snoop stopped due to overflow.Reconnecting." #define MSG_OFLOW "Snoop stopped due to overflow. Reconnecting."
#define MSG_CLOSED "Snoop stopped due to tty close.Reconnecting." #define MSG_CLOSED "Snoop stopped due to tty close. Reconnecting."
#define MSG_CHANGE "Snoop device change by user request." #define MSG_CHANGE "Snoop device change by user request."
#define DEV_NAME_LEN 12 /* for /dev/ttyXX++ */ #define DEV_NAME_LEN 1024 /* for /dev/ttyXX++ */
#define MIN_SIZE 256 #define MIN_SIZE 256
#define CHR_SWITCH 24 /* Ctrl+X */ #define CHR_SWITCH 24 /* Ctrl+X */
@ -46,7 +47,7 @@ int opt_timestamp = 0;
char dev_name[DEV_NAME_LEN]; char dev_name[DEV_NAME_LEN];
int snp_io; int snp_io;
struct snptty snp_tty; dev_t snp_tty;
int std_in = 0, std_out = 1; int std_in = 0, std_out = 1;
@ -111,7 +112,7 @@ fatal(buf)
int int
open_snp() open_snp()
{ {
char snp[DEV_NAME_LEN] = "/dev/snpX"; char *snp = "/dev/snpX";
char c; char c;
int f; int f;
for (c = '0'; c <= '9'; c++) { for (c = '0'; c <= '9'; c++) {
@ -174,10 +175,10 @@ ctoh(c)
void void
detach_snp() detach_snp()
{ {
struct snptty st; dev_t dev;
st.st_type = -1;
st.st_unit = -1; dev = -1;
ioctl(snp_io, SNPSTTY, &st); ioctl(snp_io, SNPSTTY, &dev);
} }
void void
@ -194,62 +195,19 @@ void
set_dev(name) set_dev(name)
char *name; char *name;
{ {
char buf[DEV_NAME_LEN], num[DEV_NAME_LEN]; char buf[DEV_NAME_LEN];
int unitbase = 0; struct stat sb;
if (strlen(name) > 5 && !strncmp(name, "/dev/", 5)) if (strlen(name) > 5 && !strncmp(name, "/dev/", 5))
strcpy(buf, &(name[5])); strcpy(buf, &(name[5]));
else else
strcpy(buf, name); strcpy(buf, name);
if (strlen(buf) < 4)
fatal("Bad tty name.");
if (!strncmp(buf, "tty", 3)) if (stat(buf, &sb) < 0)
switch (buf[3]) { fatal("Bad device name.");
case 'v':
snp_tty.st_unit = ctoh(buf[4]);
snp_tty.st_type = ST_VTY;
goto got_num;
case 'r':
unitbase += 16;
case 'q':
unitbase += 16;
case 'p':
snp_tty.st_unit = ctoh(buf[4]) + unitbase;
snp_tty.st_type = ST_PTY;
goto got_num;
case '0':
case 'd':
snp_tty.st_unit = ctoh(buf[4]);
snp_tty.st_type = ST_SIO;
goto got_num;
default:
fatal("Bad tty name.");
} snp_tty = sb.st_rdev;
if (!strncmp(buf, "vty", 3)) {
strcpy(num, &(buf[3]));
snp_tty.st_unit = atoi(num);
snp_tty.st_type = ST_VTY;
goto got_num;
}
if (!strncmp(buf, "pty", 3)) {
strcpy(num, &(buf[3]));
snp_tty.st_unit = atoi(num);
snp_tty.st_type = ST_PTY;
goto got_num;
}
if (!strncmp(buf, "sio", 3) || !strncmp(buf, "cua", 3)) {
strcpy(num, &(buf[3]));
snp_tty.st_unit = atoi(num);
snp_tty.st_type = ST_SIO;
goto got_num;
}
fatal("Bad tty name.");
got_num:
attach_snp(); attach_snp();
} }