From: [t m h] at [expert.cc.purdue.edu] (Todd M. Helfter) Newsgroups: rec.games.frp.archives Subject: SUPPLEMENT: forgotten realms calendar (PS)(C) Date: 25 Nov 93 03:13:53 GMT # This is a shell archive. # Remove everything above and including the cut line. # Then run the rest of the file through sh. #----cut here-----cut here-----cut here-----cut here----# #!/bin/sh # shar: Shell Archiver # Run the following text with /bin/sh to create: # post # This archive created: Mon Nov 22 17:38:30 1993 # By: Todd M. Helfter (Purdue University Computing Center) mkdir post cd post cat << \SHAR_EOF > Makefile GCC-COMPILE = gcc RM = /bin/rm -f SRC = fr_cal.c format.c error.c OBJ = fr_cal.o format.o error.o PRJ = fr_cal default:$(PRJ) all: @make clean @make depend @make $(PRJ) $(PRJ):$P $(OBJ) $(RM) *.out $(PRJ) $(GCC-COMPILE) -o $@ $(OBJ) @echo "$@: successfully built and linked." relink: @$(RM) $(PRJ) @make $(PRJ) lpr: @lpr -P$(PRN) Makefile $(HDR) $(SRC) clean: $(RM) $(PRJ) $(OBJ) *.out core .SUFFIXES: .c .o .c.o: -$(GCC-COMPILE) -c $*.c # The dependencies after the DO NOT DELETE line are inserted by "maketd." depend: Makefile $(SRC) $(STR) maketd -F'$(GCC-COMPILE) -M %I %F' $(SRC) # DO NOT DELETE THIS LINE - maketd DEPENDS ON IT SHAR_EOF cat << \SHAR_EOF > error.c #include #include extern char *progname; /* name of this program */ void printerr(char *s) { int saved_errno = errno; (void)fprintf(stderr, "%s: ", progname); errno = saved_errno; perror(s); exit(1); } void usage(void) { (void)fprintf(stderr, "Usage: %s [year]\n", progname); exit(2); } SHAR_EOF cat << \SHAR_EOF > format.c #include #include #include #include #ifdef unix #include #endif #include "structs.h" #define PROLOG "/user/user/src/pro/fr_cal.pro" extern struct date getdate(int, int, int); extern void printerr(char *); extern struct month month[]; extern int now; int do_fr(int day) { (void)printf("SetSpecialFont\n"); switch (day) { case 0: (void)printf("(Midwinter is known officially as the High Festival of Winter:) Tab 412 ST\n"); (void)printf("( It is a feast where, traditionally, the lords of the land plan) -32 MST\n"); (void)printf("(the year ahead, make and renew alliances, and send gifts of good-) -16 MST\n"); (void)printf("(will. To the commonfolk, this is Deadwinter Day, the midpoint of) -16 MST\n"); (void)printf("(the worst of the cold.) -16 MST\n"); break; case 1: (void)printf("(Greengrass is the official beginning of spring, a day of relaxation.) Tab 412 ST\n"); (void)printf("( Flowers that have been carefully grown in the inner rooms of) -32 MST\n"); (void)printf("(the keeps and temples during the winter are blessed and cast out) -16 MST\n"); (void)printf("(upon the snow to bring rich growth in the season ahead.) -16 MST\n"); break; case 2: (void)printf("(Midsummer, also called Midsummer Night or the Long Night is a) Tab 412 ST\n"); (void)printf("(time of feasting, music, and love.) -16 MST\n"); (void)printf("( In a ceremony performed in some lands, unwed maidens are set) -32 MST\n"); (void)printf("(free in the woods and 'hunted' by their would-be suitors throughout) -16 MST\n"); (void)printf("(the night.) -16 MST\n"); (void)printf("( Betrothals are traditionally made upon this night. It is very) -32 MST\n"); (void)printf("(rare for the weather to be bad for this night--such is considered a) -16 MST\n"); (void)printf("(very bad omen, usually thought to foretell famine or plague.) -16 MST\n"); break; case 3: (void)printf("(Shieldmeet is a special day that occurs only once every four years.) Tab 412 ST\n"); (void)printf("( This is a day of open council between the nobles and the people.) -32 MST\n"); (void)printf("(It is day for the making and renewing of pacts, oaths, and agreements.) -16 MST\n"); (void)printf("(This is a day for tournaments, tests and trials for those wishing to) -16 MST\n"); (void)printf("(advance in battle fame or clerical standing, and for entertainment of) -16 MST\n"); (void)printf("(all types, particularly theatrical, and for dueling.) -16 MST\n"); break; case 4: (void)printf("(Higharvestide heralds the coming of fall and the harvest.) Tab 412 ST\n"); (void)printf("( It is a feast that often continues for the length of the harvest.) -32 MST\n"); (void)printf("(so that food is always on hand for those coming in from the fields.) -16 MST\n"); (void)printf("( There is much traveling about on the heels of this feast, as) -32 MST\n"); (void)printf("(merchants, court emmissaries, and pilgrims make speed before the) -16 MST\n"); (void)printf("(worst of the mud arrives and the rain freezes into snow.) -16 MST\n"); break; case 5: (void)printf("(Moonfest, also called The Feast of the Moon, is the last great festival) Tab 412 ST\n"); (void)printf("(of the year.) -16 MST\n"); (void)printf("( Moonfest marks the arrival of winter and is also the day when the) -32 MST\n"); (void)printf("(dead are honored. Graves are blessed, the Ritual of Remembrance is) -16 MST\n"); (void)printf("(performed, and tales of the doings of those now gone are told far into) -16 MST\n"); (void)printf("(the night. Many stories are told of heroes, lost treasures and cities.) -16 MST\n"); (void)printf("( Wars are usually fought after the harvest is done, continuing as) -32 MST\n"); (void)printf("(late as the weather permits. The bulk of the fighting takes place in ) -16 MST\n"); (void)printf("(the month of Uktar, and the ironic practicality of the Feast of the Moon) -16 MST\n"); (void)printf("(is readily apparent.) -16 MST\n"); break; } }; /* format the page title, e.g., (January 1992) */ void do_title(int mon, int year) { char s[6]; (void)sprintf(s, "%d", year); (void)printf("SetTitleFont\n"); (void)printf("(%s - %s Dale Reckoning) Title\n", month[mon].name, s); } void do_border(void) { (void)printf("gsave\n"); (void)printf(" Border\n"); (void)printf("grestore\n"); } /* format the grid of lines for the page */ void do_lines(void) { (void)printf("gsave\n"); (void)printf(" HorizontalLines\n"); (void)printf(" VerticalLines\n"); (void)printf("grestore\n"); } /* format the column headings, currently the days of the week */ void do_headings(void) { (void)printf("SetHeadingFont\n"); (void)printf("Headings\n"); } /* the prologue */ void do_prologue(void) { FILE *fp; char buf[BUFSIZ]; if ((fp = fopen(PROLOG, "r")) == NULL) { (void)fprintf(stderr, "can't open %s\n", PROLOG); exit(1); } while (fgets((void *)buf, sizeof buf, fp)) if (fputs((void *)buf, stdout) == EOF) break; if (ferror(fp)) printerr("fgets/fputs error"); } void numbers(int maxday, int begin, int first) { (void)printf("SetNumberFont\n"); (void)printf("gsave\n"); (void)printf(" %d %d %d LeftMargin BoxWidth add %s\n", maxday, begin, first, "NumberRightMargin sub"); (void)printf(" TopLine HeadingHeight sub NumberBaseline sub\n"); (void)printf(" BoxWidth BoxHeight RightMargin\n"); (void)printf(" Numbers\n"); (void)printf("grestore\n"); } /* format the date numbers */ void do_numbers(int mon, int yr, int first) { numbers(month[mon].length, 1, 0); } /* trailer */ void do_trailer(int pages) { (void)printf("%%%%Trailer\n"); (void)printf("%%%%Pages: %d\n", pages); } /* format page for a given month and year */ void do_page(int mon, int yr, int first, int special, int day) { static int prologue_included = 0; static int page_number = 0; struct passwd *pw; if (!prologue_included) { (void)printf("%%!PS-Adobe-1.0\n"); (void)printf("%%%%Title: (none)\n"); (void)printf("%%%%Creator: "); #ifdef unix if (pw = getpwuid(getuid())) (void)printf("%s (%s)\n", pw->pw_name, pw->pw_gecos); else #endif (void)printf("(none)\n"); (void)printf("%%%%CreationDate: %s", now >= 0 ? ctime(&now) : "(none)"); (void)printf("%%%%Pages: (atend)\n"); (void)printf("%%%%EndComments\n"); /* we only insert the prologue once */ do_prologue(); prologue_included = 1; } page_number++; (void)printf("%%%%BeginPage: %d %d\n", page_number, page_number); (void)printf("save\n"); (void)printf("Landscape\n"); (void)printf("%d WeekSizes\n", 3); if (special) { do_title(mon, yr); do_fr(day); do_border(); } else { do_title(mon, yr); do_border(); do_lines(); do_headings(); do_numbers(mon, yr, first); } (void)printf("restore\n"); (void)printf("showpage\n"); (void)printf("%%%%EndPage\n"); } SHAR_EOF cat << \SHAR_EOF > fr_cal.c /* .--------------------------------------------------------------. | fr_cal | | | | -- A Forgotten Realms PostScript calendar generator | `--------------------------------------------------------------' */ #include #include #include #include "structs.h" #include "months.h" extern void do_page(int, int, int, int, int); extern void do_trailer(int); extern void printerr(char *); extern void usage(void); char *progname; /* name of this program */ int now; /* the current time */ int main(int argc, char **argv) { int num_month; /* the month we want */ int year; /* the year we want */ int i; char *bad_arg; /* check for bad month and year */ struct tm *tp; /* the current time */ int spc; /* special days */ progname = argv[0]; if (argc > 2) usage(); else { year = atoi(argv[argc - 1]); num_month = atoi(argv[1])-1; spc = 0; for (i = 0; i < 17; i++) if (month[i].length == 1) { if (i == 10 && year % 4 > 0) spc++; else do_page(i, year, 0, 1, spc++); } else do_page(i, year, 0, 0, 0); } do_trailer(argc == 2 ? 12 : 1); exit(0); } SHAR_EOF cat << \SHAR_EOF > months.h #ifndef _months_h #define _months_h #include "structs.h" struct month month[] = { { "Hammer", 30 }, { "Midwinter", 1 }, { "Alturiak", 30 }, { "Ches", 30 }, { "Tarsakh", 30 }, { "Greengrass", 1 }, { "Mirtul", 30 }, { "Kythorn", 30 }, { "Flamerule", 30 }, { "Midsummer", 1 }, { "Shieldmeet", 1 }, { "Eleasias", 30 }, { "Eleint", 30 }, { "Higharvestide", 1 }, { "Marpenoth", 30 }, { "Uktar", 30 }, { "Moonfest", 1 }, { "Nightal", 30 } }; #endif SHAR_EOF cat << \SHAR_EOF > structs.h #ifndef PSCAL_STRUCTS_H #define PSCAL_STRUCTS_H struct month { char *name; int length; }; struct date { int month; int day; int year; }; #endif /* PSCAL_STRUCTS_H */ SHAR_EOF cat << \SHAR_EOF > README the path for PROLOG must be set in format.c to where you put fr_cal.pro SHAR_EOF cat << \SHAR_EOF > fr_cal.pro %%Version: 1/24/92 /inch { 72 mul } bind def /PageHeight 8.5 inch def /PageWidth 11 inch def /BottomMargin 2.0 inch def /TopMargin 2.0 inch def /LeftMargin .5 inch def /Tab 2.0 inch def /HeadingHeight .25 inch def /TitleBaseline 1 4 div inch def /NumberBaseline 3 16 div inch def /NumberRightMargin 1 16 div inch def /TitleSize 24 def /NumberSize 14 def /HeadingSize 14 def /SpecialSize 18 def /TitleFont /Times-Bold def /NumberFont /Times-Roman def /HeadingFont /Times-Roman def /SpecialFont /Times-Roman def /RightMargin PageWidth LeftMargin sub def /TopLine PageHeight TopMargin sub def /Xlength RightMargin LeftMargin sub def /BoxWidth Xlength 10 div def /Ylength PageHeight TopMargin sub BottomMargin sub def /DayNames [(1st Day) (2nd Day) (3rd Day) (4th Day) (5th Day) (6th Day) (7th Day) (8th Day) (9th Day) (10th Day)] def /str 3 string def /WeekSizes { % weeks /weeks exch def /BoxHeight Ylength HeadingHeight sub weeks div def } bind def /SetFont { % size name findfont exch scalefont setfont } bind def /SetTitleFont { TitleSize TitleFont SetFont } bind def /SetNumberFont { NumberSize NumberFont SetFont } bind def /SetHeadingFont { HeadingSize HeadingFont SetFont } bind def /SetSpecialFont { SpecialSize SpecialFont SetFont } bind def /Landscape { 90 rotate 0 PageHeight neg translate} bind def /ST { moveto gsave show grestore } bind def /MST { %def 0 exch rmoveto gsave show grestore } bind def /Rectangle { %def gsave moveto 1 index 0 rlineto 0 exch rlineto neg 0 rlineto closepath setgray setlinewidth stroke grestore } bind def /Center { % (text) y x width 2 div add exch moveto dup stringwidth pop 2 div neg 0 rmoveto show } bind def /RightJustify { % (text) dup stringwidth pop neg 0 rmoveto show } bind def /Title { % (text) TopLine TitleBaseline add LeftMargin dup RightMargin exch sub Center } bind def /Border { 4 0 Xlength Ylength LeftMargin BottomMargin Rectangle 4 0 430 50 180 468 Rectangle } bind def /HorizontalLines { newpath LeftMargin BottomMargin BoxHeight add moveto weeks { Xlength 0 rlineto Xlength neg BoxHeight rmoveto } repeat stroke } bind def /VerticalLines { newpath LeftMargin BoxWidth add BottomMargin moveto 9 { 0 Ylength rlineto BoxWidth Ylength neg rmoveto } repeat stroke } bind def /Headings { /x LeftMargin def /y TopLine HeadingHeight HeadingSize .7 mul add 2 div sub def DayNames { y x BoxWidth Center /x x BoxWidth add def } forall } bind def /day2xytl { % day first add 1 sub dup 10 mod BoxWidth mul LeftMargin add exch 10 idiv weeks exch sub BoxHeight mul BottomMargin add } bind def /day2xybl { % day first day2xytl BoxHeight sub } bind def /Numbers { % maxday begin first x y dx dy maxx /maxx exch def /dy exch def /dx exch def /y exch def /x exch def /minx x def dx mul x add /x exch def 1 3 -1 roll { str cvs x y moveto gsave RightJustify grestore /x x dx add def x maxx gt { /x minx def /y y dy sub def } if } for } bind def %%EndProlog SHAR_EOF cd .. # End of shell archive exit 0