diff options
author | Rasmus Lerdorf <rasmus@php.net> | 2002-04-13 02:03:09 +0000 |
---|---|---|
committer | Rasmus Lerdorf <rasmus@php.net> | 2002-04-13 02:03:09 +0000 |
commit | 7a8cade379e90bafca21cd983f2f5a4d84a7ff8a (patch) | |
tree | 3ad6b2f42fd690dd7acdf04a41173471f27b5ea7 /ext/gd/libgd/gd_io.c | |
parent | c46199f5b98c35b911d18eb6a9646ccb118d46ef (diff) | |
download | php-git-7a8cade379e90bafca21cd983f2f5a4d84a7ff8a.tar.gz |
Initial commit of the built-in libgd based on GD-2.0.1
This initial checkin has no changes to any of the libgd code so it can
be used as a basis for diffs. It also will not build currently because
of this. The PHP gd checks need to be incorporated along with a bit of
other config magic. It also shouldn't break the build and will only
take effect if you use --with-gd=php right now.
Diffstat (limited to 'ext/gd/libgd/gd_io.c')
-rw-r--r-- | ext/gd/libgd/gd_io.c | 175 |
1 files changed, 175 insertions, 0 deletions
diff --git a/ext/gd/libgd/gd_io.c b/ext/gd/libgd/gd_io.c new file mode 100644 index 0000000000..7cc49d28fd --- /dev/null +++ b/ext/gd/libgd/gd_io.c @@ -0,0 +1,175 @@ + + +/* + * io.c + * + * Implements the imple 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) + + +/* + * 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 (printf ("Putting word...\n")); + (ctx->putC) (ctx, (unsigned char) (w >> 8)); + (ctx->putC) (ctx, (unsigned char) (w & 0xFF)); + IO_DBG (printf ("put.\n")); +} + +void +gdPutInt (int w, gdIOCtx * ctx) +{ + IO_DBG (printf ("Putting int...\n")); + (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 (printf ("put.\n")); +} + +int +gdGetC (gdIOCtx * ctx) +{ + return ((ctx->getC) (ctx)); +} + + + +int +gdGetByte (int *result, gdIOCtx * ctx) +{ + int r; + r = (ctx->getC) (ctx); + if (r == EOF) + { + return 0; + } + *result = r; + return 1; +} + +int +gdGetWord (int *result, gdIOCtx * ctx) +{ + int r; + r = (ctx->getC) (ctx); + if (r == EOF) + { + return 0; + } + *result = r << 8; + r = (ctx->getC) (ctx); + if (r == EOF) + { + return 0; + } + *result += r; + return 1; +} + + +int +gdGetInt (int *result, gdIOCtx * ctx) +{ + int r; + r = (ctx->getC) (ctx); + if (r == EOF) + { + return 0; + } + *result = r << 24; + + r = (ctx->getC) (ctx); + if (r == EOF) + { + return 0; + } + *result += r << 16; + + r = (ctx->getC) (ctx); + if (r == EOF) + { + return 0; + } + *result += r << 8; + + r = (ctx->getC) (ctx); + if (r == EOF) + { + return 0; + } + *result += r; + + return 1; +} + +int +gdPutBuf (const void *buf, int size, gdIOCtx * ctx) +{ + IO_DBG (printf ("Putting buf...\n")); + return (ctx->putBuf) (ctx, buf, size); + IO_DBG (printf ("put.\n")); +} + +int +gdGetBuf (void *buf, int size, gdIOCtx * ctx) +{ + return (ctx->getBuf) (ctx, buf, size); +} + + +int +gdSeek (gdIOCtx * ctx, const int pos) +{ + IO_DBG (printf ("Seeking...\n")); + return ((ctx->seek) (ctx, pos)); + IO_DBG (printf ("Done.\n")); +} + +long +gdTell (gdIOCtx * ctx) +{ + IO_DBG (printf ("Telling...\n")); + return ((ctx->tell) (ctx)); + IO_DBG (printf ("told.\n")); +} |