xref: /csrg-svn/usr.bin/uucp/libuu/prefix.c (revision 17838)
113666Ssam #ifndef lint
2*17838Sralph static char sccsid[] = "@(#)prefix.c	5.2 (Berkeley) 01/22/85";
313666Ssam #endif
413666Ssam 
5*17838Sralph /*
6*17838Sralph  *	check s2 for prefix s1
713666Ssam  *
813666Ssam  *	return 0 - !=
913666Ssam  *	return 1 - ==
1013666Ssam  */
1113666Ssam 
1213666Ssam prefix(s1, s2)
1313666Ssam register char *s1, *s2;
1413666Ssam {
1513666Ssam 	register char c;
1613666Ssam 
1713666Ssam 	while ((c = *s1++) == *s2++)
1813666Ssam 		if (c == '\0')
19*17838Sralph 			return 1;
20*17838Sralph 	return c == '\0';
2113666Ssam }
2213666Ssam 
23*17838Sralph /*
24*17838Sralph  *	check s2 for prefix s1 with a wildcard character ?
2513666Ssam  *
2613666Ssam  *	return 0 - !=
2713666Ssam  *	return 1 - ==
2813666Ssam  */
2913666Ssam 
3013666Ssam wprefix(s1, s2)
3113666Ssam register char *s1, *s2;
3213666Ssam {
3313666Ssam 	register char c;
3413666Ssam 
3513666Ssam 	while ((c = *s1++) != '\0')
3613666Ssam 		if (*s2 == '\0'  ||  (c != *s2++  &&  c != '?'))
37*17838Sralph 			return 0;
38*17838Sralph 	return 1;
3913666Ssam }
40