aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/watch
diff options
context:
space:
mode:
authorEd Schouten <ed@FreeBSD.org>2012-03-10 14:35:09 +0000
committerEd Schouten <ed@FreeBSD.org>2012-03-10 14:35:09 +0000
commitf10070765a29bf4e5a7fd8e5a25cf29d8402c0eb (patch)
tree77d3779930ad440ae4d645bc2be952aa1a0d13ed /usr.sbin/watch
parent49e49bdbc104b85fd37df4f596f98fe86defa485 (diff)
downloadsrc-f10070765a29bf4e5a7fd8e5a25cf29d8402c0eb.tar.gz
src-f10070765a29bf4e5a7fd8e5a25cf29d8402c0eb.zip
Fix whitespace.
MFC after: 1 week
Notes
Notes: svn path=/head/; revision=232780
Diffstat (limited to 'usr.sbin/watch')
-rw-r--r--usr.sbin/watch/watch.c64
1 files changed, 29 insertions, 35 deletions
diff --git a/usr.sbin/watch/watch.c b/usr.sbin/watch/watch.c
index 388614e08c18..f66e124a3648 100644
--- a/usr.sbin/watch/watch.c
+++ b/usr.sbin/watch/watch.c
@@ -44,7 +44,6 @@ __FBSDID("$FreeBSD$");
#define MSG_CHANGE "Snoop device change by user request."
#define MSG_NOWRITE "Snoop device change due to write failure."
-
#define DEV_NAME_LEN 1024 /* for /dev/ttyXX++ */
#define MIN_SIZE 256
@@ -65,27 +64,26 @@ static void detach_snp(void);
static void set_dev(const char *);
static void ask_dev(char *, const char *);
-int opt_reconn_close = 0;
-int opt_reconn_oflow = 0;
-int opt_interactive = 1;
-int opt_timestamp = 0;
+int opt_reconn_close = 0;
+int opt_reconn_oflow = 0;
+int opt_interactive = 1;
+int opt_timestamp = 0;
int opt_write = 0;
int opt_no_switch = 0;
const char *opt_snpdev;
-char dev_name[DEV_NAME_LEN];
-int snp_io;
-int std_in = 0, std_out = 1;
-
-
-int clear_ok = 0;
-struct termios otty;
-char tbuf[1024], gbuf[1024];
+char dev_name[DEV_NAME_LEN];
+int snp_io;
+int std_in = 0, std_out = 1;
+int clear_ok = 0;
+struct termios otty;
+char tbuf[1024], gbuf[1024];
static void
clear(void)
{
+
if (clear_ok)
tputs(gbuf, 1, putchar);
fflush(stdout);
@@ -94,8 +92,9 @@ clear(void)
static void
timestamp(const char *buf)
{
- time_t t;
- char btmp[1024];
+ time_t t;
+ char btmp[1024];
+
clear();
printf("\n---------------------------------------------\n");
t = time(NULL);
@@ -109,11 +108,11 @@ timestamp(const char *buf)
static void
set_tty(void)
{
- struct termios ntty;
+ struct termios ntty;
tcgetattr (std_in, &otty);
ntty = otty;
- ntty.c_lflag &= ~ICANON; /* disable canonical operation */
+ ntty.c_lflag &= ~ICANON; /* disable canonical operation */
ntty.c_lflag &= ~ECHO;
#ifdef FLUSHO
ntty.c_lflag &= ~FLUSHO;
@@ -124,11 +123,11 @@ set_tty(void)
#ifdef IEXTEN
ntty.c_lflag &= ~IEXTEN;
#endif
- ntty.c_cc[VMIN] = 1; /* minimum of one character */
- ntty.c_cc[VTIME] = 0; /* timeout value */
+ ntty.c_cc[VMIN] = 1; /* minimum of one character */
+ ntty.c_cc[VTIME] = 0; /* timeout value */
- ntty.c_cc[VINTR] = 07; /* ^G */
- ntty.c_cc[VQUIT] = 07; /* ^G */
+ ntty.c_cc[VINTR] = 07; /* ^G */
+ ntty.c_cc[VQUIT] = 07; /* ^G */
tcsetattr (std_in, TCSANOW, &ntty);
}
@@ -138,7 +137,6 @@ unset_tty(void)
tcsetattr (std_in, TCSANOW, &otty);
}
-
static void
fatal(int error, const char *buf)
{
@@ -169,7 +167,6 @@ open_snp(void)
return (f);
}
-
static void
cleanup(int signo __unused)
{
@@ -180,7 +177,6 @@ cleanup(int signo __unused)
exit(EX_OK);
}
-
static void
usage(void)
{
@@ -191,7 +187,8 @@ usage(void)
static void
setup_scr(void)
{
- char *cbuf = gbuf, *term;
+ char *cbuf = gbuf, *term;
+
if (!opt_interactive)
return;
if ((term = getenv("TERM")))
@@ -226,11 +223,10 @@ attach_snp(void)
timestamp("Logging Started.");
}
-
static void
set_dev(const char *name)
{
- char buf[DEV_NAME_LEN];
+ char buf[DEV_NAME_LEN];
struct stat sb;
if (strlen(name) > 5 && !strncmp(name, _PATH_DEV, sizeof _PATH_DEV - 1)) {
@@ -256,8 +252,8 @@ set_dev(const char *name)
void
ask_dev(char *dbuf, const char *msg)
{
- char buf[DEV_NAME_LEN];
- int len;
+ char buf[DEV_NAME_LEN];
+ int len;
clear();
unset_tty();
@@ -284,10 +280,10 @@ ask_dev(char *dbuf, const char *msg)
int
main(int ac, char *av[])
{
- int ch, res, rv, nread;
+ int ch, res, rv, nread;
size_t b_size = MIN_SIZE;
- char *buf, chb[READB_LEN];
- fd_set fd_s;
+ char *buf, chb[READB_LEN];
+ fd_set fd_s;
(void) setlocale(LC_TIME, "");
@@ -296,7 +292,6 @@ main(int ac, char *av[])
else
opt_interactive = 0;
-
while ((ch = getopt(ac, av, "Wciotnf:")) != -1)
switch (ch) {
case 'W':
@@ -382,7 +377,7 @@ main(int ac, char *av[])
detach_snp();
if (opt_no_switch)
fatal(EX_IOERR,
- "write failed");
+ "write failed");
ask_dev(dev_name, MSG_NOWRITE);
set_dev(dev_name);
}
@@ -439,4 +434,3 @@ main(int ac, char *av[])
} /* While */
return(0);
}
-