Deleted Added
full compact
printjob.c (79739) printjob.c (80133)
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 79739 2001-07-15 00:09:46Z gad $";
46 "$FreeBSD: head/usr.sbin/lpr/lpd/printjob.c 80133 2001-07-22 07:25:27Z 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.

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

426
427 /* pass 1 */
428
429 while (getline(cfp))
430 switch (line[0]) {
431 case 'H':
432 strlcpy(origin_host, line + 1, sizeof(origin_host));
433 if (class[0] == '\0') {
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.

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

426
427 /* pass 1 */
428
429 while (getline(cfp))
430 switch (line[0]) {
431 case 'H':
432 strlcpy(origin_host, line + 1, sizeof(origin_host));
433 if (class[0] == '\0') {
434 strncpy(class, line+1, sizeof(class) - 1);
435 class[sizeof(class) - 1] = '\0';
434 strlcpy(class, line+1, sizeof(class));
436 }
437 continue;
438
439 case 'P':
435 }
436 continue;
437
438 case 'P':
440 strncpy(logname, line+1, sizeof(logname) - 1);
441 logname[sizeof(logname) - 1] = '\0';
439 strlcpy(logname, line + 1, sizeof(logname));
442 if (pp->restricted) { /* restricted */
443 if (getpwnam(logname) == NULL) {
444 bombed = NOACCT;
445 sendmail(pp, line+1, bombed);
446 goto pass2;
447 }
448 }
449 continue;

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

458 i = 0;
459 while (*cp >= '0' && *cp <= '9')
460 i = i * 10 + (*cp++ - '0');
461 fino = i;
462 continue;
463
464 case 'J':
465 if (line[1] != '\0') {
440 if (pp->restricted) { /* restricted */
441 if (getpwnam(logname) == NULL) {
442 bombed = NOACCT;
443 sendmail(pp, line+1, bombed);
444 goto pass2;
445 }
446 }
447 continue;

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

456 i = 0;
457 while (*cp >= '0' && *cp <= '9')
458 i = i * 10 + (*cp++ - '0');
459 fino = i;
460 continue;
461
462 case 'J':
463 if (line[1] != '\0') {
466 strncpy(jobname, line+1, sizeof(jobname) - 1);
467 jobname[sizeof(jobname) - 1] = '\0';
464 strlcpy(jobname, line + 1, sizeof(jobname));
468 } else
469 strcpy(jobname, " ");
470 continue;
471
472 case 'C':
473 if (line[1] != '\0')
465 } else
466 strcpy(jobname, " ");
467 continue;
468
469 case 'C':
470 if (line[1] != '\0')
474 strncpy(class, line+1, sizeof(class) - 1);
475 else if (class[0] == '\0')
471 strlcpy(class, line + 1, sizeof(class));
472 else if (class[0] == '\0') {
473 /* XXX - why call gethostname instead of
474 * just strlcpy'ing local_host? */
476 gethostname(class, sizeof(class));
475 gethostname(class, sizeof(class));
477 class[sizeof(class) - 1] = '\0';
476 class[sizeof(class) - 1] = '\0';
477 }
478 continue;
479
480 case 'T': /* header title for pr */
478 continue;
479
480 case 'T': /* header title for pr */
481 strncpy(title, line+1, sizeof(title) - 1);
482 title[sizeof(title) - 1] = '\0';
481 strlcpy(title, line + 1, sizeof(title));
483 continue;
484
485 case 'L': /* identification line */
486 if (!pp->no_header && !pp->header_last)
487 banner(pp, line+1, jobname);
488 continue;
489
490 case '1': /* troff fonts */
491 case '2':
492 case '3':
493 case '4':
494 if (line[1] != '\0') {
482 continue;
483
484 case 'L': /* identification line */
485 if (!pp->no_header && !pp->header_last)
486 banner(pp, line+1, jobname);
487 continue;
488
489 case '1': /* troff fonts */
490 case '2':
491 case '3':
492 case '4':
493 if (line[1] != '\0') {
495 strncpy(fonts[line[0]-'1'], line+1,
496 50-1);
497 fonts[line[0]-'1'][50-1] = '\0';
494 strlcpy(fonts[line[0]-'1'], line + 1,
495 (size_t)50);
498 }
499 continue;
500
501 case 'W': /* page width */
496 }
497 continue;
498
499 case 'W': /* page width */
502 strncpy(width+2, line+1, sizeof(width) - 3);
503 width[2+sizeof(width) - 3] = '\0';
500 strlcpy(width+2, line + 1, sizeof(width) - 2);
504 continue;
505
506 case 'I': /* indent amount */
501 continue;
502
503 case 'I': /* indent amount */
507 strncpy(indent+2, line+1, sizeof(indent) - 3);
508 indent[2+sizeof(indent) - 3] = '\0';
504 strlcpy(indent+2, line + 1, sizeof(indent) - 2);
509 continue;
510
511 case 'Z': /* locale for pr */
505 continue;
506
507 case 'Z': /* locale for pr */
512 strncpy(locale, line+1, sizeof(locale) - 1);
508 strlcpy(locale, line + 1, sizeof(locale));
513 locale[sizeof(locale) - 1] = '\0';
514 continue;
515
516 default: /* some file to print */
517 /* only lowercase cmd-codes include a file-to-print */
518 if ((line[0] < 'a') || (line[0] > 'z')) {
519 /* ignore any other lines */
520 if (lflag <= 1)

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

891 cp++;
892 i = 0;
893 while (*cp >= '0' && *cp <= '9')
894 i = i * 10 + (*cp++ - '0');
895 fino = i;
896 } else if (line[0] == 'H') {
897 strlcpy(origin_host, line + 1, sizeof(origin_host));
898 if (class[0] == '\0') {
509 locale[sizeof(locale) - 1] = '\0';
510 continue;
511
512 default: /* some file to print */
513 /* only lowercase cmd-codes include a file-to-print */
514 if ((line[0] < 'a') || (line[0] > 'z')) {
515 /* ignore any other lines */
516 if (lflag <= 1)

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

887 cp++;
888 i = 0;
889 while (*cp >= '0' && *cp <= '9')
890 i = i * 10 + (*cp++ - '0');
891 fino = i;
892 } else if (line[0] == 'H') {
893 strlcpy(origin_host, line + 1, sizeof(origin_host));
894 if (class[0] == '\0') {
899 strncpy(class, line+1, sizeof(class) - 1);
900 class[sizeof(class) - 1] = '\0';
895 strlcpy(class, line + 1, sizeof(class));
901 }
902 } else if (line[0] == 'P') {
896 }
897 } else if (line[0] == 'P') {
903 strncpy(logname, line+1, sizeof(logname) - 1);
904 logname[sizeof(logname) - 1] = '\0';
898 strlcpy(logname, line + 1, sizeof(logname));
905 if (pp->restricted) { /* restricted */
906 if (getpwnam(logname) == NULL) {
907 sendmail(pp, line+1, NOACCT);
908 err = ERROR;
909 break;
910 }
911 }
912 } else if (line[0] == 'I') {
899 if (pp->restricted) { /* restricted */
900 if (getpwnam(logname) == NULL) {
901 sendmail(pp, line+1, NOACCT);
902 err = ERROR;
903 break;
904 }
905 }
906 } else if (line[0] == 'I') {
913 strncpy(indent+2, line+1, sizeof(indent) - 3);
914 indent[2 + sizeof(indent) - 3] = '\0';
907 strlcpy(indent+2, line + 1, sizeof(indent) - 2);
915 } else if (line[0] >= 'a' && line[0] <= 'z') {
916 strcpy(last, line);
917 while ((i = getline(cfp)) != 0)
918 if (strcmp(last, line))
919 break;
920 switch (sendfile(pp, '\3', last+1, *last)) {
921 case OK:
922 if (i)

--- 836 unchanged lines hidden ---
908 } else if (line[0] >= 'a' && line[0] <= 'z') {
909 strcpy(last, line);
910 while ((i = getline(cfp)) != 0)
911 if (strcmp(last, line))
912 break;
913 switch (sendfile(pp, '\3', last+1, *last)) {
914 case OK:
915 if (i)

--- 836 unchanged lines hidden ---