home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume25 / fsp / part01 / fput.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-12-12  |  1.2 KB  |  43 lines

  1.     /*********************************************************************\
  2.     *  Copyright (c) 1991 by Wen-King Su (wen-king@vlsi.cs.caltech.edu)   *
  3.     *                                                                     *
  4.     *  You may copy or modify this file in any manner you wish, provided  *
  5.     *  that this notice is always included, and that you hold the author  *
  6.     *  harmless for any loss or damage resulting from the installation or *
  7.     *  use of this software.                                              *
  8.     \*********************************************************************/
  9.  
  10. #include "client_def.h"
  11.  
  12. main(argc,argv,envp)
  13.     int argc;
  14.     char **argv,**envp;
  15. {
  16.     env_client();
  17.     while(*++argv) put_file(*argv);
  18.     client_done();
  19.  
  20.     exit(0);
  21. }
  22.  
  23. put_file(path)
  24.     char *path;
  25. {
  26.     struct stat sb;
  27.     char *name, *t2;
  28.     FILE *fp;
  29.  
  30.     if(stat(path,&sb) != 0) { perror(path); return; }
  31.     if(!(S_IFREG & sb.st_mode)) { fprintf(stderr,"%s: not a file\n",path);
  32.                 return; }
  33.  
  34.     for(name = t2 = path; *t2; t2++) if(*t2 == '/') name = t2 + 1;
  35.  
  36.     if(fp = fopen(path,"r"))
  37.     {
  38.     util_upload(name,fp);
  39.     fclose(fp);
  40.  
  41.     } else fprintf(stderr,"Cannot read %s\n",path);
  42. }
  43.