Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "typedefs.h"
00015 #include <stdio.h>
00016 #include <stdlib.h>
00017 #include <string.h>
00018 #define MATCH 0
00019 #define NOMATCH -1
00020
00021 INTS4 f_ut_wild(CHARS *pc_test, CHARS *pc_wild)
00022 {
00023 INTS4 l_wild,l_test,l_len;
00024 CHARS c_wild[256],c_test[256];
00025 CHARS *pc_h,*pc_n,*pc_w,*pc_s;
00026 strcpy(c_wild,pc_wild);
00027 strcpy(c_test,pc_test);
00028 pc_w=(CHARS *)c_wild;
00029 pc_s=(CHARS *)c_test;
00030 l_test=strlen(pc_s);
00031 while(1)
00032 {
00033 while(*pc_w=='*')
00034 {
00035 while(*pc_w=='*'){pc_w++; if(*pc_w==0)return MATCH;}
00036 pc_h=pc_w;
00037 while((*pc_h!='*')&(*pc_h!=0))pc_h++;
00038 if(*pc_h==0)
00039 {
00040
00041 l_len=strlen(pc_w);
00042 if(strlen(pc_s) < l_len) return NOMATCH;
00043 pc_s=(CHARS *)&c_test[l_test-l_len];
00044 }
00045 if(*pc_h=='*')
00046 {
00047
00048 *pc_h=0;
00049 if((pc_n=(CHARS *)strstr(pc_s,pc_w))==NULL) return NOMATCH;
00050 l_len=strlen(pc_w);
00051 *pc_h='*';
00052 pc_w=pc_h;
00053 pc_s=pc_n+l_len;
00054 }
00055 }
00056 if((*pc_w!='%') & (*pc_w!=*pc_s))return NOMATCH;
00057 pc_s++;pc_w++;
00058 if((*pc_s==0)&(*pc_w==0)) return MATCH;
00059 if(*pc_s==0)
00060 {
00061 if((*pc_w=='*') & (*(pc_w+1)==0))return MATCH;
00062 return NOMATCH;
00063 }
00064 if(*pc_w==0)return NOMATCH;
00065 }
00066 }