HuntnGather
/trunk/HuntnGather/Hunt/Hunt.c/Hunt.c |
@@ -15,11 +15,15 @@ |
#include <proto/dos.h> |
#include <proto/exec.h> |
|
#if defined ___AsyncIO___ |
#include <asyncio.h> |
#endif |
|
#if !defined ___HAVE_GETOPT___ |
#include "getopt.h" |
#endif |
|
#define PROGRAM_VERSION "1.7.2" |
#define PROGRAM_VERSION "1.7.3" |
|
#if defined ___AmigaOS___ |
/*************************************************************************/ |
@@ -37,6 +41,7 @@ |
#define FALSE 0; |
#endif |
|
#define ASYNC_BUF 8192 |
#define NAME_BUF 32 |
#define PATH_BUF 128 |
#define DEFAULT_DATABASE_FILE "S:gather.db" |
@@ -109,18 +114,27 @@ |
* Search the database for a matching string. |
*/ |
void SearchDatabase(char *dbFile, char* need) { |
#if defined ___AsyncIO___ |
struct AsyncFile *fp; |
LONG c; |
#else |
FILE *fp; |
char c; |
#endif |
char *name; |
int name_size; |
char *path; |
int path_size; |
char c; |
int i; |
int side; |
int match; |
int total; |
|
#if defined ___AsyncIO___ |
if((fp = OpenAsync(dbFile, MODE_READ, ASYNC_BUF)) == NULL) { |
#else |
if((fp = fopen(dbFile, "r")) == NULL) { |
#endif |
fprintf(stderr, "Unable to open gather database for reading.\n"); |
return; |
} |
@@ -135,7 +149,11 @@ |
match = FALSE; |
total = 0; |
|
#if defined ___AsyncIO___ |
while(run && (c = ReadCharAsync(fp)) != -1) { |
#else |
while(run && fscanf(fp, "%c", &c) == 1) { |
#endif |
#if defined ___AmigaOS___ |
// Check if CTRL+C was pressed and abort the program. |
if(SetSignal(0L, SIGBREAKF_CTRL_C) & SIGBREAKF_CTRL_C) { |
@@ -204,7 +222,11 @@ |
free(name); |
free(path); |
|
#if defined ___AsyncIO___ |
CloseAsync(fp); |
#else |
fclose(fp); |
#endif |
} |
|
/* |