/* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only * (the "License"). You may not use this file except in compliance * with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright 2005 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ #pragma ident "%Z%%M% %I% %E% SMI" #include "stdio.h" #include "ctype.h" #include "errno.h" #include "sys/types.h" #include "sys/utsname.h" #include "string.h" #include "lp.h" #include "msgs.h" #include "access.h" #include "class.h" #include "printers.h" #define WHO_AM_I I_AM_LPADMIN #include "oam.h" #include "lpadmin.h" #include extern void chkopts(), chkopts2(), chkopts3(), exit(); int scheduler_active = 0; char *label = 0; PRINTER *printer_pointer = 0; static CLASS *class_pointer = 0; PWHEEL *pwheel_pointer = 0; char *Local_System = 0; /** ** main() **/ int main(int argc, char *argv[]) { struct utsname un; (void) setlocale (LC_ALL, ""); #if !defined(TEXT_DOMAIN) #define TEXT_DOMAIN "SYS_TEST" #endif (void) textdomain(TEXT_DOMAIN); if (!is_user_admin()) { LP_ERRMSG (ERROR, E_LP_NOTADM); done (1); /*NOTREACHED*/ } uname(&un); Local_System = strdup(un.nodename); options (argc, argv); /* process command line options */ chkopts (); /* check for legality of options */ startup (); /* open path to Spooler */ if (d) newdflt (d); /* -d */ else if (x) { /* allow "any" or "all" to do all destinations */ if (STREQU(NAME_ALL, x) || STREQU(NAME_ANY, x)) { /* * Just deleting all the printers should get * rid of all the classes, too, but removing * the classes first should make things go a bit * faster. */ while ((class_pointer = getclass(NAME_ALL))) rmdest (1, class_pointer->name); if (errno != ENOENT) { LP_ERRMSG1 ( ERROR, E_ADM_GETCLASSES, PERROR ); done (1); /*NOTREACHED*/ } while ((printer_pointer = getprinter(NAME_ALL))) rmdest (0, printer_pointer->name); if (errno != ENOENT) { LP_ERRMSG1 ( ERROR, E_ADM_GETPRINTERS, PERROR ); done (1); /*NOTREACHED*/ } } else rmdest (isclass(x), x); } else if (!p && S) { if (STREQU(*S, NAME_ALL) || STREQU(*S, NAME_ANY)) { while ((pwheel_pointer = getpwheel(NAME_ALL))) { *S = pwheel_pointer->name; chkopts3 (0); label = *S; do_pwheel (); } } else { label = 0; do_pwheel (); } #if defined(J_OPTION) } else if (j) { do_fault (); /* -j */ #endif } else { /* allow "any" or "all" to do all printers */ if (STREQU(NAME_ALL, p) || STREQU(NAME_ANY, p)) { int called=0; while ((printer_pointer = getprinter(NAME_ALL)) != NULL) { /* * "chkopts2()" will clobber "s". */ char * save_s = s; called++; p = printer_pointer->name; chkopts2 (0); if (s) if ( A || a || e || F || H || h || i || l || m || M || o || U || v || Q != -1 || W != -1 ) LP_ERRMSG1 ( WARNING, E_ADM_SIGNORE, p ); label = p; do_printer (); s = save_s; } if (called == 0 ) LP_ERRMSG (ERROR, E_ADM_PLONELY); if (errno != ENOENT) { LP_ERRMSG2 ( ERROR, E_LP_GETPRINTER, NAME_ALL, PERROR ); done (1); /*NOTREACHED*/ } } else { label = 0; do_printer (); /* -p etc. */ } } done (0); /*NOTREACHED*/ return (0); } /** ** putp() - FAKE ROUTINES TO AVOID REAL ONES **/ int putp () { return (0); }