xref: /csrg-svn/usr.bin/uucp/libuu/prefix.c (revision 48652)
1*48652Sbostic /*-
2*48652Sbostic  * Copyright (c) 1985 The Regents of the University of California.
3*48652Sbostic  * All rights reserved.
4*48652Sbostic  *
5*48652Sbostic  * %sccs.include.proprietary.c%
6*48652Sbostic  */
7*48652Sbostic 
813666Ssam #ifndef lint
9*48652Sbostic static char sccsid[] = "@(#)prefix.c	5.4 (Berkeley) 04/24/91";
10*48652Sbostic #endif /* not lint */
1113666Ssam 
1223616Sbloom /*LINTLIBRARY*/
1323616Sbloom 
1417838Sralph /*
1517838Sralph  *	check s2 for prefix s1
1613666Ssam  *
1713666Ssam  *	return 0 - !=
1813666Ssam  *	return 1 - ==
1913666Ssam  */
2013666Ssam 
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 
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