Back to index

tetex-bin  3.0
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

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)
 BGD_DECLARE (gdIOCtx *)

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

typedef struct ssIOCtx ssIOCtx
typedef struct ssIOCtx* ssIOCtxPtr

Definition at line 44 of file gd_io_ss.c.


Function Documentation

Definition at line 53 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 void gdFreeSsCtx ( gdIOCtx ctx) [static]

Definition at line 81 of file gd_io_ss.c.

{
  gdFree (ctx);
}

Here is the caller graph for this function:

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

Definition at line 137 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 158 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 88 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 118 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: