nntpclnt(3)

NAME
getserverbyfile, server_init, put_server, get_server, close_server - NNTP Client Programming Interface

SYNTAX
#include nntp.h
#include nntpclnt.h

char	*getserverbyfile(filename)
char	*filename;

int	server_init(host)
char	*host;

void	put_server(s)
char	*s;

int	get_server(buffer,sz)
char	*buffer;
int	sz;

void	close_server();

DESCRIPTION
The routines can be used by NNTP client software to access an NNTP server.

The files nntp.h and nntpclnt.h are supplied in the source code release of the client routines. nntp.h contains each of the possible responses by the server and gives each a symbolic name. nntpclnt.h contains the external definitions of the routines described here. Users of these routines should use these files in their code whenever possible to make it easy to adapt to any changes that may occur to the routines or the NNTP protocol.

getserverbyfile returns the name of the NNTP server according to the following rules:
    1. If the NNTPSERVER environment variable is set, its value is returned. Note that if the variable exists, the filename argument is ignored.

    2. If the filename argument specifies a valid filename, then the first line that does not begin with a pound sign is returned.

    3. Otherwise, NULL is returned.

server_init initializes conversation with the NNTP server on the machine specified by the host argument. If the connection cannot be made (generally due to name lookup or other network problems), the routine returns a negative value and uses perror to send an error message to the user. If the connection can be made, the server's initial response code (200 if posting is allowed, 201 if not or 502 if the client is not allowed to use the server) is returned. If DECNET support is compiled into the client and the host is followed by two colons (e.g., ``nodname::'' or ``area.node::'') then DECNET transport will be used. The default is to use TCP/IP transport. For TCP/IP transport, the host argument may be a hostname or an IP address in dotted-quad format.

put_server sends the string s to the NNTP server over the connection setup by server_init. The string can be protocol commands like POST or ARTICLE, or other data. put_server will canonicalize the string before forwarding it to the server.

get_server retrieves data from the server. The buffer argument points to a preallocated array that must be least as large as the maximum length that may be possibly returned by the NNTP server. (RFC 977 defines this length as 512 characters.) The sz argument should contain the size of the buffer. The client application is responsible for interpreting the contents of the information.

close_server terminates the connection with the server in an orderly fashion. This routine sends the NNTP QUIT command and closes down the network connection.

ENVIRONMENT

NNTPSERVER	consulted by getserverbyfile for NNTP server name

SEE ALSO
RFC-977

AUTHOR
Stan Barber, Baylor College of Medicine.

Please reports bugs or problems to the nntp support address nntp@tmc.edu.

NOTES
For more information on supporting DECNET, please see the README.DECNET file included with the source code release of the client routines. For more information on support for PC-NFS on MSDOS, please see the README.PCNFS file included with the source code release of the client routines.