--- /dev/null
+*.o
+progress
# $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
* 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 $");
#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)
ssize_t nr, nw, off;
size_t buffersize;
struct stat statb;
- struct ttysize ts;
+ struct winsize wins;
setprogname(argv[0]);
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)
* 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>
#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.
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);
{
return __strsuftollx(desc, val, min, max, ebuf, ebuflen, 0);
}
-#endif /* !HAVE_STRSUFTOLL */