📄 swf.c
字号:
/* +----------------------------------------------------------------------+ | PHP Version 4 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2007 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_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: Sterling Hughes <sterling@php.net> | +----------------------------------------------------------------------+*//* $Id: swf.c,v 1.46.2.5.2.2 2007/01/01 09:46:49 sebastian Exp $ */#ifdef HAVE_CONFIG_H#include "config.h"#endif#include "php.h"#if HAVE_SWF#include <stdio.h>#include <swf.h>#include "ext/standard/info.h"#include "php_open_temporary_file.h"#include "php_swf.h"ZEND_DECLARE_MODULE_GLOBALS(swf)/* {{{ swf_functions[] */function_entry swf_functions[] = { PHP_FE(swf_openfile, NULL) PHP_FE(swf_closefile, NULL) PHP_FE(swf_labelframe, NULL) PHP_FE(swf_showframe, NULL) PHP_FE(swf_setframe, NULL) PHP_FE(swf_getframe, NULL) PHP_FE(swf_mulcolor, NULL) PHP_FE(swf_addcolor, NULL) PHP_FE(swf_placeobject, NULL) PHP_FE(swf_modifyobject, NULL) PHP_FE(swf_removeobject, NULL) PHP_FE(swf_nextid, NULL) PHP_FE(swf_startdoaction, NULL) PHP_FE(swf_enddoaction, NULL) PHP_FE(swf_actiongotoframe, NULL) PHP_FE(swf_actiongeturl, NULL) PHP_FE(swf_actionnextframe, NULL) PHP_FE(swf_actionprevframe, NULL) PHP_FE(swf_actionplay, NULL) PHP_FE(swf_actionstop, NULL) PHP_FE(swf_actiontogglequality, NULL) PHP_FE(swf_actionwaitforframe, NULL) PHP_FE(swf_actionsettarget, NULL) PHP_FE(swf_actiongotolabel, NULL) PHP_FE(swf_defineline, NULL) PHP_FE(swf_definerect, NULL) PHP_FE(swf_definepoly, NULL) PHP_FE(swf_startshape, NULL) PHP_FE(swf_shapelinesolid, NULL) PHP_FE(swf_shapefilloff, NULL) PHP_FE(swf_shapefillsolid, NULL) PHP_FE(swf_shapefillbitmapclip, NULL) PHP_FE(swf_shapefillbitmaptile, NULL) PHP_FE(swf_shapemoveto, NULL) PHP_FE(swf_shapelineto, NULL) PHP_FE(swf_shapecurveto, NULL) PHP_FE(swf_shapecurveto3, NULL) PHP_FE(swf_shapearc, NULL) PHP_FE(swf_endshape, NULL) PHP_FE(swf_definefont, NULL) PHP_FE(swf_setfont, NULL) PHP_FE(swf_fontsize, NULL) PHP_FE(swf_fontslant, NULL) PHP_FE(swf_fonttracking, NULL) PHP_FE(swf_getfontinfo, NULL) PHP_FE(swf_definetext, NULL) PHP_FE(swf_textwidth, NULL) PHP_FE(swf_definebitmap, NULL) PHP_FE(swf_getbitmapinfo, NULL) PHP_FE(swf_startsymbol, NULL) PHP_FE(swf_endsymbol, NULL) PHP_FE(swf_startbutton, NULL) PHP_FE(swf_addbuttonrecord, NULL) PHP_FE(swf_oncondition, NULL) PHP_FE(swf_endbutton, NULL) PHP_FE(swf_viewport, NULL) PHP_FE(swf_ortho, NULL) PHP_FE(swf_ortho2, NULL) PHP_FE(swf_perspective, NULL) PHP_FE(swf_polarview, NULL) PHP_FE(swf_lookat, NULL) PHP_FE(swf_pushmatrix, NULL) PHP_FE(swf_popmatrix, NULL) PHP_FE(swf_scale, NULL) PHP_FE(swf_translate, NULL) PHP_FE(swf_rotate, NULL) PHP_FE(swf_posround, NULL) {NULL,NULL,NULL}};/* }}} *//* {{{ swf_module_entry */zend_module_entry swf_module_entry = { STANDARD_MODULE_HEADER, "swf", swf_functions, PHP_MINIT(swf), NULL, PHP_RINIT(swf), NULL, PHP_MINFO(swf), NO_VERSION_YET, STANDARD_MODULE_PROPERTIES};/* }}} */#ifdef COMPILE_DL_SWFZEND_GET_MODULE(swf)#endif/* {{{ PHP_MINFO_FUNCTION */PHP_MINFO_FUNCTION(swf){ php_info_print_table_start(); php_info_print_table_row(2, "swf support", "enabled"); php_info_print_table_end();}/* }}} *//* {{{ _swf_init_globals */static void _swf_init_globals(zend_swf_globals *sg){ memset(sg, 0, sizeof(zend_swf_globals));}/* }}} *//* {{{ PHP_MINIT_FUNCTION */PHP_MINIT_FUNCTION(swf){ ZEND_INIT_MODULE_GLOBALS(swf, _swf_init_globals, NULL); REGISTER_LONG_CONSTANT("MOD_COLOR", MOD_COLOR, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("MOD_MATRIX", MOD_MATRIX, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("TYPE_PUSHBUTTON", TYPE_PUSHBUTTON, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("TYPE_MENUBUTTON", TYPE_MENUBUTTON, CONST_CS | CONST_PERSISTENT); REGISTER_DOUBLE_CONSTANT("BSHitTest", BSHitTest, CONST_CS | CONST_PERSISTENT); REGISTER_DOUBLE_CONSTANT("BSDown", BSDown, CONST_CS | CONST_PERSISTENT); REGISTER_DOUBLE_CONSTANT("BSOver", BSOver, CONST_CS | CONST_PERSISTENT); REGISTER_DOUBLE_CONSTANT("BSUp", BSUp, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("OverDowntoIdle", OverDowntoIdle, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("IdletoOverDown", IdletoOverDown, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("OutDowntoIdle", OutDowntoIdle, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("OutDowntoOverDown", OutDowntoOverDown, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("OverDowntoOutDown", OverDowntoOutDown, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("OverUptoOverDown", OverUptoOverDown, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("OverUptoIdle", OverUptoIdle, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("IdletoOverUp", IdletoOverUp, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("ButtonEnter", ButtonEnter, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("ButtonExit", ButtonExit, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("MenuEnter", MenuEnter, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("MenuExit", MenuExit, CONST_CS | CONST_PERSISTENT); return SUCCESS;}/* }}} *//* {{{ PHP_RINIT_FUNCTION */PHP_RINIT_FUNCTION(swf){ SWFG(use_file) = 0; return SUCCESS;}/* }}} */ /* {{{ proto void swf_openfile(string name, float xsize, float ysize, float framerate, float r, float g, float b) Create a Shockwave Flash file given by name, with width xsize and height ysize at a frame rate of framerate and a background color specified by a red value of r, green value of g and a blue value of b */PHP_FUNCTION(swf_openfile){ zval **name, **sizeX, **sizeY, **frameRate, **r, **g, **b; char *na, *tmpna; zend_bool free_na = 0; if (ZEND_NUM_ARGS() != 7 || zend_get_parameters_ex(7, &name, &sizeX, &sizeY, &frameRate, &r, &g, &b) == FAILURE) { WRONG_PARAM_COUNT; } convert_to_string_ex(name); convert_to_double_ex(sizeX); convert_to_double_ex(sizeY); convert_to_double_ex(frameRate); convert_to_double_ex(r); convert_to_double_ex(g); convert_to_double_ex(b); tmpna = Z_STRVAL_PP(name); if (strcasecmp("php://stdout", tmpna) == 0) { FILE *fp; fp = php_open_temporary_file(NULL, "php_swf_stdout", &na TSRMLS_CC); if (!fp) { free_na = 0; RETURN_FALSE; } VCWD_UNLINK((const char *)na); fclose(fp); free_na = 1; SWFG(use_file) = 0; } else { na = tmpna; SWFG(use_file) = 1; }#ifdef VIRTUAL_DIR if (virtual_filepath_ex(na, &tmpna, NULL TSRMLS_CC)) { if (free_na) { efree(na); } return; } if (free_na) { efree(na); } na = tmpna;#endif if (php_check_open_basedir(na TSRMLS_CC) || (PG(safe_mode) && !php_checkuid(na, "wb+", CHECKUID_CHECK_MODE_PARAM))) {#ifdef VIRTUAL_DIR free(na);#endif return; } if (!SWFG(use_file)) SWFG(tmpfile_name) = na; swf_openfile(na,(float)Z_DVAL_PP(sizeX), (float)Z_DVAL_PP(sizeY), (float)Z_DVAL_PP(frameRate), (float)Z_DVAL_PP(r), (float)Z_DVAL_PP(g), (float)Z_DVAL_PP(b));}/* }}} *//* {{{ proto void swf_closefile(void) Close a Shockwave flash file that was opened with swf_openfile */PHP_FUNCTION(swf_closefile){ swf_closefile(); if (!SWFG(use_file)) { FILE *f; char buf[4096]; int b; if ((f = VCWD_FOPEN(SWFG(tmpfile_name), "r")) == NULL) { php_error(E_WARNING, "Cannot create temporary file for stdout support with SWF"); RETURN_NULL(); } while ((b = fread(buf, 1, sizeof(buf), f)) > 0) php_write(buf, b TSRMLS_CC); fclose(f); VCWD_UNLINK((const char *)SWFG(tmpfile_name)); efree(SWFG(tmpfile_name)); }}/* }}} *//* {{{ proto void swf_labelframe(string name) Adds string name to the current frame */PHP_FUNCTION(swf_labelframe){ zval **name; if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &name) == FAILURE) { WRONG_PARAM_COUNT; } convert_to_string_ex(name); swf_labelframe(Z_STRVAL_PP(name));}/* }}} *//* {{{ proto void swf_showframe(void) Finish the current frame */PHP_FUNCTION(swf_showframe){ swf_showframe();}/* }}} *//* {{{ proto void swf_setframe(int frame_number) Set the current frame number to the number given by frame_number */PHP_FUNCTION(swf_setframe){ zval **frameno; if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &frameno) == FAILURE) { WRONG_PARAM_COUNT; } convert_to_long_ex(frameno); swf_setframe(Z_LVAL_PP(frameno));}/* }}} *//* {{{ proto int swf_getframe(void) Returns the current frame */PHP_FUNCTION(swf_getframe){ RETURN_LONG(swf_getframe());}/* }}} *//* {{{ col_swf */void col_swf(INTERNAL_FUNCTION_PARAMETERS, int opt) { zval **r, **g, **b, **a; if (ZEND_NUM_ARGS() != 4 || zend_get_parameters_ex(4, &r, &g, &b, &a) == FAILURE) { WRONG_PARAM_COUNT; } convert_to_double_ex(r); convert_to_double_ex(g); convert_to_double_ex(b); convert_to_double_ex(a); if (opt) { swf_addcolor((float)Z_DVAL_PP(r), (float)Z_DVAL_PP(g), (float)Z_DVAL_PP(b), (float)Z_DVAL_PP(a)); } else { swf_mulcolor((float)Z_DVAL_PP(r), (float)Z_DVAL_PP(g), (float)Z_DVAL_PP(b), (float)Z_DVAL_PP(a)); }}/* }}} *//* {{{ proto void swf_mulcolor(float r, float g, float b, float a) Sets the global multiply color to the rgba value specified */PHP_FUNCTION(swf_mulcolor){ col_swf(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);}/* }}} */ /* {{{ proto void swf_addcolor(float r, float g, float b, float a) Set the global add color to the rgba value specified */PHP_FUNCTION(swf_addcolor){ col_swf(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);}/* }}} */ /* {{{ proto void swf_placeobject(int objid, int depth) Places the object, objid, in the current frame at depth, depth */PHP_FUNCTION(swf_placeobject){ zval **objid, **depth; if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &objid, &depth) == FAILURE) { WRONG_PARAM_COUNT; } convert_to_long_ex(objid); convert_to_long_ex(depth); swf_placeobject(Z_LVAL_PP(objid), Z_LVAL_PP(depth));}/* }}} *//* {{{ proto void swf_modifyobject(int depth, int how) Updates the position and/or color of the object */PHP_FUNCTION(swf_modifyobject){ zval **depth, **how; if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &depth, &how) == FAILURE) { WRONG_PARAM_COUNT; } convert_to_long_ex(depth); convert_to_long_ex(how); swf_modifyobject(Z_LVAL_PP(depth), Z_LVAL_PP(how));}/* }}} *//* {{{ proto void swf_removeobject(int depth) Removes the object at the specified depth */PHP_FUNCTION(swf_removeobject){ zval **depth; if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &depth) == FAILURE) { WRONG_PARAM_COUNT; } convert_to_long_ex(depth); swf_removeobject(Z_LVAL_PP(depth));}/* }}} *//* {{{ proto int swf_nextid(void) Returns a free objid */PHP_FUNCTION(swf_nextid){ RETURN_LONG(swf_nextid());}/* }}} *//* {{{ proto void swf_startdoaction(void) Starts the description of an action list for the current frame */PHP_FUNCTION(swf_startdoaction){ swf_startdoaction();}/* }}} */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -