FreeBSD/sys/cam/cam.c
/*
 * Compare string with pattern, returning 0 on match.
 * Short pattern matches trailing blanks in name,
 * wildcard '*' in pattern matches rest of name,
 * wildcard '?' matches a single non-space character.
 */
Compare string with pattern, returning 0 on match.
Short pattern matches trailing blanks in name,
wildcard '*' in pattern matches rest of name,
wildcard '?' matches a single non-space character.
Compare string with pattern returning 0 on match . Short pattern matches trailing blanks in name wildcard ' * ' in pattern matches rest of name wildcard ' ? ' matches a single non - space character .
int
cam_strmatch(const u_int8_t *str, const u_int8_t *pattern, int str_len)
{
	while (*pattern != '\0'&& str_len > 0) {  
		if (*pattern == '*') {
			return (0);
		}
		if ((*pattern != *str)
		 && (*pattern != '?' || *str == ' ')) {
			return (1);
		}
		pattern++;
		str++;
		str_len--;
	}
	while (str_len > 0 && *str == ' ') {
		str++;
		str_len--;
	}
	if (str_len > 0 && *str == 0)
		str_len = 0;
	return (str_len);
}
int cam_strmatch ( const u_int8_t * str , const u_int8_t * pattern , int str_len ) { while ( * pattern != ' \0 ' && str_len > 0 ) { if ( * pattern == ' ' ) { return ( 0 ) ; } if ( ( * pattern != * str ) && ( * pattern != ' ' || * str == ' ' ) ) { return ( 1 ) ; } pattern ++ ; str ++ ; str_len -- ; } while ( str_len > 0 && * str == ' ' ) { str ++ ; str_len -- ; } if ( str_len > 0 && * str == 0 ) str_len = 0 ; return ( str_len ) ; }
Compare string with pattern, returning 0 on match.
Compare string with pattern returning 0 on match .