home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / net / calendar.c < prev    next >
Internet Message Format  |  1986-03-17  |  21KB

  1. From gregg@okstate.UUCP Wed Mar 12 03:23:00 1986
  2. Path: seismo!gatech!akgua!whuxlm!whuxl!houxm!ihnp4!inuxc!pur-ee!uiucdcs!okstate.UUCP!gregg
  3. From: gregg@okstate.UUCP
  4. Newsgroups: net.sources
  5. Subject: New CALENDAR(1) in C with extension
  6. Message-ID: <5200029@okstate.UUCP>
  7. Date: 12 Mar 86 08:23:00 GMT
  8. Lines: 763
  9. Nf-ID: #N:okstate.UUCP:5200029:000:20661
  10. Nf-From: okstate.UUCP!gregg    Mar 12 02:23:00 1986
  11. Posted: Wed Mar 12 03:23:00 1986
  12.  
  13.  
  14.  
  15.     This note contains a Shell archive (Bourne style) for the source
  16. and documentation for a C version of the CALENDAR(1) program.  Unpack
  17. the archive, and read the README file.  The program should MAKE(1) on
  18. a System 5 machine without changes.  This particular version is upward
  19. compatible with the standard CALENDAR(1), but also includes many
  20. extensions that allow far more versatile calendars.  Supported notations
  21. allow weekdays, as well as months to be used as the soul indentifier.
  22. Read the README file, and the MAN(1) page for more details.
  23.  
  24.     Please send me bug reports and complaints to me.  The C code that
  25. checks dates is very much simplified.  This helps to speed the search,
  26. as well as open some doors for new formats.
  27.  
  28.  
  29. Gregg Wonderly
  30. Department of Computing and Information Sciences
  31. Oklahoma State University
  32.  
  33. UUCP: {cbosgd, ea, ihnp4, isucs1, mcvax, uokvax}!okstate!gregg
  34. ARPA:  gregg%okstate.csnet@csnet-relay.arpa  
  35.  
  36. -------------------------    CUT   HERE    ------------------------------
  37. echo x - README
  38. sed '1,$s/^X//' <<\!FUNKY!STUFF! > README
  39. XThis is a substitute version of CALENDAR(1).  It is upward compatible
  40. Xwith the standard UNIX version, but has several extensions, and is
  41. Xmuch faster, as it does not envoke EGREP(1).  The executable generated
  42. Xby compiling calendar.c (see the makefile) is envoked for each user.
  43. XIt should be installed in /usr/lib/calendar, or the shell script
  44. Xwill need to be changed.  If you have STRCHR(3) instead of V7's INDEX(3),
  45. Xor you have some other function for finding a character in a string,
  46. Xchange/remove the #define in calendar.c.  strchr() is used in the
  47. XC code.  If you run calendar SETUSERID to ROOT, then change the man page
  48. Xto reflect that fact that world read access is not needed.
  49. X
  50. XYou should be able to just type "make install" and get a proper install.
  51. X
  52. XSend complaints/bugs to:
  53. X
  54. XGregg Wonderly
  55. XDepartment of Computing and Information Sciences
  56. XOklahoma State University
  57. X
  58. XUUCP: {cbosgd, ea, ihnp4, isucs1, mcvax, uokvax}!okstate!gregg
  59. XARPA:  gregg@A.CS.OKSTATE.EDU
  60. !FUNKY!STUFF!
  61. echo x - calendar.1
  62. sed '1,$s/^X//' <<\!FUNKY!STUFF! > calendar.1
  63. X.TH CALENDAR 1  "Oklahoma State University"
  64. X.SH NAME
  65. Xcalendar \- reminder service
  66. X.SH SYNOPSIS
  67. X.B calendar
  68. X[ \- ]
  69. X.SH DESCRIPTION
  70. X.I Calendar 
  71. Xconsults the file `calendar' in the user's home directory
  72. Xand prints out lines that contain today's,
  73. Xtomorrow's, or a proper future date at the beginning of the line.
  74. XMost reasonable month-day dates such as `Dec. 7,'
  75. X`december 7,' `12/7,' etc., are recognized, but not
  76. X`7 December' or `7/12'.
  77. XOn weekends `tomorrow' extends through Monday.
  78. X.sp
  79. X.I Calendar
  80. Xalso supports months and days of the week by themselves.  This
  81. Xallows you to specify things on a weekly or monthly basis.
  82. XThe format for weekday names is the same
  83. Xas that for month names; Mon., monday, tues, tue, wed, etc.
  84. XThe month may be specified either by name, or by number.  The weekday
  85. Xwill only be recognized by name.
  86. X.PP
  87. X.SH EXTENDED NOTIFICATION
  88. XIf you wish to have
  89. X.I extended 
  90. Xnotification of a previous or upcoming
  91. Xevent,
  92. X.I calendar
  93. Xsupports a notation that extends a date by a week.
  94. X.PP
  95. XIf "*w" is appended directly to the week day, I.E. 12/7*w, then
  96. Xyou will be sent a reminder every day beginning approximately
  97. X(depending on the weekend) 7 days prior to the date.
  98. X.PP
  99. XIf "*W" (note the significance of case "w" or "W") is appended
  100. Xto the week day as in the above example, than you will be notified
  101. Xbeginning one day before and extending up to 10 days after.
  102. X.PP
  103. XIf you wish to have both of these features, I.E. a 2 week window
  104. Xaround the given date, you can append "*Ww" or "*wW" to the
  105. Xweek day.
  106. X.SH EXTENDED MESSAGES
  107. X.I Calendar
  108. Xwill recognize lines with leading blanks or tabs as extensions
  109. Xto a line with a matched (the date given is "today") date.  This allows
  110. Xcomments longer than one line to be present for any given date.  Below
  111. Xis an example date specification.
  112. X.sp
  113. XWednesday
  114. X.br
  115. X    Backups...
  116. X.br
  117. X    Check all printers for paper, ribbons, etc.
  118. X.sp
  119. X.SH YOUR CALENDAR OR EVERYBODY'S
  120. XWhen an argument is present,
  121. X.I calendar
  122. Xdoes its job for every user who has a file `calendar' in their
  123. Xlogin directory and sends them any positive results by
  124. X.IR mail (1).
  125. XNormally this is done daily in the wee hours under control of
  126. X.IR cron (8).
  127. X.sp 2
  128. X.SH SAMPLE FILE
  129. X.nf
  130. XJuly            Get the budget ready for the new fiscal year
  131. X.br
  132. XMonday          Check all printers for paper...
  133. X.br
  134. X                Check MMDF, MDQS, and UUCP
  135. X.br
  136. XWednesday       Backups are tonight...
  137. X.br
  138. XFriday          Lets go party....
  139. X.br
  140. X6/17            John's b'day
  141. X.br
  142. X                Mark's b'day
  143. X.br
  144. X.fi
  145. X.SH FILES
  146. X$HOME/calendar        The users' calendar, $HOME is taken
  147. X.br
  148. X                      from /etc/passwd
  149. X.br
  150. X/usr/lib/calendar     processes each users' `calendar' file.
  151. X.br
  152. X/etc/passwd           Source of home directories.
  153. X.br
  154. X/tmp/Cal*             Output data file used to assure that
  155. X.br
  156. X                      there are no null messages.
  157. X.br
  158. Xsed, mail             Subprocesses
  159. X.SH "SEE ALSO"
  160. Xat(1), cron(8), mail(1)
  161. X.SH BUGS
  162. XIn general, your calendar must be readable by the public.  See your system
  163. Xadministrator for the specifics.
  164. X.I Calendar's
  165. Xextended idea of `tomorrow' doesn't account for holidays.
  166. XLines containing erroneous data are silently ignored.
  167. X.SH "CREDITS TO"
  168. XGregg Wonderly
  169. X.br
  170. XOklahoma State University
  171. !FUNKY!STUFF!
  172. echo x - calendar.c
  173. sed '1,$s/^X//' <<\!FUNKY!STUFF! > calendar.c
  174. X/****************************************************************************
  175. X
  176. X            F A S T    C A L E N D A R
  177. X
  178. X        This C program is a faster more general version of the
  179. X    standard UNIX utility CALENDAR(1).  It recognizes the following
  180. X    formats for dates.
  181. X
  182. X        numeric/numeric                     As is 1/12, 01/12, 12/1, ...
  183. X
  184. X        3-charmonth[any chars] numeric      As in January 12, Jan. 12,
  185. X                                            jan. 12, JAN. 12, ...
  186. X
  187. X        3-charweekday[any chars]            As in Friday, Monday, MON.,
  188. X                                            mon., tue, wed, ...
  189. X
  190. X        numeric month                       A month from 1 to 12 as in
  191. X                                            1, 2, 04, 12, ...
  192. X
  193. X    Any lines, following a line that is matched, that have "whitespace"
  194. X    in the first column will be printed along with the matched line.
  195. X
  196. X****************************************************************************/
  197. X
  198. X#include    <stdio.h>
  199. X#include    <ctype.h>
  200. X#include    <sys/types.h>
  201. X#include    <time.h>
  202. X#include    <pwd.h>
  203. X
  204. X/*  Number of seconds in a day.  */
  205. X
  206. X#define     DAY     (24*3600)
  207. X
  208. X/*  Remove this for SYS5 machines, or others with strchr instead of index.  */
  209. X
  210. X/*  #define     strchr  index   */
  211. X
  212. X/*  Global input line.  */
  213. X
  214. Xchar datebuf[300], *getdate();
  215. X
  216. Xmain (argc, argv)
  217. X    int argc;
  218. X    char **argv;
  219. X{
  220. X    register char *s;
  221. X    char success;
  222. X    struct passwd *passwd, *getpwuid();
  223. X    register char file[200];
  224. X    register FILE *fp;
  225. X    register int i;
  226. X
  227. X    /*
  228. X            Use file passed as an argument if it is there,
  229. X        otherwise use file in home directory.
  230. X    */
  231. X
  232. X    if (argc <= 1) {
  233. X        if ((passwd = getpwuid (getuid())) == (struct passwd *)0) {
  234. X            perror ("Hi Dennis, the compiler is still broke\n");
  235. X            exit(1);
  236. X        }
  237. X        if (passwd -> pw_dir != (char *)0)
  238. X            strcpy (file, passwd -> pw_dir);
  239. X        strcat (file, "/calendar");
  240. X    } else {
  241. X        strcpy (file, argv[1]);
  242. X    }
  243. X
  244. X    /*  Open the input file.  */
  245. X
  246. X    if ((fp = fopen (file, "r")) == NULL) {
  247. X        perror (file);
  248. X        exit (1);
  249. X    }
  250. X    
  251. X    /*  Initially, no success.  */
  252. X
  253. X    success = 0;
  254. X
  255. X    /*  Loop till EOF is encountered.  */
  256. X
  257. X    while (s = getdate(fp, &success)) {
  258. X
  259. X        /*  Check date for "NOW"  */
  260. X
  261. X        if (isnow (datebuf)) {
  262. X
  263. X            /*  Print it, it is valid.  */
  264. X
  265. X            printf(s);
  266. X        } else {
  267. X
  268. X            /* Reset the "print lines with leading blanks" flag. */
  269. X
  270. X            success = 0;
  271. X        }
  272. X    }
  273. X
  274. X    /*  Close up and exit.  */
  275. X
  276. X    fclose (fp);
  277. X    exit (0);
  278. X}
  279. X
  280. X/*
  281. X        Check the input line, and get only the lines without leading
  282. X    "whitespace".  Conditionally print those lines with leading blanks,
  283. X    based on the "success" flag.
  284. X*/
  285. X
  286. Xchar *getdate(fp, success)
  287. X    char *success;
  288. X    register FILE *fp;
  289. X{
  290. X    register int c;
  291. X    static char inbuf[300];
  292. X    register char *t, *s;
  293. X
  294. X    t = inbuf;
  295. X    s = datebuf;
  296. X    
  297. X    /*  Skip leading space.  */
  298. X
  299. X    while ((c = getc(fp)) <= ' ' && c != EOF) {
  300. X        ungetc(c, fp);
  301. X        fgets (inbuf, 300, fp);
  302. X
  303. X        /*  Print the line if we previously printed a match.  */
  304. X
  305. X        if (*success)
  306. X            printf (inbuf);
  307. X    }
  308. X
  309. X    /*  Assume success for now.  */
  310. X
  311. X    *success = 1;
  312. X
  313. X    /*  Return EOF if we are there.  */
  314. X
  315. X    if (c == EOF)
  316. X        return ((char *)0);
  317. X
  318. X    /*  Unget the character.  */
  319. X
  320. X    ungetc (c, fp);
  321. X
  322. X    /*  Get the input line.  */
  323. X
  324. X    fgets (t, 300, fp);
  325. X
  326. X    /*  Make a copy of it.  */
  327. X
  328. X    strcpy (s, t);
  329. X
  330. X    return (inbuf);
  331. X}
  332. X
  333. X/*  Month definitions.  */
  334. X
  335. Xchar *months[] = {
  336. X    "JAN", "FEB", "MAR",
  337. X    "APR", "MAY", "JUN",
  338. X    "JUL", "AUG", "SEP",
  339. X    "OCT", "NOV", "DEC"
  340. X};
  341. X
  342. X/*  Weekday definitions.  */
  343. X
  344. Xchar *weekdays[] = {
  345. X    "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"
  346. X};
  347. X
  348. X/*  See if the passed string has a "NOW" date in it.  */
  349. X
  350. Xisnow (datebuf)
  351. X    char *datebuf;
  352. X{
  353. X    char *s, *t;
  354. X    long l;
  355. X    register int before = 0, after = 0, i, offset, month, day;
  356. X    register struct tm *tmptr;
  357. X    long timenow;
  358. X
  359. X    /*  Get the current time.  */
  360. X
  361. X    time (&timenow);
  362. X    tmptr = localtime (&timenow);
  363. X
  364. X    /*  Is the first character a digit in a Month?  */
  365. X
  366. X    t = datebuf;
  367. X    if (isdigit (*t) && (month = getnum (&t) - 1) >= 0 && month < 12) {
  368. X
  369. X        /*  Find the separating slash.  */
  370. X
  371. X        if (s = (char *) strchr (t, '/'))
  372. X            t = s + 1;
  373. X        else if (tmptr -> tm_mon == month)
  374. X            return (1);
  375. X        else
  376. X            return (0);
  377. X
  378. X    /*  Is the string a month name?  */
  379. X
  380. X    } else if ((month = ischmonth (t)) >= 0) {
  381. X
  382. X        /*  Skip till while space.  */
  383. X
  384. X        while (!isspace (*t) && *t)
  385. X            ++t;
  386. X
  387. X        /*  Skip to first NON-white space.  */
  388. X
  389. X        while (isspace (*t) && *t)
  390. X            ++t;
  391. X
  392. X    /*  Not a month, so try a DAY as in Friday, Saturday, etc...  */
  393. X
  394. X    } else if ((day = ischday (datebuf)) >= 0) {
  395. X
  396. X        /*  Is this today?  */
  397. X
  398. X        if (day == tmptr -> tm_wday || ((day + 6)%7) == tmptr -> tm_wday)
  399. X            return (1);
  400. X        else
  401. X            return (0);
  402. X    } else {
  403. X
  404. X        /*  Fail to recognize any other data as a valid date.  */
  405. X
  406. X        return (0);
  407. X    }
  408. X
  409. X    /*  Is there only what looks to be a month?  If so, then OK.  */
  410. X
  411. X    if (!*t || !isdigit (*t)) {
  412. X
  413. X        /*  Is it this month?  */
  414. X
  415. X        if (tmptr -> tm_mon == month)
  416. X            return (1);
  417. X
  418. X        return (0);
  419. X    }
  420. X
  421. X    /*  Calculate the value of the day.  */
  422. X
  423. X    day = getnum (&t);
  424. X
  425. X    /*  Check for *w or *W extended week specifiers.  */
  426. X
  427. X    if (*t == '*') {
  428. X        if (t[1] == 'w')
  429. X            ++before;
  430. X        if (t[1] == 'W')
  431. X            ++after;
  432. X        if (t[2] == 'W')
  433. X            ++after;
  434. X        if (t[2] == 'w')
  435. X            ++before;
  436. X    }
  437. X            
  438. X    /*  Set weekend offset.  */
  439. X
  440. X    offset = 1;
  441. X
  442. X    /*  Get offset based on the weekend.  */
  443. X
  444. X    switch (tmptr -> tm_wday) {
  445. X        case 5:
  446. X            ++offset;
  447. X
  448. X        case 6:
  449. X            ++offset;
  450. X
  451. X        default:
  452. X            ++offset;
  453. X    }
  454. X
  455. X    /*  Step through all dates by DAY.  */
  456. X
  457. X    l = timenow - (after * 7 * DAY);
  458. X
  459. X    while (l < timenow + (before * 7 * DAY) + (offset * DAY)) {
  460. X        if (istoday (l, month, day))
  461. X            return (1);
  462. X
  463. X        l += DAY;
  464. X    }
  465. X
  466. X    /*  Return failure.  */
  467. X
  468. X    return (0);
  469. X}
  470. X    
  471. X/*
  472. X        Check if the string s is a DAY of the week as in monday, tues,
  473. X    wed, THU., or any derivative thereof.
  474. X*/
  475. X
  476. Xischday (s)
  477. X    register char *s;
  478. X{
  479. X    register char *tt;
  480. X    register int i, found = 0, c;
  481. X    register char t[30];
  482. X
  483. X    /*  Copy the input, and capitalize it.  */
  484. X
  485. X    for (tt = t, i=0; isalpha(*s) && i < 28; ++i)
  486. X        *tt++ = islower (c = *s++) ? toupper (c) : c;
  487. X
  488. X    *tt = '\0';
  489. X
  490. X    /*  Search the list of valid day names for the string.  */
  491. X
  492. X    for (i = 0; i < 7; ++i) {
  493. X        if (strncmp (t, weekdays[i], 3) == 0) {
  494. X            found++;
  495. X            break;
  496. X        }
  497. X    }
  498. X
  499. X    /*  Return the numeric equivalent if we found it.  */
  500. X
  501. X    if (found)
  502. X        return (i);
  503. X
  504. X    /*  Return invalid day name.  */
  505. X
  506. X    return (-1);
  507. X}
  508. X
  509. X/*
  510. X        Check if the string s is a valid derivative of the name of a
  511. X    month as in JUNE, jun, August, etc...
  512. X*/
  513. X
  514. Xischmonth (s)
  515. X    register char *s;
  516. X{
  517. X    register char *tt;
  518. X    register int i, found = 0, c;
  519. X    register char t[30];
  520. X
  521. X    /*  Copy and capitalize.  */
  522. X
  523. X    for (tt = t, i=0; isalpha(*s) && i < 28; ++i)
  524. X        *tt++ = islower (c = *s++) ? toupper (c) : c;
  525. X
  526. X    *tt = '\0';
  527. X
  528. X    /*  Look through the list for a match.  */
  529. X
  530. X    for (i = 0; i < 12; ++i) {
  531. X        if (strncmp (t, months[i], 3) == 0) {
  532. X            found++;
  533. X            break;
  534. X        }
  535. X    }
  536. X
  537. X    /*  Return the numeric equivalent if we found it.  */
  538. X
  539. X    if (found)
  540. X        return (i);
  541. X
  542. X    /*  Return faliure.  */
  543. X
  544. X    return (-1);
  545. X}
  546. X
  547. X/*
  548. X        Scan the string *t, and evaluate any integer contained there.
  549. X    It is assumed that at least 1 digit exists (**t).
  550. X*/
  551. X
  552. Xgetnum (t)
  553. X    char **t;
  554. X{
  555. X    register int i, c;
  556. X    register char *s;
  557. X
  558. X    i = 0;
  559. X
  560. X    /*  Get the starting address.  */
  561. X
  562. X    s = *t;
  563. X
  564. X    /*  Get the starting value from the first digit.  */
  565. X
  566. X    i = (c = *s++) - '0';
  567. X
  568. X    /*  Evaluate the rest of the digits (if any).  */
  569. X
  570. X    while (isdigit (c = *s++))
  571. X        i = i * 10 + (c - '0');
  572. X
  573. X    /*  Set the new address.  */
  574. X
  575. X    *t = --s;
  576. X
  577. X    /*  Return the value.  */
  578. X
  579. X    return (i);
  580. X}
  581. X
  582. X/*
  583. X    Return whether or not the time t corresponds to the month and day.
  584. X*/
  585. X
  586. Xistoday (t, month, day)
  587. X    long t;
  588. X    register int month, day;
  589. X{
  590. X    register struct tm *tm;
  591. X
  592. X    tm = localtime(&t);
  593. X
  594. X    return (tm -> tm_mon == month && tm -> tm_mday == day);
  595. X}
  596. !FUNKY!STUFF!
  597. echo x - calendar.doc
  598. sed '1,$s/^X//' <<\!FUNKY!STUFF! > calendar.doc
  599. X
  600. X
  601. X
  602. X     CCCCAAAALLLLEEEENNNNDDDDAAAARRRR((((1111))))   UUUUNNNNIIIIXXXX    5555....0000 ((((OOOOkkkkllllaaaahhhhoooommmmaaaa SSSSttttaaaatttteeee UUUUnnnniiiivvvveeeerrrrssssiiiittttyyyy))))       CCCCAAAALLLLEEEENNNNDDDDAAAARRRR((((1111))))
  603. X
  604. X
  605. X
  606. X     NNNNAAAAMMMMEEEE
  607. X      calendar - reminder service
  608. X
  609. X     SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  610. X      ccccaaaalllleeeennnnddddaaaarrrr [ - ]
  611. X
  612. X     DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  613. X      _C_a_l_e_n_d_a_r consults the    file `calendar'    in the user's home
  614. X      directory and    prints out lines that contain today's,
  615. X      tomorrow's, or a proper future date at the beginning of the
  616. X      line.     Most reasonable month-day dates such as `Dec. 7,'
  617. X      `december 7,'    `12/7,'    etc., are recognized, but not `7
  618. X      December' or `7/12'.    On weekends `tomorrow' extends through
  619. X      Monday.
  620. X
  621. X      _C_a_l_e_n_d_a_r also    supports months    and days of the    week by
  622. X      themselves.  This allows you to specify things on a weekly
  623. X      or monthly basis.  The format    for weekday names is the same
  624. X      as that for month names; Mon., monday, tues, tue, wed, etc.
  625. X      The month may    be specified either by name, or    by number.
  626. X      The weekday will only    be recognized by name.
  627. X
  628. X     EEEEXXXXTTTTEEEENNNNDDDDEEEEDDDD NNNNOOOOTTTTIIIIFFFFIIIICCCCAAAATTTTIIIIOOOONNNN
  629. X      If you wish to have _e_x_t_e_n_d_e_d notification of a previous or
  630. X      upcoming event, _c_a_l_e_n_d_a_r supports a notation that extends a
  631. X      date by a week.
  632. X
  633. X      If "*w" is appended directly to the week day,    I.E. 12/7*w,
  634. X      then you will    be sent    a reminder every day beginning
  635. X      approximately    (depending on the weekend) 7 days prior    to the
  636. X      date.
  637. X
  638. X      If "*W" (note    the significance of case "w" or    "W") is
  639. X      appended to the week day as in the above example, than you
  640. X      will be notified beginning one day before and    extending up
  641. X      to 10    days after.
  642. X
  643. X      If you wish to have both of these features, I.E. a 2 week
  644. X      window around    the given date,    you can    append "*Ww" or    "*wW"
  645. X      to the week day.
  646. X
  647. X     EEEEXXXXTTTTEEEENNNNDDDDEEEEDDDD MMMMEEEESSSSSSSSAAAAGGGGEEEESSSS
  648. X      _C_a_l_e_n_d_a_r will    recognize lines    with leading blanks or tabs as
  649. X      extensions to    a line with a matched (the date    given is
  650. X      "today") date.  This allows comments longer than one line to
  651. X      be present for any given date.  Below    is an example date
  652. X      specification.
  653. X
  654. X      Wednesday
  655. X           Backups...
  656. X           Check all printers for paper, ribbons, etc.
  657. X
  658. X
  659. X
  660. X
  661. X     Page 1                       (last mod. 3/12/86)
  662. X
  663. X
  664. X
  665. X
  666. X
  667. X
  668. X     CCCCAAAALLLLEEEENNNNDDDDAAAARRRR((((1111))))   UUUUNNNNIIIIXXXX    5555....0000 ((((OOOOkkkkllllaaaahhhhoooommmmaaaa SSSSttttaaaatttteeee UUUUnnnniiiivvvveeeerrrrssssiiiittttyyyy))))       CCCCAAAALLLLEEEENNNNDDDDAAAARRRR((((1111))))
  669. X
  670. X
  671. X
  672. X     YYYYOOOOUUUURRRR CCCCAAAALLLLEEEENNNNDDDDAAAARRRR OOOORRRR EEEEVVVVEEEERRRRYYYYBBBBOOOODDDDYYYY''''SSSS
  673. X      When an argument is present, _c_a_l_e_n_d_a_r    does its job for every
  674. X      user who has a file `calendar' in their login    directory and
  675. X      sends    them any positive results by _m_a_i_l(1).  Normally    this
  676. X      is done daily    in the wee hours under control of _c_r_o_n(8).
  677. X
  678. X
  679. X
  680. X     SSSSAAAAMMMMPPPPLLLLEEEE FFFFIIIILLLLEEEE
  681. X      July          Get the budget ready for the new fiscal year
  682. X      Monday      Check    all printers for paper...
  683. X              Check    MMDF, MDQS, and    UUCP
  684. X      Wednesday      Backups are tonight...
  685. X      Friday      Lets go party....
  686. X      6/17          John's b'day
  687. X              Mark's b'day
  688. X
  689. X     FFFFIIIILLLLEEEESSSS
  690. X      $HOME/calendar    The users' calendar, $HOME is taken
  691. X                from /etc/passwd
  692. X      /usr/lib/calendar    processes each users' `calendar' file.
  693. X      /etc/passwd        Source of home directories.
  694. X      /tmp/Cal*        Output data file used to assure    that
  695. X                there are no null messages.
  696. X      sed, mail        Subprocesses
  697. X
  698. X     SSSSEEEEEEEE AAAALLLLSSSSOOOO
  699. X      at(1), cron(8), mail(1)
  700. X
  701. X     BBBBUUUUGGGGSSSS
  702. X      In general, your calendar must be readable by    the public.
  703. X      See your system administrator    for the    specifics.  _C_a_l_e_n_d_a_r'_s
  704. X      extended idea    of `tomorrow' doesn't account for holidays.
  705. X      Lines    containing erroneous data are silently ignored.
  706. X
  707. X     CCCCRRRREEEEDDDDIIIITTTTSSSS TTTTOOOO
  708. X      Gregg    Wonderly
  709. X      Oklahoma State University
  710. X
  711. X
  712. X
  713. X
  714. X
  715. X
  716. X
  717. X
  718. X
  719. X
  720. X
  721. X
  722. X
  723. X
  724. X
  725. X
  726. X
  727. X     Page 2                       (last mod. 3/12/86)
  728. X
  729. X
  730. X
  731. !FUNKY!STUFF!
  732. echo x - calendar.sh
  733. sed '1,$s/^X//' <<\!FUNKY!STUFF! > calendar.sh
  734. X#
  735. X#  Replacement calendar program
  736. X#  By: Gregg Wonderly <gregg@okstate> on 01/24/86
  737. X
  738. XPATH=/bin:/usr/bin
  739. Xtmp=/tmp/Cal$$
  740. Xcal="calendar"
  741. Xlib=/usr/lib
  742. Xtrap "rm $tmp;exit" 1 2 13 15
  743. X
  744. Xcase $1 in
  745. X-)
  746. X    sed 's/\([^:]*\):.*:\(.*\):[^:]*$/dir=\2 login=\1/' /etc/passwd | \
  747. X    while read x
  748. X    do
  749. X        eval $x
  750. X        if test -r $dir/$cal; then
  751. X            $lib/calendar $dir/$cal >$tmp
  752. X            if test -s $tmp; then
  753. X                /bin/mail $login -f "Reminder Service" <$tmp >/dev/null 2>&1
  754. X            fi
  755. X            rm $tmp
  756. X        fi
  757. X    done;;
  758. X*)
  759. X    $lib/calendar;;
  760. Xesac
  761. !FUNKY!STUFF!
  762. echo x - makefile
  763. sed '1,$s/^X//' <<\!FUNKY!STUFF! > makefile
  764. XLIB=/usr/lib
  765. XBIN=/bin
  766. XCFLAGS=-i -O
  767. X
  768. Xcalendar:    calendar.c
  769. X    cc $(CFLAGS) calendar.c -o calendar
  770. X
  771. Xinstall:    calendar calendar.sh
  772. X    cp calendar.sh $(BIN)/calendar
  773. X    cp calendar $(LIB)/calendar
  774. X    chmod 511 $(LIB)/calendar $(BIN)/calendar
  775. !FUNKY!STUFF!
  776.  
  777.  
  778.