The Host Class

/*
**	(c) COPYRIGHT MIT 1995.
**	Please first read the full copyright statement in the file COPYRIGH.
*/

The Host class manages what we know about a remote host. This can for example be what type of host it is, and what version it is using. Notice that a host object can be used to describe both a server or a client - all information in the Host object can be shared regardless of whether it is to be used in a server application or a client application.

This module is implemented by HTHost.c, and it is a part of the W3C Sample Code Library.

#ifndef HTHOST_H
#define HTHOST_H

typedef struct _HTHost HTHost;
#define HOST_HASH_SIZE		HT_M_HASH_SIZE

#include "HTChannl.h"
#include "HTReq.h"
#include "HTEvent.h"
#include "HTProt.h"
#include "HTTimer.h"

The Host class contains information about the remote host, for example the type (HTTP/1.0, HTTP/1.1, FTP etc.) along with information on how the connections can be used (if it supports persistent connections, interleaved access etc.)

Creation and Deletion Methods

We keep a cache of information that we know about a remote host. This allows us to be much more detailed in generating requests. Search the host info cache for a host object or create a new one and add it. Examples of host names are

Add a Host Object

extern HTHost * HTHost_new (char * host, u_short u_port);
extern HTHost * HTHost_newWParse(HTRequest * request, char * url, u_short u_port);
extern int HTHost_hash (HTHost * host);

Delete a Host Object

The Host Class contains an automatic garbage collection of Host objects so that we don't keep information around that is stale.

Find a Host Object

Searches the cache of known hosts to see if we already have information about this host. If not then we return NULL.

extern HTHost * HTHost_find (char * host);

Delete the Host table

Cleanup and delete the host table.

extern void HTHost_deleteAll (void);

Is Host Idle?

You can use this function to see whether a host object is idle or in use. We have several modes describing how and when a host is idle. This is a function of the Transport Object

extern BOOL HTHost_isIdle (HTHost * host);

Remote Host Information

We keep track of the capabilities of the host in the other end so thatwe may adjust our queries to fit it better

Remote Host Name

Get the name of the remote host. This is set automatically when a new Host object and can be asked for at any point in time. You can not change the host name but must create a new Host object instead.

extern char * HTHost_name	(HTHost * host);

Remote Host Protocol Class and Version

Define the host class of the host at the other end. A class is a generic description of the protocol which is exactly like the access method in a URL, for example "http" etc. The host version is a finer distinction (sub-class) between various versions of the host class, for example HTTP/0.9, HTTP/1.1 etc. The host version is a bit flag that the protocol module can define on its own. That way we don't have to change this module when registering a new protocol module. The host type is a description of whether we can keep the connection persistent or not.

extern char * HTHost_class	(HTHost * host);
extern void HTHost_setClass	(HTHost * host, char * s_class);

extern int  HTHost_version	(HTHost * host);
extern void HTHost_setVersion	(HTHost * host, int version);

Public Methods accessible on This Host

A server can inform a client about the supported methods using the Public header.

extern HTMethod HTHost_publicMethods 	(HTHost * me);
extern void HTHost_setPublicMethods 	(HTHost * me, HTMethod methodset);
extern void HTHost_appendPublicMethods	(HTHost * me, HTMethod methodset);

Server Name of Remote Host

A server can send its server application name and version in a HTTP response. We pick up this information and add it to the Host object

extern char * HTHost_server	(HTHost * host);
extern BOOL HTHost_setServer	(HTHost * host, const char * server);

User Agent Name of Remote Host

A client can send the name of the client application in a HTTP request. We pick up this information and add it to the Host Object

extern char * HTHost_userAgent 	(HTHost * host);
extern BOOL HTHost_setUserAgent	(HTHost * host, const char * userAgent);

Range Units Accepted by this Host

Since all HTTP entities are represented in HTTP messages as sequences of bytes, the concept of a byte range is meaningful for any HTTP entity. (However, not all clients and servers need to support byte-range operations.) Byte range specifications in HTTP apply to the sequence of bytes in the entity-body (not necessarily the same as the message-body). A byte range operation may specify a single range of bytes, or a set of ranges within a single entity.

You can also check whether a specific range unit is OK. WeIGH. */ > extern BOOL HTHistory_replace (HTHistory *hist, HTAnchor *cur);

Delete last entry in a list

Deletes the last object from the list Returns YES if OK, else NO
extern BOOL HTHistory_removeLast 	(HTHistory *hist);

Remove the History list from position

Deletes the history list FROM the entry at position 'cur' (excluded). Home page has position 1. Returns YES if OK, else NO
extern BOOL HTHistory_removeFrom 	(HTHistory *hist, int pos);

Number of elements stored

Returns the size of the history list or -1 if none.
extern int HTHistory_count		(HTHistory *hist);

Current Position

Returns the current position or -1 on error
extern int HTHistory_position		(HTHistory *hist);

Find and re-register visited anchor

Finds already registered anchor at given position and registers it again EXCEPT if last entry. This allows for `circular' history lists with duplicate entries. Position 1 is the home anchor. The current position is updated.
extern HTAnchor * HTHistory_recall 	(HTHistory *hist, int pos);

Find Entry at position

Entry with the given index in the list (1 is the home page). Like HTHistory_recall but without re-registration. Un success, the current position is updated to the value 'pos' value.
extern HTAnchor * HTHistory_find 	(HTHistory *hist, int pos);

List the History List

This function is like HTHistory_find() but does not update the current position
extern HTAnchor * HTHistory_list	(HTHistory *hist, int pos);

Navigation

Can we back in history

Returns YES if the current anchor is not the first entry (home page)
extern BOOL HTHistory_canBacktrack 	(HTHistory *hist);

Backtrack with deletion

Returns the previous object and erases the last object. This does not allow for 'forward' as we are always at the end of the list. If no previous object exists, NULL is returned so that the application knows that no previous object was found. See also HTHistory_back().
extern HTAnchor * HTHistory_backtrack 	(HTHistory *hist);

Backtrack without deletion

Returns the previos object but does not erase the last object. This does not allow for 'forward'. If no previous object exists, NULL is returned so that the application knows that no previous object was found. See also HTHistory_backtrack()
extern HTAnchor * HTHistory_back 	(HTHistory *hist);

Can we go forward

Returns YES if the current anchor is not the last entry
extern BOOL HTHistory_canForward 	(HTHistory *hist);

Forward

Return the next object in the list or NULL if none
extern HTAnchor * HTHistory_forward 	(HTHistory *hist);

#endif /* HTHISTORY_H */

@(#) $Id: HTHist.html,v 2.14 1998/05/14 02:10:32 frystyk Exp $
./usr/share/doc/libwww-ssl-dev/html/Library/src/HTHome.html0100644000000000000000000001444407404420406022440 0ustar rootroot W3C Sample Code Library libwww Home Page Management

Home Page Management

/*
**	(c) COPYRIGHT MIT 1995.
**	Please first read the full copyright statement in the file COPYRIGH.
*/

This module provides some "make life easier" functions in order to get the application going. The functionality of this module was originally in HTAccess, but now it has been moved here as a part of the application interface where the application may use it if desired.

This module is implemented by HTHome.c, and it is a part of the W3C Sample Code Library.

#ifndef HTHOME_H
#define HTHOME_H
#include "WWWLib.h"

The home page is special in that this is is the first page to visit when  a client application starts up. Note that a home page is a generic URL and hence can be any resouce - not only resources on the local file system.

Personal Home Page

#define LOGICAL_DEFAULT 	"WWW_HOME"    /* Defined to be the home page */

#ifndef PERSONAL_DEFAULT
#define PERSONAL_DEFAULT 	"WWW/default.html"	/* in home directory */
#endif

/* If the home page isn't found, use this file: */
#ifndef LAST_RESORT
#define LAST_RESORT		"http://www.w3.org/"
#endif

Home Page for Remote Access

Some Web applications can also be run remotely - for example as a telnet login shell. The Line Mode Browser is an example of such an application. In that case, the home page is often more generic than a personal home page.

/* If one telnets to an access point it will look in this file for home page */
#ifndef REMOTE_POINTER
#define REMOTE_POINTER 		 "/etc/www-remote.url"	    /* can't be file */
#endif

/* and if that fails it will use this. */
#ifndef REMOTE_ADDRESS
#define REMOTE_ADDRESS  	"http://www.w3.org/"	    /* can't be file */
#endif

#ifndef LOCAL_DEFAULT_FILE
#define LOCAL_DEFAULT_FILE 	"/usr/local/lib/WWW/default.html"
#endif

Get an Anchor for the Home Page

Getting an anchor for the home page involves looking for the (environment) variables described in the section above. As this is something that almost all client applications must do then we provide some simple methods that do the work for you.

extern HTParentAnchor * HTHomeAnchor (void);

Create a New Anchor for Temporary Local Files

When the user starts writing a new document, the client application should create a new anchor which can contain the document while it is created. This can also be the location for backups and for security "auto-save" functionality. This functions creates a new anchor with a URL pointing to the temporary location defined by this user profile and returns that anchor. Andy Levine: I additionally found that calling HTTmpAnchor repeatedly without freeing the newly allocated anchor will cause the anchor hash table to continue to grow.

extern HTParentAnchor * HTTmpAnchor (HTUserProfile * up);

Get The Current Directory in URL form

Creates a local file URL that can be used as a relative name when calling expanding other URLs relative to the current location in the local file system tree where the application is running. The code for this routine originates from the Line Mode Browser and was moved here by howcome@w3.org in order for all clients to take advantage.

#define HTFindRelatedName	HTGetCurrentDirectoryURL
extern char *  HTGetCurrentDirectoryURL (void);

Handle HTML Form Input fields

Takes a string of the form "a=b" containing HTML form data, escapes it accordingly and puts it into the association list so that it readily can be passed to any of the HTAccess function that handles HTML form data. The string should not be encoded in any way - this function encodes it according to the HTML form encoding rules.

Examples are "foo=bar", "baz=foo and bar", "a= b ", " a = b ", "toto=", "four = two + two", "six three + three", and "a=b=c"

extern BOOL HTParseFormInput (HTAssocList * list, const char * str);

Handle Library Trace Messages

Standard interface to libwww TRACE messages. Pass this function a string of characters. It will set up the appropriate TRACE flags. The following characters are used as follows:

f
Show BASIC UTILITIES Trace Messages
l
Show APPLICATION LEVEL Trace Messages
c
Show CACHE Trace Messages
g
Show SGML Trace Messages
b
Show BIND Trace Messages
t
Show THREAD Trace Messages
s
Show STREAM Trace Messages
p
Show PROTOCOL Trace Messages
m
Show MEMORY Trace Messages
q
Show SQL Trace Messages
u
Show URI Trace Messages
h
Show AUTH Trace Messages
a
Show ANCHOR Trace Messages
i
Show PICS Trace Messages
o
Show CORE Trace Messages
x
Show MUX Trace Messages
*
Show ALL Trace Messages

The string must be null terminated, an example is "sop".

extern int HTSetTraceMessageMask (const char * shortnames);
#endif /* HTHOME_H */


@(#) $Id: HTHome.html,v 2.19 2000/07/04 15:19:45 kahan Exp $
./usr/share/doc/libwww-ssl-dev/html/Library/src/HTHost.html0100644000000000000000000004476407404420406022475 0ustar rootroot W3C Sample Code Library libwww Host Class

The Host Class

/*
**	(c) COPYRIGHT MIT 1995.
**	Please first read the full copyright statement in the file COPYRIGH.
*/

The Host class manages what we know about a remote host. This can for example be what type of host it is, and what version it is using. Notice that a host object can be used to describe both a server or a client - all information in the Host object can be shared regardless of whether it is to be used in a server application or a client application.

This module is implemented by HTHost.c, and it is a part of the W3C Sample Code Library.

#ifndef HTHOST_H
#define HTHOST_H

typedef struct _HTHost HTHost;
#define HOST_HASH_SIZE		HT_M_HASH_SIZE

#include "HTChannl.h"
#include "HTReq.h"
#include "HTEvent.h"
#include "HTProt.h"
#include "HTTimer.h"

The Host class contains information about the remote host, for example the type (HTTP/1.0, HTTP/1.1, FTP etc.) along with information on how the connections can be used (if it supports persistent connections, interleaved access etc.)

Creation and Deletion Methods

We keep a cache of information that we know about a remote host. This allows us to be much more detailed in generating requests. Search the host info cache for a host object or create a new one and add it. Examples of host names are

Add a Host Object

extern HTHost * HTHost_new (char * host, u_short u_port);
extern HTHost * HTHost_newWParse(HTRequest * request, char * url, u_short u_port);
extern int HTHost_hash (HTHost * host);

Delete a Host Object

The Host Class contains an automatic garbage collection of Host objects so that we don't keep information around that is stale.

Find a Host Object

Searches the cache of known hosts to see if we already have information about this host. If not then we return NULL.

extern HTHost * HTHost_find (char * host);

Delete the Host table

Cleanup and delete the host table.

extern void HTHost_deleteAll (void);

Is Host Idle?

You can use this function to see whether a host object is idle or in use. We have several modes describing how and when a host is idle. This is a function of the Transport Object

extern BO