pcal - another version of the PostScript calendar generator 
Author Message
 pcal - another version of the PostScript calendar generator

OK, OK, stop the E-Mail.  Here is a "C" version of the postscript
calendar generator (with thanks to Patrick Wood and Bill Vogel).
This version can load text into the day boxes from a calendar file.
See the README and manual page for more info.

Ken Keirnan

#-------- CUT HERE -------- CUT HERE -------- CUT HERE --------
#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#               "End of shell archive."
# Contents:  README Makefile pcal.c pcal.1

PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'README' -a "${1}" != "-c" ; then
  echo shar: Will not clobber existing file \"'README'\"
else
echo shar: Extracting \"'README'\" \(984 characters\)
sed "s/^X//" >'README' <<'END_OF_FILE'
X"Pcal" is a program to print PostScript calendars for any month and year.
XBy default, it looks for a file in the home directory named "calendar"
Xfor entries with leading dates matching dates on the calendar, and prints
Xany following text under the appropriate day.
X
XThe program may be a little System V flavored (getopt, time routines)
Xbut should be easily portable to other vintages of UNIX.
X
XPcal is the combined effort of several people, most notably Patrick Wood
Xof Pipeline Associates, Inc. for the original PostScript code and Bill
XVogel of AT&T for the calendar file mechanism.  My part was simple
Xtranslation to a "C" program, the addition of a couple options and a more
Xgeneralized date searching routine (oh yes, and a manual page :-).
X
XThe original calendar PostScript was Copyright (c) 1987 by Patrick Wood
Xand Pipeline Associates, Inc. with permission to modify and redistribute.
XPlease retain this README file with the package.
X
X
XKen Keirnan
XPacific Bell
XSan Ramon, CA.
END_OF_FILE
if test 984 -ne `wc -c <'README'`; then
    echo shar: \"'README'\" unpacked with wrong size!
fi
# end of 'README'
fi
if test -f 'Makefile' -a "${1}" != "-c" ; then
  echo shar: Will not clobber existing file \"'Makefile'\"
else
echo shar: Extracting \"'Makefile'\" \(295 characters\)
sed "s/^X//" >'Makefile' <<'END_OF_FILE'
X#
X# Normally the day numbers for Saturday and Sunday are printed in gray
X# instead of black.  If you want only Sundays in gray, uncomment the
X# following line.
X#
X# COPTS = -DSATBLK
X
Xpcal:  pcal.c
X       $(CC) $(CFLAGS) $(LDFLAGS) $(COPTS) -o pcal pcal.c
X
Xpcal.man:      pcal.1
X       nroff -man pcal.1 > pcal.man
END_OF_FILE
if test 295 -ne `wc -c <'Makefile'`; then
    echo shar: \"'Makefile'\" unpacked with wrong size!
fi
# end of 'Makefile'
fi
if test -f 'pcal.c' -a "${1}" != "-c" ; then
  echo shar: Will not clobber existing file \"'pcal.c'\"
