void c_quit(void) { int j; for (j = 0;j < cnum;++j) { buffer_flush(&c[j].ss); while (fsync(c[j].fdcurrent) == -1) pause3("unable to write ",c[j].dir,"/current to disk, pausing: "); while (fchmod(c[j].fdcurrent,0744) == -1) pause3("unable to set mode of ",c[j].dir,"/current, pausing: "); } }
int c_write(int pos,char *buf,int len) { struct cyclog *d; int w; d = c + pos; if (d->bytes >= d->size) fullcurrent(d); if (len >= d->size - d->bytes) len = d->size - d->bytes; if (d->bytes + len >= d->size - 2000) { w = byte_rchr(buf,len,'\n'); if (w < len) len = w + 1; } for (;;) { w = write(d->fdcurrent,buf,len); if (w > 0) break; pause3("unable to write to ",d->dir,"/current, pausing: "); } d->bytes += w; if (d->bytes >= d->size - 2000) if (buf[w - 1] == '\n') fullcurrent(d); return w; }
void finish(struct cyclog *d,const char *file,const char *code) { struct stat st; for (;;) { if (stat(file,&st) == 0) break; if (errno == error_noent) return; pause5("unable to stat ",d->dir,"/",file,", pausing: "); } if (st.st_nlink == 1) for (;;) { timestamp(fn); fn[25] = '.'; fn[26] = code[0]; fn[27] = 0; if (link(file,fn) == 0) break; pause5("unable to link to ",d->dir,"/",fn,", pausing: "); } while (unlink(file) == -1) pause5("unable to remove ",d->dir,"/",file,", pausing: "); for (;;) switch(filesfit(d)) { case 1: return; case -1: pause3("unable to read ",d->dir,", pausing: "); } }
void doit(char **script) { int flageof; char ch; int j; int i; char *action; int flagselected; int flagtimestamp; flagtimestamp = 0; if (script[0]) if (script[0][0] == 't') flagtimestamp = 1; for (i = 0;i <= 1000;++i) line[i] = '\n'; linelen = 0; flageof = 0; for (;;) { for (i = 0;i < linelen;++i) line[i] = '\n'; linelen = 0; while (linelen < 1000) { if (buffer_GETC(&ssin,&ch) <= 0) { if (!linelen) return; flageof = 1; break; } if (!linelen) if (flagtimestamp) { linelen = iso_timestamp(line); } if (ch == '\n') break; line[linelen++] = ch; } flagselected = 1; j = 0; for (i = 0;action = script[i];++i) switch(*action) { case '+': if (!flagselected) if (match(action + 1,line,linelen)) flagselected = 1; break; case '-': if (flagselected) if (match(action + 1,line,linelen)) flagselected = 0; break; case 'e': if (flagselected) { if (linelen > 200) { buffer_put(buffer_2,line,200); buffer_puts(buffer_2,"...\n"); } else { buffer_put(buffer_2,line,linelen); buffer_puts(buffer_2,"\n"); } buffer_flush(buffer_2); } break; case '=': if (flagselected) for (;;) { while (seek_begin(f[i]) == -1) pause3("unable to move to beginning of ",action + 1,", pausing: "); if (write(f[i],line,1001) == 1001) break; pause3("unable to write ",action + 1,", pausing: "); } break; case '.': case '/': c[j].flagselected = flagselected; ++j; break; } for (j = 0;j < cnum;++j) if (c[j].flagselected) buffer_put(&c[j].ss,line,linelen); if (linelen == 1000) for (;;) { if (buffer_GETC(&ssin,&ch) <= 0) { flageof = 1; break; } if (ch == '\n') break; for (j = 0;j < cnum;++j) if (c[j].flagselected) buffer_PUTC(&c[j].ss,ch); } for (j = 0;j < cnum;++j) if (c[j].flagselected) { ch = '\n'; buffer_PUTC(&c[j].ss,ch); } if (flageof) return; } }
void fullcurrent(struct cyclog *d) { int fd; int pid; int wstat; while (fchdir(d->fddir) == -1) pause3("unable to switch to ",d->dir,", pausing: "); while (fsync(d->fdcurrent) == -1) pause3("unable to write ",d->dir,"/current to disk, pausing: "); close(d->fdcurrent); while (rename("current","previous") == -1) pause3("unable to rename current to previous in directory ",d->dir,", pausing: "); while ((d->fdcurrent = open_append("current")) == -1) pause3("unable to create ",d->dir,"/current, pausing: "); coe(d->fdcurrent); d->bytes = 0; while (fchmod(d->fdcurrent,0644) == -1) pause3("unable to set mode of ",d->dir,"/current, pausing: "); while (chmod("previous",0744) == -1) pause3("unable to set mode of ",d->dir,"/previous, pausing: "); if (!d->processor) finish(d,"previous","s"); else { for (;;) { while ((pid = fork()) == -1) pause3("unable to fork for processor in ",d->dir,", pausing: "); if (!pid) { startprocessor(d); strerr_die4sys(111,FATAL,"unable to run ",d->processor,": "); } if (wait_pid(&wstat,pid) == -1) pause3("wait failed for processor in ",d->dir,", pausing: "); else if (wait_crashed(wstat)) pause3("processor crashed in ",d->dir,", pausing: "); else if (!wait_exitcode(wstat)) break; strerr_warn4(WARNING,"processor failed in ",d->dir,", pausing",0); deepsleep(5); } while ((fd = open_append("processed")) == -1) pause3("unable to create ",d->dir,"/processed, pausing: "); while (fsync(fd) == -1) pause3("unable to write ",d->dir,"/processed to disk, pausing: "); while (fchmod(fd,0744) == -1) pause3("unable to set mode of ",d->dir,"/processed, pausing: "); close(fd); while ((fd = open_append("newstate")) == -1) pause3("unable to create ",d->dir,"/newstate, pausing: "); while (fsync(fd) == -1) pause3("unable to write ",d->dir,"/newstate to disk, pausing: "); close(fd); while (unlink("previous") == -1) pause3("unable to remove ",d->dir,"/previous, pausing: "); while (rename("newstate","state") == -1) pause3("unable to rename newstate to state in directory ",d->dir,", pausing: "); finish(d,"processed","s"); } }
void tst_QPauseAnimationJob::multipleSequentialGroups() { EnableConsistentTiming enabled; QParallelAnimationGroupJob group; group.setLoopCount(2); QSequentialAnimationGroupJob subgroup1; group.appendAnimation(&subgroup1); TestableGenericAnimation animation(300); subgroup1.appendAnimation(&animation); TestablePauseAnimation pause(200); subgroup1.appendAnimation(&pause); QSequentialAnimationGroupJob subgroup2; group.appendAnimation(&subgroup2); TestableGenericAnimation animation2(200); subgroup2.appendAnimation(&animation2); TestablePauseAnimation pause2(250); subgroup2.appendAnimation(&pause2); QSequentialAnimationGroupJob subgroup3; group.appendAnimation(&subgroup3); TestablePauseAnimation pause3(400); subgroup3.appendAnimation(&pause3); TestableGenericAnimation animation3(200); subgroup3.appendAnimation(&animation3); QSequentialAnimationGroupJob subgroup4; group.appendAnimation(&subgroup4); TestablePauseAnimation pause4(310); subgroup4.appendAnimation(&pause4); TestablePauseAnimation pause5(60); subgroup4.appendAnimation(&pause5); group.start(); QVERIFY(group.state() == QAbstractAnimationJob::Running); QVERIFY(subgroup1.state() == QAbstractAnimationJob::Running); QVERIFY(subgroup2.state() == QAbstractAnimationJob::Running); QVERIFY(subgroup3.state() == QAbstractAnimationJob::Running); QVERIFY(subgroup4.state() == QAbstractAnimationJob::Running); // This is a pretty long animation so it tends to get rather out of sync // when using the consistent timer, so run for an extra half second for good // measure... QTest::qWait(group.totalDuration() + 500); #ifdef Q_OS_WIN if (group.state() != QAbstractAnimationJob::Stopped) QEXPECT_FAIL("", winTimerError, Abort); #endif QTRY_VERIFY(group.state() == QAbstractAnimationJob::Stopped); #ifdef Q_OS_WIN if (subgroup1.state() != QAbstractAnimationJob::Stopped) QEXPECT_FAIL("", winTimerError, Abort); #endif QVERIFY(subgroup1.state() == QAbstractAnimationJob::Stopped); #ifdef Q_OS_WIN if (subgroup2.state() != QAbstractAnimationJob::Stopped) QEXPECT_FAIL("", winTimerError, Abort); #endif QVERIFY(subgroup2.state() == QAbstractAnimationJob::Stopped); #ifdef Q_OS_WIN if (subgroup3.state() != QAbstractAnimationJob::Stopped) QEXPECT_FAIL("", winTimerError, Abort); #endif QVERIFY(subgroup3.state() == QAbstractAnimationJob::Stopped); #ifdef Q_OS_WIN if (subgroup4.state() != QAbstractAnimationJob::Stopped) QEXPECT_FAIL("", winTimerError, Abort); #endif QVERIFY(subgroup4.state() == QAbstractAnimationJob::Stopped); #ifdef Q_OS_WIN if (pause5.m_updateCurrentTimeCount != 4) QEXPECT_FAIL("", winTimerError, Abort); #endif QCOMPARE(pause5.m_updateCurrentTimeCount, 4); }