1073N/A/*
1073N/A * CDDL HEADER START
1073N/A *
1073N/A * The contents of this file are subject to the terms of the
1073N/A * Common Development and Distribution License, Version 1.0 only
1073N/A * (the "License"). You may not use this file except in compliance
1073N/A * with the License.
1073N/A *
1073N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
1073N/A * or http://www.opensolaris.org/os/licensing.
1073N/A * See the License for the specific language governing permissions
1073N/A * and limitations under the License.
1073N/A *
1073N/A * When distributing Covered Code, include this CDDL HEADER in each
1073N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1073N/A * If applicable, add the following below this CDDL HEADER, with the
1073N/A * fields enclosed by brackets "[]" replaced with your own identifying
1073N/A * information: Portions Copyright [yyyy] [name of copyright owner]
1073N/A *
1073N/A * CDDL HEADER END
1073N/A */
1073N/A/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
1073N/A/* All Rights Reserved */
1073N/A
1073N/A
1073N/A#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.5 */
1073N/A
1073N/A#include "stdio.h"
1073N/A#include "errno.h"
1073N/A
1073N/A#include "lp.h"
1073N/A#include "class.h"
1073N/A#include "msgs.h"
1073N/A
1073N/A#define WHO_AM_I I_AM_LPADMIN
1073N/A#include "oam.h"
1073N/A
1073N/A#include "lpadmin.h"
1073N/A
1073N/A
1073N/Astatic void _fromclass();
1073N/A
1073N/A/**
1073N/A ** fromclass() - REMOVE PRINTER FROM A CLASS
1073N/A **/
1073N/A
1073N/Avoid fromclass (printer, class)
1073N/A char *printer,
1073N/A *class;
1073N/A{
1073N/A CLASS *pc;
1073N/A
1073N/A if (!(pc = getclass(class))) {
1073N/A LP_ERRMSG1 (ERROR, E_LP_NOCLASS, class);
1073N/A done (1);
1073N/A }
1073N/A
1073N/A if (!searchlist(printer, pc->members)) {
1073N/A LP_ERRMSG2 (ERROR, E_ADM_NOTMEM, printer, class);
1073N/A done (1);
1073N/A }
1073N/A
1073N/A _fromclass (printer, class, pc);
1073N/A
1073N/A return;
1073N/A}
1073N/A
1073N/A/**
1073N/A ** fromallclasses() - DELETE A PRINTER FROM ALL CLASSES
1073N/A **/
1073N/A
1073N/Avoid fromallclasses (printer)
1073N/A char *printer;
1073N/A{
1073N/A register CLASS *pc;
1073N/A
1073N/A
1073N/A while ((pc = getclass(NAME_ALL)))
1073N/A if (searchlist(printer, pc->members))
1073N/A _fromclass (printer, pc->name, pc);
1073N/A
1073N/A if (errno != ENOENT) {
1073N/A LP_ERRMSG1 (ERROR, E_ADM_GETCLASSES, PERROR);
1073N/A done (1);
1073N/A }
1073N/A
1073N/A return;
1073N/A}
1073N/A
1073N/A/**
1073N/A ** _fromclass() - REALLY DELETE PRINTER FROM CLASS
1073N/A **/
1073N/A
1073N/Astatic void _fromclass (printer, class, pc)
1073N/A char *printer,
1073N/A *class;
1073N/A CLASS *pc;
1073N/A{
1073N/A int rc;
1073N/A
1073N/A
1073N/A if (dellist(&pc->members, printer) == -1) {
1073N/A LP_ERRMSG (ERROR, E_LP_MALLOC);
1073N/A done(1);
1073N/A }
1073N/A
1073N/A if (!pc->members)
1073N/A rmdest (1, class);
1073N/A
1073N/A else {
1073N/A BEGIN_CRITICAL
1073N/A if (putclass(class, pc) == -1) {
1073N/A LP_ERRMSG2 (
1073N/A ERROR,
1073N/A E_LP_PUTCLASS,
1073N/A class,
1073N/A PERROR
1073N/A );
1073N/A done(1);
1073N/A }
1073N/A END_CRITICAL
1073N/A
1073N/A send_message(S_LOAD_CLASS, class, "", "");
1073N/A rc = output(R_LOAD_CLASS);
1073N/A
1073N/A switch(rc) {
1073N/A case MOK:
1073N/A break;
1073N/A
1073N/A case MNODEST:
1073N/A case MERRDEST:
1073N/A LP_ERRMSG (ERROR, E_ADM_ERRDEST);
1073N/A done (1);
1073N/A /*NOTREACHED*/
1073N/A
1073N/A case MNOSPACE:
1073N/A LP_ERRMSG (WARNING, E_ADM_NOCSPACE);
1073N/A break;
1073N/A
1073N/A case MNOPERM: /* taken care of up front */
1073N/A default:
1073N/A LP_ERRMSG1 (ERROR, E_LP_BADSTATUS, rc);
1073N/A done (1);
1073N/A /*NOTREACHED*/
1073N/A }
1073N/A
1073N/A }
1073N/A return;
1073N/A}
1073N/A