home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Utilities / Ghostscript / src / gdevdfax.c < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-01  |  3.1 KB  |  109 lines

  1. /* Copyright (C) 1994, 2000 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of AFPL Ghostscript.
  4.   
  5.   AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author or
  6.   distributor accepts any responsibility for the consequences of using it, or
  7.   for whether it serves any particular purpose or works at all, unless he or
  8.   she says so in writing.  Refer to the Aladdin Free Public License (the
  9.   "License") for full details.
  10.   
  11.   Every copy of AFPL Ghostscript must include a copy of the License, normally
  12.   in a plain ASCII text file named PUBLIC.  The License grants you the right
  13.   to copy, modify and redistribute AFPL Ghostscript, but only under certain
  14.   conditions described in the License.  Among other things, the License
  15.   requires that the copyright notice and this notice be preserved on all
  16.   copies.
  17. */
  18.  
  19. /*$Id: gdevdfax.c,v 1.3 2000/09/19 19:00:12 lpd Exp $*/
  20. /* DigiBoard fax device. */
  21. /***
  22.  *** Note: this driver is maintained by a user: please contact
  23.  ***       Rick Richardson (rick@digibd.com) if you have questions.
  24.  ***/
  25. #include "gdevprn.h"
  26. #include "strimpl.h"
  27. #include "scfx.h"
  28. #include "gdevfax.h"
  29. #include "gdevtfax.h"
  30.  
  31. /* Define the device parameters. */
  32. #define X_DPI 204
  33. #define Y_DPI 196
  34.  
  35. /* The device descriptors */
  36.  
  37. private dev_proc_open_device(dfax_prn_open);
  38. private dev_proc_print_page(dfax_print_page);
  39.  
  40. struct gx_device_dfax_s {
  41.     gx_device_common;
  42.     gx_prn_device_common;
  43.     long pageno;
  44.     uint iwidth;        /* width of image data in pixels */
  45. };
  46. typedef struct gx_device_dfax_s gx_device_dfax;
  47.  
  48. private gx_device_procs dfax_procs =
  49.   prn_procs(dfax_prn_open, gdev_prn_output_page, gdev_prn_close);
  50.  
  51. gx_device_dfax far_data gs_dfaxlow_device =
  52. {   prn_device_std_body(gx_device_dfax, dfax_procs, "dfaxlow",
  53.     DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS,
  54.     X_DPI, Y_DPI/2,
  55.     0,0,0,0,            /* margins */
  56.     1, dfax_print_page)
  57. };
  58.  
  59. gx_device_dfax far_data gs_dfaxhigh_device =
  60. {   prn_device_std_body(gx_device_dfax, dfax_procs, "dfaxhigh",
  61.     DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS,
  62.     X_DPI, Y_DPI,
  63.     0,0,0,0,            /* margins */
  64.     1, dfax_print_page)
  65. };
  66.  
  67. #define dfdev ((gx_device_dfax *)dev)
  68.  
  69. /* Open the device, adjusting the paper size. */
  70. private int
  71. dfax_prn_open(gx_device *dev)
  72. {    dfdev->pageno = 0;
  73.     return gdev_fax_open(dev);
  74. }
  75.  
  76. /* Print a DigiFAX page. */
  77. private int
  78. dfax_print_page(gx_device_printer *dev, FILE *prn_stream)
  79. {    stream_CFE_state state;
  80.     static char hdr[64] = "\000PC Research, Inc\000\000\000\000\000\000";
  81.     int code;
  82.  
  83.     gdev_fax_init_state(&state, dev);
  84.     state.EndOfLine = true;
  85.     state.EncodedByteAlign = true;
  86.  
  87.     /* Start a page: write the header */
  88.     hdr[24] = 0; hdr[28] = 1;
  89.     hdr[26] = ++dfdev->pageno; hdr[27] = dfdev->pageno >> 8;
  90.     if (dev->y_pixels_per_inch == Y_DPI)
  91.         { hdr[45] = 0x40; hdr[29] = 1; }    /* high res */
  92.     else
  93.         { hdr[45] = hdr[29] = 0; }        /* low res */
  94.     fseek(prn_stream, 0, SEEK_END);
  95.     fwrite(hdr, sizeof(hdr), 1, prn_stream);
  96.  
  97.     /* Write the page */
  98.     code = gdev_fax_print_page(dev, prn_stream, &state);
  99.  
  100.     /* Fixup page count */
  101.     fseek(prn_stream, 24L, SEEK_SET);
  102.     hdr[24] = dfdev->pageno; hdr[25] = dfdev->pageno >> 8;
  103.     fwrite(hdr+24, 2, 1, prn_stream);
  104.  
  105.     return code;
  106. }
  107.  
  108. #undef dfdev
  109.