gspool_ptrread(3) get the details of a printer

SYNOPSIS

#include <gspool.h>

int gspool_ptrread(const int fd, const unsigned flags, const slotno_t slot, struct apispptr *ptrd)

DESCRIPTION

The gspool_ptrread() function is used to retrieve the details of a printer from a given slot number.

fd is a file descriptor previously returned by gspool_open

flags is zero, or a logical OR of one of the following values

GSPOOL_FLAG_LOCALONLY
Ignore remote printers/hosts, i.e. not local to the server, not the client.
GSPOOL_FLAG_USERONLY
Ignore other users jobs
GSPOOL_FLAG_IGNORESEQ
Ignore changes since the list was last read

slot is the slot number corresponding to the printer as previouly returned by a call to gspool_ptrlist() or gspool_ptrfindslot().

ptrd is a descriptor, which on return will contain the details of the printer in a "struct apispptr" as defined in gspool.h and containing the following elements:

jobno_t apispp_job
Job number being printed
slotno_t apispp_jslot
Slot number of job being printed
char apispp_state
State of printer
char apispp_sflags
Scheduler flags
unsigned char apispp_dflags
Despooler flags
unsigned char apispp_netflags
Network flags
unsigned short apispp_extrn
External printer type 0=standard
classcode_t apispp_class
Class code bits 1=A 2=B 4=C etc
int_pid_t apispp_pid
Process id of despooler process
netid_t apispp_netid
Host id of printer network byte order
slotno_t apispp_rslot
Slot number on remote machine
unsigned long apispp_minsize
Minimum size of acceptable job
unsigned long apispp_maxsize
Maximum size of acceptable job
char apispp_dev[]
Device name
char apispp_form[]
Form type
char apispp_ptr[]
Printer name
char apispp_feedback[]
Feedback message
char apispp_comment[]
Printer description

The following bits are set in the "apispp_sflags" field to indicate printer flags:

APISPP_INTER
Had interrupt message, not yet acted on it.
APISPP_HEOJ
Had halt at end of job

The following bits are set in the "apispp_dflags" field to indicate printer flags:

APISPP_HADAB
Had "Abort" message
APISPP_REQALIGN
Alignment required

The "apispp_netflags" field contains the following bits:

APISPP_LOCALONLY
Printer is local only to host.
APISPP_LOCALHOST
Printer uses network filter

RETURN VALUES

The function gspool_ptrread() returns 0 if successful, otherwise one of the following codes:
GSPOOL_UNKNOWN_PTR
Printer not found
GSPOOL_INVALID_FD
Invalid File descriptor
GSPOOL_BADWRITE
failure writing to the network
GSPOOL_BADREAD
failure reading from the network
GSPOOL_NOPERM
The user does not have permission
GSPOOL_SEQUENCE
Printer sequence error, slot may be out of date
GSPOOL_INVALIDSLOT
Invalid slot number

EXAMPLE

An example to read the names of all printers

 int fd, ret, np, i;
 struct apispptr ptr;
 slotno_t *slots;
 fd = gspool_open("myhost", (char *)0, 0);
 if (fd < 0) {  /* error handling */
     ...
 }
 ret = gspool_ptrlist(fd, 0, &np, &slots);
 if (ret < 0) { /* error handling */
     ...
 }
 for (i = 0; i < np, i++) {
     ret = gspool_ptrread(fd, GSPOOL_FLAG_IGNORESEQ, slots[i], &ptr);
     if (ret < 0)       { /* error handling */
         ...
     }
     printf("%s\n", ptr.apispp_ptr);
 }
 gspool_close(fd);

COPYRIGHT

Copyright (c) 2009 Free Software Foundation, Inc. This is free software. You may redistribute copies of it under the terms of the GNU General Public License <http://www.gnu.org/licenses/gpl.html>. There is NO WARRANTY, to the extent permitted by law.

AUTHOR

John M Collins, Xi Software Ltd.