
From: cmoore@ARL.MIL
Date:     Thu, 1 Jun 95 16:44:15 EDT
Subject:  program.in.c


/* Received from Brint Cooper
*/
#include	<stdio.h>
#include	<ctype.h>
/*
	areacode.c
	Translated from AREACODE.MAC.
	Ken Yap (ken@rochester.arpa, ..!rochester!ken).

	Compile: cc -O -o areacode areacode.c
	Run: areacode nnn nnn ...

***Begin notes by Carl Moore***
(look for "End notes" and find last update just before it)

26-28 May 1988: Modify to account for 305/407 (Florida),
	303/719 (Colorado), 617/508 (Massachusetts) splits;
	add "(also suburbs)" for 202.

Modified by Telecom moderator in Jan. 1989: Add notes about
700 & 800 & 900, and also about not-yet-in-use 708; change
entry for 312, which will be split to form 708, and which had
read: "312Aurora, Chicago, Elgin, and Highland Park, Illinois".
("(as of 11-89)" deleted 13 November 1989)

30 March 1989: Replace Adrian (which is in 517) with Flint for 313.

14 March 1990: Delete "(also suburbs)" for area 202, because of removal,
	before end of 1990, of 202 for Md. and Va. suburbs.  Delete these
        2 lines:
"170Northwest Mexico",
"190Mexico City, Mexico",

27 November 1990: Add line for 903 in Texas.

9 January 1991: Add line for 908 in New Jersey, and reverse
	Brooklyn and Queens in entry for 718.

8 April 1991: Delete this line:
"525the Country and City code for Mexico City, Mexico",

3 September 1991: Add new lines for 415/510 split, and delete this line:
"415Oakland and San Francisco, California",

4 November 1991: Add new lines for 301/410 and 404/706 splits; for
	310, make minor changes involving commas; fix spelling of state
	name in 901; delete these 2 lines:
"301all regions, Maryland",
"404Atlanta and Rome, Georgia",

15 November 1991: Add new lines for 512/210 split, and delete this line:
"512Austin, Corpus Christi and San Antonio, Texas",
	and delete "(splits 3 May 1992 to form 706)" from note about 404,
	and "(splits 1 Nov 1992 to form 210)" from note about 512

16 July 1992: Delete parenthetical comment from the following:
"706Augusta, Columbus and Rome, Georgia (use 404 until 3 May 1992)",
	and change these lines regarding New York City:
"212New York City (Manhattan and Bronx), New York",
"718New York City (Brooklyn, Queens and Staten Island), New York",
	and add lines for 810, 909, 917.

14 January 1993: Add line about 610 in Pennsylvania.
Remove "(use 512 until 1 Nov 1992)" from line about 210.  Change
"909future: Riverside and San Bernardino, California (now 714)",
to
"909Riverside and San Bernardino, California",
"910future (North Carolina)",

1 October 1993: Add line for 905 in Ontario.

12 November 1993: Revise line for 910 in North Carolina.

1 December 1993: Revise lines for 313 and 810; they were
"313Detroit, Flint and Ann Arbor, Michigan",
"810future: northern part of present area 313 in Michigan",

7 January 1994: Revise lines for 215 and 610; they were
"215Allentown, Chester and Philadelphia, Pennsylvania",
"610future (Pennsylvania)",

15 January 1995: Revise these lines:
"205all regions, Alabama",
"206Seattle, Tacoma and Vancouver, Washington",
Add new lines for 334,360,630.

31 January 1995: Add line for 500.

7 March 1995: Add lines for 281,520,540,941,954,970.
(520,540,941,970 still future)

21 March 1995: Revise lines for 502,620 (Arizona), which were:
"520future: Flagstaff and Tucson, Arizona",
"602all regions, Arizona",
and add line for 972 in Texas.

31 May 1995: Revise line for 203, which was:
"203all regions, Connecticut",
Add new line for 860.
Revise line for 703, which was:
"703Fredericksburg, Roanoke and Winchester, Virginia",
Revise line for 941, which was:
"941future: to be formed from split of 813, Florida",
Revise line for 970, which was:
"970future: to be formed from split of 303, Colorado",

***End notes by Carl Moore***

	AREACODE.MAC Ver 1.3 as of November 20, 1984
	Ver. 1.3 added LA suburbs area code 818, added periods to
	messages (why not?), deleted double entry for area code 809,
	removed ungrammatical comma from ASCII string at MSG2: and
	added a space before the `$' in MSG2: so the first space in
	messages could be removed, providing an extra space for text
	without changing the SCAN3: routine's 58-character bias.
	This version provided for M80/L80 devotees courtesy of Irv
	Hoff's XLATE5.COM to prevent undue anxiety trying to find a
	copy of ASM.COM.  It has not been tested, so bug fixes from
	Z80-land are more than welcome. - Bruce Morgen

	Ver. 1.2 added 718 area code for New York City, and fixed bug
	in area code 604-804 Harry Kaemmerer

	Ver. 1.1 update of area codes for new U.S. areas, Mexico, &
	Eastern Canada. Harvey G. Lord, Storrs, CT 06268

	Ver. 1.0 - January 2, 1981 by Kelly Smith

	AREACODE is used to display the region and state, specified
	by the user...very handy when someone leaves an area code
	number on a CBBS, but no city or state reference. Simple
	enough to use, just type AREACODE nnn<cr> (where 'nnn' is a
	three digit area code), and in return, you get a geographical
	region by city(s), and state. Sorry if your particular city
	is not represented, and feel free to add it as required...

**	Entries must be in sorted order because binary search is used.
*/

