From: dxj@cci632.cci.com (Dennis Joyce)
Subject: NBASTAT.C v2.03
Summary:  A New Version
Keywords: New version
Organization: Nothern Telecom/NAS, Rochester, NY
Date: Wed, 30 Sep 1992 20:44:37 GMT


After using the nbastat program for a little while I realized that it would
be nice to have a feature to bring up all the dates that say:
New York play Dallas     or    LA CLIPPERS  play the LA LAKERS

So I modified the original program so that you can do this...

/****************************************************************************
* Functionality has been expanded to allow for the displaying of            *
* a given NBA match up (eg Boston vs Utah)			   	    *
*									    *
*  Usage:								    *
*	nba -m boston utah	<- prints games with this matchup	    *
*									    *
*  Modified by Dennis P. Joyce (dpj4303@ritvax.rit.edu)			    *
*			       (dxj@sunsrvr3.cci.com)			    *
*  Modified on Sept. 30, 1992.						    *
*									    *
*****************************************************************************/

The program also includes the changes made by:
 Toshio Hori (toshi@nml.t.u-tokyo.ac.jp) 

So as far as I know this is the latest and greatest version of nbastat.c 

ENJOY.....

-----------------------------------------------------------------------------
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX CUT HERE XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
-----------------------------------------------------------------------------
/***************************************************************************
* This program prints out the NBA schedule for any day in the 1992-1993    *
* season. By default, the current day's schedule is printed.  One can also *
* specify one or more dates on the command line and get the schedule for   *
* that/those date(s).  Any national TV coverage (TNT and NBC) is also      *
* included.  The tip-off time for each game is also listed.  The time is   *
* set up in the matrix for the Eastern time zone.  To change the time to   *
* show either Central, Mountain, or Pacific time zone just change the      *
* "TZ_FIX" #define below before compiling (other time zones are not        *
* currently supported...sorry).                                            *
*                                                                          *
* A new feature this year is the ability to print a summary of a week's    *
* worth of games.  This feature is enabled if the first arguement is "-s". *
*                                                                          *
* To compile just use... "cc -o nba nba.c"                                 *
*                                                                          *
* Usage:                                                                   *
* nba     			<-- today's schedule                       *
* nba 12/25   			<-- Christmas day's schedule               *
* nba 11/6 4/25   		<-- schedule for the first and last        *
*           			    day of they seasson                    *
* nba -s      			<-- schedule in summary format for the     *
*           			    next week                              *
* nba -s 2/19   		<-- schedule in summary format for a week  *
*           			    starting at the All-Star Break         *
*                                                                          *
* Brought to you again this year by:                                       *
*       ___          __________   _____    ___                             *
*      /  /\        /  _______/\ /    |\  /  /\ || Len Carr                *
*     /  / /       /  /__ ____\//  /| | |/  / / || AT&T CellNet            *
*    /  / /       /  ___/\     /  / | | /  / /  || 200 Laurel Ave., 2D-213 *
*   /  / /       /  ____\/    /  / /| |/  / /   || Middletown, NJ 07748    *
*  /  /_/____   /  /______   /  / / | /  / /    || (908) 957-3571          *
* /_________/\ /_________/\ /__/ /  |__ / /     ||                         *
* \_________\/ \_________\/ \__\/    \__\/      || len@mt747.att.com       *
*                                                                          *
****************************************************************************/

/*
 * Functionality expanded to allow printing of entire NBA schedule
 * and the full schedules of individual teams.
 *
 * Usage:
 *	nba all			<-- print full NBA schedule
 *	nba Utah		<-- print Utah game scheduled for today
 *	nba Phoenix 11/20	<-- print Phoenix game scheduled for
 *				    11/20
 *	nba "LA Lakers" all	<-- print full Laker schedule (notice quotes)
 *	nba -help		<-- print help message.
 *
 *  Modified by Toshio Hori (toshi@nml.t.u-tokyo.ac.jp)
 *  Modified on Sep 26, 1992.
 */

/****************************************************************************
* Functionality has been expanded to allow for the displaying of            *
* a given NBA match up (eg Boston vs Utah)			   	    *
*									    *
*  Usage:								    *
*	nba -m boston utah	<- prints games with this matchup	    *
*									    *
*  Modified by Dennis P. Joyce (dpj4303@ritvax.rit.edu)			    *
*			       (dxj@sunsrvr3.cci.com)			    *
*  Modified on Sept. 30, 1992.						    *
*									    *
*****************************************************************************/
#include  <stdio.h>
#include  <string.h>
#include  <ctype.h>
#include  <time.h>

/*
 * All times in the schedule matrix are based on the Eastern time zone.
 * To change to one of the other three below, comment out the Eastern
 * entry and un-comment the desired one.
 */
#define TZ_FIX  0 /* Eastern */
/* #define TZ_FIX 2 /* Central */
/* #define TZ_FIX 4 /* Mountain */
/* #define TZ_FIX 6 /* Pacific */

