be used in place of all %.0f output idioms.
if (map->p_fd_offset != read_start) {
OFF_T ret = do_lseek(map->fd, read_start, SEEK_SET);
if (ret != read_start) {
- rsyserr(FERROR, errno, "lseek returned %.0f, not %.0f",
- (double)ret, (double)read_start);
+ rsyserr(FERROR, errno, "lseek returned %s, not %s",
+ big_num(ret, 0), big_num(read_start, 0));
exit_cleanup(RERR_FILEIO);
}
map->p_fd_offset = read_start;
flist->malloced);
if (DEBUG_GTE(FLIST, 1) && flist->malloced != FLIST_START) {
- rprintf(FCLIENT, "[%s] expand file_list pointer array to %.0f bytes, did%s move\n",
+ rprintf(FCLIENT, "[%s] expand file_list pointer array to %s bytes, did%s move\n",
who_am_i(),
- (double)sizeof flist->files[0] * flist->malloced,
+ big_num(sizeof flist->files[0] * flist->malloced, 0),
(new_ptr == flist->files) ? " not" : "");
}
} else
root = dir = slash = name = trail = "";
rprintf(FINFO,
- "[%s] i=%d %s %s%s%s%s mode=0%o len=%.0f%s%s flags=%x\n",
+ "[%s] i=%d %s %s%s%s%s mode=0%o len=%s%s%s flags=%x\n",
who, i + flist->ndx_start,
root, dir, slash, name, trail,
- (int)file->mode, (double)F_LENGTH(file),
+ (int)file->mode, big_num(F_LENGTH(file), 0),
uidbuf, gidbuf, file->flags);
}
}
if (sum->count && DEBUG_GTE(CHKSUM, 2)) {
rprintf(FINFO,
- "count=%.0f rem=%ld blength=%ld s2length=%d flength=%.0f\n",
- (double)sum->count, (long)sum->remainder, (long)sum->blength,
- sum->s2length, (double)sum->flength);
+ "count=%s rem=%ld blength=%ld s2length=%d flength=%s\n",
+ big_num(sum->count, 0), (long)sum->remainder, (long)sum->blength,
+ sum->s2length, big_num(sum->flength, 0));
}
}
if (DEBUG_GTE(CHKSUM, 3)) {
rprintf(FINFO,
- "chunk[%.0f] offset=%.0f len=%ld sum1=%08lx\n",
- (double)i, (double)offset - n1, (long)n1,
+ "chunk[%s] offset=%s len=%ld sum1=%08lx\n",
+ big_num(i, 0), big_num(offset - n1, 0), (long)n1,
(unsigned long)sum1);
}
write_int(f_out, sum1);
}
if (DEBUG_GTE(CHKSUM, 3)) {
- rprintf(FINFO, "gen mapped %s of size %.0f\n",
- fnamecmp, (double)sx.st.st_size);
+ rprintf(FINFO, "gen mapped %s of size %s\n",
+ fnamecmp, big_num(sx.st.st_size, 0));
}
if (DEBUG_GTE(CHKSUM, 2))
}
rprintf(FERROR, RSYNC_NAME ": connection unexpectedly closed "
- "(%.0f bytes received so far) [%s]\n",
- (double)stats.total_read, who_am_i());
+ "(%s bytes received so far) [%s]\n",
+ big_num(stats.total_read, 0), who_am_i());
exit_cleanup(RERR_STREAMIO);
}
void log_exit(int code, const char *file, int line)
{
if (code == 0) {
- rprintf(FLOG,"sent %.0f bytes received %.0f bytes total size %.0f\n",
- (double)stats.total_written,
- (double)stats.total_read,
- (double)stats.total_size);
+ rprintf(FLOG,"sent %s bytes received %s bytes total size %s\n",
+ big_num(stats.total_written, 0),
+ big_num(stats.total_read, 0),
+ big_num(stats.total_size, 0));
} else if (am_server != 2) {
const char *name;
extern int am_daemon;
extern int inc_recurse;
extern int blocking_io;
+extern int human_readable;
extern int remove_source_files;
extern int output_needs_newline;
extern int need_messages_from_generator;
rprintf(FINFO,"Number of files transferred: %d\n",
stats.num_transferred_files);
rprintf(FINFO,"Total file size: %s bytes\n",
- human_num(stats.total_size));
+ big_num(stats.total_size, human_readable));
rprintf(FINFO,"Total transferred file size: %s bytes\n",
- human_num(stats.total_transferred_size));
+ big_num(stats.total_transferred_size, human_readable));
rprintf(FINFO,"Literal data: %s bytes\n",
- human_num(stats.literal_data));
+ big_num(stats.literal_data, human_readable));
rprintf(FINFO,"Matched data: %s bytes\n",
- human_num(stats.matched_data));
+ big_num(stats.matched_data, human_readable));
rprintf(FINFO,"File list size: %s\n",
- human_num(stats.flist_size));
+ big_num(stats.flist_size, human_readable));
if (stats.flist_buildtime) {
rprintf(FINFO,
"File list generation time: %.3f seconds\n",
(double)stats.flist_xfertime / 1000);
}
rprintf(FINFO,"Total bytes sent: %s\n",
- human_num(total_written));
+ big_num(total_written, human_readable));
rprintf(FINFO,"Total bytes received: %s\n",
- human_num(total_read));
+ big_num(total_read, human_readable));
}
if (INFO_GTE(STATS, 1)) {
rprintf(FCLIENT, "\n");
rprintf(FINFO,
"sent %s bytes received %s bytes %s bytes/sec\n",
- human_num(total_written), human_num(total_read),
+ big_num(total_written, human_readable),
+ big_num(total_read, human_readable),
human_dnum((total_written + total_read)/(0.5 + (endtime - starttime)), 2));
rprintf(FINFO, "total size is %s speedup is %.2f%s\n",
- human_num(stats.total_size),
+ big_num(stats.total_size, human_readable),
(double)stats.total_size / (total_written+total_read),
write_batch < 0 ? " (BATCH ONLY)" : dry_run ? " (DRY RUN)" : "");
}
if (DEBUG_GTE(CHKSUM, 2) && i >= 0) {
rprintf(FINFO,
- "match at %.0f last_match=%.0f j=%d len=%ld n=%ld\n",
- (double)offset, (double)last_match, i,
+ "match at %s last_match=%s j=%d len=%ld n=%ld\n",
+ big_num(offset, 0), big_num(last_match, 0), i,
(long)s->sums[i].len, (long)n);
}
want_i = 0;
if (DEBUG_GTE(CHKSUM, 2)) {
- rprintf(FINFO, "hash search b=%ld len=%.0f\n",
- (long)s->blength, (double)len);
+ rprintf(FINFO, "hash search b=%ld len=%s\n",
+ (long)s->blength, big_num(len, 0));
}
k = (int32)MIN(len, (OFF_T)s->blength);
end = len + 1 - s->sums[s->count-1].len;
if (DEBUG_GTE(CHKSUM, 3)) {
- rprintf(FINFO, "hash search s->blength=%ld len=%.0f count=%.0f\n",
- (long)s->blength, (double)len, (double)s->count);
+ rprintf(FINFO, "hash search s->blength=%ld len=%s count=%s\n",
+ (long)s->blength, big_num(len, 0), big_num(s->count, 0));
}
do {
int32 i;
if (DEBUG_GTE(CHKSUM, 4)) {
- rprintf(FINFO, "offset=%.0f sum=%04x%04x\n",
- (double)offset, s2 & 0xFFFF, s1 & 0xFFFF);
+ rprintf(FINFO, "offset=%s sum=%04x%04x\n",
+ big_num(offset, 0), s2 & 0xFFFF, s1 & 0xFFFF);
}
if (tablesize == TRADITIONAL_TABLESIZE) {
if (DEBUG_GTE(CHKSUM, 3)) {
rprintf(FINFO,
- "potential match at %.0f i=%ld sum=%08x\n",
- (double)offset, (long)i, sum);
+ "potential match at %s i=%ld sum=%08x\n",
+ big_num(offset, 0), (long)i, sum);
}
if (!done_csum2) {
return;
rprintf(FINFO,
- "total: matches=%d hash_hits=%d false_alarms=%d data=%.0f\n",
+ "total: matches=%d hash_hits=%d false_alarms=%d data=%s\n",
total_matches, total_hash_hits, total_false_alarms,
- (double)stats.literal_data);
+ big_num(stats.literal_data, 0));
}
extern int am_server;
extern int need_unsorted_flist;
extern int output_needs_newline;
+extern int human_readable;
extern struct stats stats;
extern struct file_list *cur_flist;
output_needs_newline = 0;
pct = ofs == size ? 100 : (int) (100.0 * ofs / size);
rprintf(FCLIENT, "\r%12s %3d%% %7.2f%s %s%s",
- human_num(ofs), pct, rate, units, rembuf, eol);
+ big_num(ofs, human_readable), pct, rate, units, rembuf, eol);
if (!is_last) {
output_needs_newline = 1;
rflush(FCLIENT);
int32 read_size = MAX(sum.blength * 2, 16*1024);
mapbuf = map_file(fd_r, size_r, read_size, sum.blength);
if (DEBUG_GTE(CHKSUM, 2)) {
- rprintf(FINFO, "recv mapped %s of size %.0f\n",
- fname_r, (double)size_r);
+ rprintf(FINFO, "recv mapped %s of size %s\n",
+ fname_r, big_num(size_r, 0));
}
} else
mapbuf = NULL;
}
offset = sum.flength;
if (fd != -1 && (j = do_lseek(fd, offset, SEEK_SET)) != offset) {
- rsyserr(FERROR_XFER, errno, "lseek of %s returned %.0f, not %.0f",
- full_fname(fname), (double)j, (double)offset);
+ rsyserr(FERROR_XFER, errno, "lseek of %s returned %s, not %s",
+ full_fname(fname), big_num(j, 0), big_num(offset, 0));
exit_cleanup(RERR_FILEIO);
}
}
if (i > 0) {
if (DEBUG_GTE(CHKSUM, 3)) {
- rprintf(FINFO,"data recv %d at %.0f\n",
- i,(double)offset);
+ rprintf(FINFO,"data recv %d at %s\n",
+ i, big_num(offset, 0));
}
stats.literal_data += i;
if (DEBUG_GTE(CHKSUM, 3)) {
rprintf(FINFO,
- "chunk[%d] of size %ld at %.0f offset=%.0f\n",
- i, (long)len, (double)offset2, (double)offset);
+ "chunk[%d] of size %ld at %s offset=%s\n",
+ i, (long)len, big_num(offset2, 0), big_num(offset, 0));
}
if (mapbuf) {
offset += len;
if ((pos = do_lseek(fd, len, SEEK_CUR)) != offset) {
rsyserr(FERROR_XFER, errno,
- "lseek of %s returned %.0f, not %.0f",
+ "lseek of %s returned %s, not %s",
full_fname(fname),
- (double)pos, (double)offset);
+ big_num(pos, 0), big_num(offset, 0));
exit_cleanup(RERR_FILEIO);
}
continue;
s->sums = NULL;
if (DEBUG_GTE(CHKSUM, 3)) {
- rprintf(FINFO, "count=%.0f n=%ld rem=%ld\n",
- (double)s->count, (long)s->blength, (long)s->remainder);
+ rprintf(FINFO, "count=%s n=%ld rem=%ld\n",
+ big_num(s->count, 0), (long)s->blength, (long)s->remainder);
}
if (append_mode > 0) {
if (DEBUG_GTE(CHKSUM, 3)) {
rprintf(FINFO,
- "chunk[%d] len=%d offset=%.0f sum1=%08x\n",
- i, s->sums[i].len, (double)s->sums[i].offset,
+ "chunk[%d] len=%d offset=%s sum1=%08x\n",
+ i, s->sums[i].len, big_num(s->sums[i].offset, 0),
s->sums[i].sum1);
}
}
mbuf = NULL;
if (DEBUG_GTE(CHKSUM, 2)) {
- rprintf(FINFO, "send_files mapped %s%s%s of size %.0f\n",
- path,slash,fname, (double)st.st_size);
+ rprintf(FINFO, "send_files mapped %s%s%s of size %s\n",
+ path,slash,fname, big_num(st.st_size, 0));
}
write_ndx_and_attrs(f_out, ndx, iflags, fname, file,
return (depth < 0);
}
-/* Return the int64 number as a string. If the --human-readable option was
- * specified, we may output the number in K, M, or G units. We can return
- * up to 4 buffers at a time. */
-char *human_num(int64 num)
+/* Return the int64 number as a string. If the human_flag arg is non-zero,
+ * we may output the number in K, M, or G units. We can return up to 4
+ * buffers at a time. */
+char *big_num(int64 num, int human_flag)
{
static char bufs[4][128]; /* more than enough room */
static unsigned int n;
n = (n + 1) % (sizeof bufs / sizeof bufs[0]);
- if (human_readable) {
+ if (human_flag) {
char units = '\0';
- int mult = human_readable == 1 ? 1000 : 1024;
+ int mult = human_flag == 1 ? 1000 : 1024;
double dnum = 0;
if (num > mult*mult*mult) {
dnum = (double)num / (mult*mult*mult);
/* Return the double number as a string. If the --human-readable option was
* specified, we may output the number in K, M, or G units. We use a buffer
- * from human_num() to return our result. */
+ * from big_num() to return our result. */
char *human_dnum(double dnum, int decimal_digits)
{
- char *buf = human_num(dnum);
+ char *buf = big_num(dnum, human_readable);
int len = strlen(buf);
if (isDigit(buf + len - 1)) {
/* There's extra room in buf prior to the start of the num. */
/* Using _realloc_array() lets us pass the size, not a type. */
new_ptr = _realloc_array(lp->items, item_size, new_size);
if (DEBUG_GTE(FLIST, 3)) {
- rprintf(FINFO, "[%s] expand %s to %.0f bytes, did%s move\n",
- who_am_i(), desc, (double)new_size * item_size,
+ rprintf(FINFO, "[%s] expand %s to %s bytes, did%s move\n",
+ who_am_i(), desc, big_num(new_size * item_size, 0),
new_ptr == lp->items ? " not" : "");
}
if (!new_ptr)
static ssize_t get_xattr_names(const char *fname)
{
ssize_t list_len;
- double arg;
+ int64 arg;
if (!namebuf) {
namebuf_len = 1024;
} else if (errno == ENOTSUP)
return 0;
else if (errno != ERANGE) {
- arg = (double)namebuf_len;
+ arg = namebuf_len;
got_error:
rsyserr(FERROR_XFER, errno,
- "get_xattr_names: llistxattr(\"%s\",%.0f) failed",
- fname, arg);
+ "get_xattr_names: llistxattr(\"%s\",%s) failed",
+ fname, big_num(arg, 0));
return -1;
}
list_len = sys_llistxattr(fname, NULL, 0);