Commit b4a47dda authored by Daniel Stenberg's avatar Daniel Stenberg
Browse files

re-arranged the progress meter columns, made the hour-field two characters

wide and made the pgrsUpdate() make a final meter update so that the final
values actually are displayed last.
parent 32523870
Loading
Loading
Loading
Loading
+21 −15
Original line number Diff line number Diff line
@@ -58,7 +58,7 @@ void time2str(char *r, int t)
  int h = (t/3600);
  int m = (t-(h*3600))/60;
  int s = (t-(h*3600)-(m*60));
  sprintf(r,"%d:%02d:%02d",h,m,s);
  sprintf(r,"%2d:%02d:%02d",h,m,s);
}

/* The point of this function would be to return a string of the input data,
@@ -94,9 +94,12 @@ char *max5data(double bytes, char *max5)
#if 1
void pgrsDone(struct UrlData *data)
{
  if(!(data->progress.flags & PGRS_HIDE))
  if(!(data->progress.flags & PGRS_HIDE)) {
    data->progress.lastshow=0;
    pgrsUpdate(data); /* the final (forced) update */
    fprintf(stderr, "\n");
  }
}
void pgrsMode(struct UrlData *data, int mode)
{
  /* mode should include a hidden mode as well */
@@ -125,21 +128,25 @@ void pgrsSetUploadCounter(struct UrlData *data, double size)

void pgrsSetDownloadSize(struct UrlData *data, double size)
{
  if(size > 0) {
    data->progress.size_dl = size;
    data->progress.flags |= PGRS_DL_SIZE_KNOWN;
  }
}

void pgrsSetUploadSize(struct UrlData *data, double size)
{
  if(size > 0) {
    data->progress.size_ul = size;
    data->progress.flags |= PGRS_UL_SIZE_KNOWN;
  }
}

/* EXAMPLE OUTPUT to follow:

  % Total    % Received % Xferd  Average Speed          Time             Curr.
                                Download Upload Total   Current  Left   Speed
100 12345  100 12345  100 12345  12345   12345  2:47:33 2:00:02 2:00:02 12345
                                 Dload  Upload Total    Current  Left    Speed
100 12345  100 12345  100 12345  12345  12345 12:12:12 12:12:12 12:12:12 12345

 */

@@ -155,7 +162,7 @@ void pgrsUpdate(struct UrlData *data)
    if ( data->progress.mode == CURL_PROGRESS_STATS ) {
      fprintf(data->err,
              "  %% Total    %% Received %% Xferd  Average Speed          Time             Curr.\n"
              "                                Download Upload Total   Current  Left   Speed\n");
              "                                 Dload  Upload Total    Current  Left    Speed\n");
    }
    data->progress.flags |= PGRS_HEADERS_OUT; /* headers are shown */
  }
@@ -165,7 +172,6 @@ void pgrsUpdate(struct UrlData *data)
  switch(data->progress.mode) {
  case CURL_PROGRESS_STATS:
    {
      static long lastshow;
      char max5[6][6];
      double dlpercen=0;
      double ulpercen=0;
@@ -196,10 +202,10 @@ void pgrsUpdate(struct UrlData *data)
          
      double total_estimate;

      if(lastshow == tvlong(now))
      if(data->progress.lastshow == tvlong(now))
        return; /* never update this more than once a second if the end isn't 
                   reached */
      lastshow = now.tv_sec;
      data->progress.lastshow = now.tv_sec;

      /* The exact time spent so far */
      timespent = tvdiff (now, data->progress.start);