home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / files / program / prosrc / rcmain.c < prev    next >
Encoding:
C/C++ Source or Header  |  1986-10-12  |  15.4 KB  |  723 lines

  1. /*------------------------------*/
  2. /*    includes        */
  3. /*------------------------------*/
  4.  
  5. #include "portab.h"                /* portable coding conv    */
  6. #include "machine.h"                /* machine depndnt conv    */
  7. #include "obdefs.h"                /* object definitions    */
  8. #include "gembind.h"                /* gem binding structs    */
  9. #include "osbind.h"                /* BDOS definitions    */
  10. #include "gemdefs.h"
  11. #include "rsconv.h"
  12.  
  13.  
  14. /*------------------------------*/
  15. /*    defines            */
  16. /*------------------------------*/
  17.  
  18. #define    NIL        -1
  19. #define DESK        0
  20. #define    ARROW        0
  21. #define    HOUR_GLASS    2            
  22. #define END_UPDATE    0
  23. #define    BEG_UPDATE    1
  24.  
  25. typedef struct memform
  26.     {
  27.     WORD        *mp;
  28.     WORD        fwp;
  29.     WORD        fh;
  30.     WORD        fww;
  31.     WORD        ff;
  32.     WORD        np;
  33.     WORD        r1;
  34.     WORD        r2;
  35.     WORD        r3;
  36.     } MFDB;
  37.  
  38. /*------------------------------*/
  39. /*    Global            */
  40. /*------------------------------*/
  41. GLOBAL    WORD    gl_apid;
  42.  
  43. GLOBAL WORD    contrl[11];        /* control inputs        */
  44. GLOBAL WORD    intin[80];        /* max string length        */
  45. GLOBAL WORD    ptsin[256];        /* polygon fill points        */
  46. GLOBAL WORD    intout[45];        /* open workstation output    */
  47. GLOBAL WORD    ptsout[12];
  48.  
  49. GLOBAL    WORD    gl_wchar;        /* character width        */
  50. GLOBAL    WORD    gl_hchar;        /* character height        */
  51. GLOBAL    WORD    gl_wbox;        /* box (cell) width        */
  52. GLOBAL    WORD    gl_hbox;        /* box (cell) height        */
  53. GLOBAL    WORD    gem_handle;        /* GEM handle            */
  54. GLOBAL    WORD    vdi_handle;        /* VDI handle            */
  55. GLOBAL    WORD    work_out[57];        /* open virt workstation values    */
  56. GLOBAL    GRECT    scrn_area;        /* scrn area            */
  57. GLOBAL    MFDB    scrn_mfdb;        /* scrn memory def'n for blt    */
  58. GLOBAL    GRECT    full;            /* desktop size            */
  59.  
  60. /*------------------------------*/
  61. /*    External        */
  62. /*------------------------------*/
  63.  
  64. EXTERN    WORD    desel_obj();
  65.  
  66. /*------------------------------*/
  67. /*    Local            */
  68. /*------------------------------*/
  69.  
  70. MLOCAL    WORD    native_in = TRUE;    /* TRUE: input .RSC is native    */
  71.                     /* FALSE: input .RSC is foreign */
  72. MLOCAL    WORD    conv_def = TRUE;    /* TRUE: convert .DEF also    */
  73. MLOCAL    WORD    new_dfn = FALSE;    /* TRUE: use new symbol fmt    */
  74. MLOCAL    BYTE    old_rsc[4] = "RSC";    /* new resource file extent    */
  75. MLOCAL    BYTE    new_rsc[4] = "RS2";    /* new resource file extent    */
  76. MLOCAL    BYTE    old_def[4] = "DEF";    /* new definition file extend   */
  77. MLOCAL    BYTE    new_def[4] = "DF2";    /* new definition file extend   */
  78. MLOCAL    BYTE    r_file[81];        /* resource file name         */
  79. MLOCAL    BYTE    d_file[81];        /* definition file name     */
  80. MLOCAL    BYTE    r2_file[81];        /* output resource name        */
  81. MLOCAL    BYTE    d2_file[81];        /* output definition name    */
  82. MLOCAL    WORD    r_hndl = -1;        /* resource file handle     */
  83. MLOCAL    WORD    d_hndl = -1;        /* definition file handle     */
  84. MLOCAL    WORD    r2_hndl = -1;        /* output resource handle    */
  85. MLOCAL    WORD    d2_hndl = -1;        /* output definition handle    */
  86.  
  87. MLOCAL    LONG    f_err;            /* file error            */
  88. MLOCAL    BYTE    *head;            /* location of buffer        */
  89. MLOCAL    LONG    buff_size;        /* size of buffer        */
  90. MLOCAL    BYTE    buff[20];        /* def file work area        */
  91. MLOCAL    UWORD    img_offset, addr;    /* for image fixup        */
  92. MLOCAL    WORD    img_odd;        /* image fixup needed?        */
  93. MLOCAL    GRECT    prog_rect;        /* rectangle for prog indicator */
  94.  
  95. /*------------------------------*/
  96. /*    swap_bytes         */
  97. /*------------------------------*/
  98.     VOID
  99. swap_bytes(where, len)
  100.     BYTE    *where;
  101.     WORD    len;
  102.     {
  103.     BYTE    swap;
  104.  
  105.     for (; len > 0; len -= 2)
  106.         {
  107.         swap = *where;
  108.         *where = *(where + 1);
  109.         *(where + 1) = swap;
  110.         where += 2;
  111.         }
  112.     }
  113.  
  114. /*------------------------------*/
  115. /*    swap_words         */
  116. /*------------------------------*/
  117.     VOID
  118. swap_words(where, len)
  119.     WORD    *where;
  120.     WORD    len;
  121.     {
  122.     UWORD    swap;
  123.  
  124.     for (; len > 0; len -= 4)
  125.         {
  126.         swap = *where;
  127.         *where = *(where + 1);
  128.         *(where + 1) = swap;
  129.         where += 2;
  130.         }
  131.     }
  132.  
  133. /*------------------------------*/
  134. /*    swap_images         */
  135. /*------------------------------*/
  136.     VOID
  137. swap_images()
  138.     {
  139.     BITBLK    *where;
  140.     ICONBLK *where2;
  141.     BYTE    *taddr;
  142.     WORD    num;
  143.     WORD    wb, hl;
  144.  
  145.     where = (BITBLK *) (head + ((RSHDR *) head)->rsh_bitblk);
  146.     num = ((RSHDR *) head)->rsh_nbb;
  147.     for (; num--; where++)
  148.         {
  149.         taddr = where->bi_pdata;
  150.         wb = where->bi_wb;
  151.         hl = where->bi_hl;
  152.         if ((LONG) taddr != -1L)
  153.             {
  154.             if (img_odd)
  155.                 where->bi_pdata = ++taddr;
  156.             swap_bytes(head + taddr, wb * hl);
  157.             }
  158.         }
  159.  
  160.     where2 = (ICONBLK *) (head + ((RSHDR *) head)->rsh_iconblk);
  161.     num = ((RSHDR *) head)->rsh_nib;
  162.     for (; num--; where2++)
  163.         {
  164.         wb = (where2->ib_wicon + 7) >> 3;
  165.         hl = where2->ib_hicon;
  166.         taddr = where2->ib_pdata;
  167.         if ((LONG) taddr != -1L)
  168.             {
  169.             if (img_odd)
  170.                 where2->ib_pdata = ++taddr;
  171.             swap_bytes(head + taddr, wb * hl);
  172.             }
  173.         taddr = where2->ib_pmask;
  174.         if ((LONG) taddr != -1L)
  175.             {
  176.             if (img_odd)
  177.                 where2->ib_pmask = ++taddr;
  178.             swap_bytes(head + taddr, wb * hl);
  179.             }
  180.         }
  181.     }
  182.  
  183. /*------------------------------*/
  184. /*    swap_trees         */
  185. /*------------------------------*/
  186.     VOID
  187. swap_trees()
  188.     {
  189.     BYTE    *where;
  190.     WORD    size;
  191.  
  192.     where = head + ((RSHDR *) head)->rsh_trindex;
  193.     size = ((RSHDR *) head)->rsh_ntree * sizeof(LONG);
  194.     swap_bytes(where, size);
  195.     swap_words((WORD *) where, size);
  196.     }
  197.  
  198. /*------------------------------*/
  199. /*    swap_objs         */
  200. /*------------------------------*/
  201.     VOID
  202. swap_objs()
  203.     {
  204.     OBJECT    *where;
  205.     WORD    num;
  206.  
  207.     where = (OBJECT *) (head + ((RSHDR *) head)->rsh_object);
  208.     num = ((RSHDR *) head)->rsh_nobs;
  209.     swap_bytes((BYTE *) where, num * sizeof(OBJECT));
  210.     for (; num--; where++)
  211.         swap_words((WORD *) &where->ob_spec, sizeof(LONG));
  212.     }
  213.  
  214. /*------------------------------*/
  215. /*    swap_teds         */
  216. /*------------------------------*/
  217.     VOID
  218. swap_teds()
  219.     {
  220.     TEDINFO    *where;
  221.     WORD    num;
  222.  
  223.     where = (TEDINFO *) (head + ((RSHDR *) head)->rsh_tedinfo);
  224.     num = ((RSHDR *) head)->rsh_nted;
  225.     swap_bytes((BYTE *) where, num * sizeof(TEDINFO));
  226.     for (; num--; where++)
  227.         {
  228.         swap_words((WORD *) &where->te_ptext, sizeof(LONG));
  229.         swap_words((WORD *) &where->te_ptmplt, sizeof(LONG));
  230.         swap_words((WORD *) &where->te_pvalid, sizeof(LONG));
  231.         }
  232.     }
  233.  
  234. /*------------------------------*/
  235. /*    swap_ibs         */
  236. /*------------------------------*/
  237.     VOID
  238. swap_ibs()
  239.     {
  240.     ICONBLK    *where;
  241.     WORD    num;
  242.  
  243.     where = (ICONBLK *) (head + ((RSHDR *) head)->rsh_iconblk);
  244.     num = ((RSHDR *) head)->rsh_nib;
  245.     swap_bytes((BYTE *) where, num * sizeof(ICONBLK));
  246.     for (; num--; where++)
  247.         {
  248.         swap_words((WORD *) &where->ib_pdata, sizeof(LONG));
  249.         swap_words((WORD *) &where->ib_pmask, sizeof(LONG));
  250.         swap_words((WORD *) &where->ib_ptext, sizeof(LONG));
  251.         }
  252.     }
  253.  
  254. /*------------------------------*/
  255. /*    swap_bbs         */
  256. /*------------------------------*/
  257.     VOID
  258. swap_bbs()
  259.     {
  260.     BITBLK    *where;
  261.     WORD    num;
  262.  
  263.     where = (BITBLK *) (head + ((RSHDR *) head)->rsh_bitblk);
  264.     num = ((RSHDR *) head)->rsh_nbb;
  265.     swap_bytes((BYTE *) where, num * sizeof(BITBLK));
  266.     for (; num--; where++)
  267.         swap_words((WORD *) &where->bi_pdata, sizeof(LONG));
  268.     }
  269.  
  270. /*------------------------------*/
  271. /*    swap_fstr         */
  272. /*------------------------------*/
  273.     VOID
  274. swap_fstr()
  275.     {
  276.     BYTE    *where;
  277.     WORD    size;
  278.  
  279.     where = head + ((RSHDR *) head)->rsh_frstr;
  280.     size = ((RSHDR *) head)->rsh_nstring * sizeof(LONG);
  281.     swap_bytes(where, size);
  282.     swap_words((WORD *) where, size);
  283.     }
  284.  
  285. /*------------------------------*/
  286. /*    swap_fimg         */
  287. /*------------------------------*/
  288.     VOID
  289. swap_fimg()
  290.     {
  291.     LONG    where;
  292.     WORD    size;
  293.  
  294.     where = head + ((RSHDR *) head)->rsh_frimg;
  295.     size = ((RSHDR *) head)->rsh_nimages * sizeof(LONG);
  296.     swap_bytes(where, size);
  297.     swap_words((WORD *) where, size);
  298.     }
  299.  
  300. /*------------------------------*/
  301. /*    close_files         */
  302. /*------------------------------*/
  303.     VOID
  304. close_files()
  305.     {
  306.     if (r_hndl != -1)
  307.         Fclose(r_hndl);
  308.     if (d_hndl != -1)
  309.         Fclose(d_hndl);
  310.     if (r2_hndl != -1)
  311.         Fclose(r2_hndl);
  312.     if (d2_hndl != -1)
  313.         Fclose(d2_hndl);
  314.     r_hndl = d_hndl = r2_hndl = d2_hndl = -1; 
  315.     }
  316.  
  317. /*------------------------------*/
  318. /*    do_conv         */
  319. /*------------------------------*/
  320.     WORD
  321. do_conv()
  322.     {
  323.     BYTE    *str; 
  324.     LONG    size;
  325.     WORD    reply, nsym;
  326.  
  327.     r_file[0] = '\0';
  328.  
  329.     if (!get_file(old_rsc, r_file))
  330.         return;
  331.     if ((r_hndl = open_file(r_file)) == -1)
  332.         return;
  333.     if (conv_def)
  334.         {
  335.         new_ext(r_file, d_file, old_def);
  336.         FOREVER {
  337.             d_hndl = (WORD) Fopen(d_file, 0);
  338.             if (d_hndl >= 0)
  339.                 break;
  340.             rsrc_gaddr(R_STRING, NODEF, &str);
  341.             reply = form_alert(1, str);
  342.             if (reply == 3)
  343.                 {
  344.                 close_files();
  345.                 return;
  346.                 }
  347.             if (reply == 1)
  348.                 {
  349.                 conv_def = FALSE;
  350.                 break;
  351.                 }
  352.                         /* if (reply == 2) */
  353.             if (!get_file(old_def, d_file))
  354.                 break;
  355.             }
  356.         }
  357.  
  358.     graf_mouse(HOUR_GLASS, 0x0L);
  359.     beg_prog(&prog_rect);
  360.     set_prog(RSCREAD);
  361.  
  362.     f_err = Fread(r_hndl, (LONG) sizeof(RSHDR), head);
  363.     if ( f_err < 0)
  364.         {
  365.         dos_error((WORD) f_err);
  366.         return;
  367.         }
  368.  
  369.     if (!native_in)
  370.         swap_bytes(head, sizeof(RSHDR));
  371.  
  372.     size = ((RSHDR *) head)->rsh_rssize;
  373.  
  374.     if (buff_size < size)
  375.         {
  376.         graf_mouse(ARROW, 0x0L);        /* Before alert */
  377.         rsrc_gaddr(R_STRING, NOMEM, &str);
  378.         form_alert(1, str);
  379.         close_files();
  380.         return;
  381.         }
  382.  
  383.     f_err = Fread(r_hndl, size - sizeof(RSHDR), head + sizeof(RSHDR));
  384.     if ( f_err < 0)
  385.         {
  386.         dos_error((WORD) f_err);
  387.         return;
  388.         }
  389.  
  390.     img_offset = ((RSHDR *) head)->rsh_imdata;
  391.     if ( (img_odd = img_offset & 0x0001) )
  392.         {
  393.         set_prog(IMGALIGN);
  394.         ((RSHDR *) head)->rsh_rssize = img_offset + 1;
  395.         for (addr = ((RSHDR *) head)->rsh_frstr; --addr > img_offset; )
  396.             *(head + addr) = *(head + addr - 1);
  397.         }
  398.  
  399.     set_prog(BYTESWAP);
  400.     if (native_in)
  401.         swap_images();
  402.  
  403.     swap_trees();
  404.     swap_objs();
  405.     swap_teds();
  406.     swap_ibs();
  407.     swap_bbs();
  408.     swap_fstr();
  409.     swap_fimg();
  410.  
  411.     if (native_in)
  412.         swap_bytes(head, sizeof(RSHDR));
  413.     else
  414.         swap_images();
  415.  
  416.     set_prog(RSCWRITE);
  417.     new_ext(r_file, r2_file, new_rsc);
  418.     if ( (r2_hndl = create_file(r2_file)) == -1)
  419.         {
  420.         close_files();
  421.         return;
  422.         }
  423.     graf_mouse(HOUR_GLASS, 0x0L);        /* Create_file could reset */
  424.  
  425.     f_err = Fwrite(r2_hndl, size, head);
  426.     if ( f_err < 0)
  427.         {
  428.         dos_error((WORD) f_err);
  429.         return;
  430.         }
  431.  
  432.     if (!conv_def)
  433.         {
  434.         close_files();
  435.         end_prog(&prog_rect);
  436.         return;
  437.         }
  438.  
  439.     set_prog(DEFREAD);
  440.     new_ext(r_file, d2_file, new_def);
  441.     if ( (d2_hndl = create_file(d2_file)) == -1)
  442.         {
  443.         close_files();
  444.         return;
  445.         }
  446.  
  447.     f_err = Fread(d_hndl, (LONG) sizeof(WORD), &nsym);
  448.     if ( f_err < 0)
  449.         {
  450.         dos_error((WORD) f_err);
  451.         return;
  452.         }
  453.  
  454.  
  455.     set_prog(BYTESWAP);
  456.     reply = nsym;
  457.     swap_bytes(&reply, 2);
  458.  
  459.     f_err = Fwrite(d2_hndl, (LONG) sizeof(WORD), new_dfn? &nsym: &reply);
  460.     if ( f_err < 0)
  461.         {
  462.         dos_error((WORD) f_err);
  463.         return;
  464.         }
  465.  
  466.     if (!native_in || new_dfn)
  467.         nsym = reply;
  468.  
  469.     for (; nsym--; )
  470.         {
  471.         if (!new_dfn)            /* Spare words only if */
  472.                         /* using old format    */
  473.         if (!native_in)
  474.             {            /* insert spare word */
  475.             reply = 0;
  476.             f_err = Fwrite(d2_hndl, (LONG) sizeof(WORD), &reply);
  477.             if ( f_err < 0)
  478.                 {
  479.                 dos_error((WORD) f_err);
  480.                 return;
  481.                 }
  482.             }
  483.         else
  484.             {            /* delete extra word */ 
  485.             f_err = Fread(d_hndl, (LONG) sizeof(WORD), buff);
  486.             if ( f_err < 0)
  487.                 {
  488.                 dos_error((WORD) f_err);
  489.                 return;
  490.                 }
  491.             }
  492.  
  493.         f_err = Fread(d_hndl, (LONG) sizeof(WORD), buff);
  494.         if ( f_err < 0)
  495.             {
  496.             dos_error((WORD) f_err);
  497.             return;
  498.             }
  499.  
  500.         if (!new_dfn)            /* Just copy for new fmt */
  501.             swap_bytes(buff, 2);
  502.  
  503.         f_err = Fwrite(d2_hndl, (LONG) sizeof(WORD), buff);
  504.         if ( f_err < 0)
  505.             {
  506.             dos_error((WORD) f_err);
  507.             return;
  508.             }
  509.         f_err = Fread(d_hndl, (LONG) (sizeof(WORD) + 10), buff);
  510.         if ( f_err < 0)
  511.             {
  512.             dos_error((WORD) f_err);
  513.             return;
  514.             }
  515.  
  516.         if (!new_dfn)
  517.             swap_bytes(buff, 2);    /* only swap value */
  518.  
  519.         f_err = Fwrite(d2_hndl, (LONG) (sizeof(WORD) + 10), buff);
  520.         if ( f_err < 0)
  521.             {
  522.             dos_error((WORD) f_err);
  523.             return;
  524.             }
  525.         }
  526.  
  527.     set_prog(DEFWRITE);
  528.     close_files();
  529.     end_prog(&prog_rect);
  530.     }
  531.  
  532. /*------------------------------*/
  533. /*    do_help         */
  534. /*------------------------------*/
  535.     VOID
  536. do_help()
  537.     {
  538.     OBJECT    *tree;
  539.     WORD    obj;
  540.  
  541.     rsrc_gaddr(R_TREE, HELP, &tree);
  542.     obj = hndl_dial(tree, 0, 0, 0, 0, 0);
  543.     desel_obj(tree, obj);
  544.     }
  545.  
  546. /*------------------------------*/
  547. /*    do_mode         */
  548. /*------------------------------*/
  549.     WORD
  550. do_mode()
  551.     {
  552.     OBJECT    *tree;
  553.     WORD    obj;
  554.     WORD    xdial, ydial, wdial, hdial;
  555.  
  556.     rsrc_gaddr(R_TREE, MODE, &tree);
  557.  
  558.     sel_obj(tree, native_in? N2F: F2N);
  559.     if (!conv_def)
  560.         sel_obj(tree, DEFNO);
  561.     else if (!new_dfn)
  562.         sel_obj(tree, DEFYES);
  563.     else
  564.         sel_obj(tree, DFNYES);
  565.     set_text(tree, RSC1, old_rsc, 4);
  566.     set_text(tree, RSC2, new_rsc, 4);
  567.     set_text(tree, DEF1, old_def, 4);
  568.     set_text(tree, DEF2, new_def, 4);
  569.  
  570.     form_center(tree, &xdial, &ydial, &wdial, &hdial);
  571.     form_dial(0, 0, 0, 0, 0, xdial, ydial, wdial, hdial);
  572.     form_dial(1, 0, 0, 0, 0, xdial, ydial, wdial, hdial);
  573.     objc_draw(tree, ROOT, MAX_DEPTH, xdial, ydial, wdial, hdial);
  574.  
  575.     while (TRUE)
  576.         {
  577.         obj = form_do(tree, 0) & 0x7FFF;
  578.         if (obj == DEFYES)
  579.             {
  580.             if (strcmp(old_def, "DFN") == 0)
  581.                 {
  582.                 strcpy(old_def, "DEF");
  583.                 disp_obj(tree, DEF1);
  584.                 }
  585.             }
  586.         else if (obj == DFNYES)
  587.             {
  588.             if (strcmp(old_def, "DEF") == 0)
  589.                 {
  590.                 strcpy(old_def, "DFN");
  591.                 disp_obj(tree, DEF1);
  592.                 }
  593.             }
  594.         else
  595.             break;
  596.         }
  597.  
  598.     form_dial(2, 0, 0, 0, 0, xdial, ydial, wdial, hdial);
  599.     form_dial(3, 0, 0, 0, 0, xdial, ydial, wdial, hdial);
  600.  
  601.     native_in = selected(tree, N2F);
  602.     conv_def = !selected(tree, DEFNO);
  603.     new_dfn = selected(tree, DFNYES);
  604.  
  605.     map_tree(tree, ROOT, NIL, desel_obj);
  606.     return (obj);
  607.     }
  608.  
  609. /*------------------------------*/
  610. /*    rscv_run        */
  611. /*------------------------------*/
  612.     WORD
  613. rscv_run()
  614.     {
  615.     WORD    obj;
  616.  
  617.     FOREVER {
  618.         obj = do_mode();
  619.         if (obj == HELPMODE)
  620.             do_help();
  621.         else if (obj == CONVMODE)
  622.             {
  623.             do_conv();
  624.             graf_mouse(ARROW, 0x0L);
  625.             }
  626.         else 
  627.             break;
  628.         }
  629.     }
  630.  
  631. /*------------------------------*/
  632. /*    rscv_term        */
  633. /*------------------------------*/
  634.     VOID
  635. rscv_term(term_type)
  636.     WORD    term_type;
  637.     {
  638.     switch (term_type)    /* NOTE: all cases fall through        */
  639.         {
  640.         case (0 /* normal termination */):
  641.             Mfree(head);
  642.         case (2):
  643.             v_clsvwk( vdi_handle );
  644.         case (3):
  645.             rsrc_free();
  646.         case (4):
  647.             if (term_type)
  648.                 wind_update(END_UPDATE);
  649.             appl_exit();
  650.         case (5):
  651.             break;
  652.         }
  653.     }
  654.  
  655. /*------------------------------*/
  656. /*    rscv_init        */
  657. /*------------------------------*/
  658.     WORD
  659. rscv_init()
  660.     {
  661.     WORD    i;
  662.     WORD    work_in[11];
  663.     LONG    tree;
  664.  
  665.     appl_init();                /* initialize libraries    */
  666.     if (gl_apid == -1)
  667.         return (5);            /* No handles ! */
  668.     graf_mouse(HOUR_GLASS, 0x0L);
  669.     wind_update(BEG_UPDATE);
  670.     if (!rsrc_load( "RSCONV.RSC" ))
  671.         {
  672.         graf_mouse(ARROW, 0x0L);
  673.         form_alert(1,
  674.         "[3][Fatal Error !|RSCONV.RSC|File Not Found][ Abort ]" );
  675.         return(4);    /* Can't find resource */
  676.         }
  677.  
  678.     for (i=0; i<10; i++)
  679.         {
  680.         work_in[i]=1;
  681.         }
  682.     work_in[10]=2;
  683.     gem_handle = graf_handle(&gl_wchar,&gl_hchar,&gl_wbox,&gl_hbox);
  684.     vdi_handle = gem_handle;
  685.     v_opnvwk(work_in,&vdi_handle,work_out);    /* open virtual work stn*/
  686.     if (vdi_handle == 0)
  687.         return (3);
  688.  
  689.     vqt_attributes (vdi_handle, work_in);
  690.  
  691.     scrn_area.g_x = 0;
  692.     scrn_area.g_y = 0;
  693.     scrn_area.g_w = work_out[0] + 1;
  694.     scrn_area.g_h = work_out[1] + 1;
  695.  
  696.     scrn_mfdb.np = work_out[4];
  697.     scrn_mfdb.mp = 0x0L;
  698.  
  699.     wind_get(DESK, WF_WXYWH, &full.g_x, &full.g_y, &full.g_w, &full.g_h);
  700.  
  701.     vst_height(vdi_handle, work_in[7],
  702.         &gl_wchar, &gl_hchar, &gl_wbox, &gl_hbox);
  703.  
  704.     buff_size = Malloc(-1L);
  705.     head = Malloc(buff_size - 4000L);
  706.  
  707.     graf_mouse(ARROW,0x0L);
  708.     wind_update(END_UPDATE);
  709.     return(0);
  710.     }
  711.  
  712. /*------------------------------*/
  713. /*    main            */
  714. /*------------------------------*/
  715. main()
  716.     {
  717.     WORD    rscv_code;
  718.  
  719.     if ( !(rscv_code = rscv_init()) )    /* initialization    */
  720.         rscv_run();
  721.     rscv_term(rscv_code);            /* termination        */
  722.     }
  723.