smb_match.c revision 94fff7907278e4540aa7abee2b1b0ea71d36f7fa
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _KERNEL
#include <stdlib.h>
#include <string.h>
#else
#endif
#define SMB_CRC_POLYNOMIAL 0xD8B5D8B5
/*
* c Any non-special character matches itslef
* ? Match any character
* ab character 'a' followed by character 'b'
* S Any string of non-special characters
* AB String 'A' followed by string 'B'
* * Any String, including the empty string
*/
int
{
for (;;) {
switch (*patn) {
case 0:
return (*str == 0);
case '?':
if (*str != 0) {
str++;
patn++;
continue;
} else {
return (0);
}
/*NOTREACHED*/
#if 0
case '[':
patn++;
if (*patn == '!') {
invert = 1;
patn++;
}
for (;;) {
if (clower == 0)
break;
if (clower == ']') {
patn++;
break;
}
patn++;
if (*patn == '-') {
/* range */
patn++;
if (cupper == 0)
break;
patn++;
} else {
}
continue;
/* match */
if (invert)
return (0);
;
str++;
continue; /* THIS WON`T WORK */
}
if (invert) {
str++;
continue;
}
return (0);
#endif
case '*':
patn++;
if (*patn == 0)
return (1);
#if 0
/* accelerate */
while (*str) {
return (1);
str++;
}
return (0);
}
#endif
while (*str) {
return (1);
str++;
}
return (0);
default:
return (0);
str++;
patn++;
continue;
}
}
}
int
{
int avail;
char *ptr;
char name83[14];
avail--) {
}
while (avail--)
*(ptr++) = ' ';
*(ptr++) = '.';
if (*patn == '.')
patn++;
else if (*patn != 0)
return (0);
}
if (*patn != 0)
return (0);
while (avail--)
*(ptr++) = ' ';
*ptr = 0;
}
int
{
/*
* "<" is a special pattern that matches only those names that do
* NOT have an extension. "." and ".." are ok.
*/
return (1);
return (1);
return (0);
}
for (;;) {
switch (*patn) {
case 0:
return (*str == 0);
case '?':
if (*str != 0) {
str++;
patn++;
continue;
} else {
return (0);
}
/*NOTREACHED*/
case '*':
patn++;
if (*patn == 0)
return (1);
while (*str) {
return (1);
str++;
}
return (0);
default:
return (0);
}
str++;
patn++;
continue;
}
}
/* NOT REACHED */
}
{
uint8_t *p;
int i;
}
return (crc);
}