Newsgroups: bit.listserv.hellas
Date:         Sun, 27 Sep 1992 02:32:27 -0400
Reply-To:     "alexandros g. hobson" <alexees@WAM.UMD.EDU>
From:         "alexandros g. hobson" <alexees@WAM.UMD.EDU>
Subject:      NBA Utility.
Comments: To: hellas@uga.cc.uga.edu

Kalnspera,
Avti yia trayoudi, to Shoplifters of the World Unite club sas stelvei
eva nba utility, yia va blepte ti aywves paizontai kapoia suykekrimevn
mera tns sezon. Odnyies akolouthoun...
Afeirwnevo ston Spuro Mpravn, pou eixe tnv kalosuvn va mas steilei to idio
mail triavta fores :))) Apolauste...
A, nai... To pnra apo ta newsgroups... Mn vomizete dnladn oti to eftia3a
eyw :)))...

----------------------------cut here--------------------------------------------

/***************************************************************************
* 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"                                 *
*                                                                          *
* Another new feature (for UNIX users especially) is the ability to        *
* highlight games for a particular team.  This is done by calling "tput"   *
* to determine the bold/nobold stings to use.  If "tput" is not available  *
* on your system, you could manually set any string that you want.  To set *
* the team to highlight, look for the "#ifdef HIGHLIGHT" line in the       *
* "do_long_sched()" and "do_summary_sched()" functions and enter the       *
* appropriate stings for your team.                                        *
*                                                                          *
* To compile this version just use... "cc -DHIGHLIGHT -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       *
*                                                                          *
****************************************************************************/


#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	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",
};

#ifdef HIGHLIGHT
	char	bold_string[10];
	char	nobold_string[10];
#endif

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

	struct tm		*time_tm;
	register	int	i,j;
	register	int	month,day;
	int			arg_count;
	int			nba_day;
	long			current_date;
	char			*ptr;

#ifdef HIGHLIGHT
	/*
	 * Set the bold/nobold strings.
	 */
	FILE	*pipefd;

	pipefd = popen("tput smso 2>/dev/null","r");
	i = fread(bold_string,1,9,pipefd);
	if (i < 0)
		i = 0;
	bold_string[i] = '\0';

	pipefd = popen("tput rmso 2>/dev/null","r");
	i = fread(nobold_string,1,9,pipefd);
	if (i < 0)
		i = 0;
	nobold_string[i] = '\0';
#endif

	/*
	 * Look for the "summary form" flag...if specified, it must be the
	 * first option.
	 */
	arg_count = 1;
	if (argc > arg_count)
	{
		if (strcmp(argv[arg_count], "-s") == 0)
		{
			summary_form = 1;
			arg_count++;
		}
	}

	/*
	 * 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);

		exit(0);
	}

	for (;arg_count<argc;arg_count++)
	{
		/*
		 * Validate the date format.
		 */
		j = strlen(argv[arg_count]);
		ptr = strchr(argv[arg_count],'/');
		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;
		}

		/*
		 * 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 (day == 0)
		{
			fprintf(stderr,"Invalid date \"%d/%d\"...the day can not be
 \"0\"\n",month,day);
			continue;
		}
		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;
		}

		/*
		 * 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);
	}

	exit(0);
}

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);
	}

	return (nba_day);
}

void
do_long_sched(month,day,nba_day)
int			month;
int			day;
register	int	nba_day;
{
	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;

	day_o_week = nba_day % 7;

	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 (nba_schedule[nba_day][0] == '\0')
	{
		fprintf(stdout,"          No games scheduled\n");
		return;
	}

	for (i=footer=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;

#ifdef HIGHLIGHT
	/* Look for BOSTON */
	if ((strcmp(nba_teams[home],"Boston") == 0) ||
	    (strcmp(nba_teams[visitor],"Boston") == 0))
		fprintf(stdout,"%s%8s  %-12s at %-12s %s %s%s\n",
			bold_string,
			tv_coverage[tv_game],nba_teams[visitor],
			nba_teams[home],
			game_time[tip_off],
			alternate_site[alt_site],
			nobold_string);
	else
#endif
		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 (footer == 1)
		fprintf(stdout,"\n      * Specific TV game not determined yet.\n");

	return;
}

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][30];

	/*
	 * 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;
		}

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

	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");
	}

	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 (most_lines < 4)
				most_lines = 4;

			continue;
		}

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

		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';
			}

			/*
			 * 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';
			}

#ifdef HIGHLIGHT
	/* Look for BOSTON */
		if ((strcmp(nba_summary_teams[home],"Bos") == 0) ||
		    (strcmp(nba_summary_teams[visitor],"Bos") == 0))
			sprintf(summary_matrix[j][k],"|%s %3s-%-3s%2s%s",
				bold_string,
				nba_summary_teams[visitor],
				nba_summary_teams[home],
				footer,
				nobold_string);
		else
#endif
			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;
		}
	}

	/*
	 * 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 (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;
}
Comments: Gated by NETNEWS@AUVM.AMERICAN.EDU