xref: /csrg-svn/usr.bin/uucp/libuu/prefix.c (revision 62386)
148652Sbostic /*-
2*62386Sbostic  * Copyright (c) 1985, 1993
3*62386Sbostic  *	The Regents of the University of California.  All rights reserved.
448652Sbostic  *
548652Sbostic  * %sccs.include.proprietary.c%
648652Sbostic  */
748652Sbostic 
813666Ssam #ifndef lint
9*62386Sbostic static char sccsid[] = "@(#)prefix.c	8.1 (Berkeley) 06/06/93";
1048652Sbostic #endif /* not lint */
1113666Ssam 
1223616Sbloom /*LINTLIBRARY*/
1323616Sbloom 
1417838Sralph /*
1517838Sralph  *	check s2 for prefix s1
1613666Ssam  *
1713666Ssam  *	return 0 - !=
1813666Ssam  *	return 1 - ==
1913666Ssam  */
2013666Ssam 
prefix(s1,s2)2113666Ssam prefix(s1, s2)
2213666Ssam register char *s1, *s2;
2313666Ssam {
2413666Ssam 	register char c;
2513666Ssam 
2613666Ssam 	while ((c = *s1++) == *s2++)
2713666Ssam 		if (c == '\0')
2817838Sralph 			return 1;
2917838Sralph 	return c == '\0';
3013666Ssam }
3113666Ssam 
3217838Sralph /*
3317838Sralph  *	check s2 for prefix s1 with a wildcard character ?
3413666Ssam  *
3513666Ssam  *	return 0 - !=
3613666Ssam  *	return 1 - ==
3713666Ssam  */
3813666Ssam 
wprefix(s1,s2)3913666Ssam wprefix(s1, s2)
4013666Ssam register char *s1, *s2;
4113666Ssam {
4213666Ssam 	register char c;
4313666Ssam 
4413666Ssam 	while ((c = *s1++) != '\0')
4513666Ssam 		if (*s2 == '\0'  ||  (c != *s2++  &&  c != '?'))
4617838Sralph 			return 0;
4717838Sralph 	return 1;
4813666Ssam }
49