strcpy(tempfile, _PATH_TMP); strcat(tempfile, _RDIST_TMP);
strlcpy(tempfile, _PATH_TMP, sizeof tempfile); strlcat(tempfile, _RDIST_TMP, sizeof tempfile);
main(argc, argv)	int argc;	char *argv[];{	char *arg;	int cmdargs = 0;	char *dhosts[NHOSTS], **hp = dhosts;	pw = getpwuid(userid = getuid());	if (pw == NULL) {		fprintf(stderr, "%s: Who are you?\n", argv[0]);		exit(1);	}	strcpy(user, pw->pw_name);	strcpy(homedir, pw->pw_dir);	groupid = pw->pw_gid;	gethostname(host, sizeof(host));	strcpy(tempfile, _PATH_TMP);	strcat(tempfile, _RDIST_TMP);	tempname = basename(tempfile);	while (--argc > 0) {		if ((arg = *++argv)[0] != '-')			break;		if (!strcmp(arg, "-Server"))			iamremote++;		else while (*++arg)			switch (*arg) {			case 'f':				if (--argc <= 0)					usage();				distfile = *++argv;				if (distfile[0] == '-' && distfile[1] == '\0')					fin = stdin;				break;			case 'm':				if (--argc <= 0)					usage();				if (hp >= &dhosts[NHOSTS-2]) {					fprintf(stderr, "rdist: too many destination hosts\n");					exit(1);				}				*hp++ = *++argv;				break;			case 'd':				if (--argc <= 0)					usage();				define(*++argv);				break;			case 'D':				debug++;				break;			case 'c':				cmdargs++;				break;			case 'n':				if (options & VERIFY) {					printf("rdist: -n overrides -v\n");					options &= ~VERIFY;				}				nflag++;				break;			case 'q':				qflag++;				break;			case 'b':				options |= COMPARE;				break;			case 'R':				options |= REMOVE;				break;			case 'v':				if (nflag) {					printf("rdist: -n overrides -v\n");					break;				}				options |= VERIFY;				break;			case 'w':				options |= WHOLE;				break;			case 'y':				options |= YOUNGER;				break;			case 'h':				options |= FOLLOW;				break;			case 'i':				options |= IGNLNKS;				break;			default:				usage();			}	}	*hp = NULL;#if	defined(DIRECT_RCMD)	seteuid(userid);#else	/* DIRECT_RCMD */	if (!iamremote && getuid() != geteuid()) {		error("This version of rdist should not be installed setuid.\n");		exit(1);	}#endif	/* DIRECT_RCMD */	if (mktemp(tempfile) == NULL)		fatal("cannot get temp file\n");	if (iamremote) {		server();		exit(nerrs != 0);	}	if (cmdargs)		docmdargs(argc, argv);	else {		if (fin == NULL) {			if(distfile == NULL) {				if((fin = fopen("distfile","r")) == NULL)					fin = fopen("Distfile", "r");			} else				fin = fopen(distfile, "r");			if (fin == NULL) {				perror(distfile ? distfile : "distfile");				exit(1);			}		}		yyparse();		if (nerrs == 0)			docmds(dhosts, argc, argv);	}	exit(nerrs != 0);}