summaryrefslogtreecommitdiff
path: root/VP/search-script.cpp
diff options
context:
space:
mode:
authorpixel <pixel>2004-11-27 21:44:44 +0000
committerpixel <pixel>2004-11-27 21:44:44 +0000
commitd38e80ee04afe582e70150d3884e56c05f3fd7a8 (patch)
treef2627c50fa22aea89447e8406ac418eb68650d3d /VP/search-script.cpp
parent50f0dd331f8168fb5b2cd60c70178fad627b7fb6 (diff)
Large dos2unix commit...
Diffstat (limited to 'VP/search-script.cpp')
-rw-r--r--VP/search-script.cpp146
1 files changed, 73 insertions, 73 deletions
diff --git a/VP/search-script.cpp b/VP/search-script.cpp
index d68149f..ebbf214 100644
--- a/VP/search-script.cpp
+++ b/VP/search-script.cpp
@@ -1,73 +1,73 @@
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include "fileutils.h"
-#include "generic.h"
-
-#define THRESHOLD 2000
-
-int main(int argc, char ** argv) {
- int h, n, o, i, p, c, pp, b;
-
- verbosity = M_INFO;
-
- if (argc != 2) {
- printm(M_BARE, "Usage: search-script <file>\n");
- exit(-1);
- }
-
- if ((h = open(argv[1], O_RDONLY)) < 0) {
- printm(M_ERROR, "Error opening file %s\n", argv[1]);
- exit(-1);
- }
-
- printm(M_STATUS, "Reading informations from %s...\n", argv[1]);
-
- read(h, &n, 4);
-
- o = n;
-
- n -= 4;
- n /= 8;
-
- printm(M_INFO, "Script claims to have %i texts.\n", n);
-
- if (n > THRESHOLD) {
- printm(M_ERROR, "Too much texts to make sense.\n");
- exit(-1);
- }
-
- printm(M_STATUS, "Reading index.\n");
-
- pp = -1;
- for (i = 0; i < n; i++) {
- lseek(h, i * 8 + 4, SEEK_SET);
- read(h, &c, 4);
- read(h, &p, 4);
- printm(M_INFO, "Index #%i has pointer %i and counter %i\n", i, p, c);
- if (pp > p) {
- printm(M_ERROR, "Script's text overlapping.\n");
- exit(-1);
- }
-
- if (((unsigned int)(p + o)) > filesize(h)) {
- printm(M_ERROR, "Text bigger than script.\n");
- exit(-1);
- }
-
- lseek(h, p + o - 1, SEEK_SET);
- b = 0;
- read(h, &b, 1);
-
- if (b) {
- printm(M_ERROR, "Byte before the pointer is not 0 (%i = 0x%02x)\n", b, b);
- exit(-1);
- }
-
- pp = p;
- }
-
- printm(M_STATUS, "Script seems ok to me.\n");
-
- exit(0);
-}
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include "fileutils.h"
+#include "generic.h"
+
+#define THRESHOLD 2000
+
+int main(int argc, char ** argv) {
+ int h, n, o, i, p, c, pp, b;
+
+ verbosity = M_INFO;
+
+ if (argc != 2) {
+ printm(M_BARE, "Usage: search-script <file>\n");
+ exit(-1);
+ }
+
+ if ((h = open(argv[1], O_RDONLY)) < 0) {
+ printm(M_ERROR, "Error opening file %s\n", argv[1]);
+ exit(-1);
+ }
+
+ printm(M_STATUS, "Reading informations from %s...\n", argv[1]);
+
+ read(h, &n, 4);
+
+ o = n;
+
+ n -= 4;
+ n /= 8;
+
+ printm(M_INFO, "Script claims to have %i texts.\n", n);
+
+ if (n > THRESHOLD) {
+ printm(M_ERROR, "Too much texts to make sense.\n");
+ exit(-1);
+ }
+
+ printm(M_STATUS, "Reading index.\n");
+
+ pp = -1;
+ for (i = 0; i < n; i++) {
+ lseek(h, i * 8 + 4, SEEK_SET);
+ read(h, &c, 4);
+ read(h, &p, 4);
+ printm(M_INFO, "Index #%i has pointer %i and counter %i\n", i, p, c);
+ if (pp > p) {
+ printm(M_ERROR, "Script's text overlapping.\n");
+ exit(-1);
+ }
+
+ if (((unsigned int)(p + o)) > filesize(h)) {
+ printm(M_ERROR, "Text bigger than script.\n");
+ exit(-1);
+ }
+
+ lseek(h, p + o - 1, SEEK_SET);
+ b = 0;
+ read(h, &b, 1);
+
+ if (b) {
+ printm(M_ERROR, "Byte before the pointer is not 0 (%i = 0x%02x)\n", b, b);
+ exit(-1);
+ }
+
+ pp = p;
+ }
+
+ printm(M_STATUS, "Script seems ok to me.\n");
+
+ exit(0);
+}