char  *nba_teams[] = {
  "Atlanta",  "Boston", "Charlotte",  "Chicago",
  "Cleveland",  "Dallas", "Denver", "Detroit",
  "Golden State", "Houston",  "Indiana",  "LA Clippers",
  "LA Lakers",  "Miami",  "Milwaukee",  "Minnesota",
  "New Jersey", "New York", "Orlando",  "Philadelphia",
  "Phoenix",  "Portland", "Sacramento", "San Antonio",
  "Seattle",  "Utah",   "Washington",
  "All Star Break",   "All Star Game"
};

char  *nba_summary_teams[] = {
  "Atl",  "Bos",  "Cha",  "Chi",
  "Cle",  "Dal",  "Den",  "Det",
  "GS", "Hou",  "Ind",  "LAC",
  "LAL",  "Mia",  "Mil",  "Min",
  "NJ", "NY", "Orl",  "Phi",
  "Pho",  "Por",  "Sac",  "SA",
  "Sea",  "Uta",  "Was",
  "ASB",  "ASG"
};

char  *alternate_site[] = {
  "(in Baltimore)",
  "(in Hartford)",
  "(in Kingdome)",
  "(in Japan)",
  ""
};

char  *sum_alt_site[] = {
  "b = Game played in Baltimore",
  "h = Game played in Hartford",
  "k = Game played in Kingdome",
  "j = Game played in Japan",
  ""
};

char  *game_time[] = {
  "(9:00 am)",  "(9:30 am)",  "(10:00 am)", "(10:30 am)",
  "(11:00 am)", "(11:30 am)", "(12:00 Noon)", "(12:30 pm)",
  "(1:00 pm)",  "(1:30 pm)",  "(2:00 pm)",  "(2:30 pm)",
  "(3:00 pm)",  "(3:30 pm)",  "(4:00 pm)",  "(4:30 pm)",
  "(5:00 pm)",  "(5:30 pm)",  "(6:00 pm)",  "(6:30 pm)",
  "(7:00 pm)",  "(7:30 pm)",  "(8:00 pm)",  "(8:30 pm)",
  "(9:00 pm)",  "(9:30 pm)",  "(10:00 pm)", "(10:30 pm)", ""
};

char  *tv_coverage[] = {
  "(TNT)", "(TNT*)", "(NBC)", "(NBC*)", ""
};

char  *sum_tv_coverage[] = {
  "T = Game broadcast on TNT",
  "t = Game may be broadcast on TNT",
  "N = Game broadcast on NBC",
  "n = Game may be broadcast on NBC",
  ""
};

int days[] = {
     31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
  /* jan feb mar apr may jun jul aug sep oct nov dec */
};

char  *weekday[] = {
  "Friday",
  "Saturday",
  "Sunday",
  "Monday",
  "Tuesday",
  "Wednesday",
  "Thursday"
};

char  *summary_weekday[] = {
  "FR",
  "SA",
  "SU",
  "MO",
  "TU",
  "WE",
  "TH"
};

int playing = -1; /* Not looking or certain matchup */
int summary_form = 0; /* Print out schedule in summary format? */
        /*  0 = No...use long format,  */
        /*  1 = Yes...use summary format   */

