Deleted Added
full compact
recvjob.c (118881) recvjob.c (119192)
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:

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

40
41#if 0
42#ifndef lint
43static char sccsid[] = "@(#)recvjob.c 8.2 (Berkeley) 4/27/95";
44#endif /* not lint */
45#endif
46
47#include "lp.cdefs.h" /* A cross-platform version of <sys/cdefs.h> */
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:

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

40
41#if 0
42#ifndef lint
43static char sccsid[] = "@(#)recvjob.c 8.2 (Berkeley) 4/27/95";
44#endif /* not lint */
45#endif
46
47#include "lp.cdefs.h" /* A cross-platform version of <sys/cdefs.h> */
48__FBSDID("$FreeBSD: head/usr.sbin/lpr/lpd/recvjob.c 118881 2003-08-13 20:31:33Z gad $");
48__FBSDID("$FreeBSD: head/usr.sbin/lpr/lpd/recvjob.c 119192 2003-08-21 03:43:48Z gad $");
49
50/*
51 * Receive printer jobs from the network, queue them and
52 * start the printer daemon.
53 */
54#include <sys/param.h>
55#include <sys/mount.h>
56#include <sys/stat.h>

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

67#include "lp.h"
68#include "lp.local.h"
69#include "ctlinfo.h"
70#include "extern.h"
71#include "pathnames.h"
72
73#define ack() (void) write(STDOUT_FILENO, sp, (size_t)1);
74
49
50/*
51 * Receive printer jobs from the network, queue them and
52 * start the printer daemon.
53 */
54#include <sys/param.h>
55#include <sys/mount.h>
56#include <sys/stat.h>

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

67#include "lp.h"
68#include "lp.local.h"
69#include "ctlinfo.h"
70#include "extern.h"
71#include "pathnames.h"
72
73#define ack() (void) write(STDOUT_FILENO, sp, (size_t)1);
74
75/*
76 * The buffer size to use when reading/writing spool files.
77 */
78#define SPL_BUFSIZ BUFSIZ
79
75static char dfname[NAME_MAX]; /* data files */
76static int minfree; /* keep at least minfree blocks available */
77static const char *sp = "";
78static char tfname[NAME_MAX]; /* tmp copy of cf before linking */
79
80static int chksize(int _size);
81static void frecverr(const char *_msg, ...) __printf0like(1, 2);
82static int noresponse(void);

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

250
251/*
252 * Read files send by lpd and copy them to the spooling directory.
253 */
254static int
255readfile(struct printer *pp, char *file, size_t size)
256{
257 register char *cp;
80static char dfname[NAME_MAX]; /* data files */
81static int minfree; /* keep at least minfree blocks available */
82static const char *sp = "";
83static char tfname[NAME_MAX]; /* tmp copy of cf before linking */
84
85static int chksize(int _size);
86static void frecverr(const char *_msg, ...) __printf0like(1, 2);
87static int noresponse(void);

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

255
256/*
257 * Read files send by lpd and copy them to the spooling directory.
258 */
259static int
260readfile(struct printer *pp, char *file, size_t size)
261{
262 register char *cp;
258 char buf[BUFSIZ];
263 char buf[SPL_BUFSIZ];
259 size_t amt, i;
260 int err, fd, j;
261
262 fd = open(file, O_CREAT|O_EXCL|O_WRONLY, FILMOD);
263 if (fd < 0) {
264 frecverr("%s: readfile: error on open(%s): %s",
265 pp->printer, file, strerror(errno));
266 /*NOTREACHED*/
267 }
268 ack();
269 err = 0;
264 size_t amt, i;
265 int err, fd, j;
266
267 fd = open(file, O_CREAT|O_EXCL|O_WRONLY, FILMOD);
268 if (fd < 0) {
269 frecverr("%s: readfile: error on open(%s): %s",
270 pp->printer, file, strerror(errno));
271 /*NOTREACHED*/
272 }
273 ack();
274 err = 0;
270 for (i = 0; i < size; i += BUFSIZ) {
271 amt = BUFSIZ;
275 for (i = 0; i < size; i += SPL_BUFSIZ) {
276 amt = SPL_BUFSIZ;
272 cp = buf;
273 if (i + amt > size)
274 amt = size - i;
275 do {
276 j = read(STDOUT_FILENO, cp, amt);
277 if (j <= 0) {
278 frecverr("%s: lost connection", pp->printer);
279 /*NOTREACHED*/
280 }
281 amt -= j;
282 cp += j;
283 } while (amt > 0);
277 cp = buf;
278 if (i + amt > size)
279 amt = size - i;
280 do {
281 j = read(STDOUT_FILENO, cp, amt);
282 if (j <= 0) {
283 frecverr("%s: lost connection", pp->printer);
284 /*NOTREACHED*/
285 }
286 amt -= j;
287 cp += j;
288 } while (amt > 0);
284 amt = BUFSIZ;
289 amt = SPL_BUFSIZ;
285 if (i + amt > size)
286 amt = size - i;
287 if (write(fd, buf, amt) != (ssize_t)amt) {
288 err++;
289 break;
290 }
291 }
292 (void) close(fd);

--- 112 unchanged lines hidden ---
290 if (i + amt > size)
291 amt = size - i;
292 if (write(fd, buf, amt) != (ssize_t)amt) {
293 err++;
294 break;
295 }
296 }
297 (void) close(fd);

--- 112 unchanged lines hidden ---