summaryrefslogtreecommitdiff
path: root/ext/swf
diff options
context:
space:
mode:
authorSterling Hughes <sterling@php.net>2000-04-30 19:00:05 +0000
committerSterling Hughes <sterling@php.net>2000-04-30 19:00:05 +0000
commit1f64d98753c407afdd788ba123ff077e81a342d3 (patch)
treef6063c9abef96c8987bb4c1fbd90cc49b0877462 /ext/swf
parenta3c17cf766951e15ad777e1c3c845ff3084c71d8 (diff)
downloadphp-git-1f64d98753c407afdd788ba123ff077e81a342d3.tar.gz
Add LibSWF support to PHP, will be sending an e-mail on the files and
uses shortly.
Diffstat (limited to 'ext/swf')
-rw-r--r--ext/swf/Makefile.in5
-rw-r--r--ext/swf/config.m426
-rw-r--r--ext/swf/php_swf.h105
-rw-r--r--ext/swf/swf.c882
-rw-r--r--ext/swf/swf.h190
5 files changed, 1208 insertions, 0 deletions
diff --git a/ext/swf/Makefile.in b/ext/swf/Makefile.in
new file mode 100644
index 0000000000..b15d1f6942
--- /dev/null
+++ b/ext/swf/Makefile.in
@@ -0,0 +1,5 @@
+
+LTLIBRARY_NAME = libswf.la
+LTLIBRARY_SOURCES = swf.c
+
+include $(top_srcdir)/build/ltlib.mk
diff --git a/ext/swf/config.m4 b/ext/swf/config.m4
new file mode 100644
index 0000000000..cd728e6b24
--- /dev/null
+++ b/ext/swf/config.m4
@@ -0,0 +1,26 @@
+dnl $Id$
+dnl config.m4 for extension libswf
+dnl don't forget to call PHP_EXTENSION(swf)
+dnl This file is a modified version of config.m4
+dnl in php4/ext/mcrypt
+
+PHP_ARG_WITH(swf, for libswf support,
+[ --with-swf[=DIR] Include swf support])
+
+if test "$PHP_SWF" != "no"; then
+ for i in /usr/local /usr $PHP_SWF; do
+ if test -f $i/libswf.a; then
+ SWF_DIR=$i
+ fi
+ done
+
+ if test -z "$SWF_DIR"; then
+ AC_MSG_ERROR(Please reinstall libswf.a - I cannot find libswf.a)
+ fi
+ AC_ADD_INCLUDE($SWF_DIR)
+ AC_ADD_LIBRARY_WITH_PATH(swf, $SWF_DIR)
+
+ AC_DEFINE(HAVE_SWF,1,[ ])
+
+ PHP_EXTENSION(swf)
+fi
diff --git a/ext/swf/php_swf.h b/ext/swf/php_swf.h
new file mode 100644
index 0000000000..723e63896d
--- /dev/null
+++ b/ext/swf/php_swf.h
@@ -0,0 +1,105 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP version 4.0 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997, 1998, 1999, 2000 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: Sterling Hughes <sterling@php.net> |
+ +----------------------------------------------------------------------+
+*/
+
+/* $Id$ */
+
+#ifndef _PHP_SWF_H
+#define _PHP_SWF_H
+
+
+#if HAVE_SWF
+
+extern zend_module_entry swf_module_entry;
+#define swf_module_ptr &swf_module_entry
+
+PHP_MINIT_FUNCTION(swf);
+PHP_MINFO_FUNCTION(swf);
+extern void php_swf_define(INTERNAL_FUNCTION_PARAMETERS, int opt);
+extern void php_swf_fill_bitmap(INTERNAL_FUNCTION_PARAMETERS, int opt);
+extern void php_swf_geo_same(INTERNAL_FUNCTION_PARAMETERS, int opt);
+PHP_FUNCTION(swf_openfile);
+PHP_FUNCTION(swf_closefile);
+PHP_FUNCTION(swf_labelframe);
+PHP_FUNCTION(swf_showframe);
+PHP_FUNCTION(swf_setframe);
+PHP_FUNCTION(swf_getframe);
+PHP_FUNCTION(swf_mulcolor);
+PHP_FUNCTION(swf_addcolor);
+PHP_FUNCTION(swf_placeobject);
+PHP_FUNCTION(swf_modifyobject);
+PHP_FUNCTION(swf_removeobject);
+PHP_FUNCTION(swf_nextid);
+PHP_FUNCTION(swf_startdoaction);
+PHP_FUNCTION(swf_enddoaction);
+PHP_FUNCTION(swf_actiongotoframe);
+PHP_FUNCTION(swf_actiongeturl);
+PHP_FUNCTION(swf_actionnextframe);
+PHP_FUNCTION(swf_actionprevframe);
+PHP_FUNCTION(swf_actionplay);
+PHP_FUNCTION(swf_actionstop);
+PHP_FUNCTION(swf_actiontogglequality);
+PHP_FUNCTION(swf_actionwaitforframe);
+PHP_FUNCTION(swf_actionsettarget);
+PHP_FUNCTION(swf_actiongotolabel);
+PHP_FUNCTION(swf_defineline);
+PHP_FUNCTION(swf_definerect);
+PHP_FUNCTION(swf_startshape);
+PHP_FUNCTION(swf_shapelinesolid);
+PHP_FUNCTION(swf_shapefilloff);
+PHP_FUNCTION(swf_shapefillsolid);
+PHP_FUNCTION(swf_shapefillbitmapclip);
+PHP_FUNCTION(swf_shapefillbitmaptile);
+PHP_FUNCTION(swf_shapemoveto);
+PHP_FUNCTION(swf_shapelineto);
+PHP_FUNCTION(swf_shapecurveto);
+PHP_FUNCTION(swf_shapecurveto3);
+PHP_FUNCTION(swf_shapearc);
+PHP_FUNCTION(swf_endshape);
+PHP_FUNCTION(swf_definefont);
+PHP_FUNCTION(swf_setfont);
+PHP_FUNCTION(swf_fontsize);
+PHP_FUNCTION(swf_fontslant);
+PHP_FUNCTION(swf_fonttracking);
+PHP_FUNCTION(swf_getfontinfo);
+PHP_FUNCTION(swf_definetext);
+PHP_FUNCTION(swf_textwidth);
+PHP_FUNCTION(swf_definebitmap);
+PHP_FUNCTION(swf_getbitmapinfo);
+PHP_FUNCTION(swf_startsymbol);
+PHP_FUNCTION(swf_endsymbol);
+PHP_FUNCTION(swf_startbutton);
+PHP_FUNCTION(swf_addbuttonrecord);
+PHP_FUNCTION(swf_oncondition);
+PHP_FUNCTION(swf_endbutton);
+PHP_FUNCTION(swf_viewport);
+PHP_FUNCTION(swf_ortho2);
+PHP_FUNCTION(swf_perspective);
+PHP_FUNCTION(swf_polarview);
+PHP_FUNCTION(swf_lookat);
+PHP_FUNCTION(swf_pushmatrix);
+PHP_FUNCTION(swf_popmatrix);
+PHP_FUNCTION(swf_scale);
+PHP_FUNCTION(swf_translate);
+PHP_FUNCTION(swf_rotate);
+PHP_FUNCTION(swf_posround);
+
+#else
+#define swf_module_ptr NULL
+#endif /* HAVE_FLASH */
+#define phpext_swf_ptr swf_module_ptr
+#endif /* _PHP_FLASH_H */
diff --git a/ext/swf/swf.c b/ext/swf/swf.c
new file mode 100644
index 0000000000..3d92ef68a1
--- /dev/null
+++ b/ext/swf/swf.c
@@ -0,0 +1,882 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP version 4.0 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997, 1998, 1999, 2000 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: Sterling Hughes <sterling@php.net> |
+ +----------------------------------------------------------------------+
+*/
+
+/* $Id$ */
+
+
+#include "php.h"
+
+#if HAVE_SWF
+#include "swf.h"
+#include "ext/standard/info.h"
+#include "php_swf.h"
+
+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_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_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}
+};
+
+zend_module_entry swf_module_entry = {
+ "swf",
+ swf_functions,
+ PHP_MINIT(swf),
+ NULL,
+ NULL,
+ NULL,
+ PHP_MINFO(swf),
+ STANDARD_MODULE_PROPERTIES
+};
+
+#if COMPILE_DL
+DLEXPORT zend_module_entry *get_module() { return &swf_module_entry; };
+#endif
+
+PHP_MINFO_FUNCTION(swf)
+{
+ php_info_print_table_start();
+ php_info_print_table_row(2, "swf support", "enabled");
+ php_info_print_table_end();
+}
+
+
+PHP_MINIT_FUNCTION(swf)
+{
+ 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_FUNCTION(swf_openfile)
+{
+ zval **name, **sizeX, **sizeY, **frameRate, **r, **g, **b;
+ if (ARG_COUNT(ht) != 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);
+
+ swf_openfile((*name)->value.str.val, (float)(*sizeX)->value.dval, (float)(*sizeY)->value.dval,
+ (float)(*frameRate)->value.dval, (float)(*r)->value.dval, (float)(*g)->value.dval, (float)(*b)->value.dval);
+}
+
+PHP_FUNCTION(swf_closefile)
+{
+ swf_closefile();
+}
+
+PHP_FUNCTION(swf_labelframe)
+{
+ zval **name;
+ if (ARG_COUNT(ht) != 1 ||
+ zend_get_parameters_ex(1, &name) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ convert_to_string_ex(name);
+ swf_labelframe((*name)->value.str.val);
+}
+
+PHP_FUNCTION(swf_showframe)
+{
+ swf_showframe();
+}
+
+PHP_FUNCTION(swf_setframe)
+{
+ zval **frameno;
+ if (ARG_COUNT(ht) != 1 ||
+ zend_get_parameters_ex(1, &frameno) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ convert_to_long_ex(frameno);
+
+ swf_setframe((*frameno)->value.lval);
+}
+
+PHP_FUNCTION(swf_getframe)
+{
+ RETURN_LONG(swf_getframe());
+}
+
+void col_swf(INTERNAL_FUNCTION_PARAMETERS, int opt) {
+ zval **r, **g, **b, **a;
+ if (ARG_COUNT(ht) != 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)(*r)->value.dval, (float)(*g)->value.dval, (float)(*b)->value.dval, (float)(*a)->value.dval);
+ } else {
+ swf_mulcolor((float)(*r)->value.dval, (float)(*g)->value.dval, (float)(*b)->value.dval, (float)(*a)->value.dval);
+ }
+}
+
+PHP_FUNCTION(swf_mulcolor)
+{
+ col_swf(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
+}
+
+PHP_FUNCTION(swf_addcolor)
+{
+ col_swf(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
+}
+
+PHP_FUNCTION(swf_placeobject)
+{
+ zval **objid, **depth;
+ if (ARG_COUNT(ht) != 2 ||
+ zend_get_parameters_ex(2, &objid, &depth) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ convert_to_long_ex(objid);
+ convert_to_long_ex(depth);
+ swf_placeobject((*objid)->value.lval, (*depth)->value.lval);
+}
+
+PHP_FUNCTION(swf_modifyobject)
+{
+ zval **depth, **how;
+ if (ARG_COUNT(ht) != 2 ||
+ zend_get_parameters_ex(2, &depth, &how) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ convert_to_long_ex(depth);
+ convert_to_long_ex(how);
+
+ swf_modifyobject((*depth)->value.lval, (*how)->value.lval);
+}
+
+PHP_FUNCTION(swf_removeobject)
+{
+ zval **depth;
+ if (ARG_COUNT(ht) != 1 ||
+ zend_get_parameters_ex(1, &depth) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ convert_to_long_ex(depth);
+
+ swf_removeobject((*depth)->value.lval);
+}
+
+PHP_FUNCTION(swf_nextid)
+{
+ swf_nextid();
+}
+
+PHP_FUNCTION(swf_startdoaction)
+{
+ swf_startdoaction();
+}
+
+PHP_FUNCTION(swf_enddoaction)
+{
+ swf_enddoaction();
+}
+
+PHP_FUNCTION(swf_actiongotoframe)
+{
+ zval **frameno;
+ if (ARG_COUNT(ht) != 1 ||
+ zend_get_parameters_ex(1, &frameno) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ convert_to_long_ex(frameno);
+
+ swf_actionGotoFrame((*frameno)->value.lval);
+}
+
+PHP_FUNCTION(swf_actiongeturl)
+{
+ zval **url, **target;
+ if (ARG_COUNT(ht) != 2 ||
+ zend_get_parameters_ex(2, &url, &target) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ convert_to_string_ex(url);
+ convert_to_string_ex(target);
+
+ swf_actionGetURL((*url)->value.str.val, (*target)->value.str.val);
+}
+
+PHP_FUNCTION(swf_actionnextframe)
+{
+ swf_actionNextFrame();
+}
+
+PHP_FUNCTION(swf_actionprevframe)
+{
+ swf_actionPrevFrame();
+}
+
+PHP_FUNCTION(swf_actionplay)
+{
+ swf_actionPlay();
+}
+
+PHP_FUNCTION(swf_actionstop)
+{
+ swf_actionStop();
+}
+
+PHP_FUNCTION(swf_actiontogglequality)
+{
+ swf_actionToggleQuality();
+}
+
+PHP_FUNCTION(swf_actionwaitforframe)
+{
+ zval **frame, **skipcount;
+ if (ARG_COUNT(ht) != 2 ||
+ zend_get_parameters_ex(2, &frame, &skipcount) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+
+ convert_to_long_ex(frame);
+ convert_to_long_ex(skipcount);
+ swf_actionWaitForFrame((*frame)->value.lval, (*skipcount)->value.lval);
+}
+
+PHP_FUNCTION(swf_actionsettarget)
+{
+ zval **target;
+ if (ARG_COUNT(ht) != 1 ||
+ zend_get_parameters_ex(1, &target) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+
+ convert_to_string_ex(target);
+ swf_actionSetTarget((*target)->value.str.val);
+}
+
+PHP_FUNCTION(swf_actiongotolabel)
+{
+ zval **label;
+ if (ARG_COUNT(ht) != 1 ||
+ zend_get_parameters_ex(1, &label) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+
+ convert_to_string_ex(label);
+ swf_actionGoToLabel((*label)->value.str.val);
+}
+
+void php_swf_define(INTERNAL_FUNCTION_PARAMETERS, int opt)
+{
+ zval **objid, **x1, **y1, **x2, **y2, **width;
+ if (ARG_COUNT(ht) != 6 ||
+ zend_get_parameters_ex(6, &objid, &x1, &y1, &x2, &y2, &width) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+
+ convert_to_long_ex(objid);
+ convert_to_double_ex(x1);
+ convert_to_double_ex(y1);
+ convert_to_double_ex(x2);
+ convert_to_double_ex(y2);
+ convert_to_double_ex(width);
+
+ if (opt) {
+ swf_defineline((*objid)->value.lval, (float)(*x1)->value.dval, (float)(*y1)->value.dval,
+ (float)(*x2)->value.dval, (float)(*y2)->value.dval, (float)(*width)->value.dval);
+ } else {
+ swf_definerect((*objid)->value.lval, (float)(*x1)->value.dval, (float)(*y1)->value.dval,
+ (float)(*x2)->value.dval, (float)(*y2)->value.dval, (float)(*width)->value.dval);
+ }
+}
+
+PHP_FUNCTION(swf_defineline)
+{
+ php_swf_define(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
+}
+
+PHP_FUNCTION(swf_definerect)
+{
+ php_swf_define(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
+}
+
+
+PHP_FUNCTION(swf_startshape)
+{
+ zval **objid;
+ if (ARG_COUNT(ht) != 1 ||
+ zend_get_parameters_ex(1, &objid) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ convert_to_long_ex(objid);
+ swf_startshape((*objid)->value.lval);
+}
+
+PHP_FUNCTION(swf_shapelinesolid)
+{
+ zval **r, **g, **b, **a, **width;
+ if (ARG_COUNT(ht) != 5 ||
+ zend_get_parameters_ex(5, &r, &g, &b, &a, &width) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ convert_to_double_ex(r);
+ convert_to_double_ex(g);
+ convert_to_double_ex(b);
+ convert_to_double_ex(a);
+ convert_to_double_ex(width);
+ swf_shapelinesolid((float)(*r)->value.dval, (float)(*g)->value.dval, (float)(*b)->value.dval, (float)(*a)->value.dval,
+ (float)(*width)->value.dval);
+}
+
+PHP_FUNCTION(swf_shapefilloff)
+{
+ swf_shapefilloff();
+}
+
+PHP_FUNCTION(swf_shapefillsolid)
+{
+ zval **r, **g, **b, **a;
+ if (ARG_COUNT(ht) != 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);
+
+ swf_shapefillsolid((float)(*r)->value.dval, (float)(*g)->value.dval, (float)(*b)->value.dval, (float)(*a)->value.dval);
+}
+
+void php_swf_fill_bitmap(INTERNAL_FUNCTION_PARAMETERS, int opt)
+{
+ zval **bitmapid;
+ if (ARG_COUNT(ht) != 1 ||
+ zend_get_parameters_ex(1, &bitmapid) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ convert_to_long_ex(bitmapid);
+
+ if (opt) {
+ swf_shapefillbitmapclip((*bitmapid)->value.lval);
+ } else {
+ swf_shapefillbitmaptile((*bitmapid)->value.lval);
+ }
+}
+
+
+PHP_FUNCTION(swf_shapefillbitmapclip)
+{
+ php_swf_fill_bitmap(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
+}
+
+PHP_FUNCTION(swf_shapefillbitmaptile)
+{
+ php_swf_fill_bitmap(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
+}
+
+void php_swf_shape(INTERNAL_FUNCTION_PARAMETERS, int opt)
+{
+ zval **x, **y;
+ if (ARG_COUNT(ht) != 2 ||
+ zend_get_parameters_ex(2, &x, &y) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ convert_to_double_ex(x);
+ convert_to_double_ex(y);
+
+ if (opt) {
+ swf_shapemoveto((float)(*x)->value.dval, (float)(*y)->value.dval);
+ } else {
+ swf_shapelineto((float)(*x)->value.dval, (float)(*y)->value.dval);
+ }
+}
+
+PHP_FUNCTION(swf_shapemoveto)
+{
+ php_swf_shape(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
+}
+
+PHP_FUNCTION(swf_shapelineto)
+{
+ php_swf_shape(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
+}
+
+PHP_FUNCTION(swf_shapecurveto)
+{
+ zval **x1, **y1, **x2, **y2;
+ if (ARG_COUNT(ht) != 4 ||
+ zend_get_parameters_ex(4, &x1, &y1, &x2, &y2) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ convert_to_double_ex(x1);
+ convert_to_double_ex(y1);
+ convert_to_double_ex(x2);
+ convert_to_double_ex(y2);
+
+ swf_shapecurveto((float)(*x1)->value.dval, (float)(*y1)->value.dval, (float)(*x2)->value.dval, (float)(*y2)->value.dval);
+}
+
+
+PHP_FUNCTION(swf_shapecurveto3)
+{
+ zval **x1, **y1, **x2, **y2, **x3, **y3;
+ if (ARG_COUNT(ht) != 6 ||
+ zend_get_parameters_ex(6, &x1, &y1, &x2, &y2, &x3, &y3) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ convert_to_double_ex(x1);
+ convert_to_double_ex(y1);
+ convert_to_double_ex(x2);
+ convert_to_double_ex(y2);
+ convert_to_double_ex(x3);
+ convert_to_double_ex(y3);
+
+ swf_shapecurveto3((float)(*x1)->value.dval, (float)(*y1)->value.dval, (float)(*x2)->value.dval, (float)(*y2)->value.dval,
+ (float)(*x3)->value.dval, (float)(*y3)->value.dval);
+}
+
+PHP_FUNCTION(swf_shapearc)
+{
+ zval **x, **y, **r, **ang1, **ang2;
+ if (ARG_COUNT(ht) != 5 ||
+ zend_get_parameters_ex(5, &x, &y, &r, &ang1, &ang2) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ convert_to_double_ex(x);
+ convert_to_double_ex(y);
+ convert_to_double_ex(r);
+ convert_to_double_ex(ang1);
+ convert_to_double_ex(ang2);
+
+ swf_shapearc((float)(*x)->value.dval, (float)(*y)->value.dval, (float)(*r)->value.dval, (float)(*ang1)->value.dval,
+ (float)(*ang2)->value.dval);
+}
+
+PHP_FUNCTION(swf_endshape)
+{
+ swf_endshape();
+}
+
+PHP_FUNCTION(swf_definefont)
+{
+ zval **fontid, **name;
+ if (ARG_COUNT(ht) != 2 ||
+ zend_get_parameters_ex(2, &fontid, &name) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ convert_to_long_ex(fontid);
+ convert_to_string_ex(name);
+
+ swf_definefont((*fontid)->value.lval, (*name)->value.str.val);
+}
+
+PHP_FUNCTION(swf_setfont)
+{
+ zval **fontid;
+ if (ARG_COUNT(ht) != 1 ||
+ zend_get_parameters_ex(1, &fontid) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ convert_to_long_ex(fontid);
+ swf_setfont((*fontid)->value.lval);
+}
+
+PHP_FUNCTION(swf_fontsize)
+{
+ zval **height;
+ if (ARG_COUNT(ht) != 1 ||
+ zend_get_parameters_ex(1, &height) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ convert_to_double_ex(height);
+
+ swf_fontsize((float)(*height)->value.dval);
+}
+
+PHP_FUNCTION(swf_fontslant)
+{
+ zval **slant;
+ if (ARG_COUNT(ht) != 1 ||
+ zend_get_parameters_ex(1, &slant) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ convert_to_double_ex(slant);
+
+ swf_fontslant((float)(*slant)->value.dval);
+}
+
+PHP_FUNCTION(swf_fonttracking)
+{
+ zval **track;
+ if (ARG_COUNT(ht) != 1 ||
+ zend_get_parameters_ex(1, &track) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ convert_to_double_ex(track);
+ swf_fonttracking((float)(*track)->value.dval);
+}
+
+PHP_FUNCTION(swf_getfontinfo)
+{
+ float A_height, x_height;
+ swf_getfontinfo(&A_height, &x_height);
+ if (array_init(return_value) == FAILURE) {
+ php_error(E_WARNING, "Cannot initialize return value from swf_getfontinfo");
+ RETURN_FALSE;
+ }
+ add_assoc_double(return_value, "Aheight", A_height);
+ add_assoc_double(return_value, "xheight", x_height);
+}
+
+PHP_FUNCTION(swf_definetext)
+{
+ zval **objid, **str, **docCenter;
+ if (ARG_COUNT(ht) != 3 ||
+ zend_get_parameters_ex(3, &objid, &str, &docCenter) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ convert_to_long_ex(objid);
+ convert_to_string_ex(str);
+ convert_to_long_ex(docCenter);
+
+ swf_definetext((*objid)->value.lval, (*str)->value.str.val, (*docCenter)->value.lval);
+}
+
+PHP_FUNCTION(swf_textwidth)
+{
+ zval **str;
+ if (ARG_COUNT(ht) != 1 ||
+ zend_get_parameters_ex(1, &str) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ convert_to_string_ex(str);
+ RETURN_DOUBLE((double)swf_textwidth((*str)->value.str.val));
+}
+
+PHP_FUNCTION(swf_definebitmap)
+{
+ zval **objid, **imgname;
+ if (ARG_COUNT(ht) != 2 ||
+ zend_get_parameters_ex(2, &objid, &imgname) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ convert_to_long_ex(objid);
+ convert_to_string_ex(imgname);
+
+ swf_definebitmap((*objid)->value.lval, (*imgname)->value.str.val);
+}
+
+PHP_FUNCTION(swf_getbitmapinfo)
+{
+ zval **bitmapid;
+ int size, width, height;
+
+ if (ARG_COUNT(ht) != 1 ||
+ zend_get_parameters_ex(1, &bitmapid) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ convert_to_long_ex(bitmapid);
+
+ size = swf_getbitmapinfo((*bitmapid)->value.lval, &width, &height);
+ if (array_init(return_value) == FAILURE) {
+ php_error(E_WARNING, "Cannot initialize return value from swf_getbitmapinfo");
+ RETURN_FALSE;
+ }
+
+ add_assoc_long(return_value, "size", size);
+ add_assoc_long(return_value, "width", width);
+ add_assoc_long(return_value, "height", height);
+}
+
+PHP_FUNCTION(swf_startsymbol)
+{
+ zval **objid;
+ if (ARG_COUNT(ht) != 1 ||
+ zend_get_parameters_ex(1, &objid) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ convert_to_long_ex(objid);
+
+ swf_startsymbol((*objid)->value.lval);
+}
+
+PHP_FUNCTION(swf_endsymbol)
+{
+ swf_endsymbol();
+}
+
+PHP_FUNCTION(swf_startbutton)
+{
+ zval **objid, **type;
+ if (ARG_COUNT(ht) != 2 ||
+ zend_get_parameters_ex(2, &objid, &type) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ convert_to_long_ex(objid);
+ convert_to_long_ex(type);
+
+ swf_startbutton((*objid)->value.lval, (*type)->value.lval); /* TYPE_MENUBUTTON, TYPE_PUSHBUTTON */
+}
+
+PHP_FUNCTION(swf_addbuttonrecord)
+{
+ zval **state, **objid, **depth;
+ if (ARG_COUNT(ht) != 3 ||
+ zend_get_parameters_ex(3, &state, &objid, &depth) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ convert_to_long_ex(state);
+ convert_to_long_ex(objid);
+ convert_to_long_ex(depth);
+
+ swf_addbuttonrecord((*state)->value.lval, (*objid)->value.lval, (*depth)->value.lval);
+}
+
+PHP_FUNCTION(swf_oncondition)
+{
+ zval **transitions;
+ if (ARG_COUNT(ht) != 1 ||
+ zend_get_parameters_ex(1, &transitions) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ convert_to_long_ex(transitions);
+
+ swf_oncondition((*transitions)->value.lval);
+}
+
+PHP_FUNCTION(swf_endbutton)
+{
+ swf_endbutton();
+}
+
+void php_swf_geo_same(INTERNAL_FUNCTION_PARAMETERS, int opt)
+{
+ zval **arg1, **arg2, **arg3, **arg4;
+ if (ARG_COUNT(ht) != 4 ||
+ zend_get_parameters_ex(4, &arg1, &arg2, &arg3, &arg4) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ convert_to_double_ex(arg1);
+ convert_to_double_ex(arg2);
+ convert_to_double_ex(arg3);
+ convert_to_double_ex(arg4);
+
+ if (opt == 0) {
+ swf_viewport((*arg1)->value.dval, (*arg2)->value.dval, (*arg3)->value.dval,
+ (*arg4)->value.dval);
+ } else if (opt == 1) {
+ swf_ortho2((*arg1)->value.dval, (*arg2)->value.dval, (*arg3)->value.dval,
+ (*arg4)->value.dval);
+ } else if (opt == 2) {
+ swf_polarview((*arg1)->value.dval, (*arg2)->value.dval, (*arg3)->value.dval,
+ (*arg4)->value.dval);
+ } else if (opt == 3) {
+ swf_perspective((*arg1)->value.dval, (*arg2)->value.dval, (*arg3)->value.dval,
+ (*arg4)->value.dval);
+ }
+}
+
+PHP_FUNCTION(swf_viewport)
+{
+ php_swf_geo_same(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
+}
+
+PHP_FUNCTION(swf_ortho2)
+{
+ php_swf_geo_same(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
+}
+
+PHP_FUNCTION(swf_polarview)
+{
+ php_swf_geo_same(INTERNAL_FUNCTION_PARAM_PASSTHRU, 2);
+}
+
+PHP_FUNCTION(swf_perspective)
+{
+ php_swf_geo_same(INTERNAL_FUNCTION_PARAM_PASSTHRU, 3);
+}
+
+PHP_FUNCTION(swf_lookat)
+{
+ zval **vx, **vy, **vz, **px, **py, **pz, **twist;
+ if (ARG_COUNT(ht) != 7 ||
+ zend_get_parameters_ex(7, &vx, &vy, &vz, &px, &py, &pz, &twist) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ convert_to_double_ex(vx);
+ convert_to_double_ex(vy);
+ convert_to_double_ex(vz);
+ convert_to_double_ex(px);
+ convert_to_double_ex(py);
+ convert_to_double_ex(pz);
+ convert_to_double_ex(twist);
+
+ swf_lookat((*vx)->value.dval, (*vy)->value.dval, (*vz)->value.dval,
+ (*px)->value.dval, (*py)->value.dval, (*pz)->value.dval, (*twist)->value.dval);
+}
+
+PHP_FUNCTION(swf_pushmatrix)
+{
+ swf_pushmatrix();
+}
+
+PHP_FUNCTION(swf_popmatrix)
+{
+ swf_popmatrix();
+}
+
+PHP_FUNCTION(swf_scale)
+{
+ zval **x, **y, **z;
+ if (ARG_COUNT(ht) != 3 ||
+ zend_get_parameters_ex(3, &x, &y, &z) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ convert_to_double_ex(x);
+ convert_to_double_ex(y);
+ convert_to_double_ex(z);
+
+ swf_scale((*x)->value.dval, (*y)->value.dval, (*z)->value.dval);
+}
+
+PHP_FUNCTION(swf_translate)
+{
+ zval **x, **y, **z;
+ if (ARG_COUNT(ht) != 3 ||
+ zend_get_parameters_ex(3, &x, &y, &z) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ convert_to_double_ex(x);
+ convert_to_double_ex(y);
+ convert_to_double_ex(z);
+
+ swf_translate((*x)->value.dval, (*y)->value.dval, (*z)->value.dval);
+}
+
+PHP_FUNCTION(swf_rotate)
+{
+ zval **angle, **axis;
+ if (ARG_COUNT(ht) != 2 ||
+ zend_get_parameters_ex(2, &angle, &axis) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ convert_to_double_ex(angle);
+ convert_to_string_ex(axis);
+
+ swf_rotate((*angle)->value.dval, (*axis)->value.str.val);
+}
+
+PHP_FUNCTION(swf_posround)
+{
+ zval **doit;
+ if (ARG_COUNT(ht) != 1 ||
+ zend_get_parameters_ex(1, &doit) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ convert_to_long_ex(doit);
+
+ swf_posround((*doit)->value.lval);
+}
+
+#endif
diff --git a/ext/swf/swf.h b/ext/swf/swf.h
new file mode 100644
index 0000000000..2d92c9c0d9
--- /dev/null
+++ b/ext/swf/swf.h
@@ -0,0 +1,190 @@
+/*
+ * libswf.a Version 0.99
+ */
+#ifndef SWFDEF
+#define SWFDEF
+
+#include <unistd.h>
+#include <stdio.h>
+#include <math.h>
+
+typedef struct httprequest {
+ int content_length;
+ char *auth_type;
+ char *gateway_interface;
+ char *http_accept;
+ char *http_accept_charset;
+ char *http_accept_language;
+ char *http_connection;
+ char *http_host;
+ char *http_pragma;
+ char *http_referer;
+ char *http_user_agent;
+ char *path;
+ char *query_string;
+ char *remote_addr;
+ char *remote_host;
+ char *remote_user;
+ char *request_method;
+ char *request_uri;
+ char *script_filename;
+ char *script_name;
+ char *server_name;
+ char *server_port;
+ char *server_protocol;
+ char *server_software;
+ char *tz;
+ char *vserver_name;
+} httprequest;
+
+/* button types */
+
+#define TYPE_PUSHBUTTON (0)
+#define TYPE_MENUBUTTON (1)
+
+/* button shape states */
+
+#define BSHitTest (0x8)
+#define BSDown (0x4)
+#define BSOver (0x2)
+#define BSUp (0x1)
+
+/* button transitions */
+
+#define OverDowntoIdle (256)
+#define IdletoOverDown (128)
+#define OutDowntoIdle (64)
+#define OutDowntoOverDown (32)
+#define OverDowntoOutDown (16)
+#define OverDowntoOverUp (8)
+#define OverUptoOverDown (4)
+#define OverUptoIdle (2)
+#define IdletoOverUp (1)
+
+#define ButtonEnter (IdletoOverUp|OutDowntoOverDown)
+#define ButtonExit (OverUptoIdle|OverDowntoOutDown)
+
+#define MenuEnter (IdletoOverUp|IdletoOverDown)
+#define MenuExit (OverUptoIdle|OverDowntoIdle)
+
+/* sound sample rates */
+
+#define RATE_5500 (5500)
+#define RATE_11000 (11000)
+#define RATE_22000 (22000)
+#define RATE_44000 (44000)
+
+/* for modifyobject how */
+
+#define MOD_MATRIX (1)
+#define MOD_COLOR (2)
+
+/* client functions */
+
+void swf_openfile(char *name, float xsize, float ysize,
+ float framerate, float r, float g, float b);
+void swf_closefile(void);
+void swf_labelframe(char *name);
+void swf_setframe(int n);
+int swf_getframe(void);
+void swf_showframe(void);
+
+void swf_mulcolor(float r, float g, float b, float a);
+void swf_addcolor(float r, float g, float b, float a);
+void swf_removeobject(int depth);
+void swf_placeobject(int objid, int depth);
+void swf_modifyobject(int depth, int how);
+
+void swf_definepoly(int objid, float coords[][2], int npoints, float width);
+void swf_defineline(int objid, float x1, float y1, float x2, float y2, float width);
+void swf_definerect(int objid, float x1, float y1, float x2, float y2, float width);
+
+void swf_fontsize(float height);
+void swf_fontslant(float slant);
+void swf_fonttracking(float track);
+void swf_getfontinfo(float *aheight, float *xheight);
+void swf_fontlinewidth(float width);
+void swf_definefont(int fontid, char *name);
+void swf_setfont(int fontid);
+float swf_textwidth(char *s);
+void swf_definetext(int objid, char *str, int docenter);
+
+void swf_startsymbol(int objid);
+void swf_endsymbol(void);
+
+/* define buttons and actions */
+
+void swf_startbutton(int objid, int menu);
+void swf_addbuttonrecord(int state, int objid, int depth);
+void swf_oncondition(int transitions);
+void swf_actionGotoFrame(int n);
+void swf_actionGetURL(char *url, char *target);
+void swf_actionNextFrame(void);
+void swf_actionPrevFrame(void);
+void swf_actionPlay(void);
+void swf_actionStop(void);
+void swf_actionToggleQuality(void);
+void swf_actionStopSounds(void);
+void swf_actionWaitForFrame(int frame, int skipcount);
+void swf_actionSetTarget(char *target);
+void swf_actionGoToLabel(char *label);
+void swf_endbutton(void);
+
+void swf_startdoaction(void);
+void swf_enddoaction(void);
+
+
+/* bitmap primitives */
+
+void swf_definebitmap(int objid, char *imgname);
+int swf_getbitmapinfo(int bitmapid, int *xsize, int *ysize);
+
+
+/* geometry functions */
+
+void swf_viewport(double xmin, double xmax, double ymin, double ymax);
+void swf_pushmatrix(void);
+void swf_popmatrix(void);
+void swf_scale(double x, double y, double z);
+void swf_translate(double x, double y, double z);
+void swf_rotate(double angle, char *axis);
+void swf_polarview(double dist, double azimuth, double incidence, double twist);
+void swf_lookat(double vx, double vy, double vz, double px, double py, double pz, double twist);
+void swf_perspective(double fovy, double aspect, double near, double far);
+void swf_ortho(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax);
+void swf_ortho2(double xmin, double xmax, double ymin, double ymax);
+void swf_posround(int doit);
+
+/* shape support */
+
+void swf_startshape(int objid);
+void swf_shapelinesolid(float r, float g, float b, float a, float width);
+void swf_shapefilloff(void);
+void swf_shapefillsolid(float r, float g, float b, float a);
+void swf_shapefillbitmapclip(int bitmapid);
+void swf_shapefillbitmaptile(int bitmapid);
+void swf_shapemoveto(float x, float y);
+void swf_shapelineto(float x, float y);
+void swf_shapecurveto(float x1, float y1, float x2, float y2);
+void swf_shapecurveto3(float x1, float y1, float x2, float y2, float x3, float y3);
+void swf_shapearc(float x, float y, float r, float a1, float a2);
+void swf_endshape();
+
+/* sounds support */
+
+void swf_soundrate(int rate);
+void swf_soundcomp(int nbits);
+void swf_definesound(int objid, short *samples, int nsamples);
+void swf_definebuttonsound(int objid, int outid, int overid, int downid);
+int swf_soundstream(short *samples, int nsamples);
+void swf_startsound(int soundid);
+
+/* cgi support */
+
+void cgi_putmimeheader(char *str);
+void cgi_getrequest(httprequest *req);
+void cgi_getfullrequest(httprequest *req);
+
+int swf_nextid(void);
+
+#endif