xref: /csrg-svn/old/berknet/store.c (revision 8287)
1*8287Scomay static char sccsid[] = "@(#)store.c	4.1	(Berkeley)	10/02/82";
2*8287Scomay 
3*8287Scomay /*
4*8287Scomay 	store.c
5*8287Scomay 
6*8287Scomay 	send a file to the program "receive.c"
7*8287Scomay */
8*8287Scomay # include "defs.h"
main(argc,argv)9*8287Scomay main(argc,argv)
10*8287Scomay   char **argv; {
11*8287Scomay 	FILE *fp;
12*8287Scomay 	int buf[BUFSIZ], n;
13*8287Scomay 	long work;
14*8287Scomay 	char str[50];
15*8287Scomay 	char ifile[20],ofile[20];
16*8287Scomay 	struct stat statbuf;
17*8287Scomay 
18*8287Scomay 	printf("from file: ");
19*8287Scomay 	fflush(stdout);
20*8287Scomay 	gets(ifile,stdout);
21*8287Scomay 	printf("to file: ");
22*8287Scomay 	fflush(stdout);
23*8287Scomay 	gets(ofile,stdout);
24*8287Scomay 	fp = fopen(ifile,"r");
25*8287Scomay 	if(fp == NULL){
26*8287Scomay 		perror(ifile);
27*8287Scomay 		exit(1);
28*8287Scomay 		}
29*8287Scomay 	debugflg = 1;
30*8287Scomay 	setupdaemon(argc,argv);
31*8287Scomay 	strcpy(str,ofile);
32*8287Scomay 	initseqno();
33*8287Scomay 	strcat(str,"                             ");
34*8287Scomay 	xwrite(str,20);
35*8287Scomay 	if(stat(ifile,&statbuf) < 0){
36*8287Scomay 		perror(ifile);
37*8287Scomay 		exit(1);
38*8287Scomay 		}
39*8287Scomay 	work = getsize(&statbuf);
40*8287Scomay 	sprintf(buf, "|%08ld|", work);
41*8287Scomay 	xwrite(buf,10);
42*8287Scomay 	while((n = fread(buf,1,BUFSIZ,fp)) > 0)
43*8287Scomay 		xwrite(buf,n);
44*8287Scomay 	fclose(fp);
45*8287Scomay 	}
46