/********************************************************************
* Schedule matrix...each character string represents one day in the *
* life of the NBA for the 1992-1993 season.  There are 27 different *
* teams in the NBA represented by the characters "a-z", "{", "|",   *
* and "} and correspond to the "nba_teams" array above.             *
*                                                                   *
* In general the matrix can be viewed as visitor/home/time triplet  *
* where the first entry is the visiting team, the second is the     *
* home team, and the third is the tip-off time.  This 3 character   *
* set is modified slightly in order to store any TV coverage and    *
* "alternate home site" information.                                *
*                                                                   *
* If there is a digit between the visitor and the home team then we *
* look in the "alternate_site" array for the actual location that   *
* the game is being played.                                         *
*                                                                   *
* If there is a digit after the tip-off time then the "tv_coverage" *
* array is checked to see whether NBC or TNT are broadcasting the   *
* game.                                                             *
********************************************************************/
char  *nba_schedule[] = {
  /* 11/6  (001) */ "raTpbT{cUdeU0ohUy3jZ0mlZnsTqtTxwZizW",
  /* 11/7  (002) */ "adVzfVxgWhkTqnTboWipUtrTluXj3yYs{T",
  /* 11/8  (003) */ "ceTwmZgvY",
  /* 11/9  (004) */ "kdV",
  /* 11/10 (005) */ "{eTzgWmiZbnTfpUqrTcsU0uvZlwZoxV",
  /* 11/11 (006) */ "bcThdVofVajVtkTwlZ",
  /* 11/12 (007) */ "nhTeiZpqT{sTaxVmyYuzW",
  /* 11/13 (008) */ "tbTckTlmZ0doUevZr{U0",
  /* 11/14 (009) */ "ncTgdVafVkhTviZupUsqTbrTjxVwyYlzW",
  /* 11/15 (010) */ "imZgoV{qSewW",
  /* 11/16 (011) */ "yuXrvZ",
  /* 11/17 (012) */ "oaU0fcTwjVgkThlZinTdpUzqTexVryYb{T",
  /* 11/18 (013) */ "zbTstTwuX",
  /* 11/19 (014) */ "qaThgWejVrlZisTfxVd2yY",
  /* 11/20 (015) */ "icTzkTdmZ0{pUntTvwU0",
  /* 11/21 (016) */ "baTefVpgWxjVulZcnTkoWtqTsrVhyYz{T",
  /* 11/22 (017) */ "gmZiqSduWhvY",
  /* 11/23 (018) */ "a1bTywZ",
  /* 11/24 (019) */ "tcToeTdiZljVnkT{rTxvU0qyY",
  /* 11/25 (020) */ "{bTlfVwgWchTqmZknTeoVrpUjsTatTvuXxzW",
  /* 11/26 (021) */ "",
  /* 11/27 (022) */ "cbTaeTyfVskTglZjnTotTiuXmvZqzWp0{T",
  /* 11/28 (023) */ "naTkcTlgWuiZzjV{oWhpUdrGesTbtTqwZyxV",
  /* 11/29 (024) */ "rhSfmZwvY",
  /* 11/30 (025) */ "",
  /* 12/1  (026) */ "kaTbeTjgWvrTcuXmwZsyYfzWx{T",
  /* 12/2  (027) */ "dbU0ciZvkTnoVaqTxtT",
  /* 12/3  (028) */ "reTmjVslZfyYpzWo{T",
  /* 12/4  (029) */ "nbTvdU0igWakTxqThtTmuXcwZ",
  /* 12/5  (030) */ "xaTbdVveTjfVthTsiZclZqnTorGpyYgzWk{T",
  /* 12/6  (031) */ "pmZuoV",
  /* 12/7  (032) */ "",
  /* 12/8  (033) */ "daTleTnfVkiZpjVuqTyrTbsU0ovZ{wZzxV",
  /* 12/9  (034) */ "gbTucTedVshTvmZytT",
  /* 12/10 (035) */ "pfVoiZlqTcrTkwZnxV{zW",
  /* 12/11 (036) */ "gaTybTjdVehU0{mZusTltTkvZ",
  /* 12/12 (037) */ "taTgcTqdTyeTxfVunTjpUhrTiwZozW",
  /* 12/13 (038) */ "klWomZ{vU",
  /* 12/14 (039) */ "grT",
  /* 12/15 (040) */ "haTcdVjeTliZwnTbpU0rqTtsT{uXmxVoyY",
  /* 12/16 (041) */ "zcTmfVvgWahTbkTilZetT",
  /* 12/17 (042) */ "xjVqoVwsTd{T",
  /* 12/18 (043) */ "rbTweTkhUplZumZanTztTfxU0v2yY",
  /* 12/19 (044) */ "saTtdVzeTmgWpiZfjVqkThoWnrTlyYc{T",
  /* 12/20 (045) */ "wqSivY",
  /* 12/21 (046) */ "ndVktT",
  /* 12/22 (047) */ "caTjhTflZwoVbqTzsTiuU0yvZgxV",
  /* 12/23 (048) */ "jbThcT{dVkeTugWfiZymZznTwpU",
  /* 12/24 (049) */ "",
  /* 12/25 (050) */ "rdW2xlL2",
  /* 12/26 (051) */ "qeHifVgjVdkTxmZsnTroWapUyuXtvYbzLh0{T",
  /* 12/27 (052) */ "tlWguWbwW",
  /* 12/28 (053) */ "heTmnTcqTosTixVpzWa{T",
  /* 12/29 (054) */ "eaTdcTijVkrTfwZb2yY",
  /* 12/30 (055) */ "xgW{hTrkTblZdnTqpUmsTjuXfvZtzW",
  /* 12/31 (056) */ "",
  /* 1/1   (057) */ "",
  /* 1/2   (058) */ "oaUqcTkdVmeTjiZfpUlrGhsTzvYtwZgyYn{T",
  /* 1/3   (059) */ "lbSmoVjvYuxU0",
  /* 1/4   (060) */ "",
  /* 1/5   (061) */ "{aTbcTmdU0vfVujVlkThnTpoVerTqsTgwZiyYxzW",
  /* 1/6   (062) */ "kbTdeTlhTmpUqtT",
  /* 1/7   (063) */ "ufVniZvjVaoVzxV",
  /* 1/8   (064) */ "qbTlcTodVjgWahUwmZypUrsU0t{T",
  /* 1/9   (065) */ "peTzfVygWihT{qTksTdtTnwZvxV",
  /* 1/10  (066) */ "zjVnmZloVbrU0",
  /* 1/11  (067) */ "cfVxhT",
  /* 1/12  (068) */ "iaTbeTtkTjlZdsTgvZrwZuyYnzWo{T",
  /* 1/13  (069) */ "{bTrgWfhTxpUeqTitT",
  /* 1/14  (070) */ "haTcjVmlZxoVnvZuwZyzW",
  /* 1/15  (071) */ "sbTidVrfVekU0vmZgpUtqTnuXlyY",
  /* 1/16  (072) */ "sdVaeTfgWrjVikTboWhtTcxVwzWq0{T",
  /* 1/17  (073) */ "yvU0",
  /* 1/18  (074) */ "bdLwiOjmNlpUkqTurGstIzyYe{G",
  /* 1/19  (075) */ "acThfV{kTvoVjwZgxV",
  /* 1/20  (076) */ "abTueTziZymZtnTvpUcrT",
  /* 1/21  (077) */ "gfVhjVokTdqT",
  /* 1/22  (078) */ "qaTcdVyiZelZnsTrtTwvZhxVmzU0u{T",
  /* 1/23  (079) */ "uaTegWjkTtoWfsTpwZ",
  /* 1/24  (080) */ "kcTylWfnQjqSdxG2vzL2m{G",
  /* 1/25  (081) */ "waTpgWuhU0",
  /* 1/26  (082) */ "dfVjoVmqTtrTasTivZezUn{T",
  /* 1/27  (083) */ "wcTbhTgiZzlZupVktTxyY",
  /* 1/28  (084) */ "seTqgWdjVmkTonTarT",
  /* 1/29  (085) */ "mcTwfVphUliZbsT{tTxuU0",
  /* 1/30  (086) */ "taTdgWqjVhkTenTopUfuXwxVvyYlzWc{T",
  /* 1/31  (087) */ "mbF2",
  /* 2/1   (088) */ "ycTqfVioVswZdzU0",
  /* 2/2   (089) */ "yaTieTkjVulZsmZ{rTpvZqxV",
  /* 2/3   (090) */ "jfVanTeoVctTpuXdwZgzX",
  /* 2/4   (091) */ "dlZzmZyqTirTkxV",
  /* 2/5   (092) */ "tbTocTheTkfVwgWpjVrnU0muXsvZi{T",
  /* 2/6   (093) */ "eaTfgWwlZpxVy{T",
  /* 2/7   (094) */ "ibG2yhSqoJnrQsuWdvL2",
  /* 2/8   (095) */ "{jVfmZrtTszW",
  /* 2/9   (096) */ "o1bTecTnhTaiZzwZlxVgyY",
  /* 2/10  (097) */ "{fVdkTgmZnpUhqU0esTjtTluX",
  /* 2/11  (098) */ "scTuiZjrTawZ{xVzyY",
  /* 2/12  (099) */ "rdU0oeTbfVtgZ0qhUpkTvlZcnT",
  /* 2/13  (100) */ "edVtfV{gWkoWjpUiwZbxVuyYazW",
  /* 2/14  (101) */ "hcI3{iZamZnqOrsI3lvU0",
  /* 2/15  (102) */ "wdLkeQxlZgnTcoVzpU",
  /* 2/16  (103) */ "shTxiZtjToqTfrTbuU0avZ{yY",
  /* 2/17  (104) */ "rcTzdVfeTwkThnTgsT",
  /* 2/18  (105) */ "yiZbjV{lZzoVwpUauXmvZtxV",
  /* 2/19  (106) */ "|zY0",
  /* 2/20  (107) */ "|zS0",
  /* 2/21  (108) */ "}zQ2",
  /* 2/22  (109) */ "|z[",
  /* 2/23  (110) */ "{aTqcTodVneTygWthTbkTwlZprTvsTuxVjzW",
  /* 2/24  (111) */ "qbTgfVziZvnU0roVypUatTmwZk{T",
  /* 2/25  (112) */ "xcTujVdsT",
  /* 2/26  (113) */ "baTrhU0liZckTemZxnTfpUvqTotTzuXywZs{T",
  /* 2/27  (114) */ "adVohTgjViyYwzW",
  /* 2/28  (115) */ "vbScgWfkJlmL3pnMrqG3xsG3euL3",
  /* 3/1   (116) */ "bhU0tiZczW",
  /* 3/2   (117) */ "mgWxkTjlZfoVdqU0arTpsTuvZeyY",
  /* 3/3   (118) */ "xbTfdVzhVmiZ{nTtuXjwZ",
  /* 3/4   (119) */ "vgWakTepUsqTzrTcyYl{T",
  /* 3/5   (120) */ "hbTxdU0jfVtmZlnTsoWwuXcvZ",
  /* 3/6   (121) */ "zaTufVwjVxpUgqTtyY",
  /* 3/7   (122) */ "ebG2viL2cmZknMhoJlsI",
  /* 3/8   (123) */ "laTgeTykTtpUsrU0",
  /* 3/9   (124) */ "{cTydTmhTnjVaoVuwZfxVpzW",
  /* 3/10  (125) */ "vfVqlZmrTksTbtTiuXg{T",
  /* 3/11  (126) */ "ceTghTqiZvjVdnTyoTpwZ",
  /* 3/12  (127) */ "saTobTcdVplZmtTfuXr{T",
  /* 3/13  (128) */ "zjVynTkrVgtTquXfwZvxVe0{T",
  /* 3/14  (129) */ "maScbU0dhE2lpLysT",
  /* 3/15  (130) */ "ldVzfVngWqvZmxU0",
  /* 3/16  (131) */ "acTteTbiU0sjVgpUorThwZnyY",
  /* 3/17  (132) */ "sfVokTxmZaqT{tTvuXhzW",
  /* 3/18  (133) */ "pcTreTbgWjiZnlZwyY",
  /* 3/19  (134) */ "paT{dVckTbmZoqTftThuXjvZiwZsxVyzW",
  /* 3/20  (135) */ "sgWzlZenTtoWd{T",
  /* 3/21  (136) */ "yjVhmU0cpLfqSxrE2kuWbvU",
  /* 3/22  (137) */ "zgWhiZq{T",
  /* 3/23  (138) */ "faTjcTpdTxeU0nsTruXlwZv2yYkzW",
  /* 3/24  (139) */ "nbTolZumZxpUcqTdtTf{T",
  /* 3/25  (140) */ "jaTigWvwZkyYrzW",
  /* 3/26  (141) */ "fbTsdVchUrmZqnTipUetTouXlvZzxVj{T",
  /* 3/27  (142) */ "naTkgWqsTowZlyY",
  /* 3/28  (143) */ "{1bJvcE3xfUehE3riU0kmZjpLutE3",
  /* 3/29  (144) */ "vaTwbT{oVgzW",
  /* 3/30  (145) */ "ncTudU0piZmlZtqTwrThsTyxV",
  /* 3/31  (146) */ "tbTyfVagWvhT{kTpmZxzW",
  /* 4/1   (147) */ "ojVnqTerTcsTw{T",
  /* 4/2   (148) */ "ubU0ecTqdVifVogWwhUskTalZrnTvtTpxV",
  /* 4/3   (149) */ "ijVayYv{T",
  /* 4/4   (150) */ "dbH2qeHpgMukLflWzmZsnMwtFrxU0",
  /* 4/5   (151) */ "",
  /* 4/6   (152) */ "raTneT{hTljVdoVkqTtsTmuZzvZgwZixVfyY",
  /* 4/7   (153) */ "scTkpUt{T",
  /* 4/8   (154) */ "miZnoVhqTbrU0fvZuwZlxVjzW",
  /* 4/9   (155) */ "daThbT{eTvmZspUctTguZwyY",
  /* 4/10  (156) */ "acTfiZxjVdkVglZtnTsoWeqT",
  /* 4/11  (157) */ "rbG2ymL3zuL3pvUh{G",
  /* 4/12  (158) */ "tcTdhTgiZulZonTfzW",
  /* 4/13  (159) */ "eaTkbTmjV{rTosTlvZxwZpyY",
  /* 4/14  (160) */ "rcTndVmfVjgWahTxiZqkVpuZ",
  /* 4/15  (161) */ "eoVbqTstTvzU0n{T",
  /* 4/16  (162) */ "hcTodVseTgfVrkVilZjmZvpUyuZwxV",
  /* 4/17  (163) */ "caTwfVbnL2hrVjyYuzWq{T",
  /* 4/18  (164) */ "deP2lgWimK2koJbsFptGxvU",
  /* 4/19  (165) */ "juZxyY",
  /* 4/20  (166) */ "kaTtdVheTlfVrnTmpU{sTivZzwZ",
  /* 4/21  (167) */ "sbTocTfgWwiZekVqrTntTmzWa{T",
  /* 4/22  (168) */ "hdVpjVylZuvU0gxV",
  /* 4/23  (169) */ "oaTebTdcTpfVkhU{nTsqTrtTvwZmyYizW",
  /* 4/24  (170) */ "fjVnkTwmZcoWasTxuL2",
  /* 4/25  (171) */ "teL3ugWqhL3yiL3vlL3zpLdrG2jxVb{G",
};

