| 1420 | */ |
| 1421 | |
| 1422 | void |
| 1423 | do_oracles(void) |
| 1424 | { |
| 1425 | char infile[60], tempfile[60], xbuf[BUFSZ]; |
| 1426 | boolean in_oracle, ok; |
| 1427 | long fpos; |
| 1428 | unsigned long txt_offset, offset; |
| 1429 | int oracle_cnt; |
| 1430 | int i; |
| 1431 | char *line; |
| 1432 | |
| 1433 | Sprintf(tempfile, DATA_TEMPLATE, "oracles.tmp"); |
| 1434 | filename[0] = '\0'; |
| 1435 | #ifdef FILE_PREFIX |
| 1436 | Strcat(filename, file_prefix); |
| 1437 | #endif |
| 1438 | Sprintf(eos(filename), DATA_TEMPLATE, ORACLE_FILE); |
| 1439 | Sprintf(infile, DATA_IN_TEMPLATE, ORACLE_FILE); |
| 1440 | Strcat(infile, ".txt"); |
| 1441 | if (!(ifp = fopen(infile, RDTMODE))) { |
| 1442 | perror(infile); |
| 1443 | makedefs_exit(EXIT_FAILURE); |
| 1444 | /*NOTREACHED*/ |
| 1445 | } |
| 1446 | if (!(ofp = fopen(filename, WRTMODE))) { |
| 1447 | perror(filename); |
| 1448 | Fclose(ifp); |
| 1449 | makedefs_exit(EXIT_FAILURE); |
| 1450 | /*NOTREACHED*/ |
| 1451 | } |
| 1452 | if (!(tfp = fopen(tempfile, WRTMODE))) { /* oracles.tmp */ |
| 1453 | perror(tempfile); |
| 1454 | Fclose(ifp); |
| 1455 | Fclose(ofp); |
| 1456 | Unlink(filename); |
| 1457 | makedefs_exit(EXIT_FAILURE); |
| 1458 | /*NOTREACHED*/ |
| 1459 | } |
| 1460 | |
| 1461 | /* output a dummy header record; we'll rewind and overwrite it later */ |
| 1462 | Fprintf(ofp, "%s%5d\n", Dont_Edit_Data, 0); |
| 1463 | |
| 1464 | /* handle special oracle; it must come first */ |
| 1465 | (void) fputs("---\n", tfp); |
| 1466 | offset = (unsigned long) ftell(tfp); |
| 1467 | Fprintf(ofp, "%05lx\n", offset); /* start pos of special oracle */ |
| 1468 | for (i = 0; i < SIZE(special_oracle); i++) { |
| 1469 | (void) fputs(xcrypt(special_oracle[i], xbuf), tfp); |
| 1470 | (void) fputc('\n', tfp); |
| 1471 | } |
| 1472 | SpinCursor(3); |
| 1473 | |
| 1474 | oracle_cnt = 1; |
| 1475 | (void) fputs("---\n", tfp); |
| 1476 | offset = (unsigned long) ftell(tfp); |
| 1477 | Fprintf(ofp, "%05lx\n", offset); /* start pos of first oracle */ |
| 1478 | in_oracle = FALSE; |
| 1479 |
no test coverage detected