W3C home > Mailing lists > Public > www-lib@w3.org > April to June 1999

linemode diffs for HText callbacks

From: Rick Kwan <kenobi@coruscant.lightsaber.com>
Date: Thu, 24 Jun 1999 10:10:58 -0700
Message-Id: <199906241710.KAA02599@coruscant.lightsaber.com>
To: www-lib@w3.org
Greetings, folks...

The diffs below allow the linemode browser to compile and run
with libwww-5.2.6 and above.  The major enhancement is the use of
callbacks registered to the HText interface.

A little work was done with the new stylesheet interface, but mainly
so that the callbacks could compile.  But since the diffs don't take
full advantage of this, the formatting that the browser did up to
5.2.1 is now lost.  There is little visible difference between the
outputs of the tiny and linemode browsers.  (But there is hope.)

Special notes about the code:
In HTBrowse.c,
  * HTMainText and HTMainAnchor were defined in the old HText.h,
    but have been removed.  Thus, they have migrated here.  It is
    unclear to me how these should really be handled.
In GridText.c,
  * HText callbacks were added.  They are named LMHText_*() to avoid
    conflicts with similarly named HText_* typedefs.  One other
    victim of the naming scheme:  LMHText_new2().  (I think I 
    flushed out my other cases of renaming overkill.)
  * LMHText_beginElement() and LMHText_endElement() are currently
    only stubs.  Much of the formatting which was done by
    HTML_start_element() and HTML_end_element(), in HTML.c,
    should probably migrate here.  Hopefully, this will restore
    the formatting that the browser used to do.

The diffs were tested on RedHat 5.0 and 5.2 Linux machines.

--Rick Kwan, Lightsaber Computing
  rick.kwan@lightsaber.com

