int main(int argc, char ** argv) { char buf[BUFSIZ]; long long cnt = 0; time_t to, tn, ts, dt; int read_count; double rate; if (argc > 1) { fprintf(stderr, "%s", usage()); exit(1); } to = time(NULL); ts = to; fprintf(stderr, "%s", down); while (1) { read_count = read (0, buf, sizeof(buf)); if (read_count < 0 && errno == EINTR) continue; // not an error if (read_count < 0) { perror("Abnormal condition in read from stdin:"); exit(1); } if (read_count > 0) { cnt += read_count; if (fwrite (buf, 1, read_count, stdout) != read_count) { perror("Error in wcs writing to stdout:"); exit(1); } } tn = time(NULL); if (tn != to || read_count == 0) { to = tn; fprintf(stderr, "%s read: ", up); printlong(cnt); fprintf(stderr, " [ %12lld B] avg: ", cnt); // Calculate the rate dt = tn - ts; if (dt <= 0) dt = 1; // sometimes the difference is even negative // possibly slightly different per-core times rate = cnt / (double)dt; printlong((long long) rate); fprintf(stderr, "/sec [ %5d sec]%s", (int)dt, down); } if (read_count == 0) break; // we are done } fprintf(stderr, "\n"); return(0); }
static void printstat_1p() { setattr_normal(); if (!_WHITE_BG) setattr_bold(); setcurs(1, 2); printlong(" %06ld ", player1.score % 1000000); setcurs(3, 6); printint(" %02d ", player1.level); setcurs(3, 10); printint(" %03d ", player1.lines); }
static void print8longs(unsigned long v1, unsigned long v2, unsigned long v3, unsigned long v4, unsigned long v5, unsigned long v6, unsigned long v7, unsigned long v8) { printlong(v1); printf(" "); printlong(v2); printf(" "); printlong(v3); printf(" "); printlong(v4); printf(" "); printlong(v5); printf(" "); printlong(v6); printf(" "); printlong(v7); printf(" "); printlong(v8); printf("\n"); }