home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume40 / remind / patch10b / patch.10.C < prev    next >
Encoding:
C/C++ Source or Header  |  1993-10-25  |  49.0 KB  |  1,482 lines

  1. *** ../prev/makefile.os2    Mon Sep 20 15:00:08 1993
  2. --- ./makefile.os2    Tue Oct 12 16:28:52 1993
  3. ***************
  4. *** 25,31 ****
  5.   # YOU SHOULDN'T EDIT ANYTHING BELOW HERE.  You may want to change some things
  6.   # in config.h; then, you should be able to type 'make'.
  7.   #-----------------------------------------------------------------------------
  8. ! VERSION= 03.00.09
  9.   
  10.   HDRS= config.h err.h expr.h globals.h protos.h types.h version.h \
  11.   lang.h english.h german.h dutch.h finish.h french.h norwgian.h
  12. --- 25,31 ----
  13.   # YOU SHOULDN'T EDIT ANYTHING BELOW HERE.  You may want to change some things
  14.   # in config.h; then, you should be able to type 'make'.
  15.   #-----------------------------------------------------------------------------
  16. ! VERSION= 03.00.10
  17.   
  18.   HDRS= config.h err.h expr.h globals.h protos.h types.h version.h \
  19.   lang.h english.h german.h dutch.h finish.h french.h norwgian.h
  20. ***************
  21. *** 41,47 ****
  22.   remind.1 remind-all.csh remind-all.sh test.rem test-rem test.cmp makefile.tc \
  23.   makefile.msc lnk.msc lnk.tc MANIFEST.UNX MANIFEST.DOS WHATSNEW.30 kall kall.1 \
  24.   defs.rem README.OS2 makefile.os2 rem2ps.c rem2ps.h remind.def rem2ps.1 \
  25. ! tstlang.rem
  26.   
  27.   OBJS= $(SRCS:.c=$O)
  28.   
  29. --- 41,49 ----
  30.   remind.1 remind-all.csh remind-all.sh test.rem test-rem test.cmp makefile.tc \
  31.   makefile.msc lnk.msc lnk.tc MANIFEST.UNX MANIFEST.DOS WHATSNEW.30 kall kall.1 \
  32.   defs.rem README.OS2 makefile.os2 rem2ps.c rem2ps.h remind.def rem2ps.1 \
  33. ! tstlang.rem README.BCC lnk.bcc makefile.bcc os2func.c \
  34. ! test-rem.bat test-rem.cmd test1.cmp test2.cmp
  35.   
  36.   OBJS= $(SRCS:.c=$O)
  37.   
  38. *** ../prev/makefile.tc    Thu Sep 30 15:50:25 1993
  39. --- ./makefile.tc    Tue Oct 12 16:28:35 1993
  40. ***************
  41. *** 1,6 ****
  42.   # Makefile for REMIND for Turbo C for MSDOS
  43.   
  44. ! VERSION= 03.00.09
  45.   
  46.   HDRS= config.h err.h expr.h globals.h protos.h types.h version.h \
  47.   lang.h english.h german.h dutch.h finnish.h french.h norwgian.h
  48. --- 1,7 ----
  49.   # Makefile for REMIND for Turbo C for MSDOS
  50.   
  51. ! CC= tcc
  52. ! VERSION= 03.00.10
  53.   
  54.   HDRS= config.h err.h expr.h globals.h protos.h types.h version.h \
  55.   lang.h english.h german.h dutch.h finnish.h french.h norwgian.h
  56. ***************
  57. *** 20,37 ****
  58.   remind.1 remind-a.csh remind-a.sh test.rem test-rem test.cmp makefile.tc \
  59.   makefile.msc lnk.msc lnk.tc manifest.dos manifest.unx whatsnew.30 kall kall.1 \
  60.   tstlang.rem defs.rem readme.os2 makefile.os2 rem2ps.c rem2ps.h remind.def \
  61. ! rem2ps.1
  62.   
  63.   all: remind.exe rem2ps.exe
  64.   
  65.   remind.exe: $(OBJS)
  66. !     tcc @lnk.tc
  67.   
  68.   rem2ps.exe: rem2ps.obj
  69. !     tcc -erem2ps.exe rem2ps.obj
  70.   
  71.   .c.obj:
  72. !     tcc -A -w-pia -c -O -mm {$< }
  73.   
  74.   rem2ps.obj: rem2ps.c rem2ps.h config.h lang.h
  75.   
  76. --- 21,40 ----
  77.   remind.1 remind-a.csh remind-a.sh test.rem test-rem test.cmp makefile.tc \
  78.   makefile.msc lnk.msc lnk.tc manifest.dos manifest.unx whatsnew.30 kall kall.1 \
  79.   tstlang.rem defs.rem readme.os2 makefile.os2 rem2ps.c rem2ps.h remind.def \
  80. ! rem2ps.1 README.BCC lnk.bcc makefile.bcc os2func.c \
  81. ! test-rem.bat test-rem.cmd test1.cmp test2.cmp
  82.   
  83.   all: remind.exe rem2ps.exe
  84.   
  85.   remind.exe: $(OBJS)
  86. !     $(CC) @lnk.tc
  87.   
  88.   rem2ps.exe: rem2ps.obj
  89. !     $(CC) -erem2ps.exe rem2ps.obj
  90.   
  91.   .c.obj:
  92. !     $(CC) -w-pia -c -O -mm {$< }
  93.   
  94.   rem2ps.obj: rem2ps.c rem2ps.h config.h lang.h
  95.   
  96. *** ../prev/moon.c    Thu Sep 30 15:50:08 1993
  97. --- ./moon.c    Tue Oct 12 16:22:48 1993
  98. ***************
  99. *** 274,288 ****
  100.   double *usek;
  101.   #endif
  102.   {
  103. -    int yy, mm, dd;
  104.      double k, t, t2, t3, nt1;
  105.   
  106. !    jyear(sdate, &yy, &mm, &dd);
  107.   
  108. !    k = (yy + ((mm - 1) * (1.0 / 12.0)) - 1900) * 12.3685;
  109.   
  110.      /* Time in Julian centuries from 1900 January 0.5 */
  111. !    t = (sdate - 2415020.0) / 36525;
  112.      t2 = t * t;           /* Square for frequent use */
  113.      t3 = t2 * t;           /* Cube for frequent use */
  114.   
  115. --- 274,291 ----
  116.   double *usek;
  117.   #endif
  118.   {
  119.      double k, t, t2, t3, nt1;
  120.   
  121. ! /*** The following was the original code:  It gave roundoff errors
  122. !      causing moonphase info to fail for Dec 1994.  ***/
  123. ! /*    jyear(sdate, &yy, &mm, &dd);
  124. !       k = (yy + (mm/12.0) - 1900) * 12.368531; */
  125.   
  126. ! /*** The next line is the replacement ***/
  127. !    k = (sdate - 2415020.0) / synmonth;
  128.   
  129.      /* Time in Julian centuries from 1900 January 0.5 */
  130. !    t = (sdate - 2415020.0) / 36525.0;
  131.      t2 = t * t;           /* Square for frequent use */
  132.      t3 = t2 * t;           /* Cube for frequent use */
  133.   
  134. ***************
  135. *** 316,322 ****
  136.      int apcor = 0;
  137.   
  138.      k += phase;           /* Add phase to new moon time */
  139. !    t = k / 1236.85;       /* Time in Julian centuries from
  140.                        1900 January 0.5 */
  141.      t2 = t * t;           /* Square for frequent use */
  142.      t3 = t2 * t;           /* Cube for frequent use */
  143. --- 319,325 ----
  144.      int apcor = 0;
  145.   
  146.      k += phase;           /* Add phase to new moon time */
  147. !    t = k / 1236.8531;       /* Time in Julian centuries from
  148.                        1900 January 0.5 */
  149.      t2 = t * t;           /* Square for frequent use */
  150.      t3 = t2 * t;           /* Cube for frequent use */
  151. ***************
  152. *** 602,616 ****
  153.      int d1, t1;
  154.      double k1, k2, jd, jdorig;
  155.      double nt1, nt2;
  156.      /* Convert from local to UTC */
  157.      LocalToUTC(startdate, starttim, &utcd, &utct);
  158.   
  159.      /* Convert from Remind representation to year/mon/day */
  160.      FromJulian(utcd, &y, &m, &d);
  161.      /* Convert to a true Julian date -- sorry for the name clashes! */
  162.      jdorig = jtime(y, m, d, (utct / 60), (utct % 60), 0);   
  163. !    jd = jdorig - 45;
  164.      nt1 = meanphase(jd, 0.0, &k1);
  165.      while(1) {
  166.         jd += synmonth;
  167. --- 605,619 ----
  168.      int d1, t1;
  169.      double k1, k2, jd, jdorig;
  170.      double nt1, nt2;
  171.      /* Convert from local to UTC */
  172.      LocalToUTC(startdate, starttim, &utcd, &utct);
  173.   
  174.      /* Convert from Remind representation to year/mon/day */
  175.      FromJulian(utcd, &y, &m, &d);
  176.      /* Convert to a true Julian date -- sorry for the name clashes! */
  177.      jdorig = jtime(y, m, d, (utct / 60), (utct % 60), 0);   
  178. !    jd = jdorig - 45.0;
  179.      nt1 = meanphase(jd, 0.0, &k1);
  180.      while(1) {
  181.         jd += synmonth;
  182. *** ../prev/omit.c    Thu Aug 19 16:16:33 1993
  183. --- ./omit.c    Tue Oct 12 16:22:49 1993
  184. ***************
  185. *** 324,329 ****
  186. --- 324,330 ----
  187.        case T_Empty:
  188.        case T_Comment:
  189.        case T_RemType:
  190. +      case T_Priority:
  191.           parsing = 0;
  192.           break;
  193.   
  194. ***************
  195. *** 353,359 ****
  196.            NumFullOmits++;
  197.         }
  198.      }
  199. !    if (tok.type == T_RemType) return E_PARSE_AS_REM;
  200.      return OK;
  201.   
  202.   }
  203. --- 354,360 ----
  204.            NumFullOmits++;
  205.         }
  206.      }
  207. !    if (tok.type == T_RemType || tok.type == T_Priority) return E_PARSE_AS_REM;
  208.      return OK;
  209.   
  210.   }
  211. *** ../prev/protos.h    Mon Sep 20 16:53:13 1993
  212. --- ./protos.h    Wed Oct 20 11:54:30 1993
  213. ***************
  214. *** 86,92 ****
  215.   int PopOmitContext ARGS ((ParsePtr p));
  216.   int IsOmitted ARGS ((int jul, int localomit));
  217.   int DoOmit ARGS ((ParsePtr p));
  218. ! int QueueReminder ARGS ((ParsePtr p, int typ, TimeTrig *tim));
  219.   void HandleQueuedReminders ARGS ((void));
  220.   char *FindInitialToken ARGS ((Token *tok, char *s));
  221.   void FindToken ARGS ((const char *s, Token *tok));
  222. --- 86,92 ----
  223.   int PopOmitContext ARGS ((ParsePtr p));
  224.   int IsOmitted ARGS ((int jul, int localomit));
  225.   int DoOmit ARGS ((ParsePtr p));
  226. ! int QueueReminder ARGS ((ParsePtr p, int typ, TimeTrig *tim, const char *sched));
  227.   void HandleQueuedReminders ARGS ((void));
  228.   char *FindInitialToken ARGS ((Token *tok, char *s));
  229.   void FindToken ARGS ((const char *s, Token *tok));
  230. ***************
  231. *** 113,119 ****
  232.   unsigned int HashVal ARGS ((const char *str));
  233.   int DateOK ARGS ((int y, int m, int d));
  234.   Operator *FindFunc ARGS ((char *name, Operator where[], int num));
  235. ! int InsertIntoSortBuffer ARGS ((int jul, int tim, char *body, int typ));
  236.   void IssueSortedReminders ARGS ((void));    
  237.   int UserFuncExists ARGS ((char *fn));
  238.   void JulToHeb ARGS((int jul, int *hy, int *hm, int *hd));
  239. --- 113,119 ----
  240.   unsigned int HashVal ARGS ((const char *str));
  241.   int DateOK ARGS ((int y, int m, int d));
  242.   Operator *FindFunc ARGS ((char *name, Operator where[], int num));
  243. ! int InsertIntoSortBuffer ARGS ((int jul, int tim, char *body, int typ, int prio));
  244.   void IssueSortedReminders ARGS ((void));    
  245.   int UserFuncExists ARGS ((char *fn));
  246.   void JulToHeb ARGS((int jul, int *hy, int *hm, int *hd));
  247. ***************
  248. *** 136,138 ****
  249. --- 136,148 ----
  250.   void UTCToLocal ARGS ((int utcdate, int utctime, int *locdate, int *loctime));
  251.   int MoonPhase ARGS ((int date, int time));
  252.   void HuntPhase ARGS ((int startdate, int starttim, int phas, int *date, int *time));
  253. + int CompareRems ARGS ((int dat1, int tim1, int prio1, int dat2, int tim2, int prio2, int bydate, int bytime, int byprio));
  254. + #if defined(__OS2__)
  255. + int fork ARGS ((void));
  256. + void StartPopUp ARGS ((void));
  257. + void EndPopUp ARGS ((void));
  258. + int PutcPopUp ARGS ((int c));
  259. + int PutlPopUp ARGS ((char *s));
  260. + int PutsPopUp ARGS ((char *s));
  261. + #endif
  262. *** ../prev/queue.c    Thu Aug 19 16:12:20 1993
  263. --- ./queue.c    Wed Oct 20 13:16:43 1993
  264. ***************
  265. *** 22,31 ****
  266. --- 22,39 ----
  267.   #ifdef HAVE_UNISTD
  268.   #include <unistd.h>
  269.   #endif
  270. + #ifdef __BORLANDC__
  271. + #include <io.h>
  272. + #include <dos.h>
  273. + #include <process.h>
  274. + #endif
  275.   #include "globals.h"
  276.   #include "err.h"
  277.   #include "types.h"
  278.   #include "protos.h"
  279. + #include "expr.h"
  280.   
  281.   /* List structure for holding queued reminders */
  282.   typedef struct queuedrem {
  283. ***************
  284. *** 32,38 ****
  285. --- 40,48 ----
  286.      struct queuedrem *next;
  287.      int typ;
  288.      int RunDisabled;
  289. +    int ntrig;
  290.      char *text;
  291. +    char sched[VAR_NAME_LEN+1];
  292.      TimeTrig tt;
  293.   } QueuedRem;
  294.   
  295. ***************
  296. *** 45,51 ****
  297. --- 55,67 ----
  298.   PRIVATE void CheckInitialFile ARGS ((void));
  299.   PRIVATE int CalculateNextTime ARGS ((QueuedRem *q));
  300.   PRIVATE QueuedRem *FindNextReminder ARGS ((void));
  301. + PRIVATE int CalculateNextTimeUsingSched ARGS ((QueuedRem *q));
  302. + #ifdef __OS2__
  303. + void (__cdecl SigIntHandler(int));
  304. + #else
  305.   PRIVATE void SigIntHandler ARGS ((void));
  306. + #endif
  307.   
  308.   /***************************************************************/
  309.   /*                                                             */
  310. ***************
  311. *** 56,67 ****
  312.   /*                                                             */
  313.   /***************************************************************/
  314.   #ifdef HAVE_PROTOS
  315. ! PUBLIC int QueueReminder(ParsePtr p, int typ, TimeTrig *tim)
  316.   #else
  317. ! int QueueReminder(p, typ, tim)
  318.   ParsePtr p;
  319.   int typ;
  320.   TimeTrig *tim;
  321.   #endif
  322.   {
  323.      QueuedRem *qelem;
  324. --- 72,84 ----
  325.   /*                                                             */
  326.   /***************************************************************/
  327.   #ifdef HAVE_PROTOS
  328. ! PUBLIC int QueueReminder(ParsePtr p, int typ, TimeTrig *tim, const char *sched)
  329.   #else
  330. ! int QueueReminder(p, typ, tim, sched)
  331.   ParsePtr p;
  332.   int typ;
  333.   TimeTrig *tim;
  334. + char *sched;
  335.   #endif
  336.   {
  337.      QueuedRem *qelem;
  338. ***************
  339. *** 85,90 ****
  340. --- 102,109 ----
  341.      qelem->tt = *tim;
  342.      qelem->next = QueueHead;
  343.      qelem->RunDisabled = RunDisabled;
  344. +    qelem->ntrig = 0;
  345. +    strcpy(qelem->sched, sched);
  346.      QueueHead = qelem;
  347.      NumQueued++;
  348.      return OK;
  349. ***************
  350. *** 191,196 ****
  351. --- 210,218 ----
  352.   /*                                                             */
  353.   /*  Calculate the next time when a reminder should be issued.  */
  354.   /*  Return NO_TIME if reminder expired.                        */
  355. + /*  Strategy is:  If a sched() function is defined, call it.   */
  356. + /*  Otherwise, use AT time with delta and rep.  If sched()     */
  357. + /*  fails, revert to AT with delta and rep.                    */
  358.   /*                                                             */
  359.   /***************************************************************/
  360.   #ifdef HAVE_PROTOS
  361. ***************
  362. *** 204,210 ****
  363. --- 226,239 ----
  364.      int rep = q->tt.rep;
  365.      int delta = q->tt.delta;
  366.      int curtime = q->tt.nexttime+1;
  367. +    int r;
  368.   
  369. + /* Increment number of times this one has been triggered */
  370. +    q->ntrig++;
  371. +    if (q->sched[0]) {
  372. +       r = CalculateNextTimeUsingSched(q);
  373. +       if (r != NO_TIME) return r;
  374. +    }
  375.      if (delta == NO_DELTA)
  376.         if (tim < curtime) return NO_TIME; else return tim;
  377.   
  378. ***************
  379. *** 253,263 ****
  380. --- 282,296 ----
  381.   /* command-line flag is supplied.                              */
  382.   /*                                                             */
  383.   /***************************************************************/
  384. + #ifdef __OS2__
  385. + void __cdecl SigIntHandler(int d)
  386. + #else
  387.   #ifdef HAVE_PROTOS
  388.   PRIVATE void SigIntHandler(void)
  389.   #else
  390.   static void SigIntHandler()
  391.   #endif
  392. + #endif
  393.   {
  394.      QueuedRem *q = QueueHead;
  395.   
  396. ***************
  397. *** 269,278 ****
  398.   
  399.      while (q) {
  400.         if (q->tt.nexttime != NO_TIME) {
  401. !          printf("Trigger: %02d%c%02d  Activate: %02d%c%02d  Rep: %d  Delta: %d%s",
  402.                    q->tt.ttime / 60, TIMESEP, q->tt.ttime % 60,
  403.                    q->tt.nexttime / 60, TIMESEP, q->tt.nexttime % 60,
  404. !                  q->tt.rep, q->tt.delta, NL);
  405.                    printf("Text: %s %s%s%s", ((q->typ == MSG_TYPE) ? "MSG" :
  406.                                      ((q->typ == MSF_TYPE) ? "MSF" :"RUN")),
  407.                    q->text,
  408. --- 302,311 ----
  409.   
  410.      while (q) {
  411.         if (q->tt.nexttime != NO_TIME) {
  412. !          printf("Trigger: %02d%c%02d  Activate: %02d%c%02d  Rep: %d  Delta: %d  Sched: %s%s",
  413.                    q->tt.ttime / 60, TIMESEP, q->tt.ttime % 60,
  414.                    q->tt.nexttime / 60, TIMESEP, q->tt.nexttime % 60,
  415. !                  q->tt.rep, q->tt.delta, q->sched, NL);
  416.                    printf("Text: %s %s%s%s", ((q->typ == MSG_TYPE) ? "MSG" :
  417.                                      ((q->typ == MSF_TYPE) ? "MSF" :"RUN")),
  418.                    q->text,
  419. ***************
  420. *** 306,308 ****
  421. --- 339,401 ----
  422.             execvp(ArgV[0], ArgV);
  423.   }
  424.   
  425. + /***************************************************************/
  426. + /*                                                             */
  427. + /*  CalculateNextTimeUsingSched                                */
  428. + /*                                                             */
  429. + /*  Call the scheduling function.                              */
  430. + /*                                                             */
  431. + /***************************************************************/
  432. + #ifdef HAVE_PROTOS
  433. + PRIVATE int CalculateNextTimeUsingSched(QueuedRem *q)
  434. + #else
  435. + static int CalculateNextTimeUsingSched(q)
  436. + QueuedRem *q;
  437. + #endif
  438. + {
  439. +    /* Use LineBuffer for temp. string storage. */
  440. +    int r;
  441. +    Value v;
  442. +    char *s;
  443. +    int LastTime = -1;
  444. +    int ThisTime;
  445. +    if (UserFuncExists(q->sched) != 1) {
  446. +       q->sched[0] = 0;
  447. +       return NO_TIME;
  448. +    }
  449. +    RunDisabled = q->RunDisabled;  /* Don't want weird scheduling functions
  450. +                      to be a security hole!                */
  451. +    while(1) {
  452. +       sprintf(LineBuffer, "%s(%d)", q->sched, q->ntrig);
  453. +       s = LineBuffer;
  454. +       r = EvalExpr(&s, &v);
  455. +       if (r) {
  456. +          q->sched[0] = 0;
  457. +          return NO_TIME;
  458. +       }
  459. +       if (v.type == TIM_TYPE) {
  460. +          ThisTime = v.v.val;
  461. +       } else if (v.type == INT_TYPE) {
  462. +          if (v.v.val > 0) 
  463. +         ThisTime = q->tt.nexttime + v.v.val;
  464. +          else
  465. +         ThisTime = q->tt.ttime + v.v.val;
  466. +       } else {
  467. +          DestroyValue(&v);
  468. +      q->sched[0] = 0;
  469. +      return NO_TIME;
  470. +       }
  471. +       if (ThisTime < 0) ThisTime = 0;        /* Can't be less than 00:00 */
  472. +       if (ThisTime > 1439) ThisTime = 1439;  /* or greater than 11:59 */
  473. +       if (ThisTime > q->tt.nexttime) return ThisTime;
  474. +       if (ThisTime <= LastTime) {
  475. +          q->sched[0] = 0;
  476. +      return NO_TIME;
  477. +       }
  478. +       LastTime = ThisTime;
  479. +       q->ntrig++;
  480. +    }
  481. + }
  482. *** ../prev/rem2ps.c    Tue Sep 28 12:33:59 1993
  483. --- ./rem2ps.c    Wed Oct 13 10:46:21 1993
  484. ***************
  485. *** 24,29 ****
  486. --- 24,33 ----
  487.   #include <stdlib.h>
  488.   #endif
  489.   
  490. + #ifdef __TURBOC__
  491. + #include <io.h>
  492. + #endif
  493.   #ifdef HAVE_PROTOS
  494.   #define ARGS(x) x
  495.   #else
  496. ***************
  497. *** 183,189 ****
  498.      int is_ps;
  499.      CalEntry *c, *d;
  500.   
  501. -    printf("%%%%Page: %d %d\n", validfile, validfile);
  502.   /* Read the month and year name, followed by # days in month and 1st day of
  503.      month, followed by the MondayFirst flag */
  504.      gets(LineBuffer);
  505. --- 187,192 ----
  506. ***************
  507. *** 195,200 ****
  508. --- 198,206 ----
  509.      MaxDay = days;
  510.      FirstWkDay = wkday;
  511.   
  512. +    printf("%%%%Page: %c%c%c%c%c %d\n", month[0], month[1], month[2],
  513. +              year[2], year[3], validfile);
  514.   /* Emit PostScript to do the heading */
  515.      if (!PortraitMode) printf("XSIZE 0 translate 90 rotate\n");
  516.      printf("/SAVESTATE save def (%s) (%s) PreCal SAVESTATE restore\n", month, year);
  517. ***************
  518. *** 255,262 ****
  519.         if (is_ps) {
  520.   /* Save the 'P' or 'F' flag */
  521.            *(c->entry) = *LineBuffer;
  522. !      c->next = PsEntries[DayNum];
  523. !      PsEntries[DayNum] = c;
  524.         } else {
  525.   /* Put on linked list */
  526.            if (!CurEntries) CurEntries = c;
  527. --- 261,272 ----
  528.         if (is_ps) {
  529.   /* Save the 'P' or 'F' flag */
  530.            *(c->entry) = *LineBuffer;
  531. !          if (!PsEntries[DayNum]) PsEntries[DayNum] = c;
  532. !      else {
  533. !         d = PsEntries[DayNum];
  534. !         while(d->next) d = d->next;
  535. !         d->next = c;
  536. !          }
  537.         } else {
  538.   /* Put on linked list */
  539.            if (!CurEntries) CurEntries = c;
  540. *** ../prev/remind.1    Thu Sep 30 15:25:03 1993
  541. --- ./remind.1    Wed Oct 20 13:27:12 1993
  542. ***************
  543. *** 1,4 ****
  544. ! .TH REMIND 1 "30 September 1993"
  545.   .UC 4
  546.   .SH NAME
  547.   remind \- a sophisticated reminder service
  548. --- 1,4 ----
  549. ! .TH REMIND 1 "13 October 1993"
  550.   .UC 4
  551.   .SH NAME
  552.   remind \- a sophisticated reminder service
  553. ***************
  554. *** 119,130 ****
  555.   Echo lines when displaying error messages
  556.   .RE
  557.   .TP
  558. ! \fB\-g\fR[\fBa|d\fR[\fBa|d\fR]]
  559.   Normally, reminders are issued in the order in which they are encountered
  560.   in the reminder script.  The \fB\-g\fR option cause \fBRemind\fR to
  561.   sort reminders by date and time prior to issuing them.  The optional
  562.   \fBa\fR and \fBd\fR characters specify the sort order (ascending or
  563. ! descending) for the date and time fields.  See the section "Sorting
  564.   Reminders" for more information.
  565.   .TP
  566.   \fB\-b\fR[\fIn\fR]
  567. --- 119,130 ----
  568.   Echo lines when displaying error messages
  569.   .RE
  570.   .TP
  571. ! \fB\-g\fR[\fBa|d\fR[\fBa|d\fR[\fBa|d\fR]]]
  572.   Normally, reminders are issued in the order in which they are encountered
  573.   in the reminder script.  The \fB\-g\fR option cause \fBRemind\fR to
  574.   sort reminders by date and time prior to issuing them.  The optional
  575.   \fBa\fR and \fBd\fR characters specify the sort order (ascending or
  576. ! descending) for the date, time and priority fields.  See the section "Sorting
  577.   Reminders" for more information.
  578.   .TP
  579.   \fB\-b\fR[\fIn\fR]
  580. ***************
  581. *** 257,265 ****
  582. --- 257,267 ----
  583.   [\fIback\fR]
  584.   [\fIdelta\fR]
  585.   [\fIrepeat\fR]
  586. + [\fBPRIORITY\fR \fIprio\fR]
  587.   [\fBSKIP\fR | \fBBEFORE\fR | \fBAFTER\fR]
  588.   [\fBOMIT\fR \fIomit_list\fR]
  589.   [\fBAT\fR \fItime\fR [\fItdelta\fR] [\fItrepeat\fR]]
  590. + [\fBSCHED\fR \fIsched_function\fR]
  591.   [\fBUNTIL\fR \fIexpiry_date\fR]
  592.   [\fBSCANFROM\fR \fIscan_date\fR]
  593.   \fBMSG\fR | \fBMSF\fR | \fBRUN\fR | \fBCAL\fR | \fBSATISFY\fR |
  594. ***************
  595. *** 602,607 ****
  596. --- 604,617 ----
  597.   near the end of this manual.  Note that \fBSCANFROM\fR is available only
  598.   in versions of \fBRemind\fR from 03.00.04 up.
  599.   .PP
  600. + .B PRIORITY
  601. + .PP
  602. + The \fBPRIORITY\fR keyword must be followed by a number from 0 to 9999.
  603. + It is used in calendar mode and when sorting reminders.  If two reminders
  604. + have the same trigger date and time, then they are sorted by priority.
  605. + If the \fBPRIORITY\fR keyword is not supplied, a default priority of 5000
  606. + is used.
  607. + .PP
  608.   .B EXPIRY DATES
  609.   .PP
  610.   Some reminders should be issued periodically for a certain time, but then
  611. ***************
  612. *** 767,772 ****
  613. --- 777,789 ----
  614.   \fInot\fR necessarily be those which were in effect at the time the reminder
  615.   was queued.
  616.   .PP
  617. + .B THE SCHED KEYWORD
  618. + .PP
  619. + The \fBSCHED\fR keyword allows more precise control over the triggering
  620. + of timed reminders.  However, discussion must be deferred until after
  621. + expressions and user-defined functions are explained.  See the subsection
  622. + "Precise Scheduling" further on.
  623. + .PP
  624.   .SH THE SUBSTITUTION FILTER
  625.   .PP
  626.   Before being processed, the body of a
  627. ***************
  628. *** 1503,1512 ****
  629.   .TP
  630.   .B $CalcUTC 
  631.   If 1 (the default), then \fBRemind\fR uses C library functions
  632. ! to calculate the number of minutes between local and universal time.
  633.   This affects astronomical calculations (\fBsunrise()\fR for example.)
  634.   If 0, then you must supply the number of minutes between local and
  635. ! universal time in the \fB$MinsFromUTC\fR system variable.
  636.   .TP
  637.   .B $CalMode (read-only)
  638.   If non-zero, then the \fB\-c\fR option was supplied on the command line.
  639. --- 1520,1530 ----
  640.   .TP
  641.   .B $CalcUTC 
  642.   If 1 (the default), then \fBRemind\fR uses C library functions
  643. ! to calculate the number of minutes between local and Universal Time
  644. ! Coordinated.
  645.   This affects astronomical calculations (\fBsunrise()\fR for example.)
  646.   If 0, then you must supply the number of minutes between local and
  647. ! Universal Time Coordinated in the \fB$MinsFromUTC\fR system variable.
  648.   .TP
  649.   .B $CalMode (read-only)
  650.   If non-zero, then the \fB\-c\fR option was supplied on the command line.
  651. ***************
  652. *** 1613,1619 ****
  653.   (described later.)  Must be at least 10.
  654.   .TP
  655.   .B $MinsFromUTC
  656. ! The number of minutes between Universal Time and local time.  If
  657.   \fB$CalcUTC\fR is non-zero, this is calculated upon startup of \fBRemind\fR.
  658.   Otherwise, you must set it explicitly.  If \fB$CalcUTC\fR is zero,
  659.   then \fB$MinsFromUTC\fR is used in the astronomical calculations.  You
  660. --- 1631,1637 ----
  661.   (described later.)  Must be at least 10.
  662.   .TP
  663.   .B $MinsFromUTC
  664. ! The number of minutes between Universal Time Coordinated and local time.  If
  665.   \fB$CalcUTC\fR is non-zero, this is calculated upon startup of \fBRemind\fR.
  666.   Otherwise, you must set it explicitly.  If \fB$CalcUTC\fR is zero,
  667.   then \fB$MinsFromUTC\fR is used in the astronomical calculations.  You
  668. ***************
  669. *** 1656,1661 ****
  670. --- 1674,1691 ----
  671.   Set to a non-zero value if \fIeither\fR of the \fB\-p\fR or \fB\-s\fR
  672.   command-line options was supplied.
  673.   .TP
  674. + .B $SortByDate (read-only)
  675. + Set to 0 if no \fB\-g\fR option is used, 1 if sorting by date in ascending
  676. + order, or 2 if sorting by date in descending order.
  677. + .TP
  678. + .B $SortByPrio (read-only)
  679. + Set to 0 if no \fB\-g\fR option is used, 1 if sorting by priority in ascending
  680. + order, or 2 if sorting by priority in descending order.
  681. + .TP
  682. + .B $SortByTime (read-only)
  683. + Set to 0 if no \fB\-g\fR option is used, 1 if sorting by time in ascending
  684. + order, or 2 if sorting by time in descending order.
  685. + .TP
  686.   .B $SubsIndent
  687.   The number of spaces by which all lines (except the first) of an
  688.   \fBMSF\fR-type reminder should be indented.  The default is 0.
  689. ***************
  690. *** 1935,1944 ****
  691.   as with the < operator.
  692.   .TP
  693.   .B minsfromutc([d_date [,t_time]])
  694. ! Returns the number of minutes from Universal Time (formerly GMT) to
  695.   local time on the specified date and time.  \fIDate\fR defaults to
  696.   \fBtoday()\fR and \fItime\fR defaults to midnight.  If local time
  697. ! is before UT, the result is negative.  Otherwise, the result is
  698.   positive.
  699.   .RS
  700.   .PP
  701. --- 1965,1975 ----
  702.   as with the < operator.
  703.   .TP
  704.   .B minsfromutc([d_date [,t_time]])
  705. ! Returns the number of minutes from Universal Time Coordinated 
  706. ! (formerly GMT) to
  707.   local time on the specified date and time.  \fIDate\fR defaults to
  708.   \fBtoday()\fR and \fItime\fR defaults to midnight.  If local time
  709. ! is before UTC, the result is negative.  Otherwise, the result is
  710.   positive.
  711.   .RS
  712.   .PP
  713. ***************
  714. *** 1982,1989 ****
  715.   quarter, 2 full moon, and 3 third quarter.  If \fIdate\fR is omitted,
  716.   it defaults to \fBtoday()\fR.  If \fItime\fR is omitted, it defaults
  717.   to midnight.  \fBMoontime()\fR is intended to be used in conjunction
  718. ! with \fBmoondate()\fR.  Don't take the time too seriously - it's only
  719. ! accurate to within 15-20 minutes.
  720.   .RS
  721.   .PP
  722.   For example, the following returns the date and time of the next full moon:
  723. --- 2013,2021 ----
  724.   quarter, 2 full moon, and 3 third quarter.  If \fIdate\fR is omitted,
  725.   it defaults to \fBtoday()\fR.  If \fItime\fR is omitted, it defaults
  726.   to midnight.  \fBMoontime()\fR is intended to be used in conjunction
  727. ! with \fBmoondate()\fR.  The \fBmoondate()\fR and \fBmoontime()\fR
  728. ! functions are accurate to within a couple of minutes of the
  729. ! times in "Old Farmer's Almanac" for Ottawa, Ontario.
  730.   .RS
  731.   .PP
  732.   For example, the following returns the date and time of the next full moon:
  733. ***************
  734. *** 2122,2131 ****
  735.   or \fBIFTRIG\fR command.  If used
  736.   in the \fIbody\fR of a \fBREM\fR command, returns that command's trigger date.
  737.   .TP
  738. ! .B trigger(d_date)
  739.   Returns a string suitable for use in a \fBREM\fR command, allowing you to
  740. ! calculate trigger dates in advance.  See the section "Expression pasting"
  741. ! for more information.
  742.   .TP
  743.   .B trigtime()
  744.   Returns the time of the last \fBREM\fR command with an \fBAT\fR clause.
  745. --- 2154,2181 ----
  746.   or \fBIFTRIG\fR command.  If used
  747.   in the \fIbody\fR of a \fBREM\fR command, returns that command's trigger date.
  748.   .TP
  749. ! .B trigger(d_date [,t_time [,i_utcflag]])
  750.   Returns a string suitable for use in a \fBREM\fR command, allowing you to
  751. ! calculate trigger dates in advance.  (See the section "Expression pasting"
  752. ! for more information.)  Normally, the \fIdate\fR and \fItime\fR are
  753. ! the local date and time; however, if \fIutcflag\fR is non-zero, the
  754. ! \fIdate\fR and \fItime\fR are interpreted as UTC times, and are
  755. ! converted to local time.  Examples:
  756. ! .RS
  757. ! .PP
  758. ! trigger('1993/04/01')
  759. ! .PP
  760. ! returns "1 April 1993",
  761. ! .PP
  762. ! trigger('1994/08/09', 12:33)
  763. ! .PP
  764. ! returns "9 August 1994 AT 12:33", and
  765. ! .PP
  766. ! trigger('1994/12/01', 03:00, 1)
  767. ! .PP
  768. ! returns "30 November 1994 AT 22:00" for EST, which is 5 hours behind UTC.
  769. ! The value for your time zone may differ.
  770. ! .RE
  771.   .TP
  772.   .B trigtime()
  773.   Returns the time of the last \fBREM\fR command with an \fBAT\fR clause.
  774. ***************
  775. *** 2410,2415 ****
  776. --- 2460,2533 ----
  777.   functions), you may wish to name all user-defined functions beginning
  778.   with an underscore.
  779.   .PP
  780. + .SH PRECISE SCHEDULING
  781. + .PP
  782. + The \fBSCHED\fR keyword allows precise control over the scheduling of timed
  783. + reminders.  It should be followed by the name of a user-defined function,
  784. + \fIsched_function\fR.
  785. + .PP
  786. + If a scheduling function is supplied, then it must take one argument of
  787. + type \fBINT\fR.  Rather than using the \fBAT\fR time, time \fIdelta\fR, and
  788. + time \fIrepeat\fR, \fBRemind\fR calls the scheduling function to determine
  789. + when to trigger the reminder.  The first time the reminder is queued, the
  790. + scheduling function is called with an argument of 1.  Each time the reminder
  791. + is triggered, it is re-scheduled by calling the scheduling function again.
  792. + On each call, the argument is incremented by one.
  793. + .PP
  794. + The return value of the scheduling function must be an \fBINT\fR or a
  795. + \fBTIME\fR.  If the return value is a \fBTIME\fR, then the reminder is
  796. + re-queued to trigger at that time.  If it is a positive integer \fIn\fR,
  797. + then the reminder is re-queued to trigger at the previous trigger time
  798. + plus \fIn\fR minutes.  Finally, if it is a negative integer or zero, then
  799. + the reminder is re-queued to trigger \fIn\fR minutes before the \fBAT\fR
  800. + time.  Note that there must be an \fBAT\fR clause for the \fBSCHED\fR
  801. + clause to do anything.
  802. + .PP
  803. + Here's an example:
  804. + .PP
  805. + .nf
  806. +     FSET _sfun(x) choose(x, -60, 30, 15, 10, 3, 1, 1, 1, 1, 0)
  807. +     REM AT 13:00 SCHED _sfun MSG foo
  808. + .fi
  809. + .PP
  810. + The reminder would first be triggered at 13:00-60 minutes, or at 12:00.
  811. + It would next be triggered 30 minutes later, at 12:30.  Then, it would
  812. + be triggered at 12:45, 12:55, 12:58, 12:59, 13:00, 13:01 and 13:02.
  813. + .PP
  814. + .B NOTES
  815. + .TP
  816. + 1
  817. + If an error occurs during the evaluation of \fIsched_func\fR, then
  818. + \fBRemind\fR reverts to using the \fBAT\fR time and the \fIdelta\fR
  819. + and \fIrepeat\fR values, and never calls \fIsched_func\fR again.
  820. + .TP
  821. + 2
  822. + If processing \fIsched_func\fR yields a time earlier than the current
  823. + system time, it is repeatedly called with increasing argument until it
  824. + yields a value greater than or equal to the current time.  However, if
  825. + the sequence of values calculated during the repetition is not strictly
  826. + increasing, then \fBRemind\fR reverts to the default behaviour and
  827. + never calls \fIsched_func\fR again.
  828. + .TP
  829. + 3
  830. + It is quite possible using \fIsched_func\fR to keep triggering a reminder
  831. + even after the \fBAT\fR-time.  However, it is not possible to reschedule
  832. + a reminder past midnight \- no crossing of date boundaries is allowed.
  833. + Also, it is quite possible to \fBnot\fR trigger a reminder on the \fBAT\fR
  834. + time when you use a scheduling function.  However, if your scheduling
  835. + function is terminated (for reasons 1 and 2) before the \fBAT\fR time of
  836. + the reminder, it \fIwill\fR be triggered at the \fBAT\fR time, because
  837. + normal processing takes over.
  838. + .TP
  839. + 4
  840. + Your scheduling functions should (as a matter of good style) return
  841. + 0 when no more scheduling is required.  See the example.
  842. + .TP
  843. + 5
  844. + All scheduling functions are evaluated \fIafter\fR the entire Remind
  845. + script has been read in.  So whatever function definitions are in effect
  846. + at the end of the script are used.
  847. + .PP
  848.   .SH THE SATISFY CLAUSE
  849.   .PP
  850.   The form of \fBREM\fR which uses \fBSATISFY\fR is as follows:
  851. ***************
  852. *** 2699,2705 ****
  853.   Timed reminders are sorted and placed into the calendar in time order.
  854.   These are followed by non-timed reminders.  \fBRemind\fR automatically
  855.   places the time of timed reminders in the calendar according to the
  856. ! \fB\-b\fR command-line option.
  857.   .PP
  858.   .B REPEATED EXECUTION
  859.   .PP
  860. --- 2817,2826 ----
  861.   Timed reminders are sorted and placed into the calendar in time order.
  862.   These are followed by non-timed reminders.  \fBRemind\fR automatically
  863.   places the time of timed reminders in the calendar according to the
  864. ! \fB\-b\fR command-line option.  Reminders in calendar mode are sorted as
  865. ! if the \fB\-g\fR option had been used; you can change the sort order
  866. ! in calendar mode by explicitly using the \fB\-g\fR option to specify
  867. ! a different order from the default.
  868.   .PP
  869.   .B REPEATED EXECUTION
  870.   .PP
  871. ***************
  872. *** 2763,2770 ****
  873.   the PostScript output.
  874.   .PP
  875.   The PostScript-type reminders for a particular day are included in the
  876. ! PostScript output in the same order they were triggered in the \fBRemind\fR
  877. ! script file.  All of the PostScript code for a particular date is enclosed
  878.   in a \fBsave\fR-\fBrestore\fR pair.  However, if several PostScript-type
  879.   reminders are triggered for a single day, each section of PostScript is
  880.   not enclosed in a \fBsave\fR-\fBrestore\fR pair - instead, the entire
  881. --- 2884,2902 ----
  882.   the PostScript output.
  883.   .PP
  884.   The PostScript-type reminders for a particular day are included in the
  885. ! PostScript output in sorted order of priority.  Note that the order
  886. ! of PostScript commands has a \fImajor\fR impact on the appearance of the
  887. ! calendars.  For example, PostScript code to shade a calendar box will
  888. ! obliterate code to draw a moon symbol if the moon symbol code is placed
  889. ! in the calendar first.  For this reason, you should not provide \fBPS\fR
  890. ! or \fBPSFILE\fR-type reminders with priorities; instead, you should
  891. ! ensure that they appear in the reminder script in the correct order.
  892. ! PostScript code should draw objects working from the background to the
  893. ! foreground, so that foreground objects properly overlay background ones.
  894. ! If you prioritize these reminders and run the script using descending
  895. ! sort order for priorities, the PostScript output will not work.
  896. ! .PP
  897. ! All of the PostScript code for a particular date is enclosed
  898.   in a \fBsave\fR-\fBrestore\fR pair.  However, if several PostScript-type
  899.   reminders are triggered for a single day, each section of PostScript is
  900.   not enclosed in a \fBsave\fR-\fBrestore\fR pair - instead, the entire
  901. ***************
  902. *** 2855,2875 ****
  903.   .SH SORTING REMINDERS
  904.   .PP
  905.   The \fB\-g\fR option causes \fBRemind\fR to sort reminders by
  906. ! trigger date and time before issuing them.  Note that reminders are
  907.   still calculated in the order encountered in the script.  However, rather
  908.   than being issued immediately, they are saved in an internal buffer.
  909.   When \fBRemind\fR has finished processing the script, it issues the
  910.   saved reminders in sorted order.  The \fB\-g\fR option can be followed
  911. ! by one or two characters, which must be "a" or "d".  The first character
  912. ! specifies the sort order by trigger date (ascending or descending) and
  913. ! the second specifies the sort order by trigger time.  The default is
  914. ! to sort both fields in ascending order.
  915.   .PP
  916.   In ascending order, reminders are issued with the most imminent first.
  917.   Descending order is the reverse.  Reminders are always sorted by
  918.   trigger date, and reminders with the same trigger date are then sorted
  919.   by trigger time.  Non-timed reminders are always issued after timed
  920. ! reminders in this mode.
  921.   .PP
  922.   You can define a user-defined function called SORTBANNER which takes one
  923.   \fBDATE\fR-type argument.  In sort mode, the following sequence happens:
  924. --- 2987,3010 ----
  925.   .SH SORTING REMINDERS
  926.   .PP
  927.   The \fB\-g\fR option causes \fBRemind\fR to sort reminders by
  928. ! trigger date, time and priority before issuing them.  Note that reminders are
  929.   still calculated in the order encountered in the script.  However, rather
  930.   than being issued immediately, they are saved in an internal buffer.
  931.   When \fBRemind\fR has finished processing the script, it issues the
  932.   saved reminders in sorted order.  The \fB\-g\fR option can be followed
  933. ! by up to three characters, which must be "a" or "d".  The first character
  934. ! specifies the sort order by trigger date (ascending or descending),
  935. ! the second specifies the sort order by trigger time and the third
  936. ! specifies the sort order by priority.  The default is
  937. ! to sort all fields in ascending order.
  938.   .PP
  939.   In ascending order, reminders are issued with the most imminent first.
  940.   Descending order is the reverse.  Reminders are always sorted by
  941.   trigger date, and reminders with the same trigger date are then sorted
  942.   by trigger time.  Non-timed reminders are always issued after timed
  943. ! reminders in this mode.  If two reminders have the same date and time,
  944. ! then the priority is used to break ties.  Reminders with the same date,
  945. ! time and priority are issued in the order they were encountered.
  946.   .PP
  947.   You can define a user-defined function called SORTBANNER which takes one
  948.   \fBDATE\fR-type argument.  In sort mode, the following sequence happens:
  949. ***************
  950. *** 2926,2931 ****
  951. --- 3061,3121 ----
  952.       endif
  953.   .fi
  954.   .PP
  955. + .SH MSGPREFIX() AND MSGSUFFIX()
  956. + .PP
  957. + You can define two functions in your script called \fBmsgprefix()\fR
  958. + and \fBmsgsuffix()\fR.  They should each accept one argument, a number
  959. + from 0 to 9999.
  960. + .PP
  961. + In normal mode, for \fBMSG\fR- and \fBMSF\fR-type reminders,
  962. + the following sequence occurs when
  963. + \fBRemind\fR triggers a reminder:
  964. + .TP
  965. + o
  966. + If \fBmsgprefix()\fR is defined, it is evaluated with the priority
  967. + of the reminder as its argument.  The result is printed.  It is
  968. + \fInot\fR passed through the substitution filter.
  969. + .TP
  970. + o
  971. + The body of the reminder is printed.
  972. + .TP
  973. + o
  974. + If \fBmsgsuffix()\fR is defined, it is evaluated with the priority
  975. + of the reminder as its argument.  The result is printed.  It is
  976. + \fInot\fR passed through the substitution filter.
  977. + .PP
  978. + Here's an example:  The following definition causes priority-0
  979. + reminders to be preceded by "URGENT", and priority-6000 reminders to
  980. + be preceded by "(not important)".
  981. + .PP
  982. + .nf
  983. +     fset msgprefix(x) iif(x==0, "URGENT: ", \\
  984. +          x==6000, "(not important) ", "")
  985. + .fi
  986. + .PP
  987. + In Calendar Mode (with the \fB\-c\fR, \fB\-s\fR or \fB\-p\fR options),
  988. + an analagous pair of functions named \fBcalprefix()\fR and
  989. + \fBcalsuffix()\fR can be defined.  They work with all reminders which
  990. + produce an entry in the calendar (i.e., \fBCAL\fR- and possibly
  991. + \fBRUN\fR-type reminders as well as \fBMSG\fR-type reminders.)
  992. + .PP
  993. + .B NOTES
  994. + .PP
  995. + Normally, the body of a reminder is followed by a carriage return.
  996. + Thus, the results of \fBmsgsuffix()\fR will appear on the next
  997. + line.  If you don't want this, end the body of the reminder with a
  998. + percentage sign, "%".  If you want a space between your reminders,
  999. + simply include a carriage return (\fBchar(13)\fR) as part of the
  1000. + \fBmsgsuffix()\fR return value.
  1001. + .PP
  1002. + If \fBRemind\fR has problems evaluating \fBmsgprefix()\fR,
  1003. + \fBmsgsuffix()\fR or \fBsortbanner()\fR, you will see a lot of
  1004. + error messages.  For an example of this, define the following:
  1005. + .PP
  1006. + .nf
  1007. +     fset msgprefix(x) x/0
  1008. + .fi
  1009. + .PP
  1010.   .SH FOREIGN LANGUAGE SUPPORT
  1011.   .PP
  1012.   Your version of \fBRemind\fR may have been compiled to support a
  1013. ***************
  1014. *** 2992,2998 ****
  1015.   .TP
  1016.   .B hebdate(i_day, s_hebmon [,id_yrstart [,i_jahr [,i_aflag]]])
  1017.   The \fBhebdate()\fR function is the most complex of the Hebrew support
  1018. ! functions.  It can take from 2 to 4 arguments.  It returns a \fBDATE\fR
  1019.   corresponding to the Hebrew date.
  1020.   .PP
  1021.   .RS
  1022. --- 3182,3188 ----
  1023.   .TP
  1024.   .B hebdate(i_day, s_hebmon [,id_yrstart [,i_jahr [,i_aflag]]])
  1025.   The \fBhebdate()\fR function is the most complex of the Hebrew support
  1026. ! functions.  It can take from 2 to 5 arguments.  It returns a \fBDATE\fR
  1027.   corresponding to the Hebrew date.
  1028.   .PP
  1029.   .RS
  1030. ***************
  1031. *** 3307,3316 ****
  1032.   versions of \fBRemind\fR prior to 03.00.01.
  1033.   .SH AUTHOR
  1034.   .PP
  1035. ! David F. Skoll wrote \fBRemind\fR.  The moon code was copied largely verbatim
  1036. ! from "moontool" by John Walker.  The Hebrew calendar support was taken
  1037. ! from "hdate" by Amos Shapir.  The authors of the language files are
  1038. ! listed in the header file "lang.h" which comes with \fBRemind\fR.
  1039.   .SH BUGS
  1040.   .PP
  1041.   There's no good reason why read-only system variables are not
  1042. --- 3497,3508 ----
  1043.   versions of \fBRemind\fR prior to 03.00.01.
  1044.   .SH AUTHOR
  1045.   .PP
  1046. ! David F. Skoll wrote \fBRemind\fR.  The moon code was copied largely
  1047. ! unmodified from "moontool" by John Walker.  The Hebrew calendar
  1048. ! support was taken from "hdate" by Amos Shapir.  The authors of the
  1049. ! language files are listed in the header file "lang.h" which comes with
  1050. ! \fBRemind\fR.  OS/2 support was provided initially by Darrel
  1051. ! Hankerson; more complete OS/2 support was done by Russ Herman.
  1052.   .SH BUGS
  1053.   .PP
  1054.   There's no good reason why read-only system variables are not
  1055. ***************
  1056. *** 3321,3327 ****
  1057.   .PP
  1058.   The UTC functions are not reliable under MS-DOS.
  1059.   .PP
  1060. ! The MS-DOS and OS/2 versions of \fBRemind\fR do not support queuing or timed
  1061.   activation of reminders.
  1062.   .PP
  1063.   \fBRemind\fR has some built-in limits on total line length,
  1064. --- 3513,3519 ----
  1065.   .PP
  1066.   The UTC functions are not reliable under MS-DOS.
  1067.   .PP
  1068. ! The MS-DOS version of \fBRemind\fR does not support queuing or timed
  1069.   activation of reminders.
  1070.   .PP
  1071.   \fBRemind\fR has some built-in limits on total line length,
  1072. *** ../prev/sort.c    Tue Aug 31 16:28:20 1993
  1073. --- ./sort.c    Tue Oct 19 11:19:14 1993
  1074. ***************
  1075. *** 33,44 ****
  1076.      int trigdate;
  1077.      int trigtime;
  1078.      int typ;
  1079.   } Sortrem;
  1080.   
  1081.   /* The sorted reminder queue */
  1082.   static Sortrem *SortedQueue = (Sortrem *) NULL;
  1083.   
  1084. ! PRIVATE Sortrem *MakeSortRem ARGS ((int jul, int tim, char *body, int typ));
  1085.   PRIVATE void IssueSortBanner ARGS ((int jul));
  1086.   
  1087.   /***************************************************************/
  1088. --- 33,45 ----
  1089.      int trigdate;
  1090.      int trigtime;
  1091.      int typ;
  1092. +    int priority;
  1093.   } Sortrem;
  1094.   
  1095.   /* The sorted reminder queue */
  1096.   static Sortrem *SortedQueue = (Sortrem *) NULL;
  1097.   
  1098. ! PRIVATE Sortrem *MakeSortRem ARGS ((int jul, int tim, char *body, int typ, int prio));
  1099.   PRIVATE void IssueSortBanner ARGS ((int jul));
  1100.   
  1101.   /***************************************************************/
  1102. ***************
  1103. *** 49,60 ****
  1104.   /*                                                             */
  1105.   /***************************************************************/
  1106.   #ifdef HAVE_PROTOS
  1107. ! PRIVATE Sortrem *MakeSortRem(int jul, int tim, char *body, int typ)
  1108.   #else
  1109. ! static Sortrem *MakeSortRem(jul, tim, body, typ)
  1110.   int jul, tim;
  1111.   char *body;
  1112. ! int typ;
  1113.   #endif
  1114.   {
  1115.      Sortrem *new = NEW(Sortrem);
  1116. --- 50,61 ----
  1117.   /*                                                             */
  1118.   /***************************************************************/
  1119.   #ifdef HAVE_PROTOS
  1120. ! PRIVATE Sortrem *MakeSortRem(int jul, int tim, char *body, int typ, int prio)
  1121.   #else
  1122. ! static Sortrem *MakeSortRem(jul, tim, body, typ, prio)
  1123.   int jul, tim;
  1124.   char *body;
  1125. ! int typ, prio;
  1126.   #endif
  1127.   {
  1128.      Sortrem *new = NEW(Sortrem);
  1129. ***************
  1130. *** 69,74 ****
  1131. --- 70,76 ----
  1132.      new->trigdate = jul;
  1133.      new->trigtime = tim;
  1134.      new->typ = typ;
  1135. +    new->priority = prio;
  1136.      new->next = NULL;
  1137.      return new;
  1138.   }
  1139. ***************
  1140. *** 81,96 ****
  1141.   /*                                                             */
  1142.   /***************************************************************/
  1143.   #ifdef HAVE_PROTOS
  1144. ! PUBLIC int InsertIntoSortBuffer(int jul, int tim, char *body, int typ)
  1145.   #else
  1146. ! int InsertIntoSortBuffer(jul, tim, body, typ)
  1147.   int jul;
  1148.   int tim;
  1149.   char *body;
  1150. ! int typ;
  1151.   #endif
  1152.   {
  1153. !    Sortrem *new = MakeSortRem(jul, tim, body, typ);
  1154.      Sortrem *cur = SortedQueue, *prev = NULL;
  1155.      int ShouldGoAfter;
  1156.   
  1157. --- 83,98 ----
  1158.   /*                                                             */
  1159.   /***************************************************************/
  1160.   #ifdef HAVE_PROTOS
  1161. ! PUBLIC int InsertIntoSortBuffer(int jul, int tim, char *body, int typ, int prio)
  1162.   #else
  1163. ! int InsertIntoSortBuffer(jul, tim, body, typ, prio)
  1164.   int jul;
  1165.   int tim;
  1166.   char *body;
  1167. ! int typ, prio;
  1168.   #endif
  1169.   {
  1170. !    Sortrem *new = MakeSortRem(jul, tim, body, typ, prio);
  1171.      Sortrem *cur = SortedQueue, *prev = NULL;
  1172.      int ShouldGoAfter;
  1173.   
  1174. ***************
  1175. *** 99,104 ****
  1176. --- 101,107 ----
  1177.         IssueSortedReminders();
  1178.         SortByDate = 0;
  1179.         SortByTime = 0;
  1180. +       SortByPrio = 0;
  1181.         return E_NO_MEM;
  1182.      }
  1183.   
  1184. ***************
  1185. *** 108,126 ****
  1186.         return OK;
  1187.      }
  1188.      while (cur) {
  1189. !       if (cur->trigdate == new->trigdate) {
  1190. !          ShouldGoAfter =
  1191. !         (SortByTime == SORT_ASCEND) ?
  1192. !            (new->trigtime >= cur->trigtime) :
  1193. !            ((new->trigtime == NO_TIME) || (new->trigtime <= cur->trigtime));
  1194. !       } else {
  1195. !          ShouldGoAfter =
  1196. !         (SortByDate == SORT_ASCEND) ?
  1197. !            (new->trigdate >= cur->trigdate) :
  1198. !            (new->trigdate <= cur->trigdate);
  1199. !       }
  1200. !       if (ShouldGoAfter) {
  1201.            prev = cur;
  1202.        cur = cur->next;
  1203.         } else {
  1204. --- 111,121 ----
  1205.         return OK;
  1206.      }
  1207.      while (cur) {
  1208. !       ShouldGoAfter = CompareRems(new->trigdate, new->trigtime, new->priority,
  1209. !               cur->trigdate, cur->trigtime, cur->priority,
  1210. !               SortByDate, SortByTime, SortByPrio);
  1211. !               
  1212. !       if (ShouldGoAfter <= 0) {
  1213.            prev = cur;
  1214.        cur = cur->next;
  1215.         } else {
  1216. ***************
  1217. *** 160,183 ****
  1218.   
  1219.      while (cur) {
  1220.         next = cur->next;
  1221. !       if (cur->typ == MSG_TYPE || cur->typ == MSF_TYPE) {
  1222. !     if (!MsgCommand) {
  1223. !             if (cur->trigdate != olddate) {
  1224. !                IssueSortBanner(cur->trigdate);
  1225. !            olddate = cur->trigdate;
  1226.               }
  1227. !         if (cur->typ == MSG_TYPE)
  1228. !                printf("%s\n", cur->text);
  1229. !             else
  1230. !            FillParagraph(cur->text);
  1231. !          } else {
  1232. !             char buf[LINELEN+TOKSIZE];
  1233. !             sprintf(buf, MsgCommand, cur->text);
  1234. !         system(buf);
  1235. !          }
  1236. !       } else { /* Must be RUN_TYPE */
  1237. !          system(cur->text);
  1238.         }
  1239.         free(cur->text);
  1240.         free(cur);
  1241.         cur = next;
  1242. --- 155,194 ----
  1243.   
  1244.      while (cur) {
  1245.         next = cur->next;
  1246. !       switch(cur->typ) {
  1247. !          case MSG_TYPE:
  1248. !         if (MsgCommand) {
  1249. !            char buf[LINELEN+TOKSIZE];
  1250. !            sprintf(buf, MsgCommand, cur->text);
  1251. !            system(buf);
  1252. !             } else {
  1253. !            if (cur->trigdate != olddate) {
  1254. !               IssueSortBanner(cur->trigdate);
  1255. !           olddate = cur->trigdate;
  1256. !                }
  1257. ! #ifdef __OS2__
  1258. !                PutlPopUp(cur->text);
  1259. ! #else
  1260. !                printf("%s", cur->text);
  1261. ! #endif
  1262.               }
  1263. !         break;
  1264. !      case MSF_TYPE:
  1265. ! #ifdef __OS2__
  1266. !             StartPopUp();
  1267. ! #endif
  1268. !         FillParagraph(cur->text);
  1269. ! #ifdef __OS2__
  1270. !             EndPopUp();
  1271. ! #endif
  1272. !         break;
  1273. !      case RUN_TYPE:
  1274. !         system(cur->text);
  1275. !         break;
  1276.         }
  1277.         free(cur->text);
  1278.         free(cur);
  1279.         cur = next;
  1280. ***************
  1281. *** 214,217 ****
  1282. --- 225,267 ----
  1283.      if (!DoSubstFromString(v.v.str, SubstBuffer, jul, NO_TIME))
  1284.         if (*SubstBuffer) printf("%s\n", SubstBuffer);
  1285.      DestroyValue(&v);
  1286. + }
  1287. + /***************************************************************/
  1288. + /*                                                             */
  1289. + /*  CompareRems                                                */
  1290. + /*                                                             */
  1291. + /*  Compare two reminders for sorting.  Return 0 if they       */
  1292. + /*  compare equal; 1 if rem2 should come after rem1, -1 if     */
  1293. + /*  rem1 should come after rem2.  bydate and bytime control    */
  1294. + /*  sorting direction by date and time, resp.                  */
  1295. + /*                                                             */
  1296. + /***************************************************************/
  1297. + #ifdef HAVE_PROTOS
  1298. + PUBLIC int CompareRems(int dat1, int tim1, int prio1,
  1299. +                        int dat2, int tim2, int prio2,
  1300. +                int bydate, int bytime, int byprio)
  1301. + #else
  1302. + int CompareRems(dat1, tim1, prio1, dat2, tim2, prio2, bydate, bytime, byprio)
  1303. + int dat1, tim1, prio1, dat2, tim2, prio2, bydate, bytime, byprio;
  1304. + #endif
  1305. + {
  1306. +    int dafter, tafter, pafter;
  1307. +    dafter = (bydate != SORT_DESCEND) ? 1 : -1;
  1308. +    tafter = (bytime != SORT_DESCEND) ? 1 : -1;
  1309. +    pafter = (byprio != SORT_DESCEND) ? 1 : -1;
  1310. +    if (dat1 < dat2) return dafter;
  1311. +    if (dat1 > dat2) return -dafter;
  1312. +    if (tim1 == NO_TIME && tim2 != NO_TIME) return -1;
  1313. +    if (tim1 != NO_TIME && tim2 == NO_TIME) return 1;
  1314. +    if (tim1 < tim2) return tafter;
  1315. +    if (tim1 > tim2) return -tafter;
  1316. +    if (prio1 < prio2) return pafter;
  1317. +    if (prio1 > prio2) return -pafter;
  1318. +    return 0;
  1319.   }
  1320. *** ../prev/test.cmp    Tue Aug 31 13:22:46 1993
  1321. --- ./test.cmp    Tue Oct 12 16:22:53 1993
  1322. ***************
  1323. *** 631,637 ****
  1324.   "a05" + "6" => "a056"
  1325.   value("a056") => "SDFJHSDF KSJDFH KJSDFH KSJDFH"
  1326.   set a058 version()
  1327. ! version() => "03.00.09"
  1328.   set a059 wkday(today())
  1329.   today() => 1991/02/16
  1330.   wkday(1991/02/16) => "Saturday"
  1331. --- 631,637 ----
  1332.   "a05" + "6" => "a056"
  1333.   value("a056") => "SDFJHSDF KSJDFH KJSDFH KSJDFH"
  1334.   set a058 version()
  1335. ! version() => "03.00.10"
  1336.   set a059 wkday(today())
  1337.   today() => 1991/02/16
  1338.   wkday(1991/02/16) => "Saturday"
  1339. ***************
  1340. *** 772,778 ****
  1341.           a048  "foo"
  1342.           a067  "INT"
  1343.           a039  "February"
  1344. !         a058  "03.00.09"
  1345.           a077  "1992 92
  1346.   "
  1347.           a049  21
  1348. --- 772,778 ----
  1349.           a048  "foo"
  1350.           a067  "INT"
  1351.           a039  "February"
  1352. !         a058  "03.00.10"
  1353.           a077  "1992 92
  1354.   "
  1355.           a049  21
  1356. *** ../prev/token.c    Fri Sep  3 11:50:53 1993
  1357. --- ./token.c    Wed Oct 20 11:45:09 1993
  1358. ***************
  1359. *** 11,16 ****
  1360. --- 11,17 ----
  1361.   /***************************************************************/
  1362.   #include "config.h"
  1363.   #include <stdio.h>
  1364. + #include <string.h>
  1365.   #include <ctype.h>
  1366.   #ifdef HAVE_STDLIB_H
  1367.   #include <stdlib.h>
  1368. ***************
  1369. *** 77,82 ****
  1370. --- 78,84 ----
  1371.      { "once",         3,     T_Once,        0 },
  1372.      { "pop-omit-context", 3,    T_Pop,        0 },
  1373.      { "preserve",        8,      T_Preserve,     0 },
  1374. +    { "priority",    8,    T_Priority,    0 },
  1375.      { "ps",         2,     T_RemType,     PS_TYPE },
  1376.      { "psfile",         6,     T_RemType,     PSF_TYPE },
  1377.      { "push-omit-context", 4,     T_Push,        0 },
  1378. ***************
  1379. *** 85,90 ****
  1380. --- 87,93 ----
  1381.      { "satisfy",        7,    T_RemType,      SAT_TYPE },
  1382.      { "saturday",    3,    T_WkDay,    5 },
  1383.      { "scanfrom",    4,    T_Scanfrom,    0 },
  1384. +    { "sched",        5,    T_Sched,    0 },
  1385.      { "september",     3,     T_Month,     8 },
  1386.      { "set",        3,    T_Set,        0 },
  1387.      { "skip",         3,     T_Skip,     SKIP_SKIP },
  1388. *** ../prev/types.h    Fri Sep  3 11:50:48 1993
  1389. --- ./types.h    Wed Oct 20 11:50:55 1993
  1390. ***************
  1391. *** 52,57 ****
  1392. --- 52,59 ----
  1393.      int typ;
  1394.      int once;
  1395.      int scanfrom;
  1396. +    int priority;
  1397. +    char sched[VAR_NAME_LEN+1];  /* Scheduling function */
  1398.   } Trigger;
  1399.   
  1400.   /* A time trigger */
  1401. ***************
  1402. *** 93,98 ****
  1403. --- 95,102 ----
  1404.   
  1405.   #define NO_TIME 1500 /* >1440, ie > than the largest possible legal time */
  1406.   
  1407. + #define NO_PRIORITY 5000 /* Default priority is midway between 0 and 9999 */
  1408.   #define NO_TYPE  0
  1409.   #define MSG_TYPE 1
  1410.   #define RUN_TYPE 2
  1411. ***************
  1412. *** 127,133 ****
  1413.     T_Debug,
  1414.     T_Dumpvars,
  1415.     T_Scanfrom,
  1416. !   T_Flush
  1417.   };
  1418.   
  1419.   /* The structure of a token */
  1420. --- 131,139 ----
  1421.     T_Debug,
  1422.     T_Dumpvars,
  1423.     T_Scanfrom,
  1424. !   T_Flush,
  1425. !   T_Priority,
  1426. !   T_Sched
  1427.   };
  1428.   
  1429.   /* The structure of a token */
  1430. ***************
  1431. *** 162,166 ****
  1432.   #define SC_NOTIME 2   /* Do not display time in SC format. */
  1433.   
  1434.   /* Flags for sorting */
  1435. ! #define SORT_ASCEND 1
  1436.   #define SORT_DESCEND 2
  1437. --- 168,173 ----
  1438.   #define SC_NOTIME 2   /* Do not display time in SC format. */
  1439.   
  1440.   /* Flags for sorting */
  1441. ! #define SORT_NONE    0
  1442. ! #define SORT_ASCEND  1
  1443.   #define SORT_DESCEND 2
  1444. *** ../prev/var.c    Tue Sep 28 16:16:07 1993
  1445. --- ./var.c    Thu Oct 14 10:21:45 1993
  1446. ***************
  1447. *** 474,479 ****
  1448. --- 474,482 ----
  1449.      {   "PSCal",          0,    INT_TYPE,    &PsCal,        0,    0   },
  1450.      {   "RunOff",      0,    INT_TYPE,    &RunDisabled,    0,    0   },
  1451.      {   "SimpleCal",      0,    INT_TYPE,    &DoSimpleCalendar,    0,  0 },
  1452. +    {   "SortByDate",      0,    INT_TYPE,    &SortByDate,    0,    0},
  1453. +    {   "SortByPrio",      0,    INT_TYPE,    &SortByPrio,    0,    0},
  1454. +    {   "SortByTime",      0,    INT_TYPE,    &SortByTime,    0,    0},
  1455.      {   "SubsIndent",      1,    INT_TYPE,    &SubsIndent,    0,    132}
  1456.   };
  1457.   
  1458.