[sword-svn] r1734 - in trunk: tests utilities
scribe at crosswire.org
scribe at crosswire.org
Fri Mar 4 07:05:32 MST 2005
Author: scribe
Date: 2005-03-04 07:05:31 -0700 (Fri, 04 Mar 2005)
New Revision: 1734
Added:
trunk/tests/ciphertest.cpp
Removed:
trunk/utilities/ciphertest.cpp
trunk/utilities/ciphertest2.cpp
Modified:
trunk/tests/Makefile.am
trunk/utilities/Makefile.am
Log:
Added a basic cipher test that kindof works
Modified: trunk/tests/Makefile.am
===================================================================
--- trunk/tests/Makefile.am 2005-02-23 20:01:35 UTC (rev 1733)
+++ trunk/tests/Makefile.am 2005-03-04 14:05:31 UTC (rev 1734)
@@ -14,8 +14,8 @@
SUBDIRS = $(refsysdir)
-noinst_PROGRAMS = keytest mgrtest parsekey listtest casttest modtest \
-compnone complzss localetest introtest indextest configtest keycast \
+noinst_PROGRAMS = ciphertest keytest mgrtest parsekey listtest casttest \
+modtest compnone complzss localetest introtest indextest configtest keycast \
romantest testblocks filtertest rawldidxtest lextest swaptest \
genbooktest treeidxtest swbuftest xmltest webiftest
@@ -64,6 +64,7 @@
keytest_SOURCES = keytest.cpp
mgrtest_SOURCES = mgrtest.cpp
+ciphertest_SOURCES = ciphertest.cpp
parsekey_SOURCES = parsekey.cpp
listtest_SOURCES = listtest.cpp
casttest_SOURCES = casttest.cpp
Added: trunk/tests/ciphertest.cpp
===================================================================
--- trunk/tests/ciphertest.cpp 2005-02-23 20:01:35 UTC (rev 1733)
+++ trunk/tests/ciphertest.cpp 2005-03-04 14:05:31 UTC (rev 1734)
@@ -0,0 +1,31 @@
+#include <cipherfil.h>
+#include <filemgr.h>
+#include <iostream>
+
+using namespace sword;
+
+int main(int argc, char **argv) {
+
+ if (argc != 3) {
+ std::cerr << "usage: " << *argv << " <key> <0-encipher|1-decipher>\n";
+ return -1;
+ }
+
+
+ int encipher = atoi(argv[2]);
+
+ SWFilter *filter = new CipherFilter(argv[1]);
+
+ SWBuf text;
+ char buf[4096];
+ std::cin >> buf;
+ text = buf;
+
+ filter->processText(text, (SWKey *)encipher);
+
+ std::cout << text;
+
+
+
+ return 0;
+}
Modified: trunk/utilities/Makefile.am
===================================================================
--- trunk/utilities/Makefile.am 2005-02-23 20:01:35 UTC (rev 1733)
+++ trunk/utilities/Makefile.am 2005-03-04 14:05:31 UTC (rev 1734)
@@ -7,7 +7,7 @@
#else
LDADD = $(top_builddir)/lib/libsword.la
#endif
-noinst_PROGRAMS = cipherraw ciphertest ciphertest2 lexdump \
+noinst_PROGRAMS = cipherraw lexdump \
stepdump step2vpl gbfidx modwrite addvs emptyvss \
addgb imp2gbs mod2imp xml2gbs
@@ -47,8 +47,6 @@
endif
cipherraw_SOURCES = cipherraw.cpp
-ciphertest_SOURCES = ciphertest.cpp
-ciphertest2_SOURCES = ciphertest2.cpp
lexdump_SOURCES = lexdump.c
lexdump_LDADD = -lstdc++
mkfastmod_SOURCES = mkfastmod.cpp
Deleted: trunk/utilities/ciphertest.cpp
===================================================================
--- trunk/utilities/ciphertest.cpp 2005-02-23 20:01:35 UTC (rev 1733)
+++ trunk/utilities/ciphertest.cpp 2005-03-04 14:05:31 UTC (rev 1734)
@@ -1,57 +0,0 @@
-#include <ctype.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <stdlib.h>
-
-#ifndef __GNUC__
-#include <io.h>
-#else
-#include <unistd.h>
-#endif
-
-#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;
- VerseKey key;
- RawVerse *rawdrv;
- long offset;
- unsigned short size;
- unsigned long len;
- char *tmpbuf;
-
- if (argc != 3) {
- fprintf(stderr, "usage: %s <datapath> \"<key>\"\n", argv[0]);
- exit(1);
- }
-
- rawdrv = new RawVerse(argv[1]);
- zobj = new SWCipher((unsigned char *)argv[2]);
-
-#ifndef O_BINARY
-#define O_BINARY 0
-#endif
-
-
- printf("\n");
-
- key.AutoNormalize(0);
- key.Headings(1);
- for (key.Index(0); (!key.Error()); key++) {
- rawdrv->findOffset(key.Testament(), key.Index(), &offset, &size);
- SWBuf tmpbuf;
- rawdrv->readText(key.Testament(), offset, size, tmpbuf);
- len = size;
- zobj->cipherBuf(&len, tmpbuf.c_str());
- printf("%s\n", zobj->Buf());
- }
- delete zobj;
- return 0;
-}
Deleted: trunk/utilities/ciphertest2.cpp
===================================================================
--- trunk/utilities/ciphertest2.cpp 2005-02-23 20:01:35 UTC (rev 1733)
+++ trunk/utilities/ciphertest2.cpp 2005-03-04 14:05:31 UTC (rev 1734)
@@ -1,44 +0,0 @@
-#include <ctype.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <stdlib.h>
-
-#ifndef __GNUC__
-#include <io.h>
-#else
-#include <unistd.h>
-#endif
-
-#include <cipherfil.h>
-#include <versekey.h>
-#include <rawtext.h>
-
-#ifndef NO_SWORD_NAMESPACE
-using sword::VerseKey;
-using sword::RawText;
-using sword::CipherFilter;
-#endif
-
-int main(int argc, char **argv) {
- VerseKey key;
- RawText *rawdrv;
-
- if (argc != 3) {
- fprintf(stderr, "usage: %s <datapath> \"<key>\"\n", argv[0]);
- exit(1);
- }
-
- rawdrv = new RawText(argv[1]);
- rawdrv->AddRawFilter(new CipherFilter(argv[2]));
-
- printf("\n");
-
- key.AutoNormalize(0);
- key.Headings(1);
- for (key.Index(0); (!key.Error()); key++) {
- rawdrv->Key(key);
- printf("%s: %s\n", (const char *)key, (const char *)*rawdrv);
- }
- return 0;
-}
More information about the sword-cvs
mailing list