Pcal v4.0, part 3 of 5
joseph.a.brownlee
jbr0 at cbnews.att.com
Thu Mar 14 22:49:49 AEST 1991
#!/bin/sh
# This is part 03 of a multipart archive
# ============= 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 ]
[
.B \-O
] [
.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 \-B
] [
.B \-w
] [
.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
For whole-year calendars (i.e. the
.B \-w
option is given), the command line arguments are interpreted somewhat
differently. By default, all months in the current year are printed, starting
with January. If the
.B month
argument alone is given, it is expected to be the desired
.B year
to print, and prints all of the months in the given year. If both
.BR month " and " year
are given, then 12 consecutive months are printed starting at the given
month and year. If the
.BR month ", " year ", and " nmonths
arguments are all present, printing begins with the given month and year and
.B nmonths
months are printed, rounded up to the nearest multiple of 12.
.PP
.B The Date File
.PP
By default,
.I pcal
simply prints an empty calendar. Its real power is in its ability to place
``events'' in appropriate days on the calendar, thus allowing the user to
create personalized calendars. This is achieved through the use of the
``date file''.
.PP
The date file is named
.IR \.calendar " (" pcal.dat
under MS-DOS),
or
.I calendar
for compatibility with older versions.
.I Pcal
will look in several places for such a file. First, if a file called
.I \.calendar
exists in the caller's home directory, it is used. Next, if such a file exists
in the directory indicated by
environment variable
.BR PCAL_DIR
(or the current directory if no such variable is defined), it is used.
Finally, the directory where the
.I pcal
executable resides will be checked. If no date file is found, an empty
calendar is printed.
.PP
If a date file is found, 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_name> := first 3+ characters of name of month, or ``all''
X <month_spec> := <month_name>, or ``year''
X <day_spec> := first 3+ characters of name of weekday, ``day'',
X ``weekday'', ``workday'', ``holiday'', ``nonweekday'',
X ``nonworkday'', or ``nonholiday''
X <ordinal> := any ordinal number (``1st'', ``2nd'', etc.), ``first'' ... ``fifth'',
X ``last'', ``odd'', ``even'', 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> := a numeric month (1-12)
X <day> := day of month (1-31)
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_name> <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_name> | <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
X even Fridays in year Pay Day
X 183rd day of year mid-year
.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 important notes on using these keywords.
.PP
Ordinal day numbers may be used to specify dates, either relative to the
month or to the year. Either words or numeric abbreviations may be used for
``first'' through ``fifth''; higher numbers must be given using the
numeric equivalent (e.g. 100th). Negative ordinal numbers may even be used.
For example, ``\-2nd'' means ``next to last''.
.PP
``Odd'' and ``even'' do not refer to the actual date; instead, ``odd''
means ``alternate, starting with the first'', and ``even'' means ``alternate,
starting with the second''. Thus, ``odd Fridays in March'' refers to
the first, third, and (if present) fifth Fridays in March - not to
those Fridays falling on odd dates.
.PP
``All'' refers to each individual month; ``year'' refers to the year
as an entity. Thus ``odd Fridays in all'' refers to the first, third, and fifth
Friday of each month, while ``odd Fridays in year'' refers to
the first Friday of January and every other Friday thereafter.
.PP
Text in the date file may use C-like escape sequences (i.e. a `\\' followed by
a character, 1 \- 3 octal digits, or `x' followed by 1 \- 2 hexadecimal digits).
Escaped whitespace (including
.B newline
) and the standard ANSI character escapes (`\\a', `\\b', `\\f', `\\n', `\\r',
`\\t', `\\v') are all replaced by a single blank.
.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
.IR 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
.BR false "; an"
.BR ifndef
alone is always
.BR 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
In addition to pre-processing keywords,
.I pcal
also accepts boolean expressions in
.B if{n}def
directives. These expressions consist of symbol names joined by the boolean
operators
.BR ! ", " & ", " ^ ", and "
.BR | ,
in order of precedence, high to low. Parentheses may be used to alter the
precedence. The synonyms
.BR && " and " ||
are accepted for
.BR & " and " | .
A symbol name evaluates to
.B true
if currently defined,
.B false
if not; thus:
.PP
.ft CW
.nf
X ifdef A | B | C
.fi
.ft
.PP
\&...is
.B true
if any of the symbols A, B, and C is defined, and:
.PP
.ft CW
.nf
X ifdef A & B & C
.fi
.ft
.PP
\&...is
.B true
if they all are. Note that
.B ifndef <expr>
is equivalent to
.B ifdef !( <expr> ).
.PP
.B The Moon File
.PP
If a file of the name
.IR .moonXX " (" moonXX.dat
under MS-DOS),
where
.B XX
is the last two digits of the calendar year, exists in the same directory
as the date file,
.I pcal
uses the information contained within to calculate the phase of the
moon. If no such file exists,
.I pcal
uses an approximate algorithm.
.PP
Entries in the moon file must conform to the following syntax:
.PP
If the
.B \-A
option (American date formats, the default) is given:
.PP
.ft CW
.nf
X <quarter> <month><sep><day> {<hour><sep><min>}
.fi
.ft
.PP
If the
.B \-E
option (European date formats) is given:
.PP
.ft CW
.nf
X <quarter> <day><sep><month> {<hour><sep><min>}
.fi
.ft
.PP
Where:
.PP
.nf
X <quarter> := ``nm'', ``fq'' or ``1q'', ``fm'', ``3q'' or ``lq'' (new moon,
X first quarter, full moon, last quarter)
X <hour> := number 0-23 (24-hour clock)
X <min> := number 0-59
.fi
.PP
This file must contain entries for all quarter moons in the year,
in chronological order; if any errors are encountered,
.I pcal
will revert to using its default algorithm.
.PP
As in the date file, comments start with '#' and run through
end-of-line.
.PP
.B Options
.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 \-O
Causes pcal to print ``gray'' dates as outlined characters.
.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
.BI \-B
Causes pcal to leave unused calendar boxes blank (default is gray).
.TP
.BI \-w
Causes pcal to print a calendar for 12 consecutive months: 3 rows / 4
columns in landscape mode, 4 rows / 3 columns in portrait mode. See the
CAVEATS section for details on the use of this option with other options.
.TP
.B \-I
Resets all parameters to the program defaults.
.TP
.B \-h
Causes
.I pcal
to write version information and a usage message (to stdout) 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 "\-\|\-" " as per"
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
.ne 7
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 achieve the desired effect.
.PP
When the
.B \-w
and
.B \-p
options are used together,
.I pcal
revises the y-scale factor in order to use the entire portrait page; therefore,
the user should avoid using use the
.B \-y
option when using both the
.B \-w
and
.B \-p
options. Use of the
.B \-w
option in any case effectively disables the
.BR \-m ", " \-M ", " \-j ", and "
.B \-J
options.
.SH SEE ALSO
cal(1)
.SH AUTHORS
The original PostScript code to generate the calendars was written by
Patrick Wood (Copyright (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 whose 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,
Jamie Zawinski, Bill Hogsett, and Floyd Miller.
SHAR_EOF
chmod 0644 pcal.man ||
echo 'restore of pcal.man failed'
Wc_c="`wc -c < 'pcal.man'`"
test 17774 -eq "$Wc_c" ||
echo 'pcal.man: original size 17774, current size' "$Wc_c"
fi
# ============= pcal.tex ==============
if test -f 'pcal.tex' -a X"$1" != X"-c"; then
echo 'x - skipping pcal.tex (File already exists)'
else
echo 'x - extracting pcal.tex (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'pcal.tex' &&
% -*-LaTeX-*-
% Converted automatically from troff to LaTeX by tr2tex on Fri Mar 1 21:59:54 1991
% tr2tex was written by Kamal Al-Yahya at Stanford University
% (Kamal%Hanauma at SU-SCORE.ARPA)
X
\documentstyle[troffman]{article}
\begin{document}
%
% input file: pcal.man
%
\phead{PCAL}{1}{}
X
\shead{NAME}
pcal -- generate PostScript calendars
X
\shead{SYNOPSIS}
{\bf pcal}{\rm \ [} {\bf --e}{\rm \ $|$\ }{\bf --f} {\it cal} ] [ {\bf
--o}{\it \ file} ] [ {\bf --j}{\rm \ $|$\ }{\bf --J} ] [ {\bf --l}{\rm \
$|$\ }{\bf --p} ] [ {\bf --m}{\rm \ $|$\ }{\bf --M} ] [ {\bf --b}{\it \
day} $|$ all ] [ {\bf --g}{\it \ day} $|$ all ]\hfil\break
[ {\bf --O} ] [ {\bf --F}{\it \ day} ] [ {\bf --A}{\rm \ $|$\ }{\bf --E}
] [ {\bf --t}{\it \ title\_font} ] [ {\bf --d}{\it \ day\_font} ] [ {\bf
--n}{\it \ text\_font} ] [ {\bf --L}{\it \ footer\_string} ]\hfil\break
[ {\bf --C}{\it \ footer\_string} ] [ {\bf --R}{\it \ footer\_string} ] [
{\bf --D}{\it \ symbol} ] [ {\bf --U}{\it \ symbol} ] [ {\bf --x}{\it \
xscale} ] [ {\bf --y}{\it \ yscale} ]\hfil\break
[ {\bf --X}{\it \ xtrans} ] [ {\bf --Y}{\it \ ytrans} ] [ {\bf --I} ] [
{\bf --B} ] [ {\bf --w} ] [ {\bf --h} ]\hfil\break
[ {\bf month} ] [ {\bf year} ] [ {\bf nmonths} ]
X
\shead{DESCRIPTION}
{\it Pcal} generates PostScript to produce landscape or portrait
calendars for any month and year. The arguments {\bf month}{\rm ,} {\bf
year}{\rm ,} and {\bf nmonths}{\rm ,} if provided, should be numeric.
The {\bf month} value should be in the range 1 -- 12, and the {\bf 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.
\vskip\baselineskip
X
If one numeric argument is provided, it is interpreted as the {\bf year}
value, and calendars for the entire year will be generated. Otherwise,
{\bf nmonth} months, starting with {\bf month} and {\bf year}{\rm ,} will
be generated.
\vskip\baselineskip
X
For whole-year calendars ({\it i.e.}, the {\bf --w} option is given), the
command line arguments are interpreted somewhat differently. By default,
all months in the current year are printed, starting with January. If
the {\bf month} argument alone is given, it is expected to be the desired
{\bf year} to print, and prints all of the months in the given year. If
both {\bf month}{\rm \ and\ }{\bf year} are given, then 12 consecutive
months are printed starting at the given month and year. If the {\bf
month}{\rm ,\ }{\bf year}{\rm ,\ and\ }{\bf nmonths} arguments are all
present, printing begins with the given month and year and {\bf nmonths}
months are printed, rounded up to the nearest multiple of 12.
\vskip\baselineskip
X
{\bf The Date File}
\vskip\baselineskip
X
By default, {\it pcal} simply prints an empty calendar. Its real power
is in its ability to place ``events'' in appropriate days on the
calendar, thus allowing the user to create personalized calendars. This
is achieved through the use of the ``date file''.
\vskip\baselineskip
X
The date file is named {\it .calendar} (or {\it calendar} for
compatibility with older versions). {\it Pcal} will look in several
places for such a file. First, if a file called {\it .calendar} exists
in the caller's home directory, it is used. Next, if such a file exists
in the directory indicated by environment variable {\bf PCAL\_DIR} (or
the current directory if no such variable is defined), it is used.
Finally, the directory where the {\it pcal} executable resides will be
checked. If no date file is found, an empty calendar is printed.
\vskip\baselineskip
X
If a date file is found, 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 {\it .calendar} file may be expressed in any of
several formats:
X
{\tt
\nofill
X $<$ordinal$>$ $<$day\_spec$>$ in $<$month\_spec$>$\{$\ast$\} \{$<$text$>$\}
X $<$day\_spec$>$ $<$prep$>$ $<$date\_spec$>$\{$\ast$\} \{$<$text$>$\}
X $<$date\_spec$>$\{$\ast$\} \{$<$text$>$\}
\fill}
Where:
{\tt
\nofill
X $<$month\_name$>$ := first 3+ characters of name of month, or "all"
X $<$month\_spec$>$ := $<$month\_name$>$, or "year"
X $<$day\_spec$>$ := first 3+ characters of name of weekday, "day",
X "weekday", "workday", "holiday", "nonweekday",
X "nonworkday", or "nonholiday"
X $<$ordinal$>$ := any ordinal number ("1st", "2nd", {\it etc}.),
X "first" $\ldots$ "fifth", "last", "odd",
X "even", 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-`$\ast$' characters
X $<$month$>$ := a numeric month (1-12)
X $<$day$>$ := day of month (1-31)
X $<$year$>$ := a numeric year
\fill}
X
If the {\bf --A} option (American date formats, the default) is given:
{\tt
\nofill
X $<$date\_spec$>$ := [ $<$month\_name$>$ $<$day$>$ $|$ $<$month$>$$<$sep$>$$<$day$>$\{$<$sep$>$$<$year$>$\} ]
\fill}
X
If the {\bf --E} option (European date formats) is given:
{\tt
\nofill
X $<$date\_spec$>$ := [ $<$day$>$ $<$month\_name$>$ $|$ $<$day$>$$<$sep$>$$<$month$>$\{$<$sep$>$$<$year$>$\} ]
\fill}
X
Examples:
{\tt
\nofill
X last Monday in May$\ast$ Memorial Day Holiday
\vskip\baselineskip
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
X even Fridays in year Pay Day
X 183rd day of year mid-year
\vskip\baselineskip
X Tue after first Mon in Nov Election Day (USA)
\vskip\baselineskip
X 4th Thu in Nov$\ast$ Thanksgiving
X Fri after 4th Thu in Nov$\ast$ Day after Thanksgiving
\vskip\baselineskip
X 12/25/90$\ast$ Christmas \# American
X 25.12.90$\ast$ Christmas \# European
\vskip\baselineskip
X Dec 25$\ast$ Christmas \# American
X 25 Dec$\ast$ Christmas \# European
\fill}
X
Any non-numeric character may separate numeric dates. Holidays may be
flagged by following the date immediately with `$\ast$' 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.
\vskip\baselineskip
X
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 {\bf CAVEATS} below for
important notes on using these keywords.
\vskip\baselineskip
X
Ordinal day numbers may be used to specify dates, either relative to the
month or to the year. Either words or numeric abbreviations may be used
for ``first'' through ``fifth''; higher numbers must be given using the
numeric equivalent (e.g. 100th). Negative ordinal numbers may even be
used. For example, ``--2nd'' means ``next to last''.
\vskip\baselineskip
X
``Odd'' and ``even'' do not refer to the actual date; instead, ``odd''
means ``alternate, starting with the first'', and ``even'' means
``alternate, starting with the second''. Thus, ``odd Fridays in March''
refers to the first, third, and (if present) fifth Fridays in March - not
to those Fridays falling on odd dates.
\vskip\baselineskip
X
``All'' refers to each individual month; ``year'' refers to the year as
an entity. Thus ``odd Fridays in all'' refers to the first, third, and
fifth Friday of each month, while ``odd Fridays in year'' refers to the
first Friday of January and every other Friday thereafter.
\vskip\baselineskip
X
Text in the date file may use C-like escape sequences ({\it i.e.}, a `\bs
' followed by a character, 1 -- 3 octal digits, or `x' followed by 1 -- 2
hexadecimal digits). Escaped whitespace (including {\bf newline} ) and
the standard ANSI character escapes (`\bs a', `\bs b', `\bs f', `\bs n',
`\bs r', `\bs t', `\bs v') are all replaced by a single blank.
\vskip\baselineskip
X
Lines in the {\it .calendar} file consisting of {\bf year} XXXX (where
XXXXX 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.
\vskip\baselineskip
X
Lines in the {\it .calendar} file consisting of {\bf opt} $<$options$>$
can be used to override the defaults for any command-line options except
{\bf --e}{\rm ,} {\bf --f}{\rm ,} {\bf --h}{\rm ,} {\bf --D}{\rm ,\ and}
{\bf --U}{\rm .} Any options specified in this manner are, in turn,
overridden by those specified explicitly on the command line.
\vskip\baselineskip
X
Lines in the {\it .calendar} file consisting of {\bf note} $<$month$>$
can be used to place notes regarding the entire month is one of the
unused blocks of the calendar. The {\bf $<$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.
\vskip\baselineskip
X
Comments are supported in the {\it .calendar} file. Any characters
following a `\#' character through the end of the line are ignored.
\vskip\baselineskip
X
{\it Pcal} supports rudimentary {\it cpp}{\rm -like} functionality in the
date file, allowing the following constructs: {\bf define\ $|$\
undef}{\rm ,} {\bf if\{n\}def $\ldots$ \{else $\ldots$\} endif}, and {\bf
include}{\rm .} Note that these are not preceded by `\#' as they are in
C. Symbol names defined using these keywords (or via the {\bf -D}
option) are case-insensitive. It is not an error to {\bf undef} an
undefined symbol, nor to {\bf define} a previously-defined one. An {\bf
ifdef} alone is always {\bf false}{\rm ;\ an} {\bf ifndef} alone is
always {\bf true}{\rm .}
\vskip\baselineskip
X
The name of the file in the {\bf 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. {\it Pcal} is smart
enough to translate {\bf \~{}/} to the user's home directory.
\vskip\baselineskip
X
In addition to pre-processing keywords, {\it pcal} also accepts boolean
expressions in {\bf if\{n}\}def directives. These expressions consist of
symbol names joined by the boolean operators {\bf !}{\rm ,\ }{\bf \&}{\rm
,\ }{\bf \^{}}{\rm ,\ and\ } {\bf $|$}{\rm ,} in order of precedence,
high to low. Parentheses may be used to alter the precedence. The
synonyms {\bf \&\&}{\rm \ and\ }{\bf $|$$|$} are accepted for {\bf
\&}{\rm \ and\ }{\bf $|$}{\rm .} A symbol name evaluates to {\bf true} if
currently defined, {\bf false} if not; thus:
{\tt
\nofill
X ifdef A $|$ B $|$ C
\fill}
X
$\ldots$ is {\bf true} if any of the symbols A, B, and C is defined, and:
{\tt
\nofill
X ifdef A \& B \& C
\fill}
X
$\ldots$ is {\bf true} if they all are. Note that {\bf ifndef} $<$expr$>$ is
equivalent to {\bf ifdef} !( $<$expr$>$ ).
\vskip\baselineskip
X
{\bf The Moon File}
\vskip\baselineskip
X
If a file of the name {\it .moonXX} (where {\it XX} is the last two
digits of the calendar year) exists in the same directory as the date
file, {\it pcal} uses the information contained within to calculate the
phase of the moon. If no such file exists, {\it pcal} uses an
approximate algorithm.
\vskip\baselineskip
X
Entries in the moon file must conform to the following syntax; If the
{\bf --A} option (American date formats, the default) is given:
{\tt
\nofill
X $<$quarter$>$ $<$month$>$$<$sep$>$$<$day$>$ \{$<$hour$>$$<$sep$>$$<$min$>$\}
\fill}
X
If the {\bf --E} option (European date formats) is given:
{\tt
\nofill
X $<$quarter$>$ $<$day$>$$<$sep$>$$<$month$>$ \{$<$hour$>$$<$sep$>$$<$min$>$\}
\fill}
X
Where:
{\tt
\nofill
X $<$quarter$>$ := "nm", "fq" or "1q", "fm", "3q" or "lq"
X (new moon, first quarter, full moon, last quarter)
X $<$hour$>$ := number 0-23 (24-hour clock)
X $<$min$>$ := number 0-59
\fill}
X
This file must contain entries for all quarter moons in the year, in
chronological order; if any errors are encountered, {\it pcal} will
revert to using its default algorithm. As in the date file, comments
start with '\#' and run through end-of-line.
\vskip\baselineskip
X
{\bf Options}
\vskip\baselineskip
X
{\it Pcal} has many options:
X
\begin{TPlist}{{\bf --e}}
\item[{{\bf --e}}] Prints an empty calendar. Do not print entries from a
X {\it .calendar} file.
\item[{{\bf --f}{\it \ cal}}] Directs {\it pcal} to use the file name
X {\it cal} as the input file in place of the default {\it .calendar}
X file in the user's home directory (or the directory pointed to by
X {\bf PCAL\_DIR}{\rm ).}
\item[{{\bf --o}{\it \ file} }] Directs {\it pcal} to write the output to
X {\it file} instead of to stdout.
\item[{{\bf --l}}] Causes the output to be in landscape mode (default).
X This also resets the x- and y-axis scaling and translation factors to
X the defaults for landscape mode.
\item[{{\bf --p}}] Causes the output to be in portrait mode. This also
X resets the x- and y-axis scaling and translation factors to the
X defaults for portrait mode.
\item[{{\bf --j}}] Causes the Julian date (day of year) to be printed in
X each calendar box.
\item[{{\bf --J}}] Causes the Julian date and the number of days
X remaining in the year to be printed in each calendar box.
\item[{{\bf --m}}] Causes moon icons to be printed on dates corresponding
X to new, half, and full moons (the default is that no moons are
X printed).
\item[{{\bf --M}}] Causes moon icons to be printed on all dates (the
X default is that no moons are printed).
\item[{{\bf --b}{\it \ day}{\bf \ $|$\ all} }] Causes all dates falling
X on weekday {\it day} to be printed in black; {\bf --b} all causes
X all weekdays to be printed in black.
\item[{{\bf --g}{\it \ day}{\bf \ $|$\ all} }] Causes all dates falling
X on weekday {\it day} to be printed in gray; {\bf --g} all causes all
X weekdays to be printed in gray.
X \begin{itemize}
X \item[{}] The default for the {\bf --b}{\rm \ and\ }{\bf --g} options is
X to print Saturdays and Sundays in gray and other days, unless flagged
X as holidays, in black.
X \end{itemize}
\item[{{\bf --O} }] Causes pcal to print ``gray'' dates as outlined
X characters.
\item[{{\bf --F}{\it \ day} }] Selects weekday {\it day} as the first day
X of the week. The given day will appear in the left-most column of
X the calendar.
\item[{{\bf --A}}] Directs {\it pcal} to use American date conventions
X {\bf mm/dd\{/yy}\} and {\bf month} dd ) when parsing the date file
X (default).
\item[{{\bf --E}}] Directs {\it pcal} to use European date conventions
X {\bf dd/mm\{/yy}\} and {\bf dd} month ) when parsing the date file.
\item[{{\bf --X}{\it \ xtrans} }] Specifies the x-axis translation value
X for positioning the output on the page.
\item[{{\bf --Y}{\it \ ytrans} }] Specifies the y-axis translation value
X for positioning the output on the page.
\item[{{\bf --x}{\it \ xscale} }] Specifies the x-axis scaling factor for
X the calendar size.
\item[{{\bf --y}{\it \ yscale} }] Specifies the y-axis scaling factor for
X the calendar size.
\item[{{\bf --t}{\it \ title\_font} }] Specifies the name of a font to
X use to print the month name and year at the top of the calendar. For
X example, {\bf pcal\ --t\ Times-Roman}{\rm .}
\item[{{\bf --d}{\it \ day\_font} }] Similar to the {\bf --t} option, but
X selects the font used to print the day numbers.
\item[{{\bf --n}{\it \ text\_font} }] Similar to the {\bf --t} option,
X but selects the font used to print the text inside each day and in
X the notes block.
\item[{{\bf --D}{\it \ symbol} }] Defines the named symbol prior to
X reading the date file.
\item[{{\bf --U}{\it \ symbol} }] Un-defines the named symbol prior to
X reading the date file.
\item[{{\bf --L}{\it \ string} }] Causes the accompanying string to be
X printed as a left-justified footer.
\item[{{\bf --C}{\it \ string} }] Causes the accompanying string to be
X printed as a centered footer.
\item[{{\bf --R}{\it \ string} }] Causes the accompanying string to be
X printed as a right-justified footer.
\item[{{\bf --B} }] Causes pcal to leave unused calendar boxes blank
X (default is gray).
\item[{{\bf --w} }] Causes pcal to print a calendar for 12 consecutive
X months: 3 rows / 4 columns in landscape mode, 4 rows / 3 columns in
X portrait mode. See the CAVEATS section for details on the use of
X this option with other options.
\item[{{\bf --I}}] Resets all parameters to the program defaults.
\item[{{\bf --h}}] Causes {\it pcal} to write version information and a
X usage message (to stdout) and terminate.
\end{TPlist}
X
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 {\bf --D} option alone clears all the defined symbols, the {\bf
--U} option alone has no effect. The {\bf --} (or {\bf --\,--}{\rm \ as\
per} System V) argument may be used to disambiguate command lines such
as:
\begin{itemize}
\item[{}] {\bf pcal} --t 9 90
\end{itemize}
This could be written instead as one of the following:
\begin{itemize}
\item[{}] {\bf pcal} --t -- 9 90 \nwl {\bf pcal} --t --\,-- 9 90
\end{itemize}
X
If the environment variable {\bf PCAL\_OPTS} is defined, its contents are
parsed as a command line. Flags set via {\bf PCAL\_OPTS} override the
program defaults, but are overridden by options set via {\bf opt} lines
in the {\it .calendar} file or explicitly on the command line.
X
\shead{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:
X
{\tt\vbox{
\nofill
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
\fill}}
X
If the {\it .calendar} file looked like this:
{\tt
\nofill
X workday on\_or\_before all 15 payday
X 3rd Mon in Jan$\ast$ MLK day
\fill}
X
then {\it pcal} would mark the 15th as ``payday'' since at that point in
the {\it .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 {\it 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 achieve the desired effect.
\vskip\baselineskip
X
When the {\bf --w} and {\bf --p} options are used together, {\it pcal}
revises the y-scale factor in order to use the entire portrait page;
therefore, the user should avoid using use the {\bf --y} option when
using both the {\bf --w} and {\bf --p} options. Use of the {\bf --w}
option in any case effectively disables the {\bf --m}{\rm ,\ }{\bf
--M}{\rm ,\ }{\bf --j}{\rm ,\ and\ } {\bf --J} options.
X
\shead{SEE ALSO}
cal(1)
X
\shead{AUTHORS}
The original PostScript code to generate the calendars was written by
Patrick Wood (\copyright 1987 by Patrick Wood of Pipeline Associates,
Inc.), and authorized for modification and redistribution. The calendar
file inclusion code was originally written in {\it bs}{\rm (1)} by Bill
Vogel of AT\&T. Patrick's original PostScript was modified and enhanced
several times by others whose 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, Jamie Zawinski, Bill Hogsett, and Floyd Miller.
X
\end{document}
SHAR_EOF
chmod 0644 pcal.tex ||
echo 'restore of pcal.tex failed'
Wc_c="`wc -c < 'pcal.tex'`"
test 20982 -eq "$Wc_c" ||
echo 'pcal.tex: original size 20982, 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 * 4.0 AWR 03/01/91 Add STDLIB macro for systems which
X * support <stdlib.h>
X *
X * AWR 02/22/91 add definitions for MS-DOS support (as
X * per Floyd Miller)
X *
X * AWR 02/19/91 revise ORD_XXX to support negative
X * ordinals
X *
X * add definitions for Amiga support (as
X * per Bill Hogsett)
X *
X * AWR 02/06/91 additional defs for expression
X * processing
X *
X * AWR 02/04/91 support "year" as additional month
X * name; use negative numbers for
X * special ordinal codes (reserve
X * positive numbers for ordinals)
X *
X * 01/28/91 miscellaneous new constants/macros
X *
X * 01/07/91 add FEB_29_OK (cf. enter_day_info())
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 MOONFILE "moonXX.dat" /* 'XX' replaced with year */
#define DEFAULT_OUTFILE "calendar.ps"
#define START_PATH '['
#define END_PATH ']'
X
#define EXIT_SUCCESS 1 /* VMS exit() parameters */
#define EXIT_FAILURE 3
X
#else
#ifdef AMIGA /* more oddities for Amiga */
X
#include <string.h>
X
#define PROTOS /* compiler accepts prototypes */
#define STDLIB /* system has <stdlib.h> */
#define HOME_DIR "RAM:"
#define DATEFILE "s:calendar.dat"
#define MOONFILE "s:.moonXX" /* 'XX' replaced with year */
#define DEFAULT_OUTFILE "RAM:calendar.ps"
#define START_PATH '/'
#define END_PATH '/'
X
#else
#ifdef DOS /* even more oddities for MS-DOS */
X
#define DATEFILE "pcal.dat"
#define MOONFILE "moonXX.dat" /* 'XX' replaced with year */
#define START_PATH '\\'
#define END_PATH '\\'
#define HOME_DIR "HOME"
#define ALT_DATEFILE "calendar" /* for backward compatibility */
X
#else /* neither VMS, Amiga, nor MS-DOS - assume Un*x */
X
#define UNIXX /* to distinguish from others (not used yet) */
X
#define HOME_DIR "HOME"
#define DATEFILE ".calendar"
#define ALT_DATEFILE "calendar" /* for backward compatibility */
#define MOONFILE ".moonXX" /* 'XX' replaced with year */
#define ALT_MOONFILE "moonXX" /* analogous to ALT_DATEFILE */
#define START_PATH '/'
#define END_PATH '/'
X
#endif
#endif
#endif
X
/* define OUTFILE to DEFAULT_OUTFILE if defined, otherwise to "" (stdout) */
X
#ifdef DEFAULT_OUTFILE
#define OUTFILE DEFAULT_OUTFILE
#else
#define OUTFILE ""
#endif
X
/* PROTOS may be defined independently of __STDC__ for compilers which
X * support function prototypes but are not fully ANSI-compliant
X */
X
#if defined(__STDC__) && ! defined(PROTOS)
#define PROTOS
#endif
X
/* STDLIB may be defined independently of __STDC__ for systems which
X * support <stdlib.h> but are not fully ANSI-compliant
X */
X
#if defined(__STDC__) && ! defined(STDLIB)
#define STDLIB /* cf. {no}protos.h */
#endif
X
#ifdef STDLIB /* include <stdlib.h> if known to exist */
#include <stdlib.h>
#endif
X
/* EXIT_SUCCESS and EXIT_FAILURE should be defined in <stdlib.h>
X * (or above if non-standard); define here if necessary
X */
X
#ifndef EXIT_SUCCESS
#define EXIT_SUCCESS 0
#endif
#ifndef EXIT_FAILURE
#define EXIT_FAILURE 1
#endif
X
/* definition of NULL (if needed) */
X
#ifndef NULL
#define NULL 0
#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) \
X PRT((_c) == ' ' || isalnum(_c) ? "%c" : "\\%03o" , (_c) & 0377)
#define PUTSTR(_s) \
X if (1) { char *_p; for (_p = _s; *_p; _p++) PUTCHAR(*_p); } else
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 YEAR_LEN(y) (IS_LEAP(y) ? 366 : 365)
#define DAY_OF_YEAR(m, d, y) ((month_off[(m)-1] + ((m) > FEB && IS_LEAP(y))) + d)
#define OFFSET_OF(m, y) ((month_off[(m)-1] + ((m) > FEB && IS_LEAP(y))) % 7)
#define FIRST_OF(m, y) calc_weekday(m, 1, y)
X
#define PREV_MONTH(m, y) ((m) == JAN ? DEC : (m) - 1)
#define PREV_YEAR(m, y) ((m) == JAN ? (y) - 1 : (y))
#define NEXT_MONTH(m, y) ((m) == DEC ? JAN : (m) + 1)
#define NEXT_YEAR(m, y) ((m) == DEC ? (y) + 1 : (y))
X
#define INIT_COLORS memcpy(day_color, default_color, sizeof(day_color))
X
#define P_LASTCHAR(p) ((p) && *(p) ? (p) + strlen(p) - 1 : NULL)
#define LASTCHAR(p) (p)[strlen(p) - 1]
X
#define IS_NUMERIC(p) ((p)[strspn((p), DIGITS)] == '\0')
#define IS_WILD(w) ((w) >= WILD_FIRST && (w) <= WILD_LAST)
X
#define MAKE_DATE(dt, m, d, y) \
X if (1) { (dt).mm = m; (dt).dd = d; (dt).yy = y; } else
X
#define ERR(errmsg) \
X FPR(stderr, E_ILL_LINE, progname, errmsg, filename, line);
X
#ifdef __STDC__
#define TOLOWER(c) tolower(c)
#else
#define TOLOWER(c) (isupper(c) ? tolower(c) : (c))
#endif
X
#ifndef isodigit /* rare */
#define isodigit(c) ((c) >= '0' && (c) <= '7')
#endif
#ifndef isxdigit /* ANSI standard */
#define isxdigit(c) \
X (isdigit(c) || ((c) >= 'a' && (c) <= 'f') || ((c) >= 'A' && (c) <= 'F'))
#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_NEGNUM -1 /* negative ordinal (-2nd == next to last) */
#define ORD_POSNUM 1 /* positive ordinal */
#define ORD_ODD 2 /* special codes for "odd" and "even" */
#define ORD_EVEN 3
#define ORD_ALL 4 /* special code for "all" used as ordinal */
#define ORD_OTHER 0 /* not ordinal token */
X
/* moon phase codes - cf. pcallang.h and moonphas.c */
X
#define MOON_NM 0 /* new moon */
#define MOON_1Q 1 /* first quarter */
#define MOON_FM 2 /* full moon */
#define MOON_3Q 3 /* last quarter */
#define MOON_OTHER -1 /* unrecognizable */
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
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 EXPR_ERR -1 /* expression parsing error */
X
#define MIN_YR 1900 /* significant years (calendar limits) */
#define MAX_YR 9999
X
#define CENTURY 1900 /* default century for two-digit years */
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 */
#define ENTIRE_YEAR 13 /* select entire year as one entity */
X
#define SUN 0 /* significant weekdays */
#define SAT 6
#define NOT_WEEKDAY -1 /* not valid weekday */
X
#define SCREENWIDTH 72 /* command-line message in usage() */
X
#define FEB_29_OK 1 /* if != 0, ignore 2/29 of common year */
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
/* scaling/translation factors based on 8.5 x 11 inch (612 x 792 point) page */
X
#define XSVAL_L "1" /* scale/translate values (landscape) */
#define YSVAL_L "1"
#define XTVAL_L "46" /* (792 - 700) / 2 = 46 */
#define YTVAL_L "-120"
#define XSVAL_P "0.773" /* scale/translate values (portrait) */
#define YSVAL_P "0.773" /* 612/792 */
#define XTVAL_P "46"
#define YTVAL_P "492" /* 612 - 120 = 492 */
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 }
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
/*
X * Global typedef declarations for data structure (cf. readfile.c)
X */
X
/*
X * The internal data structure consists of a series of linked lists as
X * pictured below (for clarity, only one instance of each node is shown):
X *
X *
X * head
X * |
X * | year_info
X * | ----------------- month_info
X * -->| year | ----------------- day_info
X * | month_info*[0] |----->| holidays | ----------------
X * | ... | | day_info*[0] |----->| is_holiday |
X * | month_info*[11] |---> | ... | | text_string* |--->
X * | next year_info* |-- | day_info*[30] |---> | next day_info* |--
X * ----------------- | | day_info*[NOTE] |---> ---------------- |
X * | ----------------- |
X * | |
X * ... <-- ... <--
X *
X *
X * Each year_info node consists of the year, 12 pointers (Jan .. Dec) to
X * month_info nodes, and a pointer to the next year_info node in the chain.
X * (The year_info chain is maintained in ascending order by year.)
X *
X * Each month_info node consists of a bitmap of the holidays for that month,
X * a pointer to the day_info chain for all 31 possible days of the month, and
X * an additional pointer to the day_info chain for the "Notes" pseudo-day.
X * (A day_info chain is a linked list of all the text entries for a given
X * day, in the order in which they were encountered in the date file.)
X *
X * Each day_info node consists of a flag indicating whether the associated
X * text string is holiday or non-holiday text (any given day may have both),
X * a pointer to the text string itself, and a pointer to the next day_info
X * node in the chain.
X *
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 value;
X } KWD_O; /* keyword plus ordinal value */
X
typedef struct {
X char *name;
X int code;
#ifdef PROTOS
X int (*pfcn)(char *);
#else
X int (*pfcn)();
#endif
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 14453 -eq "$Wc_c" ||
echo 'pcaldefs.h: original size 14453, current size' "$Wc_c"
fi
# ============= pcalglob.h ==============
if test -f 'pcalglob.h' -a X"$1" != X"-c"; then
echo 'x - skipping pcalglob.h (File already exists)'
else
echo 'x - extracting pcalglob.h (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'pcalglob.h' &&
/*
X * pcalglob.h - definitions and declarations of globals used throughout Pcal
X *
X * Revision history:
X *
X * 4.0 AWR 01/28/91 Added support for -b and -w flags
X *
X * 01/15/91 Extracted from pcal.c
X *
X */
X
#ifdef PROTOS
#include "protos.h"
#else
#include "noprotos.h"
#endif
X
/*
X * Definitions and/or declarations of globals
X */
X
#ifdef MAIN_MODULE
X
/*
X * Misc. globals
X */
X
year_info *head = NULL; /* head of internal data structure */
int curr_year; /* current default year for date file entries */
char *words[MAXWORD]; /* maximum number of words per date file line */
char lbuf[LINSIZ]; /* date file source line buffer */
char progname[STRSIZ]; /* program name (for error messages) */
char version[20]; /* program version (for info messages) */
X
/* lengths and offsets of months in common year */
char month_len[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
short month_off[12] = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};
X
#ifdef PROTOS
int (*pdatefcn[])(int, int, int) = {
#else
int (*pdatefcn[])() = {
#endif
X is_anyday, is_weekday, is_workday, is_holiday, not_weekday,
X not_workday, not_holiday };
X
/*
X * Default values for command-line options:
X */
X
char default_color[] = DAY_COLOR; /* -b, -g */
char day_color[7];
X
int datefile_type = SYS_DATEFILE; /* -e, -f */
char datefile[STRSIZ] = "";
X
int rotate = ROTATE; /* -l, -p */
X
int draw_moons = DRAW_MOONS; /* -m, -M */
X
char dayfont[STRSIZ] = DAYFONT; /* -d, -t, -n */
char titlefont[STRSIZ] = TITLEFONT;
char notesfont[STRSIZ] = NOTESFONT;
X
char lfoot[STRSIZ] = LFOOT; /* -L, -C, -R */
char cfoot[STRSIZ] = CFOOT;
char rfoot[STRSIZ] = RFOOT;
X
int first_day_of_week = FIRST_DAY; /* -F */
X
int date_style = DATE_STYLE; /* -A, -E */
X
char outfile[STRSIZ] = OUTFILE; /* -o */
X
char xsval[12] = XSVAL; /* -x, -y, -X, -Y */
char ysval[12] = YSVAL;
char xtval[12] = XTVAL;
char ytval[12] = YTVAL;
X
int julian_dates = JULIAN_DATES; /* -j */
X
int do_whole_year = FALSE; /* -w */
X
int blank_boxes = FALSE; /* -B */
X
int outline_nums = FALSE; /* -O */
X
#else
X
/*
X * Misc. globals
X */
X
extern year_info *head; /* head of internal data structure */
extern int curr_year; /* current default year for date file entries */
extern char *words[]; /* maximum number of words per date file line */
extern char lbuf[]; /* date file source line buffer */
extern char progname[]; /* program name (for error messages) */
extern char version[]; /* program version (for info messages) */
X
/* lengths and offsets of months in common year */
extern char month_len[];
extern short month_off[];
X
/* dispatch functions and table for wildcard processing */
extern int (*pdatefcn[])();
X
/*
X * Default values for command-line options:
X */
X
extern char default_color[]; /* -b, -g */
extern char day_color[];
X
extern int datefile_type; /* -e, -f */
extern char datefile[];
X
extern int rotate; /* -l, -p */
X
extern int draw_moons; /* -m, -M */
X
extern char dayfont[]; /* -d, -t, -n */
extern char titlefont[];
extern char notesfont[];
X
extern char lfoot[]; /* -L, -C, -R */
extern char cfoot[];
extern char rfoot[];
X
extern int first_day_of_week; /* -F */
X
extern int date_style; /* -A, -E */
X
extern char outfile[]; /* -o */
X
extern char xsval[]; /* -x, -y, -X, -Y */
extern char ysval[];
extern char xtval[];
extern char ytval[];
X
extern int julian_dates; /* -j */
X
extern int do_whole_year; /* -w */
X
extern int blank_boxes; /* -B */
X
extern int outline_nums; /* -O */
X
#endif
X
SHAR_EOF
chmod 0666 pcalglob.h ||
echo 'restore of pcalglob.h failed'
Wc_c="`wc -c < 'pcalglob.h'`"
test 3493 -eq "$Wc_c" ||
echo 'pcalglob.h: original size 3493, current size' "$Wc_c"
fi
true || echo 'restore of pcalinit.c failed'
echo End of part 3, continue with part 4
exit 0
More information about the Alt.sources
mailing list