Scans the file for the custom script block and count how many lines are in it
| 9361 | |
| 9362 | // Scans the file for the custom script block and count how many lines are in it |
| 9363 | int CDallasMainDlg::CountCustomScriptLines(CFILE *infile) { |
| 9364 | int32_t start_pos; |
| 9365 | int line_count; |
| 9366 | char linebuf[2048]; |
| 9367 | bool done; |
| 9368 | |
| 9369 | line_count = 0; |
| 9370 | done = false; |
| 9371 | |
| 9372 | // Save the current file position |
| 9373 | start_pos = cftell(infile); |
| 9374 | |
| 9375 | // Read all the lines in the block |
| 9376 | while (!done && !cfeof(infile)) { |
| 9377 | |
| 9378 | strcpy(linebuf, ""); |
| 9379 | cf_ReadString(linebuf, sizeof(linebuf), infile); |
| 9380 | |
| 9381 | // Check for End of Script Block Section |
| 9382 | if (strncmp(linebuf, CUSTOM_SCRIPT_BLOCK_END_TAG, strlen(CUSTOM_SCRIPT_BLOCK_END_TAG)) == 0) { |
| 9383 | done = true; |
| 9384 | continue; |
| 9385 | } |
| 9386 | |
| 9387 | // If it's not the end of custom block tag, then it's a line we need to save |
| 9388 | line_count++; |
| 9389 | } |
| 9390 | |
| 9391 | // Move file pointer back to the original starting position |
| 9392 | cfseek(infile, start_pos, SEEK_SET); |
| 9393 | |
| 9394 | return (line_count); |
| 9395 | } |
| 9396 | |
| 9397 | // Reads in and stores all the lines in the custom script block |
| 9398 | int CDallasMainDlg::ParseCustomScriptFile(char *filename, bool show_errors /*=TRUE*/) { |
nothing calls this directly
no test coverage detected