home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / x / volume21 / xcal / part04 < prev    next >
Encoding:
Text File  |  1993-12-22  |  47.1 KB  |  1,759 lines

  1. Newsgroups: comp.sources.x
  2. From: pc@hillside.co.uk (Peter Collinson)
  3. Subject: v21i079:  xcal - A calendar program for X, Part04/08
  4. Message-ID: <1993Dec21.161743.21984@sparky.sterling.com>
  5. X-Md4-Signature: 872fcd03e4d38399228d1bb2d8caf46c
  6. Sender: chris@sparky.sterling.com (Chris Olson)
  7. Organization: Hillside Systems, 61 Hillside Avenue, Canterbury, Kent CT2 8HA
  8. Date: Tue, 21 Dec 1993 16:17:43 GMT
  9. Approved: chris@sterling.com
  10.  
  11. Submitted-by: pc@hillside.co.uk (Peter Collinson)
  12. Posting-number: Volume 21, Issue 79
  13. Archive-name: xcal/part04
  14. Environment: X11
  15. Supersedes: xcal: Volume 12, Issue 101
  16.  
  17. Xcal is a calendar program. For more details see Part 1 of this posting
  18.  
  19. Part 4 of 8
  20. --shar starts here--
  21. #! /bin/sh
  22. # This is a shell archive.  Remove anything before this line, then unpack
  23. # it by saving it into a file and typing "sh file".  To overwrite existing
  24. # files, type "sh file -c".  You can also feed this as standard input via
  25. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  26. # will see the following message at the end:
  27. #        "End of archive 4 (of 8)."
  28. # Contents:  CHANGES xcal_cal/Makefile.bsdi xcal_popup.c
  29. #   xcalpr/xcalpr.c
  30. # Wrapped by pc@hillside on Wed Nov 17 11:24:36 1993
  31. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  32. if test -f 'CHANGES' -a "${1}" != "-c" ; then 
  33.   echo shar: Will not clobber existing file \"'CHANGES'\"
  34. else
  35. echo shar: Extracting \"'CHANGES'\" \(11603 characters\)
  36. sed "s/^X//" >'CHANGES' <<'END_OF_FILE'
  37. XChanges:      CHANGES     2.38     93/11/15
  38. X
  39. X--------------------------- 4.1
  40. X    
  41. X    Remove the `marked' resource. First, it was broken anyway and
  42. X    second it got in the way of having different colours for each day.
  43. X
  44. X    Add a lot of code to cope with different systems. Remove mmap
  45. X    from most programs except xcal_help.c. Some systems that
  46. X    purport to support mmap would do well to remove it (Ultrix
  47. X    seems one).
  48. X
  49. X    Grateful thanks to the several people who worked on the beta
  50. X    releases for me.
  51. X
  52. X--------------------------- 4.1 (beta version of new features)
  53. X    
  54. X    Add in a scroll bar for the date strip, so if it doesn't fit on
  55. X    the screen (or is larger than a named resource maxStripHeight)
  56. X    then you get a scroll bar appearing. This uses a viewport
  57. X    widget and has changed the widget structure of the date strip.
  58. X    I am a little dubious of the height arithmetic here.
  59. X
  60. X    A nice thing to do would be to ensure that `today' was always in
  61. X    the centre of the viewport. This doesn't seem possible.
  62. X    ------- 
  63. X    Alter the NAME of the form widget in the strip to be the Short name of
  64. X    the day. This allows resources to be used to change fonts and colours
  65. X    for days of the week, eg:
  66. X
  67. X        XCal*Sat*Label*font: lucidasans-typewriterbold-12
  68. X    -------
  69. X    Regularise the use of dirent rather than the old 4.2 names. This may
  70. X    need some changes for SYSV based systems, I am unsure. However, let's
  71. X    start with clean code.
  72. X    -------
  73. X    Radically alter the way that date formats are done. 
  74. X    The toplevel widget is now driven by strftime() - and a user defined
  75. X    resource using standard time formats is used to set it. This is
  76. X    replicated for the memo window. The dates at the top of edit windows
  77. X    and strips are set by a modified version of strftime() - this one
  78. X    just deals in days, months and years. Again a resource is used to
  79. X    set it.
  80. X    -------
  81. X    Add the ability to insert a clock in the top level widget. Using the
  82. X    date format string to decide the format that is needed. The code also
  83. X    adapts the polling frequency depending on the clock that is needed.
  84. X    If the string does not mention seconds, then the clock will be
  85. X    pinged every minute. If you want the clock to tick every 30 secs,
  86. X    then the resource clockTick can be set.
  87. X    -------
  88. X    Add limited support for group usage. If called with
  89. X        -u user then it looks for the user's directory and
  90. X    reads files from it. I found that some sites are sharing
  91. X    calendars by using `cat', this is just a better interface than
  92. X    that.
  93. X
  94. X    I don't want to make it setuid, so if there is no access
  95. X    permission for the directory (or the user has hidden it my
  96. X    moving it from the regular name) then it won't find the files.
  97. X    The program is constrained not to write any files in this mode.
  98. X    It will also not start any alarms.
  99. X    
  100. X    If a calendar file is read-only to the user, then the string
  101. X    'Private entry' is displayed. Not much - but something. There
  102. X    should be a private/public button on the edit box.
  103. X
  104. X    The user is reminded that this invocation is not reading their
  105. X    files because the string (user) is added to various date
  106. X    titles. (Someday, proper group usage should be done).
  107. X    -------
  108. X    Fix from Ed Gould. Add a new resource execAlarms to inhibit the
  109. X    ! and %cron commands from happening - even though the remaining
  110. X    alarms will fire.
  111. X    -------
  112. X    Respond to some observations by Jaap Akkerhuis. Now when most buttons
  113. X    are pressed they are made insensitive - so a further button press
  114. X    causes no action. Previously you could get many invocations of dialogs
  115. X    and questions - things could get messy when windows were removed in
  116. X    non-logical orders. Has this fixed everything? Well time will tell.
  117. X    The solution is perhaps a little messy. Still this is the trouble
  118. X    with altering the code rather than re-writing it.
  119. X    -------
  120. X    Act on an idea from Mac Pigman - there is now an edit button on
  121. X    the Memo panel that allows you to edit today's Calendar entry.
  122. X    -------
  123. X    Redo the way that help is done. Can now take the text from a file
  124. X    and/or compile it in. This should help non-English speaking users
  125. X    to have a local language help. A shell script is provided to take
  126. X    the help file and translate it into some C.
  127. X    -------
  128. X    Rework various button handling so that buttons are made insensitive
  129. X    when they are pressed. The main problem here is putting them back on
  130. X    safely. This has added perhaps too much code - but it works better
  131. X    --------
  132. X    Redo the manual page
  133. X    --------
  134. X    Make the title bar widgets adjust their offset from the outside world
  135. X    so that they are centred vertically
  136. X    --------
  137. X    Allow for the 12 hour clock in alarms. If the resource AlarmWarp is
  138. X    set true and the time of the alarm is between zero and the value
  139. X    in MinAlarmWarp then the time is taken as a pm time. This idea from
  140. X    Mark Pawliger.
  141. X    ---------
  142. X    When the Cmd resource is set, the command that is executed takes the
  143. X    data from the remainder of the calendar line as an argument. Ensure
  144. X    that 1) this is passed as a quoted single argument to the system routine
  145. X    call. Cope with embedded single quotes.
  146. X    ---------
  147. X    Fix memory leak when displaying the Weekly entry (leak spotted by
  148. X    chet@arc.uucp - be nice to have his real name)
  149. X    ---------
  150. X    Make a number of changes to the alarm system to attempt to stop
  151. X    the races that happened when using ClockTick update polling. It turns
  152. X    out that various bits of the old code was done without real regard
  153. X    for the event driven nature of X applications. The code now appears
  154. X    to trigger alarms OK - and will not break when the control files are
  155. X    reloaded. While I was testing this the clocks went back an hour and
  156. X    that caused some confusion until I realised what had happened.
  157. X    
  158. X    It's still the case that alarms need one minute to trigger properly.
  159. X    ----------
  160. X    Provide xcalev, this should go somewhere to meet the needs of the
  161. X    several people who mailed saying `it's great' but I cannot deal with
  162. X    regular events... so I won't be using it. Their loss I feel :-)
  163. X    ----------
  164. X    Provide xcalpr, print calendar entries to a text terminal.
  165. X    Also generates input for the calendar program
  166. X    ----------
  167. X    Put xcalev, xcalpr, xcal_cal into sub dirs, deal with the Imakefiles
  168. X    to do that.
  169. X    ----------
  170. X    Remove AT&T code and replace with code from the NetII tape.
  171. X
  172. X--------------------------- 3.4
  173. X
  174. X    Add Xos.h as a define in xcal.c and xcal_edit.c.
  175. X
  176. X    When the middle button is used to get a month/year selection
  177. X    box, if you just type the month name, you will get the next month
  178. X    with that name, not the month THIS year.
  179. X
  180. X    Fix in xcal_alarm.c that was freeing a non freeable area.
  181. X    I bet this has caused some problems.
  182. X    Fix from Julian Bradfield <jcb@dcs.ed.ac.uk>
  183. X    Fix in xcal_strip.c which is causing widgets to be named
  184. X    incorrectly. Widgets were called `Day' rather than '1 Day' as
  185. X    advertised. Bug spotted by James Matthew Farrow <matty@cs.su.oz.au>.
  186. X    (This later removed to allow days to be specified in resources)
  187. X
  188. X    ------- 
  189. X    (These from Miles O'Neal <meo@pencom.com>)
  190. X
  191. X    Now builds for NeXTSTEP 3.0.
  192. X
  193. X    Compiler warnings were cleaned up.
  194. X
  195. X    Top level help now through button, not printed to tty.
  196. X    Help boxes are reused, not created and destroyed every
  197. X    time they are accessed.  This also prvents multiple
  198. X    copies of the same help box from existing simultaneoulsy.
  199. X
  200. X    Added the calendar icon from bricons.
  201. X    --------
  202. X    I guess I have changed my C bracketing style in the last two
  203. X    years. Ran the code through indent so I would feel a little happier.
  204. X    --------
  205. X    Well, I had this idea two years ago.
  206. X
  207. X    If you now make a selection using the mouse - select some text
  208. X    on the screen - then it can be appended into a day file by
  209. X    simply clicking with the MIDDLE mouse button on the day of your
  210. X    choice. This makes it easy to set groups of dates up using the
  211. X    mouse.
  212. X
  213. X
  214. X--------------------------- 3.3
  215. X
  216. X    Implement the ability to deal with regular weekly events.
  217. X    This is part of the memo system. Today's current events are
  218. X    shown as part of the memo panel. They can be edited by hitting
  219. X    a button and bringing up a special strip with an entry for
  220. X    each day. These regular event files are integrated into
  221. X    the alarm system.
  222. X
  223. X    Allow today's name: Monday, Tuesday etc to appear in the top
  224. X    level widget, the header of an edit window and the title of
  225. X    the memo box. This is controlled by the Order and Format
  226. X    resources and so previous behaviour can be maintained. Beware
  227. X    that this redefines the names of the days so
  228. X        Sunday maps to Sunday
  229. X    and a new short name is used for the abbreviated form
  230. X        Sun maps to Sun
  231. X    used in date strips.
  232. X
  233. X    Ensure that middle and right button translations work in the
  234. X    memo button in the top level widget (suggested by Casey
  235. X    Leedom).
  236. X
  237. X    New Imakefile from Casey Leedom. This has support for pscal.
  238. X    New pscal/Imakefile.
  239. X
  240. X    Add initialMemo resource so the memo box can popup at startup
  241. X    time - (suggested by G. W. Pigman III)
  242. X
  243. X    Steven Plite pointed out that the year display is
  244. X    inconsistent. To allow choice, add three new resources:
  245. X        dateYearIsTwoDigits
  246. X        memoYearIsTwoDigits
  247. X        editYearIsTwoDigits
  248. X    You can now choose how you would like to have your year
  249. X    displayed in the various places.
  250. X    Defaults to showing four digits.
  251. X
  252. X    System V release 4 fixes from Dave McCraken.
  253. X    Alters: xcal_alarm.c, xcal_cal.c, *.bm xcal.c
  254. X
  255. X    The memo box quit button causes a Save File
  256. X    dialogue box to be popped if the memo data has been
  257. X    altered and not saved. The behaviour of this was wrong
  258. X    when there was no memo data.    Reported by Greg Bond.
  259. X    Fixed by changing tests in xcal_memo.c.
  260. X
  261. X    Proper length of a directory entry under SYSV is 
  262. X    strlen(dp->d_name) not strlen(dp->d_name)+1.
  263. X    Changed xcal_edit.c             (Dave McCraken)
  264. X
  265. X    Eliminated double definition of GetMemoFile() and incorrect
  266. X    definition of MemoHelp() in xcal_memo.c (David C Lawrence)
  267. X
  268. X--------------------------- 3.2 
  269. X
  270. XXcal - Version 3.2 Issued to comp.sources.x
  271. X
  272. X    Fixes some stupid bugs
  273. X    Ensures that update code works properly
  274. X
  275. X---------------------------- 3.1
  276. X
  277. XXcal - Version 3.1 Issued to comp.sources.x (un-intentionally)
  278. X
  279. X    Adds the memo functionality and the Stick/Unpin feature
  280. X    for alarms.
  281. X
  282. X---------------------------- 2.1
  283. X
  284. XXcal - Version 2.1 Issued privately
  285. X
  286. X    Two main differences between version 1.1 and version 2.1
  287. X    a)    Version 2.1 has alarms so that xcal can poll you
  288. X        during the day - idea contributed by Mark Majhor, Sequent
  289. X        and then unashame-edly hacked by me.
  290. X    b)    Version 2.1 has a support program supplied by Ed Gould
  291. X        from Mt Xinu allowing you to set up a file suitable for
  292. X        driving UNIX's calendar program.
  293. X
  294. X---------------------------- 1.6
  295. X
  296. Xpscal/pscal.sh    Fix to make sed work better to truncate the calendar file
  297. X        when printing.
  298. X        From Gregory Bond, Burdett Buckeridge & Young Ltd, Melbourne, Australia
  299. X        Internet: gnb@melba.bby.oz.au    non-MX: gnb%melba.bby.oz@uunet.uu.net
  300. X
  301. X---------------------------- 1.5
  302. X
  303. Xxcal.h        Add initialCalendar/initialEdit switches
  304. X        Support for better start-up options... from
  305. X        From: Rod Whitby <rwhitby@adl.austek.oz.au>
  306. X
  307. Xxcal.c        Add hooks and code to perform startuo
  308. X
  309. XImakefile    Corrected
  310. X
  311. Xxcal.man    Add new lines supporting initialCalendar/initialEdit
  312. X
  313. X---------------------------- 1.4
  314. Xxcal_edit.c    Fix bug where colour mapping on days failed to change when
  315. X        data is deleted or added.
  316. X
  317. Xxcal.h/xcal.c/xcal_strip.c
  318. X        Add a new resource minStripWidth intended to allow
  319. X        users to widen the strip to some value which seems
  320. X        sensible. If zero the resource is unused.
  321. X
  322. XXCal.ad        Add colour map from wade@cs.utk.edu
  323. X
  324. Xxcal_edit.c    Changes to XBell calls due to typo
  325. X        Steve Alexander, Software Technologies Group
  326. X        INTERACTIVE Systems Corporation, Naperville, IL
  327. X         ...!{sun,ico}!laidbak!stevea
  328. X        stevea@i88.isc.com
  329. X
  330. X
  331. X    
  332. XXcal - Version 1.1 Issued to the net comp.sources.x. 
  333. X        xcal: Volume 7, Issue 1-2
  334. X
  335. END_OF_FILE
  336. if test 11603 -ne `wc -c <'CHANGES'`; then
  337.     echo shar: \"'CHANGES'\" unpacked with wrong size!
  338. fi
  339. # end of 'CHANGES'
  340. fi
  341. if test -f 'xcal_cal/Makefile.bsdi' -a "${1}" != "-c" ; then 
  342.   echo shar: Will not clobber existing file \"'xcal_cal/Makefile.bsdi'\"
  343. else
  344. echo shar: Extracting \"'xcal_cal/Makefile.bsdi'\" \(9778 characters\)
  345. sed "s/^X//" >'xcal_cal/Makefile.bsdi' <<'END_OF_FILE'
  346. X# Makefile generated by imake - do not edit!
  347. X# $XConsortium: imake.c,v 1.65 91/07/25 17:50:17 rws Exp $
  348. X
  349. X# -------------------------------------------------------------------------
  350. X# Makefile generated from "Imake.tmpl" and <Imakefile>
  351. X# $XConsortium: Imake.tmpl,v 1.139 91/09/16 08:52:48 rws Exp $
  352. X#
  353. X# Platform-specific parameters may be set in the appropriate <vendor>.cf
  354. X# configuration files.  Site-specific parameters should be set in the file
  355. X# site.def.  Full rebuilds are recommended if any parameters are changed.
  356. X#
  357. X# If your C preprocessor does not define any unique symbols, you will need
  358. X# to set BOOTSTRAPCFLAGS when rebuilding imake (usually when doing
  359. X# "make World" the first time).
  360. X#
  361. X
  362. X# -------------------------------------------------------------------------
  363. X# site-specific configuration parameters that need to come before
  364. X# the platform-specific parameters - edit site.def to change
  365. X
  366. X# site:  $XConsortium: site.def,v 1.2 91/07/30 20:26:44 rws Exp $
  367. X
  368. X# -------------------------------------------------------------------------
  369. X# platform-specific configuration parameters - edit bsd.cf to change
  370. X
  371. X# platform:  $XConsortium: bsd.cf,v 1.18 91/07/30 12:10:52 rws Exp $
  372. X
  373. X# operating system:             4.3bsd
  374. X
  375. X# -------------------------------------------------------------------------
  376. X# site-specific configuration parameters that go after
  377. X# the platform-specific parameters - edit site.def to change
  378. X
  379. X# site:  $XConsortium: site.def,v 1.2 91/07/30 20:26:44 rws Exp $
  380. X
  381. X            SHELL =     /bin/sh
  382. X
  383. X              TOP = .
  384. X      CURRENT_DIR = .
  385. X
  386. X               AR = ar clq
  387. X  BOOTSTRAPCFLAGS =
  388. X               CC = cc
  389. X               AS = as
  390. X
  391. X         COMPRESS = compress
  392. X              CPP =     /usr/bin/cpp $(STD_CPP_DEFINES)
  393. X    PREPROCESSCMD = cc -E $(STD_CPP_DEFINES)
  394. X          INSTALL = install
  395. X               LD = ld
  396. X             LINT = lint
  397. X      LINTLIBFLAG = -C
  398. X         LINTOPTS = -axz
  399. X               LN = ln -s
  400. X             MAKE = make
  401. X               MV = mv
  402. X               CP = cp
  403. X
  404. X           RANLIB = ranlib
  405. X  RANLIBINSTFLAGS =
  406. X
  407. X               RM = rm -f
  408. X            TROFF = groff -Tps
  409. X         MSMACROS = -ms
  410. X              TBL = tbl
  411. X              EQN = eqn
  412. X     STD_INCLUDES =
  413. X  STD_CPP_DEFINES =
  414. X      STD_DEFINES =
  415. X EXTRA_LOAD_FLAGS =
  416. X  EXTRA_LIBRARIES =
  417. X             TAGS = ctags
  418. X
  419. X    PROTO_DEFINES =
  420. X
  421. X     INSTPGMFLAGS = -s
  422. X
  423. X     INSTBINFLAGS = -m 0755
  424. X     INSTUIDFLAGS = -m 4755
  425. X     INSTLIBFLAGS = -m 0644
  426. X     INSTINCFLAGS = -m 0444
  427. X     INSTMANFLAGS = -m 0444
  428. X     INSTDATFLAGS = -m 0444
  429. X    INSTKMEMFLAGS = -m 4755
  430. X
  431. X      PROJECTROOT =  /usr/X11
  432. X
  433. X     TOP_INCLUDES = -I$(INCROOT)
  434. X
  435. X      CDEBUGFLAGS = -O
  436. X        CCOPTIONS =
  437. X
  438. X      ALLINCLUDES = $(INCLUDES) $(EXTRA_INCLUDES) $(TOP_INCLUDES) $(STD_INCLUDES)
  439. X       ALLDEFINES = $(ALLINCLUDES) $(STD_DEFINES) $(EXTRA_DEFINES) $(PROTO_DEFINES) $(DEFINES)
  440. X           CFLAGS = $(CDEBUGFLAGS) $(CCOPTIONS) $(ALLDEFINES)
  441. X        LINTFLAGS = $(LINTOPTS) -DLINT $(ALLDEFINES)
  442. X
  443. X           LDLIBS = $(SYS_LIBRARIES) $(EXTRA_LIBRARIES)
  444. X
  445. X        LDOPTIONS = $(CDEBUGFLAGS) $(CCOPTIONS) $(LOCAL_LDFLAGS) -L$(USRLIBDIR)
  446. X
  447. X   LDCOMBINEFLAGS = -X -r
  448. X      DEPENDFLAGS =
  449. X
  450. X        MACROFILE = bsd.cf
  451. X           RM_CMD = $(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a .emacs_* tags TAGS make.log MakeOut
  452. X
  453. X    IMAKE_DEFINES =
  454. X
  455. X         IRULESRC = $(CONFIGDIR)
  456. X        IMAKE_CMD = $(IMAKE) -DUseInstalled -I$(IRULESRC) $(IMAKE_DEFINES)
  457. X
  458. X     ICONFIGFILES = $(IRULESRC)/Imake.tmpl $(IRULESRC)/Imake.rules             $(IRULESRC)/Project.tmpl $(IRULESRC)/site.def             $(IRULESRC)/$(MACROFILE) $(EXTRA_ICONFIGFILES)
  459. X
  460. X# -------------------------------------------------------------------------
  461. X# X Window System Build Parameters
  462. X# $XConsortium: Project.tmpl,v 1.138.1.1 92/11/11 09:49:19 rws Exp $
  463. X
  464. X# -------------------------------------------------------------------------
  465. X# X Window System make variables; this need to be coordinated with rules
  466. X
  467. X          PATHSEP = /
  468. X        USRLIBDIR =  /usr/X11/lib
  469. X           BINDIR =  /usr/X11/bin
  470. X          INCROOT =  /usr/X11/include
  471. X     BUILDINCROOT = $(TOP)
  472. X      BUILDINCDIR = $(BUILDINCROOT)/X11
  473. X      BUILDINCTOP = ..
  474. X           INCDIR = $(INCROOT)/X11
  475. X           ADMDIR = /usr/adm
  476. X           LIBDIR = $(USRLIBDIR)/X11
  477. X        CONFIGDIR = $(LIBDIR)/config
  478. X       LINTLIBDIR = $(USRLIBDIR)/lint
  479. X
  480. X          FONTDIR = $(LIBDIR)/fonts
  481. X         XINITDIR = $(LIBDIR)/xinit
  482. X           XDMDIR = $(LIBDIR)/xdm
  483. X           TWMDIR = $(LIBDIR)/twm
  484. X          MANPATH =  /usr/X11/man
  485. X    MANSOURCEPATH = $(MANPATH)/man
  486. X        MANSUFFIX = n
  487. X     LIBMANSUFFIX = 3
  488. X           MANDIR = $(MANSOURCEPATH)$(MANSUFFIX)
  489. X        LIBMANDIR = $(MANSOURCEPATH)$(LIBMANSUFFIX)
  490. X           NLSDIR = $(LIBDIR)/nls
  491. X        PEXAPIDIR = $(LIBDIR)/PEX
  492. X      XAPPLOADDIR = $(LIBDIR)/app-defaults
  493. X       FONTCFLAGS = -t
  494. X
  495. X     INSTAPPFLAGS = $(INSTDATFLAGS)
  496. X
  497. X            IMAKE = imake
  498. X           DEPEND = makedepend
  499. X              RGB = rgb
  500. X
  501. X            FONTC = bdftopcf
  502. X
  503. X        MKFONTDIR = mkfontdir
  504. X        MKDIRHIER =     /bin/sh $(BINDIR)/mkdirhier
  505. X
  506. X        CONFIGSRC = $(TOP)/config
  507. X       DOCUTILSRC = $(TOP)/doc/util
  508. X        CLIENTSRC = $(TOP)/clients
  509. X          DEMOSRC = $(TOP)/demos
  510. X           LIBSRC = $(TOP)/lib
  511. X          FONTSRC = $(TOP)/fonts
  512. X       INCLUDESRC = $(TOP)/X11
  513. X        SERVERSRC = $(TOP)/server
  514. X          UTILSRC = $(TOP)/util
  515. X        SCRIPTSRC = $(UTILSRC)/scripts
  516. X       EXAMPLESRC = $(TOP)/examples
  517. X       CONTRIBSRC = $(TOP)/../contrib
  518. X           DOCSRC = $(TOP)/doc
  519. X           RGBSRC = $(TOP)/rgb
  520. X        DEPENDSRC = $(UTILSRC)/makedepend
  521. X         IMAKESRC = $(CONFIGSRC)
  522. X         XAUTHSRC = $(LIBSRC)/Xau
  523. X          XLIBSRC = $(LIBSRC)/X
  524. X           XMUSRC = $(LIBSRC)/Xmu
  525. X       TOOLKITSRC = $(LIBSRC)/Xt
  526. X       AWIDGETSRC = $(LIBSRC)/Xaw
  527. X       OLDXLIBSRC = $(LIBSRC)/oldX
  528. X      XDMCPLIBSRC = $(LIBSRC)/Xdmcp
  529. X      BDFTOSNFSRC = $(FONTSRC)/bdftosnf
  530. X      BDFTOSNFSRC = $(FONTSRC)/clients/bdftosnf
  531. X      BDFTOPCFSRC = $(FONTSRC)/clients/bdftopcf
  532. X     MKFONTDIRSRC = $(FONTSRC)/clients/mkfontdir
  533. X         FSLIBSRC = $(FONTSRC)/lib/fs
  534. X    FONTSERVERSRC = $(FONTSRC)/server
  535. X     EXTENSIONSRC = $(TOP)/extensions
  536. X         XILIBSRC = $(EXTENSIONSRC)/lib/xinput
  537. X        PEXLIBSRC = $(EXTENSIONSRC)/lib/PEXlib
  538. X      PHIGSLIBSRC = $(EXTENSIONSRC)/lib/PEX
  539. X
  540. X  DEPEXTENSIONLIB = $(USRLIBDIR)/libXext.a
  541. X     EXTENSIONLIB =              -lXext
  542. X
  543. X          DEPXLIB = $(DEPEXTENSIONLIB) $(USRLIBDIR)/libX11.a
  544. X             XLIB = $(EXTENSIONLIB)              -lX11
  545. X
  546. X      DEPXAUTHLIB = $(USRLIBDIR)/libXau.a
  547. X         XAUTHLIB =              -lXau
  548. X      DEPXDMCPLIB = $(USRLIBDIR)/libXdmcp.a
  549. X         XDMCPLIB =              -lXdmcp
  550. X
  551. X        DEPXMULIB = $(USRLIBDIR)/libXmu.a
  552. X           XMULIB =              -lXmu
  553. X
  554. X       DEPOLDXLIB = $(USRLIBDIR)/liboldX.a
  555. X          OLDXLIB =              -loldX
  556. X
  557. X      DEPXTOOLLIB = $(USRLIBDIR)/libXt.a
  558. X         XTOOLLIB =              -lXt
  559. X
  560. X        DEPXAWLIB = $(USRLIBDIR)/libXaw.a
  561. X           XAWLIB =              -lXaw
  562. X
  563. X        DEPXILIB = $(USRLIBDIR)/libXi.a
  564. X           XILIB =              -lXi
  565. X
  566. X       DEPPEXLIB = $(USRLIBDIR)/libPEX5.a
  567. X          PEXLIB =              -lPEX5
  568. X
  569. X        DEPPHIGSLIB = $(USRLIBDIR)/libphigs.a
  570. X           PHIGSLIB =              -lphigs
  571. X
  572. X       DEPXBSDLIB = $(USRLIBDIR)/libXbsd.a
  573. X          XBSDLIB =              -lXbsd
  574. X
  575. X LINTEXTENSIONLIB = $(LINTLIBDIR)/llib-lXext.ln
  576. X         LINTXLIB = $(LINTLIBDIR)/llib-lX11.ln
  577. X          LINTXMU = $(LINTLIBDIR)/llib-lXmu.ln
  578. X        LINTXTOOL = $(LINTLIBDIR)/llib-lXt.ln
  579. X          LINTXAW = $(LINTLIBDIR)/llib-lXaw.ln
  580. X           LINTXI = $(LINTLIBDIR)/llib-lXi.ln
  581. X          LINTPEX = $(LINTLIBDIR)/llib-lPEX5.ln
  582. X        LINTPHIGS = $(LINTLIBDIR)/llib-lphigs.ln
  583. X
  584. X          DEPLIBS = $(DEPXAWLIB) $(DEPXMULIB) $(DEPXTOOLLIB) $(DEPXLIB)
  585. X
  586. X         DEPLIBS1 = $(DEPLIBS)
  587. X         DEPLIBS2 = $(DEPLIBS)
  588. X         DEPLIBS3 = $(DEPLIBS)
  589. X
  590. X# -------------------------------------------------------------------------
  591. X# Imake rules for building libraries, programs, scripts, and data files
  592. X# rules:  $XConsortium: Imake.rules,v 1.123 91/09/16 20:12:16 rws Exp $
  593. X
  594. X# -------------------------------------------------------------------------
  595. X# start of Imakefile
  596. X
  597. XBINDIR=/usr/local/bin
  598. X
  599. XINSTPGMFLAGS=$(INSTBINFLAGS)
  600. X
  601. Xall:: xcal_cal
  602. X
  603. X OBJS = xcal_cal.o
  604. X SRCS = xcal_cal.c
  605. X
  606. X PROGRAM = xcal_cal
  607. X
  608. Xall:: xcal_cal
  609. X
  610. Xxcal_cal: $(OBJS) $(DEPLIBS)
  611. X    $(RM) $@
  612. X    $(CC) -o $@ $(OBJS) $(LDOPTIONS) $(LOCAL_LIBRARIES) $(LDLIBS) $(EXTRA_LOAD_FLAGS)
  613. X
  614. Xinstall:: xcal_cal
  615. X    -@if [ -d $(DESTDIR)$(BINDIR) ]; then set +x; \
  616. X    else (set -x; $(MKDIRHIER) $(DESTDIR)$(BINDIR)); fi
  617. X    $(INSTALL) -c $(INSTPGMFLAGS)  xcal_cal $(DESTDIR)$(BINDIR)
  618. X
  619. Xinstall.man:: xcal_cal.man
  620. X    -@if [ -d $(DESTDIR)$(MANDIR) ]; then set +x; \
  621. X    else (set -x; $(MKDIRHIER) $(DESTDIR)$(MANDIR)); fi
  622. X    $(INSTALL) -c $(INSTMANFLAGS) xcal_cal.man $(DESTDIR)$(MANDIR)/xcal_cal.$(MANSUFFIX)
  623. X
  624. Xdepend::
  625. X    $(DEPEND) $(DEPENDFLAGS) -s "# DO NOT DELETE" -- $(ALLDEFINES) -- $(SRCS)
  626. X
  627. Xlint:
  628. X    $(LINT) $(LINTFLAGS) $(SRCS) $(LINTLIBS)
  629. Xlint1:
  630. X    $(LINT) $(LINTFLAGS) $(FILE) $(LINTLIBS)
  631. X
  632. Xclean::
  633. X    $(RM) $(PROGRAM)
  634. X
  635. Xdepend::
  636. X    $(DEPEND) $(DEPENDFLAGS) -s "# DO NOT DELETE" -- $(ALLDEFINES) -- $(SRCS)
  637. X
  638. X# -------------------------------------------------------------------------
  639. X# common rules for all Makefiles - do not edit
  640. X
  641. Xemptyrule::
  642. X
  643. Xclean::
  644. X    $(RM_CMD) "#"*
  645. X
  646. XMakefile::
  647. X    -@if [ -f Makefile ]; then set -x; \
  648. X    $(RM) Makefile.bak; $(MV) Makefile Makefile.bak; \
  649. X    else exit 0; fi
  650. X    $(IMAKE_CMD) -DTOPDIR=$(TOP) -DCURDIR=$(CURRENT_DIR)
  651. X
  652. Xtags::
  653. X    $(TAGS) -w *.[ch]
  654. X    $(TAGS) -xw *.[ch] > TAGS
  655. X
  656. X# -------------------------------------------------------------------------
  657. X# empty rules for directories that do not have SUBDIRS - do not edit
  658. X
  659. Xinstall::
  660. X    @echo "install in $(CURRENT_DIR) done"
  661. X
  662. Xinstall.man::
  663. X    @echo "install.man in $(CURRENT_DIR) done"
  664. X
  665. XMakefiles::
  666. X
  667. Xincludes::
  668. X
  669. X# -------------------------------------------------------------------------
  670. X# dependencies generated by makedepend
  671. X
  672. END_OF_FILE
  673. if test 9778 -ne `wc -c <'xcal_cal/Makefile.bsdi'`; then
  674.     echo shar: \"'xcal_cal/Makefile.bsdi'\" unpacked with wrong size!
  675. fi
  676. # end of 'xcal_cal/Makefile.bsdi'
  677. fi
  678. if test -f 'xcal_popup.c' -a "${1}" != "-c" ; then 
  679.   echo shar: Will not clobber existing file \"'xcal_popup.c'\"
  680. else
  681. echo shar: Extracting \"'xcal_popup.c'\" \(9814 characters\)
  682. sed "s/^X//" >'xcal_popup.c' <<'END_OF_FILE'
  683. X#ifndef lint
  684. Xstatic char    *sccsid = "@(#)xcal_popup.c    3.13 (Hillside Systems) 10/29/93";
  685. Xstatic char    *copyright = "@(#)Copyright 1989,1990,1993 Peter Collinson, Hillside Systems";
  686. X#endif                /* lint */
  687. X/***
  688. X
  689. X* module name:
  690. X    xcal_popup.c
  691. X* function:
  692. X    Deal with various popups for xcal
  693. X    There are two main ones:
  694. X    a)    the centre button causes a popup date selection popup
  695. X    b)    the right button causes an exit popup
  696. X* history:
  697. X    Written November 1989
  698. X    Peter Collinson
  699. X    Hillside Systems
  700. X* (C) Copyright: 1989 Hillside Systems/Peter Collinson
  701. X    
  702. X    For full permissions and copyright notice - see xcal.c
  703. X***/
  704. X#include <stdio.h>
  705. X#include <ctype.h>
  706. X#include <X11/Intrinsic.h>
  707. X#include <X11/StringDefs.h>
  708. X#include <X11/Shell.h>
  709. X#include <X11/Xaw/Label.h>
  710. X#include <X11/Xaw/Dialog.h>
  711. X#include <X11/Xaw/AsciiText.h>
  712. X#include <X11/Xaw/Command.h>
  713. X#include "xcal.h"
  714. X
  715. Xstatic void     AskDialog();
  716. Xstatic void     NoCal();
  717. Xstatic void     YesCal();
  718. Xstatic char    *DateParse();
  719. Xstatic int      MonScan();
  720. Xstatic void     LeaveDialog();
  721. Xstatic void     NoLeave();
  722. Xstatic void     YesLeave();
  723. Xstatic void     NoEdit();
  724. X
  725. X#define argLD(N,V) { XtSetArg(args[nargs], N, V); nargs++; }
  726. X
  727. X/*
  728. X * This routine deals with most of the work to create a dialog popup, it is
  729. X * passed a function which is called to create the dialog box
  730. X * 
  731. X * The widget here is used for positioning, these popups are always children of
  732. X * the toplevel widget
  733. X *
  734. X * These widgets are generally called from a Command widget button.
  735. X * if this is the case, we make that button non-sensitive and
  736. X * use the pop-down callback to turn them on again (see xcal_buts.c)
  737. X */
  738. Xvoid
  739. XDialogPopup(w, fn, arg, but)
  740. X    Widget          w;
  741. X    void            (*fn) ();
  742. X    caddr_t         arg;
  743. X    Widget        but;
  744. X{
  745. X    Widget          pop;
  746. X    Arg             args[10];
  747. X    int        nargs;
  748. X    Position        x, y;
  749. X    Position        nx, ny;
  750. X    Dimension       width, height, border;
  751. X
  752. X    /*
  753. X     * Get the position of the toplevel so we 
  754. X     * can position the dialog box properly
  755. X     */
  756. X    XtSetArg(args[0], XtNwidth, &width);
  757. X    XtSetArg(args[1], XtNheight, &height);
  758. X    XtGetValues(w, args, 2);
  759. X    XtTranslateCoords(w, (Position) (width / 2),
  760. X              (Position) (height / 2), &x, &y);
  761. X
  762. X    /*
  763. X     * Create a popup to hold the dialog
  764. X     */
  765. X    nargs = 0;
  766. X    argLD(XtNallowShellResize, True);
  767. X    argLD(XtNinput, True);
  768. X    argLD(XtNx, x);
  769. X    argLD(XtNy, y);
  770. X    argLD(XtNsaveUnder, FALSE);    /* was true but this caused */
  771. X                    /* me problems on OpenWindows */
  772. X
  773. X    pop = XtCreatePopupShell("question", transientShellWidgetClass, toplevel, args, nargs);
  774. X
  775. X    if (but && XtIsSubclass(but, commandWidgetClass))
  776. X        ButtonOff(but, pop);
  777. X
  778. X    /*
  779. X     * Set up the dialog
  780. X     */
  781. X    (*fn) (pop, arg);
  782. X
  783. X    XtRealizeWidget(pop);
  784. X
  785. X    /*
  786. X     * We can now worry if this box is actually off the screen
  787. X     */
  788. X    XtSetArg(args[0], XtNwidth, &width);
  789. X    XtSetArg(args[1], XtNheight, &height);
  790. X    XtSetArg(args[2], XtNborderWidth, &border);
  791. X    XtGetValues(pop, args, 3);
  792. X
  793. X    border <<= 1;
  794. X    XtTranslateCoords(pop, (Position) 0, (Position) 0, &nx, &ny);
  795. X
  796. X    if ((int)(nx + width + border) > WidthOfScreen(XtScreen(toplevel)))
  797. X        nx = WidthOfScreen(XtScreen(toplevel)) - width - border;
  798. X    else
  799. X        nx = x;
  800. X
  801. X    if ((int)(ny + height + border) > HeightOfScreen(XtScreen(toplevel)))
  802. X        ny = HeightOfScreen(XtScreen(toplevel)) - height - border;
  803. X    else
  804. X        ny = y;
  805. X
  806. X    if (nx != x || ny != y) {
  807. X        XtSetArg(args[0], XtNx, nx);
  808. X        XtSetArg(args[1], XtNy, ny);
  809. X        XtSetValues(pop, args, 2);
  810. X    }
  811. X    XtPopup(pop, XtGrabNone);
  812. X}
  813. X
  814. X/************************************************************************/
  815. X/*                                    */
  816. X/*                                    */
  817. X/*    Deals with middle button presses - ask for a date        */
  818. X/*                                    */
  819. X/*                                    */
  820. X/************************************************************************/
  821. X
  822. X/*
  823. X * SetDate - ask for a date and start a calendar
  824. X * This is an action routine
  825. X */
  826. X/* ARGSUSED */
  827. Xvoid
  828. XSetDate(w, event, params, numb)
  829. X    Widget          w;
  830. X    XEvent         *event;
  831. X    String         *params;
  832. X    Cardinal       *numb;
  833. X{
  834. X    DialogPopup(toplevel, AskDialog, NULL, w);
  835. X}
  836. X
  837. X/* ARGSUSED */
  838. Xstatic void
  839. XAskDialog(pop, noop)
  840. X    Widget          pop;
  841. X    Cardinal        noop;
  842. X{
  843. X    Widget          dia;
  844. X    Arg             args[2];
  845. X    WidgetList      children;    /* which is Widget children[] */
  846. X    Cardinal        num_children;
  847. X    int             i;
  848. X
  849. X    /* Take from args: "Enter mm yyyy?" */
  850. X    XtSetArg(args[0], XtNvalue, "");
  851. X    dia = XtCreateManagedWidget("newdate", dialogWidgetClass, pop, args, 1);
  852. X    XawDialogAddButton(dia, "ok", YesCal, dia);
  853. X    XawDialogAddButton(dia, "cancel", NoCal, pop);
  854. X    /*
  855. X     * I would like to add CR translations to the text box the only way
  856. X     * to get the widget seems to be to use an R4 feature to get the
  857. X     * WidgetList
  858. X     */
  859. X    XtSetArg(args[0], XtNchildren, &children);
  860. X    XtSetArg(args[1], XtNnumChildren, &num_children);
  861. X    XtGetValues(dia, (ArgList) args, 2);
  862. X    for (i = 0; i < num_children; i++) {
  863. X        if (XtClass(children[i]) == asciiTextWidgetClass) {
  864. X            /* Bingo */
  865. X            XtOverrideTranslations(
  866. X                           children[i],
  867. X                           XtParseTranslationTable("<Key>Return: SetDateAction()")
  868. X                );
  869. X
  870. X        } else
  871. X        if (XtClass(children[i]) == labelWidgetClass) {
  872. X            XtSetArg(args[0], XtNresizable, True);
  873. X            XtSetValues(children[i], args, 1);
  874. X        }
  875. X    }
  876. X
  877. X}
  878. X
  879. X/*
  880. X * No we don't want a specified date
  881. X * Closure here is the pop shell
  882. X */
  883. X/* ARGSUSED */
  884. Xstatic void
  885. XNoCal(w, closure, call_data)
  886. X    Widget          w;
  887. X    caddr_t         closure;
  888. X    caddr_t         call_data;
  889. X{
  890. X    XtDestroyWidget((Widget) closure);
  891. X}
  892. X
  893. X/*
  894. X * Yes we do want a specified date
  895. X * Closure here is the dialog widget
  896. X */
  897. X/* ARGSUSED */
  898. Xstatic void
  899. XYesCal(w, closure, call_data)
  900. X    Widget          w;
  901. X    caddr_t         closure;
  902. X    caddr_t         call_data;
  903. X{
  904. X    Widget          dia;
  905. X    Arg             args[2];
  906. X    Date            wanted;
  907. X    char           *errstr;
  908. X
  909. X    dia = (Widget) closure;
  910. X    /*
  911. X     * Parse the string
  912. X     */
  913. X    if (errstr = DateParse(XawDialogGetValueString(dia), &wanted)) {
  914. X        /*
  915. X         * insert an error                             * message in the widget
  916. X         */
  917. X        XtSetArg(args[0], XtNlabel, errstr);
  918. X        XtSetValues(dia, args, 1);
  919. X        XBell(XtDisplay(toplevel), 0);
  920. X        return;
  921. X    }
  922. X    XtDestroyWidget(XtParent(dia));
  923. X    NewMonthStrip(&wanted, NULL);
  924. X}
  925. X
  926. X/*
  927. X * Action mapped to by CR in the dialog
  928. X */
  929. X/* ARGSUSED */
  930. Xvoid
  931. XTextCal(w, event, params, numb)
  932. X    Widget          w;
  933. X    XEvent         *event;
  934. X    String         *params;
  935. X    Cardinal       *numb;
  936. X{
  937. X    YesCal(w, (caddr_t) XtParent(w), 0);    /* parent of text widget is */
  938. X                        /* the dialog box */
  939. X}
  940. X
  941. X/*
  942. X * Parse a date string
  943. X */
  944. Xstatic char    *
  945. XDateParse(str, da)
  946. X    register char  *str;
  947. X    Date           *da;
  948. X{
  949. X    register char  *wk;
  950. X    int             lastc;
  951. X    int             mo;
  952. X
  953. X    *da = today;
  954. X
  955. X    wk = str;
  956. X    while (isspace(*wk))
  957. X        wk++;
  958. X    if (*wk == '\0')
  959. X        return ("No data found");
  960. X    str = wk;
  961. X    if (isdigit(*str)) {
  962. X        while (isdigit(*str))
  963. X            str++;
  964. X        lastc = *str;
  965. X        *str++ = '\0';
  966. X        mo = atoi(wk);
  967. X        if (mo < 1 || mo > 12)
  968. X            return ("Illegal month number");
  969. X        da->month = mo - 1;
  970. X    } else if (isalpha(*str)) {    /* be kind - allow month names */
  971. X        while (isalpha(*str)) {
  972. X            if (isupper(*str))
  973. X                *str = tolower(*str);
  974. X            str++;
  975. X        }
  976. X        lastc = *str;
  977. X        *str++ = '\0';
  978. X        mo = MonScan(wk);
  979. X        if (mo < 0)
  980. X            return ("Cannot find month name");
  981. X        if (mo < da->month)
  982. X            da->year++;
  983. X        da->month = mo;
  984. X    }
  985. X    if (lastc) {
  986. X        wk = str;
  987. X        while (isspace(*wk))
  988. X            wk++;
  989. X        str = wk;
  990. X        if (*str)
  991. X            da->year = atoi(wk);
  992. X    }
  993. X    return (NULL);
  994. X}
  995. X
  996. X/*
  997. X * Given a string look in our database for a number
  998. X */
  999. Xstatic int
  1000. XMonScan(monstr)
  1001. X    char           *monstr;
  1002. X{
  1003. X    char           *a, *b;
  1004. X    int             ca, cb;
  1005. X    int             mon;
  1006. X
  1007. X    for (mon = 0; mon < 12; mon++)
  1008. X        for (a = monstr, b = appResources.mon[mon];;) {
  1009. X            ca = *a++;
  1010. X            if (ca == '\0')
  1011. X                return (mon);
  1012. X            if (isupper(ca))
  1013. X                ca = tolower(ca);
  1014. X            cb = *b++;
  1015. X            if (cb == '\0')
  1016. X                break;
  1017. X            if (isupper(cb))
  1018. X                cb = tolower(cb);
  1019. X            if (ca != cb)
  1020. X                break;
  1021. X        }
  1022. X    return (-1);
  1023. X}
  1024. X
  1025. X/************************************************************************/
  1026. X/*                                    */
  1027. X/*                                    */
  1028. X/*        Deals with right button presses - exit            */
  1029. X/*                                    */
  1030. X/*                                    */
  1031. X/************************************************************************/
  1032. X/*
  1033. X * Get out - possibly
  1034. X */
  1035. X/* ARGSUSED */
  1036. Xvoid
  1037. XAskLeave(w, event, params, numb)
  1038. X    Widget          w;
  1039. X    XEvent         *event;
  1040. X    String         *params;
  1041. X    Cardinal       *numb;
  1042. X{
  1043. X
  1044. X    DialogPopup(toplevel, LeaveDialog, NULL, w);
  1045. X}
  1046. X
  1047. X/* ARGSUSED */
  1048. Xstatic void
  1049. XLeaveDialog(pop, noop)
  1050. X    Widget          pop;
  1051. X    Cardinal        noop;
  1052. X{
  1053. X    Widget          di;
  1054. X
  1055. X    /* Take "Really exit? from resources */
  1056. X    di = XtCreateManagedWidget("exit", dialogWidgetClass, pop, NULL, 0);
  1057. X    XawDialogAddButton(di, "yes", YesLeave, pop);
  1058. X    XawDialogAddButton(di, "no", NoLeave, pop);
  1059. X}
  1060. X
  1061. X/* ARGSUSED */
  1062. Xstatic void
  1063. XYesLeave(w, closure, call_data)
  1064. X    Widget          w;
  1065. X    caddr_t         closure;
  1066. X    caddr_t         call_data;
  1067. X{
  1068. X    Leave(0);
  1069. X}
  1070. X
  1071. X/* ARGSUSED */
  1072. Xstatic void
  1073. XNoLeave(w, closure, call_data)
  1074. X    Widget          w;
  1075. X    caddr_t         closure;
  1076. X    caddr_t         call_data;
  1077. X{
  1078. X    XtDestroyWidget((Widget) closure);
  1079. X}
  1080. X
  1081. X/************************************************************************/
  1082. X/* */
  1083. X/* */
  1084. X/* Deal with an attempt to double edit some data             */
  1085. X/* */
  1086. X/* */
  1087. X/************************************************************************/
  1088. X
  1089. X
  1090. Xvoid
  1091. XNoEditIsPossible(w, da)
  1092. X    Widget          w;
  1093. X    Date           *da;
  1094. X{
  1095. X    static char     errmsg[256];
  1096. X
  1097. X    FmtDate(da, errmsg, sizeof errmsg, appResources.already);
  1098. X
  1099. X    DialogPopup(w, NoEdit, errmsg, w);
  1100. X
  1101. X}
  1102. X
  1103. Xvoid
  1104. XNoDayEditIsPossible(w, da)
  1105. X    Widget          w;
  1106. X    Date           *da;
  1107. X{
  1108. X    static char     errmsg[256];
  1109. X
  1110. X    FmtDate(da, errmsg, sizeof errmsg, appResources.alreadyWeekly);
  1111. X
  1112. X    DialogPopup(w, NoEdit, errmsg, w);
  1113. X
  1114. X}
  1115. X
  1116. Xstatic void
  1117. XNoEdit(pop, errmsg)
  1118. X    Widget          pop;
  1119. X    String          errmsg;
  1120. X{
  1121. X    Arg             args[2];
  1122. X    Widget          dia;
  1123. X
  1124. X    XtSetArg(args[0], XtNlabel, errmsg);
  1125. X    dia = XtCreateManagedWidget("noedit", dialogWidgetClass, pop, args, 1);
  1126. X    XawDialogAddButton(dia, "ok", NoCal, pop);
  1127. X}
  1128. END_OF_FILE
  1129. if test 9814 -ne `wc -c <'xcal_popup.c'`; then
  1130.     echo shar: \"'xcal_popup.c'\" unpacked with wrong size!
  1131. fi
  1132. # end of 'xcal_popup.c'
  1133. fi
  1134. if test -f 'xcalpr/xcalpr.c' -a "${1}" != "-c" ; then 
  1135.   echo shar: Will not clobber existing file \"'xcalpr/xcalpr.c'\"
  1136. else
  1137. echo shar: Extracting \"'xcalpr/xcalpr.c'\" \(11836 characters\)
  1138. sed "s/^X//" >'xcalpr/xcalpr.c' <<'END_OF_FILE'
  1139. X#ifndef lint
  1140. Xstatic char    *sccsid = "@(#)xcalpr.c    1.11 (Hillside Systems) 11/15/93";
  1141. Xstatic char    *copyright = "@(#)Copyright 1993 Peter Collinson, Hillside Systems";
  1142. X#endif                          /* lint */
  1143. X#include "version.h"
  1144. X/***
  1145. X* program name:
  1146. X        xcalpr.c
  1147. X* function:
  1148. X    Prints xcal calendar entries
  1149. X* switches:
  1150. X    -v    print version number, then exit
  1151. X    -f    name of output file
  1152. X    -d dir    Use "dir" instead of Calendar
  1153. X    -c    be compatible with the X calendar program
  1154. X        (ie flat structure in the Calendar directory)
  1155. X    -u user    Look at the calendar for that user
  1156. X    
  1157. X        followed by a date spec.
  1158. X        If no date spec then do this week
  1159. X        If date spec is just a number of month names, then
  1160. X            print those months
  1161. X            If month is `next' do the next month
  1162. X        If the months are followed by a year, then do those months
  1163. X            in that year
  1164. X        If the argument is just a year then do that year.
  1165. X        
  1166. X* libraries used:
  1167. X        standard
  1168. X* compile time parameters:
  1169. X        standard
  1170. X* history:
  1171. X        Written October 1993
  1172. X        Peter Collinson
  1173. X        Hillside Systems
  1174. X* (C) Copyright: 1993 Hillside Systems/Peter Collinson
  1175. X        Permission to use, copy, modify, and distribute this software
  1176. X        and its documentation for any purpose is hereby granted to
  1177. X        anyone, provided that the above copyright notice appear
  1178. X        in all copies and that both that copyright notice and this
  1179. X        permission notice appear in supporting documentation, and that
  1180. X        the name of Peter Collinson not be used in advertising or
  1181. X        publicity pertaining to distribution of the software without
  1182. X        specific, written prior permission.  Hillside Systems makes no
  1183. X        representations about the suitability of this software for any
  1184. X        purpose.  It is provided "as is" without express or implied
  1185. X        warranty.
  1186. X        Peter Collinson DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
  1187. X        SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  1188. X        AND FITNESS, IN NO EVENT SHALL Peter Collinson BE LIABLE FOR
  1189. X        ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  1190. X        WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  1191. X        WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
  1192. X        ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  1193. X        PERFORMANCE OF THIS SOFTWARE.
  1194. X***/
  1195. X#include <stdio.h>
  1196. X#include <ctype.h>
  1197. X#include <string.h>
  1198. X#include <time.h>
  1199. X#include <pwd.h>
  1200. X#include <unistd.h>
  1201. X#if defined(NeXT)
  1202. X#include <sys/fcntl.h>
  1203. X#endif
  1204. X#include <sys/stat.h>
  1205. X
  1206. Xstatic char    *progname = "xcalpr";    /* name of program */
  1207. Xstatic char    *calendar = "Calendar";    /* name of calendar directory */
  1208. Xstatic int    compat;            /* if non-zero use calendar */
  1209. X                    /* compatible files */
  1210. Xstatic int    calcompat;        /* write calendar format output */
  1211. Xstatic char    *calfmt;        /* printf format of a calendar file */
  1212. Xstatic char    *caldir;        /* name of a calendar directory */
  1213. Xstatic char    *user;            /* name of a user */
  1214. X
  1215. Xstatic char    *months[]    = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
  1216. X                   "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
  1217. X
  1218. Xstatic char    *daynames[]    = {"Sun", "Mon", "Tue", "Wed",
  1219. X                   "Thu", "Fri", "Sat"};
  1220. X
  1221. Xstatic char    *dayfiles[7];        /* connected contents of any dayfiles */
  1222. X
  1223. Xstatic FILE    *fout = stdout;
  1224. X    
  1225. Xstatic int mon[] = { 
  1226. X    31, 28, 31, 30,
  1227. X    31, 30, 31, 31,
  1228. X    30, 31, 30, 31,
  1229. X};
  1230. X
  1231. X/*
  1232. X * various strings
  1233. X */
  1234. Xstatic char    *memerr = "No more memory\n";
  1235. Xstatic char    *usage = "Usage: xcalpr [-d dir][-x][-c][-u user][-f file] [month list]\n";
  1236. X
  1237. Xchar    *malloc();
  1238. X
  1239. X/*
  1240. X * Routines
  1241. X */
  1242. Xstatic void    thisweek();
  1243. Xstatic void    showmonth();
  1244. Xstatic void    showyear();
  1245. Xstatic void    filenames();
  1246. Xstatic void    connectdaily();
  1247. Xstatic void    yearformat();
  1248. Xstatic void    outputday();
  1249. Xstatic void    outputdaily();
  1250. Xstatic char     *connect_file();
  1251. Xstatic int    monthmatch();
  1252. Xstatic char     *Strdup();
  1253. Xstatic void    fatal();
  1254. Xstatic void    error();
  1255. Xstatic char    *readbfile();
  1256. X
  1257. Xmain(argc, argv)
  1258. X    int    argc;
  1259. X    char    *argv[];
  1260. X{
  1261. X    register int    c;
  1262. X    extern char     *optarg;
  1263. X    extern int    optind;
  1264. X    int        i;
  1265. X    char        **av;
  1266. X    int        ac;
  1267. X    int        yr;
  1268. X
  1269. X    while ((c = getopt(argc, argv, "d:u:f:cxv")) != EOF) {
  1270. X
  1271. X        switch (c) {
  1272. X        case 'c':
  1273. X            calcompat = 1;
  1274. X            break;
  1275. X        case 'd':
  1276. X            calendar = optarg;
  1277. X            break;
  1278. X        case 'f':
  1279. X            fout = fopen(optarg, "w");
  1280. X            if (fout == NULL)
  1281. X                fatal("Cannot open %s for writing\n", optarg);
  1282. X            break;
  1283. X        case 'u':
  1284. X            user = optarg;
  1285. X            break;
  1286. X        case 'v':
  1287. X            fprintf(stderr, "%s\n", version);
  1288. X            exit(0);
  1289. X        case 'x':
  1290. X            compat = 1;
  1291. X            break;
  1292. X        default:
  1293. X            fatal(usage);
  1294. X        }
  1295. X    }
  1296. X    filenames();
  1297. X    connectdaily();
  1298. X
  1299. X    if (optind == argc)
  1300. X        thisweek();
  1301. X    else {
  1302. X        /* 
  1303. X         * this is a little complicated
  1304. X         * the idea is to allow
  1305. X         * xcalcat month
  1306. X         * xcalcat month year
  1307. X         * xcalcat year
  1308. X         * the strategy is to scan forward for a year, storing any
  1309. X         * months, if we find a year then output the months for
  1310. X         * that year.
  1311. X         */
  1312. X        av = (char **)calloc(argc, sizeof (char *));
  1313. X        if (av == NULL)
  1314. X            fatal(memerr);
  1315. X        ac = 0;
  1316. X        for (; optind < argc; optind++) {
  1317. X            if (!isdigit(*argv[optind])) {
  1318. X                av[ac++] = argv[optind];
  1319. X            } else {
  1320. X                yr = atoi(argv[optind]);
  1321. X                if (ac == 0)
  1322. X                    showyear(yr);
  1323. X                else {
  1324. X                    for (i = 0; i < ac; i++)
  1325. X                        showmonth(av[i], yr, 0);
  1326. X                    ac = 0;
  1327. X                }
  1328. X            }
  1329. X        }
  1330. X        if (ac) {
  1331. X            for (i = 0; i < ac; i++)
  1332. X                showmonth(av[i], 0, 1);
  1333. X        }
  1334. X    }
  1335. X    exit(0);    
  1336. X}
  1337. X
  1338. X/*
  1339. X *    Do this week
  1340. X */
  1341. Xstatic void
  1342. Xthisweek()
  1343. X{    
  1344. X    time_t        ti;
  1345. X    struct    tm    *tm;
  1346. X    int        yr;
  1347. X    int        i;
  1348. X
  1349. X    time(&ti);
  1350. X
  1351. X    for (i = 0; i < 7; i++) {
  1352. X        tm = localtime(&ti);
  1353. X        yr = tm->tm_year + 1900;
  1354. X        yearformat(yr);
  1355. X        outputday(yr, tm->tm_mon, tm->tm_mday, tm->tm_wday);
  1356. X        ti += 86400;
  1357. X    }
  1358. X}
  1359. X
  1360. X/*
  1361. X *    Do a month
  1362. X */
  1363. Xstatic void
  1364. Xshowmonth(mstr, yrval, autoinc)
  1365. X    char    *mstr;
  1366. X    int    yrval;
  1367. X    int    autoinc;
  1368. X{
  1369. X    time_t        ti;
  1370. X    struct    tm    *tm;
  1371. X    int        yr;
  1372. X    int        mn;
  1373. X    int        i;
  1374. X    int        wday;
  1375. X    int        startday = 1;
  1376. X
  1377. X    time(&ti);
  1378. X    tm = localtime(&ti);
  1379. X    yr = yrval ? yrval : tm->tm_year + 1900;
  1380. X
  1381. X    if (strcasecmp(mstr, "next") == 0) {
  1382. X        mn = tm->tm_mon+1;
  1383. X        if (mn == 12) {
  1384. X            mn = 0;
  1385. X            yr++;
  1386. X        }
  1387. X    } else
  1388. X    if (yrval == 0 && strcasecmp(mstr, "rest") == 0) {
  1389. X        mn = tm->tm_mon;
  1390. X        wday = FirstDay(mn, yr);    /* get number of days in month */
  1391. X        startday = tm->tm_mday+1;
  1392. X        if (startday > mon[mn]) {
  1393. X            startday = 1;
  1394. X            mn++;
  1395. X            if (mn == 12) {
  1396. X                mn = 0;
  1397. X                yr++;
  1398. X
  1399. X            }
  1400. X        }
  1401. X    } else {
  1402. X        mn = monthmatch(mstr);
  1403. X        if (mn == -1)
  1404. X            fatal("Cannot recognise month: %s\n", mstr);
  1405. X        if (autoinc && mn < tm->tm_mon)
  1406. X            yr++;
  1407. X    }
  1408. X
  1409. X    wday = FirstDay(mn, yr);
  1410. X    wday = wday + startday - 1;
  1411. X    wday %= 7;
  1412. X
  1413. X    yearformat(yr);
  1414. X
  1415. X    for (i = startday; i < mon[mn]; i++) {
  1416. X        outputday(yr, mn, i, wday);
  1417. X        wday++;
  1418. X        wday %= 7;
  1419. X    }
  1420. X}
  1421. X
  1422. X/*
  1423. X * do a year
  1424. X */
  1425. Xstatic void
  1426. Xshowyear(yr)
  1427. X    int    yr;
  1428. X{
  1429. X    int    m;
  1430. X
  1431. X    for (m = 0; m < 12; m++)
  1432. X        showmonth(months[m], yr, 0);
  1433. X}
  1434. X
  1435. X/*
  1436. X * organise filenames
  1437. X */
  1438. Xstatic void
  1439. Xfilenames()
  1440. X{
  1441. X    struct    passwd    *pw;
  1442. X    char        buf[256];
  1443. X    time_t        ti;
  1444. X    struct    tm    *tm;
  1445. X
  1446. X    if (user) {
  1447. X        pw = getpwnam(user);
  1448. X        if (pw == NULL)
  1449. X            fatal("Cannot get password information for %s\n", user);
  1450. X    } else {
  1451. X        pw = getpwuid(getuid());
  1452. X        if (pw == NULL)
  1453. X            fatal("Cannot get password information\n");
  1454. X    }
  1455. X    /*
  1456. X     * get filename of Calendar directory
  1457. X     */
  1458. X    if (*calendar != '.' && *calendar != '/') {
  1459. X        /* need to prepend the home directory */
  1460. X        (void) sprintf(buf, "%s/%s", pw->pw_dir, calendar);
  1461. X        calendar = Strdup(buf);
  1462. X    }
  1463. X
  1464. X    /*
  1465. X     * See if we have a calendar directory
  1466. X     */
  1467. X    if (access(calendar, F_OK) < 0)
  1468. X        fatal("%s does not exist\n", calendar);
  1469. X    
  1470. X}
  1471. X
  1472. X/*
  1473. X * Connect any daily files in memory
  1474. X */
  1475. Xstatic void
  1476. Xconnectdaily()
  1477. X{
  1478. X    int    i;
  1479. X    char    filename[256];
  1480. X    int    len;
  1481. X
  1482. X    for (i = 0; i < 7; i++) {
  1483. X        (void) sprintf(filename, "%s/xw%s", calendar, daynames[i]);
  1484. X
  1485. X        dayfiles[i] = connect_file(filename, &len);
  1486. X    }
  1487. X}
  1488. X
  1489. X/*
  1490. X * Make file formats from a year
  1491. X *
  1492. X * xcalendar files are all
  1493. X * xc<d><Mon><Year>
  1494. X * or
  1495. X * xc<dd><Mon><Year>
  1496. X *
  1497. X * where d or dd is the day (%02d would have been better)
  1498. X * <Mon> is a capitalised first three letters of the
  1499. X *         English month name. If you need compatibility
  1500. X *         don't redefine the short names in the resources
  1501. X *         for this program.
  1502. X * <Year> is the full numeric year.
  1503. X *
  1504. X * We will follow this BUT we will also make this program
  1505. X * create subdirectories for new years
  1506. X *         xy<Year>
  1507. X * to speed up file access
  1508. X */
  1509. Xstatic void
  1510. Xyearformat(year)
  1511. X    int    year;
  1512. X{
  1513. X    char    buf[256];
  1514. X
  1515. X    if (compat) 
  1516. X        (void) sprintf(buf, "%s/xc%%d%%s%d", calendar, year);
  1517. X    else    (void) sprintf(buf, "%s/xy%d/xc%%d%%s%d", calendar, year, year);
  1518. X    if (calfmt)
  1519. X        free(calfmt);
  1520. X    calfmt = Strdup(buf);
  1521. X    if (compat)
  1522. X        caldir = calendar;
  1523. X    else {
  1524. X        (void) sprintf(buf, "%s/xy%d", calendar, year);
  1525. X        if (caldir)
  1526. X            free(caldir);
  1527. X        caldir = Strdup(buf);
  1528. X    }
  1529. X}
  1530. X
  1531. X/*
  1532. X * Print data for one day
  1533. X */
  1534. Xstatic void
  1535. Xoutputday(year, mn, day, wday)
  1536. X    int    year;
  1537. X    int    mn;
  1538. X    int    day;
  1539. X    int    wday;
  1540. X{
  1541. X    char    filename[256];
  1542. X    char    line[BUFSIZ];
  1543. X    char    *p;
  1544. X    FILE    *fin;
  1545. X    
  1546. X    (void) sprintf(filename, calfmt, day, months[mn]);
  1547. X    if (fin = fopen(filename, "r")) {
  1548. X        while (fgets(line, sizeof line, fin) != NULL) {
  1549. X            p = strchr(line, '\n');
  1550. X            if (p)
  1551. X                *p = '\0';
  1552. X            for (p = line; isspace(*p); p++);
  1553. X            if (*p == '\0')
  1554. X                continue;
  1555. X            if (calcompat)
  1556. X                fprintf(fout, "%s %02d\t%s\n",
  1557. X                        months[mn], day, p);
  1558. X            else
  1559. X                fprintf(fout, "%s %02d %s %4d\t%s\n",
  1560. X                        daynames[wday], day, months[mn],
  1561. X                    year, p);
  1562. X        }
  1563. X        fclose(fin);
  1564. X    }
  1565. X
  1566. X    /* check on daily file */
  1567. X    if (p = dayfiles[wday])
  1568. X        outputdaily(year, mn, day, wday, p);
  1569. X
  1570. X}
  1571. X
  1572. X/*
  1573. X * Output a daily file
  1574. X */
  1575. Xstatic void
  1576. Xoutputdaily(year, mn, day, wday, txt)
  1577. X    int    year;
  1578. X    int    mn;
  1579. X    int    day;
  1580. X    int    wday;
  1581. X    char    *txt;
  1582. X{
  1583. X    char    prefix[256];
  1584. X    char    *sol;
  1585. X    char    *eol;
  1586. X
  1587. X    if (calcompat)
  1588. X        (void) sprintf(prefix, "%s %02d\t", months[mn], day);
  1589. X    else
  1590. X        (void) sprintf(prefix, "%s %02d %s %4d\t", daynames[wday],
  1591. X                   day, months[mn], year);
  1592. X    
  1593. X    while (*txt) {
  1594. X        sol = txt;
  1595. X        while (*txt != '\n' && *txt != '\0')
  1596. X            txt++;
  1597. X        eol = txt;
  1598. X        while (*sol == ' ' || *sol == '\t')
  1599. X            sol++;
  1600. X        if (sol != eol) {
  1601. X            fputs(prefix, fout);
  1602. X            while (sol != eol) {
  1603. X                putc(*sol, fout);
  1604. X                sol++;
  1605. X            }
  1606. X            putc('\n', fout);
  1607. X        }
  1608. X        if (*eol == '\n')
  1609. X            txt++;
  1610. X    }    
  1611. X}
  1612. X    
  1613. Xstatic char *
  1614. Xconnect_file(filename, bytes)
  1615. X        char    *filename;
  1616. X        int     *bytes;
  1617. X{
  1618. X        int     fd;
  1619. X        struct  stat statb;
  1620. X        char    *fibase;
  1621. X        if ((fd = open(filename, 0)) < 0) {
  1622. X        return NULL;
  1623. X    }
  1624. X        if (fstat(fd, &statb) < 0)
  1625. X                fatal("Cannot fstat %s (shouldn't happen)\n", filename);
  1626. X        if (statb.st_size == 0) {
  1627. X        *bytes = 0;
  1628. X        return;
  1629. X    }
  1630. X
  1631. X    fibase = readbfile(fd, statb.st_size);
  1632. X        if ((int)fibase == -1)
  1633. X                fatal("Cannot map %s into memory\n", filename);
  1634. X        close(fd);      /* we have it now */
  1635. X
  1636. X    fibase[statb.st_size] = '\0';
  1637. X
  1638. X        *bytes = statb.st_size;
  1639. X        return(fibase);
  1640. X}
  1641. X
  1642. X/*
  1643. X * Attempt to recognise a month string
  1644. X * return a month (0-11) if OK
  1645. X * else -1
  1646. X */
  1647. Xstatic int
  1648. Xmonthmatch(str)
  1649. X    char    *str;
  1650. X{
  1651. X    register int i;
  1652. X    
  1653. X    for (i = 0; i < 12; i++) {
  1654. X        if (strncasecmp(str, months[i], 3) == 0)
  1655. X            return i;
  1656. X    }
  1657. X    return -1;
  1658. X}
  1659. X
  1660. X/*
  1661. X * private strdup this used to call the system strdup()
  1662. X * and fail on an error, but it seems that some systems don't a strdup()
  1663. X */
  1664. Xstatic char *
  1665. XStrdup(str)
  1666. X    char    *str;
  1667. X{
  1668. X    int    len;
  1669. X    char    *ret;
  1670. X
  1671. X    len = strlen(str) + 1;
  1672. X    ret = malloc(len);
  1673. X    if (ret == NULL)
  1674. X        fatal(memerr);
  1675. X    (void) memcpy(ret, str, len);
  1676. X    return ret;
  1677. X}
  1678. X
  1679. X/*
  1680. X * fatal routine
  1681. X * print an error message and exit
  1682. X * should use vprintf I guess
  1683. X */
  1684. Xstatic void
  1685. Xfatal(fmt, a, b, c)
  1686. X    char    *fmt;
  1687. X{
  1688. X    fprintf(stderr, "%s: ", progname);
  1689. X    fprintf(stderr, fmt, a, b, c);
  1690. X    exit(1);
  1691. X}
  1692. X
  1693. X/*
  1694. X * error routine
  1695. X */
  1696. Xstatic void
  1697. Xerror(fmt, a, b, c, d)
  1698. X    char    *fmt;
  1699. X{
  1700. X    fprintf(stderr, "%s: ", progname);
  1701. X    fprintf(stderr, fmt, a, b, c, d);
  1702. X}
  1703. X
  1704. X/*
  1705. X * malloc some memory and
  1706. X * read the file into it
  1707. X */
  1708. Xstatic char *
  1709. Xreadbfile(fd, len)
  1710. X    int    fd;
  1711. X    int    len;
  1712. X{
  1713. X    char    *base;
  1714. X    
  1715. X    base = (char *) malloc(len+1);
  1716. X    if (read(fd, base, len) != len)
  1717. X        return ((char *)-1);
  1718. X    return base;
  1719. X}
  1720. END_OF_FILE
  1721. if test 11836 -ne `wc -c <'xcalpr/xcalpr.c'`; then
  1722.     echo shar: \"'xcalpr/xcalpr.c'\" unpacked with wrong size!
  1723. fi
  1724. # end of 'xcalpr/xcalpr.c'
  1725. fi
  1726. echo shar: End of archive 4 \(of 8\).
  1727. cp /dev/null ark4isdone
  1728. MISSING=""
  1729. for I in 1 2 3 4 5 6 7 8 ; do
  1730.     if test ! -f ark${I}isdone ; then
  1731.     MISSING="${MISSING} ${I}"
  1732.     fi
  1733. done
  1734. if test "${MISSING}" = "" ; then
  1735.     echo You have unpacked all 8 archives.
  1736.     rm -f ark[1-9]isdone
  1737. else
  1738.     echo You still need to unpack the following archives:
  1739.     echo "        " ${MISSING}
  1740. fi
  1741. ##  End of shell archive.
  1742. exit 0
  1743.  
  1744. exit 0 # Just in case...
  1745. -- 
  1746.   // chris@Sterling.COM           | Send comp.sources.x submissions to:
  1747. \X/  Amiga: The only way to fly!  |    sources-x@sterling.com
  1748.        "It's intuitively obvious to the most casual observer..."
  1749.  GCS d++(--) -p+ c++ !l u++ e+ m+(-) s++/++ n h--- f+ g+++ w+ t++ r+ y+
  1750.