# non-exported but global to the package:
use vars qw{
$PSTAT_SERVICE_REQ
$PSTAT_OFFLINE
$PSTAT_PAPER_JAM
$PSTAT_DOOR_OPEN
$PSTAT_TONER_OUT
$PSTAT_TONER_LOW
$PSTAT_PAPER_OUT
$PSTAT_PAPER_LOW
$PSTAT_IDLE
$PSTAT_PRINTING
$PSTAT_WARMING_UP
$PSTAT_UNREACHABLE
$PSTAT_MAX
%statmsg
%prtstatmsg
};
# Loads modules from source directory if executed in source directory
use lib qw(. /usr/local/netprint/lib);
use npparams;
use SNMP_mib;
use SNMP_Session;
use BER;
# Note: The bit definitions for the first 8 of the items below are taken
# from the description of the values for hrPrinterDetectedErrorState in
# RFC1759.
BEGIN {
$PSTAT_SERVICE_REQ = 1;
$PSTAT_OFFLINE = 2;
$PSTAT_PAPER_JAM = 4;
$PSTAT_DOOR_OPEN = 8;
$PSTAT_TONER_OUT = 16;
$PSTAT_TONER_LOW = 32;
$PSTAT_PAPER_OUT = 64;
$PSTAT_PAPER_LOW = 128;
$PSTAT_IDLE = 256;
$PSTAT_PRINTING = 512;
$PSTAT_WARMING_UP = 1024;
$PSTAT_UNREACHABLE = 2048;
$PSTAT_MAX = 2048;
########################################################
#
# get_status($printer)
#
# Uses SNMP to find the status and returns an errorcode
# which can be deciphered in err2str, which will return an array of
# strings specifying the error(s) occuring.
#########################################################
# err2str ($code)
#
# Given an errorcode, this sub will convert the
# code to an array of strings, each ending in a newline.
#########################################################
# printer_ok($code)
#
# Given a printer status code, return TRUE for printer OK, and FALSE
# for printer not functioning.
#########################################################
# printer_idle($code)
#
# Given a printer status code, return TRUE for printer idle, and FALSE
# for any other printer status.
#########################################################
# get_printerlist
# get_printerinfo
# get_allprinterinfo
#
# More convenient and rigorous versions of get_prt_cfg.
# @list = get_printerlist() places a list of all printers in $list.
# %info = get_printerinfo($pname) returns a hash of the printer info for
# $printer.
# %info = get_allprinterinfo() returns a hash of hashes containing all
# the printer info in the database
#
# All routines return 'undef' for error.
# global variables (local to this package)
my(%printerinfo);
my($pi_timestamp);