-/* $NetBSD: bill.c,v 1.6 2001/02/05 00:57:32 christos Exp $ */
+/* $NetBSD: bill.c,v 1.11 2011/08/29 20:30:37 joerg Exp $ */
/*-
* Copyright (c) 1991 The Regents of the University of California.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
#if 0
static char sccsid[] = "@(#)bill.c 5.2 (Berkeley) 5/28/91";
#else
-__RCSID("$NetBSD: bill.c,v 1.6 2001/02/05 00:57:32 christos Exp $");
+__RCSID("$NetBSD: bill.c,v 1.11 2011/08/29 20:30:37 joerg Exp $");
#endif
#endif /* not lint */
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
+#include <paths.h>
#include "header.h"
#include "extern.h"
/* bill.c Larn is copyrighted 1986 by Noah Morgan. */
-char *mail[] = {
+static const char *mail[] = {
"From: the LRS (Larn Revenue Service)\n",
"~s undeclared income\n",
"\n We have heard you survived the caverns of Larn. Let me be the",
*/
void
-mailbill()
+mailbill(void)
{
int i;
char fname[32];
char buf[128];
- char **cp;
+ const char **cp;
int fd;
wait(0);
if (fork() == 0) {
resetscroll();
cp = mail;
- snprintf(fname, sizeof(fname), "/tmp/#%dlarnmail", getpid());
+ snprintf(fname, sizeof(fname), "%slarnmail.XXXXXX", _PATH_TMP);
for (i = 0; i < 6; i++) {
- if ((fd = open(fname, O_WRONLY | O_TRUNC | O_CREAT,
- 0666)) == -1)
+ if ((fd = mkstemp(fname)) == -1)
exit(0);
while (*cp != NULL) {
if (*cp[0] == '1') {