main(argc,argv)
int argc;
char  *argv[];
{
  extern    int is_team();
  extern    int get_nba_day();
  extern    void  do_long_sched();
  extern    void  do_all();
  extern    void  do_summary_sched();

  struct tm    *time_tm;
  register int i,j;
  register int month,day;
  int          arg_count;
  int          nba_day;
  int          team;
  int	       newteam;
  long         current_date;
  char         *ptr;
  int 	       teamtwo = -1;


  /*
   * Look for the "summary form" flag...if specified, it must be the
   * first option.
   */
  arg_count = 1;
  team = -1;
  
  if (argc > arg_count) {
    /*
     * -help option
     */
    if (strcmp(argv[arg_count], "-help") == 0) {
      fprintf(stdout, "Usage: %s [-s|team] [-m team1 team2] [mm/dd ... | all]\n", argv[0]);
      exit(0);
    }

    /*
     * Check for a request for summary or a specific team.
     */
    if (strcmp(argv[arg_count], "-s") == 0) {
      summary_form = 1;
      arg_count++;
    } /* if (strcmp()) */

/* New functionality added by Dennis P. Joyce (dpj4303@ritvax.rit.edu):
	-m option designates that matchup  listing is desired. The
	next two arguments are the teams that are desired		*/

    else if (strcmp(argv[arg_count], "-m") == 0){
	playing=1;
	arg_count++;
	if (is_team(argv[arg_count], &newteam))  {
		team = newteam;
		arg_count++;
		if (is_team(argv[arg_count], &newteam)) {
			teamtwo = newteam;
			arg_count++;
			}
		else 
			{
			fprintf(stdout,"\n%s: Is not a NBA team\n",argv[arg_count]);
			exit(0);
			}
		}
		else 
			{
			fprintf(stdout,"\n%s: Is not a NBA team\n",argv[arg_count]);
			exit(0);
			}
	do_all(team,teamtwo);
	}


      else if (is_team(argv[arg_count], &newteam))  {
      team = newteam;
      arg_count++;
    } /* else if (is_team()) */
  }/* if (argc > ..) */

  /*
   * Check for a requested date on the command line.
   */
  if (argc == arg_count) {
    /*
     * No date/options requested...give today's schedule.
     */
    current_date = time((long *)NULL);
    time_tm = localtime(&current_date);
    month = time_tm->tm_mon+1;
    day = time_tm->tm_mday,0;
    nba_day = get_nba_day(month,day);
    if (nba_day < 0)
      exit(1);

    if (summary_form == 1)      /* Do SUMMARY format */
      do_summary_sched(month,day,nba_day);
    else          /* Do LONG format */
      do_long_sched(month,day,nba_day,team);

    exit(0);
  } /* if (argc == ..) */

  for (;arg_count<argc;arg_count++) {
    /*
     * Validate the date format.
     */
    j = strlen(argv[arg_count]);
    ptr = strchr(argv[arg_count],'/');

    /*
     * This if loop is added by toshi@nml.t.u-tokyo.ac.jp
     * to allow printing of entire NBA schedule (Sep 26, 1992). 
     */
    if (strcmp(argv[arg_count], "all") == 0) {
	do_all(team,teamtwo);
    } /* if  (strcmp()) */

    else if ((strspn(argv[arg_count],"0123456789/") != j) ||
        (j < 3) || (j > 5) ||
        (argv[arg_count][0] == '/') ||
        (argv[arg_count][j-1] == '/') ||
        (ptr == NULL)) {
      fprintf(stderr,"Invalid date \"%s\"...format is \"mm/dd\"\n",
	      argv[arg_count]);
      continue;
    } /* else if ((strspn())) */

    /*
     * Do some basic date validation...
     */
    month = atoi(argv[arg_count]);
    day = atoi(++ptr);

    if (month > 12) {
      fprintf(stderr,"Invalid date \"%d/%d\"...months are from 1 - 12.\n",
	      month,day);
      continue;
    } /* if (month > 12) */

    if (day == 0) {
      fprintf(stderr,"Invalid date \"%d/%d\"...the day can not be \"0\"\n",
	      month,day);
      continue;
    }/* if (day == 0) */
    else if (day > days[month-1]) {
      fprintf(stderr,	      "Invalid date \"%d/%d\"...there are only %d days in the month.\n",
        month,day,days[month-1]);
      continue;
    } /* else if (day > ..) */

    /*
     * Figure out what julian date is being requested and convert
     * it to the specific day of the NBA season.
     */
    nba_day = get_nba_day(month,day);
    if (nba_day < 0)
      continue;

    if (summary_form == 1)      /* Do SUMMARY format */
      do_summary_sched(month,day,nba_day);
    else          /* Do LONG format */
      do_long_sched(month,day,nba_day,team,teamtwo);
  }

  exit(0);
} /* main */

