.\" $Revision: 6124 $ .TH LIBINN 3 .SH NAME libinn \- InterNetNews library routines .SH SYNOPSIS .nf .ta \w' unsigned long 'u .B #include "libinn.h" .B "typedef struct _TIMEINFO {" .B " time_t time;" .B " long usec;" .B " long tzone; .B "} TIMEINFO;" .B "char *" .B "GenerateMessageID(domain)" .B " char *domain;" .B "void" .B "HeaderCleanFrom(from)" .B " char *from;" .B "char *" .B "HeaderFind(Article, Header, size)" .B " char *Article;" .B " char *Header;" .B " int size;" .B "FILE *" .B "CAopen(FromServer, ToServer)" .B " FILE *FromServer;" .B " FILE *ToServer;" .B "FILE *" .B "CAlistopen(FromServer, ToServer, request)" .B " FILE *FromServer;" .B " FILE *ToServer;" .B " char *request;" .B "void" .B "CAclose()" .B "struct _DDHANDLE *" .B "DDstart(FromServer, ToServer)" .B " FILE *FromServer;" .B " FILE *ToServer;" .B "void" .B "DDcheck(h, group)" .B " DDHANDLE *h;" .B " char *group;" .B "char *" .B "DDend(h)" .B " DDHANDLE *h;" .B "void" .B "close_on_exec(fd, flag)" .B " int fd;" .B " bool flag;" .B "int" .B "nonblocking(fd, flag)" .B " int fd;" .B " bool flag;" .B "bool" .B "inn_lock_file(fd, type, flag)" .B " int fd;" .B " LOCKTYPE type;" .B " bool block;" .B "char *" .B "GetFQDN(domain)" .B " char *domain;" .B "char *" .B "GetModeratorAddress(FromServer, ToServer, group, moderatormailer)" .B " FILE *FromServer;" .B " FILE *ToServer;" .B " char *group;" .B " char *moderatormailer;" .B "int" .B "GetResourceUsage(usertime, systime)" .B " double *usertime;" .B " double *systime;" .B "int" .B "GetTimeInfo(now)" .B " TIMEINFO *now;" .B "int" .B "NNTPlocalopen(FromServerp, ToServerp, errbuff)" .B " FILE **FromServerp;" .B " FILE **ToServerp;" .B " char *errbuff;" .B "int" .B "NNTPremoteopen(port, FromServerp, ToServerp, errbuff)" .B " int port;" .B " FILE **FromServerp;" .B " FILE **ToServerp;" .B " char *errbuff;" .B "int" .B "NNTPconnect(host, port, FromServerp, ToServerp, errbuff)" .B " char *host;" .B " int port;" .B " FILE **FromServerp;" .B " FILE **ToServerp;" .B " char *errbuff;" .B "int" .B "NNTPsendarticle(text, ToServer, Terminate)" .B " char *text;" .B " FILE *ToServer;" .B " int Terminate;" .B "int" .B "NNTPsendpassword(server, FromServer, ToServer)" .B " char *server;" .B " FILE *FromServer;" .B " FILE *ToServer;" .B "void" .B "Radix32(value, p) .B " unsigned long value;" .B " char *p;" .B "char *" .B "ReadInFile(name, Sbp)" .B " char *name;" .B " struct stat *Sbp;" .B "char *" .B "ReadInDescriptor(fd, Sbp)" .B " int fd;" .B " struct stat *Sbp;" .B "HASH" .B "HashMessageID(MessageID)" .B " const char *MessageID;" .fi .SH DESCRIPTION .I Libinn is a library of utility routines for manipulating Usenet articles and related data. It is not necessary to use the header file .IR libinn.h ; if it is not available, it is only necessary to properly declare the .I TIMEINFO datatype, as given above. .PP .I GenerateMessageID uses the current time, process-ID, and fully-qualified domain name, which is passed as an argument and used if local host can not be resolved or it is different from ``domain'' set in .IR inn.conf , to create a Message-ID header that is highly likely to be unique. The returned value points to static space that is reused on subsequent calls. .PP .I HeaderCleanFrom removes the extraneous information from the value of a ``From'' or ``Reply-To'' header and leaves just the official mailing address. In particular, the following transformations are made to the .I from parameter: .RS .nf .ta \w'stuff
'u address --> address address (stuff) --> address stuff --> address .fi .RE The transformations are simple, based on RFC\ 1036 which limits the format of the header. .PP .I HeaderFind searches through .I Article looking for the specified .IR Header . .I Size should be the length of the header name. It returns a pointer to the value of the header, skipping leading whitespace, or NULL if the header cannot be found. .I Article should be a standard C string containing the text of the article; the end of the headers is indicated by a blank line \(em two consecutive \en characters. .PP .I CAopen and .I CAclose provide news clients with access to the active file; the ``CA'' stands for .IR C lient .IR A ctive. .I CAopen opens the .I active file for reading. It returns a pointer to an open FILE, or NULL on error. If a local or NFS-mounted copy exists, .I CAopen will use that file. The .I FromServer and .I ToServer parameters should be FILE's connected to the NNTP server for input and output, respectively. See .I NNTPremoteopen or .IR NNTPlocalopen , below. If either parameter is NULL, then .I CAopen will just return NULL if the file is not locally available. If they are not NULL, .I CAopen will use them to query the NNTP server using the ``list'' command to make a local temporary copy. .PP The .I CAlistopen sends a ``list'' command to the server and returns a temporary file containing the results. The .I request parameter, if not NULL, will be sent as an argument to the command. Unlike .IR CAopen , this routine will never use a locally-available copy of the active file. .PP .I CAclose closes the active file and removes any temporary file that might have been created by .I CAopen or .IR CAlistopen . .PP .I CloseOnExec can make a descriptor ``close-on-exec'' so that it is not shared with any child processes. If the flag is non-zero, the file is so marked; if zero, the ``close-on-exec'' mode is cleared. .PP .IR DDstart , .IR DDcheck , and .I DDend are used to set the Distribution header; the ``DD'' stands for .IR D efault .IR D istribution. The .I distrib.pats file is consulted to determine the proper value for the Distribution header after all newsgroups have been checked. .I DDstart begins the parsing. It returns a pointer to an opaque handle that should be used on subsequent calls. The .I FromServer and .I ToServer parameters should be FILE's connected to the NNTP server for input and output, respectively. If either parameter is NULL, then an empty default will ultimately be returned if the file is not locally available. .PP .I DDcheck should be called with the handle, .IR h , returned by .I DDstart and a newgroups, .IR group , to check. It can be called as often as necessary. .PP .I DDend releases any state maintained in the handle and returns an allocated copy of the text that should be used for the Distribution header. .PP .I SetNonBlocking enables (if .I flag is non-zero) or disables (if .I flag is zero) non-blocking I/O on the indicated descriptor. It returns \-1 on failure or zero on success. .PP .I inn_lock_file tries to lock the file descriptor .IR fd . If .I block is true it will block until the lock can be made, otherwise it will return false if the file cannot be locked. .I type is one of: INN_LOCK_READ, INN_LOCK_WRITE, or INN_LOCK_UNLOCK. It returns false on failure or true on success. .PP .I GetFQDN returns the fully-qualified domain name of the local host. .I Domain is used if local host can not be resolved. The returned value points to static space that is reused on subsequent calls, or NULL on error. .PP .I GetModeratorAddress returns the mailing address of the moderator for specified .I group or NULL on error. .I Moderatormailer is used as its address, if there is no matched moderator. See .IR moderators (5) for details on how the address is determined. .I GetModeratorAddress does no checking to see if the specified group is actually moderated. The returned value points to static space that is reused on subsequent calls. The .I FromServer and .I ToServer parameters should be FILE's connected to the NNTP server for input and output, respectively. If either of these parameters is NULL, then an attempt to get the list from a local copy is made. .PP .I GetResourceUsage fills in the .I usertime and .I systime parameters with the total user and system time used by the current process and any children it may have spawned. If .I