char match( char *p, char *t ) { int error_type; error_type = matche(p,t); return (error_type == MATCH_VALID ) ? 1 : 0; }
static BOOLEAN match( char *p, char *t ) { int error_type; error_type=matche(p,t); return (error_type==MATCH_VALID ) ? TRUE : FALSE; }
static int matche_after_star(register char *p, register char *t) { register int match = 0; register int nextp; while ( *p == '?' || *p == '*' ) { if ( *p == '?' ) { if ( !*t++ ) { return MATCH_ABORT; } } p++; } if ( !*p ) { return MATCH_VALID; } nextp = *p; do { if ( nextp == *t || nextp == '[' ) { match=matche(p, t); } if ( !*t++ ) match = MATCH_ABORT; } while ( match != MATCH_VALID && match != MATCH_ABORT && match != MATCH_PATTERN); return match; }
int command(const char *buf, struct client *cl, char * cmd) { char user[WORD]; char pass[WORD]; char room[WORD]; int ret = 0; matche(buf, "%s", cmd); log_debug("CMD is: %s\n",cmd); if (strcmp(cmd,"/connect") == 0) { matche(buf, "%s %s %s %s", cmd, user, pass, room); log_debug("USER %s is trying to %s: with pass %s\n", user, cmd, pass); ret = check_passwd(user, pass); strncpy(cl->cl_name, user, sizeof(user)); strncpy(cl->cl_room, room, sizeof(room)); return (ret); } if (strcmp(cmd,"/quit") == 0) { log_debug("USER is trying to %s", cmd); return (CLOSE_CONNECTION); } if (strcmp(cmd,"/secret") == 0) { matche(buf, "%s %s", cmd, user); log_debug("USER %s is trying to say a secret to %s\n", cl->cl_name, user); ret = private_message(buf); strncpy(cmd, user, sizeof(user)); return (ret); } if (strcmp(cmd,"/names") == 0) { log_debug("USER wants to know %s", cmd); return (1); } return (ret); }
//---------------------------------------------------------------------------- // recursively call matche() with final segment of PATTERN and of TEXT. //---------------------------------------------------------------------------- int matche_after_star (register char *p, register char *t) { register int match = 0; register nextp; /* pass over existing ? and * in pattern */ while ( *p == '?' || *p == '*' ) { /* take one char for each ? and + */ if ( *p == '?' ) { /* if end of text then no match */ if ( !*t++ ) { return MATCH_ABORT; } } /* move to next char in pattern */ p++; } /* if end of pattern we have matched regardless of text left */ if ( !*p ) { return MATCH_VALID; } /* get the next character to match which must be a literal or '[' */ nextp = *p; if ( nextp == '\\' ) { nextp = p[1]; /* if end of text then we have a bad pattern */ if (!nextp) return MATCH_PATTERN; } /* Continue until we run out of text or definite result seen */ do { /* a precondition for matching is that the next character in the pattern match the next character in the text or that the next pattern char is the beginning of a range. Increment text pointer as we go here */ if ( nextp == *t || nextp == '[' ) { match = matche(p, t); } /* if the end of text is reached then no match */ if ( !*t++ ) match = MATCH_ABORT; } while ( match != MATCH_VALID && match != MATCH_ABORT && match != MATCH_PATTERN); /* return result */ return match; }
int AL_PROTO ALName::WildCardMatch( const char AL_DLL_FAR *pattern ) { int error; int result; char *p = new char[ strlen( pattern ) + 1 ]; if ( !p ) return 0; strcpy( p, pattern ); switch ( mCase ) { case AL_UPPER : strupr( p ); break; case AL_LOWER : strlwr( p ); break; default : break; } if ( !is_valid_pattern( p, &error ) ) result = 0; else if ( matche( p, mszName ) == MATCH_VALID ) result = 1; else result = 0; delete p; return result; }