Deleted Added
full compact
recvjob.c (50479) recvjob.c (68253)
1/*
2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 29 unchanged lines hidden (view full) ---

38 The Regents of the University of California. All rights reserved.\n";
39#endif /* not lint */
40
41#ifndef lint
42#if 0
43static char sccsid[] = "@(#)recvjob.c 8.2 (Berkeley) 4/27/95";
44#endif
45static const char rcsid[] =
1/*
2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 29 unchanged lines hidden (view full) ---

38 The Regents of the University of California. All rights reserved.\n";
39#endif /* not lint */
40
41#ifndef lint
42#if 0
43static char sccsid[] = "@(#)recvjob.c 8.2 (Berkeley) 4/27/95";
44#endif
45static const char rcsid[] =
46 "$FreeBSD: head/usr.sbin/lpr/lpd/recvjob.c 50479 1999-08-28 01:35:59Z peter $";
46 "$FreeBSD: head/usr.sbin/lpr/lpd/recvjob.c 68253 2000-11-02 19:22:06Z gad $";
47#endif /* not lint */
48
49/*
50 * Receive printer jobs from the network, queue them and
51 * start the printer daemon.
52 */
53#include <sys/param.h>
54#include <sys/mount.h>

--- 81 unchanged lines hidden (view full) ---

136/*
137 * Read printer jobs sent by lpd and copy them to the spooling directory.
138 * Return the number of jobs successfully transfered.
139 */
140static int
141readjob(pp)
142 struct printer *pp;
143{
47#endif /* not lint */
48
49/*
50 * Receive printer jobs from the network, queue them and
51 * start the printer daemon.
52 */
53#include <sys/param.h>
54#include <sys/mount.h>

--- 81 unchanged lines hidden (view full) ---

136/*
137 * Read printer jobs sent by lpd and copy them to the spooling directory.
138 * Return the number of jobs successfully transfered.
139 */
140static int
141readjob(pp)
142 struct printer *pp;
143{
144 register int size, nfiles;
144 register int size;
145 register char *cp;
145 register char *cp;
146 int cfcnt, dfcnt;
147 char givenid[32], givenhost[MAXHOSTNAMELEN];
146
147 ack();
148
149 ack();
148 nfiles = 0;
150 cfcnt = 0;
151 dfcnt = 0;
149 for (;;) {
150 /*
151 * Read a command to tell us what to do
152 */
153 cp = line;
154 do {
155 if ((size = read(1, cp, 1)) != 1) {
156 if (size < 0)
157 frecverr("%s: lost connection",
158 pp->printer);
152 for (;;) {
153 /*
154 * Read a command to tell us what to do
155 */
156 cp = line;
157 do {
158 if ((size = read(1, cp, 1)) != 1) {
159 if (size < 0)
160 frecverr("%s: lost connection",
161 pp->printer);
159 return(nfiles);
162 return (cfcnt);
160 }
161 } while (*cp++ != '\n' && (cp - line + 1) < sizeof(line));
162 if (cp - line + 1 >= sizeof(line))
163 frecverr("readjob overflow");
164 *--cp = '\0';
165 cp = line;
166 switch (*cp++) {
167 case '\1': /* cleanup because data sent was bad */
168 rcleanup(0);
169 continue;
170
171 case '\2': /* read cf file */
172 size = 0;
163 }
164 } while (*cp++ != '\n' && (cp - line + 1) < sizeof(line));
165 if (cp - line + 1 >= sizeof(line))
166 frecverr("readjob overflow");
167 *--cp = '\0';
168 cp = line;
169 switch (*cp++) {
170 case '\1': /* cleanup because data sent was bad */
171 rcleanup(0);
172 continue;
173
174 case '\2': /* read cf file */
175 size = 0;
176 dfcnt = 0;
173 while (*cp >= '0' && *cp <= '9')
174 size = size * 10 + (*cp++ - '0');
175 if (*cp++ != ' ')
176 break;
177 /*
178 * host name has been authenticated, we use our
179 * view of the host name since we may be passed
180 * something different than what gethostbyaddr()

--- 14 unchanged lines hidden (view full) ---

195 if (!readfile(tfname, size)) {
196 rcleanup(0);
197 continue;
198 }
199 if (link(tfname, cp) < 0)
200 frecverr("%s: %m", tfname);
201 (void) unlink(tfname);
202 tfname[0] = '\0';
177 while (*cp >= '0' && *cp <= '9')
178 size = size * 10 + (*cp++ - '0');
179 if (*cp++ != ' ')
180 break;
181 /*
182 * host name has been authenticated, we use our
183 * view of the host name since we may be passed
184 * something different than what gethostbyaddr()

--- 14 unchanged lines hidden (view full) ---

199 if (!readfile(tfname, size)) {
200 rcleanup(0);
201 continue;
202 }
203 if (link(tfname, cp) < 0)
204 frecverr("%s: %m", tfname);
205 (void) unlink(tfname);
206 tfname[0] = '\0';
203 nfiles++;
207 cfcnt++;
204 continue;
205
206 case '\3': /* read df file */
208 continue;
209
210 case '\3': /* read df file */
211 *givenid = '\0';
212 *givenhost = '\0';
207 size = 0;
208 while (*cp >= '0' && *cp <= '9')
209 size = size * 10 + (*cp++ - '0');
210 if (*cp++ != ' ')
211 break;
212 if (!chksize(size)) {
213 (void) write(1, "\2", 1);
214 continue;
215 }
216 (void) strncpy(dfname, cp, sizeof(dfname) - 1);
217 dfname[sizeof(dfname) - 1] = '\0';
218 if (strchr(dfname, '/'))
219 frecverr("readjob: %s: illegal path name",
220 dfname);
213 size = 0;
214 while (*cp >= '0' && *cp <= '9')
215 size = size * 10 + (*cp++ - '0');
216 if (*cp++ != ' ')
217 break;
218 if (!chksize(size)) {
219 (void) write(1, "\2", 1);
220 continue;
221 }
222 (void) strncpy(dfname, cp, sizeof(dfname) - 1);
223 dfname[sizeof(dfname) - 1] = '\0';
224 if (strchr(dfname, '/'))
225 frecverr("readjob: %s: illegal path name",
226 dfname);
227 dfcnt++;
228 trstat_init(pp, dfname, dfcnt);
221 (void) readfile(dfname, size);
229 (void) readfile(dfname, size);
230 trstat_write(pp, TR_RECVING, size, givenid, from,
231 givenhost);
222 continue;
223 }
224 frecverr("protocol screwup: %s", line);
225 }
226}
227
228/*
229 * Read files send by lpd and copy them to the spooling directory.

--- 147 unchanged lines hidden ---
232 continue;
233 }
234 frecverr("protocol screwup: %s", line);
235 }
236}
237
238/*
239 * Read files send by lpd and copy them to the spooling directory.

--- 147 unchanged lines hidden ---