Telephone Directry (2)

Embed Size (px)

Citation preview

  • 8/4/2019 Telephone Directry (2)

    1/35

    LOVELY SCHOOL

    OFENGINEERING

    FOUNDATIO

    N

    OF

    COMPUTING

    1

  • 8/4/2019 Telephone Directry (2)

    2/35

    TERM

    PAPER:-

    TELEPHONEDIRECTORY

    2

  • 8/4/2019 Telephone Directry (2)

    3/35

    NAME-: HARVINDER KUMAR

    CLASS-: B_TECH-MBA(INT)ECECOURSE CODE:- 159

    SECTION:- 211

    ROLL NO-: 44

    REG NO.-: 10804962

    SESSION:- 2008-2009

    E MAIL ID:- [email protected]

    3

    mailto:[email protected]:[email protected]
  • 8/4/2019 Telephone Directry (2)

    4/35

    Acknowledgement

    I HARVINDER KUMAR of section 211, B-tech MBA, reg.no 10804962hereby submit this term paper of

    FOUNDATION OF COMPUTING inundertaken of MS.HARPREET KAUR.Thetopic given to me is TELEPHONEDIRECTORY.

    I have done very hard work onthis project given to me. I have searched man books and websites to complete my task andunder the guideline of my respected teacher Icompleted my work .

    4

  • 8/4/2019 Telephone Directry (2)

    5/35

    INTRODUCTION

    A telephone directory is a collection of telephone numbersand associated customer details. However, unlike a standardtelephone directory, where the user uses customer's details(such as name and address) in order to retrieve the telephonnumber of that person or business, a telephone directoryallows users to search by a telephone service number in ordto retrieve the customer details for that service.Telephone directories are used by law enforcement and othemergency services in order to determine the origin of anyrequest for assistance, however these systems include both publicly accessible (listed) and private (unlisted) services. Asuch, these directories are restricted to internal use only.

    Publicly accessible reverse telephone directories may be provided as part of the standard directory services from thetelecommunications carrier in some countries. In other countries these directories are often created by phone phreakers by collecting the information available via the publiclyaccessible directories and then providing a search functionwhich allows users to search by the telephone service detail

    5

    http://en.wikipedia.org/wiki/Telephone_directoryhttp://en.wikipedia.org/wiki/Phreakinghttp://en.wikipedia.org/wiki/Telephone_directoryhttp://en.wikipedia.org/wiki/Phreaking
  • 8/4/2019 Telephone Directry (2)

    6/35

    Header Files used:-

    1) # include2) #include3) #include4) #include5) #include

    6) #include7) #include

    6

  • 8/4/2019 Telephone Directry (2)

    7/35

    BibliographyBooks preferred:-

    1) M.S Awad2) Let Us C

    3) Balaguruswamy4) Kamthane

    Sites preferred:-

    1) www.google.com2) www.cprogramming .com

    7

    http://www.google.com/http://www.google.com/
  • 8/4/2019 Telephone Directry (2)

    8/35

    3) www.sourcecode.com

    Advantages and disadvantages of using telephone directory

    Advantages:-

    A telephone directory usually is used so that people can find all of the contact number in their area, usually in thcity or their locality. The idea is that anybody can easily access thatinformation and use it any time, whenever they really want. Now thgood and bad at the same time, because you can only find the numbthat you need in your locality. If you are looking for a business thatout of town, you cant find it in the local telephone directory.

    Disadvantages:-

    The main problem of info gathering methods sucas free telephone directory is that such methods are often abused,which causes people to be bothered about their privacy and leakage

    8

    http://www.sourcecode.com/http://www.sourcecode.com/
  • 8/4/2019 Telephone Directry (2)

    9/35

    personal information to undependable companies. With theintroduction of free r telephone directory you must give even moreconsideration to watching over your delicate info from identity thef

    Source code of telephone directory#include

    #include

    #include

    #include #include

    #include

    #include

    FILE *fp;

    addnew2(char [],char []);

    prnd();

    deleteit();

    info();

    pl();

    checkcmd();

    showall();find();

    doit();

    showme(int);

    9

  • 8/4/2019 Telephone Directry (2)

    10/35

    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();

    }

    main(){

    _setcursortype(0);

    textbackground(BLACK);

    10

  • 8/4/2019 Telephone Directry (2)

    11/35

    textcolor(WHITE);

    clrscr();

    fflush(stdin);

    textcolor(RED);

    textbackground(BLACK);

    cprintf(" Telephone Directory V 3.00

    \n");

    printf("\t\t\tWelcome To JibNet Telephone Directory.\n\t\t\t Hit A Key

    to Proceed."); prnd();

    if(getch()==0)

    getch();

    ads();

    textbackground(WHITE);

    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();

    11

  • 8/4/2019 Telephone Directry (2)

    12/35

    doit();

    }

    doit()

    {

    char asd;

    int aaa;

    aaa=0;

    while(1)

    {fflush(stdin);

    asd=getch();

    if(asd==0)

    asd=getch();

    if((int)asd==80)

    {

    if(aaa==0)

    {

    aaa=1;

    }

    else if(aaa==1){

    aaa=2;

    }

    12

  • 8/4/2019 Telephone Directry (2)

    13/35

    else if(aaa==2)

    {

    aaa=3;

    }

    else if(aaa==3)

    {

    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;

    13

  • 8/4/2019 Telephone Directry (2)

    14/35

    }

    else if(aaa==0)

    {

    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);}

    else if((int)asd==61)

    {

    14

  • 8/4/2019 Telephone Directry (2)

    15/35

    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.");

    cprintf("\n\rExit...");

    //cprintf("\n\n\n\n\n");

    }else if(x==0)

    {

    clrscr();

    15

  • 8/4/2019 Telephone Directry (2)

    16/35

    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();

    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)

    16

  • 8/4/2019 Telephone Directry (2)

    17/35

    {

    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...");}

    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;

    }

    17

  • 8/4/2019 Telephone Directry (2)

    18/35

    }

    hl()

    {

    textcolor(BLACK);

    textbackground(WHITE);

    }

    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();

    18

  • 8/4/2019 Telephone Directry (2)

    19/35

    cprintf("\r");

    _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){

    showall2();

    }

    19

  • 8/4/2019 Telephone Directry (2)

    20/35

    }

    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)

    {

    jp=strlen(crc);

    jp--;

    crc[jp]='\0';if (stricmp(name1,crc)==0)

    {

    ai=1;

    20

  • 8/4/2019 Telephone Directry (2)

    21/35

    note.draw();

    cprintf("\rName already exists");

    getch();

    note.restoretext();

    bb.activate();

    ai=1;

    break;

    }

    fgets(crc,100,fp);}

    fclose(fp);

    }

    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:");

    21

  • 8/4/2019 Telephone Directry (2)

    22/35

    note.draw();

    cprintf("\rRecord Recorded Successfully.");

    getch();

    note.restoretext();

    bb.activate();

    }

    else

    {

    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 (2)

    23/35

    cprintf(" ");

    cprintf(" ");

    cprintf("");

    cprintf("");

    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: ");

    23

  • 8/4/2019 Telephone Directry (2)

    24/35

    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;

    asd=strlen(name);note.setsize(23,10,57,5);

    note.settitle("Results");

    note.savetext();

    24

  • 8/4/2019 Telephone Directry (2)

    25/35

    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");

    found=1;

    getch();

    note.restoretext();

    bb.activate();

    }fclose(fp);

    if (found==0)

    {

    25

  • 8/4/2019 Telephone Directry (2)

    26/35

    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();

    }

    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: ");

    26

  • 8/4/2019 Telephone Directry (2)

    27/35

    note.savetext();

    note.draw();

    fflush(stdin);

    _setcursortype(2);

    gets(name);

    _setcursortype(0);

    note.restoretext();

    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)

    27

  • 8/4/2019 Telephone Directry (2)

    28/35

    {

    c=1;

    b=1;

    }

    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();

    bb.activate();

    28

  • 8/4/2019 Telephone Directry (2)

    29/35

    }

    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");

    getch();

    note.restoretext(); bb.activate();

    }

    fclose(fp);

    29

  • 8/4/2019 Telephone Directry (2)

    30/35

    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();

    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);

    30

  • 8/4/2019 Telephone Directry (2)

    31/35

    cprintf("\r%s",s);

    cprintf("\r*****");

    fflush(stdin);

    p=getch();

    if(p==0)

    p=getch();

    if(p!=27)

    goto up;

    }fclose(fp);

    if(b==0)

    {

    note.draw();

    cprintf("0 Records in DataBase");

    getch();

    }

    note.restoretext();

    bb.activate();

    }

    info(){

    struct dostime_t t;

    int memsize;

    31

  • 8/4/2019 Telephone Directry (2)

    32/35

    struct diskfree_t free;

    char far *dta;

    long avail;

    memsize=biosmemory();

    _dos_gettime(&t);

    rams.setsize(4,19,50,7);

    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;

    32

  • 8/4/2019 Telephone Directry (2)

    33/35

    }

    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 ) )

    { printf ( "Enter an alternative of the same length\n" );

    cc=0;

    }

    33

  • 8/4/2019 Telephone Directry (2)

    34/35

    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';

    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 );

    }

    34

  • 8/4/2019 Telephone Directry (2)

    35/35

    if ( flag != 1 )

    printf ( "No such DOS command\n" );

    }