-/* $NetBSD: progressbar.c,v 1.6 2005/02/10 16:00:28 jmc Exp $ */
+/* $NetBSD: progressbar.c,v 1.10 2005/06/09 16:38:29 lukem Exp $ */
/*-
- * Copyright (c) 1997-2003 The NetBSD Foundation, Inc.
+ * Copyright (c) 1997-2005 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: progressbar.c,v 1.6 2005/02/10 16:00:28 jmc Exp $");
+__RCSID("$NetBSD: progressbar.c,v 1.10 2005/06/09 16:38:29 lukem Exp $");
#endif /* not lint */
/*
struct timeval td;
off_t abbrevsize, bytespersec;
double elapsed;
- int ratio, barlength, i, remaining;
+ int ratio, i, remaining;
+ size_t barlength;
/*
* Work variables for progress bar.
* these appropriately.
*/
#endif
- int len;
+ size_t len;
char buf[256]; /* workspace for progress bar */
#ifndef NO_PROGRESS
#define BAROVERHEAD 43 /* non `*' portion of progress bar */
/*
* calculate the length of the `*' bar, ensuring that
- * the number of stars won't exceed the buffer size
+ * the number of stars won't exceed the buffer size
*/
barlength = MIN(sizeof(buf) - 1, ttywidth) - BAROVERHEAD;
if (prefix)
- barlength -= strlen(prefix);
+ barlength -= strlen(prefix);
if (barlength > 0) {
i = barlength * ratio / 100;
len += snprintf(buf + len, BUFLEFT,
- "|%.*s%*s|", i, stars, barlength - i, "");
+ "|%.*s%*s|", i, stars, (int)(barlength - i), "");
}
}
struct timeval now, td, wait;
double elapsed;
off_t bytespersec;
- int remaining, hh, i, len;
+ int remaining, hh, i;
+ size_t len;
char buf[256]; /* Work variable for transfer status. */