V8/usr/src/cmd/uucp/versys.c

Compare this file to the similar file:
Show the results in this format:

/*	/sccs/src/cmd/uucp/s.versys.c
	versys.c	1.1	8/30/84 17:38:20
*/
#include "uucp.h"
VERSION(@(#)versys.c	1.1);

/*
 * verify system name
 * if abbr is nonzero, allow the name to be truncated
 * for compatibility with old uucps
 * input:
 *	name	-> system name
 * returns:  
 *	0	-> success
 *	FAIL	-> failure
 */

#define	OLDLEN	7	/* max length of old uucp names */

versys(name, abbr)
char *name;
int abbr;
{
	register FILE *fp;
	register char *iptr;
	char line[300];
	FILE *sysopen();

	if (EQUALS(name, Myname))
		return(0);

#ifndef MANYSYS
	fp = fopen(SYSFILE, "r");
	if (fp == NULL)
		return(FAIL);
#else
	sysrewind();
	while ((fp = sysopen("r")) != NULL) {
#endif
	
	while (fgets(line, sizeof(line) ,fp) != NULL) {
		if((line[0] == '#') || (line[0] == ' ') || (line[0] == '\t') || 
			(line[0] == '\n'))
			continue;

		if ((iptr=strpbrk(line, " \t")) == NULL)
		    continue;	/* why? */
		*iptr = '\0';
		if (EQUALS(name, line)) {
			(void) fclose(fp);
			return (0);
		}
		if (abbr && strlen(name) == OLDLEN && strncmp(name, line, OLDLEN) == SAME) {
			(void) fclose(fp);
			return(0);
		}
	}
	fclose(fp);
#ifdef MANYSYS
	}
#endif
	return(FAIL);
}