printjob.c (10530) | printjob.c (15032) |
---|---|
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: --- 44 unchanged lines hidden (view full) --- 53#include <sys/param.h> 54#include <sys/wait.h> 55#include <sys/stat.h> 56#include <sys/types.h> 57 58#include <pwd.h> 59#include <unistd.h> 60#include <signal.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: --- 44 unchanged lines hidden (view full) --- 53#include <sys/param.h> 54#include <sys/wait.h> 55#include <sys/stat.h> 56#include <sys/types.h> 57 58#include <pwd.h> 59#include <unistd.h> 60#include <signal.h> |
61#include <sgtty.h> | |
62#include <syslog.h> 63#include <fcntl.h> 64#include <dirent.h> 65#include <errno.h> 66#include <stdio.h> 67#include <string.h> 68#include <stdlib.h> | 61#include <syslog.h> 62#include <fcntl.h> 63#include <dirent.h> 64#include <errno.h> 65#include <stdio.h> 66#include <string.h> 67#include <stdlib.h> |
68#include <sys/ioctl.h> 69#include <termios.h> |
|
69#include "lp.h" 70#include "lp.local.h" 71#include "pathnames.h" 72#include "extern.h" 73 74#define DORETURN 0 /* absorb fork error */ 75#define DOABORT 1 /* abort if dofork fails */ 76 --- 1099 unchanged lines hidden (view full) --- 1176 cgetstr(bp, "rf", &RF); 1177 cgetstr(bp, "tf", &TF); 1178 cgetstr(bp, "nf", &NF); 1179 cgetstr(bp, "df", &DF); 1180 cgetstr(bp, "gf", &GF); 1181 cgetstr(bp, "vf", &VF); 1182 cgetstr(bp, "cf", &CF); 1183 cgetstr(bp, "tr", &TR); | 70#include "lp.h" 71#include "lp.local.h" 72#include "pathnames.h" 73#include "extern.h" 74 75#define DORETURN 0 /* absorb fork error */ 76#define DOABORT 1 /* abort if dofork fails */ 77 --- 1099 unchanged lines hidden (view full) --- 1177 cgetstr(bp, "rf", &RF); 1178 cgetstr(bp, "tf", &TF); 1179 cgetstr(bp, "nf", &NF); 1180 cgetstr(bp, "df", &DF); 1181 cgetstr(bp, "gf", &GF); 1182 cgetstr(bp, "vf", &VF); 1183 cgetstr(bp, "cf", &CF); 1184 cgetstr(bp, "tr", &TR); |
1185 cgetstr(bp, "ms", &MS); |
|
1184 1185 RS = (cgetcap(bp, "rs", ':') != NULL); 1186 SF = (cgetcap(bp, "sf", ':') != NULL); 1187 SH = (cgetcap(bp, "sh", ':') != NULL); 1188 SB = (cgetcap(bp, "sb", ':') != NULL); 1189 HL = (cgetcap(bp, "hl", ':') != NULL); 1190 RW = (cgetcap(bp, "rw", ':') != NULL); 1191 1192 cgetnum(bp, "br", &BR); | 1186 1187 RS = (cgetcap(bp, "rs", ':') != NULL); 1188 SF = (cgetcap(bp, "sf", ':') != NULL); 1189 SH = (cgetcap(bp, "sh", ':') != NULL); 1190 SB = (cgetcap(bp, "sb", ':') != NULL); 1191 HL = (cgetcap(bp, "hl", ':') != NULL); 1192 RW = (cgetcap(bp, "rw", ':') != NULL); 1193 1194 cgetnum(bp, "br", &BR); |
1193 if (cgetnum(bp, "fc", &FC) < 0) 1194 FC = 0; 1195 if (cgetnum(bp, "fs", &FS) < 0) 1196 FS = 0; 1197 if (cgetnum(bp, "xc", &XC) < 0) 1198 XC = 0; 1199 if (cgetnum(bp, "xs", &XS) < 0) 1200 XS = 0; | |
1201 1202 tof = (cgetcap(bp, "fo", ':') == NULL); 1203} 1204 1205/* 1206 * Acquire line printer or remote connection. 1207 */ 1208static void --- 103 unchanged lines hidden (view full) --- 1312}; 1313 1314/* 1315 * setup tty lines. 1316 */ 1317static void 1318setty() 1319{ | 1195 1196 tof = (cgetcap(bp, "fo", ':') == NULL); 1197} 1198 1199/* 1200 * Acquire line printer or remote connection. 1201 */ 1202static void --- 103 unchanged lines hidden (view full) --- 1306}; 1307 1308/* 1309 * setup tty lines. 1310 */ 1311static void 1312setty() 1313{ |
1320 struct sgttyb ttybuf; 1321 register struct bauds *bp; | 1314 struct termios ttybuf; 1315 struct bauds *bp; |
1322 1323 if (ioctl(pfd, TIOCEXCL, (char *)0) < 0) { 1324 syslog(LOG_ERR, "%s: ioctl(TIOCEXCL): %m", printer); 1325 exit(1); 1326 } | 1316 1317 if (ioctl(pfd, TIOCEXCL, (char *)0) < 0) { 1318 syslog(LOG_ERR, "%s: ioctl(TIOCEXCL): %m", printer); 1319 exit(1); 1320 } |
1327 if (ioctl(pfd, TIOCGETP, (char *)&ttybuf) < 0) { 1328 syslog(LOG_ERR, "%s: ioctl(TIOCGETP): %m", printer); | 1321 if (tcgetattr(pfd, &ttybuf) < 0) { 1322 syslog(LOG_ERR, "%s: tcgetattr: %m", printer); |
1329 exit(1); 1330 } 1331 if (BR > 0) { 1332 for (bp = bauds; bp->baud; bp++) 1333 if (BR == bp->baud) 1334 break; 1335 if (!bp->baud) { 1336 syslog(LOG_ERR, "%s: illegal baud rate %d", printer, BR); 1337 exit(1); 1338 } | 1323 exit(1); 1324 } 1325 if (BR > 0) { 1326 for (bp = bauds; bp->baud; bp++) 1327 if (BR == bp->baud) 1328 break; 1329 if (!bp->baud) { 1330 syslog(LOG_ERR, "%s: illegal baud rate %d", printer, BR); 1331 exit(1); 1332 } |
1339 ttybuf.sg_ispeed = ttybuf.sg_ospeed = bp->speed; | 1333 cfsetspeed(&ttybuf, bp->speed); |
1340 } | 1334 } |
1341 ttybuf.sg_flags &= ~FC; 1342 ttybuf.sg_flags |= FS; 1343 if (ioctl(pfd, TIOCSETP, (char *)&ttybuf) < 0) { 1344 syslog(LOG_ERR, "%s: ioctl(TIOCSETP): %m", printer); 1345 exit(1); 1346 } 1347 if (XC) { 1348 if (ioctl(pfd, TIOCLBIC, &XC) < 0) { 1349 syslog(LOG_ERR, "%s: ioctl(TIOCLBIC): %m", printer); 1350 exit(1); | 1335 if (MS) { 1336 char *s = strdup(MS), *tmp; 1337 1338 while (tmp = strsep (&s, ",")) { 1339 msearch(tmp, &ttybuf); |
1351 } 1352 } | 1340 } 1341 } |
1353 if (XS) { 1354 if (ioctl(pfd, TIOCLBIS, &XS) < 0) { 1355 syslog(LOG_ERR, "%s: ioctl(TIOCLBIS): %m", printer); 1356 exit(1); | 1342 if (MS || (BR > 0)) { 1343 if (tcsetattr(pfd, TCSAFLUSH, &ttybuf) == -1) { 1344 syslog(LOG_ERR, "%s: tcsetattr: %m", printer); |
1357 } 1358 } 1359} 1360 1361#if __STDC__ 1362#include <stdarg.h> 1363#else 1364#include <varargs.h> --- 33 unchanged lines hidden --- | 1345 } 1346 } 1347} 1348 1349#if __STDC__ 1350#include <stdarg.h> 1351#else 1352#include <varargs.h> --- 33 unchanged lines hidden --- |