int main(int argc,char **argv) { int m; int n; int p; int curr_arg; bool bDebug; bool bReverse; bool bCount; bool bExactCount; bool bReupped; bool bConsecutive; bool bShowZero; bool bOneAndDone; bool bStud; bool bMaxFeltDistance; bool bStartingStack; int starting_stack; int hit_felt_count; int reupped_count; int consecutive_hit_felt_count; int exact_count; int player_name_ix; int player_name_len; FILE *fptr0; int filename_len; FILE *fptr; int line_len; int line_no; int retval; int dbg_line_no; int ix; int street; int num_street_markers; int max_streets; int starting_balance; int ante; int bring_in; int spent_this_street; int spent_this_hand; int end_ix; int uncalled_bet_amount; int collected_from_pot; int collected_from_pot_count; int ending_balance; int file_no; int dbg_file_no; int dbg; int work; double dwork1; double dwork2; bool bSkipping; int hand_number; int last_felted_hand_number; int felt_distance; int max_felt_distance; char *date_string; if ((argc < 3) || (argc > 14)) { printf(usage); return 1; } bDebug = false; bReverse = false; bCount = false; bExactCount = false; bReupped = false; bConsecutive = false; bShowZero = false; bOneAndDone = false; bStud = false; bMaxFeltDistance = false; bStartingStack = false; for (curr_arg = 1; curr_arg < argc; curr_arg++) { if (!strcmp(argv[curr_arg],"-debug")) bDebug = true; else if (!strcmp(argv[curr_arg],"-reverse")) bReverse = true; else if (!strcmp(argv[curr_arg],"-count")) bCount = true; else if (!strncmp(argv[curr_arg],"-exact_count",12)) { bExactCount = true; sscanf(&argv[curr_arg][12],"%d",&exact_count); } else if (!strcmp(argv[curr_arg],"-reupped")) bReupped = true; else if (!strcmp(argv[curr_arg],"-consecutive")) bConsecutive = true; else if (!strcmp(argv[curr_arg],"-show_zero")) { bShowZero = true; bCount = true; } else if (!strcmp(argv[curr_arg],"-one_and_done")) bOneAndDone = true; else if (!strcmp(argv[curr_arg],"-stud")) bStud = true; else if (!strcmp(argv[curr_arg],"-max_felt_distance")) bMaxFeltDistance = true; else if (!strcmp(argv[curr_arg],"-starting_stack")) bStartingStack = true; else break; } if (argc - curr_arg != 2) { printf(usage); return 2; } if (bExactCount && bOneAndDone) { printf("can't specify both -exact_countn and -one_and_done\n"); return 3; } if (bCount && bStartingStack) { printf("can't specify both -count and -starting_stack\n"); return 4; } if (bExactCount && !exact_count) bShowZero = true; player_name_ix = curr_arg++; player_name_len = strlen(argv[player_name_ix]); if ((fptr0 = fopen(argv[curr_arg],"r")) == NULL) { printf(couldnt_open,argv[curr_arg]); return 5; } if (!bStud) max_streets = 3; else max_streets = 4; file_no = 0; dbg_file_no = -1; if (bConsecutive) consecutive_hit_felt_count = 0; for ( ; ; ) { GetLine(fptr0,filename,&filename_len,MAX_FILENAME_LEN); if (feof(fptr0)) break; file_no++; if (dbg_file_no == file_no) dbg = 1; if ((fptr = fopen(filename,"r")) == NULL) { printf(couldnt_open,filename); continue; } retval = get_date_from_path(filename,'\\',3,&date_string); if (retval) { printf("get_date_from_path() on %s failed: %d\n",filename,retval); continue; } strcpy(prev_filename,date_string); line_no = 0; hit_felt_count = 0; ending_balance = -1; reupped_count = 0; hand_number = 0; if (bMaxFeltDistance) { last_felted_hand_number = 0; max_felt_distance = 0; } for ( ; ; ) { GetLine(fptr,line,&line_len,MAX_LINE_LEN); if (feof(fptr)) break; line_no++; if (line_no == dbg_line_no) dbg = 1; if (bDebug) printf("line %d %s\n",line_no,line); if (Contains(true, line,line_len, argv[player_name_ix],player_name_len, &ix)) { if (Contains(true, line,line_len, in_chips,IN_CHIPS_LEN, &ix)) { hand_number++; bSkipping = false; if (ending_balance == 0) reupped_count++; street = 0; num_street_markers = 0; spent_this_street = 0; spent_this_hand = 0; uncalled_bet_amount = 0; collected_from_pot = 0; collected_from_pot_count = 0; line[ix] = 0; for (ix--; (ix >= 0) && (line[ix] != '('); ix--) ; sscanf(&line[ix+1],"%d",&starting_balance); if (bDebug) printf("line %d starting_balance = %d\n",line_no,starting_balance); if (bStartingStack && (hand_number == 1)) starting_stack = starting_balance; continue; } else if (bSkipping) continue; else if (Contains(true, line,line_len, posts_the_ante,POSTS_THE_ANTE_LEN, &ix)) { ante = get_work_amount(line,line_len); spent_this_hand = ante; continue; } else if (Contains(true, line,line_len, posts,POSTS_LEN, &ix)) { work = get_work_amount(line,line_len); spent_this_street += work; if (bDebug) { printf("line %d street %d POSTS work = %d, spent_this_street = %d\n", line_no,street,work,spent_this_street); } continue; } else if (Contains(true, line,line_len, collected,COLLECTED_LEN, &ix)) { for (end_ix = ix + COLLECTED_LEN; end_ix < line_len; end_ix++) { if (line[end_ix] == ' ') break; } line[end_ix] = 0; sscanf(&line[ix + COLLECTED_LEN],"%d",&work); if (!collected_from_pot_count) { spent_this_hand += spent_this_street; street++; spent_this_street = 0; } collected_from_pot += work; collected_from_pot_count++; if (bDebug) { printf("line %d street %d COLLECTED work = %d, collected_from_pot = %d\n", line_no,street,work,collected_from_pot); } continue; } else if (!strncmp(line,uncalled_bet,UNCALLED_BET_LEN)) { sscanf(&line[UNCALLED_BET_LEN],"%d",&uncalled_bet_amount); spent_this_street -= uncalled_bet_amount; if (bDebug) { printf("line %d street %d UNCALLED uncalled_bet_amount = %d, spent_this_street = %d\n", line_no,street,uncalled_bet_amount,spent_this_street); } continue; } else if (Contains(true, line,line_len, folds,FOLDS_LEN, &ix)) { spent_this_hand += spent_this_street; if (bDebug) { printf("line %d street %d FOLDS spent_this_street = %d, spent_this_hand = %d\n", line_no,street,spent_this_street,spent_this_hand); } bSkipping = true; ending_balance = starting_balance - spent_this_hand + collected_from_pot; continue; } else if (Contains(true, line,line_len, bets,BETS_LEN, &ix)) { work = get_work_amount(line,line_len); spent_this_street += work; if (bDebug) { printf("line %d street %d BETS work = %d, spent_this_street = %d\n", line_no,street,work,spent_this_street); } } else if (Contains(true, line,line_len, calls,CALLS_LEN, &ix)) { work = get_work_amount(line,line_len); spent_this_street += work; if (bDebug) { printf("line %d street %d CALLS work = %d, spent_this_street = %d\n", line_no,street,work,spent_this_street); } } else if (Contains(true, line,line_len, raises,RAISES_LEN, &ix)) { work = get_work_amount(line,line_len); spent_this_street = work; if (bDebug) { printf("line %d street %d RAISES work = %d, spent_this_street = %d\n", line_no,street,work,spent_this_street); } } else if (bStud && Contains(true, line,line_len, brings_in_for,BRINGS_IN_FOR_LEN, &ix)) { bring_in = get_work_amount(line,line_len); spent_this_street += bring_in; continue; } } else if (bSkipping) continue; else { if (!strncmp(line,summary,SUMMARY_LEN)) { if (bDebug) printf("line %d SUMMARY line detected; skipping\n",line_no); bSkipping = true; ending_balance = starting_balance - spent_this_hand + collected_from_pot; if (!ending_balance) { hit_felt_count++; if (bMaxFeltDistance) { felt_distance = hand_number - last_felted_hand_number; if (felt_distance > max_felt_distance) max_felt_distance = felt_distance; last_felted_hand_number = hand_number; } } continue; } if (!strncmp(line,street_marker,STREET_MARKER_LEN)) { num_street_markers++; if (num_street_markers > 1) { if (street <= num_street_markers) spent_this_hand += spent_this_street; street++; spent_this_street = 0; } } } } if (bOneAndDone) { if ((hit_felt_count == 1) && (ending_balance == 0)) printf("%s\n",filename); } else if (!bReverse) { if (bReupped && (reupped_count == 0)) ; else if (bConsecutive) { consecutive_hit_felt_count += hit_felt_count; if (ending_balance && (consecutive_hit_felt_count > 0)) { printf(fmt,consecutive_hit_felt_count,date_string); consecutive_hit_felt_count = 0; } } else if ((bShowZero || hit_felt_count) && (!bExactCount || (hit_felt_count == exact_count))) { if (bCount) printf(fmt,hit_felt_count,date_string); else if (bStartingStack) printf(fmt,starting_stack,date_string); else { if (!bMaxFeltDistance) printf("%s\n",filename); else printf(fmt,max_felt_distance,date_string); } } } else { if (!hit_felt_count) printf("%s\n",filename); } fclose(fptr); } if (bConsecutive && (consecutive_hit_felt_count > 0)) printf(fmt,consecutive_hit_felt_count,prev_filename); fclose(fptr0); return 0; }
int main(int argc,char **argv) { int m; int n; int p; int curr_arg; bool bDebug; bool bVerbose; bool bTerse; bool bAbbrev; bool bNoBetsOrRaises; bool bGetDateFromPath; int action; int zero; int folded; int player_name_ix; int player_name_len; FILE *fptr0; int filename_len; FILE *fptr; int line_len; int line_no; int retval; char *date_string; int ix; int file_no; int dbg_file_no; int dbg; char hole_cards[6]; int tot_num_hands; int num_hands; int tot_numdecs; int numdecs; int tot_numfolds; int numfolds; int tot_numchecks; int numchecks; int tot_numcalls; int numcalls; int tot_numbets; int numbets; int tot_numraises; int numraises; int tot_action_numdecs; int action_numdecs; int tot_zero_numdecs; int zero_numdecs; double dwork; if ((argc < 3) || (argc > 12)) { printf(usage); return 1; } bDebug = false; bVerbose = false; bTerse = false; bAbbrev = false; bNoBetsOrRaises = false; bGetDateFromPath = false; action = 0; zero = 0; folded = 0; for (curr_arg = 1; curr_arg < argc; curr_arg++) { if (!strcmp(argv[curr_arg],"-debug")) bDebug = true; else if (!strcmp(argv[curr_arg],"-verbose")) bVerbose = true; else if (!strcmp(argv[curr_arg],"-terse")) bTerse = true; else if (!strcmp(argv[curr_arg],"-abbrev")) bAbbrev = true; else if (!strcmp(argv[curr_arg],"-no_bets_or_raises")) bNoBetsOrRaises = true; else if (!strcmp(argv[curr_arg],"-get_date_from_path")) bGetDateFromPath = true; else if (!strcmp(argv[curr_arg],"-action")) action = 1; else if (!strcmp(argv[curr_arg],"-zero")) zero = 1; else if (!strcmp(argv[curr_arg],"-folded")) folded = 1; else break; } if (argc - curr_arg != 2) { printf(usage); return 2; } if (action + zero + folded > 1) { printf("can only specify one of -action, -zero, and -folded\n"); return 3; } if (bVerbose && bTerse) { printf("can't specify both -verbose and -terse\n"); return 4; } getcwd(save_dir,_MAX_PATH); if (bGetDateFromPath) { retval = get_date_from_path(save_dir,'/',3,&date_string); if (retval) { printf("get_date_from_path() failed: %d\n",retval); return 5; } } else date_string = save_dir; player_name_ix = curr_arg++; player_name_len = strlen(argv[player_name_ix]); if ((fptr0 = fopen(argv[curr_arg],"r")) == NULL) { printf(couldnt_open,argv[curr_arg]); return 6; } file_no = 0; dbg_file_no = -1; hole_cards[5] = 0; tot_num_hands = 0; tot_numdecs = 0; tot_numfolds = 0; tot_numchecks = 0; tot_numcalls = 0; tot_numbets = 0; tot_numraises = 0; if (action) tot_action_numdecs = 0; else if (zero) tot_zero_numdecs = 0; for ( ; ; ) { GetLine(fptr0,filename,&filename_len,MAX_FILENAME_LEN); if (feof(fptr0)) break; file_no++; if (dbg_file_no == file_no) dbg = 1; if ((fptr = fopen(filename,"r")) == NULL) { printf(couldnt_open,filename); continue; } line_no = 0; num_hands = 0; numdecs = 0; numfolds = 0; numchecks = 0; numcalls = 0; numbets = 0; numraises = 0; if (action) action_numdecs = 0; else if (zero) zero_numdecs = 0; for ( ; ; ) { GetLine(fptr,line,&line_len,MAX_LINE_LEN); if (feof(fptr)) break; line_no++; if (Contains(true, line,line_len, argv[player_name_ix],player_name_len, &ix)) { if (!strncmp(line,dealt_to,DEALT_TO_LEN)) { for (n = 0; n < line_len; n++) { if (line[n] == '[') break; } if (n < line_len) { n++; for (m = n; m < line_len; m++) { if (line[m] == ']') break; } if (m < line_len) { for (p = 0; p < 5; p++) hole_cards[p] = line[n+p]; } } } else if (Contains(true, line,line_len, folds,FOLDS_LEN, &ix)) { numfolds++; numdecs++; if (zero) zero_numdecs++; } else if (Contains(true, line,line_len, bets,BETS_LEN, &ix)) { numbets++; numdecs++; if (action) action_numdecs++; } else if (Contains(true, line,line_len, calls,CALLS_LEN, &ix)) { numcalls++; numdecs++; if (action) action_numdecs++; } else if (Contains(true, line,line_len, raises,RAISES_LEN, &ix)) { numraises++; numdecs++; if (action) action_numdecs++; } else if (Contains(true, line,line_len, checks,CHECKS_LEN, &ix)) { numchecks++; numdecs++; if (zero) zero_numdecs++; } } else { if (!strncmp(line,summary,SUMMARY_LEN)) num_hands++; } } fclose(fptr); if (!bNoBetsOrRaises || (numbets + numraises == 0)) { if (bVerbose) { dwork = (double)numdecs / (double)num_hands; if (bAbbrev) { printf("%6d %6d %5.2lf fld %4d chk %4d call %4d bet %4d rse %4d %s\n", numdecs,num_hands,dwork, numfolds,numchecks,numcalls,numbets,numraises, filename); } else { printf("%6d %6d %5.2lf fold %4d check %4d call %4d bet %4d raise %4d %s\n", numdecs,num_hands,dwork, numfolds,numchecks,numcalls,numbets,numraises, filename); } } tot_num_hands += num_hands; tot_numdecs += numdecs; tot_numfolds += numfolds; tot_numchecks += numchecks; tot_numcalls += numcalls; tot_numbets += numbets; tot_numraises += numraises; if (action) tot_action_numdecs += action_numdecs; else if (zero) tot_zero_numdecs += zero_numdecs; } } fclose(fptr0); if (bVerbose) putchar(0x0a); if (action) { dwork = (double)tot_action_numdecs / (double)tot_numdecs; if (!bDebug) printf(fmt1,tot_action_numdecs,tot_numdecs,dwork); else printf(fmt2,tot_action_numdecs,tot_numdecs,dwork,date_string); } else if (zero) { dwork = (double)tot_zero_numdecs / (double)tot_numdecs; if (!bDebug) printf(fmt1,tot_zero_numdecs,tot_numdecs,dwork); else printf(fmt2,tot_zero_numdecs,tot_numdecs,dwork,date_string); } else if (folded) { dwork = (double)tot_numfolds / (double)tot_numdecs; if (!bDebug) printf(fmt1,tot_numfolds,tot_numdecs,dwork); else printf(fmt2,tot_numfolds,tot_numdecs,dwork,date_string); } else { dwork = (double)tot_numdecs / (double)tot_num_hands; if (!bVerbose) { if (bTerse) { if (bAbbrev) { printf("%6d %6d %5.2lf fld %4d chk %4d call %4d bet %4d rse %4d\n", tot_numdecs,tot_num_hands,dwork, tot_numfolds,tot_numchecks,tot_numcalls,tot_numbets,tot_numraises); } else { printf("%6d %6d %5.2lf fold %4d check %4d call %4d bet %4d raise %4d\n", tot_numdecs,tot_num_hands,dwork, tot_numfolds,tot_numchecks,tot_numcalls,tot_numbets,tot_numraises); } } else if (!bDebug) printf(fmt1,tot_numdecs,tot_num_hands,dwork); else printf(fmt2,tot_numdecs,tot_num_hands,dwork,date_string); } else { if (bAbbrev) { printf("%6d %6d %5.2lf fld %4d chk %4d call %4d bet %4d rse %4d\n", tot_numdecs,tot_num_hands,dwork, tot_numfolds,tot_numchecks,tot_numcalls,tot_numbets,tot_numraises); } else { printf("%6d %6d %5.2lf fold %4d check %4d call %4d bet %4d raise %4d\n", tot_numdecs,tot_num_hands,dwork, tot_numfolds,tot_numchecks,tot_numcalls,tot_numbets,tot_numraises); } } } return 0; }
int main(int argc,char **argv) { int curr_arg; bool bDebug; bool bVerbose; int player_name_ix; int player_name_len; FILE *fptr0; int filename_len; FILE *fptr; int line_len; int line_no; int retval; char *date_string; int ix; int street; int num_street_markers; int starting_balance; int spent_this_street; int spent_this_hand; int end_ix; int wagered_amount; int uncalled_bet_amount; int collected_from_pot; int collected_from_pot_count; int ending_balance; int delta; int file_no; int dbg_file_no; int dbg; int work; int total_wagered; if ((argc < 3) || (argc > 5)) { printf(usage); return 1; } bDebug = false; bVerbose = false; for (curr_arg = 1; curr_arg < argc; curr_arg++) { if (!strcmp(argv[curr_arg],"-debug")) bDebug = true; else if (!strcmp(argv[curr_arg],"-verbose")) bVerbose = true; else break; } if (argc - curr_arg != 2) { printf(usage); return 2; } player_name_ix = curr_arg++; player_name_len = strlen(argv[player_name_ix]); if ((fptr0 = fopen(argv[curr_arg],"r")) == NULL) { printf(couldnt_open,argv[curr_arg]); return 3; } if (!bVerbose && bDebug) { getcwd(save_dir,_MAX_PATH); retval = get_date_from_path(save_dir,'/',2,&date_string); if (retval) { printf("get_date_from_path() on %s failed: %d\n",save_dir,retval); return 4; } } ending_balance = -1; file_no = 0; dbg_file_no = -1; if (!bVerbose) total_wagered = 0; for ( ; ; ) { GetLine(fptr0,filename,&filename_len,MAX_FILENAME_LEN); if (feof(fptr0)) break; file_no++; if (dbg_file_no == file_no) dbg = 1; if ((fptr = fopen(filename,"r")) == NULL) { printf(couldnt_open,filename); continue; } line_no = 0; street = 0; num_street_markers = 0; spent_this_street = 0; spent_this_hand = 0; uncalled_bet_amount = 0; collected_from_pot = 0; collected_from_pot_count = 0; for ( ; ; ) { GetLine(fptr,line,&line_len,MAX_LINE_LEN); if (feof(fptr)) break; line_no++; if (Contains(true, line,line_len, argv[player_name_ix],player_name_len, &ix)) { if (Contains(true, line,line_len, in_chips,IN_CHIPS_LEN, &ix)) { line[ix] = 0; for (ix--; (ix >= 0) && (line[ix] != '('); ix--) ; sscanf(&line[ix+1],"%d",&starting_balance); continue; } else if (Contains(true, line,line_len, posts,POSTS_LEN, &ix)) { spent_this_street += get_work_amount(line,line_len); continue; } else if (!strncmp(line,dealt_to,DEALT_TO_LEN)) continue; else if (Contains(true, line,line_len, collected,COLLECTED_LEN, &ix)) { for (end_ix = ix + COLLECTED_LEN; end_ix < line_len; end_ix++) { if (line[end_ix] == ' ') break; } line[end_ix] = 0; sscanf(&line[ix + COLLECTED_LEN],"%d",&work); if (!collected_from_pot_count) { spent_this_hand += spent_this_street; street++; spent_this_street = 0; } collected_from_pot += work; collected_from_pot_count++; continue; } else if (!strncmp(line,uncalled_bet,UNCALLED_BET_LEN)) { sscanf(&line[UNCALLED_BET_LEN],"%d",&uncalled_bet_amount); spent_this_street -= uncalled_bet_amount; continue; } else if (Contains(true, line,line_len, folds,FOLDS_LEN, &ix)) { spent_this_hand += spent_this_street; break; } else if (Contains(true, line,line_len, bets,BETS_LEN, &ix)) { spent_this_street += get_work_amount(line,line_len); } else if (Contains(true, line,line_len, calls,CALLS_LEN, &ix)) { spent_this_street += get_work_amount(line,line_len); } else if (Contains(true, line,line_len, raises,RAISES_LEN, &ix)) { spent_this_street = get_work_amount(line,line_len); } } else { if (!strcmp(line,summary)) break; if (!strncmp(line,street_marker,STREET_MARKER_LEN)) { num_street_markers++; if (num_street_markers > 1) { if (street <= 3) spent_this_hand += spent_this_street; street++; spent_this_street = 0; } } } } fclose(fptr); ending_balance = starting_balance - spent_this_hand + collected_from_pot; delta = ending_balance - starting_balance; wagered_amount = spent_this_hand + uncalled_bet_amount; if (!bVerbose) total_wagered += wagered_amount; else { if (!bDebug) printf("%d\n",wagered_amount); else printf("%10d %s\n",wagered_amount,filename); } } fclose(fptr0); if (!bVerbose) { if (!bDebug) printf("%d\n",total_wagered); else printf("%10d %s\n",total_wagered,date_string); } return 0; }
int main(int argc,char **argv) { int curr_arg; bool bStandalone; char letter; int n; FILE *fptr; int filename_len; int line_len; int retval; char *date_string; int initial_stake; int buy_in; int entry_fee; int num_players; int num_hands; int place; int winnings; if ((argc < ARG_NUM_ARGS + 1) || (argc > ARG_NUM_ARGS + 2)) { printf(usage); return 1; } bStandalone = false; for (curr_arg = 1; curr_arg < argc; curr_arg++) { if (!strcmp(argv[curr_arg],"-standalone")) bStandalone = true; else break; } if (argc - curr_arg != ARG_NUM_ARGS) { printf(usage); return 2; } getcwd(save_dir,_MAX_PATH); retval = get_date_from_path(save_dir,'/',2,&date_string); if (retval) { printf("get_date_from_path() failed: %d\n",retval); return 3; } if (bStandalone) printf("use poker\n\n"); letter = 'a'; for (n = 0; n < MAX_SIT_AND_GOS; n++) { sprintf(outer_filename,"%c/sng_hands.lst",letter); if ((fptr = fopen(outer_filename,"r")) == NULL) break; GetLine(fptr,line,&line_len,MAX_FILENAME_LEN); if (feof(fptr)) { printf(unexpected_eof,outer_filename); return 4; } fclose(fptr); sprintf(filename,"%c/%s",letter,line); if ((fptr = fopen(filename,"r")) == NULL) { printf(couldnt_open,filename); return 5; } retval = get_initial_stake( argv[curr_arg + ARG_PLAYER_NAME],strlen(argv[curr_arg + ARG_PLAYER_NAME]), fptr,&initial_stake); if (retval) { printf("get_initial_stake() failed: %d\n",retval); return 6; } fclose(fptr); sprintf(outer_filename,"%c/sng_hands.ls0",letter); if ((fptr = fopen(outer_filename,"r")) == NULL) break; GetLine(fptr,line,&line_len,MAX_FILENAME_LEN); if (feof(fptr)) { printf(unexpected_eof,outer_filename); return 7; } fclose(fptr); retval = get_num_hands(line,line_len,&num_hands); if (retval) { printf("get_num_hands failed: %d\n",retval); return 8; } sprintf(filename,"%c/%s",letter,line); if ((fptr = fopen(filename,"r")) == NULL) { printf(couldnt_open,filename); return 9; } GetLine(fptr,line,&line_len,MAX_LINE_LEN); if (feof(fptr)) { printf(unexpected_eof,filename); return 10; } retval = get_buy_in_and_entry_fee(line,line_len,&buy_in,&entry_fee); if (retval) { printf("get_buy_in_and_entry_fee() failed: %d\n",retval); return 11; } GetLine(fptr,line,&line_len,MAX_LINE_LEN); if (feof(fptr)) { printf(unexpected_eof,filename); return 12; } retval = get_num_players(line,line_len,&num_players); if (retval) { printf("get_num_players() failed: %d\n",retval); return 13; } retval = get_place_and_winnings( argv[curr_arg + ARG_PLAYER_NAME],strlen(argv[curr_arg + ARG_PLAYER_NAME]), fptr,&place,&winnings); fclose(fptr); printf("insert into poker_sessions (\n"); printf(" poker_style,tournament_letter,poker_session_date,buy_in,entry_fee,initial_stake," "big_blind_amount,num_players,poker_flavor,num_hands,place,winnings\n"); printf(")\n"); printf("values (%s,'%c','%s',%d,%d,%d,%s,%d,%s,%d,%d,%d);\n", argv[curr_arg + ARG_POKER_STYLE],letter,date_string,buy_in,entry_fee, initial_stake,argv[curr_arg + ARG_BIG_BLIND_AMOUNT], num_players,argv[curr_arg + ARG_POKER_FLAVOR], num_hands,place,winnings); letter++; } if (bStandalone) printf("\nquit\n"); return 0; }
int main(int argc,char **argv) { int curr_arg; bool bDebug; bool bVerbose; bool bDateString; int retval; char *date_string; FILE *fptr; int linelen; int line_no; int tot1; int tot2; int work1; int work2; double dwork; if (argc < 2) { printf(usage); return 1; } bDebug = false; bVerbose = false; bDateString = false; for (curr_arg = 1; curr_arg < argc; curr_arg++) { if (!strcmp(argv[curr_arg],"-debug")) bDebug = true; else if (!strcmp(argv[curr_arg],"-verbose")) bVerbose = true; else if (!strcmp(argv[curr_arg],"-date_string")) bDateString = true; else break; } if (argc - curr_arg < 1) { printf(usage); return 2; } if (bDateString) { getcwd(save_dir,_MAX_PATH); retval = get_date_from_path(save_dir,'/',2,&date_string); if (retval) { printf("get_date_from_path() failed: %d\n",retval); return 3; } } for ( ; curr_arg < argc; curr_arg++) { if ((fptr = fopen(argv[curr_arg],"r")) == NULL) { printf(couldnt_open,argv[curr_arg]); continue; } if (bVerbose) printf("%s\n",argv[curr_arg]); line_no = 0; tot1 = 0; tot2 = 0; for ( ; ; ) { GetLine(fptr,line,&linelen,MAX_LINE_LEN); if (feof(fptr)) break; line_no++; sscanf(line,"%d %d",&work1,&work2); tot1 += work1; tot2 += work2; if (bVerbose) { dwork = (double)tot1 / (double)tot2; if (!bDebug) printf(fmt1,dwork); else printf(fmt2,dwork,tot1,tot2); if (!bDateString) putchar(0x0a); else printf(fmt3,date_string); } } fclose(fptr); if (!bVerbose) { dwork = (double)tot1 / (double)tot2; if (!bDebug) printf(fmt1,dwork); else printf(fmt2,dwork,tot1,tot2); if (!bDateString) putchar(0x0a); else printf(fmt3,date_string); } } return 0; }
int main(int argc,char **argv) { int curr_arg; bool bDebug; bool bVerbose; bool bTerse; bool bDiff; bool bReverse; bool bOnlyNone; bool bOnlyAll; bool bOnlyWinning; bool bOnlyLosing; bool bExactCount; bool bLeCount; bool bGeCount; bool bLastOneCounts; bool bGetDateFromPath; bool bAvgLoss; int exact_count; int le_count; int ge_count; bool bCurrentOneCounts; int val; FILE *fptr; int line_len; int line_no; int retval; char *date_string; int count; int work; double pct; double avg_loss; if ((argc < 2) || (argc > 17)) { printf(usage); return 1; } bDebug = false; bVerbose = false; bTerse = false; bDiff = false; bReverse = false; bOnlyNone = false; bOnlyAll = false; bOnlyWinning = false; bOnlyLosing = false; bExactCount = false; bLeCount = false; bGeCount = false; bLastOneCounts = false; bGetDateFromPath = false; bAvgLoss = false; for (curr_arg = 1; curr_arg < argc; curr_arg++) { if (!strcmp(argv[curr_arg],"-debug")) bDebug = true; else if (!strcmp(argv[curr_arg],"-verbose")) bVerbose = true; else if (!strcmp(argv[curr_arg],"-terse")) bTerse = true; else if (!strncmp(argv[curr_arg],"-diff",5)) { bDiff = true; sscanf(&argv[curr_arg][5],"%d",&val); } else if (!strcmp(argv[curr_arg],"-reverse")) bReverse = true; else if (!strcmp(argv[curr_arg],"-only_none")) bOnlyNone = true; else if (!strcmp(argv[curr_arg],"-only_all")) bOnlyAll = true; else if (!strcmp(argv[curr_arg],"-only_winning")) bOnlyWinning = true; else if (!strcmp(argv[curr_arg],"-only_losing")) bOnlyLosing = true; else if (!strncmp(argv[curr_arg],"-exact_count",12)) { bExactCount = true; sscanf(&argv[curr_arg][12],"%d",&exact_count); } else if (!strncmp(argv[curr_arg],"-le_count",9)) { bLeCount = true; sscanf(&argv[curr_arg][9],"%d",&le_count); } else if (!strncmp(argv[curr_arg],"-ge_count",9)) { bGeCount = true; sscanf(&argv[curr_arg][9],"%d",&ge_count); } else if (!strcmp(argv[curr_arg],"-last_one_counts")) bLastOneCounts = true; else if (!strcmp(argv[curr_arg],"-get_date_from_path")) bGetDateFromPath = true; else if (!strcmp(argv[curr_arg],"-avg_loss")) bAvgLoss = true; else break; } if (argc - curr_arg != 1) { printf(usage); return 2; } if (bAvgLoss) bOnlyAll = true; if (bDebug || bGetDateFromPath) getcwd(save_dir,_MAX_PATH); if (bGetDateFromPath) { retval = get_date_from_path(save_dir,'/',2,&date_string); if (retval) { printf("get_date_from_path() on %s failed: %d\n",save_dir,retval); return 3; } } if ((fptr = fopen(argv[curr_arg],"r")) == NULL) { printf(couldnt_open,argv[curr_arg]); return 4; } if (bOnlyNone && bOnlyAll) { printf("can't specify both -only_none and -only_all\n"); return 5; } if (bOnlyWinning && bOnlyLosing) { printf("can't specify both -only_winning and -only_losing\n"); return 6; } if (bOnlyNone && bOnlyLosing) { printf("can't specify both -only_none and -only_losing\n"); return 7; } if (bOnlyAll && bOnlyWinning) { printf("can't specify both -only_all and -only_winning\n"); return 8; } if (bExactCount && bLeCount) { printf("can't specify both -exact_countn and -le_countn\n"); return 9; } if (bExactCount && bGeCount) { printf("can't specify both -exact_countn and -ge_countn\n"); return 10; } if (bLeCount && bGeCount && (le_count < ge_count)) { printf("le_count must be >= ge_count\n"); return 11; } line_no = 0; count = 0; for ( ; ; ) { GetLine(fptr,line,&line_len,MAX_LINE_LEN); if (feof(fptr)) break; line_no++; sscanf(line,"%d",&work); bCurrentOneCounts = false; if (!bReverse) { if (work < 0) { if (bVerbose) printf("%d (%d)\n",work,line_no); count++; bCurrentOneCounts = true; } } else { if (work > 0) { if (bVerbose) printf("%d (%d)\n",work,line_no); count++; bCurrentOneCounts = true; } } } fclose(fptr); pct = (double)count / (double)line_no; if (!bDiff || (line_no - count == val)) { if (!bOnlyNone || (count == 0)) { if (!bOnlyAll || (count == line_no)) { if (!bOnlyWinning || (work > 0)) { if (!bOnlyLosing || (work < 0)) { if (!bExactCount || (count == exact_count)) { if (!bLeCount || (count <= le_count)) { if (!bGeCount || (count >= ge_count)) { if (!bLastOneCounts || bCurrentOneCounts) { if (bAvgLoss) avg_loss = (double)work / (double)line_no; if (bTerse) { if (!bGetDateFromPath) printf(fmt_str1,save_dir); else printf(fmt_str1,date_string); } else if (!bDebug) printf("%lf %3d %3d\n",pct,count,line_no); else { if (!bGetDateFromPath) { if (!bAvgLoss) printf(fmt_str2,pct,count,line_no,save_dir); else printf(fmt_str3,avg_loss,work,line_no,save_dir); } else { if (!bAvgLoss) printf(fmt_str2,pct,count,line_no,date_string); else printf(fmt_str3,avg_loss,work,line_no,date_string); } } } } } } } } } } } return 0; }
int main(int argc,char **argv) { int curr_arg; bool bNot; bool bTerse; bool bNoOthers; bool bMetCriteria; FILE *fptr; int line_no; int line_len; int retval; char *date_string; int val; int first_hand_win_val; if ((argc < 2) || (argc > 5)) { printf(usage); return 1; } bNot = false; bTerse = false; bNoOthers = false; for (curr_arg = 1; curr_arg < argc; curr_arg++) { if (!strcmp(argv[curr_arg],"-not")) bNot = true; else if (!strcmp(argv[curr_arg],"-terse")) bTerse = true; else if (!strcmp(argv[curr_arg],"-no_others")) bNoOthers = true; else break; } if (argc - curr_arg != 1) { printf(usage); return 2; } if ((fptr = fopen(argv[curr_arg],"r")) == NULL) { printf(couldnt_open,argv[curr_arg]); return 3; } getcwd(save_dir,_MAX_PATH); retval = get_date_from_path(save_dir,'/',2,&date_string); if (retval) { printf("get_date_from_path() failed: %d\n",retval); return 4; } line_no = 0; bMetCriteria = false; for ( ; ; ) { GetLine(fptr,line,&line_len,MAX_LINE_LEN); if (feof(fptr)) break; line_no++; sscanf(line,"%d",&val); if (line_no == 1) { if ((!bNot && (val > 0)) || (bNot && (val < 0))) { first_hand_win_val = val; bMetCriteria = true; } } else { if ((!bNot && (val > 0)) || (bNot && (val < 0))) bMetCriteria = false; } if (!bNoOthers) break; } fclose(fptr); if (bMetCriteria) { if (!bTerse) printf("%10d %s\n",first_hand_win_val,date_string); else printf("%s\n",date_string); } return 0; }