Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5a140b689f | ||
|
|
38ddb5e32a | ||
|
|
173de4fafd | ||
|
|
ae81f83e9b | ||
|
|
9f07a28065 | ||
|
|
60913618be | ||
|
|
43dc9d6469 | ||
|
|
6cff3c1c2a | ||
|
|
caf7d6ff18 | ||
|
|
d343669f45 | ||
|
|
ecaa5ce6cd | ||
|
|
e5b5e67e57 | ||
|
|
1efe1d60b5 | ||
|
|
f83927e451 | ||
|
|
678f655116 | ||
|
|
7794df7182 | ||
|
|
923ef47056 | ||
|
|
0a509fb535 | ||
|
|
1927e88350 | ||
|
|
760ee403fe | ||
|
|
6ecf31b5ee | ||
|
|
8051f5808c | ||
|
|
0518357560 | ||
|
|
e0856df8ef | ||
|
|
d4590e1f3b | ||
|
|
99c5e0988c | ||
|
|
6a24d75022 | ||
|
|
82aa30c306 | ||
|
|
4fa3331f88 | ||
|
|
fd0850f1ab | ||
|
|
cecc8649c2 | ||
|
|
c39e97ec5a | ||
|
|
909355619b | ||
|
|
b086ddf599 | ||
|
|
a0e5d5e9e7 | ||
|
|
dbcae4a9ae | ||
|
|
4ba1343c20 | ||
|
|
ee3c02fd7f | ||
|
|
c7e0bb727e | ||
|
|
80e3f791c4 | ||
|
|
74325282e7 | ||
|
|
ab20f9406f | ||
|
|
e94600d7a4 | ||
|
|
9783f7ebef | ||
|
|
b6d1f62979 | ||
|
|
cab177814a | ||
|
|
2303da77db | ||
|
|
264e3a5879 | ||
|
|
5f6f418cfd | ||
|
|
3b2e274907 | ||
|
|
a24342a072 | ||
|
|
101294195b | ||
|
|
5cf5eda406 | ||
|
|
8c284d863d | ||
|
|
7448c7f320 | ||
|
|
b923afc385 |
@@ -3,12 +3,12 @@
|
||||
#
|
||||
# package.mk # package name and distribution details
|
||||
# vars.mk # compilation, shell and linking variables
|
||||
# filelist.mk~ # lists of files
|
||||
# filelist.mk~ # lists of files (generated by "makemake.sh")
|
||||
# unreal.mk # phony targets
|
||||
# modules.mk~ # module linking rules
|
||||
# modules.mk~ # module linking rules (generated by "makemake.sh")
|
||||
# rules.mk # compilation rules
|
||||
# link.mk # real top-level targets
|
||||
# depend.mk~ # dependencies
|
||||
# depend.mk~ # dependencies (generated by "makemake.sh")
|
||||
#
|
||||
#
|
||||
|
||||
|
||||
+48
-70
@@ -1,53 +1,61 @@
|
||||
dnl Process this file with autoconf to produce a configure script.
|
||||
|
||||
AC_INIT(src/main/version.c)
|
||||
|
||||
dnl We're using C.
|
||||
dnl
|
||||
AC_LANG_C
|
||||
|
||||
dnl Output a header file.
|
||||
dnl Copyright 2002-2008, 2010, 2012-2015, 2017, 2021, 2023 Andrew Wood
|
||||
dnl
|
||||
AC_CONFIG_HEADER(src/include/config.h:autoconf/header.in)
|
||||
dnl Distributed under the Artistic License v2.0; see `doc/COPYING'.
|
||||
|
||||
dnl Set directory to check for Configure scripts in.
|
||||
dnl
|
||||
AC_INIT
|
||||
AC_CONFIG_SRCDIR([src/main/version.c])
|
||||
AC_CONFIG_AUX_DIR(autoconf/scripts)
|
||||
AC_CONFIG_HEADERS([src/include/config.h:autoconf/header.in])
|
||||
AH_BOTTOM([#include "config-aux.h"])
|
||||
|
||||
dnl Read in package details.
|
||||
dnl
|
||||
dnl Package identity
|
||||
PACKAGE=`cat $srcdir/doc/PACKAGE`
|
||||
VERSION=`cat $srcdir/doc/VERSION`
|
||||
UCPACKAGE=`tr a-z A-Z < $srcdir/doc/PACKAGE`
|
||||
AC_SUBST(PACKAGE)
|
||||
AC_SUBST(VERSION)
|
||||
AC_SUBST(UCPACKAGE)
|
||||
AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE")
|
||||
AC_DEFINE_UNQUOTED(PROGRAM_NAME, "$PACKAGE")
|
||||
AC_DEFINE_UNQUOTED(VERSION, "$VERSION")
|
||||
AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Package name])
|
||||
AC_DEFINE_UNQUOTED([PROGRAM_NAME], ["$PACKAGE"], [Name of this program])
|
||||
AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version of this program])
|
||||
AC_DEFINE([COPYRIGHT_YEAR], [_("2023")], [Copyright year])
|
||||
AC_DEFINE([COPYRIGHT_HOLDER], [_("Andrew Wood <andrew.wood@ivarch.com>")], [Copyright holder])
|
||||
AC_DEFINE([PROJECT_HOMEPAGE], ["http://www.ivarch.com/programs/" PROGRAM_NAME ".shtml"], [Project homepage])
|
||||
AC_DEFINE([BUG_REPORTS_TO], [_("<pv@ivarch.com>")], [Bug reporting email address])
|
||||
|
||||
AC_LANG(C)
|
||||
CFLAGS=${CFLAGS:-"-O"}
|
||||
AC_PROG_CC
|
||||
AC_PROG_INSTALL
|
||||
AC_USE_SYSTEM_EXTENSIONS
|
||||
AC_C_CONST
|
||||
AC_HEADER_STDBOOL
|
||||
AC_SYS_LARGEFILE
|
||||
AC_HEADER_TIOCGWINSZ
|
||||
AC_CHECK_FUNCS(getopt_long getopt)
|
||||
AC_CHECK_HEADERS(getopt.h)
|
||||
AC_CHECK_FUNCS(memcpy basename vsnprintf strlcat)
|
||||
AC_CHECK_FUNCS(fdatasync)
|
||||
AC_CHECK_FUNCS(fpathconf sysconf posix_memalign)
|
||||
AC_CHECK_HEADERS(limits.h)
|
||||
|
||||
dnl Check for compile-time options.
|
||||
dnl
|
||||
AC_ARG_ENABLE(debugging,
|
||||
[ --enable-debugging compile with debugging support],
|
||||
if test "$enable_debugging" = "yes"; then
|
||||
CFLAGS="-g -Wall"
|
||||
AC_DEFINE(ENABLE_DEBUGGING)
|
||||
CFLAGS="$CFLAGS -g -Wall"
|
||||
AC_DEFINE([ENABLE_DEBUGGING], [1], [Debugging support enabled])
|
||||
fi
|
||||
)
|
||||
|
||||
AC_ARG_ENABLE(profiling,
|
||||
[ --enable-profiling compile with profiling support],
|
||||
if test "$enable_profiling" = "yes"; then
|
||||
CFLAGS="-pg $CFLAGS"
|
||||
fi
|
||||
)
|
||||
LFS_SUPPORT="no"
|
||||
AC_ARG_ENABLE(lfs, [ --disable-lfs disable LFS support],
|
||||
if test "$enable_lfs" = "yes"; then
|
||||
LFS_SUPPORT="yes"
|
||||
fi,
|
||||
LFS_SUPPORT="yes"
|
||||
)
|
||||
|
||||
STATIC_NLS="no"
|
||||
AC_ARG_ENABLE(static-nls, [ --enable-static-nls hardcode NLS with no support files],
|
||||
if test "$enable_static_nls" = "yes"; then
|
||||
@@ -55,6 +63,7 @@ AC_ARG_ENABLE(static-nls, [ --enable-static-nls hardcode NLS with no suppor
|
||||
fi,
|
||||
STATIC_NLS="no"
|
||||
)
|
||||
|
||||
NLS_SUPPORT="no"
|
||||
AC_ARG_ENABLE(nls, [ --disable-nls do not use Native Language Support],
|
||||
if test "$enable_nls" = "yes"; then
|
||||
@@ -62,6 +71,7 @@ AC_ARG_ENABLE(nls, [ --disable-nls do not use Native Language Support
|
||||
fi,
|
||||
NLS_SUPPORT="yes"
|
||||
)
|
||||
|
||||
SPLICE_SUPPORT="no"
|
||||
AC_ARG_ENABLE(splice, [ --disable-splice do not use splice system call],
|
||||
if test "$enable_splice" = "yes"; then
|
||||
@@ -69,6 +79,7 @@ AC_ARG_ENABLE(splice, [ --disable-splice do not use splice system call],
|
||||
fi,
|
||||
SPLICE_SUPPORT="yes"
|
||||
)
|
||||
|
||||
IPC_SUPPORT="no"
|
||||
AC_ARG_ENABLE(ipc, [ --disable-ipc turn off IPC messaging],
|
||||
if test "$enable_ipc" = "yes"; then
|
||||
@@ -77,25 +88,15 @@ AC_ARG_ENABLE(ipc, [ --disable-ipc turn off IPC messaging],
|
||||
IPC_SUPPORT="yes"
|
||||
)
|
||||
|
||||
dnl Check for various programs.
|
||||
dnl
|
||||
CFLAGS=${CFLAGS:-"-O"}
|
||||
AC_PROG_CC
|
||||
AC_PROG_INSTALL
|
||||
AC_PROG_MAKE_SET
|
||||
|
||||
dnl AIX needs -lc128
|
||||
dnl
|
||||
AC_EGREP_CPP([^yes$], [#ifdef _AIX
|
||||
yes
|
||||
#endif
|
||||
], [LIBS="$LIBS -lc128"])
|
||||
|
||||
dnl NLS stuff.
|
||||
dnl
|
||||
ALL_LINGUAS="de fr pl pt"
|
||||
dnl Native Language Support
|
||||
if test "$NLS_SUPPORT" = "yes"; then
|
||||
AC_DEFINE(ENABLE_NLS)
|
||||
AC_DEFINE([ENABLE_NLS], [1], [Enable native language support])
|
||||
AC_PATH_PROG(MSGFMT, msgfmt, NOMSGFMT)
|
||||
AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
|
||||
AC_PATH_PROG(XGETTEXT, xgettext, xgettext)
|
||||
@@ -112,7 +113,7 @@ if test "$NLS_SUPPORT" = "yes"; then
|
||||
fi
|
||||
CATOBJEXT=.mo
|
||||
INSTOBJEXT=.mo
|
||||
for lang in $ALL_LINGUAS; do
|
||||
for lang in de fr pl pt; do
|
||||
GMOFILES="$GMOFILES $lang.gmo"
|
||||
POFILES="$POFILES \$(srcdir)/src/nls/$lang.po"
|
||||
CATALOGS="$CATALOGS src/nls/$lang$CATOBJEXT";
|
||||
@@ -121,7 +122,7 @@ if test "$NLS_SUPPORT" = "yes"; then
|
||||
CATALOGS=""
|
||||
else
|
||||
AC_CHECK_FUNC(gettext,
|
||||
[AC_DEFINE(HAVE_GETTEXT)
|
||||
[AC_DEFINE([HAVE_GETTEXT], [1], [The gettext function is available])
|
||||
NLSOBJ=""
|
||||
], [CATALOGS=""; NLSOBJ="src/nls/table.o"
|
||||
]
|
||||
@@ -140,30 +141,6 @@ AC_SUBST(POFILES)
|
||||
AC_SUBST(CATALOGS)
|
||||
AC_SUBST(NLSOBJ)
|
||||
|
||||
dnl Getopt checks.
|
||||
dnl
|
||||
AC_CHECK_FUNCS(getopt_long getopt)
|
||||
AC_CHECK_HEADERS(getopt.h)
|
||||
|
||||
dnl LFS checks.
|
||||
dnl
|
||||
if test "$LFS_SUPPORT" = "yes"; then
|
||||
AC_CHECK_FUNCS(open64, AC_DEFINE(ENABLE_LARGEFILE))
|
||||
fi
|
||||
|
||||
dnl Check for various header files and set various other macros.
|
||||
dnl
|
||||
AC_DEFINE(HAVE_CONFIG_H)
|
||||
AC_HEADER_STDC
|
||||
AC_HEADER_STDBOOL
|
||||
AC_CHECK_FUNCS(memcpy basename snprintf)
|
||||
dnl OSX 11 (apple silicon) lets you link stat64() but fails to compile
|
||||
dnl so use a compile test for stat64() instead of a link test.
|
||||
AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main() { stat64(); }])],
|
||||
[AC_DEFINE([HAVE_STAT64], [1], [Is stat64() available])],
|
||||
[])
|
||||
AC_CHECK_HEADERS(limits.h)
|
||||
|
||||
if test "$IPC_SUPPORT" = "yes"; then
|
||||
AC_CHECK_HEADERS(sys/ipc.h sys/param.h libgen.h)
|
||||
fi
|
||||
@@ -172,8 +149,8 @@ if test "$SPLICE_SUPPORT" = "yes"; then
|
||||
AC_CHECK_FUNCS(splice)
|
||||
fi
|
||||
|
||||
test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
|
||||
AC_SUBST(INSTALL_DATA)
|
||||
dnl This must go after all the compiler based tests above.
|
||||
AC_LANG_WERROR
|
||||
|
||||
dnl Fudging for separate build directories.
|
||||
dnl
|
||||
@@ -192,13 +169,14 @@ done
|
||||
|
||||
dnl Output files (and create build directory structure too).
|
||||
dnl
|
||||
AC_OUTPUT(Makefile:$mk_segments doc/lsm:doc/lsm.in
|
||||
AC_CONFIG_FILES([Makefile:$mk_segments doc/lsm:doc/lsm.in
|
||||
doc/quickref.1:doc/quickref.1.in
|
||||
src/.dummy:doc/NEWS.md,
|
||||
rm -f src/.dummy
|
||||
src/.dummy:doc/NEWS.md])
|
||||
AC_CONFIG_COMMANDS([default],[rm -f src/.dummy
|
||||
for i in $subdirs; do
|
||||
test -d $i || mkdir $i
|
||||
done
|
||||
, subdirs="$subdirs")
|
||||
],[subdirs="$subdirs"])
|
||||
AC_OUTPUT
|
||||
|
||||
dnl EOF
|
||||
|
||||
+249
-108
@@ -1,114 +1,255 @@
|
||||
/*!NOINDEX*/
|
||||
/* Define if you have standard C headers. */
|
||||
#undef STDC_HEADERS
|
||||
/* autoconf/header.in. Generated from autoconf/configure.in by autoheader. */
|
||||
|
||||
/* Define if you have "config.h" (yes, you have). */
|
||||
#undef HAVE_CONFIG_H
|
||||
/* Bug reporting email address */
|
||||
#undef BUG_REPORTS_TO
|
||||
|
||||
/* Various other header files. */
|
||||
#undef HAVE_GETOPT_H
|
||||
#undef HAVE_LIMITS_H
|
||||
#undef HAVE_SYS_IPC_H
|
||||
#undef HAVE_SYS_PARAM_H
|
||||
#undef HAVE_LIBGEN_H
|
||||
/* Copyright holder */
|
||||
#undef COPYRIGHT_HOLDER
|
||||
|
||||
/* Functions. */
|
||||
#undef HAVE_GETOPT
|
||||
#undef HAVE_GETOPT_LONG
|
||||
#undef HAVE_MEMCPY
|
||||
#undef HAVE_BASENAME
|
||||
#undef HAVE_SNPRINTF
|
||||
#undef HAVE_STAT64
|
||||
/* Copyright year */
|
||||
#undef COPYRIGHT_YEAR
|
||||
|
||||
#undef HAVE_SPLICE
|
||||
#ifdef HAVE_SPLICE
|
||||
# define _GNU_SOURCE 1
|
||||
#endif
|
||||
/* NB the above must come before NLS, as NLS includes other system headers. */
|
||||
|
||||
/* NLS stuff. */
|
||||
#undef ENABLE_NLS
|
||||
#undef HAVE_LIBINTL_H
|
||||
#undef HAVE_LOCALE_H
|
||||
#undef HAVE_GETTEXT
|
||||
#ifdef ENABLE_NLS
|
||||
# include "library/gettext.h"
|
||||
#else
|
||||
# define _(String) (String)
|
||||
# define N_(String) (String)
|
||||
#endif
|
||||
|
||||
/* The name of the program. */
|
||||
#define PROGRAM_NAME "progname"
|
||||
|
||||
/* The name of the package. */
|
||||
#define PACKAGE ""
|
||||
|
||||
/* The current package version. */
|
||||
#define VERSION "0.0.0"
|
||||
|
||||
/* Various identification and legal stuff. */
|
||||
#define COPYRIGHT_YEAR _("2015")
|
||||
#define COPYRIGHT_HOLDER _("Andrew Wood <andrew.wood@ivarch.com>")
|
||||
#define PROJECT_HOMEPAGE "http://www.ivarch.com/programs/" PROGRAM_NAME ".shtml"
|
||||
#define BUG_REPORTS_TO _("<pv@ivarch.com>")
|
||||
|
||||
/* LFS support. */
|
||||
#undef ENABLE_LARGEFILE
|
||||
#ifdef ENABLE_LARGEFILE
|
||||
# define __USE_LARGEFILE64 1
|
||||
# define _LARGEFILE64_SOURCE 1
|
||||
#else
|
||||
/*
|
||||
* Some Macs have stat64 despite not having open64 while others don't have
|
||||
* either, so here even if we don't have open64 or LFS is disabled, we have
|
||||
* to check whether stat64 exists and only redefine it if it doesn't
|
||||
* otherwise some Macs fail to compile.
|
||||
*/
|
||||
# ifdef __APPLE__
|
||||
# ifndef HAVE_STAT64
|
||||
# define stat64 stat
|
||||
# define fstat64 fstat
|
||||
# define lstat64 lstat
|
||||
# endif
|
||||
# else
|
||||
# define stat64 stat
|
||||
# define fstat64 fstat
|
||||
# define lstat64 lstat
|
||||
# endif
|
||||
# define open64 open
|
||||
# define lseek64 lseek
|
||||
#endif
|
||||
|
||||
#undef HAVE_IPC
|
||||
#ifdef HAVE_SYS_IPC_H
|
||||
#define HAVE_IPC 1
|
||||
#endif
|
||||
|
||||
#undef CURSOR_ANSWERBACK_BYTE_BY_BYTE
|
||||
#ifndef _AIX
|
||||
#define CURSOR_ANSWERBACK_BYTE_BY_BYTE 1
|
||||
#endif
|
||||
|
||||
/* Boolean type support. */
|
||||
#undef HAVE_STDBOOL_H
|
||||
#ifdef HAVE_STDBOOL_H
|
||||
# include <stdbool.h>
|
||||
#else
|
||||
# ifndef HAVE__BOOL
|
||||
# ifdef __cplusplus
|
||||
typedef bool _Bool;
|
||||
# else
|
||||
# define _Bool signed char
|
||||
# endif
|
||||
# endif
|
||||
# define bool _Bool
|
||||
# define false 0
|
||||
# define true 1
|
||||
# define __bool_true_false_are_defined 1
|
||||
#endif
|
||||
|
||||
/* Support for debugging output. */
|
||||
/* Debugging support enabled */
|
||||
#undef ENABLE_DEBUGGING
|
||||
|
||||
/* EOF */
|
||||
/* Enable native language support */
|
||||
#undef ENABLE_NLS
|
||||
|
||||
/* Define to 1 if `TIOCGWINSZ' requires <sys/ioctl.h>. */
|
||||
#undef GWINSZ_IN_SYS_IOCTL
|
||||
|
||||
/* Define to 1 if you have the `basename' function. */
|
||||
#undef HAVE_BASENAME
|
||||
|
||||
/* Define to 1 if you have the `fdatasync' function. */
|
||||
#undef HAVE_FDATASYNC
|
||||
|
||||
/* Define to 1 if you have the `fpathconf' function. */
|
||||
#undef HAVE_FPATHCONF
|
||||
|
||||
/* Define to 1 if you have the `getopt' function. */
|
||||
#undef HAVE_GETOPT
|
||||
|
||||
/* Define to 1 if you have the <getopt.h> header file. */
|
||||
#undef HAVE_GETOPT_H
|
||||
|
||||
/* Define to 1 if you have the `getopt_long' function. */
|
||||
#undef HAVE_GETOPT_LONG
|
||||
|
||||
/* The gettext function is available */
|
||||
#undef HAVE_GETTEXT
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#undef HAVE_INTTYPES_H
|
||||
|
||||
/* Define to 1 if you have the <libgen.h> header file. */
|
||||
#undef HAVE_LIBGEN_H
|
||||
|
||||
/* Define to 1 if you have the `i' library (-li). */
|
||||
#undef HAVE_LIBI
|
||||
|
||||
/* Define to 1 if you have the `intl' library (-lintl). */
|
||||
#undef HAVE_LIBINTL
|
||||
|
||||
/* Define to 1 if you have the <libintl.h> header file. */
|
||||
#undef HAVE_LIBINTL_H
|
||||
|
||||
/* Define to 1 if you have the <limits.h> header file. */
|
||||
#undef HAVE_LIMITS_H
|
||||
|
||||
/* Define to 1 if you have the <locale.h> header file. */
|
||||
#undef HAVE_LOCALE_H
|
||||
|
||||
/* Define to 1 if you have the `memcpy' function. */
|
||||
#undef HAVE_MEMCPY
|
||||
|
||||
/* Define to 1 if you have the <minix/config.h> header file. */
|
||||
#undef HAVE_MINIX_CONFIG_H
|
||||
|
||||
/* Define to 1 if you have the `posix_memalign' function. */
|
||||
#undef HAVE_POSIX_MEMALIGN
|
||||
|
||||
/* Define to 1 if you have the `splice' function. */
|
||||
#undef HAVE_SPLICE
|
||||
|
||||
/* Define to 1 if stdbool.h conforms to C99. */
|
||||
#undef HAVE_STDBOOL_H
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#undef HAVE_STDINT_H
|
||||
|
||||
/* Define to 1 if you have the <stdio.h> header file. */
|
||||
#undef HAVE_STDIO_H
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#undef HAVE_STDLIB_H
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#undef HAVE_STRINGS_H
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#undef HAVE_STRING_H
|
||||
|
||||
/* Define to 1 if you have the `strlcat' function. */
|
||||
#undef HAVE_STRLCAT
|
||||
|
||||
/* Define to 1 if you have the `sysconf' function. */
|
||||
#undef HAVE_SYSCONF
|
||||
|
||||
/* Define to 1 if you have the <sys/ipc.h> header file. */
|
||||
#undef HAVE_SYS_IPC_H
|
||||
|
||||
/* Define to 1 if you have the <sys/param.h> header file. */
|
||||
#undef HAVE_SYS_PARAM_H
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#undef HAVE_SYS_STAT_H
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#undef HAVE_SYS_TYPES_H
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#undef HAVE_UNISTD_H
|
||||
|
||||
/* Define to 1 if you have the `vsnprintf' function. */
|
||||
#undef HAVE_VSNPRINTF
|
||||
|
||||
/* Define to 1 if you have the <wchar.h> header file. */
|
||||
#undef HAVE_WCHAR_H
|
||||
|
||||
/* Define to 1 if the system has the type `_Bool'. */
|
||||
#undef HAVE__BOOL
|
||||
|
||||
/* Package name */
|
||||
#undef PACKAGE
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#undef PACKAGE_BUGREPORT
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#undef PACKAGE_NAME
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#undef PACKAGE_STRING
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#undef PACKAGE_TARNAME
|
||||
|
||||
/* Define to the home page for this package. */
|
||||
#undef PACKAGE_URL
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#undef PACKAGE_VERSION
|
||||
|
||||
/* Name of this program */
|
||||
#undef PROGRAM_NAME
|
||||
|
||||
/* Project homepage */
|
||||
#undef PROJECT_HOMEPAGE
|
||||
|
||||
/* Define to 1 if all of the C90 standard headers exist (not just the ones
|
||||
required in a freestanding environment). This macro is provided for
|
||||
backward compatibility; new code need not use it. */
|
||||
#undef STDC_HEADERS
|
||||
|
||||
/* Enable extensions on AIX 3, Interix. */
|
||||
#ifndef _ALL_SOURCE
|
||||
# undef _ALL_SOURCE
|
||||
#endif
|
||||
/* Enable general extensions on macOS. */
|
||||
#ifndef _DARWIN_C_SOURCE
|
||||
# undef _DARWIN_C_SOURCE
|
||||
#endif
|
||||
/* Enable general extensions on Solaris. */
|
||||
#ifndef __EXTENSIONS__
|
||||
# undef __EXTENSIONS__
|
||||
#endif
|
||||
/* Enable GNU extensions on systems that have them. */
|
||||
#ifndef _GNU_SOURCE
|
||||
# undef _GNU_SOURCE
|
||||
#endif
|
||||
/* Enable X/Open compliant socket functions that do not require linking
|
||||
with -lxnet on HP-UX 11.11. */
|
||||
#ifndef _HPUX_ALT_XOPEN_SOCKET_API
|
||||
# undef _HPUX_ALT_XOPEN_SOCKET_API
|
||||
#endif
|
||||
/* Identify the host operating system as Minix.
|
||||
This macro does not affect the system headers' behavior.
|
||||
A future release of Autoconf may stop defining this macro. */
|
||||
#ifndef _MINIX
|
||||
# undef _MINIX
|
||||
#endif
|
||||
/* Enable general extensions on NetBSD.
|
||||
Enable NetBSD compatibility extensions on Minix. */
|
||||
#ifndef _NETBSD_SOURCE
|
||||
# undef _NETBSD_SOURCE
|
||||
#endif
|
||||
/* Enable OpenBSD compatibility extensions on NetBSD.
|
||||
Oddly enough, this does nothing on OpenBSD. */
|
||||
#ifndef _OPENBSD_SOURCE
|
||||
# undef _OPENBSD_SOURCE
|
||||
#endif
|
||||
/* Define to 1 if needed for POSIX-compatible behavior. */
|
||||
#ifndef _POSIX_SOURCE
|
||||
# undef _POSIX_SOURCE
|
||||
#endif
|
||||
/* Define to 2 if needed for POSIX-compatible behavior. */
|
||||
#ifndef _POSIX_1_SOURCE
|
||||
# undef _POSIX_1_SOURCE
|
||||
#endif
|
||||
/* Enable POSIX-compatible threading on Solaris. */
|
||||
#ifndef _POSIX_PTHREAD_SEMANTICS
|
||||
# undef _POSIX_PTHREAD_SEMANTICS
|
||||
#endif
|
||||
/* Enable extensions specified by ISO/IEC TS 18661-5:2014. */
|
||||
#ifndef __STDC_WANT_IEC_60559_ATTRIBS_EXT__
|
||||
# undef __STDC_WANT_IEC_60559_ATTRIBS_EXT__
|
||||
#endif
|
||||
/* Enable extensions specified by ISO/IEC TS 18661-1:2014. */
|
||||
#ifndef __STDC_WANT_IEC_60559_BFP_EXT__
|
||||
# undef __STDC_WANT_IEC_60559_BFP_EXT__
|
||||
#endif
|
||||
/* Enable extensions specified by ISO/IEC TS 18661-2:2015. */
|
||||
#ifndef __STDC_WANT_IEC_60559_DFP_EXT__
|
||||
# undef __STDC_WANT_IEC_60559_DFP_EXT__
|
||||
#endif
|
||||
/* Enable extensions specified by ISO/IEC TS 18661-4:2015. */
|
||||
#ifndef __STDC_WANT_IEC_60559_FUNCS_EXT__
|
||||
# undef __STDC_WANT_IEC_60559_FUNCS_EXT__
|
||||
#endif
|
||||
/* Enable extensions specified by ISO/IEC TS 18661-3:2015. */
|
||||
#ifndef __STDC_WANT_IEC_60559_TYPES_EXT__
|
||||
# undef __STDC_WANT_IEC_60559_TYPES_EXT__
|
||||
#endif
|
||||
/* Enable extensions specified by ISO/IEC TR 24731-2:2010. */
|
||||
#ifndef __STDC_WANT_LIB_EXT2__
|
||||
# undef __STDC_WANT_LIB_EXT2__
|
||||
#endif
|
||||
/* Enable extensions specified by ISO/IEC 24747:2009. */
|
||||
#ifndef __STDC_WANT_MATH_SPEC_FUNCS__
|
||||
# undef __STDC_WANT_MATH_SPEC_FUNCS__
|
||||
#endif
|
||||
/* Enable extensions on HP NonStop. */
|
||||
#ifndef _TANDEM_SOURCE
|
||||
# undef _TANDEM_SOURCE
|
||||
#endif
|
||||
/* Enable X/Open extensions. Define to 500 only if necessary
|
||||
to make mbstate_t available. */
|
||||
#ifndef _XOPEN_SOURCE
|
||||
# undef _XOPEN_SOURCE
|
||||
#endif
|
||||
|
||||
|
||||
/* Version of this program */
|
||||
#undef VERSION
|
||||
|
||||
/* Number of bits in a file offset, on hosts where this is settable. */
|
||||
#undef _FILE_OFFSET_BITS
|
||||
|
||||
/* Define for large files, on AIX-style hosts. */
|
||||
#undef _LARGE_FILES
|
||||
|
||||
/* Define to empty if `const' does not conform to ANSI C. */
|
||||
#undef const
|
||||
|
||||
#include "config-aux.h"
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
$(CC) $< $(<:%.c=%) $(srcdir) $(CFLAGS) $(CPPFLAGS) > $@
|
||||
|
||||
#
|
||||
# NLS stuff
|
||||
# Native language support
|
||||
#
|
||||
|
||||
%.mo: %.po
|
||||
|
||||
@@ -11,6 +11,7 @@ infodir = @infodir@
|
||||
mandir = @mandir@
|
||||
etcdir = @prefix@/etc
|
||||
datadir = @datadir@
|
||||
datarootdir = @datarootdir@
|
||||
sbindir = @sbindir@
|
||||
|
||||
VPATH = $(srcdir)
|
||||
@@ -27,7 +28,6 @@ MSGMERGE = msgmerge
|
||||
CATOBJEXT = @CATOBJEXT@
|
||||
INSTOBJEXT = @INSTOBJEXT@
|
||||
|
||||
@SET_MAKE@
|
||||
SHELL = /bin/sh
|
||||
CC = @CC@
|
||||
INSTALL = @INSTALL@
|
||||
|
||||
@@ -5,15 +5,15 @@
|
||||
# time, as suggested by Ville Herva <Ville.Herva@iki.fi>.
|
||||
#
|
||||
|
||||
test_input=`mktemp /tmp/pvbench1XXXXXX`
|
||||
strace_output=`mktemp /tmp/pvbench2XXXXXX`
|
||||
test_input=$(mktemp /tmp/pvbench1XXXXXX)
|
||||
strace_output=$(mktemp /tmp/pvbench2XXXXXX)
|
||||
|
||||
trap "rm -f ${test_input} ${strace_output}" 0
|
||||
trap 'rm -f ${test_input} ${strace_output}' EXIT
|
||||
|
||||
pv=${pv:-./pv}
|
||||
test -x ${pv} || pv=pv
|
||||
test -x "${pv}" || pv="pv"
|
||||
|
||||
dd if=/dev/zero of=${test_input} bs=1k count=1k >/dev/null 2>&1
|
||||
dd if=/dev/zero of="${test_input}" bs=1k count=1k >/dev/null 2>&1
|
||||
|
||||
echo -e "Buf(k)\tRate(k)\tReads\tRsize\tWrites\tWsize"
|
||||
|
||||
@@ -21,16 +21,16 @@ for ((buffer=100; buffer<=1000; buffer+=100)); do
|
||||
for ((rate=0; rate<=1000; rate+=100)); do
|
||||
rateparm="-L ${rate}k"
|
||||
test ${rate} -eq 0 && rateparm=""
|
||||
strace -tt -o ${strace_output} \
|
||||
${pv} ${rateparm} -B ${buffer}k \
|
||||
-f < ${test_input} > /dev/null 2>&1
|
||||
strace -tt -o "${strace_output}" \
|
||||
"${pv}" "${rateparm}" -B "${buffer}k" \
|
||||
-f < "${test_input}" > /dev/null 2>&1
|
||||
rdata=$(
|
||||
awk '$2~/^read\(0,/{c++;t+=$NF}END{print c "\t" t/c}' \
|
||||
${strace_output}
|
||||
"${strace_output}"
|
||||
)
|
||||
wdata=$(
|
||||
awk '$2~/^write\(1,/{c++;t+=$NF}END{print c "\t" t/c}' \
|
||||
${strace_output}
|
||||
"${strace_output}"
|
||||
)
|
||||
echo -e "${buffer}\t${rate}\t${rdata}\t${wdata}"
|
||||
done
|
||||
|
||||
+15
-12
@@ -3,25 +3,28 @@
|
||||
# Generate dependencies for a C source file.
|
||||
#
|
||||
|
||||
CC=$1
|
||||
CC="$1"
|
||||
shift
|
||||
file=$1
|
||||
file="$1"
|
||||
shift
|
||||
stem=$1
|
||||
stem="$1"
|
||||
shift
|
||||
srcdir=$1
|
||||
abssrc=`echo $srcdir | sed ':1
|
||||
srcdir="$1"
|
||||
abssrc=$(echo "$srcdir" | sed ':1
|
||||
s,^\./,,g
|
||||
t1'`
|
||||
t1')
|
||||
shift
|
||||
|
||||
abssrc=`echo "$abssrc" | sed 's,\\.,\\\\.,g'`
|
||||
srcdir=`echo "$srcdir" | sed 's,\\.,\\\\.,g'`
|
||||
abssrc=$(echo "$abssrc" | sed 's,\.,\\.,g')
|
||||
srcdir=$(echo "$srcdir" | sed 's,\.,\\.,g')
|
||||
|
||||
$CC -M -MG $* $file \
|
||||
| sed -e 's, /[^ ]*,,g' -e "s,^.*\.o:,${stem}.d ${stem}.o:," \
|
||||
-e '/^ \\$/d' -e 's/ \\$//' \
|
||||
-e 's,'"$srcdir"'/,,g' -e 's,'"$abssrc"'/,,g' \
|
||||
$CC -M -MG "$@" "$file" \
|
||||
| sed \
|
||||
-e "s,^.*\.o:,${stem}.d ${stem}.o:," \
|
||||
-e 's,'"$srcdir"'/,,g' \
|
||||
-e 's,'"$abssrc"'/,,g' \
|
||||
-e 's, /[^ ]*,,g' \
|
||||
-e '/^ \\$/d' -e 's/ \\$//' \
|
||||
| tr '\n' ' ' \
|
||||
| tr -s ' '
|
||||
|
||||
|
||||
+75
-55
@@ -15,8 +15,15 @@
|
||||
# Requires ctags and cproto.
|
||||
#
|
||||
|
||||
OFFS=$1
|
||||
command -v "ctags" >/dev/null 2>&1 || { echo "${0##*/}: ctags: command not found" 1>&2; exit 1; }
|
||||
command -v "cproto" >/dev/null 2>&1 || { echo "${0##*/}: cproto: command not found" 1>&2; exit 1; }
|
||||
|
||||
linkPrefix=$1
|
||||
test -n "${linkPrefix}" || linkPrefix="."
|
||||
|
||||
# Add "/" to the link prefix, and empty it entirely if it ends up just "./".
|
||||
linkPrefix=$(echo "${linkPrefix}" | sed 's,/*$,,')
|
||||
test "$linkPrefix" = "." && linkPrefix="" || linkPrefix="${linkPrefix}/"
|
||||
|
||||
# Convert the given string to HTML-escaped values (<, >, & escaped) on
|
||||
# stdout.
|
||||
@@ -35,14 +42,18 @@ html_safebr () {
|
||||
| sed -e 's|&|\&|g;s|<|\<|g;s|>|\>|g;s/$/<BR>/'
|
||||
}
|
||||
|
||||
ALLFILES=`find . -name '*~' -prune -o -type f -name '*.c' \
|
||||
-exec grep -FL '!NOINDEX' /dev/null '{}' ';'`
|
||||
allEligibleFiles=$(
|
||||
find . -name '*~' -prune -o -type f -name '*.c' \
|
||||
-exec grep -FL '!NOINDEX' /dev/null '{}' ';'
|
||||
)
|
||||
|
||||
CTAGDATA=`echo "$ALLFILES" \
|
||||
| ctags -nRf- -L- --c-types=f \
|
||||
| sed 's/ .\// /;s/;" .*$//'`
|
||||
ctagsOutput=$(
|
||||
echo "${allEligibleFiles}" \
|
||||
| ctags -nRf- -L- --c-types=f \
|
||||
| sed 's/ .\// /;s/;" .*$//'
|
||||
)
|
||||
|
||||
FILELIST=`echo "$CTAGDATA" | cut -d ' ' -f 2 | sort | uniq`
|
||||
sourceFiles=$(echo "${ctagsOutput}" | cut -d ' ' -f 2 | sort | uniq)
|
||||
|
||||
echo '<HTML><HEAD>'
|
||||
echo '<TITLE>Source Code Index</TITLE>'
|
||||
@@ -56,39 +67,43 @@ echo '</UL></P>'
|
||||
|
||||
echo '<H2><A NAME="files">File Listing</A></H2>'
|
||||
echo '<P><UL>'
|
||||
echo "$FILELIST" \
|
||||
echo "${sourceFiles}" \
|
||||
| sed -e \
|
||||
's|^.*$|<LI><CODE CLASS="filename"><A HREF="#file-\0">\0</A></CODE></LI>|'
|
||||
echo '</UL></P>'
|
||||
|
||||
for FILE in $FILELIST; do
|
||||
for sourceFile in ${sourceFiles}; do
|
||||
|
||||
DIR=`dirname $FILE`
|
||||
FUNCDEFS=`cproto -f1 -I. -Isrc/include -I$DIR $FILE 2>/dev/null \
|
||||
| sed -n 's/^.*[ *]\([^ *(]*\)(.*$/\1/p'`
|
||||
FILEHEAD="`sed -n -e \
|
||||
'1,/\*\//{/\/\*/,/\*\//{s/^[\/ *]//;s/^\*[\/]*//;p;};}' \
|
||||
< $FILE`"
|
||||
FILESHORTDESC=`echo "$FILEHEAD" | sed -n '1,/^ *$/{/^ *[^ ]*/p;}'`
|
||||
FILELONGDESC=`echo "$FILEHEAD" | sed '1,/^ *$/d'`
|
||||
sourceDir="${sourceFile##*/}"
|
||||
test "${sourceDir}" = "${sourceFile}" && sourceDir="."
|
||||
functionPrototypes=$(
|
||||
cproto -f1 -I. -Isrc/include -I"${sourceDir}" "${sourceFile}" 2>/dev/null \
|
||||
| sed -n 's/^.*[ *]\([^ *(]*\)(.*$/\1/p'
|
||||
)
|
||||
fileHeaderComment=$(
|
||||
sed -n -e '1,/\*\//{/\/\*/,/\*\//{s/^[\/ *]//;s/^\*[\/]*//;p;};}' \
|
||||
< "${sourceFile}"
|
||||
)
|
||||
fileShortDescription=$(echo "${fileHeaderComment}" | sed -n '1,/^ *$/{/^ *[^ ]*/p;}')
|
||||
fileLongDescription=$(echo "${fileHeaderComment}" | sed '1,/^ *$/d')
|
||||
|
||||
echo '<P><HR WIDTH="100%"></P>'
|
||||
echo '<P><TABLE BORDER="0"><TR>'
|
||||
echo '<TD VALIGN="TOP"><CODE CLASS="filename">'
|
||||
echo '<A NAME="file-'"$FILE"'">'"$FILE"'</A></CODE></TD>'
|
||||
echo '<A NAME="file-'"${sourceFile}"'">'"${sourceFile}"'</A></CODE></TD>'
|
||||
echo '<TD VALIGN="TOP"> - </TD>'
|
||||
echo '<TD VALIGN="TOP">'`html_safe "$FILESHORTDESC"`'</TD>'
|
||||
echo '<TD VALIGN="TOP">'"$(html_safe "${fileShortDescription}")"'</TD>'
|
||||
echo '</TR></TABLE></P>'
|
||||
echo '<P><SMALL>[<A HREF="'"$OFFS/$FILE"'">View File</A>]</SMALL></P>'
|
||||
echo '<P><SMALL>[<A HREF="'"${linkPrefix}${sourceFile}"'">View File</A>]</SMALL></P>'
|
||||
echo '<P><BLOCKQUOTE>'
|
||||
echo "`html_safebr "$FILELONGDESC"`"
|
||||
html_safebr "${fileLongDescription}"
|
||||
echo '</BLOCKQUOTE></P>'
|
||||
|
||||
if [ -n "$FUNCDEFS" ]; then
|
||||
if [ -n "${functionPrototypes}" ]; then
|
||||
echo '<P>Functions defined:</P>'
|
||||
echo '<P><UL>'
|
||||
echo "$FUNCDEFS" \
|
||||
| sed 's|^.*$|<A HREF="#func-\0---'"$FILE"'">\0</A>|' \
|
||||
echo "${functionPrototypes}" \
|
||||
| sed 's|^.*$|<A HREF="#func-\0---'"${sourceFile}"'">\0</A>|' \
|
||||
| sed 's/^/<LI><CODE CLASS="funcname">/;s|$|</CODE></LI>|'
|
||||
echo '</UL></P>'
|
||||
fi
|
||||
@@ -101,40 +116,45 @@ done
|
||||
|
||||
echo '<H2><A NAME="funcs">Function Listing</A></H2>'
|
||||
echo '<P><UL>'
|
||||
echo "$CTAGDATA" | while read FUNC FILE LINENUM REST; do
|
||||
echo -n '<LI><CODE CLASS="funcname">'
|
||||
echo -n '<A HREF="#func-'"$FUNC"'---'"$FILE"'">'"$FUNC"'</A></CODE> '
|
||||
echo '[<CODE CLASS="filename">'"$FILE"'</CODE>]</LI>'
|
||||
|
||||
echo "${ctagsOutput}" | while read -r functionName sourceFile sourceLineNo restOfLine; do
|
||||
echo '<LI><CODE CLASS="funcname"><A' \
|
||||
'HREF="#func-'"${functionName}"'---'"${sourceFile}"'">'"${functionName}"'</A></CODE>' \
|
||||
'[<CODE CLASS="filename">'"${sourceFile}"'</CODE>]</LI>'
|
||||
done
|
||||
echo '</UL></P>'
|
||||
|
||||
echo "$CTAGDATA" | while read FUNC FILE LINENUM REST; do
|
||||
# shellcheck disable=SC2034
|
||||
echo "${ctagsOutput}" | while read -r functionName sourceFile sourceLineNo restOfLine; do
|
||||
|
||||
FUNCDEF=`sed -n "$LINENUM,/{/p" < $FILE \
|
||||
| tr '\n' ' ' \
|
||||
| tr -d '{'`
|
||||
functionPrototype=$(
|
||||
sed -n "${sourceLineNo},/{/p" < "${sourceFile}" \
|
||||
| tr '\n' ' ' \
|
||||
| tr -d '{'
|
||||
)
|
||||
|
||||
LASTCOMLINE=`sed -n '1,'"$LINENUM"'{/\/\*/=;}' < $FILE | sed -n '$p'`
|
||||
[ -z "$LASTCOMLINE" ] && LASTCOMLINE=1
|
||||
LASTENDFUNCLINE=`sed -n '1,'"$LINENUM"'{/}/=;}' < $FILE | sed -n '$p'`
|
||||
[ -z "$LASTENDFUNCLINE" ] && LASTENDFUNCLINE=1
|
||||
FUNCHEAD="`sed -n -e \
|
||||
"$LASTCOMLINE,"'/\*\//{h;s/^[\/ *]//;s/^\*[\/]*//;p;x;/\*\//q;}' \
|
||||
< $FILE`"
|
||||
[ "$LASTCOMLINE" -le "$LASTENDFUNCLINE" ] && FUNCHEAD=""
|
||||
lastCommentOpenLineNo=$(sed -n '1,'"${sourceLineNo}"'{/\/\*/=;}' < "${sourceFile}" | sed -n '$p')
|
||||
test -n "${lastCommentOpenLineNo}" || lastCommentOpenLineNo=1
|
||||
lastCommentCloseLineNo=$(sed -n '1,'"${sourceLineNo}"'{/}/=;}' < "${sourceFile}" | sed -n '$p')
|
||||
test -n "${lastCommentCloseLineNo}" || lastCommentCloseLineNo=1
|
||||
functionHeaderComment=$(
|
||||
sed -n -e \
|
||||
"${lastCommentOpenLineNo},"'/\*\//{h;s/^[\/ *]//;s/^\*[\/]*//;p;x;/\*\//q;}' \
|
||||
< "${sourceFile}"
|
||||
)
|
||||
test "${lastCommentOpenLineNo}" -le "${lastCommentCloseLineNo}" && functionHeaderComment=""
|
||||
|
||||
echo '<P><HR WIDTH="100%"></P>'
|
||||
echo '<P ALIGN="LEFT">'
|
||||
echo -n '<CODE CLASS="funcname"><A NAME="func-'"$FUNC"'---'"$FILE"'">'
|
||||
echo -n "$FUNC"'</A></CODE> '
|
||||
echo -n '[<CODE CLASS="filename"><A HREF="#file-'"$FILE"'">'
|
||||
echo "$FILE"'</A></CODE>]'
|
||||
echo '<CODE CLASS="funcname"><A' \
|
||||
'NAME="func-'"${functionName}"'---'"${sourceFile}"'">'"${functionName}"'</A></CODE>' \
|
||||
'[<CODE CLASS="filename"><A HREF="#file-'"${sourceFile}"'">'"${sourceFile}"'</A></CODE>]'
|
||||
echo '</P>'
|
||||
|
||||
echo '<P><CODE CLASS="funcdef">'"`html_safe "$FUNCDEF"`"'</CODE></P>'
|
||||
echo '<P><CODE CLASS="funcdef">'"$(html_safe "${functionPrototype}")"'</CODE></P>'
|
||||
|
||||
echo '<P><BLOCKQUOTE>'
|
||||
echo "`html_safebr "$FUNCHEAD"`"
|
||||
html_safebr "${functionHeaderComment}"
|
||||
echo '</BLOCKQUOTE></P>'
|
||||
|
||||
echo '<P ALIGN="RIGHT"><SMALL CLASS="navbar">['
|
||||
@@ -145,22 +165,22 @@ done
|
||||
|
||||
echo '<H2><A NAME="todo">To Do Listing</A></H2>'
|
||||
echo '<P><UL>'
|
||||
for FILE in $FILELIST; do
|
||||
for sourceFile in ${sourceFiles}; do
|
||||
|
||||
TODOLINES=`sed -n \
|
||||
todoLineNumbers=$(sed -n \
|
||||
-e '/\/\*.*\*\//!{/\/\*/,/\*\//{/TODO:/{=;};};}' \
|
||||
-e '/\/\*.*\*\//{/TODO:/{=;};}' \
|
||||
< $FILE`
|
||||
< "${sourceFile}")
|
||||
|
||||
[ -z "$TODOLINES" ] && continue
|
||||
test -n "${todoLineNumbers}" || continue
|
||||
|
||||
echo -n '<LI><CODE CLASS="filename">'
|
||||
echo '<A HREF="#file-'"$FILE"'">'"$FILE"'</A></CODE>'
|
||||
echo '<LI><CODE CLASS="filename"><A' \
|
||||
'HREF="#file-'"${sourceFile}"'">'"${sourceFile}"'</A></CODE>'
|
||||
echo '<UL>'
|
||||
|
||||
for NUM in $TODOLINES; do
|
||||
TODO=`sed -n "$NUM"'{s/^.*TODO://;s/\*\/.*$//;p;}' < $FILE`
|
||||
echo "<LI>[<B>$NUM</B>] `html_safe "$TODO"`</LI>"
|
||||
for todoLineNo in ${todoLineNumbers}; do
|
||||
todoNote=$(sed -n "${todoLineNo}"'{s/^.*TODO://;s/\*\/.*$//;p;}' < "${sourceFile}")
|
||||
echo "<LI>[<B>${todoLineNo}</B>] $(html_safe "${todoNote}")</LI>"
|
||||
done
|
||||
|
||||
echo '</UL></LI>'
|
||||
|
||||
Executable
+541
@@ -0,0 +1,541 @@
|
||||
#!/bin/sh
|
||||
# install - install a program, script, or datafile
|
||||
|
||||
scriptversion=2020-11-14.01; # UTC
|
||||
|
||||
# This originates from X11R5 (mit/util/scripts/install.sh), which was
|
||||
# later released in X11R6 (xc/config/util/install.sh) with the
|
||||
# following copyright and license.
|
||||
#
|
||||
# Copyright (C) 1994 X Consortium
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to
|
||||
# deal in the Software without restriction, including without limitation the
|
||||
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
# sell copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
|
||||
# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
#
|
||||
# Except as contained in this notice, the name of the X Consortium shall not
|
||||
# be used in advertising or otherwise to promote the sale, use or other deal-
|
||||
# ings in this Software without prior written authorization from the X Consor-
|
||||
# tium.
|
||||
#
|
||||
#
|
||||
# FSF changes to this file are in the public domain.
|
||||
#
|
||||
# Calling this script install-sh is preferred over install.sh, to prevent
|
||||
# 'make' implicit rules from creating a file called install from it
|
||||
# when there is no Makefile.
|
||||
#
|
||||
# This script is compatible with the BSD install script, but was written
|
||||
# from scratch.
|
||||
|
||||
tab=' '
|
||||
nl='
|
||||
'
|
||||
IFS=" $tab$nl"
|
||||
|
||||
# Set DOITPROG to "echo" to test this script.
|
||||
|
||||
doit=${DOITPROG-}
|
||||
doit_exec=${doit:-exec}
|
||||
|
||||
# Put in absolute file names if you don't have them in your path;
|
||||
# or use environment vars.
|
||||
|
||||
chgrpprog=${CHGRPPROG-chgrp}
|
||||
chmodprog=${CHMODPROG-chmod}
|
||||
chownprog=${CHOWNPROG-chown}
|
||||
cmpprog=${CMPPROG-cmp}
|
||||
cpprog=${CPPROG-cp}
|
||||
mkdirprog=${MKDIRPROG-mkdir}
|
||||
mvprog=${MVPROG-mv}
|
||||
rmprog=${RMPROG-rm}
|
||||
stripprog=${STRIPPROG-strip}
|
||||
|
||||
posix_mkdir=
|
||||
|
||||
# Desired mode of installed file.
|
||||
mode=0755
|
||||
|
||||
# Create dirs (including intermediate dirs) using mode 755.
|
||||
# This is like GNU 'install' as of coreutils 8.32 (2020).
|
||||
mkdir_umask=22
|
||||
|
||||
backupsuffix=
|
||||
chgrpcmd=
|
||||
chmodcmd=$chmodprog
|
||||
chowncmd=
|
||||
mvcmd=$mvprog
|
||||
rmcmd="$rmprog -f"
|
||||
stripcmd=
|
||||
|
||||
src=
|
||||
dst=
|
||||
dir_arg=
|
||||
dst_arg=
|
||||
|
||||
copy_on_change=false
|
||||
is_target_a_directory=possibly
|
||||
|
||||
usage="\
|
||||
Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
|
||||
or: $0 [OPTION]... SRCFILES... DIRECTORY
|
||||
or: $0 [OPTION]... -t DIRECTORY SRCFILES...
|
||||
or: $0 [OPTION]... -d DIRECTORIES...
|
||||
|
||||
In the 1st form, copy SRCFILE to DSTFILE.
|
||||
In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
|
||||
In the 4th, create DIRECTORIES.
|
||||
|
||||
Options:
|
||||
--help display this help and exit.
|
||||
--version display version info and exit.
|
||||
|
||||
-c (ignored)
|
||||
-C install only if different (preserve data modification time)
|
||||
-d create directories instead of installing files.
|
||||
-g GROUP $chgrpprog installed files to GROUP.
|
||||
-m MODE $chmodprog installed files to MODE.
|
||||
-o USER $chownprog installed files to USER.
|
||||
-p pass -p to $cpprog.
|
||||
-s $stripprog installed files.
|
||||
-S SUFFIX attempt to back up existing files, with suffix SUFFIX.
|
||||
-t DIRECTORY install into DIRECTORY.
|
||||
-T report an error if DSTFILE is a directory.
|
||||
|
||||
Environment variables override the default commands:
|
||||
CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
|
||||
RMPROG STRIPPROG
|
||||
|
||||
By default, rm is invoked with -f; when overridden with RMPROG,
|
||||
it's up to you to specify -f if you want it.
|
||||
|
||||
If -S is not specified, no backups are attempted.
|
||||
|
||||
Email bug reports to bug-automake@gnu.org.
|
||||
Automake home page: https://www.gnu.org/software/automake/
|
||||
"
|
||||
|
||||
while test $# -ne 0; do
|
||||
case $1 in
|
||||
-c) ;;
|
||||
|
||||
-C) copy_on_change=true;;
|
||||
|
||||
-d) dir_arg=true;;
|
||||
|
||||
-g) chgrpcmd="$chgrpprog $2"
|
||||
shift;;
|
||||
|
||||
--help) echo "$usage"; exit $?;;
|
||||
|
||||
-m) mode=$2
|
||||
case $mode in
|
||||
*' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*)
|
||||
echo "$0: invalid mode: $mode" >&2
|
||||
exit 1;;
|
||||
esac
|
||||
shift;;
|
||||
|
||||
-o) chowncmd="$chownprog $2"
|
||||
shift;;
|
||||
|
||||
-p) cpprog="$cpprog -p";;
|
||||
|
||||
-s) stripcmd=$stripprog;;
|
||||
|
||||
-S) backupsuffix="$2"
|
||||
shift;;
|
||||
|
||||
-t)
|
||||
is_target_a_directory=always
|
||||
dst_arg=$2
|
||||
# Protect names problematic for 'test' and other utilities.
|
||||
case $dst_arg in
|
||||
-* | [=\(\)!]) dst_arg=./$dst_arg;;
|
||||
esac
|
||||
shift;;
|
||||
|
||||
-T) is_target_a_directory=never;;
|
||||
|
||||
--version) echo "$0 $scriptversion"; exit $?;;
|
||||
|
||||
--) shift
|
||||
break;;
|
||||
|
||||
-*) echo "$0: invalid option: $1" >&2
|
||||
exit 1;;
|
||||
|
||||
*) break;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
# We allow the use of options -d and -T together, by making -d
|
||||
# take the precedence; this is for compatibility with GNU install.
|
||||
|
||||
if test -n "$dir_arg"; then
|
||||
if test -n "$dst_arg"; then
|
||||
echo "$0: target directory not allowed when installing a directory." >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
|
||||
# When -d is used, all remaining arguments are directories to create.
|
||||
# When -t is used, the destination is already specified.
|
||||
# Otherwise, the last argument is the destination. Remove it from $@.
|
||||
for arg
|
||||
do
|
||||
if test -n "$dst_arg"; then
|
||||
# $@ is not empty: it contains at least $arg.
|
||||
set fnord "$@" "$dst_arg"
|
||||
shift # fnord
|
||||
fi
|
||||
shift # arg
|
||||
dst_arg=$arg
|
||||
# Protect names problematic for 'test' and other utilities.
|
||||
case $dst_arg in
|
||||
-* | [=\(\)!]) dst_arg=./$dst_arg;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
|
||||
if test $# -eq 0; then
|
||||
if test -z "$dir_arg"; then
|
||||
echo "$0: no input file specified." >&2
|
||||
exit 1
|
||||
fi
|
||||
# It's OK to call 'install-sh -d' without argument.
|
||||
# This can happen when creating conditional directories.
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if test -z "$dir_arg"; then
|
||||
if test $# -gt 1 || test "$is_target_a_directory" = always; then
|
||||
if test ! -d "$dst_arg"; then
|
||||
echo "$0: $dst_arg: Is not a directory." >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if test -z "$dir_arg"; then
|
||||
do_exit='(exit $ret); exit $ret'
|
||||
trap "ret=129; $do_exit" 1
|
||||
trap "ret=130; $do_exit" 2
|
||||
trap "ret=141; $do_exit" 13
|
||||
trap "ret=143; $do_exit" 15
|
||||
|
||||
# Set umask so as not to create temps with too-generous modes.
|
||||
# However, 'strip' requires both read and write access to temps.
|
||||
case $mode in
|
||||
# Optimize common cases.
|
||||
*644) cp_umask=133;;
|
||||
*755) cp_umask=22;;
|
||||
|
||||
*[0-7])
|
||||
if test -z "$stripcmd"; then
|
||||
u_plus_rw=
|
||||
else
|
||||
u_plus_rw='% 200'
|
||||
fi
|
||||
cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
|
||||
*)
|
||||
if test -z "$stripcmd"; then
|
||||
u_plus_rw=
|
||||
else
|
||||
u_plus_rw=,u+rw
|
||||
fi
|
||||
cp_umask=$mode$u_plus_rw;;
|
||||
esac
|
||||
fi
|
||||
|
||||
for src
|
||||
do
|
||||
# Protect names problematic for 'test' and other utilities.
|
||||
case $src in
|
||||
-* | [=\(\)!]) src=./$src;;
|
||||
esac
|
||||
|
||||
if test -n "$dir_arg"; then
|
||||
dst=$src
|
||||
dstdir=$dst
|
||||
test -d "$dstdir"
|
||||
dstdir_status=$?
|
||||
# Don't chown directories that already exist.
|
||||
if test $dstdir_status = 0; then
|
||||
chowncmd=""
|
||||
fi
|
||||
else
|
||||
|
||||
# Waiting for this to be detected by the "$cpprog $src $dsttmp" command
|
||||
# might cause directories to be created, which would be especially bad
|
||||
# if $src (and thus $dsttmp) contains '*'.
|
||||
if test ! -f "$src" && test ! -d "$src"; then
|
||||
echo "$0: $src does not exist." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if test -z "$dst_arg"; then
|
||||
echo "$0: no destination specified." >&2
|
||||
exit 1
|
||||
fi
|
||||
dst=$dst_arg
|
||||
|
||||
# If destination is a directory, append the input filename.
|
||||
if test -d "$dst"; then
|
||||
if test "$is_target_a_directory" = never; then
|
||||
echo "$0: $dst_arg: Is a directory" >&2
|
||||
exit 1
|
||||
fi
|
||||
dstdir=$dst
|
||||
dstbase=`basename "$src"`
|
||||
case $dst in
|
||||
*/) dst=$dst$dstbase;;
|
||||
*) dst=$dst/$dstbase;;
|
||||
esac
|
||||
dstdir_status=0
|
||||
else
|
||||
dstdir=`dirname "$dst"`
|
||||
test -d "$dstdir"
|
||||
dstdir_status=$?
|
||||
fi
|
||||
fi
|
||||
|
||||
case $dstdir in
|
||||
*/) dstdirslash=$dstdir;;
|
||||
*) dstdirslash=$dstdir/;;
|
||||
esac
|
||||
|
||||
obsolete_mkdir_used=false
|
||||
|
||||
if test $dstdir_status != 0; then
|
||||
case $posix_mkdir in
|
||||
'')
|
||||
# With -d, create the new directory with the user-specified mode.
|
||||
# Otherwise, rely on $mkdir_umask.
|
||||
if test -n "$dir_arg"; then
|
||||
mkdir_mode=-m$mode
|
||||
else
|
||||
mkdir_mode=
|
||||
fi
|
||||
|
||||
posix_mkdir=false
|
||||
# The $RANDOM variable is not portable (e.g., dash). Use it
|
||||
# here however when possible just to lower collision chance.
|
||||
tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
|
||||
|
||||
trap '
|
||||
ret=$?
|
||||
rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null
|
||||
exit $ret
|
||||
' 0
|
||||
|
||||
# Because "mkdir -p" follows existing symlinks and we likely work
|
||||
# directly in world-writeable /tmp, make sure that the '$tmpdir'
|
||||
# directory is successfully created first before we actually test
|
||||
# 'mkdir -p'.
|
||||
if (umask $mkdir_umask &&
|
||||
$mkdirprog $mkdir_mode "$tmpdir" &&
|
||||
exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1
|
||||
then
|
||||
if test -z "$dir_arg" || {
|
||||
# Check for POSIX incompatibilities with -m.
|
||||
# HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
|
||||
# other-writable bit of parent directory when it shouldn't.
|
||||
# FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
|
||||
test_tmpdir="$tmpdir/a"
|
||||
ls_ld_tmpdir=`ls -ld "$test_tmpdir"`
|
||||
case $ls_ld_tmpdir in
|
||||
d????-?r-*) different_mode=700;;
|
||||
d????-?--*) different_mode=755;;
|
||||
*) false;;
|
||||
esac &&
|
||||
$mkdirprog -m$different_mode -p -- "$test_tmpdir" && {
|
||||
ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"`
|
||||
test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
|
||||
}
|
||||
}
|
||||
then posix_mkdir=:
|
||||
fi
|
||||
rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir"
|
||||
else
|
||||
# Remove any dirs left behind by ancient mkdir implementations.
|
||||
rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null
|
||||
fi
|
||||
trap '' 0;;
|
||||
esac
|
||||
|
||||
if
|
||||
$posix_mkdir && (
|
||||
umask $mkdir_umask &&
|
||||
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
|
||||
)
|
||||
then :
|
||||
else
|
||||
|
||||
# mkdir does not conform to POSIX,
|
||||
# or it failed possibly due to a race condition. Create the
|
||||
# directory the slow way, step by step, checking for races as we go.
|
||||
|
||||
case $dstdir in
|
||||
/*) prefix='/';;
|
||||
[-=\(\)!]*) prefix='./';;
|
||||
*) prefix='';;
|
||||
esac
|
||||
|
||||
oIFS=$IFS
|
||||
IFS=/
|
||||
set -f
|
||||
set fnord $dstdir
|
||||
shift
|
||||
set +f
|
||||
IFS=$oIFS
|
||||
|
||||
prefixes=
|
||||
|
||||
for d
|
||||
do
|
||||
test X"$d" = X && continue
|
||||
|
||||
prefix=$prefix$d
|
||||
if test -d "$prefix"; then
|
||||
prefixes=
|
||||
else
|
||||
if $posix_mkdir; then
|
||||
(umask $mkdir_umask &&
|
||||
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
|
||||
# Don't fail if two instances are running concurrently.
|
||||
test -d "$prefix" || exit 1
|
||||
else
|
||||
case $prefix in
|
||||
*\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
|
||||
*) qprefix=$prefix;;
|
||||
esac
|
||||
prefixes="$prefixes '$qprefix'"
|
||||
fi
|
||||
fi
|
||||
prefix=$prefix/
|
||||
done
|
||||
|
||||
if test -n "$prefixes"; then
|
||||
# Don't fail if two instances are running concurrently.
|
||||
(umask $mkdir_umask &&
|
||||
eval "\$doit_exec \$mkdirprog $prefixes") ||
|
||||
test -d "$dstdir" || exit 1
|
||||
obsolete_mkdir_used=true
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if test -n "$dir_arg"; then
|
||||
{ test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
|
||||
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
|
||||
{ test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
|
||||
test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
|
||||
else
|
||||
|
||||
# Make a couple of temp file names in the proper directory.
|
||||
dsttmp=${dstdirslash}_inst.$$_
|
||||
rmtmp=${dstdirslash}_rm.$$_
|
||||
|
||||
# Trap to clean up those temp files at exit.
|
||||
trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
|
||||
|
||||
# Copy the file name to the temp name.
|
||||
(umask $cp_umask &&
|
||||
{ test -z "$stripcmd" || {
|
||||
# Create $dsttmp read-write so that cp doesn't create it read-only,
|
||||
# which would cause strip to fail.
|
||||
if test -z "$doit"; then
|
||||
: >"$dsttmp" # No need to fork-exec 'touch'.
|
||||
else
|
||||
$doit touch "$dsttmp"
|
||||
fi
|
||||
}
|
||||
} &&
|
||||
$doit_exec $cpprog "$src" "$dsttmp") &&
|
||||
|
||||
# and set any options; do chmod last to preserve setuid bits.
|
||||
#
|
||||
# If any of these fail, we abort the whole thing. If we want to
|
||||
# ignore errors from any of these, just make sure not to ignore
|
||||
# errors from the above "$doit $cpprog $src $dsttmp" command.
|
||||
#
|
||||
{ test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
|
||||
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
|
||||
{ test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
|
||||
{ test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
|
||||
|
||||
# If -C, don't bother to copy if it wouldn't change the file.
|
||||
if $copy_on_change &&
|
||||
old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
|
||||
new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
|
||||
set -f &&
|
||||
set X $old && old=:$2:$4:$5:$6 &&
|
||||
set X $new && new=:$2:$4:$5:$6 &&
|
||||
set +f &&
|
||||
test "$old" = "$new" &&
|
||||
$cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
|
||||
then
|
||||
rm -f "$dsttmp"
|
||||
else
|
||||
# If $backupsuffix is set, and the file being installed
|
||||
# already exists, attempt a backup. Don't worry if it fails,
|
||||
# e.g., if mv doesn't support -f.
|
||||
if test -n "$backupsuffix" && test -f "$dst"; then
|
||||
$doit $mvcmd -f "$dst" "$dst$backupsuffix" 2>/dev/null
|
||||
fi
|
||||
|
||||
# Rename the file to the real destination.
|
||||
$doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
|
||||
|
||||
# The rename failed, perhaps because mv can't rename something else
|
||||
# to itself, or perhaps because mv is so ancient that it does not
|
||||
# support -f.
|
||||
{
|
||||
# Now remove or move aside any old file at destination location.
|
||||
# We try this two ways since rm can't unlink itself on some
|
||||
# systems and the destination file might be busy for other
|
||||
# reasons. In this case, the final cleanup might fail but the new
|
||||
# file should still install successfully.
|
||||
{
|
||||
test ! -f "$dst" ||
|
||||
$doit $rmcmd "$dst" 2>/dev/null ||
|
||||
{ $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
|
||||
{ $doit $rmcmd "$rmtmp" 2>/dev/null; :; }
|
||||
} ||
|
||||
{ echo "$0: cannot unlink or rename $dst" >&2
|
||||
(exit 1); exit 1
|
||||
}
|
||||
} &&
|
||||
|
||||
# Now rename the file to the real destination.
|
||||
$doit $mvcmd "$dsttmp" "$dst"
|
||||
}
|
||||
fi || exit 1
|
||||
|
||||
trap '' 0
|
||||
fi
|
||||
done
|
||||
|
||||
# Local variables:
|
||||
# eval: (add-hook 'before-save-hook 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC0"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
||||
@@ -1,250 +0,0 @@
|
||||
#! /bin/sh
|
||||
#
|
||||
# install - install a program, script, or datafile
|
||||
# This comes from X11R5 (mit/util/scripts/install.sh).
|
||||
#
|
||||
# Copyright 1991 by the Massachusetts Institute of Technology
|
||||
#
|
||||
# Permission to use, copy, modify, distribute, and sell this software and its
|
||||
# documentation for any purpose is hereby granted without fee, provided that
|
||||
# the above copyright notice appear in all copies and that both that
|
||||
# copyright notice and this permission notice appear in supporting
|
||||
# documentation, and that the name of M.I.T. not be used in advertising or
|
||||
# publicity pertaining to distribution of the software without specific,
|
||||
# written prior permission. M.I.T. makes no representations about the
|
||||
# suitability of this software for any purpose. It is provided "as is"
|
||||
# without express or implied warranty.
|
||||
#
|
||||
# Calling this script install-sh is preferred over install.sh, to prevent
|
||||
# `make' implicit rules from creating a file called install from it
|
||||
# when there is no Makefile.
|
||||
#
|
||||
# This script is compatible with the BSD install script, but was written
|
||||
# from scratch. It can only install one file at a time, a restriction
|
||||
# shared with many OS's install programs.
|
||||
|
||||
|
||||
# set DOITPROG to echo to test this script
|
||||
|
||||
# Don't use :- since 4.3BSD and earlier shells don't like it.
|
||||
doit="${DOITPROG-}"
|
||||
|
||||
|
||||
# put in absolute paths if you don't have them in your path; or use env. vars.
|
||||
|
||||
mvprog="${MVPROG-mv}"
|
||||
cpprog="${CPPROG-cp}"
|
||||
chmodprog="${CHMODPROG-chmod}"
|
||||
chownprog="${CHOWNPROG-chown}"
|
||||
chgrpprog="${CHGRPPROG-chgrp}"
|
||||
stripprog="${STRIPPROG-strip}"
|
||||
rmprog="${RMPROG-rm}"
|
||||
mkdirprog="${MKDIRPROG-mkdir}"
|
||||
|
||||
transformbasename=""
|
||||
transform_arg=""
|
||||
instcmd="$mvprog"
|
||||
chmodcmd="$chmodprog 0755"
|
||||
chowncmd=""
|
||||
chgrpcmd=""
|
||||
stripcmd=""
|
||||
rmcmd="$rmprog -f"
|
||||
mvcmd="$mvprog"
|
||||
src=""
|
||||
dst=""
|
||||
dir_arg=""
|
||||
|
||||
while [ x"$1" != x ]; do
|
||||
case $1 in
|
||||
-c) instcmd="$cpprog"
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-d) dir_arg=true
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-m) chmodcmd="$chmodprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-o) chowncmd="$chownprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-g) chgrpcmd="$chgrpprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-s) stripcmd="$stripprog"
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-t=*) transformarg=`echo $1 | sed 's/-t=//'`
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
|
||||
shift
|
||||
continue;;
|
||||
|
||||
*) if [ x"$src" = x ]
|
||||
then
|
||||
src=$1
|
||||
else
|
||||
# this colon is to work around a 386BSD /bin/sh bug
|
||||
:
|
||||
dst=$1
|
||||
fi
|
||||
shift
|
||||
continue;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ x"$src" = x ]
|
||||
then
|
||||
echo "install: no input file specified"
|
||||
exit 1
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
if [ x"$dir_arg" != x ]; then
|
||||
dst=$src
|
||||
src=""
|
||||
|
||||
if [ -d $dst ]; then
|
||||
instcmd=:
|
||||
else
|
||||
instcmd=mkdir
|
||||
fi
|
||||
else
|
||||
|
||||
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
|
||||
# might cause directories to be created, which would be especially bad
|
||||
# if $src (and thus $dsttmp) contains '*'.
|
||||
|
||||
if [ -f $src -o -d $src ]
|
||||
then
|
||||
true
|
||||
else
|
||||
echo "install: $src does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ x"$dst" = x ]
|
||||
then
|
||||
echo "install: no destination specified"
|
||||
exit 1
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
# If destination is a directory, append the input filename; if your system
|
||||
# does not like double slashes in filenames, you may need to add some logic
|
||||
|
||||
if [ -d $dst ]
|
||||
then
|
||||
dst="$dst"/`basename $src`
|
||||
else
|
||||
true
|
||||
fi
|
||||
fi
|
||||
|
||||
## this sed command emulates the dirname command
|
||||
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
|
||||
|
||||
# Make sure that the destination directory exists.
|
||||
# this part is taken from Noah Friedman's mkinstalldirs script
|
||||
|
||||
# Skip lots of stat calls in the usual case.
|
||||
if [ ! -d "$dstdir" ]; then
|
||||
defaultIFS='
|
||||
'
|
||||
IFS="${IFS-${defaultIFS}}"
|
||||
|
||||
oIFS="${IFS}"
|
||||
# Some sh's can't handle IFS=/ for some reason.
|
||||
IFS='%'
|
||||
set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
|
||||
IFS="${oIFS}"
|
||||
|
||||
pathcomp=''
|
||||
|
||||
while [ $# -ne 0 ] ; do
|
||||
pathcomp="${pathcomp}${1}"
|
||||
shift
|
||||
|
||||
if [ ! -d "${pathcomp}" ] ;
|
||||
then
|
||||
$mkdirprog "${pathcomp}"
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
pathcomp="${pathcomp}/"
|
||||
done
|
||||
fi
|
||||
|
||||
if [ x"$dir_arg" != x ]
|
||||
then
|
||||
$doit $instcmd $dst &&
|
||||
|
||||
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
|
||||
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
|
||||
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
|
||||
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
|
||||
else
|
||||
|
||||
# If we're going to rename the final executable, determine the name now.
|
||||
|
||||
if [ x"$transformarg" = x ]
|
||||
then
|
||||
dstfile=`basename $dst`
|
||||
else
|
||||
dstfile=`basename $dst $transformbasename |
|
||||
sed $transformarg`$transformbasename
|
||||
fi
|
||||
|
||||
# don't allow the sed command to completely eliminate the filename
|
||||
|
||||
if [ x"$dstfile" = x ]
|
||||
then
|
||||
dstfile=`basename $dst`
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
# Make a temp file name in the proper directory.
|
||||
|
||||
dsttmp=$dstdir/#inst.$$#
|
||||
|
||||
# Move or copy the file name to the temp name
|
||||
|
||||
$doit $instcmd $src $dsttmp &&
|
||||
|
||||
trap "rm -f ${dsttmp}" 0 &&
|
||||
|
||||
# and set any options; do chmod last to preserve setuid bits
|
||||
|
||||
# If any of these fail, we abort the whole thing. If we want to
|
||||
# ignore errors from any of these, just make sure not to ignore
|
||||
# errors from the above "$doit $instcmd $src $dsttmp" command.
|
||||
|
||||
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
|
||||
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
|
||||
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
|
||||
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
|
||||
|
||||
# Now rename the file to the real destination.
|
||||
|
||||
$doit $rmcmd -f $dstdir/$dstfile &&
|
||||
$doit $mvcmd $dsttmp $dstdir/$dstfile
|
||||
|
||||
fi &&
|
||||
|
||||
|
||||
exit 0
|
||||
@@ -1,8 +1,9 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Generate Makefile dependencies inclusion and module target file "depend.mk~"
|
||||
# by scanning the directory "src" for files ending in ".c" and ".d", and for
|
||||
# subdirectories not starting with "_".
|
||||
# Generate Makefile components "filelist.mk~" (list source, object, and
|
||||
# dependency files) and "modules.mk~" (linking rules for each directory's
|
||||
# overall object file) by scanning the directory "src" for files ending in
|
||||
# ".c", and for subdirectories not starting with "_".
|
||||
#
|
||||
# Modules live inside subdirectories called [^_]* - i.e. a directory "foo" will
|
||||
# have a rule created which links all code inside it to "foo.o".
|
||||
@@ -11,103 +12,114 @@
|
||||
# directories.
|
||||
#
|
||||
|
||||
outlist=$1
|
||||
outlink=$2
|
||||
listingsFile="$1"
|
||||
linkingRulesFile="$2"
|
||||
|
||||
FIND=find
|
||||
GREP=grep
|
||||
which gfind 2>/dev/null | grep /gfind >/dev/null && FIND=gfind
|
||||
which ggrep 2>/dev/null | grep /ggrep >/dev/null && GREP=ggrep
|
||||
FIND="find"
|
||||
GREP="grep"
|
||||
command -v gfind 2>/dev/null | grep /gfind >/dev/null && FIND="gfind"
|
||||
command -v which ggrep 2>/dev/null | grep /ggrep >/dev/null && GREP="ggrep"
|
||||
|
||||
echo '# Automatically generated file listings' > $outlist
|
||||
echo '#' >> $outlist
|
||||
echo "# Creation time: `date`" >> $outlist
|
||||
echo >> $outlist
|
||||
{
|
||||
echo '# Automatically generated file listings'
|
||||
echo '#'
|
||||
echo "# Creation time: $(date)"
|
||||
echo
|
||||
} > "${listingsFile}"
|
||||
|
||||
echo '# Automatically generated module linking rules' > $outlink
|
||||
echo '#' >> $outlink
|
||||
echo "# Creation time: `date`" >> $outlink
|
||||
echo >> $outlink
|
||||
{
|
||||
echo '# Automatically generated module linking rules'
|
||||
echo '#'
|
||||
echo "# Creation time: $(date)"
|
||||
echo
|
||||
} > "${linkingRulesFile}"
|
||||
|
||||
echo -n "Scanning for source files: "
|
||||
printf "%s" "Scanning for source files: "
|
||||
|
||||
allsrc=`$FIND src -type f -name "*.c" -print`
|
||||
allobj=`echo $allsrc | tr ' ' '\n' | sed 's/\.c$/.o/'`
|
||||
alldep=`echo $allsrc | tr ' ' '\n' | sed 's/\.c$/.d/'`
|
||||
allsrc=$("${FIND}" src -type f -name "*.c" -print)
|
||||
allobj=$(echo "${allsrc}" | tr ' ' '\n' | sed 's/\.c$/.o/')
|
||||
alldep=$(echo "${allsrc}" | tr ' ' '\n' | sed 's/\.c$/.d/')
|
||||
|
||||
echo `echo $allsrc | wc -w | tr -d ' '` found
|
||||
echo "$(echo "${allsrc}" | wc -w | tr -d ' ') found"
|
||||
|
||||
echo -n "Scanning for modules: "
|
||||
printf "%s" "Scanning for modules: "
|
||||
|
||||
modules=`$FIND src -type d -print \
|
||||
| $GREP -v '^src$' \
|
||||
| $GREP -v '/_' \
|
||||
| $GREP -v '^src/include' \
|
||||
| $GREP -v 'CVS' \
|
||||
| $GREP -v '.svn' \
|
||||
| while read DIR; do \
|
||||
CONTENT=\$(/bin/ls -d \$DIR/* \
|
||||
| $GREP -v '.po$' \
|
||||
| $GREP -v '.gmo$' \
|
||||
| $GREP -v '.mo$' \
|
||||
| $GREP -v '.h$' \
|
||||
modules=$("${FIND}" src -type d -print \
|
||||
| "${GREP}" -v '^src$' \
|
||||
| "${GREP}" -v '/_' \
|
||||
| "${GREP}" -v '^src/include' \
|
||||
| "${GREP}" -v 'CVS' \
|
||||
| "${GREP}" -v '.svn' \
|
||||
| while read -r DIR; do \
|
||||
CONTENT=$(/bin/ls -d "${DIR}"/* \
|
||||
| "${GREP}" -v '.po$' \
|
||||
| "${GREP}" -v '.gmo$' \
|
||||
| "${GREP}" -v '.mo$' \
|
||||
| "${GREP}" -v '.h$' \
|
||||
| sed -n '$p'); \
|
||||
[ -n "\$CONTENT" ] || continue; \
|
||||
echo \$DIR; \
|
||||
[ -n "$CONTENT" ] || continue; \
|
||||
echo "${DIR}"; \
|
||||
done
|
||||
`
|
||||
)
|
||||
|
||||
echo up to `echo $modules | wc -w | tr -d ' '` found
|
||||
echo "up to $(echo "${modules}" | wc -w | tr -d ' ') found"
|
||||
|
||||
echo "Writing module linking rules"
|
||||
|
||||
echo -n [
|
||||
for i in $modules; do echo -n ' '; done
|
||||
echo -n -e ']\r['
|
||||
printf "%s" "["
|
||||
for i in ${modules}; do printf "%s" " "; done
|
||||
printf "%s\r%s" "]" "["
|
||||
|
||||
for i in $modules; do
|
||||
echo -n '.'
|
||||
allobj="$allobj $i.o"
|
||||
for i in ${modules}; do
|
||||
printf "%s" "."
|
||||
allobj="${allobj} ${i}.o"
|
||||
deps=""
|
||||
for j in $i/*.c; do
|
||||
[ -f $j ] || continue
|
||||
newobj=`echo $j | sed -e 's@\.c$@.o@'`
|
||||
for j in "${i}"/*.c; do
|
||||
[ -f "$j" ] || continue
|
||||
newobj=$(echo "$j" | sed -e 's@\.c$@.o@')
|
||||
deps="$deps $newobj"
|
||||
done
|
||||
for j in $i/*; do
|
||||
for j in "${i}"/*; do
|
||||
[ -d "$j" ] || continue
|
||||
[ `basename $j` = "CVS" ] && continue
|
||||
[ `basename $j` = ".svn" ] && continue
|
||||
CONTENT=`/bin/ls -d $j/* \
|
||||
| $GREP -v '.po$' \
|
||||
| $GREP -v '.gmo$' \
|
||||
| $GREP -v '.mo$' \
|
||||
| $GREP -v '.h$' \
|
||||
| sed -n '$p'`
|
||||
[ "$(basename "$j")" = "CVS" ] && continue
|
||||
[ "$(basename "$j")" = ".svn" ] && continue
|
||||
CONTENT=$(/bin/ls -d "$j"/* \
|
||||
| "${GREP}" -v '.po$' \
|
||||
| "${GREP}" -v '.gmo$' \
|
||||
| "${GREP}" -v '.mo$' \
|
||||
| "${GREP}" -v '.h$' \
|
||||
| sed -n '$p')
|
||||
[ -n "$CONTENT" ] || continue
|
||||
deps="$deps $j.o"
|
||||
done
|
||||
[ -n "$deps" ] || continue
|
||||
echo "$i.o: $deps" >> $outlink
|
||||
echo ' $(LD) $(LDFLAGS) -o $@' "$deps" >> $outlink
|
||||
echo >> $outlink
|
||||
{
|
||||
echo "$i.o: $deps"
|
||||
echo " \$(LD) \$(LDFLAGS) -o \$@ $deps"
|
||||
echo
|
||||
} >> "${linkingRulesFile}"
|
||||
done
|
||||
|
||||
echo ']'
|
||||
|
||||
echo "Listing source, object and dependency files"
|
||||
|
||||
echo -n "allsrc = " >> $outlist
|
||||
echo $allsrc | sed 's,src/nls/cat-id-tbl.c,,' | sed -e 's/ / \\!/g'\
|
||||
| tr '!' '\n' >> $outlist
|
||||
echo >> $outlist
|
||||
echo -n "allobj = " >> $outlist
|
||||
echo $allobj | sed -e 's/ / \\!/g' | tr '!' '\n' >> $outlist
|
||||
echo >> $outlist
|
||||
echo -n "alldep = " >> $outlist
|
||||
echo $alldep | sed -e 's/ / \\!/g' | tr '!' '\n' >> $outlist
|
||||
{
|
||||
printf "%s" "allsrc = "
|
||||
echo "$allsrc" | tr '\n' ' ' | sed 's,src/nls/cat-id-tbl.c,,' | sed -e 's/ $//;s/ / \\!/g' \
|
||||
| tr '!' '\n'
|
||||
echo
|
||||
echo
|
||||
printf "%s" "allobj = "
|
||||
echo "$allobj" | tr '\n' ' ' | sed -e 's/ $//;s/ / \\!/g' | tr '!' '\n'
|
||||
echo
|
||||
echo
|
||||
printf "%s" "alldep = "
|
||||
echo "$alldep" | tr '\n' ' ' | sed -e 's/ $//;s/ / \\!/g' | tr '!' '\n'
|
||||
echo
|
||||
echo
|
||||
} >> "${listingsFile}"
|
||||
|
||||
echo >> $outlist
|
||||
echo >> $outlink
|
||||
echo >> "${linkingRulesFile}"
|
||||
|
||||
# EOF
|
||||
|
||||
@@ -8,9 +8,7 @@ cat <<EOF
|
||||
* Translation table - automatically generated by po2table.sh.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
#include <string.h>
|
||||
|
||||
struct msgtable_s {
|
||||
@@ -26,8 +24,8 @@ struct msgtable_s *minigettext__gettable(char *lang)
|
||||
|
||||
EOF
|
||||
|
||||
for POFILE in $*; do
|
||||
LANG=`basename "$POFILE" | sed 's/.po$//'`
|
||||
for POFILE in "$@"; do
|
||||
LANG=$(basename "$POFILE" | sed 's/.po$//')
|
||||
echo " if (strncmp(lang, \"$LANG\", 2) == 0) {"
|
||||
echo " static struct msgtable_s data[] = {";
|
||||
|
||||
|
||||
+195
-30
@@ -1,45 +1,210 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Run a test. Parameters are program name and source directory; if
|
||||
# additional parameters are given, they are the tests to run, otherwise all
|
||||
# tests are run.
|
||||
# Parameters: testSubject sourcePath [testScript...]
|
||||
#
|
||||
# Run one or more test scripts. The ${testSubject} is the path of the test
|
||||
# subject program, and the ${sourcePath} is the path to the top level of the
|
||||
# source directory. If any ${testScript} parameters are given, they are the
|
||||
# tests to run (each one being either the full path to a script, or the base
|
||||
# filename of the script in the test directory). If no test scripts are
|
||||
# listed, then all tests directly under "${sourcePath}/tests/" are run.
|
||||
#
|
||||
# Test scripts should be written to exit 0 if the test passed, 2 if the test
|
||||
# is to be skipped, or any other exit status to indicate failure. They are
|
||||
# run via "sh -e", so any command exiting non-zero will cause the test
|
||||
# script to exit early.
|
||||
#
|
||||
# The test scripts can rely on the environment variables "testSubject",
|
||||
# "sourcePath", "workFile1", "workFile2", "workFile3", and "workFile4" being
|
||||
# populated, and should use those work files - which will be present and
|
||||
# empty - for scratch space. They should not delete those files.
|
||||
#
|
||||
# When the test scripts are called, LANG and LC_ALL are set to "C".
|
||||
#
|
||||
# Anything output by a test script on stdout or stderr is captured and shown
|
||||
# after the "OK" / "FAILED" / "skipped" result description.
|
||||
#
|
||||
# The exit status of this script will be 1 if any test failed, 0 otherwise.
|
||||
# A skipped test is not counted as a failure.
|
||||
#
|
||||
|
||||
PROG="$1"
|
||||
SRCDIR="$2"
|
||||
# Parameters.
|
||||
testSubject="$1"
|
||||
sourcePath="$2"
|
||||
shift
|
||||
shift
|
||||
TESTS="$*"
|
||||
selectedTests="$*"
|
||||
|
||||
# Temporary working files
|
||||
# Constants.
|
||||
formatCodesPass="setaf 2;bold" # terminal capabilities for "pass" formatting
|
||||
formatCodesFail="setaf 1;bold" # terminal capabilities for "fail" formatting
|
||||
formatCodesSkip="setaf 3" # terminal capabilities for "skip" formatting
|
||||
formatCodesZero="setaf 4" # terminal capabilities for zero result
|
||||
|
||||
# Temporary working files, for the test scripts to use.
|
||||
workFile1=$(mktemp 2>/dev/null) || workFile1="./.tmp1"
|
||||
workFile2=$(mktemp 2>/dev/null) || workFile2="./.tmp2"
|
||||
workFile3=$(mktemp 2>/dev/null) || workFile3="./.tmp3"
|
||||
workFile4=$(mktemp 2>/dev/null) || workFile4="./.tmp4"
|
||||
|
||||
# Clean up the temporary files on exit, in case we are interrupted.
|
||||
trap 'rm -f "${workFile1}" "${workFile2}" "${workFile3}" "${workFile4}"' EXIT
|
||||
|
||||
# Variables used by the test scripts.
|
||||
export testSubject sourcePath workFile1 workFile2 workFile3 workFile4
|
||||
|
||||
# Set everything to the "C" locale.
|
||||
LANG=C
|
||||
LC_ALL=C
|
||||
export LANG LC_ALL
|
||||
|
||||
# If no tests were specified, list all test scripts under the source path.
|
||||
test -n "${selectedTests}" || selectedTests=$(find "${sourcePath}/tests" -maxdepth 1 -type f | sort -n)
|
||||
|
||||
# Initial pass to count the number of tests and find the length of the
|
||||
# longest test name, to use when formatting the output.
|
||||
#
|
||||
TMP1=`mktemp 2>/dev/null` || TMP1=.tmp1
|
||||
TMP2=`mktemp 2>/dev/null` || TMP2=.tmp2
|
||||
TMP3=`mktemp 2>/dev/null` || TMP3=.tmp3
|
||||
TMP4=`mktemp 2>/dev/null` || TMP4=.tmp4
|
||||
numberOfTests=0
|
||||
maxTestNameLength=0
|
||||
for testScript in ${selectedTests}; do
|
||||
# Find the test script, make sure it exists.
|
||||
test -f "${testScript}" || testScript="${sourcePath}/tests/${testScript}"
|
||||
test -f "${testScript}" || testScript=$(find "${sourcePath}/tests" -maxdepth 1 -type f -name "${testScript##*/}*" | sed -n '1p')
|
||||
test -f "${testScript}" || continue
|
||||
|
||||
export PROG TMP1 TMP2 TMP3 TMP4 # variables used by test scripts
|
||||
numberOfTests=$((1+numberOfTests))
|
||||
|
||||
FAIL=0
|
||||
|
||||
test -n "$TESTS" || TESTS=`ls "$SRCDIR/tests" | sort -n`
|
||||
|
||||
for SCRIPT in $TESTS; do
|
||||
test -f "$SCRIPT" || SCRIPT="$SRCDIR/tests/$SCRIPT"
|
||||
test -f "$SCRIPT" || SCRIPT=`ls "$SRCDIR/tests/$SCRIPT"*`
|
||||
test -f "$SCRIPT" || continue
|
||||
|
||||
echo `basename "$SCRIPT"`: " " | cut -b1-20 | sed 's/-/ - /' | tr "\n" ' '
|
||||
|
||||
STATUS=0
|
||||
sh -e "$SCRIPT" || STATUS=1
|
||||
test $STATUS -eq 1 && FAIL=1
|
||||
|
||||
test $STATUS -eq 1 && echo "FAILED" || echo "OK"
|
||||
testScriptLeaf="${testScript##*/}"
|
||||
testName="$(echo "${testScriptLeaf%.sh}" | tr '_' ' ' | sed 's/ - /: /')"
|
||||
testNameLength=${#testName}
|
||||
test "${testNameLength}" -gt "${maxTestNameLength}" && maxTestNameLength="${testNameLength}"
|
||||
done
|
||||
|
||||
rm -f $TMP1 $TMP2 $TMP3 $TMP4
|
||||
# Set a minimum and maximum test name length.
|
||||
test "${maxTestNameLength}" -lt 10 && maxTestNameLength=10
|
||||
test "${maxTestNameLength}" -gt 60 && maxTestNameLength=60
|
||||
|
||||
exit $FAIL
|
||||
# Count the number of digits in the number of tests so we know how wide the
|
||||
# column for the test count should be.
|
||||
testCountWidth=${#numberOfTests}
|
||||
|
||||
# Get the terminal width, for later display formatting calculations.
|
||||
#
|
||||
# We have to fiddle with `stty' because $COLUMNS is only in `bash', `resize`
|
||||
# is not available everywhere, and `stty' itself varies in its output format
|
||||
# between "columns 158" and "158 cols".
|
||||
#
|
||||
terminalWidth=80
|
||||
test -t 1 && terminalWidth=$(stty -a 2>/dev/null | tr ';' '\n' | grep -e cols -e columns | tr ' ' '\n' | grep '[0-9]' | sed -n 1p)
|
||||
test -n "${terminalWidth}" || terminalWidth=80
|
||||
|
||||
# Remaining space left on each line after the result description.
|
||||
colsUsed=$((testCountWidth + 1 + testCountWidth + 2 + maxTestNameLength + 2 + 8 + 2))
|
||||
colsRemaining=0
|
||||
test "${colsUsed}" -lt "${terminalWidth}" && colsRemaining=$((terminalWidth - colsUsed))
|
||||
|
||||
# Run all of the selected test scripts, formatting the output.
|
||||
#
|
||||
testPassCount=0
|
||||
testFailCount=0
|
||||
testSkipCount=0
|
||||
testNumber=0
|
||||
for testScript in ${selectedTests}; do
|
||||
# Find the test script, make sure it exists.
|
||||
test -f "${testScript}" || testScript="${sourcePath}/tests/${testScript}"
|
||||
test -f "${testScript}" || testScript=$(find "${sourcePath}/tests" -maxdepth 1 -type f -name "${testScript##*/}*" | sed -n '1p')
|
||||
test -f "${testScript}" || continue
|
||||
|
||||
testNumber=$((1+testNumber))
|
||||
|
||||
testScriptLeaf="${testScript##*/}"
|
||||
testName="$(echo "${testScriptLeaf%.sh}" | tr '_' ' ' | sed 's/ - /: /')"
|
||||
printf "%${testCountWidth}d/%d: %-${maxTestNameLength}.${maxTestNameLength}s " "${testNumber}" "${numberOfTests}" "${testName}"
|
||||
|
||||
# Run the test script, capturing the output and the exit status.
|
||||
testExitStatus=0
|
||||
testOutput=""
|
||||
if test -s "${testScript}"; then
|
||||
true > "${workFile1}"
|
||||
true > "${workFile2}"
|
||||
true > "${workFile3}"
|
||||
true > "${workFile4}"
|
||||
testOutput=$(sh -e "${testScript}" 2>&1)
|
||||
testExitStatus=$?
|
||||
else
|
||||
testOutput="test script has not yet been written"
|
||||
testExitStatus=2
|
||||
fi
|
||||
|
||||
# Work out what we're going to say about this test result.
|
||||
testResultDescription=""
|
||||
resultFormatCodes=""
|
||||
if test ${testExitStatus} -eq 0; then
|
||||
resultFormatCodes="${formatCodesPass}"
|
||||
testResultDescription="OK"
|
||||
testPassCount=$((1+testPassCount))
|
||||
elif test ${testExitStatus} -eq 2; then
|
||||
resultFormatCodes="${formatCodesSkip}"
|
||||
testResultDescription="skipped"
|
||||
testSkipCount=$((1+testSkipCount))
|
||||
else
|
||||
resultFormatCodes="${formatCodesFail}"
|
||||
testResultDescription="FAILED"
|
||||
testFailCount=$((1+testFailCount))
|
||||
fi
|
||||
|
||||
# If stdout is not a terminal, don't use terminal format codes.
|
||||
test -t 1 || resultFormatCodes=""
|
||||
|
||||
# Show the description of the test result, and start a new line.
|
||||
test -n "${resultFormatCodes}" && command -v tput >/dev/null 2>&1 && echo "${resultFormatCodes}" | tr ';' '\n' | tput -S 2>/dev/null
|
||||
printf "%s" "${testResultDescription}"
|
||||
|
||||
# If there was any output from the test, display it - either on the
|
||||
# current line, if there's space, or the next line, with each line
|
||||
# prefixed with the test number.
|
||||
if test -n "${testOutput}"; then
|
||||
if test "${#testOutput}" -lt "${colsRemaining}" && ! test "$(echo "${testOutput}" | wc -l | tr -dc '0-9')" -gt 1 2>/dev/null; then
|
||||
printf " - %s" "${testOutput}"
|
||||
else
|
||||
printf "\n%s" "$(echo "${testOutput}" | sed "s,^,$(printf "%${testCountWidth}d/%d: - " "${testNumber}" "${numberOfTests}"),")"
|
||||
fi
|
||||
fi
|
||||
printf "\n"
|
||||
|
||||
test -n "${resultFormatCodes}" && command -v tput >/dev/null 2>&1 && tput sgr0 2>/dev/null
|
||||
done
|
||||
|
||||
# Clean up.
|
||||
rm -f "${workFile1}" "${workFile2}" "${workFile3}" "${workFile4}"
|
||||
trap '' EXIT
|
||||
|
||||
# Report the totals.
|
||||
printf "\n"
|
||||
printf "%s: " "Tests passed"
|
||||
numberFormatting="${formatCodesPass}"
|
||||
test "${testPassCount}" -gt 0 || numberFormatting="${formatCodesZero}"
|
||||
test -t 1 && command -v tput >/dev/null 2>&1 && echo "${numberFormatting}" | tr ';' '\n' | tput -S 2>/dev/null
|
||||
printf "%d" "${testPassCount}"
|
||||
test -t 1 && command -v tput >/dev/null 2>&1 && tput sgr0 2>/dev/null
|
||||
|
||||
printf " %s: " "Tests failed"
|
||||
numberFormatting="${formatCodesFail}"
|
||||
test "${testFailCount}" -gt 0 || numberFormatting="${formatCodesZero}"
|
||||
test -t 1 && command -v tput >/dev/null 2>&1 && echo "${numberFormatting}" | tr ';' '\n' | tput -S 2>/dev/null
|
||||
printf "%d" "${testFailCount}"
|
||||
test -t 1 && command -v tput >/dev/null 2>&1 && tput sgr0 2>/dev/null
|
||||
|
||||
printf " %s: " "Tests skipped"
|
||||
numberFormatting="${formatCodesSkip}"
|
||||
test "${testSkipCount}" -gt 0 || numberFormatting="${formatCodesZero}"
|
||||
test -t 1 && command -v tput >/dev/null 2>&1 && echo "${numberFormatting}" | tr ';' '\n' | tput -S 2>/dev/null
|
||||
printf "%d" "${testSkipCount}"
|
||||
test -t 1 && command -v tput >/dev/null 2>&1 && tput sgr0 2>/dev/null
|
||||
printf "\n"
|
||||
|
||||
# Exit with status 1 if any test failed outright, 0 otherwise.
|
||||
test "${testFailCount}" -eq 0 || exit 1
|
||||
exit 0
|
||||
|
||||
# EOF
|
||||
|
||||
+22
@@ -1,3 +1,25 @@
|
||||
1.7.18 - 28 July 2023
|
||||
* fix: language file installation had been broken by the configuration script rewrite
|
||||
|
||||
1.7.17 - 27 July 2023
|
||||
* feature: new "`--sync`" option to flush cache to disk after every write (related to [GH#6](https://github.com/a-j-wood/pv/issues/6), to improve accuracy when writing to slow disks)
|
||||
* feature: new "`--direct-io`" option to bypass cache - implements [GH#29 "Option to enable *O_DIRECT*"](https://github.com/a-j-wood/pv/issues/29) - requested by Romain Kang, Jacek Wielemborek
|
||||
* fix: correct byte prefix size to 2 spaces in rate display, so progress display size remains constant at low transfer rates
|
||||
* cleanup: rewrote `configure.in` as per suggestions in newer "`autoconf`" manuals
|
||||
* cleanup: replaced `header.in` with one generated by "`autoheader`", moving custom logic to a separate header file "`config-aux.h`"
|
||||
* cleanup: added copyright notice to all source files as per GNU standards
|
||||
* cleanup: changed "`--version`" output to conform to GNU standards
|
||||
* cleanup: replaced backticks with `$()` in all shell scripts that did not come from elsewhere, as backticks are deprecated and harder to read
|
||||
* cleanup: improved the output formatting of "`make test`"
|
||||
* cleanup: extended the "`make test`" mechanism to allow certain tests to be skipped on platforms that cannot support them
|
||||
* cleanup: skip the "pipe" test (for *SIGPIPE*) if GNU "`head`" is not available, so that "`make test`" on stock OpenBSD 7.3 works
|
||||
* cleanup: added a lot more tests to "`make test`"
|
||||
* cleanup: replace all calls to `sprintf()` and `snprintf()` with a new wrapper function `pv_snprintf()` to improve security and compatibility
|
||||
* cleanup: replace all calls to `strcat()` with a wrapper `pv_strlcat()` to improve security and compatibility
|
||||
* cleanup: replace all `write()` calls to the terminal with a wrapper `pv_write_retry()` for consistency
|
||||
* cleanup: tidy up and fix compilation warning in "`--watchfd`" code
|
||||
* cleanup: rewrote all local shell scripts to pass analysis by [ShellCheck](https://www.shellcheck.net)
|
||||
|
||||
1.7.0 - 17 July 2023
|
||||
* dropped: support for Red Hat Enterprise Linux and its derivatives has been dropped; removed the RPM spec file, and will no longer build binaries
|
||||
* feature: the "`--size`" option now accepts "`@filename`" to use the size of another file (pull request [#57](https://github.com/a-j-wood/pv/pull/57) supplied by [Dave Beckett](https://github.com/dajobe))
|
||||
|
||||
+3
-1
@@ -8,6 +8,9 @@ Bugs
|
||||
* ([GH#20](https://github.com/a-j-wood/pv/issues/20)) Terminal state is not restored correctly in all cases (VA)
|
||||
* ([GH#24](https://github.com/a-j-wood/pv/issues/24)) Race condition with multiple "`pv -c`" leaves terminal state inconsistent (Lars Ellenberg, Viktor Ashirov)
|
||||
* ([GH#34](https://github.com/a-j-wood/pv/issues/34)) Continue timer even if input or output is blocking (Martin Probst - Jun 2017)
|
||||
* ([GH#69](https://github.com/a-j-wood/pv/issues/69)) Configure issue for stat64
|
||||
* ([GH#70](https://github.com/a-j-wood/pv/issues/70)) New compilation warnings
|
||||
* ([GH#71](https://github.com/a-j-wood/pv/issues/71)) Debian complains about old OpenPGP signatures
|
||||
|
||||
Feature requests
|
||||
----------------
|
||||
@@ -23,7 +26,6 @@ Feature requests
|
||||
* ([GH#17](https://github.com/a-j-wood/pv/issues/17)) Allow "`-r`" with "`-l`" and "`-n`" to output lines/sec (Roland Kletzing)
|
||||
* ([GH#22](https://github.com/a-j-wood/pv/issues/22)) Options to skip input and seek on output (Jason A. Pfeil, Feb 2022)
|
||||
* ([GH#25](https://github.com/a-j-wood/pv/issues/25)) Normalise progress to 100% on overrun (Andrej Gantvorg)
|
||||
* ([GH#29](https://github.com/a-j-wood/pv/issues/29)) Option to enable *O_DIRECT* (Romain Kang, Jacek Wielemborek)
|
||||
* ([GH#35](https://github.com/a-j-wood/pv/issues/35)) Allow decimal values for "`-s`", "`-L`", "`-B`" (Thomas Watson - Aug 2020)
|
||||
* ([GH#36](https://github.com/a-j-wood/pv/issues/36)) Ignore *SIGWINCH* (window size change) if "`-w`" / "`-H`" provided
|
||||
* ([GH#37](https://github.com/a-j-wood/pv/issues/37)) Allow "`-E`" to take a block size argument so errors cause a skip to the next block (Anthony DeRobertis - Oct 2016)
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
1.7.0
|
||||
1.7.18
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
Begin3
|
||||
Title: @PACKAGE@
|
||||
Version: @VERSION@
|
||||
Entered-date: 17JUL23
|
||||
Entered-date: 28JUL23
|
||||
Description: A tool for monitoring the progress of data through a
|
||||
pipeline. It can be inserted into any normal pipeline
|
||||
between two processes to give a visual indication of how
|
||||
|
||||
+30
-4
@@ -209,10 +209,16 @@ is in use, then adding
|
||||
will cause the number of bytes processed so far to be output instead of a
|
||||
percentage; if
|
||||
.B \-\-line\-mode
|
||||
is also in use, then instead of bytes or a percentage, the number of lines
|
||||
is also in use as well as
|
||||
.B \-\-bytes
|
||||
and
|
||||
.BR \-\-numeric ,
|
||||
then instead of bytes or a percentage, the number of lines
|
||||
so far is output. And finally, if
|
||||
.B \-\-timer
|
||||
is also in use, then each output line is prefixed with the elapsed time
|
||||
is added to
|
||||
.BR \-\-numeric ,
|
||||
then each output line is prefixed with the elapsed time
|
||||
so far, as a decimal number of seconds.
|
||||
.TP
|
||||
.B \-q, \-\-quiet
|
||||
@@ -389,6 +395,24 @@ If a size was specified with
|
||||
stop transferring data once that many bytes have been written, instead of
|
||||
continuing to the end of input.
|
||||
.TP
|
||||
.B \-Y, \-\-sync
|
||||
After every write operation, synchronise the buffer caches to disk - see
|
||||
.BR fdatasync (2).
|
||||
This has no effect when the output is a pipe. Using
|
||||
.B \-Y
|
||||
may improve the accuracy of the progress bar when writing to a slow disk.
|
||||
.TP
|
||||
.B \-K, \-\-direct-io
|
||||
Set the
|
||||
.I O_DIRECT
|
||||
flag on all inputs and outputs, if it is available. This will minimise
|
||||
the effect of caches, at the cost of performance. Due to memory alignment
|
||||
requirements, it also may cause read or write failures with an error of
|
||||
"Invalid argument", especially if reading and writing files across a variety
|
||||
of filesystems in a single
|
||||
.B @PACKAGE@
|
||||
call. Use this option with caution.
|
||||
.TP
|
||||
.B \-d PID[:FD], \-\-watchfd PID[:FD]
|
||||
Instead of transferring data, watch file descriptor
|
||||
.B FD
|
||||
@@ -648,8 +672,10 @@ home page: <http://www.ivarch.com/programs/pv.shtml>
|
||||
.SH "SEE ALSO"
|
||||
.BR cat (1),
|
||||
.BR dialog (1),
|
||||
.BR splice (2)
|
||||
|
||||
.BR splice (2),
|
||||
.BR open (2)
|
||||
(for
|
||||
.IR O_DIRECT )
|
||||
|
||||
.SH LICENSE
|
||||
This is free software, distributed under the ARTISTIC 2.0 license.
|
||||
|
||||
+20
-8
@@ -1,32 +1,44 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Script to autogenerate the `configure' script, and rebuild the dependency
|
||||
# list.
|
||||
# Script to autogenerate the `configure' script, and the config header
|
||||
# template if `autoconf' is available, and then rebuild the dependency list.
|
||||
|
||||
set -e
|
||||
|
||||
cd `dirname $0`
|
||||
cd $(dirname $0)
|
||||
|
||||
cd autoconf
|
||||
autoconf configure.in > ../configure
|
||||
cd ..
|
||||
test -t 1 && echo "${0##*/}: running autoconf"
|
||||
autoconf autoconf/configure.in > configure
|
||||
chmod 755 configure
|
||||
|
||||
if command -v autoheader >/dev/null; then
|
||||
test -t 1 && echo "${0##*/}: running autoheader"
|
||||
autoheader autoconf/configure.in
|
||||
else
|
||||
test -t 1 && echo "${0##*/}: autoheader not found, skipping"
|
||||
fi
|
||||
|
||||
echo > autoconf/make/depend.mk~
|
||||
echo > autoconf/make/filelist.mk~
|
||||
echo > autoconf/make/modules.mk~
|
||||
|
||||
MAKE=make
|
||||
which gmake >/dev/null 2>&1 && MAKE=gmake
|
||||
command -v gmake >/dev/null 2>&1 && MAKE=gmake
|
||||
|
||||
rm -rf .gen
|
||||
mkdir .gen
|
||||
cd .gen
|
||||
|
||||
test -t 1 && echo "${0##*/}: running new \`configure' script"
|
||||
sh ../configure
|
||||
|
||||
test -t 1 && echo "${0##*/}: regenerating Makefile fragments"
|
||||
$MAKE make
|
||||
$MAKE dep
|
||||
|
||||
test -t 1 && echo "${0##*/}: cleaning up"
|
||||
cd ..
|
||||
rm -rf .gen
|
||||
rm -rf autoconf/autom4te.cache
|
||||
rm -rf autom4te.cache autoconf/autom4te.cache
|
||||
|
||||
# EOF
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Standard definitions to make use of the config.h values set by the
|
||||
* `configure' script. Include this after config.h and before anything
|
||||
* else.
|
||||
*
|
||||
* Copyright 2002-2008, 2010, 2012-2015, 2017, 2021, 2023 Andrew Wood
|
||||
*
|
||||
* Distributed under the Artistic License v2.0; see `doc/COPYING'.
|
||||
*/
|
||||
|
||||
#ifdef ENABLE_NLS
|
||||
# include "library/gettext.h"
|
||||
#else
|
||||
# define _(String) (String)
|
||||
# define N_(String) (String)
|
||||
#endif
|
||||
|
||||
#undef HAVE_IPC
|
||||
#ifdef HAVE_SYS_IPC_H
|
||||
#define HAVE_IPC 1
|
||||
#endif
|
||||
|
||||
#undef CURSOR_ANSWERBACK_BYTE_BY_BYTE
|
||||
#ifndef _AIX
|
||||
#define CURSOR_ANSWERBACK_BYTE_BY_BYTE 1
|
||||
#endif
|
||||
|
||||
/* Boolean type support */
|
||||
#undef HAVE_STDBOOL_H
|
||||
#ifdef HAVE_STDBOOL_H
|
||||
# include <stdbool.h>
|
||||
#else
|
||||
# ifndef HAVE__BOOL
|
||||
# ifdef __cplusplus
|
||||
typedef bool _Bool;
|
||||
# else
|
||||
# define _Bool signed char
|
||||
# endif
|
||||
# endif
|
||||
# define bool _Bool
|
||||
# define false 0
|
||||
# define true 1
|
||||
# define __bool_true_false_are_defined 1
|
||||
#endif
|
||||
|
||||
/* EOF */
|
||||
@@ -1,5 +1,9 @@
|
||||
/*
|
||||
* Replacement getopt function's header file. Include this AFTER config.h.
|
||||
*
|
||||
* Copyright 2002-2008, 2010, 2012-2015, 2017, 2021, 2023 Andrew Wood
|
||||
*
|
||||
* Distributed under the Artistic License v2.0; see `doc/COPYING'.
|
||||
*/
|
||||
|
||||
#ifndef _LIBRARY_GETOPT_H
|
||||
|
||||
@@ -9,6 +9,9 @@
|
||||
* # define N_(String) (String)
|
||||
* #endif
|
||||
*
|
||||
* Copyright 2002-2008, 2010, 2012-2015, 2017, 2021, 2023 Andrew Wood
|
||||
*
|
||||
* Distributed under the Artistic License v2.0; see `doc/COPYING'.
|
||||
*/
|
||||
|
||||
#ifndef _LIBRARY_GETTEXT_H
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
/*
|
||||
* Global program option structure and the parsing function prototype.
|
||||
*
|
||||
* Copyright 2002-2008, 2010, 2012-2015, 2017, 2021, 2023 Andrew Wood
|
||||
*
|
||||
* Distributed under the Artistic License v2.0; see `doc/COPYING'.
|
||||
*/
|
||||
|
||||
#ifndef _OPTIONS_H
|
||||
@@ -39,6 +43,8 @@ struct opts_s { /* structure describing run-time options */
|
||||
bool no_splice; /* flag set if never to use splice */
|
||||
unsigned int skip_errors; /* skip read errors counter */
|
||||
bool stop_at_size; /* set if we stop at "size" bytes */
|
||||
bool sync_after_write; /* set if we sync after every write */
|
||||
bool direct_io; /* set if O_DIRECT is to be used */
|
||||
double interval; /* interval between updates */
|
||||
double delay_start; /* delay before first display */
|
||||
unsigned int watch_pid; /* process to watch fds of */
|
||||
|
||||
+54
-41
@@ -1,33 +1,20 @@
|
||||
/*
|
||||
* Functions internal to the PV library.
|
||||
* Functions internal to the PV library. Include "config.h" first.
|
||||
*
|
||||
* Copyright 2002-2008, 2010, 2012-2015, 2017, 2021, 2023 Andrew Wood
|
||||
*
|
||||
* Distributed under the Artistic License v2.0; see `doc/COPYING'.
|
||||
*/
|
||||
|
||||
#ifndef _PV_INTERNAL_H
|
||||
#define _PV_INTERNAL_H 1
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#ifndef _PV_H
|
||||
#include "pv.h"
|
||||
#endif /* _PV_H */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <signal.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
/*
|
||||
* Since macOS 10.6, stat64 variants are equivalent to plain stat, and the
|
||||
* suffixed versions have been removed in macOS 11. See stat(2).
|
||||
*/
|
||||
#if defined(__APPLE__) || defined(APPLE)
|
||||
#define stat64 stat
|
||||
#define fstat64 fstat
|
||||
#define lstat64 lstat
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@@ -61,6 +48,27 @@ typedef struct pvhistory {
|
||||
long double elapsed_sec;
|
||||
} pvhistory_t;
|
||||
|
||||
#define PV_SIZEOF_DEFAULT_FORMAT 512
|
||||
#define PV_SIZEOF_CWD 4096
|
||||
#define PV_SIZEOF_LASTOUTPUT_BUFFER 256
|
||||
#define PV_SIZEOF_STR_NAME 512
|
||||
#define PV_SIZEOF_STR_TRANSFERRED 128
|
||||
#define PV_SIZEOF_STR_BUFPERCENT 128
|
||||
#define PV_SIZEOF_STR_TIMER 128
|
||||
#define PV_SIZEOF_STR_RATE 128
|
||||
#define PV_SIZEOF_STR_AVERAGE_RATE 128
|
||||
#define PV_SIZEOF_STR_PROGRESS 1024
|
||||
#define PV_SIZEOF_STR_LASTOUTPUT 512
|
||||
#define PV_SIZEOF_STR_ETA 128
|
||||
#define PV_SIZEOF_STR_FINETA 128
|
||||
#define PV_FORMAT_ARRAY_MAX 100
|
||||
#define PV_SIZEOF_CRS_LOCK_FILE 1024
|
||||
|
||||
#define PV_SIZEOF_FILE_FDINFO 4096
|
||||
#define PV_SIZEOF_FILE_FD 4096
|
||||
#define PV_SIZEOF_FILE_FDPATH 4096
|
||||
#define PV_SIZEOF_DISPLAY_NAME 512
|
||||
|
||||
|
||||
/*
|
||||
* Structure for holding PV internal state. Opaque outside the PV library.
|
||||
@@ -85,6 +93,9 @@ struct pvstate_s {
|
||||
bool no_op; /* do nothing other than pipe data */
|
||||
unsigned int skip_errors; /* skip read errors counter */
|
||||
bool stop_at_size; /* set if we stop at "size" bytes */
|
||||
bool sync_after_write; /* set if we sync after every write */
|
||||
bool direct_io; /* set if O_DIRECT is to be used */
|
||||
bool direct_io_changed; /* set when direct_io is changed */
|
||||
bool no_splice; /* never use splice() */
|
||||
unsigned long long rate_limit; /* rate limit, in bytes per second */
|
||||
unsigned long long target_buffer_size; /* buffer size (0=default) */
|
||||
@@ -96,14 +107,14 @@ struct pvstate_s {
|
||||
unsigned int width; /* screen width */
|
||||
unsigned int height; /* screen height */
|
||||
const char *name; /* display name */
|
||||
char default_format[512]; /* default format string */
|
||||
char default_format[PV_SIZEOF_DEFAULT_FORMAT]; /* default format string */
|
||||
const char *format_string; /* output format string */
|
||||
|
||||
/******************
|
||||
* Program status *
|
||||
******************/
|
||||
const char *program_name; /* program name for error reporting */
|
||||
char cwd[4096]; /* current working directory for relative path */
|
||||
char cwd[PV_SIZEOF_CWD]; /* current working directory for relative path */
|
||||
const char *current_file; /* current file being read */
|
||||
int exit_status; /* exit status to give (0=OK) */
|
||||
|
||||
@@ -145,24 +156,24 @@ struct pvstate_s {
|
||||
char *display_buffer;
|
||||
long display_buffer_size;
|
||||
int lastoutput_length; /* number of last-output bytes to show */
|
||||
unsigned char lastoutput_buffer[256];
|
||||
unsigned char lastoutput_buffer[PV_SIZEOF_LASTOUTPUT_BUFFER];
|
||||
int prev_width; /* screen width last time we were called */
|
||||
int prev_length; /* length of last string we output */
|
||||
char str_name[512];
|
||||
char str_transferred[128];
|
||||
char str_bufpercent[128];
|
||||
char str_timer[128];
|
||||
char str_rate[128];
|
||||
char str_average_rate[128];
|
||||
char str_progress[1024];
|
||||
char str_lastoutput[512];
|
||||
char str_eta[128];
|
||||
char str_fineta[128];
|
||||
char str_name[PV_SIZEOF_STR_NAME];
|
||||
char str_transferred[PV_SIZEOF_STR_TRANSFERRED];
|
||||
char str_bufpercent[PV_SIZEOF_STR_BUFPERCENT];
|
||||
char str_timer[PV_SIZEOF_STR_TIMER];
|
||||
char str_rate[PV_SIZEOF_STR_RATE];
|
||||
char str_average_rate[PV_SIZEOF_STR_AVERAGE_RATE];
|
||||
char str_progress[PV_SIZEOF_STR_PROGRESS];
|
||||
char str_lastoutput[PV_SIZEOF_STR_LASTOUTPUT];
|
||||
char str_eta[PV_SIZEOF_STR_ETA];
|
||||
char str_fineta[PV_SIZEOF_STR_FINETA];
|
||||
unsigned long components_used; /* bitmask of components used */
|
||||
struct {
|
||||
const char *string;
|
||||
int length;
|
||||
} format[100];
|
||||
} format[PV_FORMAT_ARRAY_MAX];
|
||||
bool display_visible; /* set once anything written to terminal */
|
||||
|
||||
/********************
|
||||
@@ -179,7 +190,7 @@ struct pvstate_s {
|
||||
bool crs_noipc; /* set if we can't use IPC */
|
||||
#endif /* HAVE_IPC */
|
||||
int crs_lock_fd; /* fd of lockfile, -1 if none open */
|
||||
char crs_lock_file[1024];
|
||||
char crs_lock_file[PV_SIZEOF_CRS_LOCK_FILE];
|
||||
int crs_y_start; /* our initial Y coordinate */
|
||||
|
||||
/*******************
|
||||
@@ -242,13 +253,13 @@ struct pvwatchfd_s {
|
||||
int watch_fd; /* fd to watch, -1 = not displayed */
|
||||
#ifdef __APPLE__
|
||||
#else
|
||||
char file_fdinfo[4096]; /* path to /proc fdinfo file */
|
||||
char file_fd[4096]; /* path to /proc fd symlink */
|
||||
char file_fdinfo[PV_SIZEOF_FILE_FDINFO]; /* path to /proc fdinfo file */
|
||||
char file_fd[PV_SIZEOF_FILE_FD]; /* path to /proc fd symlink */
|
||||
#endif
|
||||
char file_fdpath[4096]; /* path to file that was opened */
|
||||
char display_name[512]; /* name to show on progress bar */
|
||||
struct stat64 sb_fd; /* stat of fd symlink */
|
||||
struct stat64 sb_fd_link; /* lstat of fd symlink */
|
||||
char file_fdpath[PV_SIZEOF_FILE_FDPATH]; /* path to file that was opened */
|
||||
char display_name[PV_SIZEOF_DISPLAY_NAME]; /* name to show on progress bar */
|
||||
struct stat sb_fd; /* stat of fd symlink */
|
||||
struct stat sb_fd_link; /* lstat of fd symlink */
|
||||
unsigned long long size; /* size of whole file, 0 if unknown */
|
||||
long long position; /* position last seen at */
|
||||
struct timeval start_time; /* time we started watching the fd */
|
||||
@@ -263,9 +274,11 @@ long pv_transfer(pvstate_t, int, int *, int *, unsigned long long, long *);
|
||||
void pv_set_buffer_size(unsigned long long, int);
|
||||
int pv_next_file(pvstate_t, int, int);
|
||||
|
||||
void pv_write_retry(int, const char *, size_t);
|
||||
|
||||
void pv_crs_fini(pvstate_t);
|
||||
void pv_crs_init(pvstate_t);
|
||||
void pv_crs_update(pvstate_t, char *);
|
||||
void pv_crs_update(pvstate_t, const char *);
|
||||
#ifdef HAVE_IPC
|
||||
void pv_crs_needreinit(pvstate_t);
|
||||
#endif
|
||||
|
||||
+26
-1
@@ -1,10 +1,16 @@
|
||||
/*
|
||||
* Functions used across the program.
|
||||
* Functions used across the program. Include "config.h" first.
|
||||
*
|
||||
* Copyright 2002-2008, 2010, 2012-2015, 2017, 2021, 2023 Andrew Wood
|
||||
*
|
||||
* Distributed under the Artistic License v2.0; see `doc/COPYING'.
|
||||
*/
|
||||
|
||||
#ifndef _PV_H
|
||||
#define _PV_H 1
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@@ -49,6 +55,23 @@ extern unsigned long long pv_getnum_ull(const char *);
|
||||
*/
|
||||
extern int pv_getnum_check(const char *, pv_numtype_t);
|
||||
|
||||
/*
|
||||
* String handling wrappers.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Wrapper for sprintf(), falling back to sprintf() on systems without that
|
||||
* function.
|
||||
*/
|
||||
extern int pv_snprintf(char *, size_t, const char *, ...);
|
||||
|
||||
/*
|
||||
* Implementation of strlcat() where it is unavailable: append a string to a
|
||||
* buffer, constraining the buffer to a particular size and ensuring
|
||||
* termination with '\0'.
|
||||
*/
|
||||
extern size_t pv_strlcat(char *, const char *, size_t);
|
||||
|
||||
/*
|
||||
* Main PV functions.
|
||||
*/
|
||||
@@ -83,6 +106,8 @@ extern void pv_state_null_set(pvstate_t, bool);
|
||||
extern void pv_state_no_op_set(pvstate_t, bool);
|
||||
extern void pv_state_skip_errors_set(pvstate_t, unsigned int);
|
||||
extern void pv_state_stop_at_size_set(pvstate_t, bool);
|
||||
extern void pv_state_sync_after_write_set(pvstate_t, bool);
|
||||
extern void pv_state_direct_io_set(pvstate_t, bool);
|
||||
extern void pv_state_rate_limit_set(pvstate_t, unsigned long long);
|
||||
extern void pv_state_target_buffer_size_set(pvstate_t, unsigned long long);
|
||||
extern void pv_state_no_splice_set(pvstate_t, bool);
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
/*
|
||||
* Small reimplementation of getopt().
|
||||
*
|
||||
* Copyright 2002-2008, 2010, 2012-2015, 2017, 2021, 2023 Andrew Wood
|
||||
*
|
||||
* Distributed under the Artistic License v2.0; see `doc/COPYING'.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
@@ -11,6 +11,10 @@
|
||||
* returns a struct msg_table_s[] of msgid and msgstr pairs, with the end
|
||||
* of the table being marked by a NULL msgid. The po2table.sh script will do
|
||||
* this.
|
||||
*
|
||||
* Copyright 2002-2008, 2010, 2012-2015, 2017, 2021, 2023 Andrew Wood
|
||||
*
|
||||
* Distributed under the Artistic License v2.0; see `doc/COPYING'.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
+4
-2
@@ -1,10 +1,12 @@
|
||||
/*
|
||||
* Output debugging information.
|
||||
*
|
||||
* Copyright 2002-2008, 2010, 2012-2015, 2017, 2021, 2023 Andrew Wood
|
||||
*
|
||||
* Distributed under the Artistic License v2.0; see `doc/COPYING'.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
#include "pv.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
+19
-16
@@ -1,18 +1,18 @@
|
||||
/*
|
||||
* Output command-line help to stdout.
|
||||
*
|
||||
* Copyright 2002-2008, 2010, 2012-2015, 2017, 2021, 2023 Andrew Wood
|
||||
*
|
||||
* Distributed under the Artistic License v2.0; see `doc/COPYING'.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "pv.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#define N_(String) (String)
|
||||
|
||||
struct optdesc_s {
|
||||
char *optshort;
|
||||
char *optlong;
|
||||
@@ -91,6 +91,10 @@ void display_help(void)
|
||||
N_("skip read errors in input")},
|
||||
{"-S", "--stop-at-size", 0,
|
||||
N_("stop after --size bytes have been transferred")},
|
||||
{"-Y", "--sync", 0,
|
||||
N_("flush cache to disk after every write")},
|
||||
{"-K", "--direct-io", 0,
|
||||
N_("use direct I/O to bypass cache")},
|
||||
#ifdef HAVE_IPC
|
||||
{"-R", "--remote", N_("PID"),
|
||||
N_("update settings of process PID")},
|
||||
@@ -110,6 +114,7 @@ void display_help(void)
|
||||
};
|
||||
unsigned int i, col1max = 0, tw = 77;
|
||||
char *optbuf;
|
||||
size_t optbuf_size;
|
||||
|
||||
printf(_("Usage: %s [OPTION] [FILE]..."), PROGRAM_NAME);
|
||||
printf("\n%s\n\n",
|
||||
@@ -139,7 +144,8 @@ void display_help(void)
|
||||
|
||||
col1max++;
|
||||
|
||||
optbuf = malloc((size_t) (col1max + 16));
|
||||
optbuf_size = 16 + col1max;
|
||||
optbuf = malloc(optbuf_size);
|
||||
if (NULL == optbuf) {
|
||||
fprintf(stderr, "%s: %s\n", PROGRAM_NAME, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
@@ -163,19 +169,16 @@ void display_help(void)
|
||||
if (description)
|
||||
description = _(description);
|
||||
|
||||
#ifdef HAVE_SNPRINTF
|
||||
(void) snprintf(optbuf, (size_t) (col1max + 15),
|
||||
"%s%s%s%s%s", optlist[i].optshort,
|
||||
#else
|
||||
sprintf(optbuf, "%s%s%s%s%s", optlist[i].optshort,
|
||||
#endif
|
||||
(void) pv_snprintf(optbuf, optbuf_size, "%s%s%s%s%s",
|
||||
optlist[i].optshort,
|
||||
#ifdef HAVE_GETOPT_LONG
|
||||
optlist[i].optlong ? ", " : "",
|
||||
optlist[i].optlong ? optlist[i].optlong : "",
|
||||
optlist[i].optlong ? ", " : "",
|
||||
optlist[i].
|
||||
optlong ? optlist[i].optlong : "",
|
||||
#else
|
||||
"", "",
|
||||
"", "",
|
||||
#endif
|
||||
param ? " " : "", param ? param : "");
|
||||
param ? " " : "", param ? param : "");
|
||||
|
||||
printf(" %-*s ", (int) (col1max - 2), optbuf);
|
||||
|
||||
|
||||
+6
-2
@@ -1,11 +1,13 @@
|
||||
/*
|
||||
* Main program entry point - read the command line options, then perform
|
||||
* the appropriate actions.
|
||||
*
|
||||
* Copyright 2002-2008, 2010, 2012-2015, 2017, 2021, 2023 Andrew Wood
|
||||
*
|
||||
* Distributed under the Artistic License v2.0; see `doc/COPYING'.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
#include "options.h"
|
||||
#include "pv.h"
|
||||
|
||||
@@ -199,6 +201,8 @@ int main(int argc, char **argv)
|
||||
pv_state_null_set(state, opts->null);
|
||||
pv_state_skip_errors_set(state, opts->skip_errors);
|
||||
pv_state_stop_at_size_set(state, opts->stop_at_size);
|
||||
pv_state_sync_after_write_set(state, opts->sync_after_write);
|
||||
pv_state_direct_io_set(state, opts->direct_io);
|
||||
pv_state_rate_limit_set(state, opts->rate_limit);
|
||||
pv_state_target_buffer_size_set(state, opts->buffer_size);
|
||||
pv_state_no_splice_set(state, opts->no_splice);
|
||||
|
||||
+16
-5
@@ -1,10 +1,12 @@
|
||||
/*
|
||||
* Parse command-line options.
|
||||
*
|
||||
* Copyright 2002-2008, 2010, 2012-2015, 2017, 2021, 2023 Andrew Wood
|
||||
*
|
||||
* Distributed under the Artistic License v2.0; see `doc/COPYING'.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
#include "options.h"
|
||||
#include "library/getopt.h"
|
||||
#include "pv.h"
|
||||
@@ -80,6 +82,8 @@ opts_t opts_parse(int argc, char **argv)
|
||||
{"no-splice", 0, NULL, (int) 'C'},
|
||||
{"skip-errors", 0, NULL, (int) 'E'},
|
||||
{"stop-at-size", 0, NULL, (int) 'S'},
|
||||
{"sync", 0, NULL, (int) 'Y'},
|
||||
{"direct-io", 0, NULL, (int) 'K'},
|
||||
{"remote", 1, NULL, (int) 'R'},
|
||||
{"pidfile", 1, NULL, (int) 'P'},
|
||||
{"watchfd", 1, NULL, (int) 'd'},
|
||||
@@ -89,7 +93,7 @@ opts_t opts_parse(int argc, char **argv)
|
||||
int option_index = 0;
|
||||
#endif
|
||||
char *short_options =
|
||||
"hVpteIrab8TA:fnqcWD:s:l0i:w:H:N:F:L:B:CESR:P:d:m:";
|
||||
"hVpteIrab8TA:fnqcWD:s:l0i:w:H:N:F:L:B:CESYKR:P:d:m:";
|
||||
int c, numopts;
|
||||
unsigned int check_pid;
|
||||
int check_fd;
|
||||
@@ -146,6 +150,7 @@ opts_t opts_parse(int argc, char **argv)
|
||||
/* "-s @" is valid, so allow it. */
|
||||
if ('@' == *optarg)
|
||||
break;
|
||||
/* falls through */
|
||||
case 'A':
|
||||
case 'w':
|
||||
case 'H':
|
||||
@@ -274,12 +279,12 @@ opts_t opts_parse(int argc, char **argv)
|
||||
/* Permit "@<filename>" as well as just a number. */
|
||||
if ('@' == *optarg) {
|
||||
const char *size_file = 1 + optarg;
|
||||
struct stat64 sb;
|
||||
struct stat sb;
|
||||
int rc;
|
||||
|
||||
rc = 0;
|
||||
memset(&sb, 0, sizeof(sb));
|
||||
rc = stat64(size_file, &sb);
|
||||
rc = stat(size_file, &sb);
|
||||
if (0 == rc) {
|
||||
opts->size = sb.st_size;
|
||||
} else {
|
||||
@@ -330,6 +335,12 @@ opts_t opts_parse(int argc, char **argv)
|
||||
case 'S':
|
||||
opts->stop_at_size = true;
|
||||
break;
|
||||
case 'Y':
|
||||
opts->sync_after_write = true;
|
||||
break;
|
||||
case 'K':
|
||||
opts->direct_io = true;
|
||||
break;
|
||||
case 'R':
|
||||
opts->remote = pv_getnum_ui(optarg);
|
||||
break;
|
||||
|
||||
+4
-2
@@ -1,10 +1,12 @@
|
||||
/*
|
||||
* Remote-control functions.
|
||||
*
|
||||
* Copyright 2002-2008, 2010, 2012-2015, 2017, 2021, 2023 Andrew Wood
|
||||
*
|
||||
* Distributed under the Artistic License v2.0; see `doc/COPYING'.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
#include "options.h"
|
||||
#include "pv.h"
|
||||
|
||||
|
||||
+19
-19
@@ -1,34 +1,34 @@
|
||||
/*
|
||||
* Output version information to stdout.
|
||||
*
|
||||
* Copyright 2002-2008, 2010, 2012-2015, 2017, 2021, 2023 Andrew Wood
|
||||
*
|
||||
* Distributed under the Artistic License v2.0; see `doc/COPYING'.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
/*
|
||||
* Display current package version.
|
||||
* Display current package version as per GNU standards.
|
||||
*/
|
||||
void display_version(void)
|
||||
{
|
||||
printf(_("%s %s - Copyright %s %s"),
|
||||
PROGRAM_NAME, VERSION, COPYRIGHT_YEAR, COPYRIGHT_HOLDER);
|
||||
printf("\n\n");
|
||||
printf(_("Web site: %s"), PROJECT_HOMEPAGE);
|
||||
printf("\n\n");
|
||||
printf("%s",
|
||||
_("This program is free software, and is being distributed "
|
||||
"under the\nterms of the Artistic License 2.0."));
|
||||
printf("\n\n");
|
||||
printf("%s",
|
||||
/* GNU standard first line format: program and version only */
|
||||
printf("%s %s\n", PROGRAM_NAME, VERSION);
|
||||
/* GNU standard second line format - "Copyright" always in English */
|
||||
printf("Copyright %s %s\n", COPYRIGHT_YEAR, COPYRIGHT_HOLDER);
|
||||
/* GNU standard license line and free software notice */
|
||||
printf("%s\n",
|
||||
_
|
||||
("This program is distributed in the hope that it will be useful,\n"
|
||||
"but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
|
||||
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."));
|
||||
printf("\n\n");
|
||||
("License: Artistic v2.0 <https://opensource.org/license/artistic-2-0/>"));
|
||||
printf("%s\n",
|
||||
_
|
||||
("This is free software: you are free to change and redistribute it."));
|
||||
printf("%s\n",
|
||||
_("There is NO WARRANTY, to the extent permitted by law."));
|
||||
/* Project web site link */
|
||||
printf("\n%s: <%s>\n", _("Project web site"), PROJECT_HOMEPAGE);
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
||||
+119
-117
@@ -8,7 +8,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2023-07-17 21:52+0100\n"
|
||||
"POT-Creation-Date: 2023-07-27 20:49+0100\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
@@ -16,156 +16,158 @@ msgstr ""
|
||||
"Content-Type: text/plain; charset=CHARSET\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#: src/pv/cursor.c:80
|
||||
#: src/pv/cursor.c:86
|
||||
msgid "failed to get terminal name"
|
||||
msgstr ""
|
||||
|
||||
#: src/pv/cursor.c:125
|
||||
#: src/pv/cursor.c:124
|
||||
msgid "failed to open lock file"
|
||||
msgstr ""
|
||||
|
||||
#: src/pv/cursor.c:159
|
||||
#: src/pv/cursor.c:158
|
||||
msgid "lock attempt failed"
|
||||
msgstr ""
|
||||
|
||||
#: src/pv/cursor.c:409
|
||||
#: src/pv/cursor.c:408
|
||||
msgid "failed to open terminal"
|
||||
msgstr ""
|
||||
|
||||
#: src/pv/file.c:119
|
||||
#: src/pv/file.c:124
|
||||
msgid "failed to seek to start of output"
|
||||
msgstr ""
|
||||
|
||||
#: src/pv/file.c:215
|
||||
#: src/pv/file.c:220
|
||||
msgid "failed to close file"
|
||||
msgstr ""
|
||||
|
||||
#: src/pv/file.c:238
|
||||
#: src/pv/file.c:243
|
||||
msgid "failed to read file"
|
||||
msgstr ""
|
||||
|
||||
#: src/pv/file.c:248 src/main/options.c:288
|
||||
#: src/pv/file.c:253 src/main/options.c:293
|
||||
msgid "failed to stat file"
|
||||
msgstr ""
|
||||
|
||||
#: src/pv/file.c:257
|
||||
#: src/pv/file.c:262
|
||||
msgid "failed to stat output file"
|
||||
msgstr ""
|
||||
|
||||
#: src/pv/file.c:280
|
||||
#: src/pv/file.c:285
|
||||
msgid "input file is output file"
|
||||
msgstr ""
|
||||
|
||||
#: src/pv/loop.c:527 src/pv/loop.c:597 src/pv/loop.c:649 src/pv/watchpid.c:68
|
||||
#: src/pv/watchpid.c:79 src/pv/watchpid.c:93 src/pv/watchpid.c:104
|
||||
#: src/pv/watchpid.c:145 src/pv/watchpid.c:168 src/pv/watchpid.c:178
|
||||
#: src/pv/watchpid.c:192 src/pv/watchpid.c:285 src/pv/watchpid.c:294
|
||||
#: src/pv/watchpid.c:332 src/pv/watchpid.c:349
|
||||
msgid "pid"
|
||||
msgstr ""
|
||||
|
||||
#: src/pv/transfer.c:341
|
||||
#: src/pv/transfer.c:387
|
||||
msgid "read failed"
|
||||
msgstr ""
|
||||
|
||||
#: src/pv/transfer.c:359
|
||||
#: src/pv/transfer.c:405
|
||||
msgid "warning: read errors detected"
|
||||
msgstr ""
|
||||
|
||||
#: src/pv/transfer.c:374
|
||||
#: src/pv/transfer.c:420
|
||||
msgid "file is not seekable"
|
||||
msgstr ""
|
||||
|
||||
#: src/pv/transfer.c:437
|
||||
#: src/pv/transfer.c:483
|
||||
msgid "failed to seek past error"
|
||||
msgstr ""
|
||||
|
||||
#: src/pv/transfer.c:456
|
||||
#: src/pv/transfer.c:502
|
||||
msgid "skipped past read error"
|
||||
msgstr ""
|
||||
|
||||
#: src/pv/transfer.c:458 src/pv/display.c:687
|
||||
#: src/pv/transfer.c:504 src/pv/display.c:723
|
||||
msgid "B"
|
||||
msgstr ""
|
||||
|
||||
#: src/pv/transfer.c:631
|
||||
#: src/pv/transfer.c:678
|
||||
msgid "write failed"
|
||||
msgstr ""
|
||||
|
||||
#: src/pv/transfer.c:679 src/pv/display.c:618
|
||||
#: src/pv/transfer.c:808 src/pv/display.c:646
|
||||
msgid "buffer allocation failed"
|
||||
msgstr ""
|
||||
|
||||
#: src/pv/transfer.c:770
|
||||
#: src/pv/transfer.c:913
|
||||
msgid "select call failed"
|
||||
msgstr ""
|
||||
|
||||
#: src/pv/state.c:25
|
||||
msgid "history structure allocation failed"
|
||||
#: src/pv/watchpid.c:74 src/pv/watchpid.c:85 src/pv/watchpid.c:99
|
||||
#: src/pv/watchpid.c:110 src/pv/watchpid.c:151 src/pv/watchpid.c:168
|
||||
#: src/pv/watchpid.c:178 src/pv/watchpid.c:192 src/pv/watchpid.c:280
|
||||
#: src/pv/watchpid.c:289 src/pv/watchpid.c:322 src/pv/watchpid.c:343
|
||||
#: src/pv/loop.c:542 src/pv/loop.c:604 src/pv/loop.c:656
|
||||
msgid "pid"
|
||||
msgstr ""
|
||||
|
||||
#: src/pv/state.c:55
|
||||
msgid "none"
|
||||
msgstr ""
|
||||
|
||||
#: src/pv/display.c:151
|
||||
msgid "yzafpnum kMGTPEZY"
|
||||
msgstr ""
|
||||
|
||||
#: src/pv/display.c:156
|
||||
msgid "yzafpnum KMGTPEZY"
|
||||
msgstr ""
|
||||
|
||||
#: src/pv/display.c:683
|
||||
msgid "b"
|
||||
msgstr ""
|
||||
|
||||
#: src/pv/display.c:738 src/pv/display.c:752
|
||||
msgid "b/s"
|
||||
msgstr ""
|
||||
|
||||
#: src/pv/display.c:742 src/pv/display.c:757
|
||||
msgid "/s"
|
||||
msgstr ""
|
||||
|
||||
#: src/pv/display.c:742 src/pv/display.c:758
|
||||
msgid "B/s"
|
||||
msgstr ""
|
||||
|
||||
#: src/pv/display.c:793 src/pv/display.c:798 src/pv/display.c:860
|
||||
msgid "ETA"
|
||||
msgstr ""
|
||||
|
||||
#: src/pv/watchpid.c:81 src/pv/watchpid.c:95 src/pv/watchpid.c:106
|
||||
#: src/pv/watchpid.c:87 src/pv/watchpid.c:101 src/pv/watchpid.c:112
|
||||
#: src/pv/watchpid.c:170 src/pv/watchpid.c:180 src/pv/watchpid.c:194
|
||||
msgid "fd"
|
||||
msgstr ""
|
||||
|
||||
#: src/pv/watchpid.c:109 src/pv/watchpid.c:197
|
||||
#: src/pv/watchpid.c:115 src/pv/watchpid.c:197
|
||||
msgid "not a regular file or block device"
|
||||
msgstr ""
|
||||
|
||||
#: src/main/version.c:17
|
||||
#, c-format
|
||||
msgid "%s %s - Copyright %s %s"
|
||||
#: src/pv/state.c:31
|
||||
msgid "history structure allocation failed"
|
||||
msgstr ""
|
||||
|
||||
#: src/main/version.c:20
|
||||
#, c-format
|
||||
msgid "Web site: %s"
|
||||
#: src/pv/state.c:61
|
||||
msgid "none"
|
||||
msgstr ""
|
||||
|
||||
#: src/main/version.c:23
|
||||
msgid ""
|
||||
"This program is free software, and is being distributed under the\n"
|
||||
"terms of the Artistic License 2.0."
|
||||
#: src/pv/display.c:163
|
||||
msgid "yzafpnum kMGTPEZY"
|
||||
msgstr ""
|
||||
|
||||
#: src/main/version.c:28
|
||||
msgid ""
|
||||
"This program is distributed in the hope that it will be useful,\n"
|
||||
"but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
|
||||
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
|
||||
#: src/pv/display.c:168
|
||||
msgid "yzafpnum KMGTPEZY"
|
||||
msgstr ""
|
||||
|
||||
#: src/pv/display.c:719
|
||||
msgid "b"
|
||||
msgstr ""
|
||||
|
||||
#: src/pv/display.c:784 src/pv/display.c:798
|
||||
msgid "b/s"
|
||||
msgstr ""
|
||||
|
||||
#: src/pv/display.c:788 src/pv/display.c:803
|
||||
msgid "/s"
|
||||
msgstr ""
|
||||
|
||||
#: src/pv/display.c:788 src/pv/display.c:804
|
||||
msgid "B/s"
|
||||
msgstr ""
|
||||
|
||||
#: src/pv/display.c:841 src/pv/display.c:848 src/pv/display.c:912
|
||||
msgid "ETA"
|
||||
msgstr ""
|
||||
|
||||
#: src/main/version.c:24
|
||||
msgid "License: Artistic v2.0 <https://opensource.org/license/artistic-2-0/>"
|
||||
msgstr ""
|
||||
|
||||
#: src/main/version.c:27
|
||||
msgid "This is free software: you are free to change and redistribute it."
|
||||
msgstr ""
|
||||
|
||||
#: src/main/version.c:29
|
||||
msgid "There is NO WARRANTY, to the extent permitted by law."
|
||||
msgstr ""
|
||||
|
||||
#. Project web site link
|
||||
#: src/main/version.c:31
|
||||
msgid "Project web site"
|
||||
msgstr ""
|
||||
|
||||
#: src/main/remote.c:223
|
||||
msgid "message not received"
|
||||
msgstr ""
|
||||
|
||||
#: src/main/remote.c:330
|
||||
msgid "IPC not supported on this system"
|
||||
msgstr ""
|
||||
|
||||
#: src/main/help.c:31
|
||||
@@ -325,127 +327,127 @@ msgid "stop after --size bytes have been transferred"
|
||||
msgstr ""
|
||||
|
||||
#: src/main/help.c:95
|
||||
msgid "PID"
|
||||
msgid "flush cache to disk after every write"
|
||||
msgstr ""
|
||||
|
||||
#: src/main/help.c:96
|
||||
msgid "update settings of process PID"
|
||||
#: src/main/help.c:97
|
||||
msgid "use direct I/O to bypass cache"
|
||||
msgstr ""
|
||||
|
||||
#: src/main/help.c:99
|
||||
msgid "FILE"
|
||||
msgid "PID"
|
||||
msgstr ""
|
||||
|
||||
#: src/main/help.c:100
|
||||
msgid "save process ID in FILE"
|
||||
msgstr ""
|
||||
|
||||
#: src/main/help.c:102
|
||||
msgid "PID[:FD]"
|
||||
msgid "update settings of process PID"
|
||||
msgstr ""
|
||||
|
||||
#: src/main/help.c:103
|
||||
msgid "watch file FD opened by process PID"
|
||||
msgid "FILE"
|
||||
msgstr ""
|
||||
|
||||
#: src/main/help.c:104
|
||||
msgid "save process ID in FILE"
|
||||
msgstr ""
|
||||
|
||||
#: src/main/help.c:106
|
||||
msgid "PID[:FD]"
|
||||
msgstr ""
|
||||
|
||||
#: src/main/help.c:107
|
||||
msgid "watch file FD opened by process PID"
|
||||
msgstr ""
|
||||
|
||||
#: src/main/help.c:110
|
||||
msgid "show this help and exit"
|
||||
msgstr ""
|
||||
|
||||
#: src/main/help.c:108
|
||||
#: src/main/help.c:112
|
||||
msgid "show version information and exit"
|
||||
msgstr ""
|
||||
|
||||
#: src/main/help.c:114
|
||||
#: src/main/help.c:119
|
||||
#, c-format
|
||||
msgid "Usage: %s [OPTION] [FILE]..."
|
||||
msgstr ""
|
||||
|
||||
#: src/main/help.c:117
|
||||
#: src/main/help.c:122
|
||||
msgid ""
|
||||
"Concatenate FILE(s), or standard input, to standard output,\n"
|
||||
"with monitoring."
|
||||
msgstr ""
|
||||
|
||||
#: src/main/help.c:212
|
||||
#: src/main/help.c:215
|
||||
msgid ""
|
||||
"Debugging is enabled; export the DEBUG environment variable to define the\n"
|
||||
"output filename.\n"
|
||||
msgstr ""
|
||||
|
||||
#: src/main/help.c:216
|
||||
#: src/main/help.c:219
|
||||
#, c-format
|
||||
msgid "Please report any bugs to %s."
|
||||
msgstr ""
|
||||
|
||||
#: src/main/main.c:74
|
||||
#: src/main/main.c:76
|
||||
msgid "state allocation failed"
|
||||
msgstr ""
|
||||
|
||||
#: src/main/main.c:248
|
||||
#: src/main/main.c:252
|
||||
msgid "failed to read terminal attributes"
|
||||
msgstr ""
|
||||
|
||||
#: src/main/remote.c:221
|
||||
msgid "message not received"
|
||||
msgstr ""
|
||||
|
||||
#: src/main/remote.c:328
|
||||
msgid "IPC not supported on this system"
|
||||
msgstr ""
|
||||
|
||||
#: src/main/options.c:102
|
||||
#: src/main/options.c:106
|
||||
msgid "option structure allocation failed"
|
||||
msgstr ""
|
||||
|
||||
#: src/main/options.c:116
|
||||
#: src/main/options.c:120
|
||||
msgid "option structure argv allocation failed"
|
||||
msgstr ""
|
||||
|
||||
#: src/main/options.c:160
|
||||
#: src/main/options.c:165
|
||||
msgid "integer argument expected"
|
||||
msgstr ""
|
||||
|
||||
#: src/main/options.c:171
|
||||
#: src/main/options.c:176
|
||||
msgid "numeric argument expected"
|
||||
msgstr ""
|
||||
|
||||
#: src/main/options.c:182
|
||||
#: src/main/options.c:187
|
||||
msgid "process ID or pid:fd pair expected"
|
||||
msgstr ""
|
||||
|
||||
#: src/main/options.c:189
|
||||
#: src/main/options.c:194
|
||||
msgid "invalid process ID"
|
||||
msgstr ""
|
||||
|
||||
#: src/main/options.c:355
|
||||
#: src/main/options.c:366
|
||||
#, c-format
|
||||
msgid "Try `%s --help' for more information."
|
||||
msgstr ""
|
||||
|
||||
#: src/main/options.c:359
|
||||
#: src/main/options.c:370
|
||||
#, c-format
|
||||
msgid "Try `%s -h' for more information."
|
||||
msgstr ""
|
||||
|
||||
#: src/main/options.c:375
|
||||
#: src/main/options.c:386
|
||||
msgid ""
|
||||
"cannot use line mode or transfer modifier options when watching file "
|
||||
"descriptors"
|
||||
msgstr ""
|
||||
|
||||
#: src/main/options.c:383
|
||||
#: src/main/options.c:394
|
||||
msgid "cannot use cursor positioning when watching file descriptors"
|
||||
msgstr ""
|
||||
|
||||
#: src/main/options.c:391
|
||||
#: src/main/options.c:402
|
||||
msgid "cannot use remote control when watching file descriptors"
|
||||
msgstr ""
|
||||
|
||||
#: src/main/options.c:399
|
||||
#: src/main/options.c:410
|
||||
msgid "cannot transfer files when watching file descriptors"
|
||||
msgstr ""
|
||||
|
||||
#: src/main/options.c:407
|
||||
#: src/main/options.c:418
|
||||
msgid "not available on systems without /proc/self/fdinfo"
|
||||
msgstr ""
|
||||
|
||||
+24
-37
@@ -9,8 +9,14 @@
|
||||
* However, some OSes (FreeBSD and MacOS X so far) don't allow locking of a
|
||||
* terminal, so we try to use a lockfile if terminal locking doesn't work,
|
||||
* and finally abort if even that is unavailable.
|
||||
*
|
||||
* Copyright 2002-2008, 2010, 2012-2015, 2017, 2021, 2023 Andrew Wood
|
||||
*
|
||||
* Distributed under the Artistic License v2.0; see `doc/COPYING'.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "pv.h"
|
||||
#include "pv-internal.h"
|
||||
|
||||
#include <stdio.h>
|
||||
@@ -39,7 +45,7 @@
|
||||
* Write the given buffer to the given file descriptor, retrying until all
|
||||
* bytes have been written or an error has occurred.
|
||||
*/
|
||||
static void write_retry(int fd, const char *buf, size_t count)
|
||||
void pv_write_retry(int fd, const char *buf, size_t count)
|
||||
{
|
||||
while (count > 0) {
|
||||
ssize_t nwritten;
|
||||
@@ -96,18 +102,11 @@ static void pv_crs_open_lockfile(pvstate_t state, int fd)
|
||||
if (!tmpdir)
|
||||
tmpdir = "/tmp";
|
||||
|
||||
memset(state->crs_lock_file, 0, sizeof(state->crs_lock_file));
|
||||
#ifdef HAVE_SNPRINTF
|
||||
(void) snprintf(state->crs_lock_file,
|
||||
sizeof(state->crs_lock_file) - 1,
|
||||
"%s/pv-%s-%i.lock", tmpdir, basename(ttydev),
|
||||
(int) geteuid());
|
||||
#else
|
||||
(void) sprintf(state->crs_lock_file,
|
||||
"%.*s/pv-%8s-%i.lock",
|
||||
sizeof(state->crs_lock_file) - 64, tmpdir,
|
||||
basename(ttydev), (int) geteuid());
|
||||
#endif
|
||||
memset(state->crs_lock_file, 0, PV_SIZEOF_CRS_LOCK_FILE);
|
||||
(void) pv_snprintf(state->crs_lock_file,
|
||||
PV_SIZEOF_CRS_LOCK_FILE,
|
||||
"%s/pv-%s-%i.lock", tmpdir, basename(ttydev),
|
||||
(int) geteuid());
|
||||
|
||||
/*
|
||||
* Pawel Piatek - not everyone has O_NOFOLLOW, e.g. AIX doesn't
|
||||
@@ -252,7 +251,7 @@ static int pv_crs_get_ypos(int terminalfd)
|
||||
debug("%s: %s", "tcsetattr (1) failed", strerror(errno));
|
||||
}
|
||||
|
||||
write_retry(terminalfd, "\033[6n", 4);
|
||||
pv_write_retry(terminalfd, "\033[6n", 4);
|
||||
|
||||
memset(cpr, 0, sizeof(cpr));
|
||||
|
||||
@@ -437,7 +436,7 @@ void pv_crs_init(pvstate_t state)
|
||||
* initial ypos.
|
||||
*/
|
||||
if (state->crs_y_start > 0)
|
||||
write_retry(STDERR_FILENO, "\n", 1);
|
||||
pv_write_retry(STDERR_FILENO, "\n", 1);
|
||||
pv_crs_unlock(state, fd);
|
||||
|
||||
if (state->crs_y_start < 1)
|
||||
@@ -498,7 +497,7 @@ void pv_crs_reinit(pvstate_t state)
|
||||
* Output a single-line update, moving the cursor to the correct position to
|
||||
* do so.
|
||||
*/
|
||||
void pv_crs_update(pvstate_t state, char *str)
|
||||
void pv_crs_update(pvstate_t state, const char *str)
|
||||
{
|
||||
char pos[32];
|
||||
int y;
|
||||
@@ -551,15 +550,11 @@ void pv_crs_update(pvstate_t state, char *str)
|
||||
pv_crs_lock(state, STDERR_FILENO);
|
||||
|
||||
memset(pos, 0, sizeof(pos));
|
||||
# ifdef HAVE_SNPRINTF
|
||||
(void) snprintf(pos, sizeof(pos) - 1, "\033[%u;1H",
|
||||
state->height);
|
||||
# else
|
||||
(void) sprintf(pos, "\033[%u;1H", state->height);
|
||||
# endif
|
||||
write_retry(STDERR_FILENO, pos, strlen(pos));
|
||||
(void) pv_snprintf(pos, sizeof(pos), "\033[%u;1H",
|
||||
state->height);
|
||||
pv_write_retry(STDERR_FILENO, pos, strlen(pos));
|
||||
for (; offs > 0; offs--) {
|
||||
write_retry(STDERR_FILENO, "\n", 1);
|
||||
pv_write_retry(STDERR_FILENO, "\n", 1);
|
||||
}
|
||||
|
||||
pv_crs_unlock(state, STDERR_FILENO);
|
||||
@@ -580,16 +575,12 @@ void pv_crs_update(pvstate_t state, char *str)
|
||||
y = 1;
|
||||
|
||||
memset(pos, 0, sizeof(pos));
|
||||
#ifdef HAVE_SNPRINTF
|
||||
(void) snprintf(pos, sizeof(pos) - 1, "\033[%d;1H", y);
|
||||
#else
|
||||
(void) sprintf(pos, "\033[%d;1H", y);
|
||||
#endif
|
||||
(void) pv_snprintf(pos, sizeof(pos), "\033[%d;1H", y);
|
||||
|
||||
pv_crs_lock(state, STDERR_FILENO);
|
||||
|
||||
write_retry(STDERR_FILENO, pos, strlen(pos));
|
||||
write_retry(STDERR_FILENO, str, strlen(str));
|
||||
pv_write_retry(STDERR_FILENO, pos, strlen(pos));
|
||||
pv_write_retry(STDERR_FILENO, str, strlen(str));
|
||||
|
||||
pv_crs_unlock(state, STDERR_FILENO);
|
||||
}
|
||||
@@ -622,15 +613,11 @@ void pv_crs_fini(pvstate_t state)
|
||||
y = 1;
|
||||
|
||||
memset(pos, 0, sizeof(pos));
|
||||
#ifdef HAVE_SNPRINTF
|
||||
(void) snprintf(pos, sizeof(pos) - 1, "\033[%u;1H\n", y);
|
||||
#else
|
||||
(void) sprintf(pos, "\033[%u;1H\n", y);
|
||||
#endif
|
||||
(void) pv_snprintf(pos, sizeof(pos), "\033[%u;1H\n", y);
|
||||
|
||||
pv_crs_lock(state, STDERR_FILENO);
|
||||
|
||||
write_retry(STDERR_FILENO, pos, strlen(pos));
|
||||
pv_write_retry(STDERR_FILENO, pos, strlen(pos));
|
||||
|
||||
#ifdef HAVE_IPC
|
||||
pv_crs_ipccount(state);
|
||||
|
||||
+154
-88
@@ -1,7 +1,13 @@
|
||||
/*
|
||||
* Display functions.
|
||||
*
|
||||
* Copyright 2002-2008, 2010, 2012-2015, 2017, 2021, 2023 Andrew Wood
|
||||
*
|
||||
* Distributed under the Artistic License v2.0; see `doc/COPYING'.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "pv.h"
|
||||
#include "pv-internal.h"
|
||||
|
||||
#include <stdio.h>
|
||||
@@ -12,8 +18,14 @@
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <termios.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#ifdef HAVE_TERMIOS_H
|
||||
# include <termios.h>
|
||||
#endif
|
||||
|
||||
#ifdef GWINSZ_IN_SYS_IOCTL
|
||||
# include <sys/ioctl.h>
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
@@ -171,9 +183,17 @@ static void pv__si_prefix(long double *value, char *prefix,
|
||||
|
||||
/*
|
||||
* Force an empty prefix if the value is zero to avoid "0yB".
|
||||
*
|
||||
* See below's "is_bytes" check for the reason we add another space
|
||||
* in bytes mode.
|
||||
*/
|
||||
if (0.0 == *value)
|
||||
if (0.0 == *value) {
|
||||
if (is_bytes) {
|
||||
prefix[1] = ' ';
|
||||
prefix[2] = 0;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
cutoff = ratio * 0.97;
|
||||
|
||||
@@ -187,8 +207,13 @@ static void pv__si_prefix(long double *value, char *prefix,
|
||||
prefix[0] = *i;
|
||||
}
|
||||
|
||||
if (is_bytes && prefix[0] != ' ') {
|
||||
prefix[1] = 'i';
|
||||
/*
|
||||
* Byte prefixes are of the form "KiB" rather than "KB", so that's
|
||||
* two characters, not one - meaning that for just "B", the prefix
|
||||
* is two spaces, not one.
|
||||
*/
|
||||
if (is_bytes) {
|
||||
prefix[1] = (prefix[0] == ' ' ? ' ' : 'i');
|
||||
prefix[2] = 0;
|
||||
}
|
||||
}
|
||||
@@ -210,11 +235,13 @@ static void pv__sizestr(char *buffer, int bufsize, char *format,
|
||||
char *suffix_bytes, int is_bytes)
|
||||
{
|
||||
char sizestr_buffer[256];
|
||||
char si_prefix[8] = " ";
|
||||
char si_prefix[8];
|
||||
long double divider;
|
||||
long double display_amount;
|
||||
char *suffix;
|
||||
|
||||
(void) pv_snprintf(si_prefix, sizeof(si_prefix), "%s", " ");
|
||||
|
||||
if (is_bytes) {
|
||||
suffix = suffix_bytes;
|
||||
divider = 1024.0;
|
||||
@@ -233,8 +260,9 @@ static void pv__sizestr(char *buffer, int bufsize, char *format,
|
||||
|
||||
/* Fix for display of "1.01e+03" instead of "1010" */
|
||||
if (display_amount > 99.9) {
|
||||
sprintf(sizestr_buffer, "%4ld%.2s%.16s",
|
||||
(long) display_amount, si_prefix, suffix);
|
||||
(void) pv_snprintf(sizestr_buffer, sizeof(sizestr_buffer),
|
||||
"%4ld%.2s%.16s", (long) display_amount,
|
||||
si_prefix, suffix);
|
||||
} else {
|
||||
/*
|
||||
* AIX blows up with %4.3Lg%.2s%.16s for some reason, so we
|
||||
@@ -242,16 +270,14 @@ static void pv__sizestr(char *buffer, int bufsize, char *format,
|
||||
*/
|
||||
char str_disp[64];
|
||||
/* # to get 13.0GB instead of 13GB (#1477) */
|
||||
sprintf(str_disp, "%#4.3Lg", display_amount);
|
||||
sprintf(sizestr_buffer, "%s%.2s%.16s",
|
||||
str_disp, si_prefix, suffix);
|
||||
(void) pv_snprintf(str_disp, sizeof(str_disp), "%#4.3Lg",
|
||||
display_amount);
|
||||
(void) pv_snprintf(sizestr_buffer, sizeof(sizestr_buffer),
|
||||
"%s%.2s%.16s", str_disp, si_prefix,
|
||||
suffix);
|
||||
}
|
||||
|
||||
#ifdef HAVE_SNPRINTF
|
||||
snprintf(buffer, bufsize, format, sizestr_buffer);
|
||||
#else
|
||||
sprintf(buffer, format, sizestr_buffer);
|
||||
#endif
|
||||
(void) pv_snprintf(buffer, bufsize, format, sizestr_buffer);
|
||||
}
|
||||
|
||||
|
||||
@@ -275,10 +301,13 @@ static void pv__format_init(pvstate_t state)
|
||||
state->str_average_rate[0] = 0;
|
||||
state->str_progress[0] = 0;
|
||||
state->str_eta[0] = 0;
|
||||
memset(state->format, 0, sizeof(state->format));
|
||||
memset(state->format, 0,
|
||||
PV_FORMAT_ARRAY_MAX * sizeof(state->format[0]));
|
||||
|
||||
if (state->name) {
|
||||
sprintf(state->str_name, "%9.500s:", state->name);
|
||||
(void) pv_snprintf(state->str_name,
|
||||
PV_SIZEOF_STR_NAME, "%9.500s:",
|
||||
state->name);
|
||||
}
|
||||
|
||||
formatstr =
|
||||
@@ -351,10 +380,8 @@ static void pv__format_init(pvstate_t state)
|
||||
state->format[segment].string =
|
||||
state->str_lastoutput;
|
||||
state->format[segment].length = 0;
|
||||
if (num > sizeof(state->lastoutput_buffer))
|
||||
num =
|
||||
sizeof
|
||||
(state->lastoutput_buffer);
|
||||
if (num > PV_SIZEOF_LASTOUTPUT_BUFFER)
|
||||
num = PV_SIZEOF_LASTOUTPUT_BUFFER;
|
||||
if (num < 1)
|
||||
num = 1;
|
||||
state->lastoutput_length = num;
|
||||
@@ -507,9 +534,10 @@ static void update_history_avg_rate(pvstate_t state, long long total_bytes,
|
||||
* If "total_bytes" is negative, then free all allocated memory and return
|
||||
* NULL.
|
||||
*/
|
||||
static char *pv__format(pvstate_t state,
|
||||
long double elapsed_sec,
|
||||
long long bytes_since_last, long long total_bytes)
|
||||
static const char *pv__format(pvstate_t state,
|
||||
long double elapsed_sec,
|
||||
long long bytes_since_last,
|
||||
long long total_bytes)
|
||||
{
|
||||
long double time_since_last, rate, average_rate;
|
||||
long eta;
|
||||
@@ -637,21 +665,29 @@ static char *pv__format(pvstate_t state,
|
||||
numericprefix[0] = 0;
|
||||
|
||||
if ((state->components_used & PV_DISPLAY_TIMER) != 0)
|
||||
sprintf(numericprefix, "%.4Lf ", elapsed_sec);
|
||||
(void) pv_snprintf(numericprefix,
|
||||
sizeof(numericprefix), "%.4Lf ",
|
||||
elapsed_sec);
|
||||
|
||||
if ((state->components_used & PV_DISPLAY_BYTES) != 0) {
|
||||
if (state->bits) {
|
||||
sprintf(state->display_buffer,
|
||||
"%.99s%lld\n", numericprefix,
|
||||
8 * total_bytes);
|
||||
(void) pv_snprintf(state->display_buffer,
|
||||
state->display_buffer_size,
|
||||
"%.99s%lld\n",
|
||||
numericprefix,
|
||||
8 * total_bytes);
|
||||
} else {
|
||||
sprintf(state->display_buffer,
|
||||
"%.99s%lld\n", numericprefix,
|
||||
total_bytes);
|
||||
(void) pv_snprintf(state->display_buffer,
|
||||
state->display_buffer_size,
|
||||
"%.99s%lld\n",
|
||||
numericprefix,
|
||||
total_bytes);
|
||||
}
|
||||
} else {
|
||||
sprintf(state->display_buffer, "%.99s%ld\n",
|
||||
numericprefix, state->percentage);
|
||||
(void) pv_snprintf(state->display_buffer,
|
||||
state->display_buffer_size,
|
||||
"%.99s%ld\n", numericprefix,
|
||||
state->percentage);
|
||||
}
|
||||
|
||||
return state->display_buffer;
|
||||
@@ -678,12 +714,12 @@ static char *pv__format(pvstate_t state,
|
||||
if ((state->components_used & PV_DISPLAY_BYTES) != 0) {
|
||||
if (state->bits && !state->linemode) {
|
||||
pv__sizestr(state->str_transferred,
|
||||
sizeof(state->str_transferred), "%s",
|
||||
PV_SIZEOF_STR_TRANSFERRED, "%s",
|
||||
(long double) total_bytes * 8, "",
|
||||
_("b"), 1);
|
||||
} else {
|
||||
pv__sizestr(state->str_transferred,
|
||||
sizeof(state->str_transferred), "%s",
|
||||
PV_SIZEOF_STR_TRANSFERRED, "%s",
|
||||
(long double) total_bytes, "", _("B"),
|
||||
state->linemode ? 0 : 1);
|
||||
}
|
||||
@@ -692,13 +728,18 @@ static char *pv__format(pvstate_t state,
|
||||
/* Transfer buffer percentage - set up the display string. */
|
||||
if ((state->components_used & PV_DISPLAY_BUFPERCENT) != 0) {
|
||||
if (state->buffer_size > 0)
|
||||
sprintf(state->str_bufpercent, "{%3ld%%}",
|
||||
pv__calc_percentage(state->read_position -
|
||||
state->write_position,
|
||||
state->buffer_size));
|
||||
(void) pv_snprintf(state->str_bufpercent,
|
||||
PV_SIZEOF_STR_BUFPERCENT,
|
||||
"{%3ld%%}",
|
||||
pv__calc_percentage
|
||||
(state->read_position -
|
||||
state->write_position,
|
||||
state->buffer_size));
|
||||
#ifdef HAVE_SPLICE
|
||||
if (state->splice_used)
|
||||
strcpy(state->str_bufpercent, "{----}");
|
||||
(void) pv_snprintf(state->str_bufpercent,
|
||||
PV_SIZEOF_STR_BUFPERCENT,
|
||||
"{%s}", "----");
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -717,16 +758,21 @@ static char *pv__format(pvstate_t state,
|
||||
* well as hours, minutes, and seconds.
|
||||
*/
|
||||
if (elapsed_sec > (long double) 86400.0L) {
|
||||
sprintf(state->str_timer, "%ld:%02ld:%02ld:%02ld",
|
||||
((long) elapsed_sec) / 86400,
|
||||
(((long) elapsed_sec) / 3600) % 24,
|
||||
(((long) elapsed_sec) / 60) % 60,
|
||||
((long) elapsed_sec) % 60);
|
||||
(void) pv_snprintf(state->str_timer,
|
||||
PV_SIZEOF_STR_TIMER,
|
||||
"%ld:%02ld:%02ld:%02ld",
|
||||
((long) elapsed_sec) / 86400,
|
||||
(((long) elapsed_sec) / 3600) %
|
||||
24,
|
||||
(((long) elapsed_sec) / 60) %
|
||||
60, ((long) elapsed_sec) % 60);
|
||||
} else {
|
||||
sprintf(state->str_timer, "%ld:%02ld:%02ld",
|
||||
((long) elapsed_sec) / 3600,
|
||||
(((long) elapsed_sec) / 60) % 60,
|
||||
((long) elapsed_sec) % 60);
|
||||
(void) pv_snprintf(state->str_timer,
|
||||
PV_SIZEOF_STR_TIMER,
|
||||
"%ld:%02ld:%02ld",
|
||||
((long) elapsed_sec) / 3600,
|
||||
(((long) elapsed_sec) / 60) %
|
||||
60, ((long) elapsed_sec) % 60);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -734,11 +780,11 @@ static char *pv__format(pvstate_t state,
|
||||
if ((state->components_used & PV_DISPLAY_RATE) != 0) {
|
||||
if (state->bits && !state->linemode) {
|
||||
pv__sizestr(state->str_rate,
|
||||
sizeof(state->str_rate), "[%s]",
|
||||
PV_SIZEOF_STR_RATE, "[%s]",
|
||||
8 * rate, "", _("b/s"), 1);
|
||||
} else {
|
||||
pv__sizestr(state->str_rate,
|
||||
sizeof(state->str_rate), "[%s]", rate,
|
||||
PV_SIZEOF_STR_RATE, "[%s]", rate,
|
||||
_("/s"), _("B/s"),
|
||||
state->linemode ? 0 : 1);
|
||||
}
|
||||
@@ -748,12 +794,12 @@ static char *pv__format(pvstate_t state,
|
||||
if ((state->components_used & PV_DISPLAY_AVERAGERATE) != 0) {
|
||||
if (state->bits && !state->linemode) {
|
||||
pv__sizestr(state->str_average_rate,
|
||||
sizeof(state->str_average_rate),
|
||||
PV_SIZEOF_STR_AVERAGE_RATE,
|
||||
"[%s]", 8 * average_rate, "", _("b/s"),
|
||||
1);
|
||||
} else {
|
||||
pv__sizestr(state->str_average_rate,
|
||||
sizeof(state->str_average_rate),
|
||||
PV_SIZEOF_STR_AVERAGE_RATE,
|
||||
"[%s]", average_rate, _("/s"),
|
||||
_("B/s"), state->linemode ? 0 : 1);
|
||||
}
|
||||
@@ -789,14 +835,18 @@ static char *pv__format(pvstate_t state,
|
||||
* well as hours, minutes, and seconds.
|
||||
*/
|
||||
if (eta > 86400L) {
|
||||
sprintf(state->str_eta,
|
||||
"%.16s %ld:%02ld:%02ld:%02ld", _("ETA"),
|
||||
eta / 86400, (eta / 3600) % 24,
|
||||
(eta / 60) % 60, eta % 60);
|
||||
(void) pv_snprintf(state->str_eta,
|
||||
PV_SIZEOF_STR_ETA,
|
||||
"%.16s %ld:%02ld:%02ld:%02ld",
|
||||
_("ETA"), eta / 86400,
|
||||
(eta / 3600) % 24,
|
||||
(eta / 60) % 60, eta % 60);
|
||||
} else {
|
||||
sprintf(state->str_eta, "%.16s %ld:%02ld:%02ld",
|
||||
_("ETA"), eta / 3600, (eta / 60) % 60,
|
||||
eta % 60);
|
||||
(void) pv_snprintf(state->str_eta,
|
||||
PV_SIZEOF_STR_ETA,
|
||||
"%.16s %ld:%02ld:%02ld",
|
||||
_("ETA"), eta / 3600,
|
||||
(eta / 60) % 60, eta % 60);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -805,8 +855,8 @@ static char *pv__format(pvstate_t state,
|
||||
*/
|
||||
if (bytes_since_last < 0) {
|
||||
unsigned int i;
|
||||
for (i = 0; i < sizeof(state->str_eta)
|
||||
&& state->str_eta[i] != 0; i++) {
|
||||
for (i = 0; i < PV_SIZEOF_STR_ETA
|
||||
&& state->str_eta[i] != '\0'; i++) {
|
||||
state->str_eta[i] = ' ';
|
||||
}
|
||||
}
|
||||
@@ -857,18 +907,20 @@ static char *pv__format(pvstate_t state,
|
||||
* by time functions. */
|
||||
struct tm time = *time_ptr;
|
||||
|
||||
sprintf(state->str_fineta, "%.16s ", _("ETA"));
|
||||
(void) pv_snprintf(state->str_fineta,
|
||||
PV_SIZEOF_STR_FINETA,
|
||||
"%.16s ", _("ETA"));
|
||||
strftime(state->str_fineta +
|
||||
strlen(state->str_fineta),
|
||||
sizeof(state->str_fineta) - 1 -
|
||||
strlen(state->str_fineta),
|
||||
time_format, &time);
|
||||
PV_SIZEOF_STR_FINETA - 1 -
|
||||
strlen(state->str_fineta), time_format,
|
||||
&time);
|
||||
}
|
||||
|
||||
if (!show_eta) {
|
||||
unsigned int i;
|
||||
for (i = 0; i < sizeof(state->str_fineta)
|
||||
&& state->str_fineta[i] != 0; i++) {
|
||||
for (i = 0; i < PV_SIZEOF_STR_FINETA
|
||||
&& state->str_fineta[i] != '\0'; i++) {
|
||||
state->str_fineta[i] = ' ';
|
||||
}
|
||||
}
|
||||
@@ -908,7 +960,8 @@ static char *pv__format(pvstate_t state,
|
||||
state->percentage = 0;
|
||||
if (state->percentage > 100000)
|
||||
state->percentage = 100000;
|
||||
sprintf(pct, "%2ld%%", state->percentage);
|
||||
(void) pv_snprintf(pct, sizeof(pct), "%2ld%%",
|
||||
state->percentage);
|
||||
|
||||
available_width =
|
||||
state->width - static_portion_size -
|
||||
@@ -918,26 +971,32 @@ static char *pv__format(pvstate_t state,
|
||||
available_width = 0;
|
||||
|
||||
if (available_width >
|
||||
(int) (sizeof(state->str_progress)) - 16)
|
||||
(int) (PV_SIZEOF_STR_PROGRESS) - 16)
|
||||
available_width =
|
||||
sizeof(state->str_progress) - 16;
|
||||
PV_SIZEOF_STR_PROGRESS - 16;
|
||||
|
||||
for (i = 0;
|
||||
i <
|
||||
(available_width * state->percentage) / 100 -
|
||||
1; i++) {
|
||||
if (i < available_width)
|
||||
strcat(state->str_progress, "=");
|
||||
pv_strlcat(state->str_progress,
|
||||
"=",
|
||||
PV_SIZEOF_STR_PROGRESS);
|
||||
}
|
||||
if (i < available_width) {
|
||||
strcat(state->str_progress, ">");
|
||||
pv_strlcat(state->str_progress, ">",
|
||||
PV_SIZEOF_STR_PROGRESS);
|
||||
i++;
|
||||
}
|
||||
for (; i < available_width; i++) {
|
||||
strcat(state->str_progress, " ");
|
||||
pv_strlcat(state->str_progress, " ",
|
||||
PV_SIZEOF_STR_PROGRESS);
|
||||
}
|
||||
strcat(state->str_progress, "] ");
|
||||
strcat(state->str_progress, pct);
|
||||
pv_strlcat(state->str_progress, "] ",
|
||||
PV_SIZEOF_STR_PROGRESS);
|
||||
pv_strlcat(state->str_progress, pct,
|
||||
PV_SIZEOF_STR_PROGRESS);
|
||||
} else {
|
||||
int p = state->percentage;
|
||||
|
||||
@@ -948,9 +1007,9 @@ static char *pv__format(pvstate_t state,
|
||||
available_width = 0;
|
||||
|
||||
if (available_width >
|
||||
(int) (sizeof(state->str_progress)) - 16)
|
||||
(int) (PV_SIZEOF_STR_PROGRESS) - 16)
|
||||
available_width =
|
||||
sizeof(state->str_progress) - 16;
|
||||
PV_SIZEOF_STR_PROGRESS - 16;
|
||||
|
||||
debug("available_width: %d", available_width);
|
||||
|
||||
@@ -958,13 +1017,18 @@ static char *pv__format(pvstate_t state,
|
||||
p = 200 - p;
|
||||
for (i = 0; i < (available_width * p) / 100; i++) {
|
||||
if (i < available_width)
|
||||
strcat(state->str_progress, " ");
|
||||
pv_strlcat(state->str_progress,
|
||||
" ",
|
||||
PV_SIZEOF_STR_PROGRESS);
|
||||
}
|
||||
strcat(state->str_progress, "<=>");
|
||||
pv_strlcat(state->str_progress, "<=>",
|
||||
PV_SIZEOF_STR_PROGRESS);
|
||||
for (; i < available_width; i++) {
|
||||
strcat(state->str_progress, " ");
|
||||
pv_strlcat(state->str_progress, " ",
|
||||
PV_SIZEOF_STR_PROGRESS);
|
||||
}
|
||||
strcat(state->str_progress, "]");
|
||||
pv_strlcat(state->str_progress, "]",
|
||||
PV_SIZEOF_STR_PROGRESS);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1031,7 +1095,8 @@ static char *pv__format(pvstate_t state,
|
||||
while (--spaces_to_add >= 0) {
|
||||
spaces[spaces_to_add] = ' ';
|
||||
}
|
||||
strcat(state->display_buffer, spaces);
|
||||
pv_strlcat(state->display_buffer, spaces,
|
||||
state->display_buffer_size);
|
||||
}
|
||||
state->prev_width = state->width;
|
||||
state->prev_length = output_length;
|
||||
@@ -1054,7 +1119,7 @@ static char *pv__format(pvstate_t state,
|
||||
void pv_display(pvstate_t state, long double esec, long long sl,
|
||||
long long tot)
|
||||
{
|
||||
char *display;
|
||||
const char *display;
|
||||
|
||||
if (NULL == state)
|
||||
return;
|
||||
@@ -1075,7 +1140,7 @@ void pv_display(pvstate_t state, long double esec, long long sl,
|
||||
return;
|
||||
|
||||
if (state->numeric) {
|
||||
write(STDERR_FILENO, display, strlen(display));
|
||||
pv_write_retry(STDERR_FILENO, display, strlen(display));
|
||||
} else if (state->cursor) {
|
||||
if (state->force || pv_in_foreground()) {
|
||||
pv_crs_update(state, display);
|
||||
@@ -1083,8 +1148,9 @@ void pv_display(pvstate_t state, long double esec, long long sl,
|
||||
}
|
||||
} else {
|
||||
if (state->force || pv_in_foreground()) {
|
||||
write(STDERR_FILENO, display, strlen(display));
|
||||
write(STDERR_FILENO, "\r", 1);
|
||||
pv_write_retry(STDERR_FILENO, display,
|
||||
strlen(display));
|
||||
pv_write_retry(STDERR_FILENO, "\r", 1);
|
||||
state->display_visible = true;
|
||||
}
|
||||
}
|
||||
|
||||
+37
-20
@@ -1,7 +1,13 @@
|
||||
/*
|
||||
* Functions for opening and closing files.
|
||||
*
|
||||
* Copyright 2002-2008, 2010, 2012-2015, 2017, 2021, 2023 Andrew Wood
|
||||
*
|
||||
* Distributed under the Artistic License v2.0; see `doc/COPYING'.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "pv.h"
|
||||
#include "pv-internal.h"
|
||||
|
||||
#include <stdio.h>
|
||||
@@ -31,7 +37,7 @@
|
||||
unsigned long long pv_calc_total_size(pvstate_t state)
|
||||
{
|
||||
unsigned long long total;
|
||||
struct stat64 sb;
|
||||
struct stat sb;
|
||||
int rc, i, j, fd;
|
||||
|
||||
total = 0;
|
||||
@@ -42,20 +48,20 @@ unsigned long long pv_calc_total_size(pvstate_t state)
|
||||
* No files specified - check stdin.
|
||||
*/
|
||||
if (state->input_file_count < 1) {
|
||||
if (0 == fstat64(STDIN_FILENO, &sb))
|
||||
if (0 == fstat(STDIN_FILENO, &sb))
|
||||
total = sb.st_size;
|
||||
return total;
|
||||
}
|
||||
|
||||
for (i = 0; i < state->input_file_count; i++) {
|
||||
if (0 == strcmp(state->input_files[i], "-")) {
|
||||
rc = fstat64(STDIN_FILENO, &sb);
|
||||
rc = fstat(STDIN_FILENO, &sb);
|
||||
if (rc != 0) {
|
||||
total = 0;
|
||||
return total;
|
||||
}
|
||||
} else {
|
||||
rc = stat64(state->input_files[i], &sb);
|
||||
rc = stat(state->input_files[i], &sb);
|
||||
if (0 == rc)
|
||||
rc = access(state->input_files[i], R_OK);
|
||||
}
|
||||
@@ -79,13 +85,12 @@ unsigned long long pv_calc_total_size(pvstate_t state)
|
||||
* them and seeking to the end.
|
||||
*/
|
||||
if (0 == strcmp(state->input_files[i], "-")) {
|
||||
fd = open64("/dev/stdin", O_RDONLY);
|
||||
fd = open("/dev/stdin", O_RDONLY);
|
||||
} else {
|
||||
fd = open64(state->input_files[i],
|
||||
O_RDONLY);
|
||||
fd = open(state->input_files[i], O_RDONLY);
|
||||
}
|
||||
if (fd >= 0) {
|
||||
total += lseek64(fd, 0, SEEK_END);
|
||||
total += lseek(fd, 0, SEEK_END);
|
||||
close(fd);
|
||||
} else {
|
||||
pv_error(state, "%s: %s",
|
||||
@@ -109,11 +114,11 @@ unsigned long long pv_calc_total_size(pvstate_t state)
|
||||
* and that we can seek back to the start after getting the size.
|
||||
*/
|
||||
if (total <= 0) {
|
||||
rc = fstat64(STDOUT_FILENO, &sb);
|
||||
rc = fstat(STDOUT_FILENO, &sb);
|
||||
if ((0 == rc) && S_ISBLK(sb.st_mode)
|
||||
&& (0 == (fcntl(STDOUT_FILENO, F_GETFL) & O_APPEND))) {
|
||||
total = lseek64(STDOUT_FILENO, 0, SEEK_END);
|
||||
if (lseek64(STDOUT_FILENO, 0, SEEK_SET) != 0) {
|
||||
total = lseek(STDOUT_FILENO, 0, SEEK_END);
|
||||
if (lseek(STDOUT_FILENO, 0, SEEK_SET) != 0) {
|
||||
pv_error(state, "%s: %s: %s", "(stdout)",
|
||||
_
|
||||
("failed to seek to start of output"),
|
||||
@@ -144,19 +149,19 @@ unsigned long long pv_calc_total_size(pvstate_t state)
|
||||
fd = -1;
|
||||
|
||||
if (0 == strcmp(state->input_files[i], "-")) {
|
||||
rc = fstat64(STDIN_FILENO, &sb);
|
||||
rc = fstat(STDIN_FILENO, &sb);
|
||||
if ((rc != 0) || (!S_ISREG(sb.st_mode))) {
|
||||
total = 0;
|
||||
return total;
|
||||
}
|
||||
fd = dup(STDIN_FILENO);
|
||||
} else {
|
||||
rc = stat64(state->input_files[i], &sb);
|
||||
rc = stat(state->input_files[i], &sb);
|
||||
if ((rc != 0) || (!S_ISREG(sb.st_mode))) {
|
||||
total = 0;
|
||||
return total;
|
||||
}
|
||||
fd = open64(state->input_files[i], O_RDONLY);
|
||||
fd = open(state->input_files[i], O_RDONLY);
|
||||
}
|
||||
|
||||
if (fd < 0) {
|
||||
@@ -187,7 +192,7 @@ unsigned long long pv_calc_total_size(pvstate_t state)
|
||||
}
|
||||
}
|
||||
|
||||
lseek64(fd, 0, SEEK_SET);
|
||||
lseek(fd, 0, SEEK_SET);
|
||||
close(fd);
|
||||
}
|
||||
|
||||
@@ -205,8 +210,8 @@ unsigned long long pv_calc_total_size(pvstate_t state)
|
||||
*/
|
||||
int pv_next_file(pvstate_t state, int filenum, int oldfd)
|
||||
{
|
||||
struct stat64 isb;
|
||||
struct stat64 osb;
|
||||
struct stat isb;
|
||||
struct stat osb;
|
||||
int fd, input_file_is_stdout;
|
||||
|
||||
if (oldfd > 0) {
|
||||
@@ -232,7 +237,7 @@ int pv_next_file(pvstate_t state, int filenum, int oldfd)
|
||||
if (0 == strcmp(state->input_files[filenum], "-")) {
|
||||
fd = STDIN_FILENO;
|
||||
} else {
|
||||
fd = open64(state->input_files[filenum], O_RDONLY);
|
||||
fd = open(state->input_files[filenum], O_RDONLY);
|
||||
if (fd < 0) {
|
||||
pv_error(state, "%s: %s: %s",
|
||||
_("failed to read file"),
|
||||
@@ -243,7 +248,7 @@ int pv_next_file(pvstate_t state, int filenum, int oldfd)
|
||||
}
|
||||
}
|
||||
|
||||
if (fstat64(fd, &isb)) {
|
||||
if (fstat(fd, &isb)) {
|
||||
pv_error(state, "%s: %s: %s",
|
||||
_("failed to stat file"),
|
||||
state->input_files[filenum], strerror(errno));
|
||||
@@ -252,7 +257,7 @@ int pv_next_file(pvstate_t state, int filenum, int oldfd)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (fstat64(STDOUT_FILENO, &osb)) {
|
||||
if (fstat(STDOUT_FILENO, &osb)) {
|
||||
pv_error(state, "%s: %s",
|
||||
_("failed to stat output file"), strerror(errno));
|
||||
close(fd);
|
||||
@@ -288,6 +293,18 @@ int pv_next_file(pvstate_t state, int filenum, int oldfd)
|
||||
if (0 == strcmp(state->input_files[filenum], "-")) {
|
||||
state->current_file = "(stdin)";
|
||||
}
|
||||
#ifdef O_DIRECT
|
||||
/*
|
||||
* Set or clear O_DIRECT on the file descriptor.
|
||||
*/
|
||||
fcntl(fd, F_SETFL,
|
||||
(state->direct_io ? O_DIRECT : 0) | fcntl(fd, F_GETFL));
|
||||
/*
|
||||
* We don't clear direct_io_changed here, to avoid race conditions
|
||||
* that could cause the input and output settings to differ.
|
||||
*/
|
||||
#endif /* O_DIRECT */
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
|
||||
+39
-32
@@ -1,8 +1,14 @@
|
||||
/*
|
||||
* Main program entry point - read the command line options, then perform
|
||||
* the appropriate actions.
|
||||
*
|
||||
* Copyright 2002-2008, 2010, 2012-2015, 2017, 2021, 2023 Andrew Wood
|
||||
*
|
||||
* Distributed under the Artistic License v2.0; see `doc/COPYING'.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "pv.h"
|
||||
#include "pv-internal.h"
|
||||
|
||||
#include <stdio.h>
|
||||
@@ -53,7 +59,7 @@ int pv_main_loop(pvstate_t state)
|
||||
struct timeval start_time, next_update, next_ratecheck, cur_time;
|
||||
struct timeval init_time, next_remotecheck;
|
||||
long double elapsed;
|
||||
struct stat64 sb;
|
||||
struct stat sb;
|
||||
int fd, n;
|
||||
|
||||
/*
|
||||
@@ -111,12 +117,21 @@ int pv_main_loop(pvstate_t state)
|
||||
pv_crs_fini(state);
|
||||
return state->exit_status;
|
||||
}
|
||||
#ifdef O_DIRECT
|
||||
/*
|
||||
* Set or clear O_DIRECT on the output.
|
||||
*/
|
||||
fcntl(STDOUT_FILENO, F_SETFL,
|
||||
(state->direct_io ? O_DIRECT : 0) | fcntl(STDOUT_FILENO,
|
||||
F_GETFL));
|
||||
state->direct_io_changed = false;
|
||||
#endif /* O_DIRECT */
|
||||
|
||||
/*
|
||||
* Set target buffer size if the initial file's block size can be
|
||||
* read and we weren't given a target buffer size.
|
||||
*/
|
||||
if ((0 == fstat64(fd, &sb)) && (0 == state->target_buffer_size)) {
|
||||
if ((0 == fstat(fd, &sb)) && (0 == state->target_buffer_size)) {
|
||||
unsigned long long sz;
|
||||
sz = sb.st_blksize * 32;
|
||||
if (sz > BUFFER_SIZE_MAX)
|
||||
@@ -328,7 +343,7 @@ int pv_main_loop(pvstate_t state)
|
||||
} else {
|
||||
if ((!state->numeric) && (!state->no_op)
|
||||
&& (state->display_visible))
|
||||
write(STDERR_FILENO, "\n", 1);
|
||||
pv_write_retry(STDERR_FILENO, "\n", 1);
|
||||
}
|
||||
|
||||
if (state->pv_sig_abort)
|
||||
@@ -488,7 +503,7 @@ int pv_watchfd_loop(pvstate_t state)
|
||||
}
|
||||
|
||||
if (!state->numeric)
|
||||
write(STDERR_FILENO, "\n", 1);
|
||||
pv_write_retry(STDERR_FILENO, "\n", 1);
|
||||
|
||||
if (state->pv_sig_abort)
|
||||
state->exit_status |= 32;
|
||||
@@ -543,28 +558,20 @@ int pv_watchpid_loop(pvstate_t state)
|
||||
state->format_string ? state->
|
||||
format_string : state->default_format;
|
||||
if (NULL == strstr(original_format_string, "%N")) {
|
||||
#ifdef HAVE_SNPRINTF
|
||||
snprintf(new_format_string, sizeof(new_format_string) - 1,
|
||||
#else
|
||||
sprintf(new_format_string,
|
||||
#endif
|
||||
"%%N %s", original_format_string);
|
||||
(void) pv_snprintf(new_format_string,
|
||||
sizeof(new_format_string), "%%N %s",
|
||||
original_format_string);
|
||||
} else {
|
||||
#ifdef HAVE_SNPRINTF
|
||||
snprintf(new_format_string, sizeof(new_format_string) - 1,
|
||||
#else
|
||||
sprintf(new_format_string,
|
||||
#endif
|
||||
"%s", original_format_string);
|
||||
(void) pv_snprintf(new_format_string,
|
||||
sizeof(new_format_string), "%s",
|
||||
original_format_string);
|
||||
}
|
||||
new_format_string[sizeof(new_format_string) - 1] = '\0';
|
||||
state_copy.format_string = NULL;
|
||||
#ifdef HAVE_SNPRINTF
|
||||
snprintf(state_copy.default_format,
|
||||
sizeof(state_copy.default_format) - 1,
|
||||
#else
|
||||
sprintf(state_copy.default_format,
|
||||
#endif
|
||||
"%.510s", new_format_string);
|
||||
(void) pv_snprintf(state_copy.default_format,
|
||||
PV_SIZEOF_DEFAULT_FORMAT,
|
||||
"%.510s", new_format_string);
|
||||
state_copy.default_format[PV_SIZEOF_DEFAULT_FORMAT - 1] = '\0';
|
||||
|
||||
/*
|
||||
* Get things ready for the main loop.
|
||||
@@ -728,7 +735,7 @@ int pv_watchpid_loop(pvstate_t state)
|
||||
|
||||
if (displayed_lines > 0) {
|
||||
debug("%s", "adding newline");
|
||||
write(STDERR_FILENO, "\n", 1);
|
||||
pv_write_retry(STDERR_FILENO, "\n", 1);
|
||||
}
|
||||
|
||||
debug("%s %d [%d]: %Lf / %Ld / %Ld", "fd", fd, idx,
|
||||
@@ -752,10 +759,10 @@ int pv_watchpid_loop(pvstate_t state)
|
||||
while (blank_lines > 0) {
|
||||
unsigned int x;
|
||||
if (displayed_lines > 0)
|
||||
write(STDERR_FILENO, "\n", 1);
|
||||
pv_write_retry(STDERR_FILENO, "\n", 1);
|
||||
for (x = 0; x < state->width; x++)
|
||||
write(STDERR_FILENO, " ", 1);
|
||||
write(STDERR_FILENO, "\r", 1);
|
||||
pv_write_retry(STDERR_FILENO, " ", 1);
|
||||
pv_write_retry(STDERR_FILENO, "\r", 1);
|
||||
blank_lines--;
|
||||
displayed_lines++;
|
||||
}
|
||||
@@ -763,7 +770,7 @@ int pv_watchpid_loop(pvstate_t state)
|
||||
debug("%s: %d", "displayed lines", displayed_lines);
|
||||
|
||||
while (displayed_lines > 1) {
|
||||
write(STDERR_FILENO, "\033[A", 3);
|
||||
pv_write_retry(STDERR_FILENO, "\033[A", 3);
|
||||
displayed_lines--;
|
||||
}
|
||||
}
|
||||
@@ -775,14 +782,14 @@ int pv_watchpid_loop(pvstate_t state)
|
||||
while (blank_lines > 0) {
|
||||
unsigned int x;
|
||||
for (x = 0; x < state->width; x++)
|
||||
write(STDERR_FILENO, " ", 1);
|
||||
write(STDERR_FILENO, "\r", 1);
|
||||
pv_write_retry(STDERR_FILENO, " ", 1);
|
||||
pv_write_retry(STDERR_FILENO, "\r", 1);
|
||||
blank_lines--;
|
||||
if (blank_lines > 0)
|
||||
write(STDERR_FILENO, "\n", 1);
|
||||
pv_write_retry(STDERR_FILENO, "\n", 1);
|
||||
}
|
||||
while (prev_displayed_lines > 1) {
|
||||
write(STDERR_FILENO, "\033[A", 3);
|
||||
pv_write_retry(STDERR_FILENO, "\033[A", 3);
|
||||
prev_displayed_lines--;
|
||||
}
|
||||
|
||||
|
||||
+6
-4
@@ -1,14 +1,16 @@
|
||||
/*
|
||||
* Functions for converting strings to numbers.
|
||||
*
|
||||
* Copyright 2002-2008, 2010, 2012-2015, 2017, 2021, 2023 Andrew Wood
|
||||
*
|
||||
* Distributed under the Artistic License v2.0; see `doc/COPYING'.
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
#include "pv.h"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
|
||||
/*
|
||||
* This function is used instead of the macro from <ctype.h> because
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
/*
|
||||
* Signal handling functions.
|
||||
*
|
||||
* Copyright 2002-2008, 2010, 2012-2015, 2017, 2021, 2023 Andrew Wood
|
||||
*
|
||||
* Distributed under the Artistic License v2.0; see `doc/COPYING'.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "pv.h"
|
||||
#include "pv-internal.h"
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
+22
-9
@@ -1,7 +1,13 @@
|
||||
/*
|
||||
* State management functions.
|
||||
*
|
||||
* Copyright 2002-2008, 2010, 2012-2015, 2017, 2021, 2023 Andrew Wood
|
||||
*
|
||||
* Distributed under the Artistic License v2.0; see `doc/COPYING'.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "pv.h"
|
||||
#include "pv-internal.h"
|
||||
|
||||
#include <stdio.h>
|
||||
@@ -62,7 +68,7 @@ pvstate_t pv_state_alloc(const char *program_name)
|
||||
* Get the current working directory, if possible, as a base for
|
||||
* showing relative filenames with --watchfd.
|
||||
*/
|
||||
if (NULL == getcwd(state->cwd, sizeof(state->cwd))) {
|
||||
if (NULL == getcwd(state->cwd, PV_SIZEOF_CWD - 1)) {
|
||||
/* failed - will always show full path */
|
||||
state->cwd[0] = '\0';
|
||||
}
|
||||
@@ -70,6 +76,7 @@ pvstate_t pv_state_alloc(const char *program_name)
|
||||
/* CWD is root directory - always show full path */
|
||||
state->cwd[0] = '\0';
|
||||
}
|
||||
state->cwd[PV_SIZEOF_CWD - 1] = '\0';
|
||||
|
||||
return state;
|
||||
}
|
||||
@@ -113,8 +120,8 @@ void pv_state_set_format(pvstate_t state, bool progress,
|
||||
{
|
||||
#define PV_ADDFORMAT(x,y) if (x) { \
|
||||
if (state->default_format[0] != '\0') \
|
||||
strcat(state->default_format, " "); \
|
||||
strcat(state->default_format, y); \
|
||||
pv_strlcat(state->default_format, " ", sizeof(state->default_format)); \
|
||||
pv_strlcat(state->default_format, y, sizeof(state->default_format)); \
|
||||
}
|
||||
|
||||
state->default_format[0] = '\0';
|
||||
@@ -130,12 +137,7 @@ void pv_state_set_format(pvstate_t state, bool progress,
|
||||
if (lastwritten > 0) {
|
||||
char buf[16];
|
||||
memset(buf, 0, sizeof(buf));
|
||||
#ifdef HAVE_SNPRINTF
|
||||
(void) snprintf(buf, sizeof(buf) - 1, "%%%uA",
|
||||
lastwritten);
|
||||
#else
|
||||
(void) sprintf(buf, "%%%uA", lastwritten);
|
||||
#endif
|
||||
(void) pv_snprintf(buf, sizeof(buf), "%%%uA", lastwritten);
|
||||
PV_ADDFORMAT(lastwritten > 0, buf);
|
||||
}
|
||||
|
||||
@@ -199,6 +201,17 @@ void pv_state_stop_at_size_set(pvstate_t state, bool val)
|
||||
state->stop_at_size = val;
|
||||
};
|
||||
|
||||
void pv_state_sync_after_write_set(pvstate_t state, bool val)
|
||||
{
|
||||
state->sync_after_write = val;
|
||||
};
|
||||
|
||||
void pv_state_direct_io_set(pvstate_t state, bool val)
|
||||
{
|
||||
state->direct_io = val;
|
||||
state->direct_io_changed = true;
|
||||
};
|
||||
|
||||
void pv_state_rate_limit_set(pvstate_t state, unsigned long long val)
|
||||
{
|
||||
state->rate_limit = val;
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Functions for converting strings to numbers.
|
||||
*
|
||||
* Copyright 2023 Andrew Wood
|
||||
*
|
||||
* Distributed under the Artistic License v2.0; see `doc/COPYING'.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "pv.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
/*
|
||||
* Wrapper for sprintf(), falling back to sprintf() on systems without that
|
||||
* function.
|
||||
*
|
||||
* Returns -1 if "str" or "format" are NULL or if "size" is 0.
|
||||
*
|
||||
* Otherwise, ensures that the buffer "str" is always terminated with a '\0'
|
||||
* byte, before returning whatever the system's vsnprintf() or vsprintf()
|
||||
* returned.
|
||||
*/
|
||||
int pv_snprintf(char *str, size_t size, const char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int ret;
|
||||
|
||||
if (NULL == str)
|
||||
return -1;
|
||||
if (0 == size)
|
||||
return -1;
|
||||
if (NULL == format)
|
||||
return -1;
|
||||
|
||||
str[0] = '\0';
|
||||
|
||||
va_start(ap, format);
|
||||
#ifdef HAVE_VSNPRINTF
|
||||
ret = vsnprintf(str, size, format, ap);
|
||||
#else /* ! HAVE_VSNPRINTF */
|
||||
ret = vsprintf(str, format, ap);
|
||||
#endif /* HAVE_VSNPRINTF */
|
||||
va_end(ap);
|
||||
|
||||
str[size - 1] = '\0';
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Implementation of strlcat() where it is unavailable: append a string to a
|
||||
* buffer, constraining the buffer to a particular size and ensuring
|
||||
* termination with '\0'.
|
||||
*
|
||||
* Appends the string "src" to the buffer "dst", assuming "dst" is "dstsize"
|
||||
* bytes long, and ensuring that "dst" is always terminated with a '\0'
|
||||
* byte.
|
||||
*
|
||||
* Returns the intended length of the string, not including the terminating
|
||||
* '\0', i.e. strlen(src)+strlen(dst), regardless of whether truncation
|
||||
* occurred.
|
||||
*
|
||||
* Note that this implementation has the side effect that "dst" will always
|
||||
* be terminated with a '\0' even if "src" was zero bytes long.
|
||||
*/
|
||||
size_t pv_strlcat(char *dst, const char *src, size_t dstsize)
|
||||
{
|
||||
#ifdef HAVE_STRLCAT
|
||||
return strlcat(dst, src, dstsize);
|
||||
#else
|
||||
size_t dstlen, srclen, available;
|
||||
|
||||
if (NULL == dst)
|
||||
return 0;
|
||||
if (NULL == src)
|
||||
return 0;
|
||||
if (0 == dstsize)
|
||||
return 0;
|
||||
|
||||
dst[dstsize - 1] = '\0';
|
||||
dstlen = strlen(dst);
|
||||
srclen = strlen(src);
|
||||
|
||||
available = dstsize - dstlen;
|
||||
if (available > 1)
|
||||
(void) pv_snprintf(dst + dstlen, available, "%.*s",
|
||||
available - 1, src);
|
||||
|
||||
return dstlen + srclen;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
+154
-11
@@ -1,7 +1,13 @@
|
||||
/*
|
||||
* Functions for transferring between file descriptors.
|
||||
*
|
||||
* Copyright 2002-2008, 2010, 2012-2015, 2017, 2021, 2023 Andrew Wood
|
||||
*
|
||||
* Distributed under the Artistic License v2.0; see `doc/COPYING'.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "pv.h"
|
||||
#include "pv-internal.h"
|
||||
|
||||
#include <stdio.h>
|
||||
@@ -97,10 +103,13 @@ static ssize_t pv__transfer_read_repeated(int fd, void *buf, size_t count)
|
||||
* see if we can write any more, and keep trying, to make sure we empty the
|
||||
* buffer as much as we can.
|
||||
*
|
||||
* If "sync_after_write" is true, we call fdatasync() after each write().
|
||||
*
|
||||
* We stop retrying if the time elapsed since this function was entered
|
||||
* reaches TRANSFER_WRITE_TIMEOUT microseconds.
|
||||
*/
|
||||
static ssize_t pv__transfer_write_repeated(int fd, void *buf, size_t count)
|
||||
static ssize_t pv__transfer_write_repeated(int fd, void *buf, size_t count,
|
||||
bool sync_after_write)
|
||||
{
|
||||
struct timeval start_time;
|
||||
ssize_t total_written;
|
||||
@@ -119,6 +128,20 @@ static ssize_t pv__transfer_write_repeated(int fd, void *buf, size_t count)
|
||||
MAX_WRITE_AT_ONCE ? MAX_WRITE_AT_ONCE : count;
|
||||
|
||||
nwritten = write(fd, buf, asked_to_write);
|
||||
|
||||
#ifdef HAVE_FDATASYNC
|
||||
if (sync_after_write && nwritten >= 0) {
|
||||
/*
|
||||
* Ignore non IO errors, such as EBADFD (bad file
|
||||
* descriptor), EINVAL (non syncable fd, such as a
|
||||
* pipe), etc - only return an error on EIO.
|
||||
*/
|
||||
if ((fdatasync(fd) < 0) && (EIO == errno)) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
#endif /* HAVE_FDATASYNC */
|
||||
|
||||
if (nwritten < 0) {
|
||||
if ((EINTR == errno) || (EAGAIN == errno)) {
|
||||
/*
|
||||
@@ -214,6 +237,7 @@ static int pv__transfer_read(pvstate_t state, int fd,
|
||||
int *eof_in, int *eof_out,
|
||||
unsigned long long allowed)
|
||||
{
|
||||
bool do_not_skip_errors;
|
||||
unsigned long bytes_can_read;
|
||||
unsigned long amount_to_skip;
|
||||
long amount_skipped;
|
||||
@@ -224,6 +248,10 @@ static int pv__transfer_read(pvstate_t state, int fd,
|
||||
size_t bytes_to_splice;
|
||||
#endif /* HAVE_SPLICE */
|
||||
|
||||
do_not_skip_errors = false;
|
||||
if (0 == state->skip_errors)
|
||||
do_not_skip_errors = true;
|
||||
|
||||
bytes_can_read = state->buffer_size - state->read_position;
|
||||
|
||||
#ifdef HAVE_SPLICE
|
||||
@@ -250,6 +278,24 @@ static int pv__transfer_read(pvstate_t state, int fd,
|
||||
*/
|
||||
} else if (nread > 0) {
|
||||
state->written = nread;
|
||||
# ifdef HAVE_FDATASYNC
|
||||
if (state->sync_after_write) {
|
||||
/*
|
||||
* Ignore non IO errors, such as EBADFD (bad file
|
||||
* descriptor), EINVAL (non syncable fd, such as a
|
||||
* pipe), etc - only treat EIO as a failure.
|
||||
*
|
||||
* Since this is a write error, not a read
|
||||
* error, we cannot skip it, so set
|
||||
* "do_not_skip_errors".
|
||||
*/
|
||||
if ((fdatasync(STDOUT_FILENO) < 0)
|
||||
&& (EIO == errno)) {
|
||||
nread = -1;
|
||||
do_not_skip_errors = true;
|
||||
}
|
||||
}
|
||||
# endif /* HAVE_FDATASYNC */
|
||||
} else if ((-1 == nread) && (EAGAIN == errno)) {
|
||||
/* nothing read yet - do nothing */
|
||||
} else {
|
||||
@@ -335,7 +381,7 @@ static int pv__transfer_read(pvstate_t state, int fd,
|
||||
* If we aren't skipping errors, show the error and pretend we
|
||||
* reached the end of this file.
|
||||
*/
|
||||
if (0 == state->skip_errors) {
|
||||
if (do_not_skip_errors) {
|
||||
pv_error(state, "%s: %s: %s",
|
||||
state->current_file,
|
||||
_("read failed"), strerror(errno));
|
||||
@@ -361,7 +407,7 @@ static int pv__transfer_read(pvstate_t state, int fd,
|
||||
state->read_error_warning_shown = 1;
|
||||
}
|
||||
|
||||
orig_offset = lseek64(fd, 0, SEEK_CUR);
|
||||
orig_offset = lseek(fd, 0, SEEK_CUR);
|
||||
|
||||
/*
|
||||
* If the file is not seekable, we can't skip past the error, so we
|
||||
@@ -406,7 +452,7 @@ static int pv__transfer_read(pvstate_t state, int fd,
|
||||
if (amount_to_skip > bytes_can_read)
|
||||
amount_to_skip = bytes_can_read;
|
||||
|
||||
skip_offset = lseek64(fd, orig_offset + amount_to_skip, SEEK_SET);
|
||||
skip_offset = lseek(fd, orig_offset + amount_to_skip, SEEK_SET);
|
||||
|
||||
/*
|
||||
* If the skip we just tried didn't work, try only skipping 1 byte
|
||||
@@ -415,7 +461,7 @@ static int pv__transfer_read(pvstate_t state, int fd,
|
||||
if (skip_offset < 0) {
|
||||
amount_to_skip = 1;
|
||||
skip_offset =
|
||||
lseek64(fd, orig_offset + amount_to_skip, SEEK_SET);
|
||||
lseek(fd, orig_offset + amount_to_skip, SEEK_SET);
|
||||
}
|
||||
|
||||
if (skip_offset < 0) {
|
||||
@@ -496,7 +542,8 @@ static int pv__transfer_write(pvstate_t state,
|
||||
nwritten = pv__transfer_write_repeated(STDOUT_FILENO,
|
||||
state->transfer_buffer +
|
||||
state->write_position,
|
||||
state->to_write);
|
||||
state->to_write,
|
||||
state->sync_after_write);
|
||||
|
||||
alarm(0);
|
||||
|
||||
@@ -637,6 +684,63 @@ static int pv__transfer_write(pvstate_t state,
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Return a pointer to a newly allocated buffer of the given size, aligned
|
||||
* appropriately for the current input and output file descriptors
|
||||
* (important if using O_DIRECT).
|
||||
*
|
||||
* Falls back to unaligned allocation if it was not possible to get an
|
||||
* aligned buffer, or if the relevant operating system features were not
|
||||
* available. With O_DIRECT, this means that transfers could fail with an
|
||||
* "Invalid argument" error (EINVAL).
|
||||
*
|
||||
* Returns NULL on complete allocation failure.
|
||||
*/
|
||||
static unsigned char *pv__allocate_aligned_buffer(int fd,
|
||||
size_t target_size)
|
||||
{
|
||||
unsigned char *newptr;
|
||||
|
||||
#if defined(HAVE_FPATHCONF) && defined(HAVE_POSIX_MEMALIGN) && defined(_PC_REC_XFER_ALIGN)
|
||||
long input_alignment, output_alignment, min_alignment;
|
||||
size_t required_alignment;
|
||||
|
||||
input_alignment = fd >= 0 ? fpathconf(fd, _PC_REC_XFER_ALIGN) : -1;
|
||||
output_alignment = fpathconf(STDOUT_FILENO, _PC_REC_XFER_ALIGN);
|
||||
# if defined(HAVE_SYSCONF) && defined(_SC_PAGESIZE)
|
||||
min_alignment = sysconf(_SC_PAGESIZE);
|
||||
# else /* ! defined(HAVE_SYSCONF) && defined(_SC_PAGESIZE) */
|
||||
min_alignment = 8192;
|
||||
# endif /* defined(HAVE_SYSCONF) && defined(_SC_PAGESIZE) */
|
||||
|
||||
if (input_alignment > output_alignment) {
|
||||
required_alignment = input_alignment;
|
||||
} else if (output_alignment > input_alignment) {
|
||||
required_alignment = output_alignment;
|
||||
} else if (input_alignment < min_alignment) {
|
||||
required_alignment = min_alignment;
|
||||
} else {
|
||||
required_alignment = input_alignment;
|
||||
}
|
||||
|
||||
/* Ensure the alignment is at least the page size. */
|
||||
if (required_alignment < min_alignment) {
|
||||
required_alignment = min_alignment;
|
||||
}
|
||||
|
||||
if (0 !=
|
||||
posix_memalign((void **) (&newptr), required_alignment,
|
||||
target_size)) {
|
||||
newptr = (unsigned char *) malloc(target_size);
|
||||
}
|
||||
#else /* ! defined(HAVE_FPATHCONF) && defined(HAVE_POSIX_MEMALIGN) && defined(_PC_REC_XFER_ALIGN) */
|
||||
newptr = (unsigned char *) malloc(target_size);
|
||||
#endif /* defined(HAVE_FPATHCONF) && defined(HAVE_POSIX_MEMALIGN) && defined(_PC_REC_XFER_ALIGN) */
|
||||
|
||||
return newptr;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Transfer some data from "fd" to standard output, timing out after 9/100
|
||||
* of a second. If state->rate_limit is >0, and/or "allowed" is >0, only up
|
||||
@@ -660,6 +764,26 @@ long pv_transfer(pvstate_t state, int fd, int *eof_in, int *eof_out,
|
||||
if (NULL == state)
|
||||
return 0;
|
||||
|
||||
#ifdef O_DIRECT
|
||||
/*
|
||||
* Set or clear O_DIRECT on the input and output file descriptors,
|
||||
* if the setting has changed.
|
||||
*/
|
||||
if (state->direct_io_changed) {
|
||||
if (!(*eof_in)) {
|
||||
fcntl(fd, F_SETFL,
|
||||
(state->direct_io ? O_DIRECT : 0) | fcntl(fd,
|
||||
F_GETFL));
|
||||
}
|
||||
if (!(*eof_out)) {
|
||||
fcntl(STDOUT_FILENO, F_SETFL,
|
||||
(state->direct_io ? O_DIRECT : 0) |
|
||||
fcntl(STDOUT_FILENO, F_GETFL));
|
||||
}
|
||||
state->direct_io_changed = false;
|
||||
}
|
||||
#endif /* O_DIRECT */
|
||||
|
||||
/*
|
||||
* Reinitialise the error skipping variables if the file descriptor
|
||||
* has changed since the last time we were called.
|
||||
@@ -670,10 +794,15 @@ long pv_transfer(pvstate_t state, int fd, int *eof_in, int *eof_out,
|
||||
state->read_error_warning_shown = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Allocate a new buffer, aligned appropriately for the input file
|
||||
* (important if using O_DIRECT).
|
||||
*/
|
||||
if (NULL == state->transfer_buffer) {
|
||||
state->buffer_size = state->target_buffer_size;
|
||||
state->transfer_buffer =
|
||||
(unsigned char *) malloc(state->buffer_size + 32);
|
||||
pv__allocate_aligned_buffer(fd,
|
||||
state->target_buffer_size +
|
||||
32);
|
||||
if (NULL == state->transfer_buffer) {
|
||||
pv_error(state, "%s: %s",
|
||||
_("buffer allocation failed"),
|
||||
@@ -681,16 +810,22 @@ long pv_transfer(pvstate_t state, int fd, int *eof_in, int *eof_out,
|
||||
state->exit_status |= 64;
|
||||
return -1;
|
||||
}
|
||||
state->buffer_size = state->target_buffer_size;
|
||||
}
|
||||
|
||||
/*
|
||||
* Reallocate the buffer if the buffer size has changed mid-transfer.
|
||||
* Reallocate the buffer if the buffer size has changed
|
||||
* mid-transfer. We have to do this by allocating a new buffer,
|
||||
* copying to it, and freeing the old one (potentially leaking
|
||||
* memory) because the buffer may need to be aligned for O_DIRECT,
|
||||
* and we can't realloc() an aligned buffer.
|
||||
*/
|
||||
if (state->buffer_size < state->target_buffer_size) {
|
||||
unsigned char *newptr;
|
||||
newptr =
|
||||
realloc(state->transfer_buffer,
|
||||
state->target_buffer_size + 32);
|
||||
pv__allocate_aligned_buffer(fd,
|
||||
state->target_buffer_size +
|
||||
32);
|
||||
if (NULL == newptr) {
|
||||
/*
|
||||
* Reset target if realloc failed so we don't keep
|
||||
@@ -701,6 +836,14 @@ long pv_transfer(pvstate_t state, int fd, int *eof_in, int *eof_out,
|
||||
} else {
|
||||
debug("%s: %ld", "buffer resized",
|
||||
state->buffer_size);
|
||||
/*
|
||||
* Copy the old buffer contents into the new buffer,
|
||||
* and free the old one.
|
||||
*/
|
||||
if (state->buffer_size > 0)
|
||||
memcpy(newptr, state->transfer_buffer,
|
||||
state->buffer_size);
|
||||
free(state->transfer_buffer);
|
||||
state->transfer_buffer = newptr;
|
||||
state->buffer_size = state->target_buffer_size;
|
||||
}
|
||||
|
||||
+50
-62
@@ -1,7 +1,13 @@
|
||||
/*
|
||||
* Functions for watching file descriptors in other processes.
|
||||
*
|
||||
* Copyright 2002-2008, 2010, 2012-2015, 2017, 2021, 2023 Andrew Wood
|
||||
*
|
||||
* Distributed under the Artistic License v2.0; see `doc/COPYING'.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "pv.h"
|
||||
#include "pv-internal.h"
|
||||
|
||||
#include <stdio.h>
|
||||
@@ -34,9 +40,9 @@ int filesize(pvwatchfd_t info)
|
||||
* Get the size of block devices by opening
|
||||
* them and seeking to the end.
|
||||
*/
|
||||
fd = open64(info->file_fdpath, O_RDONLY);
|
||||
fd = open(info->file_fdpath, O_RDONLY);
|
||||
if (fd >= 0) {
|
||||
info->size = lseek64(fd, 0, SEEK_END);
|
||||
info->size = lseek(fd, 0, SEEK_END);
|
||||
close(fd);
|
||||
} else {
|
||||
info->size = 0;
|
||||
@@ -83,11 +89,11 @@ int pv_watchfd_info(pvstate_t state, pvwatchfd_t info, int automatic)
|
||||
}
|
||||
|
||||
strlcpy(info->file_fdpath, vnodeInfo.pvip.vip_path,
|
||||
sizeof(info->file_fdpath));
|
||||
PV_SIZEOF_FILE_FDPATH);
|
||||
|
||||
info->size = 0;
|
||||
|
||||
if (!(0 == stat64(info->file_fdpath, &(info->sb_fd)))) {
|
||||
if (!(0 == stat(info->file_fdpath, &(info->sb_fd)))) {
|
||||
if (!automatic)
|
||||
pv_error(state, "%s %u: %s %d: %s: %s",
|
||||
_("pid"),
|
||||
@@ -146,23 +152,17 @@ int pv_watchfd_info(pvstate_t state, pvwatchfd_t info, int automatic)
|
||||
info->watch_pid, strerror(errno));
|
||||
return 1;
|
||||
}
|
||||
#ifdef HAVE_SNPRINTF
|
||||
snprintf(info->file_fdinfo, sizeof(info->file_fdinfo) - 1,
|
||||
#else
|
||||
sprintf(info->file_fdinfo,
|
||||
#endif
|
||||
"/proc/%u/fdinfo/%d", info->watch_pid, info->watch_fd);
|
||||
#ifdef HAVE_SNPRINTF
|
||||
snprintf(info->file_fd, sizeof(info->file_fd) - 1,
|
||||
#else
|
||||
sprintf(info->file_fd,
|
||||
#endif
|
||||
"/proc/%u/fd/%d", info->watch_pid, info->watch_fd);
|
||||
(void) pv_snprintf(info->file_fdinfo, PV_SIZEOF_FILE_FDINFO,
|
||||
"/proc/%u/fdinfo/%d", info->watch_pid,
|
||||
info->watch_fd);
|
||||
(void) pv_snprintf(info->file_fd, PV_SIZEOF_FILE_FD,
|
||||
"/proc/%u/fd/%d", info->watch_pid,
|
||||
info->watch_fd);
|
||||
|
||||
memset(info->file_fdpath, 0, sizeof(info->file_fdpath));
|
||||
memset(info->file_fdpath, 0, PV_SIZEOF_FILE_FDPATH);
|
||||
if (readlink
|
||||
(info->file_fd, info->file_fdpath,
|
||||
sizeof(info->file_fdpath) - 1) < 0) {
|
||||
PV_SIZEOF_FILE_FDPATH - 1) < 0) {
|
||||
if (!automatic)
|
||||
pv_error(state, "%s %u: %s %d: %s",
|
||||
_("pid"),
|
||||
@@ -171,8 +171,8 @@ int pv_watchfd_info(pvstate_t state, pvwatchfd_t info, int automatic)
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (!((0 == stat64(info->file_fd, &(info->sb_fd)))
|
||||
&& (0 == lstat64(info->file_fd, &(info->sb_fd_link))))) {
|
||||
if (!((0 == stat(info->file_fd, &(info->sb_fd)))
|
||||
&& (0 == lstat(info->file_fd, &(info->sb_fd_link))))) {
|
||||
if (!automatic)
|
||||
pv_error(state, "%s %u: %s %d: %s: %s",
|
||||
_("pid"),
|
||||
@@ -214,10 +214,10 @@ int pv_watchfd_changed(pvwatchfd_t info)
|
||||
*/
|
||||
int pv_watchfd_changed(pvwatchfd_t info)
|
||||
{
|
||||
struct stat64 sb_fd, sb_fd_link;
|
||||
struct stat sb_fd, sb_fd_link;
|
||||
|
||||
if ((0 == stat64(info->file_fd, &sb_fd))
|
||||
&& (0 == lstat64(info->file_fd, &sb_fd_link))) {
|
||||
if ((0 == stat(info->file_fd, &sb_fd))
|
||||
&& (0 == lstat(info->file_fd, &sb_fd_link))) {
|
||||
if ((sb_fd.st_dev != info->sb_fd.st_dev)
|
||||
|| (sb_fd.st_ino != info->sb_fd.st_ino)
|
||||
|| (sb_fd_link.st_mode != info->sb_fd_link.st_mode)
|
||||
@@ -232,10 +232,15 @@ int pv_watchfd_changed(pvwatchfd_t info)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
|
||||
/*
|
||||
* Return the current file position of the given file descriptor, or -1 if
|
||||
* the fd has closed or has changed in some way.
|
||||
*/
|
||||
long long pv_watchfd_position(pvwatchfd_t info)
|
||||
{
|
||||
long long position;
|
||||
#ifdef __APPLE__
|
||||
struct vnode_fdinfowithpath vnodeInfo = { };
|
||||
int32_t proc_fd = (int32_t) info->watch_fd;
|
||||
|
||||
@@ -247,18 +252,7 @@ long long pv_watchfd_position(pvwatchfd_t info)
|
||||
}
|
||||
|
||||
position = (long long) vnodeInfo.pfi.fi_offset;
|
||||
|
||||
return position;
|
||||
}
|
||||
|
||||
#else
|
||||
/*
|
||||
* Return the current file position of the given file descriptor, or -1 if
|
||||
* the fd has closed or has changed in some way.
|
||||
*/
|
||||
long long pv_watchfd_position(pvwatchfd_t info)
|
||||
{
|
||||
long long position;
|
||||
FILE *fptr;
|
||||
|
||||
if (pv_watchfd_changed(info))
|
||||
@@ -268,17 +262,18 @@ long long pv_watchfd_position(pvwatchfd_t info)
|
||||
if (NULL == fptr)
|
||||
return -1;
|
||||
position = -1;
|
||||
fscanf(fptr, "pos: %llu", &position);
|
||||
if (1 != fscanf(fptr, "pos: %llu", &position))
|
||||
position = -1;
|
||||
fclose(fptr);
|
||||
#endif
|
||||
|
||||
return position;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __APPLE__
|
||||
int pidfds(pvstate_t state, unsigned int pid, struct proc_fdinfo **fds,
|
||||
int *count)
|
||||
static int pidfds(pvstate_t state, unsigned int pid,
|
||||
struct proc_fdinfo **fds, int *count)
|
||||
{
|
||||
int size_needed = proc_pidinfo(pid, PROC_PIDLISTFDS, 0, 0, 0);
|
||||
if (size_needed == -1) {
|
||||
@@ -319,11 +314,6 @@ int pv_watchpid_scanfds(pvstate_t state, pvstate_t pristine,
|
||||
struct pvwatchfd_s *info_array = NULL;
|
||||
struct pvstate_s *state_array = NULL;
|
||||
|
||||
#ifdef HAVE_SNPRINTF
|
||||
snprintf(fd_dir, sizeof(fd_dir) - 1, "/proc/%u/fd", watch_pid);
|
||||
#else
|
||||
sprintf(fd_dir, "/proc/%u/fd", watch_pid);
|
||||
#endif
|
||||
#ifdef __APPLE__
|
||||
struct proc_fdinfo *fd_infos = NULL;
|
||||
int fd_infos_count = 0;
|
||||
@@ -335,6 +325,10 @@ int pv_watchpid_scanfds(pvstate_t state, pvstate_t pristine,
|
||||
#else
|
||||
DIR *dptr;
|
||||
struct dirent *d;
|
||||
|
||||
(void) pv_snprintf(fd_dir, sizeof(fd_dir), "/proc/%u/fd",
|
||||
watch_pid);
|
||||
|
||||
dptr = opendir(fd_dir);
|
||||
if (NULL == dptr)
|
||||
return 1;
|
||||
@@ -533,7 +527,7 @@ void pv_watchpid_setname(pvstate_t state, pvwatchfd_t info)
|
||||
int path_length, cwd_length, max_display_length;
|
||||
char *file_fdpath = info->file_fdpath;
|
||||
|
||||
memset(info->display_name, 0, sizeof(info->display_name));
|
||||
memset(info->display_name, 0, PV_SIZEOF_DISPLAY_NAME);
|
||||
|
||||
path_length = strlen(info->file_fdpath);
|
||||
cwd_length = strlen(state->cwd);
|
||||
@@ -547,29 +541,23 @@ void pv_watchpid_setname(pvstate_t state, pvwatchfd_t info)
|
||||
|
||||
max_display_length = (state->width / 2) - 6;
|
||||
if (max_display_length >= path_length) {
|
||||
#ifdef HAVE_SNPRINTF
|
||||
snprintf(info->display_name,
|
||||
sizeof(info->display_name) - 1,
|
||||
#else
|
||||
sprintf(info->display_name,
|
||||
#endif
|
||||
"%4d:%.498s", info->watch_fd, file_fdpath);
|
||||
(void) pv_snprintf(info->display_name,
|
||||
PV_SIZEOF_DISPLAY_NAME,
|
||||
"%4d:%.498s", info->watch_fd,
|
||||
file_fdpath);
|
||||
} else {
|
||||
int prefix_length, suffix_length;
|
||||
|
||||
prefix_length = max_display_length / 4;
|
||||
suffix_length = max_display_length - prefix_length - 3;
|
||||
|
||||
#ifdef HAVE_SNPRINTF
|
||||
snprintf(info->display_name,
|
||||
sizeof(info->display_name) - 1,
|
||||
#else
|
||||
sprintf(info->display_name,
|
||||
#endif
|
||||
"%4d:%.*s...%.*s",
|
||||
info->watch_fd, prefix_length, file_fdpath,
|
||||
suffix_length,
|
||||
file_fdpath + path_length - suffix_length);
|
||||
(void) pv_snprintf(info->display_name,
|
||||
PV_SIZEOF_DISPLAY_NAME,
|
||||
"%4d:%.*s...%.*s",
|
||||
info->watch_fd, prefix_length,
|
||||
file_fdpath, suffix_length,
|
||||
file_fdpath + path_length -
|
||||
suffix_length);
|
||||
}
|
||||
|
||||
debug("%s: %d: [%s]", "set name for fd", info->watch_fd,
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Check that data can be just passed straight through.
|
||||
|
||||
VALUE=`echo TESTING | $PROG 2>/dev/null` || exit 1
|
||||
test "$VALUE" = "TESTING"
|
||||
|
||||
# EOF
|
||||
@@ -1,12 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Check that the update interval can be set.
|
||||
|
||||
sleep 1 | $PROG -f -i 0.1 >/dev/null 2>$TMP1
|
||||
|
||||
# There should be more than 6 lines of output.
|
||||
#
|
||||
NUM=`tr '\r' '\n' < $TMP1 | wc -l | tr -d ' '`
|
||||
test $NUM -gt 6
|
||||
|
||||
# EOF
|
||||
@@ -1,13 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# A simple test of rate limiting.
|
||||
|
||||
# Transfer 102 bytes at 100 bytes/sec. It should take at least 1 second.
|
||||
#
|
||||
START=`date +%S`
|
||||
dd if=/dev/zero bs=102 count=1 2>/dev/null | $PROG -L 100 2>/dev/null | cat >/dev/null
|
||||
END=`date +%S`
|
||||
|
||||
test $START -ne $END
|
||||
|
||||
# EOF
|
||||
@@ -1,13 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Check that the progress bar moves when data is coming in.
|
||||
|
||||
dd if=/dev/zero bs=100 count=1 2>/dev/null \
|
||||
| $PROG -f -p -i 0.1 -L 500 >/dev/null 2>$TMP1
|
||||
|
||||
# There should be more than 2 different lines of output.
|
||||
#
|
||||
NUM=`tr '\r' '\n' < $TMP1 | sort | uniq -u | wc -l | tr -d ' '`
|
||||
test $NUM -gt 2
|
||||
|
||||
# EOF
|
||||
@@ -1,14 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Check that the elapsed time counter does count up.
|
||||
|
||||
# Transfer a zero amount of data, but take 3 seconds to do it.
|
||||
#
|
||||
(sleep 3 | $PROG -f -t >/dev/null) 2>&1 | tr '\r' '\n' > $TMP1
|
||||
|
||||
# Count the number of different timer values; it should be >1.
|
||||
#
|
||||
NUM=`sort < $TMP1 | uniq -u | wc -l | tr -d ' '`
|
||||
test $NUM -gt 1
|
||||
|
||||
# EOF
|
||||
@@ -1,20 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Check that the estimated time counter counts.
|
||||
|
||||
dd if=/dev/zero bs=100 count=1 2>/dev/null \
|
||||
| $PROG -f -e -s 100 -i 0.1 -L 25 >/dev/null 2>$TMP1
|
||||
|
||||
# Count the number of different ETA values there have been.
|
||||
#
|
||||
NUM=`tr '\r' '\n' < $TMP1 | tr -d ' ' | sed '/^$/d' | sort | uniq | wc -l | tr -d ' '`
|
||||
|
||||
# 3 or less - not OK, since it should have taken 4 seconds.
|
||||
#
|
||||
test $NUM -gt 3 || exit 1
|
||||
|
||||
# 12 or more - not OK, since even on a heavily loaded system that's too long.
|
||||
#
|
||||
test $NUM -lt 12
|
||||
|
||||
# EOF
|
||||
@@ -1,20 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Check that the estimated time counter can show the end time of day.
|
||||
|
||||
dd if=/dev/zero bs=100 count=1 2>/dev/null \
|
||||
| $PROG -f -I -s 100 -i 0.1 -L 25 >/dev/null 2>$TMP1
|
||||
|
||||
# Count the number of different ETA values there have been.
|
||||
#
|
||||
NUM=`tr '\r' '\n' < $TMP1 | tr -d ' ' | sed '/^$/d' | sort | uniq | wc -l | tr -d ' '`
|
||||
|
||||
# There should be at least 1 line of output.
|
||||
#
|
||||
test $NUM -gt 0 || exit 1
|
||||
|
||||
# 8 or more different values - not OK.
|
||||
#
|
||||
test $NUM -lt 8
|
||||
|
||||
# EOF
|
||||
@@ -1,10 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Check that the byte counter counts.
|
||||
|
||||
dd if=/dev/zero bs=100 count=1 2>/dev/null \
|
||||
| LANG=C $PROG -f -b >/dev/null 2>$TMP1
|
||||
NUM=`tr '\r' '\n' < $TMP1 | tr -d ' '`
|
||||
test "$NUM" = "100B"
|
||||
|
||||
# EOF
|
||||
@@ -1,18 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Check that numeric output outputs some percentages.
|
||||
|
||||
# Process 100 bytes at 100 bytes per second, updating every 0.1 seconds for
|
||||
# around 10 output lines.
|
||||
#
|
||||
dd if=/dev/zero bs=100 count=1 2>/dev/null \
|
||||
| $PROG -s 100 -n -i 0.1 -L 100 >/dev/null 2>$TMP1
|
||||
|
||||
# The number of output lines should be >8 and <13, and the final percentage
|
||||
# should be 100.
|
||||
#
|
||||
test `wc -l < $TMP1` -gt 8
|
||||
test `wc -l < $TMP1` -lt 13
|
||||
test `sed -n '$p' < $TMP1` -eq 100
|
||||
|
||||
# EOF
|
||||
@@ -1,9 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Check that the -q option shuts everything up.
|
||||
|
||||
dd if=/dev/zero bs=1000 count=5 2>/dev/null \
|
||||
| $PROG -f -q -i 0.1 -L 5000 >/dev/null 2>$TMP1
|
||||
test ! -s $TMP1
|
||||
|
||||
# EOF
|
||||
@@ -1,26 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Check that there is no SIGPIPE or dropped data on bigger data transfers.
|
||||
|
||||
# We nead GNU head. On some platforms it is named ghead instead of head.
|
||||
HEAD=head
|
||||
for p in `echo $PATH | tr ':' '\n'`
|
||||
do
|
||||
if test -x $p/ghead
|
||||
then
|
||||
HEAD=$p/ghead
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# Don't use dd. See http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=324308
|
||||
COUNT1=100000000
|
||||
#COUNT2=`$PROG -B 100000 -q /dev/zero | $HEAD -c $COUNT1 | wc -c | tr -d ' '`
|
||||
# Remove \n to fix the test on AIX
|
||||
COUNT2=`$PROG -B 100000 -q /dev/zero | $HEAD -c $COUNT1 | tr -d '\n' | wc -c | tr -d ' '`
|
||||
|
||||
#echo "[$COUNT1] [$COUNT2]"
|
||||
|
||||
test "x$COUNT1" = "x$COUNT2"
|
||||
|
||||
# EOF
|
||||
@@ -1,26 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Transfer a large chunk of data through pv and check data correctness
|
||||
# afterwards.
|
||||
|
||||
rm -f $TMP1 $TMP2 2>/dev/null
|
||||
|
||||
# exit on non-zero return codes
|
||||
set -e
|
||||
|
||||
# generate some data
|
||||
dd if=/dev/urandom of=$TMP1 bs=1024 count=10240 2>/dev/null
|
||||
|
||||
CKSUM1=`cksum $TMP1 | awk '{print $1}'`
|
||||
|
||||
# read through pv and test afterwards
|
||||
$PROG -B 100000 -q $TMP1 > $TMP2
|
||||
|
||||
CKSUM2=`cksum $TMP2 | awk '{print $1}'`
|
||||
|
||||
test "x$CKSUM1" = "x$CKSUM2"
|
||||
|
||||
# clean up
|
||||
rm -f $TMP1 $TMP2 2>/dev/null
|
||||
|
||||
# EOF
|
||||
@@ -1,25 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Same as test 13 (1mboundary) but for rate, not bytes transferred.
|
||||
|
||||
# Transfer 1500kB of data in a bursty fashion.
|
||||
#
|
||||
(dd if=/dev/zero bs=1k count=999;
|
||||
sleep 1;
|
||||
dd if=/dev/zero bs=1k count=1;
|
||||
sleep 1;
|
||||
dd if=/dev/zero bs=3 count=1;
|
||||
sleep 1;
|
||||
dd if=/dev/zero bs=1k count=500;
|
||||
sleep 1;
|
||||
) 2>/dev/null | ($PROG -rtef -s 1500k >/dev/null) 2>$TMP1
|
||||
|
||||
# Count how many different line lengths we've seen.
|
||||
#
|
||||
NUM=`tr '\r' '\n' < $TMP1 | awk '{x=length($0);if(x>0)print length($0)}' | sort | uniq | wc -l`
|
||||
|
||||
# There should only be one length (not counting 0).
|
||||
#
|
||||
test $NUM -eq 1 || { echo; tr '\r' '\n' < $TMP1; exit 1; }
|
||||
|
||||
# EOF
|
||||
@@ -1,53 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Transfer a large chunk of data through pv using pipes, sending it in a
|
||||
# bursty fashion, and check data correctness afterwards.
|
||||
|
||||
rm -f $TMP1 $TMP2 2>/dev/null
|
||||
|
||||
# exit on non-zero return codes
|
||||
set -e
|
||||
|
||||
# generate some data
|
||||
dd if=/dev/urandom of=$TMP1 bs=1024 count=10240 2>/dev/null
|
||||
|
||||
CKSUM1=`cksum $TMP1 | awk '{print $1}'`
|
||||
|
||||
# read through pv and test afterwards
|
||||
(
|
||||
dd if=$TMP1 bs=1 count=9000
|
||||
sleep 1
|
||||
dd if=$TMP1 bs=1 skip=9000 count=1240
|
||||
sleep 1
|
||||
dd if=$TMP1 bs=1024 skip=10 count=1014
|
||||
sleep 1
|
||||
dd if=$TMP1 bs=1024 skip=1024 count=1024
|
||||
sleep 1
|
||||
dd if=$TMP1 bs=1024 skip=2048
|
||||
) 2>/dev/null | $PROG -q -L 2M | cat > $TMP2
|
||||
|
||||
CKSUM2=`cksum $TMP2 | awk '{print $1}'`
|
||||
|
||||
test "x$CKSUM1" = "x$CKSUM2"
|
||||
|
||||
# same again but with one less pipe
|
||||
(
|
||||
dd if=$TMP1 bs=1 count=9000
|
||||
sleep 1
|
||||
dd if=$TMP1 bs=1 skip=9000 count=1240
|
||||
sleep 1
|
||||
dd if=$TMP1 bs=1024 skip=10 count=1014
|
||||
sleep 1
|
||||
dd if=$TMP1 bs=1024 skip=1024 count=1024
|
||||
sleep 1
|
||||
dd if=$TMP1 bs=1024 skip=2048
|
||||
) 2>/dev/null | $PROG -q -L 2M > $TMP2
|
||||
|
||||
CKSUM2=`cksum $TMP2 | awk '{print $1}'`
|
||||
|
||||
test "x$CKSUM1" = "x$CKSUM2"
|
||||
|
||||
# clean up
|
||||
rm -f $TMP1 $TMP2 2>/dev/null
|
||||
|
||||
# EOF
|
||||
@@ -1,20 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Check that numeric output gives a timer when used with -t.
|
||||
|
||||
# Process 100 bytes at 100 bytes per second, updating every 0.1 seconds for
|
||||
# around 10 output lines.
|
||||
#
|
||||
dd if=/dev/zero bs=100 count=1 2>/dev/null \
|
||||
| $PROG -s 100 -n -t -i 0.1 -L 100 >/dev/null 2>$TMP1
|
||||
|
||||
# The number of output lines should be >8 and <13, and the number of
|
||||
# different elapsed times should be at least 7. The last percentage should
|
||||
# be 100.
|
||||
#
|
||||
test `wc -l < $TMP1` -gt 8
|
||||
test `wc -l < $TMP1` -lt 13
|
||||
test `tr , . < "$TMP1" | awk '{print int(10*$1)}' | sort -n | uniq | wc -l` -gt 7
|
||||
test `sed -n '$p' < $TMP1 | awk '{print $2}'` -eq 100
|
||||
|
||||
# EOF
|
||||
@@ -1,19 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Check that numeric output gives a byte count instead of a percentage when
|
||||
# used with -b.
|
||||
|
||||
# Process 500 bytes at 500 bytes per second, updating every 0.1 seconds for
|
||||
# around 10 output lines.
|
||||
#
|
||||
dd if=/dev/zero bs=500 count=1 2>/dev/null \
|
||||
| $PROG -s 500 -n -b -i 0.1 -L 500 >/dev/null 2>$TMP1
|
||||
|
||||
# The number of output lines should be >8 and <13, and the final byte count
|
||||
# should be 500.
|
||||
#
|
||||
test `wc -l < $TMP1` -gt 8
|
||||
test `wc -l < $TMP1` -lt 13
|
||||
test `sed -n '$p' < $TMP1` -eq 500
|
||||
|
||||
# EOF
|
||||
@@ -1,32 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Try changing the format of a transfer remotely.
|
||||
|
||||
# Do nothing if IPC is not supported.
|
||||
if ! $PROG -h | grep -Eq "^ -R,"; then
|
||||
echo "SKIPPED" | tr "\n" ' '
|
||||
exit 0
|
||||
fi
|
||||
|
||||
rm -f $TMP1 $TMP2 $TMP3 $TMP4 2>/dev/null
|
||||
|
||||
# Exit on non-zero return codes.
|
||||
set -e
|
||||
|
||||
# Generate an empty test file.
|
||||
dd if=/dev/zero of=$TMP1 bs=1024 count=10240 2>/dev/null
|
||||
|
||||
(
|
||||
sleep 1
|
||||
$PROG -R `cat $TMP4` -a
|
||||
sleep 2
|
||||
$PROG -R `cat $TMP4` -L 10M
|
||||
) &
|
||||
|
||||
$PROG -L 2M -f -P $TMP4 $TMP1 > $TMP2 2>$TMP3
|
||||
|
||||
# Make sure there is more than one length of line (excluding blank lines).
|
||||
line_lengths=`tr '\r' '\n' < "$TMP3" | awk '{print length($0)}' | grep -Fvx 0 | sort -n | uniq | wc -l`
|
||||
test $line_lengths -gt 1
|
||||
|
||||
# EOF
|
||||
@@ -1,54 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Try repeatedly messaging a transfer process, and make sure the data stays
|
||||
# intact.
|
||||
|
||||
# Do nothing if IPC is not supported.
|
||||
if ! $PROG -h | grep -Eq "^ -R,"; then
|
||||
echo "SKIPPED" | tr "\n" ' '
|
||||
exit 0
|
||||
fi
|
||||
|
||||
rm -f $TMP1 $TMP2 $TMP3 $TMP4 2>/dev/null
|
||||
|
||||
# Exit on non-zero return codes.
|
||||
set -e
|
||||
|
||||
# Generate some data.
|
||||
dd if=/dev/urandom of=$TMP1 bs=1024 count=10240 2>/dev/null
|
||||
|
||||
# Run a few remote control commands in the background.
|
||||
#
|
||||
echo FAIL > $TMP3
|
||||
(
|
||||
set +e
|
||||
sleep 2
|
||||
for x in 1 2 3; do
|
||||
$PROG -R `cat $TMP4` -apterb || exit 1
|
||||
(usleep 200000 || sleep 1) 2>/dev/null
|
||||
$PROG -R `cat $TMP4` -p || exit 1
|
||||
(usleep 200000 || sleep 1) 2>/dev/null
|
||||
$PROG -R `cat $TMP4` -N "test" || exit 1
|
||||
(usleep 200000 || sleep 1) 2>/dev/null
|
||||
$PROG -R `cat $TMP4` -F "%e" || exit 1
|
||||
(usleep 200000 || sleep 1) 2>/dev/null
|
||||
$PROG -R `cat $TMP4` -N "." || exit 1
|
||||
(usleep 200000 || sleep 1) 2>/dev/null
|
||||
done
|
||||
$PROG -R `cat $TMP4` -L 10M
|
||||
echo OK > $TMP3
|
||||
) &
|
||||
|
||||
# Run our data transfer.
|
||||
$PROG -L 100k -i 0.1 -f -P $TMP4 $TMP1 > $TMP2 2>/dev/null
|
||||
|
||||
# Check our remote control calls ran OK.
|
||||
BGSTATUS=`cat $TMP3`
|
||||
test "x$BGSTATUS" = "xOK"
|
||||
|
||||
# Check data integrity.
|
||||
CKSUM1=`cksum $TMP1 | awk '{print $1}'`
|
||||
CKSUM2=`cksum $TMP2 | awk '{print $1}'`
|
||||
test "x$CKSUM1" = "x$CKSUM2"
|
||||
|
||||
# EOF
|
||||
@@ -1,28 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Make sure -S stops at the given size.
|
||||
|
||||
rm -f $TMP1 $TMP2 2>/dev/null
|
||||
|
||||
# exit on non-zero return codes
|
||||
set -e
|
||||
|
||||
# generate some data
|
||||
dd if=/dev/urandom of=$TMP1 bs=1024 count=10 2>/dev/null
|
||||
|
||||
# read through pv and test afterwards
|
||||
$PROG -S -s 5120 -q $TMP1 > $TMP2
|
||||
|
||||
CKSUM2=`cksum $TMP2 | awk '{print $1}'`
|
||||
|
||||
# take the first 5120 bytes of TMP1 and cksum them
|
||||
rm -f $TMP2
|
||||
dd if=$TMP1 of=$TMP2 bs=1024 count=5 2>/dev/null
|
||||
CKSUM1=`cksum $TMP2 | awk '{print $1}'`
|
||||
|
||||
test "x$CKSUM1" = "x$CKSUM2"
|
||||
|
||||
# clean up
|
||||
rm -f $TMP1 $TMP2 2>/dev/null
|
||||
|
||||
# EOF
|
||||
@@ -4,6 +4,9 @@
|
||||
# 1MiB, described here:
|
||||
# http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=586763
|
||||
|
||||
# Dummy assignments for "shellcheck".
|
||||
testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"
|
||||
|
||||
# Transfer 1500kB of data in a bursty fashion.
|
||||
#
|
||||
(dd if=/dev/zero bs=1k count=999;
|
||||
@@ -12,14 +15,18 @@
|
||||
sleep 1;
|
||||
dd if=/dev/zero bs=1k count=500;
|
||||
sleep 1;
|
||||
) 2>/dev/null | ($PROG -btef -s 1500k >/dev/null) 2>$TMP1
|
||||
) 2>/dev/null | ("${testSubject}" -btIf -s 1500k >/dev/null) 2>"${workFile1}"
|
||||
|
||||
# Count how many different line lengths we've seen.
|
||||
#
|
||||
NUM=`tr '\r' '\n' < $TMP1 | awk '{x=length($0);if(x>0)print length($0)}' | sort | uniq | wc -l`
|
||||
lineLengthCount=$(tr '\r' '\n' < "${workFile1}" | sed 's/ *$//' | awk '{x=length($0);if(x>0)print length($0)}' | sort | uniq | wc -l | tr -dc '0-9')
|
||||
|
||||
# There should only be one length (not counting 0).
|
||||
#
|
||||
test $NUM -eq 1 || { echo; tr '\r' '\n' < $TMP1; exit 1; }
|
||||
test "${lineLengthCount}" = "1" && exit 0
|
||||
|
||||
echo "variable line lengths detected"
|
||||
tr '\r' '\n' < "${workFile1}"
|
||||
exit 1
|
||||
|
||||
# EOF
|
||||
@@ -0,0 +1,33 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# This is the same as the other display length at magnitude boundary check,
|
||||
# but for rate, not bytes transferred.
|
||||
|
||||
# Dummy assignments for "shellcheck".
|
||||
testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"
|
||||
|
||||
# Transfer 1500kB of data in a bursty fashion.
|
||||
#
|
||||
(dd if=/dev/zero bs=1k count=999;
|
||||
sleep 1;
|
||||
dd if=/dev/zero bs=1k count=1;
|
||||
sleep 1;
|
||||
dd if=/dev/zero bs=3 count=1;
|
||||
sleep 1;
|
||||
dd if=/dev/zero bs=1k count=500;
|
||||
sleep 1;
|
||||
) 2>/dev/null | ("${testSubject}" -rtIf -s 1500k >/dev/null) 2>"${workFile1}"
|
||||
|
||||
# Count how many different line lengths we've seen.
|
||||
#
|
||||
lineLengthCount=$(tr '\r' '\n' < "${workFile1}" | sed 's/ *$//' | awk '{x=length($0);if(x>0)print length($0)}' | sort | uniq | wc -l | tr -dc '0-9')
|
||||
|
||||
# There should only be one length (not counting 0).
|
||||
#
|
||||
test "${lineLengthCount}" = "1" && exit 0
|
||||
|
||||
echo "variable line lengths detected"
|
||||
tr '\r' '\n' < "${workFile1}"
|
||||
exit 1
|
||||
|
||||
# EOF
|
||||
@@ -3,6 +3,9 @@
|
||||
# Check that the average transfer rate counter changes, but not more than it
|
||||
# should.
|
||||
|
||||
# Dummy assignments for "shellcheck".
|
||||
testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"
|
||||
|
||||
# Transfer 210 bytes as 100 bytes, a 1 second gap, 110 bytes, and another 1
|
||||
# second gap.
|
||||
#
|
||||
@@ -10,15 +13,19 @@
|
||||
sleep 1;
|
||||
dd if=/dev/zero bs=110 count=1 2>/dev/null;
|
||||
sleep 1;
|
||||
) | $PROG -f -i 0.5 -a >/dev/null 2>$TMP1
|
||||
) | "${testSubject}" -f -i 0.5 -a >/dev/null 2>"${workFile1}"
|
||||
|
||||
# Count the number of rates output that are below 80.
|
||||
#
|
||||
NUM=`tr '\r' '\n' < $TMP1 | tr -dc '0-9.\n' | sed '/^$/d' | awk '$1<80{print}' | wc -l | tr -d ' '`
|
||||
lineCount=$(tr '\r' '\n' < "${workFile1}" | tr -dc '0-9.\n' | sed '/^$/d' | awk '$1<80{print}' | wc -l | tr -dc '0-9')
|
||||
|
||||
# Nearly all of the output rates should be above 80 since the average rate
|
||||
# will always be around 100 bytes per second, except for pauses.
|
||||
#
|
||||
test $NUM -lt 2
|
||||
test "${lineCount}" -lt 2 && exit 0
|
||||
|
||||
echo "average rate varied more than expected"
|
||||
tr '\r' '\n' < "${workFile1}"
|
||||
exit 1
|
||||
|
||||
# EOF
|
||||
@@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Check that the byte counter counts in bits when --bits is selected.
|
||||
|
||||
# Dummy assignments for "shellcheck".
|
||||
testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"
|
||||
|
||||
dd if=/dev/zero bs=100 count=1 2>/dev/null \
|
||||
| "${testSubject}" -f -b -8 >/dev/null 2>"${workFile1}"
|
||||
|
||||
counterValue=$(tr '\r' '\n' < "${workFile1}" | tr -d ' ')
|
||||
test "${counterValue}" = "800b" && exit 0
|
||||
|
||||
echo "unexpected bit counter value: ${counterValue}"
|
||||
exit 1
|
||||
|
||||
# EOF
|
||||
@@ -0,0 +1,21 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Check that "--buffer-percent" displays correctly.
|
||||
|
||||
# Dummy assignments for "shellcheck".
|
||||
testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"
|
||||
|
||||
# The output should show 100% and 0% as the buffer initially fills up due to
|
||||
# there being nowhere to write it to, and then empties.
|
||||
( dd if=/dev/zero bs=1024 count=1024; sleep 2; ) 2>/dev/null \
|
||||
| "${testSubject}" -f -T -i 0.5 -B 1024 2>"${workFile1}" \
|
||||
| (sleep 1; dd bs=1024 count=512; sleep 1; cat; ) >/dev/null 2>&1
|
||||
|
||||
differentLines=$(tr '\r' '\n' < "${workFile1}" | sed '/^ *$/d' | sort | uniq | wc -l | tr -dc '0-9')
|
||||
test "${differentLines}" -gt 1 && exit 0
|
||||
|
||||
echo "expected output changes not seen"
|
||||
tr '\r' '\n' < "${workFile1}" | sed 's/^ *$/d' | sort | uniq
|
||||
exit 1
|
||||
|
||||
# EOF
|
||||
@@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Check that the byte counter counts.
|
||||
|
||||
# Dummy assignments for "shellcheck".
|
||||
testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"
|
||||
|
||||
dd if=/dev/zero bs=100 count=1 2>/dev/null \
|
||||
| "${testSubject}" -f -b >/dev/null 2>"${workFile1}"
|
||||
|
||||
counterValue=$(tr '\r' '\n' < "${workFile1}" | tr -d ' ')
|
||||
test "${counterValue}" = "100B" && exit 0
|
||||
|
||||
echo "unexpected byte counter value: ${counterValue}"
|
||||
exit 1
|
||||
|
||||
# EOF
|
||||
@@ -0,0 +1,33 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Check that the estimated time counter counts.
|
||||
|
||||
# Dummy assignments for "shellcheck".
|
||||
testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"
|
||||
|
||||
dd if=/dev/zero bs=100 count=1 2>/dev/null \
|
||||
| "${testSubject}" -f -e -s 100 -i 0.1 -L 25 >/dev/null 2>"${workFile1}"
|
||||
|
||||
# Count the number of different ETA values there have been.
|
||||
#
|
||||
valueCount=$(tr '\r' '\n' < "${workFile1}" | tr -d ' ' | sed '/^$/d' | sort | uniq | wc -l | tr -dc '0-9')
|
||||
|
||||
# 3 or less - not OK, since it should have taken 4 seconds.
|
||||
#
|
||||
if ! test "${valueCount}" -gt 3; then
|
||||
echo "fewer than 4 ETA values seen"
|
||||
tr '\r' '\n' < "${workFile1}" | sed '/^ *$/d' | sort | uniq
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 12 or more - not OK, since even on a heavily loaded system that's too long.
|
||||
#
|
||||
if ! test "${valueCount}" -lt 12; then
|
||||
echo "more than 11 ETA values seen"
|
||||
tr '\r' '\n' < "${workFile1}" | sed '/^ *$/d' | sort | uniq
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
# EOF
|
||||
@@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Check that the estimated time counter can show the end time of day.
|
||||
|
||||
# Dummy assignments for "shellcheck".
|
||||
testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"
|
||||
|
||||
dd if=/dev/zero bs=100 count=1 2>/dev/null \
|
||||
| "${testSubject}" -f -I -s 100 -i 0.1 -L 25 >/dev/null 2>"${workFile1}"
|
||||
|
||||
# Count the number of different ETA values there have been.
|
||||
#
|
||||
valueCount=$(tr '\r' '\n' < "${workFile1}" | tr -d ' ' | sed '/^$/d' | sort | uniq | wc -l | tr -dc '0-9')
|
||||
|
||||
# There should be at least 1 line of output.
|
||||
#
|
||||
if ! test "${valueCount}" -gt 0; then
|
||||
echo "no output found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 8 or more different values - not OK.
|
||||
#
|
||||
if ! test "${valueCount}" -lt 8; then
|
||||
echo "more than 7 different values (${valueCount})"
|
||||
tr '\r' '\n' < "${workFile1}" | sed '/^ *$/d' | sort | uniq
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
# EOF
|
||||
@@ -0,0 +1,34 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Check that "--last-written" works.
|
||||
|
||||
# Dummy assignments for "shellcheck".
|
||||
testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"
|
||||
|
||||
# Slowly write a sequence of numbers (rate-limited by another `pv' instance)
|
||||
# and watch the "--last-written" output of a second `pv' instance to make
|
||||
# sure the buffer contents are visible (we use "-B" to disable splice mode).
|
||||
seq -w 3 1 100 \
|
||||
| "${testSubject}" -qL 200 \
|
||||
| "${testSubject}" -f -B 1024 -A 16 -i 0.2 >/dev/null 2>"${workFile1}"
|
||||
|
||||
differentLines=$(tr '\r' '\n' < "${workFile1}" | sed '/^ *$/d' | sort | uniq | wc -l | tr -dc '0-9')
|
||||
lastLine=$(tr '\r' '\n' < "${workFile1}" | sed '/^ *$/d' | sed -n '$p')
|
||||
|
||||
if ! test "${differentLines}" -gt 5; then
|
||||
echo "fewer than 6 different outputs seen"
|
||||
tr '\r' '\n' < "${workFile1}" | sed '/^ *$/d' | sort | uniq
|
||||
exit 1
|
||||
fi
|
||||
|
||||
expectedLastLine="097.098.099.100."
|
||||
if ! test "${lastLine}" = "${expectedLastLine}"; then
|
||||
echo "final output differs from expected value"
|
||||
echo "expected value: [${expectedLastLine}]"
|
||||
echo "observed value: [${lastLine}]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
# EOF
|
||||
@@ -0,0 +1,35 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Check that numeric output outputs some percentages.
|
||||
|
||||
# Dummy assignments for "shellcheck".
|
||||
testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"
|
||||
|
||||
# Process 100 bytes at 100 bytes per second, updating every 0.1 seconds for
|
||||
# around 10 output lines.
|
||||
#
|
||||
dd if=/dev/zero bs=100 count=1 2>/dev/null \
|
||||
| "${testSubject}" -s 100 -n -i 0.1 -L 100 >/dev/null 2>"${workFile1}"
|
||||
|
||||
lineCount=$(wc -l < "${workFile1}" | tr -dc '0-9')
|
||||
finalLine=$(sed -n '$p' < "${workFile1}")
|
||||
|
||||
# The number of output lines should be >8 and <13, and the final percentage
|
||||
# should be 100.
|
||||
#
|
||||
if ! test "${lineCount}" -gt 8; then
|
||||
echo "fewer than 9 output lines (${lineCount})"
|
||||
exit 1
|
||||
fi
|
||||
if ! test "${lineCount}" -lt 13; then
|
||||
echo "more than 12 output lines (${lineCount})"
|
||||
exit 1
|
||||
fi
|
||||
if ! test "${finalLine}" = "100"; then
|
||||
echo "final percentage was not 100 (${finalLine})"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
# EOF
|
||||
@@ -0,0 +1,34 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Check that numeric output gives a byte count instead of a percentage when
|
||||
# used with -b.
|
||||
|
||||
# Dummy assignments for "shellcheck".
|
||||
testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"
|
||||
|
||||
# Process 500 bytes at 500 bytes per second, updating every 0.1 seconds for
|
||||
# around 10 output lines.
|
||||
#
|
||||
dd if=/dev/zero bs=500 count=1 2>/dev/null \
|
||||
| "${testSubject}" -s 500 -n -b -i 0.1 -L 500 >/dev/null 2>"${workFile1}"
|
||||
|
||||
lineCount=$(wc -l < "${workFile1}" | tr -dc '0-9')
|
||||
finalLine=$(sed -n '$p' < "${workFile1}")
|
||||
|
||||
# The number of output lines should be >8 and <13, and the final byte count
|
||||
# should be 500.
|
||||
#
|
||||
if ! test "${lineCount}" -gt 8; then
|
||||
echo "fewer than 9 output lines (${lineCount})"
|
||||
exit 1
|
||||
fi
|
||||
if ! test "${lineCount}" -lt 13; then
|
||||
echo "more than 12 output lines (${lineCount})"
|
||||
exit 1
|
||||
fi
|
||||
if ! test "${finalLine}" = "500"; then
|
||||
echo "final byte count was not 500 (${finalLine})"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# EOF
|
||||
@@ -0,0 +1,37 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Check that numeric output shows line counts instead of percentages, when
|
||||
# used in line mode together with bytes mode.
|
||||
|
||||
# Dummy assignments for "shellcheck".
|
||||
testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"; workFile2="${workFile2:-.tmp2}"
|
||||
|
||||
# Pass through 100 lines.
|
||||
#
|
||||
seq -w 3 1 100 \
|
||||
| "${testSubject}" -bnl -i 0.2 -f -L 100 2>"${workFile1}" > "${workFile2}"
|
||||
|
||||
lineCount=$(wc -l < "${workFile1}" | tr -dc '0-9')
|
||||
finalStdoutLine=$(sed -n '$p' < "${workFile2}")
|
||||
|
||||
# The number of output lines should be >3 and <10, and the final line of
|
||||
# transferred data on stdout should be 100.
|
||||
#
|
||||
if ! test "${lineCount}" -gt 3; then
|
||||
echo "fewer than 4 output lines (${lineCount})"
|
||||
cat "${workFile1}"
|
||||
exit 1
|
||||
fi
|
||||
if ! test "${lineCount}" -lt 10; then
|
||||
echo "more than 9 output lines (${lineCount})"
|
||||
cat "${workFile1}"
|
||||
exit 1
|
||||
fi
|
||||
if ! test "${finalStdoutLine}" = "100"; then
|
||||
echo "final transferred line was not 100 (${finalStdoutLine})"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
# EOF
|
||||
@@ -0,0 +1,41 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Check that numeric output gives a timer when used with -t.
|
||||
|
||||
# Dummy assignments for "shellcheck".
|
||||
testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"
|
||||
|
||||
# Process 100 bytes at 100 bytes per second, updating every 0.1 seconds for
|
||||
# around 10 output lines.
|
||||
#
|
||||
dd if=/dev/zero bs=100 count=1 2>/dev/null \
|
||||
| "${testSubject}" -s 100 -n -t -i 0.1 -L 100 >/dev/null 2>"${workFile1}"
|
||||
|
||||
lineCount=$(wc -l < "${workFile1}" | tr -dc '0-9')
|
||||
timesCount=$(tr ',' '.' < "${workFile1}" | awk '{print int(10*$1)}' | sort -n | uniq | wc -l | tr -dc '0-9')
|
||||
finalPercentage=$(sed -n '$p' < "${workFile1}" | awk '{print $2}')
|
||||
|
||||
# The number of output lines should be >8 and <13, and the number of
|
||||
# different elapsed times should be at least 7. The last percentage should
|
||||
# be 100.
|
||||
#
|
||||
if ! test "${lineCount}" -gt 8; then
|
||||
echo "fewer than 9 output lines (${lineCount})"
|
||||
exit 1
|
||||
fi
|
||||
if ! test "${lineCount}" -lt 13; then
|
||||
echo "more than 12 output lines (${lineCount})"
|
||||
exit 1
|
||||
fi
|
||||
if ! test "${timesCount}" -gt 7; then
|
||||
echo "fewer than 8 different elapsed times (${timesCount})"
|
||||
exit 1
|
||||
fi
|
||||
if ! test "${finalPercentage}" = "100"; then
|
||||
echo "final percentage was not 100 (${finalPercentage})"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
# EOF
|
||||
@@ -0,0 +1,22 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Check that the progress bar moves when data is coming in.
|
||||
|
||||
# Dummy assignments for "shellcheck".
|
||||
testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"
|
||||
|
||||
dd if=/dev/zero bs=100 count=1 2>/dev/null \
|
||||
| "${testSubject}" -f -p -i 0.1 -L 500 >/dev/null 2>"${workFile1}"
|
||||
|
||||
# There should be more than 2 different lines of output.
|
||||
#
|
||||
lineCount=$(tr '\r' '\n' < "${workFile1}" | sort | uniq -u | wc -l | tr -dc '0-9')
|
||||
if ! test "${lineCount}" -gt 2; then
|
||||
echo "fewer than 3 different progress lines (${lineCount})"
|
||||
tr '\r' '\n' < "${workFile1}" | sort | uniq -u
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
# EOF
|
||||
@@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Check that the progress bar increases in size when data is coming in.
|
||||
|
||||
# Dummy assignments for "shellcheck".
|
||||
testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"
|
||||
|
||||
dd if=/dev/zero bs=100 count=1 2>/dev/null \
|
||||
| "${testSubject}" -f -p -i 0.1 -L 50 -s 100 >/dev/null 2>"${workFile1}"
|
||||
|
||||
# There should be more than 5 different lines of output.
|
||||
#
|
||||
lineCount=$(tr '\r' '\n' < "${workFile1}" | sort | uniq -u | wc -l | tr -dc '0-9')
|
||||
if ! test "${lineCount}" -gt 5; then
|
||||
echo "fewer than 6 different progress lines (${lineCount})"
|
||||
tr '\r' '\n' < "${workFile1}" | sort | uniq -u
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Counting the "=" characters in each line that make up the progress bar
|
||||
# should give at least 5 different line lengths.
|
||||
#
|
||||
differentBarLengthsCount=$(tr '\r' '\n' < "${workFile1}" | tr -dc '=\n' | awk '{print length($1)}' | sort | uniq -u | wc -l | tr -dc '0-9')
|
||||
if ! test "${differentBarLengthsCount}" -gt 5; then
|
||||
echo "fewer than 6 different progress bar lengths detected (${differentBarLengthsCount})"
|
||||
tr '\r' '\n' < "${workFile1}" | sort | uniq -u
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
# EOF
|
||||
@@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Check that the -q option shuts everything up.
|
||||
|
||||
# Dummy assignments for "shellcheck".
|
||||
testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"
|
||||
|
||||
dd if=/dev/zero bs=1000 count=5 2>/dev/null \
|
||||
| "${testSubject}" -f -q -i 0.1 -L 5000 >/dev/null 2>"${workFile1}"
|
||||
|
||||
if test -s "${workFile1}"; then
|
||||
echo "output detected when there should be none"
|
||||
cat "${workFile1}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
# EOF
|
||||
@@ -2,21 +2,30 @@
|
||||
#
|
||||
# Check that the transfer rate counter changes.
|
||||
|
||||
# Dummy assignments for "shellcheck".
|
||||
testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"
|
||||
|
||||
# Transfer 200 bytes as two 100-byte blocks with a 2-second gap between.
|
||||
#
|
||||
(dd if=/dev/zero bs=100 count=1 2>/dev/null;
|
||||
sleep 2;
|
||||
dd if=/dev/zero bs=100 count=1 2>/dev/null;
|
||||
) | $PROG -f -i 0.5 -r >/dev/null 2>$TMP1
|
||||
) | "${testSubject}" -f -i 0.5 -r >/dev/null 2>"${workFile1}"
|
||||
|
||||
# Count the number of different rates output.
|
||||
#
|
||||
NUM=`tr '\r' '\n' < $TMP1 | sort | uniq -u | wc -l | tr -d ' '`
|
||||
rateCount=$(tr '\r' '\n' < "${workFile1}" | sort | uniq -u | wc -l | tr -dc '0-9')
|
||||
|
||||
# There should be more than 2 different rates counted (around 100 bytes/sec
|
||||
# for the each block, 0 bytes/sec for the gap in the middle, and around 50
|
||||
# bytes/sec for the average time reported at the end).
|
||||
#
|
||||
test $NUM -gt 2
|
||||
if ! test "${rateCount}" -gt 2; then
|
||||
echo "fewer than 3 different rates detected (${rateCount})"
|
||||
tr '\r' '\n' < "${workFile1}" | sort | uniq -u
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
# EOF
|
||||
@@ -0,0 +1,22 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Check that the elapsed time counter does count up.
|
||||
|
||||
# Dummy assignments for "shellcheck".
|
||||
testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"
|
||||
|
||||
# Transfer a zero amount of data, but take 3 seconds to do it.
|
||||
#
|
||||
(sleep 3 | "${testSubject}" -f -t >/dev/null) 2>&1 | tr '\r' '\n' > "${workFile1}"
|
||||
|
||||
# Count the number of different timer values; it should be >1.
|
||||
#
|
||||
valueCount=$(sort < "${workFile1}" | uniq -u | wc -l | tr -dc '0-9')
|
||||
if ! test "${valueCount}" -gt 1; then
|
||||
echo "timer value did not change"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
# EOF
|
||||
@@ -0,0 +1,49 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Check that process ID can be written to a file as described in the manual.
|
||||
|
||||
# Dummy assignments for "shellcheck".
|
||||
testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"
|
||||
|
||||
# Check we can run "kill -s 0".
|
||||
if ! kill -s 0 $$ >/dev/null 2>&1; then
|
||||
echo "cannot check process existence with \`kill -s 0'"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
dd if=/dev/zero bs=150 count=1 2>/dev/null \
|
||||
| "${testSubject}" -q -L 50 -P "${workFile1}" >/dev/null 2>/dev/null \
|
||||
&
|
||||
|
||||
testPid="$!"
|
||||
sleep 1
|
||||
|
||||
storedPid=$(cat "${workFile1}" 2>/dev/null)
|
||||
|
||||
pidValid="0"
|
||||
kill -s 0 "${storedPid}" 2>/dev/null && pidValid="1"
|
||||
|
||||
wait
|
||||
|
||||
sleep 1
|
||||
|
||||
if test -s "${workFile1}"; then
|
||||
echo "PID file was not removed on exit"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
true > "${workFile1}"
|
||||
|
||||
if ! test "${testPid}" = "${storedPid}"; then
|
||||
echo "stored PID [${storedPid}] did not match actual PID [${testPid}]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! test "${pidValid}" = "1"; then
|
||||
echo "stored PID [${storedPid}] was not reachable"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
# EOF
|
||||
@@ -0,0 +1,27 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Check that data can be just passed straight through.
|
||||
|
||||
# Dummy assignment for "shellcheck".
|
||||
testSubject="${testSubject:-false}"
|
||||
|
||||
inputString="TESTING"
|
||||
outputString=$(printf "%s" "${inputString}" | "${testSubject}" 2>/dev/null) || { echo "unexpected failure code"; exit 1; }
|
||||
|
||||
if ! test "${inputString}" = "${outputString}"; then
|
||||
echo "output did not match input"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Test again with --force.
|
||||
inputString="TESTINGAGAIN"
|
||||
outputString=$(printf "%s" "${inputString}" | "${testSubject}" -f 2>/dev/null) || { echo "unexpected failure code"; exit 1; }
|
||||
|
||||
if ! test "${inputString}" = "${outputString}"; then
|
||||
echo "output did not match input when using --force"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
# EOF
|
||||
@@ -0,0 +1,23 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Transfer a large chunk of data through pv and check data correctness
|
||||
# afterwards.
|
||||
|
||||
# Dummy assignments for "shellcheck".
|
||||
testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"; workFile2="${workFile2:-.tmp2}"
|
||||
|
||||
# generate some data
|
||||
dd if=/dev/urandom of="${workFile1}" bs=1024 count=10240 2>/dev/null
|
||||
|
||||
inputChecksum=$(cksum "${workFile1}" | awk '{print $1}')
|
||||
|
||||
# read through pv and test afterwards
|
||||
"${testSubject}" -B 100000 -q "${workFile1}" > "${workFile2}"
|
||||
|
||||
outputChecksum=$(cksum "${workFile2}" | awk '{print $1}')
|
||||
|
||||
test "${inputChecksum}" = "${outputChecksum}" || exit 1
|
||||
|
||||
exit 0
|
||||
|
||||
# EOF
|
||||
@@ -0,0 +1,56 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Transfer a large chunk of data through pv using pipes, sending it in a
|
||||
# bursty fashion, and check data correctness afterwards.
|
||||
|
||||
# Dummy assignments for "shellcheck".
|
||||
testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"; workFile2="${workFile2:-.tmp2}"
|
||||
|
||||
# generate some data
|
||||
dd if=/dev/urandom of="${workFile1}" bs=1024 count=10240 2>/dev/null
|
||||
|
||||
inputChecksum=$(cksum "${workFile1}" | awk '{print $1}')
|
||||
|
||||
# read through pv and test afterwards
|
||||
(
|
||||
dd if="${workFile1}" bs=1 count=9000
|
||||
sleep 1
|
||||
dd if="${workFile1}" bs=1 skip=9000 count=1240
|
||||
sleep 1
|
||||
dd if="${workFile1}" bs=1024 skip=10 count=1014
|
||||
sleep 1
|
||||
dd if="${workFile1}" bs=1024 skip=1024 count=1024
|
||||
sleep 1
|
||||
dd if="${workFile1}" bs=1024 skip=2048
|
||||
) 2>/dev/null | "${testSubject}" -q -L 2M | cat > "${workFile2}"
|
||||
|
||||
outputChecksum=$(cksum "${workFile2}" | awk '{print $1}')
|
||||
|
||||
if ! test "${inputChecksum}" = "${outputChecksum}"; then
|
||||
echo "checksum mismatch with dd | pv | cat"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# same again but with one less pipe
|
||||
(
|
||||
dd if="${workFile1}" bs=1 count=9000
|
||||
sleep 1
|
||||
dd if="${workFile1}" bs=1 skip=9000 count=1240
|
||||
sleep 1
|
||||
dd if="${workFile1}" bs=1024 skip=10 count=1014
|
||||
sleep 1
|
||||
dd if="${workFile1}" bs=1024 skip=1024 count=1024
|
||||
sleep 1
|
||||
dd if="${workFile1}" bs=1024 skip=2048
|
||||
) 2>/dev/null | "${testSubject}" -q -L 2M > "${workFile2}"
|
||||
|
||||
outputChecksum=$(cksum "${workFile2}" | awk '{print $1}')
|
||||
|
||||
if ! test "${inputChecksum}" = "${outputChecksum}"; then
|
||||
echo "checksum mismatch with dd | pv > file"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
# EOF
|
||||
@@ -0,0 +1,80 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Make sure that files larger than 2GB are supported.
|
||||
|
||||
# Dummy assignments for "shellcheck".
|
||||
testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"; workFile2="${workFile2:-.tmp2}"
|
||||
|
||||
# Check there is enough free space for this test.
|
||||
workFile1Dir="${workFile1%/*}"
|
||||
workFile1FreeKiB=$(df -kP "${workFile1Dir}" | sed -n '$p' | awk '{print $(NF-2)}')
|
||||
test -n "${workFile1FreeKiB}" || workFile1FreeKiB=0
|
||||
if ! test "${workFile1FreeKiB}" -gt 3300000 2>/dev/null; then
|
||||
echo "test requires at least 3GB free on ${workFile1Dir}"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# Generate a 3GB sparse file - we don't really need 3GB of free space unless
|
||||
# sparse files are not supported.
|
||||
true > "${workFile1}"
|
||||
if ! dd if="/dev/zero" of="${workFile1}" count=1 bs=1048576 seek=3072 2>/dev/null; then
|
||||
echo "failed to create 3GB specimen file"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# NB the "stat" command is not portable - BSD stat(1) has a different syntax
|
||||
# to GNU stat(1) - so we have to parse the output of ls(1).
|
||||
# shellcheck disable=SC2012
|
||||
fileSize=$(ls -nl "${workFile1}" 2>/dev/null | awk '{print $5}')
|
||||
test -n "${fileSize}" || fileSize=0
|
||||
if ! test "${fileSize}" -gt 3000000; then
|
||||
echo "failed to validate specimen file size"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# Transfer the file, and count how many bytes came through.
|
||||
bytesTransferred=$("${testSubject}" -n -b "${workFile1}" 2>"${workFile2}" | wc -c 2>/dev/null | tr -dc '0-9')
|
||||
test -n "${bytesTransferred}" || bytesTransferred=0
|
||||
bytesReported=$(sed -n '$p' "${workFile2}" | tr -dc '0-9')
|
||||
test -n "${bytesReported}" || bytesReported=0
|
||||
if ! test "${bytesTransferred}" -eq "${fileSize}"; then
|
||||
echo "transferred ${bytesTransferred} of ${fileSize} bytes"
|
||||
exit 1
|
||||
fi
|
||||
if ! test "${bytesReported}" -eq "${fileSize}"; then
|
||||
echo "counted ${bytesTransferred} of ${fileSize} bytes"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Transfer the file from stdin, and count how many bytes came through.
|
||||
bytesTransferred=$("${testSubject}" -n -b < "${workFile1}" 2>"${workFile2}" | wc -c 2>/dev/null | tr -dc '0-9')
|
||||
test -n "${bytesTransferred}" || bytesTransferred=0
|
||||
bytesReported=$(sed -n '$p' "${workFile2}" | tr -dc '0-9')
|
||||
test -n "${bytesReported}" || bytesReported=0
|
||||
if ! test "${bytesTransferred}" -eq "${fileSize}"; then
|
||||
echo "stdin - transferred ${bytesTransferred} of ${fileSize} bytes"
|
||||
exit 1
|
||||
fi
|
||||
if ! test "${bytesReported}" -eq "${fileSize}"; then
|
||||
echo "stdin - counted ${bytesTransferred} of ${fileSize} bytes"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Use the file as a size value and transfer its size of bytes from dev/zero,
|
||||
# and count how many bytes came through.
|
||||
bytesTransferred=$("${testSubject}" -n -b -S -s "@${workFile1}" /dev/zero 2>"${workFile2}" | wc -c 2>/dev/null | tr -dc '0-9')
|
||||
test -n "${bytesTransferred}" || bytesTransferred=0
|
||||
bytesReported=$(sed -n '$p' "${workFile2}" | tr -dc '0-9')
|
||||
test -n "${bytesReported}" || bytesReported=0
|
||||
if ! test "${bytesTransferred}" -eq "${fileSize}"; then
|
||||
echo "size read - transferred ${bytesTransferred} of ${fileSize} bytes"
|
||||
exit 1
|
||||
fi
|
||||
if ! test "${bytesReported}" -eq "${fileSize}"; then
|
||||
echo "size read - counted ${bytesReported} of ${fileSize} bytes"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
# EOF
|
||||
@@ -0,0 +1,40 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Check that there is no SIGPIPE or dropped data on bigger data transfers.
|
||||
|
||||
# Dummy assignments for "shellcheck".
|
||||
testSubject="${testSubject:-false}"
|
||||
|
||||
# We nead GNU head. On some platforms it is named ghead instead of head.
|
||||
HEAD="head"
|
||||
for checkPath in $(echo "${PATH}" | tr ':' '\n')
|
||||
do
|
||||
if test -x "${checkPath}/ghead"
|
||||
then
|
||||
HEAD="${checkPath}/ghead"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# Check that it really is GNU head, and skip the test if not.
|
||||
if ! echo | "${HEAD}" -c 10 >/dev/null 2>&1; then
|
||||
echo "GNU \`head' is required"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# Don't use dd. See http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=324308
|
||||
stopAtByteCount="100000000"
|
||||
#COUNT2=`"${testSubject}" -B 100000 -q /dev/zero | $HEAD -c $COUNT1 | wc -c | tr -d ' '`
|
||||
# We have to remove \n here, to fix the test on AIX.
|
||||
bytesTransferred=$("${testSubject}" -B 100000 -q /dev/zero | "${HEAD}" -c "${stopAtByteCount}" | tr -d '\n' | wc -c | tr -dc '0-9')
|
||||
|
||||
if ! test "${stopAtByteCount}" = "${bytesTransferred}"; then
|
||||
echo "number bytes transferred was not the expected value"
|
||||
echo "transferred: ${bytesTransferred}"
|
||||
echo "expected: ${stopAtByteCount}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
# EOF
|
||||
@@ -0,0 +1,61 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Try repeatedly messaging a transfer process, and make sure the data stays
|
||||
# intact.
|
||||
|
||||
# Dummy assignments for "shellcheck".
|
||||
testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"; workFile2="${workFile2:-.tmp2}"; workFile3="${workFile3:-.tmp3}"; workFile4="${workFile4:-.tmp4}"
|
||||
|
||||
# Do nothing if IPC is not supported.
|
||||
if ! "${testSubject}" -h 2>/dev/null | grep -Eq "^ -R,"; then
|
||||
echo "IPC is not supported on this platform"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# Generate some data.
|
||||
dd if=/dev/urandom of="${workFile1}" bs=1024 count=10240 2>/dev/null
|
||||
|
||||
# Run a few remote control commands in the background.
|
||||
#
|
||||
echo FAIL > "${workFile3}"
|
||||
(
|
||||
set +e
|
||||
sleep 2
|
||||
for loopCount in 1 2 3; do
|
||||
"${testSubject}" -R "$(cat "${workFile4}")" -apterb || exit 1
|
||||
(usleep 200000 || sleep 1) 2>/dev/null
|
||||
"${testSubject}" -R "$(cat "${workFile4}")" -p || exit 1
|
||||
(usleep 200000 || sleep 1) 2>/dev/null
|
||||
"${testSubject}" -R "$(cat "${workFile4}")" -N "test" || exit 1
|
||||
(usleep 200000 || sleep 1) 2>/dev/null
|
||||
"${testSubject}" -R "$(cat "${workFile4}")" -F "%e" || exit 1
|
||||
(usleep 200000 || sleep 1) 2>/dev/null
|
||||
"${testSubject}" -R "$(cat "${workFile4}")" -N "." || exit 1
|
||||
(usleep 200000 || sleep 1) 2>/dev/null
|
||||
echo "${loopCount}" >/dev/null # dummy for shellcheck
|
||||
done
|
||||
"${testSubject}" -R "$(cat "${workFile4}")" -L 10M
|
||||
echo OK > "${workFile3}"
|
||||
) &
|
||||
|
||||
# Run our data transfer.
|
||||
"${testSubject}" -L 100k -i 0.1 -f -P "${workFile4}" "${workFile1}" > "${workFile2}" 2>/dev/null
|
||||
|
||||
# Check our remote control calls ran OK.
|
||||
backgroundStatus=$(cat "${workFile3}")
|
||||
if ! test "${backgroundStatus}" = "OK"; then
|
||||
echo "remote control calls failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check data integrity.
|
||||
inputChecksum=$(cksum "${workFile1}" | awk '{print $1}')
|
||||
outputChecksum=$(cksum "${workFile2}" | awk '{print $1}')
|
||||
if ! test "${inputChecksum}" = "${outputChecksum}"; then
|
||||
echo "input and output checksums differ"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
# EOF
|
||||
@@ -0,0 +1,55 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Transfer a large chunk of data with "--direct-io" and check data
|
||||
# correctness afterwards, both with and without rate limits. Note that this
|
||||
# doesn't check that O_DIRECT is actually being used, it just checks that
|
||||
# data is not being corrupted.
|
||||
|
||||
# Dummy assignments for "shellcheck".
|
||||
testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"; workFile2="${workFile2:-.tmp2}"
|
||||
|
||||
# generate some data
|
||||
dd if=/dev/urandom of="${workFile1}" bs=1024 count=2560 2>/dev/null
|
||||
|
||||
inputChecksum=$(cksum "${workFile1}" | awk '{print $1}')
|
||||
doubleInputChecksum=$(cat "${workFile1}" "${workFile1}" | cksum - | awk '{print $1}')
|
||||
|
||||
# read through pv and test afterwards
|
||||
"${testSubject}" -q "${workFile1}" > "${workFile2}"
|
||||
outputChecksum=$(cksum "${workFile2}" | awk '{print $1}')
|
||||
|
||||
if ! test "${inputChecksum}" = "${outputChecksum}"; then
|
||||
echo "checksum mismatched even without \"--direct-io\""
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Same again but with "--direct-io"
|
||||
|
||||
"${testSubject}" -K -q "${workFile1}" > "${workFile2}"
|
||||
outputChecksum=$(cksum "${workFile2}" | awk '{print $1}')
|
||||
if ! test "${inputChecksum}" = "${outputChecksum}"; then
|
||||
echo "checksum mismatched with \"--direct-io\""
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Now with "--direct-io" and "--rate-limit"
|
||||
|
||||
"${testSubject}" -K -L 800K -q "${workFile1}" > "${workFile2}"
|
||||
outputChecksum=$(cksum "${workFile2}" | awk '{print $1}')
|
||||
if ! test "${inputChecksum}" = "${outputChecksum}"; then
|
||||
echo "checksum mismatched with \"--direct-io\" + \"--rate-limit\""
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Now with "--direct-io" on the same file twice
|
||||
|
||||
"${testSubject}" -K -q "${workFile1}" "${workFile1}" > "${workFile2}"
|
||||
outputChecksum=$(cksum "${workFile2}" | awk '{print $1}')
|
||||
if ! test "${doubleInputChecksum}" = "${outputChecksum}"; then
|
||||
echo "checksum mismatched with \"--direct-io\" on two files"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
# EOF
|
||||
@@ -0,0 +1,36 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Check that the progress bar is produced when "--force" is used, and is not
|
||||
# when it is not, providing stderr is a file.
|
||||
|
||||
# Dummy assignments for "shellcheck".
|
||||
testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}";
|
||||
|
||||
dd if=/dev/zero bs=100 count=1 2>/dev/null \
|
||||
| "${testSubject}" -f -p -i 0.1 -L 100 >/dev/null 2>"${workFile1}"
|
||||
|
||||
# There should be more than 2 different lines of output.
|
||||
#
|
||||
lineCount=$(tr '\r' '\n' < "${workFile1}" | sort | uniq -u | wc -l | tr -dc '0-9')
|
||||
if ! test "${lineCount}" -gt 2; then
|
||||
echo "fewer than 3 different progress lines with \"--force\" (${lineCount})"
|
||||
tr '\r' '\n' < "${workFile1}" | sort | uniq -u
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Now try again without "--force".
|
||||
|
||||
dd if=/dev/zero bs=100 count=1 2>/dev/null \
|
||||
| "${testSubject}" -p -i 0.1 -L 100 >/dev/null 2>"${workFile1}"
|
||||
|
||||
# There should be no output without "--force".
|
||||
#
|
||||
if test -s "${workFile1}"; then
|
||||
echo "unexpected output when not using \"--force\""
|
||||
tr '\r' '\n' < "${workFile1}" | sort | uniq -u
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
# EOF
|
||||
@@ -0,0 +1,21 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Check that the update interval can be set.
|
||||
|
||||
# Dummy assignments for "shellcheck".
|
||||
testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"
|
||||
|
||||
sleep 1 | "${testSubject}" -f -i 0.1 >/dev/null 2>"${workFile1}"
|
||||
|
||||
# There should be more than 6 lines of output.
|
||||
#
|
||||
lineCount=$(tr '\r' '\n' < "${workFile1}" | wc -l | tr -dc '0-9')
|
||||
if ! test "${lineCount}" -gt 6; then
|
||||
echo "fewer than 7 lines of output"
|
||||
tr '\r' '\n' < "${workFile1}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
# EOF
|
||||
@@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Check that line mode counts lines instead of bytes.
|
||||
|
||||
# Dummy assignments for "shellcheck".
|
||||
testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"
|
||||
|
||||
# Pass through 100 lines.
|
||||
#
|
||||
seq 1 100 \
|
||||
| "${testSubject}" -bl -i 0.2 -f -L 50 >/dev/null 2>"${workFile1}"
|
||||
|
||||
lineCount=$(tr '\r' '\n' < "${workFile1}" | sort | uniq -u | wc -l | tr -dc '0-9')
|
||||
lastNumber=$(tr '\r' '\n' < "${workFile1}" | awk '/[0-9]/{printf "%.0f\n",$1}' | sed -n '$p')
|
||||
|
||||
# The last number output should be the number of input lines.
|
||||
if ! test "${lastNumber}" = "100"; then
|
||||
echo "line counter was incorrect (${lastNumber} instead of 100)"
|
||||
tr '\r' '\n' < "${workFile1}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# There should be more than 3 output lines as the counter increased.
|
||||
if ! test "${lineCount}" -gt 3; then
|
||||
echo "fewer than 4 line counter values (${lineCount})"
|
||||
tr '\r' '\n' < "${workFile1}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
# EOF
|
||||
@@ -0,0 +1,56 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Check that "--size" affects the percentage shown.
|
||||
|
||||
# Dummy assignments for "shellcheck".
|
||||
testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"
|
||||
|
||||
# Process 100 bytes at 100 bytes per second, updating every 0.1 seconds for
|
||||
# around 10 output lines, but set the size to 200.
|
||||
#
|
||||
dd if=/dev/zero bs=100 count=1 2>/dev/null \
|
||||
| "${testSubject}" -s 200 -n -i 0.1 -L 100 >/dev/null 2>"${workFile1}"
|
||||
|
||||
lineCount=$(wc -l < "${workFile1}" | tr -dc '0-9')
|
||||
finalLine=$(sed -n '$p' < "${workFile1}")
|
||||
|
||||
# The number of output lines should be >8 and <13, and the final percentage
|
||||
# should be 50.
|
||||
#
|
||||
if ! test "${lineCount}" -gt 8; then
|
||||
echo "part 1: fewer than 9 output lines (${lineCount})"
|
||||
exit 1
|
||||
fi
|
||||
if ! test "${lineCount}" -lt 13; then
|
||||
echo "part 1: more than 12 output lines (${lineCount})"
|
||||
exit 1
|
||||
fi
|
||||
if ! test "${finalLine}" = "50"; then
|
||||
echo "part 1: final percentage was not 50 (${finalLine})"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Same as above, but this time with a size of 50 for 100 input bytes.
|
||||
#
|
||||
dd if=/dev/zero bs=100 count=1 2>/dev/null \
|
||||
| "${testSubject}" -s 50 -n -i 0.1 -L 100 >/dev/null 2>"${workFile1}"
|
||||
|
||||
lineCount=$(wc -l < "${workFile1}" | tr -dc '0-9')
|
||||
finalLine=$(sed -n '$p' < "${workFile1}")
|
||||
|
||||
if ! test "${lineCount}" -gt 8; then
|
||||
echo "part 2: fewer than 9 output lines (${lineCount})"
|
||||
exit 1
|
||||
fi
|
||||
if ! test "${lineCount}" -lt 13; then
|
||||
echo "part 2: more than 12 output lines (${lineCount})"
|
||||
exit 1
|
||||
fi
|
||||
if ! test "${finalLine}" = "200"; then
|
||||
echo "part 2: final percentage was not 200 (${finalLine})"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
# EOF
|
||||
@@ -0,0 +1,49 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Similar to the "--size" check but, instead, using another file's size with
|
||||
# "--size @".
|
||||
|
||||
# Dummy assignments for "shellcheck".
|
||||
testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"; workFile2="${workFile2:-.tmp2}"
|
||||
|
||||
# Process 100 bytes at 100 bytes per second, interval 0.1 seconds, with the
|
||||
# size set from a file of $1 bytes and expecting a percentage of $2 at the
|
||||
# end.
|
||||
sizeCheck () {
|
||||
# Make a file of size $1 bytes, for reference.
|
||||
dd if=/dev/zero bs="$1" count=1 2>/dev/null >"${workFile2}"
|
||||
|
||||
# Run 100 bytes through the program, using the reference file's size
|
||||
# as the percentage reference.
|
||||
dd if=/dev/zero bs=100 count=1 2>/dev/null \
|
||||
| "${testSubject}" -s "@${workFile2}" -n -i 0.1 -L 100 >/dev/null 2>"${workFile1}"
|
||||
|
||||
lineCount=$(wc -l < "${workFile1}" | tr -dc '0-9')
|
||||
finalLine=$(sed -n '$p' < "${workFile1}")
|
||||
|
||||
# The number of output lines should be >5 and <13, and the final
|
||||
# percentage should be $2.
|
||||
#
|
||||
if ! test "${lineCount}" -gt 5; then
|
||||
echo "(reference size=$1) fewer than 6 output lines (${lineCount})"
|
||||
exit 1
|
||||
fi
|
||||
if ! test "${lineCount}" -lt 13; then
|
||||
echo "(reference size=$1) more than 12 output lines (${lineCount})"
|
||||
exit 1
|
||||
fi
|
||||
if ! test "${finalLine}" = "$2"; then
|
||||
echo "(reference size=$1): final percentage was not $2 (${finalLine})"
|
||||
ls -l "${workFile2}"
|
||||
cat "${workFile1}"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
sizeCheck 100 100
|
||||
sizeCheck 200 50
|
||||
sizeCheck 50 200
|
||||
|
||||
exit 0
|
||||
|
||||
# EOF
|
||||
@@ -0,0 +1,45 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Transfer a large chunk of data with "--sync" and check data correctness
|
||||
# afterwards, both with and without rate limits. Note that this doesn't
|
||||
# check that fdatasync() is actually being called, it just checks that data
|
||||
# is not being corrupted.
|
||||
|
||||
# Dummy assignments for "shellcheck".
|
||||
testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"; workFile2="${workFile2:-.tmp2}"
|
||||
|
||||
# generate some data
|
||||
dd if=/dev/urandom of="${workFile1}" bs=1024 count=2560 2>/dev/null
|
||||
|
||||
inputChecksum=$(cksum "${workFile1}" | awk '{print $1}')
|
||||
|
||||
# read through pv and test afterwards
|
||||
"${testSubject}" -q "${workFile1}" > "${workFile2}"
|
||||
outputChecksum=$(cksum "${workFile2}" | awk '{print $1}')
|
||||
|
||||
if ! test "${inputChecksum}" = "${outputChecksum}"; then
|
||||
echo "checksum mismatched even without \"--sync\""
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Same again but with "--sync"
|
||||
|
||||
"${testSubject}" -Y -q "${workFile1}" > "${workFile2}"
|
||||
outputChecksum=$(cksum "${workFile2}" | awk '{print $1}')
|
||||
if ! test "${inputChecksum}" = "${outputChecksum}"; then
|
||||
echo "checksum mismatched with \"--sync\""
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Now with "--sync" and "--rate-limit"
|
||||
|
||||
"${testSubject}" -Y -L 800K -q "${workFile1}" > "${workFile2}"
|
||||
outputChecksum=$(cksum "${workFile2}" | awk '{print $1}')
|
||||
if ! test "${inputChecksum}" = "${outputChecksum}"; then
|
||||
echo "checksum mismatched with \"--sync\" + \"--rate-limit\""
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
# EOF
|
||||
@@ -0,0 +1,21 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# A simple test of rate limiting.
|
||||
|
||||
# Dummy assignments for "shellcheck".
|
||||
testSubject="${testSubject:-false}"
|
||||
|
||||
# Transfer 102 bytes at 100 bytes/sec. It should take at least 1 second.
|
||||
#
|
||||
startTime=$(date +%S)
|
||||
dd if=/dev/zero bs=102 count=1 2>/dev/null | "${testSubject}" -L 100 2>/dev/null | cat >/dev/null
|
||||
endTime=$(date +%S)
|
||||
|
||||
if test "${startTime}" = "${endTime}"; then
|
||||
echo "transfer took zero seconds"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
# EOF
|
||||
@@ -0,0 +1,36 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Try changing the format of a transfer remotely.
|
||||
|
||||
# Dummy assignments for "shellcheck".
|
||||
testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"; workFile2="${workFile2:-.tmp2}"; workFile3="${workFile3:-.tmp3}"; workFile4="${workFile4:-.tmp4}"
|
||||
|
||||
# Do nothing if IPC is not supported.
|
||||
if ! "${testSubject}" -h 2>/dev/null | grep -Eq "^ -R,"; then
|
||||
echo "IPC is not supported on this platform"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# Generate an empty test file.
|
||||
dd if=/dev/zero of="${workFile1}" bs=1024 count=10240 2>/dev/null
|
||||
|
||||
(
|
||||
sleep 1
|
||||
"${testSubject}" -R "$(cat "${workFile4}")" -a
|
||||
sleep 2
|
||||
"${testSubject}" -R "$(cat "${workFile4}")" -L 10M
|
||||
) &
|
||||
|
||||
"${testSubject}" -L 2M -f -P "${workFile4}" "${workFile1}" > "${workFile2}" 2>"${workFile3}"
|
||||
|
||||
# Make sure there is more than one length of line (excluding blank lines).
|
||||
line_lengths=$(tr '\r' '\n' < "${workFile3}" | awk '{print length($0)}' | grep -Fvx 0 | sort -n | uniq | wc -l | tr -dc '0-9')
|
||||
|
||||
if ! test "${line_lengths}" -gt 1; then
|
||||
echo "only one line length seen - format change failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
# EOF
|
||||
@@ -0,0 +1,27 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Make sure -S stops at the given size.
|
||||
|
||||
# Dummy assignments for "shellcheck".
|
||||
testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"; workFile2="${workFile2:-.tmp2}"
|
||||
|
||||
# generate some data
|
||||
dd if=/dev/urandom of="${workFile1}" bs=1024 count=10 2>/dev/null
|
||||
|
||||
# read through pv and test afterwards
|
||||
"${testSubject}" -S -s 5120 -q "${workFile1}" > "${workFile2}"
|
||||
|
||||
outputChecksum=$(cksum "${workFile2}" | awk '{print $1}')
|
||||
|
||||
# take the first 5120 bytes of workFile1 and cksum them
|
||||
dd if="${workFile1}" of="${workFile2}" bs=1024 count=5 2>/dev/null
|
||||
inputChecksum=$(cksum "${workFile2}" | awk '{print $1}')
|
||||
|
||||
if ! test "${inputChecksum}" = "${outputChecksum}"; then
|
||||
echo "input and output checksums differ"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
# EOF
|
||||
Reference in New Issue
Block a user