| 1 |
/* |
| 2 |
* $LynxId: HTAnchor.h,v 1.40 2018/03/11 18:43:50 tom Exp $ |
| 3 |
* |
| 4 |
* Hypertext "Anchor" Object HTAnchor.h |
| 5 |
* ========================== |
| 6 |
* |
| 7 |
* An anchor represents a region of a hypertext document which is linked |
| 8 |
* to another anchor in the same or a different document. |
| 9 |
*/ |
| 10 |
|
| 11 |
#ifndef HTANCHOR_H |
| 12 |
#define HTANCHOR_H |
| 13 |
|
| 14 |
/* Version 0 (TBL) written in Objective-C for the NeXT browser */ |
| 15 |
/* Version 1 of 24-Oct-1991 (JFG), written in C, browser-independent */ |
| 16 |
|
| 17 |
#include <HTList.h> |
| 18 |
#include <HTBTree.h> |
| 19 |
#include <HTChunk.h> |
| 20 |
#include <HTAtom.h> |
| 21 |
#include <UCDefs.h> |
| 22 |
|
| 23 |
typedef struct _HyperDoc HyperDoc; /* Ready for forward references */ |
| 24 |
typedef struct _HTAnchor HTAnchor; |
| 25 |
typedef struct _HTParentAnchor HTParentAnchor; |
| 26 |
typedef struct _HTParentAnchor0 HTParentAnchor0; |
| 27 |
|
| 28 |
#include <HTFormat.h> |
| 29 |
|
| 30 |
#ifdef __cplusplus |
| 31 |
extern "C" { |
| 32 |
#endif |
| 33 |
struct _HTAnchor { |
| 34 |
/* Generic anchor */ |
| 35 |
HTParentAnchor0 *parent; /* Parent of this anchor (self for adults) */ |
| 36 |
}; |
| 37 |
|
| 38 |
#define HASH_TYPE unsigned short |
| 39 |
|
| 40 |
struct _HTParentAnchor0 { /* One for adult_table, |
| 41 |
* generally not used outside HTAnchor.c */ |
| 42 |
/* Common part from the generic anchor structure */ |
| 43 |
HTParentAnchor0 *parent; /* (self) */ |
| 44 |
|
| 45 |
/* ParentAnchor0-specific information */ |
| 46 |
char *address; /* Absolute address of this node */ |
| 47 |
HTParentAnchor *info; /* additional info, allocated on demand */ |
| 48 |
|
| 49 |
HTBTree *children; /* Subanchors <a name="tag">, sorted by tag */ |
| 50 |
HTList sources; /* List of anchors pointing to this, if any */ |
| 51 |
|
| 52 |
HTList _add_adult; /* - just a memory for list entry:) */ |
| 53 |
HASH_TYPE adult_hash; /* adult list number */ |
| 54 |
BOOL underway; /* Document about to be attached to it */ |
| 55 |
}; |
| 56 |
|
| 57 |
/* |
| 58 |
* Separated from the above to save memory: allocated on demand, |
| 59 |
* it is nearly 1:1 to HText (well, sometimes without HText...), |
| 60 |
* available for SGML, HTML, and HText stages. |
| 61 |
* [being precise, we currently allocate it before HTLoadDocument(), |
| 62 |
* in HTAnchor_findAddress() and HTAnchor_parent()]. |
| 63 |
*/ |
| 64 |
struct _HTParentAnchor { |
| 65 |
/* Common part from the generic anchor structure */ |
| 66 |
HTParentAnchor0 *parent; /* Parent of this anchor */ |
| 67 |
|
| 68 |
/* ParentAnchor-specific information */ |
| 69 |
HTList children_notag; /* Subanchors <a href=...>, tag is NULL */ |
| 70 |
HyperDoc *document; /* The document within which this is an anchor */ |
| 71 |
|
| 72 |
char *address; /* parent->address, a pointer */ |
| 73 |
bstring *post_data; /* Posting data */ |
| 74 |
char *post_content_type; /* Type of post data */ |
| 75 |
char *bookmark; /* Bookmark filename */ |
| 76 |
HTFormat format; /* Pointer to node format descriptor */ |
| 77 |
char *charset; /* Pointer to character set (kludge, for now */ |
| 78 |
BOOL isIndex; /* Acceptance of a keyword search */ |
| 79 |
char *isIndexAction; /* URL of isIndex server */ |
| 80 |
char *isIndexPrompt; /* Prompt for isIndex query */ |
| 81 |
char *title; /* Title of document */ |
| 82 |
char *owner; /* Owner of document */ |
| 83 |
char *RevTitle; /* TITLE in REV="made" or REV="owner" LINK */ |
| 84 |
char *citehost; /* Citehost from REL="citehost" LINK */ |
| 85 |
#ifdef USE_COLOR_STYLE |
| 86 |
char *style; |
| 87 |
#endif |
| 88 |
|
| 89 |
HTList *methods; /* Methods available as HTAtoms */ |
| 90 |
void *protocol; /* Protocol object */ |
| 91 |
char *physical; /* Physical address */ |
| 92 |
BOOL isISMAPScript; /* Script for clickable image map */ |
| 93 |
BOOL isHEAD; /* Document is headers from a HEAD request */ |
| 94 |
BOOL safe; /* Safe */ |
| 95 |
#ifdef USE_SOURCE_CACHE |
| 96 |
char *source_cache_file; |
| 97 |
HTChunk *source_cache_chunk; |
| 98 |
#endif |
| 99 |
char *FileCache; /* Path to a disk-cached copy (see src/HTFWriter.c) */ |
| 100 |
char *SugFname; /* Suggested filename */ |
| 101 |
char *cache_control; /* Cache-Control */ |
| 102 |
BOOL no_cache; /* Cache-Control, Pragma or META "no-cache"? */ |
| 103 |
BOOL inHEAD; /* HTMIMEConvert is decoding server-headers */ |
| 104 |
BOOL inBASE; /* duplicated from HTStructured (HTML.c/h) */ |
| 105 |
HTChunk http_headers; |
| 106 |
BOOL no_content_encoding; /* server did not use C-T? */ |
| 107 |
char *content_type_params; /* Content-Type (with parameters if any) */ |
| 108 |
char *content_type; /* Content-Type */ |
| 109 |
char *content_language; /* Content-Language */ |
| 110 |
char *content_encoding; /* Compression algorithm */ |
| 111 |
char *content_base; /* Content-Base */ |
| 112 |
char *content_disposition; /* Content-Disposition */ |
| 113 |
char *content_location; /* Content-Location */ |
| 114 |
char *content_md5; /* Content-MD5 */ |
| 115 |
char *message_id; /* Message-ID */ |
| 116 |
char *subject; /* Subject */ |
| 117 |
off_t header_length; /* length of headers */ |
| 118 |
off_t content_length; /* Content-Length */ |
| 119 |
off_t actual_length; /* actual length may differ */ |
| 120 |
char *date; /* Date */ |
| 121 |
char *expires; /* Expires */ |
| 122 |
char *last_modified; /* Last-Modified */ |
| 123 |
char *ETag; /* ETag (HTTP1.1 cache validator) */ |
| 124 |
char *server; /* Server */ |
| 125 |
UCAnchorInfo *UCStages; /* chartrans stages */ |
| 126 |
HTList *imaps; /* client side image maps */ |
| 127 |
}; |
| 128 |
|
| 129 |
typedef HTAtom HTLinkType; |
| 130 |
|
| 131 |
typedef struct { |
| 132 |
/* Common part from the generic anchor structure */ |
| 133 |
HTParentAnchor0 *parent; /* Parent of this anchor */ |
| 134 |
|
| 135 |
/* ChildAnchor-specific information */ |
| 136 |
char *tag; /* #fragment, relative to the parent */ |
| 137 |
|
| 138 |
HTAnchor *dest; /* The anchor to which this leads */ |
| 139 |
HTLinkType *type; /* Semantics of this link */ |
| 140 |
|
| 141 |
HTList _add_children_notag; /* - just a memory for list entry:) */ |
| 142 |
HTList _add_sources; /* - just a memory for list entry:) */ |
| 143 |
} HTChildAnchor; |
| 144 |
|
| 145 |
/* |
| 146 |
* DocAddress structure is used for loading an absolute anchor with all |
| 147 |
* needed information including posting data and post content type. |
| 148 |
*/ |
| 149 |
typedef struct _DocAddress { |
| 150 |
char *address; |
| 151 |
bstring *post_data; |
| 152 |
char *post_content_type; |
| 153 |
char *bookmark; |
| 154 |
BOOL isHEAD; |
| 155 |
BOOL safe; |
| 156 |
} DocAddress; |
| 157 |
|
| 158 |
/* "internal" means "within the same document, with certainty". */ |
| 159 |
extern HTLinkType *HTInternalLink; |
| 160 |
|
| 161 |
/* Create or find a child anchor with a possible link |
| 162 |
* -------------------------------------------------- |
| 163 |
* |
| 164 |
* Create new anchor with a given parent and possibly |
| 165 |
* a name, and possibly a link to a _relatively_ named anchor. |
| 166 |
* (Code originally in ParseHTML.h) |
| 167 |
*/ |
| 168 |
extern HTChildAnchor *HTAnchor_findChildAndLink(HTParentAnchor *parent, /* May not be 0 */ |
| 169 |
const char *tag, /* May be "" or 0 */ |
| 170 |
const char *href, /* May be "" or 0 */ |
| 171 |
HTLinkType *ltype); /* May be 0 */ |
| 172 |
|
| 173 |
/* Create new or find old parent anchor |
| 174 |
* ------------------------------------ |
| 175 |
* |
| 176 |
* This one is for a reference which is found in a document, and might |
| 177 |
* not be already loaded. |
| 178 |
* Note: You are not guaranteed a new anchor -- you might get an old one, |
| 179 |
* like with fonts. |
| 180 |
*/ |
| 181 |
extern HTParentAnchor *HTAnchor_findAddress(const DocAddress *address); |
| 182 |
|
| 183 |
/* Create new or find old named anchor - simple form |
| 184 |
* ------------------------------------------------- |
| 185 |
* |
| 186 |
* Like the previous one, but simpler to use for simple cases. |
| 187 |
* No post data etc. can be supplied. - kw |
| 188 |
*/ |
| 189 |
extern HTParentAnchor *HTAnchor_findSimpleAddress(const char *url); |
| 190 |
|
| 191 |
/* Delete an anchor and possibly related things (auto garbage collection) |
| 192 |
* -------------------------------------------- |
| 193 |
* |
| 194 |
* The anchor is only deleted if the corresponding document is not loaded. |
| 195 |
* All outgoing links from children are deleted, and children are |
| 196 |
* removed from the sources lists of their targets. |
| 197 |
* We also try to delete the targets whose documents are not loaded. |
| 198 |
* If this anchor's sources list is empty, we delete it and its children. |
| 199 |
*/ |
| 200 |
extern BOOL HTAnchor_delete(HTParentAnchor0 *me); |
| 201 |
|
| 202 |
/* |
| 203 |
* Unnamed children (children_notag) have no sense without HText - |
| 204 |
* delete them and their links if we are about to free HText. |
| 205 |
* Document currently exists. Called within HText_free(). |
| 206 |
*/ |
| 207 |
extern void HTAnchor_delete_links(HTParentAnchor *me); |
| 208 |
|
| 209 |
#ifdef USE_SOURCE_CACHE |
| 210 |
extern void HTAnchor_clearSourceCache(HTParentAnchor *me); |
| 211 |
#endif |
| 212 |
|
| 213 |
/* Data access functions |
| 214 |
* --------------------- |
| 215 |
*/ |
| 216 |
extern HTParentAnchor *HTAnchor_parent(HTAnchor * me); |
| 217 |
|
| 218 |
extern void HTAnchor_setDocument(HTParentAnchor *me, |
| 219 |
HyperDoc *doc); |
| 220 |
|
| 221 |
extern HyperDoc *HTAnchor_document(HTParentAnchor *me); |
| 222 |
|
| 223 |
/* Returns the full URI of the anchor, child or parent |
| 224 |
* as a malloc'd string to be freed by the caller. |
| 225 |
*/ |
| 226 |
extern char *HTAnchor_address(HTAnchor * me); |
| 227 |
|
| 228 |
extern char *HTAnchor_short_address(HTAnchor * me); |
| 229 |
|
| 230 |
extern void HTAnchor_setFormat(HTParentAnchor *me, |
| 231 |
HTFormat form); |
| 232 |
|
| 233 |
extern HTFormat HTAnchor_format(HTParentAnchor *me); |
| 234 |
|
| 235 |
extern void HTAnchor_setIndex(HTParentAnchor *me, |
| 236 |
const char *address); |
| 237 |
|
| 238 |
extern void HTAnchor_setPrompt(HTParentAnchor *me, |
| 239 |
const char *prompt); |
| 240 |
|
| 241 |
extern BOOL HTAnchor_isIndex(HTParentAnchor *me); |
| 242 |
|
| 243 |
extern BOOL HTAnchor_isISMAPScript(HTAnchor * me); |
| 244 |
|
| 245 |
#if defined(USE_COLOR_STYLE) |
| 246 |
extern const char *HTAnchor_style(HTParentAnchor *me); |
| 247 |
|
| 248 |
extern void HTAnchor_setStyle(HTParentAnchor *me, |
| 249 |
const char *style); |
| 250 |
#endif |
| 251 |
|
| 252 |
/* Title handling. |
| 253 |
*/ |
| 254 |
extern const char *HTAnchor_title(HTParentAnchor *me); |
| 255 |
|
| 256 |
extern void HTAnchor_setTitle(HTParentAnchor *me, |
| 257 |
const char *title); |
| 258 |
|
| 259 |
extern void HTAnchor_appendTitle(HTParentAnchor *me, |
| 260 |
const char *title); |
| 261 |
|
| 262 |
/* Bookmark handling. |
| 263 |
*/ |
| 264 |
extern const char *HTAnchor_bookmark(HTParentAnchor *me); |
| 265 |
|
| 266 |
extern void HTAnchor_setBookmark(HTParentAnchor *me, |
| 267 |
const char *bookmark); |
| 268 |
|
| 269 |
/* Owner handling. |
| 270 |
*/ |
| 271 |
extern const char *HTAnchor_owner(HTParentAnchor *me); |
| 272 |
|
| 273 |
extern void HTAnchor_setOwner(HTParentAnchor *me, |
| 274 |
const char *owner); |
| 275 |
|
| 276 |
/* TITLE handling in LINKs with REV="made" or REV="owner". - FM |
| 277 |
*/ |
| 278 |
extern const char *HTAnchor_RevTitle(HTParentAnchor *me); |
| 279 |
|
| 280 |
extern void HTAnchor_setRevTitle(HTParentAnchor *me, |
| 281 |
const char *title); |
| 282 |
|
| 283 |
/* Citehost for bibp links from LINKs with REL="citehost". - RDC |
| 284 |
*/ |
| 285 |
extern const char *HTAnchor_citehost(HTParentAnchor *me); |
| 286 |
|
| 287 |
extern void HTAnchor_setCitehost(HTParentAnchor *me, |
| 288 |
const char *citehost); |
| 289 |
|
| 290 |
/* Suggested filename handling. - FM |
| 291 |
* (will be loaded if we had a Content-Disposition |
| 292 |
* header or META element with filename=name.suffix) |
| 293 |
*/ |
| 294 |
extern const char *HTAnchor_SugFname(HTParentAnchor *me); |
| 295 |
|
| 296 |
/* HTTP Headers. |
| 297 |
*/ |
| 298 |
extern const char *HTAnchor_http_headers(HTParentAnchor *me); |
| 299 |
|
| 300 |
/* Content-Type handling (parameter list). |
| 301 |
*/ |
| 302 |
extern const char *HTAnchor_content_type_params(HTParentAnchor *me); |
| 303 |
|
| 304 |
/* Content-Type handling. - FM |
| 305 |
*/ |
| 306 |
extern const char *HTAnchor_content_type(HTParentAnchor *me); |
| 307 |
|
| 308 |
/* Content-Encoding handling. - FM |
| 309 |
* (will be loaded if we had a Content-Encoding |
| 310 |
* header.) |
| 311 |
*/ |
| 312 |
extern const char *HTAnchor_content_encoding(HTParentAnchor *me); |
| 313 |
|
| 314 |
/* Last-Modified header handling. - FM |
| 315 |
*/ |
| 316 |
extern const char *HTAnchor_last_modified(HTParentAnchor *me); |
| 317 |
|
| 318 |
/* Date header handling. - FM |
| 319 |
*/ |
| 320 |
extern const char *HTAnchor_date(HTParentAnchor *me); |
| 321 |
|
| 322 |
/* Server header handling. - FM |
| 323 |
*/ |
| 324 |
extern const char *HTAnchor_server(HTParentAnchor *me); |
| 325 |
|
| 326 |
/* Safe header handling. - FM |
| 327 |
*/ |
| 328 |
extern BOOL HTAnchor_safe(HTParentAnchor *me); |
| 329 |
|
| 330 |
/* Content-Base header handling. - FM |
| 331 |
*/ |
| 332 |
extern const char *HTAnchor_content_base(HTParentAnchor *me); |
| 333 |
|
| 334 |
/* Content-Location header handling. - FM |
| 335 |
*/ |
| 336 |
extern const char *HTAnchor_content_location(HTParentAnchor *me); |
| 337 |
|
| 338 |
/* Message-ID, used for mail replies - kw |
| 339 |
*/ |
| 340 |
extern const char *HTAnchor_messageID(HTParentAnchor *me); |
| 341 |
|
| 342 |
extern BOOL HTAnchor_setMessageID(HTParentAnchor *me, |
| 343 |
const char *messageid); |
| 344 |
|
| 345 |
/* Subject, used for mail replies - kw |
| 346 |
*/ |
| 347 |
extern const char *HTAnchor_subject(HTParentAnchor *me); |
| 348 |
|
| 349 |
extern BOOL HTAnchor_setSubject(HTParentAnchor *me, |
| 350 |
const char *subject); |
| 351 |
|
| 352 |
/* Manipulation of links |
| 353 |
* --------------------- |
| 354 |
*/ |
| 355 |
extern HTAnchor *HTAnchor_followLink(HTChildAnchor *me); |
| 356 |
|
| 357 |
extern HTAnchor *HTAnchor_followTypedLink(HTChildAnchor *me, |
| 358 |
HTLinkType *type); |
| 359 |
|
| 360 |
/* Read and write methods |
| 361 |
* ---------------------- |
| 362 |
*/ |
| 363 |
extern HTList *HTAnchor_methods(HTParentAnchor *me); |
| 364 |
|
| 365 |
/* Protocol |
| 366 |
* -------- |
| 367 |
*/ |
| 368 |
extern void *HTAnchor_protocol(HTParentAnchor *me); |
| 369 |
|
| 370 |
extern void HTAnchor_setProtocol(HTParentAnchor *me, |
| 371 |
void *protocol); |
| 372 |
|
| 373 |
/* Physical address |
| 374 |
* ---------------- |
| 375 |
*/ |
| 376 |
extern char *HTAnchor_physical(HTParentAnchor *me); |
| 377 |
|
| 378 |
extern void HTAnchor_setPhysical(HTParentAnchor *me, |
| 379 |
char *protocol); |
| 380 |
|
| 381 |
extern LYUCcharset *HTAnchor_getUCInfoStage(HTParentAnchor *me, |
| 382 |
int which_stage); |
| 383 |
|
| 384 |
extern int HTAnchor_getUCLYhndl(HTParentAnchor *me, |
| 385 |
int which_stage); |
| 386 |
|
| 387 |
extern LYUCcharset *HTAnchor_setUCInfoStage(HTParentAnchor *me, |
| 388 |
int LYhndl, |
| 389 |
int which_stage, |
| 390 |
int set_by); |
| 391 |
|
| 392 |
extern LYUCcharset *HTAnchor_setUCInfoStage(HTParentAnchor *me, |
| 393 |
int LYhndl, |
| 394 |
int which_stage, |
| 395 |
int set_by); |
| 396 |
|
| 397 |
extern LYUCcharset *HTAnchor_resetUCInfoStage(HTParentAnchor *me, |
| 398 |
int LYhndl, |
| 399 |
int which_stage, |
| 400 |
int set_by); |
| 401 |
|
| 402 |
extern LYUCcharset *HTAnchor_copyUCInfoStage(HTParentAnchor *me, |
| 403 |
int to_stage, |
| 404 |
int from_stage, |
| 405 |
int set_by); |
| 406 |
|
| 407 |
extern void ImageMapList_free(HTList *list); |
| 408 |
|
| 409 |
#ifdef __cplusplus |
| 410 |
} |
| 411 |
#endif |
| 412 |
#endif /* HTANCHOR_H */ |