home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Source Code 1992 March
/
Source_Code_CD-ROM_Walnut_Creek_March_1992.iso
/
usenet
/
altsrcs
/
3
/
3864
< prev
next >
Wrap
Internet Message Format
|
1991-08-22
|
60KB
Path: wupost!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!cbnews!jbr0
From: jbr0@cbnews.cb.att.com (joseph.a.brownlee)
Newsgroups: alt.sources
Subject: Pcal v4.1, part 4 of 6
Keywords: pcal calendar postscript
Message-ID: <1991Aug19.121750.863@cbnews.cb.att.com>
Date: 19 Aug 91 12:17:50 GMT
Followup-To: alt.sources.d
Organization: AT&T Bell Laboratories
Lines: 2275
#!/bin/sh
# This is part 04 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
] [
..B \-G
] [
..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
] [
..BR \-h " | " \-v
] [
..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
..I Pcal
also allows format specifiers in both the text and foot strings (see the
..BR \-L ,
..BR \-C ,
and
..B \-R
options below); each will be replaced by a corresponding
string as outlined in the table below. Most of these are derived from the
..ft CW
strftime()
..ft
function; the
..BR %l " and " %[o0+\-]
format specifiers are specific to
..IR pcal :
..PP
..nf
X %a abbreviated weekday
X %A full weekday
X %b abbreviated month name
X %B full month name
X %d day of month (1-31)
X %j day of year (1-366)
X %l days left in year (0-365)
X %m month (1-12)
X %U week number (0-53)
X %W week number (0-53)
X %y year w/o century (00-99)
X %Y year w/century
X %% `%' character
X
X %o print number as ordinal
X %0 print number with leading zeroes
X %+ use following month or year
X %\- use previous month or year
..fi
..PP
The
..B %U
format specifier considers the first logical Sunday (the first day
of the week as printed; see the
..B \-F
option below) of the year as the first day of week number 1; the
..B %W
specifier uses the first logical Monday instead. This is an
extension of the behavior of the
..ft CW
strftime()
..ft
function.
..PP
The
..B %o
format specifier prints a number as an ordinal, with the appropriate
suffix (``st'', ``nd'', ``rd'', or ``th'' in English) appended; for example,
..B %od
prints the day of the month as ``1st'', ``2nd'', ``3rd'', etc.
..PP
Unlike
..ft CW
strftime(),
..ft
..IR pcal 's
default is to print numbers (except
..BR %y )
without leading zeroes. If leading zeroes are desired, the `0'
prefix may be used; for example,
..B %0j
prints the day of year as 001-365.
..PP
The
..BR %+ " and " %\-
format specifiers direct
..I pcal
to substitute the following or previous month or year for the following
..B [bBmyY]
specifier; for example,
..B %+B
prints the name of the following month.
..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 first workday in all %-B progress report due
X all Fri in all Time card due, 3 PM
X all Monday in all Fiscal week %0W
X -2nd workday in all Schedule for %+B due
X Fri on_or_before all 15 Pay Day
X even Fridays in year Pay Day
X 183rd day of year mid-year (%l days left)
..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 ####
(where
..B ####
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 \-v ,
..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 .moon## " (" moon##.dat
under MS-DOS),
where
..B ##
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 the
end of the given 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 ``gray'' dates to be printed as outlined characters.
..TP
..BI \-G
Causes ``gray'' dates to be printed as outlined characters filled with gray.
..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.
Format specifiers denoting the month and/or year may appear in the string;
the appropriate values will be substituted upon printing.
..TP
..BI \-C " string"
Causes the accompanying string to be printed as a centered footer.
Format specifiers denoting the month and/or year may appear in the string;
the appropriate values will be substituted upon printing.
..TP
..BI \-R " string"
Causes the accompanying string to be printed as a right-justified footer.
Format specifiers denoting the month and/or year may appear in the string;
the appropriate values will be substituted upon printing.
..TP
..BI \-B
Causes
..I pcal
to leave unused calendar boxes blank (default is gray).
..TP
..BI \-w
Causes
..I 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
..B 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, usage message, and full explanation of options
and file formats (to
..IR stdout )
and terminate.
..TP
..B \-v
Causes
..I pcal
to write version information only (to
..IR 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, Richard L. Dyson, Bill Hogsett, and Floyd Miller.
SHAR_EOF
chmod 0644 pcal.man ||
echo 'restore of pcal.man failed'
Wc_c="`wc -c < 'pcal.man'`"
test 20376 -eq "$Wc_c" ||
echo 'pcal.man: original size 20376, 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.1 AWR 07/16/91 Add support for -G flag
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 Un*x from others */
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 */
#define PATH_ENV_VAR "PATH" /* cf. find_executable() (pcalutil.c) */
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)
#define START_DAY(m, y) ((FIRST_OF(m, y) - first_day_of_week + 7) % 7)
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 cond[] and gray[] in writefil.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 GRAY_NUMS 0 /* print "gray" dates in gray */
#define OUTLINE_NUMS 1 /* print as unfilled outlines */
#define FILLED_NUMS 2 /* print as filled outlines */
#define NUM_STYLE GRAY_NUMS /* default */
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 14846 -eq "$Wc_c" ||
echo 'pcaldefs.h: original size 14846, 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.1 AWR 07/16/91 Added support for -G flag
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 num_style = NUM_STYLE; /* -G, -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 num_style; /* -G, -O */
X
#endif
X
SHAR_EOF
chmod 0666 pcalglob.h ||
echo 'restore of pcalglob.h failed'
Wc_c="`wc -c < 'pcalglob.h'`"
test 3549 -eq "$Wc_c" ||
echo 'pcalglob.h: original size 3549, 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 * Revision history:
X *
X * 4.0 AWR 02/25/91 added optional third argument for
X * name of array
X *
X * AWR 02/19/91 added function prototypes; documented
X *
X * AWR 01/16/91 Escape " and \ in quoted strings;
X * strip trailing comments; skip FF
X *
X * 2.6 JAB 10/18/90 Add exit(0).
X *
X * 2.3 JWZ 09/14/90 Author
X */
X
#include <stdio.h>
#include <ctype.h>
#include <string.h>
X
#if defined(__STDC__) || defined(AMIGA)
#define PROTOS
#endif
X
#define FALSE 0
#define TRUE 1
X
#define ARRAY_NAME "header" /* default name of array in .h file */
X
#define IS_WHITESPACE(c) \
X ((c) == ' ' || (c) == '\t' || (c) == '\n' || c == '\f')
X
#define IS_POSTSCRIPT(s) ((s)[0] != '%' && (s)[0] != '\0')
X
X
/*
X * strip_white: strip leading and trailing whitespace from 'string'; return
X * pointer to first non-whitespace character
X */
#ifdef PROTOS
char *strip_white (char *string)
#else
char *strip_white (string)
X char *string;
#endif
{
X int n;
X for (; IS_WHITESPACE(*string); string++)
X ;
X n = strlen(string)-1;
X for (; IS_WHITESPACE(string[n]); n--)
X string[n] = '\0';
X return string;
}
X
X
/*
X * strip_comment: strip comment and any preceding whitespace from 'string';
X * return pointer to 'string'
X */
#ifdef PROTOS
char *strip_comment (char *string)
#else
char *strip_comment (string)
X char *string;
#endif
{
X char *p;
X if ((p = strchr(string, '%')) != NULL) {
X *p = '\0';
X string = strip_white(string);
X }
X return string;
}
X
X
/*
X * escape: copy string 'in' to string 'out', escaping the characters \ and ";
X * return pointer to 'out'
X */
#ifdef PROTOS
char *escape(char *out, char *in)
#else
char *escape(out, in)
X char *out, *in;
#endif
{
X char c, *sv_out = out;
X
X for (; c = *in; *out++ = *in++)
X if (c == '\\' || c == '"')
X *out++ = '\\';
X
X *out = '\0';
X return sv_out;
}
X
X
#ifdef PROTOS
int main(int argc, char *argv[])
#else
int main (argc, argv)
X int argc; char *argv[];
#endif
{
X FILE *in, *out;
X char line[256], line2[512], *L, *array;
X int in_initial_comments = TRUE;
X
X /* retrieve arguments and attempt to open input and output files */
X
X if (argc < 3 || argc > 4) {
X fprintf(stderr, "usage: %s <infile>.ps <outfile>.h [<arrayname>]\n",
X 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 array = argc == 4 ? argv[3] : ARRAY_NAME;
X
X /* print topline comment on output file */
X
X fprintf (out, "/*\n * %s: automatically generated by %s from %s\n",
X argv[2], argv[0], argv[1]);
X fprintf (out, " *\n *\tDO NOT EDIT THIS FILE!\n *\n");
X
X /* main loop - copy lines from input file, to output file, preserving
X * only initial block of comments and blank lines
X */
X
X while ( fgets(line, 255, in) != NULL ) {
X L = strip_white(line); /* strip whitespace */
X
X if ( IS_POSTSCRIPT(L) ) { /* PostScript source? */
X if ( in_initial_comments ) { /* first PS line? */
X in_initial_comments = FALSE;
X fprintf(out, " */\n\nchar *%s[] = {\n", array);
X }
X L = strip_comment(L); /* copy string to output */
X L = escape(line2, L);
X fprintf(out, " \"%s\",\n", L);
X } else /* blank or comment line */
X if ( in_initial_comments ) /* copy only initial block */
X fprintf(out, " * %s\n", L);
X }
X
X fprintf(out, " (char *)0,\n};\n"); /* terminate array decl */
X
X fclose(out); /* close files and exit */
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 3975 -eq "$Wc_c" ||
echo 'pcalinit.c: original size 3975, 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' &&
% pcalinit.ps - provides the PostScript routines for pcal.c
%
% 4.1 modified by Andrew Rogers:
%
% support -G option (cf. prtday) to print "gray" dates as filled
% outlines
%
% 4.0 modified by Andrew Rogers:
%
% support -w ("whole year") option - cf. printmonth_[pl], startpage
% moved all the calendar calculations to pcal.c and moonphas.c (q.v.)
%
% support -B option (leave unused boxes blank)
%
% support -O option (print "gray" numbers as outlines)
%
% revised several of the basic routines and added some others; dates,
% moons, text, Julian days are now relative to upper-left corner of box
%
% enlarged title and dates in small calendars
%
% 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
/SM 0 def % definitions for calendar sizes
/MED 1 def
/LG 2 def
X
/titlefontsize [ 60 48 48 ] def % font sizes for SM/MED/LG calendars
/datefontsize [ 54 40 25 ] def
/weekdayfontsize [ 0 24 12 ] def
/footfontsize 12 def
/notesfontsize 6 def
X
/titlepos [ 19 40 25 ] def % Y-offset (SM/MED/LG) of month/year title
/Y0 35 def % Y-coordinate of calendar grid origin
X
/daywidth 100 def % dimensions of grid boxes
/dayheight 80 def
/gridwidth daywidth 7 mul def
/gridheight dayheight 6 mul def
/negdaywidth daywidth neg def
/negdayheight dayheight neg def
/neggridwidth gridwidth neg def
/neggridheight gridheight neg def
X
/gridlinewidth 1.0 def % width of grid lines
/charlinewidth 0.1 def % width of outline characters
/moonlinewidth 0.1 def % width of moon icon line
/dategray 0.8 def % density of gray for dates
/fillgray 0.9 def % density of gray for fill squares
X
/hangingindent ( ) def % for indenting continued text lines
X
X
%
% Utility functions:
%
X
X
/center { % print string centered in given width
X /width exch def
X /str exch def
X width str 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
/prtday { % print date in black, gray, outline, or filled outline
X day 3 string cvs % convert to string
X color (outline) eq color (outline_gray) eq or {
X true charpath
X color (outline_gray) eq { % filled outline?
X gsave dategray setgray fill grestore
X } if
X stroke % print as outline
X }
X {
X color (gray) eq { dategray setgray } if % print in gray
X show
X } ifelse
} def
X
X
/nextbox { % go to next column or start of next row
X day startday add 7 mod 0 eq % end of week?
X { neggridwidth daywidth add negdayheight rmoveto } % next row
X { daywidth 0 rmoveto } % next col
X ifelse
} def
X
X
/datepos { % push coords of upper-left corner of box for day <arg>
X startday add 1 sub dup 7 mod daywidth mul % x-coord
X exch 7 idiv negdayheight mul Y0 add % y-coord
} def
X
X
%
% Functions for drawing parts of calendar:
%
X
X
/drawtitle { % draw month and year title
X titlefont findfont titlefontsize calsize get scalefont setfont
X /month_name month_names month 1 sub get def
X /yearstring year 10 string cvs def
X 0 Y0 titlepos calsize get add moveto
X month_name ( ) strcat yearstring strcat gridwidth center
} def
X
X
/drawdaynames { % draw day names above respective columns
X dayfont findfont weekdayfontsize calsize get scalefont setfont
X 0 1 6 {
X /i exch def
X i daywidth mul Y0 5 add moveto
X day_names i get
X daywidth center
X } for
} def
X
X
/drawgrid { % draw the grid for the calendar
X gridlinewidth setlinewidth
X 0 daywidth gridwidth { % vertical lines
X Y0 moveto
X 0 neggridheight rlineto
X stroke
X } for
X 0 negdayheight neggridheight { % horizontal lines
X 0 exch Y0 add moveto
X gridwidth 0 rlineto
X stroke
X } for
} def
X
X
/drawnums { % place day numbers on calendar
X dayfont findfont datefontsize calsize get scalefont setfont
X /fontdiff datefontsize calsize get datefontsize LG get sub def
X charlinewidth setlinewidth
X 1 datepos 20 fontdiff add sub exch 5 add exch moveto
X
X 1 1 ndays {
X /day exch def
X /color (black) def
X calsize SM ne { % select alternate color
X /gray day_gray day startday add 1 sub 7 mod get def
X holidays { day eq { /gray holiday_gray def } if } forall
X gray {
X /color logical_gray def
X } if
X } if
X gsave
X prtday
X grestore
X nextbox
X } for
} def
X
X
/drawjnums { % place day-of-year numbers on calendar
X notesfont findfont notesfontsize scalefont setfont
X 1 datepos dayheight 3 sub sub exch daywidth 3 sub add exch moveto
X
X 1 1 ndays {
X /day exch def
X /jday jdstart day add 1 sub def
X /str jday 3 string cvs def
X julian-dates true eq { % print days left in year?
X /str str ( \050) strcat yearlen jday sub 3 string cvs
X strcat (\051) strcat def
X } if
X gsave
X str dup stringwidth pop 0 exch sub 0 rmoveto show
X grestore
X nextbox
X } for
} def
X
X
/fillboxes { % used by drawfill to generate row of fill squares
X /last exch def % last box to fill (0 = Sun)
X /first exch def % first box to fill (0 = Sun)
X /width last first sub 1 add daywidth mul def
X
X width 0 gt {
X gsave
X first daywidth mul 0 rmoveto
X fillgray setgray
X width 0 rlineto
X 0 negdayheight rlineto
X width neg 0 rlineto
X closepath fill
X grestore
X } if
} def
X
X
/drawfill { % generate fill squares where necessary
X /firstbox startday ndays add def
X /lastbox calsize LG ne {41} { note_block {38} {39} ifelse } ifelse def
X
X 0 Y0 moveto % boxes (if any) at start of first row
X 0 startday 1 sub fillboxes
X
X 0 4 negdayheight mul rmoveto % boxes (if any) at end of fifth row
X firstbox 35 lt {
X firstbox 7 mod 6 fillboxes
X /firstbox 35 def
X } if
X
X 0 negdayheight rmoveto % boxes at end of bottom row
X firstbox 7 mod lastbox 7 mod fillboxes
} def
X
X
/footstrings { % print foot strings at bottom of page
X titlefont findfont footfontsize scalefont setfont
X /bottomrow { neggridheight 20 add } def
X 0 bottomrow moveto
X Lfootstring show
X gridwidth Rfootstring stringwidth pop sub bottomrow moveto
X Rfootstring show
X 0 bottomrow moveto
X Cfootstring gridwidth center
} def
X
X
%
% Functions for printing text inside boxes:
%
X
X
/daytext {
X notesfont findfont notesfontsize scalefont setfont
X /mytext exch def /day exch def
X day datepos 29 sub dup /ypos exch def exch 2 add exch moveto
X currentpoint pop /LM exch def /RM LM 95 add def
X showtext
} def
X
X
/holidaytext { % print text for holiday (next to date)
X notesfont findfont notesfontsize scalefont setfont
X /mytext exch def /day exch def
X /dwidth day 10 lt {20} {33} ifelse def % width of date
X /mwidth do-moon-p {16} {0} ifelse def % width of moon icon
X day datepos 8 sub dup /ypos exch def exch dwidth add exch moveto
X currentpoint pop /LM exch def /RM LM 97 dwidth mwidth add sub add def
X showtext
} def
X
X
/notetext { % print text in notes box
X dayfont findfont 12 scalefont setfont
X /day 40 startday sub def % "date" of notes box
X day datepos 11 sub exch 4 add exch moveto
X notesheading show
X
X notesfont findfont notesfontsize scalefont setfont
X /mytext exch def
X day datepos 19 sub dup /ypos exch def exch 4 add exch moveto
X /LM currentpoint pop def /RM LM 93 add def
X showtext
} def
X
X
/crlf { % simulate CR/LF sequence
X ypos notesfontsize sub /ypos exch def LM ypos moveto
} def
X
X
/prstr { % print string on current or next line
X dup stringwidth pop currentpoint pop
X add RM gt { crlf hangingindent show } if show
} def
X
X
/showtext { % print words in "mytext", splitting into lines
X mytext {
X dup linesep eq % force new line?
X { crlf pop } % yes - discard text
X { prstr ( ) show } % no - print string + space
X ifelse
X } forall
} def
X
X
%
% Functions for printing months of various sizes and orientations:
%
X
X
/startpage { % initialize new physical page
X rval rotate
X xsval ysval scale
X xtval ytval translate
} def
X
X
/calendar % draw calendar for month/year
{
X drawtitle % month/year heading
X
X calsize SM ne { % day names
X drawdaynames
X } if
X
X calsize LG eq { % foot strings
X footstrings
X } if
X
X drawnums % calendar dates
X
X julian-dates false ne calsize LG eq and { % julian dates
X drawjnums
X } if
X
X fill-boxes { % fill unused boxes
X drawfill
X } if
X
X drawgrid % calendar grid
X
X draw-moons false ne calsize LG eq and { % moon icons
X drawmoons
X } if
X
X 0 0 moveto % return to origin
} def
X
X
/printmonth_l { % print month on landscape page ("posn" = 0..11)
X /calsize MED def
X
X posn 0 eq { % assume first month printed on page is posn 0
X startpage
X footstrings
X } if
X
X gsave % draw medium calendar at selected position
X .226 .25 scale % landscape mode - 3 rows, 4 cols
X posn 4 mod 800 mul
X posn 4 idiv -700 mul 150 add
X translate
X calendar
X grestore
} def
X
X
/printmonth_p { % print month on portrait page ("posn" = 0..11)
X /calsize MED def
X /footfontsize 15 def % compensate for scaling
X
X posn 0 eq { % assume first month printed on page is posn 0
X gsave % print foot strings at original scale
X startpage
X 0 20 translate % move foot strings up slightly
X footstrings
X grestore % re-scale Y axis for portrait mode
X /sv_ysval ysval def
X /ysval ysval 1.675 mul def
X startpage
X /ysval sv_ysval def
X } if
X
X gsave % draw medium calendar at selected position
X .304 .194 scale % portrait mode - 4 rows, 3 cols
X posn 3 mod 800 mul
X posn 3 idiv -700 mul 300 add
X translate
X calendar
X grestore
} def
X
X
/printmonth { % print single month on page
X startpage
X
X /calsize LG def % main (large) calendar
X calendar
X
X gsave % small calendars
X /calsize SM def
X /sv_startday startday def
X
X % calculate previous and next month, year, and starting day
X
X /lmonth month 1 eq { 12 } { month 1 sub } ifelse def
X /lyear month 1 eq { year 1 sub } { year } ifelse def
X /lstartday startday 35 add lndays sub 7 mod def
X /nmonth month 12 eq { 1 } { month 1 add } ifelse def
X /nyear month 12 eq { year 1 add } { year } ifelse def
X /nstartday startday ndays add 7 mod def
X
X /year lyear def % prev month/year
X /month lmonth def
X /startday lstartday def
X /ndays lndays def
X 5 daywidth mul 5 negdayheight mul Y0 add translate
X gsave
X .138 .138 scale
X 12 -120 translate
X calendar
X grestore
X
X /year nyear def % next month/year
X /month nmonth def
X /startday nstartday def
X /ndays nndays def
X daywidth 0 translate
X gsave
X .138 .138 scale
X 12 -120 translate
X calendar
X grestore
X
X /startday sv_startday def % restore starting day (for text boxes)
X grestore
} def
X
X
%
% Moon drawing functions:
%
X
X
/domoon { % draw moon at phase (0 = new; .25 = 1q; .5 = full; .75 = 3q)
X /phase exch def
X
X gsave
X currentpoint translate
X newpath
X
X % if moon is full, just draw unfilled circle
X
X phase halfperiod .01 sub ge phase halfperiod .01 add le and {
X 0 0 radius
X 0 360 arc stroke
X }
X {
X % draw the line arc now; prepare (but don't draw) the fill arc
X
X 0 0 radius % for line and fill arcs
X 0 0 radius
X phase halfperiod lt { % phase between new and full
X 270 90 arc stroke % (line on right, fill on left)
X 0 radius neg moveto
X 270 90 arcn
X }
X { % phase between full and new
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
X } ifelse
X
X % curveto uses (x0,y0) (current point), (x1,y1), (x2,y2),
X % and (x3,y3) as the control points for drawing a Bezier
X % cubic section, used here as the curve dividing the moon
X % icon into dark and light sections. x1 is in the range
X % -R*sqrt(2) <= x1 <= R*sqrt(2) and y1 is in the range
X % 0 <= y1 <= R; note that except in the degenerate case
X % where x1 = y1 = x2 = y2 = 0, the curve does not actually
X % pass through (x1,y1) or (x2,y2).
X
X /x1 quartperiod phase sub rect mul def
X /y1 x1 abs 2 sqrt div def
X
X % push control points for curveto
X
X % x0 = 0 (current
X % y0 = R point)
X x1 % x1
X y1 % y1
X x1 % x2 = x1
X y1 neg % y2 = -y1
X 0 % x3 = 0
X radius neg % y3 = -R
X
X % draw Bezier curve; fill area between curve and fill arc
X
X curveto
X fill
X } ifelse
X
X grestore
} def
X
X
/do-moon-p { % draw a moon on "day"?
X draw-moons (some) eq { % printing quarter moons? look up day
X /p false def
X quarter_moons { day eq { /p true def } if } forall
X p
X }
X {
X draw-moons % all moons or no moons
X } ifelse
} def
X
X
/drawmoons { % main routine to draw moons on calendar
X /halfperiod 0.5 def
X /quartperiod 0.25 def
X /radius 6 def
X /offset radius 3 add def
X /rect radius 2 sqrt mul quartperiod div def % domoon{} scale factor
X /n 0 def
X
X gsave
X moonlinewidth setlinewidth
X 1 datepos offset sub exch daywidth add offset sub exch moveto
X 1 1 ndays {
X /day exch def
X do-moon-p { % draw a moon today?
X moon_phases n get domoon
X /n n 1 add def
X } if
X nextbox
X } for
X grestore
} def
SHAR_EOF
chmod 0666 pcalinit.ps ||
echo 'restore of pcalinit.ps failed'
Wc_c="`wc -c < 'pcalinit.ps'`"
test 13642 -eq "$Wc_c" ||
echo 'pcalinit.ps: original size 13642, current size' "$Wc_c"
fi
true || echo 'restore of pcallang.h failed'
echo End of part 4, continue with part 5
exit 0