cpipe-3.0.2/000075500000000000000000000000001213266326600126215ustar00rootroot00000000000000cpipe-3.0.2/.CVS-Versions000064400000000000000000000012401213266326600150600ustar00rootroot00000000000000 Repository revision: 1.5 /cvsroot/cpipe/cpipe/.cvsignore,v Repository revision: 1.5 /cvsroot/cpipe/cpipe/.version,v Repository revision: 1.8 /cvsroot/cpipe/cpipe/Brasfile,v Repository revision: 1.1 /cvsroot/cpipe/cpipe/COPYING-2.0,v Repository revision: 1.4 /cvsroot/cpipe/cpipe/README,v Repository revision: 1.6 /cvsroot/cpipe/cpipe/cmdline.cli,v Repository revision: 1.7 /cvsroot/cpipe/cpipe/cpipe.c,v Repository revision: 1.3 /cvsroot/cpipe/cpipe/cpipe.spec,v Repository revision: 1.1 /cvsroot/cpipe/cpipe/dir.ttml,v Repository revision: 1.4 /cvsroot/cpipe/cpipe/index.html.in,v Repository revision: 1.6 /cvsroot/cpipe/cpipe/makefile,v cpipe-3.0.2/.cvsignore000064400000000000000000000001031213266326600146130ustar00rootroot00000000000000cpipe cmdline.c cmdline.h cpipe.1 *.dc index.html *.tar.gz CHANGES cpipe-3.0.2/.version000064400000000000000000000000201213266326600142770ustar00rootroot00000000000000VERSION = 3.0.2 cpipe-3.0.2/Brasfile000064400000000000000000000053441213266326600143010ustar00rootroot00000000000000######################################################################## # # If you wonder what this strange file might be, go to # http://wsd.iitb.fhg.de/~kir/brashome/ # to find out that it is a kind of makefile, but with Tcl-syntax. It # should however not be necessary to install cpipe. Just run make. # # $Revision: 1.8 $, $Date: 2003/07/22 08:38:00 $ ######################################################################## include $::bras::base/c2o.rule include $::bras::base/o2x.rule include $::bras::base/cdeps.rule include $::bras::base/cli2ch.rule ######################################################################## set VERSION [lindex [exec cat .version] 2] getenv RPMDIR [file join [glob ~] rpm RPMS i386] getenv TGZDIR . ;#[file join [glob ~] rpm SOURCES] set TGZ [file join $TGZDIR cpipe-$VERSION.tar.gz] set RPM [file join $RPMDIR cpipe-$VERSION-0.i386.rpm] set CFLAGS {-O2 -W -Wall -ansi -pedantic} ######################################################################## ## My assorted goodies for tcl have `forfile' #package require agft #namespace import ::agft::forfile ## find the list of all files cvs knows about set CVSDEPS [::bras::cvsknown] #set in [open "|cvs -q log -h" r] # forfile line $in { # if {[regexp {^Working file: *(.*)} $line d file]} { # set f [string trim $file "\t "] # if {[file exist $f]} { # lappend CVSDEPS [string trim $file "\t "] # } # } # } ######################################################################## Newer cpipe cmdline.o Newer cpipe.1 cmdline.cli Always clean {} { rm -f [glob -nocomplain *.o cmdline.\[ch\] *.dc *~] cpipe cpipe.1 } Always tgz $TGZ { # just a link to make the tgz } Always rpm $RPM { # just a link to make the rpm } Newer $TGZ [concat $CVSDEPS cmdline.c cmdline.h cpipe.1] { ship -d $TGZDIR -F -I cmdline.c cmdline.h cpipe.1 -e cpipe.spec } Newer $RPM $TGZ { rpm --quiet -tb $TGZ } Newer index.html index.html.in { catch {file delete -force $target} set out [open $target w] puts $out "" close $out sed -e "s/|VERSION|/$VERSION/g" >$target file attributes $target -permissions 0444 } Newer CHANGES $TGZ { tar xzfO $TGZ cpipe-$VERSION/CHANGES >CHANGES } Make publish {[updated {publish-www publish-tgz}]} .relax. Make publish-www {[updated {publish-CHANGES publish-index}]} .relax. Make publish-CHANGES {[updated CHANGES]} { scp CHANGES \ pifpafpuf@shell.berlios.de:/home/groups/cpipe/htdocs/ } Make publish-index {[updated index.html]} { scp index.html \ pifpafpuf@shell.berlios.de:/home/groups/cpipe/htdocs/ #scp index.html wsd:.public_html/cpipehome/ 2>@stderr } Make publish-tgz {[updated $TGZ]} { lftp -c "open ftp.berlios.de/incoming\n put $TGZ" } cpipe-3.0.2/CHANGES000064400000000000000000000137661213266326600136310ustar00rootroot00000000000000** This change log was extracted from `cvs log', ** sorted by date and written so that identical descriptions ** are shown only once. ** digestLog ** (C) Harald Kirsch (pifpafpuf@gmx.de) ** $Revision: 1.8 $ ** $Date: 2004/04/18 12:44:38 $ ----------------------------------------------------------- added patch from Yan Morin to makefile for an uninstall target applies to: /cvsroot/cpipe/cpipe/makefile, 1.6, 2008/10/18 09:41:00; /cvsroot/cpipe/cpipe/.version, 1.5, 2008/10/18 09:41:00; /cvsroot/cpipe/cpipe/.cvsignore, 1.5, 2008/10/18 09:41:00; ----------------------------------------------------------- slight adaptions to new version of Bras applies to: /cvsroot/cpipe/cpipe/Brasfile, 1.8, 2003/07/22 08:38:00; ----------------------------------------------------------- changed contact email address; increased version number applies to: /cvsroot/cpipe/cpipe/cpipe.c, 1.7, 2003/07/22 08:16:29; /cvsroot/cpipe/cpipe/cmdline.cli, 1.6, 2003/07/22 08:16:29; /cvsroot/cpipe/cpipe/.version, 1.4, 2003/07/22 08:16:29; /cvsroot/cpipe/cpipe/README, 1.4, 2003/07/22 08:16:29; /cvsroot/cpipe/cpipe/cpipe.spec, 1.3, 2003/07/22 08:16:29; ----------------------------------------------------------- added -lm to compile rule since someone complained that without it does not compile with every gcc applies to: /cvsroot/cpipe/cpipe/makefile, 1.5, 2003/07/22 08:15:11; ----------------------------------------------------------- This will be 3.0.0 applies to: /cvsroot/cpipe/cpipe/Brasfile, 1.7, 2001/12/09 10:35:41; /cvsroot/cpipe/cpipe/index.html.in, 1.4, 2001/12/09 10:35:41; /cvsroot/cpipe/cpipe/.version, 1.3, 2001/12/09 10:35:41; ----------------------------------------------------------- Added non-greedy read which should help in communicating with interactive programs through cpipe. Fixed a bug where delta-times overflowed after about 1:10 hours (4G usec). applies to: /cvsroot/cpipe/cpipe/cpipe.c, 1.6, 2001/12/09 10:05:20; /cvsroot/cpipe/cpipe/cmdline.cli, 1.5, 2001/12/09 10:05:20; /cvsroot/cpipe/cpipe/makefile, 1.4, 2001/12/09 10:05:20; /cvsroot/cpipe/cpipe/.cvsignore, 1.4, 2001/12/09 10:05:20; /cvsroot/cpipe/cpipe/index.html.in, 1.3, 2001/12/09 10:05:20; ----------------------------------------------------------- This is 2.0.0 Added option to limit throughput. This allows to copy big files over a loaded network while being polite to others using this network. applies to: /cvsroot/cpipe/cpipe/cpipe.c, 1.5, 2001/01/21 19:18:47; /cvsroot/cpipe/cpipe/cmdline.cli, 1.4, 2001/01/21 19:18:47; /cvsroot/cpipe/cpipe/makefile, 1.3, 2001/01/21 19:18:47; /cvsroot/cpipe/cpipe/index.html.in, 1.2, 2001/01/21 19:18:47; /cvsroot/cpipe/cpipe/cpipe.spec, 1.2, 2001/01/21 19:18:47; /cvsroot/cpipe/cpipe/Brasfile, 1.6, 2001/01/21 19:18:46; /cvsroot/cpipe/cpipe/README, 1.3, 2001/01/21 19:18:46; /cvsroot/cpipe/cpipe/.version, 1.2, 2001/01/21 19:18:46; ----------------------------------------------------------- added *.dc applies to: /cvsroot/cpipe/cpipe/.cvsignore, 1.3, 2000/01/24 08:11:18; ----------------------------------------------------------- This will be version 1.0.0. applies to: /cvsroot/cpipe/cpipe/Brasfile, 1.5, 2000/01/23 14:11:57; /cvsroot/cpipe/cpipe/cpipe.c, 1.4, 2000/01/23 14:11:57; /cvsroot/cpipe/cpipe/cmdline.cli, 1.3, 2000/01/23 14:11:57; /cvsroot/cpipe/cpipe/makefile, 1.2, 2000/01/23 14:11:57; /cvsroot/cpipe/cpipe/.cvsignore, 1.2, 2000/01/23 14:11:57; /cvsroot/cpipe/cpipe/README, 1.2, 2000/01/23 14:11:57; ----------------------------------------------------------- initial checkin. applies to: /cvsroot/cpipe/cpipe/README, 1.1, 2000/01/23 13:59:07; ----------------------------------------------------------- These can be regenerated from cmdline.cli. applies to: /cvsroot/cpipe/cpipe/Attic/cpipe.1, 1.3, 2000/01/23 13:53:01; /cvsroot/cpipe/cpipe/Attic/cmdline.h, 1.3, 2000/01/23 13:53:01; /cvsroot/cpipe/cpipe/Attic/cmdline.c, 1.3, 2000/01/23 13:53:01; ----------------------------------------------------------- initial checkin applies to: /cvsroot/cpipe/cpipe/.version, 1.1, 2000/01/23 13:52:38; /cvsroot/cpipe/cpipe/makefile, 1.1, 2000/01/23 13:52:38; /cvsroot/cpipe/cpipe/index.html.in, 1.1, 2000/01/23 13:52:38; /cvsroot/cpipe/cpipe/dir.ttml, 1.1, 2000/01/23 13:52:38; /cvsroot/cpipe/cpipe/cpipe.spec, 1.1, 2000/01/23 13:52:38; /cvsroot/cpipe/cpipe/COPYING-2.0, 1.1, 2000/01/23 13:52:38; ----------------------------------------------------------- Adaption to new version of bras. applies to: /cvsroot/cpipe/cpipe/Brasfile, 1.4, 1999/11/21 13:55:57; ----------------------------------------------------------- glibc revealed that string.h was not yet included. applies to: /cvsroot/cpipe/cpipe/cpipe.c, 1.3, 1999/02/22 08:43:20; ----------------------------------------------------------- Added possibility to show the overall throughput. Added options to select which times and averages to record. Correcte scale factor for kilobytes from 1000 to 1024. applies to: /cvsroot/cpipe/cpipe/Brasfile, 1.3, 1998/02/24 11:15:35; /cvsroot/cpipe/cpipe/cpipe.c, 1.2, 1998/02/24 11:15:35; /cvsroot/cpipe/cpipe/Attic/cpipe.1, 1.2, 1998/02/24 11:15:35; /cvsroot/cpipe/cpipe/Attic/cmdline.h, 1.2, 1998/02/24 11:15:35; /cvsroot/cpipe/cpipe/cmdline.cli, 1.2, 1998/02/24 11:15:35; /cvsroot/cpipe/cpipe/Attic/cmdline.c, 1.2, 1998/02/24 11:15:35; ----------------------------------------------------------- Added target clean to Brasfile. applies to: /cvsroot/cpipe/cpipe/Brasfile, 1.2, 1997/04/29 19:22:26; ----------------------------------------------------------- Put this into a pipe to count the byte transferred and to measured throughput. applies to: /cvsroot/cpipe/cpipe/cpipe.c, 1.1, 1997/03/27 21:13:10; /cvsroot/cpipe/cpipe/Attic/cpipe.1, 1.1, 1997/03/27 21:13:10; /cvsroot/cpipe/cpipe/Attic/cmdline.h, 1.1, 1997/03/27 21:13:10; /cvsroot/cpipe/cpipe/cmdline.cli, 1.1, 1997/03/27 21:13:10; /cvsroot/cpipe/cpipe/Attic/cmdline.c, 1.1, 1997/03/27 21:13:10; /cvsroot/cpipe/cpipe/Brasfile, 1.1, 1997/03/27 21:13:10; /cvsroot/cpipe/cpipe/.cvsignore, 1.1, 1997/03/27 21:13:09; cpipe-3.0.2/COPYING-2.0000064400000000000000000000430761213266326600141630ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave, Cambridge, MA 02139, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. cpipe-3.0.2/README000064400000000000000000000002761213266326600135060ustar00rootroot00000000000000To install run make CFLAGS="-your -favorite -flags"; make install prefix=/where/to/install or edit the top of makefile. Harald Kirsch (pifpafpuf@gmx.de) ($Revision: 1.4 $, $Date) cpipe-3.0.2/cmdline.c000064400000000000000000000446731213266326600144160ustar00rootroot00000000000000/***** command line parser -- generated by clig (http://wsd.iitb.fhg.de/~kir/clighome/) The command line parser `clig': (C) 1995---2001 Harald Kirsch (kirschh@lionbioscience.com) *****/ #include #include #include #include #include #include #include #include #include "cmdline.h" char *Program; /*@-null*/ static Cmdline cmd = { /***** -b: buffer size in kB */ /* bsizeP = */ 1, /* bsize = */ 128, /* bsizeC = */ 1, /***** -vt: show throughput */ /* vtP = */ 0, /***** -vr: show read-times */ /* vrP = */ 0, /***** -vw: show write-times */ /* vwP = */ 0, /***** -ngr: non-greedy read. Don't enforce a full buffer on read before starting to write */ /* ngrP = */ 0, /***** -s: throughput speed limit in kB/s */ /* speedP = */ 0, /* speed = */ (double)0, /* speedC = */ 0, /***** uninterpreted rest of command line */ /* argc = */ 0, /* argv = */ (char**)0 }; /*@=null*/ /***** let LCLint run more smoothly */ /*@-predboolothers*/ /*@-boolops*/ /******************************************************************/ /***** This is a bit tricky. We want to make a difference between overflow and underflow and we want to allow v==Inf or v==-Inf but not v>FLT_MAX. We don't use fabs to avoid linkage with -lm. *****/ static void checkFloatConversion(double v, char *option, char *arg) { char *err = NULL; if( (errno==ERANGE && v!=0.0) /* even double overflowed */ || (v-HUGE_VAL && (v<0.0?-v:v)>(double)FLT_MAX) ) { err = "large"; } else if( (errno==ERANGE && v==0.0) || (v!=0.0 && (v<0.0?-v:v)<(double)FLT_MIN) ) { err = "small"; } if( err ) { fprintf(stderr, "%s: parameter `%s' of option `%s' to %s to represent\n", Program, arg, option, err); exit(EXIT_FAILURE); } } int getIntOpt(int argc, char **argv, int i, int *value, int force) { char *end; long v; if( ++i>=argc ) goto nothingFound; errno = 0; v = strtol(argv[i], &end, 0); /***** check for conversion error */ if( end==argv[i] ) goto nothingFound; /***** check for surplus non-whitespace */ while( isspace((int) *end) ) end+=1; if( *end ) goto nothingFound; /***** check if it fits into an int */ if( errno==ERANGE || v>(long)INT_MAX || v<(long)INT_MIN ) { fprintf(stderr, "%s: parameter `%s' of option `%s' to large to represent\n", Program, argv[i], argv[i-1]); exit(EXIT_FAILURE); } *value = (int)v; return i; nothingFound: if( !force ) return i-1; fprintf(stderr, "%s: missing or malformed integer value after option `%s'\n", Program, argv[i-1]); exit(EXIT_FAILURE); } /**********************************************************************/ int getIntOpts(int argc, char **argv, int i, int **values, int cmin, int cmax) /***** We want to find at least cmin values and at most cmax values. cmax==-1 then means infinitely many are allowed. *****/ { int alloced, used; char *end; long v; if( i+cmin >= argc ) { fprintf(stderr, "%s: option `%s' wants at least %d parameters\n", Program, argv[i], cmin); exit(EXIT_FAILURE); } /***** alloc a bit more than cmin values. It does not hurt to have room for a bit more values than cmax. *****/ alloced = cmin + 4; *values = (int*)calloc((size_t)alloced, sizeof(int)); if( ! *values ) { outMem: fprintf(stderr, "%s: out of memory while parsing option `%s'\n", Program, argv[i]); exit(EXIT_FAILURE); } for(used=0; (cmax==-1 || used(long)INT_MAX || v<(long)INT_MIN ) { fprintf(stderr, "%s: parameter `%s' of option `%s' to large to represent\n", Program, argv[i+used+1], argv[i]); exit(EXIT_FAILURE); } (*values)[used] = (int)v; } if( used=argc ) goto nothingFound; errno = 0; *value = strtol(argv[i], &end, 0); /***** check for conversion error */ if( end==argv[i] ) goto nothingFound; /***** check for surplus non-whitespace */ while( isspace((int) *end) ) end+=1; if( *end ) goto nothingFound; /***** check for overflow */ if( errno==ERANGE ) { fprintf(stderr, "%s: parameter `%s' of option `%s' to large to represent\n", Program, argv[i], argv[i-1]); exit(EXIT_FAILURE); } return i; nothingFound: /***** !force means: this parameter may be missing.*/ if( !force ) return i-1; fprintf(stderr, "%s: missing or malformed value after option `%s'\n", Program, argv[i-1]); exit(EXIT_FAILURE); } /**********************************************************************/ int getLongOpts(int argc, char **argv, int i, long **values, int cmin, int cmax) /***** We want to find at least cmin values and at most cmax values. cmax==-1 then means infinitely many are allowed. *****/ { int alloced, used; char *end; if( i+cmin >= argc ) { fprintf(stderr, "%s: option `%s' wants at least %d parameters\n", Program, argv[i], cmin); exit(EXIT_FAILURE); } /***** alloc a bit more than cmin values. It does not hurt to have room for a bit more values than cmax. *****/ alloced = cmin + 4; *values = calloc((size_t)alloced, sizeof(long)); if( ! *values ) { outMem: fprintf(stderr, "%s: out of memory while parsing option `%s'\n", Program, argv[i]); exit(EXIT_FAILURE); } for(used=0; (cmax==-1 || used=argc ) goto nothingFound; errno = 0; v = strtod(argv[i], &end); /***** check for conversion error */ if( end==argv[i] ) goto nothingFound; /***** check for surplus non-whitespace */ while( isspace((int) *end) ) end+=1; if( *end ) goto nothingFound; /***** check for overflow */ checkFloatConversion(v, argv[i-1], argv[i]); *value = (float)v; return i; nothingFound: if( !force ) return i-1; fprintf(stderr, "%s: missing or malformed float value after option `%s'\n", Program, argv[i-1]); exit(EXIT_FAILURE); } /**********************************************************************/ int getFloatOpts(int argc, char **argv, int i, float **values, int cmin, int cmax) /***** We want to find at least cmin values and at most cmax values. cmax==-1 then means infinitely many are allowed. *****/ { int alloced, used; char *end; double v; if( i+cmin >= argc ) { fprintf(stderr, "%s: option `%s' wants at least %d parameters\n", Program, argv[i], cmin); exit(EXIT_FAILURE); } /***** alloc a bit more than cmin values. *****/ alloced = cmin + 4; *values = (float*)calloc((size_t)alloced, sizeof(float)); if( ! *values ) { outMem: fprintf(stderr, "%s: out of memory while parsing option `%s'\n", Program, argv[i]); exit(EXIT_FAILURE); } for(used=0; (cmax==-1 || used=argc ) goto nothingFound; errno = 0; *value = strtod(argv[i], &end); /***** check for conversion error */ if( end==argv[i] ) goto nothingFound; /***** check for surplus non-whitespace */ while( isspace((int) *end) ) end+=1; if( *end ) goto nothingFound; /***** check for overflow */ if( errno==ERANGE ) { fprintf(stderr, "%s: parameter `%s' of option `%s' to %s to represent\n", Program, argv[i], argv[i-1], (*value==0.0 ? "small" : "large")); exit(EXIT_FAILURE); } return i; nothingFound: if( !force ) return i-1; fprintf(stderr, "%s: missing or malformed value after option `%s'\n", Program, argv[i-1]); exit(EXIT_FAILURE); } /**********************************************************************/ int getDoubleOpts(int argc, char **argv, int i, double **values, int cmin, int cmax) /***** We want to find at least cmin values and at most cmax values. cmax==-1 then means infinitely many are allowed. *****/ { int alloced, used; char *end; if( i+cmin >= argc ) { fprintf(stderr, "%s: option `%s' wants at least %d parameters\n", Program, argv[i], cmin); exit(EXIT_FAILURE); } /***** alloc a bit more than cmin values. *****/ alloced = cmin + 4; *values = (double*)calloc((size_t)alloced, sizeof(double)); if( ! *values ) { outMem: fprintf(stderr, "%s: out of memory while parsing option `%s'\n", Program, argv[i]); exit(EXIT_FAILURE); } for(used=0; (cmax==-1 || used=argc ) { if( force ) { fprintf(stderr, "%s: missing string after option `%s'\n", Program, argv[i-1]); exit(EXIT_FAILURE); } return i-1; } if( !force && argv[i][0] == '-' ) return i-1; *value = argv[i]; return i; } /**********************************************************************/ int getStringOpts(int argc, char **argv, int i, char* **values, int cmin, int cmax) /***** We want to find at least cmin values and at most cmax values. cmax==-1 then means infinitely many are allowed. *****/ { int alloced, used; if( i+cmin >= argc ) { fprintf(stderr, "%s: option `%s' wants at least %d parameters\n", Program, argv[i], cmin); exit(EXIT_FAILURE); } alloced = cmin + 4; *values = (char**)calloc((size_t)alloced, sizeof(char*)); if( ! *values ) { outMem: fprintf(stderr, "%s: out of memory during parsing of option `%s'\n", Program, argv[i]); exit(EXIT_FAILURE); } for(used=0; (cmax==-1 || used=cmin && argv[used+i+1][0]=='-' ) break; (*values)[used] = argv[used+i+1]; } if( used=min ) continue; fprintf(stderr, "%s: parameter %d of option `%s' smaller than min=%d\n", Program, i+1, opt, min); exit(EXIT_FAILURE); } } /**********************************************************************/ void checkLongLower(char *opt, long *values, int count, long max) { int i; for(i=0; i=min ) continue; fprintf(stderr, "%s: parameter %d of option `%s' smaller than min=%ld\n", Program, i+1, opt, min); exit(EXIT_FAILURE); } } /**********************************************************************/ void checkFloatLower(char *opt, float *values, int count, float max) { int i; for(i=0; i=min ) continue; fprintf(stderr, "%s: parameter %d of option `%s' smaller than min=%f\n", Program, i+1, opt, min); exit(EXIT_FAILURE); } } /**********************************************************************/ void checkDoubleLower(char *opt, double *values, int count, double max) { int i; for(i=0; i=min ) continue; fprintf(stderr, "%s: parameter %d of option `%s' smaller than min=%f\n", Program, i+1, opt, min); exit(EXIT_FAILURE); } } /**********************************************************************/ void usage(void) { fprintf(stderr, "usage: %s%s", Program, "\ [-b bsize] [-vt] [-vr] [-vw] [-ngr] [-s speed]\n\ copy stdin to stdout while counting bytes and reporting progress\n\ -b: buffer size in kB\n\ 1 int value between 1 and oo\n\ default: `128'\n\ -vt: show throughput\n\ -vr: show read-times\n\ -vw: show write-times\n\ -ngr: non-greedy read. Don't enforce a full buffer\n\ on read before starting to write\n\ -s: throughput speed limit in kB/s\n\ 1 double value between 1 and oo\n\ version: 3.0.1\n\ "); exit(EXIT_FAILURE); } /**********************************************************************/ Cmdline * parseCmdline(int argc, char **argv) { int i; Program = argv[0]; for(i=1, cmd.argc=1; i0 ) { fprintf(stderr, "%s: There are %d arguments not associated with any option\n", Program, cmd.argc); exit(EXIT_FAILURE); } /*@-compmempass*/ return &cmd; } cpipe-3.0.2/cmdline.cli000064400000000000000000000073061213266326600147330ustar00rootroot00000000000000Name cpipe Usage {copy stdin to stdout while counting bytes and reporting progress} Int -b bsize {buffer size in kB} \ range=1,oo \ default=128 Flag -vt vt {show throughput} Flag -vr vr {show read-times} Flag -vw vw {show write-times} Flag -ngr ngr {non-greedy read. Don't enforce a full buffer on read before starting to write} Double -s speed {throughput speed limit in kB/s} -r 1 oo Description { .B Cpipe copies its standard input to its standard output while measuring the time it takes to read an input buffer and write an output buffer. If one or more of the .BI -v x options is given, statistics of average throughput and the total amount of bytes copied are printed to the standard error output. .SS Non Greedy Read Normally, cpipe does its best to totally fill its buffer (option .BR -b ) before it starts writing. In some situations however, e.g. if you talk to an interactive program via cpipe, this deadlocks the communication: said program waits for input which it will never see, because the input is stuck in cpipe's buffer. But cpipe itself will not see more input before the program does not respond. To get around this, try using .BR -ngr . When issuing a read call, cpipe is then satisfied as soon as it gets at least one byte. Instead of filling the buffer, it stops reading and writes whatever it got to the output. Note, however, that the throughput measurements will be less exact if the number of bytes transferred in one read/write pair becomes small, because cpipe will spent relatively more time working on every byte. .SS Limiting Throughput If a throughput limit is specified with option .BR -s , .B cpipe calls .BR usleep (3) in between copying buffers, thereby artificially extending the duration of a read/write-cycle. Since on most systems there is a certain minimum time usleep() sleeps, e.g. 0.01s, it is impossible to reach high limits with a small buffer size. In this case increasing the buffer size (option .BR -b ) might help. However, keep in mind that this limits the throughput only on the average. Every single buffer is copied as fast as possible. .SH EXAMPLE The command .nf tar cCf / - usr | cpipe -vr -vw -vt > /dev/null .fi results in an output like .nf ... in: 19.541ms at 6.4MB/s ( 4.7MB/s avg) 2.0MB out: 0.004ms at 30.5GB/s ( 27.1GB/s avg) 2.0MB thru: 19.865ms at 6.3MB/s ( 4.6MB/s avg) 2.0MB ... .fi The .I first column shows the times it takes to handle one buffer of data (128kB by default). The read-call took 19.541ms, the write-call to /dev/null took just 0.004ms and from the start of the read to the end of write, it took 19.865ms. The .I second column shows the result of dividing the buffer size (128kB by default) by the times in the first column. The .I "third column" contains the average over all measured values from the start of the program. Finally, the .I "last column" shows the total number of bytes transferred, which is of course the same for reading and writing. .SH BUGS This program uses precious processor cycles. Consequently the measured times will be different from the transfer rates possible without it. Instead of just non-greedy reading, full non-blocking I/O and use of select(2) should be used to make sure that no deadlocks occur when communicating with interactive programs. .SH CREDITS Peter Astrand recommended the speed limit. Ivo De Decker asked for deadlock prevention, which is (hopefully) sufficiently covered by the non-greedy read. .SH AUTHOR Bug reports, beer and postcards go to .IR pifpafpuf@gmx.de . New versions will show up on .br .IR http://cpipe.berlios.de/ . } set in [open .version r]; set v [read $in]; close $in Version [lindex $v 2] cpipe-3.0.2/cmdline.h000064400000000000000000000016121213266326600144050ustar00rootroot00000000000000#ifndef __cmdline__ #define __cmdline__ /***** command line parser interface -- generated by clig (http://wsd.iitb.fhg.de/~kir/clighome/) The command line parser `clig': (C) 1995---2001 Harald Kirsch (kirschh@lionbioscience.com) *****/ typedef struct s_Cmdline { /***** -b: buffer size in kB */ char bsizeP; int bsize; int bsizeC; /***** -vt: show throughput */ char vtP; /***** -vr: show read-times */ char vrP; /***** -vw: show write-times */ char vwP; /***** -ngr: non-greedy read. Don't enforce a full buffer on read before starting to write */ char ngrP; /***** -s: throughput speed limit in kB/s */ char speedP; double speed; int speedC; /***** uninterpreted command line parameters */ int argc; /*@null*/char **argv; } Cmdline; extern char *Program; extern void usage(void); extern /*@shared*/Cmdline *parseCmdline(int argc, char **argv); #endif cpipe-3.0.2/cpipe.1000064400000000000000000000106751213266326600140140ustar00rootroot00000000000000.\" clig manual page template .\" (C) 1995-2001 Harald Kirsch (kirschh@lionbioscience.com) .\" .\" This file was generated by .\" clig -- command line interface generator .\" .\" .\" Clig will always edit the lines between pairs of `cligPart ...', .\" but will not complain, if a pair is missing. So, if you want to .\" make up a certain part of the manual page by hand rather than have .\" it edited by clig, remove the respective pair of cligPart-lines. .\" .\" cligPart TITLE .TH "cpipe" 1 "3.0.1" "Clig-manuals" "Programmer's Manual" .\" cligPart TITLE end .\" cligPart NAME .SH NAME cpipe \- copy stdin to stdout while counting bytes and reporting progress .\" cligPart NAME end .\" cligPart SYNOPSIS .SH SYNOPSIS .B cpipe [-b bsize] [-vt] [-vr] [-vw] [-ngr] [-s speed] .\" cligPart SYNOPSIS end .\" cligPart OPTIONS .SH OPTIONS .IP -b buffer size in kB, .br 1 Int value between 1 and oo. .br Default: `128' .IP -vt show throughput. .IP -vr show read-times. .IP -vw show write-times. .IP -ngr non-greedy read. Don't enforce a full buffer on read before starting to write. .IP -s throughput speed limit in kB/s, .br 1 Double value between 1 and oo. .\" cligPart OPTIONS end .\" cligPart DESCRIPTION .SH DESCRIPTION .B Cpipe copies its standard input to its standard output while measuring the time it takes to read an input buffer and write an output buffer. If one or more of the .BI -v x options is given, statistics of average throughput and the total amount of bytes copied are printed to the standard error output. .SS Non Greedy Read Normally, cpipe does its best to totally fill its buffer (option .BR -b ) before it starts writing. In some situations however, e.g. if you talk to an interactive program via cpipe, this deadlocks the communication: said program waits for input which it will never see, because the input is stuck in cpipe's buffer. But cpipe itself will not see more input before the program does not respond. To get around this, try using .BR -ngr . When issuing a read call, cpipe is then satisfied as soon as it gets at least one byte. Instead of filling the buffer, it stops reading and writes whatever it got to the output. Note, however, that the throughput measurements will be less exact if the number of bytes transferred in one read/write pair becomes small, because cpipe will spent relatively more time working on every byte. .SS Limiting Throughput If a throughput limit is specified with option .BR -s , .B cpipe calls .BR usleep (3) in between copying buffers, thereby artificially extending the duration of a read/write-cycle. Since on most systems there is a certain minimum time usleep() sleeps, e.g. 0.01s, it is impossible to reach high limits with a small buffer size. In this case increasing the buffer size (option .BR -b ) might help. However, keep in mind that this limits the throughput only on the average. Every single buffer is copied as fast as possible. .SH EXAMPLE The command .nf tar cCf / - usr | cpipe -vr -vw -vt > /dev/null .fi results in an output like .nf ... in: 19.541ms at 6.4MB/s ( 4.7MB/s avg) 2.0MB out: 0.004ms at 30.5GB/s ( 27.1GB/s avg) 2.0MB thru: 19.865ms at 6.3MB/s ( 4.6MB/s avg) 2.0MB ... .fi The .I first column shows the times it takes to handle one buffer of data (128kB by default). The read-call took 19.541ms, the write-call to /dev/null took just 0.004ms and from the start of the read to the end of write, it took 19.865ms. The .I second column shows the result of dividing the buffer size (128kB by default) by the times in the first column. The .I "third column" contains the average over all measured values from the start of the program. Finally, the .I "last column" shows the total number of bytes transferred, which is of course the same for reading and writing. .SH BUGS This program uses precious processor cycles. Consequently the measured times will be different from the transfer rates possible without it. Instead of just non-greedy reading, full non-blocking I/O and use of select(2) should be used to make sure that no deadlocks occur when communicating with interactive programs. .SH CREDITS Peter Astrand recommended the speed limit. Ivo De Decker asked for deadlock prevention, which is (hopefully) sufficiently covered by the non-greedy read. .SH AUTHOR Bug reports, beer and postcards go to .IR pifpafpuf@gmx.de . New versions will show up on .br .IR http://cpipe.berlios.de/ . .\" cligPart DESCRIPTION end cpipe-3.0.2/cpipe.c000064400000000000000000000163211213266326600140700ustar00rootroot00000000000000/********************************************************************** cpipe -- counting pipe Watch out, here comes the GPL-virus. (C) 1997--2003 Harald Kirsch (pifpafpuf@gmx.de) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. $Revision: 1.7 $, $Date: 2003/07/22 08:16:29 $ **********************************************************************/ #include #include #include #include #include #include #include #include #include #include "cmdline.h" #define ONEk 1024.0 #define ONEkSCALE (1.0/ONEk) #define ONEM (1024.0*1024.0) #define ONEMSCALE (1.0/ONEM) #define ONEG (1024.0*1024.0*1024.0) #define ONEGSCALE (1.0/ONEG) double TotalBytes; double totalTin, totalTout; /**********************************************************************/ char * scale(double v, char *buf) { if( v>ONEM ) { /***** This is at least a G */ if( v>ONEG ) { sprintf(buf, "%6.1fG", v*ONEGSCALE); } else { sprintf(buf, "%6.1fM", v*ONEMSCALE); } } else { if( v>ONEk ) { sprintf(buf, "%6.1fk", v*ONEkSCALE); } else { sprintf(buf, "%4.0f", v); } } return buf; } /**********************************************************************/ /** returns the time delta represented by the given structures as a double value in seconds. *****/ double deltaT(struct timeval* tin, struct timeval* tout) { long usec; double sec; usec = tout->tv_usec - tin->tv_usec; if( usec<0 ) { sec = tout->tv_sec-tin->tv_sec-1 + ((double)(usec + 1000000))*1e-6; } else { sec = tout->tv_sec-tin->tv_sec + ((double)usec)*1e-6; } return sec; } /**********************************************************************/ ssize_t readBuffer(char *buf, size_t length, int show, int nonblock, int *eof) { size_t totalBytes; ssize_t bytes; struct timeval tin, tout; double dt; char txt1[40], txt2[40], txt3[40]; int flags; /***** The first read is always a blocking one, because there is no point in returning 0 bytes. *****/ flags = fcntl(STDIN_FILENO, F_GETFL); fcntl(STDIN_FILENO, F_SETFL, flags & ~O_NONBLOCK); gettimeofday(&tin, NULL); for(totalBytes=0; totalBytes0 ) { if( nonblock ) fcntl(STDIN_FILENO, F_SETFL, flags|O_NONBLOCK); continue; } if( errno==EAGAIN ) { /***** non-blocking operation returned with 0 bytes */ break; } if( errno==EINTR ) { /****** on interrupt, we try again, even in non-blocking mode */ bytes = 0; continue; } /***** serious error on read */ fprintf(stderr, "%s: error reading stdin because `%s'\n", Program, strerror(errno)); exit(EXIT_FAILURE); } gettimeofday(&tout, NULL); TotalBytes += (double)totalBytes; if( show ) { dt = deltaT(&tin, &tout); totalTin += dt; fprintf(stderr, " in: %7.3fms at %7sB/s (%7sB/s avg) %7sB", 1e3*dt, scale((double)totalBytes/dt, txt1), scale(TotalBytes/totalTin, txt2), scale(TotalBytes, txt3)); if( totalBytesbsize *= ONEk; if( cmd->speedP ) cmd->speed *= ONEk; if( cmd->ngrP ) { /***** switch input into non-blocking */ fcntl(STDIN_FILENO, F_SETFL, O_NONBLOCK); } buf = malloc(cmd->bsize); if( !buf ) { fprintf(stderr, "%s: cannot allocate buffer of length `%d', out of memory\n", Program, cmd->bsize); exit(EXIT_FAILURE); } TotalBytes = 0.0; totalTin = 0.0; totalTout = 0.0; gettimeofday(&tstart, NULL); for(count=cmd->bsize, eof=0; !eof; /**/) { double dt, dtAll; double delay; gettimeofday(&tin, NULL); count = readBuffer(buf, cmd->bsize, cmd->vrP, cmd->ngrP, &eof); writeBuffer(buf, count, cmd->vwP); gettimeofday(&tnow, NULL); dt = deltaT(&tin, &tnow); /***** If speed limit is requested, we might have to sleep. On most architectures, the nanosleep will have a fixed minimum delay of e.g. 0.01s. Consequently the throughput is severely limited by this if the buffer size choosen is too small. *****/ delay = (double)count/cmd->speed /* the time it should have taken */ - dt; /* the time it took */ if( cmd->speedP && delay>0 ) { struct timespec sleeptime; double factor; delay *= calib; sleeptime.tv_sec = (time_t)delay; sleeptime.tv_nsec = 1e9*(delay-floor(delay)); if( 0==nanosleep(&sleeptime, NULL) ) { /***** only recalibrate if we waited the full time */ gettimeofday(&tnow, NULL); dt = deltaT(&tin, &tnow); /***** recalibrate the calibration factor. The value it should have had is factor*calib. However we do not jump to this value but move only 1/8th of the distance to achive some damping. *****/ factor = ((double)count/dt)/cmd->speed; calib += 0.125*(factor*calib-calib); } } dtAll = deltaT(&tstart, &tnow); if( cmd->vtP ) { fprintf(stderr, "thru: %7.3fms at %7sB/s (%7sB/s avg) %7sB\n", 1e3*dt, scale((double)count/dt, txt1), scale(TotalBytes/dtAll, txt2), scale(TotalBytes, txt3)); } } return 0; } cpipe-3.0.2/cpipe.spec000064400000000000000000000015741213266326600146040ustar00rootroot00000000000000## $Revision: 1.3 $, $Date: 2003/07/22 08:16:29 $ ## The following line is edited by my ship script to contain the true ## version I am shipping from cvs. (kir) %define VERSION 3.0.2 Summary: counting pipe Name: cpipe Version: %VERSION Release: 0 Copyright: GPL Group: Applications/Archiving Source: cpipe-%{VERSION}.tar.gz URL: http://wsd.iitb.fhg.de/~kir/cpipehome/ Packager: Harald Kirsch (pifpafpuf@gmx.de) BuildRoot: /tmp/cpipe-rpmbuild %description Cpipe copies its standard input to its standard output while measuring the time it takes to read an input buffer and write an output buffer. Statistics of average throughput and the total amount of bytes copied are printed to the standard error output. %prep %setup %build make %install rm -rf $RPM_BUILD_ROOT/usr/ make install prefix=$RPM_BUILD_ROOT/usr %post %files %attr(-,root,root) /usr/man/man1 %attr(-,root,root) /usr/bin cpipe-3.0.2/dir.ttml000064400000000000000000000012241213266326600143000ustar00rootroot00000000000000 cpipe --- all versions

