/[axel]/trunk/axel.c
ViewVC logotype

Diff of /trunk/axel.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 24 by appaji-guest, Wed Jan 16 07:56:47 2008 UTC revision 25 by appaji-guest, Wed Jan 30 11:38:43 2008 UTC
# Line 23  Line 23 
23    Suite 330, Boston, MA  02111-1307  USA    Suite 330, Boston, MA  02111-1307  USA
24  */  */
25    
26    #define _FILE_OFFSET_BITS 64
27  #include "axel.h"  #include "axel.h"
28    
29  /* Axel */  /* Axel */
# Line 123  axel_t *axel_new( conf_t *conf, int coun Line 124  axel_t *axel_new( conf_t *conf, int coun
124          if( ( axel->size = axel->conn[0].size ) != INT_MAX )          if( ( axel->size = axel->conn[0].size ) != INT_MAX )
125          {          {
126                  if( axel->conf->verbose > 0 )                  if( axel->conf->verbose > 0 )
127                          axel_message( axel, _("File size: %i bytes"), axel->size );                          axel_message( axel, _("File size: %lld bytes"), axel->size );
128          }          }
129    
130          /* Wildcards in URL --> Get complete filename                   */          /* Wildcards in URL --> Get complete filename                   */
# Line 137  axel_t *axel_new( conf_t *conf, int coun Line 138  axel_t *axel_new( conf_t *conf, int coun
138  int axel_open( axel_t *axel )  int axel_open( axel_t *axel )
139  {  {
140          int i, fd;          int i, fd;
141            long long int j;
142    
143          if( axel->conf->verbose > 0 )          if( axel->conf->verbose > 0 )
144                  axel_message( axel, _("Opening output file %s"), axel->filename );                  axel_message( axel, _("Opening output file %s"), axel->filename );
# Line 167  int axel_open( axel_t *axel ) Line 169  int axel_open( axel_t *axel )
169                  for( i = 0; i < axel->conf->num_connections; i ++ )                  for( i = 0; i < axel->conf->num_connections; i ++ )
170                          read( fd, &axel->conn[i].currentbyte, sizeof( axel->conn[i].currentbyte ) );                          read( fd, &axel->conn[i].currentbyte, sizeof( axel->conn[i].currentbyte ) );
171    
172                  axel_message( axel, _("State file found: %i bytes downloaded, %i to go."),                  axel_message( axel, _("State file found: %lld bytes downloaded, %lld to go."),
173                          axel->bytes_done, axel->size - axel->bytes_done );                          axel->bytes_done, axel->size - axel->bytes_done );
174    
175                  close( fd );                  close( fd );
# Line 193  int axel_open( axel_t *axel ) Line 195  int axel_open( axel_t *axel )
195                  /* And check whether the filesystem can handle seeks to                  /* And check whether the filesystem can handle seeks to
196                     past-EOF areas.. Speeds things up. :) AFAIK this                     past-EOF areas.. Speeds things up. :) AFAIK this
197                     should just not happen:                              */                     should just not happen:                              */
198                  if( lseek( axel->outfd, axel->size, SEEK_SET ) == -1 && axel->conf->num_connections > 1 )                  if( lseek64( axel->outfd, axel->size, SEEK_SET ) == -1 && axel->conf->num_connections > 1 )
199                  {                  {
200                          /* But if the OS/fs does not allow to seek behind                          /* But if the OS/fs does not allow to seek behind
201                             EOF, we have to fill the file with zeroes before                             EOF, we have to fill the file with zeroes before
# Line 201  int axel_open( axel_t *axel ) Line 203  int axel_open( axel_t *axel )
203                          axel_message( axel, _("Crappy filesystem/OS.. Working around. :-(") );                          axel_message( axel, _("Crappy filesystem/OS.. Working around. :-(") );
204                          lseek( axel->outfd, 0, SEEK_SET );                          lseek( axel->outfd, 0, SEEK_SET );
205                          memset( buffer, 0, axel->conf->buffer_size );                          memset( buffer, 0, axel->conf->buffer_size );
206                          i = axel->size;                          j = axel->size;
207                          while( i > 0 )                          while( j > 0 )
208                          {                          {
209                                  write( axel->outfd, buffer, min( i, axel->conf->buffer_size ) );                                  write( axel->outfd, buffer, min( j, axel->conf->buffer_size ) );
210                                  i -= axel->conf->buffer_size;                                  j -= axel->conf->buffer_size;
211                          }                          }
212                  }                  }
213          }          }
# Line 260  void axel_start( axel_t *axel ) Line 262  void axel_start( axel_t *axel )
262  void axel_do( axel_t *axel )  void axel_do( axel_t *axel )
263  {  {
264          fd_set fds[1];          fd_set fds[1];
265          int hifd, i, j, size;          int hifd, i, j;
266            long long int size;
267          struct timeval timeval[1];          struct timeval timeval[1];
268    
269          /* Create statefile if necessary                                */          /* Create statefile if necessary                                */
# Line 571  static void axel_divide( axel_t *axel ) Line 574  static void axel_divide( axel_t *axel )
574          for( i = 1; i < axel->conf->num_connections; i ++ )          for( i = 1; i < axel->conf->num_connections; i ++ )
575          {          {
576  #ifdef DEBUG  #ifdef DEBUG
577                  printf( "Downloading %i-%i using conn. %i\n", axel->conn[i-1].currentbyte, axel->conn[i-1].lastbyte, i - 1 );                  printf( "Downloading %lld-%lld using conn. %i\n", axel->conn[i-1].currentbyte, axel->conn[i-1].lastbyte, i - 1 );
578  #endif  #endif
579                  axel->conn[i].currentbyte = axel->conn[i-1].lastbyte + 1;                  axel->conn[i].currentbyte = axel->conn[i-1].lastbyte + 1;
580                  axel->conn[i].lastbyte = axel->conn[i].currentbyte + axel->size / axel->conf->num_connections;                  axel->conn[i].lastbyte = axel->conn[i].currentbyte + axel->size / axel->conf->num_connections;
581          }          }
582          axel->conn[axel->conf->num_connections-1].lastbyte = axel->size - 1;          axel->conn[axel->conf->num_connections-1].lastbyte = axel->size - 1;
583  #ifdef DEBUG  #ifdef DEBUG
584          printf( "Downloading %i-%i using conn. %i\n", axel->conn[i-1].currentbyte, axel->conn[i-1].lastbyte, i - 1 );          printf( "Downloading %lld-%lld using conn. %i\n", axel->conn[i-1].currentbyte, axel->conn[i-1].lastbyte, i - 1 );
585  #endif  #endif
586  }  }

Legend:
Removed from v.24  
changed lines
  Added in v.25

  ViewVC Help
Powered by ViewVC 1.1.5