test that the true/false rumor boundaries are valid and show the first two and very last epitaphs, engravings, and bogus monsters */
| 193 | /* test that the true/false rumor boundaries are valid and show the first |
| 194 | two and very last epitaphs, engravings, and bogus monsters */ |
| 195 | void |
| 196 | rumor_check(void) |
| 197 | { |
| 198 | dlb *rumors; |
| 199 | winid tmpwin = WIN_ERR; |
| 200 | char *endp, line[BUFSZ], xbuf[BUFSZ], rumor_buf[BUFSZ]; |
| 201 | |
| 202 | rumors = (gt.true_rumor_size >= 0) ? dlb_fopen(RUMORFILE, "r") : 0; |
| 203 | if (rumors) { |
| 204 | long ftell_rumor_start = 0L; |
| 205 | |
| 206 | rumor_buf[0] = '\0'; |
| 207 | if (gt.true_rumor_size == 0L) { /* if this is 1st outrumor() */ |
| 208 | init_rumors(rumors); |
| 209 | if (gt.true_rumor_size < 0L) { |
| 210 | rumors = (dlb *) 0; /* init_rumors() closes it upon failure */ |
| 211 | goto no_rumors; /* init failed */ |
| 212 | } |
| 213 | } |
| 214 | tmpwin = create_nhwindow(NHW_TEXT); |
| 215 | |
| 216 | /* |
| 217 | * reveal the values. |
| 218 | */ |
| 219 | Sprintf(rumor_buf, |
| 220 | "T start=%06ld (%06lx), end=%06ld (%06lx), size=%06ld (%06lx)", |
| 221 | (long) gt.true_rumor_start, gt.true_rumor_start, |
| 222 | gt.true_rumor_end, (unsigned long) gt.true_rumor_end, |
| 223 | gt.true_rumor_size,(unsigned long) gt.true_rumor_size); |
| 224 | putstr(tmpwin, 0, rumor_buf); |
| 225 | Sprintf(rumor_buf, |
| 226 | "F start=%06ld (%06lx), end=%06ld (%06lx), size=%06ld (%06lx)", |
| 227 | (long) gf.false_rumor_start, gf.false_rumor_start, |
| 228 | gf.false_rumor_end, (unsigned long) gf.false_rumor_end, |
| 229 | gf.false_rumor_size, (unsigned long) gf.false_rumor_size); |
| 230 | putstr(tmpwin, 0, rumor_buf); |
| 231 | |
| 232 | /* |
| 233 | * check the first rumor (start of true rumors) by |
| 234 | * skipping the first two lines. |
| 235 | * |
| 236 | * Then seek to the start of the false rumors (based on |
| 237 | * the value read in rumors, and display it. |
| 238 | */ |
| 239 | rumor_buf[0] = '\0'; |
| 240 | (void) dlb_fseek(rumors, (long) gt.true_rumor_start, SEEK_SET); |
| 241 | ftell_rumor_start = dlb_ftell(rumors); |
| 242 | (void) dlb_fgets(line, sizeof line, rumors); |
| 243 | if ((endp = strchr(line, '\n')) != 0) |
| 244 | *endp = 0; |
| 245 | Sprintf(rumor_buf, "T %06ld %s", ftell_rumor_start, |
| 246 | xcrypt(line, xbuf)); |
| 247 | putstr(tmpwin, 0, rumor_buf); |
| 248 | /* find last true rumor */ |
| 249 | while (dlb_fgets(line, sizeof line, rumors) |
| 250 | && dlb_ftell(rumors) < gt.true_rumor_end) |
| 251 | continue; |
| 252 | if ((endp = strchr(line, '\n')) != 0) |
no test coverage detected