]> git.cameronkatri.com Git - bsdgames-darwin.git/blob - larn/bill.c
oops, we do need privs. do the right seteuid() thing.
[bsdgames-darwin.git] / larn / bill.c
1 /* $NetBSD: bill.c,v 1.4 1996/05/22 00:34:35 mrg Exp $ */
2
3 /*-
4 * Copyright (c) 1991 The Regents of the University of California.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by the University of
18 * California, Berkeley and its contributors.
19 * 4. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 */
35
36 #ifndef lint
37 #if 0
38 static char sccsid[] = "@(#)bill.c 5.2 (Berkeley) 5/28/91";
39 #else
40 static char rcsid[] = "$NetBSD: bill.c,v 1.4 1996/05/22 00:34:35 mrg Exp $";
41 #endif
42 #endif /* not lint */
43
44 #include <sys/file.h>
45 #include <sys/wait.h>
46 #include <string.h>
47 #include <stdlib.h>
48 #include <stdio.h>
49 #include <unistd.h>
50 #include "header.h"
51
52 /* bill.c Larn is copyrighted 1986 by Noah Morgan. */
53
54 char *mail[] = {
55 "From: the LRS (Larn Revenue Service)\n",
56 "~s undeclared income\n",
57 "\n We have heard you survived the caverns of Larn. Let me be the",
58 "\nfirst to congratulate you on your success. It was quite a feat.",
59 "\nIt was also very profitable for you...",
60 "\n\n The Dungeon Master has informed us that you brought",
61 "1",
62 "\ncounty of Larn is in dire need of funds, we have spared no time",
63 "2",
64 "\nof this notice, and is due within 5 days. Failure to pay will",
65 "\nmean penalties. Once again, congratulations, We look forward",
66 "\nto your future successful expeditions.\n",
67 NULL,
68 "From: His Majesty King Wilfred of Larndom\n",
69 "~s a noble deed\n",
70 "\n I have heard of your magnificent feat, and I, King Wilfred,",
71 "\nforthwith declare today to be a national holiday. Furthermore,",
72 "\nhence three days, ye be invited to the castle to receive the",
73 "\nhonour of Knight of the realm. Upon thy name shall it be written...",
74 "\n\nBravery and courage be yours.",
75 "\n\nMay you live in happiness forevermore...\n",
76 NULL,
77 "From: Count Endelford\n",
78 "~s You Bastard!\n",
79 "\n I have heard (from sources) of your journey. Congratulations!",
80 "\nYou Bastard! With several attempts I have yet to endure the",
81 " caves,\nand you, a nobody, makes the journey! From this time",
82 " onward, bewarned\nupon our meeting you shall pay the price!\n",
83 NULL,
84 "From: Mainair, Duke of Larnty\n",
85 "~s High Praise\n",
86 "\n With certainty, a hero I declare to be amongst us! A nod of",
87 "\nfavour I send to thee. Me thinks Count Endelford this day of",
88 "\nright breath'eth fire as of dragon of whom ye are slayer. I",
89 "\nyearn to behold his anger and jealously. Should ye choose to",
90 "\nunleash some of thy wealth upon those who be unfortunate, I,",
91 "\nDuke Mainair, shall equal thy gift also.\n",
92 NULL,
93 "From: St. Mary's Children's Home\n",
94 "~s these poor children\n",
95 "\n News of your great conquests has spread to all of Larndom.",
96 "\nMight I have a moment of a great adventurers's time? We here at",
97 "\nSt. Mary's Children's Home are very poor, and many children are",
98 "\nstarving. Disease is widespread and very often fatal without",
99 "\ngood food. Could you possibly find it in your heart to help us",
100 "\nin our plight? Whatever you could give will help much.",
101 "\n(your gift is tax deductible)\n",
102 NULL,
103 "From: The National Cancer Society of Larn\n",
104 "~s hope\n",
105 "\nCongratulations on your successful expedition. We are sure much",
106 "\ncourage and determination were needed on your quest. There are",
107 "\nmany though, that could never hope to undertake such a journey",
108 "\ndue to an enfeebling disease -- cancer. We at the National",
109 "\nCancer Society of Larn wish to appeal to your philanthropy in",
110 "\norder to save many good people -- possibly even yourself a few",
111 "\nyears from now. Much work needs to be done in researching this",
112 "\ndreaded disease, and you can help today. Could you please see it",
113 "\nin your heart to give generously? Your continued good health",
114 "\ncan be your everlasting reward.\n",
115 NULL
116 };
117
118 /*
119 * function to mail the letters to the player if a winner
120 */
121
122 void
123 mailbill()
124 {
125 register int i;
126 char fname[32];
127 char buf[128];
128 char **cp;
129 int fd;
130
131 wait(0);
132 if (fork() == 0) {
133 resetscroll();
134 cp = mail;
135 sprintf(fname, "/tmp/#%dlarnmail", getpid());
136 for (i = 0; i < 6; i++) {
137 if ((fd = open(fname, O_WRONLY | O_TRUNC | O_CREAT,
138 0666)) == -1)
139 exit(0);
140 while (*cp != NULL) {
141 if (*cp[0] == '1') {
142 sprintf(buf, "\n%d gold pieces back with you from your journey. As the",
143 (long)c[GOLD]);
144 write(fd, buf, strlen(buf));
145 } else if (*cp[0] == '2') {
146 sprintf(buf, "\nin preparing your tax bill. You owe %d gold pieces as", (long)c[GOLD]*TAXRATE);
147 write(fd, buf, strlen(buf));
148 } else
149 write(fd, *cp, strlen(*cp));
150 cp++;
151 }
152 cp++;
153
154 close(fd);
155 sprintf(buf, "mail -I %s < %s > /dev/null",
156 loginname, fname);
157 system(buf);
158 unlink(fname);
159 }
160 }
161 exit(0);
162 }