File: io.c

package info (click to toggle)
cjet 0.8.9-2
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 316 kB
  • ctags: 428
  • sloc: ansic: 2,937; makefile: 64
file content (100 lines) | stat: -rw-r--r-- 2,075 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/* 
 * CJet:  LaserJet emulation for Canon CaPSL III+ laser printers
 *        Copyright (C) 1996 Michael Huijsmans
 *        Email: mgh@sbox.tu-graz.ac.at
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2, or (at
 * your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 *
 *  io.c - input/output
 *
 *  #define get_next_char()     fgetc(infile)
 *  #define unget_char(a)       ungetc(a,infile)
 */

#include "cjet.h"


/* 
 * output a string, either directly to the printer or to the 
 * macro recording buffer 
 */

void PutString(char *format, ... )
{
  va_list stuff;
  va_start(stuff, format);
  vfprintf(outfile, format, stuff);
  va_end(stuff);
}


void put_next_char( int c)
{
  if(recording == TRUE) {
    /* record in macro buffer */
  }
  else
    fputc (c,outfile);
}


/* 
 * read file/pipe routine with `helpful' error message 
 */

void pipe_read( BYTE *p, int size)
{
  if ( fread(p,1,size,infile) != size) {
    MorePanic(UN_RFILE, "input", 0);
    exit(1);           /* yes, a bit abrupt */
  }
}



/* 
 * file/pipe write routine with `helpful' error message
 */

void pipe_write( BYTE *p, int size)
{
  if(recording == TRUE) {
    /* macro recording */
  } else {
    if (fwrite(p, 1, size, outfile) != size) {
      MorePanic(UN_WFILE, "output", 0);
      exit(1);           /* yes, a bit abrupt */
    }
  }
}



void PutWord(int a)
/* the stupid way */
{
  WORD hi, lo;
  hi = (char) ((a>>8) & 0xff);
  lo = (char) (a & 0xff);
  put_next_char(hi);
  put_next_char(lo);
}