151 Commits
Author SHA1 Message Date
Andrew Wood 303d3ea359 Corrected Markdown list formatting. 2023-07-30 20:11:30 +01:00
Andrew Wood 318954d21e Add link to issue describing terminal sizing bug. 2023-07-30 20:04:17 +01:00
Andrew Wood 85dd2603bf Added DEVELOPERS.md. 2023-07-30 19:59:19 +01:00
Andrew Wood b6c797af1a Track position movements due to reformatting. 2023-07-30 19:22:00 +01:00
Andrew Wood 40b9ef2a9d Version update for new release. 2023-07-30 18:56:09 +01:00
Andrew Wood 146add0ed3 Check for termios.h so that HAVE_TERMIOS_H is defined, otherwise terminal size detection is broken on Cygwin (issue GH#72). 2023-07-30 16:54:35 +01:00
Andrew Wood 911969c2a8 Cast char to int in isdigit() to satisfy GCC on Cygwin. 2023-07-30 16:52:31 +01:00
Andrew Wood 4b3b49806f Added notes about code reformatting, and "--help" word wrapping. 2023-07-29 22:37:16 +01:00
Andrew Wood 943c05a8a0 Reformatted with "indent" to a line length of 120. 2023-07-29 22:21:32 +01:00
Andrew Wood 630d92fef6 Added splint annotation. 2023-07-29 22:19:43 +01:00
Andrew Wood 34fe796806 Refactored "--help" to support multi-byte character locales when word wrapping, and clear all "splint" and "flawfinder" warnings. 2023-07-29 21:32:34 +01:00
Andrew Wood 907b449c6b Set line length to 120 in "make indent". 2023-07-29 21:29:22 +01:00
Andrew Wood b59b1bad4b Added note about DEBUG. 2023-07-28 23:16:41 +01:00
Andrew Wood 7e374be0d7 Minor spacing changes due to "indent". 2023-07-28 23:15:09 +01:00
Andrew Wood b9f96d9508 Provide new option "--debug" instead of using insecure environment variable DEBUG. 2023-07-28 23:14:14 +01:00
Andrew Wood 08a8c2ea70 Version bump and first changes listed. 2023-07-28 22:36:42 +01:00
Andrew Wood 1f103d6a11 Include POSIX library in splint calls. 2023-07-28 22:35:50 +01:00
Andrew Wood 7f3924db77 Added "make analyse" to run analysis tools on the source. 2023-07-28 22:28:07 +01:00
Andrew Wood cd9f057f15 Removed incorrect undef HAVE_STDBOOL_H which caused standard boolean types to be redefined unnecessarily. 2023-07-28 21:55:57 +01:00
Andrew Wood 7088833627 Closed issue #70 - the problem was successfully reproduced with 1.7.0 and then observed to have been resolved in 1.7.18. 2023-07-28 21:38:42 +01:00
Andrew Wood 57f8daff30 Closed issue #69 - confirmation received that this is fixed in 1.7.18. 2023-07-28 21:33:12 +01:00
Andrew Wood 275cc6c10d Updated "make release" to sign using a specific key, and only do tar.gz files. 2023-07-28 17:57:55 +01:00
Andrew Wood 8491b5cdd5 Updated "make release" for upcoming change. 2023-07-28 17:50:12 +01:00
Andrew Wood 6496c8785b Removed an obsolete step. 2023-07-28 17:40:44 +01:00
Andrew Wood 506ec4a8ec Updating as a result of msgmerge during release. 2023-07-28 17:34:29 +01:00
Andrew Wood 5a140b689f Updated for new release 2023-07-28 11:10:30 +01:00
Andrew Wood 38ddb5e32a Corrected language list in NLS support. 2023-07-28 11:08:49 +01:00
Andrew Wood 173de4fafd Bump version for new release. 2023-07-27 22:19:42 +01:00
Andrew Wood ae81f83e9b New option "--direct-io". 2023-07-27 21:44:30 +01:00
Andrew Wood 9f07a28065 Formatting fix for short multiline test output on wide terminals 2023-07-27 21:11:08 +01:00
Andrew Wood 60913618be Adjust lower threshold in case of heavy load during testing. 2023-07-27 20:49:14 +01:00
Andrew Wood 43dc9d6469 Added test for "--sync" 2023-07-26 22:43:00 +01:00
Andrew Wood 6cff3c1c2a First draft of new "--sync" option. 2023-07-26 22:17:00 +01:00
Andrew Wood caf7d6ff18 Unreleased version bump 2023-07-25 22:41:41 +01:00
Andrew Wood d343669f45 Added note about adding more tests. 2023-07-25 22:39:48 +01:00
Andrew Wood ecaa5ce6cd Added test 2023-07-25 22:19:15 +01:00
Andrew Wood e5b5e67e57 Added test 2023-07-25 22:06:31 +01:00
Andrew Wood 1efe1d60b5 Added test 2023-07-25 21:43:29 +01:00
Andrew Wood f83927e451 Add more tests 2023-07-25 21:21:37 +01:00
Andrew Wood 678f655116 Also test basic integrity with --force 2023-07-25 21:21:02 +01:00
Andrew Wood 7794df7182 Capitalisation fix 2023-07-24 23:16:52 +01:00
Andrew Wood 923ef47056 Progress update 2023-07-24 23:15:09 +01:00
Andrew Wood 0a509fb535 Cleaned up with shellcheck, and corrected the description in the comment block at the top. 2023-07-24 23:08:18 +01:00
Andrew Wood 1927e88350 Minor shellcheck-suggested update. 2023-07-24 22:30:49 +01:00
Andrew Wood 760ee403fe Variable name modernisation, and shellcheck corrections. 2023-07-24 22:29:18 +01:00
Andrew Wood 6ecf31b5ee Cleanups suggested by shellcheck. 2023-07-24 21:50:22 +01:00
Andrew Wood 8051f5808c Cleanups suggested by shellcheck. 2023-07-24 21:48:23 +01:00
Andrew Wood 0518357560 Make the --numeric --bytes --line-mode combination more explicitly defined 2023-07-24 20:57:31 +01:00
Andrew Wood e0856df8ef Fix rate display width when it is exactly 0 in bytes mode. 2023-07-23 22:29:09 +01:00
Andrew Wood d4590e1f3b New tests added 2023-07-23 22:00:19 +01:00
Andrew Wood 99c5e0988c Additional formatting improvements 2023-07-23 21:59:25 +01:00
Andrew Wood 6a24d75022 Add more verbose output and apply fixes suggested by shellcheck. 2023-07-23 18:45:53 +01:00
Andrew Wood 82aa30c306 Add more verbose output and apply fixes suggested by shellcheck. 2023-07-23 18:35:49 +01:00
Andrew Wood 4fa3331f88 Explicitly set locale for tests 2023-07-23 17:59:38 +01:00
Andrew Wood fd0850f1ab Correction to the detection of this bug 2023-07-23 17:16:29 +01:00
Andrew Wood cecc8649c2 Further display improvements and cleanups 2023-07-23 17:16:04 +01:00
Andrew Wood c39e97ec5a Fix byte prefix at low rates so it is two spaces, not one 2023-07-23 17:13:14 +01:00
Andrew Wood 909355619b Restructure tests and adjust display format, to better understand what each test is testing. 2023-07-23 16:25:52 +01:00
Andrew Wood b086ddf599 Rewrote most of run-test, and gave variables clearer names 2023-07-23 14:54:45 +01:00
Andrew Wood a0e5d5e9e7 Rebuild timestamp update 2023-07-23 14:27:19 +01:00
Andrew Wood dbcae4a9ae Updated with latest news 2023-07-23 12:34:39 +01:00
Andrew Wood 4ba1343c20 Added test of large file support 2023-07-23 12:28:11 +01:00
Andrew Wood ee3c02fd7f Renamed tests for consistency 2023-07-23 11:41:56 +01:00
Andrew Wood c7e0bb727e Introduce strlcat() instead of strcat(), and replace all sizeof() of buffers inside structures with constants where possible, to avoid bugs caused by reading the size of a pointer instead of the size of the buffer it points to. 2023-07-23 01:57:00 +01:00
Andrew Wood 80e3f791c4 Rebuilt automatically 2023-07-23 01:50:04 +01:00
Andrew Wood 74325282e7 Corrected quoting issue in sed 2023-07-23 01:49:48 +01:00
Andrew Wood ab20f9406f Corrected path handling which was writing bad dependency files 2023-07-23 00:35:49 +01:00
Andrew Wood e94600d7a4 Put all terminal writes through the same pv_write_retry function for consistency and to clear up compiler warnings. 2023-07-22 23:22:34 +01:00
Andrew Wood 9783f7ebef Cleanups to fscanf() and Apple-specific watchfd code 2023-07-22 22:53:02 +01:00
Andrew Wood b6d1f62979 Centralise all sprintf()/snprintf() calls in a compatibility wrapper pv_snprintf() 2023-07-22 22:40:07 +01:00
Andrew Wood cab177814a Document the cleanups to "make test". 2023-07-22 20:49:25 +01:00
Andrew Wood 2303da77db Skip the pipe test if GNU head is not available. 2023-07-22 20:46:51 +01:00
Andrew Wood 264e3a5879 Format output with printf, allow test scripts to write output to be displayed, and allow test scripts to be skipped. 2023-07-22 20:46:35 +01:00
Andrew Wood 5f6f418cfd Added backticks note 2023-07-22 20:21:42 +01:00
Andrew Wood 3b2e274907 Check for ctags and cproto before starting any work 2023-07-22 20:20:48 +01:00
Andrew Wood a24342a072 Replace backticks in shell scripts with S() 2023-07-22 20:20:15 +01:00
Andrew Wood 101294195b Remove references to 64-bit file functions - stat, lstat, lseek, etc - as part of large file support rewrite. 2023-07-22 19:55:55 +01:00
Andrew Wood 5cf5eda406 Minor correction to cleanup. 2023-07-22 19:55:07 +01:00
Andrew Wood 8c284d863d TODO and version update to show unreleased status 2023-07-22 19:45:57 +01:00
Andrew Wood 7448c7f320 Rewrote configure.in and replaced header.in with one generated by autoheader, added copyright notice to all source files as per GNU standards, and changed "pv --version" output to conform to GNU standards. 2023-07-22 19:35:43 +01:00
Andrew Wood b923afc385 Added the new issues after 1.7.0 2023-07-18 07:29:32 +01:00
Andrew Wood 88dd09393c Set current release line 2023-07-17 22:05:29 +01:00
Andrew Wood 29124c585e Minor updates 2023-07-17 21:57:56 +01:00
Andrew Wood 65828899ea Version update pending new release 2023-07-17 21:53:54 +01:00
Andrew Wood 853190d36d Updated acknowledgements for stat64 patch 2023-07-17 21:48:16 +01:00
Andrew Wood f13f5e70c1 More macOS stat fixes 2023-07-17 21:37:54 +01:00
Andrew Wood 4e2ab087e5 Removed bug about no Cygwin output as it is not reproducible 2023-07-17 21:29:17 +01:00
Andrew Wood 242c19e4f6 Remove GH#27 as the rate limit changes have corrected this fault 2023-07-17 20:49:38 +01:00
Andrew Wood 3003f46313 Removed code that was making percentages go down after 100% in numeric mode 2023-07-17 12:28:32 +01:00
Andrew Wood c718a00e2c Note the translation file updates 2023-07-16 23:28:47 +01:00
Andrew Wood 01f627b2de Recoded Polish PO file from ISO8859-2 to UTF-8, and removed potentially incorrect fuzzy matches from all PO files 2023-07-16 23:24:53 +01:00
Andrew Wood 461486ec4f Added --bits option 2023-07-16 23:12:12 +01:00
Andrew Wood fd46c9b1f6 Update manual month and year 2023-07-16 22:44:33 +01:00
Andrew Wood 001dfb71c2 Show elapsed time as D:HH:MM:SS after 1 day, to match the ETA format 2023-07-16 22:29:18 +01:00
Andrew Wood bcb33ce2aa Honour the --force setting when writing the progress display 2023-07-16 21:58:08 +01:00
Andrew Wood c8090806f9 Added debugging output to pv_in_foreground() 2023-07-16 21:31:17 +01:00
Andrew Wood 3403ebd857 Adjust threshold to cope with new ETA calculation mechanism 2023-07-16 21:16:02 +01:00
Andrew Wood 4fddf40436 Rename --eta-window to --average-rate-window, since that is what it does, and correct the behaviour of the final update so the final rate shown is the average rate across the whole transfer. 2023-07-16 21:00:08 +01:00
Andrew Wood 62b5ac26df Reverse the average rate history early-return logic to make it easier to understand 2023-07-16 20:49:59 +01:00
Andrew Wood e8c0b6717f Update documentation regarding ETA issues 2023-07-16 12:27:20 +01:00
Andrew Wood 2bf76577dd Remove assertions from ETA history, set minimum boundary on ETA window, check for history structure allocation success 2023-07-16 12:14:07 +01:00
Andrew Wood 90d9638488 Minor format changes as per indent(1) standardisation 2023-07-16 11:53:36 +01:00
Andrew WoodandGitHub f6d0135cc6 Merge pull request #65 from lemonsqueeze/eta_fix
Alter ETA calculation to use the rate over the past 30 seconds instead of over the whole transfer, and allow that 30 second window to be adjusted.
2023-07-16 11:46:23 +01:00
Andrew WoodandGitHub 56adce8edf Merge branch 'main' into eta_fix 2023-07-16 11:41:50 +01:00
Andrew Wood 008ee74a98 Update documentation to reflex bug fix GH#62, GH#32 2023-07-16 11:33:44 +01:00
Andrew Wood fa8aa85248 Merge branch 'vbychkoviak-main' into main 2023-07-16 11:24:06 +01:00
Andrew Wood 442a298c38 Merge branch 'main' of https://github.com/vbychkoviak/pv into vbychkoviak-main 2023-07-16 11:23:46 +01:00
Andrew Wood bb0c5bdfca Applied standard indent(1) settings 2023-07-16 11:20:03 +01:00
Andrew Wood 29908cff6c Remove "-s @" / issue 44 from TODO list 2023-07-16 11:14:05 +01:00
Andrew Wood 456ab7cebb Applied OS X 11 stat64 configure.in patch from Dave Beckett 2023-07-16 11:11:09 +01:00
Andrew Wood 0d1d5b77ec Applied patch from Dave Beckett to support "@filename" as a "--size" argument. 2023-07-16 11:07:06 +01:00
Andrew Wood ff5efbe3eb Added issue #56 2023-07-16 01:54:00 +01:00
Andrew Wood 81d008a325 Updated to include mention of latest pull request 2023-07-16 01:43:07 +01:00
Andrew Wood 288dd633d7 Merge branch 'christoph-zededa-mac_os_x_pidfds' into main 2023-07-16 01:37:21 +01:00
Andrew Wood 9dce037cdc Merge branch 'mac_os_x_pidfds' of https://github.com/christoph-zededa/pv into christoph-zededa-mac_os_x_pidfds 2023-07-16 01:37:08 +01:00
Andrew Wood 6ae07496d2 Minor formatting fixes 2023-07-16 01:35:58 +01:00
Andrew Wood cd60822380 Convert issue numbers to links, and bring the feature request list up to date. 2023-07-16 01:30:50 +01:00
Andrew Wood 0fdd9f0787 Formatting fix 2023-07-16 01:03:47 +01:00
Andrew Wood 0d520172ac Added new contributors and cleaned up formatting 2023-07-16 01:02:50 +01:00
Andrew Wood 04ea58f786 Added details of latest pull request 2023-07-16 00:56:24 +01:00
Andrew Wood 94a9f658e1 Merge branch 'quitschbo-main' into main 2023-07-16 00:47:52 +01:00
Andrew Wood 0ec9e208df Merge branch 'main' of https://github.com/quitschbo/pv into quitschbo-main 2023-07-16 00:47:33 +01:00
Andrew Wood 4c84060940 Markdown formatting cleanups 2023-07-16 00:44:21 +01:00
Andrew Wood 8fb3aecde5 Finalise pull from ikasty to show relative filenames in --watchfd 2023-07-16 00:28:58 +01:00
Andrew Wood e228b3397d Merge branch 'ikasty-main' into main 2023-07-16 00:16:03 +01:00
Andrew Wood d1d1999334 Merge branch 'main' of https://github.com/ikasty/pv into ikasty-main 2023-07-16 00:14:34 +01:00
Andrew Wood 685c91a1cb NEWS was renamed to NEWS.md. 2023-07-16 00:04:33 +01:00
Andrew Wood 50c0b329c9 Moved NEWS and TODO to UTF-8 Markdown format, and linked them in from the README. 2023-07-16 00:00:19 +01:00
Andrew Wood 5c8e2707a4 Removed support for Red Hat Enterprise Linux package builds 2023-07-15 23:41:27 +01:00
Kang Daeyoun 5768166460 Use relative filepath in watchpid if possible 2023-06-09 12:32:59 +09:00
lemonsqueeze 6bdb951af4 Added -m, --eta-window option: set time window for average rate computation (default 30s) 2023-05-29 15:11:37 +02:00
lemonsqueeze 06824aee2d Fixed inaccurate ETAs: use current average rate over last 30 seconds instead of global rate
using global rate gives wildly inacurrate ETAs if rate changes over time.

this makes pv keep a history of progress over the last 30s interval and compute
current average rate over that, which fixes the issue.

fixed -a, --average-rate: show current average rate instead of global rate

[ quick test ]

- in one shell:
    $ dd if=/dev/zero of=/tmp/foo bs=1M count=5                 # simulate fast initial rate,
    $ (while true; do ls /*; sleep 1; done) >> /tmp/foo         # then slow rate. leave running ...

- in another shell:
    $ tail -f -n +1 /tmp/foo | pv -s 800M > /dev/null

    5.62MiB 0:00:17 [33.1KiB/s] [>                              ]  0% ETA 0:40:02
        bad:  (pv 1.6.6 - 1.6.20)
        ETA of a few minutes that keeps increasing ever and ever ...

    5.62MiB 0:00:16 [33.1KiB/s] [>                              ]  0% ETA 6:45:53
        good:
        ETA of 6+ hours, which is how long it'll take to reach 800Mb at 33k/s
2023-05-29 15:09:36 +02:00
Michael Weiß c5cd932fb0 pv/display: handle error of tcgetpgrp() in pv_in_foreground()
Show pv progress bar even if no terminal is set, e.g., in a busybox
init script. The description of pv_in_forground() states it will
return true "if we aren't outputting to a terminal". However, this
is not the case since tcgetpgrg() will return an error and set ERRNO
to ENOTTY if the output fd is not an tty. We now handle this error
correctly and pv_in_foreground() returns also true in that case.

Signed-off-by: Michael Weiß <michael.weiss@aisec.fraunhofer.de>
2023-05-10 09:54:59 +02:00
Volodymyr Bychkovyak a6ecf60ad1 fix rate limiting issues 2023-03-22 02:49:46 -07:00
Christoph Ostarek b0cad6d3e3 implement fd watching for OS X 2023-02-19 18:20:00 +01:00
Andrew Wood a9cef81657 Minor formatting corrections 2022-05-29 21:52:15 +01:00
Andrew Wood cc95aa67a3 Renamed README to README.md and altered it to Markdown format; moved contributors from the README to docs/ACKNOWLEDGEMENTS.md 2022-05-29 21:45:13 +01:00
Andrew Wood b78e58ab87 Moved all open issues into the GitHub issue tracker and copied in all related correspondence. 2022-05-29 21:00:43 +01:00
Andrew Wood 12d22b5ab0 Acknowledged new pull request 2022-05-29 17:12:09 +01:00
Andrew Wood 3255f72f39 Merge branch 'jwilk-forks-mojibake' into main 2022-05-29 12:47:33 +01:00
Jakub Wilk c79eb8540a Fixed encoding in README 2022-04-11 23:08:21 +02:00
Andrew Wood 0ca8ef5187 Dates bumped for release of 1.6.20 2021-09-12 17:13:24 +01:00
Andrew Wood 386e3ac5fa Updated to include details of latest contributor 2021-09-08 17:26:13 +01:00
Andrew Wood 6e24924a23 Merge branch 'thesamesam-main' into main 2021-09-08 17:20:53 +01:00
Sam James b0720194e1 src/pv/number.c: add missing <stddef.h> include for NULL 2021-09-08 01:06:29 +01:00
Andrew Wood 613642ba3d Added TODO from Zach Riggle 2021-09-06 23:12:16 +01:00
Andrew WoodandGitHub 103df51a59 Create FUNDING.yml 2021-09-06 22:41:38 +01:00
Andrew Wood 0f7069796e Minor updates in preparation for release of v1.6.19 2021-09-05 19:29:45 +01:00
Andrew Wood adf9672b25 Cleanup 2021-09-05 19:17:58 +01:00
Andrew Wood 7d68a574ca Added all changes made between v1.6.6 and June 2020 2021-09-04 21:00:00 +01:00
Andrew Wood 9dd06d8acb Adjusted README for GitHub 2021-09-04 20:54:15 +01:00
117 changed files with 7328 additions and 4815 deletions
+1
View File
@@ -0,0 +1 @@
github: a-j-wood
+3
View File
@@ -0,0 +1,3 @@
*~
configure
patch-backlog
-230
View File
@@ -1,230 +0,0 @@
Introduction
************
This is the README for `pv' ("Pipe Viewer"), a terminal-based 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
quickly data is passing through, how long it has taken, how near to
completion it is, and an estimate of how long it will be until completion.
Documentation
*************
A manual page is included in this distribution. See `man ./doc/quickref.1',
or `man pv' after installation.
Compilation
***********
If you have downloaded `pv' from Subversion, first run "./generate.sh".
To compile the package, type "sh ./configure", which should generate a
Makefile for your system. You may then type "make" to build everything.
Note that GNU `make' is required; this may be installed as `gmake' on some
systems, so if typing "make" gives an error, try "gmake" instead.
See the file `doc/INSTALL' for more about the `configure' script.
Developers note that you can do "./configure --enable-debugging" to cause
debugging support to be built in, and "--enable-profiling" builds in
profiling support (see "man gprof"). Also note that doing "make index" will
generate an HTML code index (using "ctags" and "cproto"); this index lists
all files used, all functions defined, and all TODOs marked in the code.
Author and acknowledgements
***************************
This package is copyright 2015 Andrew Wood, and is being distributed under
the terms of the Artistic License 2.0. For more details of this license,
see the file `doc/COPYING'.
Report bugs in `pv' using the contact form linked from the home page.
The `pv' home page is at:
http://www.ivarch.com/programs/pv.shtml
The latest version can always be found here.
Credit is also due to:
Jakub Hrozek <jhrozek@redhat.com>
- Fedora package maintainer
Antoine Beaupré <anarcat@debian.org>
- Debian package maintainer
Kevin Coyner <kcoyner@debian.org>
Cédric Delfosse <cedric@debian.org>
- previous Debian package maintainers
Eduardo Aguiar <eduardo.oliveira@sondabrasil.com.br>
- provided Portuguese (Brazilian) translation
Stéphane Lacasse <stephane@gorfou.ca>
- provided French translation
Marcos Kreinacke <public@kreinacke.com>
- provided German translation
Bartosz Feñski <fenio@o2.pl> <http://skawina.eu.org/>
- provided Polish translation along with Krystian Zubel
Joshua Jensen
- reported RPM installation bug
Boris Folgmann <http://www.folgmann.com/en/>
- reported cursor handling bug
Mathias Gumz
- reported NLS bug
Daniel Roethlisberger
- submitted patch to use lockfiles for -c if terminal locking fails
Adam Buchbinder
- lots of help with a Cygwin port of -c
Mark Tomich <http://metuchen.dyndns.org>
- suggested -B option
Gert Menke
- reported bug when piping to dd with a large input buffer size
Ville Herva <Ville.Herva@iki.fi>
- informative bug report about rate limiting performance
Elias Pipping
- patch to compile properly on Darwin 9; potential NULL deref report
Patrick Collison
- similar patch for OS X
Boris Lohner
- reported problem that "-L" does not complain if given non-numeric value
Sebastian Kayser
- supplied testing for SIGPIPE, demonstrated internationalisation problem
Laszlo Ersek <http://phptest11.atw.hu/>
- reported shared memory leak on SIGINT with -c
Phil Rutschman <http://bandgap.rsnsoft.com/>
- provided a patch for fully restoring terminal state on exit
Henry Precheur <http://henry.precheur.org/>
- reporting and suggestions for --rate-limit bug when rate is under 10
E. Rosten <http://mi.eng.cam.ac.uk/~er258/>
- supplied patch for block buffering in line mode
Kjetil Torgrim Homme
- reported compilation error with default CFLAGS on non-GCC compilers
Alexandre de Verteuil
- reported bug in OS X build and supplied test environment to fix in
Martin Baum
- supplied patch to return nonzero exit status if terminated by signal
Sam Nelson <http://www.siliconfuture.net/>
- supplied patch to fix trailing slash on DESTDIR
Daniel Pape
- reported Cygwin installation problem due to DESTDIR
Philipp Beckers
- ported to the Syabas PopcornHour A-100 series
Henry Gebhard <hsggebhardt@googlemail.com>
- supplied patches to improve SI prefixes and add --average-rate
Vladimir Kokarev, Alexander Leo
- reported that exit status did not reflect file errors
Thomas Rachel
- submitted patches for IEEE1541 (MiB suffixes), 1+e03 bug
Guillaume Marcais
- submitted speedup patch for line mode
Moritz Barsnick
- submitted patch for compile warning in size calculation
Pawel Piatek
- submitted RPM and patches for AIX
Sami Liedes
- submitted patch for --timer and --bytes with --numeric
Steven Willis
- reported problem with "-R" killing non-PV remote processes
Vladimir Pal, Vladimir Ermakov
- submitted patch which led to development of --format option
Peter Samuelson <peter@p12n.org>
- submitted patch to calculate size if stdout is a block device
Miguel Diaz
- much Cygwin help (and packaging), found narrow-terminal bug
Jim Salter <http://ubuntuwiki.net>
- commissioned work on the --skip-errors option
Wouter Pronk
- reported build problem on SCO
Bryan Dongray <http://www.dongrays.com>
- provided patches for test scripts failing on older Red Hats
Zev Weiss <www.bewilderbeest.net>
- provided patch to fix splice() not using stdin
Zing Shishak
- provided patch for --null / -0 (count null terminated lines)
Jacek Wielemborek <http://deetah.jogger.pl/kategorie/english>
- implemented fdwatch in Python, suggested PV port
- reported bug with "-l" and ETA / size
- suggested common switches
Kim Krecht
- suggested buffer fill status and last bytes output display options
Cristian Ciupitu <http://ciupicri.github.io>, Josh Stone
- pointed out file descriptor leak with helpful suggestions
(Josh Stone initially noticed the missing close)
Jan Seda
- found issue with splice() and SPLICE_F_NONBLOCK causing slowdown
André Stapf
- pointed out formatting problem e.g. 13GB -> 13.1GB which should be
shown 13.0GB -> 13.1GB; highlighted on-startup row swapping in -c
Damon Harper <http://www.usrbin.ca/>
- suggested "-D" / "--delay-start" option
Ganaël Laplanche <http://www.martymac.org>
- provided patch for lstat64 on systems that do not support it
Peter Korsgaard <http://www.buildroot.net/>
- provided similar patch for lstat64, specifically for uClibc support
Ralf Ramsauer <https://blog.ramses-pyramidenbau.de/>
- reported bug which dropped transfer rate on terminal resize
Michiel Van Herwegen
- reported and discussed bug with "-l" and ETA / size
Erkki Seppälä <http://www.inside.org/~flux/>
- provided patch implementing "-I"
Eric A. Borisch
- provided details of compatibility fix for "%Lu" in watchpid code
-----------------------------------------------------------------------------
+53
View File
@@ -0,0 +1,53 @@
Introduction
------------
This is the README for **pv** ("Pipe Viewer"), a terminal-based 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
quickly data is passing through, how long it has taken, how near to
completion it is, and an estimate of how long it will be until completion.
Documentation
-------------
A manual page is included in this distribution. See "`man ./doc/quickref.1`",
or "`man pv`" after installation.
Changes are listed in "[doc/NEWS.md](./doc/NEWS.md)". The to-do list is "[doc/TODO.md](./doc/TODO.md)".
Developers and translators, please see "[doc/DEVELOPERS.md](./doc/DEVELOPERS.md)".
Compilation
-----------
If this is not a packaged release, first run "`./generate.sh`".
To compile the package, type "`sh ./configure`", which should generate a
Makefile for your system. You may then type "`make`" to build everything.
Note that GNU _make_ is required; this may be installed as _gmake_ on some
systems, so if typing "`make`" gives an error, try "`gmake`" instead.
See the file "[doc/INSTALL](./doc/INSTALL)" for more about the _configure_ script.
Author and acknowledgements
---------------------------
This package is copyright 2023 Andrew Wood, and is being distributed under
the terms of the Artistic License 2.0. For more details of this license,
see the file "[doc/COPYING](./doc/COPYING)".
Report bugs in **pv** using the contact form linked from the home page, or
though the [project issue tracker](https://github.com/a-j-wood/pv/issues).
The **pv** home page is at:
&nbsp;&nbsp;[http://www.ivarch.com/programs/pv.shtml](http://www.ivarch.com/programs/pv.shtml)
The latest version can always be found here.
**Please see "[doc/ACKNOWLEDGEMENTS.md](./doc/ACKNOWLEDGEMENTS.md)" for a list of contributors.**
---
+3 -3
View File
@@ -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")
#
#
+51 -66
View File
@@ -1,53 +1,63 @@
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)
AC_CHECK_HEADERS(wctype.h)
AC_CHECK_HEADERS(termios.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 +65,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 +73,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 +81,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 +90,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
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 +115,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 +124,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,24 +143,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_CHECK_FUNCS(memcpy basename snprintf stat64)
AC_CHECK_HEADERS(limits.h)
if test "$IPC_SUPPORT" = "yes"; then
AC_CHECK_HEADERS(sys/ipc.h sys/param.h libgen.h)
fi
@@ -166,8 +151,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
@@ -186,14 +171,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
doc/$PACKAGE.spec:doc/spec.in
src/.dummy:doc/NEWS,
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
+255 -90
View File
@@ -1,96 +1,261 @@
/*!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
/* 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 <termios.h> header file. */
#undef HAVE_TERMIOS_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 you have the <wctype.h> header file. */
#undef HAVE_WCTYPE_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"
-21
View File
@@ -1,21 +0,0 @@
#
# Dependencies.
#
src/library/getopt.d src/library/getopt.o: src/library/getopt.c src/include/config.h src/include/library/gettext.h
src/library/gettext.d src/library/gettext.o: src/library/gettext.c src/include/config.h src/include/library/gettext.h
src/pv/signal.d src/pv/signal.o: src/pv/signal.c src/include/pv-internal.h src/include/config.h src/include/library/gettext.h src/include/pv.h
src/pv/watchpid.d src/pv/watchpid.o: src/pv/watchpid.c src/include/pv-internal.h src/include/config.h src/include/library/gettext.h src/include/pv.h
src/pv/cursor.d src/pv/cursor.o: src/pv/cursor.c src/include/pv-internal.h src/include/config.h src/include/library/gettext.h src/include/pv.h
src/pv/file.d src/pv/file.o: src/pv/file.c src/include/pv-internal.h src/include/config.h src/include/library/gettext.h src/include/pv.h
src/pv/display.d src/pv/display.o: src/pv/display.c src/include/pv-internal.h src/include/config.h src/include/library/gettext.h src/include/pv.h
src/pv/loop.d src/pv/loop.o: src/pv/loop.c src/include/pv-internal.h src/include/config.h src/include/library/gettext.h src/include/pv.h
src/pv/number.d src/pv/number.o: src/pv/number.c src/include/config.h src/include/library/gettext.h src/include/pv.h
src/pv/transfer.d src/pv/transfer.o: src/pv/transfer.c src/include/pv-internal.h src/include/config.h src/include/library/gettext.h src/include/pv.h
src/pv/state.d src/pv/state.o: src/pv/state.c src/include/pv-internal.h src/include/config.h src/include/library/gettext.h src/include/pv.h
src/main/version.d src/main/version.o: src/main/version.c src/include/config.h src/include/library/gettext.h
src/main/debug.d src/main/debug.o: src/main/debug.c src/include/config.h src/include/library/gettext.h src/include/pv.h
src/main/main.d src/main/main.o: src/main/main.c src/include/config.h src/include/library/gettext.h src/include/options.h src/include/pv.h
src/main/options.d src/main/options.o: src/main/options.c src/include/config.h src/include/library/gettext.h src/include/options.h src/include/library/getopt.h src/include/pv.h
src/main/remote.d src/main/remote.o: src/main/remote.c src/include/config.h src/include/library/gettext.h src/include/options.h src/include/pv.h
src/main/help.d src/main/help.o: src/main/help.c src/include/config.h src/include/library/gettext.h
-62
View File
@@ -1,62 +0,0 @@
# Automatically generated file listings
#
# Creation time: Fri Jun 30 22:23:37 BST 2017
allsrc = src/library/getopt.c \
src/library/gettext.c \
src/pv/signal.c \
src/pv/watchpid.c \
src/pv/cursor.c \
src/pv/file.c \
src/pv/display.c \
src/pv/loop.c \
src/pv/number.c \
src/pv/transfer.c \
src/pv/state.c \
src/main/version.c \
src/main/debug.c \
src/main/main.c \
src/main/options.c \
src/main/remote.c \
src/main/help.c
allobj = src/library/getopt.o \
src/library/gettext.o \
src/pv/signal.o \
src/pv/watchpid.o \
src/pv/cursor.o \
src/pv/file.o \
src/pv/display.o \
src/pv/loop.o \
src/pv/number.o \
src/pv/transfer.o \
src/pv/state.o \
src/main/version.o \
src/main/debug.o \
src/main/main.o \
src/main/options.o \
src/main/remote.o \
src/main/help.o \
src/library.o \
src/pv.o \
src/nls.o \
src/main.o
alldep = src/library/getopt.d \
src/library/gettext.d \
src/pv/signal.d \
src/pv/watchpid.d \
src/pv/cursor.d \
src/pv/file.d \
src/pv/display.d \
src/pv/loop.d \
src/pv/number.d \
src/pv/transfer.d \
src/pv/state.d \
src/main/version.d \
src/main/debug.d \
src/main/main.d \
src/main/options.d \
src/main/remote.d \
src/main/help.d
-14
View File
@@ -1,14 +0,0 @@
# Automatically generated module linking rules
#
# Creation time: Fri Jun 30 22:23:37 BST 2017
src/library.o: src/library/getopt.o src/library/gettext.o
$(LD) $(LDFLAGS) -o $@ src/library/getopt.o src/library/gettext.o
src/pv.o: src/pv/cursor.o src/pv/display.o src/pv/file.o src/pv/loop.o src/pv/number.o src/pv/signal.o src/pv/state.o src/pv/transfer.o src/pv/watchpid.o
$(LD) $(LDFLAGS) -o $@ src/pv/cursor.o src/pv/display.o src/pv/file.o src/pv/loop.o src/pv/number.o src/pv/signal.o src/pv/state.o src/pv/transfer.o src/pv/watchpid.o
src/main.o: src/main/debug.o src/main/help.o src/main/main.o src/main/options.o src/main/remote.o src/main/version.o
$(LD) $(LDFLAGS) -o $@ src/main/debug.o src/main/help.o src/main/main.o src/main/options.o src/main/remote.o src/main/version.o
+1 -1
View File
@@ -7,7 +7,7 @@ version = @VERSION@
PACKAGE = @PACKAGE@
distfiles = \
$(srcdir)/README \
$(srcdir)/README.md \
$(srcdir)/autoconf \
$(srcdir)/configure \
$(srcdir)/doc \
+6 -2
View File
@@ -2,7 +2,7 @@
# Compilation rules.
#
.SUFFIXES: .c .d .o
.SUFFIXES: .c .d .o .e
.c.o:
$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
@@ -11,8 +11,12 @@
sh $(srcdir)/autoconf/scripts/depend.sh \
$(CC) $< $(<:%.c=%) $(srcdir) $(CFLAGS) $(CPPFLAGS) > $@
.c.e:
-splint -badflag +posixlib $(CPPFLAGS) $< > $@ 2>&1
-flawfinder $< >> $@ 2>&1
#
# NLS stuff
# Native language support
#
%.mo: %.po
+20 -33
View File
@@ -2,12 +2,11 @@
# Rules for all phony targets.
#
.PHONY: all help make dep depend test check \
clean depclean indentclean distclean cvsclean svnclean \
.PHONY: all help make dep depend test check analyse \
clean depclean analysisclean indentclean distclean gitclean \
index manhtml indent update-po \
doc dist release \
install uninstall \
rpm srpm
install uninstall
all: $(alltarg) $(CATALOGS)
@@ -23,11 +22,13 @@ help:
@echo
@echo ' make rebuild the Makefile (after adding new files)'
@echo ' dep / depend rebuild .d (dependency) files'
@echo ' clean remove .o (object) and .c~ (backup) files'
@echo ' analyse run analysis tools on all .c files'
@echo ' clean remove .o (object) files'
@echo ' depclean remove .d (dependency) files'
@echo ' analysisclean remove .e (analysis) files'
@echo ' indentclean remove files left over from "make indent"'
@echo ' distclean remove everything not distributed'
@echo ' cvsclean remove everything not in CVS/SVN'
@echo ' gitclean remove everything not in version control'
@echo
@echo ' index generate an HTML index of source code'
@echo ' manhtml output HTML man page to stdout'
@@ -35,9 +36,7 @@ help:
@echo ' update-po update the .po files'
@echo
@echo ' dist create a source tarball for distribution'
@echo ' rpm build a binary RPM (passes $$RPMFLAGS to RPM)'
@echo ' srpm build a source RPM (passes $$RPMFLAGS to RPM)'
@echo ' release dist+rpm+srpm'
@echo ' release create and sign tar.gz and tar.bz2'
@echo
make:
@@ -57,12 +56,17 @@ dep depend: $(alldep)
cat $(alldep) >> $(srcdir)/autoconf/make/depend.mk~
sh ./config.status
analyse: $(allanalysis)
clean:
rm -f $(allobj)
depclean:
rm -f $(alldep)
analysisclean:
rm -f $(allanalysis)
indentclean:
cd $(srcdir) && for FILE in $(allsrc); do rm -f ./$${FILE}~; done
@@ -81,15 +85,14 @@ update-po: $(srcdir)/src/nls/$(PACKAGE).pot
fi; \
done
distclean: clean depclean
distclean: clean depclean analysisclean
rm -f $(alltarg) src/include/config.h
rm -rf $(package)-$(version).tar* $(package)-$(version) $(package)-$(version)-*.rpm
rm -rf $(package)-$(version).tar* $(package)-$(version)
rm -f *.html config.*
rm Makefile
cvsclean svnclean: distclean
gitclean: distclean
rm -f doc/lsm
rm -f doc/$(package).spec
rm -f doc/quickref.1
rm -f configure
rm -f src/nls/*.gmo src/nls/*.mo
@@ -98,7 +101,7 @@ cvsclean svnclean: distclean
echo > $(srcdir)/autoconf/make/modules.mk~
doc:
:
-true
index:
(cd $(srcdir); sh autoconf/scripts/index.sh $(srcdir)) > index.html
@@ -115,7 +118,7 @@ manhtml:
| sed -e '1,/<HR/d' -e '/<H2>Index/,/<HR/d' \
indent:
cd $(srcdir) && indent -npro -kr -i8 -cd42 -c45 $(allsrc)
cd $(srcdir) && indent -npro -kr -i8 -cd42 -c45 -l120 $(allsrc)
dist: doc update-po
rm -rf $(package)-$(version)
@@ -123,7 +126,6 @@ dist: doc update-po
cp -dprf Makefile $(distfiles) $(package)-$(version)
cd $(package)-$(version); $(MAKE) distclean
cp -dpf doc/lsm $(package)-$(version)/doc/
cp -dpf doc/$(package).spec $(package)-$(version)/doc/
chmod 644 `find $(package)-$(version) -type f -print`
chmod 755 `find $(package)-$(version) -type d -print`
chmod 755 `find $(package)-$(version)/autoconf/scripts`
@@ -181,21 +183,6 @@ uninstall:
done; \
fi
rpm:
test -e $(package)-$(version).tar.gz || $(MAKE) dist
rpmbuild $(RPMFLAGS) --define="%_topdir `pwd`/rpm" -tb $(package)-$(version).tar.gz
mv rpm/RPMS/*/$(package)-*.rpm .
rm -rf rpm
srpm:
test -e $(package)-$(version).tar.gz || $(MAKE) dist
rpmbuild $(RPMFLAGS) --define="%_topdir `pwd`/rpm" -ts $(package)-$(version).tar.gz
mv rpm/SRPMS/*$(package)-*.rpm .
rm -rf rpm
release: dist rpm srpm
zcat $(package)-$(version).tar.gz | bzip2 > $(package)-$(version).tar.bz2
-grep -Fq '%_gpg_name' ~/.rpmmacros 2>/dev/null && rpm --addsign *.rpm
-gpg --list-secret-keys 2>&1 | grep -Fq 'uid' && gpg -ab *.tar.gz && rename .asc .txt *.tar.gz.asc
-gpg --list-secret-keys 2>&1 | grep -Fq 'uid' && gpg -ab *.tar.bz2 && rename .asc .txt *.tar.bz2.asc
release: dist
-gpg --list-secret-keys 2>&1 | grep -F 'uid' | grep -Fq "$(MAINTAINER)" && gpg -u "$(MAINTAINER)" -ab *.tar.gz && cp $(package)-$(version).tar.gz.asc $(package)-$(version).tar.gz.txt
chmod 644 $(package)-$(version)*
+1 -1
View File
@@ -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@
+10 -10
View File
@@ -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
View File
@@ -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 ' '
+76 -56
View File
@@ -1,4 +1,4 @@
#!/bin/ash
#!/bin/sh
#
# Script to generate an HTML index of all C code from the current directory
# downwards (skipping directories ending in ~). The header comment in each
@@ -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|&|\&amp;|g;s|<|\&lt;|g;s|>|\&gt;|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>'
+541
View File
@@ -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:
-250
View File
@@ -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
+88 -71
View File
@@ -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,119 @@
# 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/')
allanalysis=$(echo "${allsrc}" | tr ' ' '\n' | sed 's/\.c$/.e/')
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
printf "%s" "allanalysis = "
echo "$allanalysis" | tr '\n' ' ' | sed -e 's/ $//;s/ / \\!/g' | tr '!' '\n'
echo
echo
} >> "${listingsFile}"
echo >> $outlist
echo >> $outlink
echo >> "${linkingRulesFile}"
# EOF
+2 -4
View File
@@ -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
View File
@@ -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
+87
View File
@@ -0,0 +1,87 @@
The following people have contributed to this project, and their assistance
is acknowledged and greatly appreciated:
* Antoine Beaupré <anarcat@debian.org> - Debian package maintainer
* Kevin Coyner <kcoyner@debian.org> - previous Debian package maintainer
* Cédric Delfosse <cedric@debian.org> - previous Debian package maintainer
* Jakub Hrozek <jhrozek@redhat.com> - Fedora package maintainer
* Eduardo Aguiar <eduardo.oliveira@sondabrasil.com.br> - provided Portuguese (Brazilian) translation
* Stéphane Lacasse <stephane@gorfou.ca> - provided French translation
* Marcos Kreinacke <public@kreinacke.com> - provided German translation
* Bartosz Feński <fenio@o2.pl> <http://skawina.eu.org/> - provided Polish translation along with Krystian Zubel
* Joshua Jensen - reported RPM installation bug
* Boris Folgmann <http://www.folgmann.com/en/> - reported cursor handling bug
* Mathias Gumz - reported NLS bug
* Daniel Roethlisberger - submitted patch to use lockfiles for "`-c`" if terminal locking fails
* Adam Buchbinder - lots of help with a Cygwin port of "`-c`"
* Mark Tomich <http://metuchen.dyndns.org> - suggested "`-B`" option
* Gert Menke - reported bug when piping to `dd` with a large input buffer size
* Ville Herva <Ville.Herva@iki.fi> - informative bug report about rate limiting performance
* Elias Pipping - patch to compile properly on Darwin 9; potential NULL deref report
* Patrick Collison - similar patch for OS X
* Boris Lohner - reported problem that "`-L`" does not complain if given non-numeric value
* Sebastian Kayser - supplied testing for *SIGPIPE*, demonstrated internationalisation problem
* Laszlo Ersek <http://phptest11.atw.hu/> - reported shared memory leak on *SIGINT* with "`-c`"
* Phil Rutschman <http://bandgap.rsnsoft.com/> - provided a patch for fully restoring terminal state on exit
* Henry Precheur <http://henry.precheur.org/> - reporting and suggestions for "`--rate-limit`" bug when rate is under 10
* E. Rosten <http://mi.eng.cam.ac.uk/~er258/> - supplied patch for block buffering in line mode
* Kjetil Torgrim Homme - reported compilation error with default *CFLAGS* on non-GCC compilers
* Alexandre de Verteuil - reported bug in OS X build and supplied test environment to fix in
* Martin Baum - supplied patch to return nonzero exit status if terminated by signal
* Sam Nelson <http://www.siliconfuture.net/> - supplied patch to fix trailing slash on *DESTDIR*
* Daniel Pape - reported Cygwin installation problem due to *DESTDIR*
* Philipp Beckers - ported to the Syabas PopcornHour A-100 series
* Henry Gebhard <hsggebhardt@googlemail.com> - supplied patches to improve SI prefixes and add "`--average-rate`"
* Vladimir Kokarev, Alexander Leo - reported that exit status did not reflect file errors
* Thomas Rachel - submitted patches for IEEE1541 (MiB suffixes), 1+e03 bug
* Guillaume Marcais - submitted speedup patch for line mode
* Moritz Barsnick - submitted patch for compile warning in size calculation
* Pawel Piatek - submitted RPM and patches for AIX
* Sami Liedes - submitted patch for "`--timer`" and "`--bytes`" with "`--numeric`"
* Steven Willis - reported problem with "`-R`" killing non-PV remote processes
* Vladimir Pal, Vladimir Ermakov - submitted patch which led to development of "`--format`" option
* Peter Samuelson <peter@p12n.org> - submitted patch to calculate size if stdout is a block device
* Miguel Diaz - much Cygwin help (and packaging), found narrow-terminal bug
* Jim Salter <http://ubuntuwiki.net> - commissioned work on the "`--skip-errors`" option
* Wouter Pronk - reported build problem on SCO
* Bryan Dongray <http://www.dongrays.com> - provided patches for test scripts failing on older Red Hats
* Zev Weiss <www.bewilderbeest.net> - provided patch to fix `splice()` not using stdin
* Zing Shishak - provided patch for "`--null`" / "`-0`" (count null terminated lines)
* Jacek Wielemborek <http://deetah.jogger.pl/kategorie/english> - implemented fdwatch in Python, suggested PV port; reported bug with "`-l`" and ETA / size; many other contributions
* Kim Krecht - suggested buffer fill status and last bytes output display options
* Cristian Ciupitu <http://ciupicri.github.io>, Josh Stone - pointed out file descriptor leak with helpful suggestions (Josh Stone initially noticed the missing close)
* Jan Seda - found issue with `splice()` and *SPLICE_F_NONBLOCK* causing slowdown
* André Stapf - pointed out formatting problem e.g. 13GB -> 13.1GB which should be shown 13.0GB -> 13.1GB; highlighted on-startup row swapping in "`-c`"
* Damon Harper <http://www.usrbin.ca/> - suggested "`-D`" / "`--delay-start`" option
* Ganaël Laplanche <http://www.martymac.org> - provided patch for `lstat64()` on systems that do not support it
* Peter Korsgaard <http://www.buildroot.net/> - provided similar patch for `lstat64()`, specifically for uClibc support; provided AIX cross-compilation patch to fix bug in "`-lc128`" check
* Ralf Ramsauer <https://blog.ramses-pyramidenbau.de/> - reported bug which dropped transfer rate on terminal resize
* Michiel Van Herwegen - reported and discussed bug with "`-l`" and ETA / size
* Erkki Seppälä <http://www.inside.org/~flux/> - provided patch implementing "`-I`"
* Eric A. Borisch - provided details of compatibility fix for "`%Lu`" in watchpid code
* Jan Venekamp - reported MacOS buffer size interactions with pipes
* Matt <https://github.com/lemonsqueeze/pv> - provided "rate-window" patches for rate calculation
* [Filippo Valsorda](https://github.com/FiloSottile) - provided patch for stat64 issue on Apple Silicon
* Matt Koscica, William Dillon - also reported stat64 issue on Apple Silicon
* [Demitri Muna](https://github.com/demitri) - assisted with stat64 patch on Apple Silicon
* Norman Rasmussen - suggested "`-c`" with "`-d PID:FD`", reject "`-N`" with "`-d PID`"
* Andriy Gapon, Jonathan Elchison - reported bug where "`pv /dev/zero >/dev/null &`" stops immediately
* Marcelo Chiesa - reported unused-result warnings when compiling PV 1.6.6
* Jered Floyd - provided patches to improve "`--rate-limit`"
* Christoph Biedl - provided ETA and dynamic interval patches
* Richard Fonfara - provided German translations for "`pv --help`"
* Johannes Gerer <http://johannesgerer.com> - suggested that "`-B`" should enable "`-C`"
* Sam James - provided fix for number.c build issue caused by missing stddef.h
* Jakub Wilk <jwilk@jwilk.net> - corrected README encoding
* Frederik Eaton - reported issue with `<()` shell constructs
* [gray](https://github.com/gray) - reported issue with "`--force`" and terminal process groups, and proposed a patch
* [Luc Gommans](https://github.com/lgommans) / https://lgms.nl/ - provided a "momentary ETA" patch
* [ikasty](https://github.com/ikasty) - added relative filename display to "`--watchfd`"
* [Michael Weiß](https://github.com/quitschbo) - corrected behaviour when not attached to a terminal
* [christoph-zededa](https://github.com/christoph-zededa) - provided OS X support for "`--watchfd`"
* [Dave Beckett](https://github.com/dajobe) - added "`@filename`" syntax to "`--size`", and corrected an autoconf problem with stat64 on OS X
* [Volodymyr Bychkovyak](https://github.com/vbychkoviak) - provided fix for rate limit behaviour with bursty traffic
* [Nick Black](https://nick-black.com) - added "`--bits`" option
* [Andrew Schulman](https://github.com/andrew-schulman) - provided reproducible example of terminal size detection issue in 1.7.17/1.7.18
---
+125
View File
@@ -0,0 +1,125 @@
Notes for developers and translators
====================================
The following "`configure`" options will be of interest to developers and
translators:
* `--enable-debugging` - build in debugging support
* `--enable-profiling` - build in support for profiling
* `--enable-static-nls` - compile translations directly into the program
These "`make`" targets are available:
* `make help` - describe all of the "`.PHONY`" targets
* `make index` - generate a source code index
* `make analyse` - run _splint_ and _flawfinder_ on all C source files
Debugging and profiling support
-------------------------------
When "`./configure --enable-debugging`" is used, the "`pv`" produced by
"`make`" will support an extra option, "`--debug FILE`", which will cause
debugging output to be written to *FILE*. This is not recommended for
production builds due to the extra processing it introduces, and the
potential size of the output.
Within the code, "`debug()`" is used in a similar way to "`printf()`". It
will automatically include the calling function, source file, and line
number, so they don't need to be included in the parameters. When debugging
support is not enabled, it evaluates to a null statement.
This does mean that if you call "`debug()`", make sure it has no side
effects, as they won't be present in builds without debugging support.
Builds produced after "`./configure --enable-profiling`" will write profile
data when run, to be used with _gprof_. See "`man gprof`" for details.
Source code indexing
--------------------
Running "`make index`" calls a script which uses _cproto_ and _ctags_ to
generate a single file, "`index.html`", which lists all C source files, all
functions within them, and all TODOs marked in the code.
It relies on each function having a comment block directly before it,
describing what it does.
The indexing script pre-dates the author's knowledge of documentation
generation tools like Doxygen, and is over 20 years old. If it contains
bugs, then rather than fixing them, it may be worth looking at how to alter
the C sources to better suit widely available documentation generation
tools. Please open issues or start discussions about this if it comes up.
Source code analysis
--------------------
Running "`make analyse`" runs _splint_ and _flawfinder_ on all C sources,
writing the output of both programs to files named "`*.e`" for each "`*.c`".
There are no dependency rules set up for these "`.e`" files, so if a header
file is altered, either run "`make analysisclean`", manually remove the
relevant "`.e`" files, or update the timestamp of the relevant "`.c`" files
before running "`make analyse`" again.
The eventual goal is for all C source files to generate zero warnings from
either tool.
Translation notes
-----------------
The message catalogues used to translate program messages into other
languages are in the "`src/nls/`" directory, named "`xx.po`", where "`xx`"
is the ISO 639-1 2-letter language code, such as "`fr`" for French.
Each of these files contains lines like this:
#: src/pv/cursor.c:85
msgid "failed to get terminal name"
msgstr "erro ao ler o nome do terminal"
The comment line, starting "`#`", shows the source filename and line number
at which this message can be found. The "`msgid`" is the original message
in the program, in English. The "`msgstr`" is the translated text.
It is the "`msgstr`" lines which need to be updated by translators.
Message catalogue files should all be encoded as UTF-8.
To quickly test translations, use "`./configure --enable-static-nls`". This
is not recommended for production use, because it replaces the system
internationalisation libraries with some very simplistic alternatives, but
it has the benefit of compiling the message catalogues directly into the
program.
This means that after making a change to a "`.po`" file, do this:
make
LANG=de LC_ALL=en_GB.UTF-8 ./pv --help
Replace "`--help`" with whatever is appropriate for your test. In this
example, the language being tested is "`de`" (German), on a system which is
otherwise running in English with UTF-8 support.
To add a new language, edit "`autoconf/configure.in`". Look for this line:
for lang in de fr pl pt; do
Add the new language code before the "`; do`".
Create the new message catalogue file under "`src/nls/`" by copying
"`src/nls/pv.pot`" to "`src/nls/xx.po`", where "`xx`" is the language code,
and adjusting it.
Then run "`./generate.sh`" to generate a new "`configure`" script; you will
need to run "`./configure --enable-static-nls`" and "`make`" afterwards.
When the source code is updated, running "`make`" will update the "`pv.pot`"
file so that it lists where all the messages are in the source, and running
"`make update-po`" will use _msgmerge_ to update all of the "`.po`" files
from the updated "`pv.pot`" file. After doing this, look for missing
translations (empty "`msgstr`" lines) or translations marked as "fuzzy", as
these will need to be corrected by translators.
-304
View File
@@ -1,304 +0,0 @@
1.6.6 - 30 June 2017
- (r161) use %llu instead of %Lu for better compatibility (Eric A. Borisch)
- (r162) (#1532) fix target buffer size (-B) being ignored (AndCycle, Ilya
Basin, Antoine Beaupré)
- (r164) cap read/write sizes, and check elapsed time during read/write
cycles, to avoid display hangs with large buffers or slow media; also
remove select() call from repeated_write function as it slows the
transfer down and the wrapping alarm() means it is unnecessary
- (r169) (#1477) use alternate form for transfer counter, such that 13GB
is shown as 13.0GB so it's the same width as 13.1GB (André Stapf)
- (r171) cleanup: units corrections in man page, of the form kb -> KiB
- (r175) report error in "-d" if process fd directory is unreadable, or if
process disappears before we start the main loop (Jacek Wielemborek)
1.6.0 - 15 March 2015
- fix lstat64 support when unavailable - separate patches supplied by
Ganael Laplanche and Peter Korsgaard
- (#1506) new option "-D" / "--delay-start" to only show bar after N
seconds (Damon Harper)
- new option "--fineta" / "-I" to show ETA as time of day rather than time
remaining - patch supplied by Erkki Seppälä (r147)
- (#1509) change ETA (--eta / -e) so that days are given if the hours
remaining are 24 or more (Jacek Wielemborek)
- (#1499) repeat read and write attempts on partial buffer fill/empty to
work around post-signal transfer rate drop reported by Ralf Ramsauer
- (#1507) do not try to calculate total size in line mode, due to bug
reported by Jacek Wielemborek and Michiel Van Herwegen
- cleanup: removed defunct RATS comments and unnecessary copyright notices
- clean up displayed lines when using --watchfd PID, when PID exits
- output errors on a new line to avoid overwriting transfer bar
1.5.7 - 26 August 2014
- show KiB instead of incorrect kiB (Debian bug #706175)
- (#1284) do not gzip man page, for non-Linux OSes (Bob Friesenhahn)
- work around "awk" bug in tests/016-numeric-timer in decimal "," locales
- fix "make rpm" and "make srpm", extend "make release" to sign releases
1.5.3 - 4 May 2014
- remove SPLICE_F_NONBLOCK to fix problem with slow splice() (Jan Seda)
1.5.2 - 10 February 2014
- allow "--watchfd" to look at block devices
- let "--watchfd PID:FD" work with "--size N"
- moved contributors out of the manual as the list was too long
(NB everyone is still listed in the README and always will be)
1.5.1 - 23 January 2014
- new option "--watchfd" - suggested by Jacek Wielemborek and "fdwatch"
- use non-block flag with splice()
- new display option "--buffer-percent", suggested by Kim Krecht
- new display option "--last-written", suggested by Kim Krecht
- new transfer option "--no-splice"
- fix for minor bug which dropped display elements after one empty one
- fix for single fd leak on exit (Cristian Ciupitu)
1.4.12 - 5 August 2013
- new option "--null" - patch supplied by Zing Shishak
- AIX build fix (add "-lc128") - with help from Pawel Piatek
- AIX "-c" fixes - with help from Pawel Piatek
- SCO build fix (po2table.sh) - reported by Wouter Pronk
- test scripts fix for older distributions - patch from Bryan Dongray
- fix for splice() not using stdin - patch from Zev Weiss
1.4.6 - 22 January 2013
- added patch from Pawel Piatek to omit O_NOFOLLOW in AIX
1.4.5 - 10 January 2013
- updated manual page to show known problem with "-R" on Cygwin
1.4.4 - 11 December 2012
- added debugging, see `pv -h' when configure run with "--enable-debugging"
- rewrote cursor positioning code used when IPC is unavailable (Cygwin)
- fixed cursor positioning cursor read answerback problem (Cygwin/Solaris)
- fixed bug causing crash when progress displayed with too-small terminal
1.4.0 - 6 December 2012
- new option "--skip-errors" commissioned by Jim Salter
- if stdout is a block device, and we don't know the total size, use the
size of that block device as the total (Peter Samuelson)
- new option "--stop-at-size" to stop after "--size" bytes
- report correct filename on read errors
- fix use-after-free bug in remote PID cleanup code
- refactored large chunks of code to make it more readable and to replace
most static variables with a state structure
1.3.9 - 5 November 2012
- allow "--format" parameters to be sent with "--remote"
- configure option "--disable-ipc"
- added tests for --numeric with --timer and --bytes
- added tests for --remote
1.3.8 - 29 October 2012
- new "--pidfile" option to save process ID to a file
- integrated patch for --numeric with --timer and --bytes (Sami Liedes)
- removed signalling from --remote to prevent accidental process kills
- new "--format" option (originally Vladimir Pal / Vladimir Ermakov)
1.3.4 - 27 June 2012
- new "--disable-splice" configure script option
- fixed line mode size count with multiple files (Moritz Barsnick)
- fixes for AIX core dumps (Pawel Piatek)
1.3.1 - 9 June 2012
- do not use splice() if the write buffer is not empty (Thomas Rachel)
- added test 15 (pipe transfers), and new test script
1.3.0 - 5 June 2012
- added Tiger build patch from Olle Jonsson
- fix 1024-boundary display garble (Debian bug #586763)
- use splice(2) where available (Debian bug #601683)
- added known bugs section of the manual page
- fixed average rate test, 12 (Andrew Macheret)
- use IEEE1541 units (Thomas Rachel)
- bug with rate limit under 10 fixed (Henry Precheur)
- speed up PV line mode (patch: Guillaume Marcais)
- remove LD=ld from vars.mk to fix cross-compilation (paintitgray/PV#1291)
1.2.0 - 14 December 2010
- integrated improved SI prefixes and --average-rate (Henry Gebhardt)
- return nonzero if exiting due to SIGTERM (Martin Baum)
- patch from Phil Rutschman to restore terminal properly on exit
- fix i18n especially for --help (Sebastian Kayser)
- refactored pv_display
- we now have a coherent, documented, exit status
- modified pipe test and new cksum test from Sebastian Kayser
- default CFLAGS to just "-O" for non-GCC (Kjetil Torgrim Homme)
- LFS compile fix for OS X 10.4 (Alexandre de Verteuil)
- remove DESTDIR / suffix (Sam Nelson, Daniel Pape)
- fixed potential NULL deref in transfer (Elias Pipping / LLVM/Clang)
1.1.4 - 6 March 2008
- patch from Elias Pipping correcting compilation failure on Darwin 9
- patch from Patrick Collison correcting similar problems on OS X
- trap SIGINT/SIGHUP/SIGTERM so we clean up IPCs on exit (Laszlo Ersek)
- abort if numeric option, eg -L, has non-numeric value (Boris Lohner)
1.1.0 - 30 August 2007
- new option --remote (-R) to control an already-running process
- new option --line-mode (-l) to count lines instead of bytes
- fix for "-L" to be less resource intensive
- fix for input/output equivalence check on Mac OS X
- fix for size calculation in pipelines on Mac OS X
- fixed "make uninstall"
- removed /debian directory at request of new Debian maintainer
1.0.1 - 4 August 2007
- licensing change from Artistic to Artistic 2.0
- removed the "-l" / "--license" option
1.0.0 - 2 August 2007
- act more like "cat" - just skip unreadable files, don't abort
- removed text version of manual page, and obsolete Info file generation
- code cleanup and separation of PV internals from CLI front-end
0.9.9 - 5 February 2007
- new option --buffer-size (-B) suggested by Mark Tomich
- build fix: HP/UX largefile compile fix from Timo Savinen
- maintain better buffer filling during transfers
- workaround: pv /dev/zero | dd bs=1M count=1k bug (reported by Gert Menke)
- dropped support for the Texinfo manual
0.9.6 - 27 February 2006
- bugfix: key_t incompatibility with Cygwin
- bugfix: interval (-i) parameter parses numbers after decimal point
- build fix: use static NLS if msgfmt is unavailable
- on the final update, blank out the now-zero ETA
0.9.2 - 1 September 2005
- Daniel Roethlisberger patch: use lockfiles if terminal locking fails
0.9.1 - 16 June 2005
- minor RPM spec file fix for Fedora Core 4
0.9.0 - 15 November 2004
- minor NLS bugfix
0.8.9 - 6 November 2004
- decimal values now accepted for rate and size, eg "-L 1.23M"
- code cleanup
- developers: "make help" now lists Makefile targets
0.8.6 - 29 June 2004
- use uu_lock() for terminal locking on FreeBSD
0.8.5 - 2 May 2004
- cursor positioning (-c) reliability improved on systems with IPC
- minor fix: made test 005 more reliable
- new option --height (-H)
0.8.2 - 24 April 2004
- allow k,m,g,t suffixes on numbers
- added "srpm" and "release" Makefile targets
0.8.1 - 19 April 2004
- bugfix in cursor positioning (-c)
0.8.0 - 12 February 2004
- replaced GNU getopt with my library code
- replaced GNU gettext with my very minimal replacement
- use DESTDIR instead of RPM_BUILD_ROOT for optional installation prefix
- looked for flaws using RATS, cleaned up code
0.7.0 - 8 February 2004
- display buffer management fixes (thanks Cédric Delfosse)
- replaced --enable-debug with --enable-debugging and --enable-profiling
0.6.4 - 14 January 2004
- fixed minor bug in RPM installation
- bugfix in "make index" (only of interest to developers)
0.6.3 - 22 December 2003
- fixed transient bug that reported "resource unavailable" occasionally
0.6.2 - 6 August 2003
- block devices now have their size read correctly, so pv /dev/hda1 works
- minor code cleanups (mainly removal of CVS "Id" tags)
0.6.0 - 3 August 2003
- doing ^Z then "bg" then "fg" now continues displaying
0.5.9 - 23 July 2003
- fix for test 007 when not in C locale
- fix for build process to use CPPFLAGS
- fix for build process to use correct i18n libraries
- fix for build process - more portable sed in dependency generator
- fix for install process - remember to mkinstalldirs before installing
- fixes for building on Mac OS X
0.5.3 - 4 May 2003
- added Polish translation thanks to Bartosz Feñski
<fenio@o2.pl> <http://skawina.eu.org/> and Krystian Zubel
- moved doc/debian to ./debian at insistence of common sense
- minor Solaris 8 compatibility fixes
- seems to compile and test OK on Mac OS X
0.5.0 - 15 April 2003
- added French translation thanks to Stéphane Lacasse
<stephane@gorfou.ca>
- added German translation thanks to Marcos Kreinacke
<public@kreinacke.com>
- switched LGPL reference from "Library" to "Lesser"
0.4.9 - 18 February 2003
- support for >2GB files added where available (Debian bug #180986)
- added doc/debian dir (from Cédric Delfosse)
- added "make rpm" and "make deb" targets to build RPM and Debian packages
- added a "make pv-static" rule to build a statically linked version
0.4.5 - 13 December 2002
- added Portuguese (Brazilian) translation thanks to Eduardo Aguiar
0.4.4 - 7 December 2002
- pause/resume support - don't count time while stopped
- stop output when resumed in the background
- terminal size change support
- bugfix: <=> indicator no longer sticks at right hand edge
0.4.0 - 27 November 2002
- allow decimal interval values, eg 0.1, 0.5, etc
- some simple tests added (`make check')
- smoother throughput limiting (--rate-limit), now done in 0.1sec chunks
- bounds-check interval values (-i) - max update interval now 10 minutes
- more reliable non-blocking output to keep display updated
- no longer rely on atoll()
- don't output final blank line if --numeric
- use fcntl() instead of flock() for Solaris compatibility
0.3.0 - 25 November 2002
- handle broken output pipe gracefully
- continue updating display even when output pipe is blocking
0.2.6 - 21 October 2002
- we now ignore EINTR on select()
- variable-size buffer (still need to add code to change size)
- added (tentative) support for internationalisation
- removed superfluous --no-progress, etc options
- optimised transfer by using bigger buffers, based on st_blksize
- added --wait option to wait until transfer begins before showing progress
- added --rate-limit option to limit rate to a maximum throughput
- added --quiet option (no output at all) to be used with --rate-limit
0.2.5 - 23 July 2002
- added [FILE]... arguments, like `cat'
- function separation in code
- some bug fixes related to numeric overflow
0.2.3 - 19 July 2002
- Texinfo manual written, man page updated
- byte counter added
0.2.0 - 18 July 2002
- ETA counter added
- screen width estimation added
- progress bar added
0.1.0 - 17 July 2002
- main loop created
- rate counter added
- elapsed time counter added
- percentage calculation added
0.0.1 - 16 July 2002
- package created
- first draft of man page written
+425
View File
@@ -0,0 +1,425 @@
1.7.24 - 30 July 2023
* fix: correct terminal size detection, broken in 1.7.17 by the configuration script rewrite ([GH#72](https://github.com/a-j-wood/pv/issues/72))
* security: removed *DEBUG* environment variable in debug mode, added "`--debug`" instead
* cleanup: added "`make analyse`" to run "`splint`" and "`flawfinder`" on all source files
* cleanup: corrected detection of boolean capability
* cleanup: word wrapping of "`--help`" output is now multi-byte locale aware
* cleanup: adjusted "`indent`" rules to line length of 120 and reformatted code
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))
* feature: the "`--watchfd`" option is now available on OS X (pull request [#60](https://github.com/a-j-wood/pv/pull/60) supplied by [christoph-zededa](https://github.com/christoph-zededa))
* feature: new "`--bits`" option to show bit count instead of byte count (adapted from pull request [#63](https://github.com/a-j-wood/pv/pull/63) supplied by [Nick Black](https://nick-black.com))
* feature: new "`--average-rate-window`" option, to set the window over which the average rate is calculated, also used for ETA (modified from pull request [#65](https://github.com/a-j-wood/pv/pull/65) supplied by [lemonsqueeze](https://github.com/lemonsqueeze))
* feature: the "`--watchfd`" option will now show relative filenames, if they are under the current directory (pull request [#66](https://github.com/a-j-wood/pv/pull/66) supplied by [ikasty](https://github.com/ikasty))
* fix: correction to `pv_in_foreground()` to behave as its comment block says it should, when not on a terminal - corrects [GH#19 "No output in Arch Linux initcpio after 1.6.6"](https://github.com/a-j-wood/pv/issues/19), [GH#31 "No output written from inside zsh <() construct"](https://github.com/a-j-wood/pv/issues/31), [GH#55 "pv Stopped Working in the Background"](https://github.com/a-j-wood/pv/issues/55) (pull request [#64](https://github.com/a-j-wood/pv/pull/64) supplied by [Michael Weiß](https://github.com/quitschbo))
* fix: workaround for OS X 11 behaviour in configure script regarding stat64 at compile time (pull request [#57](https://github.com/a-j-wood/pv/pull/57) supplied by [Dave Beckett](https://github.com/dajobe))
* fix: workaround for macOS equivalence of stat to stat64 - patches from [Filippo Valsorda](https://github.com/FiloSottile) and [Demitri Muna](https://github.com/demitri), correcting [GH#33 "Fix compilation problems due to `stat64()` on Apple Silicon"](https://github.com/a-j-wood/pv/issues/33)
* fix: add burst rate limit to transfer, so rate limits are not broken by bursty traffic (pull request [#62](https://github.com/a-j-wood/pv/pull/62) supplied by [Volodymyr Bychkovyak](https://github.com/vbychkoviak))
* fix: corrected "`--force`" option so it will still output progress when not in the same process group as the owner of the terminal - corrects [GH#23 "No output with "`-f`" when run in background after 1.6.6"](https://github.com/a-j-wood/pv/issues/23) and helps to correct [GH#31 "No output written from inside zsh <() construct"](https://github.com/a-j-wood/pv/issues/31)
* fix: corrected elapsed time display to show as D:HH:MM:SS after 1 day, like the ETA does - corrects [GH#16 "Show days in same format in ETA as in elapsed time"](https://github.com/a-j-wood/pv/issues/16)
* fix: corrected bug where percentages went down after 100% when in "`--numeric`" mode with a "`--size`" that was too small - corrects [GH#26 "Correct "`-n`" behaviour when going past 100% of "`-s`" size"](https://github.com/a-j-wood/pv/issues/26)
* i18n: recoded Polish translation file to UTF-8
* i18n: removed inaccurate fuzzy translation matches
* docs: moved all open issues into GitHub and updated the TODO list
* docs: renamed README to README.md and altered it to Markdown format
* docs: moved contributors from the README to docs/ACKNOWLEDGEMENTS.md
* docs: moved TODO to TODO.md and altered it to Markdown format
* docs: moved NEWS to NEWS.md, converted it to UTF-8, and altered it to Markdown format
1.6.20 - 12 September 2021
* fix: add missing `stddef.h` include to `number.c` (Sam James)
1.6.19 - 5 September 2021
* fix: starting pv in the background no longer immediately stops unless the transfer is to/from the terminal (Andriy Gapon, Jonathan Elchison)
* fix: using "`-B`", "`-A`", or "`-T`" now switches on "`-C`" implicitly (Johannes Gerer, André Stapf)
* fix: AIX build fixes (Peter Korsgaard)
* i18n: updated German "`--help`" translations (Richard Fonfara)
* i18n: switched to UTF-8 encoding, added missing translations (de,fr,pt)
* docs: new "common switches" manual section (Jacek Wielemborek)
* docs: use placeholder instead of `/dev/sda` in the manual (Pranav Peshwe)
* docs: mention MacOS pipes and "`-B 1024`" in the manual (Jan Venekamp)
* docs: correct shell in `autoconf/scripts/index.sh` (Juan Picca)
* cleanup: various compiler warnings cleaned up
Full changelog is below:
* (r181) added common switches section to manual (Jacek Wielemborek)
* (r184) use placeholder instead of /dev/sda in the manual (Pranav Peshwe)
* (r185) replace ash with sh in autoconf/scripts/index.sh (Juan Picca)
* (r185) added note to manual about "`-B 1024`" in MacOS pipes (Jan Venekamp)
* (r185) fix AIX config check when the CWD contains "yes" (Peter Korsgaard)
* (r189) (#1556) updated German "`--help`" translations (Richard Fonfara)
* (r189) updated missing German translations and changed to UTF-8 encoding
* (r191) updated missing French translations and changed to UTF-8 encoding
* (r193) updated missing Portuguese translations, changed to UTF-8 encoding
* (r196) (#1563) using "`-B`", "`-A`", or "`-T`" now switches on "`-C`" implicitly (Johannes Gerer, André Stapf)
* (r199) fixed numerous compiler warnings in newer GCC versions
* (r200,205) fixed bug where "`pv /dev/zero >/dev/null &`" stopped immediately (Jonathan Elchison, Andriy Gapon)
* (r203,205) marked unused arguments with GCC unused attribute, started using boolean data type for flags, corrected more compiler warnings
1.6.6 - 30 June 2017
* (r161) use `%llu` instead of `%Lu` for better compatibility (Eric A. Borisch)
* (r162) (#1532) fix target buffer size ("`-B`") being ignored (AndCycle, Ilya Basin, Antoine Beaupré)
* (r164) cap read/write sizes, and check elapsed time during read/write cycles, to avoid display hangs with large buffers or slow media; also remove `select()` call from repeated_write function as it slows the transfer down and the wrapping `alarm()` means it is unnecessary
* (r169) (#1477) use alternate form for transfer counter, such that 13GB is shown as 13.0GB so it's the same width as 13.1GB (André Stapf)
* (r171) cleanup: units corrections in man page, of the form kb -> KiB
* (r175) report error in "`-d`" if process fd directory is unreadable, or if process disappears before we start the main loop (Jacek Wielemborek)
1.6.0 - 15 March 2015
* fix lstat64 support when unavailable - separate patches supplied by Ganael Laplanche and Peter Korsgaard
* (#1506) new option "`-D`" / "`--delay-start`" to only show bar after N seconds (Damon Harper)
* new option "`--fineta`" / "`-I`" to show ETA as time of day rather than time remaining - patch supplied by Erkki Seppälä (r147)
* (#1509) change ETA ("`--eta`" / "`-e`") so that days are given if the hours remaining are 24 or more (Jacek Wielemborek)
* (#1499) repeat read and write attempts on partial buffer fill/empty to work around post-signal transfer rate drop reported by Ralf Ramsauer
* (#1507) do not try to calculate total size in line mode, due to bug reported by Jacek Wielemborek and Michiel Van Herwegen
* cleanup: removed defunct RATS comments and unnecessary copyright notices
* clean up displayed lines when using "`--watchfd PID`", when PID exits
* output errors on a new line to avoid overwriting transfer bar
1.5.7 - 26 August 2014
* show KiB instead of incorrect kiB (Debian bug #706175)
* (#1284) do not gzip man page, for non-Linux OSes (Bob Friesenhahn)
* work around "awk" bug in `tests/016-numeric-timer` in decimal "," locales
* fix "`make rpm`" and "`make srpm`", extend "`make release`" to sign releases
1.5.3 - 4 May 2014
* remove *SPLICE_F_NONBLOCK* to fix problem with slow `splice()` (Jan Seda)
1.5.2 - 10 February 2014
* allow "`--watchfd`" to look at block devices
* let "`--watchfd PID:FD`" work with "`--size N`"
* moved contributors out of the manual as the list was too long (NB everyone is still listed in the README and always will be)
1.5.1 - 23 January 2014
* new option "`--watchfd`" - suggested by Jacek Wielemborek and "fdwatch"
* use non-block flag with `splice()`
* new display option "`--buffer-percent`", suggested by Kim Krecht
* new display option "`--last-written`", suggested by Kim Krecht
* new transfer option "`--no-splice`"
* fix for minor bug which dropped display elements after one empty one
* fix for single fd leak on exit (Cristian Ciupitu)
1.4.12 - 5 August 2013
* new option "`--null`" - patch supplied by Zing Shishak
* AIX build fix (add "`-lc128`") - with help from Pawel Piatek
* AIX "`-c`" fixes - with help from Pawel Piatek
* SCO build fix (`po2table.sh`) - reported by Wouter Pronk
* test scripts fix for older distributions - patch from Bryan Dongray
* fix for `splice()` not using stdin - patch from Zev Weiss
1.4.6 - 22 January 2013
* added patch from Pawel Piatek to omit *O_NOFOLLOW* in AIX
1.4.5 - 10 January 2013
* updated manual page to show known problem with "`-R`" on Cygwin
1.4.4 - 11 December 2012
* added debugging, see "`pv -h`" when `configure` is run with "`--enable-debugging`"
* rewrote cursor positioning code used when IPC is unavailable (Cygwin)
* fixed cursor positioning cursor read answerback problem (Cygwin/Solaris)
* fixed bug causing crash when progress displayed with too-small terminal
1.4.0 - 6 December 2012
* new option "`--skip-errors`" commissioned by Jim Salter
* if stdout is a block device, and we don't know the total size, use the size of that block device as the total (Peter Samuelson)
* new option "`--stop-at-size`" to stop after "`--size`" bytes
* report correct filename on read errors
* fix use-after-free bug in remote PID cleanup code
* refactored large chunks of code to make it more readable and to replace most static variables with a state structure
1.3.9 - 5 November 2012
* allow "`--format`" parameters to be sent with "`--remote`"
* configure option "`--disable-ipc`"
* added tests for "`--numeric`" with "`--timer`" and "`--bytes`"
* added tests for "`--remote`"
1.3.8 - 29 October 2012
* new "`--pidfile`" option to save process ID to a file
* integrated patch for "`--numeric`" with "`--timer`" and "`--bytes`" (Sami Liedes)
* removed signalling from "`--remote`" to prevent accidental process kills
* new "`--format`" option (originally Vladimir Pal / Vladimir Ermakov)
1.3.4 - 27 June 2012
* new "`--disable-splice`" configure script option
* fixed line mode size count with multiple files (Moritz Barsnick)
* fixes for AIX core dumps (Pawel Piatek)
1.3.1 - 9 June 2012
* do not use `splice()` if the write buffer is not empty (Thomas Rachel)
* added test 15 (pipe transfers), and new test script
1.3.0 - 5 June 2012
* added Tiger build patch from Olle Jonsson
* fix 1024-boundary display garble (Debian bug #586763)
* use `splice`(2) where available (Debian bug #601683)
* added known bugs section of the manual page
* fixed average rate test, 12 (Andrew Macheret)
* use IEEE1541 units (Thomas Rachel)
* bug with rate limit under 10 fixed (Henry Precheur)
* speed up PV line mode (patch: Guillaume Marcais)
* remove `LD=ld` from `vars.mk` to fix cross-compilation (paintitgray/PV#1291)
1.2.0 - 14 December 2010
* integrated improved SI prefixes and "`--average-rate`" (Henry Gebhardt)
* return nonzero if exiting due to *SIGTERM* (Martin Baum)
* patch from Phil Rutschman to restore terminal properly on exit
* fix i18n especially for "`--help`" (Sebastian Kayser)
* refactored `pv_display`
* we now have a coherent, documented, exit status
* modified pipe test and new cksum test from Sebastian Kayser
* default *CFLAGS* to just "`-O`" for non-GCC (Kjetil Torgrim Homme)
* LFS compile fix for OS X 10.4 (Alexandre de Verteuil)
* remove *DESTDIR* `/` suffix (Sam Nelson, Daniel Pape)
* fixed potential NULL deref in transfer (Elias Pipping / LLVM/Clang)
1.1.4 - 6 March 2008
* patch from Elias Pipping correcting compilation failure on Darwin 9
* patch from Patrick Collison correcting similar problems on OS X
* trap *SIGINT* / *SIGHUP* / *SIGTERM* so we clean up IPCs on exit (Laszlo Ersek)
* abort if numeric option, eg "`-L`", has non-numeric value (Boris Lohner)
1.1.0 - 30 August 2007
* new option "`--remote`" ("`-R`") to control an already-running process
* new option "`--line-mode`" ("`-l`") to count lines instead of bytes
* fix for "`-L`" to be less resource intensive
* fix for input/output equivalence check on Mac OS X
* fix for size calculation in pipelines on Mac OS X
* fixed "`make uninstall`"
* removed "`/debian`" directory at request of new Debian maintainer
1.0.1 - 4 August 2007
* licensing change from Artistic to Artistic 2.0
* removed the "`-l`" / "`--license`" option
1.0.0 - 2 August 2007
* act more like "`cat`" - just skip unreadable files, don't abort
* removed text version of manual page, and obsolete Info file generation
* code cleanup and separation of PV internals from CLI front-end
0.9.9 - 5 February 2007
* new option "`--buffer-size`" ("`-B`") suggested by Mark Tomich
* build fix: HP/UX largefile compile fix from Timo Savinen
* maintain better buffer filling during transfers
* workaround: "`pv /dev/zero | dd bs=1M count=1k`" bug (reported by Gert Menke)
* dropped support for the Texinfo manual
0.9.6 - 27 February 2006
* bugfix: `key_t` incompatibility with Cygwin
* bugfix: interval ("`-i`") parameter parses numbers after decimal point
* build fix: use static NLS if `msgfmt` is unavailable
* on the final update, blank out the now-zero ETA
0.9.2 - 1 September 2005
* Daniel Roethlisberger patch: use lockfiles if terminal locking fails
0.9.1 - 16 June 2005
* minor RPM spec file fix for Fedora Core 4
0.9.0 - 15 November 2004
* minor NLS bugfix
0.8.9 - 6 November 2004
* decimal values now accepted for rate and size, eg "`-L 1.23M`"
* code cleanup
* developers: "`make help`" now lists Makefile targets
0.8.6 - 29 June 2004
* use `uu_lock()` for terminal locking on FreeBSD
0.8.5 - 2 May 2004
* cursor positioning ("`-c`") reliability improved on systems with IPC
* minor fix: made test 005 more reliable
* new option "`--height`" ("`-H`")
0.8.2 - 24 April 2004
* allow k,m,g,t suffixes on numbers
* added "`srpm`" and "`release`" Makefile targets
0.8.1 - 19 April 2004
* bugfix in cursor positioning ("`-c`")
0.8.0 - 12 February 2004
* replaced GNU getopt with my library code
* replaced GNU gettext with my very minimal replacement
* use *DESTDIR* instead of *RPM_BUILD_ROOT* for optional installation prefix
* looked for flaws using RATS, cleaned up code
0.7.0 - 8 February 2004
* display buffer management fixes (thanks Cédric Delfosse)
* replaced "`--enable-debug`" with "`--enable-debugging`" and "`--enable-profiling`"
0.6.4 - 14 January 2004
* fixed minor bug in RPM installation
* bugfix in "`make index`" (only of interest to developers)
0.6.3 - 22 December 2003
* fixed transient bug that reported "resource unavailable" occasionally
0.6.2 - 6 August 2003
* block devices now have their size read correctly, so "`pv /dev/hda1`" works
* minor code cleanups (mainly removal of CVS "Id" tags)
0.6.0 - 3 August 2003
* doing *^Z* then "`bg`" then "`fg`" now continues displaying
0.5.9 - 23 July 2003
* fix for test 007 when not in C locale
* fix for build process to use *CPPFLAGS*
* fix for build process to use correct i18n libraries
* fix for build process - more portable sed in dependency generator
* fix for install process - remember to `mkinstalldirs` before installing
* fixes for building on Mac OS X
0.5.3 - 4 May 2003
* added Polish translation thanks to Bartosz Feński <fenio@o2.pl> <http://skawina.eu.org/> and Krystian Zubel
* moved `doc/debian` to `./debian` at insistence of common sense
* minor Solaris 8 compatibility fixes
* seems to compile and test OK on Mac OS X
0.5.0 - 15 April 2003
* added French translation thanks to Stéphane Lacasse <stephane@gorfou.ca>
* added German translation thanks to Marcos Kreinacke <public@kreinacke.com>
* switched LGPL reference from "Library" to "Lesser"
0.4.9 - 18 February 2003
* support for >2GB files added where available (Debian bug #180986)
* added `doc/debian` dir (from Cédric Delfosse)
* added "`make rpm`" and "`make deb`" targets to build RPM and Debian packages
* added a "`make pv-static`" rule to build a statically linked version
0.4.5 - 13 December 2002
* added Portuguese (Brazilian) translation thanks to Eduardo Aguiar
0.4.4 - 7 December 2002
* pause/resume support - don't count time while stopped
* stop output when resumed in the background
* terminal size change support
* bugfix: "`<=>`" indicator no longer sticks at right hand edge
0.4.0 - 27 November 2002
* allow decimal interval values, eg 0.1, 0.5, etc
* some simple tests added ("`make check`")
* smoother throughput limiting ("`--rate-limit`"), now done in 0.1sec chunks
* bounds-check interval values ("`-i`") - max update interval now 10 minutes
* more reliable non-blocking output to keep display updated
* no longer rely on `atoll()`
* don't output final blank line if "`--numeric`"
* use `fcntl()` instead of `flock()` for Solaris compatibility
0.3.0 - 25 November 2002
* handle broken output pipe gracefully
* continue updating display even when output pipe is blocking
0.2.6 - 21 October 2002
* we now ignore *EINTR* on `select()`
* variable-size buffer (still need to add code to change size)
* added (tentative) support for internationalisation
* removed superfluous "`--no-progress`", etc options
* optimised transfer by using bigger buffers, based on `st_blksize`
* added "`--wait`" option to wait until transfer begins before showing progress
* added "`--rate-limit`" option to limit rate to a maximum throughput
* added "`--quiet`" option (no output at all) to be used with "`--rate-limit`"
0.2.5 - 23 July 2002
* added *[FILE]...* arguments, like "`cat`"
* function separation in code
* some bug fixes related to numeric overflow
0.2.3 - 19 July 2002
* Texinfo manual written, man page updated
* byte counter added
0.2.0 - 18 July 2002
* ETA counter added
* screen width estimation added
* progress bar added
0.1.0 - 17 July 2002
* main loop created
* rate counter added
* elapsed time counter added
* percentage calculation added
0.0.1 - 16 July 2002
* package created
* first draft of man page written
-35
View File
@@ -1,35 +0,0 @@
Things still to do:
- allow -E to take a block size argument so errors cause a skip to the
next block (Anthony DeRobertis)
- (#1559) momentary ETA option (Luc Gommans)
- (#1556) correct German translations (Richard Fonfara)
- (#1557) use clock_gettime() in ETA calculation (Mateju Miroslav)
- (#1561) show days in same format in ETA as in elapsed time
- (#1562) allow -r with -l and -n to output lines/sec (Roland Kletzing)
- (#1563) make -B imply -C (Johannes Gerer)
- document zsh <() incompatibility (frederik@ofb.net - Frederik Eaton)
- do not check terminal in -q/-n mode (zsh <(pv -n) fails)
- if -w/-H was specified, ignore SIGWINCH
- option to enable O_DIRECT (Romain Kang, Jacek Wielemborek)
- use posix_fadvise() like cat(1) does (Jacek Wielemborek)
- (#1508) add watchfd tests
- (#1534) allow multiple -d options
- (#1533) one-shot option (Jacek Wielemborek)
- (#1505) option to switch rate to per minute if really slow
- (#1510) option "--progress-from FILE", read last number and use it as bytes read:
pv --progress-from <( while sleep 1; do du -sb somedir; done ) -s 123g
(Jacek Wielemborek)
- (#1476) (Debian #507682) adjustable averaging window for rate display
- (#1286) option for process title (Martin Sarsale) as "pv - name:FooProcess -xyz - transferred: 1.3GB - 500KB/s - running: 10:15:30s"
- (#1290) look at effect of O_SYNC or fsync on performance
- (#1281) option (-x?) to use xterm title line for status (Joachim Haga)
- (#1287) if the first pv exits, should the second become IPC leader?
- (#1560) use Unicode for more granular progress bar (Alexander Petrossian)
- add development support for http://clang-analyzer.llvm.org/
- stats for avg/min/max/stddev throughput (Venky.N.Iyer)
- pv-ify a command line (Will Entriken) - "pv FOO | BAR | BAZ"
- get more translations
Any assistance would be appreciated.
+45
View File
@@ -0,0 +1,45 @@
Things still to do. (GH#n) indicates the Github issue tracker number.
Bugs
----
* ([GH#5](https://github.com/a-j-wood/pv/issues/5)) Transfer IPC leadership on exit of leader
* ([GH#13](https://github.com/a-j-wood/pv/issues/13)) Use `clock_gettime()` in ETA calculation to cope with machine suspend/resume (Mateju Miroslav)
* ([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)
Feature requests
----------------
* ([GH#3](https://github.com/a-j-wood/pv/issues/3)) Option ("`-x`"?) to use xterm title line for status (Joachim Haga)
* ([GH#4](https://github.com/a-j-wood/pv/issues/4)) Option for process title (Martin Sarsale) as "`pv - name:FooProcess -xyz - transferred: 1.3GB - 500KB/s - running: 10:15:30s`"
* ([GH#6](https://github.com/a-j-wood/pv/issues/6)) Look at effect of *O_SYNC* or `fsync` on performance; update counters during buffer flush
* ([GH#9](https://github.com/a-j-wood/pv/issues/9)) Option to switch rate to per minute if really slow
* ([GH#10](https://github.com/a-j-wood/pv/issues/10)) Add watchfd tests
* ([GH#11](https://github.com/a-j-wood/pv/issues/11)) Option "`--progress-from FILE`", read last number and use it as bytes read (Jacek Wielemborek)
* ([GH#12](https://github.com/a-j-wood/pv/issues/12)) Allow multiple "`-d`" options (Linus Heckemann for multiple PID:FD; Jacek Wielemborek)
* ([GH#15](https://github.com/a-j-wood/pv/issues/15)) Use Unicode for more granular progress bar (Alexander Petrossian)
* ([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#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)
* ([GH#38](https://github.com/a-j-wood/pv/issues/38)) Reset ETA on *SIGUSR1* (Jacek Wielemborek - Jan 2019)
* ([GH#39](https://github.com/a-j-wood/pv/issues/39)) Use `posix_fadvise()` like `cat`(1) does (Jacek Wielemborek - Oct 2015)
* ([GH#40](https://github.com/a-j-wood/pv/issues/40)) Permit "`-c`" with "`-d PID:FD`", reject "`-N`" with "`-d PID`" (Norman Rasmussen - Nov 2020)
* ([GH#41](https://github.com/a-j-wood/pv/issues/41)) Improve how backwards-moving reads are shown in "`--watchfd`" (Ryan Cooley - Dec 2017)
* ([GH#42](https://github.com/a-j-wood/pv/issues/42)) Option to discard stdin so nothing is written to stdout (André Stapf - Apr 2017)
* ([GH#43](https://github.com/a-j-wood/pv/issues/43)) Differentiate between "`--eta`" and "`--fineta`" in display (André Stapf - Apr 2017)
* ([GH#45](https://github.com/a-j-wood/pv/issues/45)) Option "`--sparse`" (with block size option) to write sparse output (Andriy Galetski - Apr 2019)
* ([GH#46](https://github.com/a-j-wood/pv/issues/46)) Option to show speed gauge (% max speed) if progress not known (Ryan Cooley - Jun 2019)
* ([GH#47](https://github.com/a-j-wood/pv/issues/47)) Analyse splice and buffer usage to improve performance
* ([GH#48](https://github.com/a-j-wood/pv/issues/48)) Option to show multiple files with individual sizes and a cumulative total (Zach Riggle - Jul 2021)
* ([GH#49](https://github.com/a-j-wood/pv/issues/49)) Option to provide stats for avg/min/max/stddev throughput (Venky.N.Iyer)
* ([GH#50](https://github.com/a-j-wood/pv/issues/50)) Allow pv to report on a whole pipeline at once (Will Entriken - Feb 2011)
* ([GH#54](https://github.com/a-j-wood/pv/issues/54)) Run command every n percent ([haarp](https://github.com/haarp))
* ([GH#56](https://github.com/a-j-wood/pv/issues/56)) Support for backgrounding pv, and allowing it to be monitored separately ([jimbobmcgee](https://github.com/jimbobmcgee))
* ([GH#67](https://github.com/a-j-wood/pv/issues/67)) Wrap another process to monitor its stdin & stdout ([Alex Mason](https://github.com/axman6))
Any assistance would be appreciated.
+1 -1
View File
@@ -1 +1 @@
1.6.6
1.7.24
+1 -1
View File
@@ -1,7 +1,7 @@
Begin3
Title: @PACKAGE@
Version: @VERSION@
Entered-date: 30JUN17
Entered-date: 30JUL23
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
+103 -22
View File
@@ -1,4 +1,4 @@
.TH @UCPACKAGE@ 1 "June 2017" Linux "User Manuals"
.TH @UCPACKAGE@ 1 "July 2023" Linux "User Manuals"
.SH NAME
@PACKAGE@ \- monitor the progress of data through a pipe
.SH SYNOPSIS
@@ -63,19 +63,19 @@ program for a full-screen progress display:
Taking an image of a disk, skipping errors:
.RS
.B @PACKAGE@ -EE /dev/sda > disk-image.img
.B @PACKAGE@ -EE /dev/your/disk/device > disk-image.img
.RE
Writing an image back to a disk:
.RS
.B @PACKAGE@ disk-image.img > /dev/sda
.B @PACKAGE@ disk-image.img > /dev/your/disk/device
.RE
Zeroing a disk:
.RS
.B @PACKAGE@ < /dev/zero > /dev/sda
.B @PACKAGE@ < /dev/zero > /dev/your/disk/device
.RE
Note that if the input size cannot be calculated, and the output is a block
@@ -127,7 +127,7 @@ Turn the timer on. This will display the total elapsed time that
has been running for.
.TP
.B \-e, \-\-eta
Turn the ETA timer on. This will attempt to guess, based on previous
Turn the ETA timer on. This will attempt to guess, based on current
transfer rates and the total data size, how long it will be before
completion. This option will have no effect if the total data size cannot
be determined.
@@ -142,20 +142,25 @@ Turn the rate counter on. This will display the current rate of data
transfer.
.TP
.B \-a, \-\-average\-rate
Turn the average rate counter on. This will display the average rate of
data transfer so far.
Turn the average rate counter on. This will display the current average
rate of data transfer (default: last 30s, see --average-rate-window).
.TP
.B \-b, \-\-bytes
Turn the total byte counter on. This will display the total amount of
data transferred so far.
.TP
.B \-8, \-\-bits
Display the total bits instead of the total bytes. The output suffix will
be "b" instead of "B".
.TP
.B \-T, \-\-buffer\-percent
Turn on the transfer buffer percentage display. This will show the
percentage of the transfer buffer in use - but see the caveat under
.B %T
in the
.B FORMATTING
section below.
section below. Implies
.BR \-C .
.TP
.B \-A, \-\-last\-written NUM
Show the last
@@ -164,7 +169,8 @@ bytes written - but see the caveat under
.B %nA
in the
.B FORMATTING
section below.
section below. Implies
.BR \-C .
.TP
.B \-F, \-\-format FORMAT
Ignore the options
@@ -203,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
@@ -241,7 +253,18 @@ etc can be used as with
.BR -L .
.TP
.B ""
Has no effect if used with
If
.B SIZE
starts with
.BR "@" ,
the size of file whose name follows the
.B @
will be used.
.TP
.B ""
Note that
.B \-\-size
has no effect if used with
.B -d PID
to watch all file descriptors of a process, but will work with
.BR "-d PID:FD" .
@@ -263,6 +286,11 @@ Wait
seconds between updates. The default is to update every second.
Note that this can be a decimal such as 0.1.
.TP
.B \-m SEC, \-\-average-rate-window SEC
Compute current average rate over a
.B SEC
seconds window for average rate and ETA calculations (default 30s).
.TP
.B \-w WIDTH, \-\-width WIDTH
Assume the terminal is
.B WIDTH
@@ -312,7 +340,10 @@ Use a transfer buffer size of
bytes. A suffix of "K", "M", "G", or "T" can be added to denote
kibibytes (*1024), mebibytes, and so on. The default buffer size is the
block size of the input file's filesystem multiplied by 32 (512KiB max), or
400KiB if the block size cannot be determined.
400KiB if the block size cannot be determined. This can be useful on
platforms like MacOS which perform better in pipelines with specific buffer
sizes such as 1024. Implies
.BR \-C .
.TP
.B \-C, \-\-no-splice
Never use
@@ -328,13 +359,18 @@ but means that the transfer buffer may not be used. This prevents
.B \-A
and
.B \-T
from working, so if you want to use
.B \-A
from working, and makes
.B \-B
redundant, so using
.BR \-A ,
.BR \-T ,
or
.B \-T
then you will need to use
.BR \-C ,
at the cost of a small loss in transfer efficiency.
.B \-B
automatically switches on
.BR \-C .
Switching on
.B \-C
results in a small loss of transfer efficiency.
(This option has no effect on systems where
.BR splice (2)
is unavailable).
@@ -359,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
@@ -463,6 +517,11 @@ Bytes transferred so far (or lines if
.B \-l
was specified). Equivalent to
.BR \-b .
If
.B \-\-bits
was specified,
.B %b
shows the bits transferred so far, not bytes.
.TP
.B %T
Percentage of the transfer buffer in use. Equivalent to
@@ -513,6 +572,11 @@ Show only the elapsed time - useful as a simple timer, e.g.
The default behaviour: progress bar, elapsed time, estimated completion
time, current rate, and byte counter.
.P
On MacOS, it may be useful to specify
.B -B 1024
in a pipeline, as this may improve performance.
.SH EXIT STATUS
An exit status of 1 indicates a problem with the
@@ -544,12 +608,14 @@ A signal was caught that caused an early exit.
.B 64
Memory allocation failed.
.P
A zero exit status indicates no problems.
.SH AUTHOR
Written by Andrew Wood, with patches submitted by various other people.
Please see the package README for a complete list of contributors.
Please see the package's ACKNOWLEDGEMENTS file for a complete list of
contributors.
.SH KNOWN PROBLEMS
@@ -557,6 +623,19 @@ The following problems are known to exist in
.BR @PACKAGE@ :
.TP
.B *
In some versions of
.BR bash (1)
and
.BR zsh (1),
the construct
.B <(pv filename)
will not output any progress to the terminal when run from an interactive
shell, due to the subprocess being run in a separate process group from the
one that owns the terminal. In these cases, use
.BR \-\-force .
.P
.TP
.B *
The
.B -c
option does not work properly on Cygwin without
@@ -593,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.
+7 -9
View File
@@ -1,20 +1,18 @@
Before releasing a new version, go through this checklist:
- check for patches from http://packages.qa.debian.org/p/pv.html
- check for patches from https://tracker.debian.org/pkg/pv
- bump doc/VERSION
- bump doc/lsm.in
- check doc/NEWS is up to date
- check doc/spec.in is up to date (changelog)
- check doc/NEWS.md is up to date
- check manual is up to date
- make indent indentclean
- make indent; make indent indentclean
- make update-po
- make test
- commit
- commit to repository
- wipe build directory, re-run generate.sh and configure
- make release
- make release MAINTAINER=<signing-user>
- make manhtml | tidy -asxhtml | sed -e '1,/<body>/d' -e '/<\/body>/,$d'
- update HTML for todo and news
- copy and sign tar.gz to HTML directory
- submit new release
- copy and sign tar.gz to HTML directory (sig as both .asc and .txt)
- submit new release to Sourceforge
- upload HTML
- check validator results for project page and manual
-249
View File
@@ -1,249 +0,0 @@
Summary: Monitor the progress of data through a pipe
Name: @PACKAGE@
Version: @VERSION@
Release: 1%{?dist}
License: Artistic 2.0
Group: Development/Tools
Source: http://www.ivarch.com/programs/sources/@PACKAGE@-@VERSION@.tar.gz
Url: http://www.ivarch.com/programs/pv.shtml
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: gettext
%description
PV ("Pipe Viewer") is 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 quickly data is passing through, how long
it has taken, how near to completion it is, and an estimate of how long it
will be until completion.
%prep
%setup -q
%build
%configure
make %{?_smp_mflags}
%install
[ -n "$RPM_BUILD_ROOT" -a "$RPM_BUILD_ROOT" != / ] && rm -rf "$RPM_BUILD_ROOT"
mkdir -p "$RPM_BUILD_ROOT"%{_bindir}
mkdir -p "$RPM_BUILD_ROOT"%{_mandir}/man1
mkdir -p "$RPM_BUILD_ROOT"/usr/share/locale
make DESTDIR="$RPM_BUILD_ROOT" install
%find_lang %{name}
%check
make test
%clean
[ -n "$RPM_BUILD_ROOT" -a "$RPM_BUILD_ROOT" != / ] && rm -rf "$RPM_BUILD_ROOT"
%files -f %{name}.lang
%defattr(-, root, root)
%{_bindir}/%{name}
%{_mandir}/man1/%{name}.1.gz
%doc README doc/NEWS doc/TODO doc/COPYING
%changelog
* Fri Jun 30 2017 Andrew Wood <andrew.wood@ivarch.com> 1.6.6-1
- (r161) use %llu instead of %Lu for better compatibility (Eric A. Borisch)
- (r162) (#1532) fix target buffer size (-B) being ignored (AndCycle, Ilya
- Basin, Antoine Beaupré)
- (r164) cap read/write sizes, and check elapsed time during read/write
- cycles, to avoid display hangs with large buffers or slow media; also
- remove select() call from repeated_write function as it slows the
- transfer down and the wrapping alarm() means it is unnecessary
- (r169) (#1477) use alternate form for transfer counter, such that 13GB
- is shown as 13.0GB so it's the same width as 13.1GB (André Stapf)
- (r171) cleanup: units corrections in man page, of the form kb -> KiB
- (r175) report error in "-d" if process fd directory is unreadable, or if
- process disappears before we start the main loop (Jacek Wielemborek)
* Sun Mar 15 2015 Andrew Wood <andrew.wood@ivarch.com> 1.6.0-1
- fix lstat64 support when unavailable - separate patches supplied by Ganael
- Laplanche and Peter Korsgaard
- (#1506) new option "-D" / "--delay-start" to only show bar after N seconds
- (Damon Harper)
- new option "--fineta" / "-I" to show ETA as time of day rather than time
- remaining - patch supplied by Erkki Seppälä (r147)
- (#1509) change ETA (--eta / -e) so that days are given if the hours
- remaining are 24 or more (Jacek Wielemborek)
- (#1499) repeat read and write attempts on partial buffer fill/empty to
- work around post-signal transfer rate drop reported by Ralf Ramsauer
- (#1507) do not try to calculate total size in line mode, due to bug
- reported by Jacek Wielemborek and Michiel Van Herwegen
- cleanup: removed defunct RATS comments and unnecessary copyright notices
- clean up displayed lines when using --watchfd PID, when PID exits
- output errors on a new line to avoid overwriting transfer bar
* Tue Aug 26 2014 Andrew Wood <andrew.wood@ivarch.com> 1.5.7-1
- show KiB instead of incorrect kiB (Debian bug #706175)
- (#1284) do not gzip man page, for non-Linux OSes (Bob Friesenhahn)
- work around "awk" bug in tests/016-numeric-timer in decimal "," locales
- fix "make rpm" and "make srpm", extend "make release" to sign releases
* Sun May 4 2014 Andrew Wood <andrew.wood@ivarch.com> 1.5.3-1
- remove SPLICE_F_NONBLOCK to fix problem with slow splice() (Jan Seda)
* Mon Feb 10 2014 Andrew Wood <andrew.wood@ivarch.com> 1.5.2-1
- allow "--watchfd" to look at block devices
- let "--watchfd PID:FD" work with "--size N"
- moved contributors out of the manual as the list was too long
- (NB everyone is still listed in the README and always will be)
* Thu Jan 23 2014 Andrew Wood <andrew.wood@ivarch.com> 1.5.1-1
- new option "--watchfd" - suggested by Jacek Wielemborek and "fdwatch"
- use non-block flag with splice()
- new display option "--buffer-percent", suggested by Kim Krecht
- new display option "--last-written", suggested by Kim Krecht
- new transfer option "--no-splice"
- fix for minor bug which dropped display elements after one empty one
- fix for single fd leak on exit (Cristian Ciupitu, Josh Stone)
* Mon Aug 5 2013 Andrew Wood <andrew.wood@ivarch.com> 1.4.12-1
- new option "--null" - patch supplied by Zing Shishak
- AIX build fix (add "-lc128") - with help from Pawel Piatek
- AIX "-c" fixes - with help from Pawel Piatek
- SCO build fix (po2table.sh) - reported by Wouter Pronk
- test scripts fix for older distributions - patch from Bryan Dongray
- fix for splice() not using stdin - patch from Zev Weiss
* Tue Jan 22 2013 Andrew Wood <andrew.wood@ivarch.com> 1.4.6-1
- added patch from Pawel Piatek to omit O_NOFOLLOW in AIX
* Thu Jan 10 2013 Andrew Wood <andrew.wood@ivarch.com> 1.4.5-1
- updated manual page to show known problem with "-R" on Cygwin
* Tue Dec 11 2012 Andrew Wood <andrew.wood@ivarch.com> 1.4.4-1
- added debugging, see `pv -h' when configure run with "--enable-debugging"
- rewrote cursor positioning code used when IPC is unavailable (Cygwin)
- fixed cursor positioning cursor read answerback problem (Cygwin/Solaris)
- fixed bug causing crash when progress displayed with too-small terminal
* Thu Dec 6 2012 Andrew Wood <andrew.wood@ivarch.com> 1.4.0-1
- new option "--skip-errors" commissioned by Jim Salter
- if stdout is a block device, and we don't know the total size, use the
- size of that block device as the total (Peter Samuelson)
- new option "--stop-at-size" to stop after "--size" bytes
- report correct filename on read errors
- fix use-after-free bug in remote PID cleanup code
- refactored large chunks of code to make it more readable and to replace
- most static variables with a state structure
* Mon Nov 5 2012 Andrew Wood <andrew.wood@ivarch.com> 1.3.9-1
- allow "--format" parameters to be sent with "--remote"
- configure option "--disable-ipc"
- added tests for --numeric with --timer and --bytes
- added tests for --remote
* Mon Oct 29 2012 Andrew Wood <andrew.wood@ivarch.com> 1.3.8-1
- new "--pidfile" option to save process ID to a file
- integrated patch for --numeric with --timer and --bytes (Sami Liedes)
- removed signalling from --remote to prevent accidental process kills
- new "--format" option (originally Vladimir Pal / Vladimir Ermakov)
* Wed Jun 27 2012 Andrew Wood <andrew.wood@ivarch.com> 1.3.4-1
- new "--disable-splice" configure script option
- fixed line mode size count with multiple files (Moritz Barsnick)
- fixes for AIX core dumps (Pawel Piatek)
* Sat Jun 9 2012 Andrew Wood <andrew.wood@ivarch.com> 1.3.1-1
- do not use splice() if the write buffer is not empty (Thomas Rachel)
- added test 15 (pipe transfers), and new test script
* Tue Jun 5 2012 Andrew Wood <andrew.wood@ivarch.com> 1.3.0-1
- added Tiger build patch from Olle Jonsson.
- fix 1024-boundary display garble (Debian bug #586763).
- use splice(2) where available (Debian bug #601683).
- added known bugs section of the manual page.
- fixed average rate test, 12 (Andrew Macheret).
- use IEEE1541 units (Thomas Rachel).
- bug with rate limit under 10 fixed (Henry Precheur).
- speed up PV line mode (patch: Guillaume Marcais).
- remove LD=ld from vars.mk to fix cross-compilation (paintitgray/PV#1291).
* Tue Dec 14 2010 Andrew Wood <andrew.wood@ivarch.com> 1.2.0-1
- Integrated improved SI prefixes and --average-rate (Henry Gebhardt).
- Return nonzero if exiting due to SIGTERM (Martin Baum).
- Patch from Phil Rutschman to restore terminal properly on exit.
- Fix i18n especially for --help (Sebastian Kayser).
- Refactored pv_display.
- We now have a coherent, documented, exit status.
- Modified pipe test and new cksum test from Sebastian Kayser.
- Default CFLAGS to just "-O" for non-GCC (Kjetil Torgrim Homme).
- LFS compile fix for OS X 10.4 (Alexandre de Verteuil).
- Remove DESTDIR / suffix (Sam Nelson, Daniel Pape).
- Fixed potential NULL deref in transfer (Elias Pipping / LLVM/Clang).
* Thu Mar 6 2008 Andrew Wood <andrew.wood@ivarch.com> 1.1.4-1
- Trap SIGINT/SIGHUP/SIGTERM so we clean up IPCs on exit (Laszlo Ersek).
- Abort if numeric option, eg -L, has non-numeric value (Boris Lohner).
- Compilation fixes for Darwin 9 and OS X.
* Thu Aug 30 2007 Andrew Wood <andrew.wood@ivarch.com> 1.1.0-1
- New option "-R" to remotely control another @PACKAGE@ process.
- New option "-l" to count lines instead of bytes.
- Performance improvement for "-L" (rate) option.
- Some Mac OS X fixes, and packaging cleanups.
* Sat Aug 4 2007 Andrew Wood <andrew.wood@ivarch.com> 1.0.1-1
- Changed license from Artistic to Artistic 2.0.
- Removed "--license" option.
* Thu Aug 2 2007 Andrew Wood <andrew.wood@ivarch.com> 1.0.0-1
- We now act more like "cat" - just skip unreadable files, don't abort.
- Various code cleanups were done.
* Mon Feb 5 2007 Andrew Wood <andrew.wood@ivarch.com> 0.9.9-1
- New option "-B" to set the buffer size, and a workaround for problems
- piping to dd(1).
* Mon Feb 27 2006 Andrew Wood <andrew.wood@ivarch.com>
- Minor bugfixes, and on the final update, blank out the now-zero ETA.
* Thu Sep 1 2005 Andrew Wood <andrew.wood@ivarch.com>
- Terminal locking now uses lockfiles if the terminal itself cannot be locked.
* Thu Jun 16 2005 Andrew Wood <andrew.wood@ivarch.com>
- A minor problem with the spec file was fixed.
* Mon Nov 15 2004 Andrew Wood <andrew.wood@ivarch.com>
- A minor bug in the NLS code was fixed.
* Sat Nov 6 2004 Andrew Wood <andrew.wood@ivarch.com>
- Code cleanups and minor usability fixes.
* Tue Jun 29 2004 Andrew Wood <andrew.wood@ivarch.com>
- A port of the terminal locking code to FreeBSD.
* Sun May 2 2004 Andrew Wood <andrew.wood@ivarch.com>
- Major reliability improvements to the cursor positioning.
* Sat Apr 24 2004 Andrew Wood <andrew.wood@ivarch.com>
- Rate and size parameters can now take suffixes such as "k", "m" etc.
* Mon Apr 19 2004 Andrew Wood <andrew.wood@ivarch.com>
- A bug in the cursor positioning was fixed.
* Thu Feb 12 2004 Andrew Wood <andrew.wood@ivarch.com>
- Code cleanups and portability fixes.
* Sun Feb 8 2004 Andrew Wood <andrew.wood@ivarch.com>
- The display buffer is now dynamically allocated, fixing an overflow bug.
* Wed Jan 14 2004 Andrew Wood <andrew.wood@ivarch.com>
- A minor bug triggered when installing the RPM was fixed.
* Mon Dec 22 2003 Andrew Wood <andrew.wood@ivarch.com>
- Fixed a minor bug that occasionally reported "resource unavailable".
* Wed Aug 6 2003 Andrew Wood <andrew.wood@ivarch.com>
- Block devices now have their size read correctly, so pv /dev/hda1 works
- Minor code cleanups (mainly removal of CVS "Id" tags)
* Sun Aug 3 2003 Andrew Wood <andrew.wood@ivarch.com>
- Doing ^Z then "bg" then "fg" now continues displaying
* Tue Jul 16 2002 Andrew Wood <andrew.wood@ivarch.com>
- First draft of spec file created.
+20 -8
View File
@@ -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
+45
View File
@@ -0,0 +1,45 @@
/*
* 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 */
#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 */
+4
View File
@@ -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
+15 -8
View File
@@ -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
@@ -26,22 +29,26 @@
#else
# define _(String) minigettext (String)
# define N_(String) (String)
# define setlocale minisetlocale
# ifdef HAVE_LOCALE_H
# include <locale.h>
# else
# define setlocale minisetlocale
# ifndef LC_ALL
# define LC_ALL ""
# endif
# endif
# define bindtextdomain minibindtextdomain
# define textdomain minitextdomain
# ifndef LC_ALL
# define LC_ALL ""
# endif
#endif
#ifdef __cplusplus
extern "C" {
#endif
char *minisetlocale(char *, char *);
char *minibindtextdomain(char *, char *);
char *minitextdomain(char *);
char *minigettext(char *);
char *minisetlocale(const char *, const char *);
char *minibindtextdomain(const char *, const char *);
char *minitextdomain(const char *);
char *minigettext(const char *);
#ifdef __cplusplus
}
+27 -19
View File
@@ -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
@@ -14,34 +18,38 @@ typedef struct opts_s *opts_t;
struct opts_s { /* structure describing run-time options */
char *program_name; /* name the program is running as */
unsigned char do_nothing; /* exit-without-doing-anything flag */
unsigned char progress; /* progress bar flag */
unsigned char timer; /* timer flag */
unsigned char eta; /* ETA flag */
unsigned char fineta; /* absolute ETA flag */
unsigned char rate; /* rate counter flag */
unsigned char average_rate; /* average rate counter flag */
unsigned char bytes; /* bytes transferred flag */
unsigned char bufpercent; /* transfer buffer percentage flag */
bool do_nothing; /* exit-without-doing-anything flag */
bool progress; /* progress bar flag */
bool timer; /* timer flag */
bool eta; /* ETA flag */
bool fineta; /* absolute ETA flag */
bool rate; /* rate counter flag */
bool average_rate; /* average rate counter flag */
bool bytes; /* bytes transferred flag */
bool bits; /* report transfer size in bits */
bool bufpercent; /* transfer buffer percentage flag */
unsigned int lastwritten; /* show N bytes last written */
unsigned char force; /* force-if-not-terminal flag */
unsigned char cursor; /* whether to use cursor positioning */
unsigned char numeric; /* numeric output only */
unsigned char wait; /* wait for transfer before display */
unsigned char linemode; /* count lines instead of bytes */
unsigned char null; /* lines are null-terminated */
unsigned char no_op; /* do nothing other than pipe data */
bool force; /* force-if-not-terminal flag */
bool cursor; /* whether to use cursor positioning */
bool numeric; /* numeric output only */
bool wait; /* wait for transfer before display */
bool linemode; /* count lines instead of bytes */
bool null; /* lines are null-terminated */
bool no_op; /* do nothing other than pipe data */
unsigned long long rate_limit; /* rate limit, in bytes per second */
unsigned long long buffer_size;/* buffer size, in bytes (0=default) */
unsigned int remote; /* PID of pv to update settings of */
unsigned long long size; /* total size of data */
unsigned char no_splice; /* flag set if never to use splice */
unsigned char skip_errors; /* skip read errors flag */
unsigned char stop_at_size; /* set if we stop at "size" bytes */
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 */
int watch_fd; /* fd to watch */
unsigned int average_rate_window; /* time window in seconds for average rate calculations */
unsigned int width; /* screen width */
unsigned int height; /* screen height */
char *name; /* process name, if any */
+87 -43
View File
@@ -1,18 +1,15 @@
/*
* 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>
@@ -34,6 +31,7 @@ extern "C" {
#define PV_DISPLAY_FINETA 512
#define RATE_GRANULARITY 100000 /* usec between -L rate chunks */
#define RATE_BURST_WINDOW 5 /* rate burst window (multiples of rate) */
#define REMOTE_INTERVAL 100000 /* usec between checks for -R */
#define BUFFER_SIZE 409600 /* default transfer buffer size */
#define BUFFER_SIZE_MAX 524288 /* max auto transfer buffer size */
@@ -45,6 +43,33 @@ extern "C" {
#define MAXIMISE_BUFFER_FILL 1
typedef struct pvhistory {
long long total_bytes;
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.
*/
@@ -58,16 +83,20 @@ struct pvstate_s {
/*******************
* Program control *
*******************/
unsigned char force; /* display even if not on terminal */
unsigned char cursor; /* use cursor positioning */
unsigned char numeric; /* numeric output only */
unsigned char wait; /* wait for data before display */
unsigned char linemode; /* count lines instead of bytes */
unsigned char null; /* lines are null-terminated */
unsigned char no_op; /* do nothing other than pipe data */
unsigned char skip_errors; /* skip read errors flag */
unsigned char stop_at_size; /* set if we stop at "size" bytes */
unsigned char no_splice; /* never use splice() */
bool force; /* display even if not on terminal */
bool cursor; /* use cursor positioning */
bool numeric; /* numeric output only */
bool wait; /* wait for data before display */
bool linemode; /* count lines instead of bytes */
bool bits; /* report bits instead of bytes */
bool null; /* lines are null-terminated */
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) */
unsigned long long size; /* total size of data */
@@ -78,13 +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[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) */
@@ -113,29 +143,38 @@ struct pvstate_s {
long double prev_elapsed_sec;
long double prev_rate;
long double prev_trans;
/* Keep track of progress over last intervals to compute current average rate. */
pvhistory_t *history; /* state at previous intervals (circular buffer) */
int history_len; /* total size */
int history_interval; /* seconds between each history entry */
int history_first;
int history_last;
long double current_avg_rate; /* current average rate over last history intervals */
unsigned long long initial_offset;
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];
unsigned char display_visible; /* set once anything written to terminal */
} format[PV_FORMAT_ARRAY_MAX];
bool display_visible; /* set once anything written to terminal */
/********************
* Cursor/IPC state *
@@ -147,11 +186,11 @@ struct pvstate_s {
int *crs_y_top; /* pointer to Y coord of topmost `pv' */
int crs_y_lastread; /* last value of _y_top seen */
int crs_y_offset; /* our Y offset from this top position */
int crs_needreinit; /* set if we need to reinit cursor pos */
int crs_noipc; /* set if we can't use IPC */
int crs_needreinit; /* counter if we need to reinit cursor pos */
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 */
/*******************
@@ -212,12 +251,15 @@ struct pvstate_s {
struct pvwatchfd_s {
unsigned int watch_pid; /* PID to watch */
int watch_fd; /* fd to watch, -1 = not displayed */
char file_fdinfo[4096]; /* path to /proc fdinfo file */
char file_fd[4096]; /* path to /proc fd symlink */
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 */
#ifdef __APPLE__
#else
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[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 */
@@ -232,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
+58 -21
View File
@@ -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
@@ -34,14 +40,14 @@ typedef enum {
extern double pv_getnum_d(const char *);
/*
* Return the given string converted to an integer.
* Return the given string converted to an unsigned integer.
*/
extern int pv_getnum_i(const char *);
extern unsigned int pv_getnum_ui(const char *);
/*
* Return the given string converted to a long long.
* Return the given string converted to an unsigned long long.
*/
extern long long pv_getnum_ll(const char *);
extern unsigned long long pv_getnum_ull(const char *);
/*
* Return zero if the given string is a number of the given type. NB an
@@ -49,6 +55,23 @@ extern long long pv_getnum_ll(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.
*/
@@ -61,30 +84,33 @@ extern pvstate_t pv_state_alloc(const char *);
/*
* Set the formatting string, given a set of old-style formatting options.
*/
extern void pv_state_set_format(pvstate_t state, unsigned char progress,
unsigned char timer, unsigned char eta,
unsigned char fineta, unsigned char rate,
unsigned char average_rate, unsigned char bytes,
unsigned char bufpercent,
extern void pv_state_set_format(pvstate_t state, bool progress,
bool timer, bool eta,
bool fineta, bool rate,
bool average_rate, bool bytes,
bool bufpercent,
unsigned int lastwritten,
const char *name);
/*
* Set the various options.
*/
extern void pv_state_force_set(pvstate_t, unsigned char);
extern void pv_state_cursor_set(pvstate_t, unsigned char);
extern void pv_state_numeric_set(pvstate_t, unsigned char);
extern void pv_state_wait_set(pvstate_t, unsigned char);
extern void pv_state_force_set(pvstate_t, bool);
extern void pv_state_cursor_set(pvstate_t, bool);
extern void pv_state_numeric_set(pvstate_t, bool);
extern void pv_state_wait_set(pvstate_t, bool);
extern void pv_state_delay_start_set(pvstate_t, double);
extern void pv_state_linemode_set(pvstate_t, unsigned char);
extern void pv_state_null_set(pvstate_t, unsigned char);
extern void pv_state_no_op_set(pvstate_t, unsigned char);
extern void pv_state_skip_errors_set(pvstate_t, unsigned char);
extern void pv_state_stop_at_size_set(pvstate_t, unsigned char);
extern void pv_state_linemode_set(pvstate_t, bool);
extern void pv_state_bits_set(pvstate_t, bool);
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, unsigned char);
extern void pv_state_no_splice_set(pvstate_t, bool);
extern void pv_state_size_set(pvstate_t, unsigned long long);
extern void pv_state_interval_set(pvstate_t, double);
extern void pv_state_width_set(pvstate_t, unsigned int);
@@ -93,9 +119,15 @@ extern void pv_state_name_set(pvstate_t, const char *);
extern void pv_state_format_string_set(pvstate_t, const char *);
extern void pv_state_watch_pid_set(pvstate_t, unsigned int);
extern void pv_state_watch_fd_set(pvstate_t, int);
extern void pv_state_average_rate_window_set(pvstate_t, int);
extern void pv_state_inputfiles(pvstate_t, int, const char **);
/*
* Work out whether we are in the foreground.
*/
extern bool pv_in_foreground(void);
/*
* Work out the terminal size.
*/
@@ -138,7 +170,7 @@ extern void pv_state_free(pvstate_t);
#ifdef ENABLE_DEBUGGING
# if __STDC_VERSION__ < 199901L
# if __STDC_VERSION__ < 199901L && !defined(__func__)
# if __GNUC__ >= 2
# define __func__ __FUNCTION__
# else
@@ -150,6 +182,11 @@ extern void pv_state_free(pvstate_t);
# define debug(x,...) do { } while (0)
#endif
/*
* Set the debugging destination file, if debugging is enabled.
*/
void debugging_output_destination(const char *);
/*
* Output debugging information, if debugging is enabled.
*/
+6 -4
View File
@@ -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"
@@ -68,8 +72,7 @@ int minigetopt(int argc, char **argv, char *optstring)
if (0 == optstring[i]) {
minioptopt = optchar;
if (miniopterr)
fprintf(stderr, "%s: invalid option -- %c\n",
argv[0], optchar);
fprintf(stderr, "%s: invalid option -- %c\n", argv[0], optchar);
return '?';
}
@@ -99,8 +102,7 @@ int minigetopt(int argc, char **argv, char *optstring)
nextchar = 0;
minioptind++;
if (minioptind >= argc) {
fprintf(stderr, "%s: option `-%c' requires an argument\n",
argv[0], optchar);
fprintf(stderr, "%s: option `-%c' requires an argument\n", argv[0], optchar);
return ':';
}
minioptarg = argv[minioptind++];
+13 -9
View File
@@ -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"
@@ -34,25 +38,25 @@ struct msgtable_s *minigettext__gettable(char *a)
}
#endif /* ENABLE_NLS */
char *minisetlocale(char *a, char *b)
char *minisetlocale(const char *a, const char *b)
{
return NULL;
}
char *minibindtextdomain(char *a, char *b)
char *minibindtextdomain(const char *a, const char *b)
{
return NULL;
}
char *minitextdomain(char *a)
char *minitextdomain(const char *a)
{
return NULL;
}
char *minigettext(char *msgid)
char *minigettext(const char *msgid)
{
static struct msgtable_s *table = NULL;
static int tried_lang = 0;
@@ -60,7 +64,7 @@ char *minigettext(char *msgid)
int i;
if (NULL == msgid)
return msgid;
return NULL;
if (0 == tried_lang) {
lang = getenv("LANGUAGE");
@@ -89,19 +93,19 @@ char *minigettext(char *msgid)
}
if (NULL == table)
return msgid;
return (char *) msgid;
for (i = 0; table[i].msgid; i++) {
if (0 == strcmp(table[i].msgid, msgid)) {
if (0 == table[i].msgstr)
return msgid;
return (char *) msgid;
if (0 == table[i].msgstr[0])
return msgid;
return (char *) msgid;
return table[i].msgstr;
}
}
return msgid;
return (char *) msgid;
}
#endif /* HAVE_GETTEXT */
+64 -24
View File
@@ -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>
@@ -16,53 +18,91 @@
#ifdef ENABLE_DEBUGGING
/*@null@*/ static const char *debug_filename = NULL;
/*
* Output debugging information to the file given in the DEBUG environment
* variable, if it is defined.
* Set the destination for debugging information.
*/
void debugging_output(const char *function, const char *file, int line,
const char *format, ...)
void debugging_output_destination(const char *filename)
{
static int tried_open = 0;
debug_filename = filename;
}
/*
* Output debugging information to the file specified earlier by a call to
* debugging_output_destination(), if any.
*/
void debugging_output(const char *function, const char *file, int line, const char *format, ...)
{
static bool tried_open = false;
static FILE *debugfptr = NULL;
char *debugfile;
va_list ap;
time_t t;
struct tm *tm;
char tbuf[128];
char tbuf[128]; /* flawfinder: ignore */
if (0 == tried_open) {
debugfile = getenv("DEBUG");
if (NULL != debugfile)
debugfptr = fopen(debugfile, "a");
tried_open = 1;
/*
* flawfinder note: tbuf is only written to by strftime() which
* takes its size, and we enforce string termination.
*/
if (false == tried_open) {
if (NULL != debug_filename) {
debugfptr = fopen(debug_filename, "a"); /* flawfinder: ignore */
/*
* flawfinder note: caller directly controls
* filename, the safest we can manage is to use
* append mode.
*/
}
tried_open = true;
}
if (NULL == debugfptr)
if (NULL == debugfptr) {
return;
}
time(&t);
(void) time(&t);
tm = localtime(&t);
tbuf[0] = 0;
strftime(tbuf, sizeof(tbuf), "%Y-%m-%d %H:%M:%S", tm);
tbuf[0] = '\0';
if (0 == strftime(tbuf, sizeof(tbuf), "%Y-%m-%d %H:%M:%S", tm)) {
tbuf[0] = '\0';
}
tbuf[sizeof(tbuf) - 1] = '\0'; /* enforce termination */
fprintf(debugfptr, "[%s] (%d) %s (%s:%d): ", tbuf, getpid(),
function, file, line);
(void) fprintf(debugfptr, "[%s] (%d) %s (%s:%d): ", tbuf, getpid(), function, file, line);
va_start(ap, format);
vfprintf(debugfptr, format, ap);
(void) vfprintf(debugfptr, format, ap); /* flawfinder: ignore */
va_end(ap);
fprintf(debugfptr, "\n");
fflush(debugfptr);
/*
* flawfinder note: vfprintf format is explicitly controlled by the
* caller of this function - no mitigation possible or desirable.
*/
(void) fprintf(debugfptr, "\n");
(void) fflush(debugfptr);
}
#else /* ! ENABLE_DEBUGGING */
/*
* Stub debugging destination function.
*/
void debugging_output_destination( __attribute__((unused))
const char *filename)
{
}
/*
* Stub debugging output function.
*/
void debugging_output(const char *function, const char *file, int line,
void debugging_output( __attribute__((unused))
const char *function, __attribute__((unused))
const char *file, __attribute__((unused))
int line, __attribute__((unused))
const char *format, ...)
{
}
+560 -180
View File
@@ -1,23 +1,275 @@
/*
* 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>
#if defined(ENABLE_NLS) && defined(HAVE_WCHAR_H)
#include <wchar.h>
#if defined(HAVE_WCTYPE_H)
#include <wctype.h>
#endif
#endif
#define N_(String) (String)
struct optdesc_s {
char *optshort;
char *optlong;
char *param;
char *description;
/*
* Return the number of display columns needed to show the given string.
*
* To do this, we convert it to a wide character string, and use the wide
* character display width function "wcswidth()" on it.
*
* If NLS is disabled, or the string cannot be converted, this is just the
* same as "strlen()".
*/
static size_t display_width(const char *string)
{
size_t width;
#if defined(ENABLE_NLS) && defined(HAVE_WCHAR_H)
size_t wide_char_count;
size_t wide_string_buffer_size;
wchar_t *wide_string;
if (NULL == string)
return 0;
/*@-nullpass@ */
/*
* splint note: mbstowcs() manual page on Linux explicitly says it
* takes NULL.
*/
wide_char_count = mbstowcs(NULL, string, 0);
/*@+nullpass@ */
if (wide_char_count == (size_t) -1) {
debug("%s: %s: %s", "mbstowcs", string, strerror(errno));
return strlen(string); /* flawfinder: ignore */
/*
* flawfinder rationale: we have already checked for NULL,
* and we don't know the size of the originating buffer so
* can't use strnlen(); it is up to the caller to provide a
* terminated string.
*/
}
wide_string_buffer_size = sizeof(*wide_string) * (1 + wide_char_count);
wide_string = malloc(wide_string_buffer_size);
if (NULL == wide_string) {
perror("malloc");
return strlen(string); /* flawfinder: ignore */
/* flawfinder rationale: see above. */
}
memset(wide_string, 0, wide_string_buffer_size);
if (mbstowcs(wide_string, string, 1 + wide_char_count) == (size_t) -1) {
debug("%s: %s: %s", "mbstowcs", string, strerror(errno));
width = strlen(string); /* flawfinder: ignore */
/* flawfinder rationale: see above. */
} else if (NULL != wide_string) {
/*@-unrecog @ */
/* splint seems unable to see the prototype. */
width = wcswidth(wide_string, wide_char_count);
/*@+unrecog @ */
} else {
width = 0;
}
free(wide_string);
#else /* ! defined(ENABLE_NLS) && defined(HAVE_WCHAR_H) */
if (NULL == string)
return 0;
width = strlen(string); /* flawfinder: ignore */
/* flawfinder rationale: see above. */
#endif /* defined(ENABLE_NLS) && defined(HAVE_WCHAR_H) */
return width;
}
/*
* The 7-bit ASCII version of display_word_wrap() below - does not
* understand multi-byte characters.
*/
static void display_word_wrap_7bit(const char *string, size_t display_width, size_t left_margin)
{
const char *start;
const char *end;
if (NULL == string)
return;
start = string;
while (strlen(start) > display_width) { /* flawfinder: ignore */
/* flawfinder rationale: see above. */
end = start + display_width;
while ((end > start) && (end[0] != ' '))
end--;
if (end == start) {
end = start + display_width;
} else {
end++;
}
printf("%.*s", (int) (end - start), start);
if (end == start)
end++;
start = end;
if (start[0] != '\0')
printf("\n%*s", (int) left_margin, "");
}
printf("%s", start);
}
/*
* Output a string to standard output, word wrapping to "display_width"
* display character positions, and left-padding any new lines after the
* first one with "left_margin" spaces.
*
* Wide characters are handled if NLS is enabled, but if they can't be, this
* falls back to a version which just counts bytes as characters.
*/
static void display_word_wrap(const char *string, size_t display_width, size_t left_margin)
{
#if defined(ENABLE_NLS) && defined(HAVE_WCHAR_H)
size_t wide_char_count;
size_t wide_string_buffer_size;
wchar_t *wide_string;
size_t start_idx, end_idx, chars_remaining;
if (NULL == string)
return;
/*@-nullpass@ */
/* splint note: see earlier mbstowcs() call. */
wide_char_count = mbstowcs(NULL, string, 0);
/*@+nullpass@ */
if (wide_char_count == (size_t) -1) {
debug("%s: %s: %s", "mbstowcs", string, strerror(errno));
display_word_wrap_7bit(string, display_width, left_margin);
return;
}
wide_string_buffer_size = sizeof(*wide_string) * (1 + wide_char_count);
wide_string = malloc(wide_string_buffer_size);
if (NULL == wide_string) {
perror("malloc");
display_word_wrap_7bit(string, display_width, left_margin);
return;
}
memset(wide_string, 0, wide_string_buffer_size);
if (mbstowcs(wide_string, string, 1 + wide_char_count) == (size_t) -1) {
debug("%s: %s: %s", "mbstowcs", string, strerror(errno));
free(wide_string);
display_word_wrap_7bit(string, display_width, left_margin);
return;
}
start_idx = 0;
chars_remaining = wide_char_count;
while (chars_remaining > 0 && wcswidth(&(wide_string[start_idx]), chars_remaining) > display_width) {
size_t next_idx;
end_idx = start_idx + display_width;
while ((end_idx > start_idx) && (!iswspace(wide_string[end_idx])))
end_idx--;
if (end_idx == start_idx) {
end_idx = start_idx + display_width;
} else {
end_idx++;
}
next_idx = end_idx;
if (end_idx == start_idx)
next_idx++;
while (start_idx < end_idx && start_idx < wide_char_count) {
char multi_byte_string[MB_CUR_MAX + 1]; /* flawfinder: ignore */
/*
* flawfinder rationale: array is explicitly
* cleared, large enough according to the wctomb()
* manual, and we explicitly terminate the string.
*/
memset(multi_byte_string, 0, MB_CUR_MAX + 1);
if (wctomb(multi_byte_string, wide_string[start_idx]) >= 0) {
multi_byte_string[MB_CUR_MAX] = '\0';
printf("%s", multi_byte_string);
}
start_idx++;
}
start_idx = next_idx;
if (start_idx < wide_char_count)
printf("\n%*s", (int) left_margin, "");
chars_remaining = wide_char_count - start_idx;
}
while (start_idx < wide_char_count) {
char multi_byte_string[MB_CUR_MAX + 1]; /* flawfinder: ignore */
/* flawfinder rationale as above. */
memset(multi_byte_string, 0, MB_CUR_MAX + 1);
if (wctomb(multi_byte_string, wide_string[start_idx]) >= 0) {
multi_byte_string[MB_CUR_MAX] = '\0';
printf("%s", multi_byte_string);
}
start_idx++;
}
free(wide_string);
#else /* ! defined(ENABLE_NLS) && defined(HAVE_WCHAR_H) */
display_word_wrap_7bit(string, display_width, left_margin);
#endif /* defined(ENABLE_NLS) && defined(HAVE_WCHAR_H) */
}
/*
* Structure holding the displayed descriptions of each option - the short
* option such as "-s", its long counterpart such as "--size", the name of
* its argument such as "SIZE", and the description of what the option does.
* Any of them may be NULL.
*
* In the initialiser for this structure, translatable strings are wrapped
* with N_() to indicate that they are to be translated into the operator's
* language by this function at run-time.
*
* Note that "opt_short" and "opt_long" should never be marked as
* translatable, as they must remain consistent across all locales.
*
* The list is terminated with a NULL opt_short value - to leave a gap, set
* opt_short to an empty string instead.
*/
struct option_definition_s {
/*@null@ */ const char *opt_short;
/*@null@ */ const char *opt_long;
/*@null@ *//*@observer@ */ const char *opt_argument;
/*@null@ *//*@observer@ */ const char *opt_description;
struct {
/*
* Structure holding the width, in display character
* positions, of the individual parts of the description of
* each option - calculated after initialisation, so that
* translation can be performed.
*/
size_t opt_short;
size_t opt_long;
size_t opt_argument;
size_t opt_description;
} width;
};
@@ -26,183 +278,311 @@ struct optdesc_s {
*/
void display_help(void)
{
struct optdesc_s optlist[] = {
{"-p", "--progress", 0,
N_("show progress bar")},
{"-t", "--timer", 0,
N_("show elapsed time")},
{"-e", "--eta", 0,
N_("show estimated time of arrival (completion)")},
{"-I", "--fineta", 0,
N_
("show absolute estimated time of arrival (completion)")},
{"-r", "--rate", 0,
N_("show data transfer rate counter")},
{"-a", "--average-rate", 0,
N_("show data transfer average rate counter")},
{"-b", "--bytes", 0,
N_("show number of bytes transferred")},
{"-T", "--buffer-percent", 0,
N_("show percentage of transfer buffer in use")},
{"-A", "--last-written", _("NUM"),
N_("show NUM bytes last written")},
{"-F", "--format", N_("FORMAT"),
N_("set output format to FORMAT")},
{"-n", "--numeric", 0,
N_("output percentages, not visual information")},
{"-q", "--quiet", 0,
N_("do not output any transfer information at all")},
{"", 0, 0, 0},
{"-W", "--wait", 0,
N_("display nothing until first byte transferred")},
{"-D", "--delay-start", N_("SEC"),
N_("display nothing until SEC seconds have passed")},
{"-s", "--size", N_("SIZE"),
N_("set estimated data size to SIZE bytes")},
{"-l", "--line-mode", 0,
N_("count lines instead of bytes")},
{"-0", "--null", 0,
N_("lines are null-terminated")},
{"-i", "--interval", N_("SEC"),
N_("update every SEC seconds")},
{"-w", "--width", N_("WIDTH"),
N_("assume terminal is WIDTH characters wide")},
{"-H", "--height", N_("HEIGHT"),
N_("assume terminal is HEIGHT rows high")},
{"-N", "--name", N_("NAME"),
N_("prefix visual information with NAME")},
{"-f", "--force", 0,
N_("output even if standard error is not a terminal")},
{"-c", "--cursor", 0,
N_("use cursor positioning escape sequences")},
{"", 0, 0, 0},
{"-L", "--rate-limit", N_("RATE"),
N_("limit transfer to RATE bytes per second")},
{"-B", "--buffer-size", N_("BYTES"),
N_("use a buffer size of BYTES")},
{"-C", "--no-splice", 0,
N_("never use splice(), always use read/write")},
{"-E", "--skip-errors", 0,
N_("skip read errors in input")},
{"-S", "--stop-at-size", 0,
N_("stop after --size bytes have been transferred")},
struct option_definition_s option_definitions[] = {
{ "-p", "--progress", NULL,
N_("show progress bar"),
{ 0, 0, 0, 0} },
{ "-t", "--timer", NULL,
N_("show elapsed time"),
{ 0, 0, 0, 0} },
{ "-e", "--eta", NULL,
N_("show estimated time of arrival (completion)"),
{ 0, 0, 0, 0} },
{ "-I", "--fineta", NULL,
N_("show absolute estimated time of arrival (completion)"),
{ 0, 0, 0, 0} },
{ "-r", "--rate", NULL,
N_("show data transfer rate counter"),
{ 0, 0, 0, 0} },
{ "-a", "--average-rate", NULL,
N_("show data transfer average rate counter"),
{ 0, 0, 0, 0} },
{ "-m", "--average-rate-window", N_("SEC"),
N_("compute average rate over past SEC seconds (default 30s)"),
{ 0, 0, 0, 0} },
{ "-b", "--bytes", NULL,
N_("show number of bytes transferred"),
{ 0, 0, 0, 0} },
{ "-8", "--bits", NULL,
N_("show number of bits transferred"),
{ 0, 0, 0, 0} },
{ "-T", "--buffer-percent", NULL,
N_("show percentage of transfer buffer in use"),
{ 0, 0, 0, 0} },
{ "-A", "--last-written", _("NUM"),
N_("show NUM bytes last written"),
{ 0, 0, 0, 0} },
{ "-F", "--format", N_("FORMAT"),
N_("set output format to FORMAT"),
{ 0, 0, 0, 0} },
{ "-n", "--numeric", NULL,
N_("output percentages, not visual information"),
{ 0, 0, 0, 0} },
{ "-q", "--quiet", NULL,
N_("do not output any transfer information at all"),
{ 0, 0, 0, 0} },
{ "", NULL, NULL, NULL, { 0, 0, 0, 0} },
{ "-W", "--wait", NULL,
N_("display nothing until first byte transferred"),
{ 0, 0, 0, 0} },
{ "-D", "--delay-start", N_("SEC"),
N_("display nothing until SEC seconds have passed"),
{ 0, 0, 0, 0} },
{ "-s", "--size", N_("SIZE"),
N_("set estimated data size to SIZE bytes"),
{ 0, 0, 0, 0} },
{ "-l", "--line-mode", NULL,
N_("count lines instead of bytes"),
{ 0, 0, 0, 0} },
{ "-0", "--null", NULL,
N_("lines are null-terminated"),
{ 0, 0, 0, 0} },
{ "-i", "--interval", N_("SEC"),
N_("update every SEC seconds"),
{ 0, 0, 0, 0} },
{ "-w", "--width", N_("WIDTH"),
N_("assume terminal is WIDTH characters wide"),
{ 0, 0, 0, 0} },
{ "-H", "--height", N_("HEIGHT"),
N_("assume terminal is HEIGHT rows high"),
{ 0, 0, 0, 0} },
{ "-N", "--name", N_("NAME"),
N_("prefix visual information with NAME"),
{ 0, 0, 0, 0} },
{ "-f", "--force", NULL,
N_("output even if standard error is not a terminal"),
{ 0, 0, 0, 0} },
{ "-c", "--cursor", NULL,
N_("use cursor positioning escape sequences"),
{ 0, 0, 0, 0} },
{ "", NULL, NULL, NULL, { 0, 0, 0, 0} },
{ "-L", "--rate-limit", N_("RATE"),
N_("limit transfer to RATE bytes per second"),
{ 0, 0, 0, 0} },
{ "-B", "--buffer-size", N_("BYTES"),
N_("use a buffer size of BYTES"),
{ 0, 0, 0, 0} },
{ "-C", "--no-splice", NULL,
N_("never use splice(), always use read/write"),
{ 0, 0, 0, 0} },
{ "-E", "--skip-errors", NULL,
N_("skip read errors in input"),
{ 0, 0, 0, 0} },
{ "-S", "--stop-at-size", NULL,
N_("stop after --size bytes have been transferred"),
{ 0, 0, 0, 0} },
{ "-Y", "--sync", NULL,
N_("flush cache to disk after every write"),
{ 0, 0, 0, 0} },
{ "-K", "--direct-io", NULL,
N_("use direct I/O to bypass cache"),
{ 0, 0, 0, 0} },
#ifdef HAVE_IPC
{"-R", "--remote", N_("PID"),
N_("update settings of process PID")},
{ "-R", "--remote", N_("PID"),
N_("update settings of process PID"),
{ 0, 0, 0, 0} },
#endif /* HAVE_IPC */
{"", 0, 0, 0},
{"-P", "--pidfile", N_("FILE"),
N_("save process ID in FILE")},
{"", 0, 0, 0},
{"-d", "--watchfd", N_("PID[:FD]"),
N_("watch file FD opened by process PID")},
{"", 0, 0, 0},
{"-h", "--help", 0,
N_("show this help and exit")},
{"-V", "--version", 0,
N_("show version information and exit")},
{0, 0, 0, 0}
};
int i, col1max = 0, tw = 77;
char *optbuf;
printf(_("Usage: %s [OPTION] [FILE]..."), PROGRAM_NAME);
printf("\n%s\n\n",
_
("Concatenate FILE(s), or standard input, to standard output,\n"
"with monitoring."));
for (i = 0; optlist[i].optshort; i++) {
int width = 0;
char *param;
width = 2 + strlen(optlist[i].optshort);
#ifdef HAVE_GETOPT_LONG
if (optlist[i].optlong)
width += 2 + strlen(optlist[i].optlong);
#endif
param = optlist[i].param;
if (param)
param = _(param);
if (param)
width += 1 + strlen(param);
if (width > col1max)
col1max = width;
}
col1max++;
optbuf = malloc(col1max + 16);
if (NULL == optbuf) {
fprintf(stderr, "%s: %s\n", PROGRAM_NAME, strerror(errno));
exit(1);
}
for (i = 0; optlist[i].optshort; i++) {
char *param;
char *description;
char *start;
char *end;
if (0 == optlist[i].optshort[0]) {
printf("\n");
continue;
}
param = optlist[i].param;
if (param)
param = _(param);
description = optlist[i].description;
if (description)
description = _(description);
sprintf(optbuf, "%s%s%s%s%s", optlist[i].optshort,
#ifdef HAVE_GETOPT_LONG
optlist[i].optlong ? ", " : "",
optlist[i].optlong ? optlist[i].optlong : "",
#else
"", "",
#endif
param ? " " : "", param ? param : "");
printf(" %-*s ", col1max - 2, optbuf);
if (NULL == description) {
printf("\n");
continue;
}
start = description;
while (strlen(start) > tw - col1max) {
end = start + tw - col1max;
while ((end > start) && (end[0] != ' '))
end--;
if (end == start) {
end = start + tw - col1max;
} else {
end++;
}
printf("%.*s\n%*s ", (int) (end - start), start,
col1max, "");
if (end == start)
end++;
start = end;
}
printf("%s\n", start);
}
{ "", NULL, NULL, NULL, { 0, 0, 0, 0} },
{ "-P", "--pidfile", N_("FILE"),
N_("save process ID in FILE"),
{ 0, 0, 0, 0} },
{ "", NULL, NULL, NULL, { 0, 0, 0, 0} },
{ "-d", "--watchfd", N_("PID[:FD]"),
N_("watch file FD opened by process PID"),
{ 0, 0, 0, 0} },
{ "", NULL, NULL, NULL, { 0, 0, 0, 0} },
{ "-h", "--help", NULL,
N_("show this help and exit"),
{ 0, 0, 0, 0} },
{ "-V", "--version", NULL,
N_("show version information and exit"),
{ 0, 0, 0, 0} },
#ifdef ENABLE_DEBUGGING
printf("\n");
printf("%s",
_
("Debugging is enabled; export the DEBUG environment variable to define the\noutput filename.\n"));
{ "-!", "--debug", N_("FILE"),
N_("write debug logs to FILE"),
{ 0, 0, 0, 0} },
#endif
{ NULL, NULL, NULL, NULL, { 0, 0, 0, 0} }
};
unsigned int option_index;
size_t widest_option_width = 0;
size_t description_left_margin = 0;
size_t min_description_width = 50;
size_t right_margin = 77;
const char *program_description;
const char *bug_report_note;
unsigned int terminal_width = 0, terminal_height = 0;
pv_screensize(&terminal_width, &terminal_height);
if (terminal_width > 5) {
right_margin = (size_t) (terminal_width - 3);
}
/*@-formatconst@ */
/*
* splint note: unavoidable use of %s in translated string. Should
* be hard to exploit - the message catalogue would have to be
* replaced or forced to load from another location.
*/
printf(_("Usage: %s [OPTION] [FILE]..."), PROGRAM_NAME);
/*@+formatconst@ */
printf("\n");
printf(_("Please report any bugs to %s."), BUG_REPORTS_TO);
/*@-mustfreefresh@ */
/*
* splint note: the gettext calls made by _() cause memory leak
* warnings, but in this case it's unavoidable, and mitigated by the
* fact we only translate each string once.
*/
program_description = _("Concatenate FILE(s), or standard input, to standard output, with monitoring.");
if (NULL != program_description) {
display_word_wrap(program_description, right_margin, 0);
printf("\n");
}
printf("\n");
/*
* Translate the help text, and calculate the displayed width of
* each part of each option definition. The total display width of
* the short option, long option, and option argument together form
* the "option" width - we look for the widest one to calculate the
* left margin for all of the descriptions to start at.
*/
for (option_index = 0; NULL != option_definitions[option_index].opt_short; option_index++) {
struct option_definition_s *definition;
size_t option_width;
definition = &(option_definitions[option_index]);
option_width = 0;
definition->width.opt_short = display_width(definition->opt_short);
definition->width.opt_long = 0;
definition->width.opt_argument = 0;
definition->width.opt_description = 0;
if (NULL != definition->opt_long) {
definition->width.opt_long = display_width(definition->opt_long);
}
if (NULL != definition->opt_argument) {
/*@observer@ */ const char *translated;
translated = _(definition->opt_argument);
if (NULL != translated) {
definition->opt_argument = translated;
}
definition->width.opt_argument = display_width(definition->opt_argument);
}
if (NULL != definition->opt_description) {
/*@observer@ */ const char *translated;
translated = _(definition->opt_description);
if (NULL != translated) {
definition->opt_description = translated;
}
definition->width.opt_description = display_width(definition->opt_description);
}
/*
* The option_width is padded with a left margin of 2
* spaces, a ", " between the short and long options, a
* space between the long option and the argument, and two
* spaces after the argument:
*
* " <short>, <long> <arg> <description>"
*
* If we don't have getopt_long() then ", <long>" is omitted.
*/
option_width += 2 + definition->width.opt_short; /* " short" */
#ifdef HAVE_GETOPT_LONG
option_width += 2 + definition->width.opt_long; /* ", <long>" */
#endif
option_width += 1 + definition->width.opt_argument; /* " ARG" */
option_width += 2; /* final 2 spaces */
if (option_width > widest_option_width) {
widest_option_width = option_width;
}
}
/*
* Set the left margin for the option descriptions, based on the
* widest option width, or (right margin - min_description_width),
* whichever is less, so that there is always room for
* "min_description_width" characters of description.
*/
description_left_margin = right_margin - min_description_width;
if (widest_option_width < description_left_margin) {
description_left_margin = widest_option_width;
}
debug("%s: description_left_margin=%d, widest_option_width=%d, right_margin=%d", "help display",
(int) description_left_margin, (int) widest_option_width, (int) right_margin);
/*
* Display each of the option definitions, word wrapping the
* descriptions.
*/
for (option_index = 0; NULL != option_definitions[option_index].opt_short; option_index++) {
struct option_definition_s *definition;
size_t option_width;
definition = &(option_definitions[option_index]);
option_width = 0;
if (definition->width.opt_short > 0 && NULL != definition->opt_short) {
printf(" %s", definition->opt_short);
option_width += 2 + definition->width.opt_short;
}
#ifdef HAVE_GETOPT_LONG
if (definition->width.opt_long > 0 && NULL != definition->opt_long) {
printf(", %s", definition->opt_long);
option_width += 2 + definition->width.opt_long;
}
#endif
if (definition->width.opt_argument > 0 && NULL != definition->opt_argument) {
printf(" %s", definition->opt_argument);
option_width += 1 + definition->width.opt_argument;
}
/* Just start a new line if there's no description. */
if ((0 == definition->width.opt_description) || (NULL == definition->opt_description)) {
printf("\n");
continue;
}
/*
* If the option is too wide, start a new line for the
* description. In both cases, pad with spaces up to the
* description left margin.
*/
if (option_width > description_left_margin) {
printf("\n%*s", (int) description_left_margin, "");
} else if (option_width < description_left_margin) {
printf("%*s", (int) (description_left_margin - option_width), "");
}
/* Output the description, word wrapped. */
display_word_wrap(definition->opt_description, right_margin - description_left_margin,
description_left_margin);
printf("\n");
}
printf("\n");
bug_report_note = _("Please report any bugs to %s.");
if (NULL != bug_report_note) {
/*@-formatconst@ */
/*
* splint note: see earlier "formatconst" note.
* flawfinder: same reason.
*/
printf(bug_report_note, BUG_REPORTS_TO); /* flawfinder: ignore */
/*@+formatconst@ */
}
printf("\n");
}
+76 -39
View File
@@ -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"
@@ -35,12 +37,13 @@ int main(int argc, char **argv)
struct termios t, t_save;
opts_t opts;
pvstate_t state;
bool t_saved, t_needs_reset;
int retcode = 0;
#ifdef ENABLE_NLS
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
(void) setlocale(LC_ALL, "");
(void) bindtextdomain(PACKAGE, LOCALEDIR);
(void) textdomain(PACKAGE);
#endif
opts = opts_parse(argc, argv);
@@ -69,8 +72,7 @@ int main(int argc, char **argv)
*/
state = pv_state_alloc(opts->program_name);
if (NULL == state) {
fprintf(stderr, "%s: %s: %s\n", opts->program_name,
_("state allocation failed"), strerror(errno));
fprintf(stderr, "%s: %s: %s\n", opts->program_name, _("state allocation failed"), strerror(errno));
opts_free(opts);
debug("%s: %d", "exiting with status", 64);
return 64;
@@ -83,14 +85,15 @@ int main(int argc, char **argv)
FILE *pidfptr;
pidfptr = fopen(opts->pidfile, "w");
if (NULL == pidfptr) {
fprintf(stderr, "%s: %s: %s\n", opts->program_name,
opts->pidfile, strerror(errno));
fprintf(stderr, "%s: %s: %s\n", opts->program_name, opts->pidfile, strerror(errno));
pv_state_free(state);
opts_free(opts);
return 1;
}
fprintf(pidfptr, "%d\n", getpid());
fclose(pidfptr);
if (0 != fclose(pidfptr)) {
fprintf(stderr, "%s: %s: %s\n", opts->program_name, opts->pidfile, strerror(errno));
}
}
/*
@@ -104,25 +107,23 @@ int main(int argc, char **argv)
/*
* Put our list of files into the PV internal state.
*/
pv_state_inputfiles(state, opts->argc,
(const char **) (opts->argv));
pv_state_inputfiles(state, opts->argc, (const char **) (opts->argv));
if (0 == opts->watch_pid) {
/*
* If no size was given, and we're not in line mode, try to
* calculate the total size.
*/
if ((0 == opts->size) && (0 == opts->linemode)) {
if ((0 == opts->size) && (false == opts->linemode)) {
opts->size = pv_calc_total_size(state);
debug("%s: %llu", "no size given - calculated",
opts->size);
debug("%s: %llu", "no size given - calculated", opts->size);
}
/*
* If the size is unknown, we cannot have an ETA.
*/
if (opts->size < 1) {
opts->eta = 0;
opts->eta = false;
debug("%s", "size unknown - ETA disabled");
}
}
@@ -132,9 +133,9 @@ int main(int argc, char **argv)
* outputting numerically, we will have nothing to display at all.
*/
if ((0 == isatty(STDERR_FILENO))
&& (0 == opts->force)
&& (0 == opts->numeric)) {
opts->no_op = 1;
&& (false == opts->force)
&& (false == opts->numeric)) {
opts->no_op = true;
debug("%s", "nothing to display - setting no_op");
}
@@ -148,13 +149,11 @@ int main(int argc, char **argv)
pv_screensize(&width, &height);
if (0 == opts->width) {
opts->width = width;
debug("%s: %u", "auto-detected terminal width",
width);
debug("%s: %u", "auto-detected terminal width", width);
}
if (0 == opts->height) {
opts->height = height;
debug("%s: %u", "auto-detected terminal height",
height);
debug("%s: %u", "auto-detected terminal height", height);
}
}
@@ -191,9 +190,12 @@ int main(int argc, char **argv)
pv_state_wait_set(state, opts->wait);
pv_state_delay_start_set(state, opts->delay_start);
pv_state_linemode_set(state, opts->linemode);
pv_state_bits_set(state, opts->bits);
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);
@@ -202,11 +204,11 @@ int main(int argc, char **argv)
pv_state_format_string_set(state, opts->format);
pv_state_watch_pid_set(state, opts->watch_pid);
pv_state_watch_fd_set(state, opts->watch_fd);
pv_state_average_rate_window_set(state, opts->average_rate_window);
pv_state_set_format(state, opts->progress, opts->timer, opts->eta,
opts->fineta, opts->rate, opts->average_rate,
opts->bytes, opts->bufpercent,
opts->lastwritten, opts->name);
opts->bytes, opts->bufpercent, opts->lastwritten, opts->name);
#ifdef MAKE_STDOUT_NONBLOCKING
/*
@@ -215,10 +217,16 @@ int main(int argc, char **argv)
* Note that this can cause problems with (broken) applications
* such as dd.
*/
fcntl(STDOUT_FILENO, F_SETFL,
O_NONBLOCK | fcntl(STDOUT_FILENO, F_GETFL));
fcntl(STDOUT_FILENO, F_SETFL, O_NONBLOCK | fcntl(STDOUT_FILENO, F_GETFL));
#endif /* MAKE_STDOUT_NONBLOCKING */
/*
* Keep track of whether we've saved the terminal attributes and
* whether we need to reset them at the end.
*/
t_saved = false;
t_needs_reset = false;
/*
* Set terminal option TOSTOP so we get signal SIGTTOU if we try to
* write to the terminal while backgrounded.
@@ -226,25 +234,49 @@ int main(int argc, char **argv)
* Also, save the current terminal attributes for later restoration.
*/
memset(&t, 0, sizeof(t));
tcgetattr(STDERR_FILENO, &t);
if (0 != isatty(STDERR_FILENO)) {
if (0 == tcgetattr(STDERR_FILENO, &t)) {
debug("%s", "saved terminal attributes");
t_saved = true;
} else {
fprintf(stderr, "%s: %s: %s\n", opts->program_name,
_("failed to read terminal attributes"), strerror(errno));
}
}
t_save = t;
t.c_lflag |= TOSTOP;
tcsetattr(STDERR_FILENO, TCSANOW, &t);
if (t_saved && pv_in_foreground()) {
t.c_lflag |= TOSTOP;
(void) tcsetattr(STDERR_FILENO, TCSANOW, &t);
t_needs_reset = true;
debug("%s", "set terminal TOSTOP attribute");
}
if (0 != opts->watch_pid) {
if (0 <= opts->watch_fd) {
pv_sig_init(state);
retcode = pv_watchfd_loop(state);
tcsetattr(STDERR_FILENO, TCSANOW, &t_save);
if (opts->pidfile != NULL)
remove(opts->pidfile);
if (t_needs_reset && pv_in_foreground()) {
(void) tcsetattr(STDERR_FILENO, TCSANOW, &t_save);
}
if (opts->pidfile != NULL) {
if (0 != remove(opts->pidfile)) {
fprintf(stderr, "%s: %s: %s\n",
opts->program_name, opts->pidfile, strerror(errno));
}
}
pv_sig_fini(state);
} else {
pv_sig_init(state);
retcode = pv_watchpid_loop(state);
tcsetattr(STDERR_FILENO, TCSANOW, &t_save);
if (opts->pidfile != NULL)
remove(opts->pidfile);
if (t_needs_reset && pv_in_foreground()) {
(void) tcsetattr(STDERR_FILENO, TCSANOW, &t_save);
}
if (opts->pidfile != NULL) {
if (0 != remove(opts->pidfile)) {
fprintf(stderr, "%s: %s: %s\n",
opts->program_name, opts->pidfile, strerror(errno));
}
}
pv_sig_fini(state);
}
} else {
@@ -252,9 +284,14 @@ int main(int argc, char **argv)
pv_remote_init();
retcode = pv_main_loop(state);
pv_remote_fini();
tcsetattr(STDERR_FILENO, TCSANOW, &t_save);
if (opts->pidfile != NULL)
remove(opts->pidfile);
if (t_needs_reset && pv_in_foreground()) {
(void) tcsetattr(STDERR_FILENO, TCSANOW, &t_save);
}
if (opts->pidfile != NULL) {
if (0 != remove(opts->pidfile)) {
fprintf(stderr, "%s: %s: %s\n", opts->program_name, opts->pidfile, strerror(errno));
}
}
pv_sig_fini(state);
}
+176 -153
View File
@@ -1,18 +1,22 @@
/*
* 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"
#include "pv-internal.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <sys/stat.h>
#include <unistd.h>
@@ -27,7 +31,7 @@ void opts_free(opts_t opts)
{
if (!opts)
return;
if (opts->argv)
if (NULL != opts->argv)
free(opts->argv);
free(opts);
}
@@ -47,45 +51,55 @@ opts_t opts_parse(int argc, char **argv)
{
#ifdef HAVE_GETOPT_LONG
struct option long_options[] = {
{"help", 0, 0, 'h'},
{"version", 0, 0, 'V'},
{"progress", 0, 0, 'p'},
{"timer", 0, 0, 't'},
{"eta", 0, 0, 'e'},
{"fineta", 0, 0, 'I'},
{"rate", 0, 0, 'r'},
{"average-rate", 0, 0, 'a'},
{"bytes", 0, 0, 'b'},
{"buffer-percent", 0, 0, 'T'},
{"last-written", 1, 0, 'A'},
{"force", 0, 0, 'f'},
{"numeric", 0, 0, 'n'},
{"quiet", 0, 0, 'q'},
{"cursor", 0, 0, 'c'},
{"wait", 0, 0, 'W'},
{"delay-start", 1, 0, 'D'},
{"size", 1, 0, 's'},
{"line-mode", 0, 0, 'l'},
{"null", 0, 0, '0'},
{"interval", 1, 0, 'i'},
{"width", 1, 0, 'w'},
{"height", 1, 0, 'H'},
{"name", 1, 0, 'N'},
{"format", 1, 0, 'F'},
{"rate-limit", 1, 0, 'L'},
{"buffer-size", 1, 0, 'B'},
{"no-splice", 0, 0, 'C'},
{"skip-errors", 0, 0, 'E'},
{"stop-at-size", 0, 0, 'S'},
{"remote", 1, 0, 'R'},
{"pidfile", 1, 0, 'P'},
{"watchfd", 1, 0, 'd'},
{0, 0, 0, 0}
{ "help", 0, NULL, (int) 'h' },
{ "version", 0, NULL, (int) 'V' },
{ "progress", 0, NULL, (int) 'p' },
{ "timer", 0, NULL, (int) 't' },
{ "eta", 0, NULL, (int) 'e' },
{ "fineta", 0, NULL, (int) 'I' },
{ "rate", 0, NULL, (int) 'r' },
{ "average-rate", 0, NULL, (int) 'a' },
{ "bytes", 0, NULL, (int) 'b' },
{ "bits", 0, NULL, (int) '8' },
{ "buffer-percent", 0, NULL, (int) 'T' },
{ "last-written", 1, NULL, (int) 'A' },
{ "force", 0, NULL, (int) 'f' },
{ "numeric", 0, NULL, (int) 'n' },
{ "quiet", 0, NULL, (int) 'q' },
{ "cursor", 0, NULL, (int) 'c' },
{ "wait", 0, NULL, (int) 'W' },
{ "delay-start", 1, NULL, (int) 'D' },
{ "size", 1, NULL, (int) 's' },
{ "line-mode", 0, NULL, (int) 'l' },
{ "null", 0, NULL, (int) '0' },
{ "interval", 1, NULL, (int) 'i' },
{ "width", 1, NULL, (int) 'w' },
{ "height", 1, NULL, (int) 'H' },
{ "name", 1, NULL, (int) 'N' },
{ "format", 1, NULL, (int) 'F' },
{ "rate-limit", 1, NULL, (int) 'L' },
{ "buffer-size", 1, NULL, (int) 'B' },
{ "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' },
{ "average-rate-window", 1, NULL, (int) 'm' },
#ifdef ENABLE_DEBUGGING
{ "debug", 1, NULL, (int) '!' },
#endif /* ENABLE_DEBUGGING */
{ NULL, 0, NULL, 0 }
};
int option_index = 0;
#endif /* HAVE_GETOPT_LONG */
char *short_options = "hVpteIrab8TA:fnqcWD:s:l0i:w:H:N:F:L:B:CESYKR:P:d:m:"
#ifdef ENABLE_DEBUGGING
"!:"
#endif
char *short_options =
"hVpteIrabTA:fnqcWD:s:l0i:w:H:N:F:L:B:CESR:P:d:";
;
int c, numopts;
unsigned int check_pid;
int check_fd;
@@ -94,28 +108,22 @@ opts_t opts_parse(int argc, char **argv)
opts = calloc(1, sizeof(*opts));
if (!opts) {
fprintf(stderr,
_("%s: option structure allocation failed (%s)"),
argv[0], strerror(errno));
fprintf(stderr, "\n");
return 0;
fprintf(stderr, "%s: %s: %s\n", argv[0], _("option structure allocation failed"), strerror(errno));
return NULL;
}
opts->program_name = argv[0];
ptr = strrchr(opts->program_name, '/');
if (NULL != ptr)
opts->program_name = &(ptr[1]);
opts->program_name = 1 + ptr;
opts->argc = 0;
opts->argv = calloc(argc + 1, sizeof(char *));
if (!opts->argv) {
fprintf(stderr,
_
("%s: option structure argv allocation failed (%s)"),
opts->program_name, strerror(errno));
fprintf(stderr, "\n");
opts->argv = calloc((size_t) (argc + 1), sizeof(char *));
if (NULL == opts->argv) {
fprintf(stderr, "%s: %s: %s\n", opts->program_name,
_("option structure argv allocation failed"), strerror(errno));
opts_free(opts);
return 0;
return NULL;
}
numopts = 0;
@@ -124,12 +132,11 @@ opts_t opts_parse(int argc, char **argv)
opts->delay_start = 0;
opts->watch_pid = 0;
opts->watch_fd = -1;
opts->average_rate_window = 30;
do {
#ifdef HAVE_GETOPT_LONG
c = getopt_long(argc, argv,
short_options, long_options,
&option_index);
c = getopt_long(argc, argv, short_options, long_options, &option_index);
#else
c = getopt(argc, argv, short_options);
#endif
@@ -141,48 +148,43 @@ opts_t opts_parse(int argc, char **argv)
*/
switch (c) {
case 's':
/* "-s @" is valid, so allow it. */
if ('@' == *optarg)
break;
/* falls through */
case 'A':
case 'w':
case 'H':
case 'L':
case 'B':
case 'R':
if (pv_getnum_check(optarg, PV_NUMTYPE_INTEGER) !=
0) {
fprintf(stderr, "%s: -%c: %s\n",
opts->program_name, c,
_("integer argument expected"));
case 'm':
if (pv_getnum_check(optarg, PV_NUMTYPE_INTEGER) != 0) {
fprintf(stderr, "%s: -%c: %s\n", opts->program_name, c, _("integer argument expected"));
opts_free(opts);
return 0;
return NULL;
}
break;
case 'i':
case 'D':
if (pv_getnum_check(optarg, PV_NUMTYPE_DOUBLE) !=
0) {
fprintf(stderr, "%s: -%c: %s\n",
opts->program_name, c,
_("numeric argument expected"));
if (pv_getnum_check(optarg, PV_NUMTYPE_DOUBLE) != 0) {
fprintf(stderr, "%s: -%c: %s\n", opts->program_name, c, _("numeric argument expected"));
opts_free(opts);
return 0;
return NULL;
}
break;
case 'd':
if (sscanf(optarg, "%u:%d", &check_pid, &check_fd)
< 1) {
fprintf(stderr, "%s: -%c: %s\n",
opts->program_name, c,
_
("process ID or pid:fd pair expected"));
opts->program_name, c, _("process ID or pid:fd pair expected"));
opts_free(opts);
return 0;
return NULL;
}
if (check_pid < 1) {
fprintf(stderr, "%s: -%c: %s\n",
opts->program_name, c,
_("invalid process ID"));
fprintf(stderr, "%s: -%c: %s\n", opts->program_name, c, _("invalid process ID"));
opts_free(opts);
return 0;
return NULL;
}
break;
default:
@@ -195,109 +197,141 @@ opts_t opts_parse(int argc, char **argv)
switch (c) {
case 'h':
display_help();
opts->do_nothing = 1;
return opts;
break;
opts->do_nothing = true;
return opts; /* early return */
case 'V':
display_version();
opts->do_nothing = 1;
return opts;
break;
opts->do_nothing = true;
return opts; /* early return */
case 'p':
opts->progress = 1;
opts->progress = true;
numopts++;
break;
case 't':
opts->timer = 1;
opts->timer = true;
numopts++;
break;
case 'I':
opts->fineta = 1;
opts->fineta = true;
numopts++;
break;
case 'e':
opts->eta = 1;
opts->eta = true;
numopts++;
break;
case 'r':
opts->rate = 1;
opts->rate = true;
numopts++;
break;
case 'a':
opts->average_rate = 1;
opts->average_rate = true;
numopts++;
break;
case 'b':
opts->bytes = 1;
opts->bytes = true;
numopts++;
break;
case '8':
opts->bytes = true;
opts->bits = true;
numopts++;
break;
case 'T':
opts->bufpercent = 1;
opts->bufpercent = true;
numopts++;
opts->no_splice = true;
break;
case 'A':
opts->lastwritten = pv_getnum_i(optarg);
opts->lastwritten = pv_getnum_ui(optarg);
numopts++;
opts->no_splice = true;
break;
case 'f':
opts->force = 1;
opts->force = true;
break;
case 'n':
opts->numeric = 1;
opts->numeric = true;
numopts++;
break;
case 'q':
opts->no_op = 1;
opts->no_op = true;
numopts++;
break;
case 'c':
opts->cursor = 1;
opts->cursor = true;
break;
case 'W':
opts->wait = 1;
opts->wait = true;
break;
case 'D':
opts->delay_start = pv_getnum_d(optarg);
break;
case 's':
opts->size = pv_getnum_ll(optarg);
/* Permit "@<filename>" as well as just a number. */
if ('@' == *optarg) {
const char *size_file = 1 + optarg;
struct stat sb;
int rc;
rc = 0;
memset(&sb, 0, sizeof(sb));
rc = stat(size_file, &sb);
if (0 == rc) {
opts->size = sb.st_size;
} else {
fprintf(stderr, "%s: %s %s: %s\n",
opts->program_name,
_("failed to stat file"), size_file, strerror(errno));
opts_free(opts);
return NULL;
}
} else {
opts->size = pv_getnum_ull(optarg);
}
break;
case 'l':
opts->linemode = 1;
opts->linemode = true;
break;
case '0':
opts->null = 1;
opts->linemode = 1;
opts->null = true;
opts->linemode = true;
break;
case 'i':
opts->interval = pv_getnum_d(optarg);
break;
case 'w':
opts->width = pv_getnum_i(optarg);
opts->width = pv_getnum_ui(optarg);
break;
case 'H':
opts->height = pv_getnum_i(optarg);
opts->height = pv_getnum_ui(optarg);
break;
case 'N':
opts->name = optarg;
break;
case 'L':
opts->rate_limit = pv_getnum_ll(optarg);
opts->rate_limit = pv_getnum_ull(optarg);
break;
case 'B':
opts->buffer_size = pv_getnum_ll(optarg);
opts->buffer_size = pv_getnum_ull(optarg);
opts->no_splice = true;
break;
case 'C':
opts->no_splice = 1;
opts->no_splice = true;
break;
case 'E':
opts->skip_errors++;
break;
case 'S':
opts->stop_at_size = 1;
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_i(optarg);
opts->remote = pv_getnum_ui(optarg);
break;
case 'P':
opts->pidfile = optarg;
@@ -308,23 +342,26 @@ opts_t opts_parse(int argc, char **argv)
case 'd':
opts->watch_pid = 0;
opts->watch_fd = -1;
sscanf(optarg, "%u:%d", &(opts->watch_pid),
&(opts->watch_fd));
/* No syntax check here, already done earlier */
(void) sscanf(optarg, "%u:%d", &(opts->watch_pid), &(opts->watch_fd));
break;
case 'm':
opts->average_rate_window = pv_getnum_ui(optarg);
break;
#ifdef ENABLE_DEBUGGING
case '!':
debugging_output_destination(optarg);
break;
#endif /* ENABLE_DEBUGGING */
default:
#ifdef HAVE_GETOPT_LONG
fprintf(stderr,
_("Try `%s --help' for more information."),
opts->program_name);
fprintf(stderr, _("Try `%s --help' for more information."), opts->program_name);
#else
fprintf(stderr,
_("Try `%s -h' for more information."),
opts->program_name);
fprintf(stderr, _("Try `%s -h' for more information."), opts->program_name);
#endif
fprintf(stderr, "\n");
opts_free(opts);
return 0;
break;
return NULL; /* early return */
}
} while (c != -1);
@@ -333,65 +370,51 @@ opts_t opts_parse(int argc, char **argv)
if (opts->linemode || opts->null || opts->stop_at_size
|| (opts->skip_errors > 0) || (opts->buffer_size > 0)
|| (opts->rate_limit > 0)) {
fprintf(stderr,
_
("%s: cannot use line mode or transfer modifier options when watching file descriptors"),
opts->program_name);
fprintf(stderr, "\n");
fprintf(stderr, "%s: %s\n", opts->program_name,
_("cannot use line mode or transfer modifier options when watching file descriptors"));
opts_free(opts);
return 0;
return NULL;
}
if (opts->cursor) {
fprintf(stderr,
_
("%s: cannot use cursor positioning when watching file descriptors"),
opts->program_name);
fprintf(stderr, "\n");
fprintf(stderr, "%s: %s\n", opts->program_name,
_("cannot use cursor positioning when watching file descriptors"));
opts_free(opts);
return 0;
return NULL;
}
if (0 != opts->remote) {
fprintf(stderr,
_
("%s: cannot use remote control when watching file descriptors"),
opts->program_name);
fprintf(stderr, "\n");
fprintf(stderr, "%s: %s\n", opts->program_name,
_("cannot use remote control when watching file descriptors"));
opts_free(opts);
return 0;
return NULL;
}
if (optind < argc) {
fprintf(stderr,
_
("%s: cannot transfer files when watching file descriptors"),
opts->program_name);
fprintf(stderr, "\n");
fprintf(stderr, "%s: %s\n", opts->program_name,
_("cannot transfer files when watching file descriptors"));
opts_free(opts);
return 0;
return NULL;
}
#ifndef __APPLE__
if (0 != access("/proc/self/fdinfo", X_OK)) {
fprintf(stderr,
_
("%s: -d: not available on systems without /proc/self/fdinfo"),
opts->program_name);
fprintf(stderr, "\n");
fprintf(stderr, "%s: -d: %s\n", opts->program_name,
_("not available on systems without /proc/self/fdinfo"));
opts_free(opts);
return 0;
return NULL;
}
#endif
}
/*
* Default options: -pterb
*/
if (0 == numopts) {
opts->progress = 1;
opts->timer = 1;
opts->eta = 1;
opts->rate = 1;
opts->bytes = 1;
opts->progress = true;
opts->timer = true;
opts->eta = true;
opts->rate = true;
opts->bytes = true;
}
/*
+40 -46
View File
@@ -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"
@@ -25,14 +27,14 @@
#ifdef HAVE_IPC
struct remote_msg {
long mtype;
unsigned char progress; /* progress bar flag */
unsigned char timer; /* timer flag */
unsigned char eta; /* ETA flag */
unsigned char fineta; /* absolute ETA flag */
unsigned char rate; /* rate counter flag */
unsigned char average_rate; /* average rate counter flag */
unsigned char bytes; /* bytes transferred flag */
unsigned char bufpercent; /* transfer buffer percentage flag */
bool progress; /* progress bar flag */
bool timer; /* timer flag */
bool eta; /* ETA flag */
bool fineta; /* absolute ETA flag */
bool rate; /* rate counter flag */
bool average_rate; /* average rate counter flag */
bool bytes; /* bytes transferred flag */
bool bufpercent; /* transfer buffer percentage flag */
unsigned int lastwritten; /* last-written bytes count */
unsigned long long rate_limit; /* rate limit, in bytes per second */
unsigned long long buffer_size; /* buffer size, in bytes (0=default) */
@@ -59,14 +61,12 @@ static int remote__msgid = -1;
*/
static key_t remote__genkey(void)
{
int uid;
uid_t uid;
key_t key;
uid = geteuid();
if (uid < 0)
uid = 0;
key = ftok("/tmp", 'P') | uid;
key = ftok("/tmp", (int) 'P') | uid;
return key;
}
@@ -79,7 +79,7 @@ static key_t remote__genkey(void)
static int remote__msgget(void)
{
/* Catch SIGSYS in case msgget() raises it, so we get ENOSYS */
signal(SIGSYS, SIG_IGN);
(void) signal(SIGSYS, SIG_IGN);
return msgget(remote__genkey(), IPC_CREAT | 0600);
}
@@ -97,29 +97,28 @@ int pv_remote_set(opts_t opts)
struct msqid_ds qbuf;
long timeout;
int msgid;
long initial_qnum;
unsigned long initial_qnum;
/*
* Check that the remote process exists.
*/
if (kill(opts->remote, 0) != 0) {
fprintf(stderr, "%s: %d: %s\n", opts->program_name,
opts->remote, strerror(errno));
if (kill((pid_t) (opts->remote), 0) != 0) {
fprintf(stderr, "%s: %u: %s\n", opts->program_name, opts->remote, strerror(errno));
return 1;
}
/*
* Make sure parameters are within sensible bounds.
*/
if (opts->width < 0)
if (opts->width < 1)
opts->width = 80;
if (opts->height < 0)
if (opts->height < 1)
opts->height = 25;
if (opts->width > 999999)
opts->width = 999999;
if (opts->height > 999999)
opts->height = 999999;
if ((opts->interval != 0) && (opts->interval < 0.1))
if ((opts->interval > 0) && (opts->interval < 0.1))
opts->interval = 0.1;
if (opts->interval > 600)
opts->interval = 600;
@@ -128,7 +127,7 @@ int pv_remote_set(opts_t opts)
* Copy parameters into message buffer.
*/
memset(&msgbuf, 0, sizeof(msgbuf));
msgbuf.mtype = opts->remote;
msgbuf.mtype = (long) (opts->remote);
msgbuf.progress = opts->progress;
msgbuf.timer = opts->timer;
msgbuf.eta = opts->eta;
@@ -148,28 +147,25 @@ int pv_remote_set(opts_t opts)
strncpy(msgbuf.name, opts->name, sizeof(msgbuf.name) - 1);
}
if (opts->format != NULL) {
strncpy(msgbuf.format, opts->format,
sizeof(msgbuf.format) - 1);
strncpy(msgbuf.format, opts->format, sizeof(msgbuf.format) - 1);
}
msgid = remote__msgget();
if (msgid < 0) {
fprintf(stderr, "%s: %s\n", opts->program_name,
strerror(errno));
fprintf(stderr, "%s: %s\n", opts->program_name, strerror(errno));
return 1;
}
memset(&qbuf, 0, sizeof(qbuf));
if (msgctl(msgid, IPC_STAT, &qbuf) < 0) {
fprintf(stderr, "%s: %s\n", opts->program_name,
strerror(errno));
fprintf(stderr, "%s: %s\n", opts->program_name, strerror(errno));
return 1;
}
initial_qnum = qbuf.msg_qnum;
if (msgsnd(msgid, &msgbuf, sizeof(msgbuf) - sizeof(long), 0) != 0) {
fprintf(stderr, "%s: %s\n", opts->program_name,
strerror(errno));
fprintf(stderr, "%s: %s\n", opts->program_name, strerror(errno));
return 1;
}
@@ -178,14 +174,16 @@ int pv_remote_set(opts_t opts)
while (timeout > 10000) {
struct timeval tv;
memset(&tv, 0, sizeof(tv));
tv.tv_sec = 0;
tv.tv_usec = 10000;
select(0, NULL, NULL, NULL, &tv);
(void) select(0, NULL, NULL, NULL, &tv);
timeout -= 10000;
/*
* If we can't stat the queue, it must have been deleted.
*/
memset(&qbuf, 0, sizeof(qbuf));
if (msgctl(msgid, IPC_STAT, &qbuf) < 0)
break;
@@ -201,21 +199,20 @@ int pv_remote_set(opts_t opts)
/*
* Message not received - delete it.
*/
memset(&qbuf, 0, sizeof(qbuf));
if (msgctl(msgid, IPC_STAT, &qbuf) >= 0) {
msgrcv(msgid, &msgbuf, sizeof(msgbuf) - sizeof(long),
opts->remote, IPC_NOWAIT);
(void) msgrcv(msgid, &msgbuf, sizeof(msgbuf) - sizeof(long), (long) (opts->remote), IPC_NOWAIT);
/*
* If this leaves nothing on the queue, remove the
* queue, in case we created one for no reason.
*/
if (msgctl(msgid, IPC_STAT, &qbuf) >= 0) {
if (qbuf.msg_qnum < 1)
msgctl(msgid, IPC_RMID, &qbuf);
(void) msgctl(msgid, IPC_RMID, &qbuf);
}
}
fprintf(stderr, "%s: %d: %s\n", opts->program_name, opts->remote,
_("message not received"));
fprintf(stderr, "%s: %u: %s\n", opts->program_name, opts->remote, _("message not received"));
return 1;
}
@@ -230,16 +227,14 @@ int pv_remote_set(opts_t opts)
void pv_remote_check(pvstate_t state)
{
struct remote_msg msgbuf;
int got;
ssize_t got;
if (remote__msgid < 0)
return;
memset(&msgbuf, 0, sizeof(msgbuf));
got =
msgrcv(remote__msgid, &msgbuf, sizeof(msgbuf) - sizeof(long),
getpid(), IPC_NOWAIT);
got = msgrcv(remote__msgid, &msgbuf, sizeof(msgbuf) - sizeof(long), getpid(), IPC_NOWAIT);
if (got < 0) {
/*
* If our queue had been deleted, re-create it.
@@ -260,9 +255,7 @@ void pv_remote_check(pvstate_t state)
msgbuf.eta, msgbuf.fineta, msgbuf.rate,
msgbuf.average_rate,
msgbuf.bytes, msgbuf.bufpercent,
msgbuf.lastwritten,
0 ==
msgbuf.name[0] ? NULL : strdup(msgbuf.name));
msgbuf.lastwritten, '\0' == msgbuf.name[0] ? NULL : strdup(msgbuf.name));
if (msgbuf.rate_limit > 0)
pv_state_rate_limit_set(state, msgbuf.rate_limit);
@@ -277,7 +270,7 @@ void pv_remote_check(pvstate_t state)
pv_state_width_set(state, msgbuf.width);
if (msgbuf.height > 0)
pv_state_height_set(state, msgbuf.height);
if (msgbuf.format[0] != 0)
if (msgbuf.format[0] != '\0')
pv_state_format_string_set(state, strdup(msgbuf.format));
}
@@ -298,7 +291,8 @@ void pv_remote_fini(void)
{
if (remote__msgid >= 0) {
struct msqid_ds qbuf;
msgctl(remote__msgid, IPC_RMID, &qbuf);
memset(&qbuf, 0, sizeof(qbuf));
(void) msgctl(remote__msgid, IPC_RMID, &qbuf);
}
}
+21 -20
View File
@@ -1,34 +1,35 @@
/*
* 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",
_
("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");
/*@-mustfreefresh@ */
/*
* splint note: the gettext calls made by _() cause memory leak
* warnings, but in this case it's unavoidable, and mitigated by the
* fact we only translate each string once.
*/
/* 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", _("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 */
+328 -271
View File
@@ -1,8 +1,8 @@
msgid ""
msgstr ""
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-06-30 22:21+0100\n"
"Content-Type: text/plain; charset=iso-8859-15\n"
"POT-Creation-Date: 2023-07-30 19:07+0100\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Date: 1999-06-01 15:18:29+0100\n"
"From: Andrew Wood <ivarch@ubik>\n"
"Xgettext-Options: --default-domain=pkgbuild --directory=./.pkgdir --add-"
@@ -19,434 +19,491 @@ msgstr ""
"nls/intl/textdomain.c src/nls/intl-cat/cat-compat.c src/nls/intl-gett/intl-"
"compat.c\n"
#: src/pv/watchpid.c:51 src/pv/watchpid.c:66 src/pv/watchpid.c:76
#: src/pv/watchpid.c:107 src/pv/loop.c:519 src/pv/loop.c:580 src/pv/loop.c:632
msgid "pid"
msgstr ""
#: src/pv/watchpid.c:68 src/pv/watchpid.c:78 src/pv/watchpid.c:109
msgid "fd"
msgstr ""
#: src/pv/watchpid.c:112
msgid "not a regular file or block device"
msgstr ""
#: src/pv/cursor.c:53
#, fuzzy
#: src/pv/cursor.c:85
msgid "failed to get terminal name"
msgstr "Terminal konnte nicht geöffnet werden"
msgstr "Terminalname konnte nicht gelesen werden"
#: src/pv/cursor.c:96
#, fuzzy
#: src/pv/cursor.c:117
msgid "failed to open lock file"
msgstr "Datei konnte nicht geschlossen werden"
msgstr "Sperrdatei konnte nicht geöffnet werden"
#: src/pv/cursor.c:129
#: src/pv/cursor.c:150
msgid "lock attempt failed"
msgstr ""
msgstr "Sperrversuch fehlgeschlagen"
#: src/pv/cursor.c:369
#: src/pv/cursor.c:391
msgid "failed to open terminal"
msgstr "Terminal konnte nicht geöffnet werden"
msgstr "Terminal konnte nicht geöffnet werden"
#: src/pv/file.c:118
#, fuzzy
#: src/pv/file.c:119
msgid "failed to seek to start of output"
msgstr "Dateiinformationen für Ausgabe-Datei konnten nicht gelesen werden"
msgstr "Konnte nicht versuchen, die Ausgabe zu starten"
#: src/pv/file.c:214
#: src/pv/file.c:210
msgid "failed to close file"
msgstr "Datei konnte nicht geschlossen werden"
#: src/pv/file.c:237
#: src/pv/file.c:232
msgid "failed to read file"
msgstr "Datei konnte nicht gelesen werden"
#: src/pv/file.c:247
#: src/pv/file.c:239 src/main/options.c:284
msgid "failed to stat file"
msgstr "Dateiinformationen konnten nicht gelesen werden"
#: src/pv/file.c:256
#: src/pv/file.c:246
msgid "failed to stat output file"
msgstr "Dateiinformationen für Ausgabe-Datei konnten nicht gelesen werden"
msgstr "Dateiinformationen für Ausgabe-Datei konnten nicht gelesen werden"
#: src/pv/file.c:279
#: src/pv/file.c:268
msgid "input file is output file"
msgstr "Eingabe-Datei ist Ausgabe-Datei"
#: src/pv/display.c:117
msgid "yzafpnum kMGTPEZY"
msgstr ""
#: src/pv/display.c:122
msgid "yzafpnum KMGTPEZY"
msgstr ""
#: src/pv/display.c:532 src/pv/transfer.c:679
msgid "buffer allocation failed"
msgstr "Puffer konnte nicht allokiert werden"
#: src/pv/display.c:592 src/pv/transfer.c:458
msgid "B"
msgstr "B"
#: src/pv/display.c:628 src/pv/display.c:636
msgid "/s"
msgstr ""
#: src/pv/display.c:628 src/pv/display.c:636
msgid "B/s"
msgstr ""
#: src/pv/display.c:671 src/pv/display.c:676 src/pv/display.c:738
msgid "ETA"
msgstr "ETA"
#: src/pv/transfer.c:341
#: src/pv/transfer.c:359
msgid "read failed"
msgstr "read-Aufruf fehlgeschlagen"
#: src/pv/transfer.c:359
msgid "warning: read errors detected"
msgstr ""
#: src/pv/transfer.c:374
msgid "warning: read errors detected"
msgstr "warnung: lesefehler erkannt"
#: src/pv/transfer.c:386
msgid "file is not seekable"
msgstr ""
msgstr "datei ist nicht durchsuchbar"
#: src/pv/transfer.c:437
#, fuzzy
#: src/pv/transfer.c:445
msgid "failed to seek past error"
msgstr "Dateiinformationen konnten nicht gelesen werden"
msgstr "konnte den Fehler nicht überwinden"
#: src/pv/transfer.c:456
#: src/pv/transfer.c:461
msgid "skipped past read error"
msgstr ""
msgstr "über den Lesefehler hinaus verschoben"
#: src/pv/transfer.c:631
#: src/pv/transfer.c:461 src/pv/display.c:660
msgid "B"
msgstr "B"
#: src/pv/transfer.c:617
msgid "write failed"
msgstr "write-Aufruf fehlgeschlagen"
#: src/pv/transfer.c:770
#: src/pv/transfer.c:736 src/pv/display.c:594
msgid "buffer allocation failed"
msgstr "Puffer konnte nicht allokiert werden"
#.
#. * Any other error is a problem and we must report back.
#.
#: src/pv/transfer.c:833
msgid "select call failed"
msgstr "select-Aufruf fehlgeschlagen"
#: src/pv/state.c:33
#: src/pv/watchpid.c:73 src/pv/watchpid.c:83 src/pv/watchpid.c:94
#: src/pv/watchpid.c:102 src/pv/watchpid.c:139 src/pv/watchpid.c:150
#: src/pv/watchpid.c:158 src/pv/watchpid.c:169 src/pv/watchpid.c:253
#: src/pv/watchpid.c:261 src/pv/watchpid.c:292 src/pv/watchpid.c:312
#: src/pv/loop.c:506 src/pv/loop.c:558 src/pv/loop.c:602
msgid "pid"
msgstr ""
#: src/pv/watchpid.c:83 src/pv/watchpid.c:95 src/pv/watchpid.c:104
#: src/pv/watchpid.c:150 src/pv/watchpid.c:159 src/pv/watchpid.c:171
msgid "fd"
msgstr ""
#: src/pv/watchpid.c:104 src/pv/watchpid.c:171
msgid "not a regular file or block device"
msgstr "keine normale Datei oder Blockgerät"
#: src/pv/state.c:30
msgid "history structure allocation failed"
msgstr ""
#: src/pv/state.c:59
msgid "none"
msgstr ""
#: src/main/version.c:17
#, fuzzy, c-format
msgid "%s %s - Copyright %s %s"
msgstr "%s %s - Copyright(C) %s %s"
#: src/main/version.c:20
#, c-format
msgid "Web site: %s"
msgstr "Web-Site: %s"
#: 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:159
msgid "yzafpnum kMGTPEZY"
msgstr ""
"Dieses Programm ist freie Software und wird unter den Bedingungen\n"
"der Artistic License verbreitet."
#: src/pv/display.c:164
msgid "yzafpnum KMGTPEZY"
msgstr ""
#: src/pv/display.c:656
msgid "b"
msgstr ""
#: src/pv/display.c:711 src/pv/display.c:722
msgid "b/s"
msgstr ""
#: src/pv/display.c:714 src/pv/display.c:726
msgid "/s"
msgstr ""
#: src/pv/display.c:714 src/pv/display.c:726
msgid "B/s"
msgstr ""
#: src/pv/display.c:762 src/pv/display.c:766 src/pv/display.c:825
msgid "ETA"
msgstr "ETA"
#. GNU standard license line and free software notice
#: 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."
msgstr ""
"Dieses Programm wird verbreitet unter der Annahme dass es nützlich ist,\n"
"aber OHNE JEGLICHE GARANTIE; insbesondere ohne der impliziten Garantie\n"
"einer MARKTGÄNGIGKEIT oder EIGNUNG ZU EINEM BESTIMMTEN ZWECK."
#: src/main/main.c:73
#, fuzzy
msgid "state allocation failed"
msgstr "Puffer konnte nicht allokiert werden"
#: src/main/options.c:98
#, c-format
msgid "%s: option structure allocation failed (%s)"
msgstr "%s: `option' konnte nicht allokiert werden (%s)"
#: src/main/options.c:114
#, c-format
msgid "%s: option structure argv allocation failed (%s)"
msgstr "%s: `option' (argv) konnte nicht allokiert werden (%s)"
#: src/main/options.c:154
msgid "integer argument expected"
msgid "License: Artistic v2.0 <https://opensource.org/license/artistic-2-0/>"
msgstr ""
#: src/main/options.c:165
msgid "numeric argument expected"
#: src/main/version.c:29
msgid "This is free software: you are free to change and redistribute it."
msgstr ""
#: src/main/options.c:176
msgid "process ID or pid:fd pair expected"
#: src/main/version.c:30
msgid "There is NO WARRANTY, to the extent permitted by law."
msgstr ""
#: src/main/options.c:183
msgid "invalid process ID"
#. Project web site link
#: src/main/version.c:32
msgid "Project web site"
msgstr ""
#: src/main/options.c:317
#, c-format
msgid "Try `%s --help' for more information."
msgstr "`%s --help' zeigt weitere Informationen an."
#: src/main/options.c:321
#, fuzzy, c-format
msgid "Try `%s -h' for more information."
msgstr "`%s -h' zeigt weitere Informationen an."
#: src/main/options.c:338
#, c-format
msgid ""
"%s: cannot use line mode or transfer modifier options when watching file "
"descriptors"
msgstr ""
#: src/main/options.c:348
#, c-format
msgid "%s: cannot use cursor positioning when watching file descriptors"
msgstr ""
#: src/main/options.c:358
#, c-format
msgid "%s: cannot use remote control when watching file descriptors"
msgstr ""
#: src/main/options.c:368
#, c-format
msgid "%s: cannot transfer files when watching file descriptors"
msgstr ""
#: src/main/options.c:378
#, c-format
msgid "%s: -d: not available on systems without /proc/self/fdinfo"
msgstr ""
#: src/main/remote.c:218
#: src/main/remote.c:215
msgid "message not received"
msgstr ""
msgstr "Nachricht nicht empfangen"
#: src/main/remote.c:324
#: src/main/remote.c:318
msgid "IPC not supported on this system"
msgstr ""
msgstr "IPC wird auf diesem System nicht unterstützt"
#: src/main/help.c:31
#: src/main/help.c:283
msgid "show progress bar"
msgstr "Fortschritts-Anzeige"
#: src/main/help.c:33
#: src/main/help.c:286
msgid "show elapsed time"
msgstr "zeige die verstrichene Zeit an"
#: src/main/help.c:35
#: src/main/help.c:289
msgid "show estimated time of arrival (completion)"
msgstr "zeige die erwartete Zeit bis zum Ende an"
#: src/main/help.c:38
#, fuzzy
#: src/main/help.c:292
msgid "show absolute estimated time of arrival (completion)"
msgstr "zeige die erwartete Zeit bis zum Ende an"
msgstr "zeige die absolute geschätzte Zeit bis zur Fertigstellung"
#: src/main/help.c:40
#: src/main/help.c:295
msgid "show data transfer rate counter"
msgstr "zeige die Datentransferrate an"
#: src/main/help.c:42
#: src/main/help.c:298
msgid "show data transfer average rate counter"
msgstr ""
#: src/main/help.c:44
msgid "show number of bytes transferred"
msgstr "zeige die Anzahl von Bytes, die transferiert worden sind"
#: src/main/help.c:46
msgid "show percentage of transfer buffer in use"
msgstr ""
#: src/main/help.c:47
msgid "NUM"
msgstr ""
#: src/main/help.c:48
msgid "show NUM bytes last written"
msgstr ""
#: src/main/help.c:49
msgid "FORMAT"
msgstr ""
#: src/main/help.c:50
msgid "set output format to FORMAT"
msgstr ""
#: src/main/help.c:52
msgid "output percentages, not visual information"
msgstr "Ausgabe von Prozent-Angaben statt visueller Darstellung"
#: src/main/help.c:54
msgid "do not output any transfer information at all"
msgstr "sämtliche Transferinformationen unterdrücken"
#: src/main/help.c:57
msgid "display nothing until first byte transferred"
msgstr "keine Ausgabe bevor das erste Byte übertragen wurde"
#: src/main/help.c:58 src/main/help.c:66
#: src/main/help.c:300 src/main/help.c:328 src/main/help.c:340
msgid "SEC"
msgstr ""
#: src/main/help.c:59
#, fuzzy
msgid "display nothing until SEC seconds have passed"
msgstr "keine Ausgabe bevor das erste Byte übertragen wurde"
#: src/main/help.c:301
msgid "compute average rate over past SEC seconds (default 30s)"
msgstr ""
#: src/main/help.c:60
#: src/main/help.c:304
msgid "show number of bytes transferred"
msgstr "zeige die Anzahl von Bytes, die transferiert worden sind"
#: src/main/help.c:307
msgid "show number of bits transferred"
msgstr ""
#: src/main/help.c:310
msgid "show percentage of transfer buffer in use"
msgstr "zeige, wie viel Prozent des Übertragungsbuffers in Benutzung sind"
#: src/main/help.c:312
msgid "NUM"
msgstr ""
#: src/main/help.c:313
msgid "show NUM bytes last written"
msgstr "NUM zeige die zuletzt geschriebenen NUM Bytes"
#: src/main/help.c:315
msgid "FORMAT"
msgstr ""
#: src/main/help.c:316
msgid "set output format to FORMAT"
msgstr "setze das Ausgabeformat auf FORMAT"
#: src/main/help.c:319
msgid "output percentages, not visual information"
msgstr "Ausgabe von Prozent-Angaben statt visueller Darstellung"
#: src/main/help.c:322
msgid "do not output any transfer information at all"
msgstr "sämtliche Transferinformationen unterdrücken"
#: src/main/help.c:326
msgid "display nothing until first byte transferred"
msgstr "keine Ausgabe bevor das erste Byte übertragen wurde"
#: src/main/help.c:329
msgid "display nothing until SEC seconds have passed"
msgstr "SEC nichts anzeigen, bis SEC Sekunden vergangen sind"
#: src/main/help.c:331
msgid "SIZE"
msgstr ""
#: src/main/help.c:61
#: src/main/help.c:332
msgid "set estimated data size to SIZE bytes"
msgstr "setze erwartete Daten-Länge auf SIZE Byte"
msgstr "setze erwartete Datenlänge auf SIZE Byte"
#: src/main/help.c:63
#: src/main/help.c:335
msgid "count lines instead of bytes"
msgstr ""
msgstr "zähle Zeilen anstelle von Bytes"
#: src/main/help.c:65
#: src/main/help.c:338
msgid "lines are null-terminated"
msgstr ""
msgstr "Zeilen sind nullterminiert"
#: src/main/help.c:67
#: src/main/help.c:341
msgid "update every SEC seconds"
msgstr "aktualisiere Ausgabe nach SEC Sekunden Intervall"
#: src/main/help.c:68
#: src/main/help.c:343
msgid "WIDTH"
msgstr ""
#: src/main/help.c:69
#: src/main/help.c:344
msgid "assume terminal is WIDTH characters wide"
msgstr "setze Terminal-Breite auf WIDTH Zeichen"
#: src/main/help.c:70
#: src/main/help.c:346
msgid "HEIGHT"
msgstr ""
#: src/main/help.c:71
#: src/main/help.c:347
msgid "assume terminal is HEIGHT rows high"
msgstr "setze Terminal-Breite auf WIDTH Zeichen"
msgstr "setze Terminal-Höhe auf HEIGHT Zeichen"
#: src/main/help.c:72
#: src/main/help.c:349
msgid "NAME"
msgstr ""
#: src/main/help.c:73
#: src/main/help.c:350
msgid "prefix visual information with NAME"
msgstr "setze den NAMEn für visuelle Darstellung"
msgstr "setze den NAMEn für visuelle Darstellung"
#: src/main/help.c:75
#: src/main/help.c:353
msgid "output even if standard error is not a terminal"
msgstr ""
"Ausgabe auch dann erzwingen, wenn der Fehlerausgabe-Kanal kein Terminal ist"
#: src/main/help.c:77
#: src/main/help.c:356
msgid "use cursor positioning escape sequences"
msgstr "benutze Escape-Sequenzen zur Cursor-Positionierung"
#: src/main/help.c:79
#: src/main/help.c:359
msgid "RATE"
msgstr ""
#: src/main/help.c:80
#: src/main/help.c:360
msgid "limit transfer to RATE bytes per second"
msgstr "beschränke die Transferrate auf RATE Byte pro Sekunde"
msgstr "beschränke die Transferrate auf RATE Byte pro Sekunde"
#: src/main/help.c:81
#: src/main/help.c:362
msgid "BYTES"
msgstr ""
#: src/main/help.c:82
#: src/main/help.c:363
msgid "use a buffer size of BYTES"
msgstr ""
msgstr "BYTES benutze einen Puffer in der Größe von BYTES"
#: src/main/help.c:84
#: src/main/help.c:366
msgid "never use splice(), always use read/write"
msgstr ""
msgstr "anstelle von splice() immer read/write benutzen"
#: src/main/help.c:86
#: src/main/help.c:369
msgid "skip read errors in input"
msgstr "Lesefehler in der Eingabe nicht beachten"
#: src/main/help.c:372
msgid "stop after --size bytes have been transferred"
msgstr "anhalten, nachdem --size Bytes übertragen wurden"
#: src/main/help.c:375
msgid "flush cache to disk after every write"
msgstr ""
#: src/main/help.c:88
#, fuzzy
msgid "stop after --size bytes have been transferred"
msgstr "zeige die Anzahl von Bytes, die transferiert worden sind"
#: src/main/help.c:378
msgid "use direct I/O to bypass cache"
msgstr ""
#: src/main/help.c:90
#: src/main/help.c:381
msgid "PID"
msgstr ""
#: src/main/help.c:91
#: src/main/help.c:382
msgid "update settings of process PID"
msgstr ""
msgstr "Einstellungen der Prozess-PID updaten"
#: src/main/help.c:94
#: src/main/help.c:386 src/main/help.c:401
msgid "FILE"
msgstr ""
#: src/main/help.c:95
#: src/main/help.c:387
msgid "save process ID in FILE"
msgstr ""
msgstr "Prozess-ID in FILE speichern"
#: src/main/help.c:97
#: src/main/help.c:390
msgid "PID[:FD]"
msgstr ""
#: src/main/help.c:98
#: src/main/help.c:391
msgid "watch file FD opened by process PID"
msgstr ""
msgstr "die vom Prozess PID geöffnete Datei FD beobachten"
#: src/main/help.c:101
#: src/main/help.c:395
msgid "show this help and exit"
msgstr "zeige diese Hilfe und beende"
#: src/main/help.c:103
#: src/main/help.c:398
msgid "show version information and exit"
msgstr "zeige Versionsinformationen und beende"
#: src/main/help.c:109
#: src/main/help.c:402
msgid "write debug logs to FILE"
msgstr ""
#. @-formatconst@
#.
#. * splint note: unavoidable use of %s in translated string. Should
#. * be hard to exploit - the message catalogue would have to be
#. * replaced or forced to load from another location.
#.
#: src/main/help.c:427
#, c-format
msgid "Usage: %s [OPTION] [FILE]..."
msgstr "Syntax: %s [OPTION] [DATEI]..."
#: src/main/help.c:112
#. @-mustfreefresh@
#.
#. * splint note: the gettext calls made by _() cause memory leak
#. * warnings, but in this case it's unavoidable, and mitigated by the
#. * fact we only translate each string once.
#.
#: src/main/help.c:438
msgid ""
"Concatenate FILE(s), or standard input, to standard output,\n"
"with monitoring."
"Concatenate FILE(s), or standard input, to standard output, with monitoring."
msgstr ""
"Verbindet DATEI(en) oder den Standard-Eingabe-Kanal mit dem\n"
"Standard-Ausgabe-Kanal und misst den Datenstrom."
"Verbindet DATEI(en) oder den Standard-Eingabe-Kanal mit dem Standard-Ausgabe-"
"Kanal und misst den Datenstrom."
#: src/main/help.c:201
msgid ""
"Debugging is enabled; export the DEBUG environment variable to define the\n"
"output filename.\n"
msgstr ""
#: src/main/help.c:205
#: src/main/help.c:575
#, c-format
msgid "Please report any bugs to %s."
msgstr "Bitte senden Sie Fehlerberichte an %s."
#~ msgid "failed to lock terminal"
#~ msgstr "Terminal konnte nicht geöffnet werden"
#: src/main/main.c:75
msgid "state allocation failed"
msgstr "Zustandszuweisung fehlgeschlagen"
#: src/main/main.c:243
msgid "failed to read terminal attributes"
msgstr ""
#: src/main/options.c:111
msgid "option structure allocation failed"
msgstr "`option' konnte nicht allokiert werden"
#: src/main/options.c:124
msgid "option structure argv allocation failed"
msgstr "`option' (argv) konnte nicht allokiert werden"
#: src/main/options.c:163
msgid "integer argument expected"
msgstr "Ganzzahliges Argument erwartet"
#: src/main/options.c:171
msgid "numeric argument expected"
msgstr "numerisches Argument erwartet"
#: src/main/options.c:180
msgid "process ID or pid:fd pair expected"
msgstr "Prozess-ID oder PID:FD-Paar erwartet"
#: src/main/options.c:185
msgid "invalid process ID"
msgstr "ungültige Prozess-ID"
#: src/main/options.c:358
#, c-format
msgid "Try `%s --help' for more information."
msgstr "`%s --help' zeigt weitere Informationen an."
#: src/main/options.c:360
#, c-format
msgid "Try `%s -h' for more information."
msgstr "`%s -h' zeigt weitere Informationen an."
#: src/main/options.c:374
msgid ""
"cannot use line mode or transfer modifier options when watching file "
"descriptors"
msgstr ""
"Beim Anzeigen von Dateideskriptoren können keine Optionen für den "
"Zeilenmodus oder den Übertragungsmodifikator verwendet werden"
#: src/main/options.c:381
msgid "cannot use cursor positioning when watching file descriptors"
msgstr ""
"Beim Anzeigen von Dateideskriptoren können keine Zeilenmodus- oder "
"Übertragungsmodifikatoroptionen verwendet werden."
#: src/main/options.c:388
msgid "cannot use remote control when watching file descriptors"
msgstr ""
"kann keine Fernbedienung verwenden, wenn Dateideskriptoren angezeigt werden"
#: src/main/options.c:395
msgid "cannot transfer files when watching file descriptors"
msgstr ""
"Dateien können beim Betrachten von Dateideskriptoren nicht übertragen werden"
#: src/main/options.c:402
msgid "not available on systems without /proc/self/fdinfo"
msgstr "Nicht verfügbar auf Systemen ohne /proc/self/fdinfo"
#~ msgid ""
#~ "Debugging is enabled; export the DEBUG environment variable to define "
#~ "the\n"
#~ "output filename.\n"
#~ msgstr ""
#~ "Das Debuggen ist aktiviert. Exportieren Sie die Umgebungsvariable DEBUG,\n"
#~ "um den Ausgabedateinamen zu definieren.\n"
#~ msgid "%s %s - Copyright %s %s"
#~ msgstr "%s %s - Copyright(C) %s %s"
#~ msgid "Web site: %s"
#~ msgstr "Web-Site: %s"
#~ msgid ""
#~ "This program is free software, and is being distributed under the\n"
#~ "terms of the Artistic License 2.0."
#~ msgstr ""
#~ "Dieses Programm ist freie Software und wird unter den Bedingungen\n"
#~ "der Artistic License verbreitet."
#~ 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."
#~ msgstr ""
#~ "Dieses Programm wird in der Hoffnung verbreitet, dass es nützlich sein "
#~ "wird,\n"
#~ "aber OHNE JEGLICHE GARANTIE; ohne die implizite Garantie von\n"
#~ "MARKTGÄNGIGKEIT oder EIGNUNG FÜR EINEN BESTIMMTEN ZWECK."
+348 -292
View File
@@ -1,8 +1,8 @@
msgid ""
msgstr ""
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-06-30 22:21+0100\n"
"Content-Type: text/plain; charset=ISO-8859-15\n"
"POT-Creation-Date: 2023-07-30 19:07+0100\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Date: 1999-06-01 15:18:29+0100\n"
"From: Andrew Wood <ivarch@ubik>\n"
"Xgettext-Options: --default-domain=pkgbuild --directory=./.pkgdir --add-"
@@ -19,436 +19,492 @@ msgstr ""
"nls/intl/textdomain.c src/nls/intl-cat/cat-compat.c src/nls/intl-gett/intl-"
"compat.c\n"
#: src/pv/watchpid.c:51 src/pv/watchpid.c:66 src/pv/watchpid.c:76
#: src/pv/watchpid.c:107 src/pv/loop.c:519 src/pv/loop.c:580 src/pv/loop.c:632
msgid "pid"
msgstr ""
#: src/pv/watchpid.c:68 src/pv/watchpid.c:78 src/pv/watchpid.c:109
msgid "fd"
msgstr ""
#: src/pv/watchpid.c:112
msgid "not a regular file or block device"
msgstr ""
#: src/pv/cursor.c:53
#, fuzzy
#: src/pv/cursor.c:85
msgid "failed to get terminal name"
msgstr "l'ouverture du terminal a échoué"
msgstr "échec de lecture du nom du terminal"
#: src/pv/cursor.c:96
#, fuzzy
#: src/pv/cursor.c:117
msgid "failed to open lock file"
msgstr "la fermeture du fichier a échoué"
msgstr "échec de l'ouverture du fichier de verrouillage"
#: src/pv/cursor.c:129
#: src/pv/cursor.c:150
msgid "lock attempt failed"
msgstr ""
msgstr "tentative de verrouillage échoué"
#: src/pv/cursor.c:369
#: src/pv/cursor.c:391
msgid "failed to open terminal"
msgstr "l'ouverture du terminal a échoué"
msgstr "l'ouverture du terminal a échoué"
#: src/pv/file.c:118
#, fuzzy
#: src/pv/file.c:119
msgid "failed to seek to start of output"
msgstr "échec à statuer sur le fichier de sortie"
msgstr "ne peut pas passer au début de la sortie"
#: src/pv/file.c:214
#: src/pv/file.c:210
msgid "failed to close file"
msgstr "la fermeture du fichier a échoué"
msgstr "la fermeture du fichier a échoué"
#: src/pv/file.c:237
#: src/pv/file.c:232
msgid "failed to read file"
msgstr "la lecture du fichier a échoué"
msgstr "la lecture du fichier a échoué"
#: src/pv/file.c:247
#: src/pv/file.c:239 src/main/options.c:284
msgid "failed to stat file"
msgstr "échec à statuer sur le fichier"
msgstr "échec à statuer sur le fichier"
#: src/pv/file.c:256
#: src/pv/file.c:246
msgid "failed to stat output file"
msgstr "échec à statuer sur le fichier de sortie"
msgstr "échec à statuer sur le fichier de sortie"
#: src/pv/file.c:279
#: src/pv/file.c:268
msgid "input file is output file"
msgstr "fichiers d'entré et de sortie sont les mêmes"
msgstr "fichiers d'entré et de sortie sont les mêmes"
#: src/pv/display.c:117
msgid "yzafpnum kMGTPEZY"
msgstr ""
#: src/pv/transfer.c:359
msgid "read failed"
msgstr "la lecture a échoué"
#: src/pv/display.c:122
msgid "yzafpnum KMGTPEZY"
msgstr ""
#: src/pv/transfer.c:374
msgid "warning: read errors detected"
msgstr "avertissement: erreurs de lecture détectées"
#: src/pv/display.c:532 src/pv/transfer.c:679
msgid "buffer allocation failed"
msgstr "l'allocation de mémoire tampon a échoué"
#: src/pv/transfer.c:386
msgid "file is not seekable"
msgstr "ne peut pas se déplacer dans le fichier"
#: src/pv/display.c:592 src/pv/transfer.c:458
#: src/pv/transfer.c:445
msgid "failed to seek past error"
msgstr "n'a pas réussi à dépasser l'erreur"
#: src/pv/transfer.c:461
msgid "skipped past read error"
msgstr "erreur de lecture dépassée"
#: src/pv/transfer.c:461 src/pv/display.c:660
msgid "B"
msgstr "O"
#: src/pv/display.c:628 src/pv/display.c:636
msgid "/s"
msgstr "/s"
#: src/pv/display.c:628 src/pv/display.c:636
#, fuzzy
msgid "B/s"
msgstr "O/s"
#: src/pv/display.c:671 src/pv/display.c:676 src/pv/display.c:738
msgid "ETA"
msgstr "ETA"
#: src/pv/transfer.c:341
msgid "read failed"
msgstr "la lecture a échoué"
#: src/pv/transfer.c:359
msgid "warning: read errors detected"
msgstr ""
#: src/pv/transfer.c:374
msgid "file is not seekable"
msgstr ""
#: src/pv/transfer.c:437
#, fuzzy
msgid "failed to seek past error"
msgstr "échec à statuer sur le fichier"
#: src/pv/transfer.c:456
msgid "skipped past read error"
msgstr ""
#: src/pv/transfer.c:631
#: src/pv/transfer.c:617
msgid "write failed"
msgstr "l'écriture a échoué"
msgstr "l'écriture a échoué"
#: src/pv/transfer.c:770
#: src/pv/transfer.c:736 src/pv/display.c:594
msgid "buffer allocation failed"
msgstr "l'allocation de mémoire tampon a échoué"
#.
#. * Any other error is a problem and we must report back.
#.
#: src/pv/transfer.c:833
msgid "select call failed"
msgstr "appel de sélection a échoué"
msgstr "appel de sélection a échoué"
#: src/pv/state.c:33
#: src/pv/watchpid.c:73 src/pv/watchpid.c:83 src/pv/watchpid.c:94
#: src/pv/watchpid.c:102 src/pv/watchpid.c:139 src/pv/watchpid.c:150
#: src/pv/watchpid.c:158 src/pv/watchpid.c:169 src/pv/watchpid.c:253
#: src/pv/watchpid.c:261 src/pv/watchpid.c:292 src/pv/watchpid.c:312
#: src/pv/loop.c:506 src/pv/loop.c:558 src/pv/loop.c:602
msgid "pid"
msgstr ""
#: src/pv/watchpid.c:83 src/pv/watchpid.c:95 src/pv/watchpid.c:104
#: src/pv/watchpid.c:150 src/pv/watchpid.c:159 src/pv/watchpid.c:171
msgid "fd"
msgstr ""
#: src/pv/watchpid.c:104 src/pv/watchpid.c:171
msgid "not a regular file or block device"
msgstr "pas un fichier ordinaire ou un périphérique de bloc"
#: src/pv/state.c:30
msgid "history structure allocation failed"
msgstr ""
#: src/pv/state.c:59
msgid "none"
msgstr ""
#: src/main/version.c:17
#, fuzzy, c-format
msgid "%s %s - Copyright %s %s"
msgstr "%s %s - Copyright(C) %s %s"
#: src/main/version.c:20
#, c-format
msgid "Web site: %s"
msgstr "Site Web: %s"
#: 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:159
msgid "yzafpnum kMGTPEZY"
msgstr ""
"Ce programme est un logiciel libre et est distribué sous les termes\n"
"anglophone de la Licence Artistique 2.0 (Artistic License 2.0)."
#: src/pv/display.c:164
msgid "yzafpnum KMGTPEZY"
msgstr ""
#: src/pv/display.c:656
msgid "b"
msgstr ""
#: src/pv/display.c:711 src/pv/display.c:722
msgid "b/s"
msgstr ""
#: src/pv/display.c:714 src/pv/display.c:726
msgid "/s"
msgstr "/s"
#: src/pv/display.c:714 src/pv/display.c:726
msgid "B/s"
msgstr "O/s"
#: src/pv/display.c:762 src/pv/display.c:766 src/pv/display.c:825
msgid "ETA"
msgstr "ETA"
#. GNU standard license line and free software notice
#: 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."
msgstr ""
"Ce programme est distribué dans l'espoir qu'il sera utile, mais\n"
"SANS GARANTIE AUCUNE; ni même de garantie sous-entendu que le\n"
"programme soit COMMERCIALISABLE ou APPLICABLE À UNE TÂCHE\n"
"PARTICULIÈRE."
#: src/main/main.c:73
#, fuzzy
msgid "state allocation failed"
msgstr "l'allocation de mémoire tampon a échoué"
#: src/main/options.c:98
#, c-format
msgid "%s: option structure allocation failed (%s)"
msgstr "%s: l'allocation pour la structure d'une option a echoué (%s)"
#: src/main/options.c:114
#, c-format
msgid "%s: option structure argv allocation failed (%s)"
msgstr "%s: l'allocation pour la structure de l'option argv a echoué (%s)"
#: src/main/options.c:154
msgid "integer argument expected"
msgstr "Valeur entière attendue"
#: src/main/options.c:165
msgid "numeric argument expected"
msgstr "Valeur numérique attendue"
#: src/main/options.c:176
msgid "process ID or pid:fd pair expected"
msgid "License: Artistic v2.0 <https://opensource.org/license/artistic-2-0/>"
msgstr ""
#: src/main/options.c:183
msgid "invalid process ID"
#: src/main/version.c:29
msgid "This is free software: you are free to change and redistribute it."
msgstr ""
#: src/main/options.c:317
#, c-format
msgid "Try `%s --help' for more information."
msgstr "Essayez `%s --help' pour plus d'information."
#: src/main/options.c:321
#, fuzzy, c-format
msgid "Try `%s -h' for more information."
msgstr "Essayez `%s -h' pour plus d'information."
#: src/main/options.c:338
#, c-format
msgid ""
"%s: cannot use line mode or transfer modifier options when watching file "
"descriptors"
#: src/main/version.c:30
msgid "There is NO WARRANTY, to the extent permitted by law."
msgstr ""
#: src/main/options.c:348
#, c-format
msgid "%s: cannot use cursor positioning when watching file descriptors"
#. Project web site link
#: src/main/version.c:32
msgid "Project web site"
msgstr ""
#: src/main/options.c:358
#, c-format
msgid "%s: cannot use remote control when watching file descriptors"
msgstr ""
#: src/main/options.c:368
#, c-format
msgid "%s: cannot transfer files when watching file descriptors"
msgstr ""
#: src/main/options.c:378
#, c-format
msgid "%s: -d: not available on systems without /proc/self/fdinfo"
msgstr ""
#: src/main/remote.c:218
#: src/main/remote.c:215
msgid "message not received"
msgstr ""
msgstr "message non reçu"
#: src/main/remote.c:324
#: src/main/remote.c:318
msgid "IPC not supported on this system"
msgstr ""
msgstr "IPC non pris en charge sur ce système"
#: src/main/help.c:31
#: src/main/help.c:283
msgid "show progress bar"
msgstr "affiche la barre de progression"
#: src/main/help.c:33
#: src/main/help.c:286
msgid "show elapsed time"
msgstr "affiche le temps écoulé"
msgstr "affiche le temps écoulé"
#: src/main/help.c:35
#: src/main/help.c:289
msgid "show estimated time of arrival (completion)"
msgstr "affiche l'heure approximative de l'achèvement de la tâche"
msgstr "affiche l'heure approximative de l'achèvement de la tâche"
#: src/main/help.c:38
#, fuzzy
#: src/main/help.c:292
msgid "show absolute estimated time of arrival (completion)"
msgstr "affiche l'heure approximative de l'achèvement de la tâche"
msgstr "affiche l'heure absolute de l'achèvement de la tâche"
#: src/main/help.c:40
#: src/main/help.c:295
msgid "show data transfer rate counter"
msgstr "affiche le taux de tranfert des données"
msgstr "affiche le taux de tranfert des données"
#: src/main/help.c:42
#: src/main/help.c:298
msgid "show data transfer average rate counter"
msgstr ""
msgstr "afficher le compteur de taux moyen de transfert de données"
#: src/main/help.c:44
msgid "show number of bytes transferred"
msgstr "affiche le nombre d'octets transférés"
#: src/main/help.c:46
msgid "show percentage of transfer buffer in use"
msgstr ""
#: src/main/help.c:47
msgid "NUM"
msgstr ""
#: src/main/help.c:48
msgid "show NUM bytes last written"
msgstr ""
#: src/main/help.c:49
#, fuzzy
msgid "FORMAT"
msgstr "TAUX"
#: src/main/help.c:50
msgid "set output format to FORMAT"
msgstr ""
#: src/main/help.c:52
msgid "output percentages, not visual information"
msgstr "imprime en pourcentage, pas les informations visuelles"
#: src/main/help.c:54
msgid "do not output any transfer information at all"
msgstr "n'afficher aucune information de transfert"
#: src/main/help.c:57
msgid "display nothing until first byte transferred"
msgstr "ne rien afficher avant qu'au moins un octet soit tranféré"
#: src/main/help.c:58 src/main/help.c:66
#: src/main/help.c:300 src/main/help.c:328 src/main/help.c:340
msgid "SEC"
msgstr "SEC"
#: src/main/help.c:59
#, fuzzy
msgid "display nothing until SEC seconds have passed"
msgstr "ne rien afficher avant qu'au moins un octet soit tranféré"
#: src/main/help.c:301
msgid "compute average rate over past SEC seconds (default 30s)"
msgstr ""
#: src/main/help.c:60
#: src/main/help.c:304
msgid "show number of bytes transferred"
msgstr "affiche le nombre d'octets transférés"
#: src/main/help.c:307
msgid "show number of bits transferred"
msgstr ""
#: src/main/help.c:310
msgid "show percentage of transfer buffer in use"
msgstr "afficher le pourcentage de tampon de transfert utilisé"
#: src/main/help.c:312
msgid "NUM"
msgstr ""
#: src/main/help.c:313
msgid "show NUM bytes last written"
msgstr "affiche NUM octets pour la dernière fois écrits"
#: src/main/help.c:315
msgid "FORMAT"
msgstr ""
#: src/main/help.c:316
msgid "set output format to FORMAT"
msgstr "définir le format de sortie sur FORMAT"
#: src/main/help.c:319
msgid "output percentages, not visual information"
msgstr "imprime en pourcentage, pas les informations visuelles"
#: src/main/help.c:322
msgid "do not output any transfer information at all"
msgstr "n'afficher aucune information de transfert"
#: src/main/help.c:326
msgid "display nothing until first byte transferred"
msgstr "ne rien afficher avant qu'au moins un octet soit tranféré"
#: src/main/help.c:329
msgid "display nothing until SEC seconds have passed"
msgstr "n'afficher rien jusqu'à ce que SEC secondes se soient écoulées"
#: src/main/help.c:331
msgid "SIZE"
msgstr "TAILLE"
#: src/main/help.c:61
#: src/main/help.c:332
msgid "set estimated data size to SIZE bytes"
msgstr "ajuste la taille estimée des données à TAILLE octets"
msgstr "ajuste la taille estimée des données à TAILLE octets"
#: src/main/help.c:63
#: src/main/help.c:335
msgid "count lines instead of bytes"
msgstr "compte les lignes au lieu des octets"
#: src/main/help.c:65
#: src/main/help.c:338
msgid "lines are null-terminated"
msgstr ""
msgstr "les lignes sont terminées par un nul"
#: src/main/help.c:67
#: src/main/help.c:341
msgid "update every SEC seconds"
msgstr "mise-à-jour toute les SEC secondes"
msgstr "mise-à-jour toute les SEC secondes"
#: src/main/help.c:68
#: src/main/help.c:343
msgid "WIDTH"
msgstr "LARGEUR"
#: src/main/help.c:69
#: src/main/help.c:344
msgid "assume terminal is WIDTH characters wide"
msgstr "présumer la largeur du terminal à LARGEUR caractères"
msgstr "présumer la largeur du terminal à LARGEUR caractères"
#: src/main/help.c:70
#: src/main/help.c:346
msgid "HEIGHT"
msgstr "HAUTEUR"
#: src/main/help.c:71
#: src/main/help.c:347
msgid "assume terminal is HEIGHT rows high"
msgstr "présumer la hauteur du terminal à HAUTEUR lignes"
msgstr "présumer la hauteur du terminal à HAUTEUR lignes"
#: src/main/help.c:72
#: src/main/help.c:349
msgid "NAME"
msgstr "NOM"
#: src/main/help.c:73
#: src/main/help.c:350
msgid "prefix visual information with NAME"
msgstr "préfixer les informations visuelles avec NOM"
msgstr "préfixer les informations visuelles avec NOM"
#: src/main/help.c:75
#: src/main/help.c:353
msgid "output even if standard error is not a terminal"
msgstr "imprime vers la sortie d'erreur même si ce n'est pas un terminal"
msgstr "imprime vers la sortie d'erreur même si ce n'est pas un terminal"
#: src/main/help.c:77
#: src/main/help.c:356
msgid "use cursor positioning escape sequences"
msgstr "utiliser les séquences d'échappements de positionnement de curseur"
msgstr "utiliser les séquences d'échappements de positionnement de curseur"
#: src/main/help.c:79
#: src/main/help.c:359
msgid "RATE"
msgstr "TAUX"
#: src/main/help.c:80
#: src/main/help.c:360
msgid "limit transfer to RATE bytes per second"
msgstr "limite le taux de transfer à TAUX octets par seconde"
msgstr "limite le taux de transfer à TAUX octets par seconde"
#: src/main/help.c:81
#: src/main/help.c:362
msgid "BYTES"
msgstr "OCTETS"
#: src/main/help.c:82
#: src/main/help.c:363
msgid "use a buffer size of BYTES"
msgstr "Utiliser une mémoire tampon de OCTETS octets"
msgstr "Utiliser une mémoire tampon de OCTETS octets"
#: src/main/help.c:84
#: src/main/help.c:366
msgid "never use splice(), always use read/write"
msgstr ""
msgstr "n'utilisez jamais splice(), utilisez toujours read/write"
#: src/main/help.c:86
#: src/main/help.c:369
msgid "skip read errors in input"
msgstr "ignorer les erreurs de lecture dans l'entrée"
#: src/main/help.c:372
msgid "stop after --size bytes have been transferred"
msgstr "arrêter après le transfert de --size octets"
#: src/main/help.c:375
msgid "flush cache to disk after every write"
msgstr ""
#: src/main/help.c:88
#, fuzzy
msgid "stop after --size bytes have been transferred"
msgstr "affiche le nombre d'octets transférés"
#: src/main/help.c:378
msgid "use direct I/O to bypass cache"
msgstr ""
#: src/main/help.c:90
#: src/main/help.c:381
msgid "PID"
msgstr "PID"
#: src/main/help.c:91
#: src/main/help.c:382
msgid "update settings of process PID"
msgstr "mettre-à-jour la configuration du processus PID"
msgstr "mettre-à-jour la configuration du processus PID"
#: src/main/help.c:94
#: src/main/help.c:386 src/main/help.c:401
msgid "FILE"
msgstr ""
#: src/main/help.c:95
#: src/main/help.c:387
msgid "save process ID in FILE"
msgstr ""
msgstr "enregistrer l'ID de processus dans FILE"
#: src/main/help.c:97
#: src/main/help.c:390
msgid "PID[:FD]"
msgstr ""
#: src/main/help.c:98
#: src/main/help.c:391
msgid "watch file FD opened by process PID"
msgstr ""
msgstr "regarder le fichier FD ouvert par le processus PID"
#: src/main/help.c:101
#: src/main/help.c:395
msgid "show this help and exit"
msgstr "afficher cette aide puis quitter"
#: src/main/help.c:103
#: src/main/help.c:398
msgid "show version information and exit"
msgstr "afficher la version puis quitter"
#: src/main/help.c:109
#: src/main/help.c:402
msgid "write debug logs to FILE"
msgstr ""
#. @-formatconst@
#.
#. * splint note: unavoidable use of %s in translated string. Should
#. * be hard to exploit - the message catalogue would have to be
#. * replaced or forced to load from another location.
#.
#: src/main/help.c:427
#, c-format
msgid "Usage: %s [OPTION] [FILE]..."
msgstr "Utilisation : %s [OPTIONS] [FICHIER]..."
#: src/main/help.c:112
#. @-mustfreefresh@
#.
#. * splint note: the gettext calls made by _() cause memory leak
#. * warnings, but in this case it's unavoidable, and mitigated by the
#. * fact we only translate each string once.
#.
#: src/main/help.c:438
msgid ""
"Concatenate FILE(s), or standard input, to standard output,\n"
"with monitoring."
"Concatenate FILE(s), or standard input, to standard output, with monitoring."
msgstr ""
"Concatène FICHIER(s), ou l'entrée standard, sur la sortie standard\n"
"avec monitorage."
"Concatène FICHIER(s), ou l'entrée standard, sur la sortie standard avec "
"monitorage."
#: src/main/help.c:201
msgid ""
"Debugging is enabled; export the DEBUG environment variable to define the\n"
"output filename.\n"
msgstr ""
#: src/main/help.c:205
#: src/main/help.c:575
#, c-format
msgid "Please report any bugs to %s."
msgstr "SVP rapporter touts bogues à %s."
msgstr "SVP rapporter touts bogues à %s."
#~ msgid "failed to lock terminal"
#~ msgstr "l'ouverture du terminal a échoué"
#: src/main/main.c:75
msgid "state allocation failed"
msgstr "échec de l'allocation de mémoire de condition"
#: src/main/main.c:243
msgid "failed to read terminal attributes"
msgstr ""
#: src/main/options.c:111
msgid "option structure allocation failed"
msgstr "l'allocation pour la structure d'une option a echoué"
#: src/main/options.c:124
msgid "option structure argv allocation failed"
msgstr "l'allocation pour la structure de l'option argv a echoué"
#: src/main/options.c:163
msgid "integer argument expected"
msgstr "Valeur entière attendue"
#: src/main/options.c:171
msgid "numeric argument expected"
msgstr "Valeur numérique attendue"
#: src/main/options.c:180
msgid "process ID or pid:fd pair expected"
msgstr "ID de processus ou paire pid:fd attendue"
#: src/main/options.c:185
msgid "invalid process ID"
msgstr "ID de processus non valide"
#: src/main/options.c:358
#, c-format
msgid "Try `%s --help' for more information."
msgstr "Essayez `%s --help' pour plus d'information."
#: src/main/options.c:360
#, c-format
msgid "Try `%s -h' for more information."
msgstr "Essayez `%s -h' pour plus d'information."
#: src/main/options.c:374
msgid ""
"cannot use line mode or transfer modifier options when watching file "
"descriptors"
msgstr ""
"impossible d'utiliser le mode ligne ou les options de modificateur de "
"transfert lors de la visualisation des descripteurs de fichiers"
#: src/main/options.c:381
msgid "cannot use cursor positioning when watching file descriptors"
msgstr ""
"impossible d'utiliser le positionnement du curseur lors de la visualisation "
"des descripteurs de fichier"
#: src/main/options.c:388
msgid "cannot use remote control when watching file descriptors"
msgstr ""
"impossible d'utiliser la télécommande lors de la visualisation des "
"descripteurs de fichiers"
#: src/main/options.c:395
msgid "cannot transfer files when watching file descriptors"
msgstr ""
"impossible de transférer des fichiers lorsque vous regardez des descripteurs "
"de fichiers"
#: src/main/options.c:402
msgid "not available on systems without /proc/self/fdinfo"
msgstr "non disponible sur les systèmes sans /proc/self/fdinfo"
#~ msgid ""
#~ "Debugging is enabled; export the DEBUG environment variable to define "
#~ "the\n"
#~ "output filename.\n"
#~ msgstr ""
#~ "Le débogage est activé; exportez la variable d'environnement DEBUG pour\n"
#~ "définir le nom du fichier de sortie.\n"
#~ msgid "%s %s - Copyright %s %s"
#~ msgstr "%s %s - Copyright(C) %s %s"
#~ msgid "Web site: %s"
#~ msgstr "Site Web: %s"
#~ msgid ""
#~ "This program is free software, and is being distributed under the\n"
#~ "terms of the Artistic License 2.0."
#~ msgstr ""
#~ "Ce programme est un logiciel libre et est distribué sous les termes\n"
#~ "anglophone de la Licence Artistique 2.0 (Artistic License 2.0)."
#~ 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."
#~ msgstr ""
#~ "Ce programme est distribué dans l'espoir qu'il sera utile, mais\n"
#~ "SANS GARANTIE AUCUNE; ni même de garantie sous-entendu que le\n"
#~ "programme soit COMMERCIALISABLE ou APPLICABLE À UNE TÂCHE\n"
#~ "PARTICULIÈRE."
+385 -404
View File
@@ -6,486 +6,467 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-06-30 22:21+0100\n"
"POT-Creation-Date: 2023-07-30 19:07+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"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=ISO-8859-2\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: src/pv/watchpid.c:51 src/pv/watchpid.c:66 src/pv/watchpid.c:76
#: src/pv/watchpid.c:107 src/pv/loop.c:519 src/pv/loop.c:580 src/pv/loop.c:632
msgid "pid"
msgstr ""
#: src/pv/watchpid.c:68 src/pv/watchpid.c:78 src/pv/watchpid.c:109
msgid "fd"
msgstr ""
#: src/pv/watchpid.c:112
msgid "not a regular file or block device"
msgstr ""
#: src/pv/cursor.c:53
#, fuzzy
#: src/pv/cursor.c:85
msgid "failed to get terminal name"
msgstr "nie uda³o siê otworzyæ terminala"
msgstr ""
# "Przewidywany czas ukoñczenia" for ETA is too long
#: src/pv/cursor.c:96
#, fuzzy
# "Przewidywany czas ukończenia" for ETA is too long
#: src/pv/cursor.c:117
msgid "failed to open lock file"
msgstr "nie uda³o siê zamkn±æ pliku"
msgstr ""
#: src/pv/cursor.c:129
#: src/pv/cursor.c:150
msgid "lock attempt failed"
msgstr ""
#: src/pv/cursor.c:369
#: src/pv/cursor.c:391
msgid "failed to open terminal"
msgstr "nie uda³o siê otworzyæ terminala"
msgstr "nie udało się otworzyć terminala"
#: src/pv/file.c:118
#, fuzzy
#: src/pv/file.c:119
msgid "failed to seek to start of output"
msgstr "nie uda³o siê wykonaæ operacji stat na pliku wyj¶ciowym"
msgstr ""
# "Przewidywany czas ukoñczenia" for ETA is too long
#: src/pv/file.c:214
# "Przewidywany czas ukończenia" for ETA is too long
#: src/pv/file.c:210
msgid "failed to close file"
msgstr "nie uda³o siê zamkn±æ pliku"
msgstr "nie udało się zamknąć pliku"
#: src/pv/file.c:237
#: src/pv/file.c:232
msgid "failed to read file"
msgstr "nie uda³o siê odczytaæ pliku"
msgstr "nie udało się odczytać pliku"
#: src/pv/file.c:247
#: src/pv/file.c:239 src/main/options.c:284
msgid "failed to stat file"
msgstr "nie uda³o siê wykonaæ operacji stat na pliku"
msgstr "nie udało się wykonać operacji stat na pliku"
#: src/pv/file.c:256
#: src/pv/file.c:246
msgid "failed to stat output file"
msgstr "nie uda³o siê wykonaæ operacji stat na pliku wyjciowym"
msgstr "nie udało się wykonać operacji stat na pliku wyjściowym"
#: src/pv/file.c:279
#: src/pv/file.c:268
msgid "input file is output file"
msgstr "plik wejciowy jest zarazem plikiem wyjciowym"
#: src/pv/display.c:117
msgid "yzafpnum kMGTPEZY"
msgstr ""
#: src/pv/display.c:122
msgid "yzafpnum KMGTPEZY"
msgstr ""
#: src/pv/display.c:532 src/pv/transfer.c:679
msgid "buffer allocation failed"
msgstr "nie uda³o siê zaalokowaæ bufora"
#: src/pv/display.c:592 src/pv/transfer.c:458
msgid "B"
msgstr "B"
#: src/pv/display.c:628 src/pv/display.c:636
msgid "/s"
msgstr "/s"
#: src/pv/display.c:628 src/pv/display.c:636
msgid "B/s"
msgstr "B/s"
#: src/pv/display.c:671 src/pv/display.c:676 src/pv/display.c:738
msgid "ETA"
msgstr "ETA"
#: src/pv/transfer.c:341
msgid "read failed"
msgstr "b³±d odczytu"
msgstr "plik wejściowy jest zarazem plikiem wyjściowym"
#: src/pv/transfer.c:359
msgid "read failed"
msgstr "błąd odczytu"
#: src/pv/transfer.c:374
msgid "warning: read errors detected"
msgstr ""
#: src/pv/transfer.c:374
#: src/pv/transfer.c:386
msgid "file is not seekable"
msgstr ""
#: src/pv/transfer.c:437
#, fuzzy
#: src/pv/transfer.c:445
msgid "failed to seek past error"
msgstr "nie uda³o siê wykonaæ operacji stat na pliku"
msgstr ""
#: src/pv/transfer.c:456
#: src/pv/transfer.c:461
msgid "skipped past read error"
msgstr ""
#: src/pv/transfer.c:631
#: src/pv/transfer.c:461 src/pv/display.c:660
msgid "B"
msgstr "B"
#: src/pv/transfer.c:617
msgid "write failed"
msgstr "b³±d zapisu"
msgstr "błąd zapisu"
#: src/pv/transfer.c:770
#: src/pv/transfer.c:736 src/pv/display.c:594
msgid "buffer allocation failed"
msgstr "nie udało się zaalokować bufora"
#.
#. * Any other error is a problem and we must report back.
#.
#: src/pv/transfer.c:833
msgid "select call failed"
msgstr "nie uda³o siê wywo³aæ funkcji select"
msgstr "nie udało się wywołać funkcji select"
#: src/pv/state.c:33
#: src/pv/watchpid.c:73 src/pv/watchpid.c:83 src/pv/watchpid.c:94
#: src/pv/watchpid.c:102 src/pv/watchpid.c:139 src/pv/watchpid.c:150
#: src/pv/watchpid.c:158 src/pv/watchpid.c:169 src/pv/watchpid.c:253
#: src/pv/watchpid.c:261 src/pv/watchpid.c:292 src/pv/watchpid.c:312
#: src/pv/loop.c:506 src/pv/loop.c:558 src/pv/loop.c:602
msgid "pid"
msgstr ""
#: src/pv/watchpid.c:83 src/pv/watchpid.c:95 src/pv/watchpid.c:104
#: src/pv/watchpid.c:150 src/pv/watchpid.c:159 src/pv/watchpid.c:171
msgid "fd"
msgstr ""
#: src/pv/watchpid.c:104 src/pv/watchpid.c:171
msgid "not a regular file or block device"
msgstr ""
#: src/pv/state.c:30
msgid "history structure allocation failed"
msgstr ""
#: src/pv/state.c:59
msgid "none"
msgstr ""
#: src/main/version.c:17
#, fuzzy, c-format
msgid "%s %s - Copyright %s %s"
msgstr "%s %s - Prawa autorskie (C) %s %s"
#: src/main/version.c:20
#, c-format
msgid "Web site: %s"
msgstr "Strona WWW: %s"
#: 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:159
msgid "yzafpnum kMGTPEZY"
msgstr ""
#: src/pv/display.c:164
msgid "yzafpnum KMGTPEZY"
msgstr ""
#: src/pv/display.c:656
msgid "b"
msgstr ""
#: src/pv/display.c:711 src/pv/display.c:722
msgid "b/s"
msgstr ""
#: src/pv/display.c:714 src/pv/display.c:726
msgid "/s"
msgstr "/s"
#: src/pv/display.c:714 src/pv/display.c:726
msgid "B/s"
msgstr "B/s"
#: src/pv/display.c:762 src/pv/display.c:766 src/pv/display.c:825
msgid "ETA"
msgstr "ETA"
#. GNU standard license line and free software notice
#: 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."
msgid "License: Artistic v2.0 <https://opensource.org/license/artistic-2-0/>"
msgstr ""
#: src/main/main.c:73
#, fuzzy
#: src/main/version.c:29
msgid "This is free software: you are free to change and redistribute it."
msgstr ""
#: src/main/version.c:30
msgid "There is NO WARRANTY, to the extent permitted by law."
msgstr ""
#. Project web site link
#: src/main/version.c:32
msgid "Project web site"
msgstr ""
#: src/main/remote.c:215
msgid "message not received"
msgstr ""
#: src/main/remote.c:318
msgid "IPC not supported on this system"
msgstr ""
#: src/main/help.c:283
msgid "show progress bar"
msgstr "pokaż pasek postępu"
#: src/main/help.c:286
msgid "show elapsed time"
msgstr "pokaż upływający czas"
#: src/main/help.c:289
msgid "show estimated time of arrival (completion)"
msgstr "pokaż szacowany czas ukończenia"
#: src/main/help.c:292
msgid "show absolute estimated time of arrival (completion)"
msgstr ""
#: src/main/help.c:295
msgid "show data transfer rate counter"
msgstr "pokaż licznik prędkości przesyłania"
#: src/main/help.c:298
msgid "show data transfer average rate counter"
msgstr ""
#: src/main/help.c:300 src/main/help.c:328 src/main/help.c:340
msgid "SEC"
msgstr "WARTOŚĆ"
#: src/main/help.c:301
msgid "compute average rate over past SEC seconds (default 30s)"
msgstr ""
#: src/main/help.c:304
msgid "show number of bytes transferred"
msgstr "pokaż ilość przesłanych bajtów"
#: src/main/help.c:307
msgid "show number of bits transferred"
msgstr ""
#: src/main/help.c:310
msgid "show percentage of transfer buffer in use"
msgstr ""
#: src/main/help.c:312
msgid "NUM"
msgstr ""
#: src/main/help.c:313
msgid "show NUM bytes last written"
msgstr ""
#: src/main/help.c:315
msgid "FORMAT"
msgstr ""
#: src/main/help.c:316
msgid "set output format to FORMAT"
msgstr ""
#: src/main/help.c:319
msgid "output percentages, not visual information"
msgstr "wświetl wyjście procentowo, bez graficznej prezentacji"
#: src/main/help.c:322
msgid "do not output any transfer information at all"
msgstr "nie wyświetlaj żadnych informacji o przesyłaniu"
#: src/main/help.c:326
msgid "display nothing until first byte transferred"
msgstr "nie wyświetlaj nic aż do pierwszego przesłanego bajtu"
#: src/main/help.c:329
msgid "display nothing until SEC seconds have passed"
msgstr ""
#: src/main/help.c:331
msgid "SIZE"
msgstr "WARTOŚĆ"
#: src/main/help.c:332
msgid "set estimated data size to SIZE bytes"
msgstr "ustaw oczekiwany rozmiar danych na WARTOŚĆ bajtów"
#: src/main/help.c:335
msgid "count lines instead of bytes"
msgstr ""
#: src/main/help.c:338
msgid "lines are null-terminated"
msgstr ""
#: src/main/help.c:341
msgid "update every SEC seconds"
msgstr "aktualizuj co każde WARTOŚĆ sekund"
#: src/main/help.c:343
msgid "WIDTH"
msgstr "WARTOŚĆ"
#: src/main/help.c:344
msgid "assume terminal is WIDTH characters wide"
msgstr "przyjmij, że terminal ma szerokość WARTOŚĆ znaków"
#: src/main/help.c:346
msgid "HEIGHT"
msgstr ""
#: src/main/help.c:347
msgid "assume terminal is HEIGHT rows high"
msgstr "przyjmij, że terminal ma szerokość WARTOŚĆ znaków"
#: src/main/help.c:349
msgid "NAME"
msgstr "NAZWA"
#: src/main/help.c:350
msgid "prefix visual information with NAME"
msgstr "poprzedź informacje prefiksem NAZWA"
#: src/main/help.c:353
msgid "output even if standard error is not a terminal"
msgstr "pokaż wyjście nawet gdy błędy nie są typu terminal"
#: src/main/help.c:356
msgid "use cursor positioning escape sequences"
msgstr "używaj sekwencji escape do pozycjonowania"
#: src/main/help.c:359
msgid "RATE"
msgstr ""
#: src/main/help.c:360
msgid "limit transfer to RATE bytes per second"
msgstr "ogranicz przesyłane dane do RATE bajtów na sekundę"
#: src/main/help.c:362
msgid "BYTES"
msgstr ""
#: src/main/help.c:363
msgid "use a buffer size of BYTES"
msgstr ""
#: src/main/help.c:366
msgid "never use splice(), always use read/write"
msgstr ""
#: src/main/help.c:369
msgid "skip read errors in input"
msgstr ""
#: src/main/help.c:372
msgid "stop after --size bytes have been transferred"
msgstr ""
#: src/main/help.c:375
msgid "flush cache to disk after every write"
msgstr ""
#: src/main/help.c:378
msgid "use direct I/O to bypass cache"
msgstr ""
#: src/main/help.c:381
msgid "PID"
msgstr ""
#: src/main/help.c:382
msgid "update settings of process PID"
msgstr ""
#: src/main/help.c:386 src/main/help.c:401
msgid "FILE"
msgstr ""
#: src/main/help.c:387
msgid "save process ID in FILE"
msgstr ""
#: src/main/help.c:390
msgid "PID[:FD]"
msgstr ""
#: src/main/help.c:391
msgid "watch file FD opened by process PID"
msgstr ""
#: src/main/help.c:395
msgid "show this help and exit"
msgstr "wyświetl te informacje z pomocą i wyjdź"
#: src/main/help.c:398
msgid "show version information and exit"
msgstr "wyświetl informacje o wersji i wyjdź"
#: src/main/help.c:402
msgid "write debug logs to FILE"
msgstr ""
#. @-formatconst@
#.
#. * splint note: unavoidable use of %s in translated string. Should
#. * be hard to exploit - the message catalogue would have to be
#. * replaced or forced to load from another location.
#.
#: src/main/help.c:427
#, c-format
msgid "Usage: %s [OPTION] [FILE]..."
msgstr "Sposób użycia: %s [OPCJA] [PLIK]..."
#. @-mustfreefresh@
#.
#. * splint note: the gettext calls made by _() cause memory leak
#. * warnings, but in this case it's unavoidable, and mitigated by the
#. * fact we only translate each string once.
#.
#: src/main/help.c:438
msgid ""
"Concatenate FILE(s), or standard input, to standard output, with monitoring."
msgstr ""
"Łączenie PLIK(ów) lub wejścia standardowego, do wyjścia standardowego z "
"monitoringiem."
#: src/main/help.c:575
#, c-format
msgid "Please report any bugs to %s."
msgstr "Proszę przesyłać zgłoszenia błędów do %s."
#: src/main/main.c:75
msgid "state allocation failed"
msgstr "nie uda³o siê zaalokowaæ bufora"
msgstr ""
#: src/main/options.c:98
#, c-format
msgid "%s: option structure allocation failed (%s)"
msgstr "%s: nie uda³o siê zaalokowaæ struktur opcji (%s)"
#: src/main/main.c:243
msgid "failed to read terminal attributes"
msgstr ""
#: src/main/options.c:114
#, c-format
msgid "%s: option structure argv allocation failed (%s)"
msgstr "%s: nie uda³o siê zaalokowaæ struktur opcji argv (%s)"
#: src/main/options.c:111
msgid "option structure allocation failed"
msgstr "nie udało się zaalokować struktur opcji"
#: src/main/options.c:154
#: src/main/options.c:124
msgid "option structure argv allocation failed"
msgstr "nie udało się zaalokować struktur opcji argv"
#: src/main/options.c:163
msgid "integer argument expected"
msgstr ""
#: src/main/options.c:165
#: src/main/options.c:171
msgid "numeric argument expected"
msgstr ""
#: src/main/options.c:176
#: src/main/options.c:180
msgid "process ID or pid:fd pair expected"
msgstr ""
#: src/main/options.c:183
#: src/main/options.c:185
msgid "invalid process ID"
msgstr ""
#: src/main/options.c:317
#, c-format
msgid "Try `%s --help' for more information."
msgstr "Spróbuj `%s --help' by uzyskaæ wiêcej informacji"
#: src/main/options.c:321
#, fuzzy, c-format
msgid "Try `%s -h' for more information."
msgstr "Spróbuj `%s -h' by uzyskaæ wiêcej informacji"
#: src/main/options.c:338
#, c-format
msgid ""
"%s: cannot use line mode or transfer modifier options when watching file "
"descriptors"
msgstr ""
#: src/main/options.c:348
#, c-format
msgid "%s: cannot use cursor positioning when watching file descriptors"
msgstr ""
#: src/main/options.c:358
#, c-format
msgid "%s: cannot use remote control when watching file descriptors"
msgstr ""
msgid "Try `%s --help' for more information."
msgstr "Spróbuj `%s --help' by uzyskać więcej informacji"
#: src/main/options.c:368
#: src/main/options.c:360
#, c-format
msgid "%s: cannot transfer files when watching file descriptors"
msgstr ""
msgid "Try `%s -h' for more information."
msgstr "Spróbuj `%s -h' by uzyskać więcej informacji"
#: src/main/options.c:378
#, c-format
msgid "%s: -d: not available on systems without /proc/self/fdinfo"
msgstr ""
#: src/main/remote.c:218
msgid "message not received"
msgstr ""
#: src/main/remote.c:324
msgid "IPC not supported on this system"
msgstr ""
#: src/main/help.c:31
msgid "show progress bar"
msgstr "poka¿ pasek postêpu"
#: src/main/help.c:33
msgid "show elapsed time"
msgstr "poka¿ up³ywaj±cy czas"
#: src/main/help.c:35
msgid "show estimated time of arrival (completion)"
msgstr "poka¿ szacowany czas ukoñczenia"
#: src/main/help.c:38
#, fuzzy
msgid "show absolute estimated time of arrival (completion)"
msgstr "poka¿ szacowany czas ukoñczenia"
#: src/main/help.c:40
msgid "show data transfer rate counter"
msgstr "poka¿ licznik prêdko¶ci przesy³ania"
#: src/main/help.c:42
msgid "show data transfer average rate counter"
msgstr ""
#: src/main/help.c:44
msgid "show number of bytes transferred"
msgstr "poka¿ ilo¶æ przes³anych bajtów"
#: src/main/help.c:46
msgid "show percentage of transfer buffer in use"
msgstr ""
#: src/main/help.c:47
msgid "NUM"
msgstr ""
#: src/main/help.c:48
msgid "show NUM bytes last written"
msgstr ""
#: src/main/help.c:49
msgid "FORMAT"
msgstr ""
#: src/main/help.c:50
msgid "set output format to FORMAT"
msgstr ""
#: src/main/help.c:52
msgid "output percentages, not visual information"
msgstr "w¶wietl wyj¶cie procentowo, bez graficznej prezentacji"
#: src/main/help.c:54
msgid "do not output any transfer information at all"
msgstr "nie wy¶wietlaj ¿adnych informacji o przesy³aniu"
#: src/main/help.c:57
msgid "display nothing until first byte transferred"
msgstr "nie wy¶wietlaj nic a¿ do pierwszego przes³anego bajtu"
#: src/main/help.c:58 src/main/help.c:66
msgid "SEC"
msgstr "WARTO¦Æ"
#: src/main/help.c:59
#, fuzzy
msgid "display nothing until SEC seconds have passed"
msgstr "nie wy¶wietlaj nic a¿ do pierwszego przes³anego bajtu"
#: src/main/help.c:60
msgid "SIZE"
msgstr "WARTO¦Æ"
#: src/main/help.c:61
msgid "set estimated data size to SIZE bytes"
msgstr "ustaw oczekiwany rozmiar danych na WARTO¦Æ bajtów"
#: src/main/help.c:63
msgid "count lines instead of bytes"
msgstr ""
#: src/main/help.c:65
msgid "lines are null-terminated"
msgstr ""
#: src/main/help.c:67
msgid "update every SEC seconds"
msgstr "aktualizuj co ka¿de WARTO¦Æ sekund"
#: src/main/help.c:68
msgid "WIDTH"
msgstr "WARTO¦Æ"
#: src/main/help.c:69
msgid "assume terminal is WIDTH characters wide"
msgstr "przyjmij, ¿e terminal ma szeroko¶æ WARTO¦Æ znaków"
#: src/main/help.c:70
msgid "HEIGHT"
msgstr ""
#: src/main/help.c:71
msgid "assume terminal is HEIGHT rows high"
msgstr "przyjmij, ¿e terminal ma szeroko¶æ WARTO¦Æ znaków"
#: src/main/help.c:72
msgid "NAME"
msgstr "NAZWA"
#: src/main/help.c:73
msgid "prefix visual information with NAME"
msgstr "poprzed¼ informacje prefiksem NAZWA"
#: src/main/help.c:75
msgid "output even if standard error is not a terminal"
msgstr "poka¿ wyj¶cie nawet gdy b³êdy nie s± typu terminal"
#: src/main/help.c:77
msgid "use cursor positioning escape sequences"
msgstr "u¿ywaj sekwencji escape do pozycjonowania"
#: src/main/help.c:79
msgid "RATE"
msgstr ""
#: src/main/help.c:80
msgid "limit transfer to RATE bytes per second"
msgstr "ogranicz przesy³ane dane do RATE bajtów na sekundê"
#: src/main/help.c:81
msgid "BYTES"
msgstr ""
#: src/main/help.c:82
msgid "use a buffer size of BYTES"
msgstr ""
#: src/main/help.c:84
msgid "never use splice(), always use read/write"
msgstr ""
#: src/main/help.c:86
msgid "skip read errors in input"
msgstr ""
#: src/main/help.c:88
#, fuzzy
msgid "stop after --size bytes have been transferred"
msgstr "poka¿ ilo¶æ przes³anych bajtów"
#: src/main/help.c:90
msgid "PID"
msgstr ""
#: src/main/help.c:91
msgid "update settings of process PID"
msgstr ""
#: src/main/help.c:94
msgid "FILE"
msgstr ""
#: src/main/help.c:95
msgid "save process ID in FILE"
msgstr ""
#: src/main/help.c:97
msgid "PID[:FD]"
msgstr ""
#: src/main/help.c:98
msgid "watch file FD opened by process PID"
msgstr ""
#: src/main/help.c:101
msgid "show this help and exit"
msgstr "wy¶wietl te informacje z pomoc± i wyjd¼"
#: src/main/help.c:103
msgid "show version information and exit"
msgstr "wy¶wietl informacje o wersji i wyjd¼"
#: src/main/help.c:109
#, c-format
msgid "Usage: %s [OPTION] [FILE]..."
msgstr "Sposób u¿ycia: %s [OPCJA] [PLIK]..."
#: src/main/help.c:112
#: src/main/options.c:374
msgid ""
"Concatenate FILE(s), or standard input, to standard output,\n"
"with monitoring."
msgstr ""
"£±czenie PLIK(ów) lub wej¶cia standardowego, do wyj¶cia standardowego\n"
"z monitoringiem."
#: src/main/help.c:201
msgid ""
"Debugging is enabled; export the DEBUG environment variable to define the\n"
"output filename.\n"
"cannot use line mode or transfer modifier options when watching file "
"descriptors"
msgstr ""
#: src/main/help.c:205
#, c-format
msgid "Please report any bugs to %s."
msgstr "Proszê przesy³aæ zg³oszenia b³êdów do %s."
#: src/main/options.c:381
msgid "cannot use cursor positioning when watching file descriptors"
msgstr ""
#~ msgid "failed to lock terminal"
#~ msgstr "nie uda³o siê otworzyæ terminala"
#: src/main/options.c:388
msgid "cannot use remote control when watching file descriptors"
msgstr ""
#~ msgid "G"
#~ msgstr "GB"
#: src/main/options.c:395
msgid "cannot transfer files when watching file descriptors"
msgstr ""
#~ msgid "M"
#~ msgstr "MB"
#: src/main/options.c:402
msgid "not available on systems without /proc/self/fdinfo"
msgstr ""
#~ msgid "k"
#~ msgstr "kB"
#~ msgid "GB"
#~ msgstr "GB"
#~ msgid "MB"
#~ msgstr "MB"
#~ msgid "kB"
#~ msgstr "kB"
#~ msgid "M/s"
#~ msgstr "MB/s"
#~ msgid "k/s"
#~ msgstr "kB/s"
#~ msgid "/s "
#~ msgstr "B/s"
#~ msgid "GB/s"
#~ msgstr "GB/s"
#~ msgid "MB/s"
#~ msgstr "MB/s"
#~ msgid "kB/s"
#~ msgstr "kB/s"
#~ msgid "For more information, please run `%s --license'."
#~ msgstr "By uzyskaæ wiêcej informacji wprowad¼ `%s --license'."
#~ msgid "For more information, please run `%s -l'."
#~ msgstr "By uzyskaæ wiêcej informacji wprowad¼ `%s -l'."
#~ msgid "show the license this program is distributed under"
#~ msgstr "wy¶wietl informacje o licencji pod któr± program jest rozprowadzany"
#~ msgid "%s %s - Copyright (C) %s %s"
#~ msgstr "%s %s - Prawa autorskie (C) %s %s"
#~ msgid "Web site: %s"
#~ msgstr "Strona WWW: %s"
+336 -281
View File
@@ -6,441 +6,496 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-06-30 22:21+0100\n"
"POT-Creation-Date: 2023-07-30 19:07+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"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=ISO-8859-15\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: src/pv/watchpid.c:51 src/pv/watchpid.c:66 src/pv/watchpid.c:76
#: src/pv/watchpid.c:107 src/pv/loop.c:519 src/pv/loop.c:580 src/pv/loop.c:632
msgid "pid"
msgstr ""
#: src/pv/watchpid.c:68 src/pv/watchpid.c:78 src/pv/watchpid.c:109
msgid "fd"
msgstr ""
#: src/pv/watchpid.c:112
msgid "not a regular file or block device"
msgstr ""
#: src/pv/cursor.c:53
#, fuzzy
#: src/pv/cursor.c:85
msgid "failed to get terminal name"
msgstr "erro abrindo o terminal"
msgstr "erro ao ler o nome do terminal"
#: src/pv/cursor.c:96
#, fuzzy
#: src/pv/cursor.c:117
msgid "failed to open lock file"
msgstr "erro fechando o arquivo"
msgstr "erro ao abrir arquivo de bloqueio"
#: src/pv/cursor.c:129
#: src/pv/cursor.c:150
msgid "lock attempt failed"
msgstr ""
msgstr "tentativa de bloqueio falhou"
#: src/pv/cursor.c:369
#: src/pv/cursor.c:391
msgid "failed to open terminal"
msgstr "erro abrindo o terminal"
#: src/pv/file.c:118
#, fuzzy
#: src/pv/file.c:119
msgid "failed to seek to start of output"
msgstr "erro obtendo informações do arquivo de saída"
msgstr "não pode mover para o início da produção"
#: src/pv/file.c:214
#: src/pv/file.c:210
msgid "failed to close file"
msgstr "erro fechando o arquivo"
#: src/pv/file.c:237
#: src/pv/file.c:232
msgid "failed to read file"
msgstr "erro lendo o arquivo"
#: src/pv/file.c:247
#: src/pv/file.c:239 src/main/options.c:284
msgid "failed to stat file"
msgstr "erro obtendo informações do arquivo"
msgstr "erro obtendo informações do arquivo"
#: src/pv/file.c:256
#: src/pv/file.c:246
msgid "failed to stat output file"
msgstr "erro obtendo informações do arquivo de saída"
msgstr "erro obtendo informações do arquivo de saída"
#: src/pv/file.c:279
#: src/pv/file.c:268
msgid "input file is output file"
msgstr "os arquivos de entrada e saída são o mesmo"
msgstr "os arquivos de entrada e saída são o mesmo"
#: src/pv/display.c:117
msgid "yzafpnum kMGTPEZY"
msgstr ""
#: src/pv/display.c:122
msgid "yzafpnum KMGTPEZY"
msgstr ""
#: src/pv/display.c:532 src/pv/transfer.c:679
msgid "buffer allocation failed"
msgstr "erro alocando o buffer"
#: src/pv/display.c:592 src/pv/transfer.c:458
msgid "B"
msgstr ""
#: src/pv/display.c:628 src/pv/display.c:636
msgid "/s"
msgstr ""
#: src/pv/display.c:628 src/pv/display.c:636
msgid "B/s"
msgstr "B/s"
#: src/pv/display.c:671 src/pv/display.c:676 src/pv/display.c:738
msgid "ETA"
msgstr "ETA"
#: src/pv/transfer.c:341
#: src/pv/transfer.c:359
msgid "read failed"
msgstr "erro de leitura"
#: src/pv/transfer.c:359
msgid "warning: read errors detected"
msgstr ""
#: src/pv/transfer.c:374
msgid "warning: read errors detected"
msgstr "aviso: erros de leitura detectados"
#: src/pv/transfer.c:386
msgid "file is not seekable"
msgstr ""
msgstr "não pode mover dentro do arquivo"
#: src/pv/transfer.c:437
#, fuzzy
#: src/pv/transfer.c:445
msgid "failed to seek past error"
msgstr "erro obtendo informações do arquivo"
msgstr "não pode ir além do erro"
#: src/pv/transfer.c:456
#: src/pv/transfer.c:461
msgid "skipped past read error"
msgstr "ignorado erro de leitura"
#: src/pv/transfer.c:461 src/pv/display.c:660
msgid "B"
msgstr ""
#: src/pv/transfer.c:631
#: src/pv/transfer.c:617
msgid "write failed"
msgstr "erro de gravação"
msgstr "erro de gravação"
#: src/pv/transfer.c:770
#: src/pv/transfer.c:736 src/pv/display.c:594
msgid "buffer allocation failed"
msgstr "erro alocando o buffer"
#.
#. * Any other error is a problem and we must report back.
#.
#: src/pv/transfer.c:833
msgid "select call failed"
msgstr "erro na chamada da função select"
msgstr "erro na chamada da função select"
#: src/pv/state.c:33
#: src/pv/watchpid.c:73 src/pv/watchpid.c:83 src/pv/watchpid.c:94
#: src/pv/watchpid.c:102 src/pv/watchpid.c:139 src/pv/watchpid.c:150
#: src/pv/watchpid.c:158 src/pv/watchpid.c:169 src/pv/watchpid.c:253
#: src/pv/watchpid.c:261 src/pv/watchpid.c:292 src/pv/watchpid.c:312
#: src/pv/loop.c:506 src/pv/loop.c:558 src/pv/loop.c:602
msgid "pid"
msgstr ""
#: src/pv/watchpid.c:83 src/pv/watchpid.c:95 src/pv/watchpid.c:104
#: src/pv/watchpid.c:150 src/pv/watchpid.c:159 src/pv/watchpid.c:171
msgid "fd"
msgstr ""
#: src/pv/watchpid.c:104 src/pv/watchpid.c:171
msgid "not a regular file or block device"
msgstr "não é um arquivo regular ou dispositivo de bloqueio"
#: src/pv/state.c:30
msgid "history structure allocation failed"
msgstr ""
#: src/pv/state.c:59
msgid "none"
msgstr ""
#: src/main/version.c:17
#, fuzzy, c-format
msgid "%s %s - Copyright %s %s"
msgstr "%s %s - Copyright(C) %s %s"
#: src/main/version.c:20
#, c-format
msgid "Web site: %s"
msgstr "Site: %s"
#: 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:159
msgid "yzafpnum kMGTPEZY"
msgstr ""
"Este programa é um software livre, distribuído sob os termos da\n"
"Licença Artística."
#: src/pv/display.c:164
msgid "yzafpnum KMGTPEZY"
msgstr ""
#: src/pv/display.c:656
msgid "b"
msgstr ""
#: src/pv/display.c:711 src/pv/display.c:722
msgid "b/s"
msgstr ""
#: src/pv/display.c:714 src/pv/display.c:726
msgid "/s"
msgstr ""
#: src/pv/display.c:714 src/pv/display.c:726
msgid "B/s"
msgstr "B/s"
#: src/pv/display.c:762 src/pv/display.c:766 src/pv/display.c:825
msgid "ETA"
msgstr "ETA"
#. GNU standard license line and free software notice
#: 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."
msgstr ""
"Este programa é distribuído com o intuito de que seja útil,\n"
"porém SEM QUAISQUER GARANTIAS; sem inclusive as garantias implícitas de\n"
"COMERCIALIZAÇÃO e ADEQUAÇÃO A OBJETIVOS PARTICULARES."
#: src/main/main.c:73
#, fuzzy
msgid "state allocation failed"
msgstr "erro alocando o buffer"
#: src/main/options.c:98
#, c-format
msgid "%s: option structure allocation failed (%s)"
msgstr "%s: erro na alocação da estrutura de opções (%s)"
#: src/main/options.c:114
#, c-format
msgid "%s: option structure argv allocation failed (%s)"
msgstr "%s: erro na alocação da estrutura de opções argv (%s)"
#: src/main/options.c:154
msgid "integer argument expected"
msgid "License: Artistic v2.0 <https://opensource.org/license/artistic-2-0/>"
msgstr ""
#: src/main/options.c:165
msgid "numeric argument expected"
#: src/main/version.c:29
msgid "This is free software: you are free to change and redistribute it."
msgstr ""
#: src/main/options.c:176
msgid "process ID or pid:fd pair expected"
#: src/main/version.c:30
msgid "There is NO WARRANTY, to the extent permitted by law."
msgstr ""
#: src/main/options.c:183
msgid "invalid process ID"
#. Project web site link
#: src/main/version.c:32
msgid "Project web site"
msgstr ""
#: src/main/options.c:317
#, c-format
msgid "Try `%s --help' for more information."
msgstr "Tente `%s --help' para maiores informações."
#: src/main/options.c:321
#, fuzzy, c-format
msgid "Try `%s -h' for more information."
msgstr "Tente `%s -h' para maiores informações."
#: src/main/options.c:338
#, c-format
msgid ""
"%s: cannot use line mode or transfer modifier options when watching file "
"descriptors"
msgstr ""
#: src/main/options.c:348
#, c-format
msgid "%s: cannot use cursor positioning when watching file descriptors"
msgstr ""
#: src/main/options.c:358
#, c-format
msgid "%s: cannot use remote control when watching file descriptors"
msgstr ""
#: src/main/options.c:368
#, c-format
msgid "%s: cannot transfer files when watching file descriptors"
msgstr ""
#: src/main/options.c:378
#, c-format
msgid "%s: -d: not available on systems without /proc/self/fdinfo"
msgstr ""
#: src/main/remote.c:218
#: src/main/remote.c:215
msgid "message not received"
msgstr ""
msgstr "mensagem não recebida"
#: src/main/remote.c:324
#: src/main/remote.c:318
msgid "IPC not supported on this system"
msgstr ""
msgstr "IPC não suportado neste sistema"
#: src/main/help.c:31
#: src/main/help.c:283
msgid "show progress bar"
msgstr "exibe barra de progressão"
msgstr "exibe barra de progressão"
#: src/main/help.c:33
#: src/main/help.c:286
msgid "show elapsed time"
msgstr "exibe tempo passado"
#: src/main/help.c:35
#: src/main/help.c:289
msgid "show estimated time of arrival (completion)"
msgstr "exibe o tempo estimado de término"
msgstr "exibe o tempo estimado de término"
#: src/main/help.c:38
#, fuzzy
#: src/main/help.c:292
msgid "show absolute estimated time of arrival (completion)"
msgstr "exibe o tempo estimado de término"
msgstr "exibe o tempo absoluto estimado de término"
#: src/main/help.c:40
#: src/main/help.c:295
msgid "show data transfer rate counter"
msgstr "exibe a taxa de transferência"
msgstr "exibe a taxa de transferência"
#: src/main/help.c:42
#: src/main/help.c:298
msgid "show data transfer average rate counter"
msgstr ""
msgstr "exibe o contador da taxa média de transferência de dados"
#: src/main/help.c:44
msgid "show number of bytes transferred"
msgstr "exibe a quantidade de bytes transferidos"
#: src/main/help.c:46
msgid "show percentage of transfer buffer in use"
msgstr ""
#: src/main/help.c:47
msgid "NUM"
msgstr ""
#: src/main/help.c:48
msgid "show NUM bytes last written"
msgstr ""
#: src/main/help.c:49
msgid "FORMAT"
msgstr ""
#: src/main/help.c:50
msgid "set output format to FORMAT"
msgstr ""
#: src/main/help.c:52
msgid "output percentages, not visual information"
msgstr "exibe apenas as porcentagens, sem informações visuais"
#: src/main/help.c:54
msgid "do not output any transfer information at all"
msgstr "executa programa sem exibir quaisquer informações"
#: src/main/help.c:57
msgid "display nothing until first byte transferred"
msgstr "não exibe nada até iniciar o processamento"
#: src/main/help.c:58 src/main/help.c:66
#: src/main/help.c:300 src/main/help.c:328 src/main/help.c:340
msgid "SEC"
msgstr ""
#: src/main/help.c:59
#, fuzzy
msgid "display nothing until SEC seconds have passed"
msgstr "não exibe nada até iniciar o processamento"
#: src/main/help.c:301
msgid "compute average rate over past SEC seconds (default 30s)"
msgstr ""
#: src/main/help.c:60
#: src/main/help.c:304
msgid "show number of bytes transferred"
msgstr "exibe a quantidade de bytes transferidos"
#: src/main/help.c:307
msgid "show number of bits transferred"
msgstr ""
#: src/main/help.c:310
msgid "show percentage of transfer buffer in use"
msgstr "exibe a porcentagem de buffer de transferência em uso"
#: src/main/help.c:312
msgid "NUM"
msgstr ""
#: src/main/help.c:313
msgid "show NUM bytes last written"
msgstr "exibe NUM bytes gravados pela última vez"
#: src/main/help.c:315
msgid "FORMAT"
msgstr ""
#: src/main/help.c:316
msgid "set output format to FORMAT"
msgstr "definir o formato de saída para FORMAT"
#: src/main/help.c:319
msgid "output percentages, not visual information"
msgstr "exibe apenas as porcentagens, sem informações visuais"
#: src/main/help.c:322
msgid "do not output any transfer information at all"
msgstr "executa programa sem exibir quaisquer informações"
#: src/main/help.c:326
msgid "display nothing until first byte transferred"
msgstr "não exibe nada até iniciar o processamento"
#: src/main/help.c:329
msgid "display nothing until SEC seconds have passed"
msgstr "não exibir nada até que os segundos SEC tenham passado"
#: src/main/help.c:331
msgid "SIZE"
msgstr ""
#: src/main/help.c:61
#: src/main/help.c:332
msgid "set estimated data size to SIZE bytes"
msgstr "seta a quantidade estimada de dados em SIZE bytes"
#: src/main/help.c:63
#: src/main/help.c:335
msgid "count lines instead of bytes"
msgstr ""
msgstr "contar linhas em vez de bytes"
#: src/main/help.c:65
#: src/main/help.c:338
msgid "lines are null-terminated"
msgstr ""
msgstr "linhas são terminadas em nulo"
#: src/main/help.c:67
#: src/main/help.c:341
msgid "update every SEC seconds"
msgstr "atualiza informações a cada SEC segundos"
msgstr "atualiza informações a cada SEC segundos"
#: src/main/help.c:68
#: src/main/help.c:343
msgid "WIDTH"
msgstr ""
#: src/main/help.c:69
#: src/main/help.c:344
msgid "assume terminal is WIDTH characters wide"
msgstr "assume que terminal possui WIDTH caracteres de largura"
msgstr "presuma que o terminal tem WIDTH caracteres de largura"
#: src/main/help.c:70
#: src/main/help.c:346
msgid "HEIGHT"
msgstr ""
#: src/main/help.c:71
#: src/main/help.c:347
msgid "assume terminal is HEIGHT rows high"
msgstr "assume que terminal possui WIDTH caracteres de largura"
msgstr "presuma que o terminal tem HEIGHT caracteres de altura"
#: src/main/help.c:72
#: src/main/help.c:349
msgid "NAME"
msgstr ""
#: src/main/help.c:73
#: src/main/help.c:350
msgid "prefix visual information with NAME"
msgstr "exibe NAME antes das demais informações"
msgstr "exibe NAME antes das demais informações"
#: src/main/help.c:75
#: src/main/help.c:353
msgid "output even if standard error is not a terminal"
msgstr "gera dados mesmo que a saída de erro seja redirecionada"
msgstr "gera dados mesmo que a saída de erro seja redirecionada"
#: src/main/help.c:77
#: src/main/help.c:356
msgid "use cursor positioning escape sequences"
msgstr "utiliza caracteres de escape para posicionar o cursor"
#: src/main/help.c:79
#: src/main/help.c:359
msgid "RATE"
msgstr ""
#: src/main/help.c:80
#: src/main/help.c:360
msgid "limit transfer to RATE bytes per second"
msgstr "limita a transferência a RATE bytes por segundo"
msgstr "limita a transferência a RATE bytes por segundo"
#: src/main/help.c:81
#: src/main/help.c:362
msgid "BYTES"
msgstr ""
#: src/main/help.c:82
#: src/main/help.c:363
msgid "use a buffer size of BYTES"
msgstr ""
msgstr "use um tamanho de buffer de BYTES"
#: src/main/help.c:84
#: src/main/help.c:366
msgid "never use splice(), always use read/write"
msgstr ""
msgstr "nunca use splice(), sempre use read/write"
#: src/main/help.c:86
#: src/main/help.c:369
msgid "skip read errors in input"
msgstr "ignorar erros de leitura em entrada"
#: src/main/help.c:372
msgid "stop after --size bytes have been transferred"
msgstr "parar após --size bytes terem sido transferidos"
#: src/main/help.c:375
msgid "flush cache to disk after every write"
msgstr ""
#: src/main/help.c:88
#, fuzzy
msgid "stop after --size bytes have been transferred"
msgstr "exibe a quantidade de bytes transferidos"
#: src/main/help.c:378
msgid "use direct I/O to bypass cache"
msgstr ""
#: src/main/help.c:90
#: src/main/help.c:381
msgid "PID"
msgstr ""
#: src/main/help.c:91
#: src/main/help.c:382
msgid "update settings of process PID"
msgstr ""
msgstr "atualizar as configurações do processo PID"
#: src/main/help.c:94
#: src/main/help.c:386 src/main/help.c:401
msgid "FILE"
msgstr ""
#: src/main/help.c:95
#: src/main/help.c:387
msgid "save process ID in FILE"
msgstr ""
msgstr "salvar ID do processo em FILE"
#: src/main/help.c:97
#: src/main/help.c:390
msgid "PID[:FD]"
msgstr ""
#: src/main/help.c:98
#: src/main/help.c:391
msgid "watch file FD opened by process PID"
msgstr ""
msgstr "assistir arquivo FD aberto pelo processo PID"
#: src/main/help.c:101
#: src/main/help.c:395
msgid "show this help and exit"
msgstr "exibe esta tela de ajuda e termina"
#: src/main/help.c:103
#: src/main/help.c:398
msgid "show version information and exit"
msgstr "exibe a versão e termina"
msgstr "exibe a versão e termina"
#: src/main/help.c:109
#: src/main/help.c:402
msgid "write debug logs to FILE"
msgstr ""
#. @-formatconst@
#.
#. * splint note: unavoidable use of %s in translated string. Should
#. * be hard to exploit - the message catalogue would have to be
#. * replaced or forced to load from another location.
#.
#: src/main/help.c:427
#, c-format
msgid "Usage: %s [OPTION] [FILE]..."
msgstr "Uso: %s [OPÇÕES] [ARQUIVOS]..."
msgstr "Uso: %s [OPÇÕES] [ARQUIVOS]..."
#: src/main/help.c:112
#. @-mustfreefresh@
#.
#. * splint note: the gettext calls made by _() cause memory leak
#. * warnings, but in this case it's unavoidable, and mitigated by the
#. * fact we only translate each string once.
#.
#: src/main/help.c:438
msgid ""
"Concatenate FILE(s), or standard input, to standard output,\n"
"with monitoring."
"Concatenate FILE(s), or standard input, to standard output, with monitoring."
msgstr ""
"Concatena ARQUIVO(s) ou a entrada padrão e grava na saída padrão,\n"
"com monitoramento."
"Concatena ARQUIVO(s) ou a entrada padrão e grava na saída padrão, com "
"monitoramento."
#: src/main/help.c:201
msgid ""
"Debugging is enabled; export the DEBUG environment variable to define the\n"
"output filename.\n"
msgstr ""
#: src/main/help.c:205
#: src/main/help.c:575
#, c-format
msgid "Please report any bugs to %s."
msgstr "Por favor, reporte quaisquer defeitos para %s."
#~ msgid "failed to lock terminal"
#~ msgstr "erro abrindo o terminal"
#: src/main/main.c:75
msgid "state allocation failed"
msgstr "alocação de memória de status falhou"
#: src/main/main.c:243
msgid "failed to read terminal attributes"
msgstr ""
#: src/main/options.c:111
msgid "option structure allocation failed"
msgstr "erro na alocação da estrutura de opções"
#: src/main/options.c:124
msgid "option structure argv allocation failed"
msgstr "erro na alocação da estrutura de opções argv"
#: src/main/options.c:163
msgid "integer argument expected"
msgstr "argumento inteiro esperado"
#: src/main/options.c:171
msgid "numeric argument expected"
msgstr "argumento numérico esperado"
#: src/main/options.c:180
msgid "process ID or pid:fd pair expected"
msgstr "ID do processo ou par pid:fd esperado"
#: src/main/options.c:185
msgid "invalid process ID"
msgstr "ID de processo inválido"
#: src/main/options.c:358
#, c-format
msgid "Try `%s --help' for more information."
msgstr "Tente `%s --help' para maiores informações."
#: src/main/options.c:360
#, c-format
msgid "Try `%s -h' for more information."
msgstr "Tente `%s -h' para maiores informações."
#: src/main/options.c:374
msgid ""
"cannot use line mode or transfer modifier options when watching file "
"descriptors"
msgstr ""
"não pode usar o modo de linha ou opções de modificador de transferência ao "
"assistir os descritores de arquivo"
#: src/main/options.c:381
msgid "cannot use cursor positioning when watching file descriptors"
msgstr ""
"não pode usar o posicionamento do cursor ao observar os descritores de "
"arquivo"
#: src/main/options.c:388
msgid "cannot use remote control when watching file descriptors"
msgstr "não pode usar o controle remoto ao assistir os descritores de arquivo"
#: src/main/options.c:395
msgid "cannot transfer files when watching file descriptors"
msgstr "não pode transferir arquivos ao assistir descritores de arquivo"
#: src/main/options.c:402
msgid "not available on systems without /proc/self/fdinfo"
msgstr "não disponível em sistemas sem /proc/self/fdinfo"
#~ msgid ""
#~ "Debugging is enabled; export the DEBUG environment variable to define "
#~ "the\n"
#~ "output filename.\n"
#~ msgstr ""
#~ "A depuração está habilitada; exporte a variável de ambiente DEBUG para\n"
#~ "definir o nome do arquivo de saída.\n"
#~ msgid "%s %s - Copyright %s %s"
#~ msgstr "%s %s - Copyright(C) %s %s"
#~ msgid "Web site: %s"
#~ msgstr "Site: %s"
#~ msgid ""
#~ "This program is free software, and is being distributed under the\n"
#~ "terms of the Artistic License 2.0."
#~ msgstr ""
#~ "Este programa é um software livre, distribuído sob os termos da\n"
#~ "Licença Artística."
#~ 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."
#~ msgstr ""
#~ "Este programa é distribuído com o intuito de que seja útil,\n"
#~ "porém SEM QUAISQUER GARANTIAS; sem inclusive as garantias implícitas de\n"
#~ "COMERCIALIZAÇÃO e ADEQUAÇÃO A OBJETIVOS PARTICULARES."
+257 -220
View File
@@ -8,423 +8,460 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-06-30 22:21+0100\n"
"POT-Creation-Date: 2023-07-30 19:07+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"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
#: src/pv/watchpid.c:51 src/pv/watchpid.c:66 src/pv/watchpid.c:76
#: src/pv/watchpid.c:107 src/pv/loop.c:519 src/pv/loop.c:580 src/pv/loop.c:632
msgid "pid"
msgstr ""
#: src/pv/watchpid.c:68 src/pv/watchpid.c:78 src/pv/watchpid.c:109
msgid "fd"
msgstr ""
#: src/pv/watchpid.c:112
msgid "not a regular file or block device"
msgstr ""
#: src/pv/cursor.c:53
#: src/pv/cursor.c:85
msgid "failed to get terminal name"
msgstr ""
#: src/pv/cursor.c:96
#: src/pv/cursor.c:117
msgid "failed to open lock file"
msgstr ""
#: src/pv/cursor.c:129
#: src/pv/cursor.c:150
msgid "lock attempt failed"
msgstr ""
#: src/pv/cursor.c:369
#: src/pv/cursor.c:391
msgid "failed to open terminal"
msgstr ""
#: src/pv/file.c:118
#: src/pv/file.c:119
msgid "failed to seek to start of output"
msgstr ""
#: src/pv/file.c:214
#: src/pv/file.c:210
msgid "failed to close file"
msgstr ""
#: src/pv/file.c:237
#: src/pv/file.c:232
msgid "failed to read file"
msgstr ""
#: src/pv/file.c:247
#: src/pv/file.c:239 src/main/options.c:284
msgid "failed to stat file"
msgstr ""
#: src/pv/file.c:256
#: src/pv/file.c:246
msgid "failed to stat output file"
msgstr ""
#: src/pv/file.c:279
#: src/pv/file.c:268
msgid "input file is output file"
msgstr ""
#: src/pv/display.c:117
msgid "yzafpnum kMGTPEZY"
msgstr ""
#: src/pv/display.c:122
msgid "yzafpnum KMGTPEZY"
msgstr ""
#: src/pv/display.c:532 src/pv/transfer.c:679
msgid "buffer allocation failed"
msgstr ""
#: src/pv/display.c:592 src/pv/transfer.c:458
msgid "B"
msgstr ""
#: src/pv/display.c:628 src/pv/display.c:636
msgid "/s"
msgstr ""
#: src/pv/display.c:628 src/pv/display.c:636
msgid "B/s"
msgstr ""
#: src/pv/display.c:671 src/pv/display.c:676 src/pv/display.c:738
msgid "ETA"
msgstr ""
#: src/pv/transfer.c:341
#: src/pv/transfer.c:359
msgid "read failed"
msgstr ""
#: src/pv/transfer.c:359
#: src/pv/transfer.c:374
msgid "warning: read errors detected"
msgstr ""
#: src/pv/transfer.c:374
#: src/pv/transfer.c:386
msgid "file is not seekable"
msgstr ""
#: src/pv/transfer.c:437
#: src/pv/transfer.c:445
msgid "failed to seek past error"
msgstr ""
#: src/pv/transfer.c:456
#: src/pv/transfer.c:461
msgid "skipped past read error"
msgstr ""
#: src/pv/transfer.c:631
#: src/pv/transfer.c:461 src/pv/display.c:660
msgid "B"
msgstr ""
#: src/pv/transfer.c:617
msgid "write failed"
msgstr ""
#: src/pv/transfer.c:770
#: src/pv/transfer.c:736 src/pv/display.c:594
msgid "buffer allocation failed"
msgstr ""
#.
#. * Any other error is a problem and we must report back.
#.
#: src/pv/transfer.c:833
msgid "select call failed"
msgstr ""
#: src/pv/state.c:33
#: src/pv/watchpid.c:73 src/pv/watchpid.c:83 src/pv/watchpid.c:94
#: src/pv/watchpid.c:102 src/pv/watchpid.c:139 src/pv/watchpid.c:150
#: src/pv/watchpid.c:158 src/pv/watchpid.c:169 src/pv/watchpid.c:253
#: src/pv/watchpid.c:261 src/pv/watchpid.c:292 src/pv/watchpid.c:312
#: src/pv/loop.c:506 src/pv/loop.c:558 src/pv/loop.c:602
msgid "pid"
msgstr ""
#: src/pv/watchpid.c:83 src/pv/watchpid.c:95 src/pv/watchpid.c:104
#: src/pv/watchpid.c:150 src/pv/watchpid.c:159 src/pv/watchpid.c:171
msgid "fd"
msgstr ""
#: src/pv/watchpid.c:104 src/pv/watchpid.c:171
msgid "not a regular file or block device"
msgstr ""
#: src/pv/state.c:30
msgid "history structure allocation failed"
msgstr ""
#: src/pv/state.c:59
msgid "none"
msgstr ""
#: src/main/version.c:17
#, c-format
msgid "%s %s - Copyright %s %s"
#: src/pv/display.c:159
msgid "yzafpnum kMGTPEZY"
msgstr ""
#: src/main/version.c:20
#, c-format
msgid "Web site: %s"
#: src/pv/display.c:164
msgid "yzafpnum KMGTPEZY"
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:656
msgid "b"
msgstr ""
#: src/pv/display.c:711 src/pv/display.c:722
msgid "b/s"
msgstr ""
#: src/pv/display.c:714 src/pv/display.c:726
msgid "/s"
msgstr ""
#: src/pv/display.c:714 src/pv/display.c:726
msgid "B/s"
msgstr ""
#: src/pv/display.c:762 src/pv/display.c:766 src/pv/display.c:825
msgid "ETA"
msgstr ""
#. GNU standard license line and free software notice
#: 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."
msgid "License: Artistic v2.0 <https://opensource.org/license/artistic-2-0/>"
msgstr ""
#: src/main/main.c:73
msgid "state allocation failed"
#: src/main/version.c:29
msgid "This is free software: you are free to change and redistribute it."
msgstr ""
#: src/main/options.c:98
#, c-format
msgid "%s: option structure allocation failed (%s)"
#: src/main/version.c:30
msgid "There is NO WARRANTY, to the extent permitted by law."
msgstr ""
#: src/main/options.c:114
#, c-format
msgid "%s: option structure argv allocation failed (%s)"
#. Project web site link
#: src/main/version.c:32
msgid "Project web site"
msgstr ""
#: src/main/options.c:154
msgid "integer argument expected"
msgstr ""
#: src/main/options.c:165
msgid "numeric argument expected"
msgstr ""
#: src/main/options.c:176
msgid "process ID or pid:fd pair expected"
msgstr ""
#: src/main/options.c:183
msgid "invalid process ID"
msgstr ""
#: src/main/options.c:317
#, c-format
msgid "Try `%s --help' for more information."
msgstr ""
#: src/main/options.c:321
#, c-format
msgid "Try `%s -h' for more information."
msgstr ""
#: src/main/options.c:338
#, c-format
msgid ""
"%s: cannot use line mode or transfer modifier options when watching file "
"descriptors"
msgstr ""
#: src/main/options.c:348
#, c-format
msgid "%s: cannot use cursor positioning when watching file descriptors"
msgstr ""
#: src/main/options.c:358
#, c-format
msgid "%s: cannot use remote control when watching file descriptors"
msgstr ""
#: src/main/options.c:368
#, c-format
msgid "%s: cannot transfer files when watching file descriptors"
msgstr ""
#: src/main/options.c:378
#, c-format
msgid "%s: -d: not available on systems without /proc/self/fdinfo"
msgstr ""
#: src/main/remote.c:218
#: src/main/remote.c:215
msgid "message not received"
msgstr ""
#: src/main/remote.c:324
#: src/main/remote.c:318
msgid "IPC not supported on this system"
msgstr ""
#: src/main/help.c:31
#: src/main/help.c:283
msgid "show progress bar"
msgstr ""
#: src/main/help.c:33
#: src/main/help.c:286
msgid "show elapsed time"
msgstr ""
#: src/main/help.c:35
#: src/main/help.c:289
msgid "show estimated time of arrival (completion)"
msgstr ""
#: src/main/help.c:38
#: src/main/help.c:292
msgid "show absolute estimated time of arrival (completion)"
msgstr ""
#: src/main/help.c:40
#: src/main/help.c:295
msgid "show data transfer rate counter"
msgstr ""
#: src/main/help.c:42
#: src/main/help.c:298
msgid "show data transfer average rate counter"
msgstr ""
#: src/main/help.c:44
msgid "show number of bytes transferred"
msgstr ""
#: src/main/help.c:46
msgid "show percentage of transfer buffer in use"
msgstr ""
#: src/main/help.c:47
msgid "NUM"
msgstr ""
#: src/main/help.c:48
msgid "show NUM bytes last written"
msgstr ""
#: src/main/help.c:49
msgid "FORMAT"
msgstr ""
#: src/main/help.c:50
msgid "set output format to FORMAT"
msgstr ""
#: src/main/help.c:52
msgid "output percentages, not visual information"
msgstr ""
#: src/main/help.c:54
msgid "do not output any transfer information at all"
msgstr ""
#: src/main/help.c:57
msgid "display nothing until first byte transferred"
msgstr ""
#: src/main/help.c:58 src/main/help.c:66
#: src/main/help.c:300 src/main/help.c:328 src/main/help.c:340
msgid "SEC"
msgstr ""
#: src/main/help.c:59
#: src/main/help.c:301
msgid "compute average rate over past SEC seconds (default 30s)"
msgstr ""
#: src/main/help.c:304
msgid "show number of bytes transferred"
msgstr ""
#: src/main/help.c:307
msgid "show number of bits transferred"
msgstr ""
#: src/main/help.c:310
msgid "show percentage of transfer buffer in use"
msgstr ""
#: src/main/help.c:312
msgid "NUM"
msgstr ""
#: src/main/help.c:313
msgid "show NUM bytes last written"
msgstr ""
#: src/main/help.c:315
msgid "FORMAT"
msgstr ""
#: src/main/help.c:316
msgid "set output format to FORMAT"
msgstr ""
#: src/main/help.c:319
msgid "output percentages, not visual information"
msgstr ""
#: src/main/help.c:322
msgid "do not output any transfer information at all"
msgstr ""
#: src/main/help.c:326
msgid "display nothing until first byte transferred"
msgstr ""
#: src/main/help.c:329
msgid "display nothing until SEC seconds have passed"
msgstr ""
#: src/main/help.c:60
#: src/main/help.c:331
msgid "SIZE"
msgstr ""
#: src/main/help.c:61
#: src/main/help.c:332
msgid "set estimated data size to SIZE bytes"
msgstr ""
#: src/main/help.c:63
#: src/main/help.c:335
msgid "count lines instead of bytes"
msgstr ""
#: src/main/help.c:65
#: src/main/help.c:338
msgid "lines are null-terminated"
msgstr ""
#: src/main/help.c:67
#: src/main/help.c:341
msgid "update every SEC seconds"
msgstr ""
#: src/main/help.c:68
#: src/main/help.c:343
msgid "WIDTH"
msgstr ""
#: src/main/help.c:69
#: src/main/help.c:344
msgid "assume terminal is WIDTH characters wide"
msgstr ""
#: src/main/help.c:70
#: src/main/help.c:346
msgid "HEIGHT"
msgstr ""
#: src/main/help.c:71
#: src/main/help.c:347
msgid "assume terminal is HEIGHT rows high"
msgstr ""
#: src/main/help.c:72
#: src/main/help.c:349
msgid "NAME"
msgstr ""
#: src/main/help.c:73
#: src/main/help.c:350
msgid "prefix visual information with NAME"
msgstr ""
#: src/main/help.c:75
#: src/main/help.c:353
msgid "output even if standard error is not a terminal"
msgstr ""
#: src/main/help.c:77
#: src/main/help.c:356
msgid "use cursor positioning escape sequences"
msgstr ""
#: src/main/help.c:79
#: src/main/help.c:359
msgid "RATE"
msgstr ""
#: src/main/help.c:80
#: src/main/help.c:360
msgid "limit transfer to RATE bytes per second"
msgstr ""
#: src/main/help.c:81
#: src/main/help.c:362
msgid "BYTES"
msgstr ""
#: src/main/help.c:82
#: src/main/help.c:363
msgid "use a buffer size of BYTES"
msgstr ""
#: src/main/help.c:84
#: src/main/help.c:366
msgid "never use splice(), always use read/write"
msgstr ""
#: src/main/help.c:86
#: src/main/help.c:369
msgid "skip read errors in input"
msgstr ""
#: src/main/help.c:88
#: src/main/help.c:372
msgid "stop after --size bytes have been transferred"
msgstr ""
#: src/main/help.c:90
#: src/main/help.c:375
msgid "flush cache to disk after every write"
msgstr ""
#: src/main/help.c:378
msgid "use direct I/O to bypass cache"
msgstr ""
#: src/main/help.c:381
msgid "PID"
msgstr ""
#: src/main/help.c:91
#: src/main/help.c:382
msgid "update settings of process PID"
msgstr ""
#: src/main/help.c:94
#: src/main/help.c:386 src/main/help.c:401
msgid "FILE"
msgstr ""
#: src/main/help.c:95
#: src/main/help.c:387
msgid "save process ID in FILE"
msgstr ""
#: src/main/help.c:97
#: src/main/help.c:390
msgid "PID[:FD]"
msgstr ""
#: src/main/help.c:98
#: src/main/help.c:391
msgid "watch file FD opened by process PID"
msgstr ""
#: src/main/help.c:101
#: src/main/help.c:395
msgid "show this help and exit"
msgstr ""
#: src/main/help.c:103
#: src/main/help.c:398
msgid "show version information and exit"
msgstr ""
#: src/main/help.c:109
#: src/main/help.c:402
msgid "write debug logs to FILE"
msgstr ""
#. @-formatconst@
#.
#. * splint note: unavoidable use of %s in translated string. Should
#. * be hard to exploit - the message catalogue would have to be
#. * replaced or forced to load from another location.
#.
#: src/main/help.c:427
#, c-format
msgid "Usage: %s [OPTION] [FILE]..."
msgstr ""
#: src/main/help.c:112
#. @-mustfreefresh@
#.
#. * splint note: the gettext calls made by _() cause memory leak
#. * warnings, but in this case it's unavoidable, and mitigated by the
#. * fact we only translate each string once.
#.
#: src/main/help.c:438
msgid ""
"Concatenate FILE(s), or standard input, to standard output,\n"
"with monitoring."
"Concatenate FILE(s), or standard input, to standard output, with monitoring."
msgstr ""
#: src/main/help.c:201
msgid ""
"Debugging is enabled; export the DEBUG environment variable to define the\n"
"output filename.\n"
msgstr ""
#: src/main/help.c:205
#: src/main/help.c:575
#, c-format
msgid "Please report any bugs to %s."
msgstr ""
#: src/main/main.c:75
msgid "state allocation failed"
msgstr ""
#: src/main/main.c:243
msgid "failed to read terminal attributes"
msgstr ""
#: src/main/options.c:111
msgid "option structure allocation failed"
msgstr ""
#: src/main/options.c:124
msgid "option structure argv allocation failed"
msgstr ""
#: src/main/options.c:163
msgid "integer argument expected"
msgstr ""
#: src/main/options.c:171
msgid "numeric argument expected"
msgstr ""
#: src/main/options.c:180
msgid "process ID or pid:fd pair expected"
msgstr ""
#: src/main/options.c:185
msgid "invalid process ID"
msgstr ""
#: src/main/options.c:358
#, c-format
msgid "Try `%s --help' for more information."
msgstr ""
#: src/main/options.c:360
#, c-format
msgid "Try `%s -h' for more information."
msgstr ""
#: src/main/options.c:374
msgid ""
"cannot use line mode or transfer modifier options when watching file "
"descriptors"
msgstr ""
#: src/main/options.c:381
msgid "cannot use cursor positioning when watching file descriptors"
msgstr ""
#: src/main/options.c:388
msgid "cannot use remote control when watching file descriptors"
msgstr ""
#: src/main/options.c:395
msgid "cannot transfer files when watching file descriptors"
msgstr ""
#: src/main/options.c:402
msgid "not available on systems without /proc/self/fdinfo"
msgstr ""
+102 -79
View File
@@ -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>
@@ -21,6 +27,7 @@
#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <signal.h>
#ifdef HAVE_IPC
#include <sys/ipc.h>
@@ -34,6 +41,32 @@
#endif /* HAVE_IPC */
/*
* Write the given buffer to the given file descriptor, retrying until all
* bytes have been written or an error has occurred.
*/
void pv_write_retry(int fd, const char *buf, size_t count)
{
while (count > 0) {
ssize_t nwritten;
nwritten = write(fd, buf, count);
if (nwritten < 0) {
if ((EINTR == errno) || (EAGAIN == errno)) {
continue;
}
return;
}
if (nwritten < 1)
return;
count -= nwritten;
buf += nwritten;
}
}
/*
* Create a per-euid, per-tty, lockfile in ${TMPDIR:-${TMP:-/tmp}} for the
* tty on the given file descriptor.
@@ -49,17 +82,14 @@ static void pv_crs_open_lockfile(pvstate_t state, int fd)
ttydev = ttyname(fd);
if (!ttydev) {
if (!state->force) {
pv_error(state, "%s: %s",
_("failed to get terminal name"),
strerror(errno));
pv_error(state, "%s: %s", _("failed to get terminal name"), strerror(errno));
}
/*
* If we don't know our terminal name, we can neither do IPC
* nor make a lock file, so turn off cursor positioning.
*/
state->cursor = 0;
debug("%s",
"ttyname failed - cursor positioning disabled");
debug("%s", "ttyname failed - cursor positioning disabled");
return;
}
@@ -69,16 +99,9 @@ static void pv_crs_open_lockfile(pvstate_t state, int fd)
if (!tmpdir)
tmpdir = "/tmp";
#ifdef HAVE_SNPRINTF
snprintf(state->crs_lock_file, sizeof(state->crs_lock_file) - 1,
"%s/pv-%s-%i.lock", tmpdir, basename(ttydev),
(int) geteuid());
#else
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
@@ -91,9 +114,7 @@ static void pv_crs_open_lockfile(pvstate_t state, int fd)
state->crs_lock_fd = open(state->crs_lock_file, openflags, 0600);
if (state->crs_lock_fd < 0) {
pv_error(state, "%s: %s: %s",
state->crs_lock_file,
_("failed to open lock file"), strerror(errno));
pv_error(state, "%s: %s: %s", state->crs_lock_file, _("failed to open lock file"), strerror(errno));
state->cursor = 0;
return;
}
@@ -113,8 +134,9 @@ static void pv_crs_lock(pvstate_t state, int fd)
if (state->crs_lock_fd >= 0)
lock_fd = state->crs_lock_fd;
lock.l_type = F_WRLCK;
lock.l_whence = SEEK_SET;
memset(&lock, 0, sizeof(lock));
lock.l_type = (short) F_WRLCK;
lock.l_whence = (short) SEEK_SET;
lock.l_start = 0;
lock.l_len = 1;
while (fcntl(lock_fd, F_SETLKW, &lock) < 0) {
@@ -125,17 +147,14 @@ static void pv_crs_lock(pvstate_t state, int fd)
lock_fd = state->crs_lock_fd;
}
} else {
pv_error(state, "%s: %s",
_("lock attempt failed"),
strerror(errno));
pv_error(state, "%s: %s", _("lock attempt failed"), strerror(errno));
return;
}
}
}
if (state->crs_lock_fd >= 0) {
debug("%s: %s", state->crs_lock_file,
"terminal lockfile acquired");
debug("%s: %s", state->crs_lock_file, "terminal lockfile acquired");
} else {
debug("%s", "terminal lock acquired");
}
@@ -155,15 +174,15 @@ static void pv_crs_unlock(pvstate_t state, int fd)
if (state->crs_lock_fd >= 0)
lock_fd = state->crs_lock_fd;
lock.l_type = F_UNLCK;
lock.l_whence = SEEK_SET;
memset(&lock, 0, sizeof(lock));
lock.l_type = (short) F_UNLCK;
lock.l_whence = (short) SEEK_SET;
lock.l_start = 0;
lock.l_len = 1;
fcntl(lock_fd, F_SETLK, &lock);
(void) fcntl(lock_fd, F_SETLK, &lock);
if (state->crs_lock_fd >= 0) {
debug("%s: %s", state->crs_lock_file,
"terminal lockfile released");
debug("%s: %s", state->crs_lock_file, "terminal lockfile released");
} else {
debug("%s", "terminal lock released");
}
@@ -181,10 +200,11 @@ static void pv_crs_ipccount(pvstate_t state)
{
struct shmid_ds buf;
memset(&buf, 0, sizeof(buf));
buf.shm_nattch = 0;
shmctl(state->crs_shmid, IPC_STAT, &buf);
state->crs_pvcount = buf.shm_nattch;
(void) shmctl(state->crs_shmid, IPC_STAT, &buf);
state->crs_pvcount = (int) (buf.shm_nattch);
if (state->crs_pvcount > state->crs_pvmax)
state->crs_pvmax = state->crs_pvcount;
@@ -204,23 +224,29 @@ static int pv_crs_get_ypos(int terminalfd)
struct termios old_tty;
char cpr[32];
int ypos;
int r;
ssize_t r;
#ifdef CURSOR_ANSWERBACK_BYTE_BY_BYTE
int got;
#endif /* CURSOR_ANSWERBACK_BYTE_BY_BYTE */
tcgetattr(terminalfd, &tty);
tcgetattr(terminalfd, &old_tty);
if (0 != tcgetattr(terminalfd, &tty)) {
debug("%s: %s", "tcgetattr (1) failed", strerror(errno));
}
if (0 != tcgetattr(terminalfd, &old_tty)) {
debug("%s: %s", "tcgetattr (2) failed", strerror(errno));
}
tty.c_lflag &= ~(ICANON | ECHO);
tcsetattr(terminalfd, TCSANOW | TCSAFLUSH, &tty);
if (0 != tcsetattr(terminalfd, TCSANOW | TCSAFLUSH, &tty)) {
debug("%s: %s", "tcsetattr (1) failed", strerror(errno));
}
write(terminalfd, "\033[6n", 4);
pv_write_retry(terminalfd, "\033[6n", 4);
memset(cpr, 0, sizeof(cpr));
#ifdef CURSOR_ANSWERBACK_BYTE_BY_BYTE
/* Read answerback byte by byte - fails on AIX */
for (got = 0, r = 0; got < sizeof(cpr) - 2; got += r) {
for (got = 0, r = 0; got < (int) (sizeof(cpr) - 2); got += r) {
r = read(terminalfd, cpr + got, 1);
if (r <= 0) {
debug("got=%d, r=%d: %s", got, r, strerror(errno));
@@ -232,8 +258,7 @@ static int pv_crs_get_ypos(int terminalfd)
debug
("read answerback message from fd %d, length %d - buf = %02X %02X %02X %02X %02X %02X",
terminalfd, got, cpr[0], cpr[1], cpr[2], cpr[3], cpr[4],
cpr[5]);
terminalfd, got, cpr[0], cpr[1], cpr[2], cpr[3], cpr[4], cpr[5]);
#else /* !CURSOR_ANSWERBACK_BYTE_BY_BYTE */
/* Read answerback in one big lump - may fail on Solaris */
@@ -243,15 +268,16 @@ static int pv_crs_get_ypos(int terminalfd)
} else {
debug
("read answerback message from fd %d, length %d - buf = %02X %02X %02X %02X %02X %02X",
terminalfd, r, cpr[0], cpr[1], cpr[2], cpr[3], cpr[4],
cpr[5]);
terminalfd, r, cpr[0], cpr[1], cpr[2], cpr[3], cpr[4], cpr[5]);
}
#endif /* CURSOR_ANSWERBACK_BYTE_BY_BYTE */
ypos = pv_getnum_i(cpr + 2);
ypos = (int) pv_getnum_ui(cpr + 2);
tcsetattr(terminalfd, TCSANOW | TCSAFLUSH, &old_tty);
if (0 != tcsetattr(terminalfd, TCSANOW | TCSAFLUSH, &old_tty)) {
debug("%s: %s", "tcsetattr (2) failed", strerror(errno));
}
debug("%s: %d", "ypos", ypos);
@@ -281,7 +307,7 @@ static int pv_crs_ipcinit(pvstate_t state, char *ttyfile, int terminalfd)
* we don't end up interfering in any way with instances of `pv'
* running on another terminal.
*/
key = ftok(ttyfile, 'p');
key = ftok(ttyfile, (int) 'p');
if (-1 == key) {
debug("%s: %s\n", "ftok failed", strerror(errno));
return 1;
@@ -300,7 +326,7 @@ static int pv_crs_ipcinit(pvstate_t state, char *ttyfile, int terminalfd)
return 1;
}
state->crs_y_top = shmat(state->crs_shmid, 0, 0);
state->crs_y_top = shmat(state->crs_shmid, NULL, 0);
pv_crs_ipccount(state);
@@ -327,8 +353,7 @@ static int pv_crs_ipcinit(pvstate_t state, char *ttyfile, int terminalfd)
if (state->crs_pvcount > 1) {
state->crs_y_start = *(state->crs_y_top);
state->crs_y_lastread = state->crs_y_start;
debug("%s: %d", "not the first to attach - got top y",
state->crs_y_start);
debug("%s: %d", "not the first to attach - got top y", state->crs_y_start);
}
pv_crs_unlock(state, terminalfd);
@@ -347,7 +372,7 @@ void pv_crs_init(pvstate_t state)
int fd;
state->crs_lock_fd = -2;
state->crs_lock_file[0] = 0;
state->crs_lock_file[0] = '\0';
if (!state->cursor)
return;
@@ -356,25 +381,21 @@ void pv_crs_init(pvstate_t state)
ttyfile = ttyname(STDERR_FILENO);
if (!ttyfile) {
debug("%s: %s",
"disabling cursor positioning because ttyname failed",
strerror(errno));
debug("%s: %s", "disabling cursor positioning because ttyname failed", strerror(errno));
state->cursor = 0;
return;
}
fd = open(ttyfile, O_RDWR);
if (fd < 0) {
pv_error(state, "%s: %s: %s",
_("failed to open terminal"), ttyfile,
strerror(errno));
state->cursor = 0;
pv_error(state, "%s: %s: %s", _("failed to open terminal"), ttyfile, strerror(errno));
state->cursor = false;
return;
}
#ifdef HAVE_IPC
if (pv_crs_ipcinit(state, ttyfile, fd) != 0) {
debug("%s", "ipcinit failed, setting noipc flag");
state->crs_noipc = 1;
state->crs_noipc = true;
}
/*
@@ -397,14 +418,14 @@ void pv_crs_init(pvstate_t state)
* initial ypos.
*/
if (state->crs_y_start > 0)
write(STDERR_FILENO, "\n", 1);
pv_write_retry(STDERR_FILENO, "\n", 1);
pv_crs_unlock(state, fd);
if (state->crs_y_start < 1)
state->cursor = 0;
}
close(fd);
(void) close(fd);
}
@@ -458,14 +479,14 @@ 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;
#ifdef HAVE_IPC
if (!state->crs_noipc) {
if (state->crs_needreinit)
if (state->crs_needreinit > 0)
pv_crs_reinit(state);
pv_crs_ipccount(state);
@@ -488,14 +509,12 @@ void pv_crs_update(pvstate_t state, char *str)
* scroll the screen (only if we're the first `pv'), and then move
* our initial Y co-ordinate up.
*/
if (((state->crs_y_start + state->crs_pvmax) > state->height)
if (((state->crs_y_start + state->crs_pvmax) > (int) (state->height))
&& (!state->crs_noipc)
) {
int offs;
offs =
((state->crs_y_start + state->crs_pvmax) -
state->height);
offs = ((state->crs_y_start + state->crs_pvmax) - state->height);
state->crs_y_start -= offs;
if (state->crs_y_start < 1)
@@ -509,10 +528,11 @@ void pv_crs_update(pvstate_t state, char *str)
if (0 == state->crs_y_offset) {
pv_crs_lock(state, STDERR_FILENO);
sprintf(pos, "\033[%d;1H", state->height);
write(STDERR_FILENO, pos, strlen(pos));
memset(pos, 0, sizeof(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(STDERR_FILENO, "\n", 1);
pv_write_retry(STDERR_FILENO, "\n", 1);
}
pv_crs_unlock(state, STDERR_FILENO);
@@ -531,12 +551,14 @@ void pv_crs_update(pvstate_t state, char *str)
*/
if ((y < 1) || (y > 999999))
y = 1;
sprintf(pos, "\033[%d;1H", y);
memset(pos, 0, sizeof(pos));
(void) pv_snprintf(pos, sizeof(pos), "\033[%d;1H", y);
pv_crs_lock(state, STDERR_FILENO);
write(STDERR_FILENO, pos, strlen(pos));
write(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);
}
@@ -548,11 +570,11 @@ void pv_crs_update(pvstate_t state, char *str)
void pv_crs_fini(pvstate_t state)
{
char pos[32];
int y;
unsigned int y;
debug("%s", "fini");
y = state->crs_y_start;
y = (unsigned int) (state->crs_y_start);
#ifdef HAVE_IPC
if ((state->crs_pvmax > 0) && (!state->crs_noipc))
@@ -568,34 +590,35 @@ void pv_crs_fini(pvstate_t state)
if ((y < 1) || (y > 999999))
y = 1;
sprintf(pos, "\033[%d;1H\n", y);
memset(pos, 0, sizeof(pos));
(void) pv_snprintf(pos, sizeof(pos), "\033[%u;1H\n", y);
pv_crs_lock(state, STDERR_FILENO);
write(STDERR_FILENO, pos, strlen(pos));
pv_write_retry(STDERR_FILENO, pos, strlen(pos));
#ifdef HAVE_IPC
pv_crs_ipccount(state);
shmdt((void *) state->crs_y_top);
(void) shmdt((void *) state->crs_y_top);
/*
* If we are the last instance detaching from the shared memory,
* delete it so it's not left lying around.
*/
if (state->crs_pvcount < 2)
shmctl(state->crs_shmid, IPC_RMID, 0);
(void) shmctl(state->crs_shmid, IPC_RMID, NULL);
#endif /* HAVE_IPC */
pv_crs_unlock(state, STDERR_FILENO);
if (state->crs_lock_fd >= 0) {
close(state->crs_lock_fd);
(void) close(state->crs_lock_fd);
/*
* We can get away with removing this on exit because all
* the other PVs will be finishing at the same sort of time.
*/
remove(state->crs_lock_file);
(void) remove(state->crs_lock_file);
}
}
+278 -209
View File
@@ -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>
#ifdef HAVE_TERMIOS_H
#include <termios.h>
#endif
#ifdef GWINSZ_IN_SYS_IOCTL
#include <sys/ioctl.h>
#endif
/*
@@ -28,12 +40,46 @@ void pv_error(pvstate_t state, char *format, ...)
fprintf(stderr, "\n");
fprintf(stderr, "%s: ", state->program_name);
va_start(ap, format);
vfprintf(stderr, format, ap);
(void) vfprintf(stderr, format, ap);
va_end(ap);
fprintf(stderr, "\n");
}
/*
* Return true if we are the foreground process on the terminal, or if we
* aren't outputting to a terminal; false otherwise.
*/
bool pv_in_foreground(void)
{
pid_t our_process_group;
pid_t tty_process_group;
if (0 == isatty(STDERR_FILENO)) {
debug("%s: true: %s", "pv_in_foreground", "not a tty");
return true;
}
our_process_group = getpgrp();
tty_process_group = tcgetpgrp(STDERR_FILENO);
if (tty_process_group == -1 && errno == ENOTTY) {
debug("%s: true: %s", "pv_in_foreground", "tty_process_group is -1, errno is ENOTTY");
return true;
}
if (our_process_group == tty_process_group) {
debug("%s: true: %s", "pv_in_foreground", "our_process_group == tty_process_group");
return true;
}
debug("%s: false: our_process_group=%d, tty_process_group=%d",
"pv_in_foreground", our_process_group, tty_process_group);
return false;
}
/*
* Fill in *width and *height with the current terminal size,
* if possible.
@@ -43,7 +89,7 @@ void pv_screensize(unsigned int *width, unsigned int *height)
#ifdef TIOCGWINSZ
struct winsize wsz;
if (isatty(STDERR_FILENO)) {
if (0 != isatty(STDERR_FILENO)) {
if (0 == ioctl(STDERR_FILENO, TIOCGWINSZ, &wsz)) {
*width = wsz.ws_col;
*height = wsz.ws_row;
@@ -73,17 +119,14 @@ static long pv__calc_percentage(long long so_far, const long long total)
* transfer, and how long it's taken so far in seconds, return the estimated
* number of seconds until completion.
*/
static long pv__calc_eta(const long long so_far, const long long total,
const long elapsed)
static long pv__calc_eta(const long long so_far, const long long total, const long rate)
{
long long amount_left;
if (so_far < 1)
if ((so_far < 1) || (0 == rate))
return 0;
amount_left = total - so_far;
amount_left *= (long long) elapsed;
amount_left /= so_far;
amount_left = (total - so_far) / rate;
return (long) amount_left;
}
@@ -101,8 +144,7 @@ static long pv__calc_eta(const long long so_far, const long long total,
* modified. Further changed after input from Thomas Rachel; changed still
* further after Debian bug #706175.
*/
static void pv__si_prefix(long double *value, char *prefix,
const long double ratio, int is_bytes)
static void pv__si_prefix(long double *value, char *prefix, const long double ratio, int is_bytes)
{
static char *pfx_000 = NULL; /* kilo, mega, etc */
static char *pfx_024 = NULL; /* kibi, mibi, etc */
@@ -137,9 +179,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;
@@ -153,8 +203,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;
}
}
@@ -172,15 +227,16 @@ static void pv__si_prefix(long double *value, char *prefix,
* parameter (a %s) which will expand to the string described above.
*/
static void pv__sizestr(char *buffer, int bufsize, char *format,
long double amount, char *suffix_basic,
char *suffix_bytes, int is_bytes)
long double amount, char *suffix_basic, 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;
@@ -199,8 +255,8 @@ 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
@@ -208,12 +264,11 @@ 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);
}
snprintf(buffer, bufsize, format, sizestr_buffer);
(void) pv_snprintf(buffer, bufsize, format, sizestr_buffer);
}
@@ -237,15 +292,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 =
state->format_string ? state->
format_string : state->default_format;
formatstr = state->format_string ? state->format_string : state->default_format;
state->components_used = 0;
@@ -271,107 +324,85 @@ static void pv__format_init(pvstate_t state)
* these segments together.
*/
segment = 0;
for (strpos = 0; formatstr[strpos] != 0 && segment < 99;
strpos++, segment++) {
for (strpos = 0; formatstr[strpos] != 0 && segment < 99; strpos++, segment++) {
if ('%' == formatstr[strpos]) {
int num;
unsigned int num;
strpos++;
num = 0;
while (isdigit(formatstr[strpos])) {
while (isdigit((int)(formatstr[strpos]))) {
num = num * 10;
num += formatstr[strpos] - '0';
strpos++;
}
switch (formatstr[strpos]) {
case 'p':
state->format[segment].string =
state->str_progress;
state->format[segment].string = state->str_progress;
state->format[segment].length = -1;
state->components_used |=
PV_DISPLAY_PROGRESS;
state->components_used |= PV_DISPLAY_PROGRESS;
break;
case 't':
state->format[segment].string =
state->str_timer;
state->format[segment].string = state->str_timer;
state->format[segment].length = 0;
state->components_used |= PV_DISPLAY_TIMER;
break;
case 'e':
state->format[segment].string =
state->str_eta;
state->format[segment].string = state->str_eta;
state->format[segment].length = 0;
state->components_used |= PV_DISPLAY_ETA;
break;
case 'I':
state->format[segment].string =
state->str_fineta;
state->format[segment].string = state->str_fineta;
state->format[segment].length = 0;
state->components_used |=
PV_DISPLAY_FINETA;
state->components_used |= PV_DISPLAY_FINETA;
break;
case 'A':
state->format[segment].string =
state->str_lastoutput;
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;
state->components_used |=
PV_DISPLAY_OUTPUTBUF;
state->components_used |= PV_DISPLAY_OUTPUTBUF;
break;
case 'r':
state->format[segment].string =
state->str_rate;
state->format[segment].string = state->str_rate;
state->format[segment].length = 0;
state->components_used |= PV_DISPLAY_RATE;
break;
case 'a':
state->format[segment].string =
state->str_average_rate;
state->format[segment].string = state->str_average_rate;
state->format[segment].length = 0;
state->components_used |=
PV_DISPLAY_AVERAGERATE;
state->components_used |= PV_DISPLAY_AVERAGERATE;
break;
case 'b':
state->format[segment].string =
state->str_transferred;
state->format[segment].string = state->str_transferred;
state->format[segment].length = 0;
state->components_used |= PV_DISPLAY_BYTES;
break;
case 'T':
state->format[segment].string =
state->str_bufpercent;
state->format[segment].string = state->str_bufpercent;
state->format[segment].length = 0;
state->components_used |=
PV_DISPLAY_BUFPERCENT;
state->components_used |= PV_DISPLAY_BUFPERCENT;
break;
case 'N':
state->format[segment].string =
state->str_name;
state->format[segment].length =
strlen(state->str_name);
state->format[segment].string = state->str_name;
state->format[segment].length = strlen(state->str_name);
state->components_used |= PV_DISPLAY_NAME;
break;
case '%':
/* %% => % */
state->format[segment].string =
&(formatstr[strpos]);
state->format[segment].string = &(formatstr[strpos]);
state->format[segment].length = 1;
break;
case 0:
/* % at end => just % */
state->format[segment].string =
&(formatstr[--strpos]);
state->format[segment].string = &(formatstr[--strpos]);
state->format[segment].length = 1;
break;
default:
/* %z (unknown) => %z */
state->format[segment].string =
&(formatstr[--strpos]);
state->format[segment].string = &(formatstr[--strpos]);
state->format[segment].length = 2;
strpos++;
break;
@@ -382,11 +413,9 @@ static void pv__format_init(pvstate_t state)
if (NULL == searchptr) {
foundlength = strlen(&(formatstr[strpos]));
} else {
foundlength =
searchptr - &(formatstr[strpos]);
foundlength = searchptr - &(formatstr[strpos]);
}
state->format[segment].string =
&(formatstr[strpos]);
state->format[segment].string = &(formatstr[strpos]);
state->format[segment].length = foundlength;
strpos += foundlength - 1;
}
@@ -405,6 +434,48 @@ static long bound_long(long x, long min, long max)
return x < min ? min : x > max ? max : x;
}
/* Update history and current average rate */
static void update_history_avg_rate(pvstate_t state, long long total_bytes, long double elapsed_sec, long double rate)
{
int first = state->history_first;
int last = state->history_last;
long double last_elapsed;
if (NULL == state->history)
return;
last_elapsed = state->history[last].elapsed_sec;
/*
* Do nothing if this is not the first call but not enough time has
* elapsed since the previous call yet.
*/
if ((last_elapsed > 0.0)
&& (elapsed_sec < (last_elapsed + state->history_interval)))
return;
/*
* This is not the first call, so add a new entry to the circular
* buffer.
*/
if (last_elapsed > 0.0) {
int len = state->history_len;
state->history_last = last = (last + 1) % len;
if (last == first)
state->history_first = first = (first + 1) % len;
}
state->history[last].elapsed_sec = elapsed_sec;
state->history[last].total_bytes = total_bytes;
if (first == last) {
state->current_avg_rate = rate;
} else {
long long bytes = (state->history[last].total_bytes - state->history[first].total_bytes);
long double sec = (state->history[last].elapsed_sec - state->history[first].elapsed_sec);
state->current_avg_rate = bytes / sec;
}
}
/*
* Return a pointer to a string (which must not be freed), containing status
@@ -423,9 +494,8 @@ static long bound_long(long x, long min, long max)
* 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;
@@ -457,30 +527,28 @@ static char *pv__format(pvstate_t state,
rate = state->prev_rate;
state->prev_trans += bytes_since_last;
} else {
rate =
((long double) bytes_since_last +
state->prev_trans) / time_since_last;
rate = ((long double) bytes_since_last + state->prev_trans) / time_since_last;
state->prev_elapsed_sec = elapsed_sec;
state->prev_trans = 0;
}
state->prev_rate = rate;
/* Update history and current average rate for ETA. */
update_history_avg_rate(state, total_bytes, elapsed_sec, rate);
average_rate = state->current_avg_rate;
/*
* We only calculate the overall average rate if this is the last
* update or if the average rate display is enabled. Otherwise it's
* not worth the extra CPU cycles.
* If this is the final update at the end of the transfer, we
* recalculate the rate - and the average rate - across the whole
* period of the transfer.
*/
if ((bytes_since_last < 0)
|| ((state->components_used & PV_DISPLAY_AVERAGERATE) != 0)) {
if (bytes_since_last < 0) {
/* Sanity check to avoid division by zero */
if (elapsed_sec < 0.000001)
elapsed_sec = 0.000001;
average_rate =
(((long double) total_bytes) -
((long double) state->initial_offset)) /
(long double) elapsed_sec;
if (bytes_since_last < 0)
rate = average_rate;
(((long double) total_bytes) - ((long double) state->initial_offset)) / (long double) elapsed_sec;
rate = average_rate;
}
if (state->size <= 0) {
@@ -496,23 +564,19 @@ static char *pv__format(pvstate_t state,
state->percentage += 2;
if (state->percentage > 199)
state->percentage = 0;
} else if (state->numeric
|| ((state->components_used & PV_DISPLAY_PROGRESS) !=
0)) {
} else if (state->numeric || ((state->components_used & PV_DISPLAY_PROGRESS) != 0)) {
/*
* If we do know the total size, and we're going to show
* the percentage (numeric mode or a progress bar),
* calculate the percentage completion.
*/
state->percentage =
pv__calc_percentage(total_bytes, state->size);
state->percentage = pv__calc_percentage(total_bytes, state->size);
}
/*
* Reallocate output buffer if width changes.
*/
if (state->display_buffer != NULL
&& state->display_buffer_size < (state->width * 2)) {
if (state->display_buffer != NULL && state->display_buffer_size < (state->width * 2)) {
free(state->display_buffer);
state->display_buffer = NULL;
state->display_buffer_size = 0;
@@ -525,12 +589,9 @@ static char *pv__format(pvstate_t state,
state->display_buffer_size = (2 * state->width) + 80;
if (state->name)
state->display_buffer_size += strlen(state->name);
state->display_buffer =
malloc(state->display_buffer_size + 16);
state->display_buffer = malloc(state->display_buffer_size + 16);
if (NULL == state->display_buffer) {
pv_error(state, "%s: %s",
_("buffer allocation failed"),
strerror(errno));
pv_error(state, "%s: %s", _("buffer allocation failed"), strerror(errno));
state->exit_status |= 64;
return NULL;
}
@@ -551,18 +612,21 @@ 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) {
sprintf(state->display_buffer, "%.99s%lld\n",
numericprefix, total_bytes);
} else if (state->percentage > 100) {
/* As mentioned above, we go 0-100, then 100-0. */
sprintf(state->display_buffer, "%.99s%ld\n",
numericprefix, 200 - state->percentage);
if (state->bits) {
(void) pv_snprintf(state->display_buffer,
state->display_buffer_size,
"%.99s%lld\n", numericprefix, 8 * total_bytes);
} else {
(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;
@@ -587,22 +651,27 @@ static char *pv__format(pvstate_t state,
/* If we're showing bytes transferred, set up the display string. */
if ((state->components_used & PV_DISPLAY_BYTES) != 0) {
pv__sizestr(state->str_transferred,
sizeof(state->str_transferred), "%s",
(long double) total_bytes, "", _("B"),
state->linemode ? 0 : 1);
if (state->bits && !state->linemode) {
pv__sizestr(state->str_transferred,
PV_SIZEOF_STR_TRANSFERRED, "%s", (long double) total_bytes * 8, "", _("b"), 1);
} else {
pv__sizestr(state->str_transferred,
PV_SIZEOF_STR_TRANSFERRED, "%s",
(long double) total_bytes, "", _("B"), state->linemode ? 0 : 1);
}
}
/* 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
}
@@ -616,25 +685,46 @@ static char *pv__format(pvstate_t state,
if (elapsed_sec > (long double) 360000000.0L)
elapsed_sec = (long double) 360000000.0L;
sprintf(state->str_timer, "%ld:%02ld:%02ld",
((long) elapsed_sec) / 3600,
(((long) elapsed_sec) / 60) % 60,
((long) elapsed_sec) % 60);
/*
* If the elapsed time is more than a day, include a day count as
* well as hours, minutes, and seconds.
*/
if (elapsed_sec > (long double) 86400.0L) {
(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 {
(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);
}
}
/* Rate - set up the display string. */
if ((state->components_used & PV_DISPLAY_RATE) != 0) {
pv__sizestr(state->str_rate, sizeof(state->str_rate),
"[%s]", rate, _("/s"), _("B/s"),
state->linemode ? 0 : 1);
if (state->bits && !state->linemode) {
pv__sizestr(state->str_rate, PV_SIZEOF_STR_RATE, "[%s]", 8 * rate, "", _("b/s"), 1);
} else {
pv__sizestr(state->str_rate,
PV_SIZEOF_STR_RATE, "[%s]", rate, _("/s"), _("B/s"), state->linemode ? 0 : 1);
}
}
/* Average rate - set up the display string. */
if ((state->components_used & PV_DISPLAY_AVERAGERATE) != 0) {
pv__sizestr(state->str_average_rate,
sizeof(state->str_average_rate), "[%s]",
average_rate, _("/s"), _("B/s"),
state->linemode ? 0 : 1);
if (state->bits && !state->linemode) {
pv__sizestr(state->str_average_rate,
PV_SIZEOF_STR_AVERAGE_RATE, "[%s]", 8 * average_rate, "", _("b/s"), 1);
} else {
pv__sizestr(state->str_average_rate,
PV_SIZEOF_STR_AVERAGE_RATE,
"[%s]", average_rate, _("/s"), _("B/s"), state->linemode ? 0 : 1);
}
}
/* Last output bytes - set up the display string. */
@@ -653,8 +743,7 @@ static char *pv__format(pvstate_t state,
&& (state->size > 0)) {
eta =
pv__calc_eta(total_bytes - state->initial_offset,
state->size - state->initial_offset,
elapsed_sec);
state->size - state->initial_offset, state->current_avg_rate);
/*
* Bounds check, so we don't overrun the suffix buffer. This
@@ -667,14 +756,14 @@ 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);
}
/*
@@ -682,9 +771,8 @@ static char *pv__format(pvstate_t state,
* ETA used to be.
*/
if (bytes_since_last < 0) {
int i;
for (i = 0; i < sizeof(state->str_eta)
&& state->str_eta[i] != 0; i++) {
unsigned int i;
for (i = 0; i < PV_SIZEOF_STR_ETA && state->str_eta[i] != '\0'; i++) {
state->str_eta[i] = ' ';
}
}
@@ -705,8 +793,7 @@ static char *pv__format(pvstate_t state,
eta =
pv__calc_eta(total_bytes - state->initial_offset,
state->size - state->initial_offset,
elapsed_sec);
state->size - state->initial_offset, state->current_avg_rate);
/*
* Bounds check, so we don't overrun the suffix buffer. This
@@ -735,18 +822,15 @@ 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) {
int i;
for (i = 0; i < sizeof(state->str_fineta)
&& state->str_fineta[i] != 0; i++) {
unsigned int i;
for (i = 0; i < PV_SIZEOF_STR_FINETA && state->str_fineta[i] != '\0'; i++) {
state->str_fineta[i] = ' ';
}
}
@@ -762,11 +846,9 @@ static char *pv__format(pvstate_t state,
if (state->format[segment].length < 0) {
continue;
} else if (state->format[segment].length > 0) {
static_portion_size +=
state->format[segment].length;
static_portion_size += state->format[segment].length;
} else {
static_portion_size +=
strlen(state->format[segment].string);
static_portion_size += strlen(state->format[segment].string);
}
}
@@ -786,49 +868,39 @@ 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 -
strlen(pct) - 3;
available_width = state->width - static_portion_size - strlen(pct) - 3;
if (available_width < 0)
available_width = 0;
if (available_width >
sizeof(state->str_progress) - 16)
available_width =
sizeof(state->str_progress) - 16;
if (available_width > (int) (PV_SIZEOF_STR_PROGRESS) - 16)
available_width = PV_SIZEOF_STR_PROGRESS - 16;
for (i = 0;
i <
(available_width * state->percentage) / 100 -
1; i++) {
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;
available_width =
state->width - static_portion_size - 5;
available_width = state->width - static_portion_size - 5;
if (available_width < 0)
available_width = 0;
if (available_width >
sizeof(state->str_progress) - 16)
available_width =
sizeof(state->str_progress) - 16;
if (available_width > (int) (PV_SIZEOF_STR_PROGRESS) - 16)
available_width = PV_SIZEOF_STR_PROGRESS - 16;
debug("available_width: %d", available_width);
@@ -836,20 +908,19 @@ 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);
}
/*
* If the progress bar won't fit, drop it.
*/
if (strlen(state->str_progress) + static_portion_size >
state->width)
if (strlen(state->str_progress) + static_portion_size > state->width)
state->str_progress[0] = 0;
}
@@ -864,8 +935,7 @@ static char *pv__format(pvstate_t state,
if (state->format[segment].length > 0) {
segment_length = state->format[segment].length;
} else {
segment_length =
strlen(state->format[segment].string);
segment_length = strlen(state->format[segment].string);
}
/* Skip empty segments */
if (segment_length == 0)
@@ -874,18 +944,14 @@ static char *pv__format(pvstate_t state,
* Truncate segment if it would make the display string
* overflow the buffer
*/
if (segment_length + display_string_length >
state->display_buffer_size - 2)
segment_length =
state->display_buffer_size -
display_string_length - 2;
if (segment_length + display_string_length > state->display_buffer_size - 2)
segment_length = state->display_buffer_size - display_string_length - 2;
if (segment_length < 1)
break;
/* Skip segment if it would make the display too wide */
if (segment_length + display_string_length > state->width)
if (segment_length + display_string_length > (int) (state->width))
break;
strncat(state->display_buffer,
state->format[segment].string, segment_length);
strncat(state->display_buffer, state->format[segment].string, segment_length);
display_string_length += segment_length;
}
@@ -895,7 +961,7 @@ static char *pv__format(pvstate_t state,
*/
output_length = strlen(state->display_buffer);
if ((output_length < state->prev_length)
&& (state->width >= state->prev_width)) {
&& ((int) (state->width) >= state->prev_width)) {
char spaces[32];
int spaces_to_add;
spaces_to_add = state->prev_length - output_length;
@@ -908,7 +974,7 @@ 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;
@@ -928,10 +994,9 @@ static char *pv__format(pvstate_t state,
*
* In line mode, "sl" and "tot" are in lines, not bytes.
*/
void pv_display(pvstate_t state, long double esec, long long sl,
long long tot)
void pv_display(pvstate_t state, long double esec, long long sl, long long tot)
{
char *display;
const char *display;
if (NULL == state)
return;
@@ -952,14 +1017,18 @@ 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) {
pv_crs_update(state, display);
state->display_visible = 1;
if (state->force || pv_in_foreground()) {
pv_crs_update(state, display);
state->display_visible = true;
}
} else {
write(STDERR_FILENO, display, strlen(display));
write(STDERR_FILENO, "\r", 1);
state->display_visible = 1;
if (state->force || pv_in_foreground()) {
pv_write_retry(STDERR_FILENO, display, strlen(display));
pv_write_retry(STDERR_FILENO, "\r", 1);
state->display_visible = true;
}
}
debug("%s: [%s]", "display", display);
+48 -49
View File
@@ -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,40 +37,39 @@
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;
rc = 0;
memset(&sb, 0, sizeof(sb));
/*
* 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);
}
if (rc != 0) {
pv_error(state, "%s: %s",
state->input_files[i], strerror(errno));
pv_error(state, "%s: %s", state->input_files[i], strerror(errno));
for (j = i; j < state->input_file_count - 1; j++) {
state->input_files[j] =
state->input_files[j + 1];
state->input_files[j] = state->input_files[j + 1];
}
state->input_file_count--;
i--;
@@ -78,18 +83,15 @@ 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",
state->input_files[i],
strerror(errno));
pv_error(state, "%s: %s", state->input_files[i], strerror(errno));
state->exit_status |= 2;
}
} else if (S_ISREG(sb.st_mode)) {
@@ -108,15 +110,13 @@ 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"),
strerror(errno));
_("failed to seek to start of output"), strerror(errno));
state->exit_status |= 2;
}
/*
@@ -143,24 +143,23 @@ 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) {
pv_error(state, "%s: %s", state->input_files[i],
strerror(errno));
pv_error(state, "%s: %s", state->input_files[i], strerror(errno));
total = 0;
state->exit_status |= 2;
return total;
@@ -172,9 +171,7 @@ unsigned long long pv_calc_total_size(pvstate_t state)
numread = read(fd, scanbuf, sizeof(scanbuf));
if (numread < 0) {
pv_error(state, "%s: %s",
state->input_files[i],
strerror(errno));
pv_error(state, "%s: %s", state->input_files[i], strerror(errno));
state->exit_status |= 2;
break;
} else if (0 == numread) {
@@ -186,7 +183,7 @@ unsigned long long pv_calc_total_size(pvstate_t state)
}
}
lseek64(fd, 0, SEEK_SET);
lseek(fd, 0, SEEK_SET);
close(fd);
}
@@ -204,15 +201,13 @@ 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) {
if (close(oldfd)) {
pv_error(state, "%s: %s",
_("failed to close file"),
strerror(errno));
pv_error(state, "%s: %s", _("failed to close file"), strerror(errno));
state->exit_status |= 8;
return -1;
}
@@ -231,29 +226,24 @@ 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"),
state->input_files[filenum],
strerror(errno));
_("failed to read file"), state->input_files[filenum], strerror(errno));
state->exit_status |= 2;
return -1;
}
}
if (fstat64(fd, &isb)) {
pv_error(state, "%s: %s: %s",
_("failed to stat file"),
state->input_files[filenum], strerror(errno));
if (fstat(fd, &isb)) {
pv_error(state, "%s: %s: %s", _("failed to stat file"), state->input_files[filenum], strerror(errno));
close(fd);
state->exit_status |= 2;
return -1;
}
if (fstat64(STDOUT_FILENO, &osb)) {
pv_error(state, "%s: %s",
_("failed to stat output file"), strerror(errno));
if (fstat(STDOUT_FILENO, &osb)) {
pv_error(state, "%s: %s", _("failed to stat output file"), strerror(errno));
close(fd);
state->exit_status |= 2;
return -1;
@@ -275,9 +265,7 @@ int pv_next_file(pvstate_t state, int filenum, int oldfd)
input_file_is_stdout = 0;
if (input_file_is_stdout) {
pv_error(state, "%s: %s",
_("input file is output file"),
state->input_files[filenum]);
pv_error(state, "%s: %s", _("input file is output file"), state->input_files[filenum]);
close(fd);
state->exit_status |= 4;
return -1;
@@ -287,6 +275,17 @@ 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;
}
+83 -125
View File
@@ -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;
/*
@@ -88,12 +94,9 @@ int pv_main_loop(pvstate_t state)
next_update.tv_usec = start_time.tv_usec;
if ((state->delay_start > 0)
&& (state->delay_start > state->interval)) {
pv_timeval_add_usec(&next_update,
(long) (1000000.0 *
state->delay_start));
pv_timeval_add_usec(&next_update, (long) (1000000.0 * state->delay_start));
} else {
pv_timeval_add_usec(&next_update,
(long) (1000000.0 * state->interval));
pv_timeval_add_usec(&next_update, (long) (1000000.0 * state->interval));
}
next_ratecheck.tv_sec = start_time.tv_sec;
@@ -111,12 +114,19 @@ 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)
@@ -135,11 +145,9 @@ int pv_main_loop(pvstate_t state)
* Check for remote messages from -R every short while
*/
if ((cur_time.tv_sec > next_remotecheck.tv_sec)
|| (cur_time.tv_sec == next_remotecheck.tv_sec
&& cur_time.tv_usec >= next_remotecheck.tv_usec)) {
|| (cur_time.tv_sec == next_remotecheck.tv_sec && cur_time.tv_usec >= next_remotecheck.tv_usec)) {
pv_remote_check(state);
pv_timeval_add_usec(&next_remotecheck,
REMOTE_INTERVAL);
pv_timeval_add_usec(&next_remotecheck, REMOTE_INTERVAL);
}
if (state->pv_sig_abort)
@@ -148,15 +156,15 @@ int pv_main_loop(pvstate_t state)
if (state->rate_limit > 0) {
gettimeofday(&cur_time, NULL);
if ((cur_time.tv_sec > next_ratecheck.tv_sec)
|| (cur_time.tv_sec == next_ratecheck.tv_sec
&& cur_time.tv_usec >=
next_ratecheck.tv_usec)) {
|| (cur_time.tv_sec == next_ratecheck.tv_sec && cur_time.tv_usec >= next_ratecheck.tv_usec)) {
target +=
((long double) (state->rate_limit)) /
(long double) (1000000 /
RATE_GRANULARITY);
pv_timeval_add_usec(&next_ratecheck,
RATE_GRANULARITY);
((long double) (state->rate_limit)) / (long double) (1000000 / RATE_GRANULARITY);
long double burstMax = ((long double) (state->rate_limit * RATE_BURST_WINDOW));
if (target > burstMax) {
target = burstMax;
}
pv_timeval_add_usec(&next_ratecheck, RATE_GRANULARITY);
}
cansend = target;
}
@@ -166,7 +174,7 @@ int pv_main_loop(pvstate_t state)
* try to write more than we're allowed to.
*/
if ((0 < state->size) && (state->stop_at_size)) {
if ((state->size < (total_written + cansend))
if (((long) (state->size) < (total_written + cansend))
|| ((0 == cansend)
&& (0 == state->rate_limit))) {
cansend = state->size - total_written;
@@ -181,9 +189,7 @@ int pv_main_loop(pvstate_t state)
&& (0 >= cansend) && eof_in && eof_out) {
written = 0;
} else {
written =
pv_transfer(state, fd, &eof_in, &eof_out,
cansend, &lineswritten);
written = pv_transfer(state, fd, &eof_in, &eof_out, cansend, &lineswritten);
}
if (written < 0) {
@@ -263,32 +269,25 @@ int pv_main_loop(pvstate_t state)
next_update.tv_sec = start_time.tv_sec;
next_update.tv_usec = start_time.tv_usec;
pv_timeval_add_usec(&next_update,
(long) (1000000.0 *
state->interval));
pv_timeval_add_usec(&next_update, (long) (1000000.0 * state->interval));
}
if ((cur_time.tv_sec < next_update.tv_sec)
|| (cur_time.tv_sec == next_update.tv_sec
&& cur_time.tv_usec < next_update.tv_usec)) {
|| (cur_time.tv_sec == next_update.tv_sec && cur_time.tv_usec < next_update.tv_usec)) {
continue;
}
pv_timeval_add_usec(&next_update,
(long) (1000000.0 * state->interval));
pv_timeval_add_usec(&next_update, (long) (1000000.0 * state->interval));
if (next_update.tv_sec < cur_time.tv_sec) {
next_update.tv_sec = cur_time.tv_sec;
next_update.tv_usec = cur_time.tv_usec;
} else if (next_update.tv_sec == cur_time.tv_sec
&& next_update.tv_usec < cur_time.tv_usec) {
} else if (next_update.tv_sec == cur_time.tv_sec && next_update.tv_usec < cur_time.tv_usec) {
next_update.tv_usec = cur_time.tv_usec;
}
init_time.tv_sec =
start_time.tv_sec + state->pv_sig_toffset.tv_sec;
init_time.tv_usec =
start_time.tv_usec + state->pv_sig_toffset.tv_usec;
init_time.tv_sec = start_time.tv_sec + state->pv_sig_toffset.tv_sec;
init_time.tv_usec = start_time.tv_usec + state->pv_sig_toffset.tv_usec;
if (init_time.tv_usec >= 1000000) {
init_time.tv_sec++;
init_time.tv_usec -= 1000000;
@@ -299,8 +298,7 @@ int pv_main_loop(pvstate_t state)
}
elapsed = cur_time.tv_sec - init_time.tv_sec;
elapsed +=
(cur_time.tv_usec - init_time.tv_usec) / 1000000.0;
elapsed += (cur_time.tv_usec - init_time.tv_usec) / 1000000.0;
if (final_update)
since_last = -1;
@@ -320,7 +318,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)
@@ -381,8 +379,7 @@ int pv_watchfd_loop(pvstate_t state)
next_update.tv_sec = info.start_time.tv_sec;
next_update.tv_usec = info.start_time.tv_usec;
pv_timeval_add_usec(&next_update,
(long) (1000000.0 * state->interval));
pv_timeval_add_usec(&next_update, (long) (1000000.0 * state->interval));
next_remotecheck.tv_sec = info.start_time.tv_sec;
next_remotecheck.tv_usec = info.start_time.tv_usec;
@@ -397,11 +394,9 @@ int pv_watchfd_loop(pvstate_t state)
* Check for remote messages from -R every short while
*/
if ((cur_time.tv_sec > next_remotecheck.tv_sec)
|| (cur_time.tv_sec == next_remotecheck.tv_sec
&& cur_time.tv_usec >= next_remotecheck.tv_usec)) {
|| (cur_time.tv_sec == next_remotecheck.tv_sec && cur_time.tv_usec >= next_remotecheck.tv_usec)) {
pv_remote_check(state);
pv_timeval_add_usec(&next_remotecheck,
REMOTE_INTERVAL);
pv_timeval_add_usec(&next_remotecheck, REMOTE_INTERVAL);
}
if (state->pv_sig_abort)
@@ -428,8 +423,7 @@ int pv_watchfd_loop(pvstate_t state)
}
if ((cur_time.tv_sec < next_update.tv_sec)
|| (cur_time.tv_sec == next_update.tv_sec
&& cur_time.tv_usec < next_update.tv_usec)) {
|| (cur_time.tv_sec == next_update.tv_sec && cur_time.tv_usec < next_update.tv_usec)) {
struct timeval tv;
tv.tv_sec = 0;
tv.tv_usec = 50000;
@@ -437,22 +431,17 @@ int pv_watchfd_loop(pvstate_t state)
continue;
}
pv_timeval_add_usec(&next_update,
(long) (1000000.0 * state->interval));
pv_timeval_add_usec(&next_update, (long) (1000000.0 * state->interval));
if (next_update.tv_sec < cur_time.tv_sec) {
next_update.tv_sec = cur_time.tv_sec;
next_update.tv_usec = cur_time.tv_usec;
} else if (next_update.tv_sec == cur_time.tv_sec
&& next_update.tv_usec < cur_time.tv_usec) {
} else if (next_update.tv_sec == cur_time.tv_sec && next_update.tv_usec < cur_time.tv_usec) {
next_update.tv_usec = cur_time.tv_usec;
}
init_time.tv_sec =
info.start_time.tv_sec + state->pv_sig_toffset.tv_sec;
init_time.tv_usec =
info.start_time.tv_usec +
state->pv_sig_toffset.tv_usec;
init_time.tv_sec = info.start_time.tv_sec + state->pv_sig_toffset.tv_sec;
init_time.tv_usec = info.start_time.tv_usec + state->pv_sig_toffset.tv_usec;
if (init_time.tv_usec >= 1000000) {
init_time.tv_sec++;
init_time.tv_usec -= 1000000;
@@ -463,8 +452,7 @@ int pv_watchfd_loop(pvstate_t state)
}
elapsed = cur_time.tv_sec - init_time.tv_sec;
elapsed +=
(cur_time.tv_usec - init_time.tv_usec) / 1000000.0;
elapsed += (cur_time.tv_usec - init_time.tv_usec) / 1000000.0;
if (ended)
since_last = -1;
@@ -480,7 +468,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;
@@ -505,7 +493,7 @@ int pv_watchpid_loop(pvstate_t state)
struct pvstate_s *state_array = NULL;
int array_length = 0;
int fd_to_idx[FD_SETSIZE] = { 0, };
struct timeval next_update, cur_time, next_remotecheck;
struct timeval next_update, cur_time;
int idx;
int prev_displayed_lines, blank_lines;
int first_pass = 1;
@@ -515,8 +503,7 @@ int pv_watchpid_loop(pvstate_t state)
* it's not there at the start.
*/
if (kill(state->watch_pid, 0) != 0) {
pv_error(state, "%s %u: %s",
_("pid"), state->watch_pid, strerror(errno));
pv_error(state, "%s %u: %s", _("pid"), state->watch_pid, strerror(errno));
state->exit_status |= 2;
return 2;
}
@@ -531,20 +518,16 @@ int pv_watchpid_loop(pvstate_t state)
* Make sure there's a format string, and then insert %N into it if
* it's not present.
*/
original_format_string =
state->format_string ? state->
format_string : state->default_format;
original_format_string = state->format_string ? state->format_string : state->default_format;
if (NULL == strstr(original_format_string, "%N")) {
snprintf(new_format_string, sizeof(new_format_string) - 1,
"%%N %s", original_format_string);
(void) pv_snprintf(new_format_string, sizeof(new_format_string), "%%N %s", original_format_string);
} else {
snprintf(new_format_string, sizeof(new_format_string) - 1,
"%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;
snprintf(state_copy.default_format,
sizeof(state_copy.default_format) - 1, "%s",
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.
@@ -552,13 +535,9 @@ int pv_watchpid_loop(pvstate_t state)
gettimeofday(&cur_time, NULL);
next_remotecheck.tv_sec = cur_time.tv_sec;
next_remotecheck.tv_usec = cur_time.tv_usec;
next_update.tv_sec = cur_time.tv_sec;
next_update.tv_usec = cur_time.tv_usec;
pv_timeval_add_usec(&next_update,
(long) (1000000.0 * state->interval));
pv_timeval_add_usec(&next_update, (long) (1000000.0 * state->interval));
for (idx = 0; idx < FD_SETSIZE; idx++) {
fd_to_idx[idx] = -1;
@@ -576,9 +555,7 @@ int pv_watchpid_loop(pvstate_t state)
if (kill(state->watch_pid, 0) != 0) {
if (first_pass) {
pv_error(state, "%s %u: %s",
_("pid"), state->watch_pid,
strerror(errno));
pv_error(state, "%s %u: %s", _("pid"), state->watch_pid, strerror(errno));
state->exit_status |= 2;
if (NULL != info_array)
free(info_array);
@@ -590,8 +567,7 @@ int pv_watchpid_loop(pvstate_t state)
}
if ((cur_time.tv_sec < next_update.tv_sec)
|| (cur_time.tv_sec == next_update.tv_sec
&& cur_time.tv_usec < next_update.tv_usec)) {
|| (cur_time.tv_sec == next_update.tv_sec && cur_time.tv_usec < next_update.tv_usec)) {
struct timeval tv;
tv.tv_sec = 0;
tv.tv_usec = 50000;
@@ -599,14 +575,12 @@ int pv_watchpid_loop(pvstate_t state)
continue;
}
pv_timeval_add_usec(&next_update,
(long) (1000000.0 * state->interval));
pv_timeval_add_usec(&next_update, (long) (1000000.0 * state->interval));
if (next_update.tv_sec < cur_time.tv_sec) {
next_update.tv_sec = cur_time.tv_sec;
next_update.tv_usec = cur_time.tv_usec;
} else if (next_update.tv_sec == cur_time.tv_sec
&& next_update.tv_usec < cur_time.tv_usec) {
} else if (next_update.tv_sec == cur_time.tv_sec && next_update.tv_usec < cur_time.tv_usec) {
next_update.tv_usec = cur_time.tv_usec;
}
@@ -616,21 +590,16 @@ int pv_watchpid_loop(pvstate_t state)
for (idx = 0; idx < array_length; idx++) {
state_array[idx].width = state->width;
state_array[idx].height = state->height;
pv_watchpid_setname(state,
&(info_array[idx]));
pv_watchpid_setname(state, &(info_array[idx]));
state_array[idx].reparse_display = 1;
}
}
rc = pv_watchpid_scanfds(state, &state_copy,
state->watch_pid, &array_length,
&info_array, &state_array,
fd_to_idx);
state->watch_pid, &array_length, &info_array, &state_array, fd_to_idx);
if (rc != 0) {
if (first_pass) {
pv_error(state, "%s %u: %s",
_("pid"), state->watch_pid,
strerror(errno));
pv_error(state, "%s %u: %s", _("pid"), state->watch_pid, strerror(errno));
state->exit_status |= 2;
if (NULL != info_array)
free(info_array);
@@ -649,7 +618,7 @@ int pv_watchpid_loop(pvstate_t state)
struct timeval init_time;
long double elapsed;
if (displayed_lines >= state->height)
if (displayed_lines >= (int) (state->height))
break;
idx = fd_to_idx[fd];
@@ -665,8 +634,7 @@ int pv_watchpid_loop(pvstate_t state)
if (pv_watchfd_changed(&(info_array[idx]))) {
fd_to_idx[fd] = -1;
info_array[idx].watch_pid = 0;
debug("%s %d: %s", "fd", fd,
"removing");
debug("%s %d: %s", "fd", fd, "removing");
}
continue;
}
@@ -675,8 +643,7 @@ int pv_watchpid_loop(pvstate_t state)
* Displayable fd - display, or remove if changed
*/
position_now =
pv_watchfd_position(&(info_array[idx]));
position_now = pv_watchfd_position(&(info_array[idx]));
if (position_now < 0) {
fd_to_idx[fd] = -1;
@@ -685,16 +652,11 @@ int pv_watchpid_loop(pvstate_t state)
continue;
}
since_last =
position_now - info_array[idx].position;
since_last = position_now - info_array[idx].position;
info_array[idx].position = position_now;
init_time.tv_sec =
info_array[idx].start_time.tv_sec +
state->pv_sig_toffset.tv_sec;
init_time.tv_usec =
info_array[idx].start_time.tv_usec +
state->pv_sig_toffset.tv_usec;
init_time.tv_sec = info_array[idx].start_time.tv_sec + state->pv_sig_toffset.tv_sec;
init_time.tv_usec = info_array[idx].start_time.tv_usec + state->pv_sig_toffset.tv_usec;
if (init_time.tv_usec >= 1000000) {
init_time.tv_sec++;
init_time.tv_usec -= 1000000;
@@ -705,20 +667,16 @@ int pv_watchpid_loop(pvstate_t state)
}
elapsed = cur_time.tv_sec - init_time.tv_sec;
elapsed +=
(cur_time.tv_usec -
init_time.tv_usec) / 1000000.0;
elapsed += (cur_time.tv_usec - init_time.tv_usec) / 1000000.0;
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,
elapsed, since_last, position_now);
debug("%s %d [%d]: %Lf / %Ld / %Ld", "fd", fd, idx, elapsed, since_last, position_now);
pv_display(&(state_array[idx]), elapsed,
since_last, position_now);
pv_display(&(state_array[idx]), elapsed, since_last, position_now);
displayed_lines++;
}
@@ -733,12 +691,12 @@ int pv_watchpid_loop(pvstate_t state)
debug("%s: %d", "adding blank lines", blank_lines);
while (blank_lines > 0) {
int x;
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++;
}
@@ -746,7 +704,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--;
}
}
@@ -756,16 +714,16 @@ int pv_watchpid_loop(pvstate_t state)
*/
blank_lines = prev_displayed_lines;
while (blank_lines > 0) {
int x;
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--;
}
+29 -25
View File
@@ -1,43 +1,47 @@
/*
* 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'.
*/
#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
* including <ctype.h> causes weird versioned glibc dependencies on certain
* Red Hat systems, complicating package management.
*/
static int pv__isdigit(char c)
static bool pv__isdigit(char c)
{
return ((c >= '0') && (c <= '9'));
return ((c >= '0') && (c <= '9')) ? true : false;
}
/*
* Return the numeric value of "str", as a long long.
* Return the numeric value of "str", as an unsigned long long.
*/
long long pv_getnum_ll(const char *str)
unsigned long long pv_getnum_ull(const char *str)
{
long long n = 0;
long long decimal = 0;
int decdivisor = 1;
int shift = 0;
unsigned long long n = 0;
unsigned long long decimal = 0;
unsigned int decdivisor = 1;
unsigned int shift = 0;
if (0 == str)
if (NULL == str)
return n;
while (str[0] != 0 && (!pv__isdigit(str[0])))
while (str[0] != '\0' && (!pv__isdigit(str[0])))
str++;
for (; pv__isdigit(str[0]); str++) {
n = n * 10;
n += (str[0] - '0');
n += (unsigned long long) (str[0] - '0');
}
/*
@@ -48,7 +52,7 @@ long long pv_getnum_ll(const char *str)
for (; pv__isdigit(str[0]); str++) {
if (decdivisor < 10000) {
decimal = decimal * 10;
decimal += (str[0] - '0');
decimal += (unsigned long long) (str[0] - '0');
decdivisor = decdivisor * 10;
}
}
@@ -58,7 +62,7 @@ long long pv_getnum_ll(const char *str)
* Parse any units given (K=KiB=*1024, M=MiB=1024KiB, G=GiB=1024MiB,
* T=TiB=1024GiB).
*/
if (str[0]) {
if (str[0] != '\0') {
while ((' ' == str[0]) || ('\t' == str[0]))
str++;
switch (str[0]) {
@@ -89,7 +93,7 @@ long long pv_getnum_ll(const char *str)
* more than 30 at a time to avoid overflows.
*/
while (shift > 0) {
int shiftby;
unsigned int shiftby;
shiftby = shift;
if (shiftby > 30)
@@ -118,15 +122,15 @@ double pv_getnum_d(const char *str)
double n = 0.0;
double step = 1;
if (0 == str)
if (NULL == str)
return n;
while (str[0] != 0 && (!pv__isdigit(str[0])))
while (str[0] != '\0' && (!pv__isdigit(str[0])))
str++;
for (; pv__isdigit(str[0]); str++) {
n = n * 10;
n += (str[0] - '0');
n += (double) (str[0] - '0');
}
if ((str[0] != '.') && (str[0] != ','))
@@ -136,7 +140,7 @@ double pv_getnum_d(const char *str)
for (; pv__isdigit(str[0]) && step < 1000000; str++) {
step = step * 10;
n += (str[0] - '0') / step;
n += ((double) (str[0] - '0')) / step;
}
return n;
@@ -144,11 +148,11 @@ double pv_getnum_d(const char *str)
/*
* Return the numeric value of "str", as an int.
* Return the numeric value of "str", as an unsigned int.
*/
int pv_getnum_i(const char *str)
unsigned int pv_getnum_ui(const char *str)
{
return (int) pv_getnum_ll(str);
return (unsigned int) pv_getnum_ull(str);
}
@@ -176,7 +180,7 @@ int pv_getnum_check(const char *str, pv_numtype_t type)
for (; pv__isdigit(str[0]); str++);
}
if (0 == str[0])
if ('\0' == str[0])
return 0;
/*
@@ -202,7 +206,7 @@ int pv_getnum_check(const char *str, pv_numtype_t type)
return 1;
}
if (str[0] != 0)
if (str[0] != '\0')
return 1;
return 0;
+19 -10
View File
@@ -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>
@@ -25,7 +31,8 @@ static pvstate_t pv_sig_state = NULL;
* subsequent SIGCONT we can try writing to the terminal again, in case we
* get backgrounded and later get foregrounded again.
*/
static void pv_sig_ttou(int s)
static void pv_sig_ttou( __attribute__((unused))
int s)
{
int fd;
@@ -45,7 +52,8 @@ static void pv_sig_ttou(int s)
* Handle SIGTSTP (stop typed at tty) by storing the time the signal
* happened for later use by pv_sig_cont(), and then stopping the process.
*/
static void pv_sig_tstp(int s)
static void pv_sig_tstp( __attribute__((unused))
int s)
{
gettimeofday(&(pv_sig_state->pv_sig_tstp_time), NULL);
raise(SIGSTOP);
@@ -57,7 +65,8 @@ static void pv_sig_tstp(int s)
* last SIGTSTP to the elapsed time offset, and by trying to write to the
* terminal again (by replacing the /dev/null stderr with the old stderr).
*/
static void pv_sig_cont(int s)
static void pv_sig_cont( __attribute__((unused))
int s)
{
struct timeval tv;
struct termios t;
@@ -76,10 +85,8 @@ static void pv_sig_cont(int s)
gettimeofday(&tv, NULL);
pv_sig_state->pv_sig_toffset.tv_sec +=
(tv.tv_sec - pv_sig_state->pv_sig_tstp_time.tv_sec);
pv_sig_state->pv_sig_toffset.tv_usec +=
(tv.tv_usec - pv_sig_state->pv_sig_tstp_time.tv_usec);
pv_sig_state->pv_sig_toffset.tv_sec += (tv.tv_sec - pv_sig_state->pv_sig_tstp_time.tv_sec);
pv_sig_state->pv_sig_toffset.tv_usec += (tv.tv_usec - pv_sig_state->pv_sig_tstp_time.tv_usec);
if (pv_sig_state->pv_sig_toffset.tv_usec >= 1000000) {
pv_sig_state->pv_sig_toffset.tv_sec++;
pv_sig_state->pv_sig_toffset.tv_usec -= 1000000;
@@ -111,7 +118,8 @@ static void pv_sig_cont(int s)
/*
* Handle SIGWINCH (window size changed) by setting a flag.
*/
static void pv_sig_winch(int s)
static void pv_sig_winch( __attribute__((unused))
int s)
{
pv_sig_state->pv_sig_newsize = 1;
}
@@ -120,7 +128,8 @@ static void pv_sig_winch(int s)
/*
* Handle termination signals by setting the abort flag.
*/
static void pv_sig_term(int s)
static void pv_sig_term( __attribute__((unused))
int s)
{
pv_sig_state->pv_sig_abort = 1;
}
@@ -211,7 +220,7 @@ void pv_sig_init(pvstate_t state)
/*
* Shut down signal handling.
*/
void pv_sig_fini(pvstate_t state)
void pv_sig_fini( __attribute__((unused)) pvstate_t state)
{
sigaction(SIGPIPE, &(pv_sig_state->pv_sig_old_sigpipe), NULL);
sigaction(SIGTTOU, &(pv_sig_state->pv_sig_old_sigttou), NULL);
+102 -31
View File
@@ -1,14 +1,40 @@
/*
* 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>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
/* alloc / realloc history buffer */
static void pv_alloc_history(pvstate_t state)
{
if (NULL != state->history)
free(state->history);
state->history = NULL;
state->history = calloc(state->history_len, sizeof(state->history[0]));
if (NULL == state->history) {
fprintf(stderr, "%s: %s: %s\n", state->program_name,
_("history structure allocation failed"), strerror(errno));
return;
}
state->history_first = state->history_last = 0;
state->history[0].elapsed_sec = 0.0; /* to be safe, memset() not recommended for doubles */
}
/*
* Create a new state structure, and return it, or 0 (NULL) on error.
*/
@@ -17,8 +43,8 @@ pvstate_t pv_state_alloc(const char *program_name)
pvstate_t state;
state = calloc(1, sizeof(*state));
if (0 == state)
return 0;
if (NULL == state)
return NULL;
state->program_name = program_name;
state->watch_pid = 0;
@@ -34,7 +60,21 @@ pvstate_t pv_state_alloc(const char *program_name)
#ifdef HAVE_SPLICE
state->splice_failed_fd = -1;
#endif /* HAVE_SPLICE */
state->display_visible = 0;
state->display_visible = false;
/*
* Get the current working directory, if possible, as a base for
* showing relative filenames with --watchfd.
*/
if (NULL == getcwd(state->cwd, PV_SIZEOF_CWD - 1)) {
/* failed - will always show full path */
state->cwd[0] = '\0';
}
if ('\0' == state->cwd[1]) {
/* CWD is root directory - always show full path */
state->cwd[0] = '\0';
}
state->cwd[PV_SIZEOF_CWD - 1] = '\0';
return state;
}
@@ -48,14 +88,18 @@ void pv_state_free(pvstate_t state)
if (0 == state)
return;
if (state->display_buffer)
if (NULL != state->display_buffer)
free(state->display_buffer);
state->display_buffer = NULL;
if (state->transfer_buffer)
if (NULL != state->transfer_buffer)
free(state->transfer_buffer);
state->transfer_buffer = NULL;
if (NULL != state->history)
free(state->history);
state->history = NULL;
free(state);
return;
@@ -65,20 +109,18 @@ void pv_state_free(pvstate_t state)
/*
* Set the formatting string, given a set of old-style formatting options.
*/
void pv_state_set_format(pvstate_t state, unsigned char progress,
unsigned char timer, unsigned char eta,
unsigned char fineta, unsigned char rate,
unsigned char average_rate, unsigned char bytes,
unsigned char bufpercent,
unsigned int lastwritten, const char *name)
void pv_state_set_format(pvstate_t state, bool progress,
bool timer, bool eta,
bool fineta, bool rate,
bool average_rate, bool bytes, bool bufpercent, unsigned int lastwritten, const char *name)
{
#define PV_ADDFORMAT(x,y) if (x) { \
if (state->default_format[0] != 0) \
strcat(state->default_format, " "); \
strcat(state->default_format, y); \
if (state->default_format[0] != '\0') \
pv_strlcat(state->default_format, " ", sizeof(state->default_format)); \
pv_strlcat(state->default_format, y, sizeof(state->default_format)); \
}
state->default_format[0] = 0;
state->default_format[0] = '\0';
PV_ADDFORMAT(name, "%N");
PV_ADDFORMAT(bytes, "%b");
PV_ADDFORMAT(bufpercent, "%T");
@@ -90,8 +132,9 @@ void pv_state_set_format(pvstate_t state, unsigned char progress,
PV_ADDFORMAT(fineta, "%I");
if (lastwritten > 0) {
char buf[16];
sprintf(buf, "%%%uA", lastwritten);
PV_ADDFORMAT(lastwritten, buf);
memset(buf, 0, sizeof(buf));
(void) pv_snprintf(buf, sizeof(buf), "%%%uA", lastwritten);
PV_ADDFORMAT(lastwritten > 0, buf);
}
state->name = name;
@@ -99,22 +142,22 @@ void pv_state_set_format(pvstate_t state, unsigned char progress,
}
void pv_state_force_set(pvstate_t state, unsigned char val)
void pv_state_force_set(pvstate_t state, bool val)
{
state->force = val;
}
void pv_state_cursor_set(pvstate_t state, unsigned char val)
void pv_state_cursor_set(pvstate_t state, bool val)
{
state->cursor = val;
};
void pv_state_numeric_set(pvstate_t state, unsigned char val)
void pv_state_numeric_set(pvstate_t state, bool val)
{
state->numeric = val;
};
void pv_state_wait_set(pvstate_t state, unsigned char val)
void pv_state_wait_set(pvstate_t state, bool val)
{
state->wait = val;
};
@@ -124,43 +167,58 @@ void pv_state_delay_start_set(pvstate_t state, double val)
state->delay_start = val;
};
void pv_state_linemode_set(pvstate_t state, unsigned char val)
void pv_state_linemode_set(pvstate_t state, bool val)
{
state->linemode = val;
};
void pv_state_null_set(pvstate_t state, unsigned char val)
void pv_state_bits_set(pvstate_t state, bool bits)
{
state->bits = bits;
};
void pv_state_null_set(pvstate_t state, bool val)
{
state->null = val;
};
void pv_state_no_op_set(pvstate_t state, unsigned char val)
void pv_state_no_op_set(pvstate_t state, bool val)
{
state->no_op = val;
};
void pv_state_skip_errors_set(pvstate_t state, unsigned char val)
void pv_state_skip_errors_set(pvstate_t state, unsigned int val)
{
state->skip_errors = val;
};
void pv_state_stop_at_size_set(pvstate_t state, unsigned char val)
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;
};
void pv_state_target_buffer_size_set(pvstate_t state,
unsigned long long val)
void pv_state_target_buffer_size_set(pvstate_t state, unsigned long long val)
{
state->target_buffer_size = val;
};
void pv_state_no_splice_set(pvstate_t state, unsigned char val)
void pv_state_no_splice_set(pvstate_t state, bool val)
{
state->no_splice = val;
};
@@ -205,12 +263,25 @@ void pv_state_watch_fd_set(pvstate_t state, int val)
state->watch_fd = val;
};
void pv_state_average_rate_window_set(pvstate_t state, int val)
{
if (val < 1)
val = 1;
if (val >= 20) {
state->history_len = val / 5 + 1;
state->history_interval = 5;
} else {
state->history_len = val + 1;
state->history_interval = 1;
}
pv_alloc_history(state);
};
/*
* Set the array of input files.
*/
void pv_state_inputfiles(pvstate_t state, int input_file_count,
const char **input_files)
void pv_state_inputfiles(pvstate_t state, int input_file_count, const char **input_files)
{
state->input_file_count = input_file_count;
state->input_files = input_files;
+96
View File
@@ -0,0 +1,96 @@
/*
* 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 */
+191 -139
View File
@@ -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>
@@ -42,10 +48,7 @@ static ssize_t pv__transfer_read_repeated(int fd, void *buf, size_t count)
struct timeval now;
long elapsed_usec;
nread =
read(fd, buf,
count >
MAX_READ_AT_ONCE ? MAX_READ_AT_ONCE : count);
nread = read(fd, buf, count > MAX_READ_AT_ONCE ? MAX_READ_AT_ONCE : count);
if (nread < 0)
return nread;
@@ -57,13 +60,10 @@ static ssize_t pv__transfer_read_repeated(int fd, void *buf, size_t count)
return total_read;
gettimeofday(&now, NULL);
elapsed_usec =
1000000 * (now.tv_sec - start_time.tv_sec) +
(now.tv_usec - start_time.tv_usec);
elapsed_usec = 1000000 * (now.tv_sec - start_time.tv_sec) + (now.tv_usec - start_time.tv_usec);
if (elapsed_usec > TRANSFER_READ_TIMEOUT) {
debug("%s %d: %s (%ld %s)", "fd", fd,
"stopping read - timer expired",
elapsed_usec, "usec elapsed");
"stopping read - timer expired", elapsed_usec, "usec elapsed");
return total_read;
}
@@ -77,8 +77,7 @@ static ssize_t pv__transfer_read_repeated(int fd, void *buf, size_t count)
FD_SET(fd, &readfds);
debug("%s %d: %s (%ld %s, %ld %s)", "fd", fd,
"trying another read after partial buffer fill",
nread, "read", count, "remaining");
"trying another read after partial buffer fill", nread, "read", count, "remaining");
if (select(fd + 1, &readfds, NULL, NULL, &tv) < 1)
break;
@@ -97,10 +96,12 @@ 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;
@@ -115,10 +116,23 @@ static ssize_t pv__transfer_write_repeated(int fd, void *buf, size_t count)
long elapsed_usec;
size_t asked_to_write;
asked_to_write = count >
MAX_WRITE_AT_ONCE ? MAX_WRITE_AT_ONCE : count;
asked_to_write = 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)) {
/*
@@ -143,13 +157,10 @@ static ssize_t pv__transfer_write_repeated(int fd, void *buf, size_t count)
return total_written;
gettimeofday(&now, NULL);
elapsed_usec =
1000000 * (now.tv_sec - start_time.tv_sec) +
(now.tv_usec - start_time.tv_usec);
elapsed_usec = 1000000 * (now.tv_sec - start_time.tv_sec) + (now.tv_usec - start_time.tv_usec);
if (elapsed_usec > TRANSFER_WRITE_TIMEOUT) {
debug("%s %d: %s (%ld %s)", "fd", fd,
"stopping write - timer expired",
elapsed_usec, "usec elapsed");
"stopping write - timer expired", elapsed_usec, "usec elapsed");
return total_written;
}
@@ -160,22 +171,23 @@ static ssize_t pv__transfer_write_repeated(int fd, void *buf, size_t count)
* out of time - also on our gettimeofday() check.
*/
if (count > 0) {
#if 0 /* disabled after 1.6.0 - see comment above */
fd_set writefds;
struct timeval tv;
tv.tv_sec = 0;
tv.tv_usec = 0;
FD_ZERO(&writefds);
FD_SET(fd, &writefds);
#endif
debug("%s %d: %s (%ld %s, %ld %s)", "fd", fd,
"trying another write after partial buffer flush",
nwritten, "written", count, "remaining");
# if 0 /* disabled after 1.6.0 - see comment above */
#if 0 /* disabled after 1.6.0 - see comment above */
tv.tv_sec = 0;
tv.tv_usec = 0;
FD_ZERO(&writefds);
FD_SET(fd, &writefds);
if (select(fd + 1, NULL, &writefds, NULL, &tv) < 1)
break;
# endif
#endif
}
}
@@ -209,11 +221,9 @@ static ssize_t pv__transfer_write_repeated(int fd, void *buf, size_t count)
* sets *eof_in to 1. If all data in the buffer has been written at this
* point, then also sets *eof_out.
*/
static int pv__transfer_read(pvstate_t state, int fd,
int *eof_in, int *eof_out,
unsigned long long allowed,
long *lineswritten)
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 +234,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
@@ -236,13 +250,11 @@ static int pv__transfer_read(pvstate_t state, int fd,
else
bytes_to_splice = bytes_can_read;
nread = splice(fd, NULL, STDOUT_FILENO, NULL,
bytes_to_splice, SPLICE_F_MORE);
nread = splice(fd, NULL, STDOUT_FILENO, NULL, bytes_to_splice, SPLICE_F_MORE);
state->splice_used = 1;
if ((nread < 0) && (EINVAL == errno)) {
debug("%s %d: %s", "fd", fd,
"splice failed with EINVAL - disabling");
debug("%s %d: %s", "fd", fd, "splice failed with EINVAL - disabling");
state->splice_failed_fd = fd;
state->splice_used = 0;
/*
@@ -250,6 +262,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 {
@@ -258,18 +288,10 @@ static int pv__transfer_read(pvstate_t state, int fd,
}
}
if (0 == state->splice_used) {
nread =
pv__transfer_read_repeated(fd,
state->transfer_buffer +
state->read_position,
bytes_can_read);
nread = pv__transfer_read_repeated(fd, state->transfer_buffer + state->read_position, bytes_can_read);
}
#else
nread =
pv__transfer_read_repeated(fd,
state->transfer_buffer +
state->read_position,
bytes_can_read);
nread = pv__transfer_read_repeated(fd, state->transfer_buffer + state->read_position, bytes_can_read);
#endif /* HAVE_SPLICE */
@@ -314,9 +336,7 @@ static int pv__transfer_read(pvstate_t state, int fd,
*/
if ((EINTR == errno) || (EAGAIN == errno)) {
struct timeval tv;
debug("%s %d: %s: %s", "fd", fd,
"transient error - waiting briefly",
strerror(errno));
debug("%s %d: %s: %s", "fd", fd, "transient error - waiting briefly", strerror(errno));
tv.tv_sec = 0;
tv.tv_usec = 10000;
select(0, NULL, NULL, NULL, &tv);
@@ -335,10 +355,8 @@ 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) {
pv_error(state, "%s: %s: %s",
state->current_file,
_("read failed"), strerror(errno));
if (do_not_skip_errors) {
pv_error(state, "%s: %s: %s", state->current_file, _("read failed"), strerror(errno));
*eof_in = 1;
if (state->write_position >= state->read_position) {
*eof_out = 1;
@@ -353,15 +371,11 @@ static int pv__transfer_read(pvstate_t state, int fd,
amount_skipped = -1;
if (!state->read_error_warning_shown) {
pv_error(state, "%s: %s: %s",
state->current_file,
_
("warning: read errors detected"),
strerror(errno));
pv_error(state, "%s: %s: %s", state->current_file, _("warning: read errors detected"), strerror(errno));
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
@@ -369,9 +383,7 @@ static int pv__transfer_read(pvstate_t state, int fd,
* of the file.
*/
if (0 > orig_offset) {
pv_error(state, "%s: %s: %s",
state->current_file,
_("file is not seekable"), strerror(errno));
pv_error(state, "%s: %s: %s", state->current_file, _("file is not seekable"), strerror(errno));
*eof_in = 1;
if (state->write_position >= state->read_position) {
*eof_out = 1;
@@ -406,7 +418,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
@@ -414,8 +426,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);
skip_offset = lseek(fd, orig_offset + amount_to_skip, SEEK_SET);
}
if (skip_offset < 0) {
@@ -431,11 +442,7 @@ static int pv__transfer_read(pvstate_t state, int fd,
*/
if (EINVAL != errno) {
pv_error(state,
"%s: %s: %s",
state->current_file,
_
("failed to seek past error"),
strerror(errno));
"%s: %s: %s", state->current_file, _("failed to seek past error"), strerror(errno));
}
} else {
amount_skipped = skip_offset - orig_offset;
@@ -446,16 +453,12 @@ static int pv__transfer_read(pvstate_t state, int fd,
* of the transfer buffer, and update the buffer position.
*/
if (amount_skipped > 0) {
memset(state->transfer_buffer +
state->read_position, 0, amount_skipped);
memset(state->transfer_buffer + state->read_position, 0, amount_skipped);
state->read_position += amount_skipped;
if (state->skip_errors < 2) {
pv_error(state, "%s: %s: %ld - %ld (%ld %s)",
state->current_file,
_
("skipped past read error"),
orig_offset,
skip_offset, amount_skipped, _("B"));
_("skipped past read error"), orig_offset, skip_offset, amount_skipped, _("B"));
}
} else {
/*
@@ -484,9 +487,7 @@ static int pv__transfer_read(pvstate_t state, int fd,
* On error, sets *eof_out to 1, sets state->written to -1, and updates
* state->exit_status.
*/
static int pv__transfer_write(pvstate_t state, int fd,
int *eof_in, int *eof_out,
long *lineswritten)
static int pv__transfer_write(pvstate_t state, int *eof_in, int *eof_out, long *lineswritten)
{
ssize_t nwritten;
@@ -495,8 +496,7 @@ static int pv__transfer_write(pvstate_t state, int fd,
nwritten = pv__transfer_write_repeated(STDOUT_FILENO,
state->transfer_buffer +
state->write_position,
state->to_write);
state->write_position, state->to_write, state->sync_after_write);
alarm(0);
@@ -518,33 +518,25 @@ static int pv__transfer_write(pvstate_t state, int fd,
char *ptr;
long lines = 0;
save =
state->transfer_buffer[state->write_position +
nwritten];
state->transfer_buffer[state->write_position +
nwritten] = 0;
ptr =
(char *) (state->transfer_buffer +
state->write_position - 1);
save = state->transfer_buffer[state->write_position + nwritten];
state->transfer_buffer[state->write_position + nwritten] = 0;
ptr = (char *) (state->transfer_buffer + state->write_position - 1);
if (state->null) {
for (ptr++;
ptr -
(char *) state->transfer_buffer -
state->write_position < nwritten;
ptr++) {
state->write_position < (size_t) nwritten; ptr++) {
if (*ptr == '\0')
++lines;
}
} else {
while ((ptr =
strchr((char *) (ptr + 1), '\n')))
while ((ptr = strchr((char *) (ptr + 1), '\n')))
++lines;
}
*lineswritten += lines;
state->transfer_buffer[state->write_position +
nwritten] = save;
state->transfer_buffer[state->write_position + nwritten] = save;
}
state->write_position += nwritten;
@@ -560,20 +552,16 @@ static int pv__transfer_write(pvstate_t state, int fd,
new_portion_length = nwritten;
if (new_portion_length > state->lastoutput_length)
new_portion_length =
state->lastoutput_length;
new_portion_length = state->lastoutput_length;
old_portion_length =
state->lastoutput_length - new_portion_length;
old_portion_length = state->lastoutput_length - new_portion_length;
/*
* Make room for the new portion.
*/
if (old_portion_length > 0) {
memmove(state->lastoutput_buffer,
state->lastoutput_buffer +
new_portion_length,
old_portion_length);
state->lastoutput_buffer + new_portion_length, old_portion_length);
}
/*
@@ -581,9 +569,7 @@ static int pv__transfer_write(pvstate_t state, int fd,
*/
memcpy(state->lastoutput_buffer +
old_portion_length,
state->transfer_buffer +
state->write_position - new_portion_length,
new_portion_length);
state->transfer_buffer + state->write_position - new_portion_length, new_portion_length);
}
/*
@@ -637,6 +623,60 @@ static int pv__transfer_write(pvstate_t state, int fd,
}
/*
* 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
@@ -648,8 +688,7 @@ static int pv__transfer_write(pvstate_t state, int fd,
* state->exit_status is updated). In line mode, the number of lines written
* will be put into *lineswritten.
*/
long pv_transfer(pvstate_t state, int fd, int *eof_in, int *eof_out,
unsigned long long allowed, long *lineswritten)
long pv_transfer(pvstate_t state, int fd, int *eof_in, int *eof_out, unsigned long long allowed, long *lineswritten)
{
struct timeval tv;
fd_set readfds;
@@ -660,6 +699,23 @@ 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,27 +726,30 @@ 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);
state->transfer_buffer = pv__allocate_aligned_buffer(fd, state->target_buffer_size + 32);
if (NULL == state->transfer_buffer) {
pv_error(state, "%s: %s",
_("buffer allocation failed"),
strerror(errno));
pv_error(state, "%s: %s", _("buffer allocation failed"), strerror(errno));
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);
newptr = pv__allocate_aligned_buffer(fd, state->target_buffer_size + 32);
if (NULL == newptr) {
/*
* Reset target if realloc failed so we don't keep
@@ -699,8 +758,14 @@ long pv_transfer(pvstate_t state, int fd, int *eof_in, int *eof_out,
debug("realloc: %s", strerror(errno));
state->target_buffer_size = state->buffer_size;
} else {
debug("%s: %ld", "buffer resized",
state->buffer_size);
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;
}
@@ -738,7 +803,7 @@ long pv_transfer(pvstate_t state, int fd, int *eof_in, int *eof_out,
*/
state->to_write = state->read_position - state->write_position;
if ((state->rate_limit > 0) || (allowed > 0)) {
if (state->to_write > allowed) {
if ((unsigned long long) (state->to_write) > allowed) {
state->to_write = allowed;
}
}
@@ -765,9 +830,7 @@ long pv_transfer(pvstate_t state, int fd, int *eof_in, int *eof_out,
/*
* Any other error is a problem and we must report back.
*/
pv_error(state, "%s: %s: %d: %s",
state->current_file,
_("select call failed"), n, strerror(errno));
pv_error(state, "%s: %s: %d: %s", state->current_file, _("select call failed"), n, strerror(errno));
state->exit_status |= 16;
@@ -783,9 +846,7 @@ long pv_transfer(pvstate_t state, int fd, int *eof_in, int *eof_out,
* NB this can update state->written because of splice().
*/
if (FD_ISSET(fd, &readfds)) {
if (pv__transfer_read
(state, fd, eof_in, eof_out, allowed,
lineswritten) == 0)
if (pv__transfer_read(state, fd, eof_in, eof_out, allowed) == 0)
return 0;
}
@@ -801,18 +862,12 @@ long pv_transfer(pvstate_t state, int fd, int *eof_in, int *eof_out,
char *start;
char *end;
save =
state->transfer_buffer[state->write_position +
state->to_write];
state->transfer_buffer[state->write_position +
state->to_write] = 0;
save = state->transfer_buffer[state->write_position + state->to_write];
state->transfer_buffer[state->write_position + state->to_write] = 0;
start =
(char *) (state->transfer_buffer +
state->write_position);
start = (char *) (state->transfer_buffer + state->write_position);
end = strrchr(start, '\n');
state->transfer_buffer[state->write_position +
state->to_write] = save;
state->transfer_buffer[state->write_position + state->to_write] = save;
if (end != NULL) {
state->to_write = (end - start) + 1;
@@ -830,8 +885,7 @@ long pv_transfer(pvstate_t state, int fd, int *eof_in, int *eof_out,
#endif /* HAVE_SPLICE */
&& (state->read_position > state->write_position)
&& (state->to_write > 0)) {
if (pv__transfer_write
(state, fd, eof_in, eof_out, lineswritten) == 0)
if (pv__transfer_write(state, eof_in, eof_out, lineswritten) == 0)
return 0;
}
#ifdef MAXIMISE_BUFFER_FILL
@@ -843,9 +897,7 @@ long pv_transfer(pvstate_t state, int fd, int *eof_in, int *eof_out,
if (state->write_position < state->read_position) {
memmove(state->transfer_buffer,
state->transfer_buffer +
state->write_position,
state->read_position -
state->write_position);
state->write_position, state->read_position - state->write_position);
state->read_position -= state->write_position;
state->write_position = 0;
} else {
+224 -100
View File
@@ -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>
@@ -20,6 +26,89 @@
#include <sys/types.h>
#include <dirent.h>
#ifdef __APPLE__
#include <libproc.h>
#include <sys/proc_info.h>
#endif
int filesize(pvwatchfd_t info)
{
if (S_ISBLK(info->sb_fd.st_mode)) {
int fd;
/*
* Get the size of block devices by opening
* them and seeking to the end.
*/
fd = open(info->file_fdpath, O_RDONLY);
if (fd >= 0) {
info->size = lseek(fd, 0, SEEK_END);
close(fd);
} else {
info->size = 0;
}
} else if (S_ISREG(info->sb_fd.st_mode)) {
if ((info->sb_fd_link.st_mode & S_IWUSR) == 0) {
info->size = info->sb_fd.st_size;
}
} else {
return 4;
}
return 0;
}
#ifdef __APPLE__
int pv_watchfd_info(pvstate_t state, pvwatchfd_t info, int automatic)
{
struct vnode_fdinfowithpath vnodeInfo = { };
if (NULL == state)
return -1;
if (NULL == info)
return -1;
if (kill(info->watch_pid, 0) != 0) {
if (!automatic)
pv_error(state, "%s %u: %s", _("pid"), info->watch_pid, strerror(errno));
return 1;
}
int32_t proc_fd = (int32_t) info->watch_fd;
int size = proc_pidfdinfo(info->watch_pid, proc_fd,
PROC_PIDFDVNODEPATHINFO, &vnodeInfo,
PROC_PIDFDVNODEPATHINFO_SIZE);
if (size != PROC_PIDFDVNODEPATHINFO_SIZE) {
pv_error(state, "%s %u: %s %d: %s",
_("pid"), info->watch_pid, _("fd"), info->watch_fd, strerror(errno));
return 3;
}
strlcpy(info->file_fdpath, vnodeInfo.pvip.vip_path, PV_SIZEOF_FILE_FDPATH);
info->size = 0;
if (!(0 == stat(info->file_fdpath, &(info->sb_fd)))) {
if (!automatic)
pv_error(state, "%s %u: %s %d: %s: %s",
_("pid"),
info->watch_pid, _("fd"), info->watch_fd, info->file_fdpath, strerror(errno));
return 3;
}
if (filesize(info) != 0) {
if (!automatic)
pv_error(state, "%s %u: %s %d: %s: %s",
_("pid"),
info->watch_pid,
_("fd"), info->watch_fd, info->file_fdpath, _("not a regular file or block device"));
return 4;
}
return 0;
}
#else
/*
* Fill in the given information structure with the file paths and stat
@@ -47,86 +136,62 @@ int pv_watchfd_info(pvstate_t state, pvwatchfd_t info, int automatic)
if (kill(info->watch_pid, 0) != 0) {
if (!automatic)
pv_error(state, "%s %u: %s",
_("pid"),
info->watch_pid, strerror(errno));
pv_error(state, "%s %u: %s", _("pid"), info->watch_pid, strerror(errno));
return 1;
}
(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);
snprintf(info->file_fdinfo, sizeof(info->file_fdinfo) - 1,
"/proc/%u/fdinfo/%d", info->watch_pid, info->watch_fd);
snprintf(info->file_fd, sizeof(info->file_fd) - 1,
"/proc/%u/fd/%d", info->watch_pid, info->watch_fd);
if (readlink
(info->file_fd, info->file_fdpath,
sizeof(info->file_fdpath) - 1) < 0) {
memset(info->file_fdpath, 0, PV_SIZEOF_FILE_FDPATH);
if (readlink(info->file_fd, info->file_fdpath, PV_SIZEOF_FILE_FDPATH - 1) < 0) {
if (!automatic)
pv_error(state, "%s %u: %s %d: %s",
_("pid"),
info->watch_pid,
_("fd"), info->watch_fd, strerror(errno));
_("pid"), info->watch_pid, _("fd"), info->watch_fd, strerror(errno));
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"),
info->watch_pid,
_("fd"),
info->watch_fd, info->file_fdpath,
strerror(errno));
info->watch_pid, _("fd"), info->watch_fd, info->file_fdpath, strerror(errno));
return 3;
}
info->size = 0;
if (S_ISBLK(info->sb_fd.st_mode)) {
int fd;
/*
* Get the size of block devices by opening
* them and seeking to the end.
*/
fd = open64(info->file_fdpath, O_RDONLY);
if (fd >= 0) {
info->size = lseek64(fd, 0, SEEK_END);
close(fd);
} else {
info->size = 0;
}
} else if (S_ISREG(info->sb_fd.st_mode)) {
if ((info->sb_fd_link.st_mode & S_IWUSR) == 0) {
info->size = info->sb_fd.st_size;
}
} else {
int ret = filesize(info);
if (ret != 0) {
if (!automatic)
pv_error(state, "%s %u: %s %d: %s: %s",
_("pid"),
info->watch_pid,
_("fd"),
info->watch_fd,
info->file_fdpath,
_("not a regular file or block device"));
return 4;
_("fd"), info->watch_fd, info->file_fdpath, _("not a regular file or block device"));
return ret;
}
return 0;
}
#endif
#ifdef __APPLE__
int pv_watchfd_changed(pvwatchfd_t info)
{
return 1;
}
#else
/*
* Return nonzero if the given file descriptor has changed in some way since
* we started looking at it (i.e. changed destination or permissions).
*/
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)
@@ -139,6 +204,7 @@ int pv_watchfd_changed(pvwatchfd_t info)
return 0;
}
#endif
/*
@@ -148,6 +214,19 @@ int pv_watchfd_changed(pvwatchfd_t info)
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;
int size = proc_pidfdinfo(info->watch_pid, proc_fd,
PROC_PIDFDVNODEPATHINFO, &vnodeInfo,
PROC_PIDFDVNODEPATHINFO_SIZE);
if (size != PROC_PIDFDVNODEPATHINFO_SIZE) {
return -1;
}
position = (long long) vnodeInfo.pfi.fi_offset;
#else
FILE *fptr;
if (pv_watchfd_changed(info))
@@ -157,13 +236,38 @@ 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;
}
#ifdef __APPLE__
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) {
pv_error(state, "%s: unable to list pid fds: %s", _("pid"), strerror(errno));
return -1;
}
*count = size_needed / PROC_PIDLISTFD_SIZE;
*fds = (struct proc_fdinfo *) malloc(size_needed);
if (*fds == NULL) {
pv_error(state, "%s: alloc failed: %s", _("pid"), strerror(errno));
return -1;
}
proc_pidinfo(pid, PROC_PIDLISTFDS, 0, *fds, size_needed);
return 0;
}
#endif
/*
* Scan the given process and update the arrays with any new file
* descriptors.
@@ -173,35 +277,57 @@ long long pv_watchfd_position(pvwatchfd_t info)
*/
int pv_watchpid_scanfds(pvstate_t state, pvstate_t pristine,
unsigned int watch_pid, int *array_length_ptr,
pvwatchfd_t * info_array_ptr,
pvstate_t * state_array_ptr, int *fd_to_idx)
pvwatchfd_t * info_array_ptr, pvstate_t * state_array_ptr, int *fd_to_idx)
{
char fd_dir[512] = { 0, };
DIR *dptr;
struct dirent *d;
int array_length = 0;
struct pvwatchfd_s *info_array = NULL;
struct pvstate_s *state_array = NULL;
snprintf(fd_dir, sizeof(fd_dir) - 1, "/proc/%u/fd", watch_pid);
#ifdef __APPLE__
struct proc_fdinfo *fd_infos = NULL;
int fd_infos_count = 0;
if (pidfds(state, watch_pid, &fd_infos, &fd_infos_count) != 0) {
pv_error(state, "%s: pidfds failed", _("pid"));
return -1;
}
#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;
#endif
array_length = *array_length_ptr;
info_array = *info_array_ptr;
state_array = *state_array_ptr;
#ifdef __APPLE__
if (fd_infos_count < 1) {
pv_error(state, "%s: no fds found", _("pid"));
return -1;
}
for (int i = 0; i < fd_infos_count; i++) {
#else
while ((d = readdir(dptr)) != NULL) {
#endif
int fd, check_idx, use_idx, rc;
long long position_now;
fd = -1;
#ifdef __APPLE__
fd = fd_infos[i].proc_fd;
#else
if (sscanf(d->d_name, "%d", &fd) != 1)
continue;
if ((fd < 0) || (fd >= FD_SETSIZE))
continue;
#endif
/*
* Skip if this fd is already known to us.
*/
@@ -232,14 +358,9 @@ int pv_watchpid_scanfds(pvstate_t state, pvstate_t pristine,
use_idx = array_length - 1;
if (NULL == info_array) {
new_info_array =
malloc(array_length *
sizeof(*info_array));
new_info_array = malloc(array_length * sizeof(*info_array));
} else {
new_info_array =
realloc(info_array,
array_length *
sizeof(*info_array));
new_info_array = realloc(info_array, array_length * sizeof(*info_array));
}
if (NULL == new_info_array)
return 2;
@@ -248,14 +369,9 @@ int pv_watchpid_scanfds(pvstate_t state, pvstate_t pristine,
info_array[use_idx].watch_pid = 0;
if (NULL == state_array) {
new_state_array =
malloc(array_length *
sizeof(*state_array));
new_state_array = malloc(array_length * sizeof(*state_array));
} else {
new_state_array =
realloc(state_array,
array_length *
sizeof(*state_array));
new_state_array = realloc(state_array, array_length * sizeof(*state_array));
}
if (NULL == new_state_array)
return 2;
@@ -264,10 +380,8 @@ int pv_watchpid_scanfds(pvstate_t state, pvstate_t pristine,
*array_length_ptr = array_length;
for (check_idx = 0; check_idx < array_length;
check_idx++) {
state_array[check_idx].name =
info_array[check_idx].display_name;
for (check_idx = 0; check_idx < array_length; check_idx++) {
state_array[check_idx].name = info_array[check_idx].display_name;
state_array[check_idx].reparse_display = 1;
}
}
@@ -277,13 +391,16 @@ int pv_watchpid_scanfds(pvstate_t state, pvstate_t pristine,
/*
* Initialise the details of this new entry.
*/
memcpy(&(state_array[use_idx]), pristine,
sizeof(*pristine));
memset(&(info_array[use_idx]), 0,
sizeof(info_array[use_idx]));
memcpy(&(state_array[use_idx]), pristine, sizeof(*pristine));
memset(&(info_array[use_idx]), 0, sizeof(info_array[use_idx]));
info_array[use_idx].watch_pid = watch_pid;
info_array[use_idx].watch_fd = fd;
#ifdef __APPLE__
if (fd_infos[i].proc_fdtype != PROX_FDTYPE_VNODE) {
continue;
}
#endif
rc = pv_watchfd_info(state, &(info_array[use_idx]), 1);
/*
@@ -291,9 +408,7 @@ int pv_watchpid_scanfds(pvstate_t state, pvstate_t pristine,
*/
if ((rc != 0) && (rc != 4)) {
info_array[use_idx].watch_pid = 0;
debug("%s %d: %s: %d", "fd", fd,
"lookup failed - marking slot for re-use",
use_idx);
debug("%s %d: %s: %d", "fd", fd, "lookup failed - marking slot for re-use", use_idx);
continue;
}
@@ -304,18 +419,14 @@ int pv_watchpid_scanfds(pvstate_t state, pvstate_t pristine,
* show it.
*/
if (rc != 0) {
debug("%s %d: %s", "fd", fd,
"marking as not displayable");
debug("%s %d: %s", "fd", fd, "marking as not displayable");
info_array[use_idx].watch_fd = -1;
}
state_array[use_idx].size = info_array[use_idx].size;
if (state_array[use_idx].size < 1) {
char *fmt;
while (NULL !=
(fmt =
strstr(state_array[use_idx].default_format,
"%e"))) {
while (NULL != (fmt = strstr(state_array[use_idx].default_format, "%e"))) {
debug("%s", "zero size - removing ETA");
/* strlen-1 here to include trailing NUL */
memmove(fmt, fmt + 2, strlen(fmt) - 1);
@@ -323,8 +434,7 @@ int pv_watchpid_scanfds(pvstate_t state, pvstate_t pristine,
}
}
state_array[use_idx].name =
info_array[use_idx].display_name;
state_array[use_idx].name = info_array[use_idx].display_name;
pv_watchpid_setname(state, &(info_array[use_idx]));
@@ -342,7 +452,12 @@ int pv_watchpid_scanfds(pvstate_t state, pvstate_t pristine,
}
}
#ifdef __APPLE__
free(fd_infos);
#else
closedir(dptr);
#endif
return 0;
}
@@ -351,35 +466,44 @@ int pv_watchpid_scanfds(pvstate_t state, pvstate_t pristine,
/*
* Set the display name for the given watched file descriptor, truncating at
* the relevant places according to the current screen width.
*
* If the file descriptor is pointing to a file under the current working
* directory, show its relative path, not the full path.
*/
void pv_watchpid_setname(pvstate_t state, pvwatchfd_t info)
{
int path_length, max_display_length;
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);
if (cwd_length > 0 && path_length > cwd_length) {
if (0 == strncmp(info->file_fdpath, state->cwd, cwd_length)) {
file_fdpath += cwd_length + 1;
path_length -= cwd_length + 1;
}
}
max_display_length = (state->width / 2) - 6;
if (max_display_length >= path_length) {
snprintf(info->display_name,
sizeof(info->display_name) - 1, "%4d:%s",
info->watch_fd, info->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;
snprintf(info->display_name,
sizeof(info->display_name) - 1, "%4d:%.*s...%.*s",
info->watch_fd, prefix_length, info->file_fdpath,
suffix_length,
info->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,
info->display_name);
debug("%s: %d: [%s]", "set name for fd", info->watch_fd, info->display_name);
}
/* EOF */
-8
View File
@@ -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
-12
View File
@@ -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
-13
View File
@@ -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
-13
View File
@@ -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
-14
View File
@@ -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
-20
View File
@@ -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
# 8 or more - not OK, since even on a heavily loaded system that's too long.
#
test $NUM -lt 8
# EOF
-20
View File
@@ -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
-10
View File
@@ -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
-18
View File
@@ -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
-9
View File
@@ -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
-26
View File
@@ -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
-26
View File
@@ -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
-25
View File
@@ -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
-53
View File
@@ -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
-20
View File
@@ -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
-19
View File
@@ -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
-32
View File
@@ -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
-54
View File
@@ -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
-28
View File
@@ -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
+17
View File
@@ -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
+21
View File
@@ -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
+17
View File
@@ -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
+34
View File
@@ -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
+35
View File
@@ -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
+34
View File
@@ -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
+41
View File
@@ -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
+19
View File
@@ -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

Some files were not shown because too many files have changed in this diff Show More