summaryrefslogtreecommitdiff
path: root/src/gd_io_ss.c
diff options
context:
space:
mode:
authorpierre <none@none>2006-04-05 15:42:56 +0000
committerpierre <none@none>2006-04-05 15:42:56 +0000
commit1cdea7482e810bfb1d8deb439a52a20c7db7ebd9 (patch)
tree4985f6ab8c60688b650cf40ea87d4f6670c4b3c5 /src/gd_io_ss.c
parentff50323cfa78527876c9efaff1a828c9694c817b (diff)
downloadlibgd-1cdea7482e810bfb1d8deb439a52a20c7db7ebd9.tar.gz
- sync to 2.0.1GD_2_0_1
Diffstat (limited to 'src/gd_io_ss.c')
-rw-r--r--src/gd_io_ss.c177
1 files changed, 97 insertions, 80 deletions
diff --git a/src/gd_io_ss.c b/src/gd_io_ss.c
index 7e0038b..1ea78d5 100644
--- a/src/gd_io_ss.c
+++ b/src/gd_io_ss.c
@@ -1,24 +1,25 @@
+
/*
-* io_ss.c
-*
-* Implements the Source/Sink interface.
-*
-* As will all I/O modules, most functions are for local use only (called
-* via function pointers in the I/O context).
-*
-* The Source/Sink model is the primary 'user' interface for alternate data
-* sources; the IOCtx interface is intended (at least in version 1.5) to be
-* used internally until it settles down a bit.
-*
-* This module just layers the Source/Sink interface on top of the IOCtx; no
-* support is provided for tell/seek, so GD2 writing is not possible, and
-* retrieving parts of GD2 files is also not possible.
-*
-* A new SS context does not need to be created with both a Source and a Sink.
-*
-* Written/Modified 1999, Philip Warner.
-*
-*/
+ * io_ss.c
+ *
+ * Implements the Source/Sink interface.
+ *
+ * As will all I/O modules, most functions are for local use only (called
+ * via function pointers in the I/O context).
+ *
+ * The Source/Sink model is the primary 'user' interface for alternate data
+ * sources; the IOCtx interface is intended (at least in version 1.5) to be
+ * used internally until it settles down a bit.
+ *
+ * This module just layers the Source/Sink interface on top of the IOCtx; no
+ * support is provided for tell/seek, so GD2 writing is not possible, and
+ * retrieving parts of GD2 files is also not possible.
+ *
+ * A new SS context does not need to be created with both a Source and a Sink.
+ *
+ * Written/Modified 1999, Philip Warner.
+ *
+ */
#include <math.h>
#include <string.h>
@@ -26,32 +27,37 @@
#include "gd.h"
#include "gdhelpers.h"
-/* this is used for creating images in main memory*/
+/* this is used for creating images in main memory */
-typedef struct ssIOCtx {
- gdIOCtx ctx;
- gdSourcePtr src;
- gdSinkPtr snk;
-} ssIOCtx;
+typedef struct ssIOCtx
+ {
+ gdIOCtx ctx;
+ gdSourcePtr src;
+ gdSinkPtr snk;
+ }
+ssIOCtx;
-typedef struct ssIOCtx *ssIOCtxPtr;
+typedef struct ssIOCtx *ssIOCtxPtr;
-gdIOCtx* gdNewSSCtx(gdSourcePtr src, gdSinkPtr snk);
+gdIOCtx *gdNewSSCtx (gdSourcePtr src, gdSinkPtr snk);
-static int sourceGetbuf( gdIOCtx*, void *, int );
-static int sourceGetchar( gdIOCtx* ctx);
-static int sinkPutbuf( gdIOCtx* ctx, const void *buf, int size );
-static void sinkPutchar( gdIOCtx* ctx, int a );
-static void gdFreeSsCtx(gdIOCtx *ctx);
+static int sourceGetbuf (gdIOCtx *, void *, int);
+static int sourceGetchar (gdIOCtx * ctx);
+static int sinkPutbuf (gdIOCtx * ctx, const void *buf, int size);
+static void sinkPutchar (gdIOCtx * ctx, int a);
+static void gdFreeSsCtx (gdIOCtx * ctx);
/* return data as a dynamic pointer */
-gdIOCtx* gdNewSSCtx (gdSourcePtr src, gdSinkPtr snk) {
- ssIOCtxPtr ctx;
+gdIOCtx *
+gdNewSSCtx (gdSourcePtr src, gdSinkPtr snk)
+{
+ ssIOCtxPtr ctx;
- ctx = (ssIOCtxPtr) gdMalloc(sizeof(ssIOCtx));
- if (ctx == NULL) {
- return NULL;
- }
+ ctx = (ssIOCtxPtr) gdMalloc (sizeof (ssIOCtx));
+ if (ctx == NULL)
+ {
+ return NULL;
+ }
ctx->src = src;
ctx->snk = snk;
@@ -67,82 +73,93 @@ gdIOCtx* gdNewSSCtx (gdSourcePtr src, gdSinkPtr snk) {
ctx->ctx.free = gdFreeSsCtx;
- return (gdIOCtx*)ctx;
+ return (gdIOCtx *) ctx;
}
static
-void gdFreeSsCtx(gdIOCtx *ctx)
+void
+gdFreeSsCtx (gdIOCtx * ctx)
{
- gdFree(ctx);
+ gdFree (ctx);
}
static int
-sourceGetbuf( gdIOCtx* ctx, void *buf, int size )
+sourceGetbuf (gdIOCtx * ctx, void *buf, int size)
{
- ssIOCtx *lctx;
- int res;
+ ssIOCtx *lctx;
+ int res;
- lctx = (ssIOCtx*) ctx;
+ lctx = (ssIOCtx *) ctx;
- res = ((lctx->src->source)(lctx->src->context, buf, size));
+ res = ((lctx->src->source) (lctx->src->context, buf, size));
/*
-** Translate the return values from the Source object:
-** 0 is EOF, -1 is error
-*/
-
- if (res == 0) {
- return EOF;
- } else if (res < 0) {
- return 0;
- } else {
- return res;
- };
+ ** Translate the return values from the Source object:
+ ** 0 is EOF, -1 is error
+ */
+
+ if (res == 0)
+ {
+ return EOF;
+ }
+ else if (res < 0)
+ {
+ return 0;
+ }
+ else
+ {
+ return res;
+ };
}
-static int sourceGetchar( gdIOCtx* ctx)
+static int
+sourceGetchar (gdIOCtx * ctx)
{
int res;
unsigned char buf;
- res = sourceGetbuf(ctx, &buf, 1);
+ res = sourceGetbuf (ctx, &buf, 1);
- if (res == 1) {
- return buf;
- } else {
- return EOF;
- };
+ if (res == 1)
+ {
+ return buf;
+ }
+ else
+ {
+ return EOF;
+ };
}
static int
-sinkPutbuf( gdIOCtx* ctx, const void *buf, int size )
+sinkPutbuf (gdIOCtx * ctx, const void *buf, int size)
{
- ssIOCtxPtr lctx;
- int res;
+ ssIOCtxPtr lctx;
+ int res;
- lctx = (ssIOCtx*) ctx;
+ lctx = (ssIOCtx *) ctx;
- res = (lctx->snk->sink)(lctx->snk->context, buf, size);
+ res = (lctx->snk->sink) (lctx->snk->context, buf, size);
- if (res <= 0) {
- return 0;
- } else {
- return res;
- };
+ if (res <= 0)
+ {
+ return 0;
+ }
+ else
+ {
+ return res;
+ };
}
static void
-sinkPutchar( gdIOCtx* ctx, int a )
+sinkPutchar (gdIOCtx * ctx, int a)
{
- unsigned char b;
+ unsigned char b;
b = a;
- sinkPutbuf(ctx, &b, 1);
+ sinkPutbuf (ctx, &b, 1);
}
-
-