HuntnGather – Diff between revs 2 and 3
?pathlinks?
Rev 2 | Rev 3 | |||
---|---|---|---|---|
Line 59... | Line 59... | |||
59 | |
59 | |
|
60 | return up; |
60 | return up; |
|
Line 61... | Line 61... | |||
61 | } |
61 | } |
|
- | 62 | |
||
- | 63 | /* |
||
- | 64 | * Compare "name" and "needle" for equality. |
||
- | 65 | */ |
||
- | 66 | int compare(char *name, char *needle) { |
||
- | 67 | #if defined ___AmigaOS___ |
||
- | 68 | ULONG size; |
||
- | 69 | char *upn, *upe; |
||
- | 70 | int success; |
||
- | 71 | UBYTE *pattern; |
||
- | 72 | |
||
- | 73 | upe = strupr(needle); |
||
- | 74 | upn = strupr(name); |
||
- | 75 | |
||
- | 76 | size = strlen(upe) * 3; |
||
- | 77 | |
||
- | 78 | if(pattern = AllocVec(size, MEMF_ANY|MEMF_CLEAR)) { |
||
- | 79 | |
||
- | 80 | if(ParsePatternNoCase(upe, pattern, (LONG)size) >= 0) { |
||
- | 81 | success = MatchPatternNoCase(pattern, upn); |
||
- | 82 | |
||
- | 83 | FreeMem(pattern, size); |
||
- | 84 | |
||
- | 85 | return success; |
||
- | 86 | } |
||
- | 87 | } |
||
- | 88 | |
||
- | 89 | return FALSE; |
||
- | 90 | #else |
||
- | 91 | return strstr(strupr(name), strupr(needle) != NULL; |
||
- | 92 | #endif |
||
- | 93 | } |
||
- | 94 | |
||
62 | |
95 | |
|
63 | /* |
96 | /* |
|
64 | * |
97 | * |
|
65 | * Search the database for a matching string. |
98 | * Search the database for a matching string. |
|
66 | */ |
99 | */ |
|
67 | void SearchDatabase(char *dbFile, char* string) { |
100 | void SearchDatabase(char *dbFile, char* needle) { |
|
68 | FILE *fp; |
101 | FILE *fp; |
|
69 | char *name; |
102 | char *name; |
|
70 | char *path; |
103 | char *path; |
|
Line 108... | Line 141... | |||
108 | --side; |
141 | --side; |
|
109 | i = 0; |
142 | i = 0; |
|
110 | break; |
143 | break; |
|
111 | case '\t': |
144 | case '\t': |
|
112 | // Case insensitive match. |
145 | // Case insensitive match. |
|
113 | if(strstr(strupr(name), strupr(string)) != NULL) { |
146 | if(compare(name, needle)) { |
|
114 | match = TRUE; |
147 | match = TRUE; |
|
115 | } |
148 | } |
|
116 | if(path != NULL) { |
149 | if(path != NULL) { |
|
117 | free(path); |
150 | free(path); |
|
118 | path = (char *) malloc(sizeof(char)); |
151 | path = (char *) malloc(sizeof(char)); |
|
Line 166... | Line 199... | |||
166 | switch(option) { |
199 | switch(option) { |
|
167 | case 'd': |
200 | case 'd': |
|
168 | dbFile = optarg; |
201 | dbFile = optarg; |
|
169 | break; |
202 | break; |
|
170 | case 'h': |
203 | case 'h': |
|
171 | fprintf(stdout, "SYNTAX: %s [-d DATABASE] STRING\n", argv[0]); |
204 | fprintf(stdout, "SYNTAX: %s [-d DATABASE] PATTERN\n", argv[0]); |
|
172 | break; |
205 | break; |
|
173 | case '?': |
206 | case '?': |
|
174 | fprintf(stderr, "Invalid option %c.\n", optopt); |
207 | fprintf(stderr, "Invalid option %c.\n", optopt); |
|
175 | fprintf(stdout, "SYNTAX: %s [-d DATABASE] STRING\n", argv[0]); |
208 | fprintf(stdout, "SYNTAX: %s [-d DATABASE] PATTERN\n", argv[0]); |
|
176 | return 1; |
209 | return 1; |
|
177 | } |
210 | } |
|
178 | } |
211 | } |
|
Line 179... | Line 212... | |||
179 | |
212 | |
|
180 | if(optind > argc) { |
213 | if(optind > argc) { |
|
181 | fprintf(stdout, "SYNTAX: %s [-d DATABASE] STRING\n", argv[0]); |
214 | fprintf(stdout, "SYNTAX: %s [-d DATABASE] PATTERN\n", argv[0]); |
|
182 | return 1; |
215 | return 1; |
|
Line 183... | Line 216... | |||
183 | } |
216 | } |
|
184 | |
217 | |