home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / INTERNET / WWW / LYNX / SOURCE / SRC0_8A.ZIP / DOSLYNX / SRC / GRIDTEXT.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1994-07-17  |  20.7 KB  |  661 lines

  1. //    Copyright (c) 1994, University of Kansas, All Rights Reserved
  2. //
  3. //    Class:        'HText'
  4. //    Include File:    gridtext.h
  5. //    Purpose:    Implement the 'member' functions of the HText 'class'
  6. //    Remarks/Portability/Dependencies/Restrictions:
  7. //        Unlike other WWW clients, no display will be done here in
  8. //        gridtext.  In fact, many unique things will be taking place.
  9. //        Structures were moved to the gridtext.h header file for
  10. //        access by other client modules.
  11. //    Revision History:
  12. //        02-01-94    created, see gridtext.h for details.
  13. //        02-25-94    Began modification to serialize all changes
  14. //                in anchors, styles, and paragraphs by writing
  15. //                pointer values to file that will never change.
  16. //                All functions modified to assume that the
  17. //                HText structure is valid as is the image
  18. //                file.  If not, expect errors.  This was
  19. //                done for the sake of speed in a slow dos
  20. //                WWW client.
  21. #define Uses_TProgram
  22. #include"gridtext.h"
  23. #include"trace.h"
  24. #include"globals.h"
  25. #include"turlview.h"
  26. #include"ttempnam.h"
  27. #include<stdlib.h>
  28. #include<string.h>
  29.  
  30. //    These functions will be called by "C" source code.
  31. extern "C"    {
  32. #include"htfont.h"
  33.  
  34. //    The default style to use in case of no others being set.
  35. static HTStyle HTS_default = {    0,
  36.                 "(Unstyled)",
  37.                 "",
  38.                 (HTFont)0,
  39.                 1.0,
  40.                 HT_BLACK,
  41.                 0,
  42.                 0,
  43.                 0,
  44.                 0,
  45.                 0,
  46.                 HT_LEFT,
  47.                 1,
  48.                 0,
  49.                 0,
  50.                 NO,
  51.                 NO,
  52.                 0,
  53.                 0,
  54.                 0
  55. };
  56.  
  57.  
  58. extern HText *HText_new(HTParentAnchor *HTPAp_anchor)    {
  59. //    Purpose:    Construct a new HText object.
  60. //    Arguments:    HTPAp_anchr    The parent anchor of the HText object.
  61. //    Return Value:    HText *    The new HText object.
  62. //    Remarks/Portability/Dependencies/Restrictions:
  63. //        Does nothing more than member initialization.
  64. //    Revision History:
  65. //        02-01-94    created
  66. #ifndef RELEASE
  67.     trace("creating new HText object.");
  68. #endif // RELEASE
  69.     //    Allocate a new HText structure.
  70.     HText *HTp_text = new HText;
  71.     if(HTp_text == NULL)
  72.         return(NULL);
  73.  
  74.     //    Assign in the parent anchor.
  75.     HTp_text->HTPAp_node_anchor = HTPAp_anchor;
  76.  
  77.     //    Currently not inside of a form.
  78.     HTp_text->B_inForm = FALSE;
  79.  
  80.     //    Initially no views are owning this HText.
  81.     HTp_text->usi_Views = 0U;
  82.     //    No styles or paragraphs yet appended.
  83.     HTp_text->B_hasParagraph = False;
  84.     HTp_text->B_hasStyle = False;
  85.  
  86.     //    Create the temporary file name.
  87.     HTp_text->TTNp_fspname = new TTempName(cp_TempDir);
  88.  
  89.     //    Open the image stream in the temporary directory.
  90.     if(HTp_text->TTNp_fspname != NULL)    {
  91.         HTp_text->fsp_image = new fstream(HTp_text->TTNp_fspname->
  92.             getName(), ios::trunc | ios::out | ios::binary);
  93.     }
  94.  
  95.     //    If everything allocated correctly return.
  96.     if(HTp_text->fsp_image != NULL && HTp_text->TTNp_fspname != NULL)
  97.     {
  98.         //    Set the DosLynx HText collection to know there is a
  99.         //    new HText in memory and is begin loaded.
  100.         HTp_text->B_isLoading = True;
  101.         TNSCp_LoadedHTexts->insert((void *)HTp_text);
  102.  
  103.         //    Check to see if the number of current HTexts is over
  104.         //    the specified limit.  If so, try to find the amount
  105.         //    over not in use and free them, from the beginning
  106.         //    which are the older documents.
  107.         //    Exclude this newly created HText from the search.
  108.         if(usi_MaxLoadedHTexts < TNSCp_LoadedHTexts->getCount())
  109.         {
  110.             HText *HTp_remove;
  111.             unsigned short int usi_over = TNSCp_LoadedHTexts->
  112.                 getCount() - usi_MaxLoadedHTexts;
  113.             for(signed short int ssi_search = 0; ssi_search <
  114.                 TNSCp_LoadedHTexts->getCount() - 2;
  115.                 ssi_search++)    {
  116.                 HTp_remove = (HText *)(TNSCp_LoadedHTexts->
  117.                     at(ssi_search));
  118.                 if(HTp_remove->usi_Views != 0U)
  119.                     continue;
  120.                 HText_free(HTp_remove);
  121.                 //    Reset ssi_search since HText_free
  122.                 //    messed with the number in the
  123.                 //    collection.
  124.                 ssi_search--;
  125.                 if(--usi_over == 0U)
  126.                     break;
  127.             }
  128.         }
  129.  
  130.         //    Set WWW to know that the parent anchor is now
  131.         //    associated with this HText.
  132.         HTAnchor_setDocument(HTPAp_anchor, (HyperDoc *)HTp_text);
  133.  
  134.         //    Set TURLV_current to own this HText.
  135.         TURLV_current->registerText(HTp_text);
  136.  
  137.         //    Set the current style of the HText to the default.
  138.         HText_beginStyle(HTp_text, &HTS_default);
  139.         return(HTp_text);
  140.     }
  141.  
  142.     //    Not everything initialized correctly, return NULL after
  143.     //    releasing memory taken.
  144.     if(HTp_text->fsp_image != NULL && HTp_text->TTNp_fspname != NULL)
  145.     {
  146.         HTp_text->fsp_image->close();
  147.         delete(HTp_text->fsp_image);
  148.     }
  149.     if(HTp_text->TTNp_fspname != NULL)
  150.         delete(HTp_text->TTNp_fspname);
  151.  
  152.     return(NULL);
  153. }
  154.  
  155. extern HText *HText_new2(HTParentAnchor *HTPAp_anchor, HTStream *HTSp_stream)
  156. {
  157. //    Purpose:    Construct a new HText object associated with a
  158. //            HTStream.
  159. //    Arguments:    HTPAp_anchor    The parent anchor of this HText.
  160. //            HTSp_stream    The stream to direct output.
  161. //    Return Value:    HText *    The new HText object.
  162. //    Remarks/Portability/Dependencies/Restrictions:
  163. //        Assignment of a HTStream to a HText object is currently not
  164. //            supported.
  165. //    Revision History:
  166. //        02-01-94    created
  167.  
  168.     //    Just call the default constructor until support for a
  169.     //    HTStream is implemented.
  170.     return(HText_new(HTPAp_anchor));
  171.  
  172. #ifdef TODO
  173. #error Implement a HTStream hook into HText.
  174. #endif // TODO
  175. }
  176.  
  177. extern void HText_free(HText *HTp_text)    {
  178. //    Purpose:    Destroy a HText object.
  179. //    Arguments:    HTp_text    The HText to release from memory.
  180. //    Return Value:    void
  181. //    Remarks/Portability/Dependencies/Restrictions:
  182. //        Will also delete any temporary file associated with the
  183. //        HText object.
  184. //    Revision History:
  185. //        02-01-94    created
  186. //        04-28-94    Modified so that we take ourselves out of
  187. //                the global collection containing the loaded
  188. //                HTexts so that functions calling us don't
  189. //                worry about it.
  190.  
  191.     doslynxmessage("Freeing " << HTp_text->HTPAp_node_anchor->address);
  192.  
  193.     //    Take this out of the loaded HText collection.
  194.     TNSCp_LoadedHTexts->remove((void *)HTp_text);
  195.     TNSCp_LoadedHTexts->pack();
  196.  
  197.     //    Tell WWW to no longer associate this HText with its parent
  198.     //    anchor.
  199.     HTAnchor_setDocument(HTp_text->HTPAp_node_anchor, (HyperDoc *)NULL);
  200.  
  201.     //    Delete any anchors from this parent anchor.
  202.     HTAnchor_delete(HTp_text->HTPAp_node_anchor);
  203.  
  204.     //    Attempt to delete the image stream.
  205.     delete(HTp_text->TTNp_fspname);
  206.  
  207.     //    Free the actual HText object.
  208.     delete(HTp_text);
  209. }
  210.  
  211. extern void HText_beginAppend(HText *HTp_text)    {
  212. //    Purpose:    Prepare the HText object for appending.
  213. //    Arguments:    HTp_text    The HText object to append to.
  214. //    Return Value:    void
  215. //    Remarks/Portability/Dependencies/Restrictions:
  216. //        Doesn't do a thing, just for compatibility with WWW.
  217. //    Revision History:
  218. //        02-01-94    created
  219. #ifndef RELEASE
  220.     trace("preparing HText for appending.");
  221. #endif // RELEASE
  222. }
  223.  
  224. extern void HText_endAppend(HText *HTp_text)    {
  225. //    Purpose:    End appending to the HText object.
  226. //    Arguments:    HTp_text    The HText object to end appends.
  227. //    Return Value:    void
  228. //    Remarks/Portability/Dependencies/Restrictions:
  229. //        Closes the image file opened upon HText creation.
  230. //    Revision History:
  231. //        02-01-94    created
  232.  
  233.     //    Finish any open styles and paragraphs.
  234.     HText_endParagraph(HTp_text);
  235.     HText_endStyle(HTp_text);
  236.  
  237.     //    Finish any forms not yet closed.
  238.     HText_endForm(HTp_text);
  239.  
  240. #ifndef RELEASE
  241.     trace("ending appends to HText.");
  242. #endif // RELEASE
  243.     //    Close then free the image file.
  244.     //    The actual file will not be deleted here, but will be deleted
  245.     //    in HText_free when it is called.  The name of the file is
  246.     //    preserved in TTNp_fspname.
  247.     HTp_text->fsp_image->close();
  248.     delete(HTp_text->fsp_image);
  249.     HTp_text->fsp_image = NULL;
  250.  
  251.     //    Set the HText object to no longer be loading.
  252.     HTp_text->B_isLoading = False;
  253. }
  254.  
  255. extern void HText_beginParagraph(HText *HTp_text)    {
  256. //    Purpose:    Begin a paragraph in the HText object.
  257. //    Arguments:    HTp_text    The HText object to create a paragraph
  258. //                    for.
  259. //    Return Value:    void
  260. //    Remarks/Portability/Dependencies/Restrictions:
  261. //        Will end any unended paragraphs before starting a new
  262. //        paragraph.
  263. //    Revision History:
  264. //        02-01-94    created
  265. //        02-17-94    Updated code to include the index of the
  266. //                paragraph.
  267. //        02-25-94    Serialized new paragraph.
  268.  
  269.     //    Close any open paragraphs.
  270.     HText_endParagraph(HTp_text);
  271.  
  272.     //    Put in the embedded character.
  273.     HTp_text->fsp_image->put(c_Embedded);
  274.     HTp_text->fsp_image->put(c_AppendParagraph);
  275.     //    If some type of error occured while writing, print a message
  276.     //    and close the file.
  277.     if(HTp_text->fsp_image->bad())    {
  278.         doslynxmessage("An error occured while writing to file " <<
  279.             HTp_text->TTNp_fspname->getName());
  280.         HTp_text->fsp_image->close();
  281.  
  282.         //    Cause the application to exit.
  283.         TEvent TE_quit;
  284.         TE_quit.what = evMessage;
  285.         TE_quit.message.command = cmQuit;
  286.         TProgram::application->handleEvent(TE_quit);
  287.     }
  288.  
  289.     //    Set flag so that endParagraph knows that there is one to end.
  290.     HTp_text->B_hasParagraph = True;
  291. }
  292.  
  293. extern void HText_endParagraph(HText *HTp_text)    {
  294. //    Purpose:    End a paragraph in the HText object.
  295. //    Arguments:    HTp_text    The HText object to end the paragraph
  296. //                    in.
  297. //    Return Value:    void
  298. //    Remarks/Portability/Dependencies/Restrictions:
  299. //        Will first check to see if a paragraph need be ended.
  300. //    Revision History:
  301. //        02-01-94    created.
  302. //        02-25-94    Modified so does nothing....
  303. //                Maybe in the future.
  304.  
  305.     //    Only the very first time this function is called there will
  306.     //    be no need to close a paragraph.
  307.     if(HTp_text->B_hasParagraph == False)
  308.         return;
  309.  
  310.     //    Do some special processing when a paragraph ends if needed.
  311. }
  312.  
  313. extern void HText_beginStyle(HText *HTp_text, HTStyle *HTSp_style)    {
  314. //    Purpose:    Start a particular style in a HText object.
  315. //    Arguments:    HTp_text    The HText to set the style for.
  316. //            HTSp_style    The style to set to.
  317. //    Return Value:    void.
  318. //    Remarks/Portability/Dependencies/Restrictions:
  319. //        Will end any open styles first.
  320. //    Revision History:
  321. //        02-01-94    created
  322. //        02-25-94    Writing style pointer to disk.
  323.  
  324.     //    End any open styles.
  325.     HText_endStyle(HTp_text);
  326.  
  327.     //    Put in the embedded character.
  328.     HTp_text->fsp_image->put(c_Embedded);
  329.     HTp_text->fsp_image->put(c_SetStyle);
  330.     //    Here's the trick, write a pointer to the style to file.
  331.     HTp_text->fsp_image->write((const char *)(&HTSp_style),
  332.         sizeof(HTStyle *));
  333.     //    If some type of error occured while writing, print a message
  334.     //    and close the file.
  335.     if(HTp_text->fsp_image->bad())    {
  336.         doslynxmessage("An error occured while writing to file " <<
  337.             HTp_text->TTNp_fspname->getName());
  338.         HTp_text->fsp_image->close();
  339.  
  340.         //    Cause the application to exit.
  341.         TEvent TE_quit;
  342.         TE_quit.what = evMessage;
  343.         TE_quit.message.command = cmQuit;
  344.         TProgram::application->handleEvent(TE_quit);
  345.     }
  346.  
  347.     //    Set a flag so that endStyle will know that there is a style
  348.     //    to end.
  349.     HTp_text->B_hasStyle = True;
  350. }
  351.  
  352. extern void HText_endStyle(HText *HTp_text)    {
  353. //    Purpose:    End the use of a style in a HText object.
  354. //    Arguments:    HTp_text    The HText object to end the style.
  355. //    Return Value:    void
  356. //    Remarks/Portability/Dependencies/Restrictions:
  357. //        Will first check and see if a style needs to be ended.
  358. //    Revision History:
  359. //        02-01-94    created
  360. //        02-25-94    Changed to do nothing, maybe in the future....
  361.  
  362.     //    Only the very first time this function is called will there
  363.     //    be no need to close a style.
  364.     if(HTp_text->B_hasStyle == False)
  365.         return;
  366.  
  367.     //    Do nothing unless special processing is needed to end a style.
  368. }
  369.  
  370. extern void HText_beginAnchor(HText *HTp_text, HTChildAnchor *HTCAp_anchor)
  371. {
  372. //    Purpose:    Begin an anchor in a HText object.
  373. //    Arguments:    HTp_text    The HText object to begin the anchor
  374. //                    in.
  375. //            HTCAp_anchor    The child anchor beginning the anchor
  376. //                    in HText.
  377. //    Return Value:    void
  378. //    Remarks/Portability/Dependencies/Restrictions:
  379. //    Revision History:
  380. //        02-01-94    created
  381. //        02-25-94    Modified to serialize the pointer value.
  382.  
  383.     //    Put in the embedded character.
  384.     HTp_text->fsp_image->put(c_Embedded);
  385.     HTp_text->fsp_image->put(c_BeginAnchor);
  386.     //    Here's the trick, write a pointer to the anchor to file.
  387.     HTp_text->fsp_image->write((const char *)(&HTCAp_anchor),
  388.         sizeof(HTChildAnchor *));
  389.     //    If some type of error occured while writing, print a message
  390.     //    and close the file.
  391.     if(HTp_text->fsp_image->bad())    {
  392.         doslynxmessage("An error occured while writing to file " <<
  393.             HTp_text->TTNp_fspname->getName());
  394.         HTp_text->fsp_image->close();
  395.  
  396.         //    Cause the application to exit.
  397.         TEvent TE_quit;
  398.         TE_quit.what = evMessage;
  399.         TE_quit.message.command = cmQuit;
  400.         TProgram::application->handleEvent(TE_quit);
  401.  
  402.     }
  403. }
  404.  
  405. extern void HText_endAnchor(HText *HTp_text)    {
  406. //    Purpose:    End an anchor in a HText object.
  407. //    Arguments:    HTp_text    The HText to end the anchor in.
  408. //    Return Value:    void
  409. //    Remarks/Portability/Dependencies/Restrictions:
  410. //        Unlike HText_endParagraph and HText_endStyle, there will
  411. //        always be an anchor to close; there is no need to check.
  412. //    Revision History:
  413. //        02-01-94    created
  414. //        02-25-94    Modified to serialize a marker to end the
  415. //                anchor.
  416.  
  417.     //    Put in the embedded character.
  418.     HTp_text->fsp_image->put(c_Embedded);
  419.     HTp_text->fsp_image->put(c_EndAnchor);
  420.     //    If some type of error occured while writing, print a message
  421.     //    and close the file.
  422.     if(HTp_text->fsp_image->bad())    {
  423.         doslynxmessage("An error occured while writing to file " <<
  424.             HTp_text->TTNp_fspname->getName());
  425.         HTp_text->fsp_image->close();
  426.         //    Cause the application to exit.
  427.         TEvent TE_quit;
  428.         TE_quit.what = evMessage;
  429.         TE_quit.message.command = cmQuit;
  430.         TProgram::application->handleEvent(TE_quit);
  431.     }
  432. }
  433.  
  434. extern void HText_appendCharacter(HText *HTp_text, char c_append)    {
  435. //    Purpose:    Add a character to the HText object.
  436. //    Arguments:    HTp_text    The HText object to append to.
  437. //            c_append    The character to add.
  438. //    Return Value:    void
  439. //    Remarks/Portability/Dependencies/Restrictions:
  440. //        Character not actually added to HText but appended to the
  441. //        image file.
  442. //    Revision History:
  443. //        02-01-94    created
  444.  
  445.     //    Write the character to the binary file stream.
  446.     HTp_text->fsp_image->put(c_append);
  447.  
  448.     //    If some type of error occured while writing, print a message
  449.     //    and close the file.
  450.     if(HTp_text->fsp_image->bad())    {
  451.         doslynxmessage("An error occured while writing to file " <<
  452.             HTp_text->TTNp_fspname->getName());
  453.         HTp_text->fsp_image->close();
  454.         //    Cause the application to exit.
  455.         TEvent TE_quit;
  456.         TE_quit.what = evMessage;
  457.         TE_quit.message.command = cmQuit;
  458.         TProgram::application->handleEvent(TE_quit);
  459.     }
  460. }
  461.  
  462. extern void HText_appendImage(HText *HTp_text, HTChildAnchor *HTCAp_anc,
  463.     const char *cp_alt, int ssi_alignment, BOOL B_isMap)    {
  464. //    Purpose:    Append an image in the HTML rendering.
  465. //    Arguments:    HTp_text    The hyper document in which to insert
  466. //                    the image.
  467. //            HTCAp_anc    The anchor pointing to the image.
  468. //            cp_alt        The title of the picture.
  469. //            ssi_alignment    How the picture should be aligned on
  470. //                    the screen.
  471. //            B_isMap        Whether or not portions are
  472. //                    selectable?
  473. //    Return Value:    void
  474. //    Remarks/Portability/Dependencies/Restrictions:
  475. //        Created just to fill where pictures should be with an anchor.
  476. //    Revision History:
  477. //        03-07-94    created
  478.  
  479.     auto char *cp_append = "<IMAGE>";
  480.  
  481.     if(cp_alt != NULL)    {
  482.         if(*cp_alt != '\0')    {
  483.             cp_append = (char *)cp_alt;
  484.         }
  485.     }
  486.  
  487.     HText_appendText(HTp_text, cp_append);
  488. }
  489.  
  490. extern void HText_appendText(HText *HTp_text, const char *cp_append)    {
  491. //    Purpose:    Add a string to the HText object.
  492. //    Arguments:    HTp_text    The HText object to add to.
  493. //    Return Value:    void
  494. //    Remarks/Portability/Dependencies/Restrictions:
  495. //        Characters are not actually added to HText but appended to the
  496. //        image file.
  497. //    Revision History:
  498. //        02-01-94    created
  499.  
  500.     for(char *cp = (char *)cp_append; *cp != '\0'; cp++)    {
  501.         HText_appendCharacter(HTp_text, *cp);
  502.     }
  503. }
  504.  
  505. extern BOOL HText_selectAnchor(HText *HTp_text, HTChildAnchor *HTCAp_anchor)
  506. {
  507. //    Purpose:    Selects the specified anchor in HText.
  508. //    Arguments:    HTp_text    The HText object with the anchor.
  509. //            HTCAp_anchor    The anchor to select.
  510. //    Return Value:    BOOL    TRUE    The anchor was selected.
  511. //                FALSE    The anchor could not be selected.
  512. //    Remarks/Portability/Dependencies/Restrictions:
  513. //        The only reason why an anchor is unable to be selected is
  514. //        if the anchor does not exists in the Anchor collection.
  515. //        Also, assume that if an anchor is selected, the HText is
  516. //        viewable in the current TURLView.  Since multiple views
  517. //        of the same HText can exists, we can not record the selected
  518. //        anchor in the HText structure, but must call a TURLView
  519. //        function to set the selected anchor for each different view.
  520. //    Revision History:
  521. //        02-01-94    created
  522.  
  523. #ifndef RELEASE
  524.     trace("selecting an anchor in HText.");
  525. #endif // RELEASE
  526.  
  527.     //    Have the view select the anchor.
  528.     if(TURLV_current->selectAnchor(HTCAp_anchor) == False)    {
  529.         //    Anchor wasn't found.
  530.         doslynxmessage("Attempt to select invalid anchor failed.");
  531.         return(FALSE);
  532.     }
  533.     return(TRUE);
  534. }
  535.  
  536. extern BOOL HText_select(HText *HTp_text)    {
  537. //    Purpose:    View the HText object NOW.
  538. //    Arguments:    HTp_text    The HText object to be viewed.
  539. //    Return Value:    BOOL    TRUE    The HText was selected.
  540. //                FALSE    The HText was not selected.
  541. //    Remarks/Portability/Dependencies/Restrictions:
  542. //        This function won't be called unless a request to load is
  543. //        made.
  544. //        The HText was loaded at some time and is still in memory, be
  545. //        it in none, one, or more windows.
  546. //        Inform the calling window that this HText exists, by simply
  547. //        manually assigning a pointer to this HText.
  548. //    Revision History:
  549. //        02-01-94    created.
  550.  
  551.     //    Use the global variable of the URL view to point to us.
  552.     TURLV_current->registerText(HTp_text);
  553.     return(TRUE);
  554. }
  555.  
  556. extern void HText_beginForm(HText *HTp_text, char *cp_action,
  557.     char *cp_enctype, char *cp_method)    {
  558. //    Purpose:    Begin a Form in a HText object.
  559. //    Arguments:    HTp_text    The HText object to add the form to.
  560. //            cp_action    The URL to submit the form
  561. //                        information.
  562. //            cp_enctype    The encoding scheme to send the form
  563. //                        information in.  NOT
  564. //                        SUPPORTED.
  565. //            cp_method    The way in which to send the form
  566. //                        information (either on the
  567. //                        URL or after the URL).
  568. //    Return Value:    void
  569. //    Remarks/Portability/Dependencies/Restrictions:
  570. //        Encoding types are not supported.
  571. //        Forms are not nestable.
  572. //    Revision History:
  573. //        07-18-94    created
  574.  
  575. #ifndef RELEASE
  576.     trace("Beginning form.");
  577. #endif // RELEASE
  578.  
  579.     //    Forms are not nestable.  If already in a form, just end the
  580.     //        last one.
  581.     if(HTp_text->B_inForm == TRUE)    {
  582.         HText_endForm(HTp_text);
  583.     }
  584.  
  585.     //    Mark that the HText has entered a form.
  586.     HTp_text->B_inForm = TRUE;
  587.  
  588.     //    Unlike all the paradigm of handling anchors (writing a
  589.     //        pionter to file) a form has state specific to the
  590.     //        loaded document.  We will have to write all needed
  591.     //        information to the file before creating the form.
  592.  
  593.     //    Put in the embedded character.
  594.     HTp_text->fsp_image->put(c_Embedded);
  595.     HTp_text->fsp_image->put(c_BeginForm);
  596.     //    Here's the trick, write the information to the file.
  597.     //    A zero terminates each.  A zero by itself means empty.
  598.     //    The action.
  599.     HTp_text->fsp_image->write(cp_action, strlen(cp_action) + 1);
  600.     //    The enctype.
  601.     HTp_text->fsp_image->write(cp_enctype, strlen(cp_enctype) + 1);
  602.     //    The method.
  603.     HTp_text->fsp_image->write(cp_method, strlen(cp_method) + 1);
  604.  
  605.     //    If some type of error occured while writing, print a message
  606.     //    and close the file.
  607.     if(HTp_text->fsp_image->bad())    {
  608.         doslynxmessage("An error occured while writing to file " <<
  609.             HTp_text->TTNp_fspname->getName());
  610.         HTp_text->fsp_image->close();
  611.  
  612.         //    Cause the application to exit.
  613.         TEvent TE_quit;
  614.         TE_quit.what = evMessage;
  615.         TE_quit.message.command = cmQuit;
  616.         TProgram::application->handleEvent(TE_quit);
  617.  
  618.     }
  619. }
  620.  
  621. extern void HText_endForm(HText *HTp_text)    {
  622. //    Purpose:    End the current form.
  623. //    Arguments:    HTp_text    The HText in which to end a form.
  624. //    Return Value:    void
  625. //    Remarks/Portability/Dependencies/Restrictions:
  626. //        Can't end a form that was never begun.
  627. //        This function must be called for every form begun in HText.
  628. //    Revision History:
  629. //        07-18-94    created
  630.  
  631. #ifndef RELEASE
  632.     trace("Ending form.");
  633. #endif // RELEASE
  634.  
  635.     //    First, there must be a form to end.
  636.     if(HTp_text->B_inForm != TRUE)    {
  637.         return;
  638.     }
  639.  
  640.     //    Put in the embedded character.
  641.     HTp_text->fsp_image->put(c_Embedded);
  642.     HTp_text->fsp_image->put(c_EndForm);
  643.  
  644.     //    If some type of error occured while writing, print a message
  645.     //    and close the file.
  646.     if(HTp_text->fsp_image->bad())    {
  647.         doslynxmessage("An error occured while writing to file " <<
  648.             HTp_text->TTNp_fspname->getName());
  649.         HTp_text->fsp_image->close();
  650.  
  651.         //    Cause the application to exit.
  652.         TEvent TE_quit;
  653.         TE_quit.what = evMessage;
  654.         TE_quit.message.command = cmQuit;
  655.         TProgram::application->handleEvent(TE_quit);
  656.  
  657.     }
  658.  
  659. }
  660.  
  661. }; // extern "C"