11926Swollman/* 21926Swollman * Copyright (c) 1989, 1993 31926Swollman * The Regents of the University of California. All rights reserved. 41926Swollman * 51926Swollman * Redistribution and use in source and binary forms, with or without 61926Swollman * modification, are permitted provided that the following conditions 71926Swollman * are met: 81926Swollman * 1. Redistributions of source code must retain the above copyright 91926Swollman * notice, this list of conditions and the following disclaimer. 101926Swollman * 2. Redistributions in binary form must reproduce the above copyright 111926Swollman * notice, this list of conditions and the following disclaimer in the 121926Swollman * documentation and/or other materials provided with the distribution. 131926Swollman * 4. Neither the name of the University nor the names of its contributors 141926Swollman * may be used to endorse or promote products derived from this software 151926Swollman * without specific prior written permission. 161926Swollman * 171926Swollman * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 181926Swollman * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 191926Swollman * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 201926Swollman * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 211926Swollman * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 221926Swollman * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 231926Swollman * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 241926Swollman * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 251926Swollman * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 261926Swollman * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 271926Swollman * SUCH DAMAGE. 281926Swollman */ 291926Swollman 301926Swollman#if defined(LIBC_SCCS) && !defined(lint) 3190039Sobrienstatic char sccsid[] = "@(#)sethostname.c 8.1 (Berkeley) 6/4/93"; 321926Swollman#endif /* LIBC_SCCS and not lint */ 3390039Sobrien#include <sys/cdefs.h> 3490039Sobrien__FBSDID("$FreeBSD$"); 351926Swollman 361926Swollman#include <sys/param.h> 371926Swollman#include <sys/sysctl.h> 381926Swollman 3917145Swollman#include <unistd.h> 4017145Swollman 4117145Swollmanint 421926Swollmansetdomainname(const char *name, int namelen) 431926Swollman{ 441926Swollman int mib[2]; 451926Swollman 461926Swollman mib[0] = CTL_KERN; 4717282Swollman mib[1] = KERN_NISDOMAINNAME; 481926Swollman if (sysctl(mib, 2, NULL, NULL, (void *)name, namelen) == -1) 491926Swollman return (-1); 501926Swollman return (0); 511926Swollman} 52