113695Ssam #ifndef lint 2*33965Srick static char sccsid[] = "@(#)uux.c 5.8 (Berkeley) 04/05/88"; 313695Ssam #endif 413695Ssam 513695Ssam #include "uucp.h" 633578Srick #include <sys/stat.h> 713695Ssam 813695Ssam #define NOSYSPART 0 913695Ssam #define HASSYSPART 1 1013695Ssam 1125146Sbloom #define LQUOTE '(' 1225146Sbloom #define RQUOTE ')' 1325146Sbloom 1413695Ssam #define APPCMD(d) {\ 1525967Sbloom register char *p; for (p = d; *p != '\0';)\ 1625967Sbloom {*cmdp++ = *p++;\ 1725967Sbloom if(cmdp>(sizeof(cmd)+&cmd[0])){\ 1825967Sbloom fprintf(stderr,"argument list too long\n");\ 1925967Sbloom cleanup(EX_SOFTWARE);\ 2025967Sbloom }\ 2125967Sbloom }\ 2225967Sbloom *cmdp++ = ' '; *cmdp = '\0';} 2313695Ssam 2413695Ssam #define GENSEND(f, a, b, c, d, e) {\ 2525967Sbloom fprintf(f, "S %s %s %s -%s %s 0666\n", a, b, c, d, e); } 2617845Sralph #define GENRCV(f, a, b, c) {fprintf(f, "R %s %s %s - \n", a, b, c);} 2713695Ssam 2825146Sbloom struct timeb Now; 2925146Sbloom 3013695Ssam main(argc, argv) 31*33965Srick int argc; 32*33965Srick char **argv; 3313695Ssam { 3413695Ssam char cfile[NAMESIZE]; /* send commands for files from here */ 3513695Ssam char dfile[NAMESIZE]; /* used for all data files from here */ 3613695Ssam char rxfile[NAMESIZE]; /* to be sent to xqt file (X. ...) */ 3713695Ssam char tfile[NAMESIZE]; /* temporary file name */ 3813695Ssam char tcfile[NAMESIZE]; /* temporary file name */ 3913695Ssam char t2file[NAMESIZE]; /* temporary file name */ 4013695Ssam int cflag = 0; /* commands in C. file flag */ 4113695Ssam int rflag = 0; /* C. files for receiving flag */ 4217845Sralph #ifdef DONTCOPY 4317845Sralph int Copy = 0; /* Don't Copy spool files */ 4417845Sralph #else !DONTCOPY 4513695Ssam int Copy = 1; /* Copy spool files */ 4617845Sralph #endif !DONTCOPY 4717845Sralph int Linkit = 0; /* Try link before copy */ 4825967Sbloom char buf[2*BUFSIZ]; 4925967Sbloom char inargs[2*BUFSIZ]; 5013695Ssam int pipein = 0; 5113695Ssam int startjob = 1; 5213695Ssam char Grade = 'A'; 5333578Srick long Gradedelta = 100000000L; /* "huge number" */ 5433578Srick long size = 0L; 5513695Ssam char path[MAXFULLNAME]; 5625967Sbloom char cmd[2*BUFSIZ]; 5713695Ssam char *ap, *cmdp; 5825967Sbloom char prm[2*BUFSIZ]; 5923691Sbloom char syspart[MAXBASENAME+1], rest[MAXFULLNAME]; 6023691Sbloom char Xsys[MAXBASENAME+1], local[MAXBASENAME+1]; 6118627Sralph char *xsys = Xsys; 6213695Ssam FILE *fprx, *fpc, *fpd, *fp; 6313695Ssam extern char *getprm(), *lastpart(); 6413695Ssam extern FILE *ufopen(); 65*33965Srick int uid, ret, c; 6613695Ssam char redir = '\0'; 6713695Ssam int nonoti = 0; 6813695Ssam int nonzero = 0; 6917845Sralph int link_failed; 7017845Sralph char *ReturnTo = NULL; 7117845Sralph extern int LocalOnly; 72*33965Srick extern char *optarg; 73*33965Srick extern int optind; 7413695Ssam 7513695Ssam strcpy(Progname, "uux"); 7613695Ssam uucpname(Myname); 7713695Ssam umask(WFMASK); 7813695Ssam Ofn = 1; 7913695Ssam Ifn = 0; 8017845Sralph #ifdef VMS 8117845Sralph arg_fix(argc, argv); 8217845Sralph #endif 83*33965Srick while ((c = getopt(argc, argv, "prclCg:x:nzLa:")) != EOF || 84*33965Srick *argv[optind] == '-') 85*33965Srick switch (c) { 86*33965Srick case EOF: 87*33965Srick /* getopt doesn't like "-" as an argument... */ 88*33965Srick optind++; 89*33965Srick /* NO BREAK */ 9013695Ssam case 'p': 9113695Ssam pipein = 1; 9213695Ssam break; 9313695Ssam case 'r': 9413695Ssam startjob = 0; 9513695Ssam break; 9613695Ssam case 'c': 9717845Sralph Copy = 0; 9817845Sralph Linkit = 0; 9917845Sralph break; 10013695Ssam case 'l': 10113695Ssam Copy = 0; 10217845Sralph Linkit = 1; 10313695Ssam break; 10417845Sralph case 'C': 10517845Sralph Copy = 1; 10617845Sralph Linkit = 0; 10717845Sralph break; 10813695Ssam case 'g': 109*33965Srick Grade = *optarg; 110*33965Srick Gradedelta = atol(optarg+1); 11113695Ssam break; 11213695Ssam case 'x': 11317845Sralph chkdebug(); 114*33965Srick Debug = atoi(optarg); 11513695Ssam if (Debug <= 0) 11613695Ssam Debug = 1; 11713695Ssam break; 11813695Ssam case 'n': 11913695Ssam nonoti = 1; 12013695Ssam break; 12113695Ssam case 'z': 12213695Ssam nonzero = 1; 12313695Ssam break; 12417845Sralph case 'L': 12517845Sralph LocalOnly++; 12617845Sralph break; 12717845Sralph case 'a': 128*33965Srick ReturnTo = optarg; 12923691Sbloom if (prefix(Myname, ReturnTo) && ReturnTo[strlen(Myname)] == '!') 13023691Sbloom ReturnTo = index(ReturnTo, '!') + 1; 13117845Sralph break; 132*33965Srick case '?': 13313695Ssam default: 134*33965Srick fprintf(stderr, "unknown flag %s\n", argv[optind-1]); 135*33965Srick break; 13613695Ssam } 137*33965Srick 13825146Sbloom ap = getwd(Wrkdir); 13925146Sbloom if (ap == 0) { 14025146Sbloom fprintf(stderr, "can't get working directory; will try to continue\n"); 14125146Sbloom strcpy(Wrkdir, "/UNKNOWN"); 14217845Sralph } 14313695Ssam 14413695Ssam DEBUG(4, "\n\n** %s **\n", "START"); 14513695Ssam 14613695Ssam inargs[0] = '\0'; 147*33965Srick while (optind < argc) { 148*33965Srick DEBUG(4, "arg - %s:", argv[optind]); 14913695Ssam strcat(inargs, " "); 150*33965Srick strcat(inargs, argv[optind++]); 15113695Ssam } 15213695Ssam DEBUG(4, "arg - %s\n", inargs); 153*33965Srick if (subchdir(Spool) < 0) { 154*33965Srick syslog(LOG_WARNING, "chdir(%s) failed: %m", Spool); 155*33965Srick cleanup(1); 156*33965Srick } 15713695Ssam uid = getuid(); 15833578Srick if (guinfo(uid, User, path) != SUCCESS) { 159*33965Srick syslog(LOG_WARNING, "Can't find username for uid %d", uid); 16033578Srick DEBUG(1, "Using username", "uucp"); 16133578Srick strcpy(User, "uucp"); 16233578Srick } 16313695Ssam 16423691Sbloom strncpy(local, Myname, MAXBASENAME); 16513695Ssam cmdp = cmd; 16613695Ssam *cmdp = '\0'; 16713695Ssam gename(DATAPRE, local, 'X', rxfile); 16813695Ssam fprx = ufopen(rxfile, "w"); 169*33965Srick if (fprx == NULL) { 170*33965Srick syslog(LOG_WARNING, "fopen(%s) failed: %m", rxfile); 171*33965Srick cleanup(1); 172*33965Srick } 17313695Ssam gename(DATAPRE, local, 'T', tcfile); 17413695Ssam fpc = ufopen(tcfile, "w"); 175*33965Srick if (fpc == NULL) { 176*33965Srick syslog(LOG_WARNING, "fopen(%s) failed: %m", tcfile); 177*33965Srick cleanup(1); 178*33965Srick } 17913695Ssam fprintf(fprx, "%c %s %s\n", X_USER, User, local); 18013695Ssam if (nonoti) 18113695Ssam fprintf(fprx, "%c\n", X_NONOTI); 18213695Ssam if (nonzero) 18313695Ssam fprintf(fprx, "%c\n", X_NONZERO); 18417845Sralph if (ReturnTo == NULL || *ReturnTo == '\0') 18517845Sralph ReturnTo = User; 18617845Sralph fprintf(fprx, "%c %s\n", X_RETURNTO, ReturnTo); 18713695Ssam 18813695Ssam /* find remote system name */ 18913695Ssam ap = inargs; 19013695Ssam xsys[0] = '\0'; 19113695Ssam while ((ap = getprm(ap, prm)) != NULL) { 19213695Ssam if (prm[0] == '>' || prm[0] == '<') { 19313695Ssam ap = getprm(ap, prm); 19413695Ssam continue; 19513695Ssam } 19613695Ssam 19713695Ssam split(prm, xsys, rest); 19813695Ssam break; 19913695Ssam } 20013695Ssam if (xsys[0] == '\0') 20113695Ssam strcpy(xsys, local); 20218627Sralph if (versys(&xsys) != 0) { 20313695Ssam /* bad system name */ 20413695Ssam fprintf(stderr, "bad system name: %s\n", xsys); 20513695Ssam fclose(fprx); 20613695Ssam fclose(fpc); 20713695Ssam cleanup(EX_NOHOST); 20813695Ssam } 20913695Ssam 21025146Sbloom strncpy(Rmtname, xsys, MAXBASENAME); 21125146Sbloom DEBUG(4, "xsys %s\n", xsys); 21225146Sbloom 21313695Ssam if (pipein) { 21413695Ssam gename(DATAPRE, local, 'B', dfile); 21513695Ssam fpd = ufopen(dfile, "w"); 216*33965Srick if (fpd == NULL) { 217*33965Srick syslog(LOG_WARNING, "fopen(%s) failed: %m", dfile); 218*33965Srick cleanup(1); 219*33965Srick } 22013695Ssam while (!feof(stdin)) { 22113695Ssam ret = fread(buf, 1, BUFSIZ, stdin); 22213695Ssam fwrite(buf, 1, ret, fpd); 22325967Sbloom if (ferror(stdin)) { 22425967Sbloom perror("stdin"); 22525967Sbloom cleanup(EX_IOERR); 22625967Sbloom } 22725967Sbloom if (ferror(fpd)) { 22825967Sbloom perror(dfile); 22925967Sbloom cleanup(EX_IOERR); 23025967Sbloom } 23133578Srick size += ret; 23213695Ssam } 23313695Ssam fclose(fpd); 23417845Sralph strcpy(tfile, dfile); 23513695Ssam if (strcmp(local, xsys) != SAME) { 23625146Sbloom register int Len = strlen(local); 23725146Sbloom if (Len > SYSNSIZE) 23825146Sbloom Len = SYSNSIZE; 23925146Sbloom tfile[Len + 2] = 'S'; 24017845Sralph GENSEND(fpc, dfile, tfile, User, "", dfile); 24113695Ssam cflag++; 24213695Ssam } 24317845Sralph fprintf(fprx, "%c %s\n", X_RQDFILE, tfile); 24417845Sralph fprintf(fprx, "%c %s\n", X_STDIN, tfile); 24513695Ssam } 24613695Ssam /* parse command */ 24713695Ssam ap = inargs; 24813695Ssam while ((ap = getprm(ap, prm)) != NULL) { 24913695Ssam DEBUG(4, "prm - %s\n", prm); 25013695Ssam if (prm[0] == '>' || prm[0] == '<') { 25113695Ssam redir = prm[0]; 25213695Ssam continue; 25313695Ssam } 25413695Ssam 25513695Ssam if (prm[0] == ';') { 25613695Ssam APPCMD(prm); 25713695Ssam continue; 25813695Ssam } 25913695Ssam 26013695Ssam if (prm[0] == '|' || prm[0] == '^') { 26113695Ssam if (cmdp != cmd) 26213695Ssam APPCMD(prm); 26313695Ssam continue; 26413695Ssam } 26513695Ssam 26613695Ssam /* process command or file or option */ 26713695Ssam ret = split(prm, syspart, rest); 26813695Ssam DEBUG(4, "s - %s, ", syspart); 26913695Ssam DEBUG(4, "r - %s, ", rest); 27013695Ssam DEBUG(4, "ret - %d\n", ret); 27113695Ssam if (syspart[0] == '\0') 27213695Ssam strcpy(syspart, local); 27313695Ssam 27413695Ssam if (cmdp == cmd && redir == '\0') { 27513695Ssam /* command */ 27613695Ssam APPCMD(rest); 27713695Ssam continue; 27813695Ssam } 27913695Ssam 28013695Ssam /* process file or option */ 28113695Ssam DEBUG(4, "file s- %s, ", syspart); 28213695Ssam DEBUG(4, "local - %s\n", local); 28313695Ssam /* process file */ 28413695Ssam if (redir == '>') { 28513695Ssam if (rest[0] != '~') 28613695Ssam if (ckexpf(rest)) 28713695Ssam cleanup(EX_CANTCREAT); 28813695Ssam fprintf(fprx, "%c %s %s\n", X_STDOUT, rest, 28913695Ssam syspart); 29013695Ssam redir = '\0'; 29113695Ssam continue; 29213695Ssam } 29313695Ssam 29413695Ssam if (ret == NOSYSPART && redir == '\0') { 29513695Ssam /* option */ 29613695Ssam APPCMD(rest); 29713695Ssam continue; 29813695Ssam } 29913695Ssam 30033578Srick if (rest[0] != '\0') { 30133578Srick struct stat stbuf; 30233578Srick if (stat(rest, &stbuf) < 0) 30333578Srick DEBUG(4, "Can't stat %s\n", rest); 30433578Srick else 30533578Srick size += stbuf.st_size; 30633578Srick DEBUG(4, "size = %ld\n", size); 30733578Srick } 30833578Srick 30913695Ssam if (strcmp(xsys, local) == SAME 31013695Ssam && strcmp(xsys, syspart) == SAME) { 31113695Ssam if (ckexpf(rest)) 31213695Ssam cleanup(EX_CANTCREAT); 31313695Ssam if (redir == '<') 31413695Ssam fprintf(fprx, "%c %s\n", X_STDIN, rest); 31513695Ssam else 31613695Ssam APPCMD(rest); 31713695Ssam redir = '\0'; 31813695Ssam continue; 31913695Ssam } 32013695Ssam 32113695Ssam if (strcmp(syspart, local) == SAME) { 32213695Ssam /* generate send file */ 32313695Ssam if (ckexpf(rest)) 32413695Ssam cleanup(EX_CANTCREAT); 32513695Ssam gename(DATAPRE, local, 'A', dfile); 32613695Ssam DEBUG(4, "rest %s\n", rest); 32713695Ssam if ((chkpth(User, "", rest) || anyread(rest)) != 0) { 32813695Ssam fprintf(stderr, "permission denied %s\n", rest); 32913695Ssam cleanup(EX_NOINPUT); 33013695Ssam } 33117845Sralph link_failed = 0; 33217845Sralph if (Linkit) { 33317845Sralph if (link(subfile(rest), subfile(dfile)) != 0) 33417845Sralph link_failed++; 33517845Sralph else 33617845Sralph GENSEND(fpc, rest, dfile, User, "", dfile); 33717845Sralph } 33817845Sralph if (Copy || link_failed) { 33913695Ssam if (xcp(rest, dfile) != 0) { 34013695Ssam fprintf(stderr, "can't copy %s to %s\n", rest, dfile); 34113695Ssam cleanup(EX_NOINPUT); 34213695Ssam } 34313695Ssam GENSEND(fpc, rest, dfile, User, "", dfile); 34413695Ssam } 34517845Sralph if (!Copy && !Linkit) { 34613695Ssam GENSEND(fpc, rest, dfile, User, "c", "D.0"); 34713695Ssam } 34813695Ssam cflag++; 34913695Ssam if (redir == '<') { 35013695Ssam fprintf(fprx, "%c %s\n", X_STDIN, dfile); 35113695Ssam fprintf(fprx, "%c %s\n", X_RQDFILE, dfile); 35218627Sralph } else { 35313695Ssam APPCMD(lastpart(rest)); 35413695Ssam fprintf(fprx, "%c %s %s\n", X_RQDFILE, 35513695Ssam dfile, lastpart(rest)); 35613695Ssam } 35713695Ssam redir = '\0'; 35813695Ssam continue; 35913695Ssam } 36013695Ssam 36113695Ssam if (strcmp(local, xsys) == SAME) { 36213695Ssam /* generate local receive */ 36313695Ssam gename(CMDPRE, syspart, 'R', tfile); 36413695Ssam strcpy(dfile, tfile); 36513695Ssam dfile[0] = DATAPRE; 36613695Ssam fp = ufopen(tfile, "w"); 367*33965Srick if (fp == NULL) { 368*33965Srick syslog(LOG_WARNING, "fopen(%s) failed: %m", 369*33965Srick tfile); 370*33965Srick cleanup(1); 371*33965Srick } 37213695Ssam if (ckexpf(rest)) 37313695Ssam cleanup(EX_CANTCREAT); 37413695Ssam GENRCV(fp, rest, dfile, User); 37513695Ssam fclose(fp); 37613695Ssam rflag++; 37713695Ssam if (rest[0] != '~') 37813695Ssam if (ckexpf(rest)) 37913695Ssam cleanup(EX_CANTCREAT); 38013695Ssam if (redir == '<') { 38113695Ssam fprintf(fprx, "%c %s\n", X_RQDFILE, dfile); 38213695Ssam fprintf(fprx, "%c %s\n", X_STDIN, dfile); 38318627Sralph } else { 38413695Ssam fprintf(fprx, "%c %s %s\n", X_RQDFILE, dfile, 38513695Ssam lastpart(rest)); 38613695Ssam APPCMD(lastpart(rest)); 38713695Ssam } 38813695Ssam 38913695Ssam redir = '\0'; 39013695Ssam continue; 39113695Ssam } 39213695Ssam 39313695Ssam if (strcmp(syspart, xsys) != SAME) { 39413695Ssam /* generate remote receives */ 39513695Ssam gename(DATAPRE, syspart, 'R', dfile); 39613695Ssam strcpy(tfile, dfile); 39713695Ssam tfile[0] = CMDPRE; 39813695Ssam fpd = ufopen(dfile, "w"); 399*33965Srick if (fpd == NULL) { 400*33965Srick syslog(LOG_WARNING, "fopen(%s) failed: %m", 401*33965Srick dfile); 402*33965Srick cleanup(1); 403*33965Srick } 40413695Ssam gename(DATAPRE, local, 'T', t2file); 40513695Ssam GENRCV(fpd, rest, t2file, User); 40613695Ssam fclose(fpd); 40713695Ssam GENSEND(fpc, dfile, tfile, User, "", dfile); 40813695Ssam cflag++; 40913695Ssam if (redir == '<') { 41013695Ssam fprintf(fprx, "%c %s\n", X_RQDFILE, t2file); 41113695Ssam fprintf(fprx, "%c %s\n", X_STDIN, t2file); 41218627Sralph } else { 41313695Ssam fprintf(fprx, "%c %s %s\n", X_RQDFILE, t2file, 41413695Ssam lastpart(rest)); 41513695Ssam APPCMD(lastpart(rest)); 41613695Ssam } 41713695Ssam redir = '\0'; 41813695Ssam continue; 41913695Ssam } 42013695Ssam 42113695Ssam /* file on remote system */ 42213695Ssam if (rest[0] != '~') 42313695Ssam if (ckexpf(rest)) 42413695Ssam cleanup(EX_CANTCREAT); 42513695Ssam if (redir == '<') 42613695Ssam fprintf(fprx, "%c %s\n", X_STDIN, rest); 42713695Ssam else 42813695Ssam APPCMD(rest); 42913695Ssam redir = '\0'; 43013695Ssam continue; 43113695Ssam 43213695Ssam } 43317845Sralph /* 43417845Sralph * clean up trailing ' ' in command. 43517845Sralph */ 43617845Sralph if (cmdp > cmd && cmdp[0] == '\0' && cmdp[-1] == ' ') 43717845Sralph *--cmdp = '\0'; 43817845Sralph /* block multi-hop uux, which doesn't work */ 43917845Sralph for (ap = cmd; *ap && *ap != ' '; ap++) 44017845Sralph if (*ap == '!') { 44117845Sralph fprintf(stderr, "uux handles only adjacent sites.\n"); 44217845Sralph fprintf(stderr, "Try uusend for multi-hop delivery.\n"); 44325967Sbloom cleanup(EX_USAGE); 44417845Sralph } 44513695Ssam 44613695Ssam fprintf(fprx, "%c %s\n", X_CMD, cmd); 44725967Sbloom if (ferror(fprx)) { 44825967Sbloom logent(cmd, "COULD NOT QUEUE XQT"); 44925967Sbloom cleanup(EX_IOERR); 45025967Sbloom } else 45125967Sbloom logent(cmd, "XQT QUE'D"); 45213695Ssam fclose(fprx); 45313695Ssam 45433578Srick if (size > 0 && Gradedelta > 0) { 45533578Srick DEBUG (4, "Grade changed from %c ", Grade); 45633578Srick Grade += size/Gradedelta; 45733578Srick if (Grade > 'z') 45833578Srick Grade = 'z'; 45933578Srick DEBUG(4, "to %c\n", Grade); 46033578Srick } 46117845Sralph gename(XQTPRE, local, Grade, tfile); 46213695Ssam if (strcmp(xsys, local) == SAME) { 46313695Ssam /* rti!trt: xmv() works across filesystems, link(II) doesnt */ 46413695Ssam xmv(rxfile, tfile); 46513695Ssam if (startjob) 46613695Ssam if (rflag) 46713695Ssam xuucico(xsys); 46813695Ssam else 46913695Ssam xuuxqt(); 47013695Ssam } 47113695Ssam else { 47213695Ssam GENSEND(fpc, rxfile, tfile, User, "", rxfile); 47313695Ssam cflag++; 47413695Ssam } 47513695Ssam 47625967Sbloom if (ferror(fpc)) 47725967Sbloom cleanup(EX_IOERR); 47813695Ssam fclose(fpc); 47913695Ssam if (cflag) { 48013695Ssam gename(CMDPRE, xsys, Grade, cfile); 48113695Ssam /* rti!trt: use xmv() rather than link(II) */ 48213695Ssam xmv(tcfile, cfile); 48313695Ssam if (startjob) 48413695Ssam xuucico(xsys); 48513695Ssam cleanup(0); 48613695Ssam } 48713695Ssam else 48813695Ssam unlink(subfile(tcfile)); 48918627Sralph exit(0); 49013695Ssam } 49113695Ssam 49213695Ssam #define FTABSIZE 30 49313695Ssam char Fname[FTABSIZE][NAMESIZE]; 49413695Ssam int Fnamect = 0; 49513695Ssam 49617845Sralph /* 49717845Sralph * cleanup and unlink if error 49813695Ssam * 49913695Ssam * return - none - do exit() 50013695Ssam */ 50113695Ssam 50213695Ssam cleanup(code) 50313695Ssam int code; 50413695Ssam { 50513695Ssam int i; 50613695Ssam 50713695Ssam logcls(); 50813695Ssam rmlock(CNULL); 50913695Ssam if (code) { 51013695Ssam for (i = 0; i < Fnamect; i++) 51113695Ssam unlink(subfile(Fname[i])); 51213695Ssam fprintf(stderr, "uux failed. code %d\n", code); 51313695Ssam } 51413695Ssam DEBUG(1, "exit code %d\n", code); 51513695Ssam exit(code); 51613695Ssam } 51713695Ssam 51817845Sralph /* 51917845Sralph * open file and record name 52013695Ssam * 52113695Ssam * return file pointer. 52213695Ssam */ 52313695Ssam 52413695Ssam FILE *ufopen(file, mode) 52513695Ssam char *file, *mode; 52613695Ssam { 52713695Ssam if (Fnamect < FTABSIZE) 52813695Ssam strcpy(Fname[Fnamect++], file); 52913695Ssam else 53013695Ssam logent("Fname", "TABLE OVERFLOW"); 53117845Sralph return fopen(subfile(file), mode); 53213695Ssam } 53317845Sralph #ifdef VMS 53417845Sralph /* 53517845Sralph * EUNICE bug: 53617845Sralph * quotes are not stripped from DCL. Do it here. 53717845Sralph * Note if we are running under Unix shell we don't 53817845Sralph * do the right thing. 53917845Sralph */ 54017845Sralph arg_fix(argc, argv) 54117845Sralph char **argv; 54217845Sralph { 54317845Sralph register char *cp, *tp; 54417845Sralph 54517845Sralph for (; argc > 0; --argc, argv++) { 54617845Sralph cp = *argv; 54717845Sralph if (cp == (char *)0 || *cp++ != '"') 54817845Sralph continue; 54917845Sralph tp = cp; 55017845Sralph while (*tp++) ; 55117845Sralph tp -= 2; 55217845Sralph if (*tp == '"') { 55317845Sralph *tp = '\0'; 55417845Sralph *argv = cp; 55517845Sralph } 55617845Sralph } 55717845Sralph } 55817845Sralph #endif VMS 55925146Sbloom 56025146Sbloom /* 56125146Sbloom * split into system and file part 56225146Sbloom * 56325146Sbloom * return codes: 56425146Sbloom * NOSYSPART 56525146Sbloom * HASSYSPART 56625146Sbloom */ 56725146Sbloom 56825146Sbloom split(name, sys, rest) 56925146Sbloom register char *name, *rest; 57025146Sbloom char *sys; 57125146Sbloom { 57225146Sbloom register char *c; 57325146Sbloom 57425146Sbloom if (*name == LQUOTE) { 57525146Sbloom if ((c = index(name + 1, RQUOTE)) != NULL) { 57625146Sbloom /* strip off quotes */ 57725146Sbloom name++; 57825146Sbloom while (c != name) 57925146Sbloom *rest++ = *name++; 58025146Sbloom *rest = '\0'; 58125146Sbloom *sys = '\0'; 58225146Sbloom return NOSYSPART; 58325146Sbloom } 58425146Sbloom } 58525146Sbloom 58625146Sbloom if ((c = index(name, '!')) == NULL) { 58725146Sbloom strcpy(rest, name); 58825146Sbloom *sys = '\0'; 58925146Sbloom return NOSYSPART; 59025146Sbloom } 59125146Sbloom 59225146Sbloom *c++ = '\0'; 59325146Sbloom strncpy(sys, name, MAXBASENAME); 59425146Sbloom sys[MAXBASENAME] = '\0'; 59525146Sbloom 59625146Sbloom strcpy(rest, c); 59725146Sbloom return HASSYSPART; 59825146Sbloom } 599