1: static char sccsid[] = "@(#)receive.c	4.1	(Berkeley)	10/2/82";
   2: 
   3: /*
   4: 	receive.c
   5: 
   6: 	take the file sent by "store.c" and write it locally
   7: */
   8: # include "defs.h"
   9: 
  10: /* global variables */
  11: struct daemonparms netd;
  12: 
  13: main(argc,argv)
  14:   char **argv; {
  15:     FILE *fp;
  16:     char *p, save[40];
  17:     int i, n;
  18:     char buf[BUFSIZ];
  19:     long length;
  20:     debugflg = DBV;
  21:     setupdaemon(argc,argv);
  22:     putchar('!');
  23:     for(;;){
  24:         initseqno();
  25:         while((i = nread(buf,20)) == BROKENREAD);
  26:         if(i != 20){
  27:             printf("Didn't read file name\n");
  28:             exit(EX_USAGE);
  29:             }
  30:         for(p=buf; *p && *p != '\n' && *p != ' '; p++);
  31:         *p = 0;
  32:         printf("Creating file %s ",buf);
  33:         fp = fopen(buf,"w");
  34:         if(fp == NULL){
  35:             fp = fopen(buf,"w");
  36:             exit(EX_OSFILE);
  37:             }
  38:         strcpy(save,buf);
  39:         while((i = nread(buf,10)) == BROKENREAD);
  40:         if(i != 10){
  41:             printf("Didn't read length right\n");
  42:             exit(EX_SOFTWARE);
  43:             }
  44:         length = atol(buf+1);
  45:         printf("length %ld\n",length);
  46:         while(length > 0){
  47:             i = min(length,512);
  48:             while((n = nread(buf,i)) == BROKENREAD);
  49:             length -= n;
  50:             fwrite(buf,1,n,fp);
  51:             }
  52:         fclose(fp);
  53:         printf("Finished file %s\n",save);
  54:         }
  55:     }

Defined functions

main defined in line 13; never used

Defined variables

netd defined in line 11; never used
sccsid defined in line 1; never used
Last modified: 1982-10-03
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1097
Valid CSS Valid XHTML 1.0 Strict