From 53e46eabcb5a98ea4f79a9ad34e0b79704d63031 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Sun, 8 Jun 2003 10:49:08 +0000 Subject: port to OpenBSD --- Makefile | 7 +++++++ watch.c | 33 +++++++++++++++++---------------- 2 files changed, 24 insertions(+), 16 deletions(-) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..c55ca35 --- /dev/null +++ b/Makefile @@ -0,0 +1,7 @@ +PROG= watch +BINDIR= /usr/local/bin +NOMAN= noman +PDADD= ${LIBCURSES} +LDADD= -lcurses + +. include \ No newline at end of file diff --git a/watch.c b/watch.c index c36e563..acd9ec4 100644 --- a/watch.c +++ b/watch.c @@ -1,3 +1,4 @@ +/* $OpenBSD: watch.c,v 1.3 2003/06/08 06:46:04 demon Exp $ */ /* From: Tony Rems Newsgroups: comp.sources.unix Subject: v24i084: Repeatedly execute a program under curses(3) @@ -10,40 +11,36 @@ #include #include #include +#include int die_flag; void die (); +int usage (); extern FILE *popen (); extern int pclose (); -extern long time (); +extern time_t time (); extern char *ctime (); /*-----------------------------------------. | Decode parameters and launch execution. | `-----------------------------------------*/ -char *program_name; +extern char *__progname; -void -main (argc, argv) - int argc; -char *argv[]; +int +main (int argc, char *argv[]) { int hor = 1, ver = 0; FILE *piper; char buf[180]; char cmd[128]; int count = 1; - long timer; + time_t timer; int nsecs = 2; - program_name = argv[0]; if (argc < 2) - { - fprintf (stderr, "Usage: %s COMMAND [-n SLEEP] [ARG ...]\n", argv[0]); - exit (1); - } + usage (); /* If -n is specified, convert the next argument to the numver for the number of seconds. */ @@ -53,10 +50,7 @@ char *argv[]; nsecs = atoi (argv[2]); count = 3; if (nsecs == 0 || argc < 4) - { - fprintf (stderr, "Usage: %s COMMAND [-n SLEEP] [ARG ...]\n", argv[0]); - exit (1); - } + usage (); } /* Build command string to give to popen. */ @@ -138,3 +132,10 @@ die () { die_flag = 1; } + +int +usage () +{ + fprintf (stderr, "Usage: %s COMMAND [-n SLEEP] [ARG ...]\n", __progname); + exit (1); +} -- cgit v1.2.3