/*
* 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 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
extern char *postbegin;
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <stdarg.h>
#include <signal.h>
#include <unistd.h>
/*
* the parameter structure for the parallel port
*/
struct ppc_params_t {
};
extern char *block;
extern int readblock(int);
static void printer_info(char *fmt, ...);
/* These are the routines avaliable to others for use */
int is_a_parallel_bpp(int);
int bpp_state(int);
int parallel_comm(int, int());
int get_ecpp_status(int);
int is_a_prnio(int);
int prnio_state(int);
/****************************************************************************/
/**
* for BPP PARALLEL interfaces
**/
{
return(1);
return(0);
}
{
return(buf);
}
#endif
{
int state;
#endif
/* paper is out */
return(PRINTER_ERROR_PAPER_OUT);
} else if (state & BPP_BUSY_ERR) {
/* printer is busy */
return(PRINTER_ERROR_BUSY);
} else if (state & BPP_SLCT_ERR) {
/* printer is offline */
return(PRINTER_ERROR_OFFLINE);
} else if (state & BPP_ERR_ERR) {
/* printer is errored */
return(PRINTER_ERROR_ERROR);
} else if (state == BPP_PE_ERR) {
return(PRINTER_ERROR_CABLE_POWER);
} else if (state) {
return(PRINTER_ERROR_UNKNOWN);
} else
return(0);
}
return(0);
}
int
{
int state;
return(-1);
}
/*
* We don't know what all printers will return in
* nibble mode, therefore if we support nibble mode we will
* force the printer to be in CENTRONICS mode.
*/
if (state != ECPP_CENTRONICS) {
return(-1);
} else {
}
}
return(state);
}
/**
* For prnio(7I) - generic printer interface
**/
{
/* check if device supports prnio */
return (0);
}
/* we will use 1284 status if available */
if ((cap & PRN_1284_STATUS) == 0) {
/* some devices may only support 1284 status in unidir. mode */
}
}
return (1);
}
{
return(0);
}
return(PRINTER_ERROR_UNKNOWN);
}
/* paper is out */
return(PRINTER_ERROR_PAPER_OUT);
return(PRINTER_ERROR_CABLE_POWER);
} else if ((pins & PRN_1284_SELECT) == 0) {
/* printer is offline */
return(PRINTER_ERROR_OFFLINE);
} else if ((pins & PRN_1284_NOFAULT) == 0) {
/* printer is errored */
return(PRINTER_ERROR_ERROR);
} else if (pins & PRN_1284_PE) {
/* paper is out */
return(PRINTER_ERROR_PAPER_OUT);
return(PRINTER_ERROR_UNKNOWN);
}
return(0);
}
/**
* Common routines
**/
/*ARGSUSED0*/
static void
{
/* try to shove out the EOT */
exit(0);
}
/*ARGSUSED0*/
static void
{
"%%%%[ PrinterError: %s; source: parallel ]%%%%\n",
mesg);
fsync(2);
"%%%%[ PrinterError: %s; source: parallel ]%%%%\n",
mesg);
}
}
static void
{
switch (error) {
case -1:
break;
case PRINTER_ERROR_PAPER_OUT:
printer_info("out of paper");
break;
case PRINTER_ERROR_OFFLINE:
printer_info("offline");
break;
case PRINTER_ERROR_BUSY:
printer_info("busy");
break;
case PRINTER_ERROR_ERROR:
printer_info("printer error");
break;
printer_info("printer powered off or disconnected");
break;
case PRINTER_ERROR_UNKNOWN:
printer_info("unknown error");
break;
case PRINTER_ERROR_TIMEOUT:
printer_info("communications timeout");
break;
default:
printer_info("get_status() failed");
}
}
static void
{
int state;
int was_faulted = 0;
was_faulted=1;
sleep(15);
}
if (was_faulted) {
fsync(2);
}
}
}
int
{
int count = 0;
/* is the device ready? */
/* bracket job with EOT */
/* write(fd, postbegin, strlen(postbegin)); */
alarm(120);
alarm(0);
sleep(30);
continue;
} else {
printer_info("I/O Error during write(): %s",
exit(2);
}
}
alarm(0);
if (actual >= 0)
#endif
}
/* write the final EOT */
return (0);
}