home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 6 / AACD06.ISO / AACD / Programming / MUI / MCC_HTMLview / Developer / C / Examples / HTMLView-demo.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-12-24  |  16.2 KB  |  535 lines

  1. /*
  2. ** Example code for HTMLview.mcc. (Compiles with StormC.)
  3. ** $VER: HTMLview-demo.c V0.1 (07-Aug-98)
  4. **
  5. ** Questions concerning this source: ole_f@post3.tele.dk
  6. ** Questions concerning HTMLview.mcc: duff@diku.dk
  7. **
  8. ** Find the latest version of HTMLview.mcc at Allan Odgaard's homepage
  9. ** http://www.diku.dk/students/duff/
  10. */
  11.  
  12. /* ANSI C */
  13. #include <stdio.h>
  14. #include <string.h>
  15.  
  16. /* MUI */
  17. #include <libraries/mui.h>
  18. #include <proto/muimaster.h>
  19.  
  20. /* ASL */
  21. #include <libraries/asl.h>
  22.  
  23. /* Exec */
  24. #include <exec/exec.h>
  25.  
  26. /* Protos */
  27. #include <clib/alib_protos.h>
  28. #include <proto/dos.h>
  29. #include <proto/exec.h>
  30. #include <proto/intuition.h>
  31.  
  32. #ifndef MAKE_ID
  33. #define MAKE_ID(a,b,c,d) ((ULONG) (a)<<24 | (ULONG) (b)<<16 | (ULONG) (c)<<8 | (ULONG) (d))
  34. #endif
  35. #define REG(x) register __ ## x
  36.  
  37. /* MCC_HTMLview */
  38. #include <mui/HTMLview_mcc.h>
  39.  
  40. /* Some structures for the demo */
  41. struct HistoryItem { char *URL; char *Target; };
  42. struct HTMLviewer_Data
  43. {
  44.     struct FileRequester *ASLreq;
  45.     char **Visited;
  46.     int VisitedPosition;
  47.     struct HistoryItem **History;
  48.     int HistoryPosition;
  49. };
  50. struct MUIP_HTMLviewer_ClickedURL { APTR MethodID; char *NewURL; };
  51.  
  52. /* MUIMaster library base */
  53. struct Library *MUIMasterBase;
  54.  
  55. /* Our HTMLview subclass */
  56. struct MUI_CustomClass *CL_HTMLviewer;
  57.  
  58. /* Tags */
  59. #define MUISERIALNR_HTMLVIEVER 1
  60. #define TAGBASE_HTMLVIEVER (TAG_USER | (MUISERIALNR_HTMLVIEVER << 16))
  61. enum
  62. {
  63.     MUIM_HTMLviewer_OpenFile = TAGBASE_HTMLVIEVER,
  64.     MUIM_HTMLviewer_ClickedURL,
  65.     MUIM_HTMLviewer_Back
  66. };
  67.  
  68. /*
  69. ** The "VLinks" and history lists are plain lists, no neat binary trees
  70. ** or similar here. Sorry about that, but this source should only serve a
  71. ** teaching purpose on HTMLview.mcc, not in general programming.
  72. **
  73. ** Number of "VLinks" that we will remember */
  74. #define VLINKSIZE 50
  75. /* Max number of elements in our history */
  76. #define HISTORYSIZE 50
  77.  
  78. /* The classic help function */
  79. ULONG DoSuperNew(struct IClass *cl,Object *obj,ULONG tag1,...)
  80. {
  81.     return(DoSuperMethod(cl,obj,OM_NEW,&tag1,NULL));
  82. }
  83.  
  84. /* Frees a history item */
  85. void FreeHistoryItem(struct HistoryItem *FreeMe)
  86. {
  87.     if(FreeMe)
  88.     {
  89.         FreeVec(FreeMe->URL);
  90.         if(FreeMe->Target)
  91.             FreeVec(FreeMe->Target);
  92.         FreeVec(FreeMe);
  93.     }
  94.     return;
  95. }
  96.  
  97. /* The procedure which will be called by the load task. Simple, right?
  98. ** Please note: The built-in LoadFunc in HTMLview is smarter (uses
  99. ** asyncio.library if present, for example), so this one serves only a
  100. ** teaching purpose. */
  101. ULONG __saveds HTMLviewer_LoadFunc(REG(a0) struct Hook *h,REG(a1) struct HTMLview_LoadMsg *lmsg,REG(a2) Object *obj)
  102. {
  103.     FILE *fp = (FILE *)lmsg->lm_Userdata; // Our file handle
  104.  
  105.     switch(lmsg->lm_Type)
  106.     {
  107.         case HTMLview_Open: /* Just open the file */
  108.             {
  109.                 char *filename = lmsg->lm_Open.URL;
  110.                 if(!strncmp(filename,"file://",7))
  111.                     filename += 7;
  112.                 return((ULONG)(lmsg->lm_Userdata = fopen(filename,"r")));
  113.             }
  114.         case HTMLview_Close: /* And close it again */
  115.             fclose(fp);
  116.             break;
  117.         case HTMLview_Read: /* Read from the file */
  118.             return(fread(lmsg->lm_Read.Buffer,1,lmsg->lm_Read.Size,fp));
  119.     }
  120.     return(0);
  121. }
  122.  
  123. /* Override the HTMLview_GotoURL so that we can update our link histories */
  124. ULONG HTMLviewer_GotoURL(struct IClass *cl,Object *obj,struct MUIP_HTMLview_GotoURL *msg)
  125. {
  126.     struct HTMLviewer_Data *data = (struct HTMLviewer_Data *)INST_DATA(cl,obj);
  127.     char *NewLink;
  128.     int i;
  129.  
  130.     /* Insert the new link in the history */
  131.     if(NewLink = (char *)AllocVec(strlen(msg->URL)+1,NULL))
  132.     {
  133.         char *NewTarget = 0;
  134.         struct HistoryItem *NewItem;
  135.  
  136.         strcpy(NewLink,msg->URL);
  137.         /* Copy the target too */
  138.         if(msg->Target)
  139.         {
  140.             /* It isn't dangerous if our AllocVec() fails here. If so, we just
  141.             ** get a NULL as Target, which is quite harmless. */
  142.             if(NewTarget = (char *)AllocVec(strlen(msg->Target)+1,NULL))
  143.                 strcpy(NewTarget,msg->Target);
  144.         }
  145.  
  146.         if(NewItem = (struct HistoryItem *)AllocVec(sizeof(struct HistoryItem),NULL))
  147.         {
  148.             /* Update the list position, cycle the buffer if we get too far */
  149.             i = ++data->HistoryPosition;
  150.             if(i >= HISTORYSIZE)
  151.                 i = data->HistoryPosition = 0;
  152.  
  153.             /* Free an existing entry? */
  154.             FreeHistoryItem(data->History[i]);
  155.             /* Now insert the new entry */
  156.             NewItem->URL = NewLink;
  157.             NewItem->Target = NewTarget;
  158.             data->History[i] = NewItem;
  159.         }
  160.         else
  161.         {
  162.             FreeVec(NewLink);
  163.             if(NewTarget)
  164.                 FreeVec(NewTarget);
  165.         }
  166.     }
  167.  
  168.     /* Insert the new link in the VLink list? */
  169.     if(!DoMethod(obj,MUIM_HTMLview_VLink,msg->URL))
  170.     {
  171.         if(NewLink = (char *)AllocVec(strlen(msg->URL)+1,NULL))
  172.         {
  173.             strcpy(NewLink,msg->URL);
  174.  
  175.             /* Update the list position, cycle the buffer if we get too far */
  176.             i = ++data->VisitedPosition;
  177.             if(i >= VLINKSIZE)
  178.                 i = data->VisitedPosition = 0;
  179.  
  180.             /* Free an existing entry? */
  181.             if(data->Visited[i])
  182.                 FreeVec(data->Visited[i]);
  183.             /* Now insert the new entry */
  184.             data->Visited[i] = NewLink;
  185.         }
  186.     }
  187.     /* Now, let the superclass handle the loading! */
  188.     return(DoSuperMethodA(cl,obj,(Msg)msg));
  189. }
  190.  
  191. /* See if a link is in our VLink history */
  192. ULONG HTMLviewer_VLink(struct IClass *cl,Object *obj,struct MUIP_HTMLview_VLink *msg)
  193. {
  194.     struct HTMLviewer_Data *data = (struct HTMLviewer_Data *)INST_DATA(cl,obj);
  195.     int i;
  196.  
  197.     /* Just search in our plain list */
  198.     for(i=0 ; i < VLINKSIZE ; i++)
  199.     {
  200.         if(data->Visited[i] && !strcmp(data->Visited[i],msg->URL))
  201.             return(TRUE);
  202.     }
  203.     return(FALSE);
  204. }
  205.  
  206. /* This method is called whenever the user presses a link */
  207. ULONG HTMLviewer_ClickedURL(struct IClass *cl,Object *obj,struct MUIP_HTMLviewer_ClickedURL *msg)
  208. {
  209.     struct HTMLviewer_Data *data = (struct HTMLviewer_Data *)INST_DATA(cl,obj);
  210.     ULONG target;
  211.  
  212.     get(obj,MUIA_HTMLview_Target,&target);
  213.     DoMethod(obj,MUIM_HTMLview_GotoURL,msg->NewURL,target);
  214.     return(0);
  215. }
  216.  
  217. /* This method is called when the user presses the "Back" button */
  218. ULONG HTMLviewer_Back(struct IClass *cl,Object *obj,Msg msg)
  219. {
  220.     struct HTMLviewer_Data *data = (struct HTMLviewer_Data *)INST_DATA(cl,obj);
  221.     int i,oldpos;
  222.  
  223.     oldpos = data->HistoryPosition;
  224.     /* Update the list position, cycle in the list if needed */
  225.     i = oldpos-1;
  226.     if(i < 0)
  227.         i = HISTORYSIZE-1;
  228.  
  229.     /* See if we do have any history */
  230.     if(!data->History[i])
  231.         return(0);
  232.  
  233.     /* Free the current page from the list */
  234.     FreeHistoryItem(data->History[oldpos]);
  235.     data->History[oldpos] = 0;
  236.  
  237.     /* Load the last page, but only through our superclass. If our subclass
  238.     ** knows about this call, it will add the "Back" page to the history list... */
  239.     DoSuperMethod(cl,obj,MUIM_HTMLview_GotoURL,data->History[i]->URL,data->History[i]->Target);
  240.  
  241.     data->HistoryPosition = i;
  242.     return(0);
  243. }
  244.  
  245. /* Open an ASL requester and let the user open a file */
  246. ULONG HTMLviewer_OpenFile(struct IClass *cl,Object *obj,Msg msg)
  247. {
  248.     struct HTMLviewer_Data *data = (struct HTMLviewer_Data *)INST_DATA(cl,obj);
  249.  
  250.     if(!data->ASLreq)
  251.     {
  252.         /* Allocate an ASL requester */
  253.         data->ASLreq = (struct FileRequester *)MUI_AllocAslRequestTags(ASL_FileRequest,
  254.             ASLFR_TitleText,"Open an HTML file",
  255.             ASLFR_DoPatterns,TRUE,
  256.             ASLFR_InitialPattern,"#?.(html|htm)",
  257.             ASLFR_RejectIcons,TRUE,
  258.             TAG_END);
  259.     }
  260.  
  261.     if(data->ASLreq)
  262.     {
  263.         /* Open the requester */
  264.         if(MUI_AslRequestTags(data->ASLreq,TAG_END))
  265.         {
  266.             int FileNameLength;
  267.             char *FileName;
  268.  
  269.             FileNameLength = strlen(data->ASLreq->fr_Drawer)+strlen(data->ASLreq->fr_File)+20;
  270.             if(FileName = (char *)AllocVec(FileNameLength,0))
  271.             {
  272.                 sprintf(FileName,"file://%s",data->ASLreq->fr_Drawer);
  273.                 AddPart(FileName+7,data->ASLreq->fr_File,FileNameLength-7);
  274.                 DoMethod(obj,MUIM_HTMLview_GotoURL,FileName,NULL);
  275.                 FreeVec(FileName);
  276.             }
  277.         }
  278.     }
  279.     return(0);
  280. }
  281.  
  282. /* Initialize our object and data */
  283. ULONG HTMLviewer_Init(struct IClass *cl,Object *obj,struct opSet *msg)
  284. {
  285.     struct HistoryItem **History;
  286.  
  287.     if(History = (struct HistoryItem **)AllocVec(HISTORYSIZE*sizeof(struct HistoryItem *),MEMF_CLEAR))
  288.     {
  289.         char **Visited;
  290.  
  291.         if(Visited = (char **)AllocVec(VLINKSIZE*sizeof(char *),MEMF_CLEAR))
  292.         {
  293.             static const struct Hook HTMLviewer_LoadHook = { { 0,0 }, (VOID *)HTMLviewer_LoadFunc,NULL,NULL };
  294.  
  295.             obj = (Object *)DoSuperNew(cl,obj,
  296.                 ReadListFrame,
  297.                 MUIA_HTMLview_LoadHook,&HTMLviewer_LoadHook,
  298.                 TAG_MORE,msg->ops_AttrList);
  299.  
  300.             if(obj)
  301.             {
  302.                 struct HTMLviewer_Data *data = (struct HTMLviewer_Data *)INST_DATA(cl,obj);
  303.  
  304.                 data->ASLreq = 0;
  305.                 data->History = History;
  306.                 data->Visited = Visited;
  307.                 data->HistoryPosition = 0;
  308.                 data->VisitedPosition = 0;
  309.  
  310.                 /* Get notified when a URL is clicked, so that we can fetch the new page */
  311.                 DoMethod(obj,MUIM_Notify,MUIA_HTMLview_ClickedURL,MUIV_EveryTime,obj,2,MUIM_HTMLviewer_ClickedURL,MUIV_TriggerValue);
  312.                 return((ULONG)obj);
  313.             }
  314.             FreeVec(Visited);
  315.         }
  316.         FreeVec(History);
  317.     }
  318.     DisplayBeep(0);
  319.     return((ULONG)0);
  320. }
  321.  
  322. /* Clean up the mess we have created... */
  323. ULONG HTMLviewer_Cleanup(struct IClass *cl,Object *obj,Msg msg)
  324. {
  325.     struct HTMLviewer_Data *data = (struct HTMLviewer_Data *)INST_DATA(cl,obj);
  326.     int i;
  327.  
  328.     /* Free the ASL requester */
  329.     if(data->ASLreq)
  330.         MUI_FreeAslRequest(data->ASLreq);
  331.  
  332.     /* Free the history list */
  333.     for(i=0; i < HISTORYSIZE; i++)
  334.         FreeHistoryItem(data->History[i]);
  335.     FreeVec(data->History);
  336.  
  337.     /* Free the VLink list */
  338.     for(i=0; i < VLINKSIZE; i++)
  339.     {
  340.         if(data->Visited[i])
  341.             FreeVec(data->Visited[i]);
  342.     }
  343.     FreeVec(data->Visited);
  344.  
  345.     /* And leave the rest to the superclass */
  346.     return(DoSuperMethodA(cl,obj,msg));
  347. }
  348.  
  349. /* Dispatcher for the HTMLview subclass */
  350. ULONG __saveds HTMLviewer_Dispatcher(REG(a0) struct IClass *cl,REG(a2) Object *obj,REG(a1) Msg msg)
  351. {
  352.     switch(msg->MethodID)
  353.     {
  354.         case OM_NEW:                        return(HTMLviewer_Init      (cl,obj,(struct opSet *)msg));
  355.         case OM_DISPOSE:                    return(HTMLviewer_Cleanup   (cl,obj,msg));
  356.         case MUIM_HTMLviewer_OpenFile:        return(HTMLviewer_OpenFile  (cl,obj,msg));
  357.         case MUIM_HTMLviewer_ClickedURL:    return(HTMLviewer_ClickedURL(cl,obj,(struct MUIP_HTMLviewer_ClickedURL *)msg));
  358.         case MUIM_HTMLviewer_Back:            return(HTMLviewer_Back      (cl,obj,msg));
  359.         /* Override some methods */
  360.         case MUIM_HTMLview_GotoURL:            return(HTMLviewer_GotoURL   (cl,obj,(struct MUIP_HTMLview_GotoURL *)msg));
  361.         case MUIM_HTMLview_VLink:            return(HTMLviewer_VLink     (cl,obj,(struct MUIP_HTMLview_VLink *)msg));
  362.     }
  363.     return(DoSuperMethodA(cl,obj,msg));
  364. }
  365.  
  366. /* Main function */
  367. void main(void)
  368. {
  369.     Object *app;
  370.     Object *WI_Main;
  371.     Object *BT_Load;
  372.     Object *BT_Abort;
  373.     Object *BT_Reload;
  374.     Object *BT_Back;
  375.     Object *HV_Viewer;
  376.     Object *SB_Bottom;
  377.     Object *SB_Right;
  378.     Object *TX_URL;
  379.     struct RDArgs *args;
  380.     LONG argarray[1] = {0};
  381.  
  382.     ULONG sigs = 0;
  383.     ULONG res = 5;
  384.  
  385.     /* Let us make sure we have enough stack space - we'll add 8kb to the stack */
  386.     struct StackSwapStruct stackswap;
  387.     struct Task *mytask   = FindTask(NULL);
  388.     ULONG  stacksize      = (ULONG)mytask->tc_SPUpper-(ULONG)mytask->tc_SPLower+8192;
  389.     APTR   newstack       = AllocVec(stacksize, 0L);
  390.  
  391.     stackswap.stk_Lower   = newstack;
  392.     stackswap.stk_Upper   = (ULONG)newstack+stacksize;
  393.     stackswap.stk_Pointer = (APTR)stackswap.stk_Upper;
  394.  
  395.     if(newstack)
  396.     {
  397.         StackSwap(&stackswap);
  398.  
  399.         if(MUIMasterBase = OpenLibrary(MUIMASTER_NAME, MUIMASTER_VMIN))
  400.         {
  401.             if(CL_HTMLviewer = MUI_CreateCustomClass(NULL,MUIC_HTMLview,NULL,sizeof(struct HTMLviewer_Data),HTMLviewer_Dispatcher))
  402.             {
  403.                 app = ApplicationObject,
  404.                     MUIA_Application_Title      , "HTMLview-Demo",
  405.                     MUIA_Application_Version    , "$VER: HTMLview-Demo V1.0 (11-Aug-98)",
  406.                     MUIA_Application_Copyright  , "©1998 Ole Friis",
  407.                     MUIA_Application_Author     , "Ole Friis",
  408.                     MUIA_Application_Description, "HTMLview.mcc demo program",
  409.                     MUIA_Application_Base       , "HTMLVIEWDEMO",
  410.                     SubWindow, WI_Main = WindowObject,
  411.                         MUIA_Window_ID, MAKE_ID('M','A','I','N'),
  412.                         MUIA_Window_UseRightBorderScroller,TRUE,
  413.                         MUIA_Window_UseBottomBorderScroller,TRUE,
  414.                         WindowContents, VGroup,
  415.                             Child, HGroup,
  416.                                 Child, TX_URL = TextObject,
  417.                                     TextFrame,
  418.                                     MUIA_Weight,300,
  419.                                     End,
  420.                                 Child, BT_Load = SimpleButton("_Open"),
  421.                                 Child, BT_Abort = SimpleButton("_Abort"),
  422.                                 Child, BT_Reload = SimpleButton("_Reload"),
  423.                                 Child, BT_Back = SimpleButton("_Back"),
  424.                                 End,
  425.                             Child, HGroup,
  426.                                 Child, HV_Viewer = (Object *)NewObject(CL_HTMLviewer->mcc_Class,NULL,TAG_DONE),
  427.                                 Child, SB_Right = ScrollbarObject,
  428.                                     MUIA_Prop_UseWinBorder,MUIV_Prop_UseWinBorder_Right,
  429.                                     End,
  430.                                 End,
  431.                             Child, SB_Bottom = ScrollbarObject,
  432.                                 MUIA_Group_Horiz,TRUE,
  433.                                 MUIA_Prop_UseWinBorder,MUIV_Prop_UseWinBorder_Bottom,
  434.                                 End,
  435.                             End,
  436.                         End,
  437.                     End;
  438.  
  439.                 if(app)
  440.                 {
  441.                     ULONG open;
  442.  
  443.                     /* Get notified on window close request */
  444.                     DoMethod(WI_Main,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,app,2,MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
  445.  
  446.                     /* The various buttons */
  447.                     DoMethod(BT_Load  ,MUIM_Notify,MUIA_Pressed,FALSE,HV_Viewer,1,MUIM_HTMLviewer_OpenFile);
  448.                     DoMethod(BT_Abort ,MUIM_Notify,MUIA_Pressed,FALSE,HV_Viewer,1,MUIM_HTMLview_Abort);
  449.                     DoMethod(BT_Reload,MUIM_Notify,MUIA_Pressed,FALSE,HV_Viewer,1,MUIM_HTMLview_Reload);
  450.                     DoMethod(BT_Back  ,MUIM_Notify,MUIA_Pressed,FALSE,HV_Viewer,1,MUIM_HTMLviewer_Back);
  451.  
  452.                     /* The "You're over this URL" text field */
  453.                     DoMethod(HV_Viewer,MUIM_Notify,MUIA_HTMLview_CurrentURL,MUIV_EveryTime,TX_URL,3,MUIM_Set,MUIA_Text_Contents,MUIV_TriggerValue);
  454.  
  455.                     /* Window title */
  456.                     DoMethod(HV_Viewer,MUIM_Notify,MUIA_HTMLview_Title,MUIV_EveryTime,WI_Main,3,MUIM_Set,MUIA_Window_Title,MUIV_TriggerValue);
  457.  
  458.                     /* The scrollbar in the right window border */
  459.                     DoMethod(HV_Viewer,MUIM_Notify,MUIA_Virtgroup_Height,MUIV_EveryTime,SB_Right,3,MUIM_NoNotifySet,MUIA_Prop_Entries,MUIV_TriggerValue);
  460.                     DoMethod(HV_Viewer,MUIM_Notify,MUIA_Virtgroup_Top   ,MUIV_EveryTime,SB_Right,3,MUIM_NoNotifySet,MUIA_Prop_First  ,MUIV_TriggerValue);
  461.                     DoMethod(HV_Viewer,MUIM_Notify,MUIA_Height          ,MUIV_EveryTime,SB_Right,3,MUIM_NoNotifySet,MUIA_Prop_Visible,MUIV_TriggerValue);
  462.                     DoMethod(SB_Right ,MUIM_Notify,MUIA_Prop_First,MUIV_EveryTime,HV_Viewer,3,MUIM_NoNotifySet,MUIA_Virtgroup_Top,MUIV_TriggerValue);
  463.  
  464.                     /* The scrollbar in the bottom window border */
  465.                     DoMethod(HV_Viewer,MUIM_Notify,MUIA_Virtgroup_Width,MUIV_EveryTime,SB_Bottom,3,MUIM_NoNotifySet,MUIA_Prop_Entries,MUIV_TriggerValue);
  466.                     DoMethod(HV_Viewer,MUIM_Notify,MUIA_Virtgroup_Left ,MUIV_EveryTime,SB_Bottom,3,MUIM_NoNotifySet,MUIA_Prop_First  ,MUIV_TriggerValue);
  467.                     DoMethod(HV_Viewer,MUIM_Notify,MUIA_Width          ,MUIV_EveryTime,SB_Bottom,3,MUIM_NoNotifySet,MUIA_Prop_Visible,MUIV_TriggerValue);
  468.                     DoMethod(SB_Bottom,MUIM_Notify,MUIA_Prop_First,MUIV_EveryTime,HV_Viewer,3,MUIM_NoNotifySet,MUIA_Virtgroup_Left,MUIV_TriggerValue);
  469.  
  470.                     /* Make the HTMLview object the default object */
  471.                     set(WI_Main,MUIA_Window_DefaultObject,HV_Viewer);
  472.  
  473.                     /* Set some standard "Hello" text */
  474.                     set(HV_Viewer,MUIA_HTMLview_Contents,
  475.                         "<HTML><HEAD><TITLE>HTMLview demo</TITLE></HEAD><BODY>"
  476.                         "<H1>HTMLview demo</H1>"
  477.                         "This is a simple demonstration of the HTMLview MUI "
  478.                         "custom class. Please press any of the buttons above "
  479.                         "to open HTML files etc.<P>"
  480.                         "From CLI, you can start the demo with a URL as parameter, "
  481.                         "e.g.:<BR><BR>"
  482.                         "<TT>HTMLview-demo file://work:HTML/My_File.html</TT><BR><BR>"
  483.                         "Please note that this program is only a small demo, not "
  484.                         "an entire browser, although it can be used as a small "
  485.                         ""discount HTML viewer". Feel free to improve "
  486.                         "on the HTMLview-demo.c source yourself and add better "
  487.                         "history, AppWindow support, more colorful buttons, "
  488.                         "pulldown menues, network support, ..."
  489.                         "</BODY></HTML>");
  490.  
  491.                     /* See if we have any command-line parameters */
  492.                     if(args = ReadArgs("URL/F",argarray,NULL))
  493.                     {
  494.                         /* Yup, open an URL */
  495.                         if(argarray[0] && strlen((STRPTR)argarray[0]))
  496.                             DoMethod(HV_Viewer,MUIM_HTMLview_GotoURL,argarray[0],NULL);
  497.                         FreeArgs(args);
  498.                     }
  499.  
  500.                     /* Open the window */
  501.                     set(WI_Main,MUIA_Window_Open,TRUE);
  502.                     get(WI_Main,MUIA_Window_Open,&open);
  503.                     if(open)
  504.                     {
  505.                         res = 0;
  506.                         while(DoMethod(app,MUIM_Application_NewInput,&sigs) != MUIV_Application_ReturnID_Quit)
  507.                         {
  508.                             if(sigs)
  509.                             {
  510.                                 sigs = Wait(sigs | SIGBREAKF_CTRL_C);
  511.  
  512.                                 /* Quit when receiving break from console */
  513.                                 if(sigs & SIGBREAKF_CTRL_C)
  514.                                     break;
  515.                             }
  516.                         }
  517.                     }
  518.                     MUI_DisposeObject(app);
  519.                 }
  520.                 MUI_DeleteCustomClass(CL_HTMLviewer);
  521.             }
  522.             CloseLibrary(MUIMasterBase);
  523.         }
  524.         StackSwap(&stackswap);
  525.         FreeVec(newstack);
  526.     }
  527.     exit(res);
  528. }
  529.  
  530. /* StormC specific */
  531. void wbmain(void)
  532. {
  533.     main();
  534. }
  535.