else
echo shar: Extracting \"'pcal.c'\" \(10818 characters\)
sed "s/^X//" >'pcal.c' <<'END_OF_FILE'
X#include <stdio.h>
X#include <ctype.h>
X#include <time.h>
X#include <string.h>
X
X#define PRT    (void)printf
X#define FPR    (void)fprintf
X
Xchar *words[100];      /* maximum number of words on a line */
Xchar lbuf[512];                /* maximum line size */
X
Xchar *months[] = {     /* used to match alpha months */
X       "jan", "feb", "mar", "apr", "may", "jun",
X       "jul", "aug", "sep", "oct", "nov", "dec",
X       (char *)0,
X};
X
X/*
X * pheader - provides the PostScript routines
X */
Xchar *pheader[] = {
X  "%!",
X  "/titlefont /Times-Bold def",
X  "/dayfont /Helvetica-Bold def",
X  "/month_names [ (January) (February) (March) (April) (May) (June) (July)",
X  "\t\t(August) (September) (October) (November) (December) ] def",
X  "/prtnum { 3 string cvs show} def",
X  "/drawgrid {\t\t% draw calendar boxes",
X  "\tdayfont findfont 10 scalefont setfont",
X  "\t0 1 6 {",
X  "\t\tdup dup 100 mul 40 moveto",
X  "\t\t[ (Sunday) (Monday) (Tuesday) (Wednesday) (Thursday) (Friday) (Saturday) ] exch get",
X  "\t\t100 center",
X  "\t\t100 mul 35 moveto",
X  "\t\t1.0 setlinewidth",
X  "\t\t0 1 5 {",
X  "\t\t\tgsave",
X  "\t\t\t100 0 rlineto ",
X  "\t\t\t0 -80 rlineto",
X  "\t\t\t-100 0 rlineto",
X  "\t\t\tclosepath stroke",
X  "\t\t\tgrestore",
X  "\t\t\t0 -80 rmoveto",
X  "\t\t} for",
X  "\t} for",
X  "} def",
X  "/drawnums {\t\t% place day numbers on calendar",
X  "\tdayfont findfont 30 scalefont setfont",
X  "\t/start startday def",
X  "\t/days ndays def",
X  "\tstart 100 mul 5 add 10 rmoveto",
X  "\t1 1 days {",
X  "\t\t/day exch def",
X  "\t\tgsave",
X#ifndef SATBLK
X  "\t\tday start add 7 mod 0 eq",
X  "\t\t{",
X  "\t\t\tsubmonth 0 eq",
X  "\t\t\t{",
X  "\t\t\t\t.8 setgray",
X  "\t\t\t} if",
X  "\t\t} if",
X#endif
X  "\t\tday start add 7 mod 1 eq",
X  "\t\t{",
X  "\t\t\tsubmonth 0 eq",
X  "\t\t\t{",
X  "\t\t\t\t.8 setgray",
X  "\t\t\t} if",
X  "\t\t} if",
X  "\t\tday prtnum",
X  "\t\tgrestore",
X  "\t\tday start add 7 mod 0 eq",
X  "\t\t{",
X  "\t\t\tcurrentpoint exch pop 80 sub 5 exch moveto",
X  "\t\t}",
X  "\t\t{",
X  "\t\t\t100 0 rmoveto",
X  "\t\t} ifelse",
X  "\t} for",
X  "} def",
X  "/drawfill {\t\t% place fill squares on calendar",
X  "\t/start startday def",
X  "\t/days ndays def",
X  "\t0 35 rmoveto",
X  "\t1.0 setlinewidth",
X  "\t0 1 start 1 sub {",
X  "\t\tgsave",
X  "\t\t.9 setgray",
X  "\t\t100 0 rlineto ",
X  "\t\t0 -80 rlineto",
X  "\t\t-100 0 rlineto",
X  "\t\tclosepath fill",
X  "\t\tgrestore",
X  "\t\t100 0 rmoveto",
X  "\t} for",
X  "\tsubmonth 1 eq",
X  "\t{",
X  "\t\t/lastday 42 def",
X  "\t\t600 -365 moveto",
X  "\t}",
X  "\t{",
X  "\t\t/lastday 40 def",
X  "\t\t400 -365 moveto",
X  "\t} ifelse",
X  "\tlastday -1 ndays start 1 add add",
X  "\t{",
X  "\t\t/day exch def",
X  "\t\tgsave",
X  "\t\t.9 setgray",
X  "\t\t100 0 rlineto ",
X  "\t\t0 -80 rlineto",
X  "\t\t-100 0 rlineto",
X  "\t\tclosepath fill",
X  "\t\tgrestore",
X  "\t\tday 7 mod 1 eq",
X  "\t\t{",
X  "\t\t\t600 -365 80 add moveto",
X  "\t\t}",
X  "\t\t{",
X  "\t\t\t-100 0 rmoveto",
X  "\t\t} ifelse",
X  "\t} for",
X  "} def",
X  "/isleap {\t\t% is this a leap year?",
X  "\tyear 4 mod 0 eq\t\t% multiple of 4",
X  "\tyear 100 mod 0 ne \t% not century",
X  "\tyear 1000 mod 0 eq or and\t% unless it's a millenia",
X  "} def",
X  "/days_month [ 31 28 31 30 31 30 31 31 30 31 30 31 ] def",
X  "/ndays {\t\t% number of days in this month",
X  "\tdays_month month 1 sub get",
X  "\tmonth 2 eq\t% Feb",
X  "\tisleap and",
X  "\t{",
X  "\t\t1 add",
X  "\t} if",
X  "} def",
X  "/startday {\t\t% starting day-of-week for this month",
X  "\t/off year 2000 sub def\t% offset from start of epoch",
X  "\toff",
X  "\toff 4 idiv add\t\t% number of leap years",
X  "\toff 100 idiv sub\t% number of centuries",
X  "\toff 1000 idiv add\t% number of millenia",
X  "\t6 add 7 mod 7 add \t% offset from Jan 1 2000",
X  "\t/off exch def",
X  "\t1 1 month 1 sub {",
X  "\t\t/idx exch def",
X  "\t\tdays_month idx 1 sub get",
X  "\t\tidx 2 eq",
X  "\t\tisleap and",
X  "\t\t{",
X  "\t\t\t1 add",
X  "\t\t} if",
X  "\t\t/off exch off add def",
X  "\t} for",
X  "\toff 7 mod\t\t% 0--Sunday, 1--monday, etc.",
X  "} def",
X  "/center {\t\t% center string in given width",
X  "\t/width exch def",
X  "\t/str exch def width str ",
X  "\tstringwidth pop sub 2 div 0 rmoveto str show",
X  "} def",
X  "/calendar",
X  "{",
X  "\ttitlefont findfont 48 scalefont setfont",
X  "\t0 60 moveto",
X  "\t/month_name month_names month 1 sub get def",
X  "\tmonth_name show",
X  "\t/yearstring year 10 string cvs def",
X  "\t700 yearstring stringwidth pop sub 60 moveto",
X  "\tyearstring show",
X  "\t0 0 moveto",
X  "\tdrawnums",
X  "\t0 0 moveto",
X  "\tdrawfill",
X  "\t0 0 moveto",
X  "\tdrawgrid",
X  "} def",
X  "/daytext {",
X  "\t/Helvetica-Narrow findfont 6 scalefont setfont",
X  "\t/mytext\texch def /myday exch def",
X  "\tstartday myday 1 sub add dup 7 mod 100 mul 5 add % gives column",
X  "\texch 7 idiv -80 mul % gives row",
X  "\tdup /ypos exch def moveto",
X  "\t/LM currentpoint pop def /RM LM 95 add def",
X  "        mytext { dup (.p) eq { crlf pop} {prstr ( ) show} ifelse } forall",
X  "} def",
X  "/crlf {",
X  "    ypos 8 sub /ypos exch def LM ypos moveto",
X  "} def",
X  "/prstr {",
X  "    dup stringwidth pop currentpoint pop",
X  "    add RM gt {crlf} if show",
X  "} def",
X  "/printmonth {",
X  "\t90 rotate",
X  "\t50 -120 translate",
X  "\t/submonth 0 def",
X  "\tcalendar",
X  "\tmonth 1 sub 0 eq",
X  "\t{",
X  "\t\t/lmonth 12 def",
X  "\t\t/lyear year 1 sub def",
X  "\t}",
X  "\t{",
X  "\t\t/lmonth month 1 sub def",
X  "\t\t/lyear year def",
X  "\t} ifelse",
X  "\tmonth 1 add 13 eq",
X  "\t{",
X  "\t\t/nmonth 1 def",
X  "\t\t/nyear year 1 add def",
X  "\t} ",
X  "\t{",
X  "\t\t/nmonth month 1 add def",
X  "\t\t/nyear year def",
X  "\t} ifelse",
X  "\t/savemonth month def",
X  "\t/saveyear year def",
X  "\t/submonth 1 def",
X  "\t/year lyear def",
X  "\t/month lmonth def",
X  "\tgsave",
X  "\t500 -365 translate",
X  "\tgsave",
X  "\t.138 .138 scale",
X  "\t10 -120 translate",
X  "\tcalendar",
X  "\tgrestore",
X  "\t/submonth 1 def",
X  "\t/year nyear def",
X  "\t/month nmonth def",
X  "\t100 0 translate",
X  "\tgsave",
X  "\t.138 .138 scale",
X  "\t10 -120 translate",
X  "\tcalendar",
X  "\tgrestore",
X  "\t/month savemonth def",
X  "\t/year saveyear def",
X  "\t/submonth 0 def",
X  "\tgrestore",
X  "} def",
X  (char *)0,
X};
X
XFILE *cfp = NULL;
Xint year;
Xint cyear;
X
Xvoid exit();
Xchar *getenv();
X
Xmain(argc, argv)
Xint argc;
Xchar **argv;
X{
X       extern char *optarg;
X       extern int optind;
X       register struct tm *lt;
X       register char **ap;
X       register char *cp;
X       char *cfile = NULL;
X       char cbuf[80];
X       long t, time();
X       int errflg = 0;
X       int nocal = 0;
X       int m;
X
X       while ((m = getopt(argc, argv, "ef:")) != EOF)
X
X               switch (m) {
X
X               case 'e':
X                       nocal++;
X                       cfile = NULL;
X                       break;
X
X               case 'f':
X                       cfile = optarg;
X                       nocal = 0;
X                       break;
X
X               case '?':
X                       errflg = 1;
X                       break;
X               }
X       if (errflg) {
X               FPR(stderr, "Usage: pcal [ -e |
...

read more »



Sat, 17 Oct 1992 16:42:00 GMT  
 pcal - another version of the PostScript calendar generator
I had to change the first part of parse() to get it to work under
SunOS 4.0 as shown below.  The stupid tolower changes everything to
lowercase, whether it is an uppercase letter or not!  Many thanks to Ken
for putting this together -- it's exactly what I was going to do (eventually).

        cp = strtok(lbuf, " \t");     /* get first field */
        while (*cp) {
                if (isupper(*cp))
                        *cp = tolower(*cp);
                cp++;
        }
        cp = lbuf;

--

I'm a right-to-lifer -- everyone has a right to earn a living sufficient to
feed himself and his family.



Sat, 17 Oct 1992 15:06:00 GMT  
 pcal - another version of the PostScript calendar generator
The pcal capability has been folded into the latest version of calentool
(actually as part of Patch#2) to generate pretty PostScript output of a
months worth of appointments.  [Calentool, recently sent to comp.sources.sun,
is a SunView based desktop calendar.]

        -Bill Randle
        Tektronix, Inc.



Sat, 17 Oct 1992 20:56:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Patch to PCAL PostScript calendar program

2. PostScript calendar creator: pcal -- installation problem

3. Seeking author(s) of pcal (Postscript Calendar)

4. Pcal: postscript/c calendar printer

5. **NEW** Postscript Calendar Generator

6. Postscript Calendar Generator

7. multi-page calendars (pcal | multi | lpr)

8. calendar generator

9. pcal version >4.5

10. Latest version of pcal

11. Current version and whereabouts of PCAL???

12. Latest version of PCAL?

 

 
Powered by phpBB® Forum Software