home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / APPS / DVI_MGR / dvimgr_s.lzh / dvi_fbi_hh / INCLUDES / dvifile.h < prev    next >
Text File  |  1993-05-06  |  6KB  |  178 lines

  1. /* -*-C-*- dvifile.h */
  2. /*-->dvifile*/
  3. /**********************************************************************/
  4. /****************************** dvifile *******************************/
  5. /**********************************************************************/
  6.  
  7. /*--------------------------------------------------------------------*/
  8. /* Modified for use with DVIDECW driver     (30.06.89)              */
  9. /*--------------------------------------------------------------------*/
  10.  
  11. void
  12. dvifile(argc,argv,filestr)
  13. int   argc;            /* argument count */
  14. char* argv[];            /* argument strings */
  15. char* filestr;            /* DVI filename to process */
  16. {
  17.  
  18. #define PAGENUMBER(p) ((p) < 0 ? (page_count + 1 + (p)) : (p))
  19.  
  20.     register INT16 i,j,m;    /* loop indices */
  21.     register INT16 swap;    /* swap storage */
  22.  
  23.     INT16 m_begin,m_end,m_step;    /* loop limits and increment */
  24.     INT16 list[3];        /* index list for sort */
  25.     char tempstr[MAXSTR];    /* temporary string storage */
  26.  
  27.  
  28.     /*
  29.     Establish the default  font file  search order.  This  is done  here
  30.     instead of  in  initglob()  or  option(),  because  both  could  set
  31.     fontlist[].
  32.  
  33.     By default, the search list contains  names for the PK, GF, and  PXL
  34.     font  files;  that  order   corresponds  to  increasing  size   (and
  35.     therefore, presumably, increasing  processing cost)  of font  raster
  36.     information.  This search  order may  be overridden at  run time  by
  37.     defining an alternate one in the environment variable FONTLIST;  the
  38.     order of  the  strings  "PK",  "GF",  and  "PXL"  in  that  variable
  39.     determines the search  order, and  letter case  is NOT  significant.
  40.     The  substrings  may  be  separated   by  zero  or  more   arbitrary
  41.     characters, so  the  values  "PK-GF-PXL", "PK  GF  PXL",  "PKGFPXL",
  42.     "PK;GF;PXL", "PK/GF/PXL"  are all  acceptable,  and all  choose  the
  43.     default search  order.   This  flexibility  in  separator  character
  44.     choice is occasioned  by the  requirement on some  systems that  the
  45.     environment variable have the syntax of a file name, or be a  single
  46.     "word".  If  any  substring  is  omitted, then  that  font  will  be
  47.     excluded from consideration.  Thus, "GF" permits the use only of  GF
  48.     font files.
  49.  
  50.     The indexes gf_index, pk_index, and pxl_index are in -1 .. 2, and at
  51.     least one must be non-negative.  A negative index excludes that font
  52.     file type from the search.
  53.     */
  54.  
  55.     /* Note that non-negative entries in list[] are UNIQUE. */
  56.     list[0] = gf_index = (INT16)strid2(fontlist,"GF");
  57.     list[1] = pk_index = (INT16)strid2(fontlist,"PK");
  58.     list[2] = pxl_index = (INT16)strid2(fontlist,"PXL");
  59.  
  60.     for (i = 0; i < 3; ++i)    /* put list in non-decreasing order */
  61.     for (j = i+1; j < 3; ++j)
  62.         if (list[i] > list[j])
  63.         {
  64.         swap = list[i];
  65.         list[i] = list[j];
  66.         list[j] = swap;
  67.         }
  68.     for (i = 0; i < 3; ++i)    /* assign indexes 0,1,2 */
  69.     if (list[i] >= 0)
  70.     {
  71.             if (list[i] == gf_index)
  72.         gf_index = i;
  73.             else if (list[i] == pk_index)
  74.         pk_index = i;
  75.             else if (list[i] == pxl_index)
  76.         pxl_index = i;
  77.     }
  78.  
  79.     if ((gf_index < 0) && (pk_index < 0) && (pxl_index < 0))
  80.     (void)fatal("dvifile():  FONTLIST does not define at least one of \
  81. GF, PK, or PXL fonts");
  82.  
  83.     (void)dviinit(filestr);    /* initialize DVI file processing */
  84.  
  85.     (void)devinit(argc,argv);    /* initialize device output */
  86.  
  87.     (void)readpost();
  88.     (void)FSEEK(dvifp, 14L, 0); /* position past preamble */
  89.     (void)getbytes(dvifp, tempstr,
  90.     (BYTE)nosignex(dvifp,(BYTE)1)); /* flush DVI comment */
  91.  
  92.     cur_page_number = 0;
  93.  
  94.  
  95. #if    (HPLASERJET|HPJETPLUS|GOLDENDAWNGL100|POSTSCRIPT|IMPRESS|CANON_A2)
  96.     /* print pages in reverse order because of laser printer */
  97.     /* page stacking */
  98.     if (backwards)
  99.     {
  100.     m_begin = 1;
  101.     m_end = page_count;
  102.     m_step = 1;
  103.     }
  104.     else    /* normal device order */
  105.     {
  106.     m_begin = page_count;
  107.     m_end = 1;
  108.     m_step = -1;
  109.     }
  110.  
  111. #else
  112.   /* NOT (HPLASERJET|HPJETPLUS|GOLDENDAWNGL100|POSTSCRIPT|IMPRESS|CANON_A2) */
  113.     /* print pages in forward order for most devices */
  114.     if (backwards)
  115.     {
  116.     m_begin = page_count;
  117.     m_end = 1;
  118.     m_step = -1;
  119.     }
  120.     else
  121.     {
  122.     m_begin = 1;
  123.     m_end = page_count;
  124.     m_step = 1;
  125.     }
  126. #endif /* (HPLASERJET|HPJETPLUS|GOLDENDAWNGL100|POSTSCRIPT|IMPRESS|CANON_A2) */
  127.  
  128.     for (i = 0; i < npage; ++i)        /* make page numbers positive */
  129.     {                    /* and order pairs non-decreasing */
  130.     page_begin[i] = PAGENUMBER(page_begin[i]);
  131.     page_end[i] = PAGENUMBER(page_end[i]);
  132.     if (page_begin[i] > page_end[i])
  133.     {
  134.         swap = page_begin[i];
  135.         page_begin[i] = page_end[i];
  136.         page_end[i] = swap;
  137.     }
  138.     }
  139.  
  140. #if    DECWINDOWS
  141.     for (m = m_begin; ; m += m_step)
  142.     {
  143.     for (i = 0; i < npage; ++i)    /* search page list for 1st page*/
  144.         if ( IN(page_begin[i],m,page_end[i]) &&
  145.             (((m - page_begin[i]) % page_step[i]) == 0) )
  146.         {
  147.         cur_page_number++;    /* sequential page number 1..N     */
  148.         cur_index = m-1;    /* remember index globally     */
  149.         XtMainLoop();        /* We will never return here    */
  150.         }
  151.     }   
  152.     
  153. #else
  154.     for (m = m_begin; ; m += m_step)
  155.     {
  156.     for (i = 0; i < npage; ++i)    /* search page list */
  157.         if ( IN(page_begin[i],m,page_end[i]) &&
  158.             (((m - page_begin[i]) % page_step[i]) == 0) )
  159.         {
  160.         if (!quiet)        /* start progress report */
  161.             (void)fprintf(stderr,"[%d", m);
  162.         cur_page_number++;/* sequential page number 1..N */
  163.         cur_index = m-1;    /* remember index globally */
  164.         prtpage(page_ptr[cur_index]);
  165.         if (!quiet)        /* finish progress report */
  166.             (void)fprintf(stderr,"] ");
  167.         break;
  168.         }
  169.     if (m == m_end)            /* exit loop after last page */
  170.         break;
  171.     }   
  172.  
  173.     (void)devterm();        /* terminate device output */
  174.  
  175.     (void)dviterm();        /* terminate DVI file processing */
  176. #endif
  177. }
  178.