Blame WWW/Library/Implementation/HTAnchor.h

Packit f574b8
/*
Packit f574b8
 * $LynxId: HTAnchor.h,v 1.40 2018/03/11 18:43:50 tom Exp $
Packit f574b8
 *
Packit f574b8
 *	Hypertext "Anchor" Object				     HTAnchor.h
Packit f574b8
 *	==========================
Packit f574b8
 *
Packit f574b8
 *	An anchor represents a region of a hypertext document which is linked
Packit f574b8
 *	to another anchor in the same or a different document.
Packit f574b8
 */
Packit f574b8
Packit f574b8
#ifndef HTANCHOR_H
Packit f574b8
#define HTANCHOR_H
Packit f574b8
Packit f574b8
/* Version 0 (TBL) written in Objective-C for the NeXT browser */
Packit f574b8
/* Version 1 of 24-Oct-1991 (JFG), written in C, browser-independent */
Packit f574b8
Packit f574b8
#include <HTList.h>
Packit f574b8
#include <HTBTree.h>
Packit f574b8
#include <HTChunk.h>
Packit f574b8
#include <HTAtom.h>
Packit f574b8
#include <UCDefs.h>
Packit f574b8
Packit f574b8
typedef struct _HyperDoc HyperDoc;	/* Ready for forward references */
Packit f574b8
typedef struct _HTAnchor HTAnchor;
Packit f574b8
typedef struct _HTParentAnchor HTParentAnchor;
Packit f574b8
typedef struct _HTParentAnchor0 HTParentAnchor0;
Packit f574b8
Packit f574b8
#include <HTFormat.h>
Packit f574b8
Packit f574b8
#ifdef __cplusplus
Packit f574b8
extern "C" {
Packit f574b8
#endif
Packit f574b8
    struct _HTAnchor {
Packit f574b8
	/* Generic anchor */
Packit f574b8
	HTParentAnchor0 *parent;	/* Parent of this anchor (self for adults) */
Packit f574b8
    };
Packit f574b8
Packit f574b8
#define HASH_TYPE unsigned short
Packit f574b8
Packit f574b8
    struct _HTParentAnchor0 {	/* One for adult_table,
Packit f574b8
				 * generally not used outside HTAnchor.c */
Packit f574b8
	/* Common part from the generic anchor structure */
Packit f574b8
	HTParentAnchor0 *parent;	/* (self) */
Packit f574b8
Packit f574b8
	/* ParentAnchor0-specific information */
Packit f574b8
	char *address;		/* Absolute address of this node */
Packit f574b8
	HTParentAnchor *info;	/* additional info, allocated on demand */
Packit f574b8
Packit f574b8
	HTBTree *children;	/* Subanchors , sorted by tag */
Packit f574b8
	HTList sources;		/* List of anchors pointing to this, if any */
Packit f574b8
Packit f574b8
	HTList _add_adult;	/* - just a memory for list entry:) */
Packit f574b8
	HASH_TYPE adult_hash;	/* adult list number */
Packit f574b8
	BOOL underway;		/* Document about to be attached to it */
Packit f574b8
    };
Packit f574b8
Packit f574b8
    /*
Packit f574b8
     *  Separated from the above to save memory:  allocated on demand,
Packit f574b8
     *  it is nearly 1:1 to HText (well, sometimes without HText...),
Packit f574b8
     *  available for SGML, HTML, and HText stages.
Packit f574b8
     *  [being precise, we currently allocate it before HTLoadDocument(),
Packit f574b8
     *  in HTAnchor_findAddress() and HTAnchor_parent()].
Packit f574b8
     */
Packit f574b8
    struct _HTParentAnchor {
Packit f574b8
	/* Common part from the generic anchor structure */
Packit f574b8
	HTParentAnchor0 *parent;	/* Parent of this anchor */
Packit f574b8
Packit f574b8
	/* ParentAnchor-specific information */
Packit f574b8
	HTList children_notag;	/* Subanchors , tag is NULL */
Packit f574b8
	HyperDoc *document;	/* The document within which this is an anchor */
Packit f574b8
Packit f574b8
	char *address;		/* parent->address, a pointer */
Packit f574b8
	bstring *post_data;	/* Posting data */
Packit f574b8
	char *post_content_type;	/* Type of post data */
Packit f574b8
	char *bookmark;		/* Bookmark filename */
Packit f574b8
	HTFormat format;	/* Pointer to node format descriptor */
Packit f574b8
	char *charset;		/* Pointer to character set (kludge, for now */
Packit f574b8
	BOOL isIndex;		/* Acceptance of a keyword search */
Packit f574b8
	char *isIndexAction;	/* URL of isIndex server */
Packit f574b8
	char *isIndexPrompt;	/* Prompt for isIndex query */
Packit f574b8
	char *title;		/* Title of document */
Packit f574b8
	char *owner;		/* Owner of document */
Packit f574b8
	char *RevTitle;		/* TITLE in REV="made" or REV="owner" LINK */
Packit f574b8
	char *citehost;		/* Citehost from REL="citehost" LINK */
Packit f574b8
#ifdef USE_COLOR_STYLE
Packit f574b8
	char *style;
Packit f574b8
#endif
Packit f574b8
Packit f574b8
	HTList *methods;	/* Methods available as HTAtoms */
Packit f574b8
	void *protocol;		/* Protocol object */
Packit f574b8
	char *physical;		/* Physical address */
Packit f574b8
	BOOL isISMAPScript;	/* Script for clickable image map */
Packit f574b8
	BOOL isHEAD;		/* Document is headers from a HEAD request */
Packit f574b8
	BOOL safe;		/* Safe */
Packit f574b8
#ifdef USE_SOURCE_CACHE
Packit f574b8
	char *source_cache_file;
Packit f574b8
	HTChunk *source_cache_chunk;
Packit f574b8
#endif
Packit f574b8
	char *FileCache;	/* Path to a disk-cached copy (see src/HTFWriter.c) */
Packit f574b8
	char *SugFname;		/* Suggested filename */
Packit f574b8
	char *cache_control;	/* Cache-Control */
Packit f574b8
	BOOL no_cache;		/* Cache-Control, Pragma or META "no-cache"? */
Packit f574b8
	BOOL inHEAD;		/* HTMIMEConvert is decoding server-headers */
Packit f574b8
	BOOL inBASE;		/* duplicated from HTStructured (HTML.c/h) */
Packit f574b8
	HTChunk http_headers;
Packit f574b8
	BOOL no_content_encoding;	/* server did not use C-T? */
Packit f574b8
	char *content_type_params;	/* Content-Type (with parameters if any) */
Packit f574b8
	char *content_type;	/* Content-Type */
Packit f574b8
	char *content_language;	/* Content-Language */
Packit f574b8
	char *content_encoding;	/* Compression algorithm */
Packit f574b8
	char *content_base;	/* Content-Base */
Packit f574b8
	char *content_disposition;	/* Content-Disposition */
Packit f574b8
	char *content_location;	/* Content-Location */
Packit f574b8
	char *content_md5;	/* Content-MD5 */
Packit f574b8
	char *message_id;	/* Message-ID */
Packit f574b8
	char *subject;		/* Subject */
Packit f574b8
	off_t header_length;	/* length of headers */
Packit f574b8
	off_t content_length;	/* Content-Length */
Packit f574b8
	off_t actual_length;	/* actual length may differ */
Packit f574b8
	char *date;		/* Date */
Packit f574b8
	char *expires;		/* Expires */
Packit f574b8
	char *last_modified;	/* Last-Modified */
Packit f574b8
	char *ETag;		/* ETag (HTTP1.1 cache validator) */
Packit f574b8
	char *server;		/* Server */
Packit f574b8
	UCAnchorInfo *UCStages;	/* chartrans stages */
Packit f574b8
	HTList *imaps;		/* client side image maps */
Packit f574b8
    };
Packit f574b8
Packit f574b8
    typedef HTAtom HTLinkType;
Packit f574b8
Packit f574b8
    typedef struct {
Packit f574b8
	/* Common part from the generic anchor structure */
Packit f574b8
	HTParentAnchor0 *parent;	/* Parent of this anchor */
Packit f574b8
Packit f574b8
	/* ChildAnchor-specific information */
Packit f574b8
	char *tag;		/* #fragment,  relative to the parent */
Packit f574b8
Packit f574b8
	HTAnchor *dest;		/* The anchor to which this leads */
Packit f574b8
	HTLinkType *type;	/* Semantics of this link */
Packit f574b8
Packit f574b8
	HTList _add_children_notag;	/* - just a memory for list entry:) */
Packit f574b8
	HTList _add_sources;	/* - just a memory for list entry:) */
Packit f574b8
    } HTChildAnchor;
Packit f574b8
Packit f574b8
    /*
Packit f574b8
     *  DocAddress structure is used for loading an absolute anchor with all
Packit f574b8
     *  needed information including posting data and post content type.
Packit f574b8
     */
Packit f574b8
    typedef struct _DocAddress {
Packit f574b8
	char *address;
Packit f574b8
	bstring *post_data;
Packit f574b8
	char *post_content_type;
Packit f574b8
	char *bookmark;
Packit f574b8
	BOOL isHEAD;
Packit f574b8
	BOOL safe;
Packit f574b8
    } DocAddress;
Packit f574b8
Packit f574b8
    /* "internal" means "within the same document, with certainty". */
Packit f574b8
    extern HTLinkType *HTInternalLink;
Packit f574b8
Packit f574b8
    /* Create or find a child anchor with a possible link
Packit f574b8
     * --------------------------------------------------
Packit f574b8
     *
Packit f574b8
     * Create new anchor with a given parent and possibly
Packit f574b8
     * a name, and possibly a link to a _relatively_ named anchor.
Packit f574b8
     * (Code originally in ParseHTML.h)
Packit f574b8
     */
Packit f574b8
    extern HTChildAnchor *HTAnchor_findChildAndLink(HTParentAnchor *parent,	/* May not be 0 */
Packit f574b8
						    const char *tag,	/* May be "" or 0 */
Packit f574b8
						    const char *href,	/* May be "" or 0 */
Packit f574b8
						    HTLinkType *ltype);		/* May be 0 */
Packit f574b8
Packit f574b8
    /* Create new or find old parent anchor
Packit f574b8
     * ------------------------------------
Packit f574b8
     *
Packit f574b8
     * This one is for a reference which is found in a document, and might
Packit f574b8
     * not be already loaded.
Packit f574b8
     * Note: You are not guaranteed a new anchor -- you might get an old one,
Packit f574b8
     * like with fonts.
Packit f574b8
     */
Packit f574b8
    extern HTParentAnchor *HTAnchor_findAddress(const DocAddress *address);
Packit f574b8
Packit f574b8
    /* Create new or find old named anchor - simple form
Packit f574b8
     * -------------------------------------------------
Packit f574b8
     *
Packit f574b8
     * Like the previous one, but simpler to use for simple cases.
Packit f574b8
     * No post data etc.  can be supplied.  - kw
Packit f574b8
     */
Packit f574b8
    extern HTParentAnchor *HTAnchor_findSimpleAddress(const char *url);
Packit f574b8
Packit f574b8
    /* Delete an anchor and possibly related things (auto garbage collection)
Packit f574b8
     * --------------------------------------------
Packit f574b8
     *
Packit f574b8
     * The anchor is only deleted if the corresponding document is not loaded.
Packit f574b8
     * All outgoing links from children are deleted, and children are
Packit f574b8
     * removed from the sources lists of their targets.
Packit f574b8
     * We also try to delete the targets whose documents are not loaded.
Packit f574b8
     * If this anchor's sources list is empty, we delete it and its children.
Packit f574b8
     */
Packit f574b8
    extern BOOL HTAnchor_delete(HTParentAnchor0 *me);
Packit f574b8
Packit f574b8
    /*
Packit f574b8
     * Unnamed children (children_notag) have no sense without HText -
Packit f574b8
     * delete them and their links if we are about to free HText.
Packit f574b8
     * Document currently exists.  Called within HText_free().
Packit f574b8
     */
Packit f574b8
    extern void HTAnchor_delete_links(HTParentAnchor *me);
Packit f574b8
Packit f574b8
#ifdef USE_SOURCE_CACHE
Packit f574b8
    extern void HTAnchor_clearSourceCache(HTParentAnchor *me);
Packit f574b8
#endif
Packit f574b8
Packit f574b8
    /* Data access functions
Packit f574b8
     * ---------------------
Packit f574b8
     */
Packit f574b8
    extern HTParentAnchor *HTAnchor_parent(HTAnchor * me);
Packit f574b8
Packit f574b8
    extern void HTAnchor_setDocument(HTParentAnchor *me,
Packit f574b8
				     HyperDoc *doc);
Packit f574b8
Packit f574b8
    extern HyperDoc *HTAnchor_document(HTParentAnchor *me);
Packit f574b8
Packit f574b8
    /* Returns the full URI of the anchor, child or parent
Packit f574b8
     * as a malloc'd string to be freed by the caller.
Packit f574b8
     */
Packit f574b8
    extern char *HTAnchor_address(HTAnchor * me);
Packit f574b8
Packit f574b8
    extern char *HTAnchor_short_address(HTAnchor * me);
Packit f574b8
Packit f574b8
    extern void HTAnchor_setFormat(HTParentAnchor *me,
Packit f574b8
				   HTFormat form);
Packit f574b8
Packit f574b8
    extern HTFormat HTAnchor_format(HTParentAnchor *me);
Packit f574b8
Packit f574b8
    extern void HTAnchor_setIndex(HTParentAnchor *me,
Packit f574b8
				  const char *address);
Packit f574b8
Packit f574b8
    extern void HTAnchor_setPrompt(HTParentAnchor *me,
Packit f574b8
				   const char *prompt);
Packit f574b8
Packit f574b8
    extern BOOL HTAnchor_isIndex(HTParentAnchor *me);
Packit f574b8
Packit f574b8
    extern BOOL HTAnchor_isISMAPScript(HTAnchor * me);
Packit f574b8
Packit f574b8
#if defined(USE_COLOR_STYLE)
Packit f574b8
    extern const char *HTAnchor_style(HTParentAnchor *me);
Packit f574b8
Packit f574b8
    extern void HTAnchor_setStyle(HTParentAnchor *me,
Packit f574b8
				  const char *style);
Packit f574b8
#endif
Packit f574b8
Packit f574b8
    /* Title handling.
Packit f574b8
     */
Packit f574b8
    extern const char *HTAnchor_title(HTParentAnchor *me);
Packit f574b8
Packit f574b8
    extern void HTAnchor_setTitle(HTParentAnchor *me,
Packit f574b8
				  const char *title);
Packit f574b8
Packit f574b8
    extern void HTAnchor_appendTitle(HTParentAnchor *me,
Packit f574b8
				     const char *title);
Packit f574b8
Packit f574b8
    /* Bookmark handling.
Packit f574b8
     */
Packit f574b8
    extern const char *HTAnchor_bookmark(HTParentAnchor *me);
Packit f574b8
Packit f574b8
    extern void HTAnchor_setBookmark(HTParentAnchor *me,
Packit f574b8
				     const char *bookmark);
Packit f574b8
Packit f574b8
    /* Owner handling.
Packit f574b8
     */
Packit f574b8
    extern const char *HTAnchor_owner(HTParentAnchor *me);
Packit f574b8
Packit f574b8
    extern void HTAnchor_setOwner(HTParentAnchor *me,
Packit f574b8
				  const char *owner);
Packit f574b8
Packit f574b8
    /* TITLE handling in LINKs with REV="made" or REV="owner".  - FM
Packit f574b8
     */
Packit f574b8
    extern const char *HTAnchor_RevTitle(HTParentAnchor *me);
Packit f574b8
Packit f574b8
    extern void HTAnchor_setRevTitle(HTParentAnchor *me,
Packit f574b8
				     const char *title);
Packit f574b8
Packit f574b8
    /* Citehost for bibp links from LINKs with REL="citehost".  - RDC
Packit f574b8
     */
Packit f574b8
    extern const char *HTAnchor_citehost(HTParentAnchor *me);
Packit f574b8
Packit f574b8
    extern void HTAnchor_setCitehost(HTParentAnchor *me,
Packit f574b8
				     const char *citehost);
Packit f574b8
Packit f574b8
    /* Suggested filename handling.  - FM
Packit f574b8
     * (will be loaded if we had a Content-Disposition
Packit f574b8
     * header or META element with filename=name.suffix)
Packit f574b8
     */
Packit f574b8
    extern const char *HTAnchor_SugFname(HTParentAnchor *me);
Packit f574b8
Packit f574b8
    /* HTTP Headers.
Packit f574b8
     */
Packit f574b8
    extern const char *HTAnchor_http_headers(HTParentAnchor *me);
Packit f574b8
Packit f574b8
    /* Content-Type handling (parameter list).
Packit f574b8
     */
Packit f574b8
    extern const char *HTAnchor_content_type_params(HTParentAnchor *me);
Packit f574b8
Packit f574b8
    /* Content-Type handling.  - FM
Packit f574b8
     */
Packit f574b8
    extern const char *HTAnchor_content_type(HTParentAnchor *me);
Packit f574b8
Packit f574b8
    /* Content-Encoding handling.  - FM
Packit f574b8
     * (will be loaded if we had a Content-Encoding
Packit f574b8
     * header.)
Packit f574b8
     */
Packit f574b8
    extern const char *HTAnchor_content_encoding(HTParentAnchor *me);
Packit f574b8
Packit f574b8
    /* Last-Modified header handling.  - FM
Packit f574b8
     */
Packit f574b8
    extern const char *HTAnchor_last_modified(HTParentAnchor *me);
Packit f574b8
Packit f574b8
    /* Date header handling.  - FM
Packit f574b8
     */
Packit f574b8
    extern const char *HTAnchor_date(HTParentAnchor *me);
Packit f574b8
Packit f574b8
    /* Server header handling.  - FM
Packit f574b8
     */
Packit f574b8
    extern const char *HTAnchor_server(HTParentAnchor *me);
Packit f574b8
Packit f574b8
    /* Safe header handling.  - FM
Packit f574b8
     */
Packit f574b8
    extern BOOL HTAnchor_safe(HTParentAnchor *me);
Packit f574b8
Packit f574b8
    /* Content-Base header handling.  - FM
Packit f574b8
     */
Packit f574b8
    extern const char *HTAnchor_content_base(HTParentAnchor *me);
Packit f574b8
Packit f574b8
    /* Content-Location header handling.  - FM
Packit f574b8
     */
Packit f574b8
    extern const char *HTAnchor_content_location(HTParentAnchor *me);
Packit f574b8
Packit f574b8
    /* Message-ID, used for mail replies - kw
Packit f574b8
     */
Packit f574b8
    extern const char *HTAnchor_messageID(HTParentAnchor *me);
Packit f574b8
Packit f574b8
    extern BOOL HTAnchor_setMessageID(HTParentAnchor *me,
Packit f574b8
				      const char *messageid);
Packit f574b8
Packit f574b8
    /* Subject, used for mail replies - kw
Packit f574b8
     */
Packit f574b8
    extern const char *HTAnchor_subject(HTParentAnchor *me);
Packit f574b8
Packit f574b8
    extern BOOL HTAnchor_setSubject(HTParentAnchor *me,
Packit f574b8
				    const char *subject);
Packit f574b8
Packit f574b8
    /* Manipulation of links
Packit f574b8
     * ---------------------
Packit f574b8
     */
Packit f574b8
    extern HTAnchor *HTAnchor_followLink(HTChildAnchor *me);
Packit f574b8
Packit f574b8
    extern HTAnchor *HTAnchor_followTypedLink(HTChildAnchor *me,
Packit f574b8
					      HTLinkType *type);
Packit f574b8
Packit f574b8
    /* Read and write methods
Packit f574b8
     * ----------------------
Packit f574b8
     */
Packit f574b8
    extern HTList *HTAnchor_methods(HTParentAnchor *me);
Packit f574b8
Packit f574b8
    /* Protocol
Packit f574b8
     * --------
Packit f574b8
     */
Packit f574b8
    extern void *HTAnchor_protocol(HTParentAnchor *me);
Packit f574b8
Packit f574b8
    extern void HTAnchor_setProtocol(HTParentAnchor *me,
Packit f574b8
				     void *protocol);
Packit f574b8
Packit f574b8
    /* Physical address
Packit f574b8
     * ----------------
Packit f574b8
     */
Packit f574b8
    extern char *HTAnchor_physical(HTParentAnchor *me);
Packit f574b8
Packit f574b8
    extern void HTAnchor_setPhysical(HTParentAnchor *me,
Packit f574b8
				     char *protocol);
Packit f574b8
Packit f574b8
    extern LYUCcharset *HTAnchor_getUCInfoStage(HTParentAnchor *me,
Packit f574b8
						int which_stage);
Packit f574b8
Packit f574b8
    extern int HTAnchor_getUCLYhndl(HTParentAnchor *me,
Packit f574b8
				    int which_stage);
Packit f574b8
Packit f574b8
    extern LYUCcharset *HTAnchor_setUCInfoStage(HTParentAnchor *me,
Packit f574b8
						int LYhndl,
Packit f574b8
						int which_stage,
Packit f574b8
						int set_by);
Packit f574b8
Packit f574b8
    extern LYUCcharset *HTAnchor_setUCInfoStage(HTParentAnchor *me,
Packit f574b8
						int LYhndl,
Packit f574b8
						int which_stage,
Packit f574b8
						int set_by);
Packit f574b8
Packit f574b8
    extern LYUCcharset *HTAnchor_resetUCInfoStage(HTParentAnchor *me,
Packit f574b8
						  int LYhndl,
Packit f574b8
						  int which_stage,
Packit f574b8
						  int set_by);
Packit f574b8
Packit f574b8
    extern LYUCcharset *HTAnchor_copyUCInfoStage(HTParentAnchor *me,
Packit f574b8
						 int to_stage,
Packit f574b8
						 int from_stage,
Packit f574b8
						 int set_by);
Packit f574b8
Packit f574b8
    extern void ImageMapList_free(HTList *list);
Packit f574b8
Packit f574b8
#ifdef __cplusplus
Packit f574b8
}
Packit f574b8
#endif
Packit f574b8
#endif				/* HTANCHOR_H */