home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume25 / fsp / part01 / fgetcmd.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-12-12  |  1.2 KB  |  48 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. extern char **glob();
  13.  
  14. main(argc,argv,envp)
  15.     int argc;
  16.     char **argv,**envp;
  17. {
  18.     char **av, *av2[2];
  19.  
  20.     env_client();
  21.  
  22.     while(*++argv)
  23.     {
  24.     if(!(av = glob(*argv))) { av = av2; av2[0] = *argv; av2[1] = 0; }
  25.     while(*av) get_file(*av++);
  26.     }
  27.  
  28.     client_done();
  29.  
  30.     exit(0);
  31. }
  32.  
  33. get_file(path)
  34.     char *path;
  35. {
  36.     char *name, *t2;
  37.     FILE *fp;
  38.  
  39.     for(name = t2 = path; *t2; t2++) if(*t2 == '/') name = t2 + 1;
  40.  
  41.     if(fp = fopen(name,"w"))
  42.     {
  43.     if(util_download(path,fp) == -1) { fclose(fp); unlink(name); }
  44.                     else { fclose(fp);               }
  45.  
  46.     } else fprintf(stderr,"Cannot write %s\n",name);
  47. }
  48.