int Cxif_key::load_key(const byte* data, int size) { const byte* read_p = data; const t_xif_header_fast& header = *reinterpret_cast<const t_xif_header_fast*>(read_p); if (size < sizeof(t_xif_header_old) || header.id != file_id || header.version != file_version_old && header.version != file_version_new && header.version != file_version_fast) return 1; int error = 0; if (header.version == file_version_old) { read_p += sizeof(t_xif_header_old) - 4; load_old(read_p); error = size != read_p - data; } else { unsigned long cb_d = header.size_uncompressed; if (cb_d) { Cvirtual_binary d; if (header.version == file_version_new) error = Z_OK != uncompress(d.write_start(cb_d), &cb_d, data + sizeof(t_xif_header_old), size - sizeof(t_xif_header_old)); else { if (memcmp(data + sizeof(t_xif_header_fast), "BZh", 3)) error = Z_OK != uncompress(d.write_start(cb_d), &cb_d, data + sizeof(t_xif_header_fast), header.size_compressed); else error = BZ_OK != BZ2_bzBuffToBuffDecompress(reinterpret_cast<char*>(d.write_start(cb_d)), reinterpret_cast<unsigned int*>(&cb_d), const_cast<char*>(reinterpret_cast<const char*>(data + sizeof(t_xif_header_fast))), header.size_compressed, 0, 0); } // d.export("c:/temp/xif data.bin"); if (!error) { read_p = d.data(); load_new(read_p); error = read_p != d.data_end(); if (header.version == file_version_fast && !error) { read_p = data + sizeof(t_xif_header_fast) + header.size_compressed; load_external(read_p); error = size != read_p - data; } } } else { read_p = data + (header.version == file_version_fast ? sizeof(t_xif_header_fast) : sizeof(t_xif_header_old)); load_new(read_p); load_external(read_p); error = size != read_p - data; } } return error; }
int main(int argc, char** argv){ set_arguments(argv, argc); current = load_new(init_heap_size, init_stack_size); forth_start(entry_point); return run(current); }
bool StandardContactList::load() { if(!load_new()) return load_old(); return true; }