7 #include "cprogress_p.h"
10 #include <gwenhywfar/inherit.h>
11 #include <gwenhywfar/debug.h>
12 #include <gwenhywfar/misc.h>
14 #include <sys/types.h>
29 uint32_t progressFlags,
39 cp->startTime=time(0);
40 cp->flags=progressFlags;
42 cp->title=strdup(title);
44 cp->text=strdup(text);
49 fprintf(stderr,
"%s: Started.\n", cp->title);
149 fprintf(stderr,
"%s: Started.\n", cp->title);
155 progress=cp->current+1;
157 if (progress!=cp->current) {
161 fprintf(stderr,
"%s: %llu\n", cp->title,
162 (
long long unsigned)progress);
164 fprintf(stderr,
"%s: %llu of %llu\n",
166 (
long long unsigned)progress,
167 (
long long unsigned)cp->total);
170 cp->current=progress;
179 fl=fcntl(fileno(stdin), F_GETFL);
184 if (fcntl(fileno(stdin), F_SETFL, fl | O_NONBLOCK)) {
191 fcntl(fileno(stdin), F_SETFL, fl);
192 if (chr==GWEN_GUI_CPROGRESS_CHAR_ABORT) {
193 fprintf(stderr,
"------> ABORTED BY USER\n");
219 if (t[strlen(t)-1]!=
'\n')
221 fprintf(stderr,
"%s", t);
239 fprintf(stderr,
"%s: Finished.\n", cp->title);