~ubuntu-branches/ubuntu/jaunty/ghostscript/jaunty-updates

« back to all changes in this revision

Viewing changes to src/gp_dosfe.c

  • Committer: Bazaar Package Importer
  • Author(s): Till Kamppeter
  • Date: 2009-01-20 16:40:45 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20090120164045-lnfhi0n30o5lwhwa
Tags: 8.64.dfsg.1~svn9377-0ubuntu1
* New upstream release (SVN rev 9377)
   o Fixes many bugs concerning PDF rendering, to make the PDF printing
     workflow correctly working.
   o Fixes long-standing bugs in many drivers, like input paper tray and
     duplex options not working for the built-in PCL 4, 5, 5c, 5e, and
     6/XL drivers, PDF input not working for bjc600, bjc800, and cups
     output devices, several options not working and uninitialized
     memory with cups output device.
   o Merged nearly all patches of the Ubuntu and Debian packages upstream.
   o Fixes LP: #317810, LP: #314439, LP: #314018.
* debian/patches/03_libpaper_support.dpatch,
  debian/patches/11_gs-cjk_font_glyph_handling_fix.dpatch,
  debian/patches/12_gs-cjk_vertical_writing_metrics_fix.dpatch,
  debian/patches/13_gs-cjk_cjkps_examples.dpatch,
  debian/patches/20_bbox_segv_fix.dpatch,
  debian/patches/21_brother_7x0_gdi_fix.dpatch,
  debian/patches/22_epsn_margin_workaround.dpatch,
  debian/patches/24_gs_man_fix.dpatch,
  debian/patches/25_toolbin_insecure_tmp_usage_fix.dpatch,
  debian/patches/26_assorted_script_fixes.dpatch,
  debian/patches/29_gs_css_fix.dpatch,
  debian/patches/30_ps2pdf_man_improvement.dpatch,
  debian/patches/31_fix-gc-sigbus.dpatch,
  debian/patches/34_ftbfs-on-hurd-fix.dpatch,
  debian/patches/35_disable_libcairo.dpatch,
  debian/patches/38_pxl-duplex.dpatch,
  debian/patches/39_pxl-resolution.dpatch,
  debian/patches/42_gs-init-ps-delaybind-fix.dpatch,
  debian/patches/45_bjc600-bjc800-pdf-input.dpatch,
  debian/patches/48_cups-output-device-pdf-duplex-uninitialized-memory-fix.dpatch,
  debian/patches/50_lips4-floating-point-exception.dpatch,
  debian/patches/52_cups-device-logging.dpatch,
  debian/patches/55_pcl-input-slot-fix.dpatch,
  debian/patches/57_pxl-input-slot-fix.dpatch,
  debian/patches/60_pxl-cups-driver-pdf.dpatch,
  debian/patches/62_onebitcmyk-pdf.dpatch,
  debian/patches/65_too-big-temp-files-1.dpatch,
  debian/patches/67_too-big-temp-files-2.dpatch,
  debian/patches/70_take-into-account-data-in-stream-buffer-before-refill.dpatch:
  Removed, applied upstream.
* debian/patches/01_docdir_fix_for_debian.dpatch,
  debian/patches/02_gs_man_fix_debian.dpatch,
  debian/patches/01_docdir-fix-for-debian.dpatch,
  debian/patches/02_docdir-fix-for-debian.dpatch: Renamed patches to
  make merging with Debian easier.
* debian/patches/32_improve-handling-of-media-size-changes-from-gv.dpatch, 
  debian/patches/33_bad-params-to-xinitimage-on-large-bitmaps.dpatch:
  regenerated for new source directory structure.
* debian/rules: Corrected paths to remove cidfmap (it is in Resource/Init/
  in GS 8.64) and to install headers (source paths are psi/ and base/ now).
* debian/rules: Remove all fontmaps, as DeFoMa replaces them.
* debian/local/pdftoraster/pdftoraster.c,
  debian/local/pdftoraster/pdftoraster.convs, debian/rules: Removed
  added pdftoraster filter and use the one which comes with Ghostscript.
* debian/ghostscript.links: s/8.63/8.64/

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (C) 2001-2006 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, modified
8
 
   or distributed except as expressly authorized under the terms of that
9
 
   license.  Refer to licensing information at http://www.artifex.com/
10
 
   or contact Artifex Software, Inc.,  7 Mt. Lassen Drive - Suite A-134,
11
 
   San Rafael, CA  94903, U.S.A., +1(415)492-9861, for further information.
12
 
*/
13
 
 
14
 
/* $Id: gp_dosfe.c 8250 2007-09-25 13:31:24Z giles $ */
15
 
/* MS-DOS file enumeration. */
16
 
#include "stdio_.h"
17
 
#include <fcntl.h>
18
 
#include "dos_.h"
19
 
#include "memory_.h"
20
 
#include "string_.h"
21
 
#include "gstypes.h"
22
 
#include "gsmemory.h"
23
 
#include "gsstruct.h"
24
 
#include "gp.h"
25
 
#include "gsutil.h"
26
 
 
27
 
struct file_enum_s {
28
 
