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);
142 fprintf(stderr,
"%s: Started.\n", cp->title);
148 progress=cp->current+1;
150 if (progress!=cp->current) {
154 fprintf(stderr,
"%s: %llu\n", cp->title,
155 (
long long unsigned)progress);
157 fprintf(stderr,
"%s: %llu of %llu\n",
159 (
long long unsigned)progress,
160 (
long long unsigned)cp->total);
163 cp->current=progress;
172 fl=fcntl(fileno(stdin), F_GETFL);
177 if (fcntl(fileno(stdin), F_SETFL, fl | O_NONBLOCK)) {
184 fcntl(fileno(stdin), F_SETFL, fl);
185 if (chr==GWEN_GUI_CPROGRESS_CHAR_ABORT) {
186 fprintf(stderr,
"------> ABORTED BY USER\n");
212 if (t[strlen(t)-1]!=
'\n')
214 fprintf(stderr,
"%s", t);
232 fprintf(stderr,
"%s: Finished.\n", cp->title);