386BSD 0.1 development
[unix-history] / usr / othersrc / public / ghostscript-2.4.1 / gdevtrfx.c
CommitLineData
ff9dfbeb
WJ
1/* Copyright (C) 1989, 1990, 1991 Aladdin Enterprises. All rights reserved.
2 Distributed by Free Software Foundation, Inc.
3
4This file is part of Ghostscript.
5
6Ghostscript is distributed in the hope that it will be useful, but
7WITHOUT ANY WARRANTY. No author or distributor accepts responsibility
8to anyone for the consequences of using it or for whether it serves any
9particular purpose or works at all, unless he says so in writing. Refer
10to the Ghostscript General Public License for full details.
11
12Everyone is granted permission to copy, modify and redistribute
13Ghostscript, but only under the conditions described in the Ghostscript
14General Public License. A copy of this license is supposed to have been
15given to you along with Ghostscript so you can know your rights and
16responsibilities. It should be in a file named COPYING. Among other
17things, the copyright notice and this notice must be preserved on all
18copies. */
19
20/* gdevtrfx.c */
21/* TruFax driver for Ghostscript. */
22/******
23 ****** Note: this file requires encode_l.o as supplied by TruFax.
24 ******/
25#include "gdevprn.h"
26
27/* The device descriptor */
28#define X_DPI 204
29#define Y_DPI 196
30#define LINE_SIZE ((X_DPI * 85 / 10 + 7) / 8) /* bytes per line */
31private dev_proc_print_page(trufax_print_page);
32gx_device_printer gs_trufax_device =
33 prn_device(prn_std_procs, "TruFax",
34 85, /* width_10ths, 8.5" */
35 110, /* height_10ths, 11" */
36 X_DPI, Y_DPI,
37 0,0,0,0, /* margins */
38 1, trufax_print_page);
39
40/* ------ Internal routines ------ */
41
42private int
43trufax_print_page(gx_device_printer *pdev, FILE *prn_stream)
44{ char data[LINE_SIZE + 4];
45 int lnum;
46 int line_size;
47 char out_data[5 * 1734]; /* Sized according to TruFax */
48 int out_count;
49
50 /* write TruFax header */
51 strcpy(out_data, "COSIf2");
52 out_data[6]=1;
53 out_data[7]=0;
54 out_data[8]=1;
55 out_data[9]=0;
56 fwrite(out_data, sizeof(char), 10, prn_stream);
57
58 line_size = gdev_mem_bytes_per_scan_line((gx_device *)pdev);
59 for ( lnum = 0; lnum < pdev->height; lnum++ )
60 {
61 gdev_prn_copy_scan_lines(pdev, lnum, (byte *)data, line_size);
62/* 1728 = Sized according to TruFax */
63 out_count = encode_line(1728, data, out_data);
64 putc(out_count % 256, prn_stream);
65 putc(out_count / 256, prn_stream);
66 /* send the row */
67 fwrite(out_data, sizeof(char), out_count, prn_stream);
68 }
69 return 0;
70}