summaryrefslogtreecommitdiffstats
path: root/lib/libutil
diff options
context:
space:
mode:
authorbrian <brian@FreeBSD.org>2001-03-14 20:51:15 +0000
committerbrian <brian@FreeBSD.org>2001-03-14 20:51:15 +0000
commit8a3521bf30812a63d06554a1d7f88325346ba791 (patch)
tree1fd8ec664de1ae606094fb5af213bf2e0b20a1dd /lib/libutil
parentfcbc4cffa6d09c75f5ee941cb1832a175599e1d2 (diff)
downloadFreeBSD-src-8a3521bf30812a63d06554a1d7f88325346ba791.zip
FreeBSD-src-8a3521bf30812a63d06554a1d7f88325346ba791.tar.gz
Move trimdomain() into it's own source file and tidy things up a bit.
Fix disorder in the Makefile. Reviewed (mostly) by: bde
Diffstat (limited to 'lib/libutil')
-rw-r--r--lib/libutil/Makefile8
-rw-r--r--lib/libutil/logwtmp.c58
2 files changed, 5 insertions, 61 deletions
diff --git a/lib/libutil/Makefile b/lib/libutil/Makefile
index 97a3e59..07db69a 100644
--- a/lib/libutil/Makefile
+++ b/lib/libutil/Makefile
@@ -6,10 +6,10 @@ SHLIB_MAJOR= 3
SHLIB_MINOR= 0
CFLAGS+=-Wall -DLIBC_SCCS -I${.CURDIR} -I${.CURDIR}/../../sys
CFLAGS+=-DINET6
-SRCS= login.c login_tty.c logout.c logwtmp.c pty.c \
- login_cap.c login_class.c login_auth.c login_times.c login_ok.c \
- login_crypt.c _secure_path.c uucplock.c property.c auth.c \
- realhostname.c fparseln.c stub.c
+SRCS= _secure_path.c auth.c fparseln.c login.c login_auth.c login_cap.c \
+ login_class.c login_crypt.c login_ok.c login_times.c login_tty.c \
+ logout.c logwtmp.c property.c pty.c realhostname.c stub.c \
+ trimdomain.c uucplock.c
INCS= libutil.h login_cap.h
MAN3+= login.3 login_auth.3 login_tty.3 logout.3 logwtmp.3 pty.3 \
diff --git a/lib/libutil/logwtmp.c b/lib/libutil/logwtmp.c
index 2648450..d77f8a4 100644
--- a/lib/libutil/logwtmp.c
+++ b/lib/libutil/logwtmp.c
@@ -42,16 +42,13 @@ static const char rcsid[] =
#include <sys/param.h>
#include <sys/socket.h>
-#include <sys/types.h>
#include <sys/file.h>
#include <sys/stat.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
#include <libutil.h>
#include <netdb.h>
+#include <stdio.h>
#include <string.h>
-#include <time.h>
#include <unistd.h>
#include <utmp.h>
@@ -60,59 +57,6 @@ static const char rcsid[] =
#define NI_WITHSCOPEID 0
#endif
-void
-trimdomain(char *fullhost, int hostsize)
-{
- static char domain[MAXHOSTNAMELEN];
- static int first = 1;
- static size_t dlen;
- char *s, *end;
- int spn, ok;
-
- if (first) {
- first = 0;
- if (gethostname(domain, sizeof(domain) - 1) == 0 &&
- (s = strchr(domain, '.')))
- memmove(domain, s + 1, strlen(s + 1) + 1);
- else
- domain[0] = '\0';
- dlen = strlen(domain);
- }
-
- if (domain[0] != '\0') {
- s = fullhost;
- end = s + hostsize + 1;
- for (; (s = memchr(s, '.', end - s)) != NULL; s++)
- if (!strncasecmp(s + 1, domain, dlen)) {
- if (s[dlen + 1] == '\0') {
- *s = '\0'; /* Found - lose the domain */
- break;
- } else if (s[dlen + 1] == ':') { /* $DISPLAY ? */
- ok = dlen + 2;
- spn = strspn(s + ok, "0123456789");
- if (spn > 0 && ok + spn - dlen <= end - s) {
- ok += spn;
- if (s[ok] == '\0') {
- /* host.domain:nn */
- memmove(s, s + dlen + 1, ok - dlen);
- break;
- } else if (s[ok] == '.') {
- ok++;
- spn = strspn(s + ok, "0123456789");
- if (spn > 0 && s[ok + spn] == '\0' &&
- ok + spn - dlen <= end - s) {
- /* host.domain:nn.nn */
- memmove(s, s + dlen + 1, ok + spn - dlen);
- break;
- }
- }
- }
- }
- }
- }
-}
-
-#include <stdio.h>
void
logwtmp(line, name, host)
OpenPOWER on IntegriCloud