All versions of cpipe

<+ cgi_table border=4 { cgi_table_row { cgi_td File cgi_td "Size (Bytes)" cgi_td "Date" } set files [concat [lsort [glob *.tar.gz]] [lsort [glob *.rpm]]] foreach file $files { file stat $file stat cgi_table_row { cgi_td [cgi_url $file $file] cgi_td $stat(size) cgi_td [clock format $stat(mtime) -format "%Y-%m-%d %H:%M"] } } } +> cpipe-3.0.2/index.html.in000064400000000000000000000042261213266326600152270ustar00rootroot00000000000000 cpipe --- counting pipe

cpipe --- counting pipe

Did you ever want to know how fast your tar is or how much data it has transferred already. How about using socket or nc to copy files either with or without compression over a fast network connection, which one is faster?

If you want to know the answer, use cpipe as a totally unscientific approach to measure throughput. Cpipe copies its standard input to its standard output while measuring the time it takes to read an input buffer and write an output buffer. Statistics of average throughput and the total amount of bytes copied are printed to the standard error output.

Example

The command

tar cCf / - usr | cpipe -vr -vw -vt > /dev/null
results in an output like
...
  in:  19.541ms at    6.4MB/s (   4.7MB/s avg)    2.0MB
 out:   0.004ms at   30.5GB/s (  27.1GB/s avg)    2.0MB
