/* ** (c) COPYRIGHT MIT 1995. ** Please first read the full copyright statement in the file COPYRIGH. */An anchor represents a region of a hypertext document which is linked to another anchor in the same or a different document. As always we must emulate the fancy features of C++ by hand :-(. In this module you find:
#ifndef HTANCHOR_H #define HTANCHOR_H #include "HTList.h" #include "HTAtom.h" #include "HTMethod.h"
typedef HTAtom * HTFormat; typedef HTAtom * HTLevel; /* Used to specify HTML level */ typedef HTAtom * HTEncoding; /* Content Encoding */ typedef HTAtom * HTCte; /* Content transfer encoding */ typedef HTAtom * HTCharset; typedef HTAtom * HTLanguage;
typedef struct _HyperDoc HyperDoc; /* Ready for forward references */ typedef struct _HTAnchor HTAnchor; typedef struct _HTParentAnchor HTParentAnchor; typedef struct _HTChildAnchor HTChildAnchor;Must be AFTER definition of HTAnchor:
typedef HTAtom HTLinkType;
typedef enum _HTLinkResult
{
HT_LINK_INVALID = -1,
HT_LINK_NONE = 0,
HT_LINK_ERROR,
HT_LINK_OK
} HTLinkResult;
typedef struct {
HTAnchor * dest; /* The anchor to which this leads */
HTLinkType * type; /* Semantics of this link */
HTMethod method; /* Method for this link, e.g. PUT */
HTLinkResult result; /* Result of any attempt to get this link */
} HTLink;
struct _HTAnchor {
HTLink mainLink; /* Main (or default) destination of this */
HTList * links; /* List of extra links from this, if any */
HTParentAnchor * parent; /* Parent of this anchor (self for adults) */
};
struct _HTParentAnchor {
/* Common part from the generic anchor structure */
HTLink mainLink; /* Main (or default) destination of this */
HTList * links; /* List of extra links from this, if any */
HTParentAnchor * parent; /* Parent of this anchor (self) */
/* ParentAnchor-specific information */
HTList * children; /* Subanchors of this, if any */
HTList * sources; /* List of anchors pointing to this, if any */
HyperDoc * document; /* The document within this is an anchor */
char * physical; /* Physical address */
BOOL cacheHit; /* Yes, if cached object found */
char * address; /* Absolute address of this node */
BOOL isIndex; /* Acceptance of a keyword search */
/* Entity header fields */
BOOL header_parsed; /* Are we done parsing? */
char * title;
int methods; /* Allowed methods (bit-flag) */
HTEncoding content_encoding;
HTLanguage content_language; /* @@@ SHOULD BE LIST @@@ */
long int content_length;
HTCte cte; /* Content-Transfer-Encoding */
HTFormat content_type;
HTCharset charset; /* Parameter to content-type */
HTLevel level; /* Parameter to content-type `text/html' */
time_t date; /* When was the request issued */
time_t expires; /* When does the copy expire */
time_t last_modified;
char * derived_from; /* Opaque string */
char * version; /* Opaque string */
/* List of unknown headers coming in from the network. Use the field in the
request structure for sending test headers. */
HTList * extra_headers;
};
struct _HTChildAnchor {
/* Common part from the generic anchor structure */
HTLink mainLink; /* Main (or default) destination of this */
HTList * links; /* List of extra links from this, if any */
HTParentAnchor * parent; /* Parent of this anchor */
/* ChildAnchor-specific information */
char * tag; /* Address of this anchor relative to parent */
};
extern HTAnchor * HTAnchor_findAddress (CONST char * address);
extern HTChildAnchor * HTAnchor_findChild (HTParentAnchor *parent, CONST char * tag);
extern HTChildAnchor * HTAnchor_findChildAndLink (HTParentAnchor * parent, /* May not be 0 */ CONST char * tag, /* May be "" or 0 */ CONST char * href, /* May be "" or 0 */ HTLinkType * ltype); /* May be 0 */
extern BOOL HTAnchor_delete (HTParentAnchor *me);
HyperDocs found while doing it. The application may keep
its own list of HyperDocs, but this function returns it
anyway. It is always for the application to delete any
HyperDocs. If NULL then no hyperdocs are returned. Return
YES if OK, else NO. Note: This function is different from cleaning up the history list!
extern BOOL HTAnchor_deleteAll (HTList * objects);
extern BOOL HTAnchor_link (HTAnchor * source, HTAnchor * destination, HTLinkType * type, HTMethod method);
extern HTLink *HTAnchor_findLink (HTAnchor *src, HTAnchor *dest); #define HTAnchor_findMainLink(me) ((me) ? &((me)->mainLink) : NULL)
#define HTAnchor_linkMethod(me) ((me) ? (me)->method : METHOD_INVALID)
extern HTAnchor * HTAnchor_followMainLink (HTAnchor *me); #define HTAnchor_linkDest(me) ((me) ? (me)->dest : NULL)
extern HTAnchor * HTAnchor_followTypedLink (HTAnchor *me, HTLinkType *type);
#define HTAnchor_linkResult(me) ((me) ? me->result : HT_LINK_INVALID) extern BOOL HTAnchor_setLinkResult (HTLink * link, HTLinkResult result);
extern BOOL HTAnchor_makeMainLink (HTAnchor *me, HTLink *movingLink);
extern BOOL HTAnchor_moveAllLinks (HTAnchor *src, HTAnchor *dest);
extern BOOL HTAnchor_removeLink (HTAnchor *src, HTAnchor *dest); extern BOOL HTAnchor_removeAllLinks (HTAnchor * me);
extern void HTAnchor_makeLastChild (HTChildAnchor *me);
extern HTParentAnchor * HTAnchor_parent (HTAnchor *me);
extern BOOL HTAnchor_hasChildren (HTParentAnchor *me);
extern void HTAnchor_setDocument (HTParentAnchor *me, HyperDoc * doc);
extern HyperDoc * HTAnchor_document (HTParentAnchor *me);
extern char * HTAnchor_address (HTAnchor *me);
extern BOOL HTAnchor_cacheHit (HTParentAnchor *me); extern void HTAnchor_setCacheHit (HTParentAnchor *me, BOOL cacheHit);
extern char * HTAnchor_physical (HTParentAnchor * me); extern void HTAnchor_setPhysical (HTParentAnchor * me, char * protocol);
extern void HTAnchor_clearIndex (HTParentAnchor *me); extern void HTAnchor_setIndex (HTParentAnchor *me); extern BOOL HTAnchor_isIndex (HTParentAnchor *me);
extern void * HTAnchor_protocol (HTParentAnchor * me); extern void HTAnchor_setProtocol (HTParentAnchor * me, void* protocol);
extern CONST char * HTAnchor_title (HTParentAnchor *me); extern void HTAnchor_setTitle (HTParentAnchor *me, CONST char * title); extern void HTAnchor_appendTitle (HTParentAnchor *me, CONST char * title);
extern HTFormat HTAnchor_format (HTParentAnchor *me); extern void HTAnchor_setFormat (HTParentAnchor *me, HTFormat form);
extern HTCharset HTAnchor_charset (HTParentAnchor *me); extern void HTAnchor_setCharset (HTParentAnchor *me, HTCharset charset);
extern HTLevel HTAnchor_level (HTParentAnchor * me); extern void HTAnchor_setLevel (HTParentAnchor * me, HTLevel level);
extern HTLanguage HTAnchor_language (HTParentAnchor *me); extern void HTAnchor_setLanguage (HTParentAnchor *me, HTLanguage language);
extern HTEncoding HTAnchor_encoding (HTParentAnchor *me); extern void HTAnchor_setEncoding (HTParentAnchor *me, HTEncoding encoding);
extern HTCte HTAnchor_cte (HTParentAnchor *me); extern void HTAnchor_setCte (HTParentAnchor *me, HTCte cte);
extern long int HTAnchor_length (HTParentAnchor *me); extern void HTAnchor_setLength (HTParentAnchor *me, long int length);
extern int HTAnchor_methods (HTParentAnchor *me); extern void HTAnchor_setMethods (HTParentAnchor *me, int methodset); extern void HTAnchor_appendMethods (HTParentAnchor *me, int methodset);
extern CONST char * HTAnchor_version (HTParentAnchor *me); extern void HTAnchor_setVersion (HTParentAnchor *me, CONST char * version);
#define HTAnchor_date(me) ((me) ? (me)->date : -1) extern void HTAnchor_setDate (HTParentAnchor *me, CONST time_t *date);
#define HTAnchor_lastModified(me) ((me) ? (me)->last_modified : -1) extern void HTAnchor_setLastModified (HTParentAnchor *me, CONST time_t *lm);
#define HTAnchor_expires(me) ((me) ? (me)->expires : -1) extern void HTAnchor_setExpires (HTParentAnchor *me, CONST time_t *expires);
extern CONST char * HTAnchor_derived (HTParentAnchor *me); extern void HTAnchor_setDerived (HTParentAnchor *me, CONST char * derived_from);
HTAnchor_addExtra() function to extra headers here, but
use the field in the request structure
for sending test headers.
extern HTList * HTAnchor_Extra (HTParentAnchor *me); extern void HTAnchor_addExtra (HTParentAnchor *me, CONST char * header);
extern BOOL HTAnchor_headerParsed (HTParentAnchor *me); extern void HTAnchor_setHeaderParsed (HTParentAnchor *me);
extern void HTAnchor_clearHeader (HTParentAnchor *me); #endif /* HTANCHOR_H */