[gs-cvs] rev 8878 - trunk/gs/src

alexcher at ghostscript.com alexcher at ghostscript.com
Sat Jul 26 19:52:12 PDT 2008


Author: alexcher
Date: 2008-07-26 19:52:11 -0700 (Sat, 26 Jul 2008)
New Revision: 8878

Added:
   trunk/gs/src/zfile.h
Modified:
   trunk/gs/src/gsiorom.c
   trunk/gs/src/int.mak
   trunk/gs/src/zfile.c
   trunk/gs/src/zfrsd.c
Log:
Fix direct access to a subfile in the %rom% file system by reusable
stream. Bug 689976, customers 661, 580.

DETAILS:
1. Open the source file of the reusable stream as a general stream,
   rather than an os-based file stream.
2. Take into account file_offset member when accessing the stream.

DIFFERENCES:
None


Modified: trunk/gs/src/gsiorom.c
===================================================================
--- trunk/gs/src/gsiorom.c	2008-07-25 22:51:14 UTC (rev 8877)
+++ trunk/gs/src/gsiorom.c	2008-07-27 02:52:11 UTC (rev 8878)
@@ -144,7 +144,7 @@
 	stream_cursor_write pw;
 
 	/* buffer stays aligned to blocks */
-	offset = pos % ROMFS_BLOCKSIZE;
+	offset = (s->file_offset + pos) % ROMFS_BLOCKSIZE;
 	s->position = pos - offset;
 	pw.ptr = s->cbuf - 1;
 	pw.limit = pw.ptr + s->cbsize;
@@ -182,7 +182,7 @@
     int compression = ((get_u32_big_endian(node) & 0x80000000) != 0) ? 1 : 0;
     uint32_t filelen = get_u32_big_endian(node) & 0x7fffffff;	/* ignore compression bit */
     uint32_t blocks = (filelen+ROMFS_BLOCKSIZE-1)/ ROMFS_BLOCKSIZE;
-    int iblock = (s->position + pw->ptr + 1 - s->cbuf) / ROMFS_BLOCKSIZE;
+    int iblock = (s->position + s->file_offset + pw->ptr + 1 - s->cbuf) / ROMFS_BLOCKSIZE;
     unsigned long block_length = get_u32_big_endian(node+1+(2*iblock));
     unsigned const long block_offset = get_u32_big_endian(node+2+(2*iblock));
     unsigned const char *block_data = ((unsigned char *)node) + block_offset;

Modified: trunk/gs/src/int.mak
===================================================================
--- trunk/gs/src/int.mak	2008-07-25 22:51:14 UTC (rev 8877)
+++ trunk/gs/src/int.mak	2008-07-27 02:52:11 UTC (rev 8878)
@@ -255,6 +255,7 @@
 igstate_h=$(PSSRC)igstate.h $(gsstate_h) $(gxstate_h) $(imemory_h) $(istruct_h) $(gxcindex_h)
 iscan_h=$(PSSRC)iscan.h $(sa85x_h) $(sstring_h)
 sbhc_h=$(PSSRC)sbhc.h $(shc_h)
+zfile_h=$(PSSRC)zfile.h
 # Include files for optional features
 ibnum_h=$(PSSRC)ibnum.h
 
@@ -321,7 +322,8 @@
  $(gscdefs_h) $(gsfname_h) $(gsstruct_h) $(gsutil_h) $(gxalloc_h) $(gxiodev_h)\
  $(dstack_h) $(estack_h) $(files_h)\
  $(ialloc_h) $(idict_h) $(ilevel_h) $(iname_h) $(iutil_h)\
- $(isave_h) $(main_h) $(sfilter_h) $(stream_h) $(strimpl_h) $(store_h)
+ $(isave_h) $(main_h) $(sfilter_h) $(stream_h) $(strimpl_h) $(store_h)\
+ $(zfile_h)
 	$(PSCC) $(PSO_)zfile.$(OBJ) $(C_) $(PSSRC)zfile.c
 
 $(PSOBJ)zfile1.$(OBJ) : $(PSSRC)zfile1.c $(OP) $(memory__h) $(string__h)\
@@ -1060,7 +1062,8 @@
 $(PSOBJ)zfrsd.$(OBJ) : $(PSSRC)zfrsd.c $(OP) $(memory__h)\
  $(gsfname_h) $(gxiodev_h)\
  $(sfilter_h) $(stream_h) $(strimpl_h)\
- $(files_h) $(idict_h) $(idparam_h) $(iname_h) $(istruct_h) $(store_h)
+ $(files_h) $(idict_h) $(idparam_h) $(iname_h) $(istruct_h) $(store_h)\
+ $(zfile_h)
 	$(PSCC) $(PSO_)zfrsd.$(OBJ) $(C_) $(PSSRC)zfrsd.c
 
 # ======================== PostScript Level 2 ======================== #

