Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/include/swld.h b/include/swld.h
- index ced6707..d47536f 100644
- --- a/include/swld.h
- +++ b/include/swld.h
- @@ -36,9 +36,10 @@ SWORD_NAMESPACE_START
- class SWDLLEXPORT SWLD : public SWModule {
- protected:
- mutable char *entkeytxt;
- - static void strongsPad(char *buf);
- bool strongsPadding;
- +
- public:
- +
- /** Initializes data for instance of SWLD
- */
- SWLD(const char *imodname = 0, const char *imoddesc = 0,
- @@ -65,6 +66,13 @@ public:
- virtual bool hasEntry(const SWKey *k) const;
- +
- + /** Pads a key if (it-1) is 100% digits to 5 places allows for final to be alpha, e.g. '123B'
- + *
- + * @param[in,out] buffer to check and pad
- + */
- + static void strongsPad(char *buffer);
- +
- // OPERATORS -----------------------------------------------------------------
- SWMODULE_OPERATORS
- diff --git a/src/modules/common/rawstr.cpp b/src/modules/common/rawstr.cpp
- index 79c7cf2..a5ac41c 100644
- --- a/src/modules/common/rawstr.cpp
- +++ b/src/modules/common/rawstr.cpp
- @@ -165,7 +165,7 @@ void RawStr::getIDXBuf(long ioffset, char **buf) const
- * away - number of entries before of after to jump
- * (default = 0)
- *
- - * RET: error status -1 general error; -2 new file
- + * RET: error status -1 general error; -2 new file; -3 inconsecutive index
- */
- signed char RawStr::findOffset(const char *ikey, __u32 *start, __u16 *size, long away, __u32 *idxoff) const
- @@ -274,6 +274,11 @@ signed char RawStr::findOffset(const char *ikey, __u32 *start, __u16 *size, long
- if (idxoff)
- *idxoff = tryoff;
- + if(away > 0 && tmpStart < *start) {
- + SWLog::getSystemLog()->logError("inconsequtive index for module at path %s", path);
- + retval = -3;
- + }
- +
- *start = swordtoarch32(tmpStart);
- *size = swordtoarch16(tmpSize);
- diff --git a/src/modules/common/rawstr4.cpp b/src/modules/common/rawstr4.cpp
- index 9acbe4d..d14e11d 100644
- --- a/src/modules/common/rawstr4.cpp
- +++ b/src/modules/common/rawstr4.cpp
- @@ -174,7 +174,7 @@ void RawStr4::getIDXBuf(long ioffset, char **buf) const
- * away - number of entries before of after to jump
- * (default = 0)
- *
- - * RET: error status -1 general error; -2 new file
- + * RET: error status -1 general error; -2 new file; -3 inconsecutive index
- */
- signed char RawStr4::findOffset(const char *ikey, __u32 *start, __u32 *size, long away, __u32 *idxoff) const
- @@ -283,6 +283,11 @@ signed char RawStr4::findOffset(const char *ikey, __u32 *start, __u32 *size, lon
- if (idxoff)
- *idxoff = tryoff;
- + if(away > 0 && tmpStart < *start) {
- + SWLog::getSystemLog()->logError("inconsequtive index for module at path %s", path);
- + retval = -3;
- + }
- +
- *start = swordtoarch32(tmpStart);
- *size = swordtoarch32(tmpSize);
- diff --git a/utilities/imp2ld.cpp b/utilities/imp2ld.cpp
- index a9745cf..8174e74 100644
- --- a/utilities/imp2ld.cpp
- +++ b/utilities/imp2ld.cpp
- @@ -48,10 +48,12 @@ void usage(const char *progName, const char *error = 0) {
- fprintf(stderr, " -a\t\t\t augment module if exists (default is to create new)\n");
- fprintf(stderr, " -z\t\t\t use ZIP compression (default no compression)\n");
- fprintf(stderr, " -Z\t\t\t use LZSS compression (default no compression)\n");
- - fprintf(stderr, " -o <output_path>\t where to write data files.\n");
- + fprintf(stderr, " -o <output_path>\t\t where to write data files.\n");
- fprintf(stderr, " -4\t\t\t use 4 byte size entries (default is 2).\n");
- fprintf(stderr, " -b <entry_count>\t\t compression block size (default 30 entries)\n");
- fprintf(stderr, " -s\t\t\t case sensitive keys (default is not case sensitive)\n");
- + fprintf(stderr, " -P\t\t\t disable Strong's number padding check for digit entries. "
- + "Incorrect padding without StrongsPadding=false in you conf file will cause eternal loop.\n");
- fprintf(stderr, "\n");
- fprintf(stderr, "'imp' format is a simple standard for importing data into SWORD modules.\n"
- "Required is a plain text file containing $$$key lines followed by content.\n\n"
- @@ -79,6 +81,7 @@ int main(int argc, char **argv) {
- SWCompress *compressor = 0;
- SWBuf compType = "";
- bool fourByteSize = false;
- + bool paddingCheck = true;
- if (argc < 2) usage(*argv);
- @@ -102,6 +105,9 @@ int main(int argc, char **argv) {
- else if (!strcmp(argv[i], "-4")) {
- fourByteSize = true;
- }
- + else if (!strcmp(argv[i], "-P")) {
- + paddingCheck = false;
- + }
- else if (!strcmp(argv[i], "-b")) {
- if (i+1 < argc) {
- blockCount = atoi(argv[++i]);
- @@ -129,6 +135,10 @@ int main(int argc, char **argv) {
- std::ifstream infile(inFileName);
- + if(!infile.is_open()) {
- + std::cout << "Unable to open file " << inFileName << std::endl;
- + return -1;
- + }
- SWModule *mod = 0;
- SWKey *key, *linkKey;
- @@ -185,6 +195,15 @@ int main(int argc, char **argv) {
- std::cout << keybuffer << std::endl;
- *key = keybuffer.c_str();
- + if(paddingCheck) {
- + char *buf = new char [ strlen(*key) + 6 ];
- + strcpy(buf, *key);
- + SWLD::strongsPad(buf);
- + if(strcmp(buf, *key))
- + std::cout << "Warning: entry " << *key << " is a number but not padded correctly. ";
- + delete buf;
- + }
- +
- mod->setEntry(entbuffer.c_str(), entbuffer.size());
- for (i = 0; i < links; i++) {
- std::cout << "Linking: " << linkbuffer[i] << std::endl;
- @@ -213,6 +232,15 @@ int main(int argc, char **argv) {
- std::cout << keybuffer << std::endl;
- *key = keybuffer.c_str();
- + if(paddingCheck) {
- + char *buf = new char [ strlen(*key) + 6 ];
- + strcpy(buf, *key);
- + SWLD::strongsPad(buf);
- + if(strcmp(buf, *key))
- + std::cout << "Warning: entry " << *key << " is a number but not padded correctly. ";
- + delete buf;
- + }
- +
- mod->setEntry(entbuffer.c_str(), entbuffer.size());
- for (i = 0; i < links; i++) {
- std::cout << "Linking: " << linkbuffer[i] << std::endl;
- @@ -224,7 +252,6 @@ int main(int argc, char **argv) {
- infile.close();
- delete linkKey;
- - delete key;
- delete mod;
- return 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement