/// Flush set pixels // /// Compares the data matrix to the buffer matrix. /// Differences are copied to the buffer. /// Bytes with differences in them are printed on the screen. /// Data matrix is emptied. void nokia5510::flush(){ int posx = 0; int posy = 0; int ar[8]; for(int y = 0; y < 48; y++){ for(int x = 0; x <84; x++){ if (data[x][y] != buffer[x][y]){ if ((!(x == 0 && y == 0 ))&&(!(x == posx + 1 && ((y/8)*8) == ((posy/8)*8)))){ locx(x); locy(y/8); } for (int n = 0; n < 8; n++){ ar[n] = data[x][n + ((y/8)*8)]; buffer[x][n + ((y/8)*8)] = data[x][n+((y/8)*8)]; } datain(ar); posx = x; posy = y; } } } for(int y = 0; y < 48; y++){ for(int x = 0; x <84; x++){ data[x][y] = 0; } } }
/// Screen clear // /// Clears the screen of al pixels. /// Emptys both the buffer and data matrix. void nokia5510::clear(){ int empty[8] = {0}; for(int i = 0 ;i < 504; i++){ datain(empty); } for(int y = 0; y < 48; y++){ for(int x = 0; x <84; x++){ buffer[x][y] = 0; data[x][y] = 0; } } }
int main() { int i,j; int num = 0; char *text; FILE *fwp; datain(&num); printf("\n number of letters: %d\n" ,num); text = (char *)malloc(num); copy(text); fwp = fopen("testtxt.txt","w"); for(j = 0; j <= num; j++) { for(i = j; *(text+i); i++) fprintf(fwp,"%c",*(text+i)); fprintf(fwp,"\n"); } return 0; }
void test_enctain(const std::string& filedata, std::string filename) { std::ostringstream memfile; filename.size(); { Enctain::Container container; container.SetGlobalUnencryptedProperty("prop1", "test abc"); container.SetGlobalEncryptedProperty("secret1", "blah"); container.SetGlobalEncryptedProperty("prop2", std::string(255, 'a')); container.SetGlobalEncryptedProperty("prop3", std::string(256, 'b')); unsigned int sf1 = container.AppendSubFile(); container.SetSubFileEncryption(sf1, Enctain::ENCRYPTION_NONE); container.SetSubFileCompression(sf1, Enctain::COMPRESSION_NONE); container.SetSubFileProperty(sf1, "Name", "test1.txt"); container.SetSubFileProperty(sf1, "MIME-Type", "text/plain"); container.SetSubFileData(sf1, filedata.data(), filedata.size()); unsigned int sf2 = container.AppendSubFile(); container.SetSubFileEncryption(sf2, Enctain::ENCRYPTION_NONE); container.SetSubFileCompression(sf2, Enctain::COMPRESSION_ZLIB); container.SetSubFileProperty(sf2, "Name", "test2.txt"); container.SetSubFileProperty(sf2, "MIME-Type", "text/plain"); container.SetSubFileData(sf2, filedata.data(), filedata.size()); container.AddKeySlot("oYLiP4Td"); unsigned int sf3 = container.AppendSubFile(); container.SetSubFileEncryption(sf3, Enctain::ENCRYPTION_NONE); container.SetSubFileCompression(sf3, Enctain::COMPRESSION_BZIP2); container.SetSubFileProperty(sf3, "Name", "test3.txt"); container.SetSubFileProperty(sf3, "MIME-Type", "text/plain"); container.SetSubFileData(sf3, filedata.data(), filedata.size()); unsigned int sf4 = container.AppendSubFile(); container.SetSubFileEncryption(sf4, Enctain::ENCRYPTION_SERPENT256); container.SetSubFileCompression(sf4, Enctain::COMPRESSION_NONE); container.SetSubFileProperty(sf4, "Name", "test4.txt"); container.SetSubFileProperty(sf4, "MIME-Type", "text/plain"); container.SetSubFileData(sf4, filedata.data(), filedata.size()); unsigned int sf5 = container.AppendSubFile(); container.SetSubFileEncryption(sf5, Enctain::ENCRYPTION_SERPENT256); container.SetSubFileCompression(sf5, Enctain::COMPRESSION_ZLIB); container.SetSubFileProperty(sf5, "Name", "test5.txt"); container.SetSubFileProperty(sf5, "MIME-Type", "text/plain"); container.SetSubFileData(sf5, filedata.data(), filedata.size()); container.AddKeySlot("ELO0Eia9"); unsigned int sf6 = container.AppendSubFile(); container.SetSubFileEncryption(sf6, Enctain::ENCRYPTION_SERPENT256); container.SetSubFileCompression(sf6, Enctain::COMPRESSION_BZIP2); container.SetSubFileProperty(sf6, "Name", "test6.txt"); container.SetSubFileProperty(sf6, "MIME-Type", "text/plain"); container.SetSubFileData(sf6, filedata.data(), filedata.size()); #if WRITEFILE == 0 Enctain::DataOutputStream dataout(memfile); #else std::ofstream outstream(filename.c_str()); Enctain::DataOutputStream dataout(outstream); #endif container.Save(dataout); } { Enctain::Container container; #if WRITEFILE == 0 std::istringstream instream(memfile.str()); #else std::ifstream instream(filename.c_str()); #endif Enctain::DataInputStream datain(instream); container.Load(datain, "ELO0Eia9"); std::string key, val; assert( container.GetGlobalUnencryptedPropertyIndex(0, key, val) ); assert( key == "prop1" && val == "test abc" ); assert( !container.GetGlobalUnencryptedPropertyIndex(1, key, val) ); assert( container.GetGlobalEncryptedPropertyIndex(0, key, val) ); assert( key == "prop2" && val == std::string(255, 'a') ); assert( container.GetGlobalEncryptedPropertyIndex(1, key, val) ); assert( key == "prop3" && val == std::string(256, 'b') ); assert( container.GetGlobalEncryptedPropertyIndex(2, key, val) ); assert( key == "secret1" && val == "blah" ); assert( !container.GetGlobalEncryptedPropertyIndex(3, key, val) ); assert(container.CountSubFile() == 6); // subfile 0 assert( container.GetSubFilePropertyIndex(0, 0, key, val) ); assert( key == "MIME-Type" && val == "text/plain" ); assert( container.GetSubFilePropertyIndex(0, 1, key, val) ); assert( key == "Name" && val == "test1.txt" ); assert( !container.GetSubFilePropertyIndex(0, 2, key, val) ); std::string mb; container.GetSubFileData(0, mb); assert( mb == filedata ); // subfile 1 assert( container.GetSubFilePropertyIndex(1, 0, key, val) ); assert( key == "MIME-Type" && val == "text/plain" ); assert( container.GetSubFilePropertyIndex(1, 1, key, val) ); assert( key == "Name" && val == "test2.txt" ); assert( !container.GetSubFilePropertyIndex(1, 2, key, val) ); container.GetSubFileData(1, mb); assert( mb == filedata ); // subfile 2 assert( container.GetSubFilePropertyIndex(2, 0, key, val) ); assert( key == "MIME-Type" && val == "text/plain" ); assert( container.GetSubFilePropertyIndex(2, 1, key, val) ); assert( key == "Name" && val == "test3.txt" ); assert( !container.GetSubFilePropertyIndex(2, 2, key, val) ); container.GetSubFileData(2, mb); assert( mb == filedata ); // subfile 3 assert( container.GetSubFilePropertyIndex(3, 0, key, val) ); assert( key == "MIME-Type" && val == "text/plain" ); assert( container.GetSubFilePropertyIndex(3, 1, key, val) ); assert( key == "Name" && val == "test4.txt" ); assert( !container.GetSubFilePropertyIndex(3, 2, key, val) ); container.GetSubFileData(3, mb); assert( mb == filedata ); // subfile 4 assert( container.GetSubFilePropertyIndex(4, 0, key, val) ); assert( key == "MIME-Type" && val == "text/plain" ); assert( container.GetSubFilePropertyIndex(4, 1, key, val) ); assert( key == "Name" && val == "test5.txt" ); assert( !container.GetSubFilePropertyIndex(4, 2, key, val) ); container.GetSubFileData(4, mb); assert( mb == filedata ); // subfile 5 assert( container.GetSubFilePropertyIndex(5, 0, key, val) ); assert( key == "MIME-Type" && val == "text/plain" ); assert( container.GetSubFilePropertyIndex(5, 1, key, val) ); assert( key == "Name" && val == "test6.txt" ); assert( !container.GetSubFilePropertyIndex(5, 2, key, val) ); container.GetSubFileData(5, mb); assert( mb == filedata ); // subfile 5 (again) assert( container.GetSubFilePropertyIndex(5, 0, key, val) ); assert( key == "MIME-Type" && val == "text/plain" ); assert( container.GetSubFilePropertyIndex(5, 1, key, val) ); assert( key == "Name" && val == "test6.txt" ); assert( !container.GetSubFilePropertyIndex(5, 2, key, val) ); container.GetSubFileData(5, mb); assert( mb == filedata ); } }