csync: Add userdata parameter to the overall progress callback.

Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
Klaas Freitag 2013-07-19 12:45:30 +02:00 committed by Andreas Schneider
parent 0c3becfdb6
commit 05a62bb41f
3 changed files with 20 additions and 6 deletions

View file

@ -186,8 +186,12 @@ static int parse_args(struct argument_s *csync_args, int argc, char **argv)
return optind; return optind;
} }
static void _overall_callback(const char *file_name, int file_no, static void _overall_callback(const char *file_name,
int file_cnt, long long o1, long long o2) int file_no,
int file_cnt,
long long o1,
long long o2,
void *userdata)
{ {
printf("File #%2d/%2d: %s (%lld/%lld bytes)\n", file_no, file_cnt, file_name, o1, o2 ); printf("File #%2d/%2d: %s (%lld/%lld bytes)\n", file_no, file_cnt, file_name, o1, o2 );
} }

View file

@ -589,9 +589,15 @@ int csync_set_file_progress_callback(CSYNC* ctx, csync_file_progress_callback cb
* @param o1 The current transmitted bytes. * @param o1 The current transmitted bytes.
* *
* @param o2 The overall sum of bytes to transmit. * @param o2 The overall sum of bytes to transmit.
*
* @param userdata The user data pointer.
*/ */
typedef void (*csync_overall_progress_callback) (const char *file_name, int file_no, typedef void (*csync_overall_progress_callback) (const char *file_name,
int file_cnt, long long o1, long long o2); int file_no,
int file_cnt,
long long o1,
long long o2,
void *userdata);
/** /**
* @brief Set a progress callback for the overall files. * @brief Set a progress callback for the overall files.

View file

@ -465,8 +465,12 @@ static int _csync_push_file(CSYNC *ctx, csync_file_stat_t *st) {
/* Notify the overall progress */ /* Notify the overall progress */
if (ctx->callbacks.overall_progress_cb) { if (ctx->callbacks.overall_progress_cb) {
ctx->progress.byte_current += st->size; ctx->progress.byte_current += st->size;
ctx->callbacks.overall_progress_cb(duri, ++ctx->progress.current_file_no, ctx->progress.file_count, ctx->callbacks.overall_progress_cb(duri,
ctx->progress.byte_current, ctx->progress.byte_sum); ++ctx->progress.current_file_no,
ctx->progress.file_count,
ctx->progress.byte_current,
ctx->progress.byte_sum,
ctx->callbacks.userdata);
} }
CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG, "PUSHED file: %s", duri); CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG, "PUSHED file: %s", duri);