Back to index

php5  5.3.10
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 32 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 39 of file gd_io_ss.c.


Function Documentation

static void gdFreeSsCtx ( gdIOCtx ctx) [static]

Definition at line 73 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 50 of file gd_io_ss.c.

{
       ssIOCtxPtr ctx;

       ctx = (ssIOCtxPtr) gdMalloc (sizeof (ssIOCtx));

       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:

Here is the caller graph for this function:

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

Definition at line 116 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 132 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 79 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 102 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: