home *** CD-ROM | disk | FTP | other *** search
/ Collection of Internet / Collection of Internet.iso / msdos / lynx / source / www / library / implemen / htanchor.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-25  |  9.4 KB  |  307 lines

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