Generic Network Communication

/*
**	(c) COPYRIGHT MIT 1995.
**	Please first read the full copyright statement in the file COPYRIGH.
*/
This module has the common code for handling TCP/IP and DECnet connections etc. The main topics of functions in this module are: This module is implemented by HTInet.c, and it is a part of the W3C Reference Library.
#ifndef HTINET_H
#define HTINET_H
#include "HTReq.h"
#include "HTNet.h"

System Description of Error Message

Return error message corresponding to errno number given. We need to pass the error number as a parameter as we on some platforms get different codes from sockets and local file access.
extern const char * HTErrnoString	(int errnum);
extern int HTInetStatus			(int errnum, char * where);

Parse a Cardinal Value

/*	Parse a cardinal value				       parse_cardinal()
**	----------------------
**
** On entry:
** 	*pp points to first character to be interpreted, terminated by
** 	non 0..9 character.
** 	*pstatus points to status already valid,
** 	maxvalue gives the largest allowable value.
**
** On exit:
** 	*pp points to first unread character,
** 	*pstatus points to status updated iff bad
*/

extern unsigned int HTCardinal (int *		pstatus,
				char **		pp,
				unsigned int	max_value);

Internet Name Server Functions

The following functions are available to get information about a specified host.

Produce a string for an internet address

This function is equivalent to the BSD system call inet_ntoa in that it converts a numeric 32-bit IP-address to a dotted-notation decimal string. The pointer returned points to static memory which must be copied if it is to be kept.
extern const char * HTInetString (struct sockaddr_in * sin);

Parse a network node address and port

It is assumed that any portnumber and numeric host address is given in decimal notation. Separation character is '.' Any port number given in host name overrides all other values. 'host' might be modified.
extern int HTParseInet (HTNet * net, char * host);

Get Name of This Machine

This function returns a CONET char pointer to a static location containing the name of this host or NULL if not available.
extern const char * HTGetHostName (void);

Set Name of This Machine

This function overwrites any other value of current host name. This might be set by the user to change the value in the ID value parsed to a news host when posting. The change doesn't influence the Mail Address as they are stored in two different locations. If, however, the change is done before the first call to HTGetMailAddress() then this function will use the new host and domain name.
extern void HTSetHostName (char * host);

Cleanup Memory

Called from HTLibTerminate
extern void HTFreeHostName (void);

Get Domain Name of This Machine

This function rerturns the domain name part of the host name as returned by HTGetHostName() function. Changing the domain name requires a call to HTSetHostname().
extern const char *HTGetDomainName (void);

Get User Mail Address

This functions returns a char pointer to a static location containing the mail address of the current user. The static location is different from the one of the current host name so different values can be assigned. The default value is <USER>@hostname where hostname is as returned by HTGetHostName().
#ifndef HT_DEFAULT_LOGIN
#define HT_DEFAULT_LOGIN	"libwww"
#endif

extern const char * HTGetMailAddress (void);

Set User Mail Address

This function overwrites any other value of current mail address. This might be set by the user to change the value in the From field in the HTTP Protocol.
extern void HTSetMailAddress (char * address);

Free Memory

Called by HTLibTerminate
extern void HTFreeMailAddress (void);

Signal Handling

This is only necessary to compile on a few platforms and only if the application does not have its own signal handling. It is required on Solaris 2.3 (and other SVR4 platforms?) due to a bug in the TCP kernel. When a connect() is tried to a illegal port, solaris gives a SIGPIPE signal instead of returning Connection refused.
#ifdef WWWLIB_SIG
extern void HTSetSignal (void);
#endif

#endif   /* HTINET_H */

@(#) $Id: HTInet.html,v 2.1 1996/04/12 17:47:25 frystyk Exp $