Deleted Added
full compact
printjob.c (118881) printjob.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[] = "@(#)printjob.c 8.7 (Berkeley) 5/10/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[] = "@(#)printjob.c 8.7 (Berkeley) 5/10/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/printjob.c 118881 2003-08-13 20:31:33Z gad $");
48__FBSDID("$FreeBSD: head/usr.sbin/lpr/lpd/printjob.c 119192 2003-08-21 03:43:48Z gad $");
49
50/*
51 * printjob -- print jobs in the queue.
52 *
53 * NOTE: the lock file is used to pass information to lpq and lprm.
54 * it does not need to be removed because file locks are dynamic.
55 */
56

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

76#include "lp.local.h"
77#include "pathnames.h"
78#include "extern.h"
79
80#define DORETURN 0 /* dofork should return "can't fork" error */
81#define DOABORT 1 /* dofork should just die if fork() fails */
82
83/*
49
50/*
51 * printjob -- print jobs in the queue.
52 *
53 * NOTE: the lock file is used to pass information to lpq and lprm.
54 * it does not need to be removed because file locks are dynamic.
55 */
56

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

76#include "lp.local.h"
77#include "pathnames.h"
78#include "extern.h"
79
80#define DORETURN 0 /* dofork should return "can't fork" error */
81#define DOABORT 1 /* dofork should just die if fork() fails */
82
83/*
84 * The buffer size to use when reading/writing spool files.
85 */
86#define SPL_BUFSIZ BUFSIZ
87
88/*
84 * Error tokens
85 */
86#define REPRINT -2
87#define ERROR -1
88#define OK 0
89#define FATALERR 1
90#define NOACCT 2
91#define FILTERERR 3

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

602 */
603static int
604print(struct printer *pp, int format, char *file)
605{
606 register int n, i;
607 register char *prog;
608 int fi, fo;
609 FILE *fp;
89 * Error tokens
90 */
91#define REPRINT -2
92#define ERROR -1
93#define OK 0
94#define FATALERR 1
95#define NOACCT 2
96#define FILTERERR 3

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

607 */
608static int
609print(struct printer *pp, int format, char *file)
610{
611 register int n, i;
612 register char *prog;
613 int fi, fo;
614 FILE *fp;
610 char *av[15], buf[BUFSIZ];
615 char *av[15], buf[SPL_BUFSIZ];
611 pid_t wpid;
612 int p[2], retcode, stopped, wstatus, wstatus_set;
613 struct stat stb;
614
615 if (lstat(file, &stb) < 0 || (fi = open(file, O_RDONLY)) < 0) {
616 syslog(LOG_INFO, "%s: unable to open %s ('%c' line)",
617 pp->printer, file, format);
618 return (ERROR);

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

632 /* everything seems OK, start it up */
633 if (!pp->no_formfeed && !pp->tof) { /* start on a fresh page */
634 (void) write(ofd, pp->form_feed, strlen(pp->form_feed));
635 pp->tof = 1;
636 }
637 if (pp->filters[LPF_INPUT] == NULL
638 && (format == 'f' || format == 'l' || format == 'o')) {
639 pp->tof = 0;
616 pid_t wpid;
617 int p[2], retcode, stopped, wstatus, wstatus_set;
618 struct stat stb;
619
620 if (lstat(file, &stb) < 0 || (fi = open(file, O_RDONLY)) < 0) {
621 syslog(LOG_INFO, "%s: unable to open %s ('%c' line)",
622 pp->printer, file, format);
623 return (ERROR);

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

637 /* everything seems OK, start it up */
638 if (!pp->no_formfeed && !pp->tof) { /* start on a fresh page */
639 (void) write(ofd, pp->form_feed, strlen(pp->form_feed));
640 pp->tof = 1;
641 }
642 if (pp->filters[LPF_INPUT] == NULL
643 && (format == 'f' || format == 'l' || format == 'o')) {
644 pp->tof = 0;
640 while ((n = read(fi, buf, BUFSIZ)) > 0)
645 while ((n = read(fi, buf, SPL_BUFSIZ)) > 0)
641 if (write(ofd, buf, n) != n) {
642 (void) close(fi);
643 return (REPRINT);
644 }
645 (void) close(fi);
646 return (OK);
647 }
648 switch (format) {

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

875 * Send the daemon control file (cf) and any data files.
876 * Return -1 if a non-recoverable error occured, 1 if a recoverable error and
877 * 0 if all is well.
878 */
879static int
880sendit(struct printer *pp, char *file)
881{
882 int dfcopies, err, i;
646 if (write(ofd, buf, n) != n) {
647 (void) close(fi);
648 return (REPRINT);
649 }
650 (void) close(fi);
651 return (OK);
652 }
653 switch (format) {

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

880 * Send the daemon control file (cf) and any data files.
881 * Return -1 if a non-recoverable error occured, 1 if a recoverable error and
882 * 0 if all is well.
883 */
884static int
885sendit(struct printer *pp, char *file)
886{
887 int dfcopies, err, i;
883 char *cp, last[BUFSIZ];
888 char *cp, last[sizeof(line)];
884
885 /*
886 * open control file
887 */
888 if ((cfp = fopen(file, "r")) == NULL)
889 return (OK);
890
891 /* initialize job-specific count of datafiles processed */

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

984 * Return positive if we should try resending.
985 */
986static int
987sendfile(struct printer *pp, int type, char *file, char format, int copyreq)
988{
989 int i, amt;
990 struct stat stb;
991 char *av[15], *filtcmd;
889
890 /*
891 * open control file
892 */
893 if ((cfp = fopen(file, "r")) == NULL)
894 return (OK);
895
896 /* initialize job-specific count of datafiles processed */

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

989 * Return positive if we should try resending.
990 */
991static int
992sendfile(struct printer *pp, int type, char *file, char format, int copyreq)
993{
994 int i, amt;
995 struct stat stb;
996 char *av[15], *filtcmd;
992 char buf[BUFSIZ], opt_c[4], opt_h[4], opt_n[4];
997 char buf[SPL_BUFSIZ], opt_c[4], opt_h[4], opt_n[4];
993 int copycnt, filtstat, narg, resp, sfd, sfres, sizerr, statrc;
994
995 statrc = lstat(file, &stb);
996 if (statrc < 0) {
997 syslog(LOG_ERR, "%s: error from lstat(%s): %m",
998 pp->printer, file);
999 return (ERROR);
1000 }

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

1145 if (i)
1146 pstatus(pp, "sending to %s", pp->remote_host);
1147 /*
1148 * XXX - we should change trstat_init()/trstat_write() to include
1149 * the copycnt in the statistics record it may write.
1150 */
1151 if (type == '\3')
1152 trstat_init(pp, file, job_dfcnt);
998 int copycnt, filtstat, narg, resp, sfd, sfres, sizerr, statrc;
999
1000 statrc = lstat(file, &stb);
1001 if (statrc < 0) {
1002 syslog(LOG_ERR, "%s: error from lstat(%s): %m",
1003 pp->printer, file);
1004 return (ERROR);
1005 }

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

1150 if (i)
1151 pstatus(pp, "sending to %s", pp->remote_host);
1152 /*
1153 * XXX - we should change trstat_init()/trstat_write() to include
1154 * the copycnt in the statistics record it may write.
1155 */
1156 if (type == '\3')
1157 trstat_init(pp, file, job_dfcnt);
1153 for (i = 0; i < stb.st_size; i += BUFSIZ) {
1154 amt = BUFSIZ;
1158 for (i = 0; i < stb.st_size; i += SPL_BUFSIZ) {
1159 amt = SPL_BUFSIZ;
1155 if (i + amt > stb.st_size)
1156 amt = stb.st_size - i;
1157 if (sizerr == 0 && read(sfd, buf, amt) != amt)
1158 sizerr = 1;
1159 if (write(pfd, buf, amt) != amt) {
1160 sfres = REPRINT;
1161 goto return_sfres;
1162 }

--- 730 unchanged lines hidden ---
1160 if (i + amt > stb.st_size)
1161 amt = stb.st_size - i;
1162 if (sizerr == 0 && read(sfd, buf, amt) != amt)
1163 sizerr = 1;
1164 if (write(pfd, buf, amt) != amt) {
1165 sfres = REPRINT;
1166 goto return_sfres;
1167 }

--- 730 unchanged lines hidden ---