1 /* uname.c: A replacement for the uname function (sort of)
4 This software is Copyright 1996 by Craig Metz, All Rights Reserved.
5 The Inner Net License Version 2 applies to this software.
6 You should have received a copy of the license with this software. If
7 you didn't get a copy, you may request one from <license@inner.net>.
11 Modified by cmetz for OPIE 2.3. Ifdef around gethostname().
12 Created by cmetz for OPIE 2.2.
16 #include <sys/param.h>
17 #endif /* HAVE_SYS_PARAM_H */
20 int uname FUNCTION(struct utsname *buf)
23 char hostname[MAXHOSTNAMELEN], *c;
25 memset(buf, 0, sizeof(buf));
27 if (gethostname(hostname, sizeof(hostname)-1) < 0)
30 hostname[sizeof(hostname) - 1] = 0;
32 if (c = strchr(hostname, '.')) {
36 strncpy(buf->nodename, hostname, sizeof(buf->nodename) - 1);
38 #else /* HAVE_GETHOSTNAME */
39 strncpy(buf->nodename, "unknown", sizeof(buf->nodename) - 1);
41 #endif /* HAVE_GETHOSTNAME */