NetBSD/bin/domainname/domainname.c

46 lines
731 B
C
Raw Normal View History

1993-08-02 21:15:10 +04:00
#ifndef lint
static char rcsid[] = "$Id: domainname.c,v 1.3 1993/09/10 01:24:46 jtc Exp $";
1993-08-02 21:15:10 +04:00
#endif /* not lint */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/param.h>
static void usage __P((void));
main(argc, argv)
int argc;
char **argv;
{
char dom[MAXHOSTNAMELEN];
if( argc>2 ) {
usage ();
/* NOTREACHED */
}
if( argc==2 ) {
if( setdomainname(argv[1], strlen(argv[1])+1) == -1) {
perror("setdomainname");
exit(1);
}
} else {
if( getdomainname(dom, sizeof(dom)) == -1) {
perror("getdomainname");
exit(1);
}
printf("%s\n", dom);
}
exit(0);
}
static void
usage ()
{
(void)fprintf(stderr, "usage: domainname [name-of-domain]\n");
exit(1);
}