date and time created 93/04/04 13:58:57 by mckusick
authorKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Mon, 5 Apr 1993 04:58:57 +0000 (20:58 -0800)
committerKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Mon, 5 Apr 1993 04:58:57 +0000 (20:58 -0800)
SCCS-vsn: lib/libc/gen/gethostname.c 5.1
SCCS-vsn: lib/libc/gen/sethostname.c 5.1

usr/src/lib/libc/gen/gethostname.c [new file with mode: 0644]
usr/src/lib/libc/gen/sethostname.c [new file with mode: 0644]

diff --git a/usr/src/lib/libc/gen/gethostname.c b/usr/src/lib/libc/gen/gethostname.c
new file mode 100644 (file)
index 0000000..d13f79d
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 1989 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * %sccs.include.redist.c%
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)gethostname.c      5.1 (Berkeley) %G%";
+#endif /* LIBC_SCCS and not lint */
+
+#include <sys/param.h>
+#include <sys/sysctl.h>
+
+#if __STDC__
+long
+gethostname(char *name, int namelen)
+#else
+long
+gethostname(name, namelen)
+       char *name;
+       int namelen;
+#endif
+{
+       int mib[2];
+
+       mib[0] = CTL_KERN;
+       mib[1] = KERN_HOSTNAME;
+       return (sysctl(mib, 2, name, &namelen, NULL, 0));
+}
diff --git a/usr/src/lib/libc/gen/sethostname.c b/usr/src/lib/libc/gen/sethostname.c
new file mode 100644 (file)
index 0000000..2d4c5c6
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 1989 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * %sccs.include.redist.c%
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)sethostname.c      5.1 (Berkeley) %G%";
+#endif /* LIBC_SCCS and not lint */
+
+#include <sys/param.h>
+#include <sys/sysctl.h>
+
+#if __STDC__
+long
+sethostname(const char *name, int namelen)
+#else
+long
+sethostname(name, namelen)
+       char *name;
+       int namelen;
+#endif
+{
+       int mib[2];
+
+       mib[0] = CTL_KERN;
+       mib[1] = KERN_HOSTNAME;
+       return (sysctl(mib, 2, NULL, NULL, (void *)name, namelen));
+}