/* * multiTest - shs1 dual test suite */ void multiTest(void) { struct dual_test *t; /* current dual test */ struct dual_test *p; /* current dual pre-string test */ struct stat buf; /* stat of a test file */ SHS1_INFO digs[2]; /* even byte digest */ char **f; /* current file being tested */ unsigned int i; unsigned int j; /* * find all of the test files */ for (i=0, f=dual_test_file; i < MAX_DUAL_TEST_FILE; ++i, ++f) { if (stat(*f, &buf) < 0) { /* no file1 in this directory, cd to the test suite directory */ if (chdir(TLIB) < 0) { fflush(stdout); fprintf(stderr, "%s: cannot find %s or %s/%s\n", program, *f, TLIB, *f); return; } } } /* * try all combinations of test strings as prefixes and data */ for (i=0, t=dual_test_data; i < MAX_DUAL_TEST_DATA; ++i, ++t) { for (j=1, p=dual_test_data+1; j < MAX_DUAL_TEST_DATA; ++j, ++p) { printf("pre:%u data:%u\n", i, j); shs1Init(digs+0); shs1Init(digs+1); multiData(p->data, p->len, t->data, t->len, 2, digs); multiOutput(NULL, 0, 0, 2, digs); } } /* * try the files with all test strings as prefixes */ for (i=0, p=dual_test_data; i < MAX_DUAL_TEST_DATA; ++i, ++p) { for (j=0, f=dual_test_file; j < MAX_DUAL_TEST_FILE; ++j, ++f) { printf("pre:%d file:%s\n", i, *f); shs1Init(digs+0); shs1Init(digs+1); multiFile(p->data, p->len, *f, 2, digs); multiOutput(NULL, 0, 0, 2, digs); } } exit(0); }
/* * multiMain - main driver of shs1 dual routines * * given: * argc arg count left after getopt * argv args left after getopt * pre_str pre-process this data first * pre_len length of pre_str * data_str data is this string, not a file * nospace 1 => don't space seperate multi digests * cnt number of digests to perform */ void multiMain(int argc, char **argv, BYTE *pre_str, UINT pre_len, char *data_str, int nospace, UINT cnt) { extern int optind; /* option index */ SHS1_INFO *digs; /* multiple digest */ unsigned int i; /* * firewall */ if (cnt <= 0) { return; } /* * initialize multiple digests */ digs = (SHS1_INFO *)malloc(sizeof(SHS1_INFO)*cnt); if (digs == NULL) { fprintf(stderr, "%s: bad malloc #1\n", program); exit(60); } for (i=0; i < cnt; ++i) { shs1Init(digs+i); } /* * digest a string */ if (data_str != NULL) { multiData(pre_str, pre_len, (BYTE*)data_str, strlen(data_str), cnt, digs); multiOutput(data_str, 1, nospace, cnt, digs); /* * case: digest stdin */ } else if (optind == argc) { multiStream(pre_str, pre_len, stdin, cnt, digs); multiOutput(NULL, 0, nospace, cnt, digs); /* * case: digest files */ } else { for (; optind < argc; optind++) { multiFile(pre_str, pre_len, argv[optind], cnt, digs); multiOutput(argv[optind], 0, nospace, cnt, digs); } } }
/*! Parses and loads multi definitions */ void cMultiCache::load( const QString &basePath ) { QFile indexFile( basePath + "multi.idx" ); if( !indexFile.open( IO_ReadOnly ) ) throw wpException( QString( "Error opening file %1 for reading." ).arg( basePath + "multi.idx" ) ); QDataStream indexStream( &indexFile ); indexStream.setByteOrder( QDataStream::LittleEndian ); QFile multiFile( basePath + "multi.mul" ); if ( !multiFile.open( IO_ReadOnly ) ) throw wpException( QString( "Error opening file %1 for reading." ).arg( basePath + "multi.mul" ) ); struct { Q_INT32 start; Q_INT32 length; Q_INT32 unknown; } indexData; ushort currentID = 0; while ( !indexStream.atEnd() ) { indexFile.at( currentID * 12 ); indexStream >> indexData.start; indexStream >> indexData.length; indexStream >> indexData.unknown; if ( indexData.start == -1 ) // empty record? { ++currentID; continue; } QValueVector<multiItem_st> items; items.reserve( indexData.length / 12 ); uint i = 0; multiFile.at( indexData.start ); QDataStream multiStream( &multiFile ); multiStream.setByteOrder( QDataStream::LittleEndian ); for (; i < indexData.length / 12; ++i ) { multiItem_st item; multiStream >> item.tile; multiStream >> item.x; multiStream >> item.y; multiStream >> item.z; Q_UINT8 empty; multiStream >> empty; // ???? Q_UINT32 isVisible = 0; multiStream >> isVisible; item.visible = isVisible > 0 ? true : false; if ( item.visible ) // we ignore invisible items (?) items.push_back(item); } MultiDefinition* multi = new MultiDefinition; multi->setItems( items ); multis.insert( currentID++, multi ); } }