Deleted Added
full compact
printjob.c (60871) printjob.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/*
43static char sccsid[] = "@(#)printjob.c 8.7 (Berkeley) 5/10/95";
44*/
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/*
43static char sccsid[] = "@(#)printjob.c 8.7 (Berkeley) 5/10/95";
44*/
45static const char rcsid[] =
46 "$FreeBSD: head/usr.sbin/lpr/lpd/printjob.c 60871 2000-05-24 11:38:50Z mpp $";
46 "$FreeBSD: head/usr.sbin/lpr/lpd/printjob.c 68253 2000-11-02 19:22:06Z gad $";
47#endif /* not lint */
48
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.

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

90#define NOACCT 2
91#define FILTERERR 3
92#define ACCESS 4
93
94static dev_t fdev; /* device of file pointed to by symlink */
95static ino_t fino; /* inode of file pointed to by symlink */
96static FILE *cfp; /* control file */
97static int child; /* id of any filters */
47#endif /* not lint */
48
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.

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

90#define NOACCT 2
91#define FILTERERR 3
92#define ACCESS 4
93
94static dev_t fdev; /* device of file pointed to by symlink */
95static ino_t fino; /* inode of file pointed to by symlink */
96static FILE *cfp; /* control file */
97static int child; /* id of any filters */
98static int job_dfcnt; /* count of datafiles in current user job */
98static int lfd; /* lock file descriptor */
99static int ofd; /* output filter file descriptor */
100static int ofilter; /* id of output filter, if any */
101static int tfd = -1; /* output filter temp file output */
102static int pfd; /* prstatic inter file descriptor */
103static int pid; /* pid of lpd process */
104static int prchild; /* id of pr process */
105static char title[80]; /* ``pr'' title */

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

351 /*
352 * Reset troff fonts.
353 */
354 for (i = 0; i < 4; i++)
355 strcpy(fonts[i], ifonts[i]);
356 sprintf(&width[2], "%ld", pp->page_width);
357 strcpy(indent+2, "0");
358
99static int lfd; /* lock file descriptor */
100static int ofd; /* output filter file descriptor */
101static int ofilter; /* id of output filter, if any */
102static int tfd = -1; /* output filter temp file output */
103static int pfd; /* prstatic inter file descriptor */
104static int pid; /* pid of lpd process */
105static int prchild; /* id of pr process */
106static char title[80]; /* ``pr'' title */

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

