diff --git a/src/cwtools/cwbox.c b/src/cwtools/cwbox.c index b9719a0..dc64130 100644 --- a/src/cwtools/cwbox.c +++ b/src/cwtools/cwbox.c @@ -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) { @@ -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; diff --git a/src/cwtools/cwcomment.c b/src/cwtools/cwcomment.c index 256c00a..df16cc7 100644 --- a/src/cwtools/cwcomment.c +++ b/src/cwtools/cwcomment.c @@ -28,6 +28,7 @@ #include "cwlib/chadwick.h" + /************************************************************************* * Global variables for command-line options *************************************************************************/ @@ -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; @@ -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; */ diff --git a/src/cwtools/cwdaily.c b/src/cwtools/cwdaily.c index e5dceaf..4c56adc 100644 --- a/src/cwtools/cwdaily.c +++ b/src/cwtools/cwdaily.c @@ -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; @@ -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; */ diff --git a/src/cwtools/cwevent.c b/src/cwtools/cwevent.c index 25534f2..1310ee4 100644 --- a/src/cwtools/cwevent.c +++ b/src/cwtools/cwevent.c @@ -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; @@ -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; */ diff --git a/src/cwtools/cwgame.c b/src/cwtools/cwgame.c index 4a5294d..5e31562 100644 --- a/src/cwtools/cwgame.c +++ b/src/cwtools/cwgame.c @@ -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; @@ -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; */ diff --git a/src/cwtools/cwsub.c b/src/cwtools/cwsub.c index 34d3412..e3bf9ee 100644 --- a/src/cwtools/cwsub.c +++ b/src/cwtools/cwsub.c @@ -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; @@ -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; */ diff --git a/src/cwtools/cwtools.c b/src/cwtools/cwtools.c index 70b08e8..28f1dc9 100644 --- a/src/cwtools/cwtools.c +++ b/src/cwtools/cwtools.c @@ -81,6 +81,12 @@ 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) { @@ -88,22 +94,39 @@ cwtools_read_rosters(CWLeague *league) 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); @@ -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; @@ -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); @@ -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]); }