/* do_all procedure designed to check each day of NBA season. This is the same code 
	that was in the main() in the previous version			*/

void do_all(team,teamtwo)
int team,teamtwo;
{
int month,day,nba_day;
 for (month = 11; month != 5; month++) {
        if (month == 13)
          month = 1;

        for (day = 1; day <= days[month-1]; day++) {
          if ((month == 11) && (day < 6))  continue;
          if ((month == 4)  && (day > 25)) break;

          nba_day = get_nba_day(month, day);
          if (nba_day < 0)
            continue;

          do_long_sched(month, day, nba_day, team,teamtwo);
        } /* for (day = ..) */
      } /* for (month = ..) */

      exit(0);
}


int
is_team(name, team)
char *name;
int *team;
{
  char newname[128], checkname[128];
  int i, j;

  /*
   * Convert the given name to lower case and all others are lower case
   */
  for (i = 0; i < strlen(name); i++)
	newname[i] = tolower(name[i]);
/*
    if (isupper(name[i]))
      newname[i] = tolower(name[i]);
    else
      newname[i] = name[i];
*/
  newname[i] = '\0';

  /*
   * Scan the NBA teams for one that matches the given name
   */
  for (i = 0; i < (sizeof(nba_teams)/sizeof(char *)); i++) {
    /*
     * Convert the name to check to lower case
     */
    for (j = 0; j < strlen(nba_teams[i]); j++)
      if (isupper(nba_teams[i][j]))
        checkname[j] = tolower(nba_teams[i][j]);
      else
        checkname[j] = nba_teams[i][j];
    checkname[j] = '\0';

    if (strcmp(checkname, newname) == 0) {
      *team = i;
      return(1);
    } /* if (strcmp()) */
  } /* for (i = 0;..) */

  /*
   * No team found
   */
  *team = -1;
  return(0);
} /* is_team */

