HuntnGather – Diff between revs 4 and 5
?pathlinks?
Rev 4 | Rev 5 | |||
---|---|---|---|---|
Line 13... | Line 13... | |||
13 | #include <sys/stat.h> |
13 | #include <sys/stat.h> |
|
Line 14... | Line 14... | |||
14 | |
14 | |
|
15 | #include <proto/dos.h> |
15 | #include <proto/dos.h> |
|
Line 16... | Line 16... | |||
16 | #include <proto/exec.h> |
16 | #include <proto/exec.h> |
|
17 | |
17 | |
|
18 | #if defined ___AmigaOS___ |
18 | #if !defined ___HAVE_GETOPT___ |
|
Line -... | Line 19... | |||
- | 19 | #include "getopt.h" |
||
- | 20 | #endif |
||
- | 21 | |
||
- | 22 | #if defined ___AmigaOS___ |
||
- | 23 | #include <dos/dos.h> |
||
- | 24 | #include <dos/rdargs.h> |
||
- | 25 | #define TEMPLATE "D=Database/K,P=Pattern/A/F" |
||
- | 26 | #define OPT_DATABASE 0 |
||
- | 27 | #define OPT_PATTERN 1 |
||
- | 28 | #define OPT_COUNT 2 |
||
- | 29 | LONG result[OPT_COUNT]; |
||
- | 30 | /*************************************************************************/ |
||
- | 31 | /* Version string used for querrying the program version. */ |
||
- | 32 | /*************************************************************************/ |
||
- | 33 | TEXT version_string[] = |
||
19 | #include "getopt.h" |
34 | "\0$VER: Hunt 1.4 "__DATE__" by Wizardry and Steamworks"; |
|
20 | #endif |
35 | #endif |
|
21 | |
36 | |
|
Line 22... | Line 37... | |||
22 | #if !defined TRUE |
37 | #if !defined TRUE |
|
23 | #define TRUE 1; |
38 | #define TRUE 1; |
|
24 | #endif |
39 | #endif |
|
Line 25... | Line 40... | |||
25 | |
40 | |
|
Line 26... | Line -... | |||
26 | #if !defined FALSE |
- | ||
27 | #define FALSE 0; |
- | ||
28 | #endif |
- | ||
29 | |
- | ||
30 | #define DEFAULT_DATABASE_FILE "S:gather.db" |
- | ||
31 | |
- | ||
32 | /*************************************************************************/ |
41 | #if !defined FALSE |
|
Line 33... | Line 42... | |||
33 | /* Version string used for querrying the program version. */ |
42 | #define FALSE 0; |
|
34 | /*************************************************************************/ |
43 | #endif |
|
35 | TEXT version_string[] = |
44 | |
|
Line 191... | Line 200... | |||
191 | // Search the database for the matching string. |
200 | // Search the database for the matching string. |
|
192 | SearchDatabase(dbFile, need); |
201 | SearchDatabase(dbFile, need); |
|
193 | } |
202 | } |
|
Line 194... | Line 203... | |||
194 | |
203 | |
|
- | 204 | int main(int argc, char **argv) { |
||
- | 205 | #if defined ___AmigaOS___ |
||
- | 206 | struct RDArgs *rdargs; |
||
- | 207 | struct stat statPath; |
||
- | 208 | UBYTE *dbFile; |
||
- | 209 | UBYTE *argPattern; |
||
- | 210 | |
||
- | 211 | dbFile = DEFAULT_DATABASE_FILE; |
||
- | 212 | argPattern = NULL; |
||
- | 213 | if(rdargs = (struct RDArgs *) AllocDosObject(DOS_RDARGS, NULL)) { |
||
- | 214 | if(ReadArgs(TEMPLATE, result, rdargs) == NULL) { |
||
- | 215 | FreeArgs(rdargs); |
||
- | 216 | FreeDosObject(DOS_RDARGS, rdargs); |
||
- | 217 | return 1; |
||
- | 218 | } |
||
- | 219 | |
||
- | 220 | if(result[OPT_DATABASE] != NULL) { |
||
- | 221 | dbFile = (UBYTE *) result[OPT_DATABASE]; |
||
- | 222 | } |
||
- | 223 | |
||
- | 224 | argPattern = (UBYTE *) result[OPT_PATTERN]; |
||
- | 225 | |
||
- | 226 | FreeArgs(rdargs); |
||
- | 227 | FreeDosObject(DOS_RDARGS, rdargs); |
||
- | 228 | } |
||
- | 229 | |
||
- | 230 | stat(dbFile, &statPath); |
||
- | 231 | if(!S_ISREG(statPath.st_mode)) { |
||
- | 232 | fprintf(stderr, "Database file '%s' is not a file.\n", dbFile); |
||
- | 233 | return 1; |
||
- | 234 | } |
||
- | 235 | |
||
- | 236 | Hunt(dbFile, argPattern); |
||
195 | int main(int argc, char **argv) { |
237 | #else |
|
196 | int option; |
238 | int option; |
|
197 | char *dbFile; |
239 | char *dbFile; |
|
Line 198... | Line 240... | |||
198 | struct stat path; |
240 | struct stat path; |
|
Line 221... | Line 263... | |||
221 | return 1; |
263 | return 1; |
|
222 | } |
264 | } |
|
Line 223... | Line 265... | |||
223 | |
265 | |
|
224 | stat(dbFile, &path); |
266 | stat(dbFile, &path); |
|
225 | if(!S_ISREG(path.st_mode)) { |
267 | if(!S_ISREG(path.st_mode)) { |
|
226 | fprintf(stderr, "%s is not a file.\n", dbFile); |
268 | fprintf(stderr, "Database file '%s' is not a file.\n", dbFile); |
|
227 | return 1; |
269 | return 1; |
|
Line 228... | Line 270... | |||
228 | } |
270 | } |
|
- | 271 | |
||
Line 229... | Line 272... | |||
229 | |
272 | Hunt(dbFile, argv[optind]); |
|
230 | Hunt(dbFile, argv[optind]); |
273 | #endif |