/trunk/HuntnGather/Hunt/Hunt.c |
@@ -54,34 +54,34 @@ |
} |
|
/* |
* Compare "name" and "needle" for equality. |
* Compare two strings. |
*/ |
int compare(char *name, char *need) { |
int compare(char *a, char *b) { |
#if defined ___AmigaOS___ |
ULONG size; |
int success; |
UBYTE *pattern; |
char *upe = name; |
char *upn = need; |
char *e = a; |
char *n = b; |
|
#if defined ___NOCASE_FS___ |
upe = strupr(upe); |
upn = strupr(upn); |
e = strupr(e); |
n = strupr(n); |
#endif |
|
// "must be at least 2 times as large plus 2 bytes" |
size = strlen(upn) * 2 + 2; |
size = strlen(n) * 2 + 2; |
|
success = FALSE; |
|
if(pattern = AllocVec(size, MEMF_ANY|MEMF_CLEAR)) { |
switch(ParsePatternNoCase(upn, pattern, (LONG)size)) { |
switch(ParsePatternNoCase(n, pattern, (LONG)size)) { |
case 1: // the pattern contains wildcards |
success = MatchPatternNoCase(pattern, upe); |
success = MatchPatternNoCase(pattern, e); |
|
break; |
case 0: // no wildcards so fall back to exact name match |
success = (strstr(upe, upn) != NULL); |
success = (strstr(e, n) != NULL); |
|
break; |
} |
@@ -92,17 +92,17 @@ |
return success; |
#else |
int success; |
char *upe = name; |
char *upn = need; |
char *e = a; |
char *n = b; |
|
success = FALSE; |
|
#if defined ___NOCASE_FS___ |
upe = strupr(upe); |
upn = strupr(upn); |
e = strupr(e); |
n = strupr(n); |
#endif |
|
success = (strstr(upe, upn) != NULL); |
success = (strstr(e, n) != NULL); |
|
return success; |
#endif |
@@ -113,7 +113,7 @@ |
* |
* Search the database for a matching string. |
*/ |
void SearchDatabase(char *dbFile, char* need) { |
void SearchDatabase(char *dbFile, char* needle) { |
#if defined ___AsyncIO___ |
struct AsyncFile *fp; |
LONG c; |
@@ -135,7 +135,7 @@ |
#else |
if((fp = fopen(dbFile, "r")) == NULL) { |
#endif |
fprintf(stderr, "Unable to open gather database for reading.\n"); |
fprintf(stderr, "Unable to open '%s' for reading.\n", dbFile); |
return; |
} |
|
@@ -179,7 +179,7 @@ |
break; |
case '\t': |
// Case insensitive match. |
if(compare(name, need)) { |
if(compare(name, needle)) { |
match = TRUE; |
} |
if(path != NULL) { |
@@ -233,9 +233,9 @@ |
* |
* Search the database for the matching string. |
*/ |
void Hunt(char *dbFile, char *need) { |
void Hunt(char *dbFile, char *needle) { |
// Search the database for the matching string. |
SearchDatabase(dbFile, need); |
SearchDatabase(dbFile, needle); |
} |
|
void usage(char *name) { |