+struct progressInfo {
+ time_t startTime;
+ time_t lastTime;
+ off_t totalBytes;
+ off_t totalOffset;
+};
+
+void progressFunc (struct key_file *keyp, void *info)
+{
+ struct progressInfo *p = info;
+ time_t now, remaining;
+
+ if (keyp->buf_size <= 0 || p->totalBytes <= 0)
+ return ;
+ p->totalOffset += keyp->buf_size;
+ time (&now);
+
+ if (now < p->lastTime+10)
+ return ;
+ p->lastTime = now;
+ remaining = (now - p->startTime)*
+ ((double) p->totalBytes/p->totalOffset - 1.0);
+ if (remaining <= 130)
+ logf (LOG_LOG, "Merge %2.1f%% completed; %ld seconds remaining",
+ (100.0*p->totalOffset) / p->totalBytes, (long) remaining);
+ else
+ logf (LOG_LOG, "Merge %2.1f%% completed; %ld minutes remaining",
+ (100.0*p->totalOffset) / p->totalBytes, (long) remaining/60);
+}
+