#define CSIZE_HARDLIMIT 5200000L
-
static struct kaoconf {
char *user;
char *pass;
off_t size;
off_t remn;
off_t coff;
+ off_t sent;
curl_off_t speed;
};
return byps;
}
+static uint64_t time_ms( void ) {
+ struct timespec tv;
+ clock_gettime( CLOCK_REALTIME, &tv );
+ return (uint64_t)tv.tv_sec * 1000 + ( tv.tv_nsec / 1000000L );
+}
+
static void parse_cfg( const char *confpath ) {
FILE *fp;
char buf[256];
curl_easy_getinfo( curl, CURLINFO_SPEED_UPLOAD_T, &fi->speed );
curl_easy_getinfo( curl, CURLINFO_RESPONSE_CODE, &http_code );
+ fi->sent += csize;
// puts(reply.memory);
struct file_info_t fi;
struct stat stbuf;
CURL *curl;
+ uint64_t starttime, xfrtime;
if ( NULL == ( curl = curl_easy_init() ) )
die( "curl_easy_init failed", 0 );
goto err_out;
}
fi.remn = fi.size = stbuf.st_size;
- fi.coff = 0;
+ fi.coff = fi.sent = 0;
printf( "File: %s (%lu bytes)\n", fi.name, (unsigned long)fi.size );
+ starttime = time_ms();
while ( fi.remn ) {
if ( gotsig ) {
// fprintf( stderr, "[csize: %ld] {offset: %ld} ", (long)csize, (long)fi.coff );
fflush( stderr );
}
- if ( res < 0 ) {
- puts( "" );
+
+ xfrtime = time_ms() - starttime + 1;
+ printf( "\rSent %.1f kB in %.1f seconds (%.1f kB/s).\n",
+ (double)fi.sent / 1024, (double)xfrtime / 1000, (double)fi.sent / xfrtime * 1000 / 1024 );
+ if ( res < 0 )
err( "file upload incomplete", 0 );
- }
else
- printf( "\r%-20s\n", "Upload complete." );
+ printf( "Upload complete.\n" );
err_out:
curl_free( fi.esc_name );