From pa.dec.com!decwrl!uunet!sparky!kent Mon Jul 22 08:51:12 PDT 1991 Article: 2502 of comp.sources.misc Newsgroups: comp.sources.misc Path: pa.dec.com!decwrl!uunet!sparky!kent From: David F. Skoll Subject: v21i002: remind - A replacement for calendar, Patch02 Message-ID: <1991Jul19.215741.7847@sparky.IMD.Sterling.COM> X-Md4-Signature: 6246e6b315671e22b36495f7f839f9c5 Sender: kent@sparky.IMD.Sterling.COM (Kent Landfield) Organization: Carleton University Date: Fri, 19 Jul 1991 21:57:41 GMT Approved: kent@sparky.imd.sterling.com Lines: 729 Submitted-by: David F. Skoll Posting-number: Volume 21, Issue 2 Archive-name: remind/patch02 Patch-To: remind: Volume 17, Issue 3-6 This is Official Patch #2 for Remind. Most notably, this patch adds the '-h' option to Remind. This causes Remind to be silent if no reminders are triggered, or if only background reminders are triggered. You should also intall the updated version of remind-all.csh or remind-all.sh, which make use of this feature. Other fixes: New substitution sequences for inserting the current time into reminders; stdin and stdout are closed before Remind goes into the background if they are not ttys; signal handler and sleep behaviour fixed for SYSV systems; Makefile made more portable. I'd like to thank Dave Wolfe and Raphael Manfredi for some of these patches. As always, a fully-patched version of remind is available via anonymous ftp from alfred.ccs.carleton.ca:pub/remind-2.3.1.tar.Z. (Internet address: 134.117.1.1) The patches are available there, too. ------------- Cut Here ---------- Cut Here ---------- Cut Here ------------- #!/bin/sh # This is Remind 2.3 Official Patch #2, a shell archive (shar 3.32) # made 07/17/1991 17:25 UTC by dfs@data # Source directory /enterprise/transporter/dfs/work/.rem/patch2-work # # existing files will NOT be overwritten # # This shar contains: # length mode name # ------ ---------- ------------------------------------------ # 19150 -rw------- patch-02 # if touch 2>&1 | fgrep 'amc' > /dev/null then TOUCH=touch else TOUCH=true fi # ============= patch-02 ============== if test X"$1" != X"-c" -a -f 'patch-02'; then echo "File already exists: skipping 'patch-02'" else echo "x - extracting patch-02 (Text)" sed 's/^X//' << 'SHAR_EOF' > patch-02 && XVersion 2.3 Patch 2 - Fixed up a problem with timed reminders which resulted Xin cursor not starting from left side of screen on some systems. X XFixed the SIGINT handler for SYSV systems - this was interrupting the Xsleep(2) system call. X XClosed stdin and stdout if remind was part of a pipe - this prevents other Xsections of the pipe from hanging as remind puts itself in the background. X XAdded the "-h" (Hush mode) option X XAdded the "%#" and "%@" modifiers for the current time. X XMade the Makefile more portable X X*** ../patch1.work/COPYRIGHT Mon Feb 25 17:05:00 1991 X--- ./COPYRIGHT Wed Jul 17 13:18:07 1991 X*************** X*** 17,23 **** X X You may incorporate parts of REMIND into your own programs, providing X you do not sell these programs. You must clearly indicate that the parts X! of REMIND you have incorporated are Copyright (C) 1990 by David Skoll. X X I will attempt to support REMIND as much as possible. However, you use X it at your own risk. I am not responsible for any damages caused by X--- 17,23 ---- X X You may incorporate parts of REMIND into your own programs, providing X you do not sell these programs. You must clearly indicate that the parts X! of REMIND you have incorporated are Copyright (C) 1990, 1991 by David Skoll. X X I will attempt to support REMIND as much as possible. However, you use X it at your own risk. I am not responsible for any damages caused by X*************** X*** 46,51 **** X--- 46,54 ---- X for suggesting many of the new features in X REMIND. X X+ Dave Wolfe and Raphael Manfredi X+ for noticing bugs and sending me fixes. X+ X Timo Salmi, Keith Petersen, Bill Davidsen and Kent Landfield for maintaining X the uwasa and SIMTEL archives, and comp.binaries.ibm.pc and comp.sources.misc X in the face of a flurry of updates to REMIND. X*************** X*** 55,60 **** X--- 58,64 ---- X X Finally, all those who donated money to support the production of X REMIND. Your donations were gratefully appreciated. X+ X -- X David F. Skoll X 4-317 LeBreton Street South X*** ../patch1.work/Makefile Tue Feb 26 14:37:07 1991 X--- ./Makefile Wed Jul 17 12:48:49 1991 X*************** X*** 2,22 **** X X #--------------- BEGINNING OF THINGS YOU CAN CHANGE -------------- X X #If you have a BSD system: X! CFLAGS= -O -DUNIX X X #If you have a SYSV system, comment previous line and uncomment next line: X! #CFLAGS= -O -DUNIX -DSYSV X X #If your system does not include , uncomment next line: X! #CFLAGS += -DNO_MALLOC_H X X #If you have a SYSV system which does not implement the pid_t type, X #uncomment the next line: X! #CFLAGS += -Dpid_t=int X X #If you want to use gcc: X #CC= gcc X X #Where do you want it installed? X BINDIR= /usr/local/bin X--- 2,30 ---- X X #--------------- BEGINNING OF THINGS YOU CAN CHANGE -------------- X X+ #If you need more than one of the following definitions for CDEFS, X+ #concatenate the necessary definitions. X+ X #If you have a BSD system: X! CDEFS= -DUNIX X X #If you have a SYSV system, comment previous line and uncomment next line: X! #CDEFS= -DUNIX -DSYSV X X #If your system does not include , uncomment next line: X! #CDEFS= -DNO_MALLOC_H X X #If you have a SYSV system which does not implement the pid_t type, X #uncomment the next line: X! #CDEFS= -Dpid_t=int X X+ #If your system doesn't print return w/ newline for background processes: X+ #CDEFS= -DNL=\"\\r\\n\" X+ X #If you want to use gcc: X #CC= gcc X+ X+ CFLAGS = -O $(CDEFS) X X #Where do you want it installed? X BINDIR= /usr/local/bin X*** ../patch1.work/WHATSNEW.23 Thu Mar 7 15:24:35 1991 X--- ./WHATSNEW.23 Wed Jul 17 13:14:26 1991 X*************** X*** 49,51 **** X--- 49,66 ---- X Added the "rem" shell script for running Remind with a default script. X X Added manual pages for "kall" and "rem". X+ X+ * Version 2.3 Patch 2 - Fixed up a problem with timed reminders which resulted X+ in cursor not starting from left side of screen on some systems. X+ X+ Fixed the SIGINT handler for SYSV systems - this was interrupting the X+ sleep(2) system call. X+ X+ Closed stdin and stdout if remind was part of a pipe - this prevents other X+ sections of the pipe from hanging as remind puts itself in the background. X+ X+ Added the "-h" (Hush mode) option X+ X+ Added the "%#" and "%@" modifiers for the current time. X+ X+ Made the Makefile more portable X*** ../patch1.work/dosubst.c Mon Feb 18 13:05:17 1991 X--- ./dosubst.c Wed Jul 17 12:44:34 1991 X*************** X*** 39,50 **** X char c; X char *od, *s; X int wkday = jul % 7; X! char *plu, *pm; X int curtim = (int) (SystemTime() / 60); X int done; X int h; X int hh; X int min; X int tdiff; X int adiff, mdiff, hdiff; X char *mplu, *hplu, *when; X--- 39,53 ---- X char c; X char *od, *s; X int wkday = jul % 7; X! char *plu, *pm, *cpm; X int curtim = (int) (SystemTime() / 60); X int done; X int h; X int hh; X int min; X+ int ch; X+ int chh; X+ int cmin; X int tdiff; X int adiff, mdiff, hdiff; X char *mplu, *hplu, *when; X*************** X*** 85,93 **** X h = tim / 60; X min = tim % 60; X X! if (h >= 12) pm = "pm"; else pm = "am"; X! if (h == 12) hh = 12; else hh = h % 12; X X *dst = 0; X X switch(d) { X--- 88,102 ---- X h = tim / 60; X min = tim % 60; X X! pm = (h < 12) ? "am" : "pm"; X! hh = (h == 12) ? 12 : h % 12; X! X! ch = curtim / 60; X! cmin = curtim % 60; X X+ cpm = (ch < 12) ? "am" : "pm"; X+ chh = (ch == 12) ? 12 : ch % 12; X+ X *dst = 0; X X switch(d) { X*************** X*** 331,338 **** X case '!': sprintf(dst, (tdiff >= 0 ? "is" : "was")); X dst += strlen(dst); X break; X X! case '_': *dst++ = '\n'; *dst = 0; X break; X X default: X--- 340,359 ---- X case '!': sprintf(dst, (tdiff >= 0 ? "is" : "was")); X dst += strlen(dst); X break; X+ X+ case '@': sprintf(dst, "%d:%02d%s", chh, cmin, cpm); X+ dst += strlen(dst); X+ break; X+ X+ case '#': sprintf(dst, "%02d:%02d", ch, cmin); X+ dst += strlen(dst); X+ break; X X! #ifndef NL X! #define NL "\n" X! #endif X! case '_': sprintf(dst, "%s", NL); X! dst += strlen(dst); X break; X X default: X*** ../patch1.work/globals.h Thu Mar 7 15:13:58 1991 X--- ./globals.h Wed Jul 17 12:52:37 1991 X*************** X*** 46,48 **** X--- 46,49 ---- X extern int CalTime; X extern int CalWidth; X extern int SimpleCalendar; X+ extern int Hush; X*** ../patch1.work/init.c Thu Mar 7 15:42:28 1991 X--- ./init.c Wed Jul 17 12:52:26 1991 X*************** X*** 47,52 **** X--- 47,53 ---- X CalWidth = 10; X SimpleCalendar = 0; X InfiniteDelta = 0; X+ Hush = 0; X X if(argc == 1) { X fprintf(stderr, X*************** X*** 53,61 **** X "\nREMIND %d.%d Patch Level %d (C) 1990, 1991 by David Skoll.\n\n", X VERSION_MAJOR, VERSION_MINOR, PATCHLEVEL); X #ifdef UNIX X! fprintf(stderr, "Usage: remind [-n | -d | -p | -c# [-w# | -s]] [-voraqt] filename [date]\n\n"); X #else X! fprintf(stderr, "Usage: remind [-n | -d | -p | -c# [-w# | -s]] [-vort] filename [date]\n\n"); X #endif X fprintf(stderr, "-n Output next occurrence of reminders in simple format\n"); X fprintf(stderr, "-d Debug reminder file\n-p Purge reminder file\n"); X--- 54,62 ---- X "\nREMIND %d.%d Patch Level %d (C) 1990, 1991 by David Skoll.\n\n", X VERSION_MAJOR, VERSION_MINOR, PATCHLEVEL); X #ifdef UNIX X! fprintf(stderr, "Usage: remind [-n | -d | -p | -c# [-w# | -s]] [-voraqth] filename [date]\n\n"); X #else X! fprintf(stderr, "Usage: remind [-n | -d | -p | -c# [-w# | -s]] [-vorth] filename [date]\n\n"); X #endif X fprintf(stderr, "-n Output next occurrence of reminders in simple format\n"); X fprintf(stderr, "-d Debug reminder file\n-p Purge reminder file\n"); X*************** X*** 68,74 **** X fprintf(stderr, "-a Do not trigger current AT reminders in foreground\n"); X fprintf(stderr, "-q Do not queue current AT reminders\n"); X #endif X! fprintf(stderr, "-t Trigger all non-expired reminders regardless of delta\n\n"); X exit(1); X } X X--- 69,76 ---- X fprintf(stderr, "-a Do not trigger current AT reminders in foreground\n"); X fprintf(stderr, "-q Do not queue current AT reminders\n"); X #endif X! fprintf(stderr, "-t Trigger all non-expired reminders regardless of delta\n"); X! fprintf(stderr, "-h 'Hush' mode - don't display anything if no reminders triggered\n\n"); X exit(1); X } X X*************** X*** 141,146 **** X--- 143,150 ---- X break; X X case 'S': SimpleCalendar = 1; break; X+ X+ case 'H': Hush = 1; break; X X case 'V': Verbose = 1; break; X X*** ../patch1.work/main.c Thu Mar 7 15:37:14 1991 X--- ./main.c Wed Jul 17 12:53:03 1991 X*************** X*** 115,120 **** X--- 115,121 ---- X int NumFullOmit, NumPartOmit; X int JulianToday, RealToday; X int CurYear, CurMon, CurDay; X+ int Hush; X char QueueAts, PrintAts; X int NumAtsQueued; X int Calendar, CalTime, CalWidth, SimpleCalendar; X*************** X*** 672,681 **** X } X /* Get rid of any spurious OMIT contexts */ X FreeStackedOmits(); X! if (NumEmitted == 0 && NumAtsQueued == 0 && !Purge && !Debug && !Next) X printf("No reminders.\n"); X #ifdef UNIX X! if (NumEmitted == 0 && NumAtsQueued != 0 && !Purge && !Debug) X printf("%d reminder%s queued for later today.\n", NumAtsQueued, X (NumAtsQueued == 1) ? "" : "s"); X X--- 673,682 ---- X } X /* Get rid of any spurious OMIT contexts */ X FreeStackedOmits(); X! if (!Hush && NumEmitted == 0 && NumAtsQueued == 0 && !Purge && !Debug && !Next) X printf("No reminders.\n"); X #ifdef UNIX X! if (!Hush && NumEmitted == 0 && NumAtsQueued != 0 && !Purge && !Debug) X printf("%d reminder%s queued for later today.\n", NumAtsQueued, X (NumAtsQueued == 1) ? "" : "s"); X X*** ../patch1.work/patchlevel.h Thu Mar 7 14:45:04 1991 X--- ./patchlevel.h Wed Jul 17 12:41:43 1991 X*************** X*** 3,6 **** X #define VERSION_MAJOR 2 X #define VERSION_MINOR 3 X X! #define PATCHLEVEL 1 X--- 3,6 ---- X #define VERSION_MAJOR 2 X #define VERSION_MINOR 3 X X! #define PATCHLEVEL 2 X*** ../patch1.work/remind-all.csh Mon Feb 18 13:05:19 1991 X--- ./remind-all.csh Wed Jul 17 13:02:36 1991 X*************** X*** 24,38 **** X # Set the following variables as appropriate for your system X set REMIND = /usr/local/bin/remind X set MAIL = /usr/ucb/mail X- set CMP = /usr/bin/cmp X set RM = "/usr/bin/rm -f" X X! set EMPTY = /tmp/Empty.$$ X! set FULL = /tmp/Full.$$ X X- # Create the dummy empty reminder file X- $REMIND -rq /dev/null > $EMPTY X- X # Scan each user's directory for a .reminders file X foreach i ($USERS) X if (-r ~$i/.reminders) then X--- 24,33 ---- X # Set the following variables as appropriate for your system X set REMIND = /usr/local/bin/remind X set MAIL = /usr/ucb/mail X set RM = "/usr/bin/rm -f" X X! set REMFILE = /tmp/RemFile.$$ X X # Scan each user's directory for a .reminders file X foreach i ($USERS) X if (-r ~$i/.reminders) then X*************** X*** 39,54 **** X X # echo "$i has a .reminders file." DEBUGGING PURPOSES ONLY X X! $REMIND -rq ~$i/.reminders > $FULL X! $CMP -s $EMPTY $FULL X! if ($status != 0) then X! X # echo "Sending mail to $i" DEBUGGING PURPOSES ONLY X X! $MAIL -s "Reminders" $i < $FULL X endif X! $RM $FULL X endif X end X- X- $RM $EMPTY X--- 34,45 ---- X X # echo "$i has a .reminders file." DEBUGGING PURPOSES ONLY X X! $REMIND -rqh ~$i/.reminders > $REMFILE X! if (! -z $REMFILE) then X # echo "Sending mail to $i" DEBUGGING PURPOSES ONLY X X! $MAIL -s "Reminders" $i < $REMFILE X endif X! $RM $REMFILE X endif X end X*** ../patch1.work/remind-all.sh Mon Feb 18 13:05:19 1991 X--- ./remind-all.sh Wed Jul 17 13:02:58 1991 X*************** X*** 24,38 **** X # Set the following variables as appropriate for your system X REMIND=/usr/local/bin/remind X MAIL=/usr/bin/mail X- CMP=/bin/cmp X RM="/bin/rm -f" X X! EMPTY=/tmp/Empty.$$ X! FULL=/tmp/Full.$$ X X- # Create the dummy empty reminder file X- $REMIND -rq /dev/null > $EMPTY X- X # Scan each user's directory for a .reminders file X for i in $USERS X do X--- 24,33 ---- X # Set the following variables as appropriate for your system X REMIND=/usr/local/bin/remind X MAIL=/usr/bin/mail X RM="/bin/rm -f" X X! REMFILE=/tmp/RemFile.$$ X X # Scan each user's directory for a .reminders file X for i in $USERS X do X*************** X*** 41,57 **** X X # echo "$i has a .reminders file." DEBUGGING PURPOSES ONLY X X! $REMIND -rq $HOME/.reminders > $FULL X! if `$CMP -s $EMPTY $FULL`; then X! : do nothing X! else X! X # echo "Sending mail to $i" DEBUGGING PURPOSES ONLY X! X! $MAIL -s "Reminders" $i < $FULL X fi X! $RM $FULL X fi X done X- X- $RM $EMPTY X--- 36,46 ---- X X # echo "$i has a .reminders file." DEBUGGING PURPOSES ONLY X X! $REMIND -rq $HOME/.reminders > $REMFILE X! if [ -s $REMFILE ]; then X # echo "Sending mail to $i" DEBUGGING PURPOSES ONLY X! $MAIL -s "Reminders" $i < $REMFILE X fi X! $RM $REMFILE X fi X done X*** ../patch1.work/remind.1 Thu Mar 7 15:52:55 1991 X--- ./remind.1 Wed Jul 17 12:56:26 1991 X*************** X*** 5,11 **** X .SH SYNOPSIS X .B remind X [\fB\-n | \fB\-d\fR | \fB\-p\fR | \fB\-c\fR\fIn\fR [\fB\-w\fR\fIn\fR | \fB\-s\fR]] X! [\fB\-voraqt\fR] X .I filename X [\fIdate\fR] X .SH DESCRIPTION X--- 5,11 ---- X .SH SYNOPSIS X .B remind X [\fB\-n | \fB\-d\fR | \fB\-p\fR | \fB\-c\fR\fIn\fR [\fB\-w\fR\fIn\fR | \fB\-s\fR]] X! [\fB\-voraqth\fR] X .I filename X [\fIdate\fR] X .SH DESCRIPTION X*************** X*** 134,139 **** X--- 134,146 ---- X In effect, this causes reminders to be treated as if they have an X infinite value of "delta"; ie, they are triggered no matter how far in the X future they are. X+ .TP X+ .B \-h X+ The X+ .B \-h X+ flag causes \fBremind\fR to go into 'Hush' mode. In this mode, if no X+ reminders are triggered, nothing will be displayed. (Normally, \fBremind\fR X+ will display "No reminders." in this case.) X .PP X If you supply a X .I date X*************** X*** 1226,1237 **** X causes the need for the "...ago" forms. X .TP X .B %2 X! is replaced with "\fIhh\fR:\fImm\fRam" or "..pm" depending on the X .I AT X time of the reminder. X .TP X .B %3 X! is replaced with "\fIhh\fR:\fImm\fR" in 24-hour format. X .TP X .B %4 X is replaced with "\fImm\fR" where \fImm\fR is the number of minutes between X--- 1233,1244 ---- X causes the need for the "...ago" forms. X .TP X .B %2 X! is replaced with "at \fIhh\fR:\fImm\fRam" or "..pm" depending on the X .I AT X time of the reminder. X .TP X .B %3 X! is replaced with "at \fIhh\fR:\fImm\fR" in 24-hour format. X .TP X .B %4 X is replaced with "\fImm\fR" where \fImm\fR is the number of minutes between X*************** X*** 1264,1269 **** X--- 1271,1282 ---- X .B %! X is replaced with "is" if the current time is before the \fIAT\fR time, X or "was" if it is after. X+ .TP X+ .B %@ X+ is similar to \fB%2\fR but displays the current time. X+ .TP X+ .B %# X+ is similar to \fB%3\fR but displays the current time. X .TP X .B X %" X*** ../patch1.work/timed.c Mon Feb 18 13:05:21 1991 X--- ./timed.c Wed Jul 17 13:07:45 1991 X*************** X*** 8,13 **** X--- 8,17 ---- X #include "globals.h" X #include "protos.h" X X+ #ifndef NL X+ #define NL "\n" X+ #endif X+ X /***************************************************************/ X /* */ X /* TIMED.C */ X*************** X*** 158,166 **** X--- 162,187 ---- X long TimeToSleep; X unsigned SleepTime; X long now; X+ #ifdef SYSV X+ unsigned NotSlept; X+ #endif X X signal(SIGINT, SigIntHandler); X X+ /* If we are not connected to a tty, then we must close the X+ * standard file descriptors. This is to prevent someone X+ * doing: X+ * remind file | | >log X+ * and have hung because the child (us) is still X+ * connected to it. This means the only commands that will be X+ * processed correctly are RUN commands, provided they mail X+ * the result back or use their own resource (as a window). X+ */ X+ if (!isatty(1) || !isatty(2)) { X+ close(1); X+ close(2); X+ } X+ X while (e = AtQueue.next) { X now = SystemTime(); X TimeToSleep = (long) e->firsttime * 60L - now; X*************** X*** 170,185 **** X therefore, do the sleeping in 30000-second chunks. */ X X while (TimeToSleep) { X! if (TimeToSleep > 30000L) SleepTime = 30000; X! else SleepTime = (unsigned) TimeToSleep; X sleep(SleepTime); X TimeToSleep -= (long) SleepTime; X } X X /* Over here, we trigger the reminder */ X DoSubst(e->text, WorkBuf, CurDay, CurMon, CurYear, JulianToday, e->type, e->time, 0); X if (e->type == Run_t) system(WorkBuf); X! else printf("%s\n", WorkBuf); X X /* Remove the entry from the queue */ X AtQueue.next = e->next; X--- 191,210 ---- X therefore, do the sleeping in 30000-second chunks. */ X X while (TimeToSleep) { X! SleepTime = (unsigned)((TimeToSleep > 30000L) ? 30000L : TimeToSleep); X! #ifdef SYSV X! NotSlept = sleep(SleepTime); X! TimeToSleep -= (long)(SleepTime - NotSlept); X! #else X sleep(SleepTime); X TimeToSleep -= (long) SleepTime; X+ #endif X } X X /* Over here, we trigger the reminder */ X DoSubst(e->text, WorkBuf, CurDay, CurMon, CurYear, JulianToday, e->type, e->time, 0); X if (e->type == Run_t) system(WorkBuf); X! else printf("%s%s%s", NL, WorkBuf, NL); X X /* Remove the entry from the queue */ X AtQueue.next = e->next; X*************** X*** 209,223 **** X { X AtEntry *e; X X! printf("Contents of AT queue:\n"); X X e = AtQueue.next; X while (e) { X! printf("Trigger: %02d:%02d Activate: %02d:%02d Rep: %d Delta: %d\n", X e->time / 60, e->time % 60, e->firsttime / 60, e->firsttime % 60, X! e->repeat, e->delta); X! printf("Text: %s %s\n\n", ((e->type == Msg_t) ? "MSG" : "RUN"), e->text); X e = e->next; X } X! printf("\n"); X } X--- 234,253 ---- X { X AtEntry *e; X X! #ifdef SYSV X! signal(SIGINT, SigIntHandler); X! #endif X X+ printf("Contents of AT queue:%s", NL); X+ X e = AtQueue.next; X while (e) { X! printf("Trigger: %02d:%02d Activate: %02d:%02d Rep: %d Delta: %d%s", X e->time / 60, e->time % 60, e->firsttime / 60, e->firsttime % 60, X! e->repeat, e->delta, NL); X! printf("Text: %s %s%s%s", ((e->type == Msg_t) ? "MSG" : "RUN"), e->text, X! NL, NL); X e = e->next; X } X! printf(NL); X } SHAR_EOF $TOUCH -am 0717132591 patch-02 && chmod 0600 patch-02 || echo "restore of patch-02 failed" set `wc -c patch-02`;Wc_c=$1 if test "$Wc_c" != "19150"; then echo original size 19150, current size $Wc_c fi fi exit 0 -- David F. Skoll exit 0 # Just in case... -- Kent Landfield INTERNET: kent@sparky.IMD.Sterling.COM Sterling Software, IMD UUCP: uunet!sparky!kent Phone: (402) 291-8300 FAX: (402) 291-4362 Please send comp.sources.misc-related mail to kent@uunet.uu.net.