void cwcomment_process_game(CWGame *game, CWRoster *visitors, CWRoster *home) { char *buf; char output_line[4096]; int i, comma; CWGameIterator *gameiter = cw_gameiter_create(game); if (gameiter->game->first_comment != NULL) { comma = 0; strcpy(output_line, ""); buf = output_line; for (i = 0; i < 3; i++) { if (fields[i]) { if (ascii && comma) { *(buf++) = ','; } else { comma = 1; } buf += (*function_ptrs[i])(buf, gameiter, 1); } } printf("%s", output_line); printf("\n"); } while (gameiter->event != NULL) { if (gameiter->event->first_comment == NULL) { cw_gameiter_next(gameiter); continue; } comma = 0; strcpy(output_line, ""); buf = output_line; for (i = 0; i < 3; i++) { if (fields[i]) { if (ascii && comma) { *(buf++) = ','; } else { comma = 1; } buf += (*function_ptrs[i])(buf, gameiter, 0); } } printf("%s", output_line); printf("\n"); cw_gameiter_next(gameiter); } cw_gameiter_cleanup(gameiter); free(gameiter); }
void cwsub_process_game(CWGame *game, CWRoster *visitors, CWRoster *home) { char *buf; char output_line[1024]; int i, comma; CWGameIterator *gameiter = cw_gameiter_create(game); while (gameiter->event != NULL) { CWAppearance *sub = gameiter->event->first_sub; while (sub) { comma = 0; strcpy(output_line, ""); buf = output_line; for (i = 0; i < 10; i++) { if (fields[i]) { if (ascii && comma) { *(buf++) = ','; } else { comma = 1; } buf += (*field_data[i].f)(buf, gameiter, sub); } } printf("%s", output_line); printf("\n"); sub = sub->next; } cw_gameiter_next(gameiter); } cw_gameiter_cleanup(gameiter); free(gameiter); }
/* Compute the eventual "fate" of the runner on 'base' */ int cw_gameiter_runner_fate(CWGameIterator *orig_gameiter, int base) { CWGameIterator *gameiter; if (orig_gameiter->event_data->advance[base] == 0 || orig_gameiter->event_data->advance[base] >= 4) { return orig_gameiter->event_data->advance[base]; } base = orig_gameiter->event_data->advance[base]; gameiter = cw_gameiter_copy(orig_gameiter); while (gameiter->event != NULL && gameiter->state->inning == orig_gameiter->state->inning && gameiter->state->batting_team == orig_gameiter->state->batting_team && base >= 1 && base <= 3) { cw_gameiter_next(gameiter); if (gameiter->event && strcmp(gameiter->event->event_text, "NP")) { base = gameiter->event_data->advance[base]; } } cw_gameiter_cleanup(gameiter); free(gameiter); return base; }