home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / compsrcs / misc / volume02 / areacode < prev    next >
Encoding:
Internet Message Format  |  1991-08-27  |  9.0 KB

  1. From mipos3!omepd!intelisc!littlei!uunet!husc6!mailrus!ames!necntc!ncoast!allbery Mon Mar 28 19:23:14 PST 1988
  2. Article 331 of comp.sources.misc:
  3. Path: td2cad!mipos3!omepd!intelisc!littlei!uunet!husc6!mailrus!ames!necntc!ncoast!allbery
  4. From: dewey@auscso.UUCP (Dewey Coffman)
  5. Newsgroups: comp.sources.misc
  6. Subject: v02i078: New areacode.c program, new areacodes from phone company
  7. Message-ID: <8803231803.AA23255@auscso.UUCP>
  8. Date: 23 Mar 88 18:03:45 GMT
  9. Sender: allbery@ncoast.UUCP
  10. Reply-To: dewey@auscso.UUCP (Dewey Coffman)
  11. Lines: 259
  12. Approved: allbery@ncoast.UUCP
  13. To: ncoast!allbery@astro.as.utexas.edu
  14. comp.sources.misc: Volume 2, Issue 78
  15. Submitted-By: "Dewey Coffman" <dewey@auscso.UUCP>
  16. Archive-Name: areacode
  17.  
  18. comp.sources.misc: Volume 2, Issue 78
  19. Submitted-By: "Dewey Coffman" <dewey@auscso.UUCP>
  20. Archive-Name: areacode
  21.  
  22.  
  23.     Brandon, here's the update version of a areacode program
  24.     posted from years back. The phone company added to new 
  25.     area codes and this reflects the changes. enclosed is the 
  26.     comments i added to the program and the program.
  27.  
  28.     enjoy.
  29.     Dewey I. Coffman, Jr.
  30.     Austin, Texas.
  31.     UUCP: auscso!dewey, ut-sally!unisec!dewey
  32. #include    <stdio.h>
  33. #include    <ctype.h>
  34.  
  35.     Ver 1.4 added new area code (719) for Colorado Springs, Pueblo 
  36.     Colorado which goes into effect march 5th, 1988. Also added new 
  37.     area code (407) for Orlando, West Palm beach Florida.
  38.     3-23-88, Dewey Coffman, Austin, Texas, auscso!dewey
  39.  
  40.     and finally the source.
  41. --------------------------------------cut-here----nothing on the bottom-----
  42. #include    <stdio.h>
  43. #include    <ctype.h>
  44.  
  45. /*
  46.     areacode.c
  47.     Translated from AREACODE.MAC.
  48.     Ken Yap (ken@rochester.arpa, ..!rochester!ken).
  49.  
  50.     Compile: cc -O -o areacode areacode.c
  51.     Run: areacode nnn nnn ...
  52.  
  53.     Ver 1.4 added new area code (719) for Colorado Springs, Pueblo 
  54.     Colorado which goes into effect march 5th, 1988. Also added new 
  55.     area code (407) for Orlando, West Palm beach Florida.
  56.     3-23-88, Dewey Coffman, Austin, Texas, auscso!dewey
  57.  
  58.  
  59.     AREACODE.MAC Ver 1.3 as of November 20, 1984
  60.  
  61.     Ver. 1.3 added LA suburbs area code 818, added periods to
  62.     messages (why not?), deleted double entry for area code 809,
  63.     removed ungrammatical comma from ASCII string at MSG2: and
  64.     added a space before the `$' in MSG2: so the first space in
  65.     messages could be removed, providing an extra space for text
  66.     without changing the SCAN3: routine's 58-character bias.
  67.     This version provided for M80/L80 devotees courtesy of Irv
  68.     Hoff's XLATE5.COM to prevent undue anxiety trying to find a
  69.     copy of ASM.COM.  It has not been tested, so bug fixes from
  70.     Z80-land are more than welcome. - Bruce Morgen
  71.  
  72.     Ver. 1.2 added 718 area code for New York City, and fixed bug
  73.        in area code 604-804 Harry Kaemmerer
  74.  
  75.     Ver. 1.1 update of area codes for new U.S. areas, Mexico, &
  76.     Eastern Canada. Harvey G. Lord, Storrs, CT 06268
  77.  
  78.     Ver. 1.0 - January 2, 1981 by Kelly Smith
  79.  
  80.     AREACODE is used to display the region and state, specified
  81.     by the user...very handy, when someone leaves a area code
  82.     number on a CBBS, but no city or state reference. Simple
  83.     enough to use, just type AREACODE nnn<cr> (where 'nnn' is a
  84.     three digit area  code), and in return, you get a
  85.     geographical region by city(s), and state. Sorry if your
  86.     particular city is not represented, and feel free to add it
  87.     as required...
  88. */
  89.  
  90. /*
  91. **    These must be in sorted order because binary search is used
  92. */
  93.  
  94. char *areacode[]    = {
  95. "011the International Access Code",
  96. "170Northwest Mexico",
  97. "190Mexico City, Mexico",
  98. "201Hackensack, Morristown, and Newark, New Jersey",
  99. "202Washington, District of Columbia",
  100. "203all regions, Connecticut",
  101. "204Manitoba, Canada",
  102. "205all regions, Alabama",
  103. "206Seattle, Tacoma, and Vancouver, Washington",
  104. "207all regions, Maine",
  105. "208all regions, Idaho",
  106. "209Fresno and Stockton, California",
  107. "212New York City (Manhattan and Bronx) New York",
  108. "213Los Angeles, California",
  109. "214Dallas, Texas",
  110. "215Allentown, Chester, and Philadelphia, Pennsylvania",
  111. "216Akron, Cleveland, Massillon, and Youngstown, Ohio",
  112. "217Casey and Springfield, Illinois",
  113. "218Duluth, Minnesota",
  114. "219Gary, Hammond, Michigan City, and South Bend, Indiana",
  115. "301all regions, Maryland",
  116. "302all regions, Delaware",
  117. "303all regions, Colorado",
  118. "304all regions, West Virginia",
  119. "305Fort Lauderdale, Key West, Miami and Florida",
  120. "306Saskatchewan, Canada",
  121. "307all regions, Wyoming",
  122. "308North Platte and Scottsbluff, Nebraska",
  123. "309Peoria, Illinois",
  124. "312Aurora, Chicago, Elgin, and Highland Park, Illinois",
  125. "313Detroit, Adrian, and Ann Arbor, Michigan",
  126. "314Saint Louis, Columbia, Missouri",
  127. "315Syracuse and Utica, New York",
  128. "316Dodge City and Wichita, Kansas",
  129. "317Indianapolis and Kokomo, Indiana",
  130. "318Lake Charles and Shreveport, Louisiana",
  131. "319Dubuque, Iowa",
  132. "401all regions, Rhode Island",
  133. "402Lincoln and Omaha, Nebraska",
  134. "403Alberta, Canada",
  135. "404Atlanta and Rome, Georgia",
  136. "405Oklahoma City, Oklahoma",
  137. "406all regions, Montana",
  138. "407Orlando, West Palm Beach Florida",
  139. "408San Jose and Sunnyvale, California",
  140. "409Galveston, Texas",
  141. "412Pittsburgh, Indiana, and Rochester, Pennsylvania",
  142. "413Springfield, Massachusetts",
  143. "414Green Bay, Milwaukee, and Racine, Wisconsin",
  144. "415Oakland and San Francisco, California",
  145. "416Toronto and Ontario, Canada",
  146. "417Joplin and Springfield, Missouri",
  147. "418Quebec, Quebec, Canada",
  148. "419Toldeo, Ohio",
  149. "501Arkansas",
  150. "502Louisville, Paducah, and Shelbyville, Kentucky",
  151. "503all regions, Oregon",
  152. "504Baton Rouge and New Orleans, Louisiana",
  153. "505all regions, New Mexico",
  154. "506New Brunswick, Canada",
  155. "507Albert Lea and Rochester, Minnesota",
  156. "509Pullman, Spokane, and Walla Walla, Washington",
  157. "512Austin, Corpus Christi, and San Antonio, Texas",
  158. "513Cincinnati and Dayton, Ohio",
  159. "514Montreal, Canada",
  160. "515Des Moines and Mason City, Iowa",
  161. "516Hempstead, New York",
  162. "517Lansing and Saginaw, Michigan",
  163. "518Albany, Greenwich, and Schenectady, New York",
  164. "519London, Ontario, Canada",
  165. "525the Country and City code for Mexico City, Mexico",
  166. "601all regions, Mississippi",
  167. "602all regions, Arizona",
  168. "603all regions, New Hampshire",
  169. "604British Columbia, Canada",
  170. "605all regions, South Dakota",
  171. "606Ashland and Winchester, Kentucky",
  172. "607Elmira, Ithaca, and Stamford, New York",
  173. "608Beloit and Madison, Wisconsin",
  174. "609Atlantic City, Camden, and Trenton, New Jersey",
  175. "612Minneapolis and Saint Paul, Minnesota",
  176. "613Ottawa, Ontario, Canada",
  177. "614Columbus, Marietta, and Newark, Ohio",
  178. "615Chattanooga and Nashville, Tennessee",
  179. "616Battle Creek, Cadillac, and Grand Rapids, Michigan",
  180. "617Boston, Framingham, and New Bedford, Massachusetts",
  181. "618Alton, Mount Vernon, and Centralia, Illinois",
  182. "619San Diego and the Imperial Valley, California",
  183. "701all regions, North Dakota",
  184. "702all regions, Nevada",
  185. "703Fredericksburg, Roanoke, and Winchester, Virginia",
  186. "704Charlotte and Salisbury, North Carolina",
  187. "705North Bay, Ontario, Canada",
  188. "707Eureka, Napa, and Santa Rosa, California",
  189. "709Newfoundland, Canada",
  190. "712Council Bluffs, Iowa",
  191. "713Houston, Texas",
  192. "714Orange and Palm Springs, California",
  193. "715Eau Claire and Wausau, Wisconsin",
  194. "716Buffalo, Niagara Falls, and Rochester, New York",
  195. "717Harrisburg, Scranton, and Wilkes-Barre, Pennsylvania",
  196. "718New York City (Queens, Brooklyn and Staten Island) NY",
  197. "719Colorado Springs, Pueblo Colorado",
  198. "801all regions, Utah",
  199. "802all regions, Vermont",
  200. "803all regions, South Carolina",
  201. "804Charlottesville, Norfolk, and Richmond, Virginia",
  202. "805Bakersfield, Ventura, and Simi Valley, California",
  203. "806Amarillo, Texas",
  204. "807Thunder Bay, Ontario, Canada",
  205. "808all regions, Hawaii",
  206. "809Bahamas, Bermuda, Puerto Rico, and the Virgin Islands",
  207. "812Evansville, Indiana",
  208. "813Avon Park, Fort Myers, and Winter Haven, Florida",
  209. "814Altoona, Erie, and Punxsutawney, Pennsylvania",
  210. "815La Salle, Joliet, and Rockford, Illinois",
  211. "816Kansas City and Saint Joseph, Missouri",
  212. "817Fort Worth, Temple, and Waco, Texas",
  213. "818the suburban area near Los Angeles, California",
  214. "819Malartic and Western Quebec, Canada",
  215. "901Memphis, Tennesee",
  216. "902Prince Edward Island and Nova Scotia, Canada",
  217. "904Jacksonville, Florida",
  218. "906Sault Ste. Marie, Michigan",
  219. "907all regions, Alaska",
  220. "912Waycross and Savannah, Georgia",
  221. "913Ottawa and Topeka, Kansas",
  222. "914Monroe, Mount Vernon, and Poughkeepsie, New York",
  223. "915El Paso, Texas",
  224. "916Sacramento and South Tahoe, California",
  225. "918Muskogee and Tulsa, Oklahoma",
  226. "919Greenville, Raleigh, and Williamston, North Carolina"
  227. };
  228.  
  229. char *where(code)
  230.     char        *code;
  231. {
  232.     register int    i, high, low, mid;
  233.     int        strncmp();
  234.  
  235.     low = 0; high = sizeof(areacode) / sizeof(areacode[0]) - 1;
  236.     while (low <= high)
  237.     {
  238.         mid = (low + high) / 2;
  239.         i = strncmp(code, areacode[mid], 3);
  240.         if (i < 0)
  241.             high = mid - 1;
  242.         else if (i > 0)
  243.             low = mid + 1;
  244.         else
  245.             return (areacode[mid] + 3);
  246.     }
  247.     return ("not a valid area code");
  248. }
  249.  
  250. area(code)
  251.     char        *code;
  252. {
  253.     char        *where();
  254.  
  255.     if (!isdigit(code[0]) || !isdigit(code[1]) || !isdigit(code[2])
  256.         || code[3] != '\0')
  257.     {
  258.         printf("Area code %s is not a valid area code!\n", code);
  259.         exit(1);
  260.     }
  261.     printf("Area code %s is %s.\n", code, where(code));
  262. }
  263.  
  264. main(argc, argv)
  265.     int        argc;
  266.     char        *argv[];
  267. {
  268.     if (argc < 2)
  269.     {
  270.         printf("Usage: areacode nnn nnn ...\n");
  271.         exit(1);
  272.     }
  273.  
  274.     for (--argc, ++argv; argc > 0; --argc, ++argv)
  275.         area(*argv);
  276. }
  277.  
  278.  
  279.