[comp.sources.d] areacode.c

gnu@hoptoad.uucp (John Gilmore) (11/19/86)

In article <22531@rochester.ARPA>, ken@rochester.ARPA (SKY) writes:
> This is a little C program translated from an assembler program in the
> Simtel20 archives. For example, you type "areacode 212" and it tells
> you that code is in NYC.

The database of area codes and cities is useful, though
somewhat inaccurate, but people who haven't noticed should
realize that "grep" makes a great tool for searching it --
you don't need a special program to look up area codes.
(If your system has C but not "grep": there are public
domain grep's around.  Mod.sources has one from James Woods.)
-- 
John Gilmore  {sun,ptsfa,lll-crg,ihnp4}!hoptoad!gnu   jgilmore@lll-crg.arpa
    "I can't think of a better way for the War Dept to spend money than to
  subsidize the education of teenage system hackers by creating the Arpanet."

schwartz@uw-beaver.UUCP (Michael F. Schwartz) (11/20/86)

In article <22531@rochester.ARPA>, ken@rochester.ARPA (SKY) writes:
> This is a little C program translated from an assembler program in the
> Simtel20 archives. For example, you type "areacode 212" and it tells
> you that code is in NYC.

This is a handy program to have, although I prefer to keep just the
data around, and browse it with look(1).  Doing it this way is not
quite as fast as having a program which embodies the data, but it makes
the data easier to update, and it consumes less disk space.

I don't know if look is generally available; it's a binary-search
program available on at least BSD Unix systems.

If you want to try it, define the following alias:

	alias areacode 'look "\!:1 " AreaCodes'

and extract the file in the following shell archive.  (The reason for
matching the space following the number is so that we don't get matches
for partial numbers, e.g., "21" would otherwise match several area codes).

 - Mike Schwartz
   University of Washington Computer Science Department
   ihnp4!uw-beaver!schwartz  (UUCP)
   schwartz@wally.cs.washington.edu (ARPANET)
   schwartz%wally.cs.washington.edu@csnet-relay.arpa  (CSNET)

#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create:
#	AreaCodes
# This archive created: Wed Nov 19 16:10:32 1986
export PATH; PATH=/bin:/usr/bin:$PATH
echo shar: "extracting 'AreaCodes'" '(4917 characters)'
if test -f 'AreaCodes'
then
	echo shar: "will not over-write existing file 'AreaCodes'"
else
sed 's/^	X//' << \SHAR_EOF > 'AreaCodes'
	X011 - the International Access Code
	X170 - Northwest Mexico
	X190 - Mexico City, Mexico
	X201 - Hackensack, Morristown, and Newark, New Jersey
	X202 - Washington, District of Columbia
	X203 - all regions, Connecticut
	X204 - Manitoba, Canada
	X205 - all regions, Alabama
	X206 - Seattle, Tacoma, and Vancouver, Washington
	X207 - all regions, Maine
	X208 - all regions, Idaho
	X209 - Fresno and Stockton, California
	X212 - New York City (Manhattan and Bronx) New York
	X213 - Los Angeles, California
	X214 - Dallas, Texas
	X215 - Allentown, Chester, and Philadelphia, Pennsylvania
	X216 - Akron, Cleveland, Massillon, and Youngstown, Ohio
	X217 - Casey and Springfield, Illinois
	X218 - Duluth, Minnesota
	X219 - Gary, Hammond, Michigan City, and South Bend, Indiana
	X301 - all regions, Maryland
	X302 - all regions, Delaware
	X303 - all regions, Colorado
	X304 - all regions, West Virginia
	X305 - Fort Lauderdale, Key West, Miami and Florida
	X306 - Saskatchewan, Canada
	X307 - all regions, Wyoming
	X308 - North Platte and Scottsbluff, Nebraska
	X309 - Peoria, Illinois
	X312 - Aurora, Chicago, Elgin, and Highland Park, Illinois
	X313 - Detroit, Adrian, and Ann Arbor, Michigan
	X314 - Saint Louis, Missouri
	X315 - Syracuse and Utica, New York
	X316 - Dodge City and Wichita, Kansas
	X317 - Indianapolis and Kokomo, Indiana
	X318 - Lake Charles and Shreveport, Louisiana
	X319 - Dubuque, Iowa
	X401 - all regions, Rhode Island
	X402 - Lincoln and Omaha, Nebraska
	X403 - Alberta, Canada
	X404 - Atlanta and Rome, Georgia
	X405 - Oklahoma City, Oklahoma
	X406 - all regions, Montana
	X408 - San Jose and Sunnyvale, California
	X409 - Galveston, Texas
	X412 - Pittsburgh, Indiana, and Rochester, Pennsylvania
	X413 - Springfield, Massachusetts
	X414 - Green Bay, Milwaukee, and Racine, Wisconsin
	X415 - Oakland and San Francisco, California
	X416 - Toronto and Ontario, Canada
	X417 - Joplin and Springfield, Missouri
	X418 - Quebec, Quebec, Canada
	X419 - Toldeo, Ohio
	X502 - Louisville, Paducah, and Shelbyville, Kentucky
	X503 - all regions, Oregon
	X504 - Baton Rouge and New Orleans, Louisiana
	X505 - all regions, New Mexico
	X506 - New Brunswick, Canada
	X507 - Albert Lea and Rochester, Minnesota
	X509 - Pullman, Spokane, and Walla Walla, Washington
	X512 - Austin, Corpus Christi, and San Antonio, Texas
	X513 - Cincinnati and Dayton, Ohio
	X514 - Montreal, Canada
	X515 - Des Moines and Mason City, Iowa
	X516 - Hempstead, New York
	X517 - Lansing and Saginaw, Michigan
	X518 - Albany, Greenwich, and Schenectady, New York
	X519 - London, Ontario, Canada
	X525 - the Country and City code for Mexico City, Mexico
	X601 - all regions, Mississippi
	X602 - all regions, Arizona
	X603 - all regions, New Hampshire
	X604 - British Columbia, Canada
	X605 - all regions, South Dakota
	X606 - Ashland and Winchester, Kentucky
	X607 - Elmira, Ithaca, and Stamford, New York
	X608 - Beloit and Madison, Wisconsin
	X609 - Atlantic City, Camden, and Trenton, New Jersey
	X612 - Minneapolis and Saint Paul, Minnesota
	X613 - Ottawa, Ontario, Canada
	X614 - Columbus, Marietta, and Newark, Ohio
	X615 - Chattanooga and Nashville, Tennessee
	X616 - Battle Creek, Cadillac, and Grand Rapids, Michigan
	X617 - Boston, Framingham, and New Bedford, Massachusetts
	X618 - Alton, Mount Vernon, and Centralia, Illinois
	X619 - San Diego and the Imperial Valley, California
	X701 - all regions, North Dakota
	X702 - all regions, Nevada
	X703 - Fredericksburg, Roanoke, and Winchester, Virginia
	X704 - Charlotte and Salisbury, North Carolina
	X705 - North Bay, Ontario, Canada
	X707 - Eureka, Napa, and Santa Rosa, California
	X709 - Newfoundland, Canada
	X712 - Council Bluffs, Iowa
	X713 - Houston, Texas
	X714 - Orange and Palm Springs, California
	X715 - Eau Claire and Wausau, Wisconsin
	X716 - Buffalo, Niagara Falls, and Rochester, New York
	X717 - Harrisburg, Scranton, and Wilkes-Barre, Pennsylvania
	X718 - New York City (Queens, Brooklyn and Staten Island) NY
	X801 - all regions, Utah
	X802 - all regions, Vermont
	X803 - all regions, South Carolina
	X804 - Charlottesville, Norfolk, and Richmond, Virginia
	X805 - Bakersfield, Ventura, and Simi Valley, California
	X806 - Amarillo, Texas
	X807 - Thunder Bay, Ontario, Canada
	X808 - all regions, Hawaii
	X809 - Bahamas, Bermuda, Puerto Rico, and the Virgin Islands
	X812 - Evansville, Indiana
	X813 - Avon Park, Fort Myers, and Winter Haven, Florida
	X814 - Altoona, Erie, and Punxsutawney, Pennsylvania
	X815 - La Salle, Joliet, and Rockford, Illinois
	X816 - Kansas City and Saint Joseph, Missouri
	X817 - Fort Worth, Temple, and Waco, Texas
	X818 - the suburban area near Los Angeles, California
	X819 - Malartic and Western Quebec, Canada
	X901 - Memphis, Tennesee
	X902 - Prince Edward Island and Nova Scotia, Canada
	X904 - Jacksonville, Florida
	X906 - Sault Ste. Marie, Michigan
	X907 - All regions, Alaska
	X912 - Waycross and Savannah, Georgia
	X913 - Ottawa and Topeka, Kansas
	X914 - Monroe, Mount Vernon, and Poughkeepsie, New York
	X915 - El Paso, Texas
	X916 - Sacramento and South Tahoe, California
	X918 - Muskogee and Tulsa, Oklahoma
	X919 - Greenville, Raleigh, and Williamston, North Carolina
SHAR_EOF
if test 4917 -ne "`wc -c < 'AreaCodes'`"
then
	echo shar: "error transmitting 'AreaCodes'" '(should have been 4917 characters)'
fi
fi
exit 0
#	End of shell archive

ken@rochester.ARPA (SKY) (11/20/86)

True, but not everybody has Unix. I run my program on a CP/M system
and I suspect there are many who will run theirs on a portable computer.

In any case, extracting the data is trivial for Unixers.

	Ken

scott@cdp.UUCP (11/21/86)

Is the database of cities and area codes in the public domain,
or at least available for non-profit usage?  Also, does
anyone know of a database of either cities or area codes to
time zones?

Thanks.

-scott
{ihnp4,decvax,ucbvax,cbosgd,hao,...}!hplabs!cdp!scott

mikel@codas.ATT.COM (Mikel Manitius) (11/21/86)

In article <22531@rochester.ARPA>, ken@rochester.ARPA (SKY) writes:
> This is a little C program translated from an assembler program in the
> Simtel20 archives. For example, you type "areacode 212" and it tells
> you that code is in NYC.

If you're an AT&T entity registerd with Action Central, a grep
on the Dialcodes file will work just as niceley.
-- 
					Mikel Manitius @ AT&T-IS
					mikel@codas.ATT.COM.UUCP

mikel@codas.ATT.COM (Mikel Manitius) (11/24/86)

The area code for Orlando & area will change from 305 to 407
by 1988, area code 305 will then be only for Miami & southern Florida.
-- 
					Mikel Manitius @ AT&T-IS
					mikel@codas.ATT.COM.UUCP