Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 20 | pmbaty | 1 | #include "pattern.h" |
| 2 | #include "harness/trace.h" |
||
| 3 | #include <ctype.h> |
||
| 4 | |||
| 5 | // IDA: br_boolean __cdecl BrNamePatternMatch(char *p, char *s) |
||
| 6 | br_boolean BrNamePatternMatch(char* p, char* s) { |
||
| 7 | char* cp; |
||
| 8 | LOG_TRACE9("(\"%s\", \"%s\")", p, s); |
||
| 9 | |||
| 10 | if (p == NULL) { |
||
| 11 | return 1; |
||
| 12 | } |
||
| 13 | if (s == NULL) { |
||
| 14 | return 0; |
||
| 15 | } |
||
| 16 | |||
| 17 | for (;; s++, p++) { |
||
| 18 | |||
| 19 | if (*p == '\0') { |
||
| 20 | // if pattern string ends at the same point as search string, we match |
||
| 21 | return *s == 0; |
||
| 22 | } |
||
| 23 | |||
| 24 | if (*p == '*') { |
||
| 25 | cp = s; |
||
| 26 | do { |
||
| 27 | if (BrNamePatternMatch(p + 1, cp)) { |
||
| 28 | return 1; |
||
| 29 | } |
||
| 30 | } while (*cp++); |
||
| 31 | return 0; |
||
| 32 | } |
||
| 33 | if (*p == '/') { |
||
| 34 | return *s == 0; |
||
| 35 | } |
||
| 36 | if (*p == '?') { |
||
| 37 | if (*s == '\0') { |
||
| 38 | return 0; |
||
| 39 | } |
||
| 40 | continue; |
||
| 41 | } |
||
| 42 | |||
| 43 | if (toupper(*p) != toupper(*s)) { |
||
| 44 | return 0; |
||
| 45 | } |
||
| 46 | } |
||
| 47 | return 1; |
||
| 48 | } |