Category : Databases and related files
Archive   : NYC.ZIP
Filename : NYC.C

 
Output of file : NYC.C contained in archive : NYC.ZIP
/***************************************************************************
* *
* NYC Street Locator v.1.0 *
* Copyright 1988, all rights reserved *
* November 5, 1988 *
* by Tony Tortorelli *
* Compu$erve 71571,3647 *
* *
***************************************************************************/

#include
#include
#include
#ifdef __TURBOC__
#define cls() clrscr()
#else
#include
#define cls() _clearscreen(_GCLEARSCREEN)
#define outport(a,b) outp(a,b)
#define inport(a) inp(a)
#endif
#define ch1 argv[2][0] /* 1st Character of 3rd argument */
#define ch2 argv[2][1] /* 2nd Character of 3rd argument */
#define ch3 argv[2][2] /* 3rd Character of 3rd argument */
#define ch4 argv[3][0] /* 1st Character of 4th argument */
#define ch5 argv[3][1] /* 2nd Character of 4th argument */
#define ch6 argv[4][0] /* 1st Character of 5th argument */
#define address argv[2] /* Avenue Name */
#define issign(c) (((c)=='-'||(c)=='+')?(1):(0))


main(argc,argv)
char *argv[];
int argc;
{
unsigned int number;
int count,result;
char *suffix();

if(argc<2||(argc==2&&(argv[1][0]=='?'||(argv[1][0]=='/'||argv[1][0]=='-')&&argv[1][1]=='?')))
{ /* test for 1st argument */
cls(); /* clear screen */
tone(524,30);
puts(" NYC Street Locator ver 1.0\t\t Copyright 1988, all rights reserved\n\t by Tony Tortorelli\n\n");
puts(" Usage:\n"
"\t a) NYC \"Building Number\" \"Avenue Name\"\n"
"\t to locate the nearest cross street.\n"
"\t (i.e. NYC 101 Second Avenue)\n\n"
"\t b) NYC /s\n"
"\t for a listing of street addresses.\n\n"
"\t Note: Abbreviations are valid (i.e. Se, 2nd, 2, etc.).\n\n\n\n\n\n\n\n\n\n");
exit(0);
}

if(argc==2&&(argv[1][0]=='/'||argv[1][0]=='-')&&(argv[1][1]=='s'||argv[1][1]=='S'))
{
cls(); /* clear screen */
puts("\n\n\n\nÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ\n");
puts("\t\t\tStreet Numbers commence as follows:\n\n"
"\t\tEAST SIDE \t\t\tWEST SIDE\n"
"\tÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ\t\tÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ\n"
"\t 1 at 5th Avenue \t\t 1 at 5th Avenue\n"
"\t101 at Park or 4th Avenue\t\t101 at Ave. of the Americas\n"
"\t201 at 3rd Avenue \t\t201 at 7th Avenue\n"
"\t301 at 2nd Avenue \t\t301 at 8th Avenue\n"
"\t401 at 1st Avenue \t\t401 at 9th Avenue\n"
"\t501 at York or Avenue A \t\t501 at 10th Avenue\n"
"\t601 at Avenue B \t\t601 at 11th Avenue\n");
puts("\nÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ\n");
exit(0);
}

for(count=0;argv[1][count]!='\0';count++) /* test 1st argument */
if(!isdigit(argv[1][count])||issign(argv[1][count]))
{
tone(262,60);
puts("\n *** First argument must be a valid building number ***");
exit(1);
}

if(argc==2) /* test for 2nd argument */
{
tone(262,60);
puts("\n *** Second argument must be a valid avenue ***");
exit(1);
}

for(count=0;argv[1][count]!='\0';count++) /* do not accept input > 9999 */
if(count>3)
{
tone(262,60);
puts("\n *** Building number is too large ***");
exit(1);
}

/*-----Command line arguments have all passed tests----*/


number=atoi(argv[1]); /* convert 1st argument to integer */
result=((number/10)/2); /* define result */
if(isupper(ch1)) /* if 1st character, 2nd arg is upper case */
ch1=_tolower(ch1); /* convert to lower case */
if(isupper(ch2)) /* if 2st character, 2nd arg is upper case */
ch2=_tolower(ch2); /* convert to lower case */
if(argc==4)
{
if(isupper(ch4)) /* if 1st character, 3rd arg is upper case */
ch4=_tolower(ch4); /* convert to lower case */
if(isupper(ch5)) /* if 2st character, 3th arg is upper case */
ch5=_tolower(ch5); /* convert to lower case */
}
if(ch2=='2'||ch2=='3'||ch2=='4'||ch2=='5'||ch2=='6'||ch2=='7'||ch2=='8'||ch2=='9')
{ /* do not accept avenues > 11th in Address */
cls(); /* clear screen */
puts("\n\n\n\n\n\n\n\n\nÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ\n");
goto invalid;
}

cls(); /* clear screen */
puts("\n\n\n\n\n\n\n\n\nÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ\n");


/*---------All conversions are done---------*/


switch(ch1)
{
case 'a':
case 'b':
case 'c':
case 'd':
case '6':
if(argc>=3&&((ch1=='a'&&ch2=='\0')||(ch1=='b'&&ch2=='\0')
||(ch1=='c'&&ch2=='\0')||(ch1=='d'&&ch2=='\0'))
||argc>=4&&((ch4=='a'&&ch5=='\0')||(ch4=='b'&&ch5=='\0')
||(ch4=='c'&&ch5=='\0')||(ch4=='d'&&ch5=='\0')))
{
result=result+3; /* Avenue A,B,C,D */
if(result>14)
goto invalid;
if(argc==4)
{
if((ch4=='a'||ch4=='b'||ch4=='c'||ch4=='d'))
ch1=ch4;
}
if(islower(ch1))
ch1=_toupper(ch1);
printf("\t\t%u Avenue %c is located at Avenue %c and %u%s Street.\n"
,number,ch1,ch1,result,suffix(result));
}
else if(argc>3&&((ch1=='a'&&ch2=='v'&&ch4=='o'&&ch5=='f'))||argc==3&&((ch1=='6'&&ch2=='\0')))
{
result=result-12; /* Avenue of the Americas */
if(result>59)
goto invalid;
if(result<8)
{
printf("\t%u Avenue of the Americas is located below 8th street.\n",number);
break;
}
printf("\t\t%u Avenue of the Americas is located at \n\t\t Avenue of the Americas and %u%s Street.\n"
,number,result,suffix(result));
}
else if(argc>=3&&(ch1=='a'&&ch2=='m'))
{
result=result+59;
if(result>190) /* Amsterdam Avenue */
goto invalid;
if(result<59)
{
printf("\t%u Amsterdam Avenue is located below 59th street.\n",number);
break;
}
printf(" %u Amsterdam Avenue is located at Amsterdam Avenue and %u%s Street.\n"
,number,result,suffix(result));
}
else if(argc>=3&&(ch1=='b'&&ch2=='r'))
{ /* Broadway */
if(number<755)
{
printf("\t\t%u Broadway is located below 8th street.\n",number);
break;
}
else if(number>754&&number<859)
result=result-29;
else if(number>858&&number<959)
result=result-25;
else
result=result-31;
if(result>228)
goto invalid;
printf(" %u Broadway is located at Broadway and %u%s Street.\n"
,number,result,suffix(result));
}
else if(argc>=3&&(ch1=='c'&&ch2=='o'))
{
result=result+59;
if(result>110) /* Columbus Avenue */
goto invalid;
if(result<59)
{
printf("\t%u Columbus Avenue is located below 59th street.\n",number);
break;
}
printf(" %u Columbus Avenue is located at Columbus Avenue and %u%s Street.\n"
,number,result,suffix(result));
}
else if(argc>=3&&(ch1=='c'&&ch2=='e'))
{
result=((number/10)+60); /* define result */
if(result>110) /* Central Park West */
goto invalid;
if(result<59)
{
printf("\t%u Central Park West is located below 59th street.\n",number);
break;
}
printf(" %u Central Park West is located at Central Park West and %u%s Street.\n"
,number,result,suffix(result));
}
else
goto invalid;
break;


case 's':
case '2':
case '7':
if((ch1=='2'||(ch1=='s'&&ch2=='e'&&ch3=='c'))&&!isdigit(argv[2][1]))
{
result=result+3; /* Second Avenue */
if(result>129)
goto invalid;
if(result<4)
{
printf("\t\t%u Second Avenue is located below 4th street.\n",number);
break;
}
printf("\t%u Second Avenue is located at Second Avenue and %u%s Street.\n"
,number,result,suffix(result));
}
else if((ch1=='7'||(ch1=='s'&&ch2=='e'&&ch3=='v'))&&!isdigit(argv[2][1]))
{ /* Seventh Avenue */
if(number<1801)
result=result+12;
else
result=result+20;
if(result>59)
goto invalid;
printf(" %u Seventh Avenue is located at Seventh Avenue and %u%s Street.\n"
,number,result,suffix(result));
}
else
goto invalid;
break;


case 'n':
case '9':
result=result+13; /* Ninth Avenue */
if(result>59)
goto invalid;
printf("\t%u Second Avenue is located at Second Avenue and %u%s Street.\n"
,number,result,suffix(result));
break;


case 'l':
result=result+22; /* Lexington */
if(result>131)
goto invalid;
printf("\t%u Lexington Avenue is located at Lexington Avenue and %u%s Street.\n"
,number,result,suffix(result));
break;


case 'm':
result=result+27; /* Madison */
if(result>138)
goto invalid;
printf("\t%u Madison Avenue is located at Madison Avenue and %u%s Street.\n"
,number,result,suffix(result));
break;


case 'p':
if(argc<=4)
{
result=result+34; /* Park */
if(result>135)
goto invalid;
printf("\t%u Park Avenue is located at Park Avenue and %u%s Street.\n"
,number,result,suffix(result));
}
else if(argc==5&&ch1=='p'&&ch4=='a'&&ch6=='s') /* Park Avenue South */
{
result=result+8;
if(result>31)
goto invalid;
if(result<14)
goto invalid;
printf(" %u Park Avenue South is located at Park Avenue South and %u%s Street.\n"
,number,result,suffix(result));
}
else
goto invalid;
break;


case 'w':
result=result+59; /* West End Avenue */
if(result>107)
goto invalid;
printf("\t%u West End Avenue is located at West End Avenue and %u%s Street.\n"
,number,result,suffix(result));
break;


case 'r': /* Riverside Drive */
if(number<568)
result=((number/10)+73); /* define result */
else
result=((number/10)+78); /* define result */
if(result>122)
goto invalid;
printf(" %u Riverside Drive is located at Riverside Drive and %u%s Street.\n"
,number,result,suffix(result));
break;


case 'e':
case 'f':
case 't':
case '1':
case '3':
case '4':
case '5':
case '8':
if((ch2=='0'||ch2=='e')&&!isdigit(argv[2][2]))
{
result=result+13; /* Tenth Avenue */
if(result>59)
goto invalid;
if(result<14)
{
printf("\t\t%u Tenth Avenue is located below 14th street.\n",number);
break;
}
printf("\t%u Tenth Avenue is located at Tenth Avenue and %u%s Street.\n"
,number,result,suffix(result));
}
else if((ch2=='1'||ch2=='l')&&!isdigit(argv[2][2]))
{
result=result+15; /* Eleventh Avenue */
if(result>59)
goto invalid;
if(result<14)
{
printf("\t\t%u Eleventh Avenue is located below 14th street.\n",number);
break;
}
printf("\t%u Eleventh Avenue is located at Eleventh Avenue and %u%s Street.\n"
,number,result,suffix(result));
}
else if((ch1=='1'||(ch1=='f'&&ch2=='i'&&ch3=='r'))&&!isdigit(argv[2][1]))
{
result=result+3; /* First Avenue */
if(result>127)
goto invalid;
if(result<4)
{
printf("\t\t%u First Avenue is located below 4th street.\n",number);
break;
}
printf("\t%u First Avenue is located at First Avenue and %u%s Street.\n"
,number,result,suffix(result));
}
else if((ch1=='3'||ch1=='t')&&!isdigit(argv[2][1]))
{
result=result+10; /* Third Avenue */
if(result>130)
goto invalid;
printf("\t%u Third Avenue is located at Third Avenue and %u%s Street.\n"
,number,result,suffix(result));
}
else if((ch1=='4'||(ch1=='f'&&ch2=='o'))&&!isdigit(argv[2][1]))
{
result=result+7; /* Fourth Avenue */
if(result>14)
goto invalid;
if(result<4)
{
printf("\t\t%u Fourth Avenue is located below 4th street.\n",number);
break;
}
printf("\t%u Fourth Avenue is located at Fourth Avenue and %u%s Street.\n"
,number,result,suffix(result));
}
else if((ch1=='5'||(ch1=='f'&&ch2=='i'&&ch3=='f'))&&!isdigit(argv[2][1]))
{ /* Fifth Avenue */
if(number<201)
result=result+13;
else if(number>200&&number<401)
result=result+16;
else if(number>400&&number<601)
result=result+18;
else if(number>600&&number<776)
result=result+20;
else
result=((number/10)-18); /* define result */
if(result>143)
goto invalid;
if(result<4)
{
printf("\t%u Fifth Avenue is located below 4th street.\n",number);
break;
}
printf(" %u Fifth Avenue is located at Fifth Avenue and %u%s Street.\n"
,number,result,suffix(result));
}
else if((ch1=='8'||(ch1=='e'&&ch2=='i'&&ch3=='g'))&&!isdigit(argv[2][1]))
{
result=result+9; /* Eighth Avenue */
if(result>147)
goto invalid;
if(result<4)
{
printf("\t\t%u Eighth Avenue is located below 4th street.\n",number);
break;
}
printf("\t%u Eighth Avenue is located at Eighth Avenue and %u%s Street.\n"
,number,result,suffix(result));
}
else
goto invalid;
break;


default:
goto invalid;

}
puts("\n\nÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ\n\n\n\n\n\n");

exit(0); /* normal termination */




/*-----------------------------Invalid Addresses----------------------------*/


invalid:
{
tone(262,30);
printf("\t\t%u %s Avenue is an invalid address.",number,address);
puts("\n\n\nÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ\n\n\n\n\n\n");
exit(1);
}


} /* Final brace, program ends */



/*--------------------------------Functions---------------------------------*/


/* This function will return the street suffix (st,th,rd) */

char *suffix(result)
int result;
{

if(((result%10>3||result%10==0)&&result>20)||(result>3&&result<21))
return ("th");
else if(result%10==1)
return ("st");
else if(result%10==2)
return ("nd");
else if(result%10==3)
return ("rd");
else
return ("0");
}


/* tone(freq,time) -- makes tone of given frequency,length */

tone(freq,time)
int freq,time;
{
int hibyt, lobyt, port;
long i, count, divisor;
divisor = 1190000L/freq;
lobyt = divisor % 256;
hibyt = divisor / 256;
count = 1230L * time;
outport(67,182);
outport(66,lobyt);
outport(66,hibyt);
port = inport(97);
outport(97,79);
for (i=0; i < count; i++);
outport(97,port);
}


  3 Responses to “Category : Databases and related files
Archive   : NYC.ZIP
Filename : NYC.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/