FreeBSD Bugzilla – Attachment 19814 Details for
Bug 35113
[patch] grdc(6) enhancement: countdown timer mode
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
file.diff
file.diff (text/plain), 2.16 KB, created by
Gavin Atkinson
on 2002-02-19 14:00:05 UTC
(
hide
)
Description:
file.diff
Filename:
MIME Type:
Creator:
Gavin Atkinson
Created:
2002-02-19 14:00:05 UTC
Size:
2.16 KB
patch
obsolete
>--- /5.0/usr/src/games/grdc/grdc.c Tue Sep 25 14:45:46 2001 >+++ grdc.c Tue Feb 19 09:21:04 2002 >@@ -1,10 +1,13 @@ > /* > * Grand digital clock for curses compatible terminals > * Usage: grdc [-s] [n] -- run for n seconds (default infinity) >+ * grdc -t n -- countdown n seconds > * Flags: -s: scroll >+ * -t: timer mode > * > * modified 10-18-89 for curses (jrl) > * 10-18-89 added signal handling >+ * 02-18-02 added countdown timer mode > * > * $FreeBSD: src/games/grdc/grdc.c,v 1.9 2001/09/25 13:45:46 ru Exp $ > */ >@@ -25,6 +28,7 @@ > > /* it won't be */ > time_t now; /* yeah! */ >+time_t end; /* for timer mode */ > struct tm *tm; > > short disp[11] = { >@@ -58,15 +62,18 @@ > int i, j, s, k; > int n; > int ch; >-int scrol; >+int scrol = 0; >+int timer = 0; >+int hour, minute, second; > >- scrol = 0; >- >- while ((ch = getopt(argc, argv, "s")) != -1) >+ while ((ch = getopt(argc, argv, "st")) != -1) > switch (ch) { > case 's': > scrol = 1; > break; >+ case 't': >+ timer = 1; >+ break; > case '?': > default: > usage(); >@@ -75,7 +82,7 @@ > argc -= optind; > argv += optind; > >- if (argc > 1) { >+ if ((argc > 1) || (argc == 0 && timer)) { > usage(); > /* NOTREACHED */ > } >@@ -85,6 +92,9 @@ > else > n = 0; > >+ if (timer && n == 0) >+ return(0); >+ > initscr(); > > signal(SIGINT,sighndl); >@@ -127,16 +137,30 @@ > > attrset(COLOR_PAIR(2)); > } >+ time(&end); >+ end += n; > do { > mask = 0; > time(&now); >- tm = localtime(&now); >- set(tm->tm_sec%10, 0); >- set(tm->tm_sec/10, 4); >- set(tm->tm_min%10, 10); >- set(tm->tm_min/10, 14); >- set(tm->tm_hour%10, 20); >- set(tm->tm_hour/10, 24); >+ if (!timer) { >+ tm = localtime(&now); >+ hour = tm->tm_hour; >+ minute = tm->tm_min; >+ second = tm->tm_sec; >+ } else { >+ n = end - now; >+ if (n <= 0) >+ break; >+ hour = (n/3600)%100; >+ minute = (n/60)%60; >+ second = n%60; >+ } >+ set(second%10, 0); >+ set(second/10, 4); >+ set(minute%10, 10); >+ set(minute/10, 14); >+ set(hour%10, 20); >+ set(hour/10, 24); > set(10, 7); > set(10, 17); > for(k=0; k<6; k++) { >@@ -229,6 +253,6 @@ > usage(void) > { > >- (void)fprintf(stderr, "usage: grdc [-s] [n]\n"); >+ (void)fprintf(stderr, "usage: grdc [-s] [n]\n grdc -t n\n"); > exit(1); > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 35113
: 19814 |
19815