/* * io.c * * Implements the simple I/O 'helper' routines. * * Not really essential, but these routines were used extensively in GD, * so they were moved here. They also make IOCtx calls look better... * * Written (or, at least, moved) 1999, Philip Warner. * */ #include <math.h> #include <string.h> #include <stdlib.h> #include "gd.h" /* Use this for commenting out debug-print statements. */ /* Just use the first '#define' to allow all the prints... */ /*#define IO_DBG(s) (s) */ #define IO_DBG(s) #define GD_IO_EOF_CHK(r) \ if (r == EOF) { \ return 0; \ } \ /* * Write out a word to the I/O context pointer */ void Putword (int w, gdIOCtx * ctx) { unsigned char buf[2]; buf[0] = w & 0xff; buf[1] = (w / 256) & 0xff; (ctx->putBuf) (ctx, (char *) buf, 2); } void Putchar (int c, gdIOCtx * ctx) { (ctx->putC) (ctx, c & 0xff); } void gdPutC (const unsigned char c, gdIOCtx * ctx) { (ctx->putC) (ctx, c); } void gdPutWord (int w, gdIOCtx * ctx) { IO_DBG (php_gd_error("Putting word...")); (ctx->putC) (ctx, (unsigned char) (w >> 8)); (ctx->putC) (ctx, (unsigned char) (w & 0xFF)); IO_DBG (php_gd_error("put.")); } void gdPutInt (int w, gdIOCtx * ctx) { IO_DBG (php_gd_error("Putting int...")); (ctx->putC) (ctx, (unsigned char) (w >> 24)); (ctx->putC) (ctx, (unsigned char) ((w >> 16) & 0xFF)); (ctx->putC) (ctx, (unsigned char) ((w >> 8) & 0xFF)); (ctx->putC) (ctx, (unsigned char) (w & 0xFF)); IO_DBG (php_gd_error("put.")); } int gdGetC (gdIOCtx * ctx) { return ((ctx->getC) (ctx)); } int gdGetByte (int *result, gdIOCtx * ctx) { int r; r = (ctx->getC) (ctx); GD_IO_EOF_CHK(r); *result = r; return 1; } int gdGetWord (int *result, gdIOCtx * ctx) { int r; r = (ctx->getC) (ctx); GD_IO_EOF_CHK(r); *result = r << 8; r = (ctx->getC) (ctx); GD_IO_EOF_CHK(r); *result += r; return 1; } int gdGetInt (int *result, gdIOCtx * ctx) { int r; r = (ctx->getC) (ctx); GD_IO_EOF_CHK(r); *result = r << 24; r = (ctx->getC) (ctx); GD_IO_EOF_CHK(r); *result += r << 16; r = (ctx->getC) (ctx); if (r == EOF) { return 0; } *result += r << 8; r = (ctx->getC) (ctx); GD_IO_EOF_CHK(r); *result += r; return 1; } int gdPutBuf (const void *buf, int size, gdIOCtx * ctx) { IO_DBG (php_gd_error("Putting buf...")); return (ctx->putBuf) (ctx, buf, size); IO_DBG (php_gd_error("put.")); } int gdGetBuf (void *buf, int size, gdIOCtx * ctx) { return (ctx->getBuf) (ctx, buf, size); } int gdSeek (gdIOCtx * ctx, const int pos) { IO_DBG (php_gd_error("Seeking...")); return ((ctx->seek) (ctx, pos)); IO_DBG (php_gd_error("Done.")); } long gdTell (gdIOCtx * ctx) { IO_DBG (php_gd_error("Telling...")); return ((ctx->tell) (ctx)); IO_DBG (php_gd_error ("told.")); }
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
gd.c | File | 72.75 KB | 0644 |
|
gd.h | File | 32.2 KB | 0644 |
|
gd_arc.c | File | 1.66 KB | 0644 |
|
gd_color.c | File | 1.5 KB | 0644 |
|
gd_crop.c | File | 9.04 KB | 0644 |
|
gd_filter.c | File | 10.3 KB | 0644 |
|
gd_gd.c | File | 5.2 KB | 0644 |
|
gd_gd2.c | File | 19.73 KB | 0644 |
|
gd_gif_in.c | File | 13.89 KB | 0644 |
|
gd_gif_out.c | File | 20.54 KB | 0644 |
|
gd_interpolation.c | File | 71.93 KB | 0644 |
|
gd_io.c | File | 2.69 KB | 0644 |
|
gd_io.h | File | 963 B | 0644 |
|
gd_io_dp.c | File | 6.93 KB | 0644 |
|
gd_io_file.c | File | 2.31 KB | 0644 |
|
gd_io_ss.c | File | 2.66 KB | 0644 |
|
gd_jpeg.c | File | 26.21 KB | 0644 |
|
gd_matrix.c | File | 7.78 KB | 0644 |
|
gd_pixelate.c | File | 1.33 KB | 0644 |
|
gd_png.c | File | 22 KB | 0644 |
|
gd_rotate.c | File | 12.98 KB | 0644 |
|
gd_security.c | File | 671 B | 0644 |
|
gd_ss.c | File | 1.08 KB | 0644 |
|
gd_topal.c | File | 63.08 KB | 0644 |
|
gd_transform.c | File | 1.27 KB | 0644 |
|
gd_wbmp.c | File | 5.17 KB | 0644 |
|
gd_webp.c | File | 5.04 KB | 0644 |
|
gdcache.c | File | 4.99 KB | 0644 |
|
gdcache.h | File | 2.68 KB | 0644 |
|
gdfontg.c | File | 113.25 KB | 0644 |
|
gdfontg.h | File | 529 B | 0644 |
|
gdfontl.c | File | 108.5 KB | 0644 |
|
gdfontl.h | File | 527 B | 0644 |
|
gdfontmb.c | File | 79.24 KB | 0644 |
|
gdfontmb.h | File | 495 B | 0644 |
|
gdfonts.c | File | 69.46 KB | 0644 |
|
gdfonts.h | File | 491 B | 0644 |
|
gdfontt.c | File | 38.49 KB | 0644 |
|
gdfontt.h | File | 522 B | 0644 |
|
gdft.c | File | 32.57 KB | 0644 |
|
gdhelpers.c | File | 1.19 KB | 0644 |
|
gdhelpers.h | File | 1.32 KB | 0644 |
|
gdkanji.c | File | 12.11 KB | 0644 |
|
gdtables.c | File | 5.45 KB | 0644 |
|
gdxpm.c | File | 3.21 KB | 0644 |
|
wbmp.c | File | 6.76 KB | 0644 |
|
wbmp.h | File | 1.25 KB | 0644 |
|
webpimg.c | File | 28.33 KB | 0644 |
|
webpimg.h | File | 7.04 KB | 0644 |
|
xbm.c | File | 5.3 KB | 0644 |
|