Modified: trunk/gs/src/zfile.c
===================================================================
--- trunk/gs/src/zfile.c	2008-07-25 22:51:14 UTC (rev 8877)
+++ trunk/gs/src/zfile.c	2008-07-27 02:52:11 UTC (rev 8878)
@@ -42,6 +42,7 @@
 #include "files.h"
 #include "main.h"		/* for gs_lib_paths */
 #include "store.h"
+#include "zfile.h"
 
 /* Import the IODevice table. */
 extern_gx_io_device_table();
@@ -59,9 +60,6 @@
 /* Forward references: other. */
 static int execfile_finish(i_ctx_t *);
 static int execfile_cleanup(i_ctx_t *);
-static int zopen_file(i_ctx_t *, const gs_parsed_file_name_t *pfn,
-		       const char *file_access, stream **ps,
-		       gs_memory_t *mem);
 static iodev_proc_open_file(iodev_os_open_file);
 stream_proc_report_error(filter_report_error);
 
@@ -831,7 +829,7 @@
  * Open a file specified by a parsed file name (which may be only a
  * device).
  */
-static int
+int
 zopen_file(i_ctx_t *i_ctx_p, const gs_parsed_file_name_t *pfn,
 	   const char *file_access, stream **ps, gs_memory_t *mem)
 {

Added: trunk/gs/src/zfile.h
===================================================================
--- trunk/gs/src/zfile.h	2008-07-25 22:51:14 UTC (rev 8877)
+++ trunk/gs/src/zfile.h	2008-07-27 02:52:11 UTC (rev 8878)
@@ -0,0 +1,44 @@
+/* Copyright (C) 2008 Artifex Software, Inc.
+   All Rights Reserved.
+  
+   This software is provided AS-IS with no warranty, either express or
+   implied.
+
+   This software is distributed under license and may not be copied, modified
+   or distributed except as expressly authorized under the terms of that
+   license.  Refer to licensing information at http://www.artifex.com/
+   or contact Artifex Software, Inc.,  7 Mt. Lassen Drive - Suite A-134,
+   San Rafael, CA  94903, U.S.A., +1(415)492-9861, for further information.
+*/
+/* $Id: zfile.h 8022 2007-06-05 22:23:38Z giles $ */
+/* Export zopen_file() for zfrsd.c */
+
+#ifndef zfile_INCLUDED
+#  define zfile_INCLUDED
+
+int zopen_file(i_ctx_t *i_ctx_p, const gs_parsed_file_name_t *pfn,
+           const char *file_access, stream **ps, gs_memory_t *mem);
+
+#endif
+/* Copyright (C) 2008 Artifex Software, Inc.
+   All Rights Reserved.
+  
+   This software is provided AS-IS with no warranty, either express or
+   implied.
+
+   This software is distributed under license and may not be copied, modified
+   or distributed except as expressly authorized under the terms of that
+   license.  Refer to licensing information at http://www.artifex.com/
+   or contact Artifex Software, Inc.,  7 Mt. Lassen Drive - Suite A-134,
+   San Rafael, CA  94903, U.S.A., +1(415)492-9861, for further information.
+*/
+/* $Id: zfile.h 8022 2007-06-05 22:23:38Z giles $ */
+/* Export zopen_file() for zfrsd.c */
+
+#ifndef zfile_INCLUDED
+#  define zfile_INCLUDED
+
+int zopen_file(i_ctx_t *i_ctx_p, const gs_parsed_file_name_t *pfn,
+           const char *file_access, stream **ps, gs_memory_t *mem);
+
+#endif

Modified: trunk/gs/src/zfrsd.c
===================================================================
--- trunk/gs/src/zfrsd.c	2008-07-25 22:51:14 UTC (rev 8877)
+++ trunk/gs/src/zfrsd.c	2008-07-27 02:52:11 UTC (rev 8878)
@@ -27,6 +27,7 @@
 #include "iname.h"
 #include "istruct.h"
 #include "store.h"
+#include "zfile.h"
 
 /* ---------------- Reusable streams ---------------- */
 
@@ -273,9 +274,7 @@
 	pname.iodev = iodev_default;
     /* Open the file again, to be independent of the source. */
     ialloc_set_space(idmemory, stream_space);
-    code = file_open_stream((const char *)pname.fname, pname.len, "r",
-			    fs->cbsize, &s, pname.iodev,
-			    pname.iodev->procs.fopen, imemory);
+    code = zopen_file(i_ctx_p, &pname, "r", &s, imemory);
     ialloc_set_space(idmemory, save_space);
     if (code < 0)
 	return code;



More information about the gs-cvs mailing list