OSDN Git Service

Fix bugs of confirmation of erasing host settings.
[ffftp/ffftp.git] / wildcard.c
index 20acbe6..9146756 100644 (file)
@@ -1,6 +1,6 @@
-/*=============================================================================\r
+/*=============================================================================\r
 *\r
-*                                                      \83\8f\83C\83\8b\83h\83J\81[\83h\8c\9f\8dõ\r
+*                                                      ワイルドカード検索\r
 *\r
 ===============================================================================\r
 / Copyright (C) 1997-2007 Sota. All rights reserved.\r
 #define        STRICT\r
 #include <stdio.h>\r
 #include <stdlib.h>\r
-#include <winsock.h>\r
+// IPv6対応\r
+//#include <winsock.h>\r
+#include <winsock2.h>\r
 #include <windowsx.h>\r
 \r
 #include "common.h"\r
 #include "jreusr.h"\r
 \r
 \r
-/*===== \83v\83\8d\83g\83^\83C\83v =====*/\r
+/*===== プロトタイプ =====*/\r
 \r
 static int CheckNameMatch(char *str, char *regexp);\r
 \r
 \r
 \r
-/*----- \83\8f\83C\83\8b\83h\83J\81[\83h\82É\83}\83b\83`\82·\82é\82©\82Ç\82¤\82©\82ð\95Ô\82· ------------------------------\r
+/*----- ワイルドカードにマッチするかどうかを返す ------------------------------\r
 *\r
 *      Parameter\r
-*              char *str : \95\8e\9a\97ñ\r
-*              char *regexp : \83\8f\83C\83\8b\83h\83J\81[\83h\8c\9f\8dõ\8e®\r
+*              char *str : 文字列\r
+*              char *regexp : ワイルドカード検索式\r
 *\r
 *      Return Value\r
-*              int \83X\83e\81[\83^\83X\r
-*                      SUCCESS/FAIL\r
+*              int ステータス\r
+*                      FFFTP_SUCCESS/FFFTP_FAIL\r
 *\r
 *      Note\r
-*              VAX VMS\82Ì\8e\9e\82Í ; \88È\8d~\82Í\96³\8e\8b\82·\82é\r
+*              VAX VMSの時は ; 以降は無視する\r
 *----------------------------------------------------------------------------*/\r
 \r
 int CheckFname(char *str, char *regexp)\r
@@ -67,14 +69,14 @@ int CheckFname(char *str, char *regexp)
        strcpy(p1, regexp);\r
        strcpy(p2, str);\r
 \r
-       /* VAX VMS\82Ì\8e\9e\82Ì\82½\82ß\82Ì\8f\88\97\9d */\r
+       /* VAX VMSの時のための処理 */\r
        if(AskHostType() == HTYPE_VMS)\r
        {\r
                if((p = strchr(p2, ';')) != NULL)\r
                        *p = NUL;\r
        }\r
 \r
-       /* *? \82Æ\82© ** \82Æ\82©\82ð\8dí\8f\9c */\r
+       /* *? とか ** とかを削除 */\r
        for(p = p1; *p != NUL; p++)\r
        {\r
                while((*p == '*') && ((*(p+1) == '?') || (*(p+1) == '*')))\r
@@ -84,14 +86,14 @@ int CheckFname(char *str, char *regexp)
        if((strcmp(p1, "*.*") == 0) || (strcmp(p1, "????????.???") == 0))\r
                strcpy(p1, "*");\r
 \r
-       Sts = SUCCESS;\r
+       Sts = FFFTP_SUCCESS;\r
        if(strcmp(p1, "*") != 0)\r
        {\r
                if(strcmp(p1, "*.") == 0)\r
                {\r
                        p = strchr(p2, '.');\r
                        if((p != NULL) && (*(p+1) != NUL))\r
-                               Sts = FAIL;\r
+                               Sts = FFFTP_FAIL;\r
                }\r
                else\r
                        Sts = CheckNameMatch(p2, p1);\r
@@ -100,15 +102,15 @@ int CheckFname(char *str, char *regexp)
 }\r
 \r
 \r
-/*----- \83\8f\83C\83\8b\83h\83J\81[\83h\8c\9f\8dõ\83T\83u\83\8b\81[\83`\83\93 ----------------------------------------\r
+/*----- ワイルドカード検索サブルーチン ----------------------------------------\r
 *\r
 *      Parameter\r
-*              char *str : \95\8e\9a\97ñ\r
-*              char *regexp : \83\8f\83C\83\8b\83h\83J\81[\83h\8c\9f\8dõ\8e®\r
+*              char *str : 文字列\r
+*              char *regexp : ワイルドカード検索式\r
 *\r
 *      Return Value\r
-*              int \83X\83e\81[\83^\83X\r
-*                      SUCCESS/FAIL\r
+*              int ステータス\r
+*                      FFFTP_SUCCESS/FFFTP_FAIL\r
 *----------------------------------------------------------------------------*/\r
 \r
 static int CheckNameMatch(char *str, char *regexp)\r
@@ -128,23 +130,23 @@ static int CheckNameMatch(char *str, char *regexp)
                                /* Look for a character matching the one after the '*' */\r
                                p++;\r
                                if(*p == NUL)\r
-                                       return SUCCESS; /* Automatic match */\r
+                                       return FFFTP_SUCCESS; /* Automatic match */\r
                                while(*str != NUL)\r
                                {\r
                                        while((*str != NUL) && (toupper(*p)!=toupper(*str)))\r
                                                str++;\r
                                        if(CheckNameMatch(str, p))\r
-                                               return SUCCESS;\r
+                                               return FFFTP_SUCCESS;\r
                                        if(*str == NUL)\r
-                                               return FAIL;\r
+                                               return FFFTP_FAIL;\r
                                        else\r
                                                str++;\r
                                }\r
-                               return FAIL;\r
+                               return FFFTP_FAIL;\r
 \r
                        default:\r
                                if(toupper(*str) != toupper(*p))\r
-                                       return FAIL;\r
+                                       return FFFTP_FAIL;\r
                                str++;\r
                                p++;\r
                                break;\r
@@ -152,10 +154,10 @@ static int CheckNameMatch(char *str, char *regexp)
        }\r
 \r
        if((*p == NUL) && (*str == NUL))\r
-               return SUCCESS;\r
+               return FFFTP_SUCCESS;\r
 \r
        if ((*p != NUL) && (str[0] == '.') && (str[1] == 0))\r
-               return(SUCCESS);\r
+               return(FFFTP_SUCCESS);\r
   \r
        if ((*str == NUL) && (*p == '?'))\r
        {\r
@@ -165,8 +167,8 @@ static int CheckNameMatch(char *str, char *regexp)
        }\r
 \r
        if((*str == NUL) && (*p == '*') && (p[1] == '\0'))\r
-               return SUCCESS;\r
+               return FFFTP_SUCCESS;\r
 \r
-       return FAIL;\r
+       return FFFTP_FAIL;\r
 }\r
 \r