char *areacode[]	= {
"011the International Access Code",
"201Hackensack, Morristown and Newark, New Jersey",
"202Washington, District of Columbia",
"203Bridgeport, New Haven and Stamford, Connecticut,"
"204Manitoba, Canada",
"205Birmingham and Huntsville, Alabama",
"206Seattle and Tacoma, Washington",
"207all regions, Maine",
"208all regions, Idaho",
"209Fresno and Stockton, California",
"210San Antonio, Texas",
"212New York City (Manhattan only), New York",
"213Los Angeles, California",
"214Dallas, Texas",
"215Philadelphia and Quakertown, Pennsylvania",
"216Akron, Cleveland, Massillon and Youngstown, Ohio",
"217Casey and Springfield, Illinois",
"218Duluth, Minnesota",
"219Gary, Hammond, Michigan City and South Bend, Indiana",
"281Houston and suburbs (cellular and pager only), Texas",
"301Silver Spring and Frederick, Maryland",
"302all regions, Delaware",
"303Denver, Colorado",
"304all regions, West Virginia",
"305Fort Lauderdale, Key West and Miami, Florida",
"306Saskatchewan, Canada",
"307all regions, Wyoming",
"308North Platte and Scottsbluff, Nebraska",
"309Peoria, Illinois",
"310Beverly Hills and Long Beach, California",
"312Chicago, Illinois",
"313Detroit and Ann Arbor, Michigan",
"314Saint Louis, Missouri",
"315Syracuse and Utica, New York",
"316Dodge City and Wichita, Kansas",
"317Indianapolis and Kokomo, Indiana",
"318Lake Charles and Shreveport, Louisiana",
"319Dubuque, Iowa",
"334Mobile and Montgomery, Alabama",
"360Bellingham, Olympia and Vancouver, Washington",
"401all regions, Rhode Island",
"402Lincoln and Omaha, Nebraska",
"403Alberta, Canada",
"404Atlanta, Georgia",
"405Oklahoma City, Oklahoma",
"406all regions, Montana",
"407Orlando and West Palm Beach, Florida",
"408San Jose and Sunnyvale, California",
"409Galveston, Texas",
"410Baltimore and Annapolis, Maryland",
"412Pittsburgh, Indiana and Rochester, Pennsylvania",
"413Springfield, Massachusetts",
"414Green Bay, Milwaukee and Racine, Wisconsin",
"415San Francisco, California",
"416Toronto, Ontario, Canada",
"417Joplin and Springfield, Missouri",
"418Quebec, Quebec, Canada",
"419Toledo, Ohio",
"500Personal Number Service/AT&T, other carriers",
"501all regions, Arkansas",
"502Louisville, Paducah and Shelbyville, Kentucky",
"503all regions, Oregon",
"504Baton Rouge and New Orleans, Louisiana",
"505all regions, New Mexico",
"506New Brunswick, Canada",
"507Albert Lea and Rochester, Minnesota",
"508Framingham and New Bedford, Massachusetts",
"509Pullman, Spokane and Walla Walla, Washington",
"510Oakland, California",
"512Austin and Corpus Christi, Texas",
"513Cincinnati and Dayton, Ohio",
"514Montreal, Canada",
"515Des Moines and Mason City, Iowa",
"516Hempstead, New York",
"517Lansing and Saginaw, Michigan",
"518Albany, Greenwich and Schenectady, New York",
"519London, Ontario, Canada",
"520Flagstaff and Tucson, Arizona",
"540future: Fredericksburg, Roanoke and Winchester, Virginia",
"601all regions, Mississippi",
"602Phoenix, Arizona",
"603all regions, New Hampshire",
"604British Columbia, Canada",
"605all regions, South Dakota",
"606Ashland and Winchester, Kentucky",
"607Elmira, Ithaca and Stamford, New York",
"608Beloit and Madison, Wisconsin",
"609Atlantic City, Camden and Trenton, New Jersey",
"610Allentown, Reading and Chester, Pennsylvania",
"612Minneapolis and Saint Paul, Minnesota",
"613Ottawa, Ontario, Canada",
"614Columbus, Marietta and Newark, Ohio",
"615Chattanooga and Nashville, Tennessee",
"616Battle Creek, Cadillac and Grand Rapids, Michigan",
"617Boston, Massachusetts",
"618Alton, Mount Vernon and Centralia, Illinois",
"619San Diego, Palm Springs and the Imperial Valley, California",
"630Chicago and suburbs (cellular and pager only), Illinois",
"700Value Added Special Services, per individual carrier",
"701all regions, North Dakota",
"702all regions, Nevada",
"703Arlington and Manassas, Virginia",
"704Charlotte and Salisbury, North Carolina",
"705North Bay, Ontario, Canada",
"706Augusta, Columbus and Rome, Georgia",
"707Eureka, Napa and Santa Rosa, California",
"708Aurora, Wheaton, Evanston, northeastern Illinois",
"709Newfoundland, Canada",
"712Council Bluffs, Iowa",
"713Houston, Texas",
"714Orange and Anaheim, California",
"715Eau Claire and Wausau, Wisconsin",
"716Buffalo, Niagara Falls and Rochester, New York",
"717Harrisburg, Scranton and Wilkes-Barre, Pennsylvania",
"718New York City (Bronx, Brooklyn, Queens, Staten Island), New York",
"719Colorado Springs, Colorado",
"800In-WATS Toll Free Calling",
"801all regions, Utah",
"802all regions, Vermont",
"803all regions, South Carolina",
"804Charlottesville, Norfolk and Richmond, Virginia",
"805Bakersfield, Ventura and Simi Valley, California",
"806Amarillo, Texas",
"807Thunder Bay, Ontario, Canada",
"808all regions, Hawaii",
"809Bahamas, Bermuda, Puerto Rico, the Virgin Islands, etc.",
"810Flint and Pontiac, Michigan",
"812Evansville, Indiana",
"813Avon Park, Fort Myers and Winter Haven, Florida",
"814Altoona, Erie and Punxsutawney, Pennsylvania",
"815La Salle, Joliet and Rockford, Illinois",
"816Kansas City and Saint Joseph, Missouri",
"817Fort Worth, Temple and Waco, Texas",
"818the suburban area north of Los Angeles, California",
"819Malartic and western Quebec, Canada",
"860future: Hartford, Connecticut",
"900Mass Calling Value Added Information Services",
"901Memphis, Tennessee",
"902Prince Edward Island and Nova Scotia, Canada",
"903Tyler and Texarkana, Texas",
"904Jacksonville, Florida",
"905Hamilton and Niagara Falls, Ontario, Canada",
"906Sault Ste. Marie, Michigan",
"907all regions, Alaska",
"908Elizabeth and New Brunswick, New Jersey",
"909Riverside and San Bernardino, California",
"910Winston-Salem, Greensboro and Fayetteville, North Carolina",
"912Waycross and Savannah, Georgia",
"913Ottawa and Topeka, Kansas",
"914Monroe, Mount Vernon and Poughkeepsie, New York",
"915El Paso, Texas",
"916Sacramento and South Tahoe, California",
"917New York City (cellular and pager only), New York",
"918Muskogee and Tulsa, Oklahoma",
"919Greenville, Raleigh and Williamston, North Carolina",
"941Avon Park, Fort Myers and Winter Haven, Florida",
"954Fort Lauderdale, Key West and Miami (305 overlay), Florida",
"970Fort Collins, Grand Junction and Vail, Colorado",
"972future: overlay on 214 area, Texas"
};

char *where(code)
	char		*code;
{
	register int	i, high, low, mid;
	int		strncmp();

	low = 0; high = sizeof(areacode) / sizeof(areacode[0]);
	while (low <= high)
	{
		mid = (low + high) / 2;
		i = strncmp(code, areacode[mid], 3);
		if (i < 0)
			high = mid - 1;
		else if (i > 0)
			low = mid + 1;
		else
			return (areacode[mid] + 3);
	}
	return ("not a valid area code");
}

area(code)
	char		*code;
{
	char		*where();

	if (!isdigit(code[0]) || !isdigit(code[1]) || !isdigit(code[2])
		|| code[3] != '\0')
		printf("Area code %s is not a valid area code!\n", code);
	else
		printf("Area code %s is %s. \n", code, where(code));
}

main(argc, argv)
	int		argc;
	char		*argv[];
{
	if (argc < 2)
	{
		printf("Usage: areacode nnn nnn ...\n");
		exit(1);
	}

	for (--argc, ++argv; argc > 0; --argc, ++argv)
		area(*argv);
}

