home *** CD-ROM | disk | FTP | other *** search
/ Amiga Elysian Archive / AmigaElysianArchive.iso / printer / dvi2pcl.lha / doodevpages.c < prev    next >
C/C++ Source or Header  |  1992-11-25  |  5KB  |  195 lines

  1. /* $Log:    doodevpages.c,v $
  2.  * Revision 0.8  92/11/23  19:46:40  19:46:40  bt (Bo Thide')
  3.  * Fixed resolution bug. Portable downloading. Added/changed options. PJXL color support
  4.  * 
  5.  * Revision 0.7  92/11/13  02:41:24  02:41:24  bt (Bo Thide')
  6.  * More bug fixes and improvements. Support for PaintJet XL
  7.  * 
  8.  * Revision 0.6  92/11/10  21:47:41  21:47:41  bt (Bo Thide')
  9.  * Bug fixes. Added -R option. Better font handling.
  10.  * 
  11.  * Revision 0.5  92/11/09  16:25:27  16:25:27  bt (Bo Thide')
  12.  * Rewrite of dospecial.c. Extended \special support
  13.  * 
  14.  * Revision 0.4  92/11/08  02:45:43  02:45:43  bt (Bo Thide')
  15.  * Changed to portable bit manipulations. Replaced strrstr for non-POSIX compliant C. Fixed numerous bugs. Added support for more \special's.
  16.  * 
  17.  * Revision 0.3  92/08/24  12:45:35  12:45:35  bt (Bo Thide')
  18.  * Fixed 8 bit (dc font) support.
  19.  * 
  20.  * Revision 0.2  92/08/23  17:28:55  17:28:55  bt (Bo Thide')
  21.  * Source cleaned up.  Changed certain function calls.  Removed globals.
  22.  * 
  23.  * Revision 0.1  92/08/22  23:58:47  23:58:47  bt (Bo Thide')
  24.  * First Release.
  25.  *  */
  26.  
  27. /*
  28.  * This routine processes all pages in the 'two-sided' mode.
  29.  * Reverse is true for LaserJet+, but false for LaserJet II.
  30.  *
  31.  * If reverse is true, all even pages are output first in reverse order,
  32.  * then the odd pages are output in reverse order.
  33.  *
  34.  * Example:
  35.  * First even pages are output: 6 4 2 (2 on top, printed side upwards).
  36.  * Then you turn the stack of paper (6 on top, printed side downwards) and
  37.  * feed in 6 4 2, and 5 3 1 are printed on the other side.
  38.  * 1 is now on top of the stack, printed side upwards.
  39.  *
  40.  * If reverse is false, all odd pages are output first in normal order,
  41.  * then the even pages are output in reverse order.
  42.  *
  43.  * Example:
  44.  * First odd pages are output: 1 3 5 (5 on top of stack, printed side
  45.  * downwards). Then you take the stack of paper and
  46.  * feed in 5 3 1 (5 on top, printed side downwards), and 6 4 2 are printed on
  47.  * the other side. 1 is now on top of the stack, printed side upwards.
  48.  */
  49.  
  50. #include <stdio.h>
  51. #include "globals.h"
  52. #include "pcl.h"
  53.  
  54. static char rcsid[] = "$Header: doodevpages.c,v 0.8 92/11/23 19:46:40 bt Exp $";
  55.  
  56. void doodevpages(bitfile, dvifile, pcllevel, reverse, resolution, device)
  57. FILE    *bitfile;
  58. FILE    *dvifile;
  59. short    pcllevel;
  60. bool    reverse;
  61. short    resolution;
  62. short    device;
  63.     long     backpage, startpage;
  64.     short     is_odd = actualpagecount % 2;
  65.  
  66.     if(inpostamble)
  67.         backpage = lastpage + 1;
  68.     else
  69.         backpage = prevpage + 1;
  70.     maxpages = actualpagecount;
  71.  
  72.     if (reverse)
  73.     {    /* Start with even pages. */
  74.  
  75.         /* Eject an empty paper if odd number of pages */
  76.         if (is_odd)  fputs(PCL4_EJECT_PAGE,bitfile);
  77.  
  78.         startpage = backpage;
  79.         h_offset = e_offset;
  80.  
  81.         while(maxpages--)
  82.         { 
  83.             fseek(dvifile , backpage , 0);
  84.             scanbop(dvifile);
  85.             backpage = prevpage + 1;
  86.             if (! is_odd)
  87.             {
  88.                 printbop(startvals, count);
  89.                 dopage(bitfile, dvifile, pcllevel, resolution,
  90.                   device);
  91.             }
  92.             if(maxpages > 0)
  93.             { 
  94.                 fseek(dvifile , backpage , 0);
  95.                 scanbop(dvifile);
  96.                 if (is_odd)
  97.                 {
  98.                     printbop(startvals, count);
  99.                     dopage(bitfile, dvifile, pcllevel,
  100.                       resolution, device);
  101.                 }
  102.                 backpage = prevpage + 1;
  103.                 maxpages--;
  104.             }
  105.         }
  106.  
  107.         /* then do the odd pages */
  108.         fprintf(stderr,"Reload paper cassette with output package\n");
  109.         fputs(PCL4_MANUAL_FEED,bitfile);
  110.  
  111.         h_offset = o_offset;
  112.         maxpages = actualpagecount;
  113.         backpage = startpage;
  114.         while (maxpages-- > 0)
  115.         {
  116.             fseek(dvifile , backpage , 0);
  117.             scanbop(dvifile);
  118.             backpage = prevpage + 1;
  119.             if (is_odd)
  120.             {
  121.                 printbop(startvals, count);
  122.                 dopage(bitfile, dvifile, pcllevel, resolution,
  123.                   device);
  124.             }
  125.             if(maxpages > 0)
  126.             { 
  127.                 fseek(dvifile , backpage , 0);
  128.                 scanbop(dvifile);
  129.                 if (! is_odd)
  130.                 {
  131.                     printbop(startvals, count);
  132.                     dopage(bitfile, dvifile, pcllevel,
  133.                       resolution, device);
  134.                 }
  135.                 backpage = prevpage + 1;
  136.                 maxpages--;
  137.             }
  138.         }
  139.     }
  140.     else
  141.     {
  142.         /* Do odd pages first */
  143.         h_offset = o_offset;
  144.         maxpages = actualpagecount;
  145.         fseek(dvifile , firstpage-1 , 0);
  146.         while(maxpages-- > 0)
  147.         { 
  148.             if(betweenpages(dvifile, PRESCAN_OFF))
  149.             { 
  150.                 printbop(startvals, count);
  151.                 dopage(bitfile, dvifile, pcllevel, resolution,
  152.                   device);
  153.                 maxpages--;
  154.                 skipnextpage(dvifile);
  155.             }
  156.         }
  157.         /* Then do the even pages */
  158.         fprintf(stderr,"Reload paper cassette with output package\n");
  159.         fputs(PCL4_MANUAL_FEED,bitfile);
  160.  
  161.         h_offset = e_offset;
  162.         maxpages = actualpagecount;
  163.         if (is_odd)  fputs(PCL4_EJECT_PAGE,bitfile); /* Odd number of pages */
  164.  
  165.         while(maxpages--)
  166.         { 
  167.             fseek(dvifile , backpage , 0);
  168.             scanbop(dvifile);
  169.             backpage = prevpage + 1;
  170.             if (! is_odd)
  171.             {
  172.                 printbop(startvals, count);
  173.                 dopage(bitfile, dvifile, pcllevel, resolution,
  174.                   device);
  175.             }
  176.             if(maxpages > 0)
  177.             { 
  178.                 fseek(dvifile , backpage , 0);
  179.                 scanbop(dvifile);
  180.                 if (is_odd)
  181.                 {
  182.                     printbop(startvals, count);
  183.                     dopage(bitfile, dvifile, pcllevel,
  184.                       resolution, device);
  185.                 }
  186.                 backpage = prevpage + 1;
  187.                 maxpages--;
  188.             }
  189.         }
  190.     }
  191.  
  192.     fprintf(stderr,"\n");
  193. }
  194.