Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

/MbsAPI/f_ut_wild.c

Go to the documentation of this file.
00001 //---------------------------------------------------------------
00002 //        Go4 Release Package v2.10-5 (build 21005) 
00003 //                      03-Nov-2005
00004 //---------------------------------------------------------------
00005 //       The GSI Online Offline Object Oriented (Go4) Project
00006 //       Experiment Data Processing at DVEE department, GSI
00007 //---------------------------------------------------------------
00008 //
00009 //Copyright (C) 2000- Gesellschaft f. Schwerionenforschung, GSI
00010 //                    Planckstr. 1, 64291 Darmstadt, Germany
00011 //Contact:            http://go4.gsi.de
00012 //----------------------------------------------------------------
00013 //This software can be used under the license agreements as stated
00014 //in Go4License.txt file which is part of the distribution.
00015 //----------------------------------------------------------------
00016 #include "typedefs.h"
00017 #include <stdio.h>
00018 #include <stdlib.h>
00019 #include <string.h>
00020 #define MATCH    0
00021 #define NOMATCH -1
00022 
00023 INTS4 f_ut_wild(CHARS *pc_test, CHARS *pc_wild)
00024 {
00025 INTS4 l_wild,l_test,l_len;
00026 CHARS c_wild[256],c_test[256];
00027 CHARS *pc_h,*pc_n,*pc_w,*pc_s;
00028 strcpy(c_wild,pc_wild);
00029 strcpy(c_test,pc_test);
00030 pc_w=(CHARS *)c_wild;
00031 pc_s=(CHARS *)c_test;
00032 l_test=strlen(pc_s);
00033 while(1)
00034 {
00035   while(*pc_w=='*')
00036   {
00037     while(*pc_w=='*'){pc_w++; if(*pc_w==0)return MATCH;}
00038     pc_h=pc_w;
00039     while((*pc_h!='*')&(*pc_h!=0))pc_h++;
00040     if(*pc_h==0)
00041     {
00042     /* match pc_w at end of test */
00043       l_len=strlen(pc_w);
00044       if(strlen(pc_s) < l_len) return NOMATCH;
00045       pc_s=(CHARS *)&c_test[l_test-l_len];
00046     }
00047     if(*pc_h=='*')
00048     {
00049     /* match pc_w-pc_h somewhere in test */
00050       *pc_h=0;
00051       if((pc_n=(CHARS *)strstr(pc_s,pc_w))==NULL) return NOMATCH;
00052       l_len=strlen(pc_w);
00053       *pc_h='*';
00054       pc_w=pc_h;
00055       pc_s=pc_n+l_len;
00056     }
00057   }
00058   if((*pc_w!='%') & (*pc_w!=*pc_s))return NOMATCH;
00059   pc_s++;pc_w++;
00060   if((*pc_s==0)&(*pc_w==0)) return MATCH;
00061   if(*pc_s==0)
00062   {
00063     if((*pc_w=='*') & (*(pc_w+1)==0))return MATCH;
00064     return NOMATCH;
00065   }
00066   if(*pc_w==0)return NOMATCH;
00067 }
00068 }
00069 
00070 //----------------------------END OF GO4 SOURCE FILE ---------------------

Generated on Tue Nov 8 10:56:08 2005 for Go4-v2.10-5 by doxygen1.2.15