File:  [Research Unix] / researchv8dc / cmd / uucp / versys.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 17:21:59 2018 UTC (8 years, 3 months ago) by root
Branches: belllabs, MAIN
CVS tags: researchv8, HEAD
researchv8 Dan Cross

/*	/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);
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.