[BACK]Return to progressmeter.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / ssh

Diff for /src/usr.bin/ssh/progressmeter.c between version 1.12 and 1.13

version 1.12, 2003/07/30 07:53:27 version 1.13, 2003/07/31 22:34:03
Line 39 
Line 39 
   
 /* formats and inserts the specified size into the given buffer */  /* formats and inserts the specified size into the given buffer */
 static void format_size(char *, int, off_t);  static void format_size(char *, int, off_t);
   static void format_rate(char *, int, off_t);
   
 /* updates the progressmeter to reflect the current state of the transfer */  /* updates the progressmeter to reflect the current state of the transfer */
 void refresh_progress_meter(void);  void refresh_progress_meter(void);
Line 56 
Line 57 
 static int bytes_per_second;    /* current speed in bytes per second */  static int bytes_per_second;    /* current speed in bytes per second */
 static int win_size;            /* terminal window size */  static int win_size;            /* terminal window size */
   
   /* units for format_size */
   static const char unit[] = " KMGT";
   
 static int  static int
 can_output(void)  can_output(void)
 {  {
Line 63 
Line 67 
 }  }
   
 static void  static void
   format_rate(char *buf, int size, off_t bytes)
   {
           int i;
   
           bytes *= 100;
           for (i = 0; bytes >= 100*1000 && unit[i] != 'T'; i++)
                   bytes = (bytes + 512) / 1024;
           if (i == 0) {
                   i++;
                   bytes = (bytes + 512) / 1024;
           }
           snprintf(buf, size, "%3lld.%1lld%c%s",
               (long long) bytes / 100,
               (long long) (bytes + 5) / 10 % 10,
               unit[i],
               i ? "B" : " ");
   }
   
   static void
 format_size(char *buf, int size, off_t bytes)  format_size(char *buf, int size, off_t bytes)
 {  {
         static const char unit[] = " KMGT";  
         int i;          int i;
   
         for (i = 0; bytes >= 10000 && unit[i] != 'T'; i++)          for (i = 0; bytes >= 10000 && unit[i] != 'T'; i++)
                 bytes /= 1024;                  bytes = (bytes + 512) / 1024;
         snprintf(buf, size, "%4lld%c%s",          snprintf(buf, size, "%4lld%c%s",
             (long long) bytes,              (long long) bytes,
             unit[i],              unit[i],
Line 115 
Line 137 
   
         /* filename */          /* filename */
         buf[0] = '\0';          buf[0] = '\0';
         file_len = win_size - 34;          file_len = win_size - 35;
         if (file_len > 0) {          if (file_len > 0) {
                 len = snprintf(buf, file_len, "\r%s", file);                  len = snprintf(buf, file_len, "\r%s", file);
                 for (i = len;  i < file_len; i++ )                  for (i = len;  i < file_len; i++ )
Line 137 
Line 159 
         strlcat(buf, " ", win_size);          strlcat(buf, " ", win_size);
   
         /* bandwidth usage */          /* bandwidth usage */
         format_size(buf + strlen(buf), win_size - strlen(buf),          format_rate(buf + strlen(buf), win_size - strlen(buf),
             bytes_per_second);              bytes_per_second);
         strlcat(buf, "/s ", win_size);          strlcat(buf, "/s ", win_size);
   

Legend:
Removed from v.1.12  
changed lines
  Added in v.1.13