4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
22 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
23 /* All Rights Reserved */
26 #ident "%Z%%M% %I% %E% SMI" /* from SVR4 bnu:gtcfile.c 2.5 */
30 #define NCSAVE 30 /* no more than 30 saved C files, please */
32 static struct cs_struct csave
[NCSAVE
];
33 int Dfileused
= FALSE
;
34 static char jobid
[NAMESIZE
];
36 extern void wfcommit(), wfremove(), putdfiles();
37 extern int job_size(), fgrade(), retseq();
41 * commit any and all saved C files
51 char cmfile
[NAMESIZE
+5];
55 for (i
= 0; i
< ncsave
; i
++) {
57 if ((job_size(&csave
[i
]) == FAIL
) ||
58 (fgrade(&csave
[i
]) == FAIL
)) {
59 wfremove(csave
[i
].file
);
65 csave
[i
].grade
= Grade
;
68 /* make new file name for for the job */
71 n
= retseq(csave
[i
].sys
);
72 (void) sprintf(cmfile
, "%c.%.*s%c%.4x", *csave
[i
].file
,
73 SYSNSIZE
, csave
[i
].sys
, csave
[i
].grade
, n
);
76 (void) strncpy(cmfile
, csave
[i
].file
, NAMESIZE
-1);
77 cmfile
[NAMESIZE
-1] = '\0';
79 DEBUG(9, "User job queued to %c queue\n", csave
[i
].grade
);
80 (void) sprintf(sys
, "/%c", csave
[i
].grade
);
81 (void) strcat(csave
[i
].sys
, sys
);
86 wfcommit(csave
[i
].file
, cmfile
, csave
[i
].sys
);
87 (void) strncpy(csave
[i
].file
, cmfile
, NAMESIZE
);
94 (void) strncpy(jobid
, BASENAME(csave
[0].file
, '.'), NAMESIZE
);
99 * gtcfile - copy into file the name of the saved C file for system sys
102 * SUCCESS -> found one
113 for (i
= 0; i
< ncsave
; i
++)
114 if (strncmp(sys
, csave
[i
].sys
, SYSNSIZE
) == SAME
) {
115 (void) strncpy(file
, csave
[i
].file
, NAMESIZE
-1);
123 * jid - returns the real job id of this uucp file transfer
137 * svcfile - save the name of a C. file for system sys for re-using
143 svcfile(file
, sys
, grd
)
144 char *file
, *sys
, *grd
;
146 ASSERT(ncsave
< NCSAVE
, "TOO MANY SAVED C FILES", "", ncsave
);
147 (void) strncpy(csave
[ncsave
].file
, BASENAME(file
, '/'), NAMESIZE
-1);
148 (void) strncpy(csave
[ncsave
].sys
, sys
, NAMESIZE
-1);
149 (void) strncpy (csave
[ncsave
].sgrade
, grd
, NAMESIZE
-1);
159 for (i
= 0; i
< ncsave
; i
++)
160 wfremove(csave
[i
].file
);
166 * wfcommit - move wfile1 in current directory to SPOOL/sys/dir/wfile2
172 wfcommit(wfile1
, wfile2
, sys
)
173 char *wfile1
, *wfile2
, *sys
;
175 char cmitfile
[MAXFULLNAME
];
176 char remote
[NAMESIZE
];
180 /* make remote directory if it does not exist */
182 (void) strncpy(remote
, sys
, NAMESIZE
);
183 if ((p
= strchr(remote
, '/')) != NULL
) {
186 DEBUG(6, "create remote spool area %s\n", remote
);
191 DEBUG(6, "create service grade directory %s under remote spool\n", p
);
193 DEBUG(6, "create remote spool area %s\n", sys
);
197 DEBUG(6, "commit %s ", wfile1
);
199 fileBase
= BASENAME(wfile2
, '/');
200 sprintf(cmitfile
, "%s/%s", RemSpool
, fileBase
);
201 DEBUG(6, "to %s\n", cmitfile
);
203 ASSERT(access(cmitfile
, 0) != 0, Fl_EXISTS
, cmitfile
, 0);
204 ASSERT(xmv(wfile1
, cmitfile
) == 0, Ct_LINK
, cmitfile
, errno
);