Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src add utmpname()
details: https://anonhg.NetBSD.org/src/rev/9f4cd52521b4
branches: trunk
changeset: 534510:9f4cd52521b4
user: christos <christos%NetBSD.org@localhost>
date: Sun Jul 28 21:45:39 2002 +0000
description:
add utmpname()
diffstat:
include/utmp.h | 3 ++-
lib/libc/gen/utmp.c | 26 +++++++++++++++++++++++---
2 files changed, 25 insertions(+), 4 deletions(-)
diffs (76 lines):
diff -r 25f0558f018a -r 9f4cd52521b4 include/utmp.h
--- a/include/utmp.h Sun Jul 28 20:47:57 2002 +0000
+++ b/include/utmp.h Sun Jul 28 21:45:39 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: utmp.h,v 1.7 2002/07/27 23:57:02 christos Exp $ */
+/* $NetBSD: utmp.h,v 1.8 2002/07/28 21:45:39 christos Exp $ */
/*
* Copyright (c) 1988, 1993
@@ -65,6 +65,7 @@
};
__BEGIN_DECLS
+int utmpname(const char *);
void setutent(void);
struct utmp *getutent(void);
void endutent(void);
diff -r 25f0558f018a -r 9f4cd52521b4 lib/libc/gen/utmp.c
--- a/lib/libc/gen/utmp.c Sun Jul 28 20:47:57 2002 +0000
+++ b/lib/libc/gen/utmp.c Sun Jul 28 21:45:39 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: utmp.c,v 1.2 2002/07/28 20:46:43 christos Exp $ */
+/* $NetBSD: utmp.c,v 1.3 2002/07/28 21:46:03 christos Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -38,15 +38,18 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: utmp.c,v 1.2 2002/07/28 20:46:43 christos Exp $");
+__RCSID("$NetBSD: utmp.c,v 1.3 2002/07/28 21:46:03 christos Exp $");
#endif /* LIBC_SCCS and not lint */
+#include <sys/types.h>
+#include <sys/param.h>
#include <stdio.h>
#include <time.h>
#include <utmp.h>
static struct utmp utmp;
static FILE *ut;
+static char utfile[MAXPATHLEN] = _PATH_UTMP;
void
setutent(void)
@@ -60,7 +63,7 @@
getutent(void)
{
if (ut == NULL) {
- if ((ut = fopen(_PATH_UTMP, "r")) == NULL)
+ if ((ut = fopen(utfile, "r")) == NULL)
return NULL;
}
if (fread(&utmp, sizeof(utmp), 1, ut) == 1)
@@ -76,3 +79,20 @@
ut = NULL;
}
}
+
+int
+utmpname(const char *fname)
+{
+ size_t len = strlen(fname);
+
+ if (len >= sizeof(utfile))
+ return 0;
+
+ /* must not end in x! */
+ if (fname[len - 1] == 'x')
+ return 0;
+
+ (void)strcpy(utfile, fname);
+ endutent();
+ return 1;
+}
Home |
Main Index |
Thread Index |
Old Index