158952Smckusick /* 258952Smckusick * Copyright (c) 1989 The Regents of the University of California. 358952Smckusick * All rights reserved. 458952Smckusick * 558952Smckusick * %sccs.include.redist.c% 658952Smckusick */ 758952Smckusick 858952Smckusick #if defined(LIBC_SCCS) && !defined(lint) 9*60350Storek static char sccsid[] = "@(#)gethostname.c 5.3 (Berkeley) 05/25/93"; 1058952Smckusick #endif /* LIBC_SCCS and not lint */ 1158952Smckusick 1258952Smckusick #include <sys/param.h> 1358952Smckusick #include <sys/sysctl.h> 1458952Smckusick 1558952Smckusick long 1658952Smckusick gethostname(name, namelen) 1758952Smckusick char *name; 1858952Smckusick int namelen; 1958952Smckusick { 2058952Smckusick int mib[2]; 21*60350Storek size_t size; 2258952Smckusick 2358952Smckusick mib[0] = CTL_KERN; 2458952Smckusick mib[1] = KERN_HOSTNAME; 25*60350Storek size = namelen; 26*60350Storek if (sysctl(mib, 2, name, &size, NULL, 0) == -1) 2758955Smckusick return (-1); 2858955Smckusick return (0); 2958952Smckusick } 30