cmds.c (68401) | cmds.c (78146) |
---|---|
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[] = "@(#)cmds.c 8.2 (Berkeley) 4/28/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[] = "@(#)cmds.c 8.2 (Berkeley) 4/28/95"; 44*/ 45static const char rcsid[] = |
46 "$FreeBSD: head/usr.sbin/lpr/lpc/cmds.c 68401 2000-11-06 19:36:38Z gad $"; | 46 "$FreeBSD: head/usr.sbin/lpr/lpc/cmds.c 78146 2001-06-12 16:38:20Z gad $"; |
47#endif /* not lint */ 48 49/* 50 * lpc -- line printer control program -- commands: 51 */ 52 53#include <sys/param.h> 54#include <sys/time.h> --- 10 unchanged lines hidden (view full) --- 65#include <ctype.h> 66#include <string.h> 67#include "lp.h" 68#include "lp.local.h" 69#include "lpc.h" 70#include "extern.h" 71#include "pathnames.h" 72 | 47#endif /* not lint */ 48 49/* 50 * lpc -- line printer control program -- commands: 51 */ 52 53#include <sys/param.h> 54#include <sys/time.h> --- 10 unchanged lines hidden (view full) --- 65#include <ctype.h> 66#include <string.h> 67#include "lp.h" 68#include "lp.local.h" 69#include "lpc.h" 70#include "extern.h" 71#include "pathnames.h" 72 |
73static void abortpr __P((struct printer *, int)); 74static int doarg __P((char *)); 75static int doselect __P((struct dirent *)); 76static void putmsg __P((struct printer *, int, char **)); 77static int sortq __P((const void *, const void *)); 78static void startpr __P((struct printer *, int)); 79static int touch __P((struct jobqueue *)); 80static void unlinkf __P((char *)); 81static void upstat __P((struct printer *, char *)); | 73static void abortpr(struct printer *_pp, int _dis); 74static int doarg(char *_job); 75static int doselect(struct dirent *_d); 76static void putmsg(struct printer *_pp, int _argc, char **_argv); 77static int sortq(const void *_a, const void *_b); 78static void startpr(struct printer *_pp, int _chgenable); 79static int touch(struct jobqueue *_jq); 80static void unlinkf(char *_name); 81static void upstat(struct printer *_pp, const char *_msg); |
82 83/* 84 * generic framework for commands which operate on all or a specified 85 * set of printers 86 */ 87void | 82 83/* 84 * generic framework for commands which operate on all or a specified 85 * set of printers 86 */ 87void |
88generic(doit, argc, argv) 89 void (*doit) __P((struct printer *)); 90 int argc; 91 char *argv[]; | 88generic(void (*specificrtn)(struct printer *_pp), int argc, char *argv[]) |
92{ | 89{ |
93 int status, more; | 90 int cmdstatus, more; |
94 struct printer myprinter, *pp = &myprinter; 95 96 if (argc == 1) { 97 printf("Usage: %s {all | printer ...}\n", argv[0]); 98 return; 99 } 100 if (argc == 2 && strcmp(argv[1], "all") == 0) { | 91 struct printer myprinter, *pp = &myprinter; 92 93 if (argc == 1) { 94 printf("Usage: %s {all | printer ...}\n", argv[0]); 95 return; 96 } 97 if (argc == 2 && strcmp(argv[1], "all") == 0) { |
101 more = firstprinter(pp, &status); 102 if (status) | 98 more = firstprinter(pp, &cmdstatus); 99 if (cmdstatus) |
103 goto looperr; 104 while (more) { | 100 goto looperr; 101 while (more) { |
105 (*doit)(pp); | 102 (*specificrtn)(pp); |
106 do { | 103 do { |
107 more = nextprinter(pp, &status); | 104 more = nextprinter(pp, &cmdstatus); |
108looperr: | 105looperr: |
109 switch (status) { | 106 switch (cmdstatus) { |
110 case PCAPERR_TCOPEN: 111 printf("warning: %s: unresolved " 112 "tc= reference(s) ", 113 pp->printer); 114 case PCAPERR_SUCCESS: 115 break; 116 default: | 107 case PCAPERR_TCOPEN: 108 printf("warning: %s: unresolved " 109 "tc= reference(s) ", 110 pp->printer); 111 case PCAPERR_SUCCESS: 112 break; 113 default: |
117 fatal(pp, pcaperr(status)); | 114 fatal(pp, pcaperr(cmdstatus)); |
118 } | 115 } |
119 } while (more && status); | 116 } while (more && cmdstatus); |
120 } 121 return; 122 } 123 while (--argc) { 124 ++argv; 125 init_printer(pp); | 117 } 118 return; 119 } 120 while (--argc) { 121 ++argv; 122 init_printer(pp); |
126 status = getprintcap(*argv, pp); 127 switch(status) { | 123 cmdstatus = getprintcap(*argv, pp); 124 switch (cmdstatus) { |
128 default: | 125 default: |
129 fatal(pp, pcaperr(status)); | 126 fatal(pp, pcaperr(cmdstatus)); |
130 case PCAPERR_NOTFOUND: 131 printf("unknown printer %s\n", *argv); 132 continue; 133 case PCAPERR_TCOPEN: 134 printf("warning: %s: unresolved tc= reference(s)\n", 135 *argv); 136 break; 137 case PCAPERR_SUCCESS: 138 break; 139 } | 127 case PCAPERR_NOTFOUND: 128 printf("unknown printer %s\n", *argv); 129 continue; 130 case PCAPERR_TCOPEN: 131 printf("warning: %s: unresolved tc= reference(s)\n", 132 *argv); 133 break; 134 case PCAPERR_SUCCESS: 135 break; 136 } |
140 (*doit)(pp); | 137 (*specificrtn)(pp); |
141 } 142} 143 144/* 145 * kill an existing daemon and disable printing. 146 */ 147void | 138 } 139} 140 141/* 142 * kill an existing daemon and disable printing. 143 */ 144void |
148doabort(pp) 149 struct printer *pp; | 145doabort(struct printer *pp) |
150{ 151 abortpr(pp, 1); 152} 153 154static void | 146{ 147 abortpr(pp, 1); 148} 149 150static void |
155abortpr(pp, dis) 156 struct printer *pp; 157 int dis; | 151abortpr(struct printer *pp, int dis) |
158{ 159 register FILE *fp; 160 struct stat stbuf; 161 int pid, fd; 162 char lf[MAXPATHLEN]; 163 164 lock_file_name(pp, lf, sizeof lf); 165 printf("%s:\n", pp->printer); --- 51 unchanged lines hidden (view full) --- 217out: 218 seteuid(uid); 219} 220 221/* 222 * Write a message into the status file. 223 */ 224static void | 152{ 153 register FILE *fp; 154 struct stat stbuf; 155 int pid, fd; 156 char lf[MAXPATHLEN]; 157 158 lock_file_name(pp, lf, sizeof lf); 159 printf("%s:\n", pp->printer); --- 51 unchanged lines hidden (view full) --- 211out: 212 seteuid(uid); 213} 214 215/* 216 * Write a message into the status file. 217 */ 218static void |
225upstat(pp, msg) 226 struct printer *pp; 227 char *msg; | 219upstat(struct printer *pp, const char *msg) |
228{ 229 register int fd; 230 char statfile[MAXPATHLEN]; 231 232 status_file_name(pp, statfile, sizeof statfile); 233 umask(0); 234 fd = open(statfile, O_WRONLY|O_CREAT|O_EXLOCK, STAT_FILE_MODE); 235 if (fd < 0) { --- 4 unchanged lines hidden (view full) --- 240 if (msg == (char *)NULL) 241 (void) write(fd, "\n", 1); 242 else 243 (void) write(fd, msg, strlen(msg)); 244 (void) close(fd); 245} 246 247static int | 220{ 221 register int fd; 222 char statfile[MAXPATHLEN]; 223 224 status_file_name(pp, statfile, sizeof statfile); 225 umask(0); 226 fd = open(statfile, O_WRONLY|O_CREAT|O_EXLOCK, STAT_FILE_MODE); 227 if (fd < 0) { --- 4 unchanged lines hidden (view full) --- 232 if (msg == (char *)NULL) 233 (void) write(fd, "\n", 1); 234 else 235 (void) write(fd, msg, strlen(msg)); 236 (void) close(fd); 237} 238 239static int |
248doselect(d) 249 struct dirent *d; | 240doselect(struct dirent *d) |
250{ 251 int c = d->d_name[0]; 252 253 if ((c == 't' || c == 'c' || c == 'd') && d->d_name[1] == 'f') 254 return(1); 255 return(0); 256} 257 258/* 259 * Comparison routine for scandir. Sort by job number and machine, then 260 * by `cf', `tf', or `df', then by the sequence letter A-Z, a-z. 261 */ 262static int | 241{ 242 int c = d->d_name[0]; 243 244 if ((c == 't' || c == 'c' || c == 'd') && d->d_name[1] == 'f') 245 return(1); 246 return(0); 247} 248 249/* 250 * Comparison routine for scandir. Sort by job number and machine, then 251 * by `cf', `tf', or `df', then by the sequence letter A-Z, a-z. 252 */ 253static int |
263sortq(a, b) 264 const void *a, *b; | 254sortq(const void *a, const void *b) |
265{ | 255{ |
266 struct dirent **d1, **d2; | 256 const struct dirent **d1, **d2; |
267 int c1, c2; 268 | 257 int c1, c2; 258 |
269 d1 = (struct dirent **)a; 270 d2 = (struct dirent **)b; | 259 d1 = (const struct dirent **)a; 260 d2 = (const struct dirent **)b; |
271 if ((c1 = strcmp((*d1)->d_name + 3, (*d2)->d_name + 3))) 272 return(c1); 273 c1 = (*d1)->d_name[0]; 274 c2 = (*d2)->d_name[0]; 275 if (c1 == c2) 276 return((*d1)->d_name[2] - (*d2)->d_name[2]); 277 if (c1 == 'c') 278 return(-1); 279 if (c1 == 'd' || c2 == 'c') 280 return(1); 281 return(-1); 282} 283 284/* 285 * Remove all spool files and temporaries from the spooling area. 286 * Or, perhaps: 287 * Remove incomplete jobs from spooling area. 288 */ 289void | 261 if ((c1 = strcmp((*d1)->d_name + 3, (*d2)->d_name + 3))) 262 return(c1); 263 c1 = (*d1)->d_name[0]; 264 c2 = (*d2)->d_name[0]; 265 if (c1 == c2) 266 return((*d1)->d_name[2] - (*d2)->d_name[2]); 267 if (c1 == 'c') 268 return(-1); 269 if (c1 == 'd' || c2 == 'c') 270 return(1); 271 return(-1); 272} 273 274/* 275 * Remove all spool files and temporaries from the spooling area. 276 * Or, perhaps: 277 * Remove incomplete jobs from spooling area. 278 */ 279void |
290clean(pp) 291 struct printer *pp; | 280clean(struct printer *pp) |
292{ 293 register int i, n; 294 register char *cp, *cp1, *lp; 295 struct dirent **queue; 296 int nitems; 297 298 printf("%s:\n", pp->printer); 299 --- 40 unchanged lines hidden (view full) --- 340 strncpy(lp, cp, sizeof(line) - strlen(line) - 1); 341 line[sizeof(line) - 1] = '\0'; 342 unlinkf(line); 343 } 344 } while (++i < nitems); 345} 346 347static void | 281{ 282 register int i, n; 283 register char *cp, *cp1, *lp; 284 struct dirent **queue; 285 int nitems; 286 287 printf("%s:\n", pp->printer); 288 --- 40 unchanged lines hidden (view full) --- 329 strncpy(lp, cp, sizeof(line) - strlen(line) - 1); 330 line[sizeof(line) - 1] = '\0'; 331 unlinkf(line); 332 } 333 } while (++i < nitems); 334} 335 336static void |
348unlinkf(name) 349 char *name; | 337unlinkf(char *name) |
350{ 351 seteuid(euid); 352 if (unlink(name) < 0) 353 printf("\tcannot remove %s\n", name); 354 else 355 printf("\tremoved %s\n", name); 356 seteuid(uid); 357} 358 359/* 360 * Enable queuing to the printer (allow lpr's). 361 */ 362void | 338{ 339 seteuid(euid); 340 if (unlink(name) < 0) 341 printf("\tcannot remove %s\n", name); 342 else 343 printf("\tremoved %s\n", name); 344 seteuid(uid); 345} 346 347/* 348 * Enable queuing to the printer (allow lpr's). 349 */ 350void |
363enable(pp) 364 struct printer *pp; | 351enable(struct printer *pp) |
365{ 366 struct stat stbuf; 367 char lf[MAXPATHLEN]; 368 369 lock_file_name(pp, lf, sizeof lf); 370 printf("%s:\n", pp->printer); 371 372 /* --- 8 unchanged lines hidden (view full) --- 381 } 382 seteuid(uid); 383} 384 385/* 386 * Disable queuing. 387 */ 388void | 352{ 353 struct stat stbuf; 354 char lf[MAXPATHLEN]; 355 356 lock_file_name(pp, lf, sizeof lf); 357 printf("%s:\n", pp->printer); 358 359 /* --- 8 unchanged lines hidden (view full) --- 368 } 369 seteuid(uid); 370} 371 372/* 373 * Disable queuing. 374 */ 375void |
389disable(pp) 390 struct printer *pp; | 376disable(struct printer *pp) |
391{ 392 register int fd; 393 struct stat stbuf; 394 char lf[MAXPATHLEN]; 395 396 lock_file_name(pp, lf, sizeof lf); 397 printf("%s:\n", pp->printer); 398 /* --- 20 unchanged lines hidden (view full) --- 419 seteuid(uid); 420} 421 422/* 423 * Disable queuing and printing and put a message into the status file 424 * (reason for being down). 425 */ 426void | 377{ 378 register int fd; 379 struct stat stbuf; 380 char lf[MAXPATHLEN]; 381 382 lock_file_name(pp, lf, sizeof lf); 383 printf("%s:\n", pp->printer); 384 /* --- 20 unchanged lines hidden (view full) --- 405 seteuid(uid); 406} 407 408/* 409 * Disable queuing and printing and put a message into the status file 410 * (reason for being down). 411 */ 412void |
427down(argc, argv) 428 int argc; 429 char *argv[]; | 413down(int argc, char *argv[]) |
430{ | 414{ |
431 int status, more; | 415 int cmdstatus, more; |
432 struct printer myprinter, *pp = &myprinter; 433 434 if (argc == 1) { 435 printf("Usage: down {all | printer} [message ...]\n"); 436 return; 437 } 438 if (!strcmp(argv[1], "all")) { | 416 struct printer myprinter, *pp = &myprinter; 417 418 if (argc == 1) { 419 printf("Usage: down {all | printer} [message ...]\n"); 420 return; 421 } 422 if (!strcmp(argv[1], "all")) { |
439 more = firstprinter(pp, &status); 440 if (status) | 423 more = firstprinter(pp, &cmdstatus); 424 if (cmdstatus) |
441 goto looperr; 442 while (more) { 443 putmsg(pp, argc - 2, argv + 2); 444 do { | 425 goto looperr; 426 while (more) { 427 putmsg(pp, argc - 2, argv + 2); 428 do { |
445 more = nextprinter(pp, &status); | 429 more = nextprinter(pp, &cmdstatus); |
446looperr: | 430looperr: |
447 switch (status) { | 431 switch (cmdstatus) { |
448 case PCAPERR_TCOPEN: 449 printf("warning: %s: unresolved " 450 "tc= reference(s) ", 451 pp->printer); 452 case PCAPERR_SUCCESS: 453 break; 454 default: | 432 case PCAPERR_TCOPEN: 433 printf("warning: %s: unresolved " 434 "tc= reference(s) ", 435 pp->printer); 436 case PCAPERR_SUCCESS: 437 break; 438 default: |
455 fatal(pp, pcaperr(status)); | 439 fatal(pp, pcaperr(cmdstatus)); |
456 } | 440 } |
457 } while (more && status); | 441 } while (more && cmdstatus); |
458 } 459 return; 460 } 461 init_printer(pp); | 442 } 443 return; 444 } 445 init_printer(pp); |
462 status = getprintcap(argv[1], pp); 463 switch(status) { | 446 cmdstatus = getprintcap(argv[1], pp); 447 switch (cmdstatus) { |
464 default: | 448 default: |
465 fatal(pp, pcaperr(status)); | 449 fatal(pp, pcaperr(cmdstatus)); |
466 case PCAPERR_NOTFOUND: 467 printf("unknown printer %s\n", argv[1]); 468 return; 469 case PCAPERR_TCOPEN: 470 printf("warning: %s: unresolved tc= reference(s)", argv[1]); 471 break; 472 case PCAPERR_SUCCESS: 473 break; 474 } 475 putmsg(pp, argc - 2, argv + 2); 476} 477 478static void | 450 case PCAPERR_NOTFOUND: 451 printf("unknown printer %s\n", argv[1]); 452 return; 453 case PCAPERR_TCOPEN: 454 printf("warning: %s: unresolved tc= reference(s)", argv[1]); 455 break; 456 case PCAPERR_SUCCESS: 457 break; 458 } 459 putmsg(pp, argc - 2, argv + 2); 460} 461 462static void |
479putmsg(pp, argc, argv) 480 struct printer *pp; 481 int argc; 482 char **argv; | 463putmsg(struct printer *pp, int argc, char **argv) |
483{ 484 register int fd; 485 register char *cp1, *cp2; 486 char buf[1024]; 487 char file[MAXPATHLEN]; 488 struct stat stbuf; 489 490 printf("%s:\n", pp->printer); --- 51 unchanged lines hidden (view full) --- 542 (void) write(fd, buf, strlen(buf)); 543 (void) close(fd); 544} 545 546/* 547 * Exit lpc 548 */ 549void | 464{ 465 register int fd; 466 register char *cp1, *cp2; 467 char buf[1024]; 468 char file[MAXPATHLEN]; 469 struct stat stbuf; 470 471 printf("%s:\n", pp->printer); --- 51 unchanged lines hidden (view full) --- 523 (void) write(fd, buf, strlen(buf)); 524 (void) close(fd); 525} 526 527/* 528 * Exit lpc 529 */ 530void |
550quit(argc, argv) 551 int argc; 552 char *argv[]; | 531quit(int argc __unused, char *argv[] __unused) |
553{ 554 exit(0); 555} 556 557/* 558 * Kill and restart the daemon. 559 */ 560void | 532{ 533 exit(0); 534} 535 536/* 537 * Kill and restart the daemon. 538 */ 539void |
561restart(pp) 562 struct printer *pp; | 540restart(struct printer *pp) |
563{ 564 abortpr(pp, 0); 565 startpr(pp, 0); 566} 567 568/* 569 * Enable printing on the specified printer and startup the daemon. 570 */ 571void | 541{ 542 abortpr(pp, 0); 543 startpr(pp, 0); 544} 545 546/* 547 * Enable printing on the specified printer and startup the daemon. 548 */ 549void |
572startcmd(pp) 573 struct printer *pp; | 550startcmd(struct printer *pp) |
574{ 575 startpr(pp, 1); 576} 577 578static void | 551{ 552 startpr(pp, 1); 553} 554 555static void |
579startpr(pp, enable) 580 struct printer *pp; 581 int enable; | 556startpr(struct printer *pp, int chgenable) |
582{ 583 struct stat stbuf; 584 char lf[MAXPATHLEN]; 585 586 lock_file_name(pp, lf, sizeof lf); 587 printf("%s:\n", pp->printer); 588 589 /* | 557{ 558 struct stat stbuf; 559 char lf[MAXPATHLEN]; 560 561 lock_file_name(pp, lf, sizeof lf); 562 printf("%s:\n", pp->printer); 563 564 /* |
590 * For enable==1 ('start'), turn off the LFM_PRINT_DIS bit of the 591 * lock file to re-enable printing. For enable==2 ('up'), also | 565 * For chgenable==1 ('start'), turn off the LFM_PRINT_DIS bit of the 566 * lock file to re-enable printing. For chgenable==2 ('up'), also |
592 * turn off the LFM_QUEUE_DIS bit to re-enable queueing. 593 */ 594 seteuid(euid); | 567 * turn off the LFM_QUEUE_DIS bit to re-enable queueing. 568 */ 569 seteuid(euid); |
595 if (enable && stat(lf, &stbuf) >= 0) { 596 mode_t bits = (enable == 2 ? 0 : LFM_QUEUE_DIS); | 570 if (chgenable && stat(lf, &stbuf) >= 0) { 571 mode_t bits = (chgenable == 2 ? 0 : LFM_QUEUE_DIS); |
597 if (chmod(lf, stbuf.st_mode & (LOCK_FILE_MODE | bits)) < 0) 598 printf("\tcannot enable printing\n"); 599 else 600 printf("\tprinting enabled\n"); 601 } 602 if (!startdaemon(pp)) 603 printf("\tcouldn't start daemon\n"); 604 else 605 printf("\tdaemon started\n"); 606 seteuid(uid); 607} 608 609/* 610 * Print the status of the printer queue. 611 */ 612void | 572 if (chmod(lf, stbuf.st_mode & (LOCK_FILE_MODE | bits)) < 0) 573 printf("\tcannot enable printing\n"); 574 else 575 printf("\tprinting enabled\n"); 576 } 577 if (!startdaemon(pp)) 578 printf("\tcouldn't start daemon\n"); 579 else 580 printf("\tdaemon started\n"); 581 seteuid(uid); 582} 583 584/* 585 * Print the status of the printer queue. 586 */ 587void |
613status(pp) 614 struct printer *pp; | 588status(struct printer *pp) |
615{ 616 struct stat stbuf; 617 register int fd, i; 618 register struct dirent *dp; 619 DIR *dirp; 620 char file[MAXPATHLEN]; 621 622 printf("%s:\n", pp->printer); --- 46 unchanged lines hidden (view full) --- 669 } 670} 671 672/* 673 * Stop the specified daemon after completing the current job and disable 674 * printing. 675 */ 676void | 589{ 590 struct stat stbuf; 591 register int fd, i; 592 register struct dirent *dp; 593 DIR *dirp; 594 char file[MAXPATHLEN]; 595 596 printf("%s:\n", pp->printer); --- 46 unchanged lines hidden (view full) --- 643 } 644} 645 646/* 647 * Stop the specified daemon after completing the current job and disable 648 * printing. 649 */ 650void |
677stop(pp) 678 struct printer *pp; | 651stop(struct printer *pp) |
679{ 680 register int fd; 681 struct stat stbuf; 682 char lf[MAXPATHLEN]; 683 684 lock_file_name(pp, lf, sizeof lf); 685 printf("%s:\n", pp->printer); 686 --- 27 unchanged lines hidden (view full) --- 714struct jobqueue **queue; 715int nitems; 716time_t mtime; 717 718/* 719 * Put the specified jobs at the top of printer queue. 720 */ 721void | 652{ 653 register int fd; 654 struct stat stbuf; 655 char lf[MAXPATHLEN]; 656 657 lock_file_name(pp, lf, sizeof lf); 658 printf("%s:\n", pp->printer); 659 --- 27 unchanged lines hidden (view full) --- 687struct jobqueue **queue; 688int nitems; 689time_t mtime; 690 691/* 692 * Put the specified jobs at the top of printer queue. 693 */ 694void |
722topq(argc, argv) 723 int argc; 724 char *argv[]; | 695topq(int argc, char *argv[]) |
725{ 726 register int i; 727 struct stat stbuf; | 696{ 697 register int i; 698 struct stat stbuf; |
728 int status, changed; | 699 int cmdstatus, changed; |
729 struct printer myprinter, *pp = &myprinter; 730 731 if (argc < 3) { 732 printf("Usage: topq printer [jobnum ...] [user ...]\n"); 733 return; 734 } 735 736 --argc; 737 ++argv; 738 init_printer(pp); | 700 struct printer myprinter, *pp = &myprinter; 701 702 if (argc < 3) { 703 printf("Usage: topq printer [jobnum ...] [user ...]\n"); 704 return; 705 } 706 707 --argc; 708 ++argv; 709 init_printer(pp); |
739 status = getprintcap(*argv, pp); 740 switch(status) { | 710 cmdstatus = getprintcap(*argv, pp); 711 switch(cmdstatus) { |
741 default: | 712 default: |
742 fatal(pp, pcaperr(status)); | 713 fatal(pp, pcaperr(cmdstatus)); |
743 case PCAPERR_NOTFOUND: 744 printf("unknown printer %s\n", *argv); 745 return; 746 case PCAPERR_TCOPEN: 747 printf("warning: %s: unresolved tc= reference(s)", *argv); 748 break; 749 case PCAPERR_SUCCESS: 750 break; --- 37 unchanged lines hidden (view full) --- 788 seteuid(uid); 789} 790 791/* 792 * Reposition the job by changing the modification time of 793 * the control file. 794 */ 795static int | 714 case PCAPERR_NOTFOUND: 715 printf("unknown printer %s\n", *argv); 716 return; 717 case PCAPERR_TCOPEN: 718 printf("warning: %s: unresolved tc= reference(s)", *argv); 719 break; 720 case PCAPERR_SUCCESS: 721 break; --- 37 unchanged lines hidden (view full) --- 759 seteuid(uid); 760} 761 762/* 763 * Reposition the job by changing the modification time of 764 * the control file. 765 */ 766static int |
796touch(q) 797 struct jobqueue *q; | 767touch(struct jobqueue *jq) |
798{ 799 struct timeval tvp[2]; 800 int ret; 801 802 tvp[0].tv_sec = tvp[1].tv_sec = --mtime; 803 tvp[0].tv_usec = tvp[1].tv_usec = 0; 804 seteuid(euid); | 768{ 769 struct timeval tvp[2]; 770 int ret; 771 772 tvp[0].tv_sec = tvp[1].tv_sec = --mtime; 773 tvp[0].tv_usec = tvp[1].tv_usec = 0; 774 seteuid(euid); |
805 ret = utimes(q->job_cfname, tvp); | 775 ret = utimes(jq->job_cfname, tvp); |
806 seteuid(uid); 807 return (ret); 808} 809 810/* 811 * Checks if specified job name is in the printer's queue. 812 * Returns: negative (-1) if argument name is not in the queue. 813 */ 814static int | 776 seteuid(uid); 777 return (ret); 778} 779 780/* 781 * Checks if specified job name is in the printer's queue. 782 * Returns: negative (-1) if argument name is not in the queue. 783 */ 784static int |
815doarg(job) 816 char *job; | 785doarg(char *job) |
817{ 818 register struct jobqueue **qq; 819 register int jobnum, n; 820 register char *cp, *machine; 821 int cnt = 0; 822 FILE *fp; 823 824 /* --- 54 unchanged lines hidden (view full) --- 879 } 880 return(cnt); 881} 882 883/* 884 * Enable everything and start printer (undo `down'). 885 */ 886void | 786{ 787 register struct jobqueue **qq; 788 register int jobnum, n; 789 register char *cp, *machine; 790 int cnt = 0; 791 FILE *fp; 792 793 /* --- 54 unchanged lines hidden (view full) --- 848 } 849 return(cnt); 850} 851 852/* 853 * Enable everything and start printer (undo `down'). 854 */ 855void |
887up(pp) 888 struct printer *pp; | 856up(struct printer *pp) |
889{ 890 startpr(pp, 2); 891} | 857{ 858 startpr(pp, 2); 859} |