Deleted Added
full compact
printjob.c (27757) printjob.c (30407)
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:

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

111static char pxlength[10] = "-y"; /* page length in pixels */
112static char pxwidth[10] = "-x"; /* page width in pixels */
113static char tempfile[] = "errsXXXXXX"; /* file name for filter errors */
114static char width[10] = "-w"; /* page width in static characters */
115#define TFILENAME "fltXXXXXX"
116static char tfile[] = TFILENAME; /* file name for filter output */
117
118static void abortpr __P((int));
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:

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

111static char pxlength[10] = "-y"; /* page length in pixels */
112static char pxwidth[10] = "-x"; /* page width in pixels */
113static char tempfile[] = "errsXXXXXX"; /* file name for filter errors */
114static char width[10] = "-w"; /* page width in static characters */
115#define TFILENAME "fltXXXXXX"
116static char tfile[] = TFILENAME; /* file name for filter output */
117
118static void abortpr __P((int));
119static void alarmhandler __P((int));
119static void banner __P((char *, char *));
120static int dofork __P((int));
121static int dropit __P((int));
122static void init __P((void));
123static void openpr __P((void));
124static void opennet __P((char *));
125static void opentty __P((void));
126static void openrem __P((void));

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

1345 DU = DEFUID;
1346 if (cgetstr(bp,"ff", &FF) == -1)
1347 FF = DEFFF;
1348 if (cgetnum(bp, "pw", &PW) < 0)
1349 PW = DEFWIDTH;
1350 sprintf(&width[2], "%ld", PW);
1351 if (cgetnum(bp, "pl", &PL) < 0)
1352 PL = DEFLENGTH;
120static void banner __P((char *, char *));
121static int dofork __P((int));
122static int dropit __P((int));
123static void init __P((void));
124static void openpr __P((void));
125static void opennet __P((char *));
126static void opentty __P((void));
127static void openrem __P((void));

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

1346 DU = DEFUID;
1347 if (cgetstr(bp,"ff", &FF) == -1)
1348 FF = DEFFF;
1349 if (cgetnum(bp, "pw", &PW) < 0)
1350 PW = DEFWIDTH;
1351 sprintf(&width[2], "%ld", PW);
1352 if (cgetnum(bp, "pl", &PL) < 0)
1353 PL = DEFLENGTH;
1354 if (cgetnum(bp, "ct", &CT) < 0)
1355 CT = DEFTIMEOUT;
1353 sprintf(&length[2], "%ld", PL);
1354 if (cgetnum(bp,"px", &PX) < 0)
1355 PX = 0;
1356 sprintf(&pxwidth[2], "%ld", PX);
1357 if (cgetnum(bp, "py", &PY) < 0)
1358 PY = 0;
1359 sprintf(&pxlength[2], "%ld", PY);
1360 cgetstr(bp, "rm", &RM);

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

1450 */
1451static void
1452opennet(cp)
1453 char *cp;
1454{
1455 register int i;
1456 int resp, port;
1457 char save_ch;
1356 sprintf(&length[2], "%ld", PL);
1357 if (cgetnum(bp,"px", &PX) < 0)
1358 PX = 0;
1359 sprintf(&pxwidth[2], "%ld", PX);
1360 if (cgetnum(bp, "py", &PY) < 0)
1361 PY = 0;
1362 sprintf(&pxlength[2], "%ld", PY);
1363 cgetstr(bp, "rm", &RM);

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

1453 */
1454static void
1455opennet(cp)
1456 char *cp;
1457{
1458 register int i;
1459 int resp, port;
1460 char save_ch;
1461 void (*savealrm)(int);
1458
1459 save_ch = *cp;
1460 *cp = '\0';
1461 port = atoi(LP);
1462 if (port <= 0) {
1463 syslog(LOG_ERR, "%s: bad port number: %s", printer, LP);
1464 exit(1);
1465 }
1466 *cp++ = save_ch;
1467
1468 for (i = 1; ; i = i < 256 ? i << 1 : i) {
1469 resp = -1;
1462
1463 save_ch = *cp;
1464 *cp = '\0';
1465 port = atoi(LP);
1466 if (port <= 0) {
1467 syslog(LOG_ERR, "%s: bad port number: %s", printer, LP);
1468 exit(1);
1469 }
1470 *cp++ = save_ch;
1471
1472 for (i = 1; ; i = i < 256 ? i << 1 : i) {
1473 resp = -1;
1474 savealrm = signal(SIGALRM, alarmhandler);
1475 alarm(CT);
1470 pfd = getport(cp, port);
1476 pfd = getport(cp, port);
1477 (void)signal(SIGALRM, savealrm);
1471 if (pfd < 0 && errno == ECONNREFUSED)
1472 resp = 1;
1473 else if (pfd >= 0) {
1474 /*
1475 * need to delay a bit for rs232 lines
1476 * to stabilize in case printer is
1477 * connected via a terminal server
1478 */

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

1522/*
1523 * Printer is on a remote host
1524 */
1525static void
1526openrem()
1527{
1528 register int i, n;
1529 int resp;
1478 if (pfd < 0 && errno == ECONNREFUSED)
1479 resp = 1;
1480 else if (pfd >= 0) {
1481 /*
1482 * need to delay a bit for rs232 lines
1483 * to stabilize in case printer is
1484 * connected via a terminal server
1485 */

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

1529/*
1530 * Printer is on a remote host
1531 */
1532static void
1533openrem()
1534{
1535 register int i, n;
1536 int resp;
1537 void (*savealrm)(int);
1530
1531 for (i = 1; ; i = i < 256 ? i << 1 : i) {
1532 resp = -1;
1538
1539 for (i = 1; ; i = i < 256 ? i << 1 : i) {
1540 resp = -1;
1541 savealrm = signal(SIGALRM, alarmhandler);
1542 alarm(CT);
1533 pfd = getport(RM, 0);
1543 pfd = getport(RM, 0);
1544 (void)signal(SIGALRM, savealrm);
1534 if (pfd >= 0) {
1535 (void) snprintf(line, sizeof(line), "\2%s\n", RP);
1536 n = strlen(line);
1537 if (write(pfd, line, n) == n &&
1538 (resp = response()) == '\0')
1539 break;
1540 (void) close(pfd);
1541 }

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

1650 }
1651 ftruncate(fd, 0);
1652 (void)vsnprintf(buf, sizeof(buf) - 1, msg, ap);
1653 va_end(ap);
1654 strcat(buf, "\n");
1655 (void) write(fd, buf, strlen(buf));
1656 (void) close(fd);
1657}
1545 if (pfd >= 0) {
1546 (void) snprintf(line, sizeof(line), "\2%s\n", RP);
1547 n = strlen(line);
1548 if (write(pfd, line, n) == n &&
1549 (resp = response()) == '\0')
1550 break;
1551 (void) close(pfd);
1552 }

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

1661 }
1662 ftruncate(fd, 0);
1663 (void)vsnprintf(buf, sizeof(buf) - 1, msg, ap);
1664 va_end(ap);
1665 strcat(buf, "\n");
1666 (void) write(fd, buf, strlen(buf));
1667 (void) close(fd);
1668}
1669
1670void
1671alarmhandler(signo)
1672{
1673 /* ignored */
1674}