get_nba_day(month,day)
int month,day;
{
  int nba_day = 0;

  for (month--;month > 0;month--)
    nba_day += days[month-1];
  nba_day += day;

  if (nba_day >= 310)
    nba_day -= 310;
  else
    nba_day += 55;

  if ((nba_day < 0) || (nba_day >= 171)) {
    fprintf(stderr,"The NBA regular season runs from 11/6 to 4/25.\n");
    return (-1);
  } /* if ((nba_day < ..)) */

  return (nba_day);
} /* get_nba_day */

/*
 * Argument "team" is added by toshi@nml.t.u-tokyo.ac.jp
 * to print out a specific team(Sep 26, 1992).
 */
void
do_long_sched(month,day,nba_day,team,teamtwo)
int     month;
int     day;
register  int nba_day;
int team;
int teamtwo;
{
  register  int i;
  register  int j;
  int   home;
  int   visitor;
  int   tip_off;
  int   alt_site;
  int   footer;
  int   tv_game;
  int   day_o_week;
  int   found;
  char  tmpVisitor[128], tmpHome[128];


  day_o_week = nba_day % 7;

  if (team == -1)
    if (nba_day == 9)
      fprintf(stdout,"\nNBA schedule for today...\n");
    else
      fprintf(stdout,"\nNBA schedule for %s, %d/%d...\n",
	      weekday[day_o_week],month,day);

  if ((team == -1) && (nba_schedule[nba_day][0] == '\0')) {
    fprintf(stdout,"          No games scheduled\n");
    return;
  } /* if (nba_schedule[][] ..) */

  for (i=footer=found=0;nba_schedule[nba_day][i] != '\0';) {
    /*
     * The first character is the visiting team.
     */
    visitor = nba_schedule[nba_day][i++] - 'a';

    /*
     * If the next character is a digit...look up the
     * alternate game site
     */
    if (isdigit(nba_schedule[nba_day][i]))
      alt_site = nba_schedule[nba_day][i++] - '0';
    else
      alt_site = 4;

    /*
     * The next charater is the home team.
     */
    home = nba_schedule[nba_day][i++] - 'a';

    /*
     * The next character is the tip-off time.
     */
    tip_off = nba_schedule[nba_day][i++] - '?' - TZ_FIX;

    /*
     * If the next character is a digit...look up the
     * TV coverage.
     */
    if (isdigit(nba_schedule[nba_day][i]))
      tv_game = nba_schedule[nba_day][i++] - '0';
    else
      tv_game = 4;

    if (tv_game % 2 == 1)
      footer = 1;

    /*
     * If any team isn't specified, print out every entry in data.
     */
    if (team == -1) {
      fprintf(stdout,"%8s  %-12s at %-12s %s %s\n",
	      tv_coverage[tv_game],
	      nba_teams[visitor],
	      nba_teams[home],
	      game_time[tip_off],
	      alternate_site[alt_site]);
    } /* if (team == -1) */

    /*
     * A specified team is found.
     */

/* LOOKING FOR SPECIFIC MATCHUP   [BOSTON vs UTAH] */
    if (teamtwo != -1){
	if (((visitor ==team) && (home == teamtwo)) || ((visitor == teamtwo) && (home == team))){
	strcpy(tmpHome, nba_teams[home]);
	strcpy(tmpVisitor, nba_teams[visitor]);
    		fprintf(stdout,"%-6s %10s, %2d/%2d %-12s at %-12s %s %s\n",
              		tv_coverage[tv_game],
              		weekday[day_o_week],
              		month, day,
	      		tmpVisitor,
	      		tmpHome,
              		game_time[tip_off],
             	 	alternate_site[alt_site]);

        	found++;
        	break;
	}
    }    	
	
    if ((teamtwo == -1) && ((visitor == team) || (home == team))) {

      /*
       * The name of a specified team is CAPITALIZED.
       */
      if (visitor == team) {
      /* When it is a visitor team. */
	strcpy(tmpHome, nba_teams[home]);

	for (j = 0; j < strlen(nba_teams[visitor]); j++)
	  if (isupper(nba_teams[visitor][j]))
	    tmpVisitor[j] = nba_teams[visitor][j];
	  else
	    tmpVisitor[j] = toupper(nba_teams[visitor][j]);
	tmpVisitor[j] = '\0';
      } /* if (visitor == team) */
      else {
      /* When it is a home team. */
	strcpy(tmpVisitor, nba_teams[visitor]);

	for (j = 0; j < strlen(nba_teams[home]); j++)
	  if (isupper(nba_teams[home][j]))
	    tmpHome[j] = nba_teams[home][j];
	  else
	    tmpHome[j] = toupper(nba_teams[home][j]);
	tmpHome[j] = '\0';
      } /* else */
      
      fprintf(stdout,"%-6s %10s, %2d/%2d %-12s at %-12s %s %s\n",
	      tv_coverage[tv_game],
	      weekday[day_o_week],
	      month, day,
	      tmpVisitor,
	      tmpHome,
	      game_time[tip_off],
	      alternate_site[alt_site]);
      
	found++;
        break;
    } /* if ((visitor ==..)) */

  } /* for (i=footer..) */

  if ((nba_schedule[nba_day][i] != '\0') && (found == 0)) {
    fprintf(stdout,"          No games scheduled\n");
    return;
  } /* if (nba_schedule[][] ..) */

  if ((footer == 1) && (team == -1))
    fprintf(stdout,"\n      * Specific TV game not determined yet.\n");

  return;
} /* do_long_sched */

