1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328
|
<HTML>
<HEAD>
<TITLE>Anchor object for libwww</TITLE>
<NEXTID N="z2">
</HEAD>
<BODY>
<H1>Hypertext "Anchor" Object</H1>An anchor represents a region of
a hypertext document which is linked
to another anchor in the same or
a different document.
<PRE>#ifndef HTANCHOR_H
#define HTANCHOR_H
/* Version 0 (TBL) written in Objective-C for the NeXT browser */
/* Version 1 of 24-Oct-1991 (JFG), written in C, browser-independant */
#include "HTList.h"
#include "HTAtom.h"
</PRE>
<H3>Short names</H3>
<PRE>#ifdef SHORT_NAMES
#define HTAnchor_findChild HTAnFiCh
#define HTAnchor_findChildAndLink HTAnFiLi
#define HTAnchor_findAddress HTAnFiAd
#define HTAnchor_delete HTAnDele
#define HTAnchor_makeLastChild HTAnMaLa
#define HTAnchor_parent HTAnPare
#define HTAnchor_setDocument HTAnSeDo
#define HTAnchor_document HTAnDocu
#define HTAnchor_setFormat HTAnSeFo
#define HTAnchor_format HTAnForm
#define HTAnchor_setIndex HTAnSeIn
#define HTAnchor_isIndex HTAnIsIn
#define HTAnchor_address HTAnAddr
#define HTAnchor_hasChildren HTAnHaCh
#define HTAnchor_title HTAnTitl
#define HTAnchor_setTitle HTAnSeTi
#define HTAnchor_appendTitle HTAnApTi
#define HTAnchor_link HTAnLink
#define HTAnchor_followMainLink HTAnFoMa
#define HTAnchor_followTypedLink HTAnFoTy
#define HTAnchor_makeMainLink HTAnMaMa
#define HTAnchor_setProtocol HTAnSePr
#define HTAnchor_protocol HTAnProt
#define HTAnchor_physical HTAnPhys
#define HTAnchor_setPhysical HTAnSePh
#define HTAnchor_methods HtAnMeth
#endif
</PRE>
<A NAME="anchor"><H2>Anchor data structures</H2></A>
<PRE>typedef struct _HyperDoc HyperDoc; /* Ready for forward references */
typedef struct _HTAnchor HTAnchor;
typedef struct _HTParentAnchor HTParentAnchor;
typedef struct _HTChildAnchor HTChildAnchor;
</PRE>Must be AFTER definition of HTAnchor:
<PRE>#include "HTFormat.h"
typedef HTAtom HTLinkType;
typedef struct {
HTAnchor * dest; /* The anchor to which this leads */
HTLinkType * type; /* Semantics of this link */
} HTLink;
</PRE>
<H3>Generic Anchor type</H3>
<PRE>struct _HTAnchor { /* Generic anchor : just links */
HTLink mainLink; /* Main (or default) destination of this */
HTList * links; /* List of extra links from this, if any */
/* We separate the first link from the others to avoid too many small mallocs
involved by a list creation. Most anchors only point to one place. */
HTParentAnchor * parent; /* Parent of this anchor (self for adults) */
};
</PRE>
<H3>Anchor for a whole object</H3>
<PRE>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 which this is an anchor */
char * address; /* Absolute address of this node */
HTFormat format; /* Pointer to node format descriptor */
BOOL isIndex; /* Acceptance of a keyword search */
char * title; /* Title of document */
HTList* methods; /* Methods available as HTAtoms */
void * protocol; /* Protocol object */
char * physical; /* Physical address */
HTList * <A
NAME="z1">cacheItems</A> ; /* Cache hits (see <A
NAME="z0" HREF="HTFWriter.html">HTFWriter</A> ) for this URL */
long int size; /* Indicative size only if multiformat */
};
</PRE>
<H3>Anchor for a fragment of an object</H3>
<PRE>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 */
};
</PRE>
<H2>Class methods</H2>
<H3>HTAnchor_findChild: Create new or
find old sub-anchor</H3>This one is for a new anchor being
edited into an existing document.
The parent anchor must already exist.
<PRE>extern HTChildAnchor * HTAnchor_findChild
PARAMS(
(HTParentAnchor *parent,
CONST char *tag)
);
</PRE>
<H3>HTAnchor_findChildAndLink: Create
or find a child anchor with a possible
link</H3>Create new anchor with a given parent
and possibly a name, and possibly
a link to a _relatively_ named anchor.
<PRE>extern HTChildAnchor * HTAnchor_findChildAndLink
PARAMS((
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 */
));
</PRE>
<H3>Create new or find old named anchor</H3>
<PRE>
</PRE>This one is for a reference which
is found in a document, and might
not be already loaded. Note: You
are not guaranteed a new anchor --
you might get an old one, like with
NXFonts.
<PRE>extern HTAnchor * HTAnchor_findAddress
PARAMS(
(CONST char * address)
);
</PRE>
<H3>HTAnchor_delete: Delete an anchor</H3>Also possibly delete related things
(auto garbage collection)<P>
The anchor is only deleted if the
corresponding document is not loaded.
All outgoing links from parent and
children are deleted, and this anchor
is removed from the sources list
of all its targets. We also try to
delete the targets whose documents
are not loaded. If this anchor's
source list is empty, we delete it
and its children.
<PRE>extern BOOL HTAnchor_delete
PARAMS(
(HTParentAnchor *me)
);
</PRE>
<H3>HTAnchor_makeLastChild: Move an
anchor to the head of the list of
its siblings</H3>This is to ensure that an anchor
which might have already existed
is put in the correct order as we
load the document.
<PRE>
extern void HTAnchor_makeLastChild
PARAMS(
(HTChildAnchor *me)
);
</PRE>
<H2>Accessing Properties of the Anchor</H2>
<PRE>
extern HTParentAnchor * HTAnchor_parent
PARAMS(
(HTAnchor *me)
);
extern void HTAnchor_setDocument
PARAMS(
(HTParentAnchor *me, HyperDoc *doc)
);
extern HyperDoc * HTAnchor_document
PARAMS(
(HTParentAnchor *me)
);
/* We don't want code to change an address after anchor creation... yet ?
extern void HTAnchor_setAddress
PARAMS(
(HTAnchor *me, char *addr)
);
*/
</PRE>
<H3>HTAnchor_address</H3>Returns the full URI of the anchor,
child or parent as a malloc'd string
to be freed by the caller.
<PRE>
extern char * HTAnchor_address
PARAMS(
(HTAnchor *me)
);
</PRE>
<H3>Format of source</H3>
<PRE>extern void HTAnchor_setFormat
PARAMS(
(HTParentAnchor *me, HTFormat form)
);
extern HTFormat HTAnchor_format
PARAMS(
(HTParentAnchor *me)
);
</PRE>
<H3>Is it searchable?</H3>
<PRE>
extern void HTAnchor_clearIndex PARAMS((HTParentAnchor *me));
extern void HTAnchor_setIndex PARAMS((HTParentAnchor *me));
extern BOOL HTAnchor_isIndex PARAMS((HTParentAnchor *me));
</PRE>
<H3>Does it have any anchors within it?</H3>
<PRE>extern BOOL HTAnchor_hasChildren
PARAMS(
(HTParentAnchor *me)
);
</PRE>
<H3>List of methods which can operate
on object</H3>
<PRE>extern HTList * HTAnchor_methods PARAMS((HTParentAnchor *me));
</PRE>
<H3>Protocol</H3>
<PRE>extern void * HTAnchor_protocol PARAMS((HTParentAnchor * me));
extern void HTAnchor_setProtocol PARAMS((HTParentAnchor * me,
void* protocol));
</PRE>
<H3>Physical address</H3>
<PRE>extern char * HTAnchor_physical PARAMS((HTParentAnchor * me));
extern void HTAnchor_setPhysical PARAMS((HTParentAnchor * me,
char * protocol));
</PRE>
<H2>Title handling</H2>
<PRE>
extern CONST char * HTAnchor_title
PARAMS(
(HTParentAnchor *me)
);
extern void HTAnchor_setTitle
PARAMS(
(HTParentAnchor *me, CONST char * title)
);
extern void HTAnchor_appendTitle
PARAMS(
(HTParentAnchor *me, CONST char * title)
);
</PRE>
<A NAME="links"><H2>Manipulation of Links</H2></A>
<H3>Link this Anchor to another given
one</H3>
<PRE>
extern BOOL HTAnchor_link
PARAMS(
(HTAnchor *source, HTAnchor *destination, HTLinkType *type)
);
</PRE>
<H3>Find destination of link</H3>
<PRE>extern HTAnchor * HTAnchor_followMainLink
PARAMS(
(HTAnchor *me)
);
</PRE>
<H3>Find destination with given relationship</H3>
<PRE>extern HTAnchor * HTAnchor_followTypedLink
PARAMS(
(HTAnchor *me, HTLinkType *type)
);
</PRE>
<H3>Make a particular link the main link</H3>
<PRE>extern BOOL HTAnchor_makeMainLink
PARAMS(
(HTAnchor *me, HTLink *movingLink)
);
#endif /* HTANCHOR_H */
</PRE></BODY>
</HTML>
|