1993-08-02 21:15:10 +04:00
|
|
|
#ifndef lint
|
1993-09-10 05:24:45 +04:00
|
|
|
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 */
|
|
|
|
|
1993-04-02 16:24:21 +04:00
|
|
|
#include <stdio.h>
|
1993-09-10 05:24:45 +04:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <sys/param.h>
|
|
|
|
|
|
|
|
static void usage __P((void));
|
1993-04-02 16:24:21 +04:00
|
|
|
|
|
|
|
main(argc, argv)
|
1993-09-10 05:24:45 +04:00
|
|
|
int argc;
|
|
|
|
char **argv;
|
1993-04-02 16:24:21 +04:00
|
|
|
{
|
|
|
|
char dom[MAXHOSTNAMELEN];
|
|
|
|
|
|
|
|
if( argc>2 ) {
|
1993-09-10 05:24:45 +04:00
|
|
|
usage ();
|
|
|
|
/* NOTREACHED */
|
1993-04-02 16:24:21 +04:00
|
|
|
}
|
1993-09-10 05:24:45 +04:00
|
|
|
|
1993-04-02 16:24:21 +04:00
|
|
|
if( argc==2 ) {
|
|
|
|
if( setdomainname(argv[1], strlen(argv[1])+1) == -1) {
|
|
|
|
perror("setdomainname");
|
|
|
|
exit(1);
|
|
|
|
}
|
1993-09-10 05:24:45 +04:00
|
|
|
} else {
|
|
|
|
if( getdomainname(dom, sizeof(dom)) == -1) {
|
|
|
|
perror("getdomainname");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
printf("%s\n", dom);
|
1993-04-02 16:24:21 +04:00
|
|
|
}
|
1993-09-10 05:24:45 +04:00
|
|
|
|
1993-04-02 16:24:21 +04:00
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
1993-09-10 05:24:45 +04:00
|
|
|
static void
|
|
|
|
usage ()
|
|
|
|
{
|
|
|
|
(void)fprintf(stderr, "usage: domainname [name-of-domain]\n");
|
|
|
|
exit(1);
|
|
|
|
}
|