home *** CD-ROM | disk | FTP | other *** search
- /*********************************************************************\
- * Copyright (c) 1991 by Wen-King Su (wen-king@vlsi.cs.caltech.edu) *
- * *
- * You may copy or modify this file in any manner you wish, provided *
- * that this notice is always included, and that you hold the author *
- * harmless for any loss or damage resulting from the installation or *
- * use of this software. *
- \*********************************************************************/
-
- #include "client_def.h"
-
- extern char **glob();
-
- static grab_file(path)
- char *path;
- {
- char *name, *t2;
- FILE *fp;
-
- for(name = t2 = path; *t2; t2++) if(*t2 == '/') name = t2 + 1;
-
- if(fp = fopen(name,"w"))
- {
- if(util_grab_file(path,fp) == -1) { fclose(fp); unlink(name); }
- else { fclose(fp); }
-
- } else fprintf(stderr,"Cannot write %s\n",name);
- }
-
- main(argc,argv,envp)
- int argc;
- char **argv,**envp;
- {
- char **av, *av2[2], n[1024];
- int prompt;
-
- env_client();
-
- if(argc > 1)
- {
- while(*++argv)
- {
- if(!(av = glob(*argv))) { av = av2; av2[0] = *argv; av2[1] = 0; }
- while(*av) grab_file(*av++);
- }
- } else
- {
- prompt = isatty(0);
-
- while(1)
- {
- if(prompt) { fputs("fgrab: ",stdout); fflush(stdout); }
- if(!gets(n)) break;
- if(!*n) continue;
- if(!(av = glob(n))) { av = av2; av2[0] = n; av2[1] = 0; }
- while(*av) grab_file(*av++);
- }
- }
-
- client_done();
-
- exit(0);
- }
-