/*
* 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"
/* EMACS_MODES: !fill, lnumb, !overwrite, !nodelete, !picture */
#include "stdio.h"
#include "string.h"
#include "errno.h"
#include "stdlib.h"
#include "lp.h"
#include "printers.h"
#include <unistd.h>
extern struct {
char *v;
short len,
} prtrheadings[];
#if defined(__STDC__)
static void print_l (int, char *, char **);
static void print_str (int, char *, char *);
#ifdef LP_USE_PAPI_ATTR
#endif
#else
static void print_sdn(),
print_l(),
print_str();
#ifdef LP_USE_PAPI_ATTR
static int addPrintersPPD();
static int copyPPDFile();
static int unzipPPDFile();
#endif
#endif
unsigned long ignprinter = 0;
int ppdopt = 0;
/**
** putprinter() - WRITE PRINTER STRUCTURE TO DISK FILES
**/
int
{
register char * path;
register char * stty;
register char * speed;
int fld;
badprinter = 0;
return (-1);
}
return (-1);
}
/*
* First go through the structure and see if we have
* anything strange.
*/
return (-1);
}
if (!Lp_A_Printers || !Lp_A_Interfaces) {
if (!Lp_A_Printers || !Lp_A_Interfaces)
return (0);
}
/*
* Create the parent directory for this printer
* if it doesn't yet exist.
*/
return (-1);
return (-1);
}
return (-1);
}
/*
* Create the copy of the interface program, unless
* that would be silly or not desired.
* Conversely, make sure the interface program doesn't
* exist for a remote printer.
*/
return (-1);
}
return (-1);
return (-1);
if (
) {
register int n;
return (-1);
}
return (-1);
}
}
}
#ifdef LP_USE_PAPI_ATTR
/*
* Handle PPD (Postscript Printer Definition) file for printer
* if this printer has been configured with one
*/
{
{
/* failed to added the printers PPD file */
return (-1);
}
}
#endif
/*
* If this printer is dialed up, remove any baud rates
* from the stty option list and move the last one to
* the ".speed" member if the ".speed" member isn't already
* set. Conversely, if this printer is directly connected,
* move any value from the ".speed" member to the stty list.
*/
else
speed = 0;
register char *newstty,
*p,
*q;
register int len;
return (-1);
}
newstty[0] = 0; /* start with empty copy */
for (
p;
p = strtok((char *)0, " ")
) {
/*
* If "prbufp->speed" isn't set, then
* use the speed we just found. Don't
* check "speed", because if more than
* one speed was given in the list, we
* want the last one.
*/
if (speed)
}
} else {
/*
* Not a speed, so copy it to the
* new stty string.
*/
if (q != newstty)
*q++ = ' ';
strcpy (q, p);
q += len;
}
}
register char *newstty;
if (!newstty) {
if (stty)
return (-1);
}
if (stty) {
} else
speed = 0;
}
/*
* Open the configuration file and write out the printer
* configuration.
*/
if (stty)
if (speed)
return (-1);
}
if (stty)
if (speed)
return (-1);
}
errno = 0;
continue;
switch (fld) {
case PR_BAN:
{
case BAN_ALWAYS:
break;
case BAN_NEVER:
break;
case BAN_OPTIONAL:
ptr = NAME_OPTIONAL;
break;
}
}
break;
case PR_CPI:
break;
case PR_CS:
break;
case PR_ITYPES:
/*
* Put out the header even if the list is empty,
* to distinguish no input types from the default.
*/
break;
case PR_DEV:
break;
case PR_DIAL:
break;
case PR_RECOV:
break;
case PR_INTFC:
break;
case PR_LPI:
break;
case PR_LEN:
break;
case PR_LOGIN:
break;
case PR_PTYPE:
{
char **printer_types;
/*
* For backward compatibility for those who
* use only "->printer_type", we have to play
* some games here.
*/
);
else
if (!printer_types || !*printer_types)
else
break;
}
case PR_REMOTE:
break;
case PR_SPEED:
break;
case PR_STTY:
break;
case PR_WIDTH:
break;
#if defined(CAN_DO_MODULES)
case PR_MODULES:
/*
* Put out the header even if the list is empty,
* to distinguish no modules from the default.
*/
break;
#endif
case PR_OPTIONS:
break;
case PR_PPD:
{
break;
}
}
}
if (stty)
if (speed)
if (errno != 0) {
return (-1);
}
/*
* If we have a description of the printer,
* write it out to a separate file.
*/
if (prbufp->description) {
return (-1);
return (-1);
}
}
/*
* Now write out the alert condition.
*/
if (
)
return (-1);
return (0);
}
/**
** print_sdn() - PRINT SCALED DECIMAL NUMBER WITH HEADER
** print_l() - PRINT (char **) LIST WITH HEADER
** print_str() - PRINT STRING WITH HEADER
**/
static void
{
return;
return;
}
static void
{
printlist_setup (0, 0, LP_SEP, 0);
return;
}
static void
{
return;
return;
}
#ifdef LP_USE_PAPI_ATTR
/*
* Function: addPrintersPPD()
*
* Description: Handle PPD (Postscript Printer Definition) file for this
* printer if it has been configured with one
*
*/
static int
{
int result = 0;
{
/* make sure the PPD file doesn't exist for a remote printer */
{
result = -1;
}
else
{
}
}
{
{
result = -1;
}
else
{
/* Check the PPD file given exists */
{
/*
* The given ppd files does not exist, but
* check if there is a zipped version of the
* file that we can use instead
*/
{
/* this is a zipped file so exit */
result = -1;
}
else
{
{
{
/*
* this zipped version
* of the file does not
* exist either
*/
result = -1;
}
}
else
{
result = -1;
}
}
}
}
/*
* Create the copy of the PPD file for this printer
* unless that would be silly or not desired
*/
if (result == 0)
{
{
result = -1;
}
}
/*
* At this point we may have a zipped or unzipped ppd file, if
* it's unzipped just copy it otherwise unzip it to the
*/
if (result == 0)
{
{
}
else
{
}
(void) chown_lppath(path);
}
{
}
{
}
}
return (result);
} /* addPrintersPPD() */
/*
* Function: copyPPDFile()
*
*
*/
static int
{
int result = 0;
register int n = 0;
int fdin = 0;
int fdout = 0;
{
{
result = -1;
}
else
{
if (fdout < 0)
{
result = -1;
}
}
if (result == 0)
{
{
}
}
}
else
{
result = -1;
}
return (result);
} /* copyPPDFile() */
/*
* Function: unzipPPDFile()
*
* This is done by forking and running the unzip utility on the
* zipped ppd file.
*
*/
static int
{
int stat = 0;
int clSize = 0;
{
switch (childPID)
{
case -1:
{
/* return error */
break;
}
case 0:
{
/* child process - so execute something */
{
}
break;
}
default:
{
/* parent process, child pid is in childPID */
if ((stat & 0xff00) == 0)
{
result = 0;
}
break;
}
}
}
return (result);
} /* unzipPPDFile() */
#endif