113695Ssam #ifndef lint 2*36176Sbostic static char sccsid[] = "@(#)uux.c 5.14 (Berkeley) 10/27/88"; 313695Ssam #endif 413695Ssam 513695Ssam #include "uucp.h" 633578Srick #include <sys/stat.h> 734674Srick #include <sysexits.h> 813695Ssam 913695Ssam #define NOSYSPART 0 1013695Ssam #define HASSYSPART 1 1113695Ssam 1225146Sbloom #define LQUOTE '(' 1325146Sbloom #define RQUOTE ')' 1425146Sbloom 1513695Ssam #define APPCMD(d) {\ 1625967Sbloom register char *p; for (p = d; *p != '\0';)\ 1725967Sbloom {*cmdp++ = *p++;\ 1825967Sbloom if(cmdp>(sizeof(cmd)+&cmd[0])){\ 1925967Sbloom fprintf(stderr,"argument list too long\n");\ 2034674Srick cleanup(EX_SOFTWARE);\ 2125967Sbloom }\ 2225967Sbloom }\ 2325967Sbloom *cmdp++ = ' '; *cmdp = '\0';} 2413695Ssam 2513695Ssam #define GENSEND(f, a, b, c, d, e) {\ 2625967Sbloom fprintf(f, "S %s %s %s -%s %s 0666\n", a, b, c, d, e); } 2717845Sralph #define GENRCV(f, a, b, c) {fprintf(f, "R %s %s %s - \n", a, b, c);} 2813695Ssam 2925146Sbloom struct timeb Now; 3025146Sbloom 3113695Ssam main(argc, argv) 3233965Srick int argc; 3333965Srick char **argv; 3413695Ssam { 3513695Ssam char cfile[NAMESIZE]; /* send commands for files from here */ 3613695Ssam char dfile[NAMESIZE]; /* used for all data files from here */ 3713695Ssam char rxfile[NAMESIZE]; /* to be sent to xqt file (X. ...) */ 3813695Ssam char tfile[NAMESIZE]; /* temporary file name */ 3913695Ssam char tcfile[NAMESIZE]; /* temporary file name */ 4013695Ssam char t2file[NAMESIZE]; /* temporary file name */ 4113695Ssam int cflag = 0; /* commands in C. file flag */ 4213695Ssam int rflag = 0; /* C. files for receiving flag */ 4317845Sralph #ifdef DONTCOPY 4417845Sralph int Copy = 0; /* Don't Copy spool files */ 4517845Sralph #else !DONTCOPY 4613695Ssam int Copy = 1; /* Copy spool files */ 4717845Sralph #endif !DONTCOPY 4817845Sralph int Linkit = 0; /* Try link before copy */ 4925967Sbloom char buf[2*BUFSIZ]; 5025967Sbloom char inargs[2*BUFSIZ]; 5113695Ssam int pipein = 0; 5213695Ssam int startjob = 1; 5313695Ssam char Grade = 'A'; 5433578Srick long Gradedelta = 100000000L; /* "huge number" */ 5533578Srick long size = 0L; 5613695Ssam char path[MAXFULLNAME]; 5725967Sbloom char cmd[2*BUFSIZ]; 5813695Ssam char *ap, *cmdp; 5925967Sbloom char prm[2*BUFSIZ]; 6023691Sbloom char syspart[MAXBASENAME+1], rest[MAXFULLNAME]; 6123691Sbloom char Xsys[MAXBASENAME+1], local[MAXBASENAME+1]; 6218627Sralph char *xsys = Xsys; 6313695Ssam FILE *fprx, *fpc, *fpd, *fp; 6413695Ssam extern char *getprm(), *lastpart(); 6513695Ssam extern FILE *ufopen(); 6633965Srick int uid, ret, c; 6713695Ssam char redir = '\0'; 6813695Ssam int nonoti = 0; 6913695Ssam int nonzero = 0; 7017845Sralph int link_failed; 7117845Sralph char *ReturnTo = NULL; 7217845Sralph extern int LocalOnly; 7333965Srick extern char *optarg; 7433965Srick extern int optind; 7513695Ssam 7613695Ssam strcpy(Progname, "uux"); 7713695Ssam uucpname(Myname); 7813695Ssam umask(WFMASK); 7913695Ssam Ofn = 1; 8013695Ssam Ifn = 0; 8117845Sralph #ifdef VMS 8217845Sralph arg_fix(argc, argv); 8317845Sralph #endif 84*36176Sbostic while (((c = getopt(argc, argv, "-prclCg:x:nzLa:")) != EOF) || 85*36176Sbostic (optind < argc && (c = *argv[optind]) == '-' && ++optind)) 8633965Srick switch (c) { 8735224Sbostic case '-': 8835224Sbostic /* FALLTHROUGH */ 8913695Ssam case 'p': 9013695Ssam pipein = 1; 9113695Ssam break; 9213695Ssam case 'r': 9313695Ssam startjob = 0; 9413695Ssam break; 9513695Ssam case 'c': 9617845Sralph Copy = 0; 9717845Sralph Linkit = 0; 9817845Sralph break; 9913695Ssam case 'l': 10013695Ssam Copy = 0; 10117845Sralph Linkit = 1; 10213695Ssam break; 10317845Sralph case 'C': 10417845Sralph Copy = 1; 10517845Sralph Linkit = 0; 10617845Sralph break; 10713695Ssam case 'g': 10833965Srick Grade = *optarg; 10933965Srick Gradedelta = atol(optarg+1); 11013695Ssam break; 11113695Ssam case 'x': 11217845Sralph chkdebug(); 11333965Srick Debug = atoi(optarg); 11413695Ssam if (Debug <= 0) 11513695Ssam Debug = 1; 11613695Ssam break; 11713695Ssam case 'n': 11813695Ssam nonoti = 1; 11913695Ssam break; 12013695Ssam case 'z': 12113695Ssam nonzero = 1; 12213695Ssam break; 12317845Sralph case 'L': 12417845Sralph LocalOnly++; 12517845Sralph break; 12617845Sralph case 'a': 12733965Srick ReturnTo = optarg; 12823691Sbloom if (prefix(Myname, ReturnTo) && ReturnTo[strlen(Myname)] == '!') 12923691Sbloom ReturnTo = index(ReturnTo, '!') + 1; 13017845Sralph break; 13133965Srick case '?': 13213695Ssam default: 13333965Srick break; 13413695Ssam } 13533965Srick 13625146Sbloom ap = getwd(Wrkdir); 13725146Sbloom if (ap == 0) { 13825146Sbloom fprintf(stderr, "can't get working directory; will try to continue\n"); 13925146Sbloom strcpy(Wrkdir, "/UNKNOWN"); 14017845Sralph } 14113695Ssam 14213695Ssam DEBUG(4, "\n\n** %s **\n", "START"); 14313695Ssam 14413695Ssam inargs[0] = '\0'; 14533965Srick while (optind < argc) { 14633965Srick DEBUG(4, "arg - %s:", argv[optind]); 14713695Ssam strcat(inargs, " "); 14833965Srick strcat(inargs, argv[optind++]); 14913695Ssam } 15013695Ssam DEBUG(4, "arg - %s\n", inargs); 15133965Srick if (subchdir(Spool) < 0) { 15233965Srick syslog(LOG_WARNING, "chdir(%s) failed: %m", Spool); 15333965Srick cleanup(1); 15433965Srick } 15513695Ssam uid = getuid(); 15633578Srick if (guinfo(uid, User, path) != SUCCESS) { 15733965Srick syslog(LOG_WARNING, "Can't find username for uid %d", uid); 15833578Srick DEBUG(1, "Using username", "uucp"); 15933578Srick strcpy(User, "uucp"); 16033578Srick } 16113695Ssam 16223691Sbloom strncpy(local, Myname, MAXBASENAME); 16313695Ssam cmdp = cmd; 16413695Ssam *cmdp = '\0'; 16513695Ssam gename(DATAPRE, local, 'X', rxfile); 16613695Ssam fprx = ufopen(rxfile, "w"); 16733965Srick if (fprx == NULL) { 16833965Srick syslog(LOG_WARNING, "fopen(%s) failed: %m", rxfile); 16933965Srick cleanup(1); 17033965Srick } 17113695Ssam gename(DATAPRE, local, 'T', tcfile); 17213695Ssam fpc = ufopen(tcfile, "w"); 17333965Srick if (fpc == NULL) { 17433965Srick syslog(LOG_WARNING, "fopen(%s) failed: %m", tcfile); 17533965Srick cleanup(1); 17633965Srick } 17713695Ssam fprintf(fprx, "%c %s %s\n", X_USER, User, local); 17813695Ssam if (nonoti) 17913695Ssam fprintf(fprx, "%c\n", X_NONOTI); 18013695Ssam if (nonzero) 18113695Ssam fprintf(fprx, "%c\n", X_NONZERO); 18217845Sralph if (ReturnTo == NULL || *ReturnTo == '\0') 18317845Sralph ReturnTo = User; 18417845Sralph fprintf(fprx, "%c %s\n", X_RETURNTO, ReturnTo); 18513695Ssam 18613695Ssam /* find remote system name */ 18713695Ssam ap = inargs; 18813695Ssam xsys[0] = '\0'; 18913695Ssam while ((ap = getprm(ap, prm)) != NULL) { 19013695Ssam if (prm[0] == '>' || prm[0] == '<') { 19113695Ssam ap = getprm(ap, prm); 19213695Ssam continue; 19313695Ssam } 19413695Ssam 19513695Ssam split(prm, xsys, rest); 19613695Ssam break; 19713695Ssam } 19813695Ssam if (xsys[0] == '\0') 19913695Ssam strcpy(xsys, local); 20018627Sralph if (versys(&xsys) != 0) { 20113695Ssam /* bad system name */ 20213695Ssam fprintf(stderr, "bad system name: %s\n", xsys); 20313695Ssam fclose(fprx); 20413695Ssam fclose(fpc); 20534674Srick cleanup(EX_NOHOST); 20613695Ssam } 20713695Ssam 20825146Sbloom strncpy(Rmtname, xsys, MAXBASENAME); 20925146Sbloom DEBUG(4, "xsys %s\n", xsys); 21025146Sbloom 21113695Ssam if (pipein) { 21213695Ssam gename(DATAPRE, local, 'B', dfile); 21313695Ssam fpd = ufopen(dfile, "w"); 21433965Srick if (fpd == NULL) { 21533965Srick syslog(LOG_WARNING, "fopen(%s) failed: %m", dfile); 21633965Srick cleanup(1); 21733965Srick } 21813695Ssam while (!feof(stdin)) { 21913695Ssam ret = fread(buf, 1, BUFSIZ, stdin); 22013695Ssam fwrite(buf, 1, ret, fpd); 22125967Sbloom if (ferror(stdin)) { 22225967Sbloom perror("stdin"); 22334674Srick cleanup(EX_IOERR); 22425967Sbloom } 22525967Sbloom if (ferror(fpd)) { 22625967Sbloom perror(dfile); 22734674Srick cleanup(EX_IOERR); 22825967Sbloom } 22933578Srick size += ret; 23013695Ssam } 23113695Ssam fclose(fpd); 23217845Sralph strcpy(tfile, dfile); 23313695Ssam if (strcmp(local, xsys) != SAME) { 23425146Sbloom register int Len = strlen(local); 23525146Sbloom if (Len > SYSNSIZE) 23625146Sbloom Len = SYSNSIZE; 23725146Sbloom tfile[Len + 2] = 'S'; 23817845Sralph GENSEND(fpc, dfile, tfile, User, "", dfile); 23913695Ssam cflag++; 24013695Ssam } 24117845Sralph fprintf(fprx, "%c %s\n", X_RQDFILE, tfile); 24217845Sralph fprintf(fprx, "%c %s\n", X_STDIN, tfile); 24313695Ssam } 24413695Ssam /* parse command */ 24513695Ssam ap = inargs; 24613695Ssam while ((ap = getprm(ap, prm)) != NULL) { 24713695Ssam DEBUG(4, "prm - %s\n", prm); 24813695Ssam if (prm[0] == '>' || prm[0] == '<') { 24913695Ssam redir = prm[0]; 25013695Ssam continue; 25113695Ssam } 25213695Ssam 25313695Ssam if (prm[0] == ';') { 25413695Ssam APPCMD(prm); 25513695Ssam continue; 25613695Ssam } 25713695Ssam 25813695Ssam if (prm[0] == '|' || prm[0] == '^') { 25913695Ssam if (cmdp != cmd) 26013695Ssam APPCMD(prm); 26113695Ssam continue; 26213695Ssam } 26313695Ssam 26413695Ssam /* process command or file or option */ 26513695Ssam ret = split(prm, syspart, rest); 26613695Ssam DEBUG(4, "s - %s, ", syspart); 26713695Ssam DEBUG(4, "r - %s, ", rest); 26813695Ssam DEBUG(4, "ret - %d\n", ret); 26913695Ssam if (syspart[0] == '\0') 27013695Ssam strcpy(syspart, local); 27113695Ssam 27213695Ssam if (cmdp == cmd && redir == '\0') { 27313695Ssam /* command */ 27413695Ssam APPCMD(rest); 27513695Ssam continue; 27613695Ssam } 27713695Ssam 27813695Ssam /* process file or option */ 27913695Ssam DEBUG(4, "file s- %s, ", syspart); 28013695Ssam DEBUG(4, "local - %s\n", local); 28113695Ssam /* process file */ 28213695Ssam if (redir == '>') { 28313695Ssam if (rest[0] != '~') 28413695Ssam if (ckexpf(rest)) 28534674Srick cleanup(EX_CANTCREAT); 28613695Ssam fprintf(fprx, "%c %s %s\n", X_STDOUT, rest, 28713695Ssam syspart); 28813695Ssam redir = '\0'; 28913695Ssam continue; 29013695Ssam } 29113695Ssam 29213695Ssam if (ret == NOSYSPART && redir == '\0') { 29313695Ssam /* option */ 29413695Ssam APPCMD(rest); 29513695Ssam continue; 29613695Ssam } 29713695Ssam 29833578Srick if (rest[0] != '\0') { 29933578Srick struct stat stbuf; 30033578Srick if (stat(rest, &stbuf) < 0) 30133578Srick DEBUG(4, "Can't stat %s\n", rest); 30233578Srick else 30333578Srick size += stbuf.st_size; 30433578Srick DEBUG(4, "size = %ld\n", size); 30533578Srick } 30633578Srick 30713695Ssam if (strcmp(xsys, local) == SAME 30813695Ssam && strcmp(xsys, syspart) == SAME) { 30913695Ssam if (ckexpf(rest)) 31034674Srick cleanup(EX_CANTCREAT); 31113695Ssam if (redir == '<') 31213695Ssam fprintf(fprx, "%c %s\n", X_STDIN, rest); 31313695Ssam else 31413695Ssam APPCMD(rest); 31513695Ssam redir = '\0'; 31613695Ssam continue; 31713695Ssam } 31813695Ssam 31913695Ssam if (strcmp(syspart, local) == SAME) { 32013695Ssam /* generate send file */ 32113695Ssam if (ckexpf(rest)) 32234674Srick cleanup(EX_CANTCREAT); 32313695Ssam gename(DATAPRE, local, 'A', dfile); 32413695Ssam DEBUG(4, "rest %s\n", rest); 32513695Ssam if ((chkpth(User, "", rest) || anyread(rest)) != 0) { 32613695Ssam fprintf(stderr, "permission denied %s\n", rest); 32734674Srick cleanup(EX_NOINPUT); 32813695Ssam } 32917845Sralph link_failed = 0; 33017845Sralph if (Linkit) { 33117845Sralph if (link(subfile(rest), subfile(dfile)) != 0) 33217845Sralph link_failed++; 33317845Sralph else 33417845Sralph GENSEND(fpc, rest, dfile, User, "", dfile); 33517845Sralph } 33617845Sralph if (Copy || link_failed) { 33713695Ssam if (xcp(rest, dfile) != 0) { 33813695Ssam fprintf(stderr, "can't copy %s to %s\n", rest, dfile); 33934674Srick cleanup(EX_NOINPUT); 34013695Ssam } 34113695Ssam GENSEND(fpc, rest, dfile, User, "", dfile); 34213695Ssam } 34317845Sralph if (!Copy && !Linkit) { 34413695Ssam GENSEND(fpc, rest, dfile, User, "c", "D.0"); 34513695Ssam } 34613695Ssam cflag++; 34713695Ssam if (redir == '<') { 34813695Ssam fprintf(fprx, "%c %s\n", X_STDIN, dfile); 34913695Ssam fprintf(fprx, "%c %s\n", X_RQDFILE, dfile); 35018627Sralph } else { 35113695Ssam APPCMD(lastpart(rest)); 35213695Ssam fprintf(fprx, "%c %s %s\n", X_RQDFILE, 35313695Ssam dfile, lastpart(rest)); 35413695Ssam } 35513695Ssam redir = '\0'; 35613695Ssam continue; 35713695Ssam } 35813695Ssam 35913695Ssam if (strcmp(local, xsys) == SAME) { 36013695Ssam /* generate local receive */ 36113695Ssam gename(CMDPRE, syspart, 'R', tfile); 36213695Ssam strcpy(dfile, tfile); 36313695Ssam dfile[0] = DATAPRE; 36413695Ssam fp = ufopen(tfile, "w"); 36533965Srick if (fp == NULL) { 36633965Srick syslog(LOG_WARNING, "fopen(%s) failed: %m", 36733965Srick tfile); 36833965Srick cleanup(1); 36933965Srick } 37013695Ssam if (ckexpf(rest)) 37134674Srick cleanup(EX_CANTCREAT); 37213695Ssam GENRCV(fp, rest, dfile, User); 37313695Ssam fclose(fp); 37413695Ssam rflag++; 37513695Ssam if (rest[0] != '~') 37613695Ssam if (ckexpf(rest)) 37734674Srick cleanup(EX_CANTCREAT); 37813695Ssam if (redir == '<') { 37913695Ssam fprintf(fprx, "%c %s\n", X_RQDFILE, dfile); 38013695Ssam fprintf(fprx, "%c %s\n", X_STDIN, dfile); 38118627Sralph } else { 38213695Ssam fprintf(fprx, "%c %s %s\n", X_RQDFILE, dfile, 38313695Ssam lastpart(rest)); 38413695Ssam APPCMD(lastpart(rest)); 38513695Ssam } 38613695Ssam 38713695Ssam redir = '\0'; 38813695Ssam continue; 38913695Ssam } 39013695Ssam 39113695Ssam if (strcmp(syspart, xsys) != SAME) { 39213695Ssam /* generate remote receives */ 39313695Ssam gename(DATAPRE, syspart, 'R', dfile); 39413695Ssam strcpy(tfile, dfile); 39513695Ssam tfile[0] = CMDPRE; 39613695Ssam fpd = ufopen(dfile, "w"); 39733965Srick if (fpd == NULL) { 39833965Srick syslog(LOG_WARNING, "fopen(%s) failed: %m", 39933965Srick dfile); 40033965Srick cleanup(1); 40133965Srick } 40213695Ssam gename(DATAPRE, local, 'T', t2file); 40313695Ssam GENRCV(fpd, rest, t2file, User); 40413695Ssam fclose(fpd); 40513695Ssam GENSEND(fpc, dfile, tfile, User, "", dfile); 40613695Ssam cflag++; 40713695Ssam if (redir == '<') { 40813695Ssam fprintf(fprx, "%c %s\n", X_RQDFILE, t2file); 40913695Ssam fprintf(fprx, "%c %s\n", X_STDIN, t2file); 41018627Sralph } else { 41113695Ssam fprintf(fprx, "%c %s %s\n", X_RQDFILE, t2file, 41213695Ssam lastpart(rest)); 41313695Ssam APPCMD(lastpart(rest)); 41413695Ssam } 41513695Ssam redir = '\0'; 41613695Ssam continue; 41713695Ssam } 41813695Ssam 41913695Ssam /* file on remote system */ 42013695Ssam if (rest[0] != '~') 42113695Ssam if (ckexpf(rest)) 42234674Srick cleanup(EX_CANTCREAT); 42313695Ssam if (redir == '<') 42413695Ssam fprintf(fprx, "%c %s\n", X_STDIN, rest); 42513695Ssam else 42613695Ssam APPCMD(rest); 42713695Ssam redir = '\0'; 42813695Ssam continue; 42913695Ssam 43013695Ssam } 43117845Sralph /* 43217845Sralph * clean up trailing ' ' in command. 43317845Sralph */ 43417845Sralph if (cmdp > cmd && cmdp[0] == '\0' && cmdp[-1] == ' ') 43517845Sralph *--cmdp = '\0'; 43617845Sralph /* block multi-hop uux, which doesn't work */ 43717845Sralph for (ap = cmd; *ap && *ap != ' '; ap++) 43817845Sralph if (*ap == '!') { 43917845Sralph fprintf(stderr, "uux handles only adjacent sites.\n"); 44017845Sralph fprintf(stderr, "Try uusend for multi-hop delivery.\n"); 44134674Srick cleanup(EX_USAGE); 44217845Sralph } 44313695Ssam 44413695Ssam fprintf(fprx, "%c %s\n", X_CMD, cmd); 44525967Sbloom if (ferror(fprx)) { 44625967Sbloom logent(cmd, "COULD NOT QUEUE XQT"); 44734674Srick cleanup(EX_IOERR); 44825967Sbloom } else 44925967Sbloom logent(cmd, "XQT QUE'D"); 45013695Ssam fclose(fprx); 45113695Ssam 45233578Srick if (size > 0 && Gradedelta > 0) { 45333578Srick DEBUG (4, "Grade changed from %c ", Grade); 45433578Srick Grade += size/Gradedelta; 45533578Srick if (Grade > 'z') 45633578Srick Grade = 'z'; 45733578Srick DEBUG(4, "to %c\n", Grade); 45833578Srick } 45917845Sralph gename(XQTPRE, local, Grade, tfile); 46013695Ssam if (strcmp(xsys, local) == SAME) { 46113695Ssam /* rti!trt: xmv() works across filesystems, link(II) doesnt */ 46213695Ssam xmv(rxfile, tfile); 46313695Ssam if (startjob) 46413695Ssam if (rflag) 46513695Ssam xuucico(xsys); 46613695Ssam else 46713695Ssam xuuxqt(); 46813695Ssam } 46913695Ssam else { 47013695Ssam GENSEND(fpc, rxfile, tfile, User, "", rxfile); 47113695Ssam cflag++; 47213695Ssam } 47313695Ssam 47425967Sbloom if (ferror(fpc)) 47534674Srick cleanup(EX_IOERR); 47613695Ssam fclose(fpc); 47713695Ssam if (cflag) { 47813695Ssam gename(CMDPRE, xsys, Grade, cfile); 47913695Ssam /* rti!trt: use xmv() rather than link(II) */ 48013695Ssam xmv(tcfile, cfile); 48113695Ssam if (startjob) 48213695Ssam xuucico(xsys); 48313695Ssam cleanup(0); 48413695Ssam } 48513695Ssam else 48613695Ssam unlink(subfile(tcfile)); 48718627Sralph exit(0); 48813695Ssam } 48913695Ssam 49013695Ssam #define FTABSIZE 30 49113695Ssam char Fname[FTABSIZE][NAMESIZE]; 49213695Ssam int Fnamect = 0; 49313695Ssam 49417845Sralph /* 49517845Sralph * cleanup and unlink if error 49613695Ssam * 49713695Ssam * return - none - do exit() 49813695Ssam */ 49913695Ssam 50013695Ssam cleanup(code) 50113695Ssam int code; 50213695Ssam { 50313695Ssam int i; 50413695Ssam 50513695Ssam logcls(); 50613695Ssam rmlock(CNULL); 50713695Ssam if (code) { 50813695Ssam for (i = 0; i < Fnamect; i++) 50913695Ssam unlink(subfile(Fname[i])); 51013695Ssam fprintf(stderr, "uux failed. code %d\n", code); 51113695Ssam } 51213695Ssam DEBUG(1, "exit code %d\n", code); 51313695Ssam exit(code); 51413695Ssam } 51513695Ssam 51617845Sralph /* 51717845Sralph * open file and record name 51813695Ssam * 51913695Ssam * return file pointer. 52013695Ssam */ 52113695Ssam 52213695Ssam FILE *ufopen(file, mode) 52313695Ssam char *file, *mode; 52413695Ssam { 52513695Ssam if (Fnamect < FTABSIZE) 52613695Ssam strcpy(Fname[Fnamect++], file); 52713695Ssam else 52813695Ssam logent("Fname", "TABLE OVERFLOW"); 52917845Sralph return fopen(subfile(file), mode); 53013695Ssam } 53117845Sralph #ifdef VMS 53217845Sralph /* 53317845Sralph * EUNICE bug: 53417845Sralph * quotes are not stripped from DCL. Do it here. 53517845Sralph * Note if we are running under Unix shell we don't 53617845Sralph * do the right thing. 53717845Sralph */ 53817845Sralph arg_fix(argc, argv) 53917845Sralph char **argv; 54017845Sralph { 54117845Sralph register char *cp, *tp; 54217845Sralph 54317845Sralph for (; argc > 0; --argc, argv++) { 54417845Sralph cp = *argv; 54517845Sralph if (cp == (char *)0 || *cp++ != '"') 54617845Sralph continue; 54717845Sralph tp = cp; 54817845Sralph while (*tp++) ; 54917845Sralph tp -= 2; 55017845Sralph if (*tp == '"') { 55117845Sralph *tp = '\0'; 55217845Sralph *argv = cp; 55317845Sralph } 55417845Sralph } 55517845Sralph } 55617845Sralph #endif VMS 55725146Sbloom 55825146Sbloom /* 55925146Sbloom * split into system and file part 56025146Sbloom * 56125146Sbloom * return codes: 56225146Sbloom * NOSYSPART 56325146Sbloom * HASSYSPART 56425146Sbloom */ 56525146Sbloom 56625146Sbloom split(name, sys, rest) 56725146Sbloom register char *name, *rest; 56825146Sbloom char *sys; 56925146Sbloom { 57025146Sbloom register char *c; 57125146Sbloom 57225146Sbloom if (*name == LQUOTE) { 57325146Sbloom if ((c = index(name + 1, RQUOTE)) != NULL) { 57425146Sbloom /* strip off quotes */ 57525146Sbloom name++; 57625146Sbloom while (c != name) 57725146Sbloom *rest++ = *name++; 57825146Sbloom *rest = '\0'; 57925146Sbloom *sys = '\0'; 58025146Sbloom return NOSYSPART; 58125146Sbloom } 58225146Sbloom } 58325146Sbloom 58425146Sbloom if ((c = index(name, '!')) == NULL) { 58525146Sbloom strcpy(rest, name); 58625146Sbloom *sys = '\0'; 58725146Sbloom return NOSYSPART; 58825146Sbloom } 58925146Sbloom 59025146Sbloom *c++ = '\0'; 59125146Sbloom strncpy(sys, name, MAXBASENAME); 59225146Sbloom sys[MAXBASENAME] = '\0'; 59325146Sbloom 59425146Sbloom strcpy(rest, c); 59525146Sbloom return HASSYSPART; 59625146Sbloom } 597