diff options
author | Cameron Katri <me@cameronkatri.com> | 2021-03-30 15:41:44 -0400 |
---|---|---|
committer | Cameron Katri <me@cameronkatri.com> | 2021-03-30 17:16:03 -0400 |
commit | a9bda63998e2f358b07a50a8dd4ed48100f9a9ee (patch) | |
tree | 3b2273f3e69ca3b4f651805987ce481245a875a2 | |
parent | abc920dfbe0fc390c02b1e23f64092c11726174d (diff) | |
download | bsd-progress-trunk.tar.gz bsd-progress-trunk.tar.zst bsd-progress-trunk.zip |
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | Makefile | 31 | ||||
-rw-r--r-- | progress.c | 16 | ||||
-rw-r--r-- | strsuftoll.c | 28 |
4 files changed, 47 insertions, 30 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..769578e --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.o +progress @@ -1,12 +1,31 @@ # $NetBSD: Makefile,v 1.2 2003/01/22 02:56:30 lukem Exp $ -.include <bsd.own.mk> - PROG= progress -SRCS= progress.c progressbar.c +SRCS= progress.c progressbar.c strsuftoll.c + + +CPPFLAGS +=-Iinclude -DSTANDALONE_PROGRESS +UNAME ?= $(shell uname) +PREFIX ?= /usr +PROG_PREFIX ?= bsd- + +ifeq ($(UNAME), Linux) +ifeq ($(shell pkg-config libbsd-overlay && echo 1),1) + CPPFLAGS+=$(shell pkg-config libbsd-overlay --cflags) + LDFLAGS+=$(shell pkg-config libbsd-overlay --libs) +endif # ($(shell pkg-config libbsd-overlay && echo 1),1) +endif # ($(UNAME), Linux) + +all: $(PROG) + +$(PROG): $(SRCS:%.c=%.o) + $(CC) $(LDFLAGS) -o $@ $^ -CPPFLAGS+=-I${NETBSDSRCDIR}/usr.bin/ftp -DSTANDALONE_PROGRESS +install: $(PROG) progress.1 + install -Dm755 $(PROG) $(DESTDIR)$(PREFIX)/bin/$(PROG_PREFIX)$(PROG) + install -Dm644 progress.1 $(DESTDIR)$(PREFIX)/share/man/man1/$(PROG_PREFIX)progress.1 -.PATH: ${NETBSDSRCDIR}/usr.bin/ftp +clean: + rm -f *.o $(PROG) -.include <bsd.prog.mk> +.PHONY: all install clean @@ -29,6 +29,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#define _GNU_SOURCE + #include <sys/cdefs.h> #ifndef lint __RCSID("$NetBSD: progress.c,v 1.23 2021/01/07 12:02:52 lukem Exp $"); @@ -50,12 +52,18 @@ __RCSID("$NetBSD: progress.c,v 1.23 2021/01/07 12:02:52 lukem Exp $"); #include <string.h> #include <unistd.h> + /* LONGLONG */ +long long strsuftoll(const char *, const char *, long long, long long); + /* LONGLONG */ +long long strsuftollx(const char *, const char *, long long, long long, + char *, size_t); + #define GLOBAL /* force GLOBAL decls in progressbar.h to be * declared */ #include "progressbar.h" static void broken_pipe(int unused); -__dead static void usage(void); +static void usage(void); static void broken_pipe(int unused) @@ -87,7 +95,7 @@ main(int argc, char *argv[]) ssize_t nr, nw, off; size_t buffersize; struct stat statb; - struct ttysize ts; + struct winsize wins; setprogname(argv[0]); @@ -199,10 +207,10 @@ main(int argc, char *argv[]) progress = 1; ttyout = eflag ? stderr : stdout; - if (ioctl(fileno(ttyout), TIOCGSIZE, &ts) == -1) + if (ioctl(fileno(ttyout), TIOCGWINSZ, &wins) == -1) ttywidth = 80; else - ttywidth = ts.ts_cols; + ttywidth = wins.ws_col; fb_buf = malloc(buffersize); if (fb_buf == NULL) diff --git a/strsuftoll.c b/strsuftoll.c index 80fc52f..973df9d 100644 --- a/strsuftoll.c +++ b/strsuftoll.c @@ -60,22 +60,12 @@ * SUCH DAMAGE. */ -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - #include <sys/cdefs.h> #if defined(LIBC_SCCS) && !defined(lint) __RCSID("$NetBSD: strsuftoll.c,v 1.9 2011/10/22 22:08:47 christos Exp $"); #endif /* LIBC_SCCS and not lint */ -#ifdef _LIBC -#include "namespace.h" -#endif - -#if !HAVE_STRSUFTOLL - #include <sys/types.h> #include <sys/time.h> @@ -88,12 +78,11 @@ __RCSID("$NetBSD: strsuftoll.c,v 1.9 2011/10/22 22:08:47 christos Exp $"); #include <stdlib.h> #include <string.h> -#ifdef _LIBC -# ifdef __weak_alias -__weak_alias(strsuftoll, _strsuftoll) -__weak_alias(strsuftollx, _strsuftollx) -# endif -#endif /* LIBC */ + /* LONGLONG */ +long long strsuftoll(const char *, const char *, long long, long long); + /* LONGLONG */ +long long strsuftollx(const char *, const char *, long long, long long, + char *, size_t); /* * Convert an expression of the following forms to a (u)int64_t. @@ -137,9 +126,9 @@ __strsuftollx(const char *desc, const char *val, long long num, t; char *expr; - _DIAGASSERT(desc != NULL); - _DIAGASSERT(val != NULL); - _DIAGASSERT(ebuf != NULL); + (void)(desc != NULL); + (void)(val != NULL); + (void)(ebuf != NULL); if (depth > 16) { snprintf(ebuf, ebuflen, "%s: Recursion limit exceeded", desc); @@ -246,4 +235,3 @@ strsuftollx(const char *desc, const char *val, { return __strsuftollx(desc, val, min, max, ebuf, ebuflen, 0); } -#endif /* !HAVE_STRSUFTOLL */ |