8349 thrd_equal implements the wrong specification
[unleashed.git] / usr / src / cmd / bnu / gtcfile.c
blob6468b3134c040a48f72f247cca34aecd07181405
1 /*
2 * CDDL HEADER START
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
7 * with the License.
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]
20 * CDDL HEADER END
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 */
28 #include "uucp.h"
30 #define NCSAVE 30 /* no more than 30 saved C files, please */
31 static int ncsave;
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();
39 /* commitall()
41 * commit any and all saved C files
43 * returns
44 * nothing
47 void
48 commitall()
50 char sys[NAMESIZE+5];
51 char cmfile[NAMESIZE+5];
52 int i;
53 int n;
55 for (i = 0; i < ncsave; i++) {
56 if (Sgrades) {
57 if ((job_size(&csave[i]) == FAIL) ||
58 (fgrade(&csave[i]) == FAIL)) {
59 wfremove(csave[i].file);
60 continue;
63 else {
64 Dfileused = TRUE;
65 csave[i].grade = Grade;
68 /* make new file name for for the job */
70 if (Sgrades) {
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);
75 else
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);
82 if (Dfileused) {
83 putdfiles(csave[i]);
84 Dfileused = FALSE;
86 wfcommit(csave[i].file, cmfile, csave[i].sys);
87 (void) strncpy(csave[i].file, cmfile, NAMESIZE);
90 ncsave = 0;
92 /* set real jobid */
94 (void) strncpy(jobid, BASENAME(csave[0].file, '.'), NAMESIZE);
95 return;
99 * gtcfile - copy into file the name of the saved C file for system sys
101 * returns
102 * SUCCESS -> found one
103 * FAIL -> none saved
108 gtcfile(file, sys)
109 char *file, *sys;
111 register int i;
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);
116 return(SUCCESS);
119 return(FAIL);
123 * jid - returns the real job id of this uucp file transfer
125 * returns
126 * jobid
130 char *
131 jid()
133 return(jobid);
137 * svcfile - save the name of a C. file for system sys for re-using
138 * returns
139 * none
142 void
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);
150 ncsave++;
151 return;
154 void
155 wfabort()
157 register int i;
159 for (i = 0; i < ncsave; i++)
160 wfremove(csave[i].file);
161 ncsave = 0;
162 return;
166 * wfcommit - move wfile1 in current directory to SPOOL/sys/dir/wfile2
167 * return
168 * none
171 void
172 wfcommit(wfile1, wfile2, sys)
173 char *wfile1, *wfile2, *sys;
175 char cmitfile[MAXFULLNAME];
176 char remote[NAMESIZE];
177 char *fileBase;
178 char *p;
180 /* make remote directory if it does not exist */
182 (void) strncpy(remote, sys, NAMESIZE);
183 if ((p = strchr(remote, '/')) != NULL) {
184 *p++ = '\0';
186 DEBUG(6, "create remote spool area %s\n", remote);
187 mkremdir(remote);
190 if (p != NULL)
191 DEBUG(6, "create service grade directory %s under remote spool\n", p);
192 else
193 DEBUG(6, "create remote spool area %s\n", sys);
195 mkremdir(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);
205 return;