[gs-cvs] rev 6998 - in trunk/gs: lib src

ray at ghostscript.com ray at ghostscript.com
Thu Aug 17 21:42:13 PDT 2006


Author: ray
Date: 2006-08-17 21:42:11 -0700 (Thu, 17 Aug 2006)
New Revision: 6998

Added:
   trunk/gs/src/strmio.c
   trunk/gs/src/strmio.h
Modified:
   trunk/gs/lib/FAPIconfig-FCO
   trunk/gs/lib/gs_fapi.ps
   trunk/gs/src/fapi_ft.c
   trunk/gs/src/fapiufst.c
   trunk/gs/src/gpmisc.c
   trunk/gs/src/int.mak
   trunk/gs/src/iplugin.c
   trunk/gs/src/iplugin.h
   trunk/gs/src/lib.mak
Log:
Modifications to switch to "strmio" stream I/O so that we can read from
either OS file system or IODevice files (such as %rom% file system).
Also remove unneeded i_ctx_p from fapi_*_instantiate functions (so that
we don't need the PS interpreter). The strmio functions are now included
in the graphics lib build (always).

Change fapiufst to use strmio instead of FILE * file IO. A separate change
is needed in UFST code to do this (fc_dafil.*)

Add UFST_ROMFS_ARGS to add the fco's to the %rom% file list. Note that the
UFST_ROMFS_ARGS are not defined in any top level makefile in the gs tree
but are used by the language_switch build where they have been tested.

Remove some 'hard coded' paths in the fapiufst module (F:/...)


Modified: trunk/gs/lib/FAPIconfig-FCO
===================================================================
--- trunk/gs/lib/FAPIconfig-FCO	2006-08-18 04:04:48 UTC (rev 6997)
+++ trunk/gs/lib/FAPIconfig-FCO	2006-08-18 04:42:11 UTC (rev 6998)
@@ -2,8 +2,8 @@
 % $Id$
 % This is configuration file for FAPI client.
 
-/FontPath             (.) % A default directory for FAPI-handled font files path in FAPIfontmap.
-/CIDFontPath          (.) % A default directory for FAPI-handled CID font files path in FAPIcidfmap.
+/FontPath             () % A default directory for FAPI-handled font files path in FAPIfontmap.
+/CIDFontPath          () % A default directory for FAPI-handled CID font files path in FAPIcidfmap.
 /HookDiskFonts        []  % FontType values for disk PS fonts to be redirected to FAPI.
 /HookEmbeddedFonts    []  % FontType values for embedded PS fonts to be redirected to FAPI.
 

Modified: trunk/gs/lib/gs_fapi.ps
===================================================================
--- trunk/gs/lib/gs_fapi.ps	2006-08-18 04:04:48 UTC (rev 6997)
+++ trunk/gs/lib/gs_fapi.ps	2006-08-18 04:42:11 UTC (rev 6998)
@@ -55,7 +55,6 @@
 
 /Config
 <<
-%% Replace 1 (FAPIconfig)
   systemdict /FAPIconfig known {/FAPIconfig .systemvar} {(FAPIconfig)} ifelse .runlibfile
   /ServerOptions 2 dict
 >> def

Modified: trunk/gs/src/fapi_ft.c
===================================================================
--- trunk/gs/src/fapi_ft.c	2006-08-18 04:04:48 UTC (rev 6997)
+++ trunk/gs/src/fapi_ft.c	2006-08-18 04:42:11 UTC (rev 6998)
@@ -867,8 +867,7 @@
 
 plugin_instantiation_proc(gs_fapi_ft_instantiate);
 
-int gs_fapi_ft_instantiate(i_ctx_t *a_context,
-						   i_plugin_client_memory *a_memory,
+int gs_fapi_ft_instantiate( i_plugin_client_memory *a_memory,
 						   i_plugin_instance **a_plugin_instance)
 	{
 	FF_server *server = (FF_server *)a_memory->alloc(a_memory,

Modified: trunk/gs/src/fapiufst.c
===================================================================
--- trunk/gs/src/fapiufst.c	2006-08-18 04:04:48 UTC (rev 6997)
+++ trunk/gs/src/fapiufst.c	2006-08-18 04:42:11 UTC (rev 6998)
@@ -11,7 +11,7 @@
    San Rafael, CA  94903, U.S.A., +1(415)492-9861, for further information.
 */
 /* $Id$ */
-/* UFST plugin */
+/* Agfa UFST plugin */
 
 /* GS includes : */
 #include "stdio_.h"
@@ -20,6 +20,7 @@
 #include "ierrors.h"
 #include "iplugin.h"
 #include "ifapi.h"
+#include "strmio.h"
 /* UFST includes : */
 #undef true	/* GS/UFST definition conflict. */
 #undef false	/* GS/UFST definition conflict. */
@@ -37,12 +38,8 @@
 
 typedef struct fapi_ufst_server_s fapi_ufst_server;
 
-#define DEBUG_STATIC_FCO 0
+static SW16 static_fcHandle[3] = { 0, 0, 0 };
 
-#if DEBUG_STATIC_FCO
-static SW16 static_fcHandle[2];
-#endif
-
 #if UFST_REENTRANT
 #define FSA_FROM_SERVER IF_STATE *pIFS = &r->IFS
 #else
@@ -51,7 +48,9 @@
 private fapi_ufst_server *static_server_ptr_for_ufst_callback = 0;
 #endif
 
+#ifndef PSI_INCLUDED
 GLOBAL const SW16 trace_sw = 0; /* UFST 4.3 wants it. */
+#endif
 
 GLOBAL UW16  PCLswapHdr( FSP LPUB8 p, UW16 gifct ); /* UFST header doesn't define it. */
 
@@ -194,14 +193,6 @@
 #endif
     }
 
-#if DEBUG_STATIC_FCO
-    code = gx_UFST_open_static_fco("F:/AFPL/ufst/fontdata/MTFONTS/PCLPS2/MT3/pclp2_xj.fco", &static_fcHandle[0]);
-    if (code != 0)
-	return code;
-    code = gx_UFST_open_static_fco("F:/AFPL/ufst/fontdata/MTFONTS/PCL45/MT3/wd____xh.fco", &static_fcHandle[1]);
-    if (code != 0)
-	return code;
-#endif
     return 0;
 }		      
 
@@ -228,11 +219,11 @@
     return 0;
 }
 
-private UW16 get_font_type(FILE *f)
+private UW16 get_font_type(stream *f)
 {   char buf[20], mark_PS[]="%!";
     int i;
 
-    if (fread(buf, 1, sizeof(buf), f) != sizeof(buf))
+    if (sfread(buf, 1, sizeof(buf), f) != sizeof(buf))
         return 0;
     if (buf[0] == 0x15 || buf[0] == 0x00) /* fixme : don't know how to do correctly. */
         return FC_FCO_TYPE;
@@ -662,14 +653,14 @@
 	    d->font_id = (e->fcHandle << 16) | ff->subfont;
 	    d->font_type = FC_FCO_TYPE;
 	} else {
-	    FILE *f = fopen(font_file_path, "rb"); /* note: gp_fopen isn't better since UFST calls fopen. */
+	    stream *f = sfopen(font_file_path, "rb", (gs_memory_t *)(r->client_mem.client_data));
 	    if (f == NULL) {
 		eprintf1("fapiufst: Can't open %s\n", font_file_path);
 		return e_undefinedfilename;
 	    }
 	    memcpy(d + 1, font_file_path, strlen(font_file_path) + 1);
 	    d->font_type = get_font_type(f);
-	    fclose(f);
+	    sfclose(f);
 	    if (d->font_type == FC_FCO_TYPE) {
 		fco_list_elem *e;
 		if ((code = fco_open(r, font_file_path, &e)) != 0)
@@ -880,17 +871,20 @@
 
 private FAPI_retcode get_font_proportional_feature(FAPI_server *server, FAPI_font *ff, bool *bProportional)
 {   fapi_ufst_server *r = If_to_I(server);
-    UB8 buf[74];
-    UL32 length = sizeof(buf);
     FSA_FROM_SERVER;
 
     *bProportional = false;
     if (ff->font_file_path == NULL || ff->is_type1)
         return 0;
 #if TT_ROM || TT_DISK
+    { 
+	UB8 buf[74];
+	UL32 length = sizeof(buf);
+
     if (CGIFtt_query(FSA (UB8 *)ff->font_file_path, *(UL32 *)"OS/2", (UW16)ff->subfont, &length, buf) != 0)
         return 0; /* No OS/2 table - no chance to get the info. Use default == false. */
     *bProportional = (buf[35] == 9);
+    }
 #endif
     return 0;
 }
@@ -1311,7 +1305,7 @@
 
 plugin_instantiation_proc(gs_fapiufst_instantiate);      /* check prototype */
 
-int gs_fapiufst_instantiate(i_ctx_t *i_ctx_p, i_plugin_client_memory *client_mem, i_plugin_instance **p_instance)
+int gs_fapiufst_instantiate(i_plugin_client_memory *client_mem, i_plugin_instance **p_instance)
 {   fapi_ufst_server *r = (fapi_ufst_server *)client_mem->alloc(client_mem, sizeof(fapi_ufst_server), "fapi_ufst_server");
 
     if (r == 0)
@@ -1329,14 +1323,6 @@
 
     if (r->If.ig.d != &ufst_descriptor)
         return; /* safety */
-#if DEBUG_STATIC_FCO
-    gx_UFST_close_static_fco(static_fcHandle[0]);
-    gx_UFST_close_static_fco(static_fcHandle[1]);
-#endif
-#if 0 /* Disabled against a reentrancy problem 
-	 in a single language build for host-based applications. */
-    gx_set_UFST_Callbacks(NULL, NULL, NULL);
-#endif
     release_char_data_inline(r);
     if (r->bInitialized) {
 #	if UFST_REENTRANT

Modified: trunk/gs/src/gpmisc.c
===================================================================
--- trunk/gs/src/gpmisc.c	2006-08-18 04:04:48 UTC (rev 6997)
+++ trunk/gs/src/gpmisc.c	2006-08-18 04:42:11 UTC (rev 6998)
@@ -120,6 +120,8 @@
  * directory references from the concatenation when possible.
  * The trailing zero byte is being added.
  *
+ * Also tolerates/skips leading IODevice specifiers such as %os% or %rom%
+ *
  * Examples : 
  *	"/gs/lib" + "../Resource/CMap/H" --> "/gs/Resource/CMap/H"
  *	"C:/gs/lib" + "../Resource/CMap/H" --> "C:/gs/Resource/CMap/H"
@@ -129,6 +131,8 @@
  *		"DUA1:[GHOSTSCRIPT.RESOURCE.CMAP]H"
  *      "\\server\share/a/b///c/../d.e/./" + "../x.e/././/../../y.z/v.v" --> 
  *		"\\server\share/a/y.z/v.v"
+ *	"%rom%lib/" + "gs_init.ps" --> "%rom%lib/gs_init.ps
+ *	"" + "%rom%lib/gs_init.ps" --> "%rom%lib/gs_init.ps"
  */
 gp_file_name_combine_result
 gp_file_name_combine_generic(const char *prefix, uint plen, const char *fname, uint flen, 
@@ -141,12 +145,22 @@
      */
     char *bp = buffer, *bpe = buffer + *blen;
     const char *ip, *ipe;
-    uint slen;
+    uint slen = 0;	/* initial use is as flag: 0 != no prefix */
     uint infix_type = 0; /* 0=none, 1=current, 2=parent. */
     uint infix_len = 0;
-    uint rlen = gp_file_name_root(fname, flen);
-    /* We need a special handling of infixes only immediately after a drive. */
+    uint rlen = 0;
 
+    /* Check for IODevice first since 'root' specifiers will follow %os% */
+    /* Note that IODevices are platform independent */
+    if (fname[0] == '%') {
+	slen = 1;		/* IODevices never append/insert the prefix */
+	for (rlen=1; rlen < flen; rlen++)
+	    if (fname[rlen] == '%')
+		break;
+    }
+    rlen += gp_file_name_root(fname+rlen, flen-rlen);
+    /* We need a special handling of infixes only immediately after a drive.
+     * or IODevice (such as %os%) */
     if (rlen != 0) {
         /* 'fname' is absolute, ignore the prefix. */
 	ip = fname;
@@ -159,7 +173,7 @@
     }
     if (!append(&bp, bpe, &ip, rlen))
 	return gp_combine_small_buffer;
-    slen = gs_file_name_check_separator(bp, buffer - bp, bp); /* Backward search. */
+    slen += gs_file_name_check_separator(bp, buffer - bp, bp); /* Backward search. */
     if (rlen != 0 && slen == 0) {
 	/* Patch it against names like "c:dir" on Windows. */
 	const char *sep = gp_file_name_directory_separator();

Modified: trunk/gs/src/int.mak
===================================================================
--- trunk/gs/src/int.mak	2006-08-18 04:04:48 UTC (rev 6997)
+++ trunk/gs/src/int.mak	2006-08-18 04:42:11 UTC (rev 6998)
@@ -979,7 +979,7 @@
 # This changes infrequently, but is a potential point of bitrot, but since
 # unix-inst.mak uses this macro, problems should surface when testing installed
 # versions.
-EXTRA_INIT_FILES= Fontmap cidfmap xlatmap FAPIcidfmap FAPIconfig FAPIfontmap
+EXTRA_INIT_FILES= Fontmap cidfmap xlatmap FAPI FCOfontmap-PCLPS2 
 
 #	The init files are put in the lib/ directory (gs_init.ps + EXTRA_INIT_FILES)
 #	Resource files go into Resource/...
@@ -989,7 +989,7 @@
 # PCLXL_ PJL and XPS hooks are for other parsers that may be built with a PS
 # language switch build.
 $(GLOBJ)gsromfs.c : $(MKROMFS_XE) $(PSGEN)gs_init.ps $(arch_h)
-	$(EXP)$(MKROMFS_XE) -o $(GLOBJ)gsromfs.c -c -X .svn -P $(PSRESDIR)$(D) -d Resource/ $(RESOURCE_LIST) -d lib/ -P $(PSGEN) gs_init.ps -P $(PSLIB) $(EXTRA_INIT_FILES) $(PCLXL_ROMFS_ARGS) $(PJL_ROMFS_ARGS) $(XPS_ROMFS_ARGS)
+	$(EXP)$(MKROMFS_XE) -o $(GLOBJ)gsromfs.c -X .svn $(UFST_ROMFS_ARGS) $(PCLXL_ROMFS_ARGS) $(PJL_ROMFS_ARGS) $(XPS_ROMFS_ARGS) $(UFST_ROMGS_ARGS) -c -P $(PSRESDIR)$(D) -d Resource/ $(RESOURCE_LIST) -d lib/ -P $(PSGEN) gs_init.ps -P $(PSLIB) $(EXTRA_INIT_FILES) 
 
 # ---------------- Stochastic halftone ---------------- #
 
@@ -1899,7 +1899,7 @@
 	$(ADDMOD) $(PSD)fapiu1 -link $(UFST_LIB)tt_lib$(UFST_LIB_EXT) $(UFST_LIB)psi_lib$(UFST_LIB_EXT)
 
 $(PSOBJ)fapiufst.$(OBJ) : $(PSSRC)fapiufst.c $(AK)\
- $(memory__h) $(stdio__h) $(math__h)\
+ $(memory__h) $(stdio__h) $(math__h) $(strmio_h)\
  $(ierrors_h) $(iplugin_h) $(ifapi_h) $(gxfapi_h) $(gp_h) $(gxfapiu_h) \
  $(UFST_ROOT)$(D)rts$(D)inc$(D)cgconfig.h\
  $(UFST_ROOT)$(D)rts$(D)inc$(D)shareinc.h\

Modified: trunk/gs/src/iplugin.c
===================================================================
--- trunk/gs/src/iplugin.c	2006-08-18 04:04:48 UTC (rev 6997)
+++ trunk/gs/src/iplugin.c	2006-08-18 04:42:11 UTC (rev 6998)
@@ -56,7 +56,7 @@
     i_plugin_make_memory(&client_mem, mem_raw);
     for (; *p != 0; p++) {
         i_plugin_instance *instance = 0;
-        code = (*p)(i_ctx_p, &client_mem, &instance);
+        code = (*p)(&client_mem, &instance);
         if (code != 0)
             return code;
         h = (i_plugin_holder *)gs_alloc_bytes_immovable(mem_raw, sizeof(i_plugin_holder), "plugin_holder");

Modified: trunk/gs/src/iplugin.h
===================================================================
--- trunk/gs/src/iplugin.h	2006-08-18 04:04:48 UTC (rev 6997)
+++ trunk/gs/src/iplugin.h	2006-08-18 04:42:11 UTC (rev 6998)
@@ -54,7 +54,7 @@
 };
 
 #define plugin_instantiation_proc(proc)\
-  int proc(i_ctx_t *, i_plugin_client_memory *client_mem, i_plugin_instance **instance)
+  int proc(i_plugin_client_memory *client_mem, i_plugin_instance **instance)
 
 #define extern_i_plugin_table()\
   typedef plugin_instantiation_proc((*i_plugin_instantiation_proc));\

Modified: trunk/gs/src/lib.mak
===================================================================
--- trunk/gs/src/lib.mak	2006-08-18 04:04:48 UTC (rev 6997)
+++ trunk/gs/src/lib.mak	2006-08-18 04:42:11 UTC (rev 6998)
@@ -1066,7 +1066,7 @@
 
 ###### Create a pseudo-"feature" for the entire graphics library.
 
-LIB0s=$(GLOBJ)gpmisc.$(OBJ) $(GLOBJ)stream.$(OBJ)
+LIB0s=$(GLOBJ)gpmisc.$(OBJ) $(GLOBJ)stream.$(OBJ) $(GLOBJ)strmio.$(OBJ)
 LIB1s=$(GLOBJ)gsalloc.$(OBJ) $(GLOBJ)gsalpha.$(OBJ)
 LIB2s=$(GLOBJ)gsbitcom.$(OBJ) $(GLOBJ)gsbitops.$(OBJ) $(GLOBJ)gsbittab.$(OBJ)
 # Note: gschar.c is no longer required for a standard build;
@@ -1195,6 +1195,13 @@
 $(GLOBJ)sfxboth.$(OBJ) : $(GLSRC)sfxboth.c $(GLSRC)sfxstdio.c $(GLSRC)sfxfd.c
 	$(GLCC) $(GLO_)sfxboth.$(OBJ) $(C_) $(GLSRC)sfxboth.c
 
+strmio_h=$(GLSRC)strmio.h
+
+$(GLOBJ)strmio.$(OBJ): $(GLSRC)strmio.c $(AK) \
+  $(memory__h) $(gdebug_h) $(gsfname_h)\
+  $(gsmalloc_h) $(gsmemret_h) $(strmio_h) $(stream_h)
+	$(GLCC) $(GLO_)strmio.$(OBJ) $(C_) $(GLSRC)strmio.c 
+
 # ---------------- BCP filters ---------------- #
 
 $(GLOBJ)sbcp.$(OBJ) : $(GLSRC)sbcp.c $(AK) $(stdio__h)\

Added: trunk/gs/src/strmio.c
===================================================================
--- trunk/gs/src/strmio.c	2006-08-18 04:04:48 UTC (rev 6997)
+++ trunk/gs/src/strmio.c	2006-08-18 04:42:11 UTC (rev 6998)
@@ -0,0 +1,171 @@
+/* Copyright (C) 2006 artofcode LLC.
+   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$ */
+/* Interface for streams that mimic stdio functions (fopen, fread, fseek, ftell) */
+
+#include "malloc_.h"
+#include "memory_.h"
+#include "gxiodev.h"
+#include "gdebug.h"
+#include "gsfname.h"
+#include "gslibctx.h"
+#include "gsmemret.h" /* for gs_memory_type_ptr_t */
+#include "gsmalloc.h"
+#include "gsstype.h"
+#include "stream.h"
+#include "strmio.h"
+
+/*
+ * Open a stream using a filename that can include a PS style IODevice prefix
+ * If iodev_default is the '%os' device, then the file will be on the host
+ * file system transparently to the caller. The "%os%" prefix can be used
+ * to explicilty access the host file system.
+ */
+stream *
+sfopen(const char *path, const char *mode, gs_memory_t *memory)
+{
+    gs_parsed_file_name_t pfn;
+    stream *s;
+    iodev_proc_open_file((*open_file));
+    gs_memory_t *mem = (memory == NULL) ? gs_lib_ctx_get_non_gc_memory_t() : memory;
+
+    int code = gs_parse_file_name(&pfn, path, strlen(path));
+    if (code < 0) {
+#	define EMSG	"sfopen: gs_parse_file_name failed.\n"
+	errwrite(EMSG, strlen(EMSG));
+#	undef EMSG
+	return NULL;
+    }
+    if (pfn.fname == NULL) {	/* just a device */
+#	define EMSG	"sfopen: not allowed with %device only.\n"
+	errwrite(EMSG, strlen(EMSG));
+#	undef EMSG
+	return NULL;
+    }
+    if (pfn.iodev == NULL)
+	pfn.iodev = iodev_default;
+    open_file = pfn.iodev->procs.open_file;
+    if (open_file == 0)
+	code = file_open_stream(pfn.fname, pfn.len, mode, 2048, &s,
+				pfn.iodev, pfn.iodev->procs.fopen, mem);
+    else
+	code = open_file(pfn.iodev, pfn.fname, pfn.len, mode, &s, mem);
+    if (code < 0)
+	return NULL;
+    code = ssetfilename(s, path, strlen(path));
+    if (code < 0) {
+	/* Only error is e_VMerror */
+	sclose(s);
+	gs_free_object(s->memory, s, "sfopen: allocation error");
+#	define EMSG	"sfopen: allocation error setting path name into stream.\n"
+	errwrite(EMSG, strlen(EMSG));
+#	undef EMSG
+	return NULL;
+    }
+    return s;
+}
+
+/*
+ * Read a number of bytes from a stream, returning number read. Return count
+ * will be less than count if EOF or error. Return count is number of elements.
+ */
+int
+sfread(void *ptr, size_t size, size_t count, stream *s)
+{
+    int code;
+    uint nread;
+
+    code = sgets(s, ptr, size*count, &nread);
+    return nread*size;
+}
+
+/*
+ * Read a byte from a stream
+ */
+int
+sfgetc(stream *s)
+{
+    int code = sgetc(s);
+
+    return code >= 0 ? code : EOF;
+}
+
+/*
+ * Seek to a position in the stream. Returns the 0, or -1 if error
+ */
+int
+sfseek(stream *s, long offset, int whence)
+{
+    long newpos = offset;
+
+    if (whence == SEEK_CUR)
+	newpos += stell(s);
+    if (whence == SEEK_END) {
+	long endpos;
+
+	if (savailable(s, &endpos) < 0)
+	    return -1;
+	newpos = endpos - offset;
+    }
+    if (s_can_seek(s) || newpos == stell(s)) {
+	return sseek(s, newpos);
+    }
+    return -1;		/* fail */
+}
+
+/*
+ * Position to the beginning of the file
+ */
+int
+srewind(stream *s)
+{
+    return sfseek(s, 0, SEEK_SET);
+}
+
+/*
+ * Return the current position in the stream or -1 if error.
+ */
+long
+sftell(stream *s)
+{
+    return stell(s);
+}
+
+/*
+ * Return the EOF status, or 0 if not at EOF.
+ */
+int
+sfeof(stream *s)
+{
+    return (s->end_status == EOFC) ? -1 : 0;
+}
+
+/*
+ * Return the error status, or 0 if no error
+ */
+int
+sferror(stream *s)
+{
+    return (s->end_status == ERRC) ? -1 : 0;
+}
+
+int
+sfclose(stream *s)
+{
+    /* no need to flush since these are 'read' only */
+    gs_memory_t *mem = s->memory;
+    sclose(s);
+    gs_free_object(mem, s, "sfclose(stream)");
+    return 0;
+}

Added: trunk/gs/src/strmio.h
===================================================================
--- trunk/gs/src/strmio.h	2006-08-18 04:04:48 UTC (rev 6997)
+++ trunk/gs/src/strmio.h	2006-08-18 04:42:11 UTC (rev 6998)
@@ -0,0 +1,90 @@
+/* Copyright (C) 2006 artofcode LLC.
+   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$ */
+/* Interface for streams that mimic stdio functions (fopen, fread, fseek, ftell) */
+/* Requires stream.h */
+
+#ifndef strmio_INCLUDED
+#  define strmio_INCLUDED
+
+#ifndef stream_DEFINED
+#  define stream_DEFINED
+typedef struct stream_s stream;
+#endif /* stream_DEFINED */
+
+#ifndef gs_memory_DEFINED
+#  define gs_memory_DEFINED
+typedef struct gs_memory_s gs_memory_t;
+#endif /* gs_memory_DEFINED */
+
+/*
+ * Open a stream using a filename that can include a PS style IODevice prefix
+ * If iodev_default is the '%os' device, then the file will be on the host
+ * file system transparently to the caller. The "%os%" prefix can be used
+ * to explicilty access the host file system.
+ */
+stream *
+sfopen(const char *path, const char *mode, gs_memory_t *mem);
+
+/*
+ * Read a number of bytes from a stream, returning number read. Return count
+ * will be less than count if EOF or error. Return count is number of elements.
+ */
+int
+sfread(void *ptr, size_t size, size_t count, stream *s);	
+
+/*
+ * Read a byte from a stream
+ */
+int
+sfgetc(stream *s);
+
+/*
+ * Seek to a position in the stream. Returns the 0, or -1 if error
+ */
+int
+sfseek(stream *s, long offset, int whence);
+
+/*
+ * Seek to beginning of the file
+ */
+int
+srewind(stream *s);;
+
+/*
+ * Return the current position in the stream or -1 if error.
+ */
+long
+sftell(stream *s);
+
+/*
+ * Return the EOF status, or 0 if not at EOF.
+ */
+int
+sfeof(stream *s);
+
+/*
+ * Return the error status, or 0 if no error
+ */
+int
+sferror(stream *s);
+
+/*
+ * close and free the stream. Any further access (including another call to sfclose())
+ * to  the  stream results in undefined behaviour (reference to freed memory);
+ */
+int
+sfclose(stream *s);
+
+#endif /* strmio_INCLUDED */



More information about the gs-cvs mailing list