static ex_t get_robx(bfpath *bfp) { double rx; int ret = 0; init_wordlist("word", bfp->filepath, 0, WL_REGULAR); rx = compute_robinson_x(); if (rx < 0) return EX_ERROR; if (onlyprint) printf("%f\n", rx); else { dsv_t val; word_t *word_robx = word_news(ROBX_W); /* since compute_robinson_x() closes the wordlists, init_wordlist() must be called again */ init_wordlist("word", bfp->filepath, 0, WL_REGULAR); open_wordlists(DS_WRITE); val.goodcount = 0; val.spamcount = (uint32_t) (rx * 1000000); do { ret = ds_write(word_lists->dsh, word_robx, &val); if (ret == DS_ABORT_RETRY) { rand_sleep(1000, 1000000); begin_wordlist(word_lists); } } while (ret == DS_ABORT_RETRY); close_wordlists(true); free_wordlists(); word_free(word_robx); } return ret ? EX_ERROR : EX_OK; }
static double get_robx(void) { double rx; if (user_robx > 0.0) rx = user_robx; else if (ds_flag == DS_DSK) { printf("Calculating initial x value...\n"); verbose = -verbose; /* disable bogofilter debug output */ rx = compute_robinson_x(); verbose = -verbose; /* enable bogofilter debug output */ } else rx = ROBX; if (rx > RX_MAX) rx = RX_MAX; if (rx < RX_MIN) rx = RX_MIN; printf("Initial x value is %8.6f\n", rx); return rx; }