summaryrefslogtreecommitdiff
path: root/crypto-search.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'crypto-search.cpp')
-rw-r--r--crypto-search.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/crypto-search.cpp b/crypto-search.cpp
index 8775095..4ece311 100644
--- a/crypto-search.cpp
+++ b/crypto-search.cpp
@@ -23,11 +23,12 @@
#include <string.h>
#include <unistd.h>
#include "generic.h"
-#include "fileutils.h"
+#include "Input.h"
int main(int argc, char ** argv) {
- int h, size, mind, maxd, delta, len, i, j;
+ int size, mind, maxd, delta, len, i, j;
char * buffer, * str;
+ Handle * h;
if (argc != 3) {
printm(M_BARE, "Usage: %s <inputfile> <needle>\n", argv[0]);
@@ -36,23 +37,21 @@ int main(int argc, char ** argv) {
verbosity = M_INFO;
- if ((h = open(argv[1], O_RDONLY)) < 0) {
- printm(M_ERROR, "Unable to open file %s\n", argv[1]);
- exit(-1);
- }
+ h = new Input(argv[1]);
str = argv[2];
- size = filesize(h);
+ size = h->GetSize();
printm(M_STATUS, "Requesting memory (%i bytes)\n", size);
if (!(buffer = (char *) malloc(size))) {
printm(M_ERROR, "Not enough memory.\n");
+ delete h;
exit(-1);
}
printm(M_STATUS, "Loading file...\n");
- read(h, buffer, size);
+ h->read(buffer, size);
printm(M_STATUS, "Done, initialising the search.\n");
len = strlen(argv[2]);
@@ -88,4 +87,6 @@ int main(int argc, char ** argv) {
}
}
}
+
+ delete h;
}