summaryrefslogtreecommitdiffstats
path: root/battlestar/init.c
diff options
context:
space:
mode:
authorjsm <jsm@NetBSD.org>2000-09-09 09:37:58 +0000
committerjsm <jsm@NetBSD.org>2000-09-09 09:37:58 +0000
commitba39c14448dbd478ef92c7c05e19d12ced6c7177 (patch)
treed365e7cf9cc7c3b41610dae6b9e399713b1aede8 /battlestar/init.c
parent964291ab94b8c99e06c7eb639459f9a62dabeb7c (diff)
downloadbsdgames-darwin-ba39c14448dbd478ef92c7c05e19d12ced6c7177.tar.gz
bsdgames-darwin-ba39c14448dbd478ef92c7c05e19d12ced6c7177.tar.zst
bsdgames-darwin-ba39c14448dbd478ef92c7c05e19d12ced6c7177.zip
Store copy of username with strdup rather than using a fixed length
buffer. Also make initialization functions and arrays static.
Diffstat (limited to 'battlestar/init.c')
-rw-r--r--battlestar/init.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/battlestar/init.c b/battlestar/init.c
index 854021a8..9670ea84 100644
--- a/battlestar/init.c
+++ b/battlestar/init.c
@@ -1,4 +1,4 @@
-/* $NetBSD: init.c,v 1.11 1999/09/18 16:47:11 jsm Exp $ */
+/* $NetBSD: init.c,v 1.12 2000/09/09 09:37:58 jsm Exp $ */
/*
* Copyright (c) 1983, 1993
@@ -38,12 +38,16 @@
#if 0
static char sccsid[] = "@(#)init.c 8.4 (Berkeley) 4/30/95";
#else
-__RCSID("$NetBSD: init.c,v 1.11 1999/09/18 16:47:11 jsm Exp $");
+__RCSID("$NetBSD: init.c,v 1.12 2000/09/09 09:37:58 jsm Exp $");
#endif
#endif /* not lint */
#include "extern.h"
+static int checkout __P((const char *));
+static const char *getutmp __P((void));
+static int wizard __P((const char *));
+
void
initialize(filename)
const char *filename;
@@ -56,7 +60,7 @@ initialize(filename)
puts("Admiral D.W. Riggle\n");
location = dayfile;
srand(getpid());
- getutmp(username);
+ username = getutmp();
wordinit();
if (filename == NULL) {
direction = NORTH;
@@ -77,17 +81,20 @@ initialize(filename)
signal(SIGINT, diesig);
}
-void
-getutmp(uname)
- char *uname;
+static const char *
+getutmp()
{
struct passwd *ptr;
ptr = getpwuid(getuid());
- strncpy(uname, ptr ? ptr->pw_name : "", 8);
+ if (ptr == NULL)
+ return "";
+ else
+ return strdup(ptr->pw_name);
}
-const char *const list[] = { /* hereditary wizards */
+/* Hereditary wizards. A configuration file might make more sense. */
+static const char *const list[] = {
"riggle",
"chris",
"edward",
@@ -98,14 +105,14 @@ const char *const list[] = { /* hereditary wizards */
0
};
-const char *const badguys[] = {
+static const char *const badguys[] = {
"wnj",
"root",
"ted",
0
};
-int
+static int
wizard(uname)
const char *uname;
{
@@ -116,7 +123,7 @@ wizard(uname)
return flag;
}
-int
+static int
checkout(uname)
const char *uname;
{