void
do_summary_sched(month,day,nba_day)
int     month;
int     day;
register  int nba_day;
{
  register  int i;
  register  int j;
  register  int k;
  int   home;
  int   visitor;
  int   alt_site;
  char    footer[3];
  char    footers[9];
  int   tv_game;
  int   day_o_week;
  int   most_lines = 3;
  char    summary_matrix[7][17][14];

  /*
   * Initialize the matrix for the summary display.
   */
  for (j=0;j<7;j++) {
    strcpy(summary_matrix[j][0],  "-----------");
    strcpy(summary_matrix[j][2],  "-----------");
    strcpy(summary_matrix[j][16], "-----------");

    day_o_week = (nba_day + j) % 7;
    sprintf(summary_matrix[j][1],"| %s %2d/%-2d ",
      summary_weekday[day_o_week],month,day);
    day++;
    if (day > days[month-1]) {
      day = 1;
      if (++month == 13)
        month = 1;
    } /* if (day > ..) */

    for (k=3;k<=15;k++)
      strcpy(summary_matrix[j][k],"|          ");
  } /* for (j=0;..) */

  for (k=0;k<=16;k++) {
    if ((k == 0) || (k == 2) || (k == 16))
      strcat(summary_matrix[6][k],"-\n");
    else
      strcat(summary_matrix[6][k],"|\n");
  } /* for (k=0;..) */

  strcpy(footers,"00000000");

  for (j=0;j<7;j++) {
    if ((nba_day+j) >= 171) {
      /* We just went past end of season! */
      strcpy(summary_matrix[j][3],"|  SEASON  ");
      strcpy(summary_matrix[j][4],"|  IS OVER ");

      if (j == 6) {
        strcat(summary_matrix[j][3],"|\n");
        strcat(summary_matrix[j][4],"|\n");
      } /* if (j == 6) */

      if (most_lines < 4)
        most_lines = 4;

      continue;
    } /* if ((nba_day+j)) */

    if (nba_schedule[nba_day+j][0] == '\0') {
      /* No games scheduled */
      continue;
    } /* if (nba_schedule[][]..) */

    for (i=0,k=3; nba_schedule[nba_day+j][i] != '\0';k++) {
      footer[0] = footer[1] = footer[2] = '\0';

      /*
       * The first character is the visiting team.
       */
      visitor = nba_schedule[nba_day+j][i++] - 'a';

      /*
       * If the next character is a digit...look up the
       * alternate game site
       */
      if (isdigit(nba_schedule[nba_day+j][i])) {
        alt_site = nba_schedule[nba_day+j][i++] - '0';
        strncat(footer,sum_alt_site[alt_site],1);
        footers[alt_site+4] = '1';
      } /* if (isdigit()) */

      /*
       * The next charater is the home team.
       */
      home = nba_schedule[nba_day+j][i++] - 'a';

      /*
       * The next character is the tip-off time....skip it!
       */
      i++;

      /*
       * If the next character is a digit...look up the
       * TV coverage.
       */
      if (isdigit(nba_schedule[nba_day+j][i])) {
        tv_game = nba_schedule[nba_day+j][i++] - '0';
        strncat(footer,sum_tv_coverage[tv_game],1);
        footers[tv_game] = '1';
      } /* if (isdigit()) */

      sprintf(summary_matrix[j][k],"| %3s-%-3s%2s",
        nba_summary_teams[visitor],
        nba_summary_teams[home],
        footer);

      if (j == 6)
        strcat(summary_matrix[j][k],"|\n");

      if (k > most_lines)
        most_lines = k;
    } /* for (i=0,k=3;..) */
  } /* for (j=0;..) */

  /*
   * Now print out the summary matrix...
   */
  for (k=0;k<=most_lines;k++) {
    for (j=0;j<7;j++)
      fprintf(stdout,"%s",summary_matrix[j][k]);
  } /* for (k=0;..) */
  for (j=0;j<7;j++)
    fprintf(stdout,"%s",summary_matrix[j][16]);

  /*
   * Print out any footnotes...
   */
  for (j=0;j<4;j++)
    if (footers[j] == '1')
      fprintf(stdout,"%s\n",sum_tv_coverage[j]);
  for (j=4;j<8;j++)
    if (footers[j] == '1')
      fprintf(stdout,"%s\n",sum_alt_site[j-4]);

  return;
} /* do_summary_sched */

/* EOF */


Newsgroups: rec.sport.basketball.pro