~ubuntu-branches/ubuntu/vivid/ghostscript/vivid-security

« back to all changes in this revision

Viewing changes to devices/gdevsppr.c

  • Committer: Package Import Robot
  • Author(s): Till Kamppeter
  • Date: 2013-08-09 20:01:36 UTC
  • mfrom: (1.1.37)
  • Revision ID: package-import@ubuntu.com-20130809200136-amb6zrr7hnjb5jq9
Tags: 9.08~rc1~dfsg-0ubuntu1
* New upstream release
   - Ghostscript 9.08rc1.
   - We are using the system's liblcms2 and libopenjpeg now.
* debian/patches/020130401-852e545-pxl-xl-driver-produced-drawing-commands-without-setting-color-space.patch:
  Removed patch backported from upstream.
* debian/patches/ojdk-8007925+8007926.patch,
  debian/patches/ojdk-8007927.patch,
  debian/patches/ojdk-8007929.patch,
  debian/patches/ojdk-8009654.patch: Removed patches on build in liblcms2, we
  use the system's liblcms2 now.
* debian/patches/2001_docdir_fix_for_debian.patch: Manually updated to new
  upstream source code.
* debian/patches/2003_support_multiarch.patch: Refreshed with quilt.
* debian/control: Added build dependencies on liblcms2-dev and
  libopenjpeg-dev.
* debian/rules: Check for removed lcms2/ and openjpeg/ subdirectories in
  the repackaging check again, also set build options for shared liblcms2
  and libopenjpeg libraries.
* debian/rules: Makefile.in and configure.ac are in the root directory of
  the source now and do not need to get linked from base/. Also there is no
  gstoraster and gstopxl CUPS filter in the package any more and no
  "install-cups" make target any more.
* debian/control, debian/rules, debian/ghostscript-cups.install,
  debian/ghostscript-cups.ppd-updater: Removed the ghostscript-cups binary
  package. The files are now provided by cups-filters.
* debian/symbols.common: Updated for new upstream source. Applied patch
  which dpkg-gensymbols generated for debian/libgs9.symbols to this file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 2001-2012 Artifex Software, Inc.
 
2
   All Rights Reserved.
 
3
 
 
4
   This software is provided AS-IS with no warranty, either express or
 
5
   implied.
 
6
 
 
7
   This software is distributed under license and may not be copied,
 
8
   modified or distributed except as expressly authorized under the terms
 
9
   of the license contained in the file LICENSE in this distribution.
 
10
 
 
11
   Refer to licensing information at http://www.artifex.com or contact
 
12
   Artifex Software, Inc.,  7 Mt. Lassen Drive - Suite A-134, San Rafael,
 
13
   CA  94903, U.S.A., +1(415)492-9861, for further information.
 
14
*/
 
15
 
 
16
 
 
17
/* SPARCprinter driver for Ghostscript */
 
18
#include "gdevprn.h"
 
19
#include <stdio.h>
 
20
#include <sys/types.h>
 
21
#include <sys/ioccom.h>
 
22
#include <unbdev/lpviio.h>
 
23
 
 
24
/*
 
25
   Thanks to Martin Schulte (schulte@thp.Uni-Koeln.DE) for contributing
 
26
   this driver to Ghostscript.  He supplied the following notes.
 
27
 
 
28
The device-driver (normally) returns two differnt types of Error-Conditions,
 
29
FATALS and WARNINGS. In case of a fatal, the print routine returns -1, in
 
30
case of a warning (such as paper out), a string describing the error is
 
31
printed to stderr and the output-operation is repeated after five seconds.
 
32
 
 
33
A problem is that not all possible errors seem to return the correct error,
 
34
under some circumstance I get the same response as if an error repeated,
 
35
that's why there is this the strange code about guessing the error.
 
36
 
 
37
I didn't implement asynchronous IO (yet), because "`normal"' multipage-
 
38
printings like TEX-Output seem to be printed with the maximum speed whereas
 
39
drawings normally occur as one-page outputs, where asynchronous IO doesn't
 
40
help anyway.
 
41
*/
 
42
 
 
43
static dev_proc_open_device(sparc_open);
 
44
static dev_proc_print_page(sparc_print_page);
 
45
 
 
46
#define SPARC_MARGINS_A4        0.15, 0.12, 0.12, 0.15
 
47
#define SPARC_MARGINS_LETTER    0.15, 0.12, 0.12, 0.15
 
48
 
 
49
/* Since the print_page doesn't alter the device, this device can print in the background */
 
50
gx_device_procs prn_sparc_procs =
 
51
  prn_procs(sparc_open, gdev_prn_bg_output_page, gdev_prn_close);
 
52
 
 
53
const gx_device_printer far_data gs_sparc_device =
 
54
prn_device(prn_sparc_procs,
 
55
  "sparc",
 
56
  DEFAULT_WIDTH_10THS,DEFAULT_HEIGHT_10THS,
 
57
  400,400,
 
58
  0,0,0,0,
 
59
  1,
 
60
  sparc_print_page);
 
61
 
 
62
/* Open the printer, and set the margins. */
 
63
static int
 
64
sparc_open(gx_device *pdev)
 
