home *** CD-ROM | disk | FTP | other *** search
- Path: uunet!zaphod.mps.ohio-state.edu!mips!msi!dcmartin
- From: S.Marshall@sequent.cc.hull.ac.uk (Simon Marshall)
- Newsgroups: comp.sources.x
- Subject: v16i037: Xalarm 3.02, Part02/03
- Message-ID: <1992Feb5.144747.20543@msi.com>
- Date: 5 Feb 92 14:47:47 GMT
- References: <csx-16i036-xalarm-3.02@uunet.UU.NET>
- Sender: dcmartin@msi.com (David C. Martin - Moderator)
- Organization: Molecular Simulations, Inc.
- Lines: 1956
- Approved: dcmartin@msi.com
- Originator: dcmartin@fascet
-
- Submitted-by: Simon Marshall <S.Marshall@sequent.cc.hull.ac.uk>
- Posting-number: Volume 16, Issue 37
- Archive-name: xalarm-3.02/part02
-
- # This is a shell archive. Remove anything before this line, then feed it
- # into a shell via "sh file" or similar. To overwrite existing files,
- # type "sh file -c".
- # The tool that generated this appeared in the comp.sources.unix newsgroup;
- # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
- # If this archive is complete, you will see the following message at the end:
- # "End of archive 2 (of 3)."
- # Contents: ChangeLog INSTALL Imakefile Makefile.alt XAlarm.ad alarm.c
- # config.1st fullpath man.man times.c warning.c when.c xalarm.h
- # Wrapped by dcmartin@fascet on Wed Feb 5 06:46:37 1992
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'ChangeLog' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'ChangeLog'\"
- else
- echo shar: Extracting \"'ChangeLog'\" \(8795 characters\)
- sed "s/^X//" >'ChangeLog' <<'END_OF_FILE'
- XSat Feb 1 15:40:29 1992 Simon Marshall (sm at olympus)
- X
- X * Released patch 2.
- X
- XThu Jan 30 11:11:01 1992 Simon Marshall (sm at olympus)
- X
- X * Behaves properly during leap years.
- X
- X * Fixed bug whereby dates are parsed wrongly if the number of days in
- X the current month is more than the number of days in the month given.
- X
- X * Better error messages with unrecognised dates.
- X
- XTue Jan 21 11:10:34 1992 Simon Marshall (sm at olympus)
- X
- X * Made config.1st try to find locations, instead of assuming a Sun.
- X Forgot to include times.o as dependent on xalarm.h. Non-existent
- X function was declared.
- X
- X * Fixed bug whereby changes in the dialog was silently accepted while
- X changing other values.
- X
- X * Resources properly label all quit buttons.
- X
- XMon Jan 20 10:08:55 1992 Simon Marshall (sm at olympus)
- X
- X * Released patch 1.
- X
- XWed Jan 15 14:58:08 1992 Simon Marshall (sm at olympus)
- X
- X * Input in the dialog popup properly is directed to the visible widget.
- X
- X * Cleaned resources, man page & xmemo doesn't ask for confirmation.
- X
- XFri Jan 3 13:51:52 1992 Simon Marshall (sm at olympus)
- X
- X * Fixed Imakefile where blanks after ManSuffix were not stripped, from
- X Jonathan I. Kamens.
- X
- XThu Dec 19 15:23:46 1991 Simon Marshall (sm at olympus)
- X
- X * Solved the auto-resize; just took the width resource out.
- X
- X * Casted everything properly to shut up picky compilers.
- X
- XWed Dec 18 19:29:08 1991 Simon Marshall (sm at olympus)
- X
- X * Made all the windows proper transient shells as they should be. If
- X no geometry is given, the windows popup under the mouse pointer.
- X
- X * Can no longer kill xalarm via the WM_DELETE_WINDOW protocol. It has
- X no effect with shells widgets.
- X
- XFri Dec 6 13:36:08 1991 Simon Marshall (sm at olympus)
- X
- X * Fixed bug in AppointmentIsToday() which under certain circumstances
- X would parse times in files wrong or core dump. Forgot to XtMalloc() in
- X a couple of places.
- X
- XThu Dec 5 18:29:45 1991 Simon Marshall (sm at olympus)
- X
- X * Words from the alarm message can be incorporated in the warning
- X popup. From an idea by Evan Bigall.
- X
- XSun Dec 1 14:20:46 1991 Simon Marshall (sm at olympus)
- X
- X * Made resources control the cursor shapes; took gumby out of alarm.c.
- X
- XThu Oct 17 14:46:01 1991 Simon Marshall (sm at olympus)
- X
- X * Added justification for the Dialog widget label. Still makes a
- X widget bigger than need be though.
- X
- XSun Oct 13 17:40:00 1991 Simon Marshall (sm at olympus)
- X
- X * For the confirmation window, sorts the warning times into descending
- X order, and takes the day of the week from WEEKDAYS rather than ctime(),
- X in case a different language is being used.
- X
- XSat Oct 5 15:37:59 1991 Simon Marshall (sm at olympus)
- X
- X * Released xalarm-3.
- X
- XWed Oct 2 14:35:15 1991 Simon Marshall (sm at olympus)
- X
- X * Taken out the makeX and put that stuff in with config.1st, let the
- X user sort it out.
- X
- XMon Sep 30 19:12:40 1991 Simon Marshall (sm at olympus)
- X
- X * Added -list so xalarm shows what ps thinks are the user's xalarm pids
- X are. Had to alter the makefiles so that you could set where ps & the
- X rest where; added a config.1st to do this.
- X
- XSun Sep 29 22:16:09 1991 Simon Marshall (sm at olympus)
- X
- X * Made xalarm capable of parsing a file for alarms, so for regular
- X times, it will set alarms automatically.
- X
- XFri Sep 27 10:43:41 1991 Simon Marshall (sm at olympus)
- X
- X * Fed up with ``Is it only BSD that uses bzero, or only SYSV that uses
- X memset? Or is it a bit of both?'' Wrote my own.
- X
- XWed Sep 25 22:17:05 1991 Simon Marshall (sm at olympus)
- X
- X * Split README into README and INSTALL. Made it all a touch more
- X portable? Thanks to Andreas Stolcke. Made the manual more readable,
- X thanks to suggestions by Bill Leonard.
- X
- XTue Sep 24 21:54:30 1991 Simon Marshall (sm at olympus)
- X
- X * Added a -snooze & resource on suggestion by Bill Leonard, so you can
- X have a default snoozetime already set for you. Corrected bits & bobs
- X in man page too.
- X
- XSun Sep 15 21:41:52 1991 Simon Marshall (sm at olympus)
- X
- X * Cleaned up for release in contrib for R5; re-named xalarm-3 for good
- X measure.
- X
- X * Added a -reset kill & signal trapper code so that you can wake up an
- X alarm and change the times.
- X
- XThu Sep 5 12:24:56 1991 Simon Marshall (sm at olympus)
- X
- X * Added a make flag & fix for the X crash-on-zero-timeout (bug report
- X from Jamie Zawinsk). Cleaned up Makefile & README.
- X
- XMon Sep 2 11:54:20 1991 Simon Marshall (sm at olympus)
- X
- X * Fixed the little problem with the clear button, although the resource
- X still isn't changeable by the user.
- X
- XTue Aug 27 17:08:47 1991 Simon Marshall (sm at olympus)
- X
- X * The timeout is now recalculated on confirmation so that if the time
- X is absolute, messing around during confirmation won't result in a late
- X alarm.
- X
- XWed Aug 21 18:00:00 1991 Simon Marshall (sm at olympus)
- X
- X * Released xalarm-2.00.
- X
- XTue Aug 20 10:25:58 1991 Simon Marshall (sm at olympus)
- X
- X * Fixed a little bug as a result of yesterday; if an invalid time is
- X given with the noconfirm option, the alarm message text is "".
- X
- X * Finally made the popups get their geometry from the alarm, by
- X intercepting it from the command line...
- X
- XMon Aug 19 13:56:53 1991 Simon Marshall (sm at olympus)
- X
- X * Added xmemo (thanks to an unconnected posting by Dan Jacobson, I
- X think) & found a bug in the manual - used -beep instead of -bell!!!
- X Added -beep & -nobeep to options...
- X
- XSun Aug 18 11:17:45 1991 Simon Marshall (sm at olympus)
- X
- X * Put the toggling back (!) so you can fiddle with warning times too.
- X
- X * Changed -at and -in to -time, -in times preceded by a `+' (but
- X warning times aren't). None of that silly toggling etc. Also made
- X some options have shorter aliases.
- X
- X * Made xalarm overwrite any given message, so ps etc can't show what it
- X is. From a comment by Reiner Hammer.
- X
- XFri Aug 16 12:25:08 1991 Simon Marshall (sm at olympus)
- X
- X * Cleaned up here & there.
- X
- X * Incorporated a hacked version of the time parser from xcal-3.2, Peter
- X Collinson et al.
- X
- X * Changed the way warnings are given. No longer within quotes, they
- X must be separated by commas (only).
- X
- XWed Aug 14 12:58:29 1991 Simon Marshall (sm at olympus)
- X
- X * Corrected bug whereby time wasn't always correctly calculated when
- X given as 12 hour clock but >12 hours ahead.
- X
- XTue Aug 13 12:41:32 1991 Simon Marshall (sm at olympus)
- X
- X * Added forking - so must easier than I had assumed. No closing to do
- X after all. Thanks to Gordon Freedman & Janet Anstett.
- X
- XFri Aug 9 13:38:35 1991 Simon Marshall (sm at olympus)
- X
- X * Added -h[elp].
- X
- XThu Aug 8 15:04:56 1991 Simon Marshall (sm at olympus)
- X
- X * Added -v[ersion]; I'm fed up with getting bug reports without it.
- X
- X * Added a config to Makefile so as to make sure stuff is ready for
- X making & running/playing with.
- X
- XMon Aug 5 15:46:00 1991 Simon Marshall (sm at olympus)
- X
- X * It appears that stuff in .../lib/X11/app-defaults is not
- X pre-processed with cpp, so we can't have "#ifdef" etc in there. Moved
- X colour stuff to separate file. From Scott Blachovicz & a multitude of
- X others.
- X
- XSun Aug 4 15:12:06 1991 Simon Marshall (sm at olympus)
- X
- X * Corrected bug whereby When?.when.label was for "at" time when it
- X should be "in", when user gave invalid "in" time on the command line.
- X
- X * If enabled, confirmation is now always sort, unless alarm is to
- X trigger immediately.
- X
- X * Made warnings only accept times in the [[[h]h]m]m format a` la -in.
- X Invalid times result in an error message on stderr only. Also added
- X -nowarn. (Implemented as "-warn 0" :-)
- X
- XFri Aug 2 09:46:42 1991 Simon Marshall (sm at olympus)
- X
- X * Added confirmation stuff to xalarm. Does not confirm if using
- X relative time given on the command line. Also added -confirm,
- X -noconfirm and -nobell.
- X
- X * Split up xalarm into more meaningful pieces. Preparation for
- X xalarm-2.00?
- X
- XWed Jul 31 13:20:29 1991 Simon Marshall (sm at olympus)
- X
- X * Released xalarm-1.01.
- X
- X * Made MakeX which looks for the absolute path of an executable. Need
- X it for yow, as it is often not is a person's path.
- X
- X * Fixed bug/mistake. I had sometimes declared warg as an Arg, but
- X XtSetValues expects an ArgList. Changed to declare as warg[1]. From
- X comments made by Dave Brooks, Bill Leonard & Braham Levy (plus more
- X once our mailer came up).
- X
- X * Added 2 options; -bell and -warn "...". By default the bell no
- X longer sounds, and the warning times can be specified. Both have
- X resources of course. From comments by Bill Leonard.
- X
- X * Updated the manual & made it clearer.
- X
- XTue Jul 30 10:29:22 1991 Simon Marshall (sm at olympus)
- X
- X * Changed the way the time is calculated. No more fiddling with
- X strings & it's much more compact.
- X
- X * Added Imakefile, sent by Andreas Stolcke (stolcke@edu.Berkeley.ICSI).
- X I don't know how useful it is, our imake isn't installed.
- X
- X * Changed default font for value entry to 9x15bold in XAlarm.ad; it is
- X a little more readable.
- END_OF_FILE
- if test 8795 -ne `wc -c <'ChangeLog'`; then
- echo shar: \"'ChangeLog'\" unpacked with wrong size!
- fi
- # end of 'ChangeLog'
- fi
- if test -f 'INSTALL' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'INSTALL'\"
- else
- echo shar: Extracting \"'INSTALL'\" \(4221 characters\)
- sed "s/^X//" >'INSTALL' <<'END_OF_FILE'
- XMAKING
- X~~~~~~
- X
- X First get any relevant patch files so as to make the latest patch version.
- X You can find out which patch level your xalarm is at by looking at the file
- X patchlevel.h in the source directory, or, if you have xalarm built, by:
- X
- X% xalarm -version
- X
- X See the man page for more. Apply any patches, see the patch files themselves
- X for more information.
- X
- X If you have problems, have a look below.
- X
- X 1. If you don't want to use the Imakefile or the Makefile generated from
- X it, try using Makefile.alt. First check the flag settings, then
- X copy it to Makefile.
- X Otherwise use the supplied Makefile, or check the Imakefile and
- X generate your own Makefile by "xmkmf".
- X
- X If you want to use a different notation or language for dates, see the
- X definitions for WEEKDAYS and MONTHS in xalarm.h.
- X
- X 2. First, "make config". Answer the questions.
- X
- X 3. Try making with "make". Have a play.
- X
- X 4. If you aren't installing (you selfish get), put the XAlarm.ad and
- X XAlarm.ad+ in your ~/.xresources file.
- X Otherwise, try "make install", then "make install.man".
- X
- X Look at the manual for anything else & enjoy.
- X
- X
- XPROBLEMS
- X~~~~~~~~
- X
- X Compilation
- X
- X 1. When using the Makefile generated from the Imakefile, compiler says
- X things like, "Don't know how to make target `lib/Xaw/libXaw.a'". You
- X are not building in the contrib directory, so try removing $(DEPLIBS)
- X from the xalarm target in the Makefile.
- X
- X 2. When using the Makefile generated from the Imakefile, the loader says
- X things like, "ld: ./lib/Xaw/libXaw.a: No such file or directory". You
- X are not building in the contrib directory, so try re-defining
- X LOCAL_LIBRARIES to be "-lXaw -lXmu -lXt -lXext -lX11" in the Makefile.
- X
- X 3. Compiler complains about gethostname(). If you haven't got this, you
- X need to add -DNOGETHOSTNAME to DEFINES in the Makefile.
- X
- X 4. If you don't have "ps", "fgrep" or "colrm", you can compile xalarm, but
- X you won't be able to use the -list option. The command "ps" lists
- X processes. The command "fgrep" is a pattern matcher. The command
- X "colrm" removes everything from its input after the sixth column. If
- X you don't have this, you could possibly just use "tee" (giving its full
- X path, of course) or equivalent which just replicates its input. Look
- X at the file config.1st.
- X
- X 5. Similarly, if you don't have "fortune" or "yow", you can't have
- X "xfortune" or "xyow".
- X
- X 6. Make config (config.1st) does nothing. It's probably just the execing
- X of "fullpath" that's doing this. Hack config.1st to put the correct
- X definitions for PS, FGREP and COLRM in fns.h, and create the xfortune &
- X xyow shell scripts (if you can be bothered). None of this is essential
- X for xalarm, but something has to be defined in fns.h.
- X
- X 7. What about other programs, along with xyow and xfortune, can I make
- X these too? You will have to make the manual page (it would be a copy
- X of man.man) and install it yourself, but type:
- X
- X % config.1st yourprogram
- X
- X This will make the executable file "xyourprogram" in the current
- X directory.
- X
- X Alarm Layout
- X
- X 1. You want to layout the alarm buttons differently, don't you? Mine not
- X good enough? The buttons are within a Form Widget, so have a look at
- X the Xaw man page for this. Each button has the placement resources
- X fromHoriz, fromVert, horizDistance & vertDistance. There are some
- X suggestions in the xalarm man page too.
- X
- X The button box and message label are also in a (higher level) Form
- X widget, so you can also change the relationship of button box to
- X message text. See the man page too.
- X
- X Note that the ordering of resources are important; you can't refer to a
- X widget in a resource before it's created by xalarm. The order of
- X creation is:
- X
- X Parent Widget(s)
- X ---------------------
- X alarm buttons
- X buttons quit snooze snooze1 snooze5 snooze15 snoozetime
- X alarm message
- X
- X
- XBUGS
- X~~~~
- X
- X If you have any comments, suggestions, code, fixes, please let me know and I
- X will make an attempt to include them. A few ``things'' are mentioned in the
- X bugs section of the manual. Don't forget to include the xalarm version
- X number ("xalarm -version" gives it you), machine/OS, X11 release & patch etc.
- X
- END_OF_FILE
- if test 4221 -ne `wc -c <'INSTALL'`; then
- echo shar: \"'INSTALL'\" unpacked with wrong size!
- fi
- # end of 'INSTALL'
- fi
- if test -f 'Imakefile' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'Imakefile'\"
- else
- echo shar: Extracting \"'Imakefile'\" \(1191 characters\)
- sed "s/^X//" >'Imakefile' <<'END_OF_FILE'
- X/**/# Based on an Imakefile from:
- X/**/# Andreas Stolcke
- X/**/# International Computer Science Institute, Berkeley.
- X
- X
- X/**/# If you don't have gethostname() and you can't change the #define in
- X/**/# alarm.c to what ever it is on your system, add -DNOGETHOSTNAME here:
- XDEFINES = ${SIGNAL_DEFINES}
- X
- X
- XOBJS = alarm.o when.o warning.o times.o fns.o xalarm.o
- XSRCS = alarm.c when.c warning.c times.c fns.c xalarm.c
- X
- X
- XLOCAL_LIBRARIES = XawClientLibs
- X
- XComplexProgramTarget (xalarm)
- X
- XInstallAppDefaults (XAlarm)
- XInstallMultipleFlags (xmemo xfortune xyow,$(BINDIR),$(INSTBINFLAGS))
- XInstallManPage (xmemo,$(MANDIR))
- XInstallManPage (xfortune,$(MANDIR))
- XInstallManPage (xyow,$(MANDIR))
- X
- Xfns.h:
- X @config.1st
- X
- Xxmemo.man xyow.man xfortune.man:
- X echo ".so man"`echo ManSuffix`"/xalarm."`echo ManSuffix` > $@
- X
- Xxfortune::
- X
- Xxyow::
- X
- Xclean::
- X $(RM) xfortune xyow xmemo.man xyow.man xfortune.man fns.h
- X
- Xconfig::
- X @chmod +x config.1st fullpath xmemo
- X @config.1st fortune yow
- X @xrdb -merge XAlarm.ad
- X @xrdb -merge XAlarm.ad+
- X
- Xalarm.o: xalarm.h patchlevel.h
- Xwhen.o: xalarm.h patchlevel.h
- Xwarning.o: xalarm.h patchlevel.h
- Xtimes.o: xalarm.h patchlevel.h
- Xfns.o: xalarm.h patchlevel.h fns.h
- Xxalarm.o: xalarm.h patchlevel.h
- END_OF_FILE
- if test 1191 -ne `wc -c <'Imakefile'`; then
- echo shar: \"'Imakefile'\" unpacked with wrong size!
- fi
- # end of 'Imakefile'
- fi
- if test -f 'Makefile.alt' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'Makefile.alt'\"
- else
- echo shar: Extracting \"'Makefile.alt'\" \(2271 characters\)
- sed "s/^X//" >'Makefile.alt' <<'END_OF_FILE'
- X# I use cc because gcc (gcc-1.37.1) make code 20 times larger. Remove -lXext
- X# if you don't have it; it's only used for button shapes which default to
- X# rectangle anyway.
- XCC = cc
- XCFLAGS = -O
- XLDFLAGS = -lXaw -lXmu -lXt -lX11 -lXext
- X
- X
- X# If your signal() returns int not void, then add -DSIGNALRETURNSINT here:
- X# If you don't have gethostname() and you can't change the #define in alarm.c
- X# to what ever it is on your system, add -DNOGETHOSTNAME here:
- XDEFINES =
- X
- X
- X# My, is this complex! These are the usual places for installation.
- XPREFIX =
- XX11BIN = ${PREFIX}/usr/bin/X11
- XX11MAN = ${PREFIX}/usr/man/mann
- XX11AD = ${PREFIX}/usr/lib/X11/app-defaults
- X
- X
- X# Bits and bobs.
- XMADE = test
- XSTRIP = /bin/strip
- XCP = /bin/cp
- XRM = /bin/rm -f
- XTAGS = etags -t
- XLINT = lint -hbxca
- X
- X
- XOBJS = alarm.o when.o warning.o times.o fns.o xalarm.o
- XSRCS = alarm.c when.c warning.c times.c fns.c xalarm.c
- X
- X# If your make complains about the && conditional sequences, you may have to do
- X# them by hand or go hacking below... The executables and man pages go in the
- X# same directories as xalarm do.
- X
- X# The $& notation tells a Sequent to do a parallel make. Set this variable to
- X# whatever value you need for your parallel machine.
- X
- Xall: xalarm
- X
- Xxalarm: $& ${OBJS}
- X ${CC} ${CFLAGS} -o xalarm ${OBJS} ${LDFLAGS}
- X
- X.c.o:
- X ${CC} -c ${CFLAGS} ${DEFINES} $<
- X
- Xinstall: all
- X ${STRIP} xalarm
- X ${CP} xalarm xmemo ${X11BIN}
- X ${MADE} xfortune && ${CP} xfortune ${X11BIN}
- X ${MADE} xyow && ${CP} xyow ${X11BIN}
- X ${CP} XAlarm.ad ${X11AD}/XAlarm
- X
- Xinstall.man:
- X ${CP} xalarm.man ${X11MAN}/xalarm.n
- X ${CP} man.man ${X11MAN}/xmemo.n
- X ${MADE} xfortune && ${CP} man.man ${X11MAN}/xfortune.n
- X ${MADE} xyow && ${CP} man.man ${X11MAN}/xyow.n
- X
- X# Just make sure, some shars come out with default permissions...
- X# Make sure the resources are loaded so xalarm can be used before installed.
- Xconfig:
- X @chmod +x config.1st fullpath xmemo
- X @config.1st fortune yow
- X @xrdb -merge XAlarm.ad
- X @xrdb -merge XAlarm.ad+
- X
- Xtags:
- X ${TAGS} ${SRCS}
- X
- Xclean:
- X ${RM} ${OBJS} xalarm xfortune xyow fns.h core *~ #*
- X
- Xlint:
- X ${LINT} ${SRCS}
- X
- Xfns.h:
- X @config.1st
- X
- Xalarm.o: xalarm.h patchlevel.h
- Xwhen.o: xalarm.h patchlevel.h
- Xwarning.o: xalarm.h patchlevel.h
- Xtimes.o: xalarm.h patchlevel.h
- Xfns.o: xalarm.h patchlevel.h fns.h
- Xxalarm.o: xalarm.h patchlevel.h
- END_OF_FILE
- if test 2271 -ne `wc -c <'Makefile.alt'`; then
- echo shar: \"'Makefile.alt'\" unpacked with wrong size!
- fi
- # end of 'Makefile.alt'
- fi
- if test -f 'XAlarm.ad' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'XAlarm.ad'\"
- else
- echo shar: Extracting \"'XAlarm.ad'\" \(3108 characters\)
- sed "s/^X//" >'XAlarm.ad' <<'END_OF_FILE'
- X! We can't surround this by "#ifdef COLOR ... #endif" and have it in
- X! .../lib/X11/app-defaults/XAlarm because stuff in there is not pre-processed
- X! with cpp like wot xrdb does. Now why is that...?
- X! If you want colour, you have to stick this in your ~/.xresources file (where
- X! you can surround it with #ifdefs).
- X! #ifdef COLOR
- X! XAlarm*background: LightYellow
- X! XAlarm*foreground: IndianRed
- X! XAlarm*Command.background: IndianRed
- X! XAlarm*Command.foreground: LightYellow
- X! #endif
- X
- XXAlarm.bell: True
- XXAlarm.confirm: True
- XXAlarm.warnings: 5,15
- XXAlarm.warningwords: 0
- XXAlarm.snooze: 0
- X
- XXAlarm*background: White
- XXAlarm*foreground: Black
- XXAlarm*font: *-times-bold-r-*-14-*
- XXAlarm*allowShellResize: True
- XXAlarm*resizable: True
- X
- XXAlarm*top: ChainTop
- XXAlarm*bottom: ChainTop
- XXAlarm*left: ChainLeft
- XXAlarm*right: ChainLeft
- X
- XXAlarm*Command.background: Black
- XXAlarm*Command.foreground: White
- XXAlarm*Command.ShapeStyle: rectangle
- XXAlarm*Command.cursor: hand2
- XXAlarm*Label.justify: left
- XXAlarm*Label.cursor: question_arrow
- XXAlarm*Text.cursor: pencil
- X
- XXAlarm*quit.label: Quit
- X
- XXAlarm.Alarm!.alarm.background: Black
- XXAlarm.Alarm!.alarm.message.cursor: gumby
- XXAlarm.Alarm!.alarm.message.label: Alarm Call!!!
- XXAlarm.Alarm!.alarm.message.font: *-times-bold-i-*-*-34-*
- XXAlarm.Alarm!.alarm.message.internalWidth: 10
- XXAlarm.Alarm!.alarm.message.internalHeight: 5
- XXAlarm.Alarm!.alarm.message.bottom: ChainBottom
- X
- XXAlarm.Alarm!.alarm.buttons.snooze.label: Snooze
- XXAlarm.Alarm!.alarm.buttons.snooze1.label: +1 min
- XXAlarm.Alarm!.alarm.buttons.snooze5.label: +5 mins
- XXAlarm.Alarm!.alarm.buttons.snooze15.label: +15 mins
- XXAlarm.Alarm!.alarm.buttons.snooze.fromHoriz: quit
- XXAlarm.Alarm!.alarm.buttons.snooze1.fromHoriz: snooze
- XXAlarm.Alarm!.alarm.buttons.snooze5.fromHoriz: snooze1
- XXAlarm.Alarm!.alarm.buttons.snooze15.fromHoriz: snooze5
- XXAlarm.Alarm!.alarm.buttons.snoozetime.fromHoriz: snooze15
- XXAlarm.Alarm!.alarm.message.fromVert: buttons
- X
- XXAlarm.When?.when.background: Black
- XXAlarm.When?.when.ok.label: Enter time
- XXAlarm.When?.when.toggle.label: Edit warnings
- XXAlarm.When?.when.value.translations: #override <Key>Return: EnteredTime()
- X
- XXAlarm.When?.warnings.background: Black
- XXAlarm.When?.warnings.ok.label: Enter warnings
- XXAlarm.When?.warnings.toggle.label: Edit time
- XXAlarm.When?.warnings.value.translations:#override <Key>Return: EnteredWarnings()
- X
- XXAlarm.When?.confirm.background: Black
- XXAlarm.When?.confirm.value*font: *-times-bold-i-*-*-14-*
- XXAlarm.When?.confirm.ok.label: Confirm time
- XXAlarm.When?.confirm.cancel.label: Edit time
- XXAlarm.When?.confirm.value.translations:#override <Key>Return: Confirmed()
- X
- XXAlarm.When?*value*font: 9x15bold
- XXAlarm.When?*value.bottom: ChainBottom
- XXAlarm.When?*value.right: ChainRight
- XXAlarm.When?*Command.top: ChainBottom
- XXAlarm.When?*Command.bottom: ChainBottom
- X
- XXAlarm.Warning!.warning.background: Black
- XXAlarm.Warning!.warning.dismiss.label: Dismiss
- XXAlarm.Warning!.warning.message.fromHoriz: dismiss
- XXAlarm.Warning!.warning.message.cursor: clock
- XXAlarm.Warning!.warning.quit.fromHoriz: message
- END_OF_FILE
- if test 3108 -ne `wc -c <'XAlarm.ad'`; then
- echo shar: \"'XAlarm.ad'\" unpacked with wrong size!
- fi
- # end of 'XAlarm.ad'
- fi
- if test -f 'alarm.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'alarm.c'\"
- else
- echo shar: Extracting \"'alarm.c'\" \(5440 characters\)
- sed "s/^X//" >'alarm.c' <<'END_OF_FILE'
- X/*
- X Copyright (c) 1991, 1992 by Simon Marshall, University of Hull, UK
- X
- X If you still end up late, don't blame me!
- X
- X Permission to use, copy, modify, distribute, and sell this software and its
- X documentation for any purpose and without fee is hereby granted,
- X provided that the above copyright notice appear in all copies and that
- X both that copyright notice and this permission notice appear in
- X supporting documentation.
- X
- X This software is provided AS IS with no warranties of any kind. The author
- X shall have no liability with respect to the infringement of copyrights,
- X trade secrets or any patents by this file or any part thereof. In no
- X event will the author be liable for any lost revenue or profits or
- X other special, indirect and consequential damages.
- X*/
- X
- X/*
- X * The stuff needed for the alarm call widget to appear on the screen,
- X * and the stuff for snoozing it.
- X */
- X
- X
- X#include "xalarm.h"
- X#include <X11/Xaw/Label.h>
- X#include <X11/Xaw/Command.h>
- X#include <X11/Xaw/Form.h>
- X
- X
- X/*
- X * A pain, you may have to alter this. Basically USER() should return the
- X * user name, HOSTNAME() the hostname in the first arg.
- X */
- X
- X#define HOSTNAME(str,l) gethostname ((str), (l))
- X#define TITLEFORMAT "%s: %s%s%s%s%s%s"
- X
- X
- X
- Xvoid CreateAlarmWidget(), WakeUp(), ShowClickToZero(), ShowSnoozeValue();
- Xstatic void SnoozeAmount(), Snooze();
- Xextern void AddTimeOuts(), SetGeometry(), Quit();
- Xextern String getenv();
- X
- X
- Xextern AlarmData xalarm;
- X
- X
- X
- X/*
- X * The snoozetime button displays its message when the ptr is in the
- X * window, and the snooze time when it's not.
- X */
- X
- Xstatic char snoozetimetranslations [] =
- X "<EnterWindow>: highlight() ShowClickToZero() \n\
- X <LeaveWindow>: ShowSnoozeValue() unhighlight()";
- X
- X
- X
- Xvoid CreateAlarmWidget (alarmmessage)
- X String alarmmessage;
- X{
- X Widget alarm, alarmbox, message, buttonbox,
- X quit, snooze, snooze1, snooze5, snooze15, snoozetime;
- X
- X alarm = XtVaCreatePopupShell ("Alarm!", transientShellWidgetClass,
- X xalarm.toplevel, NULL);
- X
- X alarmbox = XtVaCreateManagedWidget ("alarm", formWidgetClass, alarm, NULL);
- X
- X buttonbox = XtVaCreateManagedWidget ("buttons", formWidgetClass, alarmbox, NULL);
- X
- X CreateManagedButton (quit, "quit", buttonbox, Quit, NULL);
- X CreateManagedButton (snooze, "snooze", buttonbox, Snooze, NULL);
- X CreateManagedButton (snooze1, "snooze1", buttonbox, SnoozeAmount, 1);
- X CreateManagedButton (snooze5, "snooze5", buttonbox, SnoozeAmount, 5);
- X CreateManagedButton (snooze15, "snooze15" ,buttonbox, SnoozeAmount, 15);
- X CreateManagedButton (snoozetime, "snoozetime", buttonbox, SnoozeAmount, 0);
- X
- X if (alarmmessage != (String) NULL)
- X message = XtVaCreateManagedWidget ("message", labelWidgetClass, alarmbox, XtNlabel,
- X (XtArgVal) (xalarm.messagestr = alarmmessage),
- X NULL);
- X else {
- X message = XtVaCreateManagedWidget ("message", labelWidgetClass, alarmbox, NULL);
- X XtVaGetValues (message, XtNlabel, &xalarm.messagestr, NULL);
- X }
- X
- X XtOverrideTranslations (snoozetime,
- X XtParseTranslationTable (snoozetimetranslations));
- X
- X xalarm.alarmwidget = alarm;
- X xalarm.snoozetimewidget = snoozetime;
- X xalarm.messagewidget = message;
- X}
- X
- X
- X
- X/*
- X * This is for the snoozetime button which doubles as the label showing how
- X * much time the snooze is selected for.
- X */
- X
- Xvoid ShowClickToZero ()
- X{
- X XtVaSetValues (xalarm.snoozetimewidget, XtNlabel, (XtArgVal) "Zero time", NULL);
- X}
- X
- X
- X
- Xvoid ShowSnoozeValue ()
- X{
- X char buf[TEXT];
- X
- X MAKETIMESTRING (buf, (int) (xalarm.timeout/(60*1000)));
- X XtVaSetValues (xalarm.snoozetimewidget, XtNlabel, (XtArgVal) buf, NULL);
- X}
- X
- X
- X
- X/*
- X * Add to the amount that is currently the amount to snooze by.
- X */
- X
- Xstatic void SnoozeAmount (widget, clientdata, calldata)
- X Widget widget;
- X XtPointer clientdata, calldata;
- X{
- X int mins = (int) clientdata;
- X
- X if (mins == 0) {
- X xalarm.timeout = 0;
- X ShowClickToZero ();
- X }
- X else {
- X xalarm.timeout += (mins*60*1000);
- X ShowSnoozeValue ();
- X }
- X}
- X
- X
- X
- X/*
- X * Time to sleep. Add the time outs & disappear.
- X */
- X
- Xstatic void Snooze (widget, clientdata, calldata)
- X Widget widget;
- X XtPointer clientdata, calldata;
- X{
- X AddTimeOuts ();
- X XtPopdown (xalarm.alarmwidget);
- X}
- X
- X
- X
- X/*
- X * Time to wake up.
- X */
- X
- Xvoid WakeUp (clientdata, id)
- X XtPointer clientdata;
- X XtIntervalId id;
- X{
- X Display *display = XtDisplay (xalarm.toplevel);
- X String strs[1], name;
- X XTextProperty property;
- X#if not defined (NOGETHOSTNAME)
- X char hostname[TEXT];
- X#endif
- X
- X if (not XtIsRealized (xalarm.alarmwidget)) {
- X XtRealizeWidget (xalarm.alarmwidget);
- X /*
- X * Set the name...
- X */
- X name = getenv ("NAME");
- X#if not defined (NOGETHOSTNAME)
- X HOSTNAME (hostname, TEXT-1);
- X#endif
- X strs[0] = XtMalloc (TEXT);
- X (void) sprintf (strs[0], TITLEFORMAT, xalarm.proggie,
- X getenv ("USER"),
- X#if not defined (NOGETHOSTNAME)
- X "@", hostname,
- X#else
- X "", "",
- X#endif
- X (name == (char *) NULL) ? "" : " (",
- X (name == (char *) NULL) ? "" : name,
- X (name == (char *) NULL) ? "" : ")");
- X
- X XStringListToTextProperty (strs, 1, &property);
- X XSetWMName (display, XtWindow (xalarm.alarmwidget), &property);
- X }
- X
- X SetGeometry (xalarm.alarmwidget);
- X
- X xalarm.timeout = 0;
- X SnoozeAmount ((Widget) NULL, (XtPointer) xalarm.snooze, (XtPointer) NULL);
- X
- X if (xalarm.bell)
- X XBell (display, 0);
- X XtPopup (xalarm.alarmwidget, XtGrabNone);
- X}
- END_OF_FILE
- if test 5440 -ne `wc -c <'alarm.c'`; then
- echo shar: \"'alarm.c'\" unpacked with wrong size!
- fi
- # end of 'alarm.c'
- fi
- if test -f 'config.1st' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'config.1st'\"
- else
- echo shar: Extracting \"'config.1st'\" \(1395 characters\)
- sed "s/^X//" >'config.1st' <<'END_OF_FILE'
- X#!/bin/sh
- X
- X# Just try to find out the full path names for ps, fgrep & colrm which are used
- X# within fns.c to do the -list option.
- X
- Xecho '
- XJust a few questions! The default answer is in brackets, just press RETURN.
- X
- XIf you do not have "ps", "fgrep" or "colrm" (or equivalent), do not panic.
- Xxalarm only uses them when it is attempting to list the process ids of other
- Xxalarms. If you do not have these commands, just press RETURN. xalarm can be
- Xinstalled as normal, but you will not be able to use the -list option.
- X
- XI need to know because xalarm uses these shell commands when obeying the -list
- Xoption, and for security reasons xalarm should use full path names.
- X
- XIf you do not have "fortune" or "yow", you cannot have the X equivalent since
- Xthey are just front ends to them!
- X
- XI will try to find them myself, but if I cannot, use "which" (or "find" if you
- Xare really desperate) or ask your local System Guru or Manager.
- X'
- X
- Xecho '#define PS "'`./fullpath ps`'"
- X#define FGREP "'`./fullpath fgrep`'"
- X#define COLRM "'`./fullpath colrm`'"' > fns.h
- X
- Xecho ''
- X
- Xfor program in $*; do
- X progpath=`./fullpath $program`
- X if test -f $progpath; then
- X echo '#!/bin/sh
- Xexec xmemo -name x'$program' ${1+"$@"} "`'$progpath'`"' > x$program
- X else
- X echo '#!/bin/sh
- Xexec xmemo -name x'$program' "Sorry, x'$program' is unavailable - no '$program'"' > x$program
- X fi
- X chmod +x x$program
- Xdone
- X
- Xecho "
- XThank you.
- X"
- END_OF_FILE
- if test 1395 -ne `wc -c <'config.1st'`; then
- echo shar: \"'config.1st'\" unpacked with wrong size!
- fi
- chmod +x 'config.1st'
- # end of 'config.1st'
- fi
- if test -f 'fullpath' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'fullpath'\"
- else
- echo shar: Extracting \"'fullpath'\" \(842 characters\)
- sed "s/^X//" >'fullpath' <<'END_OF_FILE'
- X#!/bin/sh
- X
- XPATH="$PATH:.:/bin:/usr/bin:/usr/local/bin:/usr/ucb:/usr/local:/usr/lbin:/etc:/usr/new:/usr/new/bin:/usr/nbin"
- Xexport PATH
- X
- Xloc=`which $1 2>/dev/null`
- Xcase "$loc" in
- X "$1"*|"no $1"*) loc=;;
- Xesac
- X
- Xecho -n "Where is your \"$1\"? [$loc] " >&2
- Xread ans
- X
- Xif test ! "$ans" = ""; then
- X loc=$ans
- Xfi
- Xif test "$loc" = ""; then
- X loc=$1
- Xfi
- Xif test ! -f $loc; then
- X echo Warning: \"$loc\" does not exist. >&2
- Xfi
- X
- Xecho $loc
- X#!/bin/sh
- X
- XPATH="$PATH:.:/bin:/usr/bin:/usr/local/bin:/usr/ucb:/usr/local:/usr/lbin:/etc:/usr/new:/usr/new/bin:/usr/nbin"
- Xexport PATH
- X
- Xloc=`which $1 2>/dev/null`
- Xcase "$loc" in
- X "$1"*|"no $1"*) loc=;;
- Xesac
- X
- Xecho -n "Where is your \"$1\"? [$loc] " >&2
- Xread ans
- X
- Xif test ! "$ans" = ""; then
- X loc=$ans
- Xfi
- Xif test "$loc" = ""; then
- X loc=$1
- Xfi
- Xif test ! -f $loc; then
- X echo Warning: \"$loc\" does not exist. >&2
- Xfi
- X
- Xecho $loc
- END_OF_FILE
- if test 842 -ne `wc -c <'fullpath'`; then
- echo shar: \"'fullpath'\" unpacked with wrong size!
- fi
- chmod +x 'fullpath'
- # end of 'fullpath'
- fi
- if test -f 'man.man' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'man.man'\"
- else
- echo shar: Extracting \"'man.man'\" \(18 characters\)
- sed "s/^X//" >'man.man' <<'END_OF_FILE'
- X.so mann/xalarm.n
- END_OF_FILE
- if test 18 -ne `wc -c <'man.man'`; then
- echo shar: \"'man.man'\" unpacked with wrong size!
- fi
- # end of 'man.man'
- fi
- if test -f 'times.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'times.c'\"
- else
- echo shar: Extracting \"'times.c'\" \(6960 characters\)
- sed "s/^X//" >'times.c' <<'END_OF_FILE'
- X/*
- X Copyright (c) 1991, 1992 by Simon Marshall, University of Hull, UK
- X
- X If you still end up late, don't blame me!
- X
- X Permission to use, copy, modify, distribute, and sell this software and its
- X documentation for any purpose and without fee is hereby granted,
- X provided that the above copyright notice appear in all copies and that
- X both that copyright notice and this permission notice appear in
- X supporting documentation.
- X
- X This software is provided AS IS with no warranties of any kind. The author
- X shall have no liability with respect to the infringement of copyrights,
- X trade secrets or any patents by this file or any part thereof. In no
- X event will the author be liable for any lost revenue or profits or
- X other special, indirect and consequential damages.
- X*/
- X
- X/*
- X * Parse times & dates.
- X */
- X
- X
- X
- X#include "xalarm.h"
- X
- X#define VALUE(ch) ((int) (ch) - (int) '0')
- X#define INSTRING(ch, s) (((ch) != '\0') and (index ((s), (ch))))
- X#define DOWNCASE(ch) (((ch) >= 'A') and ((ch) <= 'Z') ? \
- X ((ch) - 'A' + 'a') : (ch))
- X
- X
- Xlong TimeToMilliSeconds();
- XBoolean AppointmentIsToday();
- Xstatic String NextWord();
- Xstatic Boolean ParseTimeString();
- X
- X
- X
- Xextern AlarmData xalarm;
- X
- X
- X
- X/*
- X * Is the date & time consistent with today? This includes whether
- X * the time has passed or not.
- X */
- X
- XBoolean AppointmentIsToday (line, timestr, chpos)
- X String line, *timestr;
- X int *chpos;
- X{
- X static int daysin[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
- X static char strings[][4] = {WEEKDAYS, MONTHS, "!!!", "!!!"};
- X int wday, month, mday, year, hrs, mins;
- X struct tm *now, *localtime();
- X time_t abstime, time();
- X String word, monthstr = (String) NULL;
- X Boolean gotmday = False, today, notime, dummy;
- X int i;
- X
- X if (*line == '\n')
- X return (False);
- X
- X (void) time (&abstime);
- X now = localtime (&abstime);
- X wday = now->tm_wday;
- X month = now->tm_mon;
- X mday = now->tm_mday;
- X year = now->tm_year + 1900;
- X if ((year % 400 == 0) or ((year % 4 == 0) and (year % 100 != 0)))
- X daysin[1] = 29;
- X
- X while (strcmp (word = NextWord (line, chpos), "-"))
- X if (*word == '\0')
- X break;
- X else if ((*word == '#') or (*word == '!'))
- X return (False);
- X else {
- X i = 0;
- X while ((strncmp (word, strings[i], 3)) and (i < 20))
- X i++;
- X if (i < 7)
- X wday = i;
- X else if (i < 20) {
- X month = i-7;
- X monthstr = word;
- X }
- X else
- X if (not (gotmday = ((mday = atoi (word)) > 0))) {
- X (void) fprintf (stderr,
- X "xalarm: Couldn't parse this entry (what is \"%s\"?):\n%s",
- X word, line);
- X return (False);
- X }
- X }
- X
- X if (((gotmday and monthstr) or (month == now->tm_mon)) and (mday > daysin[month])) {
- X (void) fprintf (stderr,
- X "xalarm: Couldn't parse this entry (%d days in %s?):\n%s",
- X mday, (monthstr != (String) NULL) ? monthstr : strings[month+7],
- X line);
- X return (False);
- X }
- X
- X notime = not ParseTimeString (*timestr = NextWord (line, chpos),
- X &hrs, &mins, &dummy);
- X
- X today = ((wday == now->tm_wday) and (month == now->tm_mon) and
- X (mday == now->tm_mday));
- X
- X if (today and notime) {
- X if (*timestr[0] != '\0')
- X do
- X (*chpos)--;
- X while (line[*chpos] != ' ');
- X *timestr = XtNewString ("+0");
- X return (True);
- X }
- X else
- X return (today and
- X ((hrs > now->tm_hour) or
- X ((hrs == now->tm_hour) and (mins >= now->tm_min)) or
- X (*timestr[0] == '+')));
- X}
- X
- X
- X
- X/*
- X * Return the next word in str, starting at position chpos in the
- X * string. The returned word is in lower case.
- X */
- X
- Xstatic String NextWord (str, chpos)
- X String str;
- X int *chpos;
- X{
- X String word;
- X int start, i;
- X
- X while (isspace (str[*chpos]))
- X (*chpos)++;
- X
- X start = *chpos;
- X while ((not isspace (str[*chpos])) and (str[*chpos] != '\0'))
- X (*chpos)++;
- X
- X if ((str[*chpos] == '\0') and (start == *chpos))
- X return ("");
- X else {
- X word = XtMalloc (*chpos - start + 1);
- X for (i=0; i<(*chpos-start); i++)
- X word[i] = DOWNCASE (str[start+i]);
- X word[*chpos-start] = '\0';
- X
- X return (word);
- X }
- X}
- X
- X
- X
- X/*
- X * Convert the string into milliseconds, or INVALID if
- X * not recognised.
- X * Recognises quite a lot, really, but doesn't like non absolute times
- X * having "am" or "pm" etc.
- X */
- X
- Xlong TimeToMilliSeconds (timestr)
- X String timestr;
- X{
- X Boolean in24hrformat;
- X int hours, minutes, seconds;
- X struct tm *now, *localtime();
- X time_t abstime, time();
- X
- X if (not ParseTimeString (timestr, &hours, &minutes, &in24hrformat))
- X return (INVALID);
- X
- X if (*timestr == '+')
- X seconds = (hours * 60*60) + (minutes * 60);
- X else {
- X (void) time (&abstime);
- X now = localtime (&abstime);
- X seconds = ((hours - now->tm_hour) * 60*60) +
- X ((minutes - now->tm_min) * 60) - now->tm_sec;
- X while (seconds < 0)
- X seconds += (in24hrformat ? 24*60*60 : 12*60*60);
- X }
- X
- X return ((long) seconds*1000);
- X}
- X
- X
- X
- X/*
- X * Parse that string. Robbed and hacked from xcal (3.2) by Peter
- X * Collinson et al.
- X */
- X
- Xstatic Boolean ParseTimeString (str, hrs, mins, in24hrf)
- X String str;
- X int *hrs, *mins;
- X Boolean *in24hrf;
- X{
- X enum {Hhmm, hHmm, hh_mm, hhMm, hhmM, AmPm, aMpM, Finished} state;
- X Boolean relative;
- X int numdigits = 0;
- X char *s = str;
- X
- X if (relative = (*str == '+'))
- X str++;
- X
- X while (*s)
- X if (isdigit (*s++))
- X numdigits++;
- X
- X if (relative)
- X switch (numdigits) {
- X case 1: state = hhmM; break;
- X case 2: state = hhMm; break;
- X case 3: state = hHmm; break;
- X case 4: state = Hhmm; break;
- X default: return (False);
- X }
- X else
- X switch (numdigits) {
- X case 1:
- X case 2:
- X case 4: state = Hhmm; break;
- X case 3: state = hHmm; break;
- X default: return (False);
- X }
- X
- X *hrs = *mins = 0;
- X *in24hrf = False;
- X
- X while (state != Finished)
- X switch (state) {
- X case Hhmm:
- X if (isdigit (*str)) {
- X *hrs = VALUE (*str++);
- X state = hHmm;
- X continue;
- X }
- X else
- X return (False);
- X case hHmm:
- X if (isdigit (*str)) {
- X *hrs = *hrs*10 + VALUE (*str++);
- X state = hh_mm;
- X continue;
- X }
- X case hh_mm:
- X if (INSTRING (*str, ".:-")) {
- X state = hhMm;
- X str++;
- X continue;
- X }
- X case hhMm:
- X if (isdigit (*str)) {
- X *mins = VALUE (*str++);
- X state = hhmM;
- X continue;
- X }
- X case hhmM:
- X if (isdigit (*str)) {
- X *mins = *mins*10 + VALUE (*str++);
- X state = AmPm;
- X continue;
- X }
- X case AmPm:
- X if (*str == '\0') {
- X *in24hrf = (*hrs > 12);
- X state = Finished;
- X continue;
- X }
- X else
- X if (relative)
- X return (False);
- X
- X if (INSTRING (*str, "Aa")) {
- X if (*hrs == 12)
- X *hrs = 0;
- X state = aMpM;
- X continue;
- X }
- X else
- X if (INSTRING (*str, "Pp")) {
- X if (*hrs < 12)
- X *hrs = *hrs + 12;
- X state = aMpM;
- X continue;
- X }
- X return (False);
- X case aMpM:
- X str++;
- X if (INSTRING (*str, "Mm")) {
- X *in24hrf = True;
- X str++;
- X state = Finished;
- X }
- X else
- X return (False);
- X }
- X
- X return ((*hrs < 24) and (*mins < 60) and (*str == '\0'));
- X}
- END_OF_FILE
- if test 6960 -ne `wc -c <'times.c'`; then
- echo shar: \"'times.c'\" unpacked with wrong size!
- fi
- # end of 'times.c'
- fi
- if test -f 'warning.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'warning.c'\"
- else
- echo shar: Extracting \"'warning.c'\" \(3982 characters\)
- sed "s/^X//" >'warning.c' <<'END_OF_FILE'
- X/*
- X Copyright (c) 1991, 1992 by Simon Marshall, University of Hull, UK
- X
- X If you still end up late, don't blame me!
- X
- X Permission to use, copy, modify, distribute, and sell this software and its
- X documentation for any purpose and without fee is hereby granted,
- X provided that the above copyright notice appear in all copies and that
- X both that copyright notice and this permission notice appear in
- X supporting documentation.
- X
- X This software is provided AS IS with no warranties of any kind. The author
- X shall have no liability with respect to the infringement of copyrights,
- X trade secrets or any patents by this file or any part thereof. In no
- X event will the author be liable for any lost revenue or profits or
- X other special, indirect and consequential damages.
- X*/
- X
- X/*
- X * The stuff for dealing with warnings; processing to get the times &
- X * the fns for popping up the warnings themselves.
- X */
- X
- X
- X
- X#include "xalarm.h"
- X
- X#include <X11/Xaw/Form.h>
- X#include <X11/Xaw/Command.h>
- X
- X
- X#define WARNING "Warning: %s due in "
- X
- X
- Xvoid SetWarningTimes(), Warning();
- Xstatic void QuitWarning();
- Xextern long TimeToMilliSeconds();
- Xextern void SetGeometry(), Quit();
- X
- X
- Xextern AlarmData xalarm;
- X
- X
- X
- X/*
- X * Process the string to extract warning times. Currently just gives
- X * a message if a warning time is invalid.
- X */
- X
- Xvoid SetWarningTimes (warnings)
- X String warnings;
- X{
- X String warnstr = warnings;
- X char warning[TEXT];
- X long biggest;
- X int i, j, bigindex;
- X
- X xalarm.numwarnings = 0;
- X while ((*warnstr != '\0') and (not ISINVALID (xalarm.numwarnings))) {
- X warning[i=0] = '+';
- X while ((*warnstr != ',') and (*warnstr != '\0'))
- X warning[++i] = *warnstr++;
- X warning[++i] = '\0';
- X
- X switch (xalarm.warnings[xalarm.numwarnings] = TimeToMilliSeconds (warning)) {
- X case 0:
- X break;
- X case INVALID:
- X xalarm.numwarnings = INVALID;
- X break;
- X default:
- X xalarm.numwarnings++;
- X break;
- X }
- X
- X while (*warnstr == ',')
- X warnstr++;
- X }
- X if ((warnstr != warnings) and (*(warnstr-1) == ','))
- X xalarm.numwarnings = INVALID;
- X
- X /*
- X * Sort it, why not?
- X */
- X for (i=0; i<xalarm.numwarnings-1; i++) {
- X biggest = xalarm.warnings[bigindex = i];
- X for (j=i+1; j<xalarm.numwarnings; j++)
- X if (xalarm.warnings[j] > biggest)
- X biggest = xalarm.warnings[bigindex = j];
- X xalarm.warnings[bigindex] = xalarm.warnings[i];
- X xalarm.warnings[i] = biggest;
- X }
- X}
- X
- X
- X
- X/*
- X * pop up a warning. includes a dismiss & quit button.
- X */
- X
- Xvoid Warning (clientdata, id)
- X XtPointer clientdata;
- X XtIntervalId id;
- X{
- X Widget popup, warningbox, dismiss, quit;
- X int count;
- X char buf[TEXT], warnmessage[TEXT], *wm = warnmessage;
- X
- X popup = XtVaCreatePopupShell ("Warning!", transientShellWidgetClass, xalarm.toplevel,
- X NULL);
- X
- X warningbox = XtVaCreateManagedWidget ("warning", formWidgetClass, popup, NULL);
- X
- X if (xalarm.warningwords == 0)
- X (void) sprintf (buf, WARNING, xalarm.proggie+1);
- X else {
- X (void) sprintf (warnmessage, "`%s", xalarm.messagestr);
- X count = xalarm.warningwords;
- X while ((count-- > 0) and (*wm != '\0')) {
- X while (isspace (*wm))
- X *wm++ = ' ';
- X while (not isspace (*wm) and (*wm != '\0'))
- X wm++;
- X }
- X (void) sprintf (wm, "%s", (*wm == '\0') ? "' " : "...' ");
- X (void) sprintf (buf, WARNING, warnmessage);
- X }
- X
- X MAKETIMESTRING (buf + strlen (buf), (int) clientdata);
- X
- X CreateManagedButton (dismiss, "dismiss", warningbox, QuitWarning, popup);
- X XtVaCreateManagedWidget ("message", labelWidgetClass, warningbox,
- X XtNlabel, (XtArgVal) buf, NULL);
- X CreateManagedButton (quit, "quit", warningbox, Quit, NULL);
- X
- X SetGeometry (popup);
- X if (xalarm.bell)
- X XBell (XtDisplay (xalarm.toplevel), 0);
- X XtPopup (popup, XtGrabNone);
- X}
- X
- X
- X
- Xstatic void QuitWarning (widget, clientdata, calldata)
- X Widget widget;
- X XtPointer clientdata, calldata;
- X{
- X XtPopdown ((Widget) clientdata);
- X}
- END_OF_FILE
- if test 3982 -ne `wc -c <'warning.c'`; then
- echo shar: \"'warning.c'\" unpacked with wrong size!
- fi
- # end of 'warning.c'
- fi
- if test -f 'when.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'when.c'\"
- else
- echo shar: Extracting \"'when.c'\" \(7825 characters\)
- sed "s/^X//" >'when.c' <<'END_OF_FILE'
- X/*
- X Copyright (c) 1991, 1992 by Simon Marshall, University of Hull, UK
- X
- X If you still end up late, don't blame me!
- X
- X Permission to use, copy, modify, distribute, and sell this software and its
- X documentation for any purpose and without fee is hereby granted,
- X provided that the above copyright notice appear in all copies and that
- X both that copyright notice and this permission notice appear in
- X supporting documentation.
- X
- X This software is provided AS IS with no warranties of any kind. The author
- X shall have no liability with respect to the infringement of copyrights,
- X trade secrets or any patents by this file or any part thereof. In no
- X event will the author be liable for any lost revenue or profits or
- X other special, indirect and consequential damages.
- X*/
- X
- X/*
- X * Stuff for getting the time the alarm is due to go off, and
- X * confirmation if needed.
- X */
- X
- X
- X
- X#include "xalarm.h"
- X
- X#include <X11/Xaw/Dialog.h>
- X
- X
- X#define TIMEINSTRUCTIONS "Enter time (as [+]time[am/pm]):"
- X#define WARNINGINSTRUCTIONS "Enter warnings (as time[,time...]):"
- X#define CONFIRMFORMAT "%s, %d:%02d (in %d:%02d), "
- X#define EDITTIME (0)
- X#define EDITWARNINGS (2)
- X#define EDITED(str,widget) (strcmp (str, XawDialogGetValueString (widget)))
- X#define DIALOGVALUE(widget) (XtNewString (XawDialogGetValueString (widget)))
- X#define UPCASE(ch) (((ch) >= 'a') and ((ch) <= 'z') ? \
- X ((ch) - 'a' + 'A') : (ch))
- X
- X
- X
- Xvoid PopupAndAsk(), EnteredTime(), EnteredWarnings(), Confirmed();
- Xstatic void PopupAndConfirm(), Popup(), PopupNext(), Edit(), Cancel();
- Xextern void Quit(), AddTimeOuts(), SetWarningTimes(), SetGeometry();
- Xextern long TimeToMilliSeconds();
- X
- X
- X
- Xextern AlarmData xalarm;
- X
- X
- X
- X/*
- X * just pop up a dialog widget to get an at/in time. won't pop down
- X * until a valid time is given. EnteredTime() does this.
- X */
- X
- Xvoid PopupAndAsk ()
- X{
- X Widget popup, gettimewidget, getwtimewidget, confirmwidget;
- X
- X popup = XtVaCreatePopupShell ("When?", transientShellWidgetClass, xalarm.toplevel,
- X NULL);
- X
- X gettimewidget = XtVaCreateManagedWidget ("when", dialogWidgetClass, popup, NULL);
- X XawDialogAddButton (gettimewidget, "ok", EnteredTime, (XtPointer) NULL);
- X XawDialogAddButton (gettimewidget, "toggle", Edit, (XtPointer) EDITWARNINGS);
- X XawDialogAddButton (gettimewidget, "quit", Quit, (XtPointer) NULL);
- X
- X getwtimewidget = XtVaCreateManagedWidget ("warnings", dialogWidgetClass, popup, NULL);
- X XawDialogAddButton (getwtimewidget, "ok", EnteredWarnings, (XtPointer) NULL);
- X XawDialogAddButton (getwtimewidget, "toggle", Edit, (XtPointer) EDITTIME);
- X XawDialogAddButton (getwtimewidget, "quit", Quit, (XtPointer) NULL);
- X
- X confirmwidget = XtVaCreateManagedWidget ("confirm", dialogWidgetClass, popup, NULL);
- X XawDialogAddButton (confirmwidget, "ok", Confirmed, (XtPointer) NULL);
- X XawDialogAddButton (confirmwidget, "cancel", Cancel, (XtPointer) NULL);
- X XawDialogAddButton (confirmwidget, "quit", Quit, (XtPointer) NULL);
- X
- X XtVaSetValues (xalarm.gettimewidget = gettimewidget,
- X XtNvalue, (XtArgVal) xalarm.timestr, NULL);
- X XtVaSetValues (xalarm.getwtimewidget = getwtimewidget,
- X XtNvalue, (XtArgVal) xalarm.warningsstr, NULL);
- X XtVaSetValues (xalarm.confirmwidget = confirmwidget,
- X XtNvalue, (XtArgVal) xalarm.messagestr, NULL);
- X
- X SetGeometry (popup);
- X XtPopup (popup, XtGrabExclusive);
- X PopupNext ();
- X}
- X
- X
- X
- X/*
- X * Popup the next dialog, if more needs to be entered.
- X */
- X
- Xstatic void PopupNext ()
- X{
- X if (ISINVALID (xalarm.timeout) or
- X EDITED (xalarm.timestr, xalarm.gettimewidget))
- X Popup (xalarm.gettimewidget, TIMEINSTRUCTIONS);
- X else if (ISINVALID (xalarm.numwarnings) or
- X EDITED (xalarm.warningsstr, xalarm.getwtimewidget))
- X Popup (xalarm.getwtimewidget, WARNINGINSTRUCTIONS);
- X else
- X PopupAndConfirm ();
- X}
- X
- X
- X
- X/*
- X * If invalid, stay. Otherwise, get the rest, if any.
- X */
- X
- Xvoid EnteredTime (widget, clientdata, calldata)
- X Widget widget;
- X XtPointer clientdata, calldata;
- X{
- X char message[TEXT];
- X
- X xalarm.timeout = TimeToMilliSeconds
- X (xalarm.timestr = DIALOGVALUE (xalarm.gettimewidget));
- X
- X if (not ISINVALID (xalarm.timeout))
- X PopupNext ();
- X else {
- X (void) sprintf (message, "Invalid. %s", TIMEINSTRUCTIONS);
- X XtVaSetValues (xalarm.gettimewidget, XtNlabel, (XtArgVal) message, NULL);
- X }
- X}
- X
- X
- X
- X/*
- X * If invalid, stay. Otherwise, get the rest, if any.
- X */
- X
- Xvoid EnteredWarnings (widget, clientdata, calldata)
- X Widget widget;
- X XtPointer clientdata, calldata;
- X{
- X char message[TEXT];
- X
- X SetWarningTimes (xalarm.warningsstr = DIALOGVALUE (xalarm.getwtimewidget));
- X
- X if (not ISINVALID (xalarm.numwarnings))
- X PopupNext ();
- X else {
- X (void) sprintf (message, "Invalid. %s", WARNINGINSTRUCTIONS);
- X XtVaSetValues (xalarm.getwtimewidget, XtNlabel, (XtArgVal) message, NULL);
- X }
- X}
- X
- X
- X
- X/*
- X * Just toggle whether i/t concerns alarm time/warning time(s).
- X */
- X
- Xstatic void Edit (widget, clientdata, calldata)
- X Widget widget;
- X XtPointer clientdata, calldata;
- X{
- X switch ((int) clientdata) {
- X case EDITTIME:
- X Popup (xalarm.gettimewidget, TIMEINSTRUCTIONS);
- X break;
- X case EDITWARNINGS:
- X Popup (xalarm.getwtimewidget, WARNINGINSTRUCTIONS);
- X break;
- X }
- X}
- X
- X
- X
- X/*
- X * Popup to confirm, showing the time which the alarm will trigger.
- X */
- X
- Xstatic void PopupAndConfirm ()
- X{
- X static char days[][4] = {WEEKDAYS};
- X char message[TEXT];
- X struct tm *alarmtime, *localtime();
- X time_t now, time();
- X int count = 0, i;
- X
- X (void) time (&now);
- X now += (TimeToMilliSeconds (xalarm.timestr) / 1000);
- X alarmtime = localtime (&now);
- X
- X days[alarmtime->tm_wday][0] = UPCASE (days[alarmtime->tm_wday][0]);
- X (void) sprintf (message, CONFIRMFORMAT, days[alarmtime->tm_wday],
- X alarmtime->tm_hour, alarmtime->tm_min,
- X xalarm.timeout/(1000*60*60), (xalarm.timeout/(1000*60)) % 60);
- X
- X for (i=0; i<xalarm.numwarnings; i++)
- X if (xalarm.timeout > xalarm.warnings[i])
- X count++;
- X
- X if (count == 0)
- X (void) sprintf (message + strlen (message), "no warnings:");
- X else
- X (void) sprintf (message + strlen (message), "warning%s: ", PLURAL (count));
- X
- X for (i=0; i<xalarm.numwarnings; i++)
- X if (xalarm.timeout > xalarm.warnings[i]) {
- X MAKETIME (message + strlen (message), xalarm.warnings[i]/(1000*60));
- X if (--count > 0)
- X (void) sprintf (message + strlen (message), ",");
- X }
- X
- X Popup (xalarm.confirmwidget, message);
- X}
- X
- X
- X
- X/*
- X * Yow! Let's go!
- X */
- X
- Xvoid Confirmed (widget, clientdata, calldata)
- X Widget widget;
- X XtPointer clientdata, calldata;
- X{
- X String message = DIALOGVALUE (xalarm.confirmwidget);
- X
- X if (*message)
- X XtVaSetValues (xalarm.messagewidget,
- X XtNlabel, (XtArgVal) (xalarm.messagestr = message), NULL);
- X
- X /*
- X * Reset the timeout, since the gap between entering
- X * and confirming may be significant.
- X */
- X
- X xalarm.timeout = TimeToMilliSeconds (xalarm.timestr);
- X AddTimeOuts ();
- X
- X XtPopdown (XtParent (xalarm.gettimewidget));
- X}
- X
- X
- X
- X/*
- X * Swap back to gettime widget & remove kbd focus.
- X */
- X
- Xstatic void Cancel (widget, clientdata, calldata)
- X Widget widget;
- X XtPointer clientdata, calldata;
- X{
- X Popup (xalarm.gettimewidget, TIMEINSTRUCTIONS);
- X}
- X
- X
- X
- X/*
- X * Let's get this widget to the top and set the kbd focus to it.
- X * Set the label for the new widget.
- X */
- X
- Xstatic void Popup (widget, label)
- X Widget widget;
- X String label;
- X{
- X XtVaSetValues (widget, XtNlabel, (XtArgVal) label, NULL);
- X
- X XtSetMappedWhenManaged (xalarm.gettimewidget, (widget == xalarm.gettimewidget));
- X XtSetMappedWhenManaged (xalarm.getwtimewidget, (widget == xalarm.getwtimewidget));
- X XtSetMappedWhenManaged (xalarm.confirmwidget, (widget == xalarm.confirmwidget));
- X
- X XtSetKeyboardFocus (XtParent (xalarm.gettimewidget), widget);
- X}
- END_OF_FILE
- if test 7825 -ne `wc -c <'when.c'`; then
- echo shar: \"'when.c'\" unpacked with wrong size!
- fi
- # end of 'when.c'
- fi
- if test -f 'xalarm.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'xalarm.h'\"
- else
- echo shar: Extracting \"'xalarm.h'\" \(4006 characters\)
- sed "s/^X//" >'xalarm.h' <<'END_OF_FILE'
- X/*
- X Copyright (c) 1991, 1992 by Simon Marshall, University of Hull, UK
- X
- X If you still end up late, don't blame me!
- X
- X Permission to use, copy, modify, distribute, and sell this software and its
- X documentation for any purpose and without fee is hereby granted,
- X provided that the above copyright notice appear in all copies and that
- X both that copyright notice and this permission notice appear in
- X supporting documentation.
- X
- X This software is provided AS IS with no warranties of any kind. The author
- X shall have no liability with respect to the infringement of copyrights,
- X trade secrets or any patents by this file or any part thereof. In no
- X event will the author be liable for any lost revenue or profits or
- X other special, indirect and consequential damages.
- X*/
- X
- X#ifndef xalarm_h
- X#define xalarm_h
- X
- X/*
- X * Bits & bobs #defines, needed by most/all bits & bobs files.
- X */
- X
- X#include "patchlevel.h"
- X
- X#include <stdio.h>
- X#include <ctype.h>
- X#include <signal.h>
- X
- X#include <X11/Xos.h>
- X#include <X11/Intrinsic.h>
- X#include <X11/StringDefs.h>
- X#include <X11/Shell.h>
- X
- X
- X/*
- X * Change these if you want a different notation/language. Keep it to
- X * 3 chars each, lower case only.
- X */
- X
- X#define WEEKDAYS "sun", "mon", "tue", "wed", "thu", "fri", "sat"
- X#define MONTHS "jan", "feb", "mar", "apr", "may", "jun", \
- X "jul", "aug", "sep", "oct", "nov", "dec"
- X
- X/*
- X * Application data - from the parsing of the command line args.
- X */
- X
- Xtypedef struct {
- X String snooze, proggie, geometry, time, warnings;
- X Boolean bell, confirm, list, version, help;
- X int reset, warningwords;
- X} ApplData, *ApplDataPtr;
- X
- X
- X/*
- X * Global xalarm data, stuffed under one structure.
- X */
- X
- Xtypedef struct {
- X XtAppContext appcon;
- X Widget toplevel, alarmwidget, messagewidget, snoozetimewidget,
- X gettimewidget, getwtimewidget, confirmwidget;
- X Boolean bell, confirm;
- X String proggie, geometry, messagestr, timestr, warningsstr;
- X int snooze, numwarnings, warningwords;
- X long timeout, warnings[100], settime;
- X XtIntervalId timeouts[100];
- X} AlarmData, *AlarmDataPtr;
- X
- X/*
- X * macro names...
- X */
- X
- X#define XtNtime "time"
- X#define XtCTime "Time"
- X#define XtNwarnings "warnings"
- X#define XtCWarnings "Warnings"
- X#define XtNwarningwords "warningwords"
- X#define XtCWarningwords "Warningwords"
- X#define XtNsnooze "snooze"
- X#define XtCSnooze "Snooze"
- X#define XtNconfirm "confirm"
- X#define XtCConfirm "Confirm"
- X#define XtNreset "reset"
- X#define XtCReset "Reset"
- X#define XtNbell "bell"
- X#define XtCBell "Bell"
- X#define XtNlist "list"
- X#define XtCList "List"
- X#define XtNversion "version"
- X#define XtCVersion "Version"
- X#define XtNhelp "help"
- X#define XtCHelp "Help"
- X
- X/*
- X * A R4 problem, I think, not apparent in R5.
- X */
- X
- X#ifndef XtNname
- X#define XtNname "name"
- X#endif
- X#ifndef XtCName
- X#define XtCName "Name"
- X#endif
- X
- X/*
- X * And the rest...
- X */
- X
- X#define NOGEOMETRY "NOGEOM"
- X#define or ||
- X#define and &&
- X#define not !
- X#define INVALID (-1)
- X#define TEXT 1024
- X
- X#if defined(SIGNALRETURNSINT)
- X#define SIGRET int
- X#else
- X#define SIGRET void
- X#endif
- X
- X
- X#define CreateManagedButton(widget,name,parent,callback,clientdata) \
- X widget = XtVaCreateManagedWidget (name, commandWidgetClass, parent, NULL); \
- X XtAddCallback (widget, XtNcallback, callback, (XtPointer) clientdata)
- X
- X
- X#define ISINVALID(x) ((x) == (INVALID))
- X
- X#define PLURAL(x) ((((int) (x)) == 1) ? "" : "s")
- X
- X#define MAX(x,y) ((x) > (y) ? (x) : (y))
- X#define MIN(x,y) ((x) < (y) ? (x) : (y))
- X
- X
- X#define MAKETIMESTRING(buf,mins) \
- X if ((mins) >= 60) \
- X (void) sprintf (buf, "%d:%02d hr%s", (mins)/60, (mins)%60, PLURAL ((mins)/60)); \
- X else \
- X (void) sprintf (buf, "%d min%s", (mins), PLURAL (mins));
- X
- X#define MAKETIME(buf,mins) \
- X if ((mins) >= 60) \
- X (void) sprintf (buf, "%d:%02d", (mins)/60, (mins)%60); \
- X else \
- X (void) sprintf (buf, "%d", (mins));
- X
- X
- X/*
- X * DON'T PUT ANYTHING AFTER THIS!!!
- X */
- X#endif
- END_OF_FILE
- if test 4006 -ne `wc -c <'xalarm.h'`; then
- echo shar: \"'xalarm.h'\" unpacked with wrong size!
- fi
- # end of 'xalarm.h'
- fi
- echo shar: End of archive 2 \(of 3\).
- cp /dev/null ark2isdone
- MISSING=""
- for I in 1 2 3 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 3 archives.
- rm -f ark[1-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
- --
- Molecular Simulations, Inc. mail: dcmartin@msi.com
- 796 N. Pastoria Avenue uucp: uunet!dcmartin
- Sunnyvale, California 94086 at&t: 408/522-9236
-