aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2003-06-08 10:49:08 +0000
committerDimitri Sokolyuk <demon@dim13.org>2003-06-08 10:49:08 +0000
commit53e46eabcb5a98ea4f79a9ad34e0b79704d63031 (patch)
tree7f3d6d0972384c137abaa236830fd3f7b0ca24fc
parent284f46da02a1b49fac1c8a378e565a4e6edf561b (diff)
port to OpenBSD
-rw-r--r--Makefile7
-rw-r--r--watch.c33
2 files changed, 24 insertions, 16 deletions
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 <bsd.prog.mk> \ 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 <rembo@unisoft.com>
Newsgroups: comp.sources.unix
Subject: v24i084: Repeatedly execute a program under curses(3)
@@ -10,40 +11,36 @@
#include <stdio.h>
#include <signal.h>
#include <sys/fcntl.h>
+#include <time.h>
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);
+}