www.h
上传用户:zlh9724
上传日期:2007-01-04
资源大小:1991k
文件大小:48k
源码类别:

浏览器

开发平台:

Unix_Linux

  1. /* www.h function declarations and general defines */
  2. #ifndef POPUP
  3. #define POPUP
  4. #endif
  5. #ifndef PNG
  6. #define PNG
  7. #endif
  8. #ifndef JPEG
  9. #define JPEG
  10. #endif
  11. #ifndef STYLE_COLOR
  12. #define STYLE_COLOR
  13. #endif
  14. #ifndef STYLE_BACKGROUND
  15. #define STYLE_BACKGROUND
  16. #endif
  17. #ifndef ZOOM
  18. #define ZOOM
  19. #endif
  20. #ifdef SOLARIS
  21. #define SIGWAITING_IGN
  22. #endif
  23. #ifndef SELECTION
  24. #define SELECTION
  25. #endif
  26. #define VERSION         "beta-2b"      /* REMEMBER!!! also update DEFAULT_URL and HELP_URL and INITIAL_HTML*/
  27. #define BANNER  "Arena"     /* also used as APPNAME !!!!! */
  28. /* janet: added, as they are needed within www.h  is this the right place (line)? */
  29. #include <X11/Xlib.h>
  30. #include <X11/Xutil.h>
  31. #include <X11/Xos.h>
  32. #include <X11/Xatom.h>
  33. #include <X11/keysym.h>
  34. #include <X11/cursorfont.h>
  35. #ifdef __hpux
  36. #include <X11/HPkeysym.h>
  37. #endif
  38. #include "types.h"
  39. #if 0
  40. #include "skyblue.h"    /* the constraint solver */
  41. #endif
  42. #include "machdep.h" /* machine dependent definitions wm 24.Mar.95 */
  43. #include "HTUtils.h"
  44. #include "tcp.h"
  45. #include "HTString.h"
  46. #include "HTList.h"
  47. #include "HTAccess.h"
  48. /* #include "HTEvntrg.h" */
  49. #include "HTFormat.h"
  50. #include "HTAnchor.h"
  51. #include "HTAncMan.h"
  52. /* janet: this one is not in HTList.h, where it should be */
  53. /* extern void * HTList_removeObjectAt ARGS2 (HTList *,me, int,position);*/
  54. #define COMPACTDEFLISTS 1   /* comment out for old style */
  55. #define HELP_URL   "http://www.w3.org/hypertext/WWW/Arena/beta-2"
  56. #define DEFAULT_URL "http://www.w3.org/hypertext/WWW/Arena/beta-2"
  57. #define PRINTER     "alljet"
  58. #if defined POINTER_IS_64BIT
  59. #define POINTERSIZE 8
  60. #else
  61. #define POINTERSIZE 4
  62. #endif
  63. /* HTML error codes displayed in Octal */
  64. #define ERR_ANCHOR  1 << 0
  65. #define ERR_EMPH    1 << 1
  66. #define ERR_HEADER  1 << 2
  67. #define ERR_UL      1 << 3
  68. #define ERR_OL      1 << 4
  69. #define ERR_DL      1 << 5
  70. #define ERR_SELECT  1 << 6
  71. #define ERR_BLOCK   1 << 7
  72. #define ERR_PRE     1 << 8
  73. #define ERR_FIG     1 << 13
  74. #define ERR_LI      1 << 9
  75. #define ERR_TABLE   1 << 10
  76. #define ERR_SETUP   1 << 11
  77. #define ERR_BODY    1 << 12
  78. /* fonts and colors set in www.c GetResources(void) */
  79. #define H1FONT      "-*-helvetica-bold-r-normal--*-180-75-75-*-*-iso8859-1"
  80. #define H2FONT      "-*-helvetica-bold-r-normal--*-140-75-75-*-*-iso8859-1"
  81. #define H3FONT      "-*-helvetica-bold-r-normal--*-120-75-75-*-*-iso8859-1"
  82. #define H4FONT      "-*-helvetica-bold-r-normal--*-100-75-75-*-*-iso8859-1"
  83. #define LABELFONT   "6x13"
  84. #define SUBSCRFONT  "-*-new century schoolbook-medium-r-normal--*-80-75-75-*-*-iso8859-1"
  85. #define NORMALFONT  "-*-new century schoolbook-medium-r-normal--*-120-75-75-*-*-iso8859-1"
  86. #define ITALICFONT  "-*-new century schoolbook-medium-i-normal--*-120-75-75-*-*-iso8859-1"
  87. #define BINORMFONT  "-*-new century schoolbook-bold-i-normal--*-120-75-75-*-*-iso8859-1"
  88. #define BOLDFONT    "-*-new century schoolbook-bold-r-normal--*-120-75-75-*-*-iso8859-1"
  89. #define IFIXEDFONT  "-*-courier-medium-o-normal--*-120-75-75-*-*-iso8859-1"
  90. #define BFIXEDFONT  "-*-courier-bold-r-normal--*-120-75-75-*-*-iso8859-1"
  91. #define BIFIXEDFONT "-*-courier-bold-o-normal--*-120-75-75-*-*-iso8859-1"
  92. #define RFIXEDFONT  "-*-courier-medium-r-normal--*-120-75-75-*-*-iso8859-1"
  93. #define SYMFONT     "-*-symbol-medium-r-normal--*-140-75-75-*-*-*-*"
  94. #define SUBSYMFONT  "-*-symbol-medium-r-normal--*-100-75-75-*-*-*-*"
  95. #define H1FONTL      "-*-helvetica-bold-r-normal--*-240-75-75-*-*-iso8859-1"
  96. #define H2FONTL      "-*-helvetica-bold-r-normal--*-180-75-75-*-*-iso8859-1"
  97. #define H3FONTL      "-*-helvetica-bold-r-normal--*-140-75-75-*-*-iso8859-1"
  98. #define H4FONTL      "-*-helvetica-bold-r-normal--*-100-75-75-*-*-iso8859-1"
  99. #define SUBSCRFONTL  "-*-new century schoolbook-medium-r-normal--*-100-75-75-*-*-iso8859-1"
  100. #define NORMALFONTL  "-*-new century schoolbook-medium-r-normal--*-140-75-75-*-*-iso8859-1"
  101. #define ITALICFONTL  "-*-new century schoolbook-medium-i-normal--*-140-75-75-*-*-iso8859-1"
  102. #define BINORMFONTL  "-*-new century schoolbook-bold-i-normal--*-140-75-75-*-*-iso8859-1"
  103. #define BOLDFONTL    "-*-new century schoolbook-bold-i-normal--*-140-75-75-*-*-iso8859-1"
  104. #define IFIXEDFONTL  "-*-courier-medium-o-normal--*-140-75-75-*-*-iso8859-1"
  105. #define BFIXEDFONTL  "-*-courier-bold-r-normal--*-140-75-75-*-*-iso8859-1"
  106. #define BIFIXEDFONTL "-*-courier-bold-o-normal--*-140-75-75-*-*-iso8859-1"
  107. #define RFIXEDFONTL  "-*-courier-medium-r-normal--*-140-75-75-*-*-iso8859-1"
  108. #define SYMFONTL     "-*-symbol-medium-r-normal--*-180-75-75-*-*-*-*"
  109. #define SUBSYMFONTL  "-*-symbol-medium-r-normal--*-140-75-75-*-*-*-*"
  110. /* largest font is 24 point :-( */
  111. #define H1FONTG      "-*-helvetica-bold-r-normal--*-300-75-75-*-*-iso8859-1"
  112. #define H2FONTG      "-*-helvetica-bold-r-normal--*-260-75-75-*-*-iso8859-1"
  113. #define H3FONTG      "-*-helvetica-bold-r-normal--*-220-75-75-*-*-iso8859-1"
  114. #define H4FONTG      "-*-helvetica-bold-r-normal--*-180-75-75-*-*-iso8859-1"
  115. #define SUBSCRFONTG  "-*-helvetica-medium-r-normal--*-120-75-75-*-*-iso8859-1"
  116. #define NORMALFONTG  "-*-helvetica-medium-r-normal--*-180-75-75-*-*-iso8859-1"
  117. #define ITALICFONTG  "-*-helvetica-medium-o-normal--*-180-75-75-*-*-iso8859-1"
  118. #define BINORMFONTG  "-*-helvetica-bold-o-normal--*-180-75-75-*-*-iso8859-1"
  119. #define BOLDFONTG    "-*-helvetica-bold-o-normal--*-180-75-75-*-*-iso8859-1"
  120. #define IFIXEDFONTG  "-*-courier-medium-o-normal--*-180-75-75-*-*-iso8859-1"
  121. #define BFIXEDFONTG  "-*-courier-bold-r-normal--*-180-75-75-*-*-iso8859-1"
  122. #define BIFIXEDFONTG "-*-courier-bold-o-normal--*-180-75-75-*-*-iso8859-1"
  123. #define RFIXEDFONTG  "-*-courier-medium-r-normal--*-180-75-75-*-*-iso8859-1"
  124. #define SYMFONTG     "-*-symbol-medium-r-normal--*-240-75-75-*-*-*-*"
  125. #define SUBSYMFONTG  "-*-symbol-medium-r-normal--*-180-75-75-*-*-*-*"
  126. #define IMG_WIDTH 32
  127. #define IMG_HEIGHT 32
  128. #define IMG_INDICATOR 3
  129. /* fonts are held in an array to allow them to be identified by a 4 bit index */
  130. /*#define FONTS          16*/
  131. #define IDX_H1FONT              0
  132. #define IDX_H2FONT              1
  133. #define IDX_H3FONT              2
  134. #define IDX_H4FONT              3
  135. #define IDX_LABELFONT           4
  136. #define IDX_NORMALFONT          5
  137. #define IDX_INORMALFONT         6
  138. #define IDX_BNORMALFONT         7
  139. #define IDX_BINORMALFONT        8
  140. #define IDX_FIXEDFONT           9
  141. #define IDX_IFIXEDFONT         10
  142. #define IDX_BFIXEDFONT         11
  143. #define IDX_BIFIXEDFONT        12
  144. #define IDX_SMALLFONT          13
  145. #define IDX_SYMBOLFONT         14
  146. #define IDX_SUBSYMFONT         15
  147. /*
  148. The paint stream consists of a sequence of overlapping frames:
  149.     a) TextLines which contain elements appearing on a single line
  150.        e.g. STRING, LITERAL, RULE, BULLET, IMAGE. The TextLine
  151.        is large enough to contain all objects on the line. TextLines
  152.        never overlap except when they occur in different frames.
  153.     b) Frames which contain TextLines and other Frames
  154.        (used for figures, tables and sidebars)
  155. Frames are designed for efficient painting and scrolling,
  156. regardless of the length of a document. The frames are strictly
  157. ordered with respect to increasing pixel offset from the top of
  158. the document. Objects with the same offset are sorted with
  159. respect to increasing indent.
  160. This property is vital to the scrolling and painting
  161. mechanism. The ordering may be broken for elements within LINEs,
  162. for which a left to right ordering following that in the HTML
  163. source simplifies the Find menu action.
  164. FRAMEs are broken into BEGIN and END frame objects. The END frame
  165. objects are positioned in the sequence according the offset at
  166. which the frames end. This is needed to safely terminate search
  167. for objects which intersect the top of the window, when scrolling
  168. back through the document.
  169. */
  170. #define TEXTLINE    11   /* frame containing elements on a line */
  171. #define BEGIN_FRAME 12   /* begining of a frame */
  172. #define END_FRAME   13   /* end of a frame */
  173. #ifdef STYLE_COLOR_BORDER
  174. #define FRAME_STLEN  18  /* number of bytes in start of frame marker */
  175. #else
  176. #define FRAME_STLEN  17  /* number of bytes in start of frame marker */
  177. #endif
  178. #ifdef STYLE_BACKGROUND
  179. #define FRAMESTLEN (FRAME_STLEN+POINTERSIZE)
  180. #else
  181. #define FRAMESTLEN FRAME_STLEN
  182. #endif
  183. #define FRAMENDLEN  5   /* number of bytes in end of frame marker */
  184. #define TXTLINLEN   11  /* number of bytes in TEXTLINE header */
  185. /* parameters in frame-like objects:
  186. Each object starts with an 8 bit tag and ends with a 2 byte
  187. size field that permits moving back up the list of objects.
  188. The size is set to the number of bytes from the tag up to
  189. the size field itself.
  190.     tag = BEGIN_FRAME
  191.     offset (4 bytes)
  192.     indent (2 bytes)
  193.     width  (2 bytes)
  194.     height (4 bytes)
  195.     style  (1 byte)
  196.     border (1 byte)
  197. #ifdef STYLE_COLOR_BORDER
  198.     color_border (1 byte)
  199. #endif
  200. #ifdef STYLE_BACKGROUND
  201.     background pointer (4 or 8 bytes)
  202. #endif
  203.     length (2 bytes)
  204.     zero or more elements
  205.     size   (2 bytes)
  206. The length parameter gives the number of bytes until
  207. the end of the frame's data. It is used to skip quickly
  208. to objects following this frame. This requires a simple
  209. stack in DisplayHTML() to handle nested frames.
  210. The pixel offset for the end of the frame is marked by
  211. the END_FRAME object which specifies the number of bytes
  212. back to the corresponding BEGIN_FRAME object.
  213.     tag = END_FRAME
  214.     start  (2 bytes)
  215.     size   (2 bytes)
  216. A frame for a line of text composed of multiple elements:
  217. TEXTLINE:
  218.     tag == TEXTLINE
  219.     offset (4 bytes)
  220.     baseline (two bytes)
  221.     indent (two bytes)
  222.     height (two bytes)
  223.     zero or more elements
  224.     1 byte marker (= 0)
  225.     size (two bytes)
  226. */
  227. /*
  228. When parsing, we need to defer printing the END_FRAME marker
  229. until we come to print an object with the same or larger offset
  230. and at the same level of frame nesting. We also need to examine
  231. the widths and position of active frames to decide where to flow
  232. text and graphics. In this phase the Frame struct only uses
  233. the next, nesting, info and offset fields.
  234. When displaying, we need a list of frames which intersect the
  235. top of the window, plus a pointer to the background flow. Once
  236. this list has been dealt with, display continues in the background
  237. flow and subsequent frames are dealt with one at a time.
  238. When scrolling towards the start of the document, the code needs
  239. to take care in case a text line object intersects the top of
  240. the window, otherwise the first fully visible line will do.
  241. */
  242. struct frame_struct
  243.     {
  244.         struct frame_struct *next;  /* linked list of peer frames */
  245.         struct frame_struct *child; /* linked list of nested frames */
  246.         unsigned char *top;         /* where to start displaying from */
  247.         long offset;                /* from start of document */
  248.         unsigned int indent;        /* from left of document */
  249.         long height;                /* documents can be very long */
  250.         unsigned int width;
  251.         int leftmargin;             /* indent from lhs of frame */
  252.         int rightmargin;            /* indent from rhs of frame */
  253.         unsigned int info;    /* to BEGIN_FRAME object in paint stream */
  254.         unsigned int length;        /* byte count of frame's data */
  255.         unsigned int lastrow;       /* used in parsing tables */
  256.         unsigned char style;        /* frame's background style */
  257.         unsigned char border;       /* frame's border style */
  258.         int flow;    /* ALIGN_LEFT, ALIGN_NOTE, ALIGN_CENTER or ALIGN_RIGHT */
  259.         int oldmargin;     /* previous value of parent's margin */
  260.         int pushcount;     /* save count value for restore */
  261.         int leftcount;     /* of frames with ALIGN_LEFT or ALIGN_NOTE */
  262.         int rightcount;    /* of frames with ALIGN_RIGHT */
  263.         box_link *box_list; /* a generalization of the previous push/restore margin */
  264. #ifdef STYLE_COLOR
  265. Byte cb_ix;     /* howcome 15/3/95: the index to the forgrround color of tables etc */
  266. #endif
  267.     };
  268. typedef struct frame_struct Frame;
  269. /* stack of nested frames starting after top of windo */
  270. typedef struct sframe_struct
  271.     {
  272.         unsigned char *p_next;
  273.         unsigned char *p_end;
  274.     } StackFrame;
  275. /* elements which can appear in a TEXTLINE & must be non-zero */
  276. #define STRING      1       /* tag name for string values */
  277. #define BULLET      2       /* tag name for bullet */
  278. #define RULE        3       /* horizontal rule */
  279. #define SEQTEXT     4       /* explicit text, e.g. "i)" */
  280. #define IMAGE       5       /* a pixmap (character-like) */
  281. #define INPUT       6       /* text input field */
  282. #define LINE        7       /* staalesc: line */
  283. #ifdef STYLE_COLOR
  284. #define RULE_FLEN 8
  285. #else
  286. #define RULE_FLEN 7
  287. #endif
  288. #ifdef STYLE_BACKGROUND
  289. #define RULEFLEN (POINTERSIZE + RULE_FLEN)
  290. #else
  291. #define RULEFLEN    RULE_FLEN
  292. #endif
  293. #ifdef STYLE_COLOR
  294. #define LINE_FLEN 10
  295. #else
  296. #define LINE_FLEN 9
  297. #endif
  298. #ifdef STYLE_BACKGROUND
  299. #define LINEFLEN (POINTERSIZE + LINE_FLEN)
  300. #else
  301. #define LINEFLEN LINE_FLEN
  302. #endif
  303. #ifdef STYLE_COLOR
  304. #define BULLET_FLEN  8 
  305. #else
  306. #define BULLET_FLEN  7
  307. #endif
  308. #ifdef STYLE_BACKGROUND
  309. #define BULLETFLEN (BULLET_FLEN + POINTERSIZE)
  310. #else
  311. #define BULLETFLEN BULLET_FLEN
  312. #endif
  313. #ifdef STYLE_COLOR
  314. #define STRING_FLEN  (12 + POINTERSIZE + POINTERSIZE)     /* must bold 8byte Pointers wm 20.Jan.95 */
  315. #else
  316. #define STRING_FLEN  (11 + POINTERSIZE + POINTERSIZE)     /* must bold 8byte Pointers wm 20.Jan.95 */
  317. #endif
  318. #ifdef STYLE_BACKGROUND
  319. #define IMAGEFLEN (9+3*POINTERSIZE)
  320. #define INPUTFLEN (1+2*POINTERSIZE)
  321. #define STRINGFLEN (STRING_FLEN + POINTERSIZE)
  322. #else
  323. #define IMAGEFLEN (13+POINTERSIZE)
  324. #define INPUTFLEN (1+POINTERSIZE)
  325. #define STRINGFLEN STRING_FLEN
  326. #endif
  327. #ifdef STYLE_BACKGROUND
  328. #define SEQTEXTLEN (POINTERSIZE+9)
  329. #else
  330. #define SEQTEXTLEN 9
  331. #endif
  332. #ifdef STYLE_COLOR
  333. #define SEQTEXTFLEN(len) (SEQTEXTLEN+ 1 + len) /* JS 9.6.95 was 9 */
  334. #else
  335. #define SEQTEXTFLEN(len) (SEQTEXTLEN+ 1 + len) /* JS 9.6.95 was 7 */
  336. #endif
  337. #define B_SIZE 10 /* 6 */     /* size of bullet graphic */
  338. #ifndef max
  339. #define max(a, b)   ((a) > (b) ? (a) : (b))
  340. #define min(a, b)   ((a) < (b) ? (a) : (b))
  341. #endif
  342. #define str_cmp(a, b) ((a && b) ? strcasecmp(a, b) : (a || b))
  343. #define CHWIDTH(font)    XTextWidth(Fonts[font], " ", 1)
  344. #define SPACING(font)    (2 + font->max_bounds.ascent + font->max_bounds.descent)
  345. #define BASELINE(font)   (1 + font->max_bounds.ascent)
  346. #define STRIKELINE(font) (font->max_bounds.ascent - font->max_bounds.descent + 1)
  347. #define LINETHICKNESS(font) (1 + font->ascent / 10)
  348. #define ASCENT(font)     (1 + Fonts[font]->max_bounds.ascent)
  349. #define DESCENT(font)    (1 + Fonts[font]->max_bounds.descent)
  350. #define WIDTH(font, str, len) XTextWidth(Fonts[font], str, len)
  351. #define EMPH_NORMAL      0
  352. /*#define EMPH_ANCHOR     (1 << 0)*/
  353. #define EMPH_UNDERLINE  (1 << 1)
  354. #define EMPH_STRIKE     (1 << 2)
  355. #define EMPH_HIGHLIGHT  (1 << 3)
  356. #define EMPH_OVERLINE   (1 << 4)
  357. #define EMPH_OVERLARR (1 << 5)
  358. #define EMPH_OVERRARR (1 << 6)
  359. #define EMPH_OVERTILDE (1 << 7)
  360. #define EMPH_OVERHAT (1 << 8)
  361. #define EMPH_OVERDOT    (1 << 9)
  362. #define EMPH_OVERDDOT   (1 << 10)
  363. #define EMPH_UNDERLARR (1 << 11)
  364. #define EMPH_UNDERRARR (1 << 12)
  365. #define EMPH_UNDERTILDE (1 << 13)
  366. #define EMPH_UNDERHAT (1 << 14)
  367. #define EMPH_ROOTLINE (1 << 15)
  368. /* --Spif */
  369. #define EMPH_INPUT      0x50 /* many crashes.. so ANCHOR || 0x40 ... ;) --Spif */
  370. /* note that PRE_TEXT is passed to display code with tag *not* emph */
  371. #define EMPH_ANCHOR     0x10
  372. #define ISMAP           0x80
  373. #define PRE_TEXT        0x80     /* implies preformatted text */
  374. #define GROOVE          0x80     /* draw horizontal rule as 3d groove */
  375. #define HLINE           0x40     /* width instead of right coord */
  376. #define IsWhite(c)  (c == ' ' || c == 'n' || c == 't' || c == 'f' || c == 'r')
  377. /* imaging capability */
  378. typedef struct
  379.     {
  380.         unsigned char red;
  381.         unsigned char green;
  382.         unsigned char blue;
  383.         unsigned char grey;
  384.     } Color;
  385. #define COLOR888    888     /* DirectColor 24 bit systems */
  386. #define COLOR444    444     /* DirectColor 12 bit systems */
  387. #define COLOR232    232     /* 128 shared colors from default visual */
  388. #define GREY4        4      /* 16 shared colors from default visual */
  389. #define MONO         1      /*  when all else fails */
  390. #define BUTTONUP     1      /* used by WhichAnchor() */
  391. #define BUTTONDOWN   2
  392. #define MOVEUP       3      /* Mouse move in button up state */
  393. #define MOVEDOWN     4      /* Mouse move in button down state */
  394. /*--------------------------------------------------------------------------------------*/
  395. /* document tags */
  396. /*
  397. #define REMOTE  0
  398. #define LOCAL   1
  399. */
  400. /* GATEWAY isn't a tag but is used with
  401.    REMOTE in calls to GetAuthorization */
  402. #define GATEWAY 5
  403. /* document types */
  404. #define TEXT_DOCUMENT    "text/plain"
  405. #define HTML_DOCUMENT    "text/html"
  406. #define HTML3_DOCUMENT   "text/x-html3"
  407. #define HTML_LEVEL3_DOCUMENT   "text/html; level=3"
  408. #define GIF_DOCUMENT     "image/gif"
  409. #define JPEG_DOCUMENT    "image/jpeg"
  410. #define PNG_DOCUMENT     "image/png"
  411. #define PNG_EXP_DOCUMENT "image/x-png"
  412. #define XPM_DOCUMENT     "image/x-xpixmap"
  413. #define XBM_DOCUMENT     "image/x-xbitmap"
  414. /* useful macro for freeing heap strings */
  415. #define Free(s)    {if (s) free(s); s = NULL;};  
  416. /* Block structure used to simulate file access */
  417. typedef struct memblock_struct
  418.         {
  419.                 char *buffer;
  420.                 size_t next;
  421.                 size_t size;
  422.         } Block;
  423. /* Doc structure used for new and current document */
  424. /* the html token codes, form parsehtml.c */
  425. #define ENTITY          -4
  426. #define WHITESPACE      -3     /* the specific char */
  427. #define PCDATA          -2     /* the specific char */
  428. #define ENDDATA         -1
  429. #define ENDTAG          (1<<7) /*  ORed with TAG code */
  430. #define IsTag(tag)      (tag >= 0)
  431. #define UNKNOWN         0
  432. #define TAG_ANCHOR      1       /* EN_TEXT */
  433. #define TAG_BOLD        2       /* EN_TEXT */
  434. #define TAG_DL          3       /* EN_LIST */
  435. #define TAG_DT          4       /* EN_DEFLIST */
  436. #define TAG_DD          5       /* EN_DEFLIST */
  437. #define TAG_H1          6       /* EN_HEADER */
  438. #define TAG_H2          7       /* EN_HEADER */
  439. #define TAG_H3          8       /* EN_HEADER */
  440. #define TAG_H4          9       /* EN_HEADER */
  441. #define TAG_H5          10      /* EN_HEADER */
  442. #define TAG_H6          11      /* EN_HEADER */
  443. #define TAG_ITALIC      12      /* EN_TEXT */
  444. #define TAG_IMG         13      /* EN_TEXT */
  445. #define TAG_LI          14      /* EN_LIST */
  446. #define TAG_OL          15      /* EN_LIST */
  447. #define TAG_P           16      /* EN_BLOCK */
  448. #define TAG_TITLE       17      /* EN_SETUP */
  449. #define TAG_UNDERLINE   18      /* EN_TEXT */
  450. #define TAG_UL          19      /* EN_LIST */
  451. #define TAG_HEAD        20      /* EN_SETUP */
  452. #define TAG_BODY        21      /* EN_MAIN */
  453. #define TAG_HR          22      /* EN_BLOCK */
  454. #define TAG_ADDRESS     23      /* EN_BLOCK */
  455. #define TAG_BR          24      /* EN_TEXT */
  456. #define TAG_STRIKE      25      /* EN_TEXT */
  457. #define TAG_PRE         26      /* EN_BLOCK */
  458. #define TAG_CITE        27      /* EN_TEXT */
  459. #define TAG_CODE        28      /* EN_TEXT */
  460. #define TAG_TT          29      /* EN_TEXT */
  461. #define TAG_EM          30      /* EN_TEXT */
  462. #define TAG_STRONG      31      /* EN_TEXT */
  463. #define TAG_KBD         32      /* EN_TEXT */
  464. #define TAG_SAMP        33      /* EN_TEXT */
  465. #define TAG_DFN         34      /* EN_TEXT */
  466. #define TAG_Q           35      /* EN_TEXT */
  467. #define TAG_QUOTE       36      /* EN_BLOCK */
  468. #define TAG_ISINDEX     37      /* EN_SETUP */
  469. #define TAG_FIG         38      /* EN_BLOCK */
  470. #define TAG_INPUT       39      /* EN_TEXT */
  471. #define TAG_SELECT      40      /* EN_TEXT */
  472. #define TAG_OPTION      41      /* EN_TEXT */
  473. #define TAG_TEXTAREA    42      /* EN_TEXT */
  474. #define TAG_TABLE       43      /* EN_BLOCK */
  475. #define TAG_TR          44      /* EN_TABLE */
  476. #define TAG_TH          45      /* EN_TABLE */
  477. #define TAG_TD          46      /* EN_TABLE */
  478. #define TAG_CAPTION     47      /* EN_BLOCK */
  479. #define TAG_ADDED       48      /* EN_TEXT */
  480. #define TAG_REMOVED     49      /* EN_TEXT */
  481. #define TAG_MATH        50      /* EN_TEXT */
  482. #define TAG_MARGIN      51      /* EN_TEXT */
  483. #define TAG_ABSTRACT    52      /* EN_BLOCK */
  484. #define TAG_BLOCKQUOTE  53      /* EN_BLOCK */
  485. #define TAG_VAR         54      /* EN_TEXT */
  486. #define TAG_BASE        55      /* EN_SETUP */
  487. #define TAG_SUP         56      /* EN_TEXT */
  488. #define TAG_SUB         57      /* EN_TEXT */
  489. #define TAG_SMALL       58      /* EN_TEXT */
  490. #define TAG_NOTE        59      /* EN_BLOCK */
  491. #define TAG_ALT         60      /* EN_BLOCK */
  492. #define TAG_STYLE       61      /* EN_SETUP */ /* howcome 26/2/95 */
  493. #define TAG_LINK 62 /* EN_SETUP */ /* howcome 25/4/95 */
  494. #define TAG_OVERLINE    63      /* MATH */
  495. #define TAG_HTML_SOURCE 64 /* 1/7/95: HTML source display, for use with style sheets */
  496. /* #define TAG_ALL 65 */ /* howcome 7/3/95: for use in style.c */
  497. #define TAG_HTML 65 /* howcome 27/8/85: for use in style.c */
  498. #define TAG_LAST        66 /* howcome 21/8/95: to know the size of element array */
  499. #define TAG_FORM        67      /* --Spif 10/10/95: forms (needed to build form structure) */
  500. /* style.c */
  501. #define   S_FONT_FAMILY_HELVETICA 1
  502. #define   S_FONT_FAMILY_TIMES 2
  503. typedef enum _StyleProperty {
  504.     S_UNKNOWN, 
  505.     S_FONT,
  506.     S_FONT_SHORTHAND,
  507.     S_FONT_FAMILY,
  508.     S_FONT_SIZE, /* converted into pixels */
  509.     S_FONT_WEIGHT,
  510.     S_FONT_STYLE,
  511.     S_FONT_LEADING, /* 8 */
  512.     S_COLOR,
  513.     S_BACKGROUND,
  514.     S_BACKGROUND_BLEND,
  515.     S_BACK_STYLE,
  516.     S_WORD_SPACING,
  517.     S_TEXT_SPACING,
  518.     S_TEXT_DECORATION,
  519.     S_TEXT_POSITION,
  520.     S_TEXT_TRANSFORM,
  521.     S_TEXT_EFFECT,
  522.     S_ALT_FONT,
  523.     S_ALT_FONT_SHORTHAND,
  524.     S_ALT_FONT_FAMILY,
  525.     S_ALT_FONT_SIZE,
  526.     S_ALT_FONT_WEIGHT,
  527.     S_ALT_FONT_STYLE,
  528.     S_ALT_FONT_LEADING,
  529.     S_ALT_COLOR,
  530.     S_ALT_BACKGROUND,
  531.     S_ALT_TEXT_SPACING,
  532.     S_ALT_TEXT_DECORATION,
  533.     S_ALT_TEXT_POSITION,
  534.     S_ALT_TEXT_TRANSFORM,
  535.     S_MARGIN_TOP,
  536.     S_MARGIN_RIGHT,
  537.     S_MARGIN_BOTTOM,
  538.     S_MARGIN_LEFT,
  539.     S_MARGIN_SHORTHAND,
  540.     S_ALIGN,
  541.     S_INDENT,
  542.     S_WIDTH,
  543.     S_HEIGHT,
  544. /* properties for internal use */
  545.     S_SMALL_CAPS_FONT,
  546. /* new css1 properties */
  547.     S_PADDING,
  548.     S_NPROPERTY
  549. } StyleProperty;
  550. /* howcome 22/3/95: added strengths for Arena style sheets */
  551. #define S_USER_DELTA 20
  552. #define S_DOC_DELTA 20
  553. #define S_INHERIT_MINUS 1
  554. #define S_max 0 /* used by skyblue.c */
  555. #define S_LENS 10
  556. #define S_USER_INSIST    20
  557. #define S_DOC_IMPORTANT  30
  558. #define S_USER_IMPORTANT 40
  559. #define S_DOC 50
  560. #define S_USER 40
  561. #define S_FALLBACK       30
  562. #define S_min 80 /* used by skyblue.c */
  563. #define S_SPECIFIC 0
  564. #define S_WILDCARD 1
  565. #define S_ANY 2
  566. #define S_BACKGROUND_COLOR 1
  567. #define S_BACKGROUND_IMAGE 2
  568. #define S_BACKGROUND_FIXED 4
  569. #define S_BACKGROUND_X_REPEAT 8
  570. #define S_BACKGROUND_Y_REPEAT 16
  571. #define S_BACKGROUND_ORIGIN 32
  572. typedef struct s_variable {
  573.     long value;
  574.     int strength;
  575. } *Variable;
  576. typedef struct s_style_elem {
  577.     int tag;
  578.     int influence;
  579.     char *class;
  580.     HTList *pattern;
  581.     struct s_style_elem *parent;
  582.     HTList *children;
  583.     Variable var[S_NPROPERTY];
  584.     
  585.     Bool flattened;
  586.     Bool computed[S_NPROPERTY];
  587.     long value[S_NPROPERTY];
  588. } StyleElem;
  589. #define F_FAMILY_SYMBOL 1
  590. #define F_FAMILY_HELVETICA 2
  591. #define F_FAMILY_TIMES 3
  592. #define F_FAMILY_COURIER 4
  593. #define F_FAMILY_TERMINAL 5
  594. #define F_FAMILY_FIXED 6
  595. #define F_FAMILY_CHARTER 7
  596. #define F_FAMILY_LUCIDA 8
  597. #define F_FAMILY_LUCIDABRIGHT 9
  598. #define F_FAMILY_NCS 10
  599. #define FONT_WEIGHT_NORMAL          0x0
  600. #define FONT_WEIGHT_LIGHT 0x1
  601. #define FONT_WEIGHT_MEDIUM 0x2
  602. #define FONT_WEIGHT_DEMIBOLD 0x3
  603. #define FONT_WEIGHT_BOLD 0x4
  604. #define FONT_WEIGHT_BLACK 0x5
  605. #define FONT_STYLE_NORMAL 0x0
  606. #define FONT_STYLE_ITALIC 0x1
  607. #define FONT_STYLE_ROMAN 0x2
  608. #define FONT_STYLE_OBLIQUE 0x3
  609. #define FONT_STYLE_UPRIGHT 0x4
  610. #define FONT_STYLE_SMALL_CAPS 0x5
  611. #define TEXT_EFFECT_NONE 0x0
  612. #define TEXT_EFFECT_INITIAL_CAP 0x1
  613. #define TEXT_EFFECT_DROP_CAP 0x2
  614. #define TEXT_EFFECT_ALT_FIRSTLINE 0x3
  615. #define TEXT_LINE_BLINK 0x1
  616. #define TEXT_TRANSFORM_NONE 0x0
  617. #define TEXT_TRANSFORM_CAPITALIZE 0x1
  618. #define TEXT_TRANSFORM_UPPERCASE        0x2
  619. #define TEXT_TRANSFORM_LOWERCASE 0x3
  620. #define F_SMALLCAPS_IGNORE 0x0
  621. #define F_SMALLCAPS_OFF 0x1
  622. #define F_SMALLCAPS_ON 0x2
  623. #define F_BIGINITIAL_IGNORE 0x0
  624. #define F_BIGINITIAL_OFF 0x1
  625. #define F_BIGINITIAL_ON 0x2
  626. #define F_DROPPED_IGNORE 0x0
  627. #define F_DROPPED_OFF 0x1
  628. #define F_DROPPED_ON 0x2
  629. #define VALUE_ABSOLUTE 1
  630. #define VALUE_ADD 2
  631. #define VALUE_MULTIPLY 3
  632. #define VALUE_TRANSPARENT  4
  633. #define I_NORMAL 0
  634. #define I_IMPORTANT 1 
  635. #define I_INSIST 2
  636. #define I_LEGAL 3
  637. #define S_ADDRESSING_SINGLE 0
  638. #define S_ADDRESSING_SEQUENTIAL 1
  639. #define S_ADDRESSING_HIERARCHICAL 2
  640. /* new style.h */
  641. typedef enum {
  642.     StringVal,                  /* Simple value: a string */
  643.     NumVal,     /* Simple value: a number */
  644.     KeyVal,     /* Simple value: a keyword */
  645.     PlusVal,     /* `+' */
  646.     MinusVal,     /* `-' */
  647.     TimesVal,     /* `*' */
  648.     DivVal,     /* `/' */
  649.     ListVal,     /* left=head, right=tail */
  650.     InterLoVal,     /* `<<' */
  651.     InterHiVal     /* '>>' */
  652. } ValTp;
  653. typedef union _Value {
  654.     ValTp tp;
  655.     char *str;                  /* Only if tp = StringVal */
  656.     float num;     /* Only if tp = NumVal */
  657.     char *key;     /* Only if tp = KeyVal */
  658.     union _Value *left, *right; /* Otherwise */
  659. } *Value;
  660. #define val2num(v) (assert(v && v->tp == NumVal), v->num)
  661. #define val2str(v) (assert(v && v->tp == StringVal), v->str)
  662. #define val2key(v) (assert(v && v->tp == KeyVal), v->key)
  663. #define val2head(v) (assert(v && v->tp == ListVal), v->left)
  664. #define val2tail(v) (assert(v && v->tp == ListVal), v->right)
  665. typedef struct _StyleSelectorUnit {
  666.     int element;                  /* GI or class */
  667.     char *class;     /* or None */
  668. /*     AttribSpec attr; */
  669. } StyleSelectorUnit;
  670. typedef struct _StyleSelector {
  671.     StyleSelectorUnit unit;
  672.     int specificity;
  673.     struct _StyleSelector *pred;
  674.     struct _StyleSelector *ancestor;
  675. } StyleSelector;
  676. typedef struct _StyleRule {
  677.     StyleSelector *selector;
  678.     StyleProperty property;
  679.     long value;
  680. /*    Value expr; */
  681.     int weight;
  682.     char *warning;
  683. } StyleRule;
  684. typedef struct _AttribSpec {
  685.     char *name;
  686.     Value val;
  687.     struct _AttribSpec *next;
  688. } *AttribSpec;
  689. #if 0
  690. typedef struct _Weight {      /* E.g., !legal "WBvS art. 36.5" */
  691.     int value;                   /* 0 (default) - 3 (!legal) */
  692.     char *warning;
  693. } Weight;
  694. #endif
  695. typedef struct _StyleSheet {
  696.     BOOL initial_flag;
  697.     BOOL leading_flag;
  698.     BOOL indent_flag;
  699.     BOOL margin_top_flag;
  700.     HTList *element[TAG_LAST]; /* element is the entry point in the style sheet */
  701. } StyleSheet;
  702. #define S_INITIAL_FLAG 0x4
  703. #define S_LEADING_FLAG 0x5
  704. #define S_INDENT_FLAG 0x6
  705. #define S_MARGIN_TOP_FLAG 0x7
  706. #define S_UNSET 0x0
  707. #define S_INITIALIZED 0x1
  708. #define S_INHERITED 0x2
  709. #define S_INFERRED 0x3
  710. typedef struct _StyleFlat {
  711.     long value[S_NPROPERTY];
  712.     int weight[S_NPROPERTY];
  713.     Byte status[S_NPROPERTY]; /* S_UNSET, S_INITIALIZED,  S_INFERRED, S_INHERITED */
  714. } StyleFlat;
  715. typedef struct _StyleStackElement {
  716.     StyleSelectorUnit unit;
  717.     StyleFlat *flat;
  718. } StyleStackElement;
  719. /* end new style.h */
  720. /* the main document structure */
  721. #define DOC_NOTREGISTERED 0
  722. #define DOC_PENDING 1
  723. #define DOC_LOADED 2
  724. #define DOC_PROCESSED 3
  725. #define DOC_ABORTED 4
  726. #define DOC_REJECTED 5  /* e.g. if image can't be decoded */
  727. #define DOC_EXTERNAL 6  /* externally viewed */
  728. typedef struct s_doc
  729. {
  730.     HTRequest *request;
  731.     HTParentAnchor *anchor;
  732.     char *href; /* as found in the <a href > construct, must be freed */
  733.     char *url; /* points into anchor structure */
  734.     char *title;
  735.     char *content_buffer;
  736.     char *tag; /* current tag pointing into history stack */
  737.     char *link_style;
  738.     char *head_style;
  739.     char *base;
  740.     StyleSheet *style;
  741.     long loaded_length;
  742.     long parsed_lenght;
  743.     unsigned int height, width;
  744.     int state;  /* DOC_NOREGISTER DOC_PENDING, DOC_LOADED, DOC_PROCESSED, */
  745. /*    struct s_doc *old_doc;*/
  746.     BOOL pending_reload;       /* the document is being reloaded and should be freed when the fresh copy comes in */
  747.     BOOL nofree;
  748.     BOOL main_doc;             /* main doc, as opposed to inline doc */
  749.     BOOL user_style;  /* the document contains the user's preferred style sheet */
  750.     HTList *host_anchors;        /* if inline: list of hosts where referenced */
  751.     HTList *inline_anchors;       /* if host doc: list of inline docs, if inline: list of hosts */
  752.     BOOL show_raw;             /* for html docs, show raw data? */
  753.     Image *image;              /* if doc is an image */
  754.     char *paint_stream;
  755.     long paint_lenght;
  756.     EditorBuffer *source_editor;
  757.     EditorBuffer *field_editor;
  758.     Field *edited_field;
  759.     HTList *bad_flags;
  760.     BOOL already_displayed;
  761. } Doc;
  762. /* history.c */
  763. #define HISTORY_NOTREGISTERED 0
  764. #define HISTORY_REGISTERED 1
  765. #define HISTORY_VERIFIED 2
  766. #define HISTORY_DELETED 3
  767. typedef struct s_history
  768. {
  769.     int state; 
  770.     HTAnchor *anchor;
  771.     char *tag;
  772.     long y;
  773.     char *title;
  774.     /* time etc */
  775. } History;
  776. typedef struct s_context
  777. {
  778.     HTList *registered_anchors;
  779. #if 0
  780.     HTList *pending_docs;
  781.     HTList *pending_anchors;
  782. #endif
  783.     HTList *reqs;
  784.     HTList *conversions;
  785.     HTParentAnchor *home_anchor;
  786.     StyleSheet *style;
  787.     HTList *history;
  788.     int history_pos; /* position in linked list */ /* probably obsolete now that list hav both previous and next */
  789.     History *current_history;
  790.     HTList *memory_leaks;
  791. } Context;
  792. #define TABSIZE         8
  793. /* codes returned by button down handlers to indicate
  794.    interest in receiving the corresponding button up event */
  795. #define VOID            0
  796. #define WINDOW          1
  797. #define SCROLLBAR       2
  798. #define TOOLBAR         3
  799. #define STATUS          4
  800. typedef struct s_button
  801.     {
  802.         int x;
  803.         int y;
  804.         unsigned int w;
  805.         unsigned int h;
  806.         char *label;
  807.     } Button;
  808. #if 0
  809. /* constraints.c */
  810. void set_variable_with_strength(Variable var, long val, Strength strength);
  811. void set_variable(Variable var, long val);
  812. #endif
  813. /* www.c */
  814. int GuiEvents(int s, HTRequest * rq, int f);
  815. int CloneSelf(void);
  816. void Redraw(int x, int y, int w, int h);
  817. void SetBanner(char *title);
  818. void PollEvents(int block);
  819. void BackDoc();
  820. int Exit(int); /* wm 18.Jan.95 Exit exits value, must be int not void */
  821. Context *NewContext();
  822. void ShowBusy();
  823. void HideBusy();
  824. void SetSelection(char *s);
  825. int GetColor(int red, int green, int blue, unsigned long *pix);
  826. /* file.c */
  827. char *Uncompress(char *buf, long *len);
  828. int HasXVSuffix(char *name);
  829. int NewDocumentType(void);
  830. char *ParentDirCh(char *dir);
  831. char *GetFile(char *name);
  832. char *CurrentDirectory(void);
  833. /* display.c */
  834. #define StatusTop (ToolBarHeight)
  835. #define StatusFontOffset 5
  836. #define ToolbarTop 5
  837. #define WinTop    (ToolBarHeight + statusHeight)  /* howcome 7/10/94 */
  838. #define WinBottom (win_height - sbar_width) /* howcome 7/10/94 */
  839. #define WinWidth  (win_width - sbar_width)
  840. #define WinHeight (WinBottom - WinTop)
  841. #define WinLeft   0
  842. #define WinRight (WinLeft + WinWidth)
  843. #define Abs2Win(n) (WinTop + n - PixelOffset)
  844. #define Win2Abs(n) ((long)n + PixelOffset - WinTop)
  845. void SetDisplayWin(Window aWin);
  846. void SetDisplayGC(GC aGC);
  847. void SetDisplayFont(XFontStruct *pFont_info);
  848. void SetColor(GC gc, int color_text_ix, int color_background_ix);
  849. void SetFont(GC gc, int fontIndex);
  850. void SetEmphFont(GC gc, XFontStruct *pFont, XFontStruct *pNormal);
  851. void NewBuffer(Doc *d);
  852. void DisplaySizeChanged(int all);
  853. void DisplayAll();
  854. Image *ProcessLoadedImage(Doc *doc);
  855. char *TextLine(char *txt);
  856. long CurrentHeight(char *buf);
  857. /*long DocHeight(char *buf, int *width);*/
  858. void DocDimension(Doc *doc, int *width, long *height);
  859. int LineLength(char *buf);
  860. int DeltaTextPosition(long h);
  861. void MoveVDisplay(long h);
  862. void MoveHDisplay(int indent);
  863. void MoveLeftLine();
  864. void MoveRightLine();
  865. void MoveLeftPage();
  866. void MoveRightPage();
  867. void MoveToLeft();
  868. void MoveToRight();
  869. void MoveUpLine();
  870. void MoveDownLine();
  871. void MoveUpPage();
  872. void MoveDownPage();
  873. void MoveToStart();
  874. void MoveToEnd();
  875. void SlideHDisplay(int slider, int scrollExtent);
  876. void SlideVDisplay(int slider, int scrollExtent);
  877. void DisplayDoc(int x, int y, unsigned int w, unsigned int h);
  878. void FindString(char *pattern, char **next);
  879. void ToggleView(void);
  880. /* scrollbar.c */
  881. void SetScrollBarHPosition(int indent, int buffer_width);
  882. void SetScrollBarVPosition(long offset, long buf_height);
  883. void SetScrollBarWidth(int buffer_width);
  884. void SetScrollBarHeight(long buff_height);
  885. void SetScrollBarWin(Window aWin);
  886. void SetScrollBarGC(GC aGC);
  887. int ScrollButtonDown(int x, int y);
  888. void ScrollButtonUp(int x, int y);
  889. void ScrollButtonDrag(int x, int y);
  890. void MoveHSlider(int indent, int buffer_width);
  891. void MoveVSlider(long offset, long buf_height);
  892. void DisplaySlider();
  893. void DisplayScrollBar();
  894. int AtStart(long offset);
  895. int AtEnd(long offset);
  896. int AtLeft(int indent);
  897. int AtRight(int indent);
  898. /* status.c */
  899. void SelectStatus(int x_in, int y_in);
  900. void ClearStatusSelection();
  901. void HideAuthorizeWidget();
  902. void ShowAbortButton(int n);
  903. int StatusButtonDown(int button, int x, int y);
  904. void StatusButtonUp(int x, int y);
  905. void Beep();
  906. void Announce(char *args, ...);
  907. void Warn(char *args, ...);
  908. void SetStatusWin(Window aWin);
  909. void SetStatusGC(GC aGC);
  910. void SetStatusFont(XFontStruct *pf);
  911. int StatusActive(void);
  912. void DrawOutSet(Window aWin, GC gc, int x, int y, unsigned int w, unsigned int h);
  913. void DrawInSet(Window aWin, GC gc, int x, int y, unsigned int w, unsigned int h);
  914. void DrawOutSetCircle(GC gc, int x, int y, unsigned int w, unsigned int h);
  915. void DrawInSetCircle(GC gc, int x, int y, unsigned int w, unsigned int h);
  916. void DisplayStatusBar();
  917. void SetStatusString(char *s);
  918. void ClearStatus();
  919. void RestoreStatusString(void);
  920. void SaveStatusString(void);
  921. int IsEditChar(char c);
  922. void EditChar(char c);
  923. void MoveStatusCursor(int key);
  924. void GetAuthorization(int mode, char *host);
  925. char *UserName(char *who);
  926. char *PassStr(char *who);
  927. /* toolbar.c */
  928. #define ICON_WIDTH 70
  929. #define ICON_HEIGHT (statusHeight + ToolBarHeight)
  930. void PaintVersion(int bad);
  931. void SetToolBarWin(Window aWin);
  932. void SetToolBarGC(GC aGC);
  933. void SetToolBarFont(XFontStruct *pf);
  934. void DisplayToolBar();
  935. int ToolBarButtonDown(int x, int y);
  936. void ToolBarButtonUp(int x, int y);
  937. void PrintDoc();
  938. void SaveDoc(char *file);
  939. void DisplayExtDocument(char *buffer, long length, int type, char *path);
  940. /* parsehtml.c */
  941. #define MAXVAL  1024
  942. /* alignment codes */
  943. #define ALIGN_TOP       0
  944. #define ALIGN_MIDDLE    1
  945. #define ALIGN_BOTTOM    2
  946. #define ALIGN_LEFT      3
  947. #define ALIGN_CENTER    4
  948. #define ALIGN_RIGHT     5
  949. #define ALIGN_JUSTIFY   6
  950. #define ALIGN_NOTE      7      /* used only for text flow mechanism */
  951. #define ALIGN_BLEEDLEFT 8
  952. #define ALIGN_BLEEDRIGHT 9
  953. /* entity classes */
  954. #define EN_UNKNOWN         0
  955. #define EN_TEXT         (1 << 0)
  956. #define EN_BLOCK        (1 << 1)
  957. #define EN_LIST         (1 << 2)
  958. #define EL_DEFLIST      (1 << 3)
  959. #define EN_HEADER       (1 << 4)
  960. #define EN_SETUP        (1 << 5)
  961. #define EN_MAIN         (1 << 6)
  962. #define EN_TABLE        (1 << 7)
  963. /* form actions --Spif 11-Oct-95 */
  964. #define GET             0
  965. #define POST            1
  966. /* input field types */
  967. #define TEXTFIELD       0x00
  968. #define CHECKBOX        0x10
  969. #define RADIOBUTTON     0x20
  970. #define OPTIONLIST      0x40
  971. #define SUBMITBUTTON    0x60
  972. #define RESETBUTTON     0x70
  973. #define HIDDEN          0x80
  974. #define PASSWD          0x90
  975. #define CHECKED         0x80    /* flags field as 'active' */
  976. #define IN_ERROR        0x40    /* field flagged as in error */
  977. #define DISABLED        0x20    /* field is greyed out */
  978. #define MULTIPLE        0x10    /* multiple selections are allowed */
  979. /* window margin and indents */
  980. #define MAXMARGIN       (win_width - sbar_width - 4)
  981. #define MININDENT       0 /* 4 */
  982. #define NESTINDENT      5
  983. #define GLINDENT        30
  984. #define OLINDENT        3
  985. #define LINDENT         8
  986. #define GLGAP           4
  987. typedef struct h_link
  988.         {
  989.             int x;
  990.             int y;
  991.             unsigned int w;
  992.             unsigned int h;
  993.             int continuation;
  994.             char *href;
  995.             int reflen;
  996.         } HyperLink;
  997. #define MAXLINKS        512
  998. /* structure for table widths - index from 1
  999.    upwards as zeroth entry used for book keeping */
  1000. typedef struct t_width
  1001.         {
  1002.             int left;
  1003.             int right;
  1004.             int min;   /* reused for row height in 2nd pass */
  1005.             int max;   /* we track min/max width of columns */
  1006.             int rows;  /* row span count for each column */
  1007.         } ColumnWidth;
  1008. /* store current/max number of columns in first element */
  1009. #define COLS(widths)    widths->min
  1010. #define MAXCOLS(widths) widths->max
  1011. #define NCOLS   15
  1012. int GetWord(char *p, int *len, int max);
  1013. void SwallowAttributes();
  1014. int GetToken(void);
  1015. char *TitleText(char *buf);
  1016. void ClipToWindow(void);
  1017. void DisplayHTML(int x, int y, unsigned int w, unsigned int h);
  1018. void ParseSGML(int mode, long *offset, char **data, long window, long bottom, char *target);
  1019. long DeltaHTMLPosition(long h);
  1020. long ParseImage(Doc *doc, int *width);
  1021. void ParseImageAttrs(char **href, int *hreflen, int *align, int *ismap, int *width, int *height);
  1022. void ParseAnchorAttrs(char **href, int *hreflen, char **name, int *namelen, char **class_p, int *class_len_p);
  1023. char *ParseAttribute(int *len);
  1024. char *ParseValue(int *len);
  1025. int TextWidth(int font, char *str, int len, int *up, int *down);
  1026. void FontSize(int font, int *ascent, int *descent);
  1027. void PutText(Frame *frame, unsigned int emph, int font, char *s, int len, int x, int y);
  1028. void PrintRule(Frame *frame, int type, int left, int right, int dy);
  1029. void PrintLine(Frame *frame, int left, int right, int top, int bottom); /* staalesc */
  1030. void OpenDoc(char *name);
  1031. void ReloadDoc(char *name);
  1032. int WindowButtonDown(int x, int y);
  1033. void WindowButtonUp(int shifted, int x, int y);
  1034. void SearchIndex(char *keywords);
  1035. char *FindEndComment(char *ptr);
  1036. /* html.c */
  1037. long ParseHTML(int *width, BOOL style_parse);
  1038. char *TopStr(Frame *frame);
  1039. /* http.c */
  1040. #define HTTP_PORT       80
  1041. #define OLD_PORT        2784
  1042. #define GOPHERPORT      70
  1043. #define SCHSIZ 12
  1044. #define HOSTSIZ 48
  1045. #define PATHSIZ 512
  1046. #define ANCHORSIZ 64
  1047. char *safemalloc(int n);
  1048. int IsHTMLDoc(char *p, int len);
  1049. char *MyHostName(void);
  1050. void InitCurrent(char *path);
  1051. char *UnivRefLoc(Doc *doc);
  1052. char *ParseReference(char *s, int local);
  1053. int HeaderLength(char *buf, int *type);
  1054. char *GetDocument(char *href, char *who, int local);
  1055. char *SearchRef(char *keywords);
  1056. /* cache.c */
  1057. int CloneHistoryFile(void);
  1058. void SetCurrent();
  1059. int ViewStack(void);
  1060. int PushDoc(long offset);
  1061. char *PopDoc(long *where);
  1062. char *GetCachedDoc(void);
  1063. int StoreNamePW(char *who);
  1064. char *RetrieveNamePW(void);
  1065. /* ftp.c */
  1066. char *CloseFTP(void);
  1067. char *GetFileData(int socket);
  1068. char *GetFTPdocument(char *host, char *path, char *who);
  1069. /* nntp.c */
  1070. char *GetNewsDocument(char *host, char *path);
  1071. /* tcp.c */
  1072. #define GATEWAYPORT 2785
  1073. void Pause(int delay);
  1074. int XPSend(int skt, char *data, int len, int once);
  1075. int XPRecv(int skt, char *msg, int len);
  1076. int Connect(int s, char *host, int port, int *ViaGateway);
  1077. char *GetData(int socket, int *length);
  1078. /* entities.c */
  1079. int entity(char *name, int *len);
  1080. void InitEntities(void);
  1081. /* image.c */
  1082. int InitImaging(int ColorStyle);
  1083. unsigned long GreyColor(unsigned int grey);
  1084. unsigned long StandardColor(unsigned char red, unsigned char green, unsigned char blue);
  1085. unsigned char *CreateBackground(unsigned int width, unsigned int height, unsigned int depth);
  1086. unsigned char *Transparent(unsigned char *p, int i, int j);
  1087. Image *GetImage(char *href, int hreflen, BOOL reload);
  1088. void FreeImages(int cloned);
  1089. void ReportStandardColorMaps(Atom which_map);
  1090. void ReportVisuals(void);
  1091. Visual *BestVisual(int class, int *depth);
  1092. void PaintFace(int happy);
  1093. void MakeFaces(unsigned int depth);
  1094. void MakeIcons(unsigned int depth);
  1095. Image *DefaultImage();
  1096. /* dither.c */
  1097. unsigned long magic2color(Byte ix);
  1098. long ix2color(int ix);
  1099. Byte rgb2magic(int r, int g, int b);
  1100. Byte rgb2ix(int status, int r, int g, int b, Bool rw);
  1101. long rgb2color(int status, int r, int g, int b, Bool rw);
  1102. void rgbClear();
  1103. /* gif.c */
  1104. unsigned char *LoadGifImage(Image *image, Block *bp, unsigned int depth);
  1105. /* jpeg.c */
  1106. unsigned char *LoadJPEGImage(Image *image, Block *bp, unsigned int depth);
  1107. /* png.c */
  1108. unsigned char *LoadPNGImage(Image *image, Block *bp, unsigned int depth);
  1109. /* forms.c */
  1110. char *strsav(char *s);
  1111. char *strdup2(char *s, int len);
  1112. void FreeForms(void);
  1113. void FreeFrames(Frame *frame);
  1114. void ScrollForms(long delta);
  1115. void ResizeForm(void);
  1116. void ProcessTableForm(int pass);
  1117. Form *GetForm(int method, char *url, int len);
  1118. Field *GetField(Form *form, int type, int x, char *name, int nlen,
  1119.                char *value, int vlen, int rows, int cols, int flags);
  1120. void AddOption(Field *field, int flags, char *label, int len);
  1121. int ClickedInField(GC gc, int indent, int baseline, Field *field, int x, int y, int event);
  1122. void PaintField(GC gc, int indent, int baseline, Field *field);
  1123. void PaintDropDown(GC gc, Field *field, int indent);
  1124. int ClickedInDropDown(GC gc, Field *field, int indent, int event, int x, int y);
  1125. Form *DefaultForm(void);
  1126. void PaintCross(GC gc, int x, int y, unsigned int w, unsigned int h);
  1127. void PaintTickMark(GC gc, int x, int y, unsigned int w, unsigned int h);
  1128. void ShowPaint(int npaint, int nobjs);
  1129. int RegisterDoc(char *buf);
  1130. int QueryCacheServer(char *command, char **response);
  1131. /* bridge.c */
  1132. /* #define HTList_destroy HTList_delete */
  1133. void HTList_destroy(HTList *me);
  1134. void HTAlert (CONST char * Msg);
  1135. Doc *GetInline(char *href, int hreflen, BOOL reload);
  1136. BOOL DocType(char *a, char *b);
  1137. BOOL DocHTML(Doc *d);
  1138. Doc *NewDoc();
  1139. BOOL DocImage(Doc *d);
  1140. BOOL DocRawText(Doc *d);
  1141. void libEntry();
  1142. void libExit(int pCache);
  1143. void libEventLoop(int c, char *href);
  1144. void libSane();
  1145. void DisplayUrl();
  1146. BOOL HTCheckPresentation(HTList * conversions, char * content_type, double quality);
  1147. HTAnchor *libExpandHref(char *href, size_t hreflen);
  1148. Doc *libLoadAnchor(HTAnchor *anchor, Doc *host_doc, BOOL main_doc, BOOL nofree, BOOL record, BOOL reload, BOOL block, BOOL forreal);
  1149. HTAnchor *libGetDocument(char *href, size_t hreflen, Doc *host_doc, BOOL main_doc, BOOL nofree, BOOL record, BOOL reload, BOOL block);
  1150. /*void ConnectAnchorDocument(HTAnchor *anchor, HTRequest *request);*/
  1151. void ConnectAnchorDocument(HTAnchor *anchor, HTRequest *request, BOOL terminate);
  1152. /* editor.c */
  1153. void EditCurrentBuffer();
  1154. typedef struct s_bad_flag
  1155. {
  1156.     char *p;
  1157.     char *error_text;
  1158. } BadFlag;
  1159. void RecordError(char * p, char *s);
  1160. void ForkEditor(char **b);
  1161. void FormEditChar(char c);
  1162. void FormMoveCursor(int key);
  1163. /* from phb */
  1164. #define EDIT_CHARACTER_TYPE_NORMAL       0x0
  1165. #define EDIT_CHARACTER_TYPE_PARA_BREAK   0x1
  1166. #define EDIT_CHARACTER_TYPE_WORD_BREAK   0x2
  1167. #define EXTRA_LENGTH 40
  1168. typedef enum {
  1169.     edit_cursor_movement_relative,
  1170.     edit_cursor_movement_absolute
  1171. } edit_cursor_movement;
  1172. typedef enum {
  1173.     edit_cursor_unit_pixel,
  1174.     edit_cursor_unit_character,
  1175.     edit_cursor_unit_word,
  1176.     edit_cursor_unit_paragraph,
  1177.     edit_cursor_unit_page,
  1178. } edit_cursor_unit;
  1179. typedef int edit_pixels;
  1180. typedef int edit_characters;
  1181. typedef struct s_edit_buffer 
  1182. {
  1183.     HTList  *paras;
  1184.     int width;
  1185.     BOOL auto_break;
  1186.     int break_table_size;
  1187.     char  *break_table;
  1188.     BOOL soft_break;
  1189. } EditBuffer;
  1190. typedef struct s_edit_paragraph 
  1191. {
  1192.     char *buffer;
  1193.     int buffer_used;
  1194.     int buffer_size;
  1195.     int width;
  1196.     int height;
  1197.     HTList  *lines;
  1198. } EditParagraph;
  1199. typedef struct s_edit_line
  1200. {
  1201.     int index;
  1202.     int pixel_width;
  1203.     int pixel_height;
  1204. } EditLine;
  1205. typedef struct s_edit_view 
  1206. {
  1207.     int width;
  1208.     int height;
  1209.     int (*display_line)();
  1210.     int (*display_cursor)();
  1211.     int (*display_scroll)();
  1212.     EditBuffer *main_buffer;
  1213.     EditBuffer *cut_section_buffer;
  1214.     EditBuffer *cut_line_buffer;
  1215.     EditBuffer *cut_word_buffer;
  1216.     EditBuffer *cut_character_buffer;
  1217.     int cursor_row;
  1218.     int cursor_column;
  1219.     int cursor_x;
  1220.     int cursor_y;
  1221. } EditView;
  1222. /* util.c */
  1223. void HTList_addObjectFirst (HTList *me, void *newObject);
  1224. char *strndup(char *s, int n);
  1225. char *str_tok(char *a, char *b, char **c);
  1226. char *chop_str(char *p);
  1227. Byte hex2byte(char c);
  1228. /* icon.c */
  1229. void SetIconWin(Window aWin);
  1230. void SetIconGC(GC aGC);
  1231. void DisplayIcon();
  1232. void LoadIcon();
  1233. /* history.c */
  1234. History *NewHistory();
  1235. void BackDoc();
  1236. void ForwardDoc();
  1237. void HomeDoc();
  1238. void HistoryVerify(HTAnchor *a);
  1239. void HistoryRecord(HTAnchor *a);
  1240. void HistoryDelete(HTAnchor *a);
  1241. /* mailcap.c */
  1242. void register_mailcap(char *mailcap);
  1243. void register_mailcaps();
  1244. #define MAILCAPS "/etc/mailcap:/usr/etc/mailcap:/usr/local/etc/mailcap"
  1245. #define VERBOSE_TRACE (debug & 1)
  1246. #define VERBOSE VERBOSE_TRACE 
  1247. #define X_TRACE (debug & 2)
  1248. #define BRIDGE_TRACE (debug & 4)
  1249. #define OPTION_TRACE (debug & 8)
  1250. #define IMAGE_TRACE (debug & 16)
  1251. #define SCROLL_TRACE (debug & 32)
  1252. #define BADFLAG_TRACE (debug & 64)
  1253. #define HISTORY_TRACE (debug & 128)
  1254. #define MENU_TRACE (debug & 128)
  1255. #define STATUS_TRACE (debug & 256)
  1256. #define TAG_TRACE (debug & 512)
  1257. #define TABLE_TRACE (debug & 1024)
  1258. #define MAILCAP_TRACE (debug & 2048)
  1259. #define STYLE_TRACE (debug & 4096)
  1260. #define CONNECT_TRACE (debug & 8192)
  1261. #define REGISTER_TRACE (debug & 16384)
  1262. #define FONT_TRACE (debug & 32768)
  1263. #define COLOR_TRACE (debug & 65536)
  1264. /* math.c */
  1265. void ParseMath(Frame *frame, int *up, int *down);
  1266. /* x11.c */
  1267. #define FONTS  256
  1268. int GetFont(HTList *family_l, long px_size, long weight, long style, BOOL small_caps);
  1269. long ParseColor(const char *s);
  1270. /*
  1271. int LibraryCallback( SOCKET s, HTRequest * rq, SockOps f);
  1272. int GuiEvents( SOCKET s, HTRequest * rq, SockOps f);
  1273. */
  1274. /* menu.h */
  1275. /* boundaries */
  1276. #define MAX_ITEMLENGTH 40
  1277. #define MAX_ITEMS 10
  1278. /* titles */
  1279. #define ANCHOR_POPUP_TITLE "Anchor"
  1280. #define HISTORY_POPUP_TITLE "History"
  1281. #define POPUP_ANCHOR 0
  1282. #define POPUP_HISTORY 1
  1283. /* actions */
  1284. #define NO_ACTION 0
  1285. #define VISIT_HISTORY 1
  1286. #ifdef EXTENDED_MENUS
  1287. #define COPY_TO_CLIPBOARD 3
  1288. #define ADD_AS_BKMRK 4
  1289. /*  more can be added... */
  1290. #endif
  1291. /* status of buttons */
  1292. #define INACTIVE_BUTTON 0
  1293. #define ACTIVE_BUTTON 1
  1294.     
  1295. /* structures */
  1296. typedef struct MenuItem
  1297. {
  1298.     struct MenuItem *next; /* next menu item */
  1299.     char *label;     /* the character string displayed on left*/
  1300.     char *url;                  /* url if action is GOTO */
  1301.     int  action;         /* action to be performed */
  1302.     unsigned int item_pos;        /* item number of this menu */ 
  1303.     int x;     /* x coordinate for item*/
  1304.     int y;         /* y coordinate for item */
  1305.     short state;     /* state, ACTIVE_BUTTON or INACTIVE_BUTTON */
  1306.     unsigned int strlen;     /* strlen(item) */
  1307. #ifdef SUB_MENUS
  1308.     struct MenuRoot *menu;    /* sub-menu */
  1309. #endif
  1310. } MenuItem;
  1311. typedef struct MenuRoot
  1312. {
  1313.     struct MenuItem *first; /* first item in menu */
  1314.     struct MenuItem *last; /* last item in menu */
  1315.     char *name;     /* name of root, title */
  1316.     int x;
  1317.     int y;
  1318.     int x_root;
  1319.     int y_root;
  1320.     unsigned int w;     /* width of the menu */
  1321.     unsigned int h;     /* height of the menu,  */
  1322.     unsigned int items;     /* number of items in the menu */
  1323.     unsigned int y_offset;          /* where initial item begins (below separator)*/
  1324.     
  1325.  
  1326. } MenuRoot;
  1327. typedef struct BG_Style          /* --Spif 20-Oct-95 style background struct */
  1328. {
  1329.     int            flag;           /* flag -> no bg, use color, use pixmap, repeat mode... */
  1330.     int            x_pos;
  1331.     int            y_pos;
  1332.     unsigned char  r, g, b;         /* color using RGB , must add the same thing for text or foreground color */
  1333.     Image          *image;
  1334. } BG_Style;
  1335. #define INITIAL_HTML "<HTML>n<HEAD>n<TITLE>welcome to arena</TITLE>n<STYLE>nh1: font-style = small-caps,
  1336.  font-weight = bold, text-color = DarkGreen, font-size = 22 nh2: text-color = #0A0; nem: text-color = #A00;
  1337.  nmath: text-color = #05Cna: text-background = #DD0n</STYLE>n</HEAD>n<BODY>nn<H1>Welcome to Arena</H1>
  1338. nn<P>You are using prerelease beta2. This page should disappear whennArena loads the initial page.  Unless 
  1339. otherwise specified on thencommand line or through the WWW_HOME environment variable, Arena willnload its 
  1340. <A HREF="http://www.w3.org/hypertext/WWW/Arena/beta-2">release page</A>. If you are behindna firewall, this page
  1341.  may be inaccessible and you will have to pointnArena to a SOCKSified http-server (e.g. CERN's httpd) to get
  1342.  tonfreedom.nn<P>While waiting, you may take a quick look at some of the thingsnHTML3 can do for you: nn
  1343. <table><tr><td align=middle><EM>Math without GIF's:</EM><tr><tdnalign=middle> <math>&thetav;<sub>0 </sub>(x,q)
  1344. &nbsp; = 1 + 2 sumn<sub>n=1 </sub><sup>&inf;</sup>(-1) <sup>n </sup>q <sup>n <sup>2n</sup></sup>cos2n &pi;x, 
  1345. </math><tr> </table>nn<P>The example above is a table (with non-visible borders) containingnmath markup.  The
  1346.  colors (if you're on a color screen) come from anstyle sheet. You will find more style sheet examples behind 
  1347. thenhelp button.nn</BODY>n</HTML>"
  1348. /* XGetHClrs.c */
  1349. Status XAllocColors(register Display *dpy,Colormap cmap, 
  1350.     XColor *defs, int ndefs, Status *statuses);
  1351. #ifndef EXIT_SUCCESS
  1352. #define EXIT_SUCCESS 0
  1353. #endif