cvs: gd /libgd/src gd_io.c
[email protected] ("Mattias Bengtsson") Sun, 28 Oct 2007 21:15:15 -0000
| Newsgroups | php.gd.cvs |
|---|---|
| Message-ID | <cvsmattias1193606115@cvsserver> |
mattias Sun Oct 28 21:15:15 2007 UTC
Modified files:
/gd/libgd/src gd_io.c
Log:
- ws + cs
http://cvs.php.net/viewvc.cgi/gd/libgd/src/gd_io.c?r1=1.7&r2=1.8&diff_format=u
Index: gd/libgd/src/gd_io.c
diff -u gd/libgd/src/gd_io.c:1.7 gd/libgd/src/gd_io.c:1.8
--- gd/libgd/src/gd_io.c:1.7 Tue Oct 9 11:13:56 2007
+++ gd/libgd/src/gd_io.c Sun Oct 28 21:15:15 2007
@@ -1,19 +1,14 @@
-
-
-/*
- * 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.
- *
+/*
+ * 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.
*/
#ifdef HAVE_CONFIG_H
-#include "config.h"
+ #include "config.h"
#endif
#include <math.h>
@@ -27,215 +22,209 @@
#define IO_DBG(s)
#define GD_IO_EOF_CHK(r) \
- if (r == EOF) { \
+ if(r == EOF) { \
return 0; \
}
/*
* Write out a word to the I/O context pointer
*/
-void
-Putword (int w, gdIOCtx * ctx)
+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);
+ 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)
+void Putchar(int c, gdIOCtx *ctx)
{
- (ctx->putC) (ctx, c & 0xff);
+ (ctx->putC)(ctx, c & 0xff);
}
-void
-gdPutC (const unsigned char c, gdIOCtx * ctx)
+void gdPutC(const unsigned char c, gdIOCtx *ctx)
{
- (ctx->putC) (ctx, c);
+ (ctx->putC)(ctx, c);
}
-void
-gdPutWord (int w, gdIOCtx * ctx)
+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"));
+ 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)
+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"));
+ 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)
+int gdGetC(gdIOCtx *ctx)
{
- return ((ctx->getC) (ctx));
+ return ((ctx->getC)(ctx));
}
+int gdGetByte(int *result, gdIOCtx *ctx)
+{
+ int r;
+
+ r = (ctx->getC)(ctx);
+ if(r == EOF) {
+ return 0;
+ }
+ *result = r;
-int
-gdGetByte (int *result, gdIOCtx * ctx)
-{
- int r;
- r = (ctx->getC) (ctx);
- if (r == EOF)
- {
- return 0;
- }
- *result = r;
- return 1;
+ return 1;
}
-int
-gdGetWord (int *result, gdIOCtx * ctx)
+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 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
-gdGetWordLSB (int *result, gdIOCtx * ctx)
+int gdGetWordLSB(int *result, gdIOCtx *ctx)
{
int high = 0, low = 0;
- low = (ctx->getC) (ctx);
- if (low == EOF) {
- return 0;
+
+ low = (ctx->getC)(ctx);
+ if(low == EOF) {
+ return 0;
}
- high = (ctx->getC) (ctx);
- if (high == EOF) {
- return 0;
+ high = (ctx->getC)(ctx);
+ if(high == EOF) {
+ return 0;
}
- if (result) {
+ if(result) {
*result = (high << 8) | low;
}
return 1;
}
-int
-gdGetInt (int *result, gdIOCtx * ctx)
+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;
+ int r;
+
+ r = (ctx->getC)(ctx);
+ if(r == EOF) {
+ return 0;
+ }
- return 1;
+ *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
-gdGetIntLSB (int *result, gdIOCtx * ctx)
+int gdGetIntLSB(int *result, gdIOCtx *ctx)
{
int c = 0, r = 0;
- c = (ctx->getC) (ctx);
- if (c == EOF) {
- return 0;
+
+ c = (ctx->getC)(ctx);
+ if(c == EOF) {
+ return 0;
}
+
r |= (c << 24);
r >>= 8;
- c = (ctx->getC) (ctx);
- if (c == EOF) {
- return 0;
+ c = (ctx->getC)(ctx);
+ if(c == EOF) {
+ return 0;
}
+
r |= (c << 24);
r >>= 8;
- c = (ctx->getC) (ctx);
- if (c == EOF) {
- return 0;
+ c = (ctx->getC)(ctx);
+ if(c == EOF) {
+ return 0;
}
+
r |= (c << 24);
r >>= 8;
- c = (ctx->getC) (ctx);
- if (c == EOF) {
- return 0;
+ c = (ctx->getC)(ctx);
+ if(c == EOF) {
+ return 0;
}
+
r |= (c << 24);
- if (result) {
+ if(result) {
*result = r;
}
return 1;
}
-int
-gdPutBuf (const void *buf, int size, gdIOCtx * ctx)
+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"));
+ 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)
+int gdGetBuf(void *buf, int size, gdIOCtx *ctx)
{
- return (ctx->getBuf) (ctx, buf, size);
+ return (ctx->getBuf)(ctx, buf, size);
}
-
-int
-gdSeek (gdIOCtx * ctx, const int pos)
+int gdSeek(gdIOCtx *ctx, const int pos)
{
- IO_DBG (printf ("Seeking...\n"));
- return ((ctx->seek) (ctx, pos));
- IO_DBG (printf ("Done.\n"));
+ IO_DBG(printf("Seeking...\n"));
+ return ((ctx->seek)(ctx, pos));
+ IO_DBG(printf("Done.\n"));
}
-long
-gdTell (gdIOCtx * ctx)
+long gdTell(gdIOCtx *ctx)
{
- IO_DBG (printf ("Telling...\n"));
- return ((ctx->tell) (ctx));
- IO_DBG (printf ("told.\n"));
+ IO_DBG(printf("Telling...\n"));
+ return ((ctx->tell)(ctx));
+ IO_DBG(printf("told.\n"));
}