HuntnGather – Diff between revs 24 and 26
?pathlinks?
Rev 24 | Rev 26 | |||
---|---|---|---|---|
Line 10... | Line 10... | |||
10 | #include <ctype.h> |
10 | #include <ctype.h> |
|
Line 11... | Line 11... | |||
11 | |
11 | |
|
12 | #include <sys/types.h> |
12 | #include <sys/types.h> |
|
Line -... | Line 13... | |||
- | 13 | #include <sys/stat.h> |
||
13 | #include <sys/stat.h> |
14 | |
|
14 | |
15 | #if defined ___AmigaOS___ |
|
- | 16 | #include <proto/dos.h> |
||
- | 17 | #include <proto/exec.h> |
||
Line 15... | Line 18... | |||
15 | #include <proto/dos.h> |
18 | #include <proto/utility.h> |
|
16 | #include <proto/exec.h> |
19 | #endif |
|
17 | |
20 | |
|
Line 18... | Line 21... | |||
18 | #if defined ___AsyncIO___ |
21 | #if defined ___AsyncIO___ |
|
19 | #include <asyncio.h> |
22 | #include <asyncio.h> |
|
20 | #endif |
23 | #endif |
|
Line 21... | Line 24... | |||
21 | |
24 | |
|
Line 22... | Line 25... | |||
22 | #if !defined ___HAVE_GETOPT___ |
25 | #if !defined ___HAVE_GETOPT___ |
|
23 | #include "getopt.h" |
26 | #include "getopt.h" |
|
24 | #endif |
27 | #endif |
|
25 | |
28 | |
|
Line 62... | Line 65... | |||
62 | int success; |
65 | int success; |
|
63 | UBYTE *pattern; |
66 | UBYTE *pattern; |
|
64 | char *e = a; |
67 | char *e = a; |
|
65 | char *n = b; |
68 | char *n = b; |
|
Line 66... | Line -... | |||
66 | |
- | ||
67 | #if defined ___NOCASE_FS___ |
- | ||
68 | e = strupr(e); |
- | ||
69 | n = strupr(n); |
- | ||
70 | #endif |
- | ||
71 | |
69 | |
|
72 | // "must be at least 2 times as large plus 2 bytes" |
70 | // "must be at least 2 times as large plus 2 bytes" |
|
Line 73... | Line 71... | |||
73 | size = strlen(n) * 2 + 2; |
71 | size = strlen(n) * 2 + 2; |
|
Line 79... | Line 77... | |||
79 | case 1: // the pattern contains wildcards |
77 | case 1: // the pattern contains wildcards |
|
80 | success = MatchPatternNoCase(pattern, e); |
78 | success = MatchPatternNoCase(pattern, e); |
|
Line 81... | Line 79... | |||
81 | |
79 | |
|
82 | break; |
80 | break; |
|
- | 81 | case 0: // no wildcards so fall back to exact name match |
||
- | 82 | #if defined ___NOCASE_FS___ |
||
- | 83 | success = Strnicmp(e, n, (LONG)strlen(n)) == 0; |
||
83 | case 0: // no wildcards so fall back to exact name match |
84 | #else |
|
- | 85 | success = StrnCmp(e, n, (LONG)strlen(n)) == 0; |
||
Line 84... | Line 86... | |||
84 | success = (strstr(e, n) != NULL); |
86 | #endif |
|
85 | |
87 | |
|
Line 86... | Line 88... | |||
86 | break; |
88 | break; |
|
Line 100... | Line 102... | |||
100 | #if defined ___NOCASE_FS___ |
102 | #if defined ___NOCASE_FS___ |
|
101 | e = strupr(e); |
103 | e = strupr(e); |
|
102 | n = strupr(n); |
104 | n = strupr(n); |
|
103 | #endif |
105 | #endif |
|
Line -... | Line 106... | |||
- | 106 | |
||
104 | |
107 | // search for substring |
|
Line 105... | Line 108... | |||
105 | success = (strstr(e, n) != NULL); |
108 | success = strstr(e, n) != NULL; |
|
106 | |
109 | |
|
107 | return success; |
110 | return success; |
|
Line 156... | Line 159... | |||
156 | #endif |
159 | #endif |
|
157 | #if defined ___AmigaOS___ |
160 | #if defined ___AmigaOS___ |
|
158 | // Check if CTRL+C was pressed and abort the program. |
161 | // Check if CTRL+C was pressed and abort the program. |
|
159 | if(SetSignal(0L, SIGBREAKF_CTRL_C) & SIGBREAKF_CTRL_C) { |
162 | if(SetSignal(0L, SIGBREAKF_CTRL_C) & SIGBREAKF_CTRL_C) { |
|
160 | run = FALSE; |
163 | run = FALSE; |
|
161 | break; |
164 | continue; |
|
162 | } |
165 | } |
|
163 | #endif |
166 | #endif |
|
Line 164... | Line 167... | |||
164 | |
167 | |
|
165 | switch(c) { |
168 | switch(c) { |
|
Line 195... | Line 198... | |||
195 | case 0: |
198 | case 0: |
|
196 | if(strlen(name) == name_size) { |
199 | if(strlen(name) == name_size) { |
|
197 | name_size = 1.5 * name_size; |
200 | name_size = 1.5 * name_size; |
|
198 | name = realloc(name, name_size * sizeof(*name)); |
201 | name = realloc(name, name_size * sizeof(*name)); |
|
199 | } |
202 | } |
|
200 | //name = realloc(name, (i + 1 + 1) * sizeof(*name)); |
- | ||
201 | name[i] = c; |
203 | name[i] = c; |
|
202 | name[i + 1] = '\0'; |
204 | name[i + 1] = '\0'; |
|
203 | break; |
205 | break; |
|
204 | case 1: |
206 | case 1: |
|
205 | if(strlen(path) == path_size) { |
207 | if(strlen(path) == path_size) { |
|
206 | path_size = 1.5 * path_size; |
208 | path_size = 1.5 * path_size; |
|
207 | path = realloc(path, path_size * sizeof(*path)); |
209 | path = realloc(path, path_size * sizeof(*path)); |
|
208 | } |
210 | } |
|
209 | //path = realloc(path, (i + 1 + 1) * sizeof(*path)); |
- | ||
210 | path[i] = c; |
211 | path[i] = c; |
|
211 | path[i + 1] = '\0'; |
212 | path[i + 1] = '\0'; |
|
212 | break; |
213 | break; |
|
213 | default: |
214 | default: |
|
214 | fprintf(stderr, "Database corrupted.\n"); |
215 | fprintf(stderr, "Database corrupted.\n"); |
|
Line 256... | Line 257... | |||
256 | int option; |
257 | int option; |
|
257 | char *dbFile; |
258 | char *dbFile; |
|
258 | struct stat path; |
259 | struct stat path; |
|
Line 259... | Line 260... | |||
259 | |
260 | |
|
- | 261 | // Bind handler to SIGINT. |
||
260 | // Bind handler to SIGINT. |
262 | #if !defined ___AmigaOS___ |
|
- | 263 | signal(SIGINT, SignalHandler); |
||
Line 261... | Line 264... | |||
261 | signal(SIGINT, SignalHandler); |
264 | #endif |
|
262 | |
265 | |
|
263 | dbFile = DEFAULT_DATABASE_FILE; |
266 | dbFile = DEFAULT_DATABASE_FILE; |
|
264 | while((option = getopt(argc, argv, "hd:")) != -1) { |
267 | while((option = getopt(argc, argv, "hd:")) != -1) { |
|
Line 280... | Line 283... | |||
280 | return 1; |
283 | return 1; |
|
281 | } |
284 | } |
|
Line 282... | Line 285... | |||
282 | |
285 | |
|
283 | stat(dbFile, &path); |
286 | stat(dbFile, &path); |
|
284 | if(!S_ISREG(path.st_mode)) { |
287 | if(!S_ISREG(path.st_mode)) { |
|
285 | fprintf(stderr, "Database file '%s' is not a file.\n", dbFile); |
288 | fprintf(stderr, "'%s' is not a file.\n", dbFile); |
|
286 | return 1; |
289 | return 1; |
|
Line 287... | Line 290... | |||
287 | } |
290 | } |