Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/cwtools/cwbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,12 @@ char program_name[] = "cwbox";
extern char year[], first_date[], last_date[], game_id[];
extern int ascii;
extern int quiet;
extern int sd_flag;
extern char path_to_teamfile[];

XMLDoc *doc = NULL;


void
cwbox_print_field_list(void)
{
Expand Down Expand Up @@ -128,6 +131,12 @@ cwbox_parse_command_line(int argc, char *argv[])
strncpy(year, argv[i], 5);
}
}
else if (!strcmp(argv[i], "-sd")) {
sd_flag = 1;
if (++i < argc) {
strcpy(path_to_teamfile, argv[i]);
}
}
/* This part is cwbox-specific */
else if (!strcmp(argv[i], "-X")) {
use_xml = 1;
Expand Down
7 changes: 4 additions & 3 deletions src/cwtools/cwcomment.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

#include "cwlib/chadwick.h"


/*************************************************************************
* Global variables for command-line options
*************************************************************************/
Expand Down Expand Up @@ -388,7 +389,7 @@ extern int quiet;
extern void
cwtools_parse_field_list(char *text, int max_field, int *fields);

int
/* int
cwcomment_parse_command_line(int argc, char *argv[])
{
int i;
Expand Down Expand Up @@ -450,6 +451,6 @@ cwcomment_parse_command_line(int argc, char *argv[])
}

return i;
}
}

int (*cwtools_parse_command_line)(int, char *argv[]) = cwcomment_parse_command_line;
int (*cwtools_parse_command_line)(int, char *argv[]) = cwtools_default_parse_command_line; */
4 changes: 2 additions & 2 deletions src/cwtools/cwdaily.c
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,7 @@ extern int quiet;
extern void
cwtools_parse_field_list(char *text, int max_field, int *fields);

int
/* int
cwdaily_parse_command_line(int argc, char *argv[])
{
int i;
Expand Down Expand Up @@ -907,4 +907,4 @@ cwdaily_parse_command_line(int argc, char *argv[])
return i;
}

int (*cwtools_parse_command_line)(int, char *argv[]) = cwdaily_parse_command_line;
int (*cwtools_parse_command_line)(int, char *argv[]) = cwdaily_parse_command_line; */
4 changes: 2 additions & 2 deletions src/cwtools/cwevent.c
Original file line number Diff line number Diff line change
Expand Up @@ -1951,7 +1951,7 @@ extern int quiet;
extern void
cwtools_parse_field_list(char *text, int max_field, int *fields);

int
/* int
cwevent_parse_command_line(int argc, char *argv[])
{
int i;
Expand Down Expand Up @@ -2020,4 +2020,4 @@ cwevent_parse_command_line(int argc, char *argv[])
return i;
}

int (*cwtools_parse_command_line)(int, char *argv[]) = cwevent_parse_command_line;
int (*cwtools_parse_command_line)(int, char *argv[]) = cwevent_parse_command_line; */
4 changes: 2 additions & 2 deletions src/cwtools/cwgame.c
Original file line number Diff line number Diff line change
Expand Up @@ -2351,7 +2351,7 @@ extern int quiet;
extern void
cwtools_parse_field_list(char *text, int max_field, int *fields);

int
/* int
cwgame_parse_command_line(int argc, char *argv[])
{
int i;
Expand Down Expand Up @@ -2420,4 +2420,4 @@ cwgame_parse_command_line(int argc, char *argv[])
return i;
}

int (*cwtools_parse_command_line)(int, char *argv[]) = cwgame_parse_command_line;
int (*cwtools_parse_command_line)(int, char *argv[]) = cwgame_parse_command_line; */
4 changes: 2 additions & 2 deletions src/cwtools/cwsub.c
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ extern int quiet;
extern void
cwtools_parse_field_list(char *text, int max_field, int *fields);

int
/* int
cwsub_parse_command_line(int argc, char *argv[])
{
int i;
Expand Down Expand Up @@ -499,4 +499,4 @@ cwsub_parse_command_line(int argc, char *argv[])
return i;
}

int (*cwtools_parse_command_line)(int, char *argv[]) = cwsub_parse_command_line;
int (*cwtools_parse_command_line)(int, char *argv[]) = cwsub_parse_command_line; */
49 changes: 39 additions & 10 deletions src/cwtools/cwtools.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,29 +81,52 @@ int ascii = 1;
/* If 'quiet', programs should write no status messages to stderr */
int quiet = 0;

/* Path to teamfile outside of current directory */
char path_to_teamfile[256] = "";

/* Search directory flag set -sd */
int sd_flag = 0;

void
cwtools_read_rosters(CWLeague *league)
{
char filename[256];
FILE *teamfile;
CWRoster *roster;

sprintf(filename, "TEAM%s", year);
if (sd_flag) {

teamfile = fopen(filename, "r");
sprintf(filename, path_to_teamfile, "TEAM%s", year);

if (teamfile == NULL) {
/* Also try lowercase version */
sprintf(filename, "team%s", year);
teamfile = fopen(filename, "r");

if (teamfile == NULL) {
/* Also try lowercase version */
sprintf(filename, path_to_teamfile, "team%s", year);

teamfile = fopen(filename, "r");
}
}

else if (!sd_flag) {

sprintf(filename, "TEAM%s", year);

teamfile = fopen(filename, "r");

if (teamfile == NULL) {
fprintf(stderr, "Can't find teamfile (%s)\n", filename);
exit(1);
/* Also try lowercase version */
sprintf(filename, "team%s", year);

teamfile = fopen(filename, "r");
}
}

if (teamfile == NULL) {
fprintf(stderr, "Can't find teamfile (%s)\n", filename);
exit(1);
}

cw_league_read(league, teamfile);
fclose(teamfile);

Expand Down Expand Up @@ -277,7 +300,7 @@ cwtools_parse_field_list(char *text, int maxfield, int *field)
}
}

int
extern int
cwtools_default_parse_command_line(int argc, char *argv[])
{
int i;
Expand Down Expand Up @@ -326,6 +349,12 @@ cwtools_default_parse_command_line(int argc, char *argv[])
strncpy(year, argv[i], 5);
}
}
else if (!strcmp(argv[i], "-sd")) {
sd_flag = 1;
if (++i < argc) {
strcpy(path_to_teamfile, argv[i]);
}
}
else if (argv[i][0] == '-') {
fprintf(stderr, "*** Invalid option '%s'.\n", argv[i]);
exit(1);
Expand All @@ -343,7 +372,7 @@ int main(int argc, char *argv[])
int i;
CWLeague *league = cw_league_create();

i = cwtools_parse_command_line(argc, argv);
i = cwtools_default_parse_command_line(argc, argv);
if (!quiet) {
(*cwtools_print_welcome_message)(argv[0]);
}
Expand Down