bill.c revision 1.2 1 1.2 mycroft #ifndef lint
2 1.2 mycroft static char rcsid[] = "$Id: bill.c,v 1.2 1993/08/02 17:19:54 mycroft Exp $";
3 1.2 mycroft #endif /* not lint */
4 1.2 mycroft
5 1.1 cgd #include "header.h"
6 1.1 cgd /* bill.c "Larn is copyrighted 1986 by Noah Morgan. */
7 1.1 cgd static char mail600[32];
8 1.1 cgd /*
9 1.1 cgd * function to create the tax bill for the user
10 1.1 cgd */
11 1.1 cgd static int pid;
12 1.1 cgd static letter1()
13 1.1 cgd {
14 1.1 cgd sprintf(mail600,"/tmp/#%dmail600",pid); /* prepare path */
15 1.1 cgd if (lcreat(mail600) < 0) { write(1,"can't write 600 letter\n",23); return(0);}
16 1.1 cgd lprcat("\n\n\n\n\n\n\n\n\n\n\n\n");
17 1.1 cgd standout("From:"); lprcat(" the LRS (Larn Revenue Service)\n");
18 1.1 cgd standout("\nSubject:"); lprcat(" undeclared income\n");
19 1.1 cgd lprcat("\n We heard you survived the caverns of Larn. Let me be the");
20 1.1 cgd lprcat("\nfirst to congratulate you on your success. It is quite a feat.");
21 1.1 cgd lprcat("\nIt must also have been very profitable for you.");
22 1.1 cgd lprcat("\n\n The Dungeon Master has informed us that you brought");
23 1.1 cgd lprintf("\n%d gold pieces back with you from your journey. As the",(long)c[GOLD]);
24 1.1 cgd lprcat("\ncounty of Larn is in dire need of funds, we have spared no time");
25 1.1 cgd lprintf("\nin preparing your tax bill. You owe %d gold pieces as",
26 1.1 cgd (long)c[GOLD]*TAXRATE);
27 1.1 cgd lprcat("\nof this notice, and is due within 5 days. Failure to pay will");
28 1.1 cgd lprcat("\nmean penalties. Once again, congratulations, We look forward");
29 1.1 cgd lprcat("\nto your future successful expeditions.\n");
30 1.1 cgd lwclose(); return(1);
31 1.1 cgd }
32 1.1 cgd
33 1.1 cgd static letter2()
34 1.1 cgd {
35 1.1 cgd sprintf(mail600,"/tmp/#%dmail600",pid); /* prepare path */
36 1.1 cgd if (lcreat(mail600) < 0) { write(1,"can't write 601 letter\n",23); return(0);}
37 1.1 cgd lprcat("\n\n\n\n\n\n\n\n\n\n\n\n");
38 1.1 cgd standout("From:"); lprcat(" His Majesty King Wilfred of Larndom\n");
39 1.1 cgd standout("\nSubject:"); lprcat(" a noble deed\n");
40 1.1 cgd lprcat("\n I have heard of your magnificent feat, and I, King Wilfred,");
41 1.1 cgd lprcat("\nforthwith declare today to be a national holiday. Furthermore,");
42 1.1 cgd lprcat("\nhence three days, Ye be invited to the castle to receive the");
43 1.1 cgd lprcat("\nhonour of Knight of the realm. Upon thy name shall it be written. . .");
44 1.1 cgd lprcat("\nBravery and courage be yours.");
45 1.1 cgd lprcat("\nMay you live in happiness forevermore . . .\n");
46 1.1 cgd lwclose(); return(1);
47 1.1 cgd }
48 1.1 cgd
49 1.1 cgd static letter3()
50 1.1 cgd {
51 1.1 cgd sprintf(mail600,"/tmp/#%dmail600",pid); /* prepare path */
52 1.1 cgd if (lcreat(mail600) < 0) { write(1,"can't write 602 letter\n",23); return(0);}
53 1.1 cgd lprcat("\n\n\n\n\n\n\n\n\n\n\n\n");
54 1.1 cgd standout("From:"); lprcat(" Count Endelford\n");
55 1.1 cgd standout("\nSubject:"); lprcat(" You Bastard!\n");
56 1.1 cgd lprcat("\n I heard (from sources) of your journey. Congratulations!");
57 1.1 cgd lprcat("\nYou Bastard! With several attempts I have yet to endure the");
58 1.1 cgd lprcat(" caves,\nand you, a nobody, makes the journey! From this time");
59 1.1 cgd lprcat(" onward, bewarned\nupon our meeting you shall pay the price!\n");
60 1.1 cgd lwclose(); return(1);
61 1.1 cgd }
62 1.1 cgd
63 1.1 cgd static letter4()
64 1.1 cgd {
65 1.1 cgd sprintf(mail600,"/tmp/#%dmail600",pid); /* prepare path */
66 1.1 cgd if (lcreat(mail600) < 0) { write(1,"can't write 603 letter\n",23); return(0);}
67 1.1 cgd lprcat("\n\n\n\n\n\n\n\n\n\n\n\n");
68 1.1 cgd standout("From:"); lprcat(" Mainair, Duke of Larnty\n");
69 1.1 cgd standout("\nSubject:"); lprcat(" High Praise\n");
70 1.1 cgd lprcat("\n With a certainty a hero I declare to be amongst us! A nod of");
71 1.1 cgd lprcat("\nfavour I send to thee. Me thinks Count Endelford this day of");
72 1.1 cgd lprcat("\nright breath'eth fire as of dragon of whom ye are slayer. I");
73 1.1 cgd lprcat("\nyearn to behold his anger and jealously. Should ye choose to");
74 1.1 cgd lprcat("\nunleash some of thy wealth upon those who be unfortunate, I,");
75 1.1 cgd lprcat("\nDuke Mainair, Shall equal thy gift also.\n");
76 1.1 cgd lwclose(); return(1);
77 1.1 cgd }
78 1.1 cgd
79 1.1 cgd static letter5()
80 1.1 cgd {
81 1.1 cgd sprintf(mail600,"/tmp/#%dmail600",pid); /* prepare path */
82 1.1 cgd if (lcreat(mail600) < 0) { write(1,"can't write 604 letter\n",23); return(0);}
83 1.1 cgd lprcat("\n\n\n\n\n\n\n\n\n\n\n\n");
84 1.1 cgd standout("From:"); lprcat(" St. Mary's Children's Home\n");
85 1.1 cgd standout("\nSubject:"); lprcat(" these poor children\n");
86 1.1 cgd lprcat("\n News of your great conquests has spread to all of Larndom.");
87 1.1 cgd lprcat("\nMight I have a moment of a great man's time. We here at St.");
88 1.1 cgd lprcat("\nMary's Children's Home are very poor, and many children are");
89 1.1 cgd lprcat("\nstarving. Disease is widespread and very often fatal without");
90 1.1 cgd lprcat("\ngood food. Could you possibly find it in your heart to help us");
91 1.1 cgd lprcat("\nin our plight? Whatever you could give will help much.");
92 1.1 cgd lprcat("\n(your gift is tax deductible)\n");
93 1.1 cgd lwclose(); return(1);
94 1.1 cgd }
95 1.1 cgd
96 1.1 cgd static letter6()
97 1.1 cgd {
98 1.1 cgd sprintf(mail600,"/tmp/#%dmail600",pid); /* prepare path */
99 1.1 cgd if (lcreat(mail600) < 0) { write(1,"can't write 605 letter\n",23); return(0);}
100 1.1 cgd lprcat("\n\n\n\n\n\n\n\n\n\n\n\n");
101 1.1 cgd standout("From:"); lprcat(" The National Cancer Society of Larn\n");
102 1.1 cgd standout("\nSubject:"); lprcat(" hope\n");
103 1.1 cgd lprcat("\nCongratulations on your successful expedition. We are sure much");
104 1.1 cgd lprcat("\ncourage and determination were needed on your quest. There are");
105 1.1 cgd lprcat("\nmany though, that could never hope to undertake such a journey");
106 1.1 cgd lprcat("\ndue to an enfeebling disease -- cancer. We at the National");
107 1.1 cgd lprcat("\nCancer Society of Larn wish to appeal to your philanthropy in");
108 1.1 cgd lprcat("\norder to save many good people -- possibly even yourself a few");
109 1.1 cgd lprcat("\nyears from now. Much work needs to be done in researching this");
110 1.1 cgd lprcat("\ndreaded disease, and you can help today. Could you please see it");
111 1.1 cgd lprcat("\nin your heart to give generously? Your continued good health");
112 1.1 cgd lprcat("\ncan be your everlasting reward.\n");
113 1.1 cgd lwclose(); return(1);
114 1.1 cgd }
115 1.1 cgd
116 1.1 cgd /*
117 1.1 cgd * function to mail the letters to the player if a winner
118 1.1 cgd */
119 1.1 cgd static int (*pfn[])()= { letter1, letter2, letter3, letter4, letter5, letter6 };
120 1.1 cgd mailbill()
121 1.1 cgd {
122 1.1 cgd register int i;
123 1.1 cgd char buf[128];
124 1.1 cgd wait(0); pid=getpid();
125 1.1 cgd if (fork() == 0)
126 1.1 cgd {
127 1.1 cgd resetscroll();
128 1.1 cgd for (i=0; i<sizeof(pfn)/sizeof(int (*)()); i++)
129 1.1 cgd if ((*pfn[i])())
130 1.1 cgd {
131 1.1 cgd sleep(20); sprintf(buf,"mail %s < %s",loginname,mail600);
132 1.1 cgd system(buf); unlink(mail600);
133 1.1 cgd }
134 1.1 cgd exit();
135 1.1 cgd }
136 1.1 cgd }
137