/* * uucp: copy files from one system to another. */ #include #include #include #include #include #if GEMDOS #include #endif #if OS2 #include #endif #include #include char destination[80]; char source[80]; int status; char workto[128]; char *LOGNAME; extern char *itob36(); char *unixfy(); char immediate=0; /* immediately call cico */ char makedir=1; /* make directories during copy */ char notify=0; /* tell someone on dest system when stuff */ /* arrives */ char needtocall=0; /* for -i; set if any uucp command goes off */ /* the system */ char *destperson; char program[] = "uucp"; extern int getopt(); extern char *optarg; extern int optind, optopt; main(argc, argv) char **argv; { register i; if ((LOGNAME=getenv("LOGNAME")) == (char *)0) LOGNAME = "root"; destperson = LOGNAME; argv[0] = program; while (getopt(argc, argv, "CiIfFn:N:") != EOF) switch (optopt) { case 'i': case 'I': immediate = 1; break; case 'f': case 'F': makedir = 0; break; case 'n': case 'N': destperson = optarg; notify=1; break; case 'C': /* copy? Okay... */ break; case '?': badboy: fprintf(stderr, "usage: uucp [-C] [-if] [-nUSER] [system!]from [system!]to\n"); fprintf(stderr, " f1 f2 .. fn system!to\n"); exit(99); } if (optind > argc-2) goto badboy; if (!getcfg()) exit(1); if (getsys(argv[argc-1], destination)) makepath(workto, SPOOL, destination); if (argc-optind == 2) docopy(0, argv[optind], destination, argv[argc-1]); else for (i=optind; i= 0) { fprintf(stderr, "overwrite %s? ", fileto); fflush(stderr); gets(workfrom); if (workfrom[0] == 'y' || workfrom[0] == 'Y') remove(p); else return (status = 7); } fprintf(x, " %3sR %s %s %s -dc\n", itob36(getseq()), unixfy(from), unixfy(p), LOGNAME); } fclose(x); needtocall=1; status = 0; } else { fprintf(stderr, "uucp: cannot open workfile for %s\n", source); status = 5; } } else if (destination[0]) { if (x=fopen(workto, "a")) { unixfy(fileto); zseq = itob36(getseq()); suffix = (todir && fileto[strlen(fileto)-1] != '/') ? "/" : ""; for (c=0,p=glob(from, (void*)0); p; c++,p=glob((char*)0, (void*)0)) { fprintf(x, " %3sS %s %s%s %s -%cc%s D.0 666 %s\n", zseq, fullpathof(unixfy(p)), fileto, suffix, LOGNAME, makedir ? 'd' : 'f', notify ? "n" : "", destperson); needtocall=1; } fclose(x); if (c == 0) { fprintf(stderr, "uucp: no %s\n", from); status = 6; } else status = 0; } else { fprintf(stderr, "uucp: cannot open workfile for %s\n", source); status = 5; } } else { /* local copy */ sprintf(workfrom, "cp %s %s", from, fileto); status = system(workfrom); } return status; } /* docopy */