/*
 * 5799-WZQ (C) COPYRIGHT = NONE
 * LICENSED MATERIALS - PROPERTY OF IBM
 */
/* $Header:domainname.c 12.0$ */
/* $ACIS:domainname.c 12.0$ */
/* $Source: /ibm/acis/usr/src/nfs/bin/RCS/domainname.c,v $ */

#ifndef lint
static char *rcsid = "$Header:domainname.c 12.0$";
#endif

#include <sys/nfs_defines.h>

/* @(#)domainname.c	1.2 87/07/17 3.2/4.3NFSSRC */
/* @(#)domainname.c	1.2 86/11/11 NFSSRC */
#ifndef lint
static	char sccsid[] = "@(#)domainname.c 1.1 86/09/24 Copyr 1984 Sun Micro";
#endif
/*
 * domainname -- get (or set domainname)
 */
#include <stdio.h>
#include <sys/param.h>

char domainname[MAXHOSTNAMELEN];
extern int errno;

main(argc,argv)
	char *argv[];
{
	int	myerrno;

	argc--;
	argv++;
	if (argc) {
		if (setdomainname(*argv,strlen(*argv)))
			perror("setdomainname");
		myerrno = errno;
	} else {
		getdomainname(domainname,sizeof(domainname));
		myerrno = errno;
		printf("%s\n",domainname);
	}
	exit(myerrno);
}
