HuntnGather – Diff between revs 22 and 24
?pathlinks?
Rev 22 | Rev 24 | |||
---|---|---|---|---|
Line 52... | Line 52... | |||
52 | // Toggle the run flag to stop execution. |
52 | // Toggle the run flag to stop execution. |
|
53 | run = FALSE; |
53 | run = FALSE; |
|
54 | } |
54 | } |
|
Line 55... | Line 55... | |||
55 | |
55 | |
|
56 | /* |
56 | /* |
|
57 | * Compare "name" and "needle" for equality. |
57 | * Compare two strings. |
|
58 | */ |
58 | */ |
|
59 | int compare(char *name, char *need) { |
59 | int compare(char *a, char *b) { |
|
60 | #if defined ___AmigaOS___ |
60 | #if defined ___AmigaOS___ |
|
61 | ULONG size; |
61 | ULONG size; |
|
62 | int success; |
62 | int success; |
|
63 | UBYTE *pattern; |
63 | UBYTE *pattern; |
|
64 | char *upe = name; |
64 | char *e = a; |
|
Line 65... | Line 65... | |||
65 | char *upn = need; |
65 | char *n = b; |
|
66 | |
66 | |
|
67 | #if defined ___NOCASE_FS___ |
67 | #if defined ___NOCASE_FS___ |
|
68 | upe = strupr(upe); |
68 | e = strupr(e); |
|
Line 69... | Line 69... | |||
69 | upn = strupr(upn); |
69 | n = strupr(n); |
|
70 | #endif |
70 | #endif |
|
Line 71... | Line 71... | |||
71 | |
71 | |
|
Line 72... | Line 72... | |||
72 | // "must be at least 2 times as large plus 2 bytes" |
72 | // "must be at least 2 times as large plus 2 bytes" |
|
73 | size = strlen(upn) * 2 + 2; |
73 | size = strlen(n) * 2 + 2; |
|
74 | |
74 | |
|
75 | success = FALSE; |
75 | success = FALSE; |
|
Line 76... | Line 76... | |||
76 | |
76 | |
|
77 | if(pattern = AllocVec(size, MEMF_ANY|MEMF_CLEAR)) { |
77 | if(pattern = AllocVec(size, MEMF_ANY|MEMF_CLEAR)) { |
|
78 | switch(ParsePatternNoCase(upn, pattern, (LONG)size)) { |
78 | switch(ParsePatternNoCase(n, pattern, (LONG)size)) { |
|
Line 79... | Line 79... | |||
79 | case 1: // the pattern contains wildcards |
79 | case 1: // the pattern contains wildcards |
|
80 | success = MatchPatternNoCase(pattern, upe); |
80 | success = MatchPatternNoCase(pattern, e); |
|
Line 81... | Line 81... | |||
81 | |
81 | |
|
82 | break; |
82 | break; |
|
Line 83... | Line 83... | |||
83 | case 0: // no wildcards so fall back to exact name match |
83 | case 0: // no wildcards so fall back to exact name match |
|
84 | success = (strstr(upe, upn) != NULL); |
84 | success = (strstr(e, n) != NULL); |
|
85 | |
85 | |
|
86 | break; |
86 | break; |
|
87 | } |
87 | } |
|
Line 88... | Line 88... | |||
88 | |
88 | |
|
Line 89... | Line 89... | |||
89 | FreeVec(pattern); |
89 | FreeVec(pattern); |
|
90 | } |
90 | } |
|
91 | |
91 | |
|
92 | return success; |
92 | return success; |
|
Line 93... | Line 93... | |||
93 | #else |
93 | #else |
|
Line 94... | Line 94... | |||
94 | int success; |
94 | int success; |
|
95 | char *upe = name; |
95 | char *e = a; |
|
96 | char *upn = need; |
96 | char *n = b; |
|
Line 97... | Line 97... | |||
97 | |
97 | |
|
98 | success = FALSE; |
98 | success = FALSE; |
|
99 | |
99 | |
|
100 | #if defined ___NOCASE_FS___ |
100 | #if defined ___NOCASE_FS___ |
|
101 | upe = strupr(upe); |
101 | e = strupr(e); |
|
102 | upn = strupr(upn); |
102 | n = strupr(n); |
|
103 | #endif |
103 | #endif |
|
104 | |
104 | |
|
105 | success = (strstr(upe, upn) != NULL); |
105 | success = (strstr(e, n) != NULL); |
|
106 | |
106 | |
|
Line 133... | Line 133... | |||
133 | #if defined ___AsyncIO___ |
133 | #if defined ___AsyncIO___ |
|
134 | if((fp = OpenAsync(dbFile, MODE_READ, ASYNC_BUF)) == NULL) { |
134 | if((fp = OpenAsync(dbFile, MODE_READ, ASYNC_BUF)) == NULL) { |
|
135 | #else |
135 | #else |
|
136 | if((fp = fopen(dbFile, "r")) == NULL) { |
136 | if((fp = fopen(dbFile, "r")) == NULL) { |
|
137 | #endif |
137 | #endif |
|
138 | fprintf(stderr, "Unable to open gather database for reading.\n"); |
138 | fprintf(stderr, "Unable to open '%s' for reading.\n", dbFile); |
|
139 | return; |
139 | return; |
|
140 | } |
140 | } |
|
Line 141... | Line 141... | |||
141 | |
141 | |
|
142 | name_size = NAME_BUF; |
142 | name_size = NAME_BUF; |
|
Line 177... | Line 177... | |||
177 | --side; |
177 | --side; |
|
178 | i = 0; |
178 | i = 0; |
|
179 | break; |
179 | break; |
|
180 | case '\t': |
180 | case '\t': |
|
181 | // Case insensitive match. |
181 | // Case insensitive match. |
|
182 | if(compare(name, need)) { |
182 | if(compare(name, needle)) { |
|
183 | match = TRUE; |
183 | match = TRUE; |
|
184 | } |
184 | } |
|
185 | if(path != NULL) { |
185 | if(path != NULL) { |
|
186 | free(path); |
186 | free(path); |
|
187 | path_size = PATH_BUF; |
187 | path_size = PATH_BUF; |
|
Line 231... | Line 231... | |||
231 | |
231 | |
|
232 | /* |
232 | /* |
|
233 | * |
233 | * |
|
234 | * Search the database for the matching string. |
234 | * Search the database for the matching string. |
|
235 | */ |
235 | */ |
|
236 | void Hunt(char *dbFile, char *need) { |
236 | void Hunt(char *dbFile, char *needle) { |
|
237 | // Search the database for the matching string. |
237 | // Search the database for the matching string. |
|
238 | SearchDatabase(dbFile, need); |
238 | SearchDatabase(dbFile, needle); |
|
Line 239... | Line 239... | |||
239 | } |
239 | } |
|
240 | |
240 | |
|
241 | void usage(char *name) { |
241 | void usage(char *name) { |