summaryrefslogtreecommitdiff
path: root/utilities/cipherraw.cpp
diff options
context:
space:
mode:
authorRoberto C. Sanchez <roberto@connexer.com>2014-03-29 10:53:49 -0400
committerRoberto C. Sanchez <roberto@connexer.com>2014-03-29 10:53:49 -0400
commit8c8aa6b07e595cfac56838b5964ab3e96051f1b2 (patch)
treeda38e2c1979148dbd3b0c7b87f930746f5ba7f44 /utilities/cipherraw.cpp
parent8d3fc864d094eeadc721f8e93436b37a5fab173e (diff)
Imported Upstream version 1.5.7
Diffstat (limited to 'utilities/cipherraw.cpp')
-rw-r--r--utilities/cipherraw.cpp22
1 files changed, 14 insertions, 8 deletions
diff --git a/utilities/cipherraw.cpp b/utilities/cipherraw.cpp
index 1049689..016512c 100644
--- a/utilities/cipherraw.cpp
+++ b/utilities/cipherraw.cpp
@@ -14,7 +14,10 @@
#include <swcipher.h>
#include <versekey.h>
#include <rawverse.h>
-
+#include <swbuf.h>
+#ifndef NO_SWORD_NAMESPACE
+using namespace sword;
+#endif
int main(int argc, char **argv) {
SWCipher *zobj;
@@ -59,7 +62,7 @@ int main(int argc, char **argv) {
key.AutoNormalize(0);
key.Headings(1);
for (key.Index(0); (!key.Error()); key++) {
- rawdrv->findoffset(key.Testament(), key.Index(), &offset, &size);
+ rawdrv->findOffset(key.Testament(), key.Index(), &offset, &size);
printf("%s: OLD offset: %d; size: %d\n", (const char *)key, offset, size);
if ((offset == loffset) && (size == lsize)) {
@@ -74,18 +77,21 @@ int main(int argc, char **argv) {
loffset = offset;
if (size) {
- tmpbuf = (char *) calloc(size + 2, 1);
- rawdrv->gettext(key.Testament(), offset, size + 2, tmpbuf);
- zobj->Buf(tmpbuf, size);
- zobj->cipherBuf((unsigned int *)&size);
- free(tmpbuf);
+ SWBuf tmpbuf;
+ rawdrv->readText(key.Testament(), offset, size, tmpbuf);
+ zobj->Buf(tmpbuf.c_str(), size);
+ unsigned long ulSize = size;
+ zobj->cipherBuf(&ulSize);
+ size = (unsigned int)ulSize;
}
offset = lseek(ofd[key.Testament() - 1], 0, SEEK_CUR);
tmpoff = lseek(oxfd[key.Testament() - 1], 0, SEEK_CUR);
printf("%s: (%ld) NEW offset: %ld; size: %d\n", (const char *)key, tmpoff, offset, size);
write(oxfd[key.Testament() - 1], &offset, 4);
+ unsigned long ulSize = size;
if (size)
- write(ofd[key.Testament() - 1], zobj->cipherBuf((unsigned int *)&size), size);
+ write(ofd[key.Testament() - 1], zobj->cipherBuf(&ulSize), size);
+ size = (unsigned int)ulSize;
lzoffset = offset;
write(oxfd[key.Testament() - 1], &size, 2);
lzsize = size;