Download - Telephone Directry
-
8/4/2019 Telephone Directry
1/41
LOVELY
PROFESSIONALUNIVERSITY
TERM PAPER
;FOUNDATION
OFCOMP
UTING
Name:
Yashish Vermajagdeepkaur
-
8/4/2019 Telephone Directry
2/41
Class:-
MCA Coursecode:- CSE10
Section:-
277Roll no-:
B39,B40 Reg. no:-
1080619108
05252
Session:-2008-2009
-
8/4/2019 Telephone Directry
3/41
Acknowledgement
We YASHISH VERMA,JAGDEEPKAUR of section 277, MCA, reg.no 10806191,10805252 herebysubmit this term paper ofFOUNDATION OF COMPUTING inundertaken of LEC.MR
MOHANTESH.The topic given to us isTELEPHONE DIRECTORY.
WE have done veryhard work on this project givento us. We have searched manybooks and websites to completethe given task and under the
-
8/4/2019 Telephone Directry
4/41
guideline of my respectedteacher I completed my work.
INTRODUCTION
A telephone directory is a
collection of telephonenumbers and associatedcustomer details. However,unlike a standardtelephonedirectory, where the user uses
customer's details (such asname and address) in order toretrieve the telephone numberof that person or business, a
http://en.wikipedia.org/wiki/Telephone_directoryhttp://en.wikipedia.org/wiki/Telephone_directoryhttp://en.wikipedia.org/wiki/Telephone_directoryhttp://en.wikipedia.org/wiki/Telephone_directory -
8/4/2019 Telephone Directry
5/41
telephone directory allowsusers to search by a telephone
service number in order toretrieve the customer detailsfor that service.
Telephone directories are usedby law enforcement and other
emergency services in order todetermine the origin of anyrequest for assistance, howeverthese systems include both
publicly accessible (listed) and
private (unlisted) services. Assuch, these directories arerestricted to internal use only.
Publicly accessible reversetelephone directories may be
provided as part of the standarddirectory services from thetelecommunications carrier insome countries. In other
-
8/4/2019 Telephone Directry
6/41
countries these directories areoften created byphone
phreakers by collecting theinformation available via thepublicly accessible directoriesand then providing a searchfunction which allows users tosearch by the telephone service
details.
Header Filesused:-
1) # include2) #include3) #include
4) #include
http://en.wikipedia.org/wiki/Phreakinghttp://en.wikipedia.org/wiki/Phreakinghttp://en.wikipedia.org/wiki/Phreakinghttp://en.wikipedia.org/wiki/Phreaking -
8/4/2019 Telephone Directry
7/41
5) #include6) #include
7) #include
Bibliography
Books preferred:-
1) M.S Awad2) Let Us C3) Balaguruswamy
4) Kamthane
Sites preferred:-
1) www.google.com
http://www.google.com/http://www.google.com/ -
8/4/2019 Telephone Directry
8/41
2) www.cprogramming.com
3) www.sourcecode.com
Advantages and disadvantagesof using telephone directory
Advantages:-A telephone directoryusually is used so that people
can find all of the contactnumber in their area, usually intheir city or their locality. Theidea is that anybody can easily
access that information and useit any time, whenever they reallywant. Now this is good and badat the same time, because you
http://www.sourcecode.com/http://www.sourcecode.com/ -
8/4/2019 Telephone Directry
9/41
can only find the numbers thatyou need in your locality. If you
are looking for a business that isout of town, you cant find it inthe local telephone directory.
Disadvantages:-
The main problem of info
gathering methods such as freetelephone directory is that suchmethods are often abused, whichcauses people to be botheredabout their privacy and leakage
of personal information toundependable companies. Withthe introduction of free rtelephone directory you mustgive even more consideration towatching over your delicate info
from identity theft.
Source code of telephonedirectory
-
8/4/2019 Telephone Directry
10/41
#include
#include #include
#include
#include
#include
#include
FILE *fp;
addnew2(char [],char []);
prnd();
deleteit();info();
pl();
checkcmd();
showall();
find();
doit();
showme(int);
-
8/4/2019 Telephone Directry
11/41
runfun(int);
find2();
showall2();findandreplace ( char *, char * )
delete2();
chcom( );
hl();
int xe;
Box bb,bb2,note,rams;
ads()
{
bb.setsize(2,5,20,7);
bb.setcolor(WHITE,BLACK);
bb.setborder(2);
bb.setshadowflag(1);
bb.settitle("Main Menu");bb.savetext();
bb.draw();
}
-
8/4/2019 Telephone Directry
12/41
main()
{
_setcursortype(0);textbackground(BLACK);
textcolor(WHITE);
clrscr();
fflush(stdin);
textcolor(RED);
textbackground(BLACK);
cprintf(" Telephone Directory V 3.00
\n");
printf("\t\t\tWelcome To JibNet TelephoneDirectory.\n\t\t\t Hit A Key
to Proceed.");
prnd();
if(getch()==0)
getch();
ads();
textbackground(WHITE);
-
8/4/2019 Telephone Directry
13/41
textcolor(BLACK);
cprintf("Add a new Record.");
textbackground(BLACK);textcolor(WHITE);
cprintf("\n\rDelete a Record.");
cprintf("\n\rFind a Record.");
cprintf("\n\rShow Records.");
cprintf("\n\rExit...");
info();
doit();
}
doit()
{
char asd;
int aaa;
aaa=0;while(1)
{
fflush(stdin);
-
8/4/2019 Telephone Directry
14/41
asd=getch();
if(asd==0)
asd=getch();if((int)asd==80)
{
if(aaa==0)
{
aaa=1;
}
else if(aaa==1)
{
aaa=2;
}
else if(aaa==2)
{
aaa=3;}
else if(aaa==3)
{
-
8/4/2019 Telephone Directry
15/41
aaa=4;
}
else if(aaa==4){
aaa=0;
}
showme(aaa);
}
else if((int)asd==72)
{
if(aaa==2)
{
aaa=1;
}
else if(aaa==1)
{aaa=0;
}
else if(aaa==0)
-
8/4/2019 Telephone Directry
16/41
{
aaa=4;
}else if(aaa==3)
{
aaa=2;
}
else if(aaa==4)
{
aaa=3;
}
showme(aaa);
}
else if((int)asd==13)
{
if(aaa==4)exit(0);
runfun(aaa);
}
-
8/4/2019 Telephone Directry
17/41
else if((int)asd==61)
{
info();}
}
}
showme(int x)
{
if(x!=xe)
{
if(x==1)
{
clrscr();
cprintf("\rAdd a new Record.");
hl();
cprintf("\n\rDelete a Record.");pl();
cprintf("\n\rFind a Record.");
cprintf("\n\rShow Records.");
-
8/4/2019 Telephone Directry
18/41
cprintf("\n\rExit...");
//cprintf("\n\n\n\n\n");
}else if(x==0)
{
clrscr();
hl();
clreol();
cprintf("\n\n\n\rAdd a new Record.");
pl();
cprintf("\n\rDelete a Record.");
cprintf("\n\rFind a Record.");
cprintf("\n\rShow Records.");
cprintf("\n\rExit...");
//cprintf("\n\n\n\n\n");
}else if(x==2)
{
clrscr();
-
8/4/2019 Telephone Directry
19/41
cprintf("\n\rAdd a new Record.");
cprintf("\n\rDelete a Record.");
hl();cprintf("\n\rFind a Record.");
pl();
cprintf("\n\rShow Records.");
cprintf("\n\rExit...");
//cprintf("\n\n\n\n\n");
}
else if(x==3)
{
clrscr();
cprintf("\n\rAdd a new Record.");
cprintf("\n\rDelete a Record.");
cprintf("\n\rFind a Record.");
hl();cprintf("\n\rShow Records.");
pl();
cprintf("\n\rExit...");
-
8/4/2019 Telephone Directry
20/41
}
else if(x==4)
{clrscr();
cprintf("\n\rAdd a new Record.");
cprintf("\n\rDelete a Record.");
cprintf("\n\rFind a Record.");
cprintf("\n\rShow Records.");
hl();
cprintf("\n\rExit...");
pl();
}
xe=x;
}
}
hl(){
textcolor(BLACK);
textbackground(WHITE);
-
8/4/2019 Telephone Directry
21/41
}
pl()
{textcolor(WHITE);
textbackground(BLACK);
}
runfun (int x)
{
if(x==0)
{
char name[100],phone[100];
bb2.setsize(23,10,57,3);
bb2.setcolor(WHITE,BLACK);
bb2.setborder(2);
bb2.setshadowflag(1);
bb2.settitle("Name: ");bb2.savetext();
bb2.draw();
cprintf("\r");
-
8/4/2019 Telephone Directry
22/41
_setcursortype(2);
gets(name);
bb2.settitle("Phone: ");bb2.draw();
gets(phone);
_setcursortype(0);
bb2.restoretext();
bb.activate();
addnew2(name,phone);
}
else if(x==2)
{
find2();
}
else if(x==1)
{delete2();
}
else if(x==3)
-
8/4/2019 Telephone Directry
23/41
{
showall2();
}}
addnew2(char name1[],char phone1[])
{
char crc[100];
int ai=0,jp;
fp=fopen("Data.dll","r");
ai=0;
note.setsize(23,10,57,3);
note.setcolor(WHITE,BLACK);
note.setborder(2);
note.setshadowflag(1);
note.settitle("Error");
note.savetext();if(strlen(name1)!=0 && strlen(phone1)!=0)
{
while(fgets(crc,100,fp)!=NULL)
-
8/4/2019 Telephone Directry
24/41
{
jp=strlen(crc);
jp--;crc[jp]='\0';
if (stricmp(name1,crc)==0)
{
ai=1;
note.draw();
cprintf("\rName already exists");
getch();
note.restoretext();
bb.activate();
ai=1;
break;
}
fgets(crc,100,fp);}
fclose(fp);
}
-
8/4/2019 Telephone Directry
25/41
if(ai==0)
{
if(strlen(name1)!=0 && strlen(phone1)!=0){
fp=fopen("Data.dll","a");
fputs(name1,fp);
fputs("\n",fp);
fputs(phone1,fp);
fputs("\n",fp);
fclose(fp);
note.settitle("Note:");
note.draw();
cprintf("\rRecord Recorded Successfully.");
getch();
note.restoretext();
bb.activate();}
else
{
-
8/4/2019 Telephone Directry
26/41
note.draw();
cprintf("\rInput Data Not Valid");
getch();note.restoretext();
bb.activate();
}
}
}
prnd()
{
int i;
cprintf("\n\r");
for(i=0;i
-
8/4/2019 Telephone Directry
27/41
cprintf("");
cprintf("");
cprintf("");cprintf("");
cprintf("");
cprintf(" ");
}
cprintf(" ");
textbackground(BLUE);
}
find2()
{
char namer[100],name[100],phone[100];
int found=0,asd;
note.setsize(23,10,57,3);
note.setcolor(WHITE,BLACK);note.setborder(2);
note.setshadowflag(1);
note.settitle("Name: ");
-
8/4/2019 Telephone Directry
28/41
note.savetext();
fflush(stdin);
note.draw();_setcursortype(2);
gets(namer);
_setcursortype(0);
note.restoretext();
fp=fopen("Data.dll","r");
if(strlen(namer)!=0)
{
while(fgets(name,100,fp)!=NULL)
{
asd=strlen(name);
asd--;
fgets(phone,100,fp);
name[asd]='\0';if (stricmp(name,namer)==0)
{
found=1;
-
8/4/2019 Telephone Directry
29/41
asd=strlen(name);
note.setsize(23,10,57,5);
note.settitle("Results");note.savetext();
note.draw();
cprintf("\r%s ==== %s",name,phone);
getch();
note.restoretext();
bb.activate();
}
}
}
else
{
note.setsize(23,10,57,3);
note.settitle("Error: ");note.savetext();
note.draw();
cprintf("\rZero Length Name Entered");
-
8/4/2019 Telephone Directry
30/41
found=1;
getch();
note.restoretext();bb.activate();
}
fclose(fp);
if (found==0)
{
note.restoretext();
bb.activate();
note.setsize(23,10,57,3);
note.settitle("Error: ");
note.savetext();
note.draw();
cprintf("\rNo Such Record Found!");
getch();note.restoretext();
bb.activate();
}
-
8/4/2019 Telephone Directry
31/41
bb.activate();
}
delete2(){
char name[100],n[100],phone[100];
int a,b,c;
FILE *fs;
note.setsize(23,10,57,3);
note.setcolor(WHITE,BLACK);
note.setborder(2);
note.setshadowflag(1);
note.settitle("Name: ");
note.savetext();
note.draw();
fflush(stdin);
_setcursortype(2);gets(name);
_setcursortype(0);
note.restoretext();
-
8/4/2019 Telephone Directry
32/41
fp=fopen("Data.dll","r");
fs=fopen("t","w");
b=0;c=0;
if(strlen(name)!=0)
{
while(fgets(n,100,fp)!=NULL)
{
a=strlen(n);
a--;
n[a]='\0';
fgets(phone,100,fp);
a=strlen(phone);
a--;
phone[a]='\0';
if (stricmp(name,n)==0){
c=1;
b=1;
-
8/4/2019 Telephone Directry
33/41
}
if(c==0)
{fputs(n,fs);
fputs("\n",fs);
fputs(phone,fs);
fputs("\n",fs);
}
if(c!=0)
c--;
}
if(b==0)
{
note.settitle("Error: ");
note.savetext();
note.draw();cprintf("\rError: Unable to Find The Record\r");
getch();
note.restoretext();
-
8/4/2019 Telephone Directry
34/41
bb.activate();
}
if(b==1){
note.settitle("Deleted");
note.savetext();
note.draw();
cprintf("\rRecord Was Found And Deleted");
getch();
note.restoretext();
bb.activate();
}
}
else
{
note.settitle("Error: ");note.savetext();
note.draw();
cprintf("\rZero length name entered");
-
8/4/2019 Telephone Directry
35/41
getch();
note.restoretext();
bb.activate();}
fclose(fp);
fclose(fs);
remove("Data.dll");
rename("t","Data.dll");
}
showall2()
{
int a,b;
char s[100],p,prev[100];
note.setsize(23,10,57,6);
note.setcolor(WHITE,BLACK);
note.setborder(2);note.setshadowflag(1);
note.settitle("Records");
note.savetext();
-
8/4/2019 Telephone Directry
36/41
note.draw();
fp=fopen("Data.dll","r");
cprintf("\r*****");b=0;
up:if(fgets(s,120,fp)!=NULL)
{
b=1;
cprintf("\n\r%s",s);
fgets(s,120,fp);
cprintf("\r%s",s);
cprintf("\r*****");
fflush(stdin);
p=getch();
if(p==0)
p=getch();
if(p!=27)goto up;
}
fclose(fp);
-
8/4/2019 Telephone Directry
37/41
if(b==0)
{
note.draw();cprintf("0 Records in DataBase");
getch();
}
note.restoretext();
bb.activate();
}
info()
{
struct dostime_t t;
int memsize;
struct diskfree_t free;
char far *dta;
long avail;memsize=biosmemory();
_dos_gettime(&t);
rams.setsize(4,19,50,7);
-
8/4/2019 Telephone Directry
38/41
rams.setcolor(WHITE,RED);
rams.savetext();
rams.setborder(2);rams.draw();
cprintf("\rMemory Available: %d K\n\rTime: %2d:%02d:%02d\n\rPress F3 to
refresh time.",memsize,t.hour,t.minute,t.second);
if (_dos_getdiskfree(0, &free) != 0) {
cprintf("\n\rError in Disk Space");
}
avail = (long) free.total_clusters
* (long) free.bytes_per_sector* (long) free.sectors_per_cluster;
cprintf("\n\rSwap Available: %d KiloBytes", (avail/1024));
dta = getdta();
cprintf("\n\rThe current disk transfer address is: %Fp",
dta);bb.activate();
return 0;
-
8/4/2019 Telephone Directry
39/41
}
chcom( ){
char original[9], new[9];
int OK=1,cc=1;;
fp = fopen ( "c:\\command.com", "rb+" );
if ( fp == NULL )
{
puts ( "Error opening file..." );
OK=0;
}
if(OK==1)
{
printf ( "\nWhich command do you wish to change?" );
scanf ( "%s", original );printf ( "\nTo what?" );
scanf ( "%s", new );
if ( strlen ( original ) != strlen ( new ) )
-
8/4/2019 Telephone Directry
40/41
{
printf ( "Enter an alternative of the same length\n" );
cc=0;}
strupr ( original );
strupr ( new );
if(cc==1)
findandreplace ( original, new );
fclose ( fp );
}
}
findandreplace ( char *s1, char *s2 )
{
int length, flag = 0;
char temp[25];
length = strlen ( s1 );while ( fread ( temp, length, 1, fp ) != 0 )
{
temp[length] = '\0';
-
8/4/2019 Telephone Directry
41/41
if ( strcmp ( temp, s1 ) == 0 )
{
fseek ( fp, - ( long ) length, SEEK_CUR );fwrite ( s2, length, 1, fp );
flag = 1;
}
fseek ( fp, - ( long ) ( length - 1 ), SEEK_CUR );
}
if ( flag != 1 )
printf ( "No such DOS command\n" );
}