home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 3 / 3864 < prev    next >
Internet Message Format  |  1991-08-22  |  60KB

  1. Path: wupost!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!cbnews!jbr0
  2. From: jbr0@cbnews.cb.att.com (joseph.a.brownlee)
  3. Newsgroups: alt.sources
  4. Subject: Pcal v4.1, part 4 of 6
  5. Keywords: pcal calendar postscript
  6. Message-ID: <1991Aug19.121750.863@cbnews.cb.att.com>
  7. Date: 19 Aug 91 12:17:50 GMT
  8. Followup-To: alt.sources.d
  9. Organization: AT&T Bell Laboratories
  10. Lines: 2275
  11.  
  12. #!/bin/sh
  13. # This is part 04 of a multipart archive
  14. # ============= pcal.man ==============
  15. if test -f 'pcal.man' -a X"$1" != X"-c"; then
  16.     echo 'x - skipping pcal.man (File already exists)'
  17. else
  18. echo 'x - extracting pcal.man (Text)'
  19. sed 's/^X//' << 'SHAR_EOF' > 'pcal.man' &&
  20. ..TH PCAL 1
  21. ..SH NAME
  22. pcal \- generate PostScript calendars
  23. ..SH SYNOPSIS
  24. ..BR pcal " ["
  25. ..BR \-e " | " \-f
  26. ..I cal
  27. ] [
  28. ..BI \-o " file"
  29. ] [
  30. ..BR \-j " | " \-J
  31. ] [
  32. ..BR \-l " | " \-p
  33. ] [
  34. ..BR \-m " | " \-M
  35. ] [
  36. ..BI \-b " day"
  37. | all ]
  38. [
  39. ..BI \-g " day"
  40. | all ]
  41. [
  42. ..B \-O
  43. ] [
  44. ..B \-G
  45. ] [
  46. ..BI \-F " day"
  47. ] [
  48. ..BR \-A " | " \-E
  49. ] [
  50. ..BI \-t " title_font"
  51. ] [
  52. ..BI \-d " day_font"
  53. ] [
  54. ..BI \-n " text_font"
  55. ] [
  56. ..BI \-L " footer_string"
  57. ] [
  58. ..BI \-C " footer_string"
  59. ] [
  60. ..BI \-R " footer_string"
  61. ] [
  62. ..BI \-D " symbol"
  63. ] [
  64. ..BI \-U " symbol"
  65. ] [
  66. ..BI \-x " xscale"
  67. ] [
  68. ..BI \-y " yscale"
  69. ] [
  70. ..BI \-X " xtrans"
  71. ] [
  72. ..BI \-Y " ytrans"
  73. ] [
  74. ..B \-I
  75. ] [
  76. ..B \-B
  77. ] [
  78. ..B \-w
  79. ] [
  80. ..BR \-h " | " \-v
  81. ] [
  82. ..B month
  83. ] [
  84. ..B year
  85. ] [
  86. ..B nmonths
  87. ]
  88. ..SH DESCRIPTION
  89. ..I Pcal
  90. generates PostScript to produce landscape or portrait calendars for any 
  91. month and year.  The arguments
  92. ..BR month ,
  93. ..BR year ,
  94. and
  95. ..BR nmonths ,
  96. if provided, should be numeric.  The 
  97. ..BR month
  98. value should be in the range 1 \- 12, and the 
  99. ..BR year
  100. value should be specified as 1 or 2 digits or as the full 4 digit year.
  101. If no numeric arguments are provided, the calendar for the current month
  102. and year will be generated.
  103. ..PP
  104. If one numeric argument is provided, it is interpreted as the
  105. ..BR year
  106. value, and calendars for the entire year will be generated.  Otherwise, 
  107. ..BR nmonth
  108. months, starting with
  109. ..BR month
  110. and
  111. ..BR year ,
  112. will be generated.
  113. ..PP
  114. For whole-year calendars (i.e. the
  115. ..B \-w
  116. option is given), the command line arguments are interpreted somewhat
  117. differently.  By default, all months in the current year are printed, starting
  118. with January.  If the
  119. ..B month
  120. argument alone is given, it is expected to be the desired
  121. ..B year
  122. to print, and prints all of the months in the given year.  If both
  123. ..BR month " and " year
  124. are given, then 12 consecutive months are printed starting at the given
  125. month and year.  If the
  126. ..BR month ", " year ", and " nmonths
  127. arguments are all present, printing begins with the given month and year and
  128. ..B nmonths
  129. months are printed, rounded up to the nearest multiple of 12.
  130. ..PP
  131. ..B The Date File
  132. ..PP
  133. By default,
  134. ..I pcal
  135. simply prints an empty calendar.  Its real power is in its ability to place
  136. ``events'' in appropriate days on the calendar, thus allowing the user to
  137. create personalized calendars.  This is achieved through the use of the
  138. ``date file''.
  139. ..PP
  140. The date file is named
  141. ..IR \.calendar " (" pcal.dat
  142. under MS-DOS),
  143. or
  144. ..I calendar
  145. for compatibility with older versions.
  146. ..I Pcal
  147. will look in several places for such a file.  First, if a file called
  148. ..I \.calendar
  149. exists in the caller's home directory, it is used.  Next, if such a file exists
  150. in the directory indicated by
  151. environment variable
  152. ..BR PCAL_DIR
  153. (or the current directory if no such variable is defined), it is used.
  154. Finally, the directory where the
  155. ..I pcal
  156. executable resides will be checked.  If no date file is found, an empty
  157. calendar is printed.
  158. ..PP
  159. If a date file is found, it will be searched for lines with
  160. leading dates matching the requested month and year.
  161. Any text following the dates found will be printed on the calendar under the
  162. appropriate day of the month.  Dates in the
  163. ..I \.calendar
  164. file may be expressed in any of several formats:
  165. ..PP
  166. ..ft CW
  167. ..nf
  168. X    <ordinal> <day_spec> in <month_spec>{*} {<text>}
  169. X    <day_spec> <prep> <date_spec>{*} {<text>}
  170. X    <date_spec>{*} {<text>}
  171. ..fi
  172. ..ft
  173. ..PP
  174. Where:
  175. ..PP
  176. ..nf
  177. X    <month_name>    := first 3+ characters of name of month, or ``all''
  178. X    <month_spec>    := <month_name>, or ``year''
  179. X    <day_spec>    := first 3+ characters of name of weekday, ``day'',
  180. X                ``weekday'', ``workday'', ``holiday'', ``nonweekday'',
  181. X                ``nonworkday'', or ``nonholiday''
  182. X    <ordinal>    := any ordinal number (``1st'', ``2nd'', etc.), ``first'' ... ``fifth'',
  183. X                ``last'', ``odd'', ``even'', or ``all''
  184. X    <prep>        := ``before'', ``preceding'', ``after'', ``following'',
  185. X                ``on_or_before'' (``oob''), or ``on_or_after'' (``ooa'')
  186. X    <sep>        := one or more non-numeric, non-space, non-'*' characters
  187. X    <month>    := a numeric month (1-12)
  188. X    <day>        := day of month (1-31)
  189. X    <year>        := a numeric year
  190. ..fi
  191. ..ft
  192. ..PP
  193. If the
  194. ..B \-A
  195. option (American date formats, the default) is given:
  196. ..PP
  197. ..nf
  198. X    <date_spec>    := [ <month_name> <day> | <month><sep><day>{<sep><year>} ]
  199. ..fi
  200. ..PP
  201. If the
  202. ..B \-E
  203. option (European date formats) is given:
  204. ..PP
  205. ..nf
  206. X    <date_spec>    := [ <day> <month_name> | <day><sep><month>{<sep><year>} ]
  207. ..fi
  208. ..PP
  209. ..I Pcal
  210. also allows format specifiers in both the text and foot strings (see the
  211. ..BR \-L ,
  212. ..BR \-C ,
  213. and
  214. ..B \-R
  215. options below); each will be replaced by a corresponding 
  216. string as outlined in the table below.  Most of these are derived from the
  217. ..ft CW
  218. strftime()
  219. ..ft
  220. function; the 
  221. ..BR %l " and " %[o0+\-]
  222. format specifiers are specific to
  223. ..IR pcal :
  224. ..PP
  225. ..nf
  226. X    %a    abbreviated weekday
  227. X    %A    full weekday
  228. X    %b    abbreviated month name
  229. X    %B    full month name
  230. X    %d    day of month (1-31)
  231. X    %j    day of year (1-366)
  232. X    %l    days left in year (0-365)
  233. X    %m    month (1-12)
  234. X    %U    week number (0-53)
  235. X    %W    week number (0-53)
  236. X    %y    year w/o century (00-99)
  237. X    %Y    year w/century
  238. X    %%    `%' character
  239. X
  240. X    %o    print number as ordinal
  241. X    %0    print number with leading zeroes
  242. X    %+    use following month or year
  243. X    %\-    use previous month or year
  244. ..fi
  245. ..PP
  246. The
  247. ..B %U
  248. format specifier considers the first logical Sunday (the first day
  249. of the week as printed; see the
  250. ..B \-F
  251. option below) of the year as the first day of week number 1; the
  252. ..B %W
  253. specifier uses the first logical Monday instead.  This is an
  254. extension of the behavior of the
  255. ..ft CW
  256. strftime()
  257. ..ft
  258. function.
  259. ..PP
  260. The
  261. ..B %o
  262. format specifier prints a number as an ordinal, with the appropriate
  263. suffix (``st'', ``nd'', ``rd'', or ``th'' in English) appended; for example,
  264. ..B %od
  265. prints the day of the month as ``1st'', ``2nd'', ``3rd'', etc.
  266. ..PP
  267. Unlike
  268. ..ft CW
  269. strftime(),
  270. ..ft
  271. ..IR pcal 's
  272. default is to print numbers (except
  273. ..BR %y )
  274. without leading zeroes.  If leading zeroes are desired, the `0'
  275. prefix may be used; for example, 
  276. ..B %0j
  277. prints the day of year as 001-365.
  278. ..PP
  279. The 
  280. ..BR %+ " and " %\-
  281. format specifiers direct
  282. ..I pcal
  283. to substitute the following or previous month or year for the following
  284. ..B [bBmyY]
  285. specifier; for example,
  286. ..B %+B
  287. prints the name of the following month.
  288. ..PP
  289. Examples:
  290. ..PP
  291. ..ft CW
  292. ..nf
  293. X    last Monday in May*         Memorial Day Holiday
  294. ..sp
  295. X    all Fridays in Oct          Status Meeting, 11 AM
  296. X    first workday in all        %-B progress report due
  297. X    all Fri in all              Time card due, 3 PM
  298. X    all Monday in all           Fiscal week %0W
  299. X    -2nd workday in all         Schedule for %+B due
  300. X    Fri on_or_before all 15     Pay Day
  301. X    even Fridays in year        Pay Day
  302. X    183rd day of year           mid-year (%l days left)
  303. ..sp
  304. X    Tue after first Mon in Nov  Election Day (USA)
  305. ..sp
  306. X    4th Thu in Nov*             Thanksgiving
  307. X    Fri after 4th Thu in Nov*   Day after Thanksgiving
  308. ..sp
  309. X    12/25/90*                   Christmas     # American
  310. X    25.12.90*                   Christmas     # European
  311. ..sp
  312. X    Dec 25*                     Christmas     # American
  313. X    25 Dec*                     Christmas     # European
  314. ..fi
  315. ..ft
  316. ..PP
  317. Any non-numeric character may separate numeric dates.  Holidays may
  318. be flagged by following the date immediately with `*'
  319. as in the examples above; this will cause the
  320. date to be printed in gray.
  321. ``Each'' and ``every'' are accepted as synonyms for ``all'', and any word may
  322. be used in place of ``in''.  The abbreviations ``oob'' and ``ooa'' may be used
  323. in place of the keywords ``on_or_before'' and ``on_or_after'', respectively.
  324. ..PP
  325. Wildcard day names are also provided.  The keyword ``weekday'' applies to any
  326. days which are normally printed in black on the calendar.  The keyword
  327. ``workday'' is the same, but does not include any holidays.  The keyword
  328. ``holiday'' includes only those days flagged as holidays.  The keywords
  329. ``nonweekday'', ``nonworkday'', and ``nonholiday'' are also recognized as
  330. negations of the above.  See the
  331. ..B CAVEATS
  332. below for important notes on using these keywords.
  333. ..PP
  334. Ordinal day numbers may be used to specify dates, either relative to the
  335. month or to the year.  Either words or numeric abbreviations may be used for
  336. ``first'' through ``fifth''; higher numbers must be given using the
  337. numeric equivalent (e.g. 100th).  Negative ordinal numbers may even be used.
  338. For example, ``\-2nd'' means ``next to last''.
  339. ..PP
  340. ``Odd'' and ``even'' do not refer to the actual date; instead, ``odd''
  341. means ``alternate, starting with the first'', and ``even'' means ``alternate,
  342. starting with the second''.  Thus, ``odd Fridays in March'' refers to
  343. the first, third, and (if present) fifth Fridays in March - not to
  344. those Fridays falling on odd dates.
  345. ..PP
  346. ``All'' refers to each individual month; ``year'' refers to the year
  347. as an entity.  Thus ``odd Fridays in all'' refers to the first, third, and fifth
  348. Friday of each month, while ``odd Fridays in year'' refers to
  349. the first Friday of January and every other Friday thereafter.
  350. ..PP
  351. Text in the date file may use C-like escape sequences (i.e. a `\\' followed by
  352. a character, 1 \- 3 octal digits, or `x' followed by 1 \- 2 hexadecimal digits).
  353. Escaped whitespace (including
  354. ..B newline
  355. ) and the standard ANSI character escapes (`\\a', `\\b', `\\f', `\\n', `\\r',
  356. `\\t', `\\v') are all replaced by a single blank.
  357. ..PP
  358. Lines in the
  359. ..I \.calendar
  360. file consisting of 
  361. ..B year ####
  362. (where
  363. ..B ####
  364. is a numeric year) can be used
  365. to set the year for following entries.  This assumes that the following
  366. entries do not contain a year; any date entries containing year information
  367. will set the remembered year to that year.
  368. ..PP
  369. Lines in the
  370. ..I \.calendar
  371. file consisting of 
  372. ..B opt <options>
  373. can be used to override the defaults for
  374. any command-line options except
  375. ..BR \-e ,
  376. ..BR \-f ,
  377. ..BR \-h ,
  378. ..BR \-v ,
  379. ..BR \-D ", and"
  380. ..BR \-U .
  381. Any options specified in this manner
  382. are, in turn, overridden by those specified explicitly on the command line.
  383. ..PP
  384. Lines in the
  385. ..I \.calendar
  386. file consisting of
  387. ..B note <month>
  388. can be used to place notes regarding the
  389. entire month is one of the unused blocks of the calendar.  The
  390. ..B <month>
  391. indicator may be either a number 1 through 12 or an alphabetic month name
  392. as described above;  ``note all'' will place the associated text in the
  393. notes block for each month in the current year.
  394. ..PP
  395. Comments are supported in the
  396. ..I \.calendar
  397. file.  Any characters following a `#' character through the end of the
  398. line are ignored.
  399. ..PP
  400. ..I Pcal
  401. supports rudimentary
  402. ..IR cpp -like
  403. functionality in the
  404. date file, allowing the following constructs:
  405. ..BR "define | undef" ,
  406. ..B if{n}def ... {else ...} endif,
  407. and
  408. ..BR include .
  409. Note that these are not preceded by `#' as they are in C.
  410. Symbol names defined using these keywords (or via the 
  411. ..B -D
  412. option) are case-insensitive.
  413. It is not an error to
  414. ..BR undef
  415. an undefined symbol, nor to
  416. ..BR define
  417. a previously-defined one.  An
  418. ..BR ifdef
  419. alone is always
  420. ..BR false "; an"
  421. ..BR ifndef
  422. alone is always
  423. ..BR true .
  424. ..PP
  425. The name of the file in the 
  426. ..BR include
  427. directive may optionally be
  428. surrounded by either "" or <>, both of which are ignored.  If the
  429. name is not an absolute path, it is taken to be relative to the
  430. directory where the file containing the directive is located.
  431. ..I Pcal
  432. is smart enough to translate
  433. ..B ~/
  434. to the user's home directory.
  435. ..PP
  436. In addition to pre-processing keywords,
  437. ..I pcal
  438. also accepts boolean expressions in
  439. ..B if{n}def
  440. directives.  These expressions consist of symbol names joined by the boolean
  441. operators
  442. ..BR ! ", " & ", " ^ ", and "
  443. ..BR | ,
  444. in order of precedence, high to low.  Parentheses may be used to alter the
  445. precedence.  The synonyms
  446. ..BR && " and " ||
  447. are accepted for
  448. ..BR & " and " | .
  449. A symbol name evaluates to 
  450. ..B true
  451. if currently defined,
  452. ..B false
  453. if not; thus:
  454. ..PP
  455. ..ft CW
  456. ..nf
  457. X    ifdef A | B | C
  458. ..fi
  459. ..ft
  460. ..PP
  461. \&...is
  462. ..B true
  463. if any of the symbols A, B, and C is defined, and:
  464. ..PP
  465. ..ft CW
  466. ..nf
  467. X    ifdef A & B & C
  468. ..fi
  469. ..ft
  470. ..PP
  471. \&...is
  472. ..B true
  473. if they all are.  Note that 
  474. ..B ifndef <expr>
  475. is equivalent to 
  476. ..B ifdef !( <expr> ).
  477. ..PP
  478. ..B The Moon File
  479. ..PP
  480. If a file of the name
  481. ..IR .moon## " (" moon##.dat
  482. under MS-DOS),
  483. where
  484. ..B ##
  485. is the last two digits of the calendar year, exists in the same directory
  486. as the date file,
  487. ..I pcal
  488. uses the information contained within to calculate the phase of the
  489. moon.  If no such file exists,
  490. ..I pcal
  491. uses an approximate algorithm.
  492. ..PP
  493. Entries in the moon file must conform to the following syntax:
  494. ..PP
  495. If the
  496. ..B \-A
  497. option (American date formats, the default) is given:
  498. ..PP
  499. ..ft CW
  500. ..nf
  501. X    <quarter> <month><sep><day> {<hour><sep><min>}
  502. ..fi
  503. ..ft
  504. ..PP
  505. If the
  506. ..B \-E
  507. option (European date formats) is given:
  508. ..PP
  509. ..ft CW
  510. ..nf
  511. X    <quarter> <day><sep><month> {<hour><sep><min>}
  512. ..fi
  513. ..ft
  514. ..PP
  515. Where:
  516. ..PP
  517. ..nf
  518. X    <quarter>    := ``nm'', ``fq'' or ``1q'', ``fm'', ``3q'' or ``lq'' (new moon,
  519. X                first quarter, full moon, last quarter)
  520. X    <hour>        := number 0-23 (24-hour clock)
  521. X    <min>        := number 0-59
  522. ..fi
  523. ..PP
  524. This file must contain entries for all quarter moons in the year,
  525. in chronological order; if any errors are encountered,
  526. ..I pcal
  527. will revert to using its default algorithm.
  528. ..PP
  529. As in the date file, comments start with `#' and run through the
  530. end of the given line.  
  531. ..PP
  532. ..B Options
  533. ..PP
  534. ..I Pcal
  535. has many options:
  536. ..P
  537. ..TP 12
  538. ..B \-e
  539. Prints an empty calendar.  Do not print entries from a
  540. ..I \.calendar
  541. file.
  542. ..TP
  543. ..BI \-f " cal"
  544. Directs
  545. ..I pcal
  546. to use the file name
  547. ..I cal
  548. as the input file in place of the default
  549. ..I \.calendar
  550. file in the user's home directory (or the directory pointed to by
  551. ..BR PCAL_DIR ).
  552. ..TP
  553. ..BI \-o " file"
  554. Directs
  555. ..I pcal
  556. to write the output to
  557. ..I file
  558. instead of to stdout.
  559. ..TP
  560. ..B \-l
  561. Causes the output to be in landscape mode (default).  This also resets the
  562. x- and y-axis scaling and translation factors to the defaults for
  563. landscape mode.
  564. ..TP
  565. ..B \-p
  566. Causes the output to be in portrait mode.  This also resets the
  567. x- and y-axis scaling and translation factors to the defaults for portrait
  568. mode.
  569. ..TP
  570. ..B \-j
  571. Causes the Julian date (day of year) to be printed in each calendar box.
  572. ..TP
  573. ..B \-J
  574. Causes the Julian date and the number of days remaining in the year to
  575. be printed in each calendar box.
  576. ..TP
  577. ..B \-m
  578. Causes moon icons to be printed on dates corresponding to
  579. new, half, and full moons (the default is that no moons are printed).
  580. ..TP
  581. ..B \-M
  582. Causes moon icons to be printed on all dates (the default is
  583. that no moons are printed).
  584. ..TP
  585. ..BI \-b " day" " | all"
  586. Causes all dates falling on weekday
  587. ..I day
  588. to be printed in black;
  589. ..B \-b all
  590. causes all weekdays to be printed in black.
  591. ..TP
  592. ..BI \-g " day" " | all"
  593. Causes all dates falling on weekday
  594. ..I day
  595. to be printed in gray;
  596. ..B \-g all
  597. causes all weekdays to be printed in gray.
  598. ..IP
  599. The default for the
  600. ..BR \-b " and " \-g
  601. options is to print Saturdays and Sundays in gray and other days, unless
  602. flagged as holidays, in black.
  603. ..TP
  604. ..BI \-O
  605. Causes ``gray'' dates to be printed as outlined characters.
  606. ..TP
  607. ..BI \-G
  608. Causes ``gray'' dates to be printed as outlined characters filled with gray.
  609. ..TP
  610. ..BI \-F " day"
  611. Selects weekday
  612. ..I day
  613. as the first day of the week.  The given day will appear in the left-most
  614. column of the calendar.
  615. ..TP
  616. ..B \-A
  617. Directs
  618. ..I pcal
  619. to use American date conventions
  620. ..B mm/dd{/yy}
  621. and
  622. ..B month dd
  623. ) when parsing the date file (default).
  624. ..TP
  625. ..B \-E
  626. Directs
  627. ..I pcal
  628. to use European date conventions
  629. ..B dd/mm{/yy}
  630. and
  631. ..B dd month
  632. ) when parsing the date file.
  633. ..TP
  634. ..BI \-X " xtrans"
  635. Specifies the x-axis translation value for positioning the output on the page.
  636. ..TP
  637. ..BI \-Y " ytrans"
  638. Specifies the y-axis translation value for positioning the output on the page.
  639. ..TP
  640. ..BI \-x " xscale"
  641. Specifies the x-axis scaling factor for the calendar size.
  642. ..TP
  643. ..BI \-y " yscale"
  644. Specifies the y-axis scaling factor for the calendar size.
  645. ..TP
  646. ..BI \-t " title_font"
  647. Specifies the name of a font to use to print the
  648. month name and year at the top of the calendar.  For example,
  649. ..BR "pcal \-t Times-Roman" .
  650. ..TP
  651. ..BI \-d " day_font"
  652. Similar to the
  653. ..B \-t
  654. option, but selects the font used to print the day numbers.
  655. ..TP
  656. ..BI \-n " text_font"
  657. Similar to the
  658. ..B \-t
  659. option, but selects the font used to print the text inside each day and in
  660. the notes block.
  661. ..TP
  662. ..BI \-D " symbol"
  663. Defines the named symbol prior to reading the date file.
  664. ..TP
  665. ..BI \-U " symbol"
  666. Un-defines the named symbol prior to reading the date file.
  667. ..TP
  668. ..BI \-L " string"
  669. Causes the accompanying string to be printed as a left-justified footer.
  670. Format specifiers denoting the month and/or year may appear in the string;
  671. the appropriate values will be substituted upon printing.
  672. ..TP
  673. ..BI \-C " string"
  674. Causes the accompanying string to be printed as a centered footer.
  675. Format specifiers denoting the month and/or year may appear in the string;
  676. the appropriate values will be substituted upon printing.
  677. ..TP
  678. ..BI \-R " string"
  679. Causes the accompanying string to be printed as a right-justified footer.
  680. Format specifiers denoting the month and/or year may appear in the string;
  681. the appropriate values will be substituted upon printing.
  682. ..TP
  683. ..BI \-B
  684. Causes
  685. ..I pcal
  686. to leave unused calendar boxes blank (default is gray).
  687. ..TP
  688. ..BI \-w
  689. Causes
  690. ..I pcal
  691. to print a calendar for 12 consecutive months: 3 rows / 4
  692. columns in landscape mode, 4 rows / 3 columns in portrait mode.  See the
  693. ..B CAVEATS
  694. section for details on the use of this option with other options.
  695. ..TP
  696. ..B \-I
  697. Resets all parameters to the program defaults.
  698. ..TP
  699. ..B \-h
  700. Causes
  701. ..I pcal
  702. to write version information, usage message, and full explanation of options
  703. and file formats (to
  704. ..IR stdout )
  705. and terminate.
  706. ..TP
  707. ..B \-v
  708. Causes
  709. ..I pcal
  710. to write version information only (to
  711. ..IR stdout )
  712. and terminate.
  713. ..PP
  714. Any option which normally takes an argument may be specified without
  715. the argument in order to reset the value to the program default.  Note that
  716. while the
  717. ..B \-D
  718. option alone clears all the defined symbols, the
  719. ..B \-U
  720. option alone has no effect.  The
  721. ..B \-
  722. (or
  723. ..BR "\-\|\-" " as per"
  724. System V) argument may be used to disambiguate command lines such as:
  725. ..IP
  726. ..B pcal \-t 9 90
  727. ..PP
  728. This could be written instead as one of the following:
  729. ..IP
  730. ..B pcal \-t \- 9 90
  731. ..br
  732. ..B pcal \-t \-\|\- 9 90
  733. ..PP
  734. If the environment variable
  735. ..BR PCAL_OPTS
  736. is defined, its contents are parsed as a command line.  Flags set via
  737. ..BR PCAL_OPTS
  738. override the program defaults, but are overridden by options set via 
  739. ..B opt
  740. lines in the
  741. ..I \.calendar
  742. file or explicitly on the command line.
  743. ..SH CAVEATS
  744. The ``workday'' and ``holiday'' keywords are aware of only those holidays
  745. which have already been flagged at the point where they appear.  For example,
  746. consider January 1990:
  747. ..PP
  748. ..ft CW
  749. ..nf
  750. ..ne 7
  751. X                January 1990
  752. X             S  M Tu  W Th  F  S
  753. X                1  2  3  4  5  6
  754. X             7  8  9 10 11 12 13
  755. X            14 15 16 17 18 19 20
  756. X            21 22 23 24 25 26 27
  757. X            28 29 30 31
  758. ..fi
  759. ..ft
  760. ..PP
  761. If the
  762. ..I \.calendar
  763. file looked like this:
  764. ..PP
  765. ..ft CW
  766. ..nf
  767. X    workday on_or_before all 15    payday
  768. X    3rd Mon in Jan*            MLK day
  769. ..fi
  770. ..ft
  771. ..PP
  772. \&\.\.\. then
  773. ..I pcal
  774. would mark the 15th as ``payday'' since at that point in the
  775. ..I \.calendar
  776. file it has no way of knowing that January 15th will later be flagged as a
  777. holiday.  If the two lines were reversed, such that the holiday preceded the
  778. ``workday'' wildcard, then
  779. ..I pcal
  780. would work as intended, marking instead the 12th as ``payday''.  Also, beware
  781. of year boundaries which affect the handling of all of the day wildcard
  782. keywords.  In general, it is best to place monthly wildcards such as the
  783. example above at the end of each year to achieve the desired effect.
  784. ..PP
  785. When the
  786. ..B \-w
  787. and
  788. ..B \-p
  789. options are used together,
  790. ..I pcal
  791. revises the y-scale factor in order to use the entire portrait page; therefore,
  792. the user should avoid using use the
  793. ..B \-y
  794. option when using both the
  795. ..B \-w
  796. and
  797. ..B \-p
  798. options.  Use of the
  799. ..B \-w
  800. option in any case effectively disables the
  801. ..BR \-m ", " \-M ", " \-j ", and "
  802. ..B \-J
  803. options.
  804. ..SH SEE ALSO
  805. cal(1)
  806. ..SH AUTHORS
  807. The original PostScript code to generate the calendars was written by
  808. Patrick Wood (Copyright (c) 1987 by Patrick Wood of Pipeline Associates,
  809. Inc.), and authorized for modification and redistribution.  The calendar
  810. file inclusion code was originally written in
  811. ..IR bs (1)
  812. by Bill Vogel of AT&T.  Patrick's original PostScript was modified and
  813. enhanced several times by others whose names have regrettably been lost.
  814. Ken Keirnan of Pacific Bell assembled the original ``C'' version upon which
  815. this is based; additional modifications and enhancements are the work of
  816. Joseph P. Larson, Ed Hand, Andrew W. Rogers, Mark Kantrowitz, Joe Brownlee,
  817. Jamie Zawinski, Richard L. Dyson, Bill Hogsett, and Floyd Miller.
  818. SHAR_EOF
  819. chmod 0644 pcal.man ||
  820. echo 'restore of pcal.man failed'
  821. Wc_c="`wc -c < 'pcal.man'`"
  822. test 20376 -eq "$Wc_c" ||
  823.     echo 'pcal.man: original size 20376, current size' "$Wc_c"
  824. fi
  825. # ============= pcaldefs.h ==============
  826. if test -f 'pcaldefs.h' -a X"$1" != X"-c"; then
  827.     echo 'x - skipping pcaldefs.h (File already exists)'
  828. else
  829. echo 'x - extracting pcaldefs.h (Text)'
  830. sed 's/^X//' << 'SHAR_EOF' > 'pcaldefs.h' &&
  831. /*
  832. X * pcaldefs.h - definitions for Pcal program
  833. X *
  834. X * Revision history:
  835. X *
  836. X *    4.1    AWR    07/16/91    Add support for -G flag
  837. X *
  838. X *    4.0    AWR    03/01/91    Add STDLIB macro for systems which
  839. X *                    support <stdlib.h>
  840. X *
  841. X *        AWR    02/22/91    add definitions for MS-DOS support (as
  842. X *                    per Floyd Miller)
  843. X *
  844. X *        AWR    02/19/91    revise ORD_XXX to support negative
  845. X *                    ordinals
  846. X *
  847. X *                    add definitions for Amiga support (as
  848. X *                    per Bill Hogsett)
  849. X *
  850. X *        AWR    02/06/91    additional defs for expression
  851. X *                    processing
  852. X *
  853. X *        AWR    02/04/91    support "year" as additional month
  854. X *                    name; use negative numbers for
  855. X *                    special ordinal codes (reserve
  856. X *                    positive numbers for ordinals)
  857. X *
  858. X *            01/28/91    miscellaneous new constants/macros
  859. X *
  860. X *            01/07/91    add FEB_29_OK (cf. enter_day_info())
  861. X *
  862. X *    3.0    AWR    12/10/90    support "weekday", "workday",
  863. X *                    "holiday", et. al.
  864. X *
  865. X *        AWR    11/13/90    extracted from pcal.c; added scale and
  866. X *                    translation support (-x, -y, -X, -Y);
  867. X *                    added -j, -J flags
  868. X *
  869. X */
  870. X
  871. /*
  872. X * System dependencies:
  873. X */
  874. X
  875. #ifdef VMS        /* VMS oddities isolated here */
  876. X
  877. #include <ssdef.h>    /* required for trnlog() */
  878. #include <descrip.h>
  879. X
  880. #define HOME_DIR    "SYS$LOGIN"
  881. #define DATEFILE    "calendar.dat"
  882. #define MOONFILE    "moonXX.dat"    /* 'XX' replaced with year */
  883. #define DEFAULT_OUTFILE    "calendar.ps"
  884. #define START_PATH    '['
  885. #define END_PATH    ']'
  886. X
  887. #define EXIT_SUCCESS    1        /* VMS exit() parameters */
  888. #define EXIT_FAILURE    3
  889. X
  890. #else
  891. #ifdef AMIGA        /* more oddities for Amiga */
  892. X
  893. #include <string.h>
  894. X
  895. #define PROTOS                /* compiler accepts prototypes */
  896. #define STDLIB                /* system has <stdlib.h> */
  897. #define HOME_DIR    "RAM:"
  898. #define DATEFILE    "s:calendar.dat"
  899. #define MOONFILE    "s:.moonXX"    /* 'XX' replaced with year */
  900. #define DEFAULT_OUTFILE    "RAM:calendar.ps"
  901. #define START_PATH    '/'
  902. #define END_PATH    '/'
  903. X
  904. #else
  905. #ifdef DOS        /* even more oddities for MS-DOS */
  906. X
  907. #define DATEFILE    "pcal.dat"
  908. #define MOONFILE    "moonXX.dat"    /* 'XX' replaced with year */
  909. #define START_PATH    '\\'
  910. #define END_PATH    '\\'
  911. #define HOME_DIR    "HOME"
  912. #define ALT_DATEFILE    "calendar"    /* for backward compatibility */
  913. X
  914. #else            /* neither VMS, Amiga, nor MS-DOS - assume Un*x */
  915. X
  916. #define UNIXX        /* to distinguish Un*x from others */
  917. X
  918. #define HOME_DIR    "HOME"
  919. #define DATEFILE    ".calendar"
  920. #define ALT_DATEFILE    "calendar"    /* for backward compatibility */
  921. #define MOONFILE    ".moonXX"    /* 'XX' replaced with year */
  922. #define ALT_MOONFILE    "moonXX"    /* analogous to ALT_DATEFILE */
  923. #define START_PATH    '/'
  924. #define END_PATH    '/'
  925. X
  926. #endif
  927. #endif
  928. #endif
  929. X
  930. /* define OUTFILE to DEFAULT_OUTFILE if defined, otherwise to "" (stdout) */
  931. X
  932. #ifdef DEFAULT_OUTFILE
  933. #define OUTFILE        DEFAULT_OUTFILE
  934. #else
  935. #define OUTFILE        ""
  936. #endif
  937. X
  938. /* PROTOS may be defined independently of __STDC__ for compilers which
  939. X * support function prototypes but are not fully ANSI-compliant
  940. X */
  941. X
  942. #if defined(__STDC__) && ! defined(PROTOS)
  943. #define PROTOS    
  944. #endif
  945. X
  946. /* STDLIB may be defined independently of __STDC__ for systems which
  947. X * support <stdlib.h> but are not fully ANSI-compliant
  948. X */
  949. X
  950. #if defined(__STDC__) && ! defined(STDLIB)
  951. #define STDLIB            /* cf. {no}protos.h */
  952. #endif
  953. X
  954. #ifdef STDLIB            /* include <stdlib.h> if known to exist */
  955. #include <stdlib.h>
  956. #endif
  957. X
  958. /* EXIT_SUCCESS and EXIT_FAILURE should be defined in <stdlib.h>
  959. X * (or above if non-standard); define here if necessary
  960. X */
  961. X
  962. #ifndef EXIT_SUCCESS
  963. #define EXIT_SUCCESS    0
  964. #endif
  965. #ifndef EXIT_FAILURE
  966. #define EXIT_FAILURE    1
  967. #endif
  968. X
  969. /* definition of NULL (if needed) */
  970. #ifndef NULL
  971. #define NULL    0
  972. #endif
  973. X
  974. /*
  975. X * Environment variables (global symbol, logical name on VMS):
  976. X */
  977. X
  978. #define PCAL_OPTS    "PCAL_OPTS"    /* command-line flags */
  979. #define PCAL_DIR    "PCAL_DIR"    /* calendar file directory */
  980. #define PATH_ENV_VAR    "PATH"        /* cf. find_executable() (pcalutil.c) */
  981. X
  982. /*
  983. X * Function-like macros:
  984. X */
  985. X
  986. #define FPR        (void)fprintf
  987. #define PRT        (void)printf
  988. X
  989. #define PUTCHAR(_c) \
  990. X    PRT((_c) == ' ' || isalnum(_c) ? "%c" : "\\%03o" , (_c) & 0377)
  991. #define PUTSTR(_s)  \
  992. X    if (1) { char *_p; for (_p = _s; *_p; _p++) PUTCHAR(*_p); } else
  993. X
  994. #define IS_LEAP(y)    ((y) % 4 == 0 && ((y) % 100 != 0 || (y) % 400 == 0))
  995. #define LENGTH_OF(m, y) (month_len[(m)-1] + ((m) == FEB && IS_LEAP(y)))
  996. #define YEAR_LEN(y)    (IS_LEAP(y) ? 366 : 365)
  997. #define DAY_OF_YEAR(m, d, y) ((month_off[(m)-1] + ((m) > FEB && IS_LEAP(y))) + d)
  998. #define OFFSET_OF(m, y) ((month_off[(m)-1] + ((m) > FEB && IS_LEAP(y))) % 7)
  999. #define FIRST_OF(m, y)    calc_weekday(m, 1, y)
  1000. #define START_DAY(m, y)    ((FIRST_OF(m, y) - first_day_of_week + 7) % 7)
  1001. X
  1002. #define PREV_MONTH(m, y) ((m) == JAN ? DEC : (m) - 1)
  1003. #define PREV_YEAR(m, y)  ((m) == JAN ? (y) - 1 : (y))
  1004. #define NEXT_MONTH(m, y) ((m) == DEC ? JAN : (m) + 1)
  1005. #define NEXT_YEAR(m, y)  ((m) == DEC ? (y) + 1 : (y))
  1006. X
  1007. #define INIT_COLORS    memcpy(day_color, default_color, sizeof(day_color))
  1008. X
  1009. #define P_LASTCHAR(p)    ((p) && *(p) ? (p) + strlen(p) - 1 : NULL)
  1010. #define LASTCHAR(p)    (p)[strlen(p) - 1]
  1011. X
  1012. #define IS_NUMERIC(p)    ((p)[strspn((p), DIGITS)] == '\0')
  1013. #define IS_WILD(w)    ((w) >= WILD_FIRST && (w) <= WILD_LAST)
  1014. X
  1015. #define MAKE_DATE(dt, m, d, y) \
  1016. X    if (1) { (dt).mm = m; (dt).dd = d; (dt).yy = y; } else
  1017. X
  1018. #define ERR(errmsg) \
  1019. X    FPR(stderr, E_ILL_LINE, progname, errmsg, filename, line);
  1020. X
  1021. #ifdef __STDC__
  1022. #define TOLOWER(c)    tolower(c)
  1023. #else
  1024. #define TOLOWER(c)    (isupper(c) ? tolower(c) : (c))
  1025. #endif
  1026. X
  1027. #ifndef isodigit            /* rare */
  1028. #define isodigit(c)    ((c) >= '0' && (c) <= '7')
  1029. #endif
  1030. #ifndef isxdigit            /* ANSI standard */
  1031. #define isxdigit(c) \
  1032. X    (isdigit(c) || ((c) >= 'a' && (c) <= 'f') || ((c) >= 'A' && (c) <= 'F'))
  1033. #endif
  1034. X
  1035. X
  1036. /* preprocessor token codes - cf. get_token(), pcallang.h */
  1037. X
  1038. #define PP_DEFINE     0
  1039. #define PP_ELSE         1
  1040. #define PP_ENDIF     2
  1041. #define PP_IFDEF     3
  1042. #define PP_IFNDEF     4
  1043. #define PP_INCLUDE     5
  1044. #define PP_UNDEF     6
  1045. #define PP_OTHER    -1    /* not pp token */
  1046. X
  1047. /* ordinal number codes - cf. get_ordinal(), pcallang.h */
  1048. X
  1049. #define ORD_NEGNUM    -1    /* negative ordinal (-2nd == next to last) */
  1050. #define ORD_POSNUM     1    /* positive ordinal */
  1051. #define ORD_ODD         2    /* special codes for "odd" and "even" */
  1052. #define ORD_EVEN     3
  1053. #define ORD_ALL         4    /* special code for "all" used as ordinal */
  1054. #define ORD_OTHER     0    /* not ordinal token */
  1055. X
  1056. /* moon phase codes - cf. pcallang.h and moonphas.c */
  1057. X
  1058. #define MOON_NM         0    /* new moon */
  1059. #define MOON_1Q         1    /* first quarter */
  1060. #define MOON_FM          2    /* full moon */
  1061. #define MOON_3Q         3    /* last quarter */
  1062. #define MOON_OTHER    -1    /* unrecognizable */
  1063. X
  1064. /* date type codes - cf. date_type(), get_keywd(), and pcallang.h */
  1065. X
  1066. #define DT_ALL         0    /* "all" keyword" */
  1067. #define DT_NOTE         1    /* "note" keyword */
  1068. #define DT_OPT         2    /* "opt" keyword */
  1069. #define DT_YEAR         3    /* "year" keyword */
  1070. #define DT_MONTH     4    /* name of month */
  1071. #define DT_DATE         5    /* date of form dd/mm{/yy} or mm/dd{/yy} */
  1072. #define DT_EURDATE     6    /* European date of form dd <month> */
  1073. #define DT_ORDINAL     7    /* ordinal (first, 1st, ... last) */
  1074. #define DT_WEEKDAY     8    /* weekday name */
  1075. #define DT_OTHER    -1    /* unrecognizable first token */
  1076. X
  1077. /* preposition token codes - cf. get_prep(), pcallang.h */
  1078. X
  1079. #define PR_BEFORE     0
  1080. #define PR_ON_BEFORE     1
  1081. #define PR_AFTER     2
  1082. #define PR_ON_AFTER     3
  1083. #define PR_OTHER    -1    /* not a preposition */
  1084. X
  1085. X
  1086. /*
  1087. X * Miscellaneous other constants:
  1088. X */
  1089. X
  1090. #define FALSE        0    /* pseudo-Booleans */
  1091. #define TRUE        1
  1092. X
  1093. #define MAX_NESTING    10    /* maximum nesting level for file inclusion */
  1094. X
  1095. #define MAX_PP_SYMS    100    /* number of definable preprocessor symbols */
  1096. #define PP_SYM_UNDEF     -1    /* flag for undefined symbol */
  1097. X
  1098. #define EXPR_ERR    -1    /* expression parsing error */
  1099. X
  1100. #define MIN_YR        1900    /* significant years (calendar limits) */
  1101. #define MAX_YR        9999
  1102. X
  1103. #define CENTURY        1900    /* default century for two-digit years */
  1104. X
  1105. #define JAN         1    /* significant months */
  1106. #define FEB         2
  1107. #define DEC        12
  1108. #define NOT_MONTH    -1    /* not valid month */
  1109. #define ALL_MONTHS     0    /* select all months */
  1110. #define ENTIRE_YEAR    13    /* select entire year as one entity */
  1111. X
  1112. #define SUN         0    /* significant weekdays */
  1113. #define SAT         6
  1114. #define NOT_WEEKDAY    -1    /* not valid weekday */
  1115. X
  1116. #define SCREENWIDTH    72    /* command-line message in usage() */
  1117. X
  1118. #define FEB_29_OK    1    /* if != 0, ignore 2/29 of common year */
  1119. X
  1120. /* wildcards - cf. days[] in pcallang.h and pdatefcn[] in pcal.c */
  1121. X
  1122. #define ANY_DAY         7    /* special - matches any day */
  1123. #define ANY_WEEKDAY     8    /* matches any weekday (including holidays) */
  1124. #define ANY_WORKDAY     9    /* matches any weekday (excluding holidays) */
  1125. #define ANY_HOLIDAY    10    /* matches any holiday */
  1126. #define ANY_NONWEEKDAY    11    /* converses of above three */
  1127. #define ANY_NONWORKDAY    12
  1128. #define ANY_NONHOLIDAY    13
  1129. X
  1130. #define WILD_FIRST    ANY_DAY
  1131. #define WILD_LAST    ANY_NONHOLIDAY
  1132. X
  1133. #define DAY_TEXT    0    /* types of text in data structure */
  1134. #define HOLIDAY_TEXT    1
  1135. #define NOTE_TEXT    2
  1136. X
  1137. #define NOTE_DAY    32    /* dummy day for notes text */
  1138. X
  1139. #define MAX_DATES    366    /* maximum "wildcard" dates */
  1140. X
  1141. #define MAXWORD        100    /* maximum words in date file line */
  1142. #define STRSIZ        200    /* size of misc. strings */
  1143. #define LINSIZ        512    /* size of source line buffer */
  1144. X
  1145. #define MAXARGS        3    /* numeric command-line args */
  1146. X
  1147. #define WHITESPACE    " \t"    /* token delimiters in date file */
  1148. #define DIGITS        "0123456789"
  1149. X
  1150. /* passes where flags may be recognized (cf. get_args(), pcallang.h) */
  1151. #define P_ENV    1    /* parsed from environment variable */
  1152. #define P_CMD1    2    /* parsed in first command-line pass */
  1153. #define P_OPT    4    /* parsed on "opt" lines in date file */
  1154. #define P_CMD2    8    /* parsed in second command-line pass */
  1155. X
  1156. /*
  1157. X * Defaults for calendar layout:
  1158. X */
  1159. X
  1160. #define DAYFONT        "Times-Bold"    /* default font names */
  1161. #define TITLEFONT    "Times-Bold"
  1162. #define NOTESFONT    "Helvetica-Narrow"
  1163. X
  1164. #define LFOOT         ""              /* default foot strings */
  1165. #define CFOOT         ""
  1166. #define RFOOT         ""
  1167. X
  1168. #define LANDSCAPE      90        /* degrees to rotate */
  1169. #define PORTRAIT         0
  1170. #define ROTATE           LANDSCAPE    /* default */
  1171. X
  1172. /* scaling/translation factors based on 8.5 x 11 inch (612 x 792 point) page */
  1173. X
  1174. #define XSVAL_L        "1"        /* scale/translate values (landscape) */
  1175. #define YSVAL_L        "1"
  1176. #define XTVAL_L        "46"        /* (792 - 700) / 2 = 46 */
  1177. #define YTVAL_L        "-120"
  1178. #define XSVAL_P        "0.773"        /* scale/translate values (portrait) */
  1179. #define YSVAL_P        "0.773"        /* 612/792 */
  1180. #define XTVAL_P        "46"
  1181. #define YTVAL_P        "492"        /* 612 - 120 = 492 */
  1182. X
  1183. #if (ROTATE == LANDSCAPE)        /* select appropriate defaults */
  1184. #define XSVAL        XSVAL_L
  1185. #define YSVAL        YSVAL_L
  1186. #define XTVAL        XTVAL_L
  1187. #define YTVAL        YTVAL_L
  1188. #else
  1189. #define XSVAL        XSVAL_P
  1190. #define YSVAL        YSVAL_P
  1191. #define XTVAL        XTVAL_P
  1192. #define YTVAL        YTVAL_P
  1193. #endif
  1194. X
  1195. #define USA_DATES    0        /* date styles */
  1196. #define EUR_DATES    1
  1197. #define DATE_STYLE    USA_DATES    /* default */
  1198. X
  1199. #define FIRST_DAY    SUN        /* first day of logical week */
  1200. X
  1201. #define BLACK        0        /* colors for dates */
  1202. #define GRAY        1
  1203. #define DAY_COLOR    { GRAY, BLACK, BLACK, BLACK, BLACK, BLACK, GRAY }
  1204. X
  1205. #define NO_DATEFILE     0        /* date file (if any) to use */
  1206. #define USER_DATEFILE    1
  1207. #define SYS_DATEFILE    2
  1208. X
  1209. /* values below must be in sync with cond[] and gray[] in writefil.c */
  1210. #define NO_MOONS    0        /* no moon icons */
  1211. #define ALL_MOONS    1        /* moon icon on every day */
  1212. #define SOME_MOONS    2        /* icons on full, half, new moons */
  1213. #define DRAW_MOONS    NO_MOONS    /* default */
  1214. X
  1215. #define NO_JULIANS    0        /* no Julian dates */
  1216. #define ALL_JULIANS    1        /* Julian date + days left */
  1217. #define SOME_JULIANS    2        /* just Julian dates */
  1218. #define JULIAN_DATES    NO_JULIANS    /* default: none */
  1219. X
  1220. #define    GRAY_NUMS    0        /* print "gray" dates in gray */
  1221. #define OUTLINE_NUMS    1        /* print as unfilled outlines */
  1222. #define FILLED_NUMS    2        /* print as filled outlines */
  1223. #define    NUM_STYLE    GRAY_NUMS    /* default */
  1224. X
  1225. /*
  1226. X * Global typedef declarations for data structure (cf. readfile.c)
  1227. X */
  1228. X
  1229. /*
  1230. X * The internal data structure consists of a series of linked lists as 
  1231. X * pictured below (for clarity, only one instance of each node is shown):
  1232. X *
  1233. X *
  1234. X * head
  1235. X *  |
  1236. X *  |        year_info
  1237. X *  |    -----------------           month_info
  1238. X *   -->| year            |       -----------------            day_info
  1239. X *      | month_info*[0]  |----->| holidays        |       ----------------
  1240. X *      |   ...           |      | day_info*[0]    |----->| is_holiday     |
  1241. X *      | month_info*[11] |--->  |   ...           |      | text_string*   |--->
  1242. X *      | next year_info* |--    | day_info*[30]   |--->  | next day_info* |-- 
  1243. X *       -----------------   |   | day_info*[NOTE] |--->   ----------------   |
  1244. X *                           |    -----------------                           |
  1245. X *                           |                                                |
  1246. X *             ...        <--                                     ...      <--
  1247. X *
  1248. X * 
  1249. X * Each year_info node consists of the year, 12 pointers (Jan .. Dec) to
  1250. X * month_info nodes, and a pointer to the next year_info node in the chain.
  1251. X * (The year_info chain is maintained in ascending order by year.)
  1252. X *
  1253. X * Each month_info node consists of a bitmap of the holidays for that month, 
  1254. X * a pointer to the day_info chain for all 31 possible days of the month, and
  1255. X * an additional pointer to the day_info chain for the "Notes" pseudo-day. 
  1256. X * (A day_info chain is a linked list of all the text entries for a given
  1257. X * day, in the order in which they were encountered in the date file.)
  1258. X *
  1259. X * Each day_info node consists of a flag indicating whether the associated
  1260. X * text string is holiday or non-holiday text (any given day may have both),
  1261. X * a pointer to the text string itself, and a pointer to the next day_info 
  1262. X * node in the chain.
  1263. X *
  1264. X */
  1265. X
  1266. typedef struct d_i {
  1267. X    int is_holiday;
  1268. X    char *text;
  1269. X    struct d_i *next;
  1270. X    } day_info;
  1271. X
  1272. typedef struct m_i {
  1273. X    unsigned long holidays;
  1274. X    day_info *day[32];    /* including NOTE_DAY */
  1275. X    } month_info;
  1276. X
  1277. typedef struct y_i {
  1278. X    int year;
  1279. X    month_info *month[12];
  1280. X    struct y_i *next;
  1281. X    } year_info;
  1282. X
  1283. /*
  1284. X * Global typedef declarations for keyword descriptors (cf. pcallang.h)
  1285. X */
  1286. X
  1287. typedef struct {
  1288. X    char *name;
  1289. X    int   code;
  1290. X    } KWD;
  1291. X
  1292. typedef struct {
  1293. X    char *name;
  1294. X    int   code;
  1295. X    int   value;
  1296. X    } KWD_O;        /* keyword plus ordinal value */
  1297. X
  1298. typedef struct {
  1299. X    char *name;
  1300. X    int   code;
  1301. #ifdef PROTOS
  1302. X    int (*pfcn)(char *);
  1303. #else
  1304. X    int (*pfcn)();
  1305. #endif
  1306. X    } KWD_F;        /* keyword plus dispatch function */
  1307. X
  1308. /*
  1309. X * Global typedef declaration for date structure (cf. parse_ord())
  1310. X */
  1311. X
  1312. typedef struct {
  1313. X    int mm;
  1314. X    int dd;
  1315. X    int yy;
  1316. } DATE;
  1317. X
  1318. /* 
  1319. X * Global typedef declaration for flag usage struct (cf. pcallang.h, get_args())
  1320. X */
  1321. X
  1322. typedef struct {
  1323. X    char flag;        /* name of flag */
  1324. X    char has_arg;        /* TRUE if flag takes (optional) arg */
  1325. X    char passes;        /* "or" of P_xxx for relevant passes */
  1326. X    } FLAG_USAGE;
  1327. X
  1328. /*
  1329. X * Global typedef declarations for usage message (cf. pcallang.h, usage())
  1330. X */
  1331. X
  1332. typedef struct {
  1333. X    char flag;        /* name of flag */
  1334. X    char *meta;        /* metaname for argument (if any) */
  1335. X    char *text;        /* associated text */
  1336. X    char *def;        /* default value (if any) */
  1337. X    } FLAG_MSG;
  1338. X
  1339. typedef struct {
  1340. X    char *desc;        /* description of param */
  1341. X    char *text;        /* associated text */
  1342. X    } PARAM_MSG;
  1343. X
  1344. typedef char *DATE_MSG;        /* date file syntax message */
  1345. X
  1346. SHAR_EOF
  1347. chmod 0666 pcaldefs.h ||
  1348. echo 'restore of pcaldefs.h failed'
  1349. Wc_c="`wc -c < 'pcaldefs.h'`"
  1350. test 14846 -eq "$Wc_c" ||
  1351.     echo 'pcaldefs.h: original size 14846, current size' "$Wc_c"
  1352. fi
  1353. # ============= pcalglob.h ==============
  1354. if test -f 'pcalglob.h' -a X"$1" != X"-c"; then
  1355.     echo 'x - skipping pcalglob.h (File already exists)'
  1356. else
  1357. echo 'x - extracting pcalglob.h (Text)'
  1358. sed 's/^X//' << 'SHAR_EOF' > 'pcalglob.h' &&
  1359. /*
  1360. X * pcalglob.h - definitions and declarations of globals used throughout Pcal
  1361. X *
  1362. X * Revision history:
  1363. X *
  1364. X *    4.1    AWR    07/16/91    Added support for -G flag
  1365. X *
  1366. X *    4.0    AWR    01/28/91    Added support for -b and -w flags
  1367. X *
  1368. X *            01/15/91    Extracted from pcal.c
  1369. X *
  1370. X */
  1371. X
  1372. #ifdef PROTOS
  1373. #include "protos.h"
  1374. #else
  1375. #include "noprotos.h"
  1376. #endif
  1377. X
  1378. /*
  1379. X * Definitions and/or declarations of globals
  1380. X */
  1381. X
  1382. #ifdef MAIN_MODULE
  1383. X
  1384. /*
  1385. X * Misc. globals
  1386. X */
  1387. X
  1388. year_info *head = NULL;        /* head of internal data structure */
  1389. int curr_year;            /* current default year for date file entries */
  1390. char *words[MAXWORD];        /* maximum number of words per date file line */
  1391. char lbuf[LINSIZ];        /* date file source line buffer */
  1392. char progname[STRSIZ];        /* program name (for error messages) */
  1393. char version[20];        /* program version (for info messages) */
  1394. X
  1395. /* lengths and offsets of months in common year */
  1396. char month_len[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
  1397. short month_off[12] = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};
  1398. X
  1399. #ifdef PROTOS
  1400. int (*pdatefcn[])(int, int, int) = {
  1401. #else
  1402. int (*pdatefcn[])() = {
  1403. #endif
  1404. X    is_anyday, is_weekday, is_workday, is_holiday, not_weekday,
  1405. X    not_workday, not_holiday };
  1406. X
  1407. /*
  1408. X * Default values for command-line options:
  1409. X */
  1410. X
  1411. char default_color[] = DAY_COLOR;     /* -b, -g */
  1412. char day_color[7];
  1413. X
  1414. int datefile_type = SYS_DATEFILE;    /* -e, -f */
  1415. char datefile[STRSIZ] = "";
  1416. X
  1417. int rotate = ROTATE;            /* -l, -p */
  1418. X
  1419. int draw_moons = DRAW_MOONS;        /* -m, -M */
  1420. X
  1421. char dayfont[STRSIZ] = DAYFONT;        /* -d, -t, -n */
  1422. char titlefont[STRSIZ] = TITLEFONT;
  1423. char notesfont[STRSIZ] = NOTESFONT;
  1424. X
  1425. char lfoot[STRSIZ] = LFOOT;             /* -L, -C, -R */
  1426. char cfoot[STRSIZ] = CFOOT;
  1427. char rfoot[STRSIZ] = RFOOT;
  1428. X
  1429. int first_day_of_week = FIRST_DAY;    /* -F */
  1430. X
  1431. int date_style = DATE_STYLE;        /* -A, -E */
  1432. X
  1433. char outfile[STRSIZ] = OUTFILE;        /* -o */
  1434. X
  1435. char xsval[12] = XSVAL;            /* -x, -y, -X, -Y */
  1436. char ysval[12] = YSVAL;
  1437. char xtval[12] = XTVAL;
  1438. char ytval[12] = YTVAL;
  1439. X
  1440. int julian_dates = JULIAN_DATES;    /* -j */
  1441. X
  1442. int do_whole_year = FALSE;        /* -w */
  1443. X
  1444. int blank_boxes = FALSE;        /* -B */
  1445. X
  1446. int num_style = NUM_STYLE;        /* -G, -O */
  1447. X
  1448. #else
  1449. X
  1450. /*
  1451. X * Misc. globals
  1452. X */
  1453. X
  1454. extern year_info *head;        /* head of internal data structure */
  1455. extern int curr_year;        /* current default year for date file entries */
  1456. extern char *words[];        /* maximum number of words per date file line */
  1457. extern char lbuf[];        /* date file source line buffer */
  1458. extern char progname[];        /* program name (for error messages) */
  1459. extern char version[];        /* program version (for info messages) */
  1460. X
  1461. /* lengths and offsets of months in common year */
  1462. extern char month_len[];
  1463. extern short month_off[];
  1464. X
  1465. /* dispatch functions and table for wildcard processing */
  1466. extern int (*pdatefcn[])(); 
  1467. X
  1468. /*
  1469. X * Default values for command-line options:
  1470. X */
  1471. X
  1472. extern char default_color[];         /* -b, -g */
  1473. extern char day_color[];
  1474. X
  1475. extern int datefile_type;        /* -e, -f */
  1476. extern char datefile[];
  1477. X
  1478. extern int rotate;            /* -l, -p */
  1479. X
  1480. extern int draw_moons;            /* -m, -M */
  1481. X
  1482. extern char dayfont[];            /* -d, -t, -n */
  1483. extern char titlefont[];
  1484. extern char notesfont[];
  1485. X
  1486. extern char lfoot[];            /* -L, -C, -R */
  1487. extern char cfoot[];
  1488. extern char rfoot[];
  1489. X
  1490. extern int first_day_of_week;        /* -F */
  1491. X
  1492. extern int date_style;            /* -A, -E */
  1493. X
  1494. extern char outfile[];            /* -o */
  1495. X
  1496. extern char xsval[];            /* -x, -y, -X, -Y */
  1497. extern char ysval[];
  1498. extern char xtval[];
  1499. extern char ytval[];
  1500. X
  1501. extern int julian_dates;        /* -j */
  1502. X
  1503. extern int do_whole_year;        /* -w */
  1504. X
  1505. extern int blank_boxes;            /* -B */
  1506. X
  1507. extern int num_style;            /* -G, -O */
  1508. X
  1509. #endif
  1510. X
  1511. SHAR_EOF
  1512. chmod 0666 pcalglob.h ||
  1513. echo 'restore of pcalglob.h failed'
  1514. Wc_c="`wc -c < 'pcalglob.h'`"
  1515. test 3549 -eq "$Wc_c" ||
  1516.     echo 'pcalglob.h: original size 3549, current size' "$Wc_c"
  1517. fi
  1518. # ============= pcalinit.c ==============
  1519. if test -f 'pcalinit.c' -a X"$1" != X"-c"; then
  1520.     echo 'x - skipping pcalinit.c (File already exists)'
  1521. else
  1522. echo 'x - extracting pcalinit.c (Text)'
  1523. sed 's/^X//' << 'SHAR_EOF' > 'pcalinit.c' &&
  1524. /*
  1525. X * Create a .h file from a .ps file.  Strips out leading and trailing 
  1526. X * whitespace, blank lines, and lines consisting solely of comments,
  1527. X * except for the very first block of comments/blanklines, which are
  1528. X * turned into C comments at the top of the file.
  1529. X * 
  1530. X *   14-sep-90  Jamie Zawinski  created.
  1531. X *
  1532. X * Revision history:
  1533. X *
  1534. X *    4.0    AWR    02/25/91    added optional third argument for
  1535. X *                    name of array
  1536. X *
  1537. X *        AWR    02/19/91    added function prototypes; documented
  1538. X *
  1539. X *        AWR    01/16/91    Escape " and \ in quoted strings;
  1540. X *                    strip trailing comments; skip FF
  1541. X *
  1542. X *    2.6    JAB    10/18/90    Add exit(0).
  1543. X *
  1544. X *    2.3    JWZ    09/14/90    Author
  1545. X */
  1546. X
  1547. #include <stdio.h>
  1548. #include <ctype.h>
  1549. #include <string.h>
  1550. X
  1551. #if defined(__STDC__) || defined(AMIGA)
  1552. #define PROTOS
  1553. #endif
  1554. X
  1555. #define FALSE    0
  1556. #define TRUE    1
  1557. X
  1558. #define ARRAY_NAME    "header"    /* default name of array in .h file */
  1559. X
  1560. #define IS_WHITESPACE(c) \
  1561. X    ((c) == ' ' || (c) == '\t' || (c) == '\n' || c == '\f')
  1562. X
  1563. #define IS_POSTSCRIPT(s)    ((s)[0] != '%' && (s)[0] != '\0')
  1564. X
  1565. X
  1566. /*
  1567. X * strip_white: strip leading and trailing whitespace from 'string'; return
  1568. X * pointer to first non-whitespace character
  1569. X */
  1570. #ifdef PROTOS
  1571. char *strip_white (char *string)
  1572. #else
  1573. char *strip_white (string)
  1574. X     char *string;
  1575. #endif
  1576. {
  1577. X    int n;
  1578. X    for (; IS_WHITESPACE(*string); string++)
  1579. X    ;
  1580. X    n = strlen(string)-1;
  1581. X    for (; IS_WHITESPACE(string[n]); n--)
  1582. X    string[n] = '\0';
  1583. X    return string;
  1584. }
  1585. X
  1586. X
  1587. /*
  1588. X * strip_comment: strip comment and any preceding whitespace from 'string';
  1589. X * return pointer to 'string'
  1590. X */
  1591. #ifdef PROTOS
  1592. char *strip_comment (char *string)
  1593. #else
  1594. char *strip_comment (string)
  1595. X     char *string;
  1596. #endif
  1597. {
  1598. X    char *p;
  1599. X    if ((p = strchr(string, '%')) != NULL) {
  1600. X    *p = '\0';
  1601. X    string = strip_white(string);
  1602. X    }
  1603. X    return string;
  1604. }
  1605. X
  1606. /*
  1607. X * escape: copy string 'in' to string 'out', escaping the characters \ and ";
  1608. X * return pointer to 'out'
  1609. X */
  1610. #ifdef PROTOS
  1611. char *escape(char *out, char *in)
  1612. #else
  1613. char *escape(out, in)
  1614. X     char *out, *in;
  1615. #endif
  1616. {
  1617. X   char c, *sv_out = out;
  1618. X
  1619. X   for (; c = *in; *out++ = *in++)
  1620. X       if (c == '\\' || c == '"')
  1621. X      *out++ = '\\';
  1622. X
  1623. X   *out = '\0';
  1624. X   return sv_out;
  1625. }
  1626. X
  1627. X
  1628. #ifdef PROTOS
  1629. int main(int argc, char *argv[])
  1630. #else
  1631. int main (argc, argv)
  1632. X     int argc; char *argv[];
  1633. #endif
  1634. {
  1635. X    FILE *in, *out;
  1636. X    char line[256], line2[512], *L, *array;
  1637. X    int in_initial_comments = TRUE;
  1638. X
  1639. X    /* retrieve arguments and attempt to open input and output files */
  1640. X
  1641. X    if (argc < 3 || argc > 4) {
  1642. X       fprintf(stderr, "usage: %s <infile>.ps <outfile>.h [<arrayname>]\n",
  1643. X        argv[0]);
  1644. X       exit(-1); }
  1645. X    
  1646. X    in = fopen(argv[1], "r");
  1647. X    if (NULL == in) {
  1648. X       fprintf(stderr, "%s: couldn't open %s\n", argv[0], argv[1]);
  1649. X       exit(-1); }
  1650. X    
  1651. X    out = fopen(argv[2], "w");
  1652. X    if (NULL == out) {
  1653. X       fprintf(stderr, "%s: couldn't open %s\n", argv[0], argv[2]);
  1654. X       exit(-1); }
  1655. X    
  1656. X    array = argc == 4 ? argv[3] : ARRAY_NAME;
  1657. X
  1658. X    /* print topline comment on output file */
  1659. X
  1660. X    fprintf (out, "/*\n * %s: automatically generated by %s from %s\n",
  1661. X       argv[2], argv[0], argv[1]);
  1662. X    fprintf (out, " *\n *\tDO NOT EDIT THIS FILE!\n *\n");
  1663. X
  1664. X    /* main loop - copy lines from input file, to output file, preserving
  1665. X     * only initial block of comments and blank lines
  1666. X     */
  1667. X
  1668. X    while ( fgets(line, 255, in) != NULL ) {
  1669. X       L = strip_white(line);            /* strip whitespace */
  1670. X
  1671. X       if ( IS_POSTSCRIPT(L) ) {        /* PostScript source? */
  1672. X      if ( in_initial_comments ) {        /* first PS line? */
  1673. X         in_initial_comments = FALSE;
  1674. X         fprintf(out, " */\n\nchar *%s[] = {\n", array);
  1675. X      }
  1676. X      L = strip_comment(L);            /* copy string to output */
  1677. X      L = escape(line2, L);
  1678. X      fprintf(out, "  \"%s\",\n", L);
  1679. X       } else                    /* blank or comment line */
  1680. X      if ( in_initial_comments )        /* copy only initial block */
  1681. X         fprintf(out, " * %s\n", L);
  1682. X    }
  1683. X
  1684. X    fprintf(out, "  (char *)0,\n};\n");        /* terminate array decl */
  1685. X
  1686. X    fclose(out);            /* close files and exit */
  1687. X    fclose(in);
  1688. X    exit (0);
  1689. }
  1690. SHAR_EOF
  1691. chmod 0644 pcalinit.c ||
  1692. echo 'restore of pcalinit.c failed'
  1693. Wc_c="`wc -c < 'pcalinit.c'`"
  1694. test 3975 -eq "$Wc_c" ||
  1695.     echo 'pcalinit.c: original size 3975, current size' "$Wc_c"
  1696. fi
  1697. # ============= pcalinit.ps ==============
  1698. if test -f 'pcalinit.ps' -a X"$1" != X"-c"; then
  1699.     echo 'x - skipping pcalinit.ps (File already exists)'
  1700. else
  1701. echo 'x - extracting pcalinit.ps (Text)'
  1702. sed 's/^X//' << 'SHAR_EOF' > 'pcalinit.ps' &&
  1703. % pcalinit.ps - provides the PostScript routines for pcal.c
  1704. %
  1705. % 4.1    modified by Andrew Rogers:
  1706. %
  1707. %    support -G option (cf. prtday) to print "gray" dates as filled
  1708. %    outlines
  1709. %
  1710. % 4.0    modified by Andrew Rogers:
  1711. %
  1712. %    support -w ("whole year") option - cf. printmonth_[pl], startpage
  1713. %    moved all the calendar calculations to pcal.c and moonphas.c (q.v.)
  1714. %
  1715. %    support -B option (leave unused boxes blank)
  1716. %
  1717. %    support -O option (print "gray" numbers as outlines)
  1718. %
  1719. %    revised several of the basic routines and added some others; dates,
  1720. %    moons, text, Julian days are now relative to upper-left corner of box
  1721. %
  1722. %    enlarged title and dates in small calendars
  1723. %
  1724. % 3.0    modified by Andrew Rogers:
  1725. %
  1726. %    added xsval, ysval, xtval, ytval for scaling and translation
  1727. %    as per Ed Hand
  1728. %
  1729. %    added day-of-year support (-j, -J flags)
  1730. %
  1731. % 2.6    * no modifications *
  1732. %
  1733. % 2.5    modified by Joe Brownlee:
  1734. %
  1735. %    made day numbers smaller, providing more room for event text
  1736. %    repositioned event text and moons accordingly
  1737. %    added support for variable first day of week
  1738. %
  1739. % 2.4    * no modifications *
  1740. %
  1741. % 2.3    modified by Jamie Zawinski <jwz@lucid.com>:
  1742. %
  1743. %    merged in moon routines (originally by Mark Hanson)
  1744. %
  1745. % 2.2    modified by Joe Brownlee:
  1746. %
  1747. %    add "notetext" to print notes in unused calendar box
  1748. %
  1749. % 2.1    modified by Mark Kantrowitz:
  1750. %
  1751. %    use symbolic names instead of magic numbers throughout
  1752. %    support -L, -C, -R, -n options (all new)
  1753. %    print holiday text in otherwise-wasted space next to date
  1754. %    use larger text for dates in large calendars
  1755. %
  1756. % 2.0    modified by Andrew W. Rogers:
  1757. %
  1758. %    skip printing days of week on small calendars
  1759. %    center month and year at top of calendar
  1760. %    use correct algorithm for leap year calculation
  1761. %    get month and day names from main program
  1762. %    use table to determine color (black/gray) of weekdays and holidays
  1763. %    use hanging indent to print continued text lines
  1764. X
  1765. /SM 0 def                % definitions for calendar sizes
  1766. /MED 1 def
  1767. /LG 2 def
  1768. X
  1769. /titlefontsize   [ 60 48 48 ] def    % font sizes for SM/MED/LG calendars
  1770. /datefontsize    [ 54 40 25 ] def
  1771. /weekdayfontsize [  0 24 12 ] def
  1772. /footfontsize 12 def
  1773. /notesfontsize 6 def
  1774. X
  1775. /titlepos [ 19 40 25 ] def        % Y-offset (SM/MED/LG) of month/year title
  1776. /Y0 35 def                % Y-coordinate of calendar grid origin
  1777. X
  1778. /daywidth 100 def            % dimensions of grid boxes
  1779. /dayheight 80 def
  1780. /gridwidth daywidth 7 mul def
  1781. /gridheight dayheight 6 mul def
  1782. /negdaywidth daywidth neg def
  1783. /negdayheight dayheight neg def
  1784. /neggridwidth gridwidth neg def
  1785. /neggridheight gridheight neg def
  1786. X
  1787. /gridlinewidth 1.0 def            % width of grid lines
  1788. /charlinewidth 0.1 def            % width of outline characters
  1789. /moonlinewidth 0.1 def            % width of moon icon line
  1790. /dategray 0.8 def            % density of gray for dates
  1791. /fillgray 0.9 def            % density of gray for fill squares
  1792. X
  1793. /hangingindent (   ) def        % for indenting continued text lines
  1794. X
  1795. X
  1796. %
  1797. % Utility functions:
  1798. %
  1799. X
  1800. X
  1801. /center {        % print string centered in given width
  1802. X    /width exch def
  1803. X    /str exch def
  1804. X    width str stringwidth pop sub 2 div 0 rmoveto str show
  1805. } def
  1806. X
  1807. X
  1808. /strcat {        % concatenate two strings
  1809. X    2 copy
  1810. X    length exch length
  1811. X    dup 3 -1 roll add
  1812. X    string
  1813. X    dup 0 6 -1 roll putinterval
  1814. X    dup 3 -1 roll 4 -1 roll putinterval
  1815. } def
  1816. X
  1817. X
  1818. /prtday {        % print date in black, gray, outline, or filled outline
  1819. X    day 3 string cvs                % convert to string
  1820. X    color (outline) eq color (outline_gray) eq or {
  1821. X        true charpath
  1822. X        color (outline_gray) eq {        % filled outline?
  1823. X            gsave dategray setgray fill grestore
  1824. X        } if
  1825. X        stroke                    % print as outline
  1826. X    }
  1827. X    {
  1828. X        color (gray) eq { dategray setgray } if    % print in gray
  1829. X        show
  1830. X    } ifelse
  1831. } def
  1832. X
  1833. X
  1834. /nextbox {        % go to next column or start of next row
  1835. X    day startday add 7 mod 0 eq                % end of week?
  1836. X        { neggridwidth daywidth add negdayheight rmoveto }  % next row
  1837. X        { daywidth 0 rmoveto }                    % next col
  1838. X    ifelse
  1839. } def
  1840. X
  1841. X
  1842. /datepos {        % push coords of upper-left corner of box for day <arg>
  1843. X    startday add 1 sub dup 7 mod daywidth mul        % x-coord
  1844. X    exch 7 idiv negdayheight mul Y0 add            % y-coord
  1845. } def
  1846. X    
  1847. X
  1848. %
  1849. % Functions for drawing parts of calendar:
  1850. %
  1851. X
  1852. X
  1853. /drawtitle {        % draw month and year title
  1854. X    titlefont findfont titlefontsize calsize get scalefont setfont
  1855. X    /month_name month_names month 1 sub get def
  1856. X    /yearstring year 10 string cvs def
  1857. X    0 Y0 titlepos calsize get add moveto
  1858. X    month_name (  ) strcat yearstring strcat gridwidth center
  1859. } def
  1860. X
  1861. X
  1862. /drawdaynames {        % draw day names above respective columns
  1863. X    dayfont findfont weekdayfontsize calsize get scalefont setfont
  1864. X    0 1 6 {
  1865. X        /i exch def
  1866. X        i daywidth mul Y0 5 add moveto
  1867. X        day_names i get
  1868. X        daywidth center
  1869. X    } for
  1870. } def
  1871. X
  1872. X
  1873. /drawgrid {        % draw the grid for the calendar
  1874. X    gridlinewidth setlinewidth
  1875. X    0 daywidth gridwidth {            % vertical lines
  1876. X        Y0 moveto
  1877. X        0 neggridheight rlineto
  1878. X        stroke
  1879. X    } for
  1880. X    0 negdayheight neggridheight {        % horizontal lines
  1881. X        0 exch Y0 add moveto
  1882. X        gridwidth 0 rlineto
  1883. X        stroke
  1884. X    } for
  1885. } def
  1886. X
  1887. X
  1888. /drawnums {        % place day numbers on calendar
  1889. X    dayfont findfont datefontsize calsize get scalefont setfont
  1890. X    /fontdiff datefontsize calsize get datefontsize LG get sub def
  1891. X    charlinewidth setlinewidth
  1892. X    1 datepos 20 fontdiff add sub exch 5 add exch moveto
  1893. X
  1894. X    1 1 ndays {
  1895. X        /day exch def
  1896. X        /color (black) def
  1897. X        calsize SM ne {        % select alternate color
  1898. X            /gray day_gray day startday add 1 sub 7 mod get def
  1899. X            holidays { day eq { /gray holiday_gray def } if } forall
  1900. X            gray {
  1901. X                /color logical_gray def
  1902. X            } if
  1903. X        } if
  1904. X        gsave
  1905. X        prtday
  1906. X        grestore
  1907. X        nextbox
  1908. X    } for
  1909. } def
  1910. X
  1911. X
  1912. /drawjnums {        % place day-of-year numbers on calendar
  1913. X    notesfont findfont notesfontsize scalefont setfont
  1914. X    1 datepos dayheight 3 sub sub exch daywidth 3 sub add exch moveto
  1915. X
  1916. X    1 1 ndays {
  1917. X        /day exch def
  1918. X        /jday jdstart day add 1 sub def
  1919. X        /str jday 3 string cvs def
  1920. X        julian-dates true eq {        % print days left in year?
  1921. X            /str str ( \050) strcat yearlen jday sub 3 string cvs
  1922. X                strcat (\051) strcat def
  1923. X        } if
  1924. X        gsave
  1925. X        str dup stringwidth pop 0 exch sub 0 rmoveto show
  1926. X        grestore
  1927. X        nextbox
  1928. X    } for
  1929. } def
  1930. X
  1931. X
  1932. /fillboxes {        % used by drawfill to generate row of fill squares
  1933. X    /last exch def        % last box to fill (0 = Sun)
  1934. X    /first exch def        % first box to fill (0 = Sun)
  1935. X    /width last first sub 1 add daywidth mul def
  1936. X
  1937. X    width 0 gt {
  1938. X        gsave
  1939. X        first daywidth mul 0 rmoveto
  1940. X        fillgray setgray
  1941. X        width 0 rlineto
  1942. X        0 negdayheight rlineto
  1943. X        width neg 0 rlineto
  1944. X        closepath fill
  1945. X        grestore
  1946. X    } if
  1947. } def
  1948. X
  1949. X
  1950. /drawfill {        % generate fill squares where necessary
  1951. X    /firstbox startday ndays add def
  1952. X    /lastbox calsize LG ne {41} { note_block {38} {39} ifelse } ifelse def
  1953. X
  1954. X    0 Y0 moveto            % boxes (if any) at start of first row
  1955. X    0 startday 1 sub fillboxes
  1956. X
  1957. X    0 4 negdayheight mul rmoveto    % boxes (if any) at end of fifth row
  1958. X    firstbox 35 lt {
  1959. X        firstbox 7 mod 6 fillboxes
  1960. X        /firstbox 35 def
  1961. X    } if
  1962. X
  1963. X    0 negdayheight rmoveto        % boxes at end of bottom row
  1964. X    firstbox 7 mod lastbox 7 mod fillboxes
  1965. } def
  1966. X
  1967. X
  1968. /footstrings {        % print foot strings at bottom of page
  1969. X    titlefont findfont footfontsize scalefont setfont
  1970. X    /bottomrow { neggridheight 20 add } def
  1971. X    0 bottomrow moveto
  1972. X    Lfootstring show
  1973. X    gridwidth Rfootstring stringwidth pop sub bottomrow moveto
  1974. X    Rfootstring show
  1975. X    0 bottomrow moveto
  1976. X    Cfootstring gridwidth center
  1977. } def
  1978. X
  1979. X
  1980. %
  1981. % Functions for printing text inside boxes:
  1982. %
  1983. X
  1984. X
  1985. /daytext {
  1986. X    notesfont findfont notesfontsize scalefont setfont
  1987. X    /mytext    exch def /day exch def
  1988. X    day datepos 29 sub dup /ypos exch def exch 2 add exch moveto
  1989. X    currentpoint pop /LM exch def /RM LM 95 add def
  1990. X    showtext
  1991. } def
  1992. X    
  1993. X
  1994. /holidaytext {        % print text for holiday (next to date)
  1995. X    notesfont findfont notesfontsize scalefont setfont
  1996. X    /mytext    exch def /day exch def
  1997. X    /dwidth day 10 lt {20} {33} ifelse def        % width of date
  1998. X    /mwidth do-moon-p {16} {0} ifelse def        % width of moon icon
  1999. X    day datepos 8 sub dup /ypos exch def exch dwidth add exch moveto
  2000. X    currentpoint pop /LM exch def /RM LM 97 dwidth mwidth add sub add def
  2001. X    showtext
  2002. } def
  2003. X
  2004. X
  2005. /notetext {        % print text in notes box
  2006. X    dayfont findfont 12 scalefont setfont
  2007. X    /day 40 startday sub def        % "date" of notes box
  2008. X    day datepos 11 sub exch 4 add exch moveto
  2009. X    notesheading show
  2010. X
  2011. X    notesfont findfont notesfontsize scalefont setfont
  2012. X    /mytext    exch def
  2013. X    day datepos 19 sub dup /ypos exch def exch 4 add exch moveto
  2014. X    /LM currentpoint pop def /RM LM 93 add def
  2015. X    showtext
  2016. } def
  2017. X
  2018. X
  2019. /crlf {            % simulate CR/LF sequence
  2020. X    ypos notesfontsize sub /ypos exch def LM ypos moveto
  2021. } def
  2022. X
  2023. X
  2024. /prstr {        % print string on current or next line
  2025. X    dup stringwidth pop currentpoint pop
  2026. X    add RM gt { crlf hangingindent show } if show
  2027. } def
  2028. X
  2029. X
  2030. /showtext {        % print words in "mytext", splitting into lines
  2031. X    mytext {
  2032. X        dup linesep eq            % force new line?
  2033. X            { crlf pop }        % yes - discard text
  2034. X            { prstr ( ) show }    % no - print string + space
  2035. X        ifelse
  2036. X    } forall
  2037. } def
  2038. X
  2039. X
  2040. %
  2041. % Functions for printing months of various sizes and orientations:
  2042. %
  2043. X
  2044. X
  2045. /startpage {        % initialize new physical page
  2046. X    rval rotate
  2047. X    xsval ysval scale
  2048. X    xtval ytval translate
  2049. } def
  2050. X
  2051. X
  2052. /calendar        % draw calendar for month/year
  2053. {
  2054. X    drawtitle                    % month/year heading
  2055. X
  2056. X    calsize SM ne {                    % day names
  2057. X        drawdaynames
  2058. X    } if
  2059. X
  2060. X    calsize LG eq {                    % foot strings
  2061. X        footstrings
  2062. X    } if
  2063. X
  2064. X    drawnums                    % calendar dates
  2065. X
  2066. X    julian-dates false ne calsize LG eq and {    % julian dates
  2067. X        drawjnums
  2068. X    } if
  2069. X
  2070. X    fill-boxes {                    % fill unused boxes
  2071. X        drawfill
  2072. X    } if
  2073. X
  2074. X    drawgrid                    % calendar grid
  2075. X
  2076. X    draw-moons false ne calsize LG eq and {        % moon icons
  2077. X        drawmoons
  2078. X    } if
  2079. X
  2080. X    0 0 moveto                    % return to origin
  2081. } def
  2082. X
  2083. X
  2084. /printmonth_l {        % print month on landscape page ("posn" = 0..11)
  2085. X    /calsize MED def
  2086. X
  2087. X    posn 0 eq {        % assume first month printed on page is posn 0
  2088. X        startpage
  2089. X        footstrings
  2090. X    } if
  2091. X
  2092. X    gsave            % draw medium calendar at selected position
  2093. X    .226 .25 scale        % landscape mode - 3 rows, 4 cols
  2094. X    posn 4 mod 800 mul
  2095. X    posn 4 idiv -700 mul 150 add
  2096. X    translate
  2097. X    calendar
  2098. X    grestore
  2099. } def
  2100. X
  2101. X
  2102. /printmonth_p {        % print month on portrait page ("posn" = 0..11)
  2103. X    /calsize MED def
  2104. X    /footfontsize 15 def    % compensate for scaling
  2105. X
  2106. X    posn 0 eq {        % assume first month printed on page is posn 0
  2107. X        gsave        % print foot strings at original scale
  2108. X        startpage
  2109. X        0 20 translate  % move foot strings up slightly 
  2110. X        footstrings
  2111. X        grestore    % re-scale Y axis for portrait mode
  2112. X        /sv_ysval ysval def
  2113. X        /ysval ysval 1.675 mul def
  2114. X        startpage
  2115. X        /ysval sv_ysval def
  2116. X    } if
  2117. X
  2118. X    gsave            % draw medium calendar at selected position
  2119. X    .304 .194 scale        % portrait mode - 4 rows, 3 cols
  2120. X    posn 3 mod 800 mul
  2121. X    posn 3 idiv -700 mul 300 add
  2122. X    translate
  2123. X    calendar
  2124. X    grestore
  2125. } def
  2126. X
  2127. X
  2128. /printmonth {        % print single month on page
  2129. X    startpage
  2130. X
  2131. X    /calsize LG def            % main (large) calendar
  2132. X    calendar
  2133. X    
  2134. X    gsave                % small calendars
  2135. X    /calsize SM def
  2136. X    /sv_startday startday def
  2137. X
  2138. X    % calculate previous and next month, year, and starting day
  2139. X
  2140. X    /lmonth month 1 eq { 12 } { month 1 sub } ifelse def
  2141. X    /lyear  month 1 eq { year 1 sub } { year } ifelse def
  2142. X    /lstartday startday 35 add lndays sub 7 mod def
  2143. X    /nmonth month 12 eq { 1 } { month 1 add } ifelse def
  2144. X    /nyear  month 12 eq { year 1 add } { year } ifelse def
  2145. X    /nstartday startday ndays add 7 mod def
  2146. X
  2147. X    /year lyear def            % prev month/year
  2148. X    /month lmonth def
  2149. X    /startday lstartday def
  2150. X    /ndays lndays def
  2151. X    5 daywidth mul 5 negdayheight mul Y0 add translate
  2152. X    gsave
  2153. X    .138 .138 scale
  2154. X    12 -120 translate
  2155. X    calendar
  2156. X    grestore
  2157. X
  2158. X    /year nyear def            % next month/year
  2159. X    /month nmonth def
  2160. X    /startday nstartday def
  2161. X    /ndays nndays def
  2162. X    daywidth 0 translate
  2163. X    gsave
  2164. X    .138 .138 scale
  2165. X    12 -120 translate
  2166. X    calendar
  2167. X    grestore
  2168. X
  2169. X    /startday sv_startday def    % restore starting day (for text boxes)
  2170. X    grestore
  2171. } def
  2172. X
  2173. X
  2174. %
  2175. % Moon drawing functions:
  2176. %
  2177. X
  2178. X
  2179. /domoon {    % draw moon at phase (0 = new; .25 = 1q; .5 = full; .75 = 3q)
  2180. X    /phase exch def
  2181. X
  2182. X    gsave
  2183. X    currentpoint translate
  2184. X    newpath
  2185. X
  2186. X    % if moon is full, just draw unfilled circle
  2187. X
  2188. X    phase halfperiod .01 sub ge phase halfperiod .01 add le and {
  2189. X        0 0 radius
  2190. X        0 360 arc stroke
  2191. X    }
  2192. X    {
  2193. X        % draw the line arc now; prepare (but don't draw) the fill arc
  2194. X
  2195. X        0 0 radius            % for line and fill arcs
  2196. X        0 0 radius 
  2197. X        phase halfperiod lt {        % phase between new and full
  2198. X            270 90 arc stroke    % (line on right, fill on left)
  2199. X            0 radius neg moveto
  2200. X            270 90 arcn 
  2201. X        }
  2202. X        {                % phase between full and new
  2203. X            90 270 arc stroke    % (line on left, fill on right)
  2204. X            0 radius neg moveto
  2205. X            270 90 arc 
  2206. X            /phase phase halfperiod sub def
  2207. X        } ifelse
  2208. X
  2209. X        % curveto uses (x0,y0) (current point), (x1,y1), (x2,y2),
  2210. X        % and (x3,y3) as the control points for drawing a Bezier
  2211. X        % cubic section, used here as the curve dividing the moon
  2212. X        % icon into dark and light sections.  x1 is in the range
  2213. X        % -R*sqrt(2) <= x1 <= R*sqrt(2) and y1 is in the range
  2214. X        % 0 <= y1 <= R; note that except in the degenerate case
  2215. X        % where x1 = y1 = x2 = y2 = 0, the curve does not actually
  2216. X        % pass through (x1,y1) or (x2,y2).
  2217. X
  2218. X        /x1 quartperiod phase sub rect mul def
  2219. X        /y1 x1 abs 2 sqrt div def
  2220. X
  2221. X        % push control points for curveto
  2222. X
  2223. X                    % x0 = 0   (current
  2224. X                    % y0 = R    point)
  2225. X        x1            % x1
  2226. X        y1            % y1
  2227. X        x1            % x2 = x1
  2228. X        y1 neg            % y2 = -y1
  2229. X        0            % x3 = 0
  2230. X        radius neg        % y3 = -R
  2231. X
  2232. X        % draw Bezier curve; fill area between curve and fill arc
  2233. X
  2234. X        curveto
  2235. X        fill
  2236. X    } ifelse
  2237. X
  2238. X    grestore
  2239. } def
  2240. X
  2241. X
  2242. /do-moon-p {        % draw a moon on "day"?
  2243. X    draw-moons (some) eq {        % printing quarter moons?  look up day
  2244. X        /p false def
  2245. X        quarter_moons { day eq { /p true def } if } forall
  2246. X        p
  2247. X    }
  2248. X    {
  2249. X        draw-moons        % all moons or no moons
  2250. X    } ifelse
  2251. } def
  2252. X
  2253. X
  2254. /drawmoons {        % main routine to draw moons on calendar
  2255. X    /halfperiod 0.5 def
  2256. X    /quartperiod 0.25 def
  2257. X    /radius 6 def
  2258. X    /offset radius 3 add def
  2259. X    /rect radius 2 sqrt mul quartperiod div def    % domoon{} scale factor
  2260. X    /n 0 def
  2261. X
  2262. X    gsave
  2263. X    moonlinewidth setlinewidth
  2264. X    1 datepos offset sub exch daywidth add offset sub exch moveto
  2265. X    1 1 ndays {
  2266. X        /day exch def
  2267. X        do-moon-p {            % draw a moon today?
  2268. X            moon_phases n get domoon
  2269. X            /n n 1 add def
  2270. X        } if
  2271. X    nextbox
  2272. X    } for
  2273. X    grestore
  2274. } def
  2275. SHAR_EOF
  2276. chmod 0666 pcalinit.ps ||
  2277. echo 'restore of pcalinit.ps failed'
  2278. Wc_c="`wc -c < 'pcalinit.ps'`"
  2279. test 13642 -eq "$Wc_c" ||
  2280.     echo 'pcalinit.ps: original size 13642, current size' "$Wc_c"
  2281. fi
  2282. true || echo 'restore of pcallang.h failed'
  2283. echo End of part 4, continue with part 5
  2284. exit 0
  2285.