File:
[Public] /
libwww /
Library /
src /
HTLink.html
Revision
2.2:
download - view:
text,
annotated -
select for diffs
Sun Feb 16 18:42:29 1997 UTC (27 years, 3 months ago) by
frystyk
Branches:
MAIN
CVS tags:
Release-5-1l,
Release-5-1k,
Release-5-1j,
Release-5-1g,
Release-5-1e,
Release-5-1d,
Release-5-1b,
Release-5-1a,
Release-5-1,
HEAD
Changed name of sample coed library
<HTML>
<HEAD>
<!-- Changed by: Henrik Frystyk Nielsen, 30-Jun-1996 -->
<TITLE>W3C Sample Code Library libwww Link Class</TITLE>
</HEAD>
<BODY>
<H1>
The Link Class
</H1>
<PRE>
/*
** (c) COPYRIGHT MIT 1995.
** Please first read the full copyright statement in the file COPYRIGH.
*/
</PRE>
<P>
A <A HREF="HTLink.html">Link</A> represents the link between anchor objects.
By keeping the link as a object and not as part of the anchor we are capable
of handling link semantics in a much more organized way. For example, we
can then search for link types among all the link objects that we have created.
<A HREF="HTAnchor.html">Anchor objects</A> are bound together using Link
objects. Each anchor can be the source or destination of zero, one, or more
links from and to other anchors.
<P>
This module is implemented by <A HREF="HTLink.c">HTLink.c</A>, and it is
a part of the <A HREF="http://www.w3.org/pub/WWW/Library/"> W3C Sample Code
Library</A>.
<PRE>
#ifndef HTLINK_H
#define HTLINK_H
typedef struct _HTLink HTLink;
#include "WWWUtil.h"
#include "HTMethod.h"
#include "HTAnchor.h"
</PRE>
<H2>
Creation and Deletion Methods
</H2>
<P>
These are the methods for crating and deleting new link objects
<H3>
Create a new Link Object
</H3>
<PRE>typedef HTAtom * HTLinkType;
typedef enum _HTLinkResult {
HT_LINK_INVALID = -1,
HT_LINK_NONE = 0,
HT_LINK_ERROR,
HT_LINK_OK
} HTLinkResult;
struct _HTLink {
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 * HTLink_new (void);
</PRE>
<H3>
Delete a Link Object
</H3>
<P>
A link can be removed as any other object
<PRE>BOOL HTLink_delete (HTLink * link);
</PRE>
<H3>
Remove All Link Information from an Anchor
</H3>
<P>
This is normally a part of deleting anchor objects.
<PRE>extern BOOL HTLink_removeAll (HTAnchor * me);
</PRE>
<H2>
Handle Link Between Anchors
</H2>
<P>
As mentioned, link objects are the ones that bind anchor objects together
in a Web like structure
<H3>
Add a Link between two Anchors
</H3>
<P>
This method creates a new link between two <A HREF="HTAnchor.html">anchor
objects</A>.
<PRE>extern BOOL HTLink_add (HTAnchor * source,
HTAnchor * destination,
HTLinkType type,
HTMethod method);
</PRE>
<H3>
Remove All Links Between two Anchors
</H3>
<P>
Removes link information from one anchor to another.
<PRE>extern BOOL HTLink_remove (HTAnchor * source, HTAnchor * destination);
</PRE>
<H3>
Find a Link
</H3>
<P>
Find the anchor object between a destination and a source ancher. Return
link object if any, else NULL
<PRE>extern HTLink * HTLink_find (HTAnchor * source, HTAnchor * destination);
</PRE>
<H2>
Link Information
</H2>
<P>
This is the set of methods for accessing the information carried by a link
object
<H3>
Link Destination
</H3>
<P>
The link destination is the destination anchor pointed to by the link.
<PRE>extern BOOL HTLink_setDestination (HTLink * link, HTAnchor * dest);
extern HTAnchor * HTLink_destination (HTLink * link);
</PRE>
<H3>
Link Types and Semantic Links
</H3>
<P>
Each link has a sematic representation associated with it. This means that
the application can distinguish between pages based on the semantics of the
link. This is very similar to the <CODE>LINK</CODE> tag in HTML pages which
indicates the meaning if this pages to other pages.
<PRE>extern BOOL HTLink_setType (HTLink * link, HTLinkType type);
extern HTLinkType HTLink_type (HTLink * link);
</PRE>
<H3>
Link Method
</H3>
<P>
The link method is the HTTP method we have performed between the two links.
For example, it can be a POST operation, or a PUT operation where the operation
on the first anchor created a new anchor.
<PRE>extern BOOL HTLink_setMethod (HTLink * link, HTMethod method);
extern HTMethod HTLink_method (HTLink * link);
</PRE>
<H3>
Link Result
</H3>
<P>
When a link has been used for posting an object from a source to a destination
link, the result of the operation is stored as part of the link information.
This means that we can keep track of which operations we have performed on
a link and hence the application can ask the user whether he or she wants
to do a re-post, for example.
<PRE>
extern BOOL HTLink_setResult (HTLink * link, HTLinkResult result);
extern HTLinkResult HTLink_result (HTLink * link);
</PRE>
<PRE>
#endif /* HTLINK_H */
</PRE>
<P>
<HR>
<ADDRESS>
@(#) $Id: HTLink.html,v 2.2 1997/02/16 18:42:29 frystyk Exp $
</ADDRESS>
</BODY></HTML>
Webmaster