Annotation of libwww/Library/src/HTLink.html, revision 2.4
2.1 frystyk 1: <HTML>
2: <HEAD>
3: <!-- Changed by: Henrik Frystyk Nielsen, 30-Jun-1996 -->
2.2 frystyk 4: <TITLE>W3C Sample Code Library libwww Link Class</TITLE>
2.1 frystyk 5: </HEAD>
6: <BODY>
7: <H1>
8: The Link Class
9: </H1>
10: <PRE>
11: /*
12: ** (c) COPYRIGHT MIT 1995.
13: ** Please first read the full copyright statement in the file COPYRIGH.
14: */
15: </PRE>
16: <P>
17: A <A HREF="HTLink.html">Link</A> represents the link between anchor objects.
18: By keeping the link as a object and not as part of the anchor we are capable
19: of handling link semantics in a much more organized way. For example, we
20: can then search for link types among all the link objects that we have created.
21: <A HREF="HTAnchor.html">Anchor objects</A> are bound together using Link
22: objects. Each anchor can be the source or destination of zero, one, or more
23: links from and to other anchors.
24: <P>
25: This module is implemented by <A HREF="HTLink.c">HTLink.c</A>, and it is
2.3 frystyk 26: a part of the <A HREF="http://www.w3.org/Library/"> W3C Sample Code
2.1 frystyk 27: Library</A>.
28: <PRE>
29: #ifndef HTLINK_H
30: #define HTLINK_H
31:
32: typedef struct _HTLink HTLink;
33:
34: #include "WWWUtil.h"
35: #include "HTMethod.h"
36: #include "HTAnchor.h"
37: </PRE>
38: <H2>
39: Creation and Deletion Methods
40: </H2>
41: <P>
42: These are the methods for crating and deleting new link objects
43: <H3>
44: Create a new Link Object
45: </H3>
46: <PRE>typedef HTAtom * HTLinkType;
47:
48: typedef enum _HTLinkResult {
49: HT_LINK_INVALID = -1,
50: HT_LINK_NONE = 0,
51: HT_LINK_ERROR,
52: HT_LINK_OK
53: } HTLinkResult;
54:
55: struct _HTLink {
56: HTAnchor * dest; /* The anchor to which this leads */
57: HTLinkType type; /* Semantics of this link */
58: HTMethod method; /* Method for this link, e.g. PUT */
59: HTLinkResult result; /* Result of any attempt to get this link */
60: };
61:
62: HTLink * HTLink_new (void);
63: </PRE>
64: <H3>
65: Delete a Link Object
66: </H3>
67: <P>
68: A link can be removed as any other object
69: <PRE>BOOL HTLink_delete (HTLink * link);
70: </PRE>
71: <H3>
72: Remove All Link Information from an Anchor
73: </H3>
74: <P>
75: This is normally a part of deleting anchor objects.
76: <PRE>extern BOOL HTLink_removeAll (HTAnchor * me);
77: </PRE>
78: <H2>
79: Handle Link Between Anchors
80: </H2>
81: <P>
82: As mentioned, link objects are the ones that bind anchor objects together
83: in a Web like structure
84: <H3>
85: Add a Link between two Anchors
86: </H3>
87: <P>
88: This method creates a new link between two <A HREF="HTAnchor.html">anchor
89: objects</A>.
90: <PRE>extern BOOL HTLink_add (HTAnchor * source,
91: HTAnchor * destination,
92: HTLinkType type,
93: HTMethod method);
94: </PRE>
95: <H3>
96: Remove All Links Between two Anchors
97: </H3>
98: <P>
99: Removes link information from one anchor to another.
100: <PRE>extern BOOL HTLink_remove (HTAnchor * source, HTAnchor * destination);
101: </PRE>
102: <H3>
103: Find a Link
104: </H3>
105: <P>
106: Find the anchor object between a destination and a source ancher. Return
107: link object if any, else NULL
108: <PRE>extern HTLink * HTLink_find (HTAnchor * source, HTAnchor * destination);
109: </PRE>
2.4 ! frystyk 110: <H3>
! 111: Find a Link with a given link type
! 112: </H3>
! 113: <P>
! 114: Returns a link with a given link type or NULL if nothing found
! 115: <PRE>extern HTLink * HTLink_findType (HTAnchor * me, HTLinkType type);
! 116: </PRE>
2.1 frystyk 117: <H2>
118: Link Information
119: </H2>
120: <P>
121: This is the set of methods for accessing the information carried by a link
122: object
123: <H3>
124: Link Destination
125: </H3>
126: <P>
127: The link destination is the destination anchor pointed to by the link.
128: <PRE>extern BOOL HTLink_setDestination (HTLink * link, HTAnchor * dest);
129: extern HTAnchor * HTLink_destination (HTLink * link);
130: </PRE>
131: <H3>
132: Link Types and Semantic Links
133: </H3>
134: <P>
135: Each link has a sematic representation associated with it. This means that
136: the application can distinguish between pages based on the semantics of the
137: link. This is very similar to the <CODE>LINK</CODE> tag in HTML pages which
138: indicates the meaning if this pages to other pages.
139: <PRE>extern BOOL HTLink_setType (HTLink * link, HTLinkType type);
140: extern HTLinkType HTLink_type (HTLink * link);
141: </PRE>
142: <H3>
143: Link Method
144: </H3>
145: <P>
146: The link method is the HTTP method we have performed between the two links.
147: For example, it can be a POST operation, or a PUT operation where the operation
148: on the first anchor created a new anchor.
149: <PRE>extern BOOL HTLink_setMethod (HTLink * link, HTMethod method);
150: extern HTMethod HTLink_method (HTLink * link);
151: </PRE>
152: <H3>
153: Link Result
154: </H3>
155: <P>
156: When a link has been used for posting an object from a source to a destination
157: link, the result of the operation is stored as part of the link information.
158: This means that we can keep track of which operations we have performed on
159: a link and hence the application can ask the user whether he or she wants
160: to do a re-post, for example.
161: <PRE>
162: extern BOOL HTLink_setResult (HTLink * link, HTLinkResult result);
163: extern HTLinkResult HTLink_result (HTLink * link);
164: </PRE>
165: <PRE>
166: #endif /* HTLINK_H */
167: </PRE>
168: <P>
169: <HR>
170: <ADDRESS>
2.4 ! frystyk 171: @(#) $Id: HTLink.html,v 2.3 1998/05/14 02:10:38 frystyk Exp $
2.1 frystyk 172: </ADDRESS>
173: </BODY></HTML>
Webmaster