file transferrer through local network drives when the network is divided in to hubs and shared drive is the only common way to communicate....
language used is c
// Copy.cpp : Defines the entry point for the console application.//#include "stdafx.h"
#include"conio.h"
#include"stdio.h"
#include"dos.h"
#include "stat.h"
#include "fcntl.h"
char buffer[21480];
int send(char *,char *,long);
int reciever(char *,char *,long int,long);
void start();
void intro();
void credits();
int main()//here main strats
{FILE *f1,*f2;
long int bytes;
long double l=0,type;
char source[128],target[128],temp[128],drive[15],v,o;
int res,i,tellb,getb,j,chk;
start();
intro();
clrscr();
strcpy(temp,"c:/891987.psl");
printf("tell your drive name (eg.'n' for n drive)");
strcpy(drive,"n:/psl123.psl");
scanf("%c",&v);
drive[0]=v;
temp[0]=v;
fflush(stdin);
printf("if you are sender press 1\nif you are reciever press 2\n");
i=getch();
if(i=='1')
{ printf("\nEnter Source:");
gets (source);
tellb = open(source,O_RDONLY|O_BINARY);
if (tellb==-1) printf("cannot open source");
while(1)
{
bytes = read(tellb,buffer,20480);
l=l+bytes;
if (bytes > 0);
// write(outhandle,buffer,bytes);
else break;
} close (tellb);
puts(drive);
printf("enter the code below for the sucessful data transfer\n%.0Lf\n",l);
f1=fopen(drive,"w");
while((o=getch())!=13)
{printf("%c",o);
putc(o,f1);
}
putc('z',f1);
fclose(f1);
for(j=0;;j++)
{if(j==1)
printf("\nconnecting...\n");
if ((f1 = fopen(drive, "r+"))!= NULL)
fclose(f1);
else
break;
}
printf("wait....");
res = send(source,temp,20480);}
else if(i=='2')
{
printf("\nEnter Target:");
gets (target);
for(j=0;;j++)
{if(j==1)
printf("connecting...\n");
if ((f1 = fopen(drive, "r+"))== NULL)
{fclose(f1);
continue;}
else
{fclose(f1);
break; }
}
f1 = fopen(drive,"r");
while((o=getc(f1))!='z')
{if(o=='1'||o=='2'||o=='3'||o=='4'||o=='5'||o=='6'||o=='7'||o=='8'||o=='9'||o=='0')
{ printf("%c",o); }
else
printf("\n");}
fclose(f1);
remove(drive);
puts("\nenter below the code stated above for starting the data transfer\n");
puts("please be exact ");
scanf("%Lf",&type); printf("wait....\n");
res = reciever(target,temp,type,20480);
}
else {printf("you must enter a valid choice\nrun the program again");
getch();}
if (res==1)
{ puts("Cannot open source file");
getch();
exit(1); }
if (res==2)
{ puts("\nCannot open target file");
getch();
exit(2); }
if (res==3)
{ puts("\nCannot open temporary file");
getch();
exit(3); }
if(res==0)
printf("\ncompleted sucessfully");
printf("\nto see the credits please enter 'c' else any othe key to exit");
i=getch();
if(i=='c')
credits();
getch();
return 0;}
int send(char *source,char *temp,long bufsize)
{FILE *f1;
long int bytes,i,type;
long double k=0,n=0;
int inhandle,tempo,check;
inhandle = open(source,O_RDONLY|O_BINARY);
if (inhandle==-1)
return 1;
tempo=open(temp,O_APPEND|O_BINARY|O_CREAT,S_IWRITE);
while(1)
{
bytes = read(inhandle,buffer,bufsize);
k=k+bytes;
n=n+bytes;
if (bytes > 0)
{//tempo=open(temp,O_APPEND|O_BINARY|O_CREAT,S_IWRITE);
write(tempo,buffer,bytes);
if(n>=31457280.0)
{printf("\nconnected..\ntransfering...%Lf mbs\n",n/1048576.0);
close(tempo);
delay(100);
for(i=0;;i++)
{if(i==1)
if ((f1 = fopen(temp, "r"))!= NULL)
fclose(f1);
else
break;
if(i==1)
printf("\nconnecting...");
}
n=0;
tempo=open(temp,O_APPEND|O_BINARY|O_CREAT,S_IWRITE);
}}
else{ close(tempo);
close (inhandle);
printf("packet mb recieved=%Lf\n",n/1048576.0);
break; }
}
if(k<1024.0) transfered="%Lf">1024.0)
printf("\ntotal kilo bytes transfered=%Lf",k/1024.0);
if(k/1024.0>=1024.0)
printf("\ntotal mega bytes transfered=%Lf",k/(1024.0*1024.0));
//close(tempo);
return 0;
}
int reciever(char*target,char *temp,long int type,long bufsize)
{
FILE *f1;
long int bytes;
long double k=0,i,n=0;
int outhandle,tempo;
outhandle = open(target,O_APPEND|O_CREAT|O_BINARY,S_IWRITE);
if (outhandle==-1)
{ // close(inhandle);
return 2;}
while(1)
{long int l=0;
for(i=0;;i++)
{
if ((f1 = fopen(temp, "r+"))== NULL)
{fclose(f1);
continue;}
else
{fclose(f1);
break; }
}
bytes=0;
tempo=open(temp,O_RDONLY|O_BINARY);
while(1)
{
bytes=read(tempo,buffer,20480);
k=k+bytes;
n=n+bytes;
if(n<31457280.0)>=type)
{printf("packet mb recieved=%Lf\n",n/1048576.0);
goto end;}
}
printf("connected..\n recieved=%Lf mb\n",n/1048576.0);
n=0;
close(tempo);
remove(temp);
}
end:
if(k==0)
{printf("process timed out please try again\ncheck the temporary folder path you have given");
getch();
exit(4);}
if(k<1024.0&&k>0)
printf("\ntotal bytes recieved=%Lf",k/1024.0);
if(k/1024.0<=1024.0&&k>1024.0)
printf("\ntotal kilo bytes recieved=%Lf",k/1024.0);
if(k/1024.0>=1024.0)
printf("\ntotal mega bytes recieved=%Lf",k/(1024.0*1024.0));
// close (inhandle);
//close(tempo); */
close (outhandle);
remove(temp);
return 0;}
void start()
{int i,j,k,m,y,z,zx,x,mu1,q,mu,sta,ans,g,ink=(-13),ink2=40,temp1;
clrscr();
m=47;
for(mu=0;mu<24;mu++) g="10;" mu1="mu;" ink="ink+1;" ink2="ink2-1;" m="m-1;">0)
gotoxy(23,ink);
else
gotoxy(23,1);
printf(" ###### ######### ");
gotoxy(m,g+2);
printf(" # # # # ");
if(mu1<=13)
gotoxy(mu,mu1);
else
gotoxy(mu,13);
printf(" ###### ###### # ");
gotoxy(m,g+4);
printf(" # # # ");
gotoxy(mu,g+5);
printf(" ############# ###### ");
if(m<37)
gotoxy(m,ink2);
else
gotoxy(47,ink2);
printf(" puneet synctronics ltd. india ");
}
nosound();
printf("\n\t\t\t\tQUARK");
printf("\n\t\t\t version 1.01");
printf("\n\t\t press any key to continue....");
getch();
}
void intro()
{clrscr();
printf("\t\t\t\tplease read this\n\n\n");
printf("This is a program for transfer of files greater than 10 mb \n\nand is very helpful for the interhostel file transfer\n");
printf("I suggest you for transfering files please use small name of \n\nsource for eg.\nif source is c:/document and settings/desktop/google/gtalk_google 123.exe\n");
printf("then I say you first copy the file to a drive to make the file\n\n path shorter then rename the file so that the\n\n file path becomes like c:/google.exe .\n");
printf("If you dont know the extention of the file take the help of \n\nextention finder then you will find the best experience of this program");
printf("\n\n\nso I hope you will enjoy this program \n\nyou can send views ideas and complains at -- quark.beta@gmail.com");
printf("\n\nfor better quality use vlc media player which is supports quark transfered files\nand a suggestion if you want to transfer a full folder full of chunk and the \nchunk is grater than 30 mb then first zip the folder by pressing right click to the folder and going to appropriate options and then send the zipped folder \nhaving extention '.zip'");
printf("\n\t\t press any key to continue....");
getch();
clrscr();
puts("\t\t\t some requirements\n1)At least 60 mb of of free space in you local area shared drive\n2)exact code must be entered when asked\n3)never run the program in hurry follow each step carefully\n4)And please do not use it for the files less than \n 30 mb though it will work for it also but it is point less");
printf("\n\t\t press any key to continue....");
getch();
}
void credits()
{clrscr();
gotoxy(70,1);
{printf("loading");
delay(550);
printf(".");
delay(550);
printf(".");
delay(550);
printf(".");
}
clrscr();
printf("program coded by :\nPuneet singh \nb-6\n6103571\n\ncodes,ideas and valuable assistance by :\nRoopal vegad\nb-10\n6503869\n\n\nMy special thanks to Mr. Manish singh fourth year \nwho helped me to make this program possible");
printf("\nlast but not the least I really thank Paul russel and elf who helped me really\nwhen I needed it most\n\nthank you all.......");
getch();
}
No comments:
Post a Comment