~ubuntu-branches/ubuntu/hardy/ghostscript/hardy

« back to all changes in this revision

Viewing changes to src/zfileio.c

  • Committer: Bazaar Package Importer
  • Author(s): Till Kamppeter
  • Date: 2007-11-22 12:17:43 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20071122121743-cd70s3ypq0r243mp
Tags: 8.61.dfsg.1-0ubtuntu1
* New upstream release
  o Final 8.61 release
* debian/patches/09_ijs_krgb_support.dpatch: Adapted to upstream changes.
* debian/rules: Updated CUPS-related variables for "make install" calls.
* debian/rules: Remove /usr/include/ghostscript from the ghostscript
  package, they go into lings-dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
   San Rafael, CA  94903, U.S.A., +1(415)492-9861, for further information.
12
12
*/
13
13
 
14
 
/* $Id: zfileio.c 8022 2007-06-05 22:23:38Z giles $ */
 
14
/* $Id: zfileio.c 8250 2007-09-25 13:31:24Z giles $ */
15
15
/* File I/O operators */
16
16
#include "memory_.h"
17
17
#include "ghost.h"
29
29
#include "estack.h"
30
30
 
31
31
/* Forward references */
32
 
private int write_string(ref *, stream *);
33
 
private int handle_read_status(i_ctx_t *, int, const ref *, const uint *,
 
32
static int write_string(ref *, stream *);
 
33
static int handle_read_status(i_ctx_t *, int, const ref *, const uint *,
34
34
                               op_proc_t);
35
 
private int handle_write_status(i_ctx_t *, int, const ref *, const uint *,
 
35
static int handle_write_status(i_ctx_t *, int, const ref *, const uint *,
36
36
                                op_proc_t);
37
37
 
38
38
/* ------ Operators ------ */
63
63
 
64
64
/* <file> read <int> -true- */
65
65
/* <file> read -false- */
66
 
private int
 
66
static int
67
67
zread(i_ctx_t *i_ctx_p)
68
68
{
69
69
    os_ptr op = osp;
116
116
}
117
117
 
118
118
/* <file> <string> readhexstring <substring> <filled_bool> */
119
 
private int zreadhexstring_continue(i_ctx_t *);
 
119
static int zreadhexstring_continue(i_ctx_t *);
120
120
 
121
121
/* We pack the odd digit above the the current position for the  */
122
122
/* convenience of reusing procedures that take 1 state parameter */
123
 
private int
 
123
static int
124
124
zreadhexstring_at(i_ctx_t *i_ctx_p, os_ptr op, uint start, int odd)
125
125
{
126
126
    stream *s;
164
164
    make_false(op);
165
165
    return 0;
166
166
}
167
 
private int
 
167
static int
168
168
zreadhexstring(i_ctx_t *i_ctx_p)
169
169
{
170
170
    os_ptr op = osp;
174
174
}
175
175
/* Continue a readhexstring operation after a callout. */
176
176
/* *op contains the index within the string and the odd flag. */
177
 
private int
 
177
static int
178
178
zreadhexstring_continue(i_ctx_t *i_ctx_p)
179
179
{
180
180
    os_ptr op = osp;
194
194
}
195
195
 
196
196
/* <file> <string> writehexstring - */
197
 
private int zwritehexstring_continue(i_ctx_t *);
198
 
private int
 
197
static int zwritehexstring_continue(i_ctx_t *);
 
198
static int
199
199
zwritehexstring_at(i_ctx_t *i_ctx_p, os_ptr op, uint odd)
200
200
{
201
201
    register stream *s;
248
248
    return 0;
249
249
#undef MAX_HEX
250
250
}
251
 
private int
 
251
static int
252
252
zwritehexstring(i_ctx_t *i_ctx_p)
253
253
{
254
254
    os_ptr op = osp;
257
257
}
258
258
/* Continue a writehexstring operation after a callout. */
259
259
/* *op is the odd/even hex digit flag for the first byte. */
260
 
private int
 
260
static int
261
261
zwritehexstring_continue(i_ctx_t *i_ctx_p)
262
262
{
263
263
    os_ptr op = osp;
273
273
}
274
274
 
275
275
/* <file> <string> readstring <substring> <filled_bool> */
276
 
private int zreadstring_continue(i_ctx_t *);
277
 
private int
 
276
static int zreadstring_continue(i_ctx_t *);
 
277
static int
278
278
zreadstring_at(i_ctx_t *i_ctx_p, os_ptr op, uint start)
279
279
{
280
280
    stream *s;
308
308
    make_bool(op, (rlen == len ? 1 : 0));
309
309
    return 0;
310
310
}
311
 
private int
 
311
static int
312
312
zreadstring(i_ctx_t *i_ctx_p)
313
313
{
314
314
    os_ptr op = osp;
317
317
}
318
318
/* Continue a readstring operation after a callout. */
319
319
/* *op is the index within the string. */
320
 
private int
 
320
static int
321
321
zreadstring_continue(i_ctx_t *i_ctx_p)
322
322
{
323
323
    os_ptr op = osp;
333
333
}
334
334
 
335
335
/* <file> <string> writestring - */
336
 
private int
 
336
static int
337
337
zwritestring(i_ctx_t *i_ctx_p)
338
338
{
339
339
    os_ptr op = osp;
351
351
}
352
352
 
353
353
/* <file> <string> readline <substring> <bool> */
354
 
private int zreadline(i_ctx_t *);
355
 
private int zreadline_continue(i_ctx_t *);
 
354
static int zreadline(i_ctx_t *);
 
355
static int zreadline_continue(i_ctx_t *);
356
356
 
357
357
/*
358
358
 * We could handle readline the same way as readstring,
364
364
 * we use start=0 (which we have just ruled out as a possible start value
365
365
 * for readline_continue) to indicate interruption after the CR.
366
366
 */
367
 
private int
 
367
static int
368
368
zreadline_at(i_ctx_t *i_ctx_p, os_ptr op, uint count, bool in_eol)
369
369
{
370
370
    stream *s;
400
400
    make_bool(op, status == 0);
401
401
    return 0;
402
402
}
403
 
private int
 
403
static int
404
404
zreadline(i_ctx_t *i_ctx_p)
405
405
{
406
406
    os_ptr op = osp;
409
409
}
410
410
/* Continue a readline operation after a callout. */
411
411
/* *op is the index within the string, or 0 for an interrupt after a CR. */
412
 
private int
 
412
static int
413
413
zreadline_continue(i_ctx_t *i_ctx_p)
414
414
{
415
415
    os_ptr op = osp;
446
446
}
447
447
 
448
448
/* <file> bytesavailable <int> */
449
 
private int
 
449
static int
450
450
zbytesavailable(i_ctx_t *i_ctx_p)
451
451
{
452
452
    os_ptr op = osp;
490
490
}
491
491
 
492
492
/* <file> flushfile - */
493
 
private int
 
493
static int
494
494
zflushfile(i_ctx_t *i_ctx_p)
495
495
{
496
496
    os_ptr op = osp;
520
520
}
521
521
 
522
522
/* <file> resetfile - */
523
 
private int
 
523
static int
524
524
zresetfile(i_ctx_t *i_ctx_p)
525
525
{
526
526
    os_ptr op = osp;
535
535
}
536
536
 
537
537
/* <string> print - */
538
 
private int
 
538
static int
539
539
zprint(i_ctx_t *i_ctx_p)
540
540
{
541
541
    os_ptr op = osp;
566
566
}
567
567
 
568
568
/* <bool> echo - */
569
 
private int
 
569
static int
570
570
zecho(i_ctx_t *i_ctx_p)
571
571
{
572
572
    os_ptr op = osp;
580
580
/* ------ Level 2 extensions ------ */
581
581
 
582
582
/* <file> fileposition <int> */
583
 
private int
 
583
static int
584
584
zfileposition(i_ctx_t *i_ctx_p)
585
585
{
586
586
    os_ptr op = osp;
597
597
    return 0;
598
598
}
599
599
/* <file> .fileposition <int> */
600
 
private int
 
600
static int
601
601
zxfileposition(i_ctx_t *i_ctx_p)
602
602
{
603
603
    os_ptr op = osp;
613
613
}
614
614
 
615
615
/* <file> <int> setfileposition - */
616
 
private int
 
616
static int
617
617
zsetfileposition(i_ctx_t *i_ctx_p)
618
618
{
619
619
    os_ptr op = osp;
631
631
 
632
632
/* <file> .filename <string> true */
633
633
/* <file> .filename false */
634
 
private int
 
634
static int
635
635
zfilename(i_ctx_t *i_ctx_p)
636
636
{
637
637
    os_ptr op = osp;
659
659
}
660
660
 
661
661
/* <file> .isprocfilter <bool> */
662
 
private int
 
662
static int
663
663
zisprocfilter(i_ctx_t *i_ctx_p)
664
664
{
665
665
    os_ptr op = osp;
673
673
}
674
674
 
675
675
/* <file> <string> .peekstring <substring> <filled_bool> */
676
 
private int
 
676
static int
677
677
zpeekstring(i_ctx_t *i_ctx_p)
678
678
{
679
679
    os_ptr op = osp;
716
716
}
717
717
 
718
718
/* <file> <int> .unread - */
719
 
private int
 
719
static int
720
720
zunread(i_ctx_t *i_ctx_p)
721
721
{
722
722
    os_ptr op = osp;
735
735
}
736
736
 
737
737
/* <file> <obj> <==flag> .writecvp - */
738
 
private int zwritecvp_continue(i_ctx_t *);
739
 
private int
 
738
static int zwritecvp_continue(i_ctx_t *);
 
739
static int
740
740
zwritecvp_at(i_ctx_t *i_ctx_p, os_ptr op, uint start, bool first)
741
741
{
742
742
    stream *s;
790
790
        pop(4);
791
791
    return 0;
792
792
}
793
 
private int
 
793
static int
794
794
zwritecvp(i_ctx_t *i_ctx_p)
795
795
{
796
796
    return zwritecvp_at(i_ctx_p, osp, 0, true);
797
797
}
798
798
/* Continue a .writecvp after a callout. */
799
799
/* *op is the index within the string. */
800
 
private int
 
800
static int
801
801
zwritecvp_continue(i_ctx_t *i_ctx_p)
802
802
{
803
803
    os_ptr op = osp;
886
886
 
887
887
/* Write a string on a file.  The file and string have been validated. */
888
888
/* If the status is INTC or CALLC, updates the string on the o-stack. */
889
 
private int
 
889
static int
890
890
write_string(ref * op, stream * s)
891
891
{
892
892
    const byte *data = op->value.const_bytes;
909
909
 * Look for a stream error message that needs to be copied to
910
910
 * $error.errorinfo, if any.
911
911
 */
912
 
private int
 
912
static int
913
913
copy_error_string(i_ctx_t *i_ctx_p, const ref *fop)
914
914
{
915
915
    stream *s;
930
930
/* fop points to the ref for the stream. */
931
931
/* ch may be any stream exceptional value. */
932
932
/* Return 0, 1 (EOF), o_push_estack, or an error. */
933
 
private int
 
933
static int
934
934
handle_read_status(i_ctx_t *i_ctx_p, int ch, const ref * fop,
935
935
                   const uint * pindex, op_proc_t cont)
936
936
{
957
957
/* fop points to the ref for the stream. */
958
958
/* ch may be any stream exceptional value. */
959
959
/* Return 0, 1 (EOF), o_push_estack, or an error. */
960
 
private int
 
960
static int
961
961
handle_write_status(i_ctx_t *i_ctx_p, int ch, const ref * fop,
962
962
                    const uint * pindex, op_proc_t cont)
963
963
{