|
|
1.1 ! root 1: /* /sccs/src/cmd/uucp/s.gtcfile.c ! 2: gtcfile.c 1.1 8/30/84 17:37:27 ! 3: */ ! 4: #include "uucp.h" ! 5: VERSION(@(#)gtcfile.c 1.1); ! 6: ! 7: #define NCSAVE 30 /* no more than 30 saved C files, please */ ! 8: static int ncsave; ! 9: static struct { ! 10: char file[NAMESIZE]; ! 11: char sys[NAMESIZE]; ! 12: } csave[NCSAVE]; ! 13: ! 14: /* ! 15: * svcfile - save the name of a C. file for system sys for re-using ! 16: * returns ! 17: * none ! 18: */ ! 19: ! 20: svcfile(file, sys) ! 21: char *file, *sys; ! 22: { ! 23: ASSERT(ncsave < NCSAVE, "TOO MANY SAVED C FILES", "", ncsave); ! 24: (void) strcpy(csave[ncsave].file, BASENAME(file, '/')); ! 25: (void) strcpy(csave[ncsave].sys, sys); ! 26: ncsave++; ! 27: return; ! 28: } ! 29: ! 30: /* ! 31: * gtcfile - copy into file the name of the saved C file for system sys ! 32: * ! 33: * returns ! 34: * SUCCESS -> found one ! 35: * FAIL -> none saved ! 36: * ! 37: */ ! 38: ! 39: gtcfile(file, sys) ! 40: char *file, *sys; ! 41: { ! 42: register int i; ! 43: ! 44: for (i = 0; i < ncsave; i++) ! 45: if (strncmp(sys, csave[i].sys, SYSNSIZE) == SAME) { ! 46: (void) strcpy(file, csave[i].file); ! 47: return(SUCCESS); ! 48: } ! 49: ! 50: return(FAIL); ! 51: } ! 52: ! 53: /* commitall() ! 54: * ! 55: * commit any and all saved C files ! 56: * ! 57: * returns ! 58: * nothing ! 59: */ ! 60: ! 61: commitall() ! 62: { ! 63: /* not an infinite loop; wfcommit() decrements ncsave */ ! 64: while (ncsave > 0) ! 65: wfcommit(csave[0].file, csave[0].file, csave[0].sys); ! 66: } ! 67: ! 68: /* ! 69: * wfcommit - move wfile1 in current directory to SPOOL/sys/wfile2 ! 70: * return ! 71: * none ! 72: */ ! 73: ! 74: wfcommit(wfile1, wfile2, sys) ! 75: char *wfile1, *wfile2, *sys; ! 76: { ! 77: int i; ! 78: char cmitfile[MAXFULLNAME]; ! 79: char *file1Base, *file2Base; ! 80: ! 81: DEBUG(6, "commit %s ", wfile2); ! 82: mkremdir(sys); /* sets RemSpool */ ! 83: file1Base = BASENAME(wfile1, '/'); ! 84: file2Base = BASENAME(wfile2, '/'); ! 85: sprintf(cmitfile, "%s/%s", RemSpool, file2Base); ! 86: DEBUG(6, "to %s\n", cmitfile); ! 87: ! 88: ASSERT(access(cmitfile, 0) != 0, Fl_EXISTS, cmitfile, 0); ! 89: ASSERT(xmv(wfile1, cmitfile) == 0, Ct_LINK, cmitfile, errno); ! 90: ! 91: /* if wfile1 is a saved C. file, purge it from the saved list */ ! 92: for (i = 0; i < ncsave; i++) { ! 93: if (EQUALS(file1Base, csave[i].file)) { ! 94: --ncsave; ! 95: (void) strcpy(csave[i].file, csave[ncsave].file); ! 96: (void) strcpy(csave[i].sys, csave[ncsave].sys); ! 97: break; ! 98: } ! 99: } ! 100: return; ! 101: } ! 102: ! 103: /* wfabort - unlink any and all saved C files ! 104: * return ! 105: * none ! 106: */ ! 107: ! 108: wfabort() ! 109: { ! 110: register int i; ! 111: ! 112: for (i = 0; i < ncsave; i++) ! 113: (void) unlink(csave[i].file); ! 114: ncsave = 0; ! 115: return; ! 116: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.