gspool_ptradd(3) add a new printer

SYNOPSIS

#include <gspool.h>

int gspool_ptradd(const int fd, struct apispptr *ptrd)

DESCRIPTION

The function gspool_ptradd() is used to create a printer.

fd is a file descriptor previously returned by gspool_open

ptrd is a "struct apispptr" describing the details of the printer. It is defined in the file gspool.h. The fields in struct apispptr are defined in the documentation for gspool_ptrread(3).

Only values for the name, device, formtype, description, local flag, the minimun and maximum job sizes, the network filter flag and the class code are accepted. All other parameters are ignored. We suggest that you clear all fields to zero before starting. Future releases with additional fields will be guaranteed to default to the existing behaviour if the additional fields are set to zero.

RETURN VALUES

Xt_ptradd returns zero if successful, otherwise an error code will be returned according to the reason for failure. Error codes which might be returned are:
GSPOOL_INVALID_FD
Invalid file descriptor
GSPOOL_BADWRITE
failure writing to network
GSPOOL_BADREAD
failure reading from network
GSPOOL_NOPERM
User does not have permission to add printers
GSPOOL_BAD_FORM
invalid form type

EXAMPLE

An example to add a printer called "hplj1" on device "/dev/tty12" with form type "a4"

 int fd, ret;
 struct apispptr ptr;
 fd = gspool_open("myhost", (char *) 0, 0);
 if (fd < 0) { /* error handling */
     ...
 }
 memset((void *) &ptr, '\0', sizeof(ptr));
 ptr.apispp_class = 0xffffffff;
 ptr.apispp_minsize = ptr.apispp_maxsize = 0;
 strcpy(ptr.apispp_ptr, "hplj1");
 strcpy(ptr.apispp_form, "a4");
 strcpy(ptr.apispp_dev, "tty12");
 strcpy(ptr.apispp_comment, "My new printer");
 ret = gspool_ptradd(fd, &ptr);
 if (ret < 0) { /* error handling */
     ...
 }
 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.