    ff_struct_t ffblk;
29
 
    char *pattern;              /* orig pattern + modified pattern */
30
 
    int patlen;                 /* orig pattern length */
31
 
    int pat_size;               /* allocate space for pattern */
32
 
    int head_size;              /* pattern length through last */
33
 
    /* :, / or \ */
34
 
    int first_time;
35
 
    gs_memory_t *memory;
36
 
};
37
 
gs_private_st_ptrs1(st_file_enum, struct file_enum_s, "file_enum",
38
 
                    file_enum_enum_ptrs, file_enum_reloc_ptrs, pattern);
39
 
 
40
 
/* Initialize an enumeration.  Note that * and ? in a directory */
41
 
/* don't work, and \ is taken literally unless a second \ follows. */
42
 
file_enum *
43
 
gp_enumerate_files_init(const char *pat, uint patlen, gs_memory_t * mem)
44
 
{
45
 
    file_enum *pfen = gs_alloc_struct(mem, file_enum, &st_file_enum, "gp_enumerate_files");
46
 
    int pat_size = 2 * patlen + 1;
47
 
    char *pattern;
48
 
    char *p;
49
 
    int hsize = 0;
50
 
    int i;
51
 
    int dot = 0;
52
 
 
53
 
    if (pfen == 0)
54
 
        return 0;
55
 
 
56
 
    /* pattern could be allocated as a string, */
57
 
    /* but it's simpler for GC and freeing to allocate it as bytes. */
58
 
 
59
 
    pattern = (char *)gs_alloc_bytes(mem, pat_size,
60
 
                                     "gp_enumerate_files(pattern)");
61
 
    if (pattern == 0)
62
 
        return 0;
63
 
    memcpy(pattern, pat, patlen);
64
 
    p = pattern + patlen;
65
 
    for (i = 0; i < patlen; i++) {
66
 
        switch (pat[i]) {
67
 
            case '*':
68
 
                /* Skip to . or end of string so DOS can do it. */
69
 
                *p++ = '*';
70
 
                while (i < patlen && pat[i] != '.')
71
 
                    i++;
72
 
                if (i == patlen && !dot) {      /* DOS doesn't interpret * alone as */
73
 
                    /* matching all files; we need *.*. */
74
 
                    *p++ = '.';
75
 
                    *p++ = '*';
76
 
                }
77
 
                i--;
78
 
                continue;
79
 
            case '.':
80
 
                dot = 1;
81
 
                break;
82
 
            case '\\':
83
 
                if (i + 1 < patlen && pat[i + 1] == '\\')
84
 
                    i++;
85
 
                /* falls through */
86
 
            case ':':
87
 
            case '/':
88
 
                hsize = p + 1 - (pattern + patlen);
89
 
                dot = 0;
90
 
        }
91
 
        *p++ = pat[i];
92
 
    }
93
 
    *p = 0;
94
 
    pfen->pattern = pattern;
95
 
    pfen->patlen = patlen;
96
 
    pfen->pat_size = pat_size;
97
 
    pfen->head_size = hsize;
98
 
    pfen->memory = mem;
99
 
    pfen->first_time = 1;
100
 
    return pfen;
101
 
}
102
 
 
103
 
/* Enumerate the next file. */
104
 
static const string_match_params smp_file =
105
 
{'*', '?', -1, true, true};
106
 
 
107
 
uint
108
 
gp_enumerate_files_next(file_enum * pfen, char *ptr, uint maxlen)
109
 
{
110
 
    int code;
111
 
    char *p, *q;
112
 
    uint len;
113
 
    const char *fpat = pfen->pattern + pfen->patlen;
114
 
 
115
 
  top:if (pfen->first_time) {
116
 
        code = dos_findfirst(fpat, &pfen->ffblk);
117
 
        pfen->first_time = 0;
118
 
    } else
119
 
        code = dos_findnext(&pfen->ffblk);
120
 
    if (code != 0) {            /* All done, clean up. */
121
 
        gp_enumerate_files_close(pfen);
122
 
        return ~(uint) 0;
123
 
    }
124
 
    if (maxlen < 13 + pfen->head_size)
125
 
        return maxlen + 1;      /* cop out! */
126
 
    memcpy(ptr, fpat, pfen->head_size);
127
 
    for (p = &pfen->ffblk.ff_name[0], q = ptr + pfen->head_size; *p; p++)
128
 
        if (*p != ' ')
129
 
            *q++ = *p;
130
 
    len = q - ptr;
131
 
    /* Make sure this file really matches the pattern. */
132
 
    if (!string_match(ptr, len, pfen->pattern, pfen->patlen, &smp_file))
133
 
        goto top;
134
 
    return len;
135
 
}
136
 
 
137
 
/* Clean up the file enumeration. */
138
 
void
139
 
gp_enumerate_files_close(file_enum * pfen)
140
 
{
141
 
    gs_memory_t *mem = pfen->memory;
142
 
 
143
 
    gs_free_object(mem, pfen->pattern,
144
 
                   "gp_enumerate_files_close(pattern)");
145
 
    gs_free_object(mem, pfen, "gp_enumerate_files_close");
146
 
}