65
{       /* Change the margins according to the paper size. */
 
66
        const float *m;
 
67
        static const float m_a4[4] = { SPARC_MARGINS_A4 };
 
68
        static const float m_letter[4] = { SPARC_MARGINS_LETTER };
 
69
 
 
70
        m = (pdev->height / pdev->y_pixels_per_inch >= 11.1 ? m_a4 : m_letter);
 
71
        gx_device_set_margins(pdev, m, true);
 
72
        return gdev_prn_open(pdev);
 
73
}
 
74
 
 
75
char *errmsg[]={
 
76
  "EMOTOR",
 
77
  "EROS",
 
78
  "EFUSER",
 
79
  "XEROFAIL",
 
80
  "ILCKOPEN",
 
81
  "NOTRAY",
 
82
  "NOPAPR",
 
83
  "XITJAM",
 
84
  "MISFEED",
 
85
  "WDRUMX",
 
86
  "WDEVEX",
 
87
  "NODRUM",
 
88
  "NODEVE",
 
89
  "EDRUMX",
 
90
  "EDEVEX",
 
91
  "ENGCOLD",
 
92
  "TIMEOUT",
 
93
  "EDMA",
 
94
  "ESERIAL"
 
95
  };
 
96
 
 
97
/* The static buffer is unfortunate.... */
 
98
static char err_buffer[80];
 
99
static char *
 
100
err_code_string(int err_code)
 
101
  {
 
102
  if ((err_code<EMOTOR)||(err_code>ESERIAL))
 
103
    {
 
104
    gs_sprintf(err_buffer,"err_code out of range: %d",err_code);
 
105
    return err_buffer;
 
106
    }
 
107
  return errmsg[err_code];
 
108
  }
 
109
 
 
110
int warning=0;
 
111
 
 
112
static int
 
113
sparc_print_page(gx_device_printer *pdev, FILE *prn)
 
114
  {
 
115
  struct lpvi_page lpvipage;
 
116
  struct lpvi_err lpvierr;
 
117
  char *out_buf;
 
118
  int out_size;
 
119
  if (ioctl(fileno(prn),LPVIIOC_GETPAGE,&lpvipage)!=0)
 
120
    {
 
121
    errprintf(pdev->memory, "sparc_print_page: LPVIIOC_GETPAGE failed\n");
 
122
    return -1;
 
123
    }
 
124
  lpvipage.bitmap_width=gdev_mem_bytes_per_scan_line((gx_device *)pdev);
 
125
  lpvipage.page_width=lpvipage.bitmap_width*8;
 
126
  lpvipage.page_length=pdev->height;
 
127
  lpvipage.resolution = (pdev->x_pixels_per_inch == 300 ? DPI300 : DPI400);
 
128
  if (ioctl(fileno(prn),LPVIIOC_SETPAGE,&lpvipage)!=0)
 
129
    {
 
130
    errprintf(pdev->memory, "sparc_print_page: LPVIIOC_SETPAGE failed\n");
 
131
    return -1;
 
132
    }
 
133
  out_size=lpvipage.bitmap_width*lpvipage.page_length;
 
134
  out_buf=gs_malloc(pdev->memory, out_size,1,"sparc_print_page: out_buf");
 
135
  gdev_prn_copy_scan_lines(pdev,0,out_buf,out_size);
 
136
  while (write(fileno(prn),out_buf,out_size)!=out_size)
 
137
    {
 
138
    if (ioctl(fileno(prn),LPVIIOC_GETERR,&lpvierr)!=0)
 
139
      {
 
140
      errprintf(pdev->memory, "sparc_print_page: LPVIIOC_GETERR failed\n");
 
141
      return -1;
 
142
      }
 
143
    switch (lpvierr.err_type)
 
144
      {
 
145
      case 0:
 
146
        if (warning==0)
 
147
          {
 
148
          errprintf(pdev->memory,
 
149
                    "sparc_print_page: Printer Problem with unknown reason...");
 
150
          dmflush(pdev->memory);
 
151
          warning=1;
 
152
          }
 
153
        sleep(5);
 
154
        break;
 
155
      case ENGWARN:
 
156
        errprintf(pdev->memory,
 
157
                  "sparc_print_page: Printer-Warning: %s...",
 
158
                  err_code_string(lpvierr.err_code));
 
159
        dmflush(pdev->memory);
 
160
        warning=1;
 
161
        sleep(5);
 
162
        break;
 
163
      case ENGFATL:
 
164
        errprintf(pdev->memory,
 
165
                  "sparc_print_page: Printer-Fatal: %s\n",
 
166
                  err_code_string(lpvierr.err_code));
 
167
        return -1;
 
168
      case EDRVR:
 
169
        errprintf(pdev->memory,
 
170
                  "sparc_print_page: Interface/driver error: %s\n",
 
171
                  err_code_string(lpvierr.err_code));
 
172
        return -1;
 
173
      default:
 
174
        errprintf(pdev->memory,
 
175
                  "sparc_print_page: Unknown err_type=%d(err_code=%d)\n",
 
176
                  lpvierr.err_type,lpvierr.err_code);
 
177
        return -1;
 
178
      }
 
179
    }
 
180
  if (warning==1)
 
181
    {
 
182
    errprintf(pdev->memory, "OK.\n");
 
183
    warning=0;
 
184
    }
 
185
  gs_free(pdev->memory, out_buf,out_size,1,"sparc_print_page: out_buf");
 
186
  return 0;
 
187
  }