Index: GridStyle.html
===================================================================
RCS file: /sources/public/libwww/LineMode/src/GridStyle.html,v
retrieving revision 1.9
diff -r1.9 GridStyle.html
48a49
> #include "HTStyle.h"
128a130,131
> #endif
> 
130c133
< typedef struct _HTStyleSheet {
---
> struct _HTStyleSheet {
133c136,138
< } HTStyleSheet;
---
> };
> 
> #ifdef NOT_IN_GRIDSTYLE
Index: GridText.html
===================================================================
RCS file: /sources/public/libwww/LineMode/src/GridText.html,v
retrieving revision 1.15
diff -r1.15 GridText.html
60a61,77
> <H2>
> Callbacks
> </H2>
> 
> These functions are invoked as callbacks from the HText interface.
> 
> <PRE>
> extern HText* LMHText_new (HTRequest * req,
> 		HTParentAnchor * anchor,HTStream * output_stream);
> extern BOOL LMHText_delete (HText * self);
> extern void LMHText_addText (HText * text, const char * str, int length);
> extern void LMHText_beginAnchor (HText *text,
> 		int elem_num, int attr_num, HTChildAnchor* anc,
> 		const BOOL* present, const char** value);
> 
> </PRE>
> 
Index: HTFont.html
===================================================================
RCS file: /sources/public/libwww/LineMode/src/HTFont.html,v
retrieving revision 1.2
diff -r1.2 HTFont.html
22a23
> typedef long int HTFont;	/* For now as well */
Index: DefaultStyles.c
===================================================================
RCS file: /sources/public/libwww/LineMode/src/DefaultStyles.c,v
retrieving revision 1.9
diff -r1.9 DefaultStyles.c
11d10
< #include "GridStyle.h"
12a12,15
> #include "HTStyle.h"
> #include "GridStyle.h"
> /* try this -- GridText.h */
> #include "GridText.h"
Index: GridStyle.c
===================================================================
RCS file: /sources/public/libwww/LineMode/src/GridStyle.c,v
retrieving revision 1.16
diff -r1.16 GridStyle.c
17c17,18
< #include "HTStyle.h"
---
> #include "GridStyle.h"
> /* #include "HTStyle.h" */
25a27
> #if 0	/* DEFINED IN GridStyle.h */
34d35
< 
49d49
< 
92a93,94
> 
> #endif	/* DEFINED IN GridStyle.h */
Index: GridText.c
===================================================================
RCS file: /sources/public/libwww/LineMode/src/GridText.c,v
retrieving revision 1.46
diff -r1.46 GridText.c
16a17
> #include "WWWHTML.h"
132c133,136
< PUBLIC HText *	HText_new (HTRequest * request, HTParentAnchor * anchor)
---
> PUBLIC HText *	LMHText_new (
> 	HTRequest * request,
> 	HTParentAnchor * anchor,
> 	HTStream *outstrm)
190c194
< PUBLIC HText *	HText_new2 (HTRequest *		request,
---
> PUBLIC HText *	LMHText_new2 (HTRequest *		request,
194c198
<     HText * me = HText_new(request, anchor);
---
>     HText * me = LMHText_new(request, anchor, stream);
237c241
< PUBLIC void 	HText_free (HText * self)
---
> PUBLIC int 	HText_free (HText * self)
244a249,258
> PUBLIC BOOL LMHText_delete (HText * self)
> {
>     if (self) {
> 	HTAnchor_setDocument(self->node_anchor, NULL);
> 	hyper_free(self);
> 	return YES;
>     }
>     return NO;
> }
> 
745c759,761
< PUBLIC void HText_beginAnchor (HText * text, HTChildAnchor * anc)
---
> PUBLIC void LMHText_beginAnchor (HText * text,
>     int elem_num, int attr_num, HTChildAnchor * anc,
>     const BOOL *present, const char **value)
767,772d782
<     
<     if (start_reference && a->number && display_anchors) {
<     	/* If it goes somewhere */
< 	sprintf(marker, start_reference, a->number);
< 	HText_appendText(text, marker);
<     }
776c786
< PUBLIC void HText_endAnchor (HText * text)
---
> PUBLIC void LMHText_endAnchor (HText * text)
800c810,820
< PUBLIC void HText_appendText (HText * text, const char * str)
---
> /* LMHText_addText() satisfies HText callback requirement.  */
> PUBLIC void LMHText_addText (HText * text, const char * str, int length)
> {
>     const char * p;
>     int i;
>     for (i=0,p=str; i<length; ++i,++p) {
>         HText_appendCharacter(text, *p);
>     }
> }
> 
> PUBLIC int HText_appendText (HText * text, const char * str)
1059a1080,1099
> }
> 
> /*	HTML callback functions
> */
> PUBLIC void LMHText_beginElement (HText * text,
>     int elem_num, const BOOL * present, const char ** value)
> {
>     return;
> }
> 
> PUBLIC void LMHText_endElement (HText * text, int elem_num)
> {
>     switch (elem_num) {
>     case HTML_A:
> 	LMHText_endAnchor (text);
> 	break;
>     default:
> 	break;
>     }
>     return;   
Index: HTBrowse.c
===================================================================
RCS file: /sources/public/libwww/LineMode/src/HTBrowse.c,v
retrieving revision 1.182
diff -r1.182 HTBrowse.c
198a199,205
> /* additions for browser update */
> extern HText * HTMainText;
> extern HTParentAnchor * HTMainAnchor;
> extern void LMHText_beginElement (HText * text,
>     int elem_num, const BOOL * present, const char ** value);
> extern void LMHText_endElement (HText * text, int elem_num);
> 
1912a1920,1938
>     /* Set up HText interface callbacks */
>     if (!HText_registerCDCallback (LMHText_new, LMHText_delete)) {
> 	HTPrint("HText new/delete callback registration failed.\n");
> 	exit (1);
>     }
>     if (!HText_registerTextCallback (LMHText_addText)) {
> 	HTPrint("HText addText callback registration failed.\n");
> 	exit (2);
>     }
>     if (!HText_registerLinkCallback (LMHText_beginAnchor)) {
> 	HTPrint("HText link callback registration failed.\n");
> 	exit (3);
>     }
>     if (!HText_registerElementCallback (
>     	LMHText_beginElement, LMHText_endElement)) {
> 	HTPrint("HText element callback registration failed.\n");
> 	exit (3);
>     }
> 
1965c1991
< 	    HTRequest_setOutputStream(request, SGML_new(&HTMLP_dtd, html));
---
> 	    HTRequest_setOutputStream(request, SGML_new(HTML_dtd(), html));
Received on Thursday, 24 June 1999 12:45:02 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 23 April 2007 18:18:29 GMT