home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 11 Util
/
11-Util.zip
/
OS2UTIL.ZIP
/
AC.C
next >
Wrap
Text File
|
1990-05-21
|
15KB
|
456 lines
#include <io.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int get_ac(char *ac);
int search(int i, char *ac);
int get_state(char *state);
int main(int argc, char **argv);
struct AREA_CODE
{
char *zip;
char *state;
char *loc[15];
};
struct AREA_CODE ac_tag[56];
main(argc, argv)
int argc;
char **argv;
{
register i;
int ac;
ac_tag[0].zip = strdup("AL");
ac_tag[0].state = strdup("Alabama");
ac_tag[0].loc[0] = strdup("205 All locations");
ac_tag[1].zip = strdup("AK");
ac_tag[1].state = strdup("Alaska");
ac_tag[1].loc[0] = strdup("907 All locations");
ac_tag[2].zip = strdup("AZ");
ac_tag[2].state = strdup("Arizona");
ac_tag[2].loc[0] = strdup("602 All locations");
ac_tag[3].zip = strdup("AR");
ac_tag[3].state = strdup("Arkansas");
ac_tag[3].loc[0] = strdup("501 All locations");
ac_tag[4].zip = strdup("CA");
ac_tag[4].state = strdup("California");
ac_tag[4].loc[0] = strdup("209 Fresno");
ac_tag[4].loc[1] = strdup("213 Los Angeles");
ac_tag[4].loc[2] = strdup("408 San Jose");
ac_tag[4].loc[3] = strdup("415 San Francisco");
ac_tag[4].loc[4] = strdup("510 Oakland");
ac_tag[4].loc[5] = strdup("619 San Diego");
ac_tag[4].loc[6] = strdup("707 Santa Rosa");
ac_tag[4].loc[7] = strdup("714 Orange");
ac_tag[4].loc[8] = strdup("805 Bakersfield");
ac_tag[4].loc[9] = strdup("818 Pasedena");
ac_tag[4].loc[10] = strdup("916 Sacramento");
ac_tag[5].zip = strdup("CN");
ac_tag[5].state = strdup("Canada");
ac_tag[5].loc[0] = strdup("204 Manitoba");
ac_tag[5].loc[1] = strdup("306 Saskatchewan");
ac_tag[5].loc[2] = strdup("403 Alberta");
ac_tag[5].loc[3] = strdup("416 Toronto, Ontario");
ac_tag[5].loc[4] = strdup("418 Quebec, Quebec");
ac_tag[5].loc[5] = strdup("506 New Brunswick");
ac_tag[5].loc[6] = strdup("514 Montreal, Quebec");
ac_tag[5].loc[7] = strdup("519 London, Quebec");
ac_tag[5].loc[8] = strdup("604 British Columbia");
ac_tag[5].loc[9] = strdup("613 Ottawa, Ontario");
ac_tag[5].loc[10] = strdup("705 North Bay, Ontario");
ac_tag[5].loc[11] = strdup("709 Newfoundland");
ac_tag[5].loc[12] = strdup("807 Thunder Bay, Ontario");
ac_tag[5].loc[13] = strdup("819 Sherbrooke, Quebec");
ac_tag[5].loc[14] = strdup("902 Novia Scotia, Prince Edward Island");
ac_tag[6].zip = strdup("CO");
ac_tag[6].state = strdup("Colorado");
ac_tag[6].loc[0] = strdup("303 Denver");
ac_tag[6].loc[1] = strdup("719 Colorado Springs");
ac_tag[7].zip = strdup("CT");
ac_tag[7].state = strdup("Connecticut");
ac_tag[7].loc[0] = strdup("203 All locations");
ac_tag[8].zip = strdup("DE");
ac_tag[8].state = strdup("Deleware");
ac_tag[8].loc[0] = strdup("302 All locations");
ac_tag[9].zip = strdup("DC");
ac_tag[9].state = strdup("District of Columbia");
ac_tag[9].loc[0] = strdup("202 Washington");
ac_tag[10].zip = strdup("FL");
ac_tag[10].state = strdup("Florida");
ac_tag[10].loc[0] = strdup("305 Miami");
ac_tag[10].loc[1] = strdup("407 Ontario");
ac_tag[10].loc[2] = strdup("813 Fort Meyers");
ac_tag[10].loc[3] = strdup("904 Jacksonville");
ac_tag[11].zip = strdup("GA");
ac_tag[11].state = strdup("Georgia");
ac_tag[11].loc[0] = strdup("404 Atlanta");
ac_tag[11].loc[1] = strdup("912 Savannah");
ac_tag[12].zip = strdup("HI");
ac_tag[12].state = strdup("Hawaii");
ac_tag[12].loc[0] = strdup("808 All locations");
ac_tag[13].zip = strdup("ID");
ac_tag[13].state = strdup("Idaho");
ac_tag[13].loc[0] = strdup("208 All locations");
ac_tag[14].zip = strdup("IL");
ac_tag[14].state = strdup("Illinois");
ac_tag[14].loc[0] = strdup("217 Springfield");
ac_tag[14].loc[1] = strdup("309 Peoria");
ac_tag[14].loc[2] = strdup("312 Chicago");
ac_tag[14].loc[3] = strdup("618 Centralia");
ac_tag[14].loc[4] = strdup("815 Rockford");
ac_tag[15].zip = strdup("IN");
ac_tag[15].state = strdup("Indiana");
ac_tag[15].loc[0] = strdup("219 South Bend");
ac_tag[15].loc[1] = strdup("317 Indianapolis");
ac_tag[15].loc[2] = strdup("812 Evansville");
ac_tag[16].zip = strdup("IA");
ac_tag[16].state = strdup("Iowa");
ac_tag[16].loc[0] = strdup("319 Dubuque");
ac_tag[16].loc[1] = strdup("515 Des Moines");
ac_tag[16].loc[2] = strdup("712 Council Bluffs");
ac_tag[17].zip = strdup("KS");
ac_tag[17].state = strdup("Kansas");
ac_tag[17].loc[0] = strdup("316 Wichita");
ac_tag[17].loc[1] = strdup("913 Topeka");
ac_tag[18].zip = strdup("KY");
ac_tag[18].state = strdup("Kentucky");
ac_tag[18].loc[0] = strdup("502 Louisville");
ac_tag[18].loc[1] = strdup("606 Winchester");
ac_tag[19].zip = strdup("LA");
ac_tag[19].state = strdup("Louisiana");
ac_tag[19].loc[0] = strdup("318 Shreveport");
ac_tag[19].loc[1] = strdup("504 New Orleans");
ac_tag[20].zip = strdup("ME");
ac_tag[20].state = strdup("Maine");
ac_tag[20].loc[0] = strdup("207 All locations");
ac_tag[21].zip = strdup("MD");
ac_tag[21].state = strdup("Maryland");
ac_tag[21].loc[0] = strdup("301 All locations");
ac_tag[22].zip = strdup("MA");
ac_tag[22].state = strdup("Massachusetts");
ac_tag[22].loc[0] = strdup("413 Springfield");
ac_tag[22].loc[1] = strdup("508 Eastern Massachusetts");
ac_tag[22].loc[2] = strdup("617 Boston");
ac_tag[23].zip = strdup("MX");
ac_tag[23].state = strdup("Mexico");
ac_tag[23].loc[0] = strdup("706 Northwest Mexico");
ac_tag[23].loc[1] = strdup("903 Northwest Mexico");
ac_tag[23].loc[2] = strdup("905 Mexico City");
ac_tag[24].zip = strdup("MI");
ac_tag[24].state = strdup("Michigan");
ac_tag[24].loc[0] = strdup("313 Detroit");
ac_tag[24].loc[1] = strdup("517 Lansing");
ac_tag[24].loc[2] = strdup("616 Grand Rapids");
ac_tag[24].loc[3] = strdup("906 Escanaba");
ac_tag[25].zip = strdup("MN");
ac_tag[25].state = strdup("Minnesota");
ac_tag[25].loc[0] = strdup("218 Duluth");
ac_tag[25].loc[1] = strdup("507 Rochester");
ac_tag[25].loc[2] = strdup("612 Minneapolis");
ac_tag[26].zip = strdup("MS");
ac_tag[26].state = strdup("Mississippi");
ac_tag[26].loc[0] = strdup("601 All locations");
ac_tag[27].zip = strdup("MO");
ac_tag[27].state = strdup("Missouri");
ac_tag[27].loc[0] = strdup("314 St. Louis");
ac_tag[27].loc[1] = strdup("417 Springfield");
ac_tag[27].loc[2] = strdup("816 Kansas City");
ac_tag[28].zip = strdup("MT");
ac_tag[28].state = strdup("Montana");
ac_tag[28].loc[0] = strdup("406 All locations");
ac_tag[29].zip = strdup("NE");
ac_tag[29].state = strdup("Nebraska");
ac_tag[29].loc[0] = strdup("308 North Platte");
ac_tag[29].loc[1] = strdup("402 Omaha");
ac_tag[30].zip = strdup("NV");
ac_tag[30].state = strdup("Nevada");
ac_tag[30].loc[0] = strdup("702 All locations");
ac_tag[31].zip = strdup("NH");
ac_tag[31].state = strdup("New Hampshire");
ac_tag[31].loc[0] = strdup("603 All locations");
ac_tag[32].zip = strdup("NJ");
ac_tag[32].state = strdup("New Jersey");
ac_tag[32].loc[0] = strdup("201 Newark");
ac_tag[32].loc[1] = strdup("609 Trenton");
ac_tag[33].zip = strdup("NM");
ac_tag[33].state = strdup("New Mexico");
ac_tag[33].loc[0] = strdup("505 All locations");
ac_tag[34].zip = strdup("NY");
ac_tag[34].state = strdup("New York");
ac_tag[34].loc[0] = strdup("212 New York City, Manhattan, Bronx");
ac_tag[34].loc[1] = strdup("315 Syracuse");
ac_tag[34].loc[2] = strdup("516 Hempstead");
ac_tag[34].loc[3] = strdup("518 Albany");
ac_tag[34].loc[4] = strdup("607 Binghamton");
ac_tag[34].loc[5] = strdup("716 Buffalo");
ac_tag[34].loc[6] = strdup("718 New York City, Brooklyn, Queens, Statan Island");
ac_tag[34].loc[7] = strdup("914 White Plains");
ac_tag[35].zip = strdup("NC");
ac_tag[35].state = strdup("North Carolina");
ac_tag[35].loc[0] = strdup("704 Charlotte");
ac_tag[35].loc[1] = strdup("919 Raleigh");
ac_tag[36].zip = strdup("ND");
ac_tag[36].state = strdup("North Dakota");
ac_tag[36].loc[0] = strdup("701 All locations");
ac_tag[37].zip = strdup("OH");
ac_tag[37].state = strdup("Ohio");
ac_tag[37].loc[0] = strdup("216 Cleveland");
ac_tag[37].loc[1] = strdup("419 Toledo");
ac_tag[37].loc[2] = strdup("513 Cincinatti");
ac_tag[37].loc[3] = strdup("614 Columbus");
ac_tag[38].zip = strdup("OK");
ac_tag[38].state = strdup("Oklahoma");
ac_tag[38].loc[0] = strdup("405 Oklahoma City");
ac_tag[38].loc[1] = strdup("918 Tulsa");
ac_tag[39].zip = strdup("OR");
ac_tag[39].state = strdup("Oregon");
ac_tag[39].loc[0] = strdup("503 All locations");
ac_tag[40].zip = strdup("PA");
ac_tag[40].state = strdup("Pennsylvania");
ac_tag[40].loc[0] = strdup("215 Philadelphia");
ac_tag[40].loc[1] = strdup("412 Pittsburgh");
ac_tag[40].loc[2] = strdup("717 Harrisburg");
ac_tag[40].loc[3] = strdup("814 Altoona");
ac_tag[41].zip = strdup("PR");
ac_tag[41].state = strdup("Puerto Rico");
ac_tag[41].loc[0] = strdup("809 Anguilla, Antigua, Bahamas, Barbados, \
Bequia, Bermuda, Cayman Islands, Dominca, Dominican Republic, \
Jamaica, Montserrat, Mustique, Nevis, Palm Island, Puerto Rico, \
St. Kitts, St. Lucia, St. Vincent, Trinidad and Tobabo, \
Union Island, Virgin Islands");
ac_tag[42].zip = strdup("RI");
ac_tag[42].state = strdup("Rhode Island");
ac_tag[42].loc[0] = strdup("401 All locations");
ac_tag[43].zip = strdup("SC");
ac_tag[43].state = strdup("South Carolina");
ac_tag[43].loc[0] = strdup("803 All locations");
ac_tag[44].zip = strdup("SD");
ac_tag[44].state = strdup("South Dakota");
ac_tag[44].loc[0] = strdup("605 All locations");
ac_tag[45].zip = strdup("TN");
ac_tag[45].state = strdup("Tennessee");
ac_tag[45].loc[0] = strdup("615 Nashville");
ac_tag[45].loc[1] = strdup("901 Memphis");
ac_tag[46].zip = strdup("TX");
ac_tag[46].state = strdup("Texas");
ac_tag[46].loc[0] = strdup("214 Dallas");
ac_tag[46].loc[1] = strdup("409 Galveston");
ac_tag[46].loc[2] = strdup("512 San Antonio");
ac_tag[46].loc[3] = strdup("713 Houston");
ac_tag[46].loc[4] = strdup("806 Amarillo");
ac_tag[46].loc[5] = strdup("817 Fort Worth");
ac_tag[46].loc[6] = strdup("915 Sweetwater");
ac_tag[47].zip = strdup(" ");
ac_tag[47].state = strdup("Toll Free");
ac_tag[47].loc[0] = strdup("800 All locations");
ac_tag[48].zip = strdup("UT");
ac_tag[48].state = strdup("Utah");
ac_tag[48].loc[0] = strdup("801 All locations");
ac_tag[49].zip = strdup("VT");
ac_tag[49].state = strdup("Vermont");
ac_tag[49].loc[0] = strdup("802 All locations");
ac_tag[50].zip = strdup("VI");
ac_tag[50].state = strdup("Virgin Islands");
ac_tag[50].loc[0] = strdup("809 Anguilla, Antigua, Bahamas, Barbados, \
Bequia, Bermuda, Cayman Islands, Dominca, Dominican Republic, \
Jamaica, Montserrat, Mustique, Nevis, Palm Island, Puerto Rico, \
St. Kitts, St. Lucia, St. Vincent, Trinidad and Tobabo, \
Union Island, Virgin Islands");
ac_tag[51].zip = strdup("VA");
ac_tag[51].state = strdup("Virginia");
ac_tag[51].loc[0] = strdup("703 Arlington");
ac_tag[51].loc[1] = strdup("804 Richmond");
ac_tag[52].zip = strdup("WA");
ac_tag[52].state = strdup("Washington");
ac_tag[52].loc[0] = strdup("206 Seattle");
ac_tag[52].loc[1] = strdup("509 Spokane");
ac_tag[53].zip = strdup("WV");
ac_tag[53].state = strdup("West Virginia");
ac_tag[53].loc[0] = strdup("304 All locations");
ac_tag[54].zip = strdup("WI");
ac_tag[54].state = strdup("Wisconsin");
ac_tag[54].loc[0] = strdup("414 Milwaukee");
ac_tag[54].loc[1] = strdup("608 Madison");
ac_tag[54].loc[2] = strdup("715 Eau Claire");
ac_tag[55].zip = strdup("WY");
ac_tag[55].state = strdup("Wyoming");
ac_tag[55].loc[0] = strdup("307 All locations");
if (argc == 1)
{
puts("** OS/2 Area Code Finder **");
puts(" (C) Marcusfilm 1990");
puts("\nProgram searches for telephone area codes,");
puts(" syntax: ac xxx [xxx [xxx ... ] ]");
puts(" xxx is an Area Code or State name.");
puts(" Two letter state postal codes like TX for Texas, CA for California");
puts(" can be used, otherwise type the state name.");
puts(" Enter two word state name like this: New*Jersey");
puts(" Enter * for a list of all Area Codes.");
return 0;
}
for (i = 1; i < argc; i++) /* process command line parameters */
{
ac = atoi(argv[i]); /* see if it's an area code or state */
if (ac) /* if not 0 then area code */
get_ac(argv[i]);
else
get_state(argv[i]);
}
return 0;
}
get_ac(ac)
char *ac;
{
register i;
int idx;
for (i = 0; i < 56; i++)
{
if ((idx = search(i, ac)) != -1)
{
printf("\n%s %s area code\n", ac_tag[i].zip, ac_tag[i].state);
printf(" %s.\n", ac_tag[i].loc[idx]);
return 0;
}
}
printf("Area Code %s, not found.\n", ac);
return 1;
}
search(i, ac)
int i;
char *ac;
{
register j;
for (j = 0; j < 15; j++)
{
if (!ac_tag[i].loc[j])
return -1;
if (strstr(ac_tag[i].loc[j], ac))
return j;
}
return -1;
}
get_state(state)
char *state;
{
register i, j, type;
char *strstate, *ast;
int suffix;
type = (strlen(state) == 2); /* zip code abbreviation */
if (*state == '*')
type = 2;
while(ast = strchr(state, '*')) /* remove all asterisks (*) */
*ast = ' ';
for (i = 0; i < 56; i++)
{
switch (type)
{
case 0: strstate = strdup(ac_tag[i].state);
break;
case 1: strstate = strdup(ac_tag[i].zip);
break;
case 2: strstate = strdup(" ");
break;
}
if (strstr(strupr(strstate), strupr(state)))
{
suffix = (ac_tag[i].loc[1]) ? 's' : ' ';
printf("\n%s %s area code%c\n", ac_tag[i].zip, ac_tag[i].state, suffix);
for (j = 0; j < 15; j++)
{
if (!ac_tag[i].loc[j])
if (type == 2)
break;
else
return 0;
printf(" %s.\n", ac_tag[i].loc[j]);
}
if (type < 2)
return 0;
}
}
return (type == 2) ? 0 : printf("State %s, not found.\n", state);
}