Back to index

plt-scheme  4.2.1
Classes | Typedefs | Functions
gd_io_ss.c File Reference
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include "gd.h"
#include "gdhelpers.h"

Go to the source code of this file.

Classes

struct  ssIOCtx

Typedefs

typedef struct ssIOCtx ssIOCtx
typedef struct ssIOCtxssIOCtxPtr

Functions

gdIOCtxgdNewSSCtx (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)

Class Documentation

struct ssIOCtx

Definition at line 36 of file gd_io_ss.c.

Collaboration diagram for ssIOCtx:
Class Members
gdIOCtx ctx
gdSinkPtr snk
gdSourcePtr src

Typedef Documentation

Definition at line 44 of file gd_io_ss.c.


Function Documentation

static void gdFreeSsCtx ( gdIOCtx ctx) [static]

Definition at line 84 of file gd_io_ss.c.

{
  gdFree (ctx);
}

Here is the call graph for this function:

Here is the caller graph for this function:

gdIOCtx* gdNewSSCtx ( gdSourcePtr  src,
gdSinkPtr  snk 
)

Definition at line 56 of file gd_io_ss.c.

{
  ssIOCtxPtr ctx;

  ctx = (ssIOCtxPtr) gdMalloc (sizeof (ssIOCtx));
  if (ctx == NULL)
    {
      return NULL;
    }

  ctx->src = src;
  ctx->snk = snk;

  ctx->ctx.getC = sourceGetchar;
  ctx->ctx.getBuf = sourceGetbuf;

  ctx->ctx.putC = sinkPutchar;
  ctx->ctx.putBuf = sinkPutbuf;

  ctx->ctx.tell = NULL;
  ctx->ctx.seek = NULL;

  ctx->ctx.gd_free = gdFreeSsCtx;

  return (gdIOCtx *) ctx;
}

Here is the call graph for this function:

static int sinkPutbuf ( gdIOCtx ctx,
const void buf,
int  size 
) [static]

Definition at line 140 of file gd_io_ss.c.

{
  ssIOCtxPtr lctx;
  int res;

  lctx = (ssIOCtx *) ctx;

  res = (lctx->snk->sink) (lctx->snk->context, buf, size);

  if (res <= 0)
    {
      return 0;
    }
  else
    {
      return res;
    };

}

Here is the caller graph for this function:

static void sinkPutchar ( gdIOCtx ctx,
int  a 
) [static]

Definition at line 161 of file gd_io_ss.c.

{
  unsigned char b;

  b = a;
  sinkPutbuf (ctx, &b, 1);

}

Here is the call graph for this function:

Here is the caller graph for this function:

static int sourceGetbuf ( gdIOCtx ctx,
void buf,
int  size 
) [static]

Definition at line 91 of file gd_io_ss.c.

{
  ssIOCtx *lctx;
  int res;

  lctx = (ssIOCtx *) ctx;

  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;
    };

}

Here is the caller graph for this function:

static int sourceGetchar ( gdIOCtx ctx) [static]

Definition at line 121 of file gd_io_ss.c.

{
  int res;
  unsigned char buf;

  res = sourceGetbuf (ctx, &buf, 1);

  if (res == 1)
    {
      return buf;
    }
  else
    {
      return EOF;
    };

}

Here is the call graph for this function:

Here is the caller graph for this function: