1 /* 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 */ 7 8 #if defined(LIBC_SCCS) && !defined(lint) 9 static char sccsid[] = "@(#)sethostname.c 8.1 (Berkeley) 06/04/93"; 10 #endif /* LIBC_SCCS and not lint */ 11 12 #include <sys/param.h> 13 #include <sys/sysctl.h> 14 15 #if __STDC__ 16 long 17 sethostname(const char *name, int namelen) 18 #else 19 long 20 sethostname(name, namelen) 21 char *name; 22 int namelen; 23 #endif 24 { 25 int mib[2]; 26 27 mib[0] = CTL_KERN; 28 mib[1] = KERN_HOSTNAME; 29 if (sysctl(mib, 2, NULL, NULL, (void *)name, namelen) == -1) 30 return (-1); 31 return (0); 32 } 33