File: io.c

package info (click to toggle)
dvi2dvi 2.0alpha-10
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye, buster, stretch, trixie
  • size: 616 kB
  • ctags: 1,629
  • sloc: ansic: 6,410; makefile: 96; sh: 8
file content (96 lines) | stat: -rw-r--r-- 2,087 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
#include	"defs.h"
#include	"global.h"

/*-->getbytes*/
/**********************************************************************/
/*****************************  getbytes  *****************************/
/**********************************************************************/

void
getbytes(fp, cp, n)	/* get n bytes from file fp */
FILE *fp;	/* file pointer	 */
byte *cp;	/* character pointer */
int n;		/* number of bytes  */
{
    (void)fread((char *)cp, 1, n, fp);
}

void
skipbytes(fp, n)
FILE *fp;
int n;
{
    (void)fseek(fp, (long)n, SEEK_CUR);
}


/*-->getuint*/
/**********************************************************************/
/***************************  getuint  ********************************/
/**********************************************************************/

int
getuint(fp, n)	/* return n byte quantity from file fd */
FILE *fp;	/* file pointer    */
int n;		/* number of bytes */
{
    byte s[sizeof(int)];

    (void)fread((char *)s, 1, n, fp);
    return makeuint(s, n);
}


/*-->getint*/
/**********************************************************************/
/****************************  getint  ********************************/
/**********************************************************************/

int
getint(fp, n)	/* return n byte quantity from file fd */
FILE *fp;	/* file pointer    */
int n;		/* number of bytes */
{
    byte s[sizeof(int)];

    (void)fread((char *)s, 1, n, fp);
    return makeint(s, n);
}


/**********************************************************************/
/**********************************************************************/

putbyte(fp, c)
FILE *fp;
byte c;
{
    (void)putc(c, fp);
}

copybytes(sfp, dfp, n)
FILE *sfp, *dfp;	/* file pointer    */
int n;		/* number of bytes */
{
    for (; n > 0; --n)
	(void)putc(getc(sfp), dfp);
}

putbytes(fp, cp, n)
FILE *fp;
byte *cp;
int n;
{
    (void)fwrite((char *)cp, 1, n, fp);
}

putnint(fp, x, n)
FILE *fp;	/* file pointer	 */
unsigned int x;
int n;		/* number of bytes */
{
    if (n > 0) {
	putnint(fp, x>>8, n-1);
	(void)putc((int)x&0xff, fp);
    }
}