1*48448Sbostic /*- 2*48448Sbostic * Copyright (c) 1988 The Regents of the University of California. 3*48448Sbostic * All rights reserved. 4*48448Sbostic * 5*48448Sbostic * %sccs.include.proprietary.c% 6*48448Sbostic */ 7*48448Sbostic 813695Ssam #ifndef lint 9*48448Sbostic char copyright[] = 10*48448Sbostic "@(#) Copyright (c) 1988 The Regents of the University of California.\n\ 11*48448Sbostic All rights reserved.\n"; 12*48448Sbostic #endif /* not lint */ 1313695Ssam 14*48448Sbostic #ifndef lint 15*48448Sbostic static char sccsid[] = "@(#)uux.c 5.15 (Berkeley) 04/20/91"; 16*48448Sbostic #endif /* not lint */ 17*48448Sbostic 1813695Ssam #include "uucp.h" 1933578Srick #include <sys/stat.h> 2034674Srick #include <sysexits.h> 2113695Ssam 2213695Ssam #define NOSYSPART 0 2313695Ssam #define HASSYSPART 1 2413695Ssam 2525146Sbloom #define LQUOTE '(' 2625146Sbloom #define RQUOTE ')' 2725146Sbloom 2813695Ssam #define APPCMD(d) {\ 2925967Sbloom register char *p; for (p = d; *p != '\0';)\ 3025967Sbloom {*cmdp++ = *p++;\ 3125967Sbloom if(cmdp>(sizeof(cmd)+&cmd[0])){\ 3225967Sbloom fprintf(stderr,"argument list too long\n");\ 3334674Srick cleanup(EX_SOFTWARE);\ 3425967Sbloom }\ 3525967Sbloom }\ 3625967Sbloom *cmdp++ = ' '; *cmdp = '\0';} 3713695Ssam 3813695Ssam #define GENSEND(f, a, b, c, d, e) {\ 3925967Sbloom fprintf(f, "S %s %s %s -%s %s 0666\n", a, b, c, d, e); } 4017845Sralph #define GENRCV(f, a, b, c) {fprintf(f, "R %s %s %s - \n", a, b, c);} 4113695Ssam 4225146Sbloom struct timeb Now; 4325146Sbloom 4413695Ssam main(argc, argv) 4533965Srick int argc; 4633965Srick char **argv; 4713695Ssam { 4813695Ssam char cfile[NAMESIZE]; /* send commands for files from here */ 4913695Ssam char dfile[NAMESIZE]; /* used for all data files from here */ 5013695Ssam char rxfile[NAMESIZE]; /* to be sent to xqt file (X. ...) */ 5113695Ssam char tfile[NAMESIZE]; /* temporary file name */ 5213695Ssam char tcfile[NAMESIZE]; /* temporary file name */ 5313695Ssam char t2file[NAMESIZE]; /* temporary file name */ 5413695Ssam int cflag = 0; /* commands in C. file flag */ 5513695Ssam int rflag = 0; /* C. files for receiving flag */ 5617845Sralph #ifdef DONTCOPY 5717845Sralph int Copy = 0; /* Don't Copy spool files */ 5817845Sralph #else !DONTCOPY 5913695Ssam int Copy = 1; /* Copy spool files */ 6017845Sralph #endif !DONTCOPY 6117845Sralph int Linkit = 0; /* Try link before copy */ 6225967Sbloom char buf[2*BUFSIZ]; 6325967Sbloom char inargs[2*BUFSIZ]; 6413695Ssam int pipein = 0; 6513695Ssam int startjob = 1; 6613695Ssam char Grade = 'A'; 6733578Srick long Gradedelta = 100000000L; /* "huge number" */ 6833578Srick long size = 0L; 6913695Ssam char path[MAXFULLNAME]; 7025967Sbloom char cmd[2*BUFSIZ]; 7113695Ssam char *ap, *cmdp; 7225967Sbloom char prm[2*BUFSIZ]; 7323691Sbloom char syspart[MAXBASENAME+1], rest[MAXFULLNAME]; 7423691Sbloom char Xsys[MAXBASENAME+1], local[MAXBASENAME+1]; 7518627Sralph char *xsys = Xsys; 7613695Ssam FILE *fprx, *fpc, *fpd, *fp; 7713695Ssam extern char *getprm(), *lastpart(); 7813695Ssam extern FILE *ufopen(); 7933965Srick int uid, ret, c; 8013695Ssam char redir = '\0'; 8113695Ssam int nonoti = 0; 8213695Ssam int nonzero = 0; 8317845Sralph int link_failed; 8417845Sralph char *ReturnTo = NULL; 8517845Sralph extern int LocalOnly; 8633965Srick extern char *optarg; 8733965Srick extern int optind; 8813695Ssam 8913695Ssam strcpy(Progname, "uux"); 9013695Ssam uucpname(Myname); 9113695Ssam umask(WFMASK); 9213695Ssam Ofn = 1; 9313695Ssam Ifn = 0; 9417845Sralph #ifdef VMS 9517845Sralph arg_fix(argc, argv); 9617845Sralph #endif 9736176Sbostic while (((c = getopt(argc, argv, "-prclCg:x:nzLa:")) != EOF) || 9836176Sbostic (optind < argc && (c = *argv[optind]) == '-' && ++optind)) 9933965Srick switch (c) { 10035224Sbostic case '-': 10135224Sbostic /* FALLTHROUGH */ 10213695Ssam case 'p': 10313695Ssam pipein = 1; 10413695Ssam break; 10513695Ssam case 'r': 10613695Ssam startjob = 0; 10713695Ssam break; 10813695Ssam case 'c': 10917845Sralph Copy = 0; 11017845Sralph Linkit = 0; 11117845Sralph break; 11213695Ssam case 'l': 11313695Ssam Copy = 0; 11417845Sralph Linkit = 1; 11513695Ssam break; 11617845Sralph case 'C': 11717845Sralph Copy = 1; 11817845Sralph Linkit = 0; 11917845Sralph break; 12013695Ssam case 'g': 12133965Srick Grade = *optarg; 12233965Srick Gradedelta = atol(optarg+1); 12313695Ssam break; 12413695Ssam case 'x': 12517845Sralph chkdebug(); 12633965Srick Debug = atoi(optarg); 12713695Ssam if (Debug <= 0) 12813695Ssam Debug = 1; 12913695Ssam break; 13013695Ssam case 'n': 13113695Ssam nonoti = 1; 13213695Ssam break; 13313695Ssam case 'z': 13413695Ssam nonzero = 1; 13513695Ssam break; 13617845Sralph case 'L': 13717845Sralph LocalOnly++; 13817845Sralph break; 13917845Sralph case 'a': 14033965Srick ReturnTo = optarg; 14123691Sbloom if (prefix(Myname, ReturnTo) && ReturnTo[strlen(Myname)] == '!') 14223691Sbloom ReturnTo = index(ReturnTo, '!') + 1; 14317845Sralph break; 14433965Srick case '?': 14513695Ssam default: 14633965Srick break; 14713695Ssam } 14833965Srick 14925146Sbloom ap = getwd(Wrkdir); 15025146Sbloom if (ap == 0) { 15125146Sbloom fprintf(stderr, "can't get working directory; will try to continue\n"); 15225146Sbloom strcpy(Wrkdir, "/UNKNOWN"); 15317845Sralph } 15413695Ssam 15513695Ssam DEBUG(4, "\n\n** %s **\n", "START"); 15613695Ssam 15713695Ssam inargs[0] = '\0'; 15833965Srick while (optind < argc) { 15933965Srick DEBUG(4, "arg - %s:", argv[optind]); 16013695Ssam strcat(inargs, " "); 16133965Srick strcat(inargs, argv[optind++]); 16213695Ssam } 16313695Ssam DEBUG(4, "arg - %s\n", inargs); 16433965Srick if (subchdir(Spool) < 0) { 16533965Srick syslog(LOG_WARNING, "chdir(%s) failed: %m", Spool); 16633965Srick cleanup(1); 16733965Srick } 16813695Ssam uid = getuid(); 16933578Srick if (guinfo(uid, User, path) != SUCCESS) { 17033965Srick syslog(LOG_WARNING, "Can't find username for uid %d", uid); 17133578Srick DEBUG(1, "Using username", "uucp"); 17233578Srick strcpy(User, "uucp"); 17333578Srick } 17413695Ssam 17523691Sbloom strncpy(local, Myname, MAXBASENAME); 17613695Ssam cmdp = cmd; 17713695Ssam *cmdp = '\0'; 17813695Ssam gename(DATAPRE, local, 'X', rxfile); 17913695Ssam fprx = ufopen(rxfile, "w"); 18033965Srick if (fprx == NULL) { 18133965Srick syslog(LOG_WARNING, "fopen(%s) failed: %m", rxfile); 18233965Srick cleanup(1); 18333965Srick } 18413695Ssam gename(DATAPRE, local, 'T', tcfile); 18513695Ssam fpc = ufopen(tcfile, "w"); 18633965Srick if (fpc == NULL) { 18733965Srick syslog(LOG_WARNING, "fopen(%s) failed: %m", tcfile); 18833965Srick cleanup(1); 18933965Srick } 19013695Ssam fprintf(fprx, "%c %s %s\n", X_USER, User, local); 19113695Ssam if (nonoti) 19213695Ssam fprintf(fprx, "%c\n", X_NONOTI); 19313695Ssam if (nonzero) 19413695Ssam fprintf(fprx, "%c\n", X_NONZERO); 19517845Sralph if (ReturnTo == NULL || *ReturnTo == '\0') 19617845Sralph ReturnTo = User; 19717845Sralph fprintf(fprx, "%c %s\n", X_RETURNTO, ReturnTo); 19813695Ssam 19913695Ssam /* find remote system name */ 20013695Ssam ap = inargs; 20113695Ssam xsys[0] = '\0'; 20213695Ssam while ((ap = getprm(ap, prm)) != NULL) { 20313695Ssam if (prm[0] == '>' || prm[0] == '<') { 20413695Ssam ap = getprm(ap, prm); 20513695Ssam continue; 20613695Ssam } 20713695Ssam 20813695Ssam split(prm, xsys, rest); 20913695Ssam break; 21013695Ssam } 21113695Ssam if (xsys[0] == '\0') 21213695Ssam strcpy(xsys, local); 21318627Sralph if (versys(&xsys) != 0) { 21413695Ssam /* bad system name */ 21513695Ssam fprintf(stderr, "bad system name: %s\n", xsys); 21613695Ssam fclose(fprx); 21713695Ssam fclose(fpc); 21834674Srick cleanup(EX_NOHOST); 21913695Ssam } 22013695Ssam 22125146Sbloom strncpy(Rmtname, xsys, MAXBASENAME); 22225146Sbloom DEBUG(4, "xsys %s\n", xsys); 22325146Sbloom 22413695Ssam if (pipein) { 22513695Ssam gename(DATAPRE, local, 'B', dfile); 22613695Ssam fpd = ufopen(dfile, "w"); 22733965Srick if (fpd == NULL) { 22833965Srick syslog(LOG_WARNING, "fopen(%s) failed: %m", dfile); 22933965Srick cleanup(1); 23033965Srick } 23113695Ssam while (!feof(stdin)) { 23213695Ssam ret = fread(buf, 1, BUFSIZ, stdin); 23313695Ssam fwrite(buf, 1, ret, fpd); 23425967Sbloom if (ferror(stdin)) { 23525967Sbloom perror("stdin"); 23634674Srick cleanup(EX_IOERR); 23725967Sbloom } 23825967Sbloom if (ferror(fpd)) { 23925967Sbloom perror(dfile); 24034674Srick cleanup(EX_IOERR); 24125967Sbloom } 24233578Srick size += ret; 24313695Ssam } 24413695Ssam fclose(fpd); 24517845Sralph strcpy(tfile, dfile); 24613695Ssam if (strcmp(local, xsys) != SAME) { 24725146Sbloom register int Len = strlen(local); 24825146Sbloom if (Len > SYSNSIZE) 24925146Sbloom Len = SYSNSIZE; 25025146Sbloom tfile[Len + 2] = 'S'; 25117845Sralph GENSEND(fpc, dfile, tfile, User, "", dfile); 25213695Ssam cflag++; 25313695Ssam } 25417845Sralph fprintf(fprx, "%c %s\n", X_RQDFILE, tfile); 25517845Sralph fprintf(fprx, "%c %s\n", X_STDIN, tfile); 25613695Ssam } 25713695Ssam /* parse command */ 25813695Ssam ap = inargs; 25913695Ssam while ((ap = getprm(ap, prm)) != NULL) { 26013695Ssam DEBUG(4, "prm - %s\n", prm); 26113695Ssam if (prm[0] == '>' || prm[0] == '<') { 26213695Ssam redir = prm[0]; 26313695Ssam continue; 26413695Ssam } 26513695Ssam 26613695Ssam if (prm[0] == ';') { 26713695Ssam APPCMD(prm); 26813695Ssam continue; 26913695Ssam } 27013695Ssam 27113695Ssam if (prm[0] == '|' || prm[0] == '^') { 27213695Ssam if (cmdp != cmd) 27313695Ssam APPCMD(prm); 27413695Ssam continue; 27513695Ssam } 27613695Ssam 27713695Ssam /* process command or file or option */ 27813695Ssam ret = split(prm, syspart, rest); 27913695Ssam DEBUG(4, "s - %s, ", syspart); 28013695Ssam DEBUG(4, "r - %s, ", rest); 28113695Ssam DEBUG(4, "ret - %d\n", ret); 28213695Ssam if (syspart[0] == '\0') 28313695Ssam strcpy(syspart, local); 28413695Ssam 28513695Ssam if (cmdp == cmd && redir == '\0') { 28613695Ssam /* command */ 28713695Ssam APPCMD(rest); 28813695Ssam continue; 28913695Ssam } 29013695Ssam 29113695Ssam /* process file or option */ 29213695Ssam DEBUG(4, "file s- %s, ", syspart); 29313695Ssam DEBUG(4, "local - %s\n", local); 29413695Ssam /* process file */ 29513695Ssam if (redir == '>') { 29613695Ssam if (rest[0] != '~') 29713695Ssam if (ckexpf(rest)) 29834674Srick cleanup(EX_CANTCREAT); 29913695Ssam fprintf(fprx, "%c %s %s\n", X_STDOUT, rest, 30013695Ssam syspart); 30113695Ssam redir = '\0'; 30213695Ssam continue; 30313695Ssam } 30413695Ssam 30513695Ssam if (ret == NOSYSPART && redir == '\0') { 30613695Ssam /* option */ 30713695Ssam APPCMD(rest); 30813695Ssam continue; 30913695Ssam } 31013695Ssam 31133578Srick if (rest[0] != '\0') { 31233578Srick struct stat stbuf; 31333578Srick if (stat(rest, &stbuf) < 0) 31433578Srick DEBUG(4, "Can't stat %s\n", rest); 31533578Srick else 31633578Srick size += stbuf.st_size; 31733578Srick DEBUG(4, "size = %ld\n", size); 31833578Srick } 31933578Srick 32013695Ssam if (strcmp(xsys, local) == SAME 32113695Ssam && strcmp(xsys, syspart) == SAME) { 32213695Ssam if (ckexpf(rest)) 32334674Srick cleanup(EX_CANTCREAT); 32413695Ssam if (redir == '<') 32513695Ssam fprintf(fprx, "%c %s\n", X_STDIN, rest); 32613695Ssam else 32713695Ssam APPCMD(rest); 32813695Ssam redir = '\0'; 32913695Ssam continue; 33013695Ssam } 33113695Ssam 33213695Ssam if (strcmp(syspart, local) == SAME) { 33313695Ssam /* generate send file */ 33413695Ssam if (ckexpf(rest)) 33534674Srick cleanup(EX_CANTCREAT); 33613695Ssam gename(DATAPRE, local, 'A', dfile); 33713695Ssam DEBUG(4, "rest %s\n", rest); 33813695Ssam if ((chkpth(User, "", rest) || anyread(rest)) != 0) { 33913695Ssam fprintf(stderr, "permission denied %s\n", rest); 34034674Srick cleanup(EX_NOINPUT); 34113695Ssam } 34217845Sralph link_failed = 0; 34317845Sralph if (Linkit) { 34417845Sralph if (link(subfile(rest), subfile(dfile)) != 0) 34517845Sralph link_failed++; 34617845Sralph else 34717845Sralph GENSEND(fpc, rest, dfile, User, "", dfile); 34817845Sralph } 34917845Sralph if (Copy || link_failed) { 35013695Ssam if (xcp(rest, dfile) != 0) { 35113695Ssam fprintf(stderr, "can't copy %s to %s\n", rest, dfile); 35234674Srick cleanup(EX_NOINPUT); 35313695Ssam } 35413695Ssam GENSEND(fpc, rest, dfile, User, "", dfile); 35513695Ssam } 35617845Sralph if (!Copy && !Linkit) { 35713695Ssam GENSEND(fpc, rest, dfile, User, "c", "D.0"); 35813695Ssam } 35913695Ssam cflag++; 36013695Ssam if (redir == '<') { 36113695Ssam fprintf(fprx, "%c %s\n", X_STDIN, dfile); 36213695Ssam fprintf(fprx, "%c %s\n", X_RQDFILE, dfile); 36318627Sralph } else { 36413695Ssam APPCMD(lastpart(rest)); 36513695Ssam fprintf(fprx, "%c %s %s\n", X_RQDFILE, 36613695Ssam dfile, lastpart(rest)); 36713695Ssam } 36813695Ssam redir = '\0'; 36913695Ssam continue; 37013695Ssam } 37113695Ssam 37213695Ssam if (strcmp(local, xsys) == SAME) { 37313695Ssam /* generate local receive */ 37413695Ssam gename(CMDPRE, syspart, 'R', tfile); 37513695Ssam strcpy(dfile, tfile); 37613695Ssam dfile[0] = DATAPRE; 37713695Ssam fp = ufopen(tfile, "w"); 37833965Srick if (fp == NULL) { 37933965Srick syslog(LOG_WARNING, "fopen(%s) failed: %m", 38033965Srick tfile); 38133965Srick cleanup(1); 38233965Srick } 38313695Ssam if (ckexpf(rest)) 38434674Srick cleanup(EX_CANTCREAT); 38513695Ssam GENRCV(fp, rest, dfile, User); 38613695Ssam fclose(fp); 38713695Ssam rflag++; 38813695Ssam if (rest[0] != '~') 38913695Ssam if (ckexpf(rest)) 39034674Srick cleanup(EX_CANTCREAT); 39113695Ssam if (redir == '<') { 39213695Ssam fprintf(fprx, "%c %s\n", X_RQDFILE, dfile); 39313695Ssam fprintf(fprx, "%c %s\n", X_STDIN, dfile); 39418627Sralph } else { 39513695Ssam fprintf(fprx, "%c %s %s\n", X_RQDFILE, dfile, 39613695Ssam lastpart(rest)); 39713695Ssam APPCMD(lastpart(rest)); 39813695Ssam } 39913695Ssam 40013695Ssam redir = '\0'; 40113695Ssam continue; 40213695Ssam } 40313695Ssam 40413695Ssam if (strcmp(syspart, xsys) != SAME) { 40513695Ssam /* generate remote receives */ 40613695Ssam gename(DATAPRE, syspart, 'R', dfile); 40713695Ssam strcpy(tfile, dfile); 40813695Ssam tfile[0] = CMDPRE; 40913695Ssam fpd = ufopen(dfile, "w"); 41033965Srick if (fpd == NULL) { 41133965Srick syslog(LOG_WARNING, "fopen(%s) failed: %m", 41233965Srick dfile); 41333965Srick cleanup(1); 41433965Srick } 41513695Ssam gename(DATAPRE, local, 'T', t2file); 41613695Ssam GENRCV(fpd, rest, t2file, User); 41713695Ssam fclose(fpd); 41813695Ssam GENSEND(fpc, dfile, tfile, User, "", dfile); 41913695Ssam cflag++; 42013695Ssam if (redir == '<') { 42113695Ssam fprintf(fprx, "%c %s\n", X_RQDFILE, t2file); 42213695Ssam fprintf(fprx, "%c %s\n", X_STDIN, t2file); 42318627Sralph } else { 42413695Ssam fprintf(fprx, "%c %s %s\n", X_RQDFILE, t2file, 42513695Ssam lastpart(rest)); 42613695Ssam APPCMD(lastpart(rest)); 42713695Ssam } 42813695Ssam redir = '\0'; 42913695Ssam continue; 43013695Ssam } 43113695Ssam 43213695Ssam /* file on remote system */ 43313695Ssam if (rest[0] != '~') 43413695Ssam if (ckexpf(rest)) 43534674Srick cleanup(EX_CANTCREAT); 43613695Ssam if (redir == '<') 43713695Ssam fprintf(fprx, "%c %s\n", X_STDIN, rest); 43813695Ssam else 43913695Ssam APPCMD(rest); 44013695Ssam redir = '\0'; 44113695Ssam continue; 44213695Ssam 44313695Ssam } 44417845Sralph /* 44517845Sralph * clean up trailing ' ' in command. 44617845Sralph */ 44717845Sralph if (cmdp > cmd && cmdp[0] == '\0' && cmdp[-1] == ' ') 44817845Sralph *--cmdp = '\0'; 44917845Sralph /* block multi-hop uux, which doesn't work */ 45017845Sralph for (ap = cmd; *ap && *ap != ' '; ap++) 45117845Sralph if (*ap == '!') { 45217845Sralph fprintf(stderr, "uux handles only adjacent sites.\n"); 45317845Sralph fprintf(stderr, "Try uusend for multi-hop delivery.\n"); 45434674Srick cleanup(EX_USAGE); 45517845Sralph } 45613695Ssam 45713695Ssam fprintf(fprx, "%c %s\n", X_CMD, cmd); 45825967Sbloom if (ferror(fprx)) { 45925967Sbloom logent(cmd, "COULD NOT QUEUE XQT"); 46034674Srick cleanup(EX_IOERR); 46125967Sbloom } else 46225967Sbloom logent(cmd, "XQT QUE'D"); 46313695Ssam fclose(fprx); 46413695Ssam 46533578Srick if (size > 0 && Gradedelta > 0) { 46633578Srick DEBUG (4, "Grade changed from %c ", Grade); 46733578Srick Grade += size/Gradedelta; 46833578Srick if (Grade > 'z') 46933578Srick Grade = 'z'; 47033578Srick DEBUG(4, "to %c\n", Grade); 47133578Srick } 47217845Sralph gename(XQTPRE, local, Grade, tfile); 47313695Ssam if (strcmp(xsys, local) == SAME) { 47413695Ssam /* rti!trt: xmv() works across filesystems, link(II) doesnt */ 47513695Ssam xmv(rxfile, tfile); 47613695Ssam if (startjob) 47713695Ssam if (rflag) 47813695Ssam xuucico(xsys); 47913695Ssam else 48013695Ssam xuuxqt(); 48113695Ssam } 48213695Ssam else { 48313695Ssam GENSEND(fpc, rxfile, tfile, User, "", rxfile); 48413695Ssam cflag++; 48513695Ssam } 48613695Ssam 48725967Sbloom if (ferror(fpc)) 48834674Srick cleanup(EX_IOERR); 48913695Ssam fclose(fpc); 49013695Ssam if (cflag) { 49113695Ssam gename(CMDPRE, xsys, Grade, cfile); 49213695Ssam /* rti!trt: use xmv() rather than link(II) */ 49313695Ssam xmv(tcfile, cfile); 49413695Ssam if (startjob) 49513695Ssam xuucico(xsys); 49613695Ssam cleanup(0); 49713695Ssam } 49813695Ssam else 49913695Ssam unlink(subfile(tcfile)); 50018627Sralph exit(0); 50113695Ssam } 50213695Ssam 50313695Ssam #define FTABSIZE 30 50413695Ssam char Fname[FTABSIZE][NAMESIZE]; 50513695Ssam int Fnamect = 0; 50613695Ssam 50717845Sralph /* 50817845Sralph * cleanup and unlink if error 50913695Ssam * 51013695Ssam * return - none - do exit() 51113695Ssam */ 51213695Ssam 51313695Ssam cleanup(code) 51413695Ssam int code; 51513695Ssam { 51613695Ssam int i; 51713695Ssam 51813695Ssam logcls(); 51913695Ssam rmlock(CNULL); 52013695Ssam if (code) { 52113695Ssam for (i = 0; i < Fnamect; i++) 52213695Ssam unlink(subfile(Fname[i])); 52313695Ssam fprintf(stderr, "uux failed. code %d\n", code); 52413695Ssam } 52513695Ssam DEBUG(1, "exit code %d\n", code); 52613695Ssam exit(code); 52713695Ssam } 52813695Ssam 52917845Sralph /* 53017845Sralph * open file and record name 53113695Ssam * 53213695Ssam * return file pointer. 53313695Ssam */ 53413695Ssam 53513695Ssam FILE *ufopen(file, mode) 53613695Ssam char *file, *mode; 53713695Ssam { 53813695Ssam if (Fnamect < FTABSIZE) 53913695Ssam strcpy(Fname[Fnamect++], file); 54013695Ssam else 54113695Ssam logent("Fname", "TABLE OVERFLOW"); 54217845Sralph return fopen(subfile(file), mode); 54313695Ssam } 54417845Sralph #ifdef VMS 54517845Sralph /* 54617845Sralph * EUNICE bug: 54717845Sralph * quotes are not stripped from DCL. Do it here. 54817845Sralph * Note if we are running under Unix shell we don't 54917845Sralph * do the right thing. 55017845Sralph */ 55117845Sralph arg_fix(argc, argv) 55217845Sralph char **argv; 55317845Sralph { 55417845Sralph register char *cp, *tp; 55517845Sralph 55617845Sralph for (; argc > 0; --argc, argv++) { 55717845Sralph cp = *argv; 55817845Sralph if (cp == (char *)0 || *cp++ != '"') 55917845Sralph continue; 56017845Sralph tp = cp; 56117845Sralph while (*tp++) ; 56217845Sralph tp -= 2; 56317845Sralph if (*tp == '"') { 56417845Sralph *tp = '\0'; 56517845Sralph *argv = cp; 56617845Sralph } 56717845Sralph } 56817845Sralph } 56917845Sralph #endif VMS 57025146Sbloom 57125146Sbloom /* 57225146Sbloom * split into system and file part 57325146Sbloom * 57425146Sbloom * return codes: 57525146Sbloom * NOSYSPART 57625146Sbloom * HASSYSPART 57725146Sbloom */ 57825146Sbloom 57925146Sbloom split(name, sys, rest) 58025146Sbloom register char *name, *rest; 58125146Sbloom char *sys; 58225146Sbloom { 58325146Sbloom register char *c; 58425146Sbloom 58525146Sbloom if (*name == LQUOTE) { 58625146Sbloom if ((c = index(name + 1, RQUOTE)) != NULL) { 58725146Sbloom /* strip off quotes */ 58825146Sbloom name++; 58925146Sbloom while (c != name) 59025146Sbloom *rest++ = *name++; 59125146Sbloom *rest = '\0'; 59225146Sbloom *sys = '\0'; 59325146Sbloom return NOSYSPART; 59425146Sbloom } 59525146Sbloom } 59625146Sbloom 59725146Sbloom if ((c = index(name, '!')) == NULL) { 59825146Sbloom strcpy(rest, name); 59925146Sbloom *sys = '\0'; 60025146Sbloom return NOSYSPART; 60125146Sbloom } 60225146Sbloom 60325146Sbloom *c++ = '\0'; 60425146Sbloom strncpy(sys, name, MAXBASENAME); 60525146Sbloom sys[MAXBASENAME] = '\0'; 60625146Sbloom 60725146Sbloom strcpy(rest, c); 60825146Sbloom return HASSYSPART; 60925146Sbloom } 610