⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ming-dev.c

📁 flash swf file player
💻 C
📖 第 1 页 / 共 5 页
字号:
/*   +----------------------------------------------------------------------+   | PHP Version 4                                                        |   +----------------------------------------------------------------------+   | Copyright (c) 1997-2002 The PHP Group                                |   +----------------------------------------------------------------------+   | This source file is subject to version 2.01 of the PHP license,      |   | that is bundled with this package in the file LICENSE, and is        |   | available at through the world-wide-web at                           |   | http://www.php.net/license/2_01.txt.                                 |   | If you did not receive a copy of the PHP license and are unable to   |   | obtain it through the world-wide-web, please send a note to          |   | license@php.net so we can mail you a copy immediately.               |   +----------------------------------------------------------------------+   | Author: dave@opaque.net                                              |   +----------------------------------------------------------------------+*//* $Id: ming-dev.c,v 1.3 2004/01/18 06:46:48 vapour Exp $ */#include <stdio.h>#include <math.h>#ifdef HAVE_CONFIG_H#include "ming_config.h"#endif#include "php.h"#include "php_ming.h"#include "ext/standard/info.h"#include "ext/standard/file.h"#include "ext/standard/fsock.h"#include "php_streams.h"#if HAVE_MINGstatic zend_function_entry ming_functions[] = {	PHP_FALIAS(ming_setcubicthreshold,  ming_setCubicThreshold,  NULL)	PHP_FALIAS(ming_setscale,           ming_setScale,           NULL)	PHP_FALIAS(ming_useswfversion,      ming_useSWFVersion,      NULL)	PHP_FALIAS(swfbutton_keypress,      swfbutton_keypress,      NULL)	{ NULL, NULL, NULL }};static SWFMovie getMovie(zval *id TSRMLS_DC);static SWFFill getFill(zval *id TSRMLS_DC);static SWFGradient getGradient(zval *id TSRMLS_DC);static SWFBitmap getBitmap(zval *id TSRMLS_DC);static SWFShape getShape(zval *id TSRMLS_DC);static SWFFont getFont(zval *id TSRMLS_DC);static SWFText getText(zval *id TSRMLS_DC);static SWFTextField getTextField(zval *id TSRMLS_DC);static SWFDisplayItem getDisplayItem(zval *id TSRMLS_DC);static SWFButton getButton(zval *id TSRMLS_DC);static SWFAction getAction(zval *id TSRMLS_DC);static SWFMorph getMorph(zval *id TSRMLS_DC);static SWFMovieClip getSprite(zval *id TSRMLS_DC);/* {{{ proto void ming_setcubicthreshold (int threshold)   Set cubic threshold (?) */PHP_FUNCTION(ming_setCubicThreshold){	zval **num;	if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &num) == FAILURE) {		WRONG_PARAM_COUNT;	}	convert_to_long_ex(num);	Ming_setCubicThreshold(Z_LVAL_PP(num));}/* }}} *//* {{{ proto void ming_setscale(int scale)   Set scale (?) */PHP_FUNCTION(ming_setScale){	zval **num;	if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &num) == FAILURE) {		WRONG_PARAM_COUNT;	}	convert_to_double_ex(num);	Ming_setScale(Z_DVAL_PP(num));}/* }}} *//* {{{ proto void ming_useswfversion(int version)   Use SWF version (?) */ PHP_FUNCTION(ming_useSWFVersion){	zval **num;	if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &num) == FAILURE) {		WRONG_PARAM_COUNT;	}	convert_to_long_ex(num);	Ming_useSWFVersion(Z_LVAL_PP(num));}/* }}} */static int le_swfmoviep;static int le_swfshapep;static int le_swffillp;static int le_swfgradientp;static int le_swfbitmapp;static int le_swffontp;static int le_swftextp;static int le_swftextfieldp;static int le_swfdisplayitemp;static int le_swfbuttonp;static int le_swfactionp;static int le_swfmorphp;static int le_swfspritep;static int le_swfinputp;zend_class_entry movie_class_entry;zend_class_entry shape_class_entry;zend_class_entry fill_class_entry;zend_class_entry gradient_class_entry;zend_class_entry bitmap_class_entry;zend_class_entry font_class_entry;zend_class_entry text_class_entry;zend_class_entry textfield_class_entry;zend_class_entry displayitem_class_entry;zend_class_entry button_class_entry;zend_class_entry action_class_entry;zend_class_entry morph_class_entry;zend_class_entry sprite_class_entry;/* {{{ internal function SWFgetProperty */static void *SWFgetProperty(zval *id, char *name, int namelen, int proptype TSRMLS_DC){	zval **tmp;	int id_to_find;	void *property;	int type;  	if (id) {		if (zend_hash_find(Z_OBJPROP_P(id), name, namelen+1, (void **)&tmp) == FAILURE) {			php_error(E_WARNING, "unable to find property %s", name);			return NULL;		}		id_to_find = Z_LVAL_PP(tmp);	} else {		return NULL;	}	property = zend_list_find(id_to_find, &type);	if (!property || type != proptype) {		php_error(E_WARNING, "unable to find identifier (%d)", id_to_find);		return NULL;	}	return property;}/* }}} *//* {{{ SWFCharacter - not a real class*//* {{{ internal function SWFCharacter getCharacter(zval *id)   Returns the SWFCharacter contained in zval *id */static SWFCharacter getCharacter(zval *id TSRMLS_DC){	if (Z_OBJCE_P(id) == &shape_class_entry)		return (SWFCharacter)getShape(id TSRMLS_CC);	else if (Z_OBJCE_P(id) == &font_class_entry)		return (SWFCharacter)getFont(id TSRMLS_CC);	else if (Z_OBJCE_P(id) == &text_class_entry)		return (SWFCharacter)getText(id TSRMLS_CC);	else if (Z_OBJCE_P(id) == &textfield_class_entry)		return (SWFCharacter)getTextField(id TSRMLS_CC);	else if (Z_OBJCE_P(id) == &button_class_entry)		return (SWFCharacter)getButton(id TSRMLS_CC);	else if (Z_OBJCE_P(id) == &morph_class_entry)		return (SWFCharacter)getMorph(id TSRMLS_CC);	else if (Z_OBJCE_P(id) == &sprite_class_entry)		return (SWFCharacter)getSprite(id TSRMLS_CC);	else if (Z_OBJCE_P(id) == &bitmap_class_entry)		return (SWFCharacter)getBitmap(id TSRMLS_CC);	else		php_error(E_ERROR, "called object is not an SWFCharacter");		return NULL;}/* }}} *//* }}} *//* {{{ getInput - utility func for making an SWFInput from an fopened resource*/static void destroy_SWFInput_resource(zend_rsrc_list_entry *resource TSRMLS_DC){	destroySWFInput((SWFInput)resource->ptr);}static SWFInput getInput(zval **zfile TSRMLS_DC){	FILE *file;	void *what;	int type;	SWFInput input;	what = zend_fetch_resource(zfile TSRMLS_CC, -1, "File-Handle", &type, 1, php_file_le_stream());	if (php_stream_cast((php_stream*)what, PHP_STREAM_AS_STDIO, (void *) &file, REPORT_ERRORS) != SUCCESS) {		return NULL;	}  	input = newSWFInput_file(file);	zend_list_addref(Z_LVAL_PP(zfile));	zend_list_addref(zend_list_insert(input, le_swfinputp));	return input;}/* }}} *//* {{{ SWFAction*/static zend_function_entry swfaction_functions[] = {	PHP_FALIAS(swfaction,              swfaction_init,         NULL)	{ NULL, NULL, NULL }};/* {{{ proto object swfaction_init(string)   Returns a new SWFAction object, compiling the given script */PHP_FUNCTION(swfaction_init){	SWFAction action;	zval **script;	int ret;	if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &script) == FAILURE) {		WRONG_PARAM_COUNT;	}		convert_to_string_ex(script);	action = compileSWFActionCode(Z_STRVAL_PP(script));	if (!action) {		php_error(E_ERROR, "Couldn't compile actionscript.");	}		ret = zend_list_insert(action, le_swfactionp);	object_init_ex(getThis(), &action_class_entry);	add_property_resource(getThis(), "action", ret);	zend_list_addref(ret);}/* no destructor for SWFAction, it's not a character *//* }}} *//* {{{ internal function getAction   Returns the SWFAction object contained in zval *id */static SWFAction getAction(zval *id TSRMLS_DC){	void *action = SWFgetProperty(id, "action", 6, le_swfactionp TSRMLS_CC);	if (!action) {		php_error(E_ERROR, "called object is not an SWFAction!");	}	return (SWFAction)action;}/* }}} *//* }}} *//* {{{ SWFBitmap */static zend_function_entry swfbitmap_functions[] = {	PHP_FALIAS(swfbitmap,           swfbitmap_init,                NULL)	PHP_FALIAS(getwidth,            swfbitmap_getWidth,            NULL)	PHP_FALIAS(getheight,           swfbitmap_getHeight,           NULL)	{ NULL, NULL, NULL }};/* {{{ proto class swfbitmap_init(file [, maskfile])   Returns a new SWFBitmap object from jpg (with optional mask) or dbl file */PHP_FUNCTION(swfbitmap_init){	zval **zfile, **zmask = NULL;	SWFBitmap bitmap;	SWFInput input, maskinput;	int ret;	if (ZEND_NUM_ARGS() == 1) {		if (zend_get_parameters_ex(1, &zfile) == FAILURE) {			WRONG_PARAM_COUNT;		}	} else if (ZEND_NUM_ARGS() == 2) {		if (zend_get_parameters_ex(2, &zfile, &zmask) == FAILURE) {			WRONG_PARAM_COUNT;		}	} else {		WRONG_PARAM_COUNT;	}		if (Z_TYPE_PP(zfile) != IS_RESOURCE) {		convert_to_string_ex(zfile);		input = newSWFInput_buffer(Z_STRVAL_PP(zfile), Z_STRLEN_PP(zfile));		zend_list_addref(zend_list_insert(input, le_swfinputp));	} else {		input = getInput(zfile TSRMLS_CC);	}		if (zmask != NULL) {		if (Z_TYPE_PP(zmask) != IS_RESOURCE) {			convert_to_string_ex(zmask);			maskinput = newSWFInput_buffer(Z_STRVAL_PP(zmask), Z_STRLEN_PP(zmask));			zend_list_addref(zend_list_insert(maskinput, le_swfinputp));		} else {			maskinput = getInput(zmask TSRMLS_CC);		}		bitmap = newSWFJpegWithAlpha_fromInput(input, maskinput);	} else {		bitmap = newSWFBitmap_fromInput(input);	}	ret = zend_list_insert(bitmap, le_swfbitmapp);	object_init_ex(getThis(), &bitmap_class_entry);	add_property_resource(getThis(), "bitmap", ret);	zend_list_addref(ret);}static void destroy_SWFBitmap_resource(zend_rsrc_list_entry *resource TSRMLS_DC){	destroySWFBitmap((SWFBitmap)resource->ptr);}/* }}} *//* {{{ internal function getBitmap   Returns the SWFBitmap object contained in zval *id */static SWFBitmap getBitmap(zval *id TSRMLS_DC){	void *bitmap = SWFgetProperty(id, "bitmap", 6, le_swfbitmapp TSRMLS_CC);	if (!bitmap) {		php_error(E_ERROR, "called object is not an SWFBitmap!");	}	return (SWFBitmap)bitmap;}/* }}} *//* {{{ proto void swfbitmap_getWidth(void)   Returns the width of this bitmap */PHP_FUNCTION(swfbitmap_getWidth){	RETURN_DOUBLE(SWFBitmap_getWidth(getBitmap(getThis() TSRMLS_CC)));}/* }}} *//* {{{ proto void swfbitmap_getHeight(void)   Returns the height of this bitmap */PHP_FUNCTION(swfbitmap_getHeight){	RETURN_DOUBLE(SWFBitmap_getHeight(getBitmap(getThis() TSRMLS_CC)));}/* }}} *//* }}} *//* {{{ SWFButton*/static zend_function_entry swfbutton_functions[] = {	PHP_FALIAS(swfbutton,              swfbutton_init,            NULL)	PHP_FALIAS(sethit,                 swfbutton_setHit,          NULL)	PHP_FALIAS(setover,                swfbutton_setOver,         NULL)	PHP_FALIAS(setup,                  swfbutton_setUp,           NULL)	PHP_FALIAS(setdown,                swfbutton_setDown,         NULL)	PHP_FALIAS(setaction,              swfbutton_setAction,       NULL)	PHP_FALIAS(addshape,               swfbutton_addShape,        NULL)	PHP_FALIAS(addaction,              swfbutton_addAction,       NULL)	{ NULL, NULL, NULL }};/* {{{ proto object swfbutton_init(void)   Returns a new SWFButton object */PHP_FUNCTION(swfbutton_init){	SWFButton button = newSWFButton();	int ret = zend_list_insert(button, le_swfbuttonp);	object_init_ex(getThis(), &button_class_entry);	add_property_resource(getThis(), "button", ret);	zend_list_addref(ret);}static void destroy_SWFButton_resource(zend_rsrc_list_entry *resource TSRMLS_DC){	destroySWFButton((SWFButton)resource->ptr);}/* }}} *//* {{{ internal function getButton   Returns the SWFButton object contained in zval *id */static SWFButton getButton(zval *id TSRMLS_DC){	void *button = SWFgetProperty(id, "button", 6, le_swfbuttonp TSRMLS_CC);	if(!button) {		php_error(E_ERROR, "called object is not an SWFButton!");	}	return (SWFButton)button;}/* }}} *//* {{{ proto void swfbutton_setHit(SWFCharacter)   Sets the character for this button's hit test state */PHP_FUNCTION(swfbutton_setHit){	zval **zchar;	SWFButton button = getButton(getThis() TSRMLS_CC);	SWFCharacter character;	if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zchar) == FAILURE) {		WRONG_PARAM_COUNT;	}	convert_to_object_ex(zchar);	character = getCharacter(*zchar TSRMLS_CC);	SWFButton_addShape(button, character, SWFBUTTONRECORD_HITSTATE);}/* }}} *//* {{{ proto void swfbutton_setOver(SWFCharacter)   Sets the character for this button's over state */PHP_FUNCTION(swfbutton_setOver){	zval **zchar;	SWFButton button = getButton(getThis() TSRMLS_CC);	SWFCharacter character;	if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zchar) == FAILURE) {		WRONG_PARAM_COUNT;	}		convert_to_object_ex(zchar);	character = getCharacter(*zchar TSRMLS_CC);	SWFButton_addShape(button, character, SWFBUTTONRECORD_OVERSTATE);}/* }}} *//* {{{ proto void swfbutton_setUp(SWFCharacter)   Sets the character for this button's up state */PHP_FUNCTION(swfbutton_setUp){	zval **zchar;	SWFButton button = getButton(getThis() TSRMLS_CC);	SWFCharacter character;	if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zchar) == FAILURE) {		WRONG_PARAM_COUNT;	}		convert_to_object_ex(zchar);	character = getCharacter(*zchar TSRMLS_CC);	SWFButton_addShape(button, character, SWFBUTTONRECORD_UPSTATE);}/* }}} *//* {{{ proto void swfbutton_setDown(SWFCharacter)   Sets the character for this button's down state */PHP_FUNCTION(swfbutton_setDown){	zval **zchar;	SWFButton button = getButton(getThis() TSRMLS_CC);	SWFCharacter character;	if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zchar) == FAILURE) {		WRONG_PARAM_COUNT;	}		convert_to_object_ex(zchar);	character = getCharacter(*zchar TSRMLS_CC);	SWFButton_addShape(button, character, SWFBUTTONRECORD_DOWNSTATE);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -