o Update dd(1) to accept capital letters (B, K, M, G) as size modifiers.
[dragonfly.git] / contrib / opie / libmissing / uname.c
blob5b51fa55122a6979bb5c49613a6c4a09d4eb5f3c
1 /* uname.c: A replacement for the uname function (sort of)
3 %%% copyright-cmetz
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>.
9 History:
11 Modified by cmetz for OPIE 2.3. Ifdef around gethostname().
12 Created by cmetz for OPIE 2.2.
14 #include "opie_cfg.h"
15 #if HAVE_SYS_PARAM_H
16 #include <sys/param.h>
17 #endif /* HAVE_SYS_PARAM_H */
18 #include "opie.h"
20 int uname FUNCTION(struct utsname *buf)
22 #if HAVE_GETHOSTNAME
23 char hostname[MAXHOSTNAMELEN], *c;
25 memset(buf, 0, sizeof(buf));
27 if (gethostname(hostname, sizeof(hostname)-1) < 0)
28 return -1;
30 hostname[sizeof(hostname) - 1] = 0;
32 if (c = strchr(hostname, '.')) {
33 *c = 0;
36 strncpy(buf->nodename, hostname, sizeof(buf->nodename) - 1);
37 return 0;
38 #else /* HAVE_GETHOSTNAME */
39 strncpy(buf->nodename, "unknown", sizeof(buf->nodename) - 1);
40 return 0;
41 #endif /* HAVE_GETHOSTNAME */