do_printer.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* 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
* 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 (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <limits.h>
#include <stdlib.h>
#include <libintl.h>
#include "lp.h"
#include "class.h"
#include "printers.h"
#include "msgs.h"
#define WHO_AM_I I_AM_LPADMIN
#include "oam.h"
#include "lpadmin.h"
extern void fromallclasses();
#if !defined(PATH_MAX)
# define PATH_MAX 1024
#endif
#if PATH_MAX < 1024
# define PATH_MAX 1024
#endif
extern char *label;
static void configure_printer();
static char *fullpath();
char *nameit();
/**
** do_printer() - CREATE OR CHANGE PRINTER
**/
void do_printer ()
{
int rc;
/*
* Set or change the printer configuration.
*/
if (strlen(modifications))
/*
*/
if (!oldp)
done(1);
}
done(1);
}
done(1);
}
}
if (!oldp)
done(1);
}
done(1);
}
done(1);
}
/*
*/
if (!oldp)
done(1);
}
done(1);
}
done(1);
}
}
/*
* Tell the Spooler about the printer
*/
switch (rc) {
case MOK:
break;
case MNODEST:
case MERRDEST:
done (1);
/*NOTREACHED*/
case MNOSPACE:
break;
case MNOPERM: /* taken care of up front */
default:
done (1);
/*NOTREACHED*/
}
/*
* Now that the Spooler knows about the printer,
* we can do the balance of the changes.
*/
/*
* Mount or unmount form, print-wheel.
*/
if (M)
do_mount(p, (f? f : (char *)0), (S? *S : (char *)0));
else if (t) do_max_trays(p);
/*
* Display the alert type.
*/
if (label)
}
/*
* -A quiet.
*/
if (A && STREQU(A, NAME_QUIET)) {
switch(rc) {
case MOK:
break;
case MNODEST: /* not quite, but not a lie either */
case MERRDEST:
break;
case MNOPERM: /* taken care of up front */
default:
done (1);
/*NOTREACHED*/
}
}
/*
* Add printer p to class c
*/
if (c) {
c = NAME_ALL;
goto Done;
c,
);
done (1);
}
/*
* Create the class
*/
done (1);
}
done (1);
}
);
done(1);
}
switch(rc) {
case MOK:
break;
case MNODEST:
case MERRDEST:
done (1);
/*NOTREACHED*/
case MNOSPACE:
break;
case MNOPERM: /* taken care of up front */
default:
done (1);
/*NOTREACHED*/
}
goto Loop;
}
Done:
/*
* Remove printer p from class r
*/
if (r) {
fromallclasses(p);
else
fromclass(p, r);
}
return;
}
/**
** configure_printer() - SET OR CHANGE CONFIGURATION OF PRINTER
**/
static void configure_printer (list)
char *list;
{
char type;
char * infile_opts = NULL;
if (oldp) {
if (!T)
T = prbufp->printer_types;
if (!i && !e && !m)
/*
* Don't copy the original interface program
* again, but do keep the name of the original.
*/
else
ignprinter = 0;
/*
* If we are making this a remote printer,
* make sure that local-only attributes are
* cleared.
*/
if (s) {
prbufp->fault_alert.Q = 0;
prbufp->fault_alert.W = 0;
#if defined(CAN_DO_MODULES)
#endif
/*
* If we are making this a local printer, make
* sure that some local-only attributes are set.
* values will overwrite what we set here.)
*/
/*
* Being here means "!s && oldp->remote" is true,
* i.e. this printer never had an interface pgm
* before. Thus we can safely clear the following.
* This is needed to let "putprinter()" copy the
* (default) interface program.
*/
ignprinter = 0;
}
} else {
/*
* The following takes care of the lion's share
* of the initialization of a new printer structure.
* However, special initialization (e.g. non-zero,
* or substructure members) needs to be considered
* for EACH NEW MEMBER added to the structure.
*/
prbufp = &printer_struct;
if (!s)
if (!s && !A)
prbufp->fault_alert.Q = 0;
prbufp->fault_alert.W = 0;
}
case 'A':
if (!s) {
else if (!STREQU(A, NAME_QUIET))
}
break;
case 'b':
if (!s)
break;
case 'c':
if (!s)
break;
case 'D':
prbufp->description = D;
break;
case 'e':
if (!s) {
e,
(char *)0
);
}
break;
case 'F':
if (!s)
break;
#if defined(CAN_DO_MODULES)
case 'H':
if (!s)
break;
#endif
case 'h':
if (!s)
break;
case 'i':
if (!s)
break;
case 'I':
prbufp->input_types = I;
break;
case 'l':
if (!s)
break;
case 'L':
if (!s)
break;
case 'm':
if (!s)
break;
case 'M':
if (!s)
break;
#ifdef LP_USE_PAPI_ATTR
case 'n':
{
{
if (*n_opt == '/')
{
}
else
{
}
ppdopt = 1;
}
break;
}
#endif
case 'o':
/*
* The "undefined" key-value -o options
*
* Options requires special handling. It is a
* list whose members are to be handled
* individually.
*
* Need to: set new options, keep old options if not
* redefined, remove old options if defined as "key=".
*
*
* "p" is a global containing the printer name
*/
if (!s) {
else {
}
}
break;
case 'R':
if (s) {
} else
break;
case 's':
if (!s) {
/*
* lpadmin always defers to stty
*/
}
break;
case 'S':
if (!M)
else
break;
case 'T':
prbufp->printer_types = T;
break;
case 'U':
if (!s) {
}
break;
case 'v':
if (!s) {
}
break;
case 'w':
if (!s)
break;
case 'W':
if (!s)
prbufp->fault_alert.W = W;
break;
}
if (
&& (badprinter & BAD_INTERFACE)
)
);
else
p,
);
done(1);
}
return;
}
/**
** fullpath()
**/
char *str;
{
register char *cur_dir,
*path;
str++;
if (*str == '/')
return (str);
return (str);
/*
* Here we could be nice and strip out /./ and /../
* stuff, but it isn't necessary.
*/
return (path);
}
/**
** nameit() - ADD USER NAME TO COMMAND
**/
char *cmd;
{
);
return (copy);
}