jbr0@cbnews.att.com (joseph.a.brownlee) (01/02/91)
This is yet another version of "pcal", the PostScript calendar program. The changes since version 2.6 include several requested features, and amounted to a substantial rewrite of the program; hence the new release number. The major changes are: . Two .h files have been extracted from "pcal.c": "pcaldefs.c" Program-wide definitions (including defaults). "pcallang.c" Language-dependent strings. The command-line flags can be easily be redefined to be more meaningful in languages other than English. The hard-coded strings in usage() have been moved to a table in "pcallang.c" for ease of translation to other languages. . The usage() message now includes the syntax for the .calendar file. . Support has been added for "wildcard" dates such as "all Thursdays in October", "last Thursday in all", etc. (the admittedly-counterintuitive "all Fri in all" selects every Friday in every month). Such dates apply to the currently-defined year; "each" and "every" are accepted as synonyms for "all". . Now supports "day" in place of a day name; this is mostly useful in the context of "last day in February", but also allows "day after 4th Thursday in Nov". Also supports "weekday" (any day normally printed in black, as selected by the -b and -g flags), "workday" (same as "weekday", but also cognizant of flagged holidays), and "holiday" (flagged holidays only), plus the converses thereof: "nonweekday", "nonworkday", and "nonholiday". . Supports "on_or_before" and "on_or_after", as in "Friday on_or_before all 15"; these may be abbreviated as "oob" and "ooa" respectively. Note that prepositions can now be relative to any date specification, including wildcards. . Supports "note all <text>" for notes to be propagated to all months. . Supports seven new flags: -x, -y, -X, and -Y to control page scaling and positioning (thanks to Ed Hand; see the man page); -j and -J to print Julian dates (day of year; -J also prints the number of days remaining in the year) in the lower right corner of each calendar box; and -I to reinitialize all parameters to the program defaults. . As always, the enclosed manual page has been updated to reflect all of these changes. Additional note: This distribution includes a VMS HELP file written by Richard Dyson. Countless other people worked on pcal long before me; see the Orig.ReadMe file and topline comments in "pcal.c". - _ Joe Brownlee, Analysts International Corp. @ AT&T Network Systems /_\ @ / ` 471 E Broad St, Suite 1610, Columbus, Ohio 43215 (614) 860-7461 / \ | \_, E-mail: jbr@cblph.att.com Who pays attention to what _I_ say? "Scotty, we need warp drive in 3 minutes or we're all dead!" --- James T. Kirk ------------------------------- 8< cut here >8 ------------------------------- #!/bin/sh # This is a shell archive (produced by shar 3.49) # To extract the files from this archive, save it to a file, remove # everything above the "!/bin/sh" line above, and type "sh file_name". # # existing files will NOT be overwritten unless -c is specified # # This shar contains: # length mode name # ------ ---------- ------------------------------------------ # 2453 -rw-r--r-- ReadMe # 450 -rw-r--r-- Makefile # 984 -rw-r--r-- Orig.ReadMe # 2544 -rw-rw-rw- calendar # 393 -rw-r--r-- make_pcal.com # 8437 -rw-r--r-- pcal.hlp # 12258 -rw-r--r-- pcal.man # 8799 -rw-rw-rw- pcaldefs.h # 1842 -rw-r--r-- pcalinit.c # 12028 -rw-r--r-- pcalinit.ps # 16742 -rw-rw-rw- pcallang.h # 61911 -rw-r--r-- pcal.c # # ============= ReadMe ============== if test -f 'ReadMe' -a X"$1" != X"-c"; then echo 'x - skipping ReadMe (File already exists)' else echo 'x - extracting ReadMe (Text)' sed 's/^X//' << 'SHAR_EOF' > 'ReadMe' && "pcal" Version 3.0 X This is yet another version of "pcal", the PostScript calendar program. The changes since version 2.6 include several requested features, and amounted to a substantial rewrite of the program; hence the new release number. The major changes are: X X . Two .h files have been extracted from "pcal.c": X X "pcaldefs.c" Program-wide definitions (including defaults). X "pcallang.c" Language-dependent strings. X X The command-line flags can be easily be redefined to be more meaningful X in languages other than English. The hard-coded strings in usage() have X been moved to a table in "pcallang.c" for ease of translation to other X languages. X X . The usage() message now includes the syntax for the .calendar file. X X . Support has been added for "wildcard" dates such as "all Thursdays in X October", "last Thursday in all", etc. (the admittedly-counterintuitive X "all Fri in all" selects every Friday in every month). Such dates apply X to the currently-defined year; "each" and "every" are accepted as X synonyms for "all". X X . Now supports "day" in place of a day name; this is mostly useful in the X context of "last day in February", but also allows "day after 4th X Thursday in Nov". Also supports "weekday" (any day normally printed X in black, as selected by the -b and -g flags), "workday" (same as X "weekday", but also cognizant of flagged holidays), and "holiday" X (flagged holidays only), plus the converses thereof: "nonweekday", X "nonworkday", and "nonholiday". X X . Supports "on_or_before" and "on_or_after", as in "Friday on_or_before X all 15"; these may be abbreviated as "oob" and "ooa" respectively. X Note that prepositions can now be relative to any date specification, X including wildcards. X X . Supports "note all <text>" for notes to be propagated to all months. X X . Supports seven new flags: -x, -y, -X, and -Y to control page scaling X and positioning (thanks to Ed Hand; see the man page); -j and -J to X print Julian dates (day of year; -J also prints the number of days X remaining in the year) in the lower right corner of each calendar box; X and -I to reinitialize all parameters to the program defaults. X X . As always, the enclosed manual page has been updated to reflect all of X these changes. X Additional note: This distribution includes a VMS HELP file written by Richard Dyson. Countless other people worked on pcal long before me; see the Orig.ReadMe file and topline comments in pcal.c. SHAR_EOF chmod 0644 ReadMe || echo 'restore of ReadMe failed' Wc_c="`wc -c < 'ReadMe'`" test 2453 -eq "$Wc_c" || echo 'ReadMe: original size 2453, current size' "$Wc_c" fi # ============= Makefile ============== if test -f 'Makefile' -a X"$1" != X"-c"; then echo 'x - skipping Makefile (File already exists)' else echo 'x - extracting Makefile (Text)' sed 's/^X//' << 'SHAR_EOF' > 'Makefile' && # Set the configuration variables below to taste. X CC = /bin/cc MANDIR = /usr/man X pcal: pcal.c pcalinit.h pcaldefs.h pcalinit.h X $(CC) $(CFLAGS) $(LDFLAGS) $(COPTS) -o pcal pcal.c X @ echo "+ Compile of pcal complete!" X pcalinit: pcalinit.c X $(CC) $(CFLAGS) $(LDFLAGS) $(COPTS) -o pcalinit pcalinit.c X pcalinit.h: pcalinit pcalinit.ps X pcalinit pcalinit.ps pcalinit.h X man: pcal.man X nroff -man pcal.man > pcal.1 X pack pcal.1 # mv pcal.1.z $(MANDIR) SHAR_EOF chmod 0644 Makefile || echo 'restore of Makefile failed' Wc_c="`wc -c < 'Makefile'`" test 450 -eq "$Wc_c" || echo 'Makefile: original size 450, current size' "$Wc_c" fi # ============= Orig.ReadMe ============== if test -f 'Orig.ReadMe' -a X"$1" != X"-c"; then echo 'x - skipping Orig.ReadMe (File already exists)' else echo 'x - extracting Orig.ReadMe (Text)' sed 's/^X//' << 'SHAR_EOF' > 'Orig.ReadMe' && "Pcal" is a program to print PostScript calendars for any month and year. By default, it looks for a file in the home directory named "calendar" for entries with leading dates matching dates on the calendar, and prints any following text under the appropriate day. X The program may be a little System V flavored (getopt, time routines) but should be easily portable to other vintages of UNIX. X Pcal is the combined effort of several people, most notably Patrick Wood of Pipeline Associates, Inc. for the original PostScript code and Bill Vogel of AT&T for the calendar file mechanism. My part was simple translation to a "C" program, the addition of a couple options and a more generalized date searching routine (oh yes, and a manual page :-). X The original calendar PostScript was Copyright (c) 1987 by Patrick Wood and Pipeline Associates, Inc. with permission to modify and redistribute. Please retain this README file with the package. X X Ken Keirnan Pacific Bell San Ramon, CA. SHAR_EOF chmod 0644 Orig.ReadMe || echo 'restore of Orig.ReadMe failed' Wc_c="`wc -c < 'Orig.ReadMe'`" test 984 -eq "$Wc_c" || echo 'Orig.ReadMe: original size 984, current size' "$Wc_c" fi # ============= calendar ============== if test -f 'calendar' -a X"$1" != X"-c"; then echo 'x - skipping calendar (File already exists)' else echo 'x - extracting calendar (Text)' sed 's/^X//' << 'SHAR_EOF' > 'calendar' && # Sample calendar file for pcal # # This should be ~/.calendar on Unix, SYS$LOGIN:CALENDAR.DAT on VMS # # Valid entries are of the following forms: # # year <year> # opt <options> # note [<month_spec>|<month>] <text> # # if -A flag (American date formats) specified: # <month_spec> <day>{*} {<text>} # <month><sep><day>{<sep><year>}{*} {<text>} # # if -E flag (European date formats) specified: # <day> <month_spec>{*} {<text>} # <day><sep><month>{<sep><year>}{*} {<text>} # # <ordinal> <day_spec> in <month_spec>{*} {<text>} # <day_spec> <prep> <date_spec> # # where # # [a|b|c] means any of a, b, and c # {x} means x is optional # # <date_spec> := any of the above date specs (not year, note, or opt) # <month_spec> := first 3+ characters of name of month, or "all" # <day_name> := first 3+ characters of name of weekday, "day", # "weekday", "workday", "holiday", "nonweekday", # "nonworkday", or "nonholiday" # <ordinal> := "first", "1st", ... "fifth", "5th", "last", or "all" # <prep> := "before", "preceding", "after", "following", "on_or_before", # or "on_or_after" # <sep> := one or more non-numeric, non-space, non-'*' characters # <month>, <day>, <year> are the numeric forms # # <options> := any command-line option except -e, -f, -h, -D, -U # # whitespace is to be used/avoided as implied by the above productions # '*' flags the date as a holiday (to be printed in gray) # comments run from '#' through end-of-line X # A sample "opt" line to change the fonts and output file names, to print # only Sundays in gray, and to print moons on all days: # #opt -d Helvetica-Bold -t Helvetica-Bold -o myfile.ps -b all -g sun -M X year 1990 # set year explicitly X 1/1* New Year's Day ifndef Arizona 3rd Mon in Jan* Martin Luther King's Birthday endif X 2/2 Groundhog Day X Feb 14 Valentine's Day 3rd Monday in Feb* Presidents' Day X 3/17 St. Patrick's Day X last Monday in May* Memorial Day X 7/4* Independence Day X 1st Monday in Sep* Labor Day X second Monday in Oct* Columbus Day (observed) 10/12 Columbus Day (traditional) 10/31 Halloween X Tue after first Mon in Nov Election Day second Monday in Nov* Veterans' Day (observed) 11/11* Veterans' Day (traditional) fourth Thu in Nov* Thanksgiving day after fourth Thu in Nov* X 12/24* Christmas Eve 12/25* Christmas X last day in Dec* New Year's Eve X last workday in all Status reports due X note Dec Office closed throughout week of Christmas X 1/1/91* New Year's Day # set new year implicitly SHAR_EOF chmod 0666 calendar || echo 'restore of calendar failed' Wc_c="`wc -c < 'calendar'`" test 2544 -eq "$Wc_c" || echo 'calendar: original size 2544, current size' "$Wc_c" fi # ============= make_pcal.com ============== if test -f 'make_pcal.com' -a X"$1" != X"-c"; then echo 'x - skipping make_pcal.com (File already exists)' else echo 'x - extracting make_pcal.com (Text)' sed 's/^X//' << 'SHAR_EOF' > 'make_pcal.com' && $! make_pcal.com - VMS command script to build/run pcalinit, create pcalinit.h $! from pcalinit.ps, and compile/link pcal.c $ $ cc pcalinit.c $ link pcalinit $ pcalinit = "$" + f$environment("DEFAULT") + "pcalinit" $ pcalinit pcalinit.ps pcalinit.h $ delete/exclude=(*.c,*.h,*.ps) pcalinit.*;* $ $ cc pcal.c $ link pcal.obj $ pcal == "$" + f$environment("DEFAULT") + "pcal" $ show symbol pcal SHAR_EOF chmod 0644 make_pcal.com || echo 'restore of make_pcal.com failed' Wc_c="`wc -c < 'make_pcal.com'`" test 393 -eq "$Wc_c" || echo 'make_pcal.com: original size 393, current size' "$Wc_c" fi # ============= pcal.hlp ============== if test -f 'pcal.hlp' -a X"$1" != X"-c"; then echo 'x - skipping pcal.hlp (File already exists)' else echo 'x - extracting pcal.hlp (Text)' sed 's/^X//' << 'SHAR_EOF' > 'pcal.hlp' && 1 PCAL X Pcal generates PostScript to produce landscape or portrait X orientated calendars for any month and year. The defaults for X month and year are the current month and year. X X VMS Version X Execution format: X X pcal [options] [mm yy] [n] X X If a file named CALENDAR.DAT resides in the caller's home X directory (or in a directory defined by the logical name PCAL_DIR, X if it exists), it will be searched for lines with leading dates X matching the requested month and year (current by default). Any X text following the date will be printed on the calendar under the X appropriate day of the month. Dates in the CALENDAR.DAT file may X consist of a numeric or alpha month (at least the first 3 X characters for month names) followed by a numeric day and X optionally followed by a year. Any non-numeric character may X separate numeric dates. Holidays may be flagged by following the X date immediately with '*'; this will cause the date to be printed X in gray. Lines in the CALENDAR.DAT file consisting of "year xxxx" X (where xxxx is a numeric year) can be used to set the year for X following entries. This assumes that the following entries do not X contain a year; any date entries containing year information will X set the remembered year to that year. Lines consisting of X "opt <options>" can be used to override defaults for all command- X line flags except -e, -f, -D, and -U; any flags set in this manner X are themselves overridden by flags specified explicitly on the X command line. Comments ('#' through end-of-line) are permitted. X X Example: X X # sample CALENDAR.DAT file - Raytheon holidays and exempt paydays, 1990 X X opt -t Helvetica-Bold -d Helvetica-Bold # override default fonts X opt -M # print moon phase X X year 1990 # set default year X X 7/4* Independence Day # '*' flags holiday X 7/12/90 Exempt payday # full numeric date X Aug 16 Exempt payday # alternate date format X 1st Monday in Sep* Labor Day X 9/20 Exempt payday X second Monday in Oct* Columbus Day (observed) X 10/25 Exempt payday X 11/20 Exempt payday X fourth Thu in Nov* Thanksgiving X Fri after 4th Thu in Nov* # day after Thanksgiving X 12/13 Exempt payday X 12/24* X 12/25* Christmas X X Pcal supports rudimentary cpp-like functionality in the date file, X supporting define | undef, if{n}def ... {else ...} endif, and X include: X X define meetings X X ifdef meetings X include meetings.dat X undef meetings X endif X X Symbol names are case-insensitive. It is not an error to "undef" X an undefined symbol, nor to "define" a previously-defined one. X X "ifdef" alone is always false; "ifndef" alone is always true. X X The name of the file in the "include" directive may optionally be X surrounded by either "" or <>, both of which are ignored. If the X name is not an absolute path, it is taken to be relative to the X directory where the file containing the directive is located. X X Pcal allows the user to print additional notes in an unused X calendar box via lines of the form "note <month> <text>", where X <month> specifies the month (numeric or alphabetic form) and X <text> is the text to add. All such text will appear in the X "Thursday" box on the last line (next to the small calendars). X X Pcal also looks for global symbol PCAL_OPTS; if defined, its X contents are parsed as command-line flags. These override the X program defaults, but are overridden by any specified via "opt" X lines in the date file or on the command line. Example: X X $ define PCAL_OPTS "-n Helvetica -D meetings" ! login.com X X $ pcal -"U" meetings 9 90 ! un-define symbol at runtime X 2 parameters X mm yy n X "mm" and "yy" are numeric values of the month (1-12) and year X (0-99) (i.e., July 1990 would be 7 90). If you just include the X "yy" option, an entire 12 months of calendars will be generated. X A specific month can be produced by including the "mm" parameter. X The "n" parameter will produce the "n" consecutive months of X calendars starting with the requested month. X X The following flags may be specified (in increasing order of X precedence) in global symbol PCAL_OPTS, in "opt" lines in the date X file (all but -e, -f, -D, -U), or on the command line. Any flag X which normally takes an argument may be specified without the X argument; this resets its value to the program default. (-D X alone thus clears all defined symbols; -U alone has no effect.) X X The '-' flag has been added to disambiguate cases where an X argument-less flag has been specified immediately before a numeric X parameter: X X $ pcal -t - 9 90 X 2 -e X Print an empty calendar (i.e., do not print entries from a X CALENDAR.DAT file.) X 2 -f <FILE> X Directs pcal to use the file name <FILE> as the input file in X place of the default CALENDAR.DAT file in the callers home X directory or in the directory specified by logical name PCAL_DIR. X 2 -o <FILE> X Directs pcal to write the PostScript calendar into FILE X (default: CALENDAR.PS in the current directory.) X 2 -l X This will cause the output to come out in landscape mode X (default). X 2 -p X This will cause the output to come out in portrait mode X instead of landscape mode. X 2 -b <DAY> | all X This will cause all dates on weekday DAY to be printed in X black; "-b all" causes all dates to be printed in black unless X explicitly flagged as a holiday. X 2 -g <DAY> | all X This will cause all dates on weekday DAY to be printed in X gray; "-g all" causes all dates to be printed in gray. Default is X to print Saturdays and Sundays in gray and other dates in black. X 2 -F <DAY> X This will cause the weekday DAY to be the first day of each X week; weekday DAY will appear in the left-most column of each X calendar. X 2 -A | -E X Use one of these options to select the date format for the X calendar file. The -A option (the default) selects American-style X dates like "10/19/90", while the -E option selects European-style X dates like "17/10/90". X 2 -t <FONT> X This option can be used to change the font the title is X printed in (ie. pcal -t Times-Roman). The default is Times-Bold. X 2 -d <FONT> X This option is the same as -t except that the font used to X print the day numbers is changed. The default is Times-Bold. X 2 -n <FONT> X This option is the same as -n except that the font used to X print the notes in the calendar boxes is changed. The default is X Helvetica-Narrow. X 2 -m X This option causes a moon to be printed on days corresponding X to a full, half, or new moon (default: no moons). X 2 -"M" X This option causes a moon to be printed on all days (default: X no moons). X 2 -"L" <STRING> X This will cause STRING to be printed as a left footer. X 2 -"C" <STRING> X This will cause STRING to be printed as a center footer. X 2 -"R" <STRING> X This will cause STRING to be printed as a right footer. X 2 -"D" <SYM> X This will define symbol SYM prior to reading the date file; X -D alone clears all defined symbols. X 2 -"U" <SYM> X This will undefine symbol SYM prior to reading the date file. X 2 -h X This prints version and usage information only. X 2 CREDITS X The original PostScript code to generate the calendars was X written by Patrick Wood (Copywrite (c) 1987 by Patrick Wood of X Pipeline Associates, Inc.), and authorized for modification and X redistribution. The CALENDAR.DAT file inclusion code was X originally written in "bs(1)" by Bill Vogel of AT&T. Patrick's X original PostScript was modified and enhanced several times by X others whose names have regrettably been lost. Ken Keirnan of X Pacific Bell assembled the original "C" version upon which this is X based; additional modifications and enhancements were the work of X Joseph P. Larson, Ed Hand, Andrew W. Rogers, Mark Kantrowitz, Joe X Brownlee, and Jamie Zawinski. This VMS HELP file was written by X Richard Dyson and updated by Andrew W. Rogers and Joe Brownlee. X SHAR_EOF chmod 0644 pcal.hlp || echo 'restore of pcal.hlp failed' Wc_c="`wc -c < 'pcal.hlp'`" test 8437 -eq "$Wc_c" || echo 'pcal.hlp: original size 8437, current size' "$Wc_c" fi # ============= pcal.man ============== if test -f 'pcal.man' -a X"$1" != X"-c"; then echo 'x - skipping pcal.man (File already exists)' else echo 'x - extracting pcal.man (Text)' sed 's/^X//' << 'SHAR_EOF' > 'pcal.man' && .TH PCAL 1 .SH NAME pcal \- generate PostScript calendars .SH SYNOPSIS .BR pcal " [" .BR \-e " | " \-f .I cal ] [ .BI \-o " file" ] [ .BR \-j " | " \-J ] [ .BR \-l " | " \-p ] [ .BR \-m " | " \-M ] [ .BI \-b " day" | all ] [ .BI \-g " day" | all ] [ .BI \-F " day" ] [ .BR \-A " | " \-E ] [ .BI \-t " title_font" ] [ .BI \-d " day_font" ] [ .BI \-n " text_font" ] [ .BI \-L " footer_string" ] [ .BI \-C " footer_string" ] [ .BI \-R " footer_string" ] [ .BI \-D " symbol" ] [ .BI \-U " symbol" ] [ .BI \-x " xscale" ] [ .BI \-y " yscale" ] [ .BI \-X " xtrans" ] [ .BI \-Y " ytrans" ] [ .B \-I ] [ .B \-h ] [ .B month ] [ .B year ] [ .B nmonths ] .SH DESCRIPTION .I Pcal generates PostScript to produce landscape or portrait calendars for any month and year. The arguments .BR month , .BR year , and .BR nmonths , if provided, should be numeric. The .BR month value should be in the range 1 \- 12, and the .BR year value should be specified as 1 or 2 digits or as the full 4 digit year. If no numeric arguments are provided, the calendar for the current month and year will be generated. .PP If one numeric argument is provided, it is interpreted as the .BR year value, and calendars for the entire year will be generated. Otherwise, .BR nmonth months, starting with .BR month and .BR year , will be generated. .PP If a file named .I \.calendar (or .I calendar for compatibility with older versions) exists in the caller's home directory or in the directory pointed to by environment variable .BR PCAL_DIR , it will be searched for lines with leading dates matching the requested month and year. Any text following the dates found will be printed on the calendar under the appropriate day of the month. Dates in the .I \.calendar file may be expressed in any of several formats: .PP .ft CW .nf X <ordinal> <day_spec> in <month_spec>{*} {<text>} X <day_spec> <prep> <date_spec>{*} {<text>} X <date_spec>{*} {<text>} .fi .ft .PP Where: .PP .nf X <month_spec> := first 3+ characters of name of month or ``all'' X <day_spec> := first 3+ characters of name of weekday, ``day'', X ``weekday'', ``workday'', ``holiday'', ``nonweekday'', X ``nonworkday'', or ``nonholiday'' X <ordinal> := ``first'', ``1st'', ... ``fifth'', ``5th'', ``last'', or ``all'' X <prep> := ``before'', ``preceding'', ``after'', ``following'', X ``on_or_before'' (``oob''), or ``on_or_after'' (``ooa'') X <sep> := one or more non-numeric, non-space, non-'*' characters X <month> := day of month (1-31) X <day> := a numeric month (1-12) X <year> := a numeric year .fi .ft .PP If the .B \-A option (American date formats, the default) is given: .PP .nf X <date_spec> := [<month_spec> <day> | <month><sep><day>{<sep><year>}] .fi .PP If the .B \-E option (European date formats) is given: .PP .nf X <date_spec> := [<day> <month_spec> | <day><sep><month>{<sep><year>}] .fi .PP Examples: .PP .ft CW .nf X last Monday in May* Memorial Day Holiday .sp X all Fridays in Oct Status Meeting, 11 AM X last workday in all Progress report due X all Fri in all Time card due, 3 PM X Fri on_or_before all 15 Pay Day .sp X Tue after first Mon in Nov Election Day (USA) .sp X 4th Thu in Nov* Thanksgiving X Fri after 4th Thu in Nov* Day after Thanksgiving .sp X 12/25/90* Christmas # American X 25.12.90* Christmas # European .sp X Dec 25* Christmas # American X 25 Dec* Christmas # European .fi .ft .PP Any non-numeric character may separate numeric dates. Holidays may be flagged by following the date immediately with `*' as in the examples above; this will cause the date to be printed in gray. ``Each'' and ``every'' are accepted as synonyms for ``all'', and any word may be used in place of ``in''. The abbreviations ``oob'' and ``ooa'' may be used in place of the keywords ``on_or_before'' and ``on_or_after'', respectively. .PP Wildcard day names are also provided. The keyword ``weekday'' applies to any days which are normally printed in black on the calendar. The keyword ``workday'' is the same, but does not include any holidays. The keyword ``holiday'' includes only those days flagged as holidays. The keywords ``nonweekday'', ``nonworkday'', and ``nonholiday'' are also recognized as negations of the above. See the .B CAVEATS below for importnat notes on using these keywords). .PP Lines in the .I \.calendar file consisting of .B year XXXX (where .B XXXX is a numeric year) can be used to set the year for following entries. This assumes that the following entries do not contain a year; any date entries containing year information will set the remembered year to that year. .PP Lines in the .I \.calendar file consisting of .B opt <options> can be used to override the defaults for any command-line options except .BR \-e , .BR \-f , .BR \-h , .BR \-D ", and" .BR \-U . Any options specified in this manner are, in turn, overridden by those specified explicitly on the command line. .PP Lines in the .I \.calendar file consisting of .B note <month> can be used to place notes regarding the entire month is one of the unused blocks of the calendar. The .B <month> indicator may be either a number 1 through 12 or an alphabetic month name as described above; ``note all'' will place the associated text in the notes block for each month in the current year. .PP Comments are supported in the .I \.calendar file. Any characters following a `#' character through the end of the line are ignored. .PP .I Pcal supports rudimentary cpp-like functionality in the date file, allowing the following constructs: .BR "define | undef" , .B if{n}def ... {else ...} endif, and .BR include . Note that these are not preceded by `#' as they are in C. Symbol names defined using these keywords (or via the .B -D option) are case-insensitive. It is not an error to .BR undef an undefined symbol, nor to .BR define a previously-defined one. An .BR ifdef alone is always false; an .BR ifndef alone is always true. .PP The name of the file in the .BR include directive may optionally be surrounded by either "" or <>, both of which are ignored. If the name is not an absolute path, it is taken to be relative to the directory where the file containing the directive is located. .I Pcal is smart enough to translate .B ~/ to the user's home directory. .PP .I Pcal has many options: .P .TP 12 .B \-e Prints an empty calendar. Do not print entries from a .I \.calendar file. .TP .BI \-f " cal" Directs .I pcal to use the file name .I cal as the input file in place of the default .I \.calendar file in the user's home directory (or the directory pointed to by .BR PCAL_DIR ). .TP .BI \-o " file" Directs .I pcal to write the output to .I file instead of to stdout. .TP .B \-l Causes the output to be in landscape mode (default). This also resets the x- and y-axis scaling and translation factors to the defaults for landscape mode. .TP .B \-p Causes the output to be in portrait mode. This also resets the x- and y-axis scaling and translation factors to the defaults for portrait mode. .TP .B \-j Causes the Julian date (day of year) to be printed in each calendar box. .TP .B \-J Causes the Julian date and the number of days remaining in the year to be printed in each calendar box. .TP .B \-m Causes moon icons to be printed on dates corresponding to new, half, and full moons (the default is that no moons are printed). .TP .B \-M Causes moon icons to be printed on all dates (the default is that no moons are printed). .TP .BI \-b " day" " | all" Causes all dates falling on weekday .I day to be printed in black; .B \-b all causes all weekdays to be printed in black. .TP .BI \-g " day" " | all" Causes all dates falling on weekday .I day to be printed in gray; .B \-g all causes all weekdays to be printed in gray. .IP The default for the .BR \-b " and " \-g options is to print Saturdays and Sundays in gray and other days, unless flagged as holidays, in black. .TP .BI \-F " day" Selects weekday .I day as the first day of the week. The given day will appear in the left-most column of the calendar. .TP .B \-A Directs .I pcal to use American date conventions .B mm/dd{/yy} and .B month dd ) when parsing the date file (default). .TP .B \-E Directs .I pcal to use European date conventions .B dd/mm{/yy} and .B dd month ) when parsing the date file. .TP .BI \-X " xtrans" Specifies the x-axis translation value for positioning the output on the page. .TP .BI \-Y " ytrans" Specifies the y-axis translation value for positioning the output on the page. .TP .BI \-x " xscale" Specifies the x-axis scaling factor for the calendar size. .TP .BI \-y " yscale" Specifies the y-axis scaling factor for the calendar size. .TP .BI \-t " title_font" Specifies the name of a font to use to print the month name and year at the top of the calendar. For example, .BR "pcal \-t Times-Roman" . .TP .BI \-d " day_font" Similar to the .B \-t option, but selects the font used to print the day numbers. .TP .BI \-n " text_font" Similar to the .B \-t option, but selects the font used to print the text inside each day and in the notes block. .TP .BI \-D " symbol" Defines the named symbol prior to reading the date file. .TP .BI \-U " symbol" Un-defines the named symbol prior to reading the date file. .TP .BI \-L " string" Causes the accompanying string to be printed as a left-justified footer. .TP .BI \-C " string" Causes the accompanying string to be printed as a centered footer. .TP .BI \-R " string" Causes the accompanying string to be printed as a right-justified footer. .TP .B \-I Resets all parameters to the program defaults. .TP .B \-h Causes .I pcal to write version information and a usage message and terminate. .PP Any option which normally takes an argument may be specified without the argument in order to reset the value to the program default. Note that while the .B \-D option alone clears all the defined symbols, the .B \-U option alone has no effect. The .B \- (or .BR "\-\|\-" " on" System V) argument may be used to disambiguate command lines such as: .IP .B pcal \-t 9 90 .PP This could be written instead as one of the following: .IP .B pcal \-t \- 9 90 .br .B pcal \-t \-\|\- 9 90 .PP If the environment variable .BR PCAL_OPTS is defined, its contents are parsed as a command line. Flags set via .BR PCAL_OPTS override the program defaults, but are overridden by options set via .B opt lines in the .I \.calendar file or explicitly on the command line. .SH CAVEATS The ``workday'' and ``holiday'' keywords are aware of only those holidays which have already been flagged at the point where they appear. For example, consider January 1990: .PP .ft CW .nf X January 1990 X S M Tu W Th F S X 1 2 3 4 5 6 X 7 8 9 10 11 12 13 X 14 15 16 17 18 19 20 X 21 22 23 24 25 26 27 X 28 29 30 31 .fi .ft .PP If the .I \.calendar file looked like this: .PP .ft CW .nf X workday on_or_before all 15 payday X 3rd Mon in Jan* MLK day .fi .ft .PP \.\.\then .I pcal would mark the 15th as ``payday'' since at that point in the .I \.calendar file it has no way of knowing that January 15th will later be flagged as a holiday. If the two lines were reversed, such that the holiday preceded the ``workday'' wildcard, then .I pcal would work as intended, marking instead the 12th as ``payday''. Also, beware of year boundaries which affect the handling of all of the day wildcard keywords. In general, it is best to place monthly wildcards such as the example above at the end of each year to acheive the desired effect. .SH SEE ALSO cal(1) .SH AUTHORS The original PostScript code to generate the calendars was written by Patrick Wood (Copywrite (c) 1987 by Patrick Wood of Pipeline Associates, Inc.), and authorized for modification and redistribution. The calendar file inclusion code was originally written in .IR bs (1) by Bill Vogel of AT&T. Patrick's original PostScript was modified and enhanced several times by others whos names have regrettably been lost. Ken Keirnan of Pacific Bell assembled the original ``C'' version upon which this is based; additional modifications and enhancements are the work of Joseph P. Larson, Ed Hand, Andrew W. Rogers, Mark Kantrowitz, Joe Brownlee, and Jamie Zawinski. SHAR_EOF chmod 0644 pcal.man || echo 'restore of pcal.man failed' Wc_c="`wc -c < 'pcal.man'`" test 12258 -eq "$Wc_c" || echo 'pcal.man: original size 12258, current size' "$Wc_c" fi # ============= pcaldefs.h ============== if test -f 'pcaldefs.h' -a X"$1" != X"-c"; then echo 'x - skipping pcaldefs.h (File already exists)' else echo 'x - extracting pcaldefs.h (Text)' sed 's/^X//' << 'SHAR_EOF' > 'pcaldefs.h' && /* X * pcaldefs.h - definitions for Pcal program X * X * Revision history: X * X * 3.0 AWR 12/10/90 support "weekday", "workday", X * "holiday", et. al. X * X * AWR 11/13/90 extracted from pcal.c; added scale and X * translation support (-x, -y, -X, -Y); X * added -j, -J flags X * X */ X /* X * System dependencies: X */ X #ifdef VMS /* VMS oddities isolated here */ X #include <ssdef.h> /* required for trnlog() */ #include <descrip.h> X #define HOME_DIR "SYS$LOGIN" #define DATEFILE "calendar.dat" #define OUTFILE "calendar.ps" #define START_PATH '[' #define END_PATH ']' X #define EXIT_SUCCESS 1 #define EXIT_FAILURE 3 X #else /* non-VMS - assume Un*x of some sort */ X #define HOME_DIR "HOME" #define DATEFILE ".calendar" #define ALT_DATEFILE "calendar" /* for backward compatibility */ #define OUTFILE "" #define START_PATH '/' #define END_PATH '/' X #define EXIT_SUCCESS 0 #define EXIT_FAILURE 1 X #endif X /* X * Environment variables (global symbol, logical name on VMS): X */ X #define PCAL_OPTS "PCAL_OPTS" /* command-line flags */ #define PCAL_DIR "PCAL_DIR" /* calendar file directory */ X /* X * Function-like macros: X */ X #define FPR (void)fprintf #define PRT (void)printf X #define PUTCHAR(_c) PRT(! isprint(_c) || _c == '(' || _c == ')' ? "\\%03o" : "%c", _c) X #define IS_LEAP(y) ((y) % 4 == 0 && ((y) % 100 != 0 || (y) % 400 == 0)) #define LENGTH_OF(m, y) (month_len[(m)-1] + ((m) == FEB && IS_LEAP(y))) #define OFFSET_OF(m, y) ((month_off[(m)-1] + ((m) > FEB && IS_LEAP(y))) % 7) #define INIT_COLORS memcpy(day_color, default_color, sizeof(day_color)) #define P_LASTCHAR(p) ((p) && *(p) ? (p) + strlen(p) - 1 : NULL) #define LASTCHAR(p) (p)[strlen(p) - 1] #define ADD_DATE(m, d, y) pdate->mm = m, pdate->dd = d, pdate++->yy = y #define TERM_DATES pdate->mm = pdate->dd = pdate->yy = 0 #define IS_NUMERIC(p) ((p)[strspn((p), DIGITS)] == '\0') #define IS_WILD(w) ((w) >= WILD_FIRST && (w) <= WILD_LAST) X #ifdef __STDC__ #define TOLOWER(c) tolower(c) #else #define TOLOWER(c) (isupper(c) ? tolower(c) : (c)) #endif X X /* preprocessor token codes - cf. get_token(), pcallang.h */ X #define PP_DEFINE 0 #define PP_ELSE 1 #define PP_ENDIF 2 #define PP_IFDEF 3 #define PP_IFNDEF 4 #define PP_INCLUDE 5 #define PP_UNDEF 6 #define PP_OTHER -1 /* not pp token */ X /* ordinal number codes - cf. get_ordinal(), pcallang.h */ X #define ORD_FIRST 1 /* values used in calculations - must be 1..5 */ #define ORD_SECOND 2 #define ORD_THIRD 3 #define ORD_FOURTH 4 #define ORD_FIFTH 5 X #define ORD_LAST 6 /* special code for "last" */ #define ORD_ALL 0 /* special code for "all" used as ordinal */ #define ORD_OTHER -1 /* not ordinal token */ X /* date type codes - cf. date_type(), get_keywd(), and pcallang.h */ X #define DT_ALL 0 /* "all" keyword" */ #define DT_NOTE 1 /* "note" keyword */ #define DT_OPT 2 /* "opt" keyword */ #define DT_YEAR 3 /* "year" keyword */ #define DT_MONTH 4 /* name of month */ #define DT_DATE 5 /* date of form dd/mm{/yy} or mm/dd{/yy} */ #define DT_EURDATE 6 /* European date of form dd <month> */ #define DT_ORDINAL 7 /* ordinal (first, 1st, ... last) */ #define DT_WEEKDAY 8 /* weekday name */ #define DT_OTHER -1 /* unrecognizable first token */ X /* preposition token codes - cf. get_prep(), pcallang.h */ X #define PR_BEFORE 0 #define PR_ON_BEFORE 1 #define PR_AFTER 2 #define PR_ON_AFTER 3 #define PR_OTHER -1 /* not a preposition */ X /* status codes returned by parse(), enter_day_info() */ X #define PARSE_OK 0 /* successful date parse */ #define PARSE_INVDATE 1 /* nonexistent date */ #define PARSE_INVLINE 2 /* syntax error */ X X /* X * Miscellaneous other constants: X */ X #define FALSE 0 /* pseudo-Booleans */ #define TRUE 1 X #define MAX_NESTING 10 /* maximum nesting level for file inclusion */ X #define MAX_PP_SYMS 100 /* number of definable preprocessor symbols */ #define PP_SYM_UNDEF -1 /* flag for undefined symbol */ X #define MIN_YR 1900 /* significant years (calendar limits) */ #define MAX_YR 9999 X #define JAN 1 /* significant months */ #define FEB 2 #define DEC 12 #define NOT_MONTH -1 /* not valid month */ #define ALL_MONTHS 0 /* select all months */ X #define SUN 0 /* significant weekdays */ #define SAT 6 #define NOT_WEEKDAY -1 /* not valid weekday */ X /* wildcards - cf. days[] in pcallang.h and pdatefcn[] in pcal.c */ X #define ANY_DAY 7 /* special - matches any day */ #define ANY_WEEKDAY 8 /* matches any weekday (including holidays) */ #define ANY_WORKDAY 9 /* matches any weekday (excluding holidays) */ #define ANY_HOLIDAY 10 /* matches any holiday */ #define ANY_NONWEEKDAY 11 /* converses of above three */ #define ANY_NONWORKDAY 12 #define ANY_NONHOLIDAY 13 X #define WILD_FIRST ANY_DAY #define WILD_LAST ANY_NONHOLIDAY X #define DAY_TEXT 0 /* types of text in data structure */ #define HOLIDAY_TEXT 1 #define NOTE_TEXT 2 X #define NOTE_DAY 32 /* dummy day for notes text */ X #define MAX_DATES 366 /* maximum "wildcard" dates */ X #define MAXWORD 100 /* maximum words in date file line */ #define STRSIZ 200 /* size of misc. strings */ #define LINSIZ 512 /* size of source line buffer */ X #define MAXARGS 3 /* numeric command-line args */ X #define WHITESPACE " \t" /* token delimiters in date file */ #define DIGITS "0123456789" X /* passes where flags may be recognized (cf. get_args(), pcallang.h) */ #define P_ENV 1 /* parsed from environment variable */ #define P_CMD1 2 /* parsed in first command-line pass */ #define P_OPT 4 /* parsed on "opt" lines in date file */ #define P_CMD2 8 /* parsed in second command-line pass */ X /* X * Defaults for calendar layout: X */ X #define DAYFONT "Times-Bold" /* default font names */ #define TITLEFONT "Times-Bold" #define NOTESFONT "Helvetica-Narrow" X #define LFOOT "" /* default foot strings */ #define CFOOT "" #define RFOOT "" X #define LANDSCAPE 90 /* degrees to rotate */ #define PORTRAIT 0 #define ROTATE LANDSCAPE /* default */ X #define XSVAL_L "1" /* scale/translate values (landscape) */ #define YSVAL_L "1" #define XTVAL_L "50" #define YTVAL_L "-120" #define XSVAL_P "0.75" /* scale/translate values (portrait) */ #define YSVAL_P "0.75" #define XTVAL_P "50" #define YTVAL_P "500" X #if (ROTATE == LANDSCAPE) /* select appropriate defaults */ #define XSVAL XSVAL_L #define YSVAL YSVAL_L #define XTVAL XTVAL_L #define YTVAL YTVAL_L #else #define XSVAL XSVAL_P #define YSVAL YSVAL_P #define XTVAL XTVAL_P #define YTVAL YTVAL_P #endif X #define USA_DATES 0 /* date styles */ #define EUR_DATES 1 #define DATE_STYLE USA_DATES /* default */ X #define FIRST_DAY SUN /* first day of logical week */ X #define BLACK 0 /* colors for dates */ #define GRAY 1 #define DAY_COLOR { GRAY, BLACK, BLACK, BLACK, BLACK, BLACK, GRAY } char default_color[] = DAY_COLOR; X #define NO_DATEFILE 0 /* date file (if any) to use */ #define USER_DATEFILE 1 #define SYS_DATEFILE 2 X /* values below must be in sync with conditionals[] in pcal.c */ #define NO_MOONS 0 /* no moon icons */ #define ALL_MOONS 1 /* moon icon on every day */ #define SOME_MOONS 2 /* icons on full, half, new moons */ #define DRAW_MOONS NO_MOONS /* default */ X #define NO_JULIANS 0 /* no Julian dates */ #define ALL_JULIANS 1 /* Julian date + days left */ #define SOME_JULIANS 2 /* just Julian dates */ #define JULIAN_DATES NO_JULIANS /* default: none */ X #define SCREENWIDTH 72 /* command-line message in usage() */ X /* X * Global typedef declarations for data structure X */ X typedef struct d_i { X int is_holiday; X char *text; X struct d_i *next; X } day_info; X typedef struct m_i { X unsigned long holidays; X day_info *day[32]; /* including NOTE_DAY */ X } month_info; X typedef struct y_i { X int year; X month_info *month[12]; X struct y_i *next; X } year_info; X /* X * Global typedef declarations for keyword descriptors (cf. pcallang.h) X */ X typedef struct { X char *name; X int code; X } KWD; X typedef struct { X char *name; X int code; X int (*pfcn)(); X } KWD_F; /* keyword plus dispatch function */ X /* X * Global typedef declaration for date structure (cf. parse_ord()) X */ X typedef struct { X int mm; X int dd; X int yy; } DATE; X /* X * Global typedef declaration for flag usage struct (cf. pcallang.h, get_args()) X */ X typedef struct { X char flag; /* name of flag */ X char has_arg; /* TRUE if flag takes (optional) arg */ X char passes; /* "or" of P_xxx for relevant passes */ X } FLAG_USAGE; X /* X * Global typedef declarations for usage message (cf. pcallang.h, usage()) X */ X typedef struct { X char flag; /* name of flag */ X char *meta; /* metaname for argument (if any) */ X char *text; /* associated text */ X char *def; /* default value (if any) */ X } FLAG_MSG; X typedef struct { X char *desc; /* description of param */ X char *text; /* associated text */ X } PARAM_MSG; X typedef char *DATE_MSG; /* date file syntax message */ X SHAR_EOF chmod 0666 pcaldefs.h || echo 'restore of pcaldefs.h failed' Wc_c="`wc -c < 'pcaldefs.h'`" test 8799 -eq "$Wc_c" || echo 'pcaldefs.h: original size 8799, current size' "$Wc_c" fi # ============= pcalinit.c ============== if test -f 'pcalinit.c' -a X"$1" != X"-c"; then echo 'x - skipping pcalinit.c (File already exists)' else echo 'x - extracting pcalinit.c (Text)' sed 's/^X//' << 'SHAR_EOF' > 'pcalinit.c' && /* X * Create a .h file from a .ps file. Strips out leading and trailing X * whitespace, blank lines, and lines consisting solely of comments, X * except for the very first block of comments/blanklines, which are X * turned into C comments at the top of the file. X * X * 14-sep-90 Jamie Zawinski created. X * X * 2.6 10/18/90 JAB Add exit(0). X */ X #include <stdio.h> #include <ctype.h> #include <string.h> X char *strip_white (string) X char *string; { X int n; X for (; *string == ' ' || *string == '\t' || *string == '\n'; string++); X n = strlen(string)-1; X for (; string[n] == ' ' || string[n] == '\t' || string[n] == '\n'; n--) X string[n] = '\0'; X return string; } X main (argc, argv) X int argc; char *argv[]; { X FILE *in, *out; X char line[256], *L; X int in_initial_comments = 1; X if (argc != 3) { X fprintf(stderr, "usage: %s <infile>.ps <outfile>.h\n", argv[0]); X exit(-1); } X X in = fopen(argv[1], "r"); X if (NULL == in) { X fprintf(stderr, "%s: couldn't open %s\n", argv[0], argv[1]); X exit(-1); } X X out = fopen(argv[2], "w"); X if (NULL == out) { X fprintf(stderr, "%s: couldn't open %s\n", argv[0], argv[2]); X exit(-1); } X X fprintf (out, X "/* automatically generated from \"%s\" - DO NOT EDIT THIS FILE!\n *\n", X argv[1]); X for (;;) { X if (NULL == fgets (line, 255, in)) break; X L = strip_white(line); X if ( in_initial_comments ) { X if ( L[0] != '%' && L[0] != '\0' ) { X in_initial_comments = 0; X fprintf(out, " */\n\nchar *header[] = {\n \"%s\",\n", L); } X else X fprintf(out, " * %s\n", L); X } X else if (L[0] != '%' && L[0] != '\0' ) X fprintf(out, " \"%s\",\n", L); X } X fprintf(out, " (char *)0,\n};\n"); X fclose(out); X fclose(in); X exit (0); } SHAR_EOF chmod 0644 pcalinit.c || echo 'restore of pcalinit.c failed' Wc_c="`wc -c < 'pcalinit.c'`" test 1842 -eq "$Wc_c" || echo 'pcalinit.c: original size 1842, current size' "$Wc_c" fi # ============= pcalinit.ps ============== if test -f 'pcalinit.ps' -a X"$1" != X"-c"; then echo 'x - skipping pcalinit.ps (File already exists)' else echo 'x - extracting pcalinit.ps (Text)' sed 's/^X//' << 'SHAR_EOF' > 'pcalinit.ps' && %!ps % pcalinit.ps - provides the PostScript routines for pcal.c % % 3.0 modified by Andrew Rogers: % % added xsval, ysval, xtval, ytval for scaling and translation % as per Ed Hand % % added day-of-year support (-j, -J flags) % % 2.6 * no modifications * % % 2.5 modified by Joe Brownlee: % % made day numbers smaller, providing more room for event text % repositioned event text and moons accordingly % added support for variable first day of week % % 2.4 * no modifications * % % 2.3 modified by Jamie Zawinski <jwz@lucid.com>: % % merged in moon routines (originally by Mark Hanson) % % 2.2 modified by Joe Brownlee: % % add "notetext" to print notes in unused calendar box % % 2.1 modified by Mark Kantrowitz: % % use symbolic names instead of magic numbers throughout % support -L, -C, -R, -n options (all new) % print holiday text in otherwise-wasted space next to date % use larger text for dates in large calendars % % 2.0 modified by Andrew W. Rogers: % % skip printing days of week on small calendars % center month and year at top of calendar % use correct algorithm for leap year calculation % get month and day names from main program % use table to determine color (black/gray) of weekdays and holidays % use hanging indent to print continued text lines X /titlefontsize 48 def /weekdayfontsize 12 def /footfontsize 12 def /datefontsize 25 def /savedatefontsize datefontsize def /notesfontsize 6 def /daywidth 100 def /dayheight 80 def /negdaywidth 0 daywidth sub def /negdayheight 0 dayheight sub def /prtnum { 3 string cvs show} def X /drawgrid { % draw calendar boxes X dayfont findfont weekdayfontsize scalefont setfont X 0 1 6 { X /i exch def X submonth 0 eq { X i daywidth mul 40 moveto X day_names i get X daywidth center X } if X i daywidth mul 35 moveto X 1.0 setlinewidth X 0 1 5 { X gsave X daywidth 0 rlineto X 0 negdayheight rlineto X negdaywidth 0 rlineto X closepath stroke X grestore X 0 negdayheight rmoveto X pop } for X } for } def X X /drawnums { % place day numbers on calendar X dayfont findfont datefontsize scalefont setfont X /start startday def X /days ndays def X /fontdiff datefontsize savedatefontsize sub def X /n 0 def X start daywidth mul 5 add 15 fontdiff sub rmoveto X 1 1 days { X /day exch def X gsave X submonth 0 eq { X /gray day_gray day start add 1 sub 7 mod get def X day holidays n get eq { X /gray holiday_gray def X /n n 1 add def X } if X gray { X 0.8 setgray X } if X } if X day prtnum X grestore X day start add 7 mod 0 eq X { X currentpoint exch pop dayheight sub 5 exch moveto X } X { X daywidth 0 rmoveto X } ifelse X } for } def X X /drawjnums { % place day-of-year numbers on calendar X notesfont findfont notesfontsize scalefont setfont X /start startday def X /days ndays def X /year_len 365 def X isleap { X /year_len 366 def X } if X start 1 add daywidth mul 3 sub 38 dayheight sub rmoveto X 1 1 days { X /day exch def X /jday year month day doy def X /str jday 3 string cvs def X julian-dates true eq { X /str str ( \\050) strcat year_len jday sub 3 string cvs strcat (\\051) strcat def X } if X gsave X str dup stringwidth pop 0 exch sub 0 rmoveto show X grestore X day start add 7 mod 0 eq X { X negdaywidth 6 mul negdayheight rmoveto X } X { X daywidth 0 rmoveto X } ifelse X } for } def X X /drawfill { % place fill squares on calendar X /start startday def X /days ndays def X 0 35 rmoveto X 1.0 setlinewidth X 0 1 start 1 sub { X gsave X .9 setgray X daywidth 0 rlineto X 0 negdayheight rlineto X negdaywidth 0 rlineto X closepath fill X grestore X daywidth 0 rmoveto X pop } for X submonth 1 eq X { X /lastday 42 def X 600 -365 moveto X } X { X note_block X { X /lastday 39 def X 300 -365 moveto X } X { X /lastday 40 def X 400 -365 moveto X } ifelse X } ifelse X lastday -1 ndays start 1 add add X { X /day exch def X gsave X .9 setgray X daywidth 0 rlineto X 0 negdayheight rlineto X negdaywidth 0 rlineto X closepath fill X grestore X day 7 mod 1 eq X { 600 -365 dayheight add moveto } X { negdaywidth 0 rmoveto } X ifelse X } for } def X X /isleap { % is this a leap year? X year 4 mod 0 eq % multiple of 4 X year 100 mod 0 ne % not century X year 400 mod 0 eq or and % or divisible by 400 } def X /isleap_2 { % is some other year a leap year? X /a_year exch def X a_year 4 mod 0 eq % multiple of 4 X a_year 100 mod 0 ne % not century X a_year 400 mod 0 eq or and % or divisible by 400 } def X /days_month [ 31 28 31 30 31 30 31 31 30 31 30 31 ] def X /ndays { % number of days in this month X days_month month 1 sub get X month 2 eq % Feb X isleap and X { X 1 add X } if } def X /ndays_2 { % number of days in some other month X /a_month exch def X /a_year exch def X days_month a_month 1 sub get X a_month 2 eq % February X a_year isleap_2 and X { 1 add } X if } def X X /startday { % starting day-of-week for this month X /off year 2000 sub def % offset from start of epoch X off X off 4 idiv add % number of leap years X off 100 idiv sub % number of centuries X off 400 idiv add % number of years divisible by 400 X 6 add 7 mod 7 add % offset from Jan 1 2000 X /off exch def X 1 1 month 1 sub { X /idx exch def X days_month idx 1 sub get X idx 2 eq X isleap and X { X 1 add X } if X /off exch off add def X } for X off dayoffset sub 7 add 7 mod % 0--first day of week, 1--second, etc. } def X X /center { % center string in given width X /width exch def X /str exch def width str X stringwidth pop sub 2 div 0 rmoveto str show } def X X /strcat { % concatenate two strings X 2 copy X length exch length X dup 3 -1 roll add X string X dup 0 6 -1 roll putinterval X dup 3 -1 roll 4 -1 roll putinterval } def X X /calendar { X titlefont findfont titlefontsize scalefont setfont X /month_name month_names month 1 sub get def X /yearstring year 10 string cvs def X 0 60 moveto X month_name ( ) strcat yearstring strcat 700 center % month_name show % daywidth 7 mul yearstring stringwidth pop sub 60 moveto % yearstring show X X submonth 0 eq { X titlefont findfont footfontsize scalefont setfont X /bottomrow { dayheight 6 mul 20 sub neg } def X 0 bottomrow moveto X Lfootstring show X daywidth 7 mul Rfootstring stringwidth pop sub X bottomrow moveto X Rfootstring show X daywidth 7 mul Cfootstring stringwidth pop sub 2 div X bottomrow moveto X Cfootstring show X } if X 0 0 moveto X drawnums X julian-dates false ne submonth 0 eq and { X 0 0 moveto X drawjnums X } if X 0 0 moveto X drawfill X 0 0 moveto X drawgrid X 0 0 moveto X submonth 0 eq { drawmoons } if } def X X /daytext { X notesfont findfont notesfontsize scalefont setfont X /mytext exch def /myday exch def X startday myday 1 sub add dup 7 mod daywidth mul 2 add % gives column X exch 7 idiv negdayheight mul 6 add % gives row X dup /ypos exch def moveto X /LM currentpoint pop def /RM LM 95 add def X mytext { dup (.p) eq { crlf pop} {prstr ( ) show} ifelse } forall } def X X /holidaytext { X notesfont findfont notesfontsize scalefont setfont X /mytext exch def /myday exch def X startday myday 1 sub add dup 7 mod daywidth mul X myday 10 lt {20} {33} ifelse add % gives column X exch 7 idiv negdayheight mul 27 add % gives row X dup /ypos exch def moveto X /LM currentpoint pop def /RM LM myday 10 lt {75} {60} ifelse add def X /day myday def X do-moon-p { /RM RM 16 sub def } if X mytext { dup (.p) eq { crlf pop} {prstr ( ) show} ifelse } forall } def X X /notetext { X dayfont findfont 12 scalefont setfont X 4 daywidth mul 4 add % title column X 5 negdayheight mul 24 add % title row X moveto X (Notes) show X notesfont findfont notesfontsize scalefont setfont X /mytext exch def X 4 daywidth mul 4 add % gives column X 5 negdayheight mul 16 add % gives row X dup /ypos exch def moveto X /LM currentpoint pop def /RM LM 95 add def X mytext { dup (.p) eq { crlf pop} {prstr ( ) show} ifelse } forall } def X /crlf { X ypos notesfontsize sub /ypos exch def LM ypos moveto } def X /prstr { X dup stringwidth pop currentpoint pop X add RM gt {crlf ( ) show} if show } def X /printmonth { X rval rotate X xsval ysval scale X xtval ytval translate X /submonth 0 def X calendar X month 1 sub 0 eq X { X /lmonth 12 def X /lyear year 1 sub def X } X { X /lmonth month 1 sub def X /lyear year def X } ifelse X month 1 add 13 eq X { X /nmonth 1 def X /nyear year 1 add def X } X { X /nmonth month 1 add def X /nyear year def X } ifelse X /savemonth month def X /saveyear year def X /submonth 1 def X /savedatefontsize datefontsize def X /year lyear def X /month lmonth def X /datefontsize 48 def X gsave X 500 -365 translate X gsave X .138 .138 scale X 10 -120 translate X calendar X grestore X /submonth 1 def X /year nyear def X /month nmonth def X 100 0 translate X gsave X .138 .138 scale X 10 -120 translate X calendar X grestore X /month savemonth def X /year saveyear def X /submonth 0 def X /datefontsize savedatefontsize def X grestore } def X % Moon functions... X /doy { % year month day doy -- returns the number of the day of the year X /theday exch def X /themonth exch def X /theyear exch def X /dayofyear 0 def X themonth 1 ne { X 1 1 themonth .5 sub { X /mo exch cvi def X /dayofyear theyear mo X ndays_2 X dayofyear add X def X } for X } if X dayofyear theday add } def X /findphase { % Find the difference between any day and the reference day of the full moon % Note: will probably be one off if the reference is a leap year X /thisday exch def X /thismonth exch def X /thisyear exch def X /daysdiff thisyear thismonth thisday doy X fullyear fullmonth fullday doy sub X longer mul def % try to be accurate about it X /yearsdiff thisyear fullyear sub def X yearsdiff 0 ne { X /daysdiff daysdiff yearsdiff daysperyear mul X yearsdiff 100 idiv yearsdiff 400 idiv sub sub add def X } if X daysdiff % return difference in days } def X /shrink { X 2 sqrt div } def X /transmogrify { % Take a real number and 'mod it down' so it is in the range 0->period or % -period->0. The 10000's preserve the accuracy. X 10000 mul cvi X period 10000 mul cvi mod 10000 div } def X /domoon { % draw the moon at the current phase X /phase exch def X X 0 0 radius % might as well push these on now X 0 0 radius X phase halfperiod lt { X 270 90 arc stroke % line on right, fill on left X 0 radius neg moveto X 270 90 arcn X } X { X 90 270 arc stroke % line on left, fill on right X 0 radius neg moveto X 270 90 arc X /phase phase halfperiod sub def % get rid of top halfperiod X } ifelse X X % scale it down to -r(root2) -> r(root2) X /phase phase quartperiod sub rect mul def X X phase % x1 X phase abs shrink % y1 need abs! X phase % x2 X phase abs shrink neg % y2 need abs! X 0 % x3 X radius neg % y3 X curveto X fill } def X /do-moon-p { X draw-moons true eq { X true X } X { X draw-moons (some) eq { X /p startphase day longer mul add X % AWR: tweaked to more accurately select date of X % new/half/full moons -- X % transmogrify neg period add X 0.5 sub transmogrify neg period add def X p 0.00 gt p 1.00 lt and X p 7.38 gt p 8.38 lt and or X p 14.76 gt p 15.76 lt and X p 22.15 gt p 23.15 lt and or X or X } X { X false X } ifelse X } ifelse } def X X /shiftdo { X do-moon-p { X /p startphase day longer mul add transmogrify neg period add def X p domoon X } if } def X X /drawmoons { X % The year/month/day combo below is that of a full moon. Any date of a X % full moon should work, but I haven't tried very many. I wouldn't X % make this reference date fall in a leap year, because wierdness will X % probably happen in findphase. You will probably gain or lose a day X % somewhere. -- MBH X /fullyear 1990 def X /fullmonth 2 def X /fullday 9 def X X /period 29.5306 def X /daysperyear 365.2422 def X /longer daysperyear 365 div def X /halfperiod period 2 div def X /quartperiod period 4 div def X /radius 6 def X /rect radius 2 sqrt mul quartperiod div def X /startphase year month 0 findphase transmogrify dup 0 lt { X period add X } if def X /start startday def X /days year month ndays_2 def X X gsave X 0.1 setlinewidth X newpath X daywidth radius sub 3 sub 35 radius 3 add sub translate X start daywidth mul 0 translate X 1 1 days { X /day exch def X shiftdo X day start add 1 sub 7 mod 6 eq { X daywidth 6 mul neg dayheight neg translate X } X { X daywidth 0 translate X } ifelse X } for X grestore } def SHAR_EOF chmod 0644 pcalinit.ps || echo 'restore of pcalinit.ps failed' Wc_c="`wc -c < 'pcalinit.ps'`" test 12028 -eq "$Wc_c" || echo 'pcalinit.ps: original size 12028, current size' "$Wc_c" fi true || echo 'restore of pcallang.h failed' echo End of part 1, continue with part 2 exit 0