[ Avaa Bypassed ]




Upload:

Command:

hmhc3928@18.218.119.140: ~ $
/*
   * io_file.c
   *
   * Implements the file interface.
   *
   * As will all I/O modules, most functions are for local use only (called
   * via function pointers in the I/O context).
   *
   * Most functions are just 'wrappers' for standard file functions.
   *
   * Written/Modified 1999, Philip Warner.
   *
 */

/* For platforms with incomplete ANSI defines. Fortunately,
   SEEK_SET is defined to be zero by the standard. */

#ifndef SEEK_SET
#define SEEK_SET 0
#endif /* SEEK_SET */

#include <math.h>
#include <string.h>
#include <stdlib.h>
#include "gd.h"
#include "gdhelpers.h"

/* this is used for creating images in main memory */

typedef struct fileIOCtx
{
	gdIOCtx ctx;
	FILE *f;
} fileIOCtx;

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

/* return data as a dynamic pointer */
gdIOCtx * gdNewFileCtx (FILE * f)
{
	fileIOCtx *ctx;

	ctx = (fileIOCtx *) gdMalloc(sizeof (fileIOCtx));

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

static void gdFreeFileCtx (gdIOCtx * ctx)
{
	gdFree(ctx);
}


static int filePutbuf (gdIOCtx * ctx, const void *buf, int size)
{
	fileIOCtx *fctx;
	fctx = (fileIOCtx *) ctx;

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

}

static int fileGetbuf (gdIOCtx * ctx, void *buf, int size)
{
	fileIOCtx *fctx;
	fctx = (fileIOCtx *) ctx;

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

static void filePutchar (gdIOCtx * ctx, int a)
{
	unsigned char b;
	fileIOCtx *fctx;
	fctx = (fileIOCtx *) ctx;

	b = a;

	putc (b, fctx->f);
}

static int fileGetchar (gdIOCtx * ctx)
{
	fileIOCtx *fctx;
	fctx = (fileIOCtx *) ctx;

	return getc (fctx->f);
}


static int fileSeek (struct gdIOCtx *ctx, const int pos)
{
	fileIOCtx *fctx;
	fctx = (fileIOCtx *) ctx;

	return (fseek (fctx->f, pos, SEEK_SET) == 0);
}

static long fileTell (struct gdIOCtx *ctx)
{
	fileIOCtx *fctx;
	fctx = (fileIOCtx *) ctx;

	return ftell (fctx->f);
}

Filemanager

Name Type Size Permission Actions
gd.c File 72.75 KB 0644
gd.h File 32.2 KB 0644
gd_arc.c File 1.66 KB 0644
gd_color.c File 1.5 KB 0644
gd_crop.c File 9.04 KB 0644
gd_filter.c File 10.3 KB 0644
gd_gd.c File 5.2 KB 0644
gd_gd2.c File 19.73 KB 0644
gd_gif_in.c File 13.89 KB 0644
gd_gif_out.c File 20.54 KB 0644
gd_interpolation.c File 71.93 KB 0644
gd_io.c File 2.69 KB 0644
gd_io.h File 963 B 0644
gd_io_dp.c File 6.93 KB 0644
gd_io_file.c File 2.31 KB 0644
gd_io_ss.c File 2.66 KB 0644
gd_jpeg.c File 26.21 KB 0644
gd_matrix.c File 7.78 KB 0644
gd_pixelate.c File 1.33 KB 0644
gd_png.c File 22 KB 0644
gd_rotate.c File 12.98 KB 0644
gd_security.c File 671 B 0644
gd_ss.c File 1.08 KB 0644
gd_topal.c File 63.08 KB 0644
gd_transform.c File 1.27 KB 0644
gd_wbmp.c File 5.17 KB 0644
gd_webp.c File 5.04 KB 0644
gdcache.c File 4.99 KB 0644
gdcache.h File 2.68 KB 0644
gdfontg.c File 113.25 KB 0644
gdfontg.h File 529 B 0644
gdfontl.c File 108.5 KB 0644
gdfontl.h File 527 B 0644
gdfontmb.c File 79.24 KB 0644
gdfontmb.h File 495 B 0644
gdfonts.c File 69.46 KB 0644
gdfonts.h File 491 B 0644
gdfontt.c File 38.49 KB 0644
gdfontt.h File 522 B 0644
gdft.c File 32.57 KB 0644
gdhelpers.c File 1.19 KB 0644
gdhelpers.h File 1.32 KB 0644
gdkanji.c File 12.11 KB 0644
gdtables.c File 5.45 KB 0644
gdxpm.c File 3.21 KB 0644
wbmp.c File 6.76 KB 0644
wbmp.h File 1.25 KB 0644
webpimg.c File 28.33 KB 0644
webpimg.h File 7.04 KB 0644
xbm.c File 5.3 KB 0644