pap(3)

NAME
AppleTalk Printer Access Protocol (PAP) interface

SYNOPSIS

#include <at/appletalk.h>
#include <at/pap.h>
#include <at/nbp.h>

int pap_open(at_nbptuple_t *tuple);

int pap_read(int sd, unsigned char *data, int len);

int pap_read_ignore(int sd);

char *pap_status(at_nbptuple_t *tuple);

int pap_write(int sd, char *data, int len,
int eof, int flush);

int pap_close(int sd);

DESCRIPTION
The PAP interface provides applications with access to the AppleTalk Printer Access Protocol operations.

The pap_open routine opens a PAP client AppleTalk socket to a server. It attempt to connect to the server whose name and address are contained in the tuple parameter. nbp_lookup (See nbp(3)) may be used to obtain a valid tuple for the desired PAP server.

Upon successful completion, this routine returns a PAP client AppleTalk socket connected to the server requested.

The pap_read routine reads data from a client PAP socket opened by a pap_open call.

sd  A PAP client AppleTalk socket descriptor from a previous open.

data
    The address of the data to be returned. The maximum data length returned is 512 bytes.

length
    The maximum length to be read.

Upon successful completion, the number of bytes read is returned. A value of 0 is returned when an end-of-file is reached.

The pap_read_ignore routine issues a PAP read request and ignores any returned data. This is used to allow LaserWriters to function when they want to return ``status'' messages.

sd  The AppleTalk socket descriptor returned by an earlier pap_open.

The pap_status routine locates a PAP server and returns pointer to its status string.

tuple
    A pointer to tuple struct containing an name and address of a PAP server entity. The routine nbp_lookup (See nbp(3)) may be used to get a valid tuple.

Upon successful completion, a pointer to the string containing PAP server's status is returned; if the printer's status can not be recovered, NULL is returned.

The pap_write routine sends the data passed to it to the other end of a PAP client session.

sd  A valid PAP client AppleTalk socket descriptor from a call to pap_open.

data
    A pointer to the data being written.

len The length of the data being written; this must not exceed 512 bytes.

eof Boolean flag indicating if EOF indication is to be sent to the other end of PAP session (after the data has been sent) to indicate that no more data will be sent. Setting eof to true implies flush.

flush
    Boolean flag indicating if data for all waiting PAP writes is to be sent to the remote end. Because PAP runs on top of ATP, PAP writes are queued up until either a complete ATP response is available (about 4K bytes) or an end-of-message is sent. This call sends an ATP end-of-message, which causes all waiting PAP writes to be sent to the other end. This should be done if a higher level protocol (for example, a handshake with a LaserWriter) needs to do a write followed by a read.

Upon successful completion, a value of 0 is returned.

The pap_close routine closes an open PAP client AppleTalk socket.

sd  Descriptor for the AppleTalk socket that is to be closed.

It returns 0 upon successful completion or -1 on error.

ERRORS
All routines return -1 on error with a detailed error code in errno:

[EINVAL]
    An invalid argument was passed.

[ENETDOWN]
    The network interface is down.

[ESHUTDOWN]
    The requested AppleTalk socket has already been closed.

[ETIMEDOUT]
    The connection is timed out.

See open(2), close(2), read(2), write(2), and ioctl(2) for additional error codes; see also errors returned by the underlying NBP, ATP, DDP, and LAP modules.

SEE ALSO
atp(3), ddp(3), lap(3), nbp(3), rtmp(3)

Inside AppleTalk.