#include<stdio.h>
#include<dos.h>
#include<string.h>
#include<conio.h>
#define PORT1 0x3f8
void main()
{
int c,ch,choice,i;
char filename[15],filename2[15],buf;
FILE *in,*out;
clrscr();
outportb(PORT1+0,0x03);
outportb(PORT1+1,0);
outportb(PORT1+3,0x03);
outportb(PORT1+2,0xc7);
outportb(PORT1+4,0x0b);
printf("\n1.sender \n2.receiver\n3.ENTER CHOICE");
scanf("%d",&choice);
if(choice==1)
{
flushall();
scanf("%s",filename);
for(i=0;i<=strlen(filename);i++)
outportb(PORT1,filename[i]);
in=fopen(filename,"rt");
printf("\nsending \n\n");
while(!feof(in))
{
buf=fgetc(in);
printf("%c",buf);
outportb(PORT1,buf);
//delay(10);
}
printf("\nvirus transferred succesfully");
getch();
exit(1);
}
else
{
i=0;
buf='a';
while(buf!=NULL)
{
c=inportb(PORT1+5);
if(c&1)
{
buf=inportb(PORT1);
filename2[i]=buf;
i++;
}
}
out=fopen(filename2,"wt");
printf("\nfilename recieved:%s",filename2);
printf("\nreading from the port");
printf("\nwriting to file %s",filename2);
do
{
c=inportb(PORT1+5);
if(c&1)
{
buf=inportb(PORT1);
printf("%c",buf);
fputc(buf,out);
delay(10);
}
if (kbhit())
{
ch=getch();
}
}while(ch!=27);
}
}
#include<dos.h>
#include<string.h>
#include<conio.h>
#define PORT1 0x3f8
void main()
{
int c,ch,choice,i;
char filename[15],filename2[15],buf;
FILE *in,*out;
clrscr();
outportb(PORT1+0,0x03);
outportb(PORT1+1,0);
outportb(PORT1+3,0x03);
outportb(PORT1+2,0xc7);
outportb(PORT1+4,0x0b);
printf("\n1.sender \n2.receiver\n3.ENTER CHOICE");
scanf("%d",&choice);
if(choice==1)
{
flushall();
scanf("%s",filename);
for(i=0;i<=strlen(filename);i++)
outportb(PORT1,filename[i]);
in=fopen(filename,"rt");
printf("\nsending \n\n");
while(!feof(in))
{
buf=fgetc(in);
printf("%c",buf);
outportb(PORT1,buf);
//delay(10);
}
printf("\nvirus transferred succesfully");
getch();
exit(1);
}
else
{
i=0;
buf='a';
while(buf!=NULL)
{
c=inportb(PORT1+5);
if(c&1)
{
buf=inportb(PORT1);
filename2[i]=buf;
i++;
}
}
out=fopen(filename2,"wt");
printf("\nfilename recieved:%s",filename2);
printf("\nreading from the port");
printf("\nwriting to file %s",filename2);
do
{
c=inportb(PORT1+5);
if(c&1)
{
buf=inportb(PORT1);
printf("%c",buf);
fputc(buf,out);
delay(10);
}
if (kbhit())
{
ch=getch();
}
}while(ch!=27);
}
}
No comments:
Post a Comment