static char *status_get_c(char *buffer, int64 *c, unsigned int c_ehi) { int64 current, next, rem; char *p; if (c_ehi) { strcpy(buffer, "OVERFLOW"); return buffer; } p = buffer + 31; *p = 0; current = *c; do { next = current; div64by32(&next, 10); rem = next; mul64by32(&rem, 10); neg64(&rem); add64to64(&rem, ¤t); *--p = rem.lo + '0'; current = next; } while (current.lo || current.hi); return p; }
static char *status_get_cps(char *buffer) { int use_ticks; clock_t ticks; unsigned long time; int64 tmp, cps; unsigned int cps_100; use_ticks = !status.crypts.hi && !status_restored_time; ticks = get_time() - status.start_time; if (use_ticks) time = ticks; else time = status_restored_time + ticks / clk_tck; if (!time) time = 1; cps = status.crypts; if (use_ticks) mul64by32(&cps, clk_tck); div64by32(&cps, time); if (cps.hi > 232 || (cps.hi == 232 && cps.lo >= 3567587328U)) sprintf(buffer, "%uG", div64by32lo(&cps, 1000000000)); else if (cps.hi || cps.lo >= 1000000000) sprintf(buffer, "%uM", div64by32lo(&cps, 1000000)); else if (cps.lo >= 1000000) sprintf(buffer, "%uK", div64by32lo(&cps, 1000)); else if (cps.lo >= 100) sprintf(buffer, "%u", cps.lo); else { tmp = status.crypts; if (use_ticks) mul64by32(&tmp, clk_tck); mul64by32(&tmp, 100); cps_100 = div64by32lo(&tmp, time) % 100; sprintf(buffer, "%u.%02u", cps.lo, cps_100); } return buffer; }
static void status_print_stdout(char *percent) { unsigned int time = status_get_time(); char s_wps[64]; char s_words[32]; int64 current, next, rem; char *s_words_ptr; s_words_ptr = &s_words[sizeof(s_words) - 1]; *s_words_ptr = 0; current = status.crypts; do { next = current; div64by32(&next, 10); rem = next; mul64by32(&rem, 10); neg64(&rem); add64to64(&rem, ¤t); *--s_words_ptr = rem.lo + '0'; current = next; } while (current.lo || current.hi); fprintf(stderr, "words: %s " "time: %u:%02u:%02u:%02u" "%s%s " "w/s: %s", s_words_ptr, time / 86400, time % 86400 / 3600, time % 3600 / 60, time % 60, strncmp(percent, " 100", 4) ? percent : " DONE", status_get_ETA(percent, time), status_get_cps(s_wps)); if ((options.flags & FLG_STATUS_CHK) || !(status.crypts.lo | status.crypts.hi)) fputc('\n', stderr); else fprintf(stderr, " current: %s\n", crk_get_key1()); }
static char *status_get_cps(char *buffer, int64 *c, unsigned int c_ehi) { int use_ticks; clock_t ticks; unsigned long time; int64 tmp, cps; if (!(c->lo | c->hi | c_ehi)) return "0"; use_ticks = !(c->hi | c_ehi | status_restored_time); ticks = get_time() - status.start_time; if (use_ticks) time = ticks; else time = status_restored_time + ticks / clk_tck; if (!time) time = 1; cps = *c; if (c_ehi) { cps.lo = cps.hi; cps.hi = c_ehi; } if (use_ticks) mul64by32(&cps, clk_tck); div64by32(&cps, time); if (c_ehi) { cps.hi = cps.lo; cps.lo = 0; } if (cps.hi > 232 || (cps.hi == 232 && cps.lo >= 3567587328U)) sprintf(buffer, "%uG", div64by32lo(&cps, 1000000000)); else if (cps.hi || cps.lo >= 1000000000) sprintf(buffer, "%uM", div64by32lo(&cps, 1000000)); else if (cps.lo >= 1000000) sprintf(buffer, "%uK", div64by32lo(&cps, 1000)); else if (cps.lo >= 1000) sprintf(buffer, "%u", cps.lo); else { const char *fmt; unsigned int div, frac; fmt = "%u.%06u"; div = 1000000; if (cps.lo >= 100) { fmt = "%u.%u"; div = 10; } else if (cps.lo >= 10) { fmt = "%u.%02u"; div = 100; } else if (cps.lo >= 1) { fmt = "%u.%03u"; div = 1000; } tmp = *c; if (use_ticks) mul64by32(&tmp, clk_tck); mul64by32(&tmp, div); frac = div64by32lo(&tmp, time); if (div == 1000000) { if (frac >= 100000) { fmt = "%u.%04u"; div = 10000; frac /= 100; } else if (frac >= 10000) { fmt = "%u.%05u"; div = 100000; frac /= 10; } } frac %= div; sprintf(buffer, fmt, cps.lo, frac); } return buffer; }