352 /*
353 * Reset troff fonts.
354 */
355 for (i = 0; i < 4; i++)
356 strcpy(fonts[i], ifonts[i]);
357 sprintf(&width[2], "%ld", pp->page_width);
358 strcpy(indent+2, "0");
359
360 /* initialize job-specific count of datafiles processed */
361 job_dfcnt = 0;
362
359 /*
360 * read the control file for work to do
361 *
362 * file format -- first character in the line is a command
363 * rest of the line is the argument.
364 * valid commands are:
365 *
366 * S -- "stat info" for symbolic link protection

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

567 /*
568 * Check to see if data file is a symbolic link. If so, it should
569 * still point to the same file or someone is trying to print
570 * something he shouldn't.
571 */
572 if ((stb.st_mode & S_IFMT) == S_IFLNK && fstat(fi, &stb) == 0 &&
573 (stb.st_dev != fdev || stb.st_ino != fino))
574 return(ACCESS);
363 /*
364 * read the control file for work to do
365 *
366 * file format -- first character in the line is a command
367 * rest of the line is the argument.
368 * valid commands are:
369 *
370 * S -- "stat info" for symbolic link protection

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

571 /*
572 * Check to see if data file is a symbolic link. If so, it should
573 * still point to the same file or someone is trying to print
574 * something he shouldn't.
575 */
576 if ((stb.st_mode & S_IFMT) == S_IFLNK && fstat(fi, &stb) == 0 &&
577 (stb.st_dev != fdev || stb.st_ino != fino))
578 return(ACCESS);
579
580 job_dfcnt++; /* increment datafile counter for this job */
581
582 /* everything seems OK, start it up */
575 if (!pp->no_formfeed && !pp->tof) { /* start on a fresh page */
576 (void) write(ofd, pp->form_feed, strlen(pp->form_feed));
577 pp->tof = 1;
578 }
579 if (pp->filters[LPF_INPUT] == NULL
580 && (format == 'f' || format == 'l')) {
581 pp->tof = 0;
582 while ((n = read(fi, buf, BUFSIZ)) > 0)

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

798 register int i, err = OK;
799 char *cp, last[BUFSIZ];
800
801 /*
802 * open control file
803 */
804 if ((cfp = fopen(file, "r")) == NULL)
805 return(OK);
583 if (!pp->no_formfeed && !pp->tof) { /* start on a fresh page */
584 (void) write(ofd, pp->form_feed, strlen(pp->form_feed));
585 pp->tof = 1;
586 }
587 if (pp->filters[LPF_INPUT] == NULL
588 && (format == 'f' || format == 'l')) {
589 pp->tof = 0;
590 while ((n = read(fi, buf, BUFSIZ)) > 0)

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

806 register int i, err = OK;
807 char *cp, last[BUFSIZ];
808
809 /*
810 * open control file
811 */
812 if ((cfp = fopen(file, "r")) == NULL)
813 return(OK);
814
815 /* initialize job-specific count of datafiles processed */
816 job_dfcnt = 0;
817
806 /*
807 * read the control file for work to do
808 *
809 * file format -- first character in the line is a command
810 * rest of the line is the argument.
811 * commands of interest are:
812 *
813 * a-z -- "file name" name of file to print

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

908 * Check to see if data file is a symbolic link. If so, it should
909 * still point to the same file or someone is trying to print something
910 * he shouldn't.
911 */
912 if ((stb.st_mode & S_IFMT) == S_IFLNK && fstat(f, &stb) == 0 &&
913 (stb.st_dev != fdev || stb.st_ino != fino))
914 return(ACCESS);
915
818 /*
819 * read the control file for work to do
820 *
821 * file format -- first character in the line is a command
822 * rest of the line is the argument.
823 * commands of interest are:
824 *
825 * a-z -- "file name" name of file to print

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

920 * Check to see if data file is a symbolic link. If so, it should
921 * still point to the same file or someone is trying to print something
922 * he shouldn't.
923 */
924 if ((stb.st_mode & S_IFMT) == S_IFLNK && fstat(f, &stb) == 0 &&
925 (stb.st_dev != fdev || stb.st_ino != fino))
926 return(ACCESS);
927
928 job_dfcnt++; /* increment datafile counter for this job */
929
930 /* everything seems OK, start it up */
916 sizerr = 0;
917 closedpr = 0;
918 if (type == '\3') {
919 if (pp->filters[LPF_INPUT]) {
920 /*
921 * We're sending something with an ifilter, we have to
922 * run the ifilter and store the output as a
923 * temporary file (tfile)... the protocol requires us

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

1046 "no space on remote; waiting for queue to drain");
1047 if (i == 10)
1048 syslog(LOG_ALERT, "%s: can't send to %s; queue full",
1049 pp->printer, pp->remote_host);
1050 sleep(5 * 60);
1051 }
1052 if (i)
1053 pstatus(pp, "sending to %s", pp->remote_host);
931 sizerr = 0;
932 closedpr = 0;
933 if (type == '\3') {
934 if (pp->filters[LPF_INPUT]) {
935 /*
936 * We're sending something with an ifilter, we have to
937 * run the ifilter and store the output as a
938 * temporary file (tfile)... the protocol requires us

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

1061 "no space on remote; waiting for queue to drain");
1062 if (i == 10)
1063 syslog(LOG_ALERT, "%s: can't send to %s; queue full",
1064 pp->printer, pp->remote_host);
1065 sleep(5 * 60);
1066 }
1067 if (i)
1068 pstatus(pp, "sending to %s", pp->remote_host);
1069 if (type == '\3')
1070 trstat_init(pp, file, job_dfcnt);
1054 for (i = 0; i < stb.st_size; i += BUFSIZ) {
1055 amt = BUFSIZ;
1056 if (i + amt > stb.st_size)
1057 amt = stb.st_size - i;
1058 if (sizerr == 0 && read(f, buf, amt) != amt)
1059 sizerr = 1;
1060 if (write(pfd, buf, amt) != amt) {
1061 (void) close(f);

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

1084 }
1085 if (write(pfd, "", 1) != 1 || response(pp)) {
1086 if (closedpr)
1087 openpr(pp);
1088 return(REPRINT);
1089 }
1090 if (closedpr)
1091 openpr(pp);
1071 for (i = 0; i < stb.st_size; i += BUFSIZ) {
1072 amt = BUFSIZ;
1073 if (i + amt > stb.st_size)
1074 amt = stb.st_size - i;
1075 if (sizerr == 0 && read(f, buf, amt) != amt)
1076 sizerr = 1;
1077 if (write(pfd, buf, amt) != amt) {
1078 (void) close(f);

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

1101 }
1102 if (write(pfd, "", 1) != 1 || response(pp)) {
1103 if (closedpr)
1104 openpr(pp);
1105 return(REPRINT);
1106 }
1107 if (closedpr)
1108 openpr(pp);
1109 if (type == '\3')
1110 trstat_write(pp, TR_SENDING, stb.st_size, logname,
1111 pp->remote_host, fromhost);
1092 return(OK);
1093}
1094
1095/*
1096 * Check to make sure there have been no errors and that both programs
1097 * are in sync with eachother.
1098 * Return non-zero if the connection was lost.
1099 */

--- 572 unchanged lines hidden ---
1112 return(OK);
1113}
1114
1115/*
1116 * Check to make sure there have been no errors and that both programs
1117 * are in sync with eachother.
1118 * Return non-zero if the connection was lost.
1119 */

--- 572 unchanged lines hidden ---