bar.c

Go to the documentation of this file.
00001 #include "config.h"
00002 
00003 #include "headers.h"
00004 #include "types.h"
00005 #include "error.h"
00006 #include "fd.h"
00007 #include "io.h"
00008 #include "display.h"
00009 #include "args.h"
00010 
00011 /** \mainpage Command Line Progress Bar
00012 
00013 Bar is a simple tool to copy a stream of data from input to output while
00014 displaying for the user:
00015 
00016 \li The amount of data passed
00017 \li The throughput of the data transfer
00018 
00019 and, if the total size of the data stream is known:
00020 
00021 \li The estimated time remaining
00022 \li What percent of the data stream has been copied
00023 \li A progress bar
00024 
00025 Bar was originally written for the purpose of estimating the amount of time
00026 needed to transfer large amounts (many, many gigabytes) of data across a
00027 network in a tar/ssh pipe.
00028 
00029 */
00030 
00031 int main(int argc, char *argv[])
00032 {
00033 #ifdef DEBUG
00034         int debug = 1;
00035 
00036         fprintf(stderr, "Waiting for debugger to attach...\n");
00037         while (debug);
00038 #endif
00039         if (ioInit() != 0) return(1);
00040         if (displayInit() != 0) return(1);
00041         if (parse_rcfiles(stderr) != 0) return(1);
00042         if (parse_args(stderr, argc, argv) != 0) return(1);
00043         if (ioBegin() != 0) return(1);
00044         if (displayBegin() != 0) return(1);
00045 
00046         while (!ioIsDone()) {
00047                 ioCheck();
00048                 if (ioRead() < 0) {
00049                         print_error(stderr, "read error");
00050                         break;
00051                 }
00052                 if (ioWrite() < 0) {
00053                         print_error(stderr, "write error");
00054                         break;
00055                 }
00056                 displayUpdate();
00057         }
00058 
00059         displayEnd();
00060         ioEnd();
00061         return(0);
00062 }
00063 

Generated on Thu Jun 28 09:13:03 2007 for bar by  doxygen 1.5.1