summaryrefslogtreecommitdiff
path: root/gs/psi/ziodevs.c
diff options
context:
space:
mode:
Diffstat (limited to 'gs/psi/ziodevs.c')
-rw-r--r--gs/psi/ziodevs.c142
1 files changed, 71 insertions, 71 deletions
diff --git a/gs/psi/ziodevs.c b/gs/psi/ziodevs.c
index 020b04e87..eedddab64 100644
--- a/gs/psi/ziodevs.c
+++ b/gs/psi/ziodevs.c
@@ -1,6 +1,6 @@
/* Copyright (C) 2001-2006 Artifex Software, Inc.
All Rights Reserved.
-
+
This software is provided AS-IS with no warranty, either express or
implied.
@@ -20,7 +20,7 @@
#include "oper.h"
#include "stream.h"
#include "gxiodev.h" /* must come after stream.h */
- /* and before files.h */
+ /* and before files.h */
#include "files.h"
#include "store.h"
@@ -28,11 +28,11 @@
const char iodev_dtype_stdio[] = "Special";
#define iodev_special(dname, init, open) {\
dname, iodev_dtype_stdio,\
- { init, open, iodev_no_open_file, iodev_no_fopen, iodev_no_fclose,\
- iodev_no_delete_file, iodev_no_rename_file, iodev_no_file_status,\
- iodev_no_enumerate_files, NULL, NULL,\
- iodev_no_get_params, iodev_no_put_params\
- }\
+ { init, open, iodev_no_open_file, iodev_no_fopen, iodev_no_fclose,\
+ iodev_no_delete_file, iodev_no_rename_file, iodev_no_file_status,\
+ iodev_no_enumerate_files, NULL, NULL,\
+ iodev_no_get_params, iodev_no_put_params\
+ }\
}
/*
@@ -71,7 +71,7 @@ const gx_io_device gs_iodev_stderr =
static int
s_stdin_read_process(stream_state *, stream_cursor_read *,
- stream_cursor_write *, bool);
+ stream_cursor_write *, bool);
static int
stdin_init(gx_io_device * iodev, gs_memory_t * mem)
@@ -84,49 +84,49 @@ stdin_init(gx_io_device * iodev, gs_memory_t * mem)
/* If interactive, only read one character. */
static int
s_stdin_read_process(stream_state * st, stream_cursor_read * ignore_pr,
- stream_cursor_write * pw, bool last)
+ stream_cursor_write * pw, bool last)
{
FILE *file = ((stream *) st)->file; /* hack for file streams */
int wcount = (int)(pw->limit - pw->ptr);
int count;
if (wcount <= 0)
- return 0;
+ return 0;
count = gp_stdin_read( (char*) pw->ptr + 1, wcount,
- st->memory->gs_lib_ctx->stdin_is_interactive, file);
+ st->memory->gs_lib_ctx->stdin_is_interactive, file);
pw->ptr += (count < 0) ? 0 : count;
return ((count < 0) ? ERRC : (count == 0) ? EOFC : count);
}
static int
stdin_open(gx_io_device * iodev, const char *access, stream ** ps,
- gs_memory_t * mem)
+ gs_memory_t * mem)
{
i_ctx_t *i_ctx_p = (i_ctx_t *)iodev->state; /* see above */
stream *s;
if (!streq1(access, 'r'))
- return_error(e_invalidfileaccess);
+ return_error(e_invalidfileaccess);
if (file_is_invalid(s, &ref_stdin)) {
- /****** stdin SHOULD NOT LINE-BUFFER ******/
- gs_memory_t *mem = imemory_system;
- byte *buf;
+ /****** stdin SHOULD NOT LINE-BUFFER ******/
+ gs_memory_t *mem = imemory_system;
+ byte *buf;
- s = file_alloc_stream(mem, "stdin_open(stream)");
- /* We want stdin to read only one character at a time, */
- /* but it must have a substantial buffer, in case it is used */
- /* by a stream that requires more than one input byte */
- /* to make progress. */
- buf = gs_alloc_bytes(mem, STDIN_BUF_SIZE, "stdin_open(buffer)");
- if (s == 0 || buf == 0)
- return_error(e_VMerror);
- sread_file(s, gs_stdin, buf, STDIN_BUF_SIZE);
- s->procs.process = s_stdin_read_process;
- s->save_close = s_std_null;
- s->procs.close = file_close_file;
- make_file(&ref_stdin, a_readonly | avm_system, s->read_id, s);
- *ps = s;
- return 1;
+ s = file_alloc_stream(mem, "stdin_open(stream)");
+ /* We want stdin to read only one character at a time, */
+ /* but it must have a substantial buffer, in case it is used */
+ /* by a stream that requires more than one input byte */
+ /* to make progress. */
+ buf = gs_alloc_bytes(mem, STDIN_BUF_SIZE, "stdin_open(buffer)");
+ if (s == 0 || buf == 0)
+ return_error(e_VMerror);
+ sread_file(s, gs_stdin, buf, STDIN_BUF_SIZE);
+ s->procs.process = s_stdin_read_process;
+ s->save_close = s_std_null;
+ s->procs.close = file_close_file;
+ make_file(&ref_stdin, a_readonly | avm_system, s->read_id, s);
+ *ps = s;
+ return 1;
}
*ps = s;
return 0;
@@ -140,8 +140,8 @@ zget_stdin(i_ctx_t *i_ctx_p, stream ** ps)
int code;
if (file_is_valid(s, &ref_stdin)) {
- *ps = s;
- return 0;
+ *ps = s;
+ return 0;
}
iodev = gs_findiodevice((const byte *)"%stdin", 6);
iodev->state = i_ctx_p;
@@ -158,49 +158,49 @@ zis_stdin(const stream *s)
static int
s_stdout_swrite_process(stream_state *, stream_cursor_read *,
- stream_cursor_write *, bool);
+ stream_cursor_write *, bool);
/* Write a buffer to stdout, potentially writing to callback */
static int
s_stdout_write_process(stream_state * st, stream_cursor_read * ignore_pr,
- stream_cursor_write * pw, bool last)
+ stream_cursor_write * pw, bool last)
{
uint count = pr->limit - pr->ptr;
int written;
- if (count == 0)
- return 0;
+ if (count == 0)
+ return 0;
written = outwrite(st->memory, pr->ptr + 1, count);
if (written < count) {
- return ERRC;
+ return ERRC;
pr->ptr += written;
return 0;
}
static int
stdout_open(gx_io_device * iodev, const char *access, stream ** ps,
- gs_memory_t * mem)
+ gs_memory_t * mem)
{
i_ctx_t *i_ctx_p = (i_ctx_t *)iodev->state; /* see above */
stream *s;
if (!streq1(access, 'w'))
- return_error(e_invalidfileaccess);
+ return_error(e_invalidfileaccess);
if (file_is_invalid(s, &ref_stdout)) {
- gs_memory_t *mem = imemory_system;
- byte *buf;
+ gs_memory_t *mem = imemory_system;
+ byte *buf;
- s = file_alloc_stream(mem, "stdout_open(stream)");
- buf = gs_alloc_bytes(mem, STDOUT_BUF_SIZE, "stdout_open(buffer)");
- if (s == 0 || buf == 0)
- return_error(e_VMerror);
- swrite_file(s, gs_stdout, buf, STDOUT_BUF_SIZE);
- s->save_close = s->procs.flush;
- s->procs.close = file_close_file;
- s->procs.process = s_stdout_write_process;
- make_file(&ref_stdout, a_write | avm_system, s->write_id, s);
- *ps = s;
- return 1;
+ s = file_alloc_stream(mem, "stdout_open(stream)");
+ buf = gs_alloc_bytes(mem, STDOUT_BUF_SIZE, "stdout_open(buffer)");
+ if (s == 0 || buf == 0)
+ return_error(e_VMerror);
+ swrite_file(s, gs_stdout, buf, STDOUT_BUF_SIZE);
+ s->save_close = s->procs.flush;
+ s->procs.close = file_close_file;
+ s->procs.process = s_stdout_write_process;
+ make_file(&ref_stdout, a_write | avm_system, s->write_id, s);
+ *ps = s;
+ return 1;
}
*ps = s;
return 0;
@@ -214,8 +214,8 @@ zget_stdout(i_ctx_t *i_ctx_p, stream ** ps)
int code;
if (file_is_valid(s, &ref_stdout)) {
- *ps = s;
- return 0;
+ *ps = s;
+ return 0;
}
iodev = gs_findiodevice((const byte *)"%stdout", 7);
iodev->state = i_ctx_p;
@@ -226,27 +226,27 @@ zget_stdout(i_ctx_t *i_ctx_p, stream ** ps)
static int
stderr_open(gx_io_device * iodev, const char *access, stream ** ps,
- gs_memory_t * mem)
+ gs_memory_t * mem)
{
i_ctx_t *i_ctx_p = (i_ctx_t *)iodev->state; /* see above */
stream *s;
if (!streq1(access, 'w'))
- return_error(e_invalidfileaccess);
+ return_error(e_invalidfileaccess);
if (file_is_invalid(s, &ref_stderr)) {
- gs_memory_t *mem = imemory_system;
- byte *buf;
+ gs_memory_t *mem = imemory_system;
+ byte *buf;
- s = file_alloc_stream(mem, "stderr_open(stream)");
- buf = gs_alloc_bytes(mem, STDERR_BUF_SIZE, "stderr_open(buffer)");
- if (s == 0 || buf == 0)
- return_error(e_VMerror);
- swrite_file(s, gs_stderr, buf, STDERR_BUF_SIZE);
- s->save_close = s->procs.flush;
- s->procs.close = file_close_file;
- make_file(&ref_stderr, a_write | avm_system, s->write_id, s);
- *ps = s;
- return 1;
+ s = file_alloc_stream(mem, "stderr_open(stream)");
+ buf = gs_alloc_bytes(mem, STDERR_BUF_SIZE, "stderr_open(buffer)");
+ if (s == 0 || buf == 0)
+ return_error(e_VMerror);
+ swrite_file(s, gs_stderr, buf, STDERR_BUF_SIZE);
+ s->save_close = s->procs.flush;
+ s->procs.close = file_close_file;
+ make_file(&ref_stderr, a_write | avm_system, s->write_id, s);
+ *ps = s;
+ return 1;
}
*ps = s;
return 0;
@@ -260,8 +260,8 @@ zget_stderr(i_ctx_t *i_ctx_p, stream ** ps)
int code;
if (file_is_valid(s, &ref_stderr)) {
- *ps = s;
- return 0;
+ *ps = s;
+ return 0;
}
iodev = gs_findiodevice((const byte *)"%stderr", 7);
iodev->state = i_ctx_p;