6
* Implements the imple I/O 'helper' routines.
8
* Not really essential, but these routines were used extensively in GD,
9
* so they were moved here. They also make IOCtx calls look better...
11
* Written (or, at least, moved) 1999, Philip Warner.
20
/* Use this for commenting out debug-print statements. */
21
/* Just use the first '#define' to allow all the prints... */
22
/*#define IO_DBG(s) (s) */
27
* Write out a word to the I/O context pointer
30
Putword (int w, gdIOCtx * ctx)
34
buf[1] = (w / 256) & 0xff;
35
(ctx->putBuf) (ctx, (char *) buf, 2);
39
Putchar (int c, gdIOCtx * ctx)
41
(ctx->putC) (ctx, c & 0xff);
45
gdPutC (const unsigned char c, gdIOCtx * ctx)
51
gdPutWord (int w, gdIOCtx * ctx)
53
IO_DBG (printf ("Putting word...\n"));
54
(ctx->putC) (ctx, (unsigned char) (w >> 8));
55
(ctx->putC) (ctx, (unsigned char) (w & 0xFF));
56
IO_DBG (printf ("put.\n"));
60
gdPutInt (int w, gdIOCtx * ctx)
62
IO_DBG (printf ("Putting int...\n"));
63
(ctx->putC) (ctx, (unsigned char) (w >> 24));
64
(ctx->putC) (ctx, (unsigned char) ((w >> 16) & 0xFF));
65
(ctx->putC) (ctx, (unsigned char) ((w >> 8) & 0xFF));
66
(ctx->putC) (ctx, (unsigned char) (w & 0xFF));
67
IO_DBG (printf ("put.\n"));
71
gdGetC (gdIOCtx * ctx)
73
return ((ctx->getC) (ctx));
79
gdGetByte (int *result, gdIOCtx * ctx)
82
r = (ctx->getC) (ctx);
92
gdGetWord (int *result, gdIOCtx * ctx)
95
r = (ctx->getC) (ctx);
101
r = (ctx->getC) (ctx);
112
gdGetInt (int *result, gdIOCtx * ctx)
115
r = (ctx->getC) (ctx);
122
r = (ctx->getC) (ctx);
129
r = (ctx->getC) (ctx);
136
r = (ctx->getC) (ctx);
147
gdPutBuf (const void *buf, int size, gdIOCtx * ctx)
149
IO_DBG (printf ("Putting buf...\n"));
150
return (ctx->putBuf) (ctx, buf, size);
151
IO_DBG (printf ("put.\n"));
155
gdGetBuf (void *buf, int size, gdIOCtx * ctx)
157
return (ctx->getBuf) (ctx, buf, size);
162
gdSeek (gdIOCtx * ctx, const int pos)
164
IO_DBG (printf ("Seeking...\n"));
165
return ((ctx->seek) (ctx, pos));
166
IO_DBG (printf ("Done.\n"));
170
gdTell (gdIOCtx * ctx)
172
IO_DBG (printf ("Telling...\n"));
173
return ((ctx->tell) (ctx));
174
IO_DBG (printf ("told.\n"));