📄 ming-streams.c
字号:
/* +----------------------------------------------------------------------+ | 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 | +----------------------------------------------------------------------+*/#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_MING#if 0/* +----------------------------------------------------------------------+ | 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-streams.c,v 1.2 2004/01/18 06:46:48 vapour Exp $ */#ifndef _PHP_MING_H#define _PHP_MING_H#if HAVE_MINGextern zend_module_entry ming_module_entry;#define ming_module_ptr &ming_module_entry#include <ming.h>PHP_RINIT_FUNCTION(ming);PHP_MINIT_FUNCTION(ming);PHP_MINFO_FUNCTION(ming);PHP_FUNCTION(swfbitmap_init);PHP_FUNCTION(swfbitmap_getWidth);PHP_FUNCTION(swfbitmap_getHeight);PHP_FUNCTION(swffill_init);PHP_FUNCTION(swffill_moveTo);PHP_FUNCTION(swffill_scaleTo);PHP_FUNCTION(swffill_rotateTo);PHP_FUNCTION(swffill_skewXTo);PHP_FUNCTION(swffill_skewYTo);PHP_FUNCTION(swfgradient_init);PHP_FUNCTION(swfgradient_addEntry);PHP_FUNCTION(swfshape_init);PHP_FUNCTION(swfshape_addfill);PHP_FUNCTION(swfshape_setrightfill);PHP_FUNCTION(swfshape_setleftfill);PHP_FUNCTION(swfshape_setline);PHP_FUNCTION(swfshape_movepento);PHP_FUNCTION(swfshape_movepen);PHP_FUNCTION(swfshape_drawlineto);PHP_FUNCTION(swfshape_drawline);PHP_FUNCTION(swfshape_drawcurveto);PHP_FUNCTION(swfshape_drawcurve);PHP_FUNCTION(swfshape_drawglyph);PHP_FUNCTION(swfshape_drawarc);PHP_FUNCTION(swfshape_drawcircle);PHP_FUNCTION(swfshape_drawcubic);PHP_FUNCTION(swfshape_drawcubicto);PHP_FUNCTION(swfmovie_init);PHP_FUNCTION(swfmovie_output);PHP_FUNCTION(swfmovie_saveToFile);PHP_FUNCTION(swfmovie_save);PHP_FUNCTION(swfmovie_add);PHP_FUNCTION(swfmovie_remove);PHP_FUNCTION(swfmovie_nextFrame);PHP_FUNCTION(swfmovie_labelFrame);PHP_FUNCTION(swfmovie_setBackground);PHP_FUNCTION(swfmovie_setRate);PHP_FUNCTION(swfmovie_setDimension);PHP_FUNCTION(swfmovie_setFrames);PHP_FUNCTION(swfmovie_Protect);PHP_FUNCTION(swfmovie_streamMp3);PHP_FUNCTION(swfmovie_addExport);PHP_FUNCTION(swfmovie_writeExports);PHP_FUNCTION(swfsprite_init);PHP_FUNCTION(swfsprite_add);PHP_FUNCTION(swfsprite_remove);PHP_FUNCTION(swfsprite_nextFrame);PHP_FUNCTION(swfsprite_labelFrame);PHP_FUNCTION(swfsprite_setFrames);PHP_FUNCTION(swffont_init);PHP_FUNCTION(swffont_getWidth);PHP_FUNCTION(swffont_getUTF8Width);/*PHP_FUNCTION(swffont_getWideWidth);*/PHP_FUNCTION(swffont_getAscent);PHP_FUNCTION(swffont_getDescent);PHP_FUNCTION(swffont_getLeading);/*PHP_FUNCTION(swffont_addChars);*/PHP_FUNCTION(swffont_getShape);PHP_FUNCTION(swftext_init);PHP_FUNCTION(swftext_setFont);PHP_FUNCTION(swftext_setHeight);PHP_FUNCTION(swftext_setSpacing);PHP_FUNCTION(swftext_setColor);PHP_FUNCTION(swftext_moveTo);PHP_FUNCTION(swftext_addString);PHP_FUNCTION(swftext_addUTF8String);/*PHP_FUNCTION(swftext_addWideString);*/PHP_FUNCTION(swftext_getWidth);PHP_FUNCTION(swftext_getUTF8Width);/*PHP_FUNCTION(swftext_getWideWidth);*/PHP_FUNCTION(swftext_getAscent);PHP_FUNCTION(swftext_getDescent);PHP_FUNCTION(swftext_getLeading);PHP_FUNCTION(swftextfield_init);PHP_FUNCTION(swftextfield_setFont);PHP_FUNCTION(swftextfield_setBounds);PHP_FUNCTION(swftextfield_align);PHP_FUNCTION(swftextfield_setHeight);PHP_FUNCTION(swftextfield_setLeftMargin);PHP_FUNCTION(swftextfield_setRightMargin);PHP_FUNCTION(swftextfield_setMargins);PHP_FUNCTION(swftextfield_setIndentation);PHP_FUNCTION(swftextfield_setLineSpacing);PHP_FUNCTION(swftextfield_setColor);PHP_FUNCTION(swftextfield_setName);PHP_FUNCTION(swftextfield_addString);PHP_FUNCTION(swftextfield_setPadding);PHP_FUNCTION(swftextfield_addChars);PHP_FUNCTION(swfdisplayitem_move);PHP_FUNCTION(swfdisplayitem_moveTo);PHP_FUNCTION(swfdisplayitem_scale);PHP_FUNCTION(swfdisplayitem_scaleTo);PHP_FUNCTION(swfdisplayitem_rotate);PHP_FUNCTION(swfdisplayitem_rotateTo);PHP_FUNCTION(swfdisplayitem_skewX);PHP_FUNCTION(swfdisplayitem_skewXTo);PHP_FUNCTION(swfdisplayitem_skewY);PHP_FUNCTION(swfdisplayitem_skewYTo);PHP_FUNCTION(swfdisplayitem_setMatrix);PHP_FUNCTION(swfdisplayitem_setDepth);PHP_FUNCTION(swfdisplayitem_setRatio);PHP_FUNCTION(swfdisplayitem_addColor);PHP_FUNCTION(swfdisplayitem_multColor);PHP_FUNCTION(swfdisplayitem_setName);PHP_FUNCTION(swfdisplayitem_addAction);PHP_FUNCTION(swfdisplayitem_remove);PHP_FUNCTION(swfdisplayitem_setMaskLevel);PHP_FUNCTION(swfdisplayitem_endMask);PHP_FUNCTION(swfbutton_init);PHP_FUNCTION(swfbutton_setHit);PHP_FUNCTION(swfbutton_setOver);PHP_FUNCTION(swfbutton_setUp);PHP_FUNCTION(swfbutton_setDown);PHP_FUNCTION(swfbutton_setAction);PHP_FUNCTION(swfbutton_addShape);PHP_FUNCTION(swfbutton_addAction);PHP_FUNCTION(swfbutton_addSound);PHP_FUNCTION(swfbutton_keypress);PHP_FUNCTION(swfaction_init);PHP_FUNCTION(swfmorph_init);PHP_FUNCTION(swfmorph_getShape1);PHP_FUNCTION(swfmorph_getShape2);PHP_FUNCTION(ming_setCubicThreshold);PHP_FUNCTION(ming_setScale);PHP_FUNCTION(ming_useSWFVersion);PHP_FUNCTION(ming_useConstants);#else#define ming_module_ptr NULL#endif /* HAVE_MING */#define phpext_ming_ptr ming_module_ptr#endif /* _PHP_MING_H */#endifstatic 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) PHP_FALIAS(ming_useconstants, ming_useConstants, 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));}/* }}} *//* {{{ proto void ming_useconstants(int use) Use constant pool (?) */ PHP_FUNCTION(ming_useConstants){ zval **num; if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &num) == FAILURE) WRONG_PARAM_COUNT; convert_to_long_ex(num); Ming_useConstants(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 */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;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -