lib/eggdrop/match.c File Reference

#include <eggdrop/eggdrop.h>

Go to the source code of this file.

Defines

#define irctoupper   toupper

Functions

int wild_match_per (const char *wild, const char *matchtext)
int wild_match (const char *wild, const char *matchtext)

Variables

static const char rcsid [] = "$Id: match.c,v 1.6 2004-10-17 05:14:06 stdarg Exp $"


Define Documentation

#define irctoupper   toupper

Definition at line 26 of file match.c.

Referenced by wild_match(), and wild_match_per().


Function Documentation

int wild_match ( const char *  wild,
const char *  matchtext 
)

Definition at line 107 of file match.c.

References count, irctoupper, QUOTE, WILDQ, and WILDS.

Referenced by cache_check_add(), cache_check_del(), callback_match_ircmask(), chanserv_probe_member(), check_expired_exempts(), cmd_pls_mask(), help_search_result(), ircmask_list_find(), ircmask_matches_user(), tell_bans(), tell_exempts(), tell_invites(), u_addmask(), and u_match_mask().

00107                                                         {
00108   const char *fallback=0;
00109   int match = 0, count = 0, saved = 0, wildcard = 0;
00110 
00111   /* If either string is NULL, they can't match */
00112   if (!matchtext || !wild)
00113     return 0;
00114 
00115   while(*matchtext && *wild) {
00116     switch (*wild) {
00117       case WILDQ :        /* inc both... let the while() check for errors */
00118           wild++;
00119           matchtext++;
00120           break;
00121           while ((*(matchtext++)==' '));  /* loop through spaces */
00122           break;
00123       case WILDS :
00124           if (!*++wild)
00125             return (count+saved+1);
00126           wildcard = 1;
00127           break;
00128       default :
00129           if (*wild==QUOTE)     /* is it quoted? */
00130             wild++;
00131           if (wildcard) {
00132             saved = count;
00133             match = count = 0;
00134             fallback = wild;      /* setup fallback in case we hit a false positive */
00135             while(*matchtext && (irctoupper(*wild) != irctoupper(*matchtext)))
00136               matchtext++;
00137             if (!*matchtext) {
00138               match=1;
00139               break;
00140             }
00141           }
00142           if (irctoupper(*wild) != irctoupper(*matchtext)) {
00143             if (!fallback)    /* no match and no fallback? die */
00144               return 0;
00145             count = saved;
00146             wild = fallback-1;    /* fall back */
00147             break;
00148           }
00149           wildcard = 0;
00150           count++;
00151           match=1;
00152           if (*wild)
00153             wild++;
00154           if (*matchtext)
00155             matchtext++;
00156     }
00157   }
00158   while (*wild && *wild == '*') /* Allow for trailing *'s */
00159     wild++;
00160 
00161   return (!match || *wild || *matchtext)?0:(count+saved+1);
00162 }

int wild_match_per ( const char *  wild,
const char *  matchtext 
)

Definition at line 29 of file match.c.

References count, irctoupper, QUOTE, WILDP, WILDQ, WILDS, and WILDT.

Referenced by bind_vcheck_hits().

00029                                                             {
00030   const char *fallback=0;
00031   int match = 0, saved = 0, count = 0, wildcard = 0;
00032 
00033   /* If either string is NULL, they can't match */
00034   if (!matchtext || !wild)
00035     return 0;
00036 
00037   while(*matchtext && *wild) {
00038     switch (*wild) {
00039       case WILDP :
00040           fallback = wild++;      /* setup fallback */
00041           match = 1;
00042           while((*(wild++)==WILDP));    /* get rid of redundant %s ... %%%% */
00043           if (*wild==QUOTE)     /* is the match char quoted? */
00044             wild++;
00045           while(*matchtext && (irctoupper(*wild) != irctoupper(*matchtext)))
00046             if (*matchtext==' ') {
00047               match=0;        /* loop until we find the next char... or don't */
00048               break;
00049             } else
00050               matchtext++;
00051           break;
00052       case WILDQ :        /* inc both... let the while() check for errors */
00053           wild++;
00054           matchtext++;
00055           break;
00056       case WILDT :
00057           wild++;
00058           if (*matchtext!=' '){     /* need at least one space */
00059             count = saved;
00060             if (!fallback)      /* no match and no fallback? die */
00061               return 0;
00062             wild = fallback-1;      /* fall back */
00063             break;
00064           }
00065           while ((*(matchtext++)==' '));  /* loop through spaces */
00066           count++;
00067           break;
00068       case WILDS :
00069           if (!*++wild)
00070             return (count+saved+1);
00071           wildcard = 1;
00072           break;
00073       default :
00074           if (*wild==QUOTE)     /* is it quoted? */
00075             wild++;
00076           if (wildcard) {
00077             saved = count;
00078             match = count = 0;
00079             fallback = wild;      /* setup fallback in case we hit a false positive */
00080             while(*matchtext && (irctoupper(*wild) != irctoupper(*matchtext)))
00081               matchtext++;
00082             if (!*matchtext) {
00083               match=1;
00084               break;
00085             }
00086           }
00087           if (irctoupper(*wild) != irctoupper(*matchtext)) {
00088             if (!fallback)    /* no match and no fallback? die */
00089               return 0;
00090             count = saved;
00091             wild = fallback-1;    /* fall back */
00092             break;
00093           }
00094           count++;
00095           wildcard = 0;
00096           match=1;
00097           if (*wild)
00098             wild++;
00099           if (*matchtext)
00100             matchtext++;
00101     }
00102   }
00103   return (!match || *wild || *matchtext)?0:(count+saved+1);
00104 }


Variable Documentation

const char rcsid[] = "$Id: match.c,v 1.6 2004-10-17 05:14:06 stdarg Exp $" [static]

Definition at line 21 of file match.c.


Generated on Sun Nov 30 18:43:34 2008 for eggdrop1.9 by  doxygen 1.5.6