home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / x / volume16 / xalarm30 / part02 < prev    next >
Encoding:
Internet Message Format  |  1992-02-04  |  56.9 KB

  1. Path: uunet!zaphod.mps.ohio-state.edu!mips!msi!dcmartin
  2. From: S.Marshall@sequent.cc.hull.ac.uk (Simon Marshall)
  3. Newsgroups: comp.sources.x
  4. Subject: v16i037: Xalarm 3.02, Part02/03
  5. Message-ID: <1992Feb5.144747.20543@msi.com>
  6. Date: 5 Feb 92 14:47:47 GMT
  7. References: <csx-16i036-xalarm-3.02@uunet.UU.NET>
  8. Sender: dcmartin@msi.com (David C. Martin - Moderator)
  9. Organization: Molecular Simulations, Inc.
  10. Lines: 1956
  11. Approved: dcmartin@msi.com
  12. Originator: dcmartin@fascet
  13.  
  14. Submitted-by: Simon Marshall <S.Marshall@sequent.cc.hull.ac.uk>
  15. Posting-number: Volume 16, Issue 37
  16. Archive-name: xalarm-3.02/part02
  17.  
  18. # This is a shell archive.  Remove anything before this line, then feed it
  19. # into a shell via "sh file" or similar.  To overwrite existing files,
  20. # type "sh file -c".
  21. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  22. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  23. # If this archive is complete, you will see the following message at the end:
  24. #        "End of archive 2 (of 3)."
  25. # Contents:  ChangeLog INSTALL Imakefile Makefile.alt XAlarm.ad alarm.c
  26. #   config.1st fullpath man.man times.c warning.c when.c xalarm.h
  27. # Wrapped by dcmartin@fascet on Wed Feb  5 06:46:37 1992
  28. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  29. if test -f 'ChangeLog' -a "${1}" != "-c" ; then 
  30.   echo shar: Will not clobber existing file \"'ChangeLog'\"
  31. else
  32. echo shar: Extracting \"'ChangeLog'\" \(8795 characters\)
  33. sed "s/^X//" >'ChangeLog' <<'END_OF_FILE'
  34. XSat Feb  1 15:40:29 1992  Simon Marshall  (sm at olympus)
  35. X
  36. X    * Released patch 2.
  37. X
  38. XThu Jan 30 11:11:01 1992  Simon Marshall  (sm at olympus)
  39. X
  40. X    * Behaves properly during leap years.
  41. X
  42. X    * Fixed bug whereby dates are parsed wrongly if the number of days in
  43. X    the current month is more than the number of days in the month given.
  44. X
  45. X    * Better error messages with unrecognised dates.
  46. X
  47. XTue Jan 21 11:10:34 1992  Simon Marshall  (sm at olympus)
  48. X
  49. X    * Made config.1st try to find locations, instead of assuming a Sun.
  50. X    Forgot to include times.o as dependent on xalarm.h.  Non-existent
  51. X    function was declared.
  52. X
  53. X    * Fixed bug whereby changes in the dialog was silently accepted while
  54. X    changing other values.
  55. X
  56. X    * Resources properly label all quit buttons.
  57. X
  58. XMon Jan 20 10:08:55 1992  Simon Marshall  (sm at olympus)
  59. X
  60. X    * Released patch 1.
  61. X
  62. XWed Jan 15 14:58:08 1992  Simon Marshall  (sm at olympus)
  63. X
  64. X    * Input in the dialog popup properly is directed to the visible widget.
  65. X
  66. X    * Cleaned resources, man page & xmemo doesn't ask for confirmation.
  67. X
  68. XFri Jan  3 13:51:52 1992  Simon Marshall  (sm at olympus)
  69. X
  70. X    * Fixed Imakefile where blanks after ManSuffix were not stripped, from
  71. X    Jonathan I. Kamens.
  72. X
  73. XThu Dec 19 15:23:46 1991  Simon Marshall  (sm at olympus)
  74. X
  75. X    * Solved the auto-resize; just took the width resource out.
  76. X
  77. X    * Casted everything properly to shut up picky compilers.
  78. X
  79. XWed Dec 18 19:29:08 1991  Simon Marshall  (sm at olympus)
  80. X
  81. X    * Made all the windows proper transient shells as they should be.  If
  82. X    no geometry is given, the windows popup under the mouse pointer.
  83. X
  84. X    * Can no longer kill xalarm via the WM_DELETE_WINDOW protocol.  It has
  85. X    no effect with shells widgets.
  86. X
  87. XFri Dec  6 13:36:08 1991  Simon Marshall  (sm at olympus)
  88. X
  89. X    * Fixed bug in AppointmentIsToday() which under certain circumstances
  90. X    would parse times in files wrong or core dump.  Forgot to XtMalloc() in
  91. X    a couple of places.
  92. X
  93. XThu Dec  5 18:29:45 1991  Simon Marshall  (sm at olympus)
  94. X
  95. X    * Words from the alarm message can be incorporated in the warning
  96. X    popup.  From an idea by Evan Bigall.
  97. X
  98. XSun Dec  1 14:20:46 1991  Simon Marshall  (sm at olympus)
  99. X
  100. X    * Made resources control the cursor shapes; took gumby out of alarm.c.
  101. X
  102. XThu Oct 17 14:46:01 1991  Simon Marshall  (sm at olympus)
  103. X
  104. X    * Added justification for the Dialog widget label.  Still makes a
  105. X    widget bigger than need be though.
  106. X
  107. XSun Oct 13 17:40:00 1991  Simon Marshall  (sm at olympus)
  108. X
  109. X    * For the confirmation window, sorts the warning times into descending
  110. X    order, and takes the day of the week from WEEKDAYS rather than ctime(),
  111. X    in case a different language is being used.
  112. X
  113. XSat Oct  5 15:37:59 1991  Simon Marshall  (sm at olympus)
  114. X
  115. X    * Released xalarm-3.
  116. X
  117. XWed Oct  2 14:35:15 1991  Simon Marshall  (sm at olympus)
  118. X
  119. X    * Taken out the makeX and put that stuff in with config.1st, let the
  120. X    user sort it out.
  121. X
  122. XMon Sep 30 19:12:40 1991  Simon Marshall  (sm at olympus)
  123. X
  124. X    * Added -list so xalarm shows what ps thinks are the user's xalarm pids
  125. X    are.  Had to alter the makefiles so that you could set where ps & the
  126. X    rest where; added a config.1st to do this.
  127. X
  128. XSun Sep 29 22:16:09 1991  Simon Marshall  (sm at olympus)
  129. X
  130. X    * Made xalarm capable of parsing a file for alarms, so for regular
  131. X    times, it will set alarms automatically.
  132. X
  133. XFri Sep 27 10:43:41 1991  Simon Marshall  (sm at olympus)
  134. X
  135. X    * Fed up with ``Is it only BSD that uses bzero, or only SYSV that uses
  136. X    memset?  Or is it a bit of both?''  Wrote my own.
  137. X
  138. XWed Sep 25 22:17:05 1991  Simon Marshall  (sm at olympus)
  139. X
  140. X    * Split README into README and INSTALL.  Made it all a touch more
  141. X    portable?  Thanks to Andreas Stolcke.  Made the manual more readable,
  142. X    thanks to suggestions by Bill Leonard.
  143. X
  144. XTue Sep 24 21:54:30 1991  Simon Marshall  (sm at olympus)
  145. X
  146. X    * Added a -snooze & resource on suggestion by Bill Leonard, so you can
  147. X    have a default snoozetime already set for you.  Corrected bits & bobs
  148. X    in man page too.
  149. X
  150. XSun Sep 15 21:41:52 1991  Simon Marshall  (sm at olympus)
  151. X
  152. X    * Cleaned up for release in contrib for R5; re-named xalarm-3 for good
  153. X    measure.
  154. X
  155. X    * Added a -reset kill & signal trapper code so that you can wake up an
  156. X    alarm and change the times.
  157. X
  158. XThu Sep  5 12:24:56 1991  Simon Marshall  (sm at olympus)
  159. X
  160. X    * Added a make flag & fix for the X crash-on-zero-timeout (bug report
  161. X    from Jamie Zawinsk).  Cleaned up Makefile & README.
  162. X
  163. XMon Sep  2 11:54:20 1991  Simon Marshall  (sm at olympus)
  164. X
  165. X    * Fixed the little problem with the clear button, although the resource
  166. X    still isn't changeable by the user.
  167. X
  168. XTue Aug 27 17:08:47 1991  Simon Marshall  (sm at olympus)
  169. X
  170. X    * The timeout is now recalculated on confirmation so that if the time
  171. X    is absolute, messing around during confirmation won't result in a late
  172. X    alarm.
  173. X
  174. XWed Aug 21 18:00:00 1991  Simon Marshall  (sm at olympus)
  175. X
  176. X    * Released xalarm-2.00.
  177. X
  178. XTue Aug 20 10:25:58 1991  Simon Marshall  (sm at olympus)
  179. X
  180. X    * Fixed a little bug as a result of yesterday; if an invalid time is
  181. X    given with the noconfirm option, the alarm message text is "".
  182. X
  183. X    * Finally made the popups get their geometry from the alarm, by
  184. X    intercepting it from the command line...
  185. X
  186. XMon Aug 19 13:56:53 1991  Simon Marshall  (sm at olympus)
  187. X
  188. X    * Added xmemo (thanks to an unconnected posting by Dan Jacobson, I
  189. X    think) & found a bug in the manual - used -beep instead of -bell!!!
  190. X    Added -beep & -nobeep to options...
  191. X
  192. XSun Aug 18 11:17:45 1991  Simon Marshall  (sm at olympus)
  193. X
  194. X    * Put the toggling back (!) so you can fiddle with warning times too.
  195. X
  196. X    * Changed -at and -in to -time, -in times preceded by a `+' (but
  197. X    warning times aren't).  None of that silly toggling etc.  Also made
  198. X    some options have shorter aliases.
  199. X
  200. X    * Made xalarm overwrite any given message, so ps etc can't show what it
  201. X    is.  From a comment by Reiner Hammer.
  202. X
  203. XFri Aug 16 12:25:08 1991  Simon Marshall  (sm at olympus)
  204. X
  205. X    * Cleaned up here & there.
  206. X
  207. X    * Incorporated a hacked version of the time parser from xcal-3.2, Peter
  208. X    Collinson et al.
  209. X
  210. X    * Changed the way warnings are given.  No longer within quotes, they
  211. X    must be separated by commas (only).
  212. X
  213. XWed Aug 14 12:58:29 1991  Simon Marshall  (sm at olympus)
  214. X
  215. X    * Corrected bug whereby time wasn't always correctly calculated when
  216. X    given as 12 hour clock but >12 hours ahead.
  217. X
  218. XTue Aug 13 12:41:32 1991  Simon Marshall  (sm at olympus)
  219. X
  220. X    * Added forking - so must easier than I had assumed.  No closing to do
  221. X    after all.  Thanks to Gordon Freedman & Janet Anstett.
  222. X
  223. XFri Aug  9 13:38:35 1991  Simon Marshall  (sm at olympus)
  224. X
  225. X    * Added -h[elp].
  226. X
  227. XThu Aug  8 15:04:56 1991  Simon Marshall  (sm at olympus)
  228. X
  229. X    * Added -v[ersion]; I'm fed up with getting bug reports without it.
  230. X
  231. X    * Added a config to Makefile so as to make sure stuff is ready for
  232. X    making & running/playing with.
  233. X
  234. XMon Aug  5 15:46:00 1991  Simon Marshall  (sm at olympus)
  235. X
  236. X    * It appears that stuff in .../lib/X11/app-defaults is not
  237. X    pre-processed with cpp, so we can't have "#ifdef" etc in there.  Moved
  238. X    colour stuff to separate file.  From Scott Blachovicz & a multitude of
  239. X    others.
  240. X
  241. XSun Aug  4 15:12:06 1991  Simon Marshall  (sm at olympus)
  242. X
  243. X    * Corrected bug whereby When?.when.label was for "at" time when it
  244. X    should be "in", when user gave invalid "in" time on the command line.
  245. X
  246. X    * If enabled, confirmation is now always sort, unless alarm is to
  247. X    trigger immediately.
  248. X
  249. X    * Made warnings only accept times in the [[[h]h]m]m format a` la -in.
  250. X    Invalid times result in an error message on stderr only.  Also added
  251. X    -nowarn.  (Implemented as "-warn 0" :-)
  252. X
  253. XFri Aug  2 09:46:42 1991  Simon Marshall  (sm at olympus)
  254. X
  255. X    * Added confirmation stuff to xalarm.  Does not confirm if using
  256. X    relative time given on the command line.  Also added -confirm,
  257. X    -noconfirm and -nobell.
  258. X
  259. X    * Split up xalarm into more meaningful pieces.  Preparation for
  260. X    xalarm-2.00?
  261. X
  262. XWed Jul 31 13:20:29 1991  Simon Marshall  (sm at olympus)
  263. X
  264. X    * Released xalarm-1.01.
  265. X
  266. X    * Made MakeX which looks for the absolute path of an executable.  Need
  267. X    it for yow, as it is often not is a person's path.
  268. X
  269. X    * Fixed bug/mistake.  I had sometimes declared warg as an Arg, but
  270. X    XtSetValues expects an ArgList.  Changed to declare as warg[1].  From
  271. X    comments made by Dave Brooks, Bill Leonard & Braham Levy (plus more
  272. X    once our mailer came up).
  273. X
  274. X    * Added 2 options; -bell and -warn "...".  By default the bell no
  275. X    longer sounds, and the warning times can be specified.  Both have
  276. X    resources of course.  From comments by Bill Leonard.
  277. X
  278. X    * Updated the manual & made it clearer.
  279. X
  280. XTue Jul 30 10:29:22 1991  Simon Marshall  (sm at olympus)
  281. X
  282. X    * Changed the way the time is calculated.  No more fiddling with
  283. X    strings & it's much more compact.
  284. X
  285. X    * Added Imakefile, sent by Andreas Stolcke (stolcke@edu.Berkeley.ICSI).
  286. X    I don't know how useful it is, our imake isn't installed.
  287. X
  288. X    * Changed default font for value entry to 9x15bold in XAlarm.ad; it is
  289. X    a little more readable.
  290. END_OF_FILE
  291. if test 8795 -ne `wc -c <'ChangeLog'`; then
  292.     echo shar: \"'ChangeLog'\" unpacked with wrong size!
  293. fi
  294. # end of 'ChangeLog'
  295. fi
  296. if test -f 'INSTALL' -a "${1}" != "-c" ; then 
  297.   echo shar: Will not clobber existing file \"'INSTALL'\"
  298. else
  299. echo shar: Extracting \"'INSTALL'\" \(4221 characters\)
  300. sed "s/^X//" >'INSTALL' <<'END_OF_FILE'
  301. XMAKING
  302. X~~~~~~
  303. X
  304. X  First get any relevant patch files so as to make the latest patch version.
  305. X  You can find out which patch level your xalarm is at by looking at the file
  306. X  patchlevel.h in the source directory, or, if you have xalarm built, by:
  307. X
  308. X% xalarm -version
  309. X
  310. X  See the man page for more.  Apply any patches, see the patch files themselves
  311. X  for more information.
  312. X
  313. X  If you have problems, have a look below.
  314. X
  315. X    1.  If you don't want to use the Imakefile or the Makefile generated from
  316. X        it, try using Makefile.alt.  First check the flag settings, then
  317. X        copy it to Makefile.
  318. X    Otherwise use the supplied Makefile, or check the Imakefile and
  319. X        generate your own Makefile by "xmkmf".
  320. X
  321. X    If you want to use a different notation or language for dates, see the
  322. X        definitions for WEEKDAYS and MONTHS in xalarm.h.
  323. X
  324. X    2.  First, "make config".  Answer the questions.
  325. X
  326. X    3.  Try making with "make".  Have a play.
  327. X
  328. X    4.  If you aren't installing (you selfish get), put the XAlarm.ad and
  329. X        XAlarm.ad+ in your ~/.xresources file.
  330. X    Otherwise, try "make install", then "make install.man".
  331. X
  332. X  Look at the manual for anything else & enjoy.
  333. X
  334. X
  335. XPROBLEMS
  336. X~~~~~~~~
  337. X
  338. X  Compilation
  339. X
  340. X    1.  When using the Makefile generated from the Imakefile, compiler says
  341. X    things like, "Don't know how to make target `lib/Xaw/libXaw.a'".  You
  342. X    are not building in the contrib directory, so try removing $(DEPLIBS)
  343. X    from the xalarm target in the Makefile.
  344. X
  345. X    2.  When using the Makefile generated from the Imakefile, the loader says
  346. X    things like, "ld: ./lib/Xaw/libXaw.a: No such file or directory".  You
  347. X    are not building in the contrib directory, so try re-defining
  348. X    LOCAL_LIBRARIES to be "-lXaw -lXmu -lXt -lXext -lX11" in the Makefile.
  349. X
  350. X    3.  Compiler complains about gethostname().  If you haven't got this, you
  351. X    need to add -DNOGETHOSTNAME to DEFINES in the Makefile.
  352. X
  353. X    4.  If you don't have "ps", "fgrep" or "colrm", you can compile xalarm, but
  354. X    you won't be able to use the -list option.  The command "ps" lists
  355. X    processes.  The command "fgrep" is a pattern matcher.  The command
  356. X    "colrm" removes everything from its input after the sixth column.  If
  357. X    you don't have this, you could possibly just use "tee" (giving its full
  358. X    path, of course) or equivalent which just replicates its input.  Look
  359. X    at the file config.1st.
  360. X
  361. X    5.  Similarly, if you don't have "fortune" or "yow", you can't have
  362. X    "xfortune" or "xyow".
  363. X
  364. X    6.  Make config (config.1st) does nothing.  It's probably just the execing
  365. X    of "fullpath" that's doing this.  Hack config.1st to put the correct
  366. X    definitions for PS, FGREP and COLRM in fns.h, and create the xfortune &
  367. X    xyow shell scripts (if you can be bothered).  None of this is essential
  368. X    for xalarm, but something has to be defined in fns.h.
  369. X
  370. X    7.  What about other programs, along with xyow and xfortune, can I make
  371. X    these too?  You will have to make the manual page (it would be a copy
  372. X    of man.man) and install it yourself, but type:
  373. X
  374. X        % config.1st yourprogram
  375. X
  376. X    This will make the executable file "xyourprogram" in the current
  377. X    directory.
  378. X
  379. X  Alarm Layout
  380. X
  381. X    1.  You want to layout the alarm buttons differently, don't you?  Mine not
  382. X    good enough?  The buttons are within a Form Widget, so have a look at
  383. X    the Xaw man page for this.  Each button has the placement resources
  384. X    fromHoriz, fromVert, horizDistance & vertDistance.  There are some
  385. X    suggestions in the xalarm man page too.
  386. X
  387. X    The button box and message label are also in a (higher level) Form
  388. X    widget, so you can also change the relationship of button box to
  389. X    message text.  See the man page too.
  390. X
  391. X    Note that the ordering of resources are important; you can't refer to a
  392. X    widget in a resource before it's created by xalarm.  The order of
  393. X    creation is:
  394. X
  395. X        Parent    Widget(s)
  396. X        ---------------------
  397. X        alarm    buttons
  398. X        buttons    quit snooze snooze1 snooze5 snooze15 snoozetime
  399. X        alarm    message
  400. X
  401. X
  402. XBUGS
  403. X~~~~
  404. X
  405. X  If you have any comments, suggestions, code, fixes, please let me know and I
  406. X  will make an attempt to include them.  A few ``things'' are mentioned in the
  407. X  bugs section of the manual.  Don't forget to include the xalarm version
  408. X  number ("xalarm -version" gives it you), machine/OS, X11 release & patch etc.
  409. X
  410. END_OF_FILE
  411. if test 4221 -ne `wc -c <'INSTALL'`; then
  412.     echo shar: \"'INSTALL'\" unpacked with wrong size!
  413. fi
  414. # end of 'INSTALL'
  415. fi
  416. if test -f 'Imakefile' -a "${1}" != "-c" ; then 
  417.   echo shar: Will not clobber existing file \"'Imakefile'\"
  418. else
  419. echo shar: Extracting \"'Imakefile'\" \(1191 characters\)
  420. sed "s/^X//" >'Imakefile' <<'END_OF_FILE'
  421. X/**/# Based on an Imakefile from:
  422. X/**/# Andreas Stolcke
  423. X/**/# International Computer Science Institute, Berkeley.
  424. X
  425. X
  426. X/**/# If you don't have gethostname() and you can't change the #define in
  427. X/**/# alarm.c to what ever it is on your system, add -DNOGETHOSTNAME here:
  428. XDEFINES = ${SIGNAL_DEFINES}
  429. X
  430. X
  431. XOBJS  = alarm.o when.o warning.o times.o fns.o xalarm.o
  432. XSRCS  = alarm.c when.c warning.c times.c fns.c xalarm.c
  433. X
  434. X
  435. XLOCAL_LIBRARIES = XawClientLibs
  436. X
  437. XComplexProgramTarget (xalarm)
  438. X
  439. XInstallAppDefaults (XAlarm)
  440. XInstallMultipleFlags (xmemo xfortune xyow,$(BINDIR),$(INSTBINFLAGS))
  441. XInstallManPage (xmemo,$(MANDIR))
  442. XInstallManPage (xfortune,$(MANDIR))
  443. XInstallManPage (xyow,$(MANDIR))
  444. X
  445. Xfns.h:
  446. X    @config.1st
  447. X
  448. Xxmemo.man xyow.man xfortune.man:
  449. X    echo ".so man"`echo ManSuffix`"/xalarm."`echo ManSuffix` > $@
  450. X
  451. Xxfortune::
  452. X
  453. Xxyow::
  454. X
  455. Xclean::
  456. X    $(RM) xfortune xyow xmemo.man xyow.man xfortune.man fns.h
  457. X
  458. Xconfig::
  459. X    @chmod +x config.1st fullpath xmemo
  460. X    @config.1st fortune yow
  461. X    @xrdb -merge XAlarm.ad
  462. X    @xrdb -merge XAlarm.ad+
  463. X
  464. Xalarm.o: xalarm.h patchlevel.h
  465. Xwhen.o: xalarm.h patchlevel.h
  466. Xwarning.o: xalarm.h patchlevel.h
  467. Xtimes.o: xalarm.h patchlevel.h
  468. Xfns.o: xalarm.h patchlevel.h fns.h
  469. Xxalarm.o: xalarm.h patchlevel.h
  470. END_OF_FILE
  471. if test 1191 -ne `wc -c <'Imakefile'`; then
  472.     echo shar: \"'Imakefile'\" unpacked with wrong size!
  473. fi
  474. # end of 'Imakefile'
  475. fi
  476. if test -f 'Makefile.alt' -a "${1}" != "-c" ; then 
  477.   echo shar: Will not clobber existing file \"'Makefile.alt'\"
  478. else
  479. echo shar: Extracting \"'Makefile.alt'\" \(2271 characters\)
  480. sed "s/^X//" >'Makefile.alt' <<'END_OF_FILE'
  481. X# I use cc because gcc (gcc-1.37.1) make code 20 times larger.  Remove -lXext
  482. X# if you don't have it; it's only used for button shapes which default to
  483. X# rectangle anyway.
  484. XCC    = cc
  485. XCFLAGS    = -O
  486. XLDFLAGS    = -lXaw -lXmu -lXt -lX11 -lXext
  487. X
  488. X
  489. X# If your signal() returns int not void, then add -DSIGNALRETURNSINT here:
  490. X# If you don't have gethostname() and you can't change the #define in alarm.c
  491. X# to what ever it is on your system, add -DNOGETHOSTNAME here:
  492. XDEFINES = 
  493. X
  494. X
  495. X# My, is this complex!  These are the usual places for installation.
  496. XPREFIX    =
  497. XX11BIN    = ${PREFIX}/usr/bin/X11
  498. XX11MAN    = ${PREFIX}/usr/man/mann
  499. XX11AD    = ${PREFIX}/usr/lib/X11/app-defaults
  500. X
  501. X
  502. X# Bits and bobs.
  503. XMADE    = test
  504. XSTRIP    = /bin/strip
  505. XCP    = /bin/cp
  506. XRM    = /bin/rm -f
  507. XTAGS    = etags -t
  508. XLINT    = lint -hbxca
  509. X
  510. X
  511. XOBJS    = alarm.o when.o warning.o times.o fns.o xalarm.o
  512. XSRCS    = alarm.c when.c warning.c times.c fns.c xalarm.c
  513. X
  514. X# If your make complains about the && conditional sequences, you may have to do
  515. X# them by hand or go hacking below...  The executables and man pages go in the
  516. X# same directories as xalarm do.
  517. X
  518. X# The $& notation tells a Sequent to do a parallel make.  Set this variable to
  519. X# whatever value you need for your parallel machine.
  520. X
  521. Xall: xalarm
  522. X
  523. Xxalarm: $& ${OBJS}
  524. X    ${CC} ${CFLAGS} -o xalarm ${OBJS} ${LDFLAGS}
  525. X
  526. X.c.o:
  527. X    ${CC} -c ${CFLAGS} ${DEFINES} $<
  528. X
  529. Xinstall: all
  530. X    ${STRIP} xalarm
  531. X    ${CP} xalarm xmemo ${X11BIN}
  532. X    ${MADE} xfortune && ${CP} xfortune ${X11BIN}
  533. X    ${MADE} xyow && ${CP} xyow ${X11BIN}
  534. X    ${CP} XAlarm.ad ${X11AD}/XAlarm
  535. X
  536. Xinstall.man:
  537. X    ${CP} xalarm.man ${X11MAN}/xalarm.n
  538. X    ${CP} man.man ${X11MAN}/xmemo.n
  539. X    ${MADE} xfortune && ${CP} man.man ${X11MAN}/xfortune.n
  540. X    ${MADE} xyow && ${CP} man.man ${X11MAN}/xyow.n
  541. X
  542. X# Just make sure, some shars come out with default permissions...
  543. X# Make sure the resources are loaded so xalarm can be used before installed.
  544. Xconfig:
  545. X    @chmod +x config.1st fullpath xmemo
  546. X    @config.1st fortune yow
  547. X    @xrdb -merge XAlarm.ad
  548. X    @xrdb -merge XAlarm.ad+
  549. X
  550. Xtags:
  551. X    ${TAGS} ${SRCS}
  552. X
  553. Xclean:
  554. X    ${RM} ${OBJS} xalarm xfortune xyow fns.h core *~ #*
  555. X
  556. Xlint:
  557. X    ${LINT} ${SRCS}
  558. X
  559. Xfns.h:
  560. X    @config.1st
  561. X
  562. Xalarm.o: xalarm.h patchlevel.h
  563. Xwhen.o: xalarm.h patchlevel.h
  564. Xwarning.o: xalarm.h patchlevel.h
  565. Xtimes.o: xalarm.h patchlevel.h
  566. Xfns.o: xalarm.h patchlevel.h fns.h
  567. Xxalarm.o: xalarm.h patchlevel.h
  568. END_OF_FILE
  569. if test 2271 -ne `wc -c <'Makefile.alt'`; then
  570.     echo shar: \"'Makefile.alt'\" unpacked with wrong size!
  571. fi
  572. # end of 'Makefile.alt'
  573. fi
  574. if test -f 'XAlarm.ad' -a "${1}" != "-c" ; then 
  575.   echo shar: Will not clobber existing file \"'XAlarm.ad'\"
  576. else
  577. echo shar: Extracting \"'XAlarm.ad'\" \(3108 characters\)
  578. sed "s/^X//" >'XAlarm.ad' <<'END_OF_FILE'
  579. X! We can't surround this by "#ifdef COLOR ... #endif" and have it in
  580. X! .../lib/X11/app-defaults/XAlarm because stuff in there is not pre-processed
  581. X! with cpp like wot xrdb does.  Now why is that...?
  582. X! If you want colour, you have to stick this in your ~/.xresources file (where
  583. X! you can surround it with #ifdefs).
  584. X! #ifdef COLOR
  585. X! XAlarm*background:            LightYellow
  586. X! XAlarm*foreground:            IndianRed
  587. X! XAlarm*Command.background:        IndianRed
  588. X! XAlarm*Command.foreground:        LightYellow
  589. X! #endif
  590. X
  591. XXAlarm.bell:                True
  592. XXAlarm.confirm:                True
  593. XXAlarm.warnings:            5,15
  594. XXAlarm.warningwords:            0
  595. XXAlarm.snooze:                0
  596. X
  597. XXAlarm*background:            White
  598. XXAlarm*foreground:            Black
  599. XXAlarm*font:                *-times-bold-r-*-14-*
  600. XXAlarm*allowShellResize:        True
  601. XXAlarm*resizable:            True
  602. X
  603. XXAlarm*top:                ChainTop
  604. XXAlarm*bottom:                ChainTop
  605. XXAlarm*left:                ChainLeft
  606. XXAlarm*right:                ChainLeft
  607. X
  608. XXAlarm*Command.background:        Black
  609. XXAlarm*Command.foreground:        White
  610. XXAlarm*Command.ShapeStyle:        rectangle
  611. XXAlarm*Command.cursor:            hand2
  612. XXAlarm*Label.justify:            left
  613. XXAlarm*Label.cursor:            question_arrow
  614. XXAlarm*Text.cursor:            pencil
  615. X
  616. XXAlarm*quit.label:            Quit
  617. X
  618. XXAlarm.Alarm!.alarm.background:                Black
  619. XXAlarm.Alarm!.alarm.message.cursor:            gumby
  620. XXAlarm.Alarm!.alarm.message.label:            Alarm Call!!!
  621. XXAlarm.Alarm!.alarm.message.font:            *-times-bold-i-*-*-34-*
  622. XXAlarm.Alarm!.alarm.message.internalWidth:        10
  623. XXAlarm.Alarm!.alarm.message.internalHeight:        5
  624. XXAlarm.Alarm!.alarm.message.bottom:            ChainBottom
  625. X
  626. XXAlarm.Alarm!.alarm.buttons.snooze.label:        Snooze
  627. XXAlarm.Alarm!.alarm.buttons.snooze1.label:        +1 min
  628. XXAlarm.Alarm!.alarm.buttons.snooze5.label:        +5 mins
  629. XXAlarm.Alarm!.alarm.buttons.snooze15.label:        +15 mins
  630. XXAlarm.Alarm!.alarm.buttons.snooze.fromHoriz:        quit
  631. XXAlarm.Alarm!.alarm.buttons.snooze1.fromHoriz:        snooze
  632. XXAlarm.Alarm!.alarm.buttons.snooze5.fromHoriz:        snooze1
  633. XXAlarm.Alarm!.alarm.buttons.snooze15.fromHoriz:        snooze5
  634. XXAlarm.Alarm!.alarm.buttons.snoozetime.fromHoriz:    snooze15
  635. XXAlarm.Alarm!.alarm.message.fromVert:            buttons
  636. X
  637. XXAlarm.When?.when.background:        Black
  638. XXAlarm.When?.when.ok.label:        Enter time
  639. XXAlarm.When?.when.toggle.label:        Edit warnings
  640. XXAlarm.When?.when.value.translations:    #override <Key>Return: EnteredTime()
  641. X
  642. XXAlarm.When?.warnings.background:    Black
  643. XXAlarm.When?.warnings.ok.label:        Enter warnings
  644. XXAlarm.When?.warnings.toggle.label:    Edit time
  645. XXAlarm.When?.warnings.value.translations:#override <Key>Return: EnteredWarnings()
  646. X
  647. XXAlarm.When?.confirm.background:    Black
  648. XXAlarm.When?.confirm.value*font:    *-times-bold-i-*-*-14-*
  649. XXAlarm.When?.confirm.ok.label:        Confirm time
  650. XXAlarm.When?.confirm.cancel.label:    Edit time
  651. XXAlarm.When?.confirm.value.translations:#override <Key>Return: Confirmed()
  652. X
  653. XXAlarm.When?*value*font:        9x15bold
  654. XXAlarm.When?*value.bottom:        ChainBottom
  655. XXAlarm.When?*value.right:        ChainRight
  656. XXAlarm.When?*Command.top:        ChainBottom
  657. XXAlarm.When?*Command.bottom:        ChainBottom
  658. X
  659. XXAlarm.Warning!.warning.background:        Black
  660. XXAlarm.Warning!.warning.dismiss.label:        Dismiss
  661. XXAlarm.Warning!.warning.message.fromHoriz:    dismiss
  662. XXAlarm.Warning!.warning.message.cursor:        clock
  663. XXAlarm.Warning!.warning.quit.fromHoriz:        message
  664. END_OF_FILE
  665. if test 3108 -ne `wc -c <'XAlarm.ad'`; then
  666.     echo shar: \"'XAlarm.ad'\" unpacked with wrong size!
  667. fi
  668. # end of 'XAlarm.ad'
  669. fi
  670. if test -f 'alarm.c' -a "${1}" != "-c" ; then 
  671.   echo shar: Will not clobber existing file \"'alarm.c'\"
  672. else
  673. echo shar: Extracting \"'alarm.c'\" \(5440 characters\)
  674. sed "s/^X//" >'alarm.c' <<'END_OF_FILE'
  675. X/*
  676. X      Copyright (c) 1991, 1992 by Simon Marshall, University of Hull, UK
  677. X
  678. X           If you still end up late, don't blame me!
  679. X                       
  680. X  Permission to use, copy, modify, distribute, and sell this software and its
  681. X       documentation for any purpose and without fee is hereby granted,
  682. X    provided that the above copyright notice appear in all copies and that
  683. X    both that copyright notice and this permission notice appear in
  684. X               supporting documentation.
  685. X                       
  686. X  This software is provided AS IS with no warranties of any kind.  The author
  687. X    shall have no liability with respect to the infringement of copyrights,
  688. X     trade secrets or any patents by this file or any part thereof.  In no
  689. X      event will the author be liable for any lost revenue or profits or
  690. X          other special, indirect and consequential damages.
  691. X*/
  692. X
  693. X/* 
  694. X * The stuff needed for the alarm call widget to appear on the screen, 
  695. X * and the stuff for snoozing it.
  696. X */
  697. X
  698. X
  699. X#include "xalarm.h"
  700. X#include <X11/Xaw/Label.h>
  701. X#include <X11/Xaw/Command.h>
  702. X#include <X11/Xaw/Form.h>
  703. X
  704. X
  705. X/* 
  706. X * A pain, you may have to alter this.  Basically USER() should return the
  707. X * user name, HOSTNAME() the hostname in the first arg.
  708. X */
  709. X
  710. X#define        HOSTNAME(str,l)    gethostname ((str), (l))
  711. X#define        TITLEFORMAT    "%s: %s%s%s%s%s%s"
  712. X
  713. X
  714. X
  715. Xvoid        CreateAlarmWidget(), WakeUp(), ShowClickToZero(), ShowSnoozeValue();
  716. Xstatic void    SnoozeAmount(), Snooze();
  717. Xextern void    AddTimeOuts(), SetGeometry(), Quit();
  718. Xextern String    getenv();
  719. X
  720. X
  721. Xextern AlarmData        xalarm;
  722. X
  723. X
  724. X
  725. X/* 
  726. X * The snoozetime button displays its message when the ptr is in the 
  727. X * window, and the snooze time when it's not.
  728. X */
  729. X
  730. Xstatic char snoozetimetranslations [] =
  731. X    "<EnterWindow>:    highlight() ShowClickToZero() \n\
  732. X     <LeaveWindow>:    ShowSnoozeValue() unhighlight()";
  733. X
  734. X
  735. X
  736. Xvoid CreateAlarmWidget (alarmmessage)
  737. X  String   alarmmessage;
  738. X{
  739. X    Widget   alarm, alarmbox, message, buttonbox,
  740. X         quit, snooze, snooze1, snooze5, snooze15, snoozetime;
  741. X
  742. X    alarm = XtVaCreatePopupShell ("Alarm!", transientShellWidgetClass,
  743. X                  xalarm.toplevel, NULL);
  744. X
  745. X    alarmbox = XtVaCreateManagedWidget ("alarm", formWidgetClass, alarm, NULL);
  746. X
  747. X    buttonbox = XtVaCreateManagedWidget ("buttons", formWidgetClass, alarmbox, NULL);
  748. X
  749. X    CreateManagedButton (quit, "quit", buttonbox, Quit, NULL);
  750. X    CreateManagedButton (snooze, "snooze", buttonbox, Snooze, NULL);
  751. X    CreateManagedButton (snooze1, "snooze1", buttonbox, SnoozeAmount, 1);
  752. X    CreateManagedButton (snooze5, "snooze5", buttonbox, SnoozeAmount, 5);
  753. X    CreateManagedButton (snooze15, "snooze15" ,buttonbox, SnoozeAmount, 15);
  754. X    CreateManagedButton (snoozetime, "snoozetime", buttonbox, SnoozeAmount, 0);
  755. X
  756. X    if (alarmmessage != (String) NULL)
  757. X    message = XtVaCreateManagedWidget ("message", labelWidgetClass, alarmbox, XtNlabel,
  758. X                       (XtArgVal) (xalarm.messagestr = alarmmessage),
  759. X                       NULL);
  760. X    else {
  761. X    message = XtVaCreateManagedWidget ("message", labelWidgetClass, alarmbox, NULL);
  762. X    XtVaGetValues (message, XtNlabel, &xalarm.messagestr, NULL);
  763. X    }
  764. X
  765. X    XtOverrideTranslations (snoozetime,
  766. X                XtParseTranslationTable (snoozetimetranslations));
  767. X
  768. X    xalarm.alarmwidget = alarm;
  769. X    xalarm.snoozetimewidget = snoozetime;
  770. X    xalarm.messagewidget = message;
  771. X}
  772. X
  773. X
  774. X
  775. X/* 
  776. X * This is for the snoozetime button which doubles as the label showing how 
  777. X * much time the snooze is selected for.
  778. X */
  779. X
  780. Xvoid ShowClickToZero ()
  781. X{
  782. X    XtVaSetValues (xalarm.snoozetimewidget, XtNlabel, (XtArgVal) "Zero time", NULL);
  783. X}
  784. X  
  785. X
  786. X
  787. Xvoid ShowSnoozeValue ()
  788. X{  
  789. X    char   buf[TEXT];
  790. X
  791. X    MAKETIMESTRING (buf, (int) (xalarm.timeout/(60*1000)));
  792. X    XtVaSetValues (xalarm.snoozetimewidget, XtNlabel, (XtArgVal) buf, NULL);
  793. X}
  794. X
  795. X
  796. X
  797. X/* 
  798. X * Add to the amount that is currently the amount to snooze by.
  799. X */
  800. X
  801. Xstatic void SnoozeAmount (widget, clientdata, calldata)
  802. X  Widget      widget;
  803. X  XtPointer   clientdata, calldata;
  804. X{
  805. X    int   mins = (int) clientdata;
  806. X
  807. X    if (mins == 0) {
  808. X    xalarm.timeout = 0;
  809. X    ShowClickToZero ();
  810. X    }
  811. X    else {
  812. X    xalarm.timeout += (mins*60*1000);
  813. X    ShowSnoozeValue ();
  814. X    }
  815. X}
  816. X
  817. X
  818. X
  819. X/* 
  820. X * Time to sleep.  Add the time outs & disappear.
  821. X */
  822. X
  823. Xstatic void Snooze (widget, clientdata, calldata)
  824. X  Widget      widget;
  825. X  XtPointer   clientdata, calldata;
  826. X{
  827. X    AddTimeOuts ();
  828. X    XtPopdown (xalarm.alarmwidget);
  829. X}
  830. X
  831. X
  832. X
  833. X/* 
  834. X * Time to wake up.
  835. X */
  836. X
  837. Xvoid WakeUp (clientdata, id)
  838. X  XtPointer      clientdata;
  839. X  XtIntervalId      id;
  840. X{
  841. X    Display        *display = XtDisplay (xalarm.toplevel);
  842. X    String         strs[1], name;
  843. X    XTextProperty   property;
  844. X#if not defined (NOGETHOSTNAME)
  845. X    char         hostname[TEXT];
  846. X#endif
  847. X
  848. X    if (not XtIsRealized (xalarm.alarmwidget)) {
  849. X    XtRealizeWidget (xalarm.alarmwidget);
  850. X    /* 
  851. X     * Set the name...
  852. X     */
  853. X    name = getenv ("NAME");
  854. X#if not defined (NOGETHOSTNAME)
  855. X    HOSTNAME (hostname, TEXT-1);
  856. X#endif
  857. X    strs[0] = XtMalloc (TEXT);
  858. X    (void) sprintf (strs[0], TITLEFORMAT, xalarm.proggie,
  859. X            getenv ("USER"),
  860. X#if not defined (NOGETHOSTNAME)
  861. X            "@", hostname,
  862. X#else
  863. X            "", "",
  864. X#endif
  865. X            (name == (char *) NULL) ? "" : " (",
  866. X            (name == (char *) NULL) ? "" : name,
  867. X            (name == (char *) NULL) ? "" : ")");
  868. X    
  869. X    XStringListToTextProperty (strs, 1, &property);
  870. X    XSetWMName (display, XtWindow (xalarm.alarmwidget), &property);
  871. X    }
  872. X
  873. X    SetGeometry (xalarm.alarmwidget);
  874. X
  875. X    xalarm.timeout = 0;
  876. X    SnoozeAmount ((Widget) NULL, (XtPointer) xalarm.snooze, (XtPointer) NULL);
  877. X
  878. X    if (xalarm.bell)
  879. X    XBell (display, 0);
  880. X    XtPopup (xalarm.alarmwidget, XtGrabNone);
  881. X}
  882. END_OF_FILE
  883. if test 5440 -ne `wc -c <'alarm.c'`; then
  884.     echo shar: \"'alarm.c'\" unpacked with wrong size!
  885. fi
  886. # end of 'alarm.c'
  887. fi
  888. if test -f 'config.1st' -a "${1}" != "-c" ; then 
  889.   echo shar: Will not clobber existing file \"'config.1st'\"
  890. else
  891. echo shar: Extracting \"'config.1st'\" \(1395 characters\)
  892. sed "s/^X//" >'config.1st' <<'END_OF_FILE'
  893. X#!/bin/sh
  894. X
  895. X# Just try to find out the full path names for ps, fgrep & colrm which are used
  896. X# within fns.c to do the -list option.
  897. X
  898. Xecho '
  899. XJust a few questions!  The default answer is in brackets, just press RETURN.
  900. X
  901. XIf you do not have "ps", "fgrep" or "colrm" (or equivalent), do not panic.
  902. Xxalarm only uses them when it is attempting to list the process ids of other
  903. Xxalarms.  If you do not have these commands, just press RETURN.  xalarm can be
  904. Xinstalled as normal, but you will not be able to use the -list option.
  905. X
  906. XI need to know because xalarm uses these shell commands when obeying the -list
  907. Xoption, and for security reasons xalarm should use full path names.
  908. X
  909. XIf you do not have "fortune" or "yow", you cannot have the X equivalent since
  910. Xthey are just front ends to them!
  911. X
  912. XI will try to find them myself, but if I cannot, use "which" (or "find" if you
  913. Xare really desperate) or ask your local System Guru or Manager.
  914. X'
  915. X
  916. Xecho '#define        PS    "'`./fullpath ps`'"
  917. X#define        FGREP    "'`./fullpath fgrep`'"
  918. X#define        COLRM    "'`./fullpath colrm`'"' > fns.h
  919. X
  920. Xecho ''
  921. X
  922. Xfor program in $*; do
  923. X    progpath=`./fullpath $program`
  924. X    if test -f $progpath; then
  925. X        echo '#!/bin/sh
  926. Xexec xmemo -name x'$program' ${1+"$@"} "`'$progpath'`"' > x$program
  927. X    else
  928. X        echo '#!/bin/sh
  929. Xexec xmemo -name x'$program' "Sorry, x'$program' is unavailable - no '$program'"' > x$program
  930. X    fi
  931. X    chmod +x x$program
  932. Xdone
  933. X
  934. Xecho "
  935. XThank you.
  936. X"
  937. END_OF_FILE
  938. if test 1395 -ne `wc -c <'config.1st'`; then
  939.     echo shar: \"'config.1st'\" unpacked with wrong size!
  940. fi
  941. chmod +x 'config.1st'
  942. # end of 'config.1st'
  943. fi
  944. if test -f 'fullpath' -a "${1}" != "-c" ; then 
  945.   echo shar: Will not clobber existing file \"'fullpath'\"
  946. else
  947. echo shar: Extracting \"'fullpath'\" \(842 characters\)
  948. sed "s/^X//" >'fullpath' <<'END_OF_FILE'
  949. X#!/bin/sh
  950. X
  951. XPATH="$PATH:.:/bin:/usr/bin:/usr/local/bin:/usr/ucb:/usr/local:/usr/lbin:/etc:/usr/new:/usr/new/bin:/usr/nbin"
  952. Xexport PATH
  953. X
  954. Xloc=`which $1 2>/dev/null`
  955. Xcase "$loc" in
  956. X    "$1"*|"no $1"*) loc=;;
  957. Xesac
  958. X
  959. Xecho -n "Where is your \"$1\"? [$loc] " >&2
  960. Xread ans
  961. X
  962. Xif test ! "$ans" = ""; then
  963. X    loc=$ans
  964. Xfi
  965. Xif test "$loc" = ""; then
  966. X    loc=$1
  967. Xfi
  968. Xif test ! -f $loc; then
  969. X    echo Warning: \"$loc\" does not exist. >&2
  970. Xfi
  971. X
  972. Xecho $loc
  973. X#!/bin/sh
  974. X
  975. XPATH="$PATH:.:/bin:/usr/bin:/usr/local/bin:/usr/ucb:/usr/local:/usr/lbin:/etc:/usr/new:/usr/new/bin:/usr/nbin"
  976. Xexport PATH
  977. X
  978. Xloc=`which $1 2>/dev/null`
  979. Xcase "$loc" in
  980. X    "$1"*|"no $1"*) loc=;;
  981. Xesac
  982. X
  983. Xecho -n "Where is your \"$1\"? [$loc] " >&2
  984. Xread ans
  985. X
  986. Xif test ! "$ans" = ""; then
  987. X    loc=$ans
  988. Xfi
  989. Xif test "$loc" = ""; then
  990. X    loc=$1
  991. Xfi
  992. Xif test ! -f $loc; then
  993. X    echo Warning: \"$loc\" does not exist. >&2
  994. Xfi
  995. X
  996. Xecho $loc
  997. END_OF_FILE
  998. if test 842 -ne `wc -c <'fullpath'`; then
  999.     echo shar: \"'fullpath'\" unpacked with wrong size!
  1000. fi
  1001. chmod +x 'fullpath'
  1002. # end of 'fullpath'
  1003. fi
  1004. if test -f 'man.man' -a "${1}" != "-c" ; then 
  1005.   echo shar: Will not clobber existing file \"'man.man'\"
  1006. else
  1007. echo shar: Extracting \"'man.man'\" \(18 characters\)
  1008. sed "s/^X//" >'man.man' <<'END_OF_FILE'
  1009. X.so mann/xalarm.n
  1010. END_OF_FILE
  1011. if test 18 -ne `wc -c <'man.man'`; then
  1012.     echo shar: \"'man.man'\" unpacked with wrong size!
  1013. fi
  1014. # end of 'man.man'
  1015. fi
  1016. if test -f 'times.c' -a "${1}" != "-c" ; then 
  1017.   echo shar: Will not clobber existing file \"'times.c'\"
  1018. else
  1019. echo shar: Extracting \"'times.c'\" \(6960 characters\)
  1020. sed "s/^X//" >'times.c' <<'END_OF_FILE'
  1021. X/*
  1022. X      Copyright (c) 1991, 1992 by Simon Marshall, University of Hull, UK
  1023. X
  1024. X           If you still end up late, don't blame me!
  1025. X                       
  1026. X  Permission to use, copy, modify, distribute, and sell this software and its
  1027. X       documentation for any purpose and without fee is hereby granted,
  1028. X    provided that the above copyright notice appear in all copies and that
  1029. X    both that copyright notice and this permission notice appear in
  1030. X               supporting documentation.
  1031. X                       
  1032. X  This software is provided AS IS with no warranties of any kind.  The author
  1033. X    shall have no liability with respect to the infringement of copyrights,
  1034. X     trade secrets or any patents by this file or any part thereof.  In no
  1035. X      event will the author be liable for any lost revenue or profits or
  1036. X          other special, indirect and consequential damages.
  1037. X*/
  1038. X
  1039. X/* 
  1040. X * Parse times & dates.
  1041. X */
  1042. X
  1043. X
  1044. X
  1045. X#include "xalarm.h"
  1046. X
  1047. X#define        VALUE(ch)    ((int) (ch) - (int) '0')
  1048. X#define        INSTRING(ch, s)    (((ch) != '\0') and (index ((s), (ch))))
  1049. X#define        DOWNCASE(ch)    (((ch) >= 'A') and ((ch) <= 'Z') ? \
  1050. X                 ((ch) - 'A' + 'a') : (ch))
  1051. X
  1052. X
  1053. Xlong        TimeToMilliSeconds();
  1054. XBoolean        AppointmentIsToday();
  1055. Xstatic String    NextWord();
  1056. Xstatic Boolean    ParseTimeString();
  1057. X
  1058. X
  1059. X
  1060. Xextern AlarmData xalarm;
  1061. X
  1062. X
  1063. X
  1064. X/* 
  1065. X * Is the date & time consistent with today?  This includes whether 
  1066. X * the time has passed or not.
  1067. X */
  1068. X
  1069. XBoolean AppointmentIsToday (line, timestr, chpos)
  1070. X  String   line, *timestr;
  1071. X  int       *chpos;
  1072. X{
  1073. X    static int       daysin[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  1074. X    static char   strings[][4] = {WEEKDAYS, MONTHS, "!!!", "!!!"};
  1075. X    int       wday, month, mday, year, hrs, mins;
  1076. X    struct tm      *now, *localtime();
  1077. X    time_t       abstime, time();
  1078. X    String       word, monthstr = (String) NULL;
  1079. X    Boolean       gotmday = False, today, notime, dummy;
  1080. X    int       i;
  1081. X
  1082. X    if (*line == '\n')
  1083. X    return (False);
  1084. X
  1085. X    (void) time (&abstime);
  1086. X    now = localtime (&abstime);
  1087. X    wday = now->tm_wday;
  1088. X    month = now->tm_mon;
  1089. X    mday = now->tm_mday;
  1090. X    year = now->tm_year + 1900;
  1091. X    if ((year % 400 == 0) or ((year % 4 == 0) and (year % 100 != 0)))
  1092. X    daysin[1] = 29;
  1093. X
  1094. X    while (strcmp (word = NextWord (line, chpos), "-"))
  1095. X    if (*word == '\0')
  1096. X        break;
  1097. X    else if ((*word == '#') or (*word == '!'))
  1098. X        return (False);
  1099. X    else {
  1100. X        i = 0;
  1101. X        while ((strncmp (word, strings[i], 3)) and (i < 20))
  1102. X        i++;
  1103. X        if (i < 7)
  1104. X        wday = i;
  1105. X        else if (i < 20) {
  1106. X        month = i-7;
  1107. X        monthstr = word;
  1108. X        }
  1109. X        else
  1110. X        if (not (gotmday = ((mday = atoi (word)) > 0))) {
  1111. X            (void) fprintf (stderr,
  1112. X                    "xalarm: Couldn't parse this entry (what is \"%s\"?):\n%s",
  1113. X                    word, line);
  1114. X            return (False);
  1115. X        }
  1116. X    }
  1117. X
  1118. X    if (((gotmday and monthstr) or (month == now->tm_mon)) and (mday > daysin[month])) {
  1119. X    (void) fprintf (stderr,
  1120. X            "xalarm: Couldn't parse this entry (%d days in %s?):\n%s",
  1121. X            mday, (monthstr != (String) NULL) ? monthstr : strings[month+7],
  1122. X            line);
  1123. X    return (False);
  1124. X    }
  1125. X
  1126. X    notime = not ParseTimeString (*timestr = NextWord (line, chpos),
  1127. X                  &hrs, &mins, &dummy);
  1128. X
  1129. X    today = ((wday == now->tm_wday) and (month == now->tm_mon) and
  1130. X         (mday == now->tm_mday));
  1131. X
  1132. X    if (today and notime) {
  1133. X    if (*timestr[0] != '\0')
  1134. X        do
  1135. X        (*chpos)--;
  1136. X        while (line[*chpos] != ' ');
  1137. X        *timestr = XtNewString ("+0");
  1138. X    return (True);
  1139. X    }
  1140. X    else
  1141. X    return (today and
  1142. X         ((hrs > now->tm_hour) or
  1143. X          ((hrs == now->tm_hour) and (mins >= now->tm_min)) or
  1144. X          (*timestr[0] == '+')));
  1145. X}
  1146. X
  1147. X
  1148. X
  1149. X/* 
  1150. X * Return the next word in str, starting at position chpos in the 
  1151. X * string.  The returned word is in lower case.
  1152. X */
  1153. X
  1154. Xstatic String NextWord (str, chpos)
  1155. X  String   str;
  1156. X  int       *chpos;
  1157. X{
  1158. X    String   word;
  1159. X    int      start, i;
  1160. X
  1161. X    while (isspace (str[*chpos]))
  1162. X    (*chpos)++;
  1163. X
  1164. X    start = *chpos;
  1165. X    while ((not isspace (str[*chpos])) and (str[*chpos] != '\0'))
  1166. X    (*chpos)++;
  1167. X
  1168. X    if ((str[*chpos] == '\0') and (start == *chpos))
  1169. X    return ("");
  1170. X    else {
  1171. X    word = XtMalloc (*chpos - start + 1);
  1172. X    for (i=0; i<(*chpos-start); i++)
  1173. X        word[i] = DOWNCASE (str[start+i]);
  1174. X    word[*chpos-start] = '\0';
  1175. X    
  1176. X    return (word);
  1177. X    }
  1178. X}
  1179. X
  1180. X
  1181. X
  1182. X/* 
  1183. X * Convert the string into milliseconds, or INVALID if 
  1184. X * not recognised.
  1185. X * Recognises quite a lot, really, but doesn't like non absolute times 
  1186. X * having "am" or "pm" etc.
  1187. X */    
  1188. X
  1189. Xlong TimeToMilliSeconds (timestr)
  1190. X  String   timestr;
  1191. X{
  1192. X    Boolean     in24hrformat;
  1193. X    int     hours, minutes, seconds;
  1194. X    struct tm  *now, *localtime();
  1195. X    time_t     abstime, time();
  1196. X
  1197. X    if (not ParseTimeString (timestr, &hours, &minutes, &in24hrformat))
  1198. X    return (INVALID);
  1199. X
  1200. X    if (*timestr == '+')
  1201. X    seconds = (hours * 60*60) + (minutes * 60);
  1202. X    else {
  1203. X    (void) time (&abstime);
  1204. X    now = localtime (&abstime);
  1205. X    seconds = ((hours - now->tm_hour) * 60*60) +
  1206. X        ((minutes - now->tm_min) * 60) - now->tm_sec;
  1207. X    while (seconds < 0)
  1208. X        seconds += (in24hrformat ? 24*60*60 : 12*60*60);
  1209. X    }
  1210. X    
  1211. X    return ((long) seconds*1000);
  1212. X}
  1213. X
  1214. X
  1215. X
  1216. X/* 
  1217. X * Parse that string.  Robbed and hacked from xcal (3.2) by Peter 
  1218. X * Collinson et al.
  1219. X */
  1220. X
  1221. Xstatic Boolean ParseTimeString (str, hrs, mins, in24hrf)
  1222. X  String    str;
  1223. X  int        *hrs, *mins;
  1224. X  Boolean  *in24hrf;
  1225. X{
  1226. X    enum  {Hhmm, hHmm, hh_mm, hhMm, hhmM, AmPm, aMpM, Finished}   state;
  1227. X    Boolean   relative;
  1228. X    int       numdigits = 0;
  1229. X    char     *s = str;
  1230. X              
  1231. X    if (relative = (*str == '+'))
  1232. X    str++;
  1233. X
  1234. X    while (*s)
  1235. X    if (isdigit (*s++))
  1236. X        numdigits++;
  1237. X
  1238. X    if (relative)
  1239. X    switch (numdigits) {
  1240. X     case 1: state = hhmM; break;
  1241. X     case 2: state = hhMm; break;
  1242. X     case 3: state = hHmm; break;
  1243. X     case 4: state = Hhmm; break;
  1244. X     default: return (False);
  1245. X    }
  1246. X    else
  1247. X    switch (numdigits) {
  1248. X     case 1:
  1249. X     case 2:
  1250. X     case 4: state = Hhmm; break;
  1251. X     case 3: state = hHmm; break;
  1252. X     default: return (False);
  1253. X    }
  1254. X
  1255. X    *hrs = *mins = 0;
  1256. X    *in24hrf = False;
  1257. X
  1258. X    while (state != Finished)
  1259. X    switch (state) {
  1260. X     case Hhmm:
  1261. X        if (isdigit (*str)) {
  1262. X        *hrs = VALUE (*str++);
  1263. X        state = hHmm;
  1264. X        continue;
  1265. X        }
  1266. X        else
  1267. X        return (False);
  1268. X     case hHmm:
  1269. X        if (isdigit (*str)) {
  1270. X        *hrs = *hrs*10 + VALUE (*str++);
  1271. X        state = hh_mm;
  1272. X        continue;
  1273. X        }
  1274. X     case hh_mm:
  1275. X        if (INSTRING (*str, ".:-")) {
  1276. X        state = hhMm;
  1277. X        str++;
  1278. X        continue;
  1279. X        }
  1280. X     case hhMm:
  1281. X        if (isdigit (*str)) {
  1282. X        *mins = VALUE (*str++);
  1283. X        state = hhmM;
  1284. X        continue;
  1285. X        }
  1286. X     case hhmM:
  1287. X        if (isdigit (*str)) {
  1288. X        *mins = *mins*10 + VALUE (*str++);
  1289. X        state = AmPm;
  1290. X        continue;
  1291. X        }
  1292. X     case AmPm:
  1293. X        if (*str == '\0') {
  1294. X        *in24hrf = (*hrs > 12);
  1295. X        state = Finished;
  1296. X        continue;
  1297. X        }
  1298. X        else
  1299. X        if (relative)
  1300. X            return (False);
  1301. X
  1302. X        if (INSTRING (*str, "Aa")) {
  1303. X        if (*hrs == 12)
  1304. X            *hrs = 0;
  1305. X        state = aMpM;
  1306. X        continue;
  1307. X        }
  1308. X        else
  1309. X        if (INSTRING (*str, "Pp")) {
  1310. X            if (*hrs < 12)
  1311. X            *hrs = *hrs + 12;
  1312. X            state = aMpM;
  1313. X            continue;
  1314. X        }
  1315. X        return (False);
  1316. X     case aMpM:
  1317. X        str++;
  1318. X        if (INSTRING (*str, "Mm")) {
  1319. X        *in24hrf = True;
  1320. X        str++;
  1321. X        state = Finished;
  1322. X        }
  1323. X        else
  1324. X        return (False);
  1325. X    }
  1326. X
  1327. X    return ((*hrs < 24) and (*mins < 60) and (*str == '\0'));
  1328. X}
  1329. END_OF_FILE
  1330. if test 6960 -ne `wc -c <'times.c'`; then
  1331.     echo shar: \"'times.c'\" unpacked with wrong size!
  1332. fi
  1333. # end of 'times.c'
  1334. fi
  1335. if test -f 'warning.c' -a "${1}" != "-c" ; then 
  1336.   echo shar: Will not clobber existing file \"'warning.c'\"
  1337. else
  1338. echo shar: Extracting \"'warning.c'\" \(3982 characters\)
  1339. sed "s/^X//" >'warning.c' <<'END_OF_FILE'
  1340. X/*
  1341. X      Copyright (c) 1991, 1992 by Simon Marshall, University of Hull, UK
  1342. X
  1343. X           If you still end up late, don't blame me!
  1344. X                       
  1345. X  Permission to use, copy, modify, distribute, and sell this software and its
  1346. X       documentation for any purpose and without fee is hereby granted,
  1347. X    provided that the above copyright notice appear in all copies and that
  1348. X    both that copyright notice and this permission notice appear in
  1349. X               supporting documentation.
  1350. X                       
  1351. X  This software is provided AS IS with no warranties of any kind.  The author
  1352. X    shall have no liability with respect to the infringement of copyrights,
  1353. X     trade secrets or any patents by this file or any part thereof.  In no
  1354. X      event will the author be liable for any lost revenue or profits or
  1355. X          other special, indirect and consequential damages.
  1356. X*/
  1357. X
  1358. X/* 
  1359. X * The stuff for dealing with warnings; processing to get the times & 
  1360. X * the fns for popping up the warnings themselves.
  1361. X */
  1362. X
  1363. X
  1364. X
  1365. X#include "xalarm.h"
  1366. X
  1367. X#include <X11/Xaw/Form.h>
  1368. X#include <X11/Xaw/Command.h>
  1369. X
  1370. X
  1371. X#define        WARNING        "Warning: %s due in "
  1372. X
  1373. X
  1374. Xvoid        SetWarningTimes(), Warning();
  1375. Xstatic void    QuitWarning();
  1376. Xextern long    TimeToMilliSeconds();
  1377. Xextern void    SetGeometry(), Quit();
  1378. X
  1379. X
  1380. Xextern AlarmData    xalarm;
  1381. X
  1382. X
  1383. X
  1384. X/* 
  1385. X * Process the string to extract warning times.  Currently just gives 
  1386. X * a message if a warning time is invalid.
  1387. X */
  1388. X
  1389. Xvoid SetWarningTimes (warnings)
  1390. X  String   warnings;
  1391. X{
  1392. X    String   warnstr = warnings;
  1393. X    char     warning[TEXT];
  1394. X    long     biggest;
  1395. X    int      i, j, bigindex;
  1396. X                
  1397. X    xalarm.numwarnings = 0;
  1398. X    while ((*warnstr != '\0') and (not ISINVALID (xalarm.numwarnings))) {
  1399. X    warning[i=0] = '+';
  1400. X    while ((*warnstr != ',') and (*warnstr != '\0'))
  1401. X        warning[++i] = *warnstr++;
  1402. X    warning[++i] = '\0';
  1403. X
  1404. X    switch (xalarm.warnings[xalarm.numwarnings] = TimeToMilliSeconds (warning)) {
  1405. X     case 0:
  1406. X        break;
  1407. X     case INVALID:
  1408. X        xalarm.numwarnings = INVALID;
  1409. X        break;
  1410. X     default:
  1411. X        xalarm.numwarnings++;
  1412. X        break;
  1413. X    }
  1414. X
  1415. X    while (*warnstr == ',')
  1416. X        warnstr++;
  1417. X    }
  1418. X    if ((warnstr != warnings) and (*(warnstr-1) == ','))
  1419. X    xalarm.numwarnings = INVALID;
  1420. X
  1421. X    /* 
  1422. X     * Sort it, why not?
  1423. X     */
  1424. X    for (i=0; i<xalarm.numwarnings-1; i++) {
  1425. X    biggest = xalarm.warnings[bigindex = i];
  1426. X    for (j=i+1; j<xalarm.numwarnings; j++)
  1427. X        if (xalarm.warnings[j] > biggest)
  1428. X        biggest = xalarm.warnings[bigindex = j];
  1429. X    xalarm.warnings[bigindex] = xalarm.warnings[i];
  1430. X    xalarm.warnings[i] = biggest;
  1431. X    }
  1432. X}
  1433. X
  1434. X
  1435. X
  1436. X/* 
  1437. X * pop up a warning.  includes a dismiss & quit button.
  1438. X */
  1439. X
  1440. Xvoid Warning (clientdata, id)
  1441. X  XtPointer      clientdata;
  1442. X  XtIntervalId      id;
  1443. X{
  1444. X    Widget    popup, warningbox, dismiss, quit;
  1445. X    int       count;
  1446. X    char      buf[TEXT], warnmessage[TEXT], *wm = warnmessage;
  1447. X
  1448. X    popup = XtVaCreatePopupShell ("Warning!", transientShellWidgetClass, xalarm.toplevel,
  1449. X                  NULL);
  1450. X
  1451. X    warningbox = XtVaCreateManagedWidget ("warning", formWidgetClass, popup, NULL);
  1452. X
  1453. X    if (xalarm.warningwords == 0)
  1454. X    (void) sprintf (buf, WARNING, xalarm.proggie+1);
  1455. X    else {
  1456. X    (void) sprintf (warnmessage, "`%s", xalarm.messagestr);
  1457. X    count = xalarm.warningwords;
  1458. X    while ((count-- > 0) and (*wm != '\0')) {
  1459. X        while (isspace (*wm))
  1460. X        *wm++ = ' ';
  1461. X        while (not isspace (*wm) and (*wm != '\0'))
  1462. X        wm++;
  1463. X    }
  1464. X    (void) sprintf (wm, "%s", (*wm == '\0') ? "' " : "...' ");
  1465. X    (void) sprintf (buf, WARNING, warnmessage);
  1466. X    }
  1467. X
  1468. X    MAKETIMESTRING (buf + strlen (buf), (int) clientdata);
  1469. X
  1470. X    CreateManagedButton (dismiss, "dismiss", warningbox, QuitWarning, popup);
  1471. X    XtVaCreateManagedWidget ("message", labelWidgetClass, warningbox,
  1472. X                 XtNlabel, (XtArgVal) buf, NULL);
  1473. X    CreateManagedButton (quit, "quit", warningbox, Quit, NULL);
  1474. X
  1475. X    SetGeometry (popup);
  1476. X    if (xalarm.bell)
  1477. X    XBell (XtDisplay (xalarm.toplevel), 0);
  1478. X    XtPopup (popup, XtGrabNone);
  1479. X}
  1480. X  
  1481. X         
  1482. X
  1483. Xstatic void QuitWarning (widget, clientdata, calldata)
  1484. X  Widget      widget;
  1485. X  XtPointer   clientdata, calldata;
  1486. X{
  1487. X    XtPopdown ((Widget) clientdata);
  1488. X}
  1489. END_OF_FILE
  1490. if test 3982 -ne `wc -c <'warning.c'`; then
  1491.     echo shar: \"'warning.c'\" unpacked with wrong size!
  1492. fi
  1493. # end of 'warning.c'
  1494. fi
  1495. if test -f 'when.c' -a "${1}" != "-c" ; then 
  1496.   echo shar: Will not clobber existing file \"'when.c'\"
  1497. else
  1498. echo shar: Extracting \"'when.c'\" \(7825 characters\)
  1499. sed "s/^X//" >'when.c' <<'END_OF_FILE'
  1500. X/*
  1501. X      Copyright (c) 1991, 1992 by Simon Marshall, University of Hull, UK
  1502. X
  1503. X           If you still end up late, don't blame me!
  1504. X                       
  1505. X  Permission to use, copy, modify, distribute, and sell this software and its
  1506. X       documentation for any purpose and without fee is hereby granted,
  1507. X    provided that the above copyright notice appear in all copies and that
  1508. X    both that copyright notice and this permission notice appear in
  1509. X               supporting documentation.
  1510. X                       
  1511. X  This software is provided AS IS with no warranties of any kind.  The author
  1512. X    shall have no liability with respect to the infringement of copyrights,
  1513. X     trade secrets or any patents by this file or any part thereof.  In no
  1514. X      event will the author be liable for any lost revenue or profits or
  1515. X          other special, indirect and consequential damages.
  1516. X*/
  1517. X
  1518. X/* 
  1519. X * Stuff for getting the time the alarm is due to go off, and 
  1520. X * confirmation if needed.
  1521. X */
  1522. X
  1523. X
  1524. X
  1525. X#include "xalarm.h"
  1526. X
  1527. X#include <X11/Xaw/Dialog.h>
  1528. X
  1529. X
  1530. X#define        TIMEINSTRUCTIONS    "Enter time (as [+]time[am/pm]):"
  1531. X#define        WARNINGINSTRUCTIONS    "Enter warnings (as time[,time...]):"
  1532. X#define        CONFIRMFORMAT        "%s, %d:%02d (in %d:%02d), "
  1533. X#define        EDITTIME        (0)
  1534. X#define        EDITWARNINGS        (2)
  1535. X#define        EDITED(str,widget)    (strcmp (str, XawDialogGetValueString (widget)))
  1536. X#define        DIALOGVALUE(widget)    (XtNewString (XawDialogGetValueString (widget)))
  1537. X#define        UPCASE(ch)        (((ch) >= 'a') and ((ch) <= 'z') ? \
  1538. X                     ((ch) - 'a' + 'A') : (ch))
  1539. X
  1540. X
  1541. X
  1542. Xvoid        PopupAndAsk(), EnteredTime(), EnteredWarnings(), Confirmed();
  1543. Xstatic void    PopupAndConfirm(), Popup(), PopupNext(), Edit(), Cancel();
  1544. Xextern void    Quit(), AddTimeOuts(), SetWarningTimes(), SetGeometry();
  1545. Xextern long    TimeToMilliSeconds();
  1546. X
  1547. X
  1548. X
  1549. Xextern AlarmData    xalarm;
  1550. X
  1551. X
  1552. X
  1553. X/* 
  1554. X * just pop up a dialog widget to get an at/in time.  won't pop down 
  1555. X * until a valid time is given.  EnteredTime() does this.
  1556. X */
  1557. X
  1558. Xvoid PopupAndAsk ()
  1559. X{
  1560. X    Widget    popup, gettimewidget, getwtimewidget, confirmwidget;
  1561. X
  1562. X    popup = XtVaCreatePopupShell ("When?", transientShellWidgetClass, xalarm.toplevel,
  1563. X                  NULL);
  1564. X
  1565. X    gettimewidget = XtVaCreateManagedWidget ("when", dialogWidgetClass, popup, NULL);
  1566. X    XawDialogAddButton (gettimewidget, "ok", EnteredTime, (XtPointer) NULL);
  1567. X    XawDialogAddButton (gettimewidget, "toggle", Edit, (XtPointer) EDITWARNINGS);
  1568. X    XawDialogAddButton (gettimewidget, "quit", Quit, (XtPointer) NULL);
  1569. X
  1570. X    getwtimewidget = XtVaCreateManagedWidget ("warnings", dialogWidgetClass, popup, NULL);
  1571. X    XawDialogAddButton (getwtimewidget, "ok", EnteredWarnings, (XtPointer) NULL);
  1572. X    XawDialogAddButton (getwtimewidget, "toggle", Edit, (XtPointer) EDITTIME);
  1573. X    XawDialogAddButton (getwtimewidget, "quit", Quit, (XtPointer) NULL);
  1574. X
  1575. X    confirmwidget = XtVaCreateManagedWidget ("confirm", dialogWidgetClass, popup, NULL);
  1576. X    XawDialogAddButton (confirmwidget, "ok", Confirmed, (XtPointer) NULL);
  1577. X    XawDialogAddButton (confirmwidget, "cancel", Cancel, (XtPointer) NULL);
  1578. X    XawDialogAddButton (confirmwidget, "quit", Quit, (XtPointer) NULL);
  1579. X
  1580. X    XtVaSetValues (xalarm.gettimewidget = gettimewidget,
  1581. X           XtNvalue, (XtArgVal) xalarm.timestr, NULL);
  1582. X    XtVaSetValues (xalarm.getwtimewidget = getwtimewidget,
  1583. X           XtNvalue, (XtArgVal) xalarm.warningsstr, NULL);
  1584. X    XtVaSetValues (xalarm.confirmwidget = confirmwidget,
  1585. X           XtNvalue, (XtArgVal) xalarm.messagestr, NULL);
  1586. X
  1587. X    SetGeometry (popup);
  1588. X    XtPopup (popup, XtGrabExclusive);
  1589. X    PopupNext ();
  1590. X}
  1591. X
  1592. X
  1593. X
  1594. X/* 
  1595. X * Popup the next dialog, if more needs to be entered.
  1596. X */
  1597. X
  1598. Xstatic void PopupNext ()
  1599. X{
  1600. X    if (ISINVALID (xalarm.timeout) or
  1601. X    EDITED (xalarm.timestr, xalarm.gettimewidget))
  1602. X    Popup (xalarm.gettimewidget, TIMEINSTRUCTIONS);
  1603. X    else if (ISINVALID (xalarm.numwarnings) or
  1604. X         EDITED (xalarm.warningsstr, xalarm.getwtimewidget))
  1605. X    Popup (xalarm.getwtimewidget, WARNINGINSTRUCTIONS);
  1606. X    else
  1607. X    PopupAndConfirm ();
  1608. X}
  1609. X
  1610. X
  1611. X
  1612. X/* 
  1613. X * If invalid, stay.  Otherwise, get the rest, if any.
  1614. X */
  1615. X
  1616. Xvoid EnteredTime (widget, clientdata, calldata)
  1617. X  Widget      widget;
  1618. X  XtPointer   clientdata, calldata;
  1619. X{
  1620. X    char   message[TEXT];
  1621. X
  1622. X    xalarm.timeout = TimeToMilliSeconds
  1623. X    (xalarm.timestr = DIALOGVALUE (xalarm.gettimewidget));
  1624. X
  1625. X    if (not ISINVALID (xalarm.timeout))
  1626. X    PopupNext ();
  1627. X    else {
  1628. X    (void) sprintf (message, "Invalid.  %s", TIMEINSTRUCTIONS);
  1629. X    XtVaSetValues (xalarm.gettimewidget, XtNlabel, (XtArgVal) message, NULL);
  1630. X    }
  1631. X}
  1632. X
  1633. X
  1634. X
  1635. X/* 
  1636. X * If invalid, stay.  Otherwise, get the rest, if any.
  1637. X */
  1638. X
  1639. Xvoid EnteredWarnings (widget, clientdata, calldata)
  1640. X  Widget      widget;
  1641. X  XtPointer   clientdata, calldata;
  1642. X{
  1643. X    char   message[TEXT];
  1644. X
  1645. X    SetWarningTimes (xalarm.warningsstr = DIALOGVALUE (xalarm.getwtimewidget));
  1646. X
  1647. X    if (not ISINVALID (xalarm.numwarnings))
  1648. X    PopupNext ();
  1649. X    else {
  1650. X    (void) sprintf (message, "Invalid.  %s", WARNINGINSTRUCTIONS);
  1651. X    XtVaSetValues (xalarm.getwtimewidget, XtNlabel, (XtArgVal) message, NULL);
  1652. X    }
  1653. X}
  1654. X
  1655. X
  1656. X
  1657. X/* 
  1658. X * Just toggle whether i/t concerns alarm time/warning time(s).
  1659. X */
  1660. X
  1661. Xstatic void Edit (widget, clientdata, calldata)
  1662. X  Widget      widget;
  1663. X  XtPointer   clientdata, calldata;
  1664. X{
  1665. X    switch ((int) clientdata) {
  1666. X     case EDITTIME:
  1667. X    Popup (xalarm.gettimewidget, TIMEINSTRUCTIONS);
  1668. X    break;
  1669. X     case EDITWARNINGS:
  1670. X    Popup (xalarm.getwtimewidget, WARNINGINSTRUCTIONS);
  1671. X    break;
  1672. X    }
  1673. X}
  1674. X
  1675. X
  1676. X
  1677. X/* 
  1678. X * Popup to confirm, showing the time which the alarm will trigger.
  1679. X */
  1680. X
  1681. Xstatic void PopupAndConfirm ()
  1682. X{
  1683. X    static char   days[][4] = {WEEKDAYS};
  1684. X    char       message[TEXT];
  1685. X    struct tm      *alarmtime, *localtime();
  1686. X    time_t       now, time();
  1687. X    int       count = 0, i;
  1688. X
  1689. X    (void) time (&now);
  1690. X    now += (TimeToMilliSeconds (xalarm.timestr) / 1000);
  1691. X    alarmtime = localtime (&now);
  1692. X
  1693. X    days[alarmtime->tm_wday][0] = UPCASE (days[alarmtime->tm_wday][0]);
  1694. X    (void) sprintf (message, CONFIRMFORMAT, days[alarmtime->tm_wday],
  1695. X            alarmtime->tm_hour, alarmtime->tm_min,
  1696. X            xalarm.timeout/(1000*60*60), (xalarm.timeout/(1000*60)) % 60);
  1697. X
  1698. X    for (i=0; i<xalarm.numwarnings; i++)
  1699. X    if (xalarm.timeout > xalarm.warnings[i])
  1700. X        count++;
  1701. X
  1702. X    if (count == 0)
  1703. X    (void) sprintf (message + strlen (message), "no warnings:");
  1704. X    else 
  1705. X    (void) sprintf (message + strlen (message), "warning%s: ", PLURAL (count));
  1706. X
  1707. X    for (i=0; i<xalarm.numwarnings; i++)
  1708. X    if (xalarm.timeout > xalarm.warnings[i]) {
  1709. X        MAKETIME (message + strlen (message), xalarm.warnings[i]/(1000*60));
  1710. X        if (--count > 0)
  1711. X        (void) sprintf (message + strlen (message), ",");
  1712. X    }
  1713. X
  1714. X    Popup (xalarm.confirmwidget, message);
  1715. X}
  1716. X
  1717. X
  1718. X
  1719. X/* 
  1720. X * Yow!  Let's go!
  1721. X */
  1722. X
  1723. Xvoid Confirmed (widget, clientdata, calldata)
  1724. X  Widget      widget;
  1725. X  XtPointer   clientdata, calldata;
  1726. X{
  1727. X    String   message = DIALOGVALUE (xalarm.confirmwidget);
  1728. X
  1729. X    if (*message)
  1730. X    XtVaSetValues (xalarm.messagewidget,
  1731. X               XtNlabel, (XtArgVal) (xalarm.messagestr = message), NULL);
  1732. X
  1733. X    /* 
  1734. X     * Reset the timeout, since the gap between entering 
  1735. X     * and confirming may be significant.
  1736. X     */
  1737. X
  1738. X    xalarm.timeout = TimeToMilliSeconds (xalarm.timestr);
  1739. X    AddTimeOuts ();
  1740. X
  1741. X    XtPopdown (XtParent (xalarm.gettimewidget));
  1742. X}
  1743. X
  1744. X
  1745. X
  1746. X/* 
  1747. X * Swap back to gettime widget & remove kbd focus.
  1748. X */
  1749. X
  1750. Xstatic void Cancel (widget, clientdata, calldata)
  1751. X  Widget      widget;
  1752. X  XtPointer   clientdata, calldata;
  1753. X{
  1754. X    Popup (xalarm.gettimewidget, TIMEINSTRUCTIONS);
  1755. X}
  1756. X
  1757. X
  1758. X
  1759. X/* 
  1760. X * Let's get this widget to the top and set the kbd focus to it.
  1761. X * Set the label for the new widget.
  1762. X */
  1763. X
  1764. Xstatic void Popup (widget, label)
  1765. X  Widget   widget;
  1766. X  String   label;
  1767. X{
  1768. X    XtVaSetValues (widget, XtNlabel, (XtArgVal) label, NULL);
  1769. X
  1770. X    XtSetMappedWhenManaged (xalarm.gettimewidget, (widget == xalarm.gettimewidget));
  1771. X    XtSetMappedWhenManaged (xalarm.getwtimewidget, (widget == xalarm.getwtimewidget));
  1772. X    XtSetMappedWhenManaged (xalarm.confirmwidget, (widget == xalarm.confirmwidget));
  1773. X
  1774. X    XtSetKeyboardFocus (XtParent (xalarm.gettimewidget), widget);
  1775. X}
  1776. END_OF_FILE
  1777. if test 7825 -ne `wc -c <'when.c'`; then
  1778.     echo shar: \"'when.c'\" unpacked with wrong size!
  1779. fi
  1780. # end of 'when.c'
  1781. fi
  1782. if test -f 'xalarm.h' -a "${1}" != "-c" ; then 
  1783.   echo shar: Will not clobber existing file \"'xalarm.h'\"
  1784. else
  1785. echo shar: Extracting \"'xalarm.h'\" \(4006 characters\)
  1786. sed "s/^X//" >'xalarm.h' <<'END_OF_FILE'
  1787. X/*
  1788. X      Copyright (c) 1991, 1992 by Simon Marshall, University of Hull, UK
  1789. X
  1790. X           If you still end up late, don't blame me!
  1791. X                       
  1792. X  Permission to use, copy, modify, distribute, and sell this software and its
  1793. X       documentation for any purpose and without fee is hereby granted,
  1794. X    provided that the above copyright notice appear in all copies and that
  1795. X    both that copyright notice and this permission notice appear in
  1796. X               supporting documentation.
  1797. X                       
  1798. X  This software is provided AS IS with no warranties of any kind.  The author
  1799. X    shall have no liability with respect to the infringement of copyrights,
  1800. X     trade secrets or any patents by this file or any part thereof.  In no
  1801. X      event will the author be liable for any lost revenue or profits or
  1802. X          other special, indirect and consequential damages.
  1803. X*/
  1804. X
  1805. X#ifndef xalarm_h
  1806. X#define xalarm_h
  1807. X
  1808. X/* 
  1809. X * Bits & bobs #defines, needed by most/all bits & bobs files.
  1810. X */
  1811. X
  1812. X#include "patchlevel.h"
  1813. X
  1814. X#include <stdio.h>
  1815. X#include <ctype.h>
  1816. X#include <signal.h>
  1817. X
  1818. X#include <X11/Xos.h>
  1819. X#include <X11/Intrinsic.h>
  1820. X#include <X11/StringDefs.h>
  1821. X#include <X11/Shell.h>
  1822. X
  1823. X
  1824. X/* 
  1825. X * Change these if you want a different notation/language.  Keep it to 
  1826. X * 3 chars each, lower case only.
  1827. X */
  1828. X
  1829. X#define        WEEKDAYS    "sun", "mon", "tue", "wed", "thu", "fri", "sat"
  1830. X#define        MONTHS        "jan", "feb", "mar", "apr", "may", "jun", \
  1831. X                "jul", "aug", "sep", "oct", "nov", "dec"
  1832. X
  1833. X/* 
  1834. X * Application data - from the parsing of the command line args.
  1835. X */
  1836. X
  1837. Xtypedef struct {
  1838. X    String    snooze, proggie, geometry, time, warnings;
  1839. X    Boolean   bell, confirm, list, version, help;
  1840. X    int       reset, warningwords;
  1841. X} ApplData, *ApplDataPtr;
  1842. X
  1843. X
  1844. X/* 
  1845. X * Global xalarm data, stuffed under one structure.
  1846. X */
  1847. X
  1848. Xtypedef struct {
  1849. X    XtAppContext   appcon;
  1850. X    Widget        toplevel, alarmwidget, messagewidget, snoozetimewidget,
  1851. X           gettimewidget, getwtimewidget, confirmwidget;
  1852. X    Boolean        bell, confirm;
  1853. X    String        proggie, geometry, messagestr, timestr, warningsstr;
  1854. X    int        snooze, numwarnings, warningwords;
  1855. X    long        timeout, warnings[100], settime;
  1856. X    XtIntervalId   timeouts[100];
  1857. X} AlarmData, *AlarmDataPtr;
  1858. X
  1859. X/* 
  1860. X * macro names...
  1861. X */
  1862. X
  1863. X#define        XtNtime        "time"
  1864. X#define        XtCTime        "Time"
  1865. X#define        XtNwarnings    "warnings"
  1866. X#define        XtCWarnings    "Warnings"
  1867. X#define        XtNwarningwords    "warningwords"
  1868. X#define        XtCWarningwords "Warningwords"
  1869. X#define        XtNsnooze    "snooze"
  1870. X#define        XtCSnooze    "Snooze"
  1871. X#define        XtNconfirm    "confirm"
  1872. X#define        XtCConfirm    "Confirm"
  1873. X#define        XtNreset    "reset"
  1874. X#define        XtCReset    "Reset"
  1875. X#define        XtNbell        "bell"
  1876. X#define        XtCBell        "Bell"
  1877. X#define        XtNlist        "list"
  1878. X#define        XtCList        "List"
  1879. X#define        XtNversion    "version"
  1880. X#define        XtCVersion    "Version"
  1881. X#define        XtNhelp        "help"
  1882. X#define        XtCHelp        "Help"
  1883. X
  1884. X/* 
  1885. X * A R4 problem, I think, not apparent in R5.
  1886. X */
  1887. X
  1888. X#ifndef XtNname
  1889. X#define        XtNname        "name"
  1890. X#endif
  1891. X#ifndef XtCName
  1892. X#define        XtCName        "Name"
  1893. X#endif
  1894. X
  1895. X/* 
  1896. X * And the rest...
  1897. X */
  1898. X
  1899. X#define        NOGEOMETRY    "NOGEOM"
  1900. X#define        or        ||
  1901. X#define        and        &&
  1902. X#define        not        !
  1903. X#define        INVALID        (-1)
  1904. X#define        TEXT        1024
  1905. X
  1906. X#if defined(SIGNALRETURNSINT)
  1907. X#define        SIGRET        int
  1908. X#else
  1909. X#define        SIGRET        void
  1910. X#endif
  1911. X
  1912. X
  1913. X#define        CreateManagedButton(widget,name,parent,callback,clientdata) \
  1914. X    widget = XtVaCreateManagedWidget (name, commandWidgetClass, parent, NULL); \
  1915. X    XtAddCallback (widget, XtNcallback, callback, (XtPointer) clientdata)
  1916. X
  1917. X
  1918. X#define        ISINVALID(x)    ((x) == (INVALID))
  1919. X
  1920. X#define        PLURAL(x)    ((((int) (x)) == 1) ? "" : "s")
  1921. X
  1922. X#define        MAX(x,y)    ((x) > (y) ? (x) : (y))
  1923. X#define        MIN(x,y)    ((x) < (y) ? (x) : (y))
  1924. X
  1925. X
  1926. X#define        MAKETIMESTRING(buf,mins) \
  1927. X                    if ((mins) >= 60) \
  1928. X    (void) sprintf (buf, "%d:%02d hr%s", (mins)/60, (mins)%60, PLURAL ((mins)/60)); \
  1929. X                else \
  1930. X    (void) sprintf (buf, "%d min%s", (mins), PLURAL (mins));
  1931. X
  1932. X#define        MAKETIME(buf,mins) \
  1933. X                    if ((mins) >= 60) \
  1934. X    (void) sprintf (buf, "%d:%02d", (mins)/60, (mins)%60); \
  1935. X                else \
  1936. X    (void) sprintf (buf, "%d", (mins));
  1937. X
  1938. X         
  1939. X/*
  1940. X * DON'T PUT ANYTHING AFTER THIS!!!
  1941. X */
  1942. X#endif
  1943. END_OF_FILE
  1944. if test 4006 -ne `wc -c <'xalarm.h'`; then
  1945.     echo shar: \"'xalarm.h'\" unpacked with wrong size!
  1946. fi
  1947. # end of 'xalarm.h'
  1948. fi
  1949. echo shar: End of archive 2 \(of 3\).
  1950. cp /dev/null ark2isdone
  1951. MISSING=""
  1952. for I in 1 2 3 ; do
  1953.     if test ! -f ark${I}isdone ; then
  1954.     MISSING="${MISSING} ${I}"
  1955.     fi
  1956. done
  1957. if test "${MISSING}" = "" ; then
  1958.     echo You have unpacked all 3 archives.
  1959.     rm -f ark[1-9]isdone
  1960. else
  1961.     echo You still need to unpack the following archives:
  1962.     echo "        " ${MISSING}
  1963. fi
  1964. ##  End of shell archive.
  1965. exit 0
  1966. -- 
  1967. Molecular Simulations, Inc.             mail: dcmartin@msi.com
  1968. 796 N. Pastoria Avenue                  uucp: uunet!dcmartin
  1969. Sunnyvale, California 94086             at&t: 408/522-9236
  1970.