inline void e2k_proto_request_parts( struct e2k_packet_request_parts_t *packet, conn_state_t* connection) { int res; fprintf(stdout,"REQUEST PARTS hash["); fprintf_e2k_hash(stdout,&packet->hash); fprintf(stdout,"] offset_1[%u,%u] offset_2[%u,%u] offset_3[%u,%u]", packet->start_offset_1, packet->end_offset_1, packet->start_offset_2, packet->end_offset_2, packet->start_offset_3, packet->end_offset_3 ); /* Oportunistic caching of downloaded files support */ if ( ! hashes_are_equal(&connection->download_hash,&packet->hash)){ /* FragmentedWriter setup */ if( connection->download_writer != NULL){ res = writers_pool_writer_release(w_pool, hash2str(&connection->download_hash)); assert( res == WRITERS_POOL_OK ); } copy_hash(&connection->download_hash, &packet->hash); connection->download_writer = writers_pool_writer_get( w_pool, hash2str(&connection->download_hash)); assert( connection->download_writer != NULL ); } /* Compressed-data-related setup */ /*res = e2k_zip_destroy(&connection->zip_state); connection->zip_state.start = packet->start_offset_1; assert( res == E2K_ZIP_OK );*/ }
static int stream_to_wimlib_stream_entry(const struct wim_inode *inode, const struct wim_inode_stream *strm, struct wimlib_stream_entry *wstream, const struct blob_table *blob_table, int flags) { const struct blob_descriptor *blob; const u8 *hash; if (stream_is_named(strm)) { size_t dummy; int ret; ret = utf16le_get_tstr(strm->stream_name, utf16le_len_bytes(strm->stream_name), &wstream->stream_name, &dummy); if (ret) return ret; } blob = stream_blob(strm, blob_table); if (blob) { blob_to_wimlib_resource_entry(blob, &wstream->resource); } else if (!is_zero_hash((hash = stream_hash(strm)))) { if (flags & WIMLIB_ITERATE_DIR_TREE_FLAG_RESOURCES_NEEDED) return blob_not_found_error(inode, hash); copy_hash(wstream->resource.sha1_hash, hash); wstream->resource.is_missing = 1; } return 0; }
pdfout_data * pdfout_data_copy (fz_context *ctx, pdfout_data *data) { if (pdfout_data_is_scalar (ctx, data)) return copy_scalar (ctx, data); else if (pdfout_data_is_hash (ctx, data)) return copy_hash (ctx, data); else if (pdfout_data_is_array (ctx, data)) return copy_array (ctx, data); else abort (); }
/* * calculate_integrity_table(): * * Calculates an integrity table for the data in a file beginning at offset 208 * (WIM_HEADER_DISK_SIZE). * * @in_fd: * File descriptor for the file to be checked, opened for reading. Does * not need to be at any specific location in the file. * * @new_check_end: * Offset of byte after the last byte to be checked. * * @old_table: * If non-NULL, a pointer to the table containing the previously calculated * integrity data for a prefix of this file. * * @old_check_end: * If @old_table is non-NULL, the byte after the last byte that was checked * in the old table. Must be less than or equal to new_check_end. * * @integrity_table_ret: * On success, a pointer to the calculated integrity table is written into * this location. * * Return values: * WIMLIB_ERR_SUCCESS (0) * WIMLIB_ERR_NOMEM * WIMLIB_ERR_READ * WIMLIB_ERR_UNEXPECTED_END_OF_FILE */ static int calculate_integrity_table(struct filedes *in_fd, off_t new_check_end, const struct integrity_table *old_table, off_t old_check_end, struct integrity_table **integrity_table_ret, wimlib_progress_func_t progfunc, void *progctx) { int ret; size_t chunk_size = INTEGRITY_CHUNK_SIZE; /* If an old table is provided, set the chunk size to be compatible with * the old chunk size, unless the old chunk size was weird. */ if (old_table != NULL) { if (old_table->num_entries == 0 || old_table->chunk_size < INTEGRITY_MIN_CHUNK_SIZE || old_table->chunk_size > INTEGRITY_MAX_CHUNK_SIZE) old_table = NULL; else chunk_size = old_table->chunk_size; } u64 old_check_bytes = old_check_end - WIM_HEADER_DISK_SIZE; u64 new_check_bytes = new_check_end - WIM_HEADER_DISK_SIZE; u32 old_num_chunks = DIV_ROUND_UP(old_check_bytes, chunk_size); u32 new_num_chunks = DIV_ROUND_UP(new_check_bytes, chunk_size); size_t old_last_chunk_size = MODULO_NONZERO(old_check_bytes, chunk_size); size_t new_last_chunk_size = MODULO_NONZERO(new_check_bytes, chunk_size); size_t new_table_size = 12 + new_num_chunks * SHA1_HASH_SIZE; struct integrity_table *new_table = MALLOC(new_table_size); if (!new_table) return WIMLIB_ERR_NOMEM; new_table->num_entries = new_num_chunks; new_table->size = new_table_size; new_table->chunk_size = chunk_size; u64 offset = WIM_HEADER_DISK_SIZE; union wimlib_progress_info progress; progress.integrity.total_bytes = new_check_bytes; progress.integrity.total_chunks = new_num_chunks; progress.integrity.completed_chunks = 0; progress.integrity.completed_bytes = 0; progress.integrity.chunk_size = chunk_size; progress.integrity.filename = NULL; ret = call_progress(progfunc, WIMLIB_PROGRESS_MSG_CALC_INTEGRITY, &progress, progctx); if (ret) goto out_free_new_table; for (u32 i = 0; i < new_num_chunks; i++) { size_t this_chunk_size; if (i == new_num_chunks - 1) this_chunk_size = new_last_chunk_size; else this_chunk_size = chunk_size; if (old_table && ((this_chunk_size == chunk_size && i < old_num_chunks - 1) || (i == old_num_chunks - 1 && this_chunk_size == old_last_chunk_size))) { /* Can use SHA1 message digest from old integrity table * */ copy_hash(new_table->sha1sums[i], old_table->sha1sums[i]); } else { /* Calculate the SHA1 message digest of this chunk */ ret = calculate_chunk_sha1(in_fd, this_chunk_size, offset, new_table->sha1sums[i]); if (ret) goto out_free_new_table; } offset += this_chunk_size; progress.integrity.completed_chunks++; progress.integrity.completed_bytes += this_chunk_size; ret = call_progress(progfunc, WIMLIB_PROGRESS_MSG_CALC_INTEGRITY, &progress, progctx); if (ret) goto out_free_new_table; } *integrity_table_ret = new_table; return 0; out_free_new_table: FREE(new_table); return ret; }