Back to index

tetex-bin  3.0
Classes | Defines | Typedefs | Functions
gd_io_file.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  fileIOCtx

Defines

#define SEEK_SET   0

Typedefs

typedef struct fileIOCtx fileIOCtx

Functions

gdIOCtxnewFileCtx (FILE *f)
static int fileGetbuf (gdIOCtx *, void *, int)
static int filePutbuf (gdIOCtx *, const void *, int)
static void filePutchar (gdIOCtx *, int)
static int fileGetchar (gdIOCtx *ctx)
static int fileSeek (struct gdIOCtx *, const int)
static long fileTell (struct gdIOCtx *)
static void gdFreeFileCtx (gdIOCtx *ctx)
 BGD_DECLARE (gdIOCtx *)

Class Documentation

struct fileIOCtx

Definition at line 35 of file gd_io_file.c.

Collaboration diagram for fileIOCtx:
Class Members
gdIOCtx ctx
FILE * f

Define Documentation

#define SEEK_SET   0

Definition at line 24 of file gd_io_file.c.


Typedef Documentation

typedef struct fileIOCtx fileIOCtx

Function Documentation

Definition at line 54 of file gd_io_file.c.

{
  fileIOCtx *ctx;

  ctx = (fileIOCtx *) gdMalloc (sizeof (fileIOCtx));
  if (ctx == NULL)
    {
      return NULL;
    }

  ctx->f = f;

  ctx->ctx.getC = fileGetchar;
  ctx->ctx.putC = filePutchar;

  ctx->ctx.getBuf = fileGetbuf;
  ctx->ctx.putBuf = filePutbuf;

  ctx->ctx.tell = fileTell;
  ctx->ctx.seek = fileSeek;

  ctx->ctx.gd_free = gdFreeFileCtx;

  return (gdIOCtx *) ctx;
}

Here is the call graph for this function:

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

Definition at line 98 of file gd_io_file.c.

{
  fileIOCtx *fctx;
  fctx = (fileIOCtx *) ctx;

  return (fread (buf, 1, size, fctx->f));

}

Here is the caller graph for this function:

static int fileGetchar ( gdIOCtx ctx) [static]

Definition at line 120 of file gd_io_file.c.

{
  fileIOCtx *fctx;
  fctx = (fileIOCtx *) ctx;

  return getc (fctx->f);
}

Here is the caller graph for this function:

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

Definition at line 88 of file gd_io_file.c.

{
  fileIOCtx *fctx;
  fctx = (fileIOCtx *) ctx;

  return fwrite (buf, 1, size, fctx->f);

}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 108 of file gd_io_file.c.

{
  unsigned char b;
  fileIOCtx *fctx;
  fctx = (fileIOCtx *) ctx;

  b = a;

  putc (b, fctx->f);
}

Here is the caller graph for this function:

static int fileSeek ( struct gdIOCtx ctx,
const int  pos 
) [static]

Definition at line 130 of file gd_io_file.c.

{
  fileIOCtx *fctx;
  fctx = (fileIOCtx *) ctx;
  return (fseek (fctx->f, pos, SEEK_SET) == 0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static long fileTell ( struct gdIOCtx ctx) [static]

Definition at line 138 of file gd_io_file.c.

{
  fileIOCtx *fctx;
  fctx = (fileIOCtx *) ctx;

  return ftell (fctx->f);
}

Here is the caller graph for this function:

static void gdFreeFileCtx ( gdIOCtx ctx) [static]

Definition at line 81 of file gd_io_file.c.

{
  gdFree (ctx);
}

Here is the caller graph for this function:

gdIOCtx* newFileCtx ( FILE f)