gspool_getspd(3) get the default permissions

SYNOPSIS

#include <gspool.h>

int gspool_getspd(const int fd, struct apisphdr *res)

DESCRIPTION

The gspool_getspd() function is used to retrieve the defaults privileges, form types etc for new users on the host with which the API is communicating.

fd is a file descriptor previously returned by gspool_open

res is a descriptor which upon return will contain the the default user privileges. The structure apisphdr is defined in gspool.h and contains the following elements:

long sph_lastp
Time last read password file
unsigned char sph_minp
Minimum priority
unsigned char sph_maxp
Maximum priority
unsigned char sph_defp
Default priority
char sph_form[]
Default form type
char sph_formallow[]
Allowed form type pattern
char sph_ptr[]
Default printer
char sph_ptrallow[]
Allowed printer pattern
unsigned long sph_flgs
Privilege flag
classcode_t sph_class
Class of printers
unsigned char sph_cps
Maximum copies allowed
unsigned char sph_version
Release of GNUspool

The "spu_flgs" field will contain a combination of the following:

PV_ADMIN
Administrator (edit admin file)
PV_SSTOP
Can run sstop (can stop scheduler)
PV_FORMS
Can use other forms than default
PV_CPRIO
Can change priority on queue
PV_OTHERJ
Can change other users' jobs
PV_PRINQ
Can move to printer queue
PV_HALTGO
Can halt, restart printer
PV_ANYPRIO
Can set any priority on queue
PV_CDEFLT
Can change own default priority
PV_ADDDEL
Can add/delete printers
PV_COVER
Can override class
PV_UNQUEUE
Can unqueue jobs
PV_VOTHERJ
Can view other jobs not neccesarily edit
PV_REMOTEJ
Can access remote jobs
PV_REMOTEP
Can access remote printers
PV_FREEZEOK
Can save default options
PV_ACCESSOK
Can access sub-screens
PV_OTHERP
Can use other printers from default
ALLPRIVS
A combination of all of the above

RETURN VALUES

The function gspool_getspd() returns 0 if successful otherwise one of the following codes:
GSPOOL_UNKNOWN_USER
Invalid user name
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

EXAMPLE

An example to view the default privleges on the host machine:

 int fd, ret;
 struct apisphdr res;
 fd = gspool_open("myhost", (char *) 0, 0);
 if (fd < 0) { /* error handling */
     ...
 }
 ret = gspool_getspd(fd, &res);
 if (ret < 0)  { /* error handling */
     ...
 }
 if (res.sph_flgs & PV_HALTGO)
     printf("users cannot stop and start printers\n");
 printf("the default maximum priority is %s\n", res);
 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.