X-Git-Url: http://git.sourceforge.jp/view?p=ffftp%2Fffftp.git;a=blobdiff_plain;f=wildcard.c;h=91467567e89c96f2b5eeb958634a2a4115ca0bdf;hp=20acbe650fef41b91ab215f8a7e3b8377ec8fe0f;hb=39667277c869f8eea15387ba7f30e97710721195;hpb=2bf85c03c1e059a2f75dbd48ef73be5961e12414 diff --git a/wildcard.c b/wildcard.c index 20acbe6..9146756 100644 --- a/wildcard.c +++ b/wildcard.c @@ -1,6 +1,6 @@ -/*============================================================================= +/*============================================================================= * -* ƒƒCƒ‹ƒhƒJ[ƒhŒŸõ +* ワイルドカード検索 * =============================================================================== / Copyright (C) 1997-2007 Sota. All rights reserved. @@ -30,31 +30,33 @@ #define STRICT #include #include -#include +// IPv6対応 +//#include +#include #include #include "common.h" #include "jreusr.h" -/*===== ƒvƒƒgƒ^ƒCƒv =====*/ +/*===== プロトタイプ =====*/ static int CheckNameMatch(char *str, char *regexp); -/*----- ƒƒCƒ‹ƒhƒJ[ƒh‚Ƀ}ƒbƒ`‚·‚é‚©‚Ç‚¤‚©‚ð•Ô‚· ------------------------------ +/*----- ワイルドカードにマッチするかどうかを返す ------------------------------ * * Parameter -* char *str : •¶Žš—ñ -* char *regexp : ƒƒCƒ‹ƒhƒJ[ƒhŒŸõŽ® +* char *str : 文字列 +* char *regexp : ワイルドカード検索式 * * Return Value -* int ƒXƒe[ƒ^ƒX -* SUCCESS/FAIL +* int ステータス +* FFFTP_SUCCESS/FFFTP_FAIL * * Note -* VAX VMS‚ÌŽž‚Í ; ˆÈ~‚Í–³Ž‹‚·‚é +* VAX VMSの時は ; 以降は無視する *----------------------------------------------------------------------------*/ int CheckFname(char *str, char *regexp) @@ -67,14 +69,14 @@ int CheckFname(char *str, char *regexp) strcpy(p1, regexp); strcpy(p2, str); - /* VAX VMS‚ÌŽž‚Ì‚½‚߂̏ˆ— */ + /* VAX VMSの時のための処理 */ if(AskHostType() == HTYPE_VMS) { if((p = strchr(p2, ';')) != NULL) *p = NUL; } - /* *? ‚Æ‚© ** ‚Æ‚©‚ðíœ */ + /* *? とか ** とかを削除 */ for(p = p1; *p != NUL; p++) { while((*p == '*') && ((*(p+1) == '?') || (*(p+1) == '*'))) @@ -84,14 +86,14 @@ int CheckFname(char *str, char *regexp) if((strcmp(p1, "*.*") == 0) || (strcmp(p1, "????????.???") == 0)) strcpy(p1, "*"); - Sts = SUCCESS; + Sts = FFFTP_SUCCESS; if(strcmp(p1, "*") != 0) { if(strcmp(p1, "*.") == 0) { p = strchr(p2, '.'); if((p != NULL) && (*(p+1) != NUL)) - Sts = FAIL; + Sts = FFFTP_FAIL; } else Sts = CheckNameMatch(p2, p1); @@ -100,15 +102,15 @@ int CheckFname(char *str, char *regexp) } -/*----- ƒƒCƒ‹ƒhƒJ[ƒhŒŸõƒTƒuƒ‹[ƒ`ƒ“ ---------------------------------------- +/*----- ワイルドカード検索サブルーチン ---------------------------------------- * * Parameter -* char *str : •¶Žš—ñ -* char *regexp : ƒƒCƒ‹ƒhƒJ[ƒhŒŸõŽ® +* char *str : 文字列 +* char *regexp : ワイルドカード検索式 * * Return Value -* int ƒXƒe[ƒ^ƒX -* SUCCESS/FAIL +* int ステータス +* FFFTP_SUCCESS/FFFTP_FAIL *----------------------------------------------------------------------------*/ static int CheckNameMatch(char *str, char *regexp) @@ -128,23 +130,23 @@ static int CheckNameMatch(char *str, char *regexp) /* Look for a character matching the one after the '*' */ p++; if(*p == NUL) - return SUCCESS; /* Automatic match */ + return FFFTP_SUCCESS; /* Automatic match */ while(*str != NUL) { while((*str != NUL) && (toupper(*p)!=toupper(*str))) str++; if(CheckNameMatch(str, p)) - return SUCCESS; + return FFFTP_SUCCESS; if(*str == NUL) - return FAIL; + return FFFTP_FAIL; else str++; } - return FAIL; + return FFFTP_FAIL; default: if(toupper(*str) != toupper(*p)) - return FAIL; + return FFFTP_FAIL; str++; p++; break; @@ -152,10 +154,10 @@ static int CheckNameMatch(char *str, char *regexp) } if((*p == NUL) && (*str == NUL)) - return SUCCESS; + return FFFTP_SUCCESS; if ((*p != NUL) && (str[0] == '.') && (str[1] == 0)) - return(SUCCESS); + return(FFFTP_SUCCESS); if ((*str == NUL) && (*p == '?')) { @@ -165,8 +167,8 @@ static int CheckNameMatch(char *str, char *regexp) } if((*str == NUL) && (*p == '*') && (p[1] == '\0')) - return SUCCESS; + return FFFTP_SUCCESS; - return FAIL; + return FFFTP_FAIL; }