summaryrefslogtreecommitdiff
path: root/VP/unarc.cpp
diff options
context:
space:
mode:
authorpixel <pixel>2004-11-27 21:44:15 +0000
committerpixel <pixel>2004-11-27 21:44:15 +0000
commit50f0dd331f8168fb5b2cd60c70178fad627b7fb6 (patch)
tree65fcec7bd507791f0db8a3af1b60ad9ac631f4a7 /VP/unarc.cpp
parentf1df76865d1751469deff19e62255d50a814f183 (diff)
Large dos2unix commit...
Diffstat (limited to 'VP/unarc.cpp')
-rw-r--r--VP/unarc.cpp158
1 files changed, 79 insertions, 79 deletions
diff --git a/VP/unarc.cpp b/VP/unarc.cpp
index 36a258a..1584041 100644
--- a/VP/unarc.cpp
+++ b/VP/unarc.cpp
@@ -1,79 +1,79 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-#include "Input.h"
-#include "Output.h"
-#include "generic.h"
-#include "Main.h"
-
-#define THRESHOLD 2000
-
-CODE_BEGINS
-virtual int startup() throw(GeneralException) {
- int n, * index, * sizes, i, d;
- String temp;
- Handle * h, * o;
-
- verbosity = M_INFO;
-
- if (argc != 2) {
- printm(M_BARE, "Usage: unarc <archive>\n");
- exit(-1);
- }
-
- h = new Input(argv[1]);
-
- h->read(&n, 4);
-
- printm(M_STATUS, "Archive claims to have %i files, checking integrity.\n", n);
-
- if (n > THRESHOLD) {
- printm(M_ERROR, "Archive has more than %i files, that doesn't make sense to me.\n", THRESHOLD);
- exit(-1);
- }
-
- index = (int *) malloc(n * sizeof(int));
- sizes = (int *) malloc(n * sizeof(int));
-
- for (i = 0; i < n; i++) {
- h->seek((i + 1) * 8 + 4, SEEK_SET);
- h->read(&(sizes[i]), 4);
- printm(M_INFO, "File #%i size = %i = 0x%08x\n", i, sizes[i], sizes[i]);
- }
-
- index[0] = (n + 1) * 8;
- i = 0;
- printm(M_INFO, "Index #%i = %i = 0x%08x\n", i, index[i], index[i]);
-
- for (i = 1; i < n; i++) {
- index[i] = index[i - 1] + sizes[i - 1];
- printm(M_INFO, "Index #%i = %i = 0x%08x\n", i, index[i], index[i]);
- }
-
- d = h->GetSize() - index[n - 1] - sizes[n - 1];
-
- printm(M_INFO, "Archive size: %i, last index: %i, last file size: %i, difference = %i\n", h->GetSize(), index[n - 1], sizes[n - 1], d);
-
- if ((d < 0) || (d > 2048)) {
- printm(M_ERROR, "Archive incoherent.\n");
- exit(-1);
- }
-
- printm(M_STATUS, "Archive seems to be ok, extracting.\n");
-
- for (i = 0; i < n; i++) {
- temp.set("%04i.out", i);
- o = new Output(temp);
-
- printm(M_INFO, "Extracting " + temp + "\n");
-
- h->seek(index[i], SEEK_SET);
- copy(h, o, sizes[i]);
- delete o;
- }
-
- delete h;
- return 0;
-}
-CODE_ENDS
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include "Input.h"
+#include "Output.h"
+#include "generic.h"
+#include "Main.h"
+
+#define THRESHOLD 2000
+
+CODE_BEGINS
+virtual int startup() throw(GeneralException) {
+ int n, * index, * sizes, i, d;
+ String temp;
+ Handle * h, * o;
+
+ verbosity = M_INFO;
+
+ if (argc != 2) {
+ printm(M_BARE, "Usage: unarc <archive>\n");
+ exit(-1);
+ }
+
+ h = new Input(argv[1]);
+
+ h->read(&n, 4);
+
+ printm(M_STATUS, "Archive claims to have %i files, checking integrity.\n", n);
+
+ if (n > THRESHOLD) {
+ printm(M_ERROR, "Archive has more than %i files, that doesn't make sense to me.\n", THRESHOLD);
+ exit(-1);
+ }
+
+ index = (int *) malloc(n * sizeof(int));
+ sizes = (int *) malloc(n * sizeof(int));
+
+ for (i = 0; i < n; i++) {
+ h->seek((i + 1) * 8 + 4, SEEK_SET);
+ h->read(&(sizes[i]), 4);
+ printm(M_INFO, "File #%i size = %i = 0x%08x\n", i, sizes[i], sizes[i]);
+ }
+
+ index[0] = (n + 1) * 8;
+ i = 0;
+ printm(M_INFO, "Index #%i = %i = 0x%08x\n", i, index[i], index[i]);
+
+ for (i = 1; i < n; i++) {
+ index[i] = index[i - 1] + sizes[i - 1];
+ printm(M_INFO, "Index #%i = %i = 0x%08x\n", i, index[i], index[i]);
+ }
+
+ d = h->GetSize() - index[n - 1] - sizes[n - 1];
+
+ printm(M_INFO, "Archive size: %i, last index: %i, last file size: %i, difference = %i\n", h->GetSize(), index[n - 1], sizes[n - 1], d);
+
+ if ((d < 0) || (d > 2048)) {
+ printm(M_ERROR, "Archive incoherent.\n");
+ exit(-1);
+ }
+
+ printm(M_STATUS, "Archive seems to be ok, extracting.\n");
+
+ for (i = 0; i < n; i++) {
+ temp.set("%04i.out", i);
+ o = new Output(temp);
+
+ printm(M_INFO, "Extracting " + temp + "\n");
+
+ h->seek(index[i], SEEK_SET);
+ copy(h, o, sizes[i]);
+ delete o;
+ }
+
+ delete h;
+ return 0;
+}
+CODE_ENDS