File:  [CSRG BSD Unix] / 43BSD / contrib / notes / src / check.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 16:12:54 2018 UTC (8 years, 1 month ago) by root
Branches: MAIN, BSD
CVS tags: HEAD, BSD43
BSD 4.3

#include "parms.h"
#include "structs.h"

#ifdef	RCSIDENT
static char rcsid[] = "$Header: /var/lib/cvsd/repos/CSRG/43BSD/contrib/notes/src/check.c,v 1.1.1.1 2018/04/24 16:12:54 root Exp $";
#endif	RCSIDENT

/*
 *	check.c - checks the arguement supplied. If there are any
 *	.'s or /'s in the name a -1 is returned. 
 *	If the string is . and / free, then a zero is returned.
 *
 *	Ray Essick	23-nov-1981
 */


chkpath (p)
char   *p;
{
    int     count;

    if (*p == '.')
	return (-1);					/* hidden is bad */
    count = 0;
    while (*p && (*p != '/') && (*p != ' ') && (*p != ':'))
    {
	count++;
	p++;
    }
    if (count > NNLEN)
	return (-1);					/* name too long */
    if (*p == 0)
	return 0;
    else
	return (-1);
}

/*
 *	patcheck - look for a pattern character. These are the shell
 *	meta-characters ?, [, and *
 *	Return 0 if non exist in the string
 */
patcheck (p)
char   *p;
{
    register char  *q;
    q = p;
    while (*q && (*q != '?') && (*q != '[') && (*q != '*'))
	q++;
    return (*q != '\0');				/* return 0 if no pattern */
}

unix.superglobalmegacorp.com

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