thru:  19.865ms at    6.3MB/s (   4.6MB/s avg)    2.0MB
...

The first column shows the times it takes to handle one buffer of data (128kB by default). The read-call took 19.541ms, the write-call to /dev/null took just 0.004ms and from the start of the read to the end of write, it took 19.865ms.

The second column shows the result of dividing the buffer size (128kB by default) by the times in the first column.


The current version is |VERSION|. You may want to read the list of recent CHANGES. The software can be downloaded from BerliOS Logo

cpipe-3.0.2/makefile000064400000000000000000000024701213266326600143240ustar00rootroot00000000000000## The other day I might consider learning autoconf. In the meantime I ## hope this is trivial enough to be installed without. If someone ## feels like sending me an autoconf-script for cpipe, I'll use it. ## ## $Revision: 1.6 $, $Date: 2008/10/18 09:41:00 $ ######################################################################## prefix=/usr exec_prefix=$(prefix) ## This is where the executable will be installed BINDIR=$(exec_prefix)/bin ## Here we install the manual page MANDIR=$(prefix)/man/man1 ## Your favorite compiler flags. CFLAGS = -O2 -W -Wall -pedantic ######################################################################## cpipe: cpipe.o cmdline.o $(CC) -lm -o $@ cpipe.o cmdline.o cpipe.o: cpipe.c cmdline.h cmdline.o: cmdline.c cmdline.h cmdline.c cmdline.h cpipe.1: cmdline.cli @ (echo "clig cmdline.cli"; clig cmdline.cli) || { \ echo "*****"; \ echo "Get clig at http://wsd.iitb.fhg.de/~geg/clighome"; \ echo "or use cmdline.c, cmdline.h and cpipe.1 as they come"; \ echo "in the distribution by touching them."; \ echo "*****"; \ exit 1; \ } clean: rm cmdline.o cpipe.o cpipe install: cpipe cpipe.1 mkdir -p $(BINDIR) $(MANDIR) cp cpipe $(BINDIR); chmod 755 $(BINDIR)/cpipe cp cpipe.1 $(MANDIR); chmod 744 $(MANDIR)/cpipe.1 uninstall: -rm $(BINDIR)/cpipe -rm $(MANDIR)/cpipe.1