memcpy(dst, comp->dc_data+comp->dc_data_loc, dl_size);
comp->dc_data_loc += dl_size;
if(dl_size > 0)
- zck_log(ZCK_LOG_DEBUG, "Reading %lu bytes from decompressed buffer",
- dl_size);
+ zck_log(ZCK_LOG_DEBUG, "Reading %llu bytes from decompressed buffer",
+ (long long unsigned) dl_size);
return dl_size;
}
zck_log(ZCK_LOG_ERROR, "OOM in %s", __func__);
return false;
}
- zck_log(ZCK_LOG_DEBUG, "Adding %lu bytes to compressed buffer",
- src_size);
+ zck_log(ZCK_LOG_DEBUG, "Adding %llu bytes to compressed buffer",
+ (long long unsigned) src_size);
memcpy(comp->data + comp->data_size, src, src_size);
comp->data_size += src_size;
comp->data_loc += src_size;
if(zck->mode == ZCK_MODE_WRITE) {
if(zck->chunk_min_size == 0) {
zck->chunk_min_size = CHUNK_DEFAULT_MIN;
- zck_log(ZCK_LOG_DEBUG, "Using default minimum chunk size of %lu",
- zck->chunk_min_size);
+ zck_log(ZCK_LOG_DEBUG, "Using default minimum chunk size of %llu",
+ (long long unsigned) zck->chunk_min_size);
}
if(zck->chunk_max_size == 0) {
zck->chunk_max_size = CHUNK_DEFAULT_MAX;
- zck_log(ZCK_LOG_DEBUG, "Using default maximum chunk size of %lu",
- zck->chunk_max_size);
+ zck_log(ZCK_LOG_DEBUG, "Using default maximum chunk size of %llu",
+ (long long unsigned) zck->chunk_max_size);
}
if(zck->manual_chunk == 0) {
zck_log(ZCK_LOG_DEBUG, "Using buzhash algorithm for chunking");
zck->buzhash_width = DEFAULT_BUZHASH_WIDTH;
zck->buzhash_match_bits = DEFAULT_BUZHASH_BITS;
update_buzhash_bits(zck);
- zck_log(ZCK_LOG_DEBUG, "Setting average chunk size to %lu",
- zck->buzhash_bitmask + 1);
+ zck_log(ZCK_LOG_DEBUG, "Setting average chunk size to %llu",
+ (long long unsigned) zck->buzhash_bitmask + 1);
zck->chunk_auto_min = (zck->buzhash_bitmask + 1) / 4;
if(zck->chunk_auto_min < zck->chunk_min_size)
zck->chunk_auto_min = zck->chunk_min_size;
- zck_log(ZCK_LOG_DEBUG, "Setting automatic minimum chunk size to %lu",
- zck->chunk_auto_min);
+ zck_log(ZCK_LOG_DEBUG, "Setting automatic minimum chunk size to %llu",
+ (long long unsigned) zck->chunk_auto_min);
zck->chunk_auto_max = (zck->buzhash_bitmask + 1) * 4;
if(zck->chunk_auto_max > zck->chunk_max_size)
zck->chunk_auto_max = zck->chunk_max_size;
- zck_log(ZCK_LOG_DEBUG, "Setting automatic maximum chunk size to %lu",
- zck->chunk_auto_max);
+ zck_log(ZCK_LOG_DEBUG, "Setting automatic maximum chunk size to %llu",
+ (long long unsigned) zck->chunk_auto_max);
}
}
return false;
}
zck->chunk_min_size = value;
- zck_log(ZCK_LOG_DEBUG, "Setting minimum chunk size to %li", value);
+ zck_log(ZCK_LOG_DEBUG, "Setting minimum chunk size to %lli", (long long) value);
return true;
/* Maximum chunk size */
return false;
}
zck->chunk_max_size = value;
- zck_log(ZCK_LOG_DEBUG, "Setting maximum chunk size to %li", value);
+ zck_log(ZCK_LOG_DEBUG, "Setting maximum chunk size to %lli", (long long) value);
return true;
} else {
return false;
}
if(option == ZCK_COMP_DICT) {
- zck_log(ZCK_LOG_DEBUG, "Adding dictionary of size %li", length);
+ zck_log(ZCK_LOG_DEBUG, "Adding dictionary of size %lli", (long long) length);
zck->comp.dict = (char *)value;
zck->comp.dict_size = length;
} else {
return false;
}
if(comp->dc_data_loc != 0)
- zck_log(ZCK_LOG_DEBUG, "Freeing %lu bytes from decompressed buffer",
- comp->dc_data_loc);
- zck_log(ZCK_LOG_DEBUG, "Adding %lu bytes to decompressed buffer",
- src_size);
+ zck_log(ZCK_LOG_DEBUG, "Freeing %llu bytes from decompressed buffer",
+ (long long unsigned) comp->dc_data_loc);
+ zck_log(ZCK_LOG_DEBUG, "Adding %llu bytes to decompressed buffer",
+ (long long unsigned) src_size);
memcpy(temp, comp->dc_data + comp->dc_data_loc,
comp->dc_data_size - comp->dc_data_loc);
free(comp->dc_data);
}
bool finished_rd = false;
bool finished_dc = false;
- zck_log(ZCK_LOG_DEBUG, "Trying to read %lu bytes", dst_size);
+ zck_log(ZCK_LOG_DEBUG, "Trying to read %llu bytes", (long long unsigned) dst_size);
while(dc < dst_size) {
/* Get bytes from decompressed buffer */
ssize_t rb = comp_read_from_dc(zck, &(zck->comp), dst+dc, dst_size-dc);
free(dst);
return -1;
}
- zck_log(ZCK_LOG_DDEBUG, "Finished chunk size: %lu", data_size);
+ zck_log(ZCK_LOG_DDEBUG, "Finished chunk size: %llu", (long long unsigned) data_size);
free(dst);
return data_size;
}
return false;
}
size_t retval = 0;
- zck_log(ZCK_LOG_DEBUG, "Decompressing %lu bytes to %lu bytes", src_size,
- fd_size);
+ zck_log(ZCK_LOG_DEBUG, "Decompressing %llu bytes to %llu bytes",
+ (long long unsigned) src_size,
+ (long long unsigned) fd_size
+ );
if(use_dict && comp->ddict_ctx) {
zck_log(ZCK_LOG_DEBUG, "Running decompression using dict");
retval = ZSTD_decompress_usingDDict(comp->dctx, dst, fd_size, src,
dl->write_in_chunk -= wb;
if(!hash_update(dl->zck, &(dl->zck->check_chunk_hash), at, wb))
return -1;
- zck_log(ZCK_LOG_DEBUG, "Writing %lu bytes", wb);
+ zck_log(ZCK_LOG_DEBUG, "Writing %llu bytes", (long long unsigned) wb);
dl->dl_chunk_data += wb;
}
return wb;
tgt_idx->valid = -1;
} else {
tgt_idx->valid = 1;
- zck_log(ZCK_LOG_DEBUG, "Wrote %lu bytes at %lu",
- tgt_idx->comp_length, tgt_idx->start);
+ zck_log(ZCK_LOG_DEBUG, "Wrote %llu bytes at %llu",
+ (long long unsigned) tgt_idx->comp_length,
+ (long long unsigned) tgt_idx->start
+ );
}
free(digest);
return true;
size_t wb = 0;
dl->dl += l*c;
size_t loc = tell_data(dl->zck);
- zck_log(ZCK_LOG_DEBUG, "Downloading %lu bytes to position %lu", l*c, loc);
+ zck_log(ZCK_LOG_DEBUG, "Downloading %llu bytes to position %llu",
+ (long long unsigned) l*c,
+ (long long unsigned) loc
+ );
wb = write(dl->zck->fd, ptr, l*c);
if(dl->write_cb)
return dl->write_cb(ptr, l, c, dl->write_data);
rend = rend*10 + (size_t)(c[0] - 48);
i = j;
- zck_log(ZCK_LOG_DEBUG, "Download range: %lu-%lu", rstart, rend);
+ zck_log(ZCK_LOG_DEBUG, "Download range: %llu-%llu",
+ (long long unsigned) rstart,
+ (long long unsigned) rend
+ );
mp->length = rend-rstart+1;
mp->state = 1;
}
int count = 0;
zckRangeItem *ri = range->first;
while(ri) {
- int length = snprintf(output+loc, buf_size-loc, "%lu-%lu,",
- (long unsigned)ri->start,
- (long unsigned)ri->end);
+ int length = snprintf(output+loc, buf_size-loc, "%llu-%llu,",
+ (long long unsigned)ri->start,
+ (long long unsigned)ri->end
+ );
if(length < 0) {
set_fatal_error(zck, "Unable to get range: %s", strerror(errno));
free(output);
return true;
if(message == NULL) {
set_error(zck,
- "Hash data is supposed to have %lu bytes, but is NULL", size);
+ "Hash data is supposed to have %llu bytes, but is NULL",
+ (long long unsigned) size
+ );
return false;
}
if(size == 0) {
loaded = zck->header_size - zck->lead_size;
/* Read header from file */
- zck_log(ZCK_LOG_DEBUG, "Reading the rest of the header: %lu bytes",
- zck->header_length);
+ zck_log(ZCK_LOG_DEBUG, "Reading the rest of the header: %llu bytes",
+ (long long unsigned) zck->header_length);
if(loaded < zck->header_length) {
if(!read_data(zck, header + loaded, zck->header_length - loaded))
return false;
if(zck->header_size >
zck->lead_size + zck->preface_size + zck->index_size + length)
- zck_log(ZCK_LOG_WARNING, "There are %lu unused bytes in the header");
+ zck_log(ZCK_LOG_WARNING, "There are unused bytes in the header");
zck->sig_size = length;
zck->sig_string = header;
zck->preface_string = header;
zck->preface_size = length;
- zck_log(ZCK_LOG_DEBUG, "Generated preface: %lu bytes", zck->preface_size);
+ zck_log(
+ ZCK_LOG_DEBUG,
+ "Generated preface: %llu bytes",
+ (long long unsigned) zck->preface_size
+ );
return true;
}
}
zck->sig_string = header;
zck->sig_size = length;
- zck_log(ZCK_LOG_DEBUG, "Generated signatures: %lu bytes", zck->sig_size);
+ zck_log(
+ ZCK_LOG_DEBUG,
+ "Generated signatures: %llu bytes",
+ (long long unsigned) zck->sig_size
+ );
return true;
}
zck->lead_string = header;
zck->lead_size = length;
- zck_log(ZCK_LOG_DEBUG, "Generated lead: %lu bytes", zck->lead_size);
+ zck_log(
+ ZCK_LOG_DEBUG,
+ "Generated lead: %llu bytes",
+ (long long unsigned) zck->lead_size
+ );
return true;
}
zck->index_size + zck->sig_size;
/* Merge everything into one large string */
- zck_log(ZCK_LOG_DEBUG, "Merging into header: %lu bytes",
- zck->data_offset);
+ zck_log(
+ ZCK_LOG_DEBUG,
+ "Merging into header: %llu bytes",
+ (long long unsigned) zck->data_offset
+ );
zck->header = zmalloc(zck->data_offset);
if (!zck->header) {
zck_log(ZCK_LOG_ERROR, "OOM in %s", __func__);
bool write_header(zckCtx *zck) {
VALIDATE_WRITE_BOOL(zck);
- zck_log(ZCK_LOG_DEBUG, "Writing header: %lu bytes",
- zck->lead_size);
+ zck_log(
+ ZCK_LOG_DEBUG,
+ "Writing header: %llu bytes",
+ (long long unsigned) zck->lead_size
+ );
if(!write_data(zck, zck->fd, zck->header, zck->header_size))
return false;
return true;
hash_reset(&(zck->hash_type));
free(zck->header_digest);
zck->header_digest = NULL;
- set_error(zck,
- "Header length (%lu) doesn't match requested header length "
- "(%lu)", zck->header_length + length,
- zck->prep_hdr_size);
+ set_error(
+ zck,
+ "Header length (%llu) doesn't match requested header length (%llu)",
+ (long long unsigned) zck->header_length + length,
+ (long long unsigned) zck->prep_hdr_size
+ );
return false;
}
/* Store pre-header */
zck->header_size = lead;
zck->lead_string = header;
zck->lead_size = length;
- zck_log(ZCK_LOG_DEBUG, "Parsed lead: %lu bytes", length);
+ zck_log(
+ ZCK_LOG_DEBUG,
+ "Parsed lead: %llu bytes",
+ (long long unsigned) length
+ );
return true;
}
}
zck->index_string = index;
zck->index_size = index_size;
- zck_log(ZCK_LOG_DEBUG, "Generated index: %lu bytes", zck->index_size);
+ zck_log(
+ ZCK_LOG_DEBUG,
+ "Generated index: %llu bytes",
+ (long long unsigned) zck->index_size
+ );
return true;
}
if(idx->number == number)
return idx;
}
- zck_log(ZCK_LOG_WARNING, "Chunk %lu not found", number);
+ zck_log(
+ ZCK_LOG_WARNING,
+ "Chunk %llu not found",
+ (long long unsigned) number
+ );
return NULL;
}
} else {
wh_str = "using unknown measurement";
}
- set_error(zck, "Unable to seek to %lu %s: %s", offset, wh_str,
- strerror(errno));
+ set_error(
+ zck,
+ "Unable to seek to %llu %s: %s",
+ (long long unsigned) offset,
+ wh_str,
+ strerror(errno)
+ );
return false;
}
return true;
}
if(chk_type.digest_size*2 != length) {
free(data);
- set_fatal_error(zck, "Hash digest size mismatch for header "
- "validation\n"
- "Expected: %i\nProvided: %lu",
- chk_type.digest_size*2, length);
+ set_fatal_error(
+ zck,
+ "Hash digest size mismatch for header validation\n"
+ "Expected: %i\nProvided: %llu",
+ chk_type.digest_size*2,
+ (long long unsigned) length
+ );
return false;
}
zck_log(ZCK_LOG_DEBUG, "Setting expected hash to (%s)%.*s",
} else if(option == ZCK_VAL_HEADER_HASH_TYPE) {
VALIDATE_READ_BOOL(zck);
if(value < 0) {
- set_error(zck, "Header hash type can't be less than zero: %li",
- value);
+ set_error(zck, "Header hash type can't be less than zero: %lli",
+ (long long) value);
return false;
}
/* Make sure that header hash type is set before the header digest,
VALIDATE_READ_BOOL(zck);
if(value < 0) {
set_error(zck,
- "Header size validation can't be less than zero: %li",
- value);
+ "Header size validation can't be less than zero: %lli",
+ (long long) value);
return false;
}
zck->prep_hdr_size = value;
/* Hash options */
} else if(option < 100) {
/* Currently no hash options other than setting hash type, so bail */
- set_error(zck, "Unknown option %lu", value);
+ set_error(
+ zck,
+ "Unknown option %llu",
+ (long long unsigned) value
+ );
return false;
/* Compression options */
LOG_ERROR("%s", zck_get_error(zck));
else
LOG_ERROR(
- "Dict size doesn't match expected size: %li != %li\n",
- read_size, dict_size);
+ "Dict size doesn't match expected size: %lli != %lli\n",
+ (long long) read_size, (long long) dict_size);
goto error2;
}
if(write(dst_fd, data, dict_size) != dict_size) {
goto error2;
}
if(arguments.log_level <= ZCK_LOG_INFO)
- LOG_ERROR("Decompressed %lu bytes\n", (unsigned long)total);
+ LOG_ERROR(
+ "Decompressed %llu bytes\n",
+ (long long unsigned) total
+ );
good_exit = true;
error2:
free(data);
exit(1);
}
if(arguments.log_level <= ZCK_LOG_INFO) {
- LOG_ERROR("Wrote %lu bytes in %lu chunks\n",
- (unsigned long)(zck_get_data_length(zck) +
- zck_get_header_length(zck)),
- (long)zck_get_chunk_count(zck));
+ LOG_ERROR(
+ "Wrote %llu bytes in %llu chunks\n",
+ (long long unsigned) (zck_get_data_length(zck) + zck_get_header_length(zck)),
+ (long long unsigned) zck_get_chunk_count(zck)
+ );
}
zck_free(&zck);
}
total_size += zck_get_chunk_comp_size(tgt_idx);
}
- printf("Would download %li of %li bytes\n", (long)dl_size,
- (long)total_size);
- printf("Matched %li of %lu chunks\n", (long)matched_chunks,
- (long unsigned)zck_get_chunk_count(zck_tgt));
+ printf("Would download %lli of %lli bytes\n", (long long) dl_size,
+ (long long) total_size);
+ printf("Matched %lli of %llu chunks\n", (long long) matched_chunks,
+ (long long unsigned) zck_get_chunk_count(zck_tgt));
zck_free(&zck_tgt);
zck_free(&zck_src);
}
return retval;
if(log_level <= ZCK_LOG_DEBUG)
- LOG_ERROR("Downloading %lu bytes at position %lu\n",
- (unsigned long)start+bytes-*buffer_len,
- (unsigned long)*buffer_len);
+ LOG_ERROR(
+ "Downloading %llu bytes at position %llu\n",
+ (long long unsigned) start+bytes-*buffer_len,
+ (long long unsigned) *buffer_len
+ );
*buffer_len += start + bytes - *buffer_len;
if(lseek(fd, start, SEEK_SET) == -1) {
- LOG_ERROR("Seek to byte %lu of temporary file failed: %s\n",
- (unsigned long)start, strerror(errno));
+ LOG_ERROR(
+ "Seek to byte %llu of temporary file failed: %s\n",
+ (long long unsigned) start,
+ strerror(errno)
+ );
return 0;
}
}
CURL *curl_ctx = curl_easy_init();
if(!curl_ctx) {
- LOG_ERROR("Unable to allocate %lu bytes for curl context\n",
- (unsigned long)sizeof(CURL));
+ LOG_ERROR(
+ "Unable to allocate %llu bytes for curl context\n",
+ (long long unsigned)sizeof(CURL)
+ );
exit(10);
}
}
if(retval == 1) {
printf("Missing chunks: 0\n");
- printf("Downloaded %lu bytes\n",
- (long unsigned)zck_dl_get_bytes_downloaded(dl));
+ printf(
+ "Downloaded %llu bytes\n",
+ (long long unsigned) zck_dl_get_bytes_downloaded(dl)
+ );
if(ftruncate(dst_fd, zck_get_length(zck_tgt)) < 0) {
perror(NULL);
exit_val = 10;
}
}
}
- printf("Downloaded %lu bytes\n",
- (long unsigned)zck_dl_get_bytes_downloaded(dl));
+ printf("Downloaded %llu bytes\n",
+ (long long unsigned) zck_dl_get_bytes_downloaded(dl));
if(ftruncate(dst_fd, zck_get_length(zck_tgt)) < 0) {
perror(NULL);
exit_val = 10;
LOG_ERROR("%s", zck_get_error(zck));
else
LOG_ERROR(
- "Chunk %li size doesn't match expected size: %li != %li\n",
- zck_get_chunk_number(idx), read_size, chunk_size);
+ "Chunk %lli size doesn't match expected size: %lli != %lli\n",
+ (long long) zck_get_chunk_number(idx),
+ (long long) read_size,
+ (long long) chunk_size
+ );
goto error2;
}
char *dict_block = calloc(strlen(dir) + strlen(out_name) + 12, 1);
assert(dict_block);
- snprintf(dict_block, strlen(dir) + strlen(out_name) + 12, "%s/%s.%li",
- dir, out_name, zck_get_chunk_number(idx));
+ snprintf(dict_block, strlen(dir) + strlen(out_name) + 12, "%s/%s.%lli",
+ dir, out_name, (long long) zck_get_chunk_number(idx));
int dst_fd = open(dict_block, O_TRUNC | O_WRONLY | O_CREAT | O_BINARY, 0666);
if(dst_fd < 0) {
LOG_ERROR("Unable to open %s", dict_block);
if(!arguments.quiet) {
printf("Overall checksum type: %s\n",
zck_hash_name_from_type(zck_get_full_hash_type(zck)));
- printf("Header size: %lu\n", zck_get_header_length(zck));
+ printf("Header size: %llu\n", (long long unsigned) zck_get_header_length(zck));
char *digest = zck_get_header_digest(zck);
printf("Header checksum: %s\n", digest);
- free(digest);
- printf("Data size: %lu\n", zck_get_data_length(zck));
+ free(digest);
+ printf("Data size: %llu\n", (long long unsigned) zck_get_data_length(zck));
digest = zck_get_data_digest(zck);
printf("Data checksum: %s\n", digest);
free(digest);
- printf("Chunk count: %lu\n", (long unsigned)zck_get_chunk_count(zck));
+ printf("Chunk count: %llu\n", (long long unsigned) zck_get_chunk_count(zck));
printf("Chunk checksum type: %s\n", zck_hash_name_from_type(zck_get_chunk_hash_type(zck)));
}
if(!arguments.quiet && arguments.show_chunks)
(((int)zck_get_chunk_digest_size(zck) * 2) - (int)strlen("Checksum")), ' ');
}
- printf("%12lu %s %s %12lu %12lu %12lu",
- (long unsigned)zck_get_chunk_number(chk),
+ printf("%12llu %s %s %12llu %12llu %12llu",
+ (long long unsigned)zck_get_chunk_number(chk),
digest,
digest_uncompressed,
- (long unsigned)zck_get_chunk_start(chk),
- (long unsigned)zck_get_chunk_comp_size(chk),
- (long unsigned)zck_get_chunk_size(chk));
+ (long long unsigned)zck_get_chunk_start(chk),
+ (long long unsigned)zck_get_chunk_comp_size(chk),
+ (long long unsigned)zck_get_chunk_size(chk));
if(arguments.verify) {
if(zck_get_chunk_valid(chk) == 1)
printf(" +");
memset(data, 0, 1000);
len = zck_read(zck, data, 1000);
if(len > 0) {
- printf("%li bytes read, but file should be empty\n", (long)len);
+ printf("%lli bytes read, but file should be empty\n", (long long) len);
exit(1);
}
if(!zck_close(zck))
memset(data, 0, 1000);
ssize_t len = zck_read(zck, data, 1000);
if(len > 0) {
- printf("%li bytes read, but file should be empty\n", (long)len);
+ printf("%lli bytes read, but file should be empty\n", (long long) len);
exit(1);
}
if(!zck_close(zck))
zck_free(&zck);
exit(1);
}
- ssize_t chunk_size = zck_get_chunk_size(chunk);
+ long long chunk_size = (long long) zck_get_chunk_size(chunk);
if(chunk_size < 0) {
printf("%s", zck_get_error(zck));
zck_free(&zck);
exit(1);
}
char *data = calloc(chunk_size, 1);
- ssize_t read_size = zck_get_chunk_data(chunk, data, chunk_size);
+ long long read_size = (long long) zck_get_chunk_data(chunk, data, chunk_size);
if(read_size != chunk_size) {
if(read_size < 0)
printf("%s", zck_get_error(zck));
else
- printf("chunk size didn't match expected size: %li != %li\n",
+ printf("chunk size didn't match expected size: %lli != %lli\n",
read_size, chunk_size);
free(data);
zck_free(&zck);
zck_free(&zck);
exit(1);
}
- ssize_t chunk_size = zck_get_chunk_comp_size(chunk);
+ long long chunk_size = (long long) zck_get_chunk_comp_size(chunk);
if(chunk_size < 0) {
printf("%s", zck_get_error(zck));
zck_free(&zck);
exit(1);
}
char *data = calloc(chunk_size, 1);
- ssize_t read_size = zck_get_chunk_comp_data(chunk, data, chunk_size);
+ long long read_size = (long long) zck_get_chunk_comp_data(chunk, data, chunk_size);
if(read_size != chunk_size) {
if(read_size < 0)
printf("%s", zck_get_error(zck));
else
- printf("chunk size didn't match expected size: %li != %li\n",
+ printf("chunk size didn't match expected size: %lli != %lli\n",
read_size, chunk_size);
free(data);
zck_free(&zck);