1 /*=============================================================================
\r
3 *
\83\8f\83C
\83\8b\83h
\83J
\81[
\83h
\8c\9f\8dõ
\r
5 ===============================================================================
\r
6 / Copyright (C) 1997-2007 Sota. All rights reserved.
\r
8 / Redistribution and use in source and binary forms, with or without
\r
9 / modification, are permitted provided that the following conditions
\r
12 / 1. Redistributions of source code must retain the above copyright
\r
13 / notice, this list of conditions and the following disclaimer.
\r
14 / 2. Redistributions in binary form must reproduce the above copyright
\r
15 / notice, this list of conditions and the following disclaimer in the
\r
16 / documentation and/or other materials provided with the distribution.
\r
18 / THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
\r
19 / IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
\r
20 / OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
\r
21 / IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
\r
22 / INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
\r
23 / BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
\r
24 / USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
\r
25 / ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
\r
26 / (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
\r
27 / THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\r
28 /============================================================================*/
\r
33 #include <winsock.h>
\r
34 #include <windowsx.h>
\r
40 /*=====
\83v
\83\8d\83g
\83^
\83C
\83v =====*/
\r
42 static int CheckNameMatch(char *str, char *regexp);
\r
46 /*-----
\83\8f\83C
\83\8b\83h
\83J
\81[
\83h
\82É
\83}
\83b
\83`
\82·
\82é
\82©
\82Ç
\82¤
\82©
\82ð
\95Ô
\82· ------------------------------
\r
49 * char *str :
\95¶
\8e\9a\97ñ
\r
50 * char *regexp :
\83\8f\83C
\83\8b\83h
\83J
\81[
\83h
\8c\9f\8dõ
\8e®
\r
53 * int
\83X
\83e
\81[
\83^
\83X
\r
57 * VAX VMS
\82Ì
\8e\9e\82Í ;
\88È
\8d~
\82Í
\96³
\8e\8b\82·
\82é
\r
58 *----------------------------------------------------------------------------*/
\r
60 int CheckFname(char *str, char *regexp)
\r
63 char p1[FMAX_PATH+1];
\r
64 char p2[FMAX_PATH+1];
\r
70 /* VAX VMS
\82Ì
\8e\9e\82Ì
\82½
\82ß
\82Ì
\8f\88\97\9d */
\r
71 if(AskHostType() == HTYPE_VMS)
\r
73 if((p = strchr(p2, ';')) != NULL)
\r
77 /* *?
\82Æ
\82© **
\82Æ
\82©
\82ð
\8dí
\8f\9c */
\r
78 for(p = p1; *p != NUL; p++)
\r
80 while((*p == '*') && ((*(p+1) == '?') || (*(p+1) == '*')))
\r
81 memmove(p+1, p+2, strlen(p+2)+1);
\r
84 if((strcmp(p1, "*.*") == 0) || (strcmp(p1, "????????.???") == 0))
\r
88 if(strcmp(p1, "*") != 0)
\r
90 if(strcmp(p1, "*.") == 0)
\r
92 p = strchr(p2, '.');
\r
93 if((p != NULL) && (*(p+1) != NUL))
\r
97 Sts = CheckNameMatch(p2, p1);
\r
103 /*-----
\83\8f\83C
\83\8b\83h
\83J
\81[
\83h
\8c\9f\8dõ
\83T
\83u
\83\8b\81[
\83`
\83\93 ----------------------------------------
\r
106 * char *str :
\95¶
\8e\9a\97ñ
\r
107 * char *regexp :
\83\8f\83C
\83\8b\83h
\83J
\81[
\83h
\8c\9f\8dõ
\8e®
\r
110 * int
\83X
\83e
\81[
\83^
\83X
\r
112 *----------------------------------------------------------------------------*/
\r
114 static int CheckNameMatch(char *str, char *regexp)
\r
118 for(p = regexp; (*p != NUL) && (*str != NUL); )
\r
128 /* Look for a character matching the one after the '*' */
\r
131 return SUCCESS; /* Automatic match */
\r
134 while((*str != NUL) && (toupper(*p)!=toupper(*str)))
\r
136 if(CheckNameMatch(str, p))
\r
146 if(toupper(*str) != toupper(*p))
\r
154 if((*p == NUL) && (*str == NUL))
\r
157 if ((*p != NUL) && (str[0] == '.') && (str[1] == 0))
\r
160 if ((*str == NUL) && (*p == '?'))
\r
167 if((*str == NUL) && (*p == '*') && (p[1] == '\0'))
\r