Annotation of libwww/Library/src/HTLink.html, revision 2.5
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>
2.5 ! frystyk 79: Predefined Link Types
! 80: </H2>
! 81: <P>
! 82: Just for ease of use, we define a seet of commonly used link types. You can
! 83: ofcourse use any other link type you want.
! 84: <PRE>
! 85: #define HT_LR_PERM_REDIRECT HTAtom_for("PERMANENT_REDIRECTION")
! 86: #define HT_LR_TEMP_REDIRECT HTAtom_for("TEMPORARY_REDIRECTION")
! 87: #define HT_LR_SEE_OTHER HTAtom_for("SEE_OTHER")
! 88: </PRE>
! 89: <H2>
2.1 frystyk 90: Handle Link Between Anchors
91: </H2>
92: <P>
93: As mentioned, link objects are the ones that bind anchor objects together
94: in a Web like structure
95: <H3>
96: Add a Link between two Anchors
97: </H3>
98: <P>
99: This method creates a new link between two <A HREF="HTAnchor.html">anchor
100: objects</A>.
101: <PRE>extern BOOL HTLink_add (HTAnchor * source,
102: HTAnchor * destination,
103: HTLinkType type,
104: HTMethod method);
105: </PRE>
106: <H3>
107: Remove All Links Between two Anchors
108: </H3>
109: <P>
110: Removes link information from one anchor to another.
111: <PRE>extern BOOL HTLink_remove (HTAnchor * source, HTAnchor * destination);
112: </PRE>
113: <H3>
114: Find a Link
115: </H3>
116: <P>
117: Find the anchor object between a destination and a source ancher. Return
118: link object if any, else NULL
119: <PRE>extern HTLink * HTLink_find (HTAnchor * source, HTAnchor * destination);
120: </PRE>
2.4 frystyk 121: <H3>
122: Find a Link with a given link type
123: </H3>
124: <P>
125: Returns a link with a given link type or NULL if nothing found
126: <PRE>extern HTLink * HTLink_findType (HTAnchor * me, HTLinkType type);
127: </PRE>
2.1 frystyk 128: <H2>
129: Link Information
130: </H2>
131: <P>
132: This is the set of methods for accessing the information carried by a link
133: object
134: <H3>
135: Link Destination
136: </H3>
137: <P>
138: The link destination is the destination anchor pointed to by the link.
139: <PRE>extern BOOL HTLink_setDestination (HTLink * link, HTAnchor * dest);
140: extern HTAnchor * HTLink_destination (HTLink * link);
141: </PRE>
142: <H3>
143: Link Types and Semantic Links
144: </H3>
145: <P>
146: Each link has a sematic representation associated with it. This means that
147: the application can distinguish between pages based on the semantics of the
148: link. This is very similar to the <CODE>LINK</CODE> tag in HTML pages which
149: indicates the meaning if this pages to other pages.
150: <PRE>extern BOOL HTLink_setType (HTLink * link, HTLinkType type);
151: extern HTLinkType HTLink_type (HTLink * link);
152: </PRE>
153: <H3>
154: Link Method
155: </H3>
156: <P>
157: The link method is the HTTP method we have performed between the two links.
158: For example, it can be a POST operation, or a PUT operation where the operation
159: on the first anchor created a new anchor.
160: <PRE>extern BOOL HTLink_setMethod (HTLink * link, HTMethod method);
161: extern HTMethod HTLink_method (HTLink * link);
162: </PRE>
163: <H3>
164: Link Result
165: </H3>
166: <P>
167: When a link has been used for posting an object from a source to a destination
168: link, the result of the operation is stored as part of the link information.
169: This means that we can keep track of which operations we have performed on
170: a link and hence the application can ask the user whether he or she wants
171: to do a re-post, for example.
172: <PRE>
173: extern BOOL HTLink_setResult (HTLink * link, HTLinkResult result);
174: extern HTLinkResult HTLink_result (HTLink * link);
175: </PRE>
176: <PRE>
177: #endif /* HTLINK_H */
178: </PRE>
179: <P>
180: <HR>
181: <ADDRESS>
2.5 ! frystyk 182: @(#) $Id: HTLink.html,v 2.4 1999/03/03 21:02:41 frystyk Exp $
2.1 frystyk 183: </ADDRESS>
184: </BODY></HTML>
Webmaster