diff -ruN php-5.2.5.orig/Zend/zend_language_scanner.c php-5.2.5/Zend/zend_language_scanner.c --- php-5.2.5.orig/Zend/zend_language_scanner.c 2007-11-08 08:36:37.000000000 -0700 +++ php-5.2.5/Zend/zend_language_scanner.c 2007-12-10 23:07:08.000000000 -0700 @@ -3009,7 +3009,7 @@ #define yymore() (yy_more_flag = 1) #define YY_MORE_ADJ yy_more_len #define YY_RESTORE_YY_MORE_OFFSET -char *yytext; +extern char *yytext; #define INITIAL 0 /* diff -ruN php-5.2.5.orig/build/build2.mk php-5.2.5/build/build2.mk --- php-5.2.5.orig/build/build2.mk 2007-01-01 12:32:10.000000000 -0700 +++ php-5.2.5/build/build2.mk 2007-12-10 22:04:43.000000000 -0700 @@ -52,6 +52,11 @@ aclocal.m4: configure.in acinclude.m4 @echo rebuilding $@ + @libtoolize=`./build/shtool path glibtoolize libtoolize`; \ + $$libtoolize --copy --automake --force; \ + ltpath=`dirname $$libtoolize`; \ + ltfile=`cd $$ltpath/../share/aclocal; pwd`/libtool.m4; \ + cp $$ltfile ./build/libtool.m4 cat acinclude.m4 ./build/libtool.m4 > $@ configure: aclocal.m4 configure.in $(config_m4_files) diff -ruN php-5.2.12.orig/configure php-5.2.12/configure --- php-5.2.12.orig/configure 2009-12-16 07:48:03.000000000 -0500 +++ php-5.2.12/configure 2011-04-16 13:58:17.000000000 -0400 @@ -5847,10 +5847,10 @@ ;; *darwin*) if test -x "$APR_CONFIG"; then - MH_BUNDLE_FLAGS="`$APR_CONFIG --ldflags --link-ld --libs`" + MH_BUNDLE_FLAGS="`$APR_CONFIG --ldflags --link-ld --libs | sed -e 's/-L[^ ]*//g'`" fi if test -x "$APU_CONFIG"; then - MH_BUNDLE_FLAGS="`$APU_CONFIG --ldflags --link-ld --libs` $MH_BUNDLE_FLAGS" + MH_BUNDLE_FLAGS="`$APU_CONFIG --ldflags --link-ld --libs | sed -e 's/-L[^ ]*//g'` $MH_BUNDLE_FLAGS" fi MH_BUNDLE_FLAGS="-bundle -bundle_loader $APXS_HTTPD $MH_BUNDLE_FLAGS" @@ -6695,10 +6695,10 @@ ;; *darwin*) if test -x "$APR_CONFIG"; then - MH_BUNDLE_FLAGS="`$APR_CONFIG --ldflags --link-ld --libs`" + MH_BUNDLE_FLAGS="`$APR_CONFIG --ldflags --link-ld --libs | sed -e 's/-L[^ ]*//g'`" fi if test -x "$APU_CONFIG"; then - MH_BUNDLE_FLAGS="`$APU_CONFIG --ldflags --link-ld --libs` $MH_BUNDLE_FLAGS" + MH_BUNDLE_FLAGS="`$APU_CONFIG --ldflags --link-ld --libs | sed -e 's/-L[^ ]*//g'` $MH_BUNDLE_FLAGS" fi MH_BUNDLE_FLAGS="-bundle -bundle_loader $APXS_HTTPD $MH_BUNDLE_FLAGS" @@ -21893,7 +21893,7 @@ echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" -LIBS="-lssl $LIBS" +LIBS="-L@FINKPREFIX@/lib/system-openssl/lib -lssl $LIBS" cat > conftest.$ac_ext <&6 else ac_save_LIBS="$LIBS" -LIBS="-lcrypto $LIBS" +LIBS="-L@FINKPREFIX@/lib/system-openssl/lib -lcrypto $LIBS" cat > conftest.$ac_ext <&6 else ac_save_LIBS="$LIBS" -LIBS="-lssl $LIBS" +LIBS="-L@FINKPREFIX@/lib/system-openssl/lib -lssl $LIBS" cat > conftest.$ac_ext <&6 else ac_save_LIBS="$LIBS" -LIBS="-lcrypto $LIBS" +LIBS="-L@FINKPREFIX@/lib/system-openssl/lib -lcrypto $LIBS" cat > conftest.$ac_ext <&6 else ac_save_LIBS="$LIBS" -LIBS="-lssl $LIBS" +LIBS="-L@FINKPREFIX@/lib/system-openssl/lib -lssl $LIBS" cat > conftest.$ac_ext <&6 else ac_save_LIBS="$LIBS" -LIBS="-lcrypto $LIBS" +LIBS="-L@FINKPREFIX@/lib/system-openssl/lib -lcrypto $LIBS" cat > conftest.$ac_ext <&6 else ac_save_LIBS="$LIBS" -LIBS="-lssl $LIBS" +LIBS="-L@FINKPREFIX@/lib/system-openssl/lib -lssl $LIBS" cat > conftest.$ac_ext <&6 else ac_save_LIBS="$LIBS" -LIBS="-lcrypto $LIBS" +LIBS="-L@FINKPREFIX@/lib/system-openssl/lib -lcrypto $LIBS" cat > conftest.$ac_ext <&6 else ac_save_LIBS="$LIBS" -LIBS="-lssl $LIBS" +LIBS="-L@FINKPREFIX@/lib/system-openssl/lib -lssl $LIBS" cat > conftest.$ac_ext <&2; exit 1; } + { echo "configure: warning: recode extension can not be configured together with:$recode_conflict" 1>&2; } fi fi @@ -106020,7 +106020,7 @@ if test "$PHP_PEAR" = "DEFAULT" || test "$PHP_PEAR" = "yes"; then case $PHP_LAYOUT in GNU) PEAR_INSTALLDIR=$datadir/pear;; - *) PEAR_INSTALLDIR=$libdir/php;; + *) PEAR_INSTALLDIR=$libdir/php5;; esac fi @@ -108028,12 +108028,12 @@ case $libdir in '${exec_prefix}/lib') - libdir=$libdir/php + libdir=$libdir/php5 ;; esac case $datadir in '${prefix}/share') - datadir=$datadir/php + datadir=$datadir/php5 ;; esac @@ -108097,7 +108097,7 @@ EXPANDED_DATADIR=$datadir EXPANDED_PHP_CONFIG_FILE_PATH=`eval echo "$PHP_CONFIG_FILE_PATH"` EXPANDED_PHP_CONFIG_FILE_SCAN_DIR=`eval echo "$PHP_CONFIG_FILE_SCAN_DIR"` -INCLUDE_PATH=.:$EXPANDED_PEAR_INSTALLDIR +INCLUDE_PATH=.:$EXPANDED_PEAR_INSTALLDIR:@FINKPREFIX@/share/pear exec_prefix=$old_exec_prefix libdir=$old_libdir diff -ruN php-5.2.5.orig/ext/exif/exif.c php-5.2.5/ext/exif/exif.c --- php-5.2.5.orig/ext/exif/exif.c 2007-06-10 14:12:45.000000000 -0600 +++ php-5.2.5/ext/exif/exif.c 2007-12-10 22:10:34.000000000 -0700 @@ -99,7 +99,7 @@ #define EFREE_IF(ptr) if (ptr) efree(ptr) -#define MAX_IFD_NESTING_LEVEL 100 +#define MAX_IFD_NESTING_LEVEL 250 /* {{{ arginfo */ static diff -ruN php-5.2.5.orig/ext/ext_skel php-5.2.5/ext/ext_skel --- php-5.2.5.orig/ext/ext_skel 2004-05-16 06:10:35.000000000 -0600 +++ php-5.2.5/ext/ext_skel 2007-12-10 21:40:38.000000000 -0700 @@ -70,7 +70,7 @@ fi if test -z "$skel_dir"; then - skel_dir="skeleton" + skel_dir="@FINKPREFIX@/lib/php5/skeleton" fi ## convert skel_dir to full path diff -ruN php-5.2.5.orig/ext/gd/gdcache.c php-5.2.5/ext/gd/gdcache.c --- php-5.2.5.orig/ext/gd/gdcache.c 2005-01-09 14:05:05.000000000 -0700 +++ php-5.2.5/ext/gd/gdcache.c 2007-12-10 16:38:50.000000000 -0700 @@ -52,8 +52,21 @@ /* implementation */ /*********************************************************/ - /* create a new cache */ +#ifdef __APPLE__ +extern gdCache_head_t * +gdCacheCreate( + int size, + gdCacheTestFn_t gdCacheTest, + gdCacheFetchFn_t gdCacheFetch, + gdCacheReleaseFn_t gdCacheRelease ); + +extern void +gdCacheDelete( gdCache_head_t *head ); + +extern void * +gdCacheGet( gdCache_head_t *head, void *keydata ); +#else gdCache_head_t * gdCacheCreate( int size, @@ -130,7 +143,7 @@ elem->userdata = userdata; return userdata; } - +#endif /*********************************************************/ diff -ruN php-5.2.5.orig/ext/mime_magic/mime_magic.c php-5.2.5/ext/mime_magic/mime_magic.c --- php-5.2.5.orig/ext/mime_magic/mime_magic.c 2007-06-07 02:44:41.000000000 -0600 +++ php-5.2.5/ext/mime_magic/mime_magic.c 2007-12-10 22:14:15.000000000 -0700 @@ -503,7 +503,7 @@ } while (*(++p) != '/'); ++p; do { - if (!isalnum(*p) && (*p != '-') && (*p != '.') && !isspace(*p)) { + if (!isalnum(*p) && (*p != '-') && (*p != '.') && (*p != '+') && !isspace(*p)) { return 0; } } while (*(++p)); @@ -636,6 +636,15 @@ else if (strncmp(l, "string", NSTRING) == 0) { m->type = STRING; l += NSTRING; + if (*l == '/') { + ++l; + if ((*l == 'B') || (*l == 'b') || (*l == 'c')) { + ++l; + if ((*l == 'B') || (*l == 'b') || (*l == 'c')) { + ++l; + } + } + } } else if (strncmp(l, "date", NDATE) == 0) { m->type = DATE; @@ -729,7 +738,7 @@ if (!is_valid_mimetype(l, strlen(l))) { if(MIME_MAGIC_G(debug)) php_error_docref("http://www.php.net/mime_magic" TSRMLS_CC, E_WARNING, ": (%s:%d) '%s' is not a valid mimetype, entry skipped", MIME_MAGIC_G(magicfile), lineno, l); - return -1; + return 0; } strlcpy(m->desc, l, sizeof(m->desc)); diff -ruN php-5.2.5.orig/ext/ming/ming.c php-5.2.5/ext/ming/ming.c --- php-5.2.5.orig/ext/ming/ming.c 2008-12-31 04:17:49.000000000 -0700 +++ php-5.2.5/ext/ming/ming.c 2008-09-12 03:14:52.000000000 -0600 @@ -38,9 +39,6 @@ #include #include -#define FLOAT_Z_DVAL_PP(x) ((float)Z_DVAL_PP(x)) -#define BYTE_Z_LVAL_PP(x) ((byte)Z_LVAL_PP(x)) - #ifndef HAVE_DESTROY_SWF_BLOCK void destroySWFBlock(SWFBlock block); #endif @@ -52,8 +50,6 @@ PHP_FALIAS(ming_keypress, ming_keypress, NULL) #ifdef HAVE_NEW_MING PHP_FALIAS(ming_useconstants, ming_useConstants, NULL) -#endif -#ifdef HAVE_MING_SETSWFCOMPRESSION PHP_FALIAS(ming_setswfcompression, ming_setSWFCompression, NULL) #endif { NULL, NULL, NULL } @@ -70,16 +66,25 @@ static SWFDisplayItem getDisplayItem(zval *id TSRMLS_DC); static SWFButton getButton(zval *id TSRMLS_DC); static SWFAction getAction(zval *id TSRMLS_DC); +static SWFInitAction getInitAction(zval *id TSRMLS_DC); static SWFMorph getMorph(zval *id TSRMLS_DC); static SWFMovieClip getSprite(zval *id TSRMLS_DC); static SWFSound getSound(zval *id TSRMLS_DC); +static SWFInput getInput(zval *id TSRMLS_DC); #ifdef HAVE_NEW_MING static SWFFontCharacter getFontCharacter(zval *id TSRMLS_DC); static SWFSoundInstance getSoundInstance(zval *id TSRMLS_DC); static SWFVideoStream getVideoStream(zval *id TSRMLS_DC); -#endif -#ifdef HAVE_SWFPREBUILTCLIP +static SWFButtonRecord getButtonRecord(zval *id TSRMLS_DC); static SWFPrebuiltClip getPrebuiltClip(zval *id TSRMLS_DC); +static SWFCharacter getCharacterClass(zval *id TSRMLS_DC); +static SWFBinaryData getBinaryData(zval *id TSRMLS_DC); +static SWFBlur getBlur(zval *id TSRMLS_DC); +static SWFShadow getShadow(zval *id TSRMLS_DC); +static SWFFilterMatrix getFilterMatrix(zval *id TSRMLS_DC); +static SWFFilter getFilter(zval *id TSRMLS_DC); +static SWFCXform getCXform(zval *id TSRMLS_DC); +static SWFMatrix getMatrix(zval *id TSRMLS_DC); #endif #define PHP_MING_FILE_CHK(file) \ @@ -91,27 +96,25 @@ Set cubic threshold (?) */ PHP_FUNCTION(ming_setCubicThreshold) { - zval **num; + long num; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &num) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &num) == FAILURE) { + return; } - convert_to_long_ex(num); - Ming_setCubicThreshold(Z_LVAL_PP(num)); + Ming_setCubicThreshold(num); } /* }}} */ -/* {{{ proto void ming_setscale(int scale) +/* {{{ proto void ming_setscale(float scale) Set scale (?) */ PHP_FUNCTION(ming_setScale) { - zval **num; + double num; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &num) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &num) == FAILURE) { + return; } - convert_to_double_ex(num); - Ming_setScale(FLOAT_Z_DVAL_PP(num)); + Ming_setScale((float)num); } /* }}} */ @@ -119,13 +122,12 @@ Use SWF version (?) */ PHP_FUNCTION(ming_useSWFVersion) { - zval **num; + long num; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &num) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &num) == FAILURE) { + return; } - convert_to_long_ex(num); - Ming_useSWFVersion(Z_LVAL_PP(num)); + Ming_useSWFVersion(num); } /* }}} */ @@ -134,30 +136,27 @@ 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); + long num; - Ming_useConstants(Z_LVAL_PP(num)); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &num) == FAILURE) { + return; + } + Ming_useConstants(num); } /* }}} */ -#endif -#ifdef HAVE_MING_SETSWFCOMPRESSION /* {{{ set output compression */ PHP_FUNCTION(ming_setSWFCompression) { - zval **num; - if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &num) == FAILURE) - WRONG_PARAM_COUNT; - - convert_to_long_ex(num); - Ming_setSWFCompression(Z_LVAL_PP(num)); + long num; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &num) == FAILURE) { + return; + } + Ming_setSWFCompression(num); } /* }}} */ + #endif static int le_swfmoviep; @@ -172,6 +171,7 @@ static int le_swfbuttonp; static int le_swfactionp; static int le_swfmorphp; +static int le_swfmovieclipp; static int le_swfspritep; static int le_swfinputp; static int le_swfsoundp; @@ -179,10 +179,21 @@ static int le_swffontcharp; static int le_swfsoundinstancep; static int le_swfvideostreamp; -#endif -#ifdef HAVE_SWFPREBUILTCLIP +static int le_swfbuttonrecordp; +static int le_swfbinarydatap; +static int le_swfinitactionp; static int le_swfprebuiltclipp; +static int le_swfsoundstreamp; +static int le_swffilterp; +static int le_swfblurp; +static int le_swfshadowp; +static int le_swffiltermatrixp; +static int le_swfcxformp; +static int le_swfmatrixp; +static int le_swfbrowserfontp; +static int le_swffontcollectionp; #endif +static int le_swfcharacterp; static zend_class_entry *movie_class_entry_ptr; static zend_class_entry *shape_class_entry_ptr; @@ -196,17 +207,31 @@ static zend_class_entry *button_class_entry_ptr; static zend_class_entry *action_class_entry_ptr; static zend_class_entry *morph_class_entry_ptr; +static zend_class_entry *movieclip_class_entry_ptr; static zend_class_entry *sprite_class_entry_ptr; static zend_class_entry *sound_class_entry_ptr; +static zend_class_entry *character_class_entry_ptr; +static zend_class_entry *input_class_entry_ptr; #ifdef HAVE_NEW_MING static zend_class_entry *fontchar_class_entry_ptr; static zend_class_entry *soundinstance_class_entry_ptr; static zend_class_entry *videostream_class_entry_ptr; -#endif -#ifdef HAVE_SWFPREBUILTCLIP +static zend_class_entry *buttonrecord_class_entry_ptr; +static zend_class_entry *binarydata_class_entry_ptr; +static zend_class_entry *initaction_class_entry_ptr; static zend_class_entry *prebuiltclip_class_entry_ptr; +static zend_class_entry *soundstream_class_entry_ptr; +static zend_class_entry *filter_class_entry_ptr; +static zend_class_entry *blur_class_entry_ptr; +static zend_class_entry *shadow_class_entry_ptr; +static zend_class_entry *filtermatrix_class_entry_ptr; +static zend_class_entry *cxform_class_entry_ptr; +static zend_class_entry *matrix_class_entry_ptr; +static zend_class_entry *browserfont_class_entry_ptr; +static zend_class_entry *fontcollection_class_entry_ptr; #endif - +static zend_class_entry *character_class_entry_ptr; + /* {{{ internal function SWFgetProperty */ static void *SWFgetProperty(zval *id, char *name, int namelen, int proptype TSRMLS_DC) @@ -237,7 +262,7 @@ } /* }}} */ -/* {{{ SWFCharacter - not a real class +/* {{{ SWFCharacter */ /* {{{ internal function SWFCharacter getCharacter(zval *id) @@ -256,6 +281,8 @@ return (SWFCharacter)getButton(id TSRMLS_CC); else if (Z_OBJCE_P(id) == morph_class_entry_ptr) return (SWFCharacter)getMorph(id TSRMLS_CC); + else if (Z_OBJCE_P(id) == movieclip_class_entry_ptr) + return (SWFCharacter)getSprite(id TSRMLS_CC); else if (Z_OBJCE_P(id) == sprite_class_entry_ptr) return (SWFCharacter)getSprite(id TSRMLS_CC); else if (Z_OBJCE_P(id) == bitmap_class_entry_ptr) @@ -263,1449 +290,2801 @@ else if(Z_OBJCE_P(id) == sound_class_entry_ptr) return (SWFCharacter)getSound(id TSRMLS_CC); #ifdef HAVE_NEW_MING - else if(Z_OBJCE_P(id) == fontchar_class_entry_ptr) return (SWFCharacter)getFontCharacter(id TSRMLS_CC); else if(Z_OBJCE_P(id) == soundinstance_class_entry_ptr) return (SWFCharacter)getSoundInstance(id TSRMLS_CC); - else if(Z_OBJCE_P(id) == videostream_class_entry_ptr) return (SWFCharacter)getVideoStream(id TSRMLS_CC); -#endif -#ifdef HAVE_SWFPREBUILTCLIP + else if(Z_OBJCE_P(id) == buttonrecord_class_entry_ptr) + return (SWFCharacter)getButtonRecord(id TSRMLS_CC); else if(Z_OBJCE_P(id) == prebuiltclip_class_entry_ptr) return (SWFCharacter)getPrebuiltClip(id TSRMLS_CC); #endif else - php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Called object is not an SWFCharacter"); + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFCharacter"); return NULL; } /* }}} */ + +static SWFCharacter getCharacterClass(zval *id TSRMLS_DC) +{ + void *character = SWFgetProperty(id, "character", strlen("character"), le_swfcharacterp TSRMLS_CC); + + if (!character) { + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFCharacter"); + } + return (SWFCharacter)character; +} + +/* {{{ proto swfcharacter::getWidth() */ +PHP_METHOD(swfcharacter, getWidth) +{ + RETURN_DOUBLE(SWFCharacter_getWidth(getCharacter(getThis() TSRMLS_CC))); +} +/* }}} */ + +/* {{{ proto swfcharacter::getHeight() */ +PHP_METHOD(swfcharacter, getHeight) +{ + RETURN_DOUBLE(SWFCharacter_getHeight(getCharacter(getThis() TSRMLS_CC))); +} +/* }}} */ + +static zend_function_entry swfcharacter_functions[] = { + PHP_ME(swfcharacter, getWidth, NULL, 0) + PHP_ME(swfcharacter, getHeight, NULL, 0) + { NULL, NULL, 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) +/* {{{ getInput_fromFileResource - utility func for making an SWFInput from an fopened resource */ +static SWFInput getInput_fromFileResource(zval *zfile TSRMLS_DC) { FILE *file; php_stream *stream; SWFInput input; - php_stream_from_zval_no_verify(stream, zfile); + php_stream_from_zval_no_verify(stream, &zfile); - if (stream == NULL) + if (stream == NULL) { return NULL; + } if (php_stream_cast(stream, 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(Z_LVAL_P(zfile)); zend_list_addref(zend_list_insert(input, le_swfinputp)); return input; } /* }}} */ -/* {{{ SWFAction -*/ -/* {{{ proto void swfaction::__construct(string) - Creates a new SWFAction object, compiling the given script */ -PHP_METHOD(swfaction, __construct) +/* {{{ internal function getInput */ +static SWFInput getInput(zval *id TSRMLS_DC) { - SWFAction action; - zval **script; - int ret; + void *in = SWFgetProperty(id, "input", strlen("input"), le_swfinputp TSRMLS_CC); - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &script) == FAILURE) { - WRONG_PARAM_COUNT; + if (!in) { + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFInput"); } - - convert_to_string_ex(script); - action = compileSWFActionCode(Z_STRVAL_PP(script)); + return (SWFInput)in; +} +/* }}} */ - if (!action) { - php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Couldn't compile actionscript"); +/* {{{ proto void swfinput::__construct(string data) */ +PHP_METHOD(swfinput, __construct) +{ + SWFInput input; + char *data; + int data_len; + int ret; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &data, &data_len) == FAILURE) { + return; } - - ret = zend_list_insert(action, le_swfactionp); - object_init_ex(getThis(), action_class_entry_ptr); - add_property_resource(getThis(), "action", ret); + input = newSWFInput_bufferCopy((unsigned char *)data, data_len); + + ret = zend_list_insert(input, le_swfinputp); + object_init_ex(getThis(), input_class_entry_ptr); + add_property_resource(getThis(), "input", ret); zend_list_addref(ret); } -/* no destructor for SWFAction, it's not a character */ + +static zend_function_entry swfinput_functions[] = { + PHP_ME(swfinput, __construct, NULL, 0) + { NULL, NULL, NULL } +}; /* }}} */ -/* {{{ internal function getAction - Returns the SWFAction object contained in zval *id */ -static SWFAction getAction(zval *id TSRMLS_DC) +/* {{{ SWFFontCollection */ +static SWFFontCollection getFontCollection(zval *id TSRMLS_DC) { - void *action = SWFgetProperty(id, "action", 6, le_swfactionp TSRMLS_CC); + void *fc = SWFgetProperty(id, "fontcollection", strlen("fontcollection"), + le_swffontcollectionp TSRMLS_CC); - if (!action) { - php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Called object is not an SWFAction"); + if (!fc) { + php_error_docref(NULL TSRMLS_CC, E_ERROR, + "Called object is not an SWFFontCollection"); + } + return (SWFFontCollection)fc; +} + +/* {{{ proto swffontcollection::init(filename) */ +PHP_METHOD(swffontcollection, __construct) +{ + char *filename; + int filename_len; + int ret; + SWFFontCollection fc; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &filename, &filename_len) == FAILURE) { + return; + } + + fc = newSWFFontCollection_fromFile(filename); + if(fc) { + ret = zend_list_insert(fc, le_swffontcollectionp); + object_init_ex(getThis(), fontcollection_class_entry_ptr); + add_property_resource(getThis(), "fontcollection", ret); + zend_list_addref(ret); } - return (SWFAction)action; } /* }}} */ -static zend_function_entry swfaction_functions[] = { - PHP_ME(swfaction, __construct, NULL, 0) - { NULL, NULL, NULL } -}; +/* {{{ proto long swffontcollection::getFontCount() */ +PHP_METHOD(swffontcollection, getFontCount) +{ + RETURN_LONG(SWFFontCollection_getFontCount( + getFontCollection(getThis() TSRMLS_CC))); +} /* }}} */ -/* {{{ SWFBitmap -*/ -/* {{{ proto void swfbitmap::__construct(mixed file [, mixed maskfile]) - Creates a new SWFBitmap object from jpg (with optional mask) or dbl file */ -PHP_METHOD(swfbitmap, __construct) +/* {{{ proto SWFFont swffontcollection::getFont(int index) */ +PHP_METHOD(swffontcollection, getFont) { - zval **zfile, **zmask = NULL; - SWFBitmap bitmap; - SWFJpegWithAlpha bitmap_alpha; - SWFInput input, maskinput; + long index; 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; - } + SWFFont font; - if (Z_TYPE_PP(zfile) != IS_RESOURCE) { - convert_to_string_ex(zfile); - PHP_MING_FILE_CHK(Z_STRVAL_PP(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 (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &index) == FAILURE) { + return; } - - 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_alpha = newSWFJpegWithAlpha_fromInput(input, maskinput); - if(bitmap_alpha) { - ret = zend_list_insert(bitmap_alpha, le_swfbitmapp); - object_init_ex(getThis(), bitmap_class_entry_ptr); - add_property_resource(getThis(), "bitmap", ret); - zend_list_addref(ret); - } - } else { - bitmap = newSWFBitmap_fromInput(input); - if(bitmap) { - ret = zend_list_insert(bitmap, le_swfbitmapp); - object_init_ex(getThis(), bitmap_class_entry_ptr); - add_property_resource(getThis(), "bitmap", ret); - zend_list_addref(ret); - } + + font = SWFFontCollection_getFont(getFontCollection(getThis() TSRMLS_CC), index); + + if(font != NULL) { + ret = zend_list_insert(font, le_swffontp); + object_init_ex(return_value, font_class_entry_ptr); + add_property_resource(return_value, "font", ret); + zend_list_addref(ret); } } +/* }}} */ -static void destroy_SWFBitmap_resource(zend_rsrc_list_entry *resource TSRMLS_DC) +static void destroy_SWFFontCollection_resource(zend_rsrc_list_entry *resource TSRMLS_DC) { - destroySWFBitmap((SWFBitmap)resource->ptr); + destroySWFFontCollection((SWFFontCollection)resource->ptr); } + +static zend_function_entry swffontcollection_functions[] = { + PHP_ME(swffontcollection, __construct, NULL, 0) + PHP_ME(swffontcollection, getFont, NULL, 0) + PHP_ME(swffontcollection, getFontCount, NULL, 0) + { NULL, NULL, NULL } +}; /* }}} */ -/* {{{ internal function getBitmap - Returns the SWFBitmap object contained in zval *id */ -static SWFBitmap getBitmap(zval *id TSRMLS_DC) +/* {{{ SWFBrowserFont */ +static SWFBrowserFont getBrowserFont(zval *id TSRMLS_DC) { - void *bitmap = SWFgetProperty(id, "bitmap", 6, le_swfbitmapp TSRMLS_CC); + void *bf = SWFgetProperty(id, "browserfont", strlen("browserfont"), + le_swfbrowserfontp TSRMLS_CC); - if (!bitmap) { - php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Called object is not an SWFBitmap"); + if (!bf) { + php_error_docref(NULL TSRMLS_CC, E_ERROR, + "Called object is not an SWFBrowserFont"); } - return (SWFBitmap)bitmap; + return (SWFBrowserFont)bf; } -/* }}} */ -/* {{{ proto float swfbitmap::getWidth() - Returns the width of this bitmap */ -PHP_METHOD(swfbitmap, getWidth) +/* {{{ proto swfbrowserfont::_construct(fontname) */ +PHP_METHOD(swfbrowserfont, __construct) { - if(ZEND_NUM_ARGS() != 0) { - WRONG_PARAM_COUNT; + char *name; + int name_len; + int ret; + SWFBrowserFont font; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) { + return; + } + + font = newSWFBrowserFont(name); + if(font) { + ret = zend_list_insert(font, le_swfbrowserfontp); + object_init_ex(getThis(), browserfont_class_entry_ptr); + add_property_resource(getThis(), "browserfont", ret); + zend_list_addref(ret); } - RETURN_DOUBLE(SWFBitmap_getWidth(getBitmap(getThis() TSRMLS_CC))); } /* }}} */ -/* {{{ proto float swfbitmap::getHeight() - Returns the height of this bitmap */ -PHP_METHOD(swfbitmap, getHeight) +static void destroy_SWFBrowserFont_resource(zend_rsrc_list_entry *resource TSRMLS_DC) { - if(ZEND_NUM_ARGS() != 0) { - WRONG_PARAM_COUNT; - } - RETURN_DOUBLE(SWFBitmap_getHeight(getBitmap(getThis() TSRMLS_CC))); + destroySWFBrowserFont((SWFBrowserFont)resource->ptr); } -/* }}} */ -static zend_function_entry swfbitmap_functions[] = { - PHP_ME(swfbitmap, __construct, NULL, 0) - PHP_ME(swfbitmap, getWidth, NULL, 0) - PHP_ME(swfbitmap, getHeight, NULL, 0) +static zend_function_entry swfbrowserfont_functions[] = { + PHP_ME(swfbrowserfont, __construct, NULL, 0) { NULL, NULL, NULL } }; - /* }}} */ -/* {{{ SWFButton +/* {{{ SWFCXform */ -/* {{{ proto void swfbutton::__construct() - Creates a new SWFButton object */ -PHP_METHOD(swfbutton, __construct) +/* {{{ proto void swfcxform::__construct([rAdd, gAdd, bAdd, aAdd, rMult, gMult, bMult, aMult]) */ +PHP_METHOD(swfcxform, __construct) { - SWFButton button = newSWFButton(); - int ret = zend_list_insert(button, le_swfbuttonp); + SWFCXform cx; + long rAdd, gAdd, bAdd, aAdd; + double rMult, gMult, bMult, aMult; + int ret; - object_init_ex(getThis(), button_class_entry_ptr); - add_property_resource(getThis(), "button", ret); + switch(ZEND_NUM_ARGS()) + { + case 0: + cx = newSWFCXform(0, 0, 0, 0, 1.0, 1.0, 1.0, 1.0); + break; + case 8: + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lllldddd", + &rAdd, &gAdd, &bAdd, &aAdd, + &rMult, &gMult, &bMult, &aMult) == FAILURE) { + return; + } + cx = newSWFCXform(rAdd, gAdd, bAdd, aAdd, rMult, gMult, bMult, aMult); + break; + default: + WRONG_PARAM_COUNT; + } + + ret = zend_list_insert(cx, le_swfcxformp); + object_init_ex(getThis(), cxform_class_entry_ptr); + add_property_resource(getThis(), "cx", ret); zend_list_addref(ret); } +/* }}} */ -static void destroy_SWFButton_resource(zend_rsrc_list_entry *resource TSRMLS_DC) +/* {{{ proto void setColorAdd(r, g, b, a) */ +PHP_METHOD(swfcxform, setColorAdd) { - destroySWFButton((SWFButton)resource->ptr); + long rAdd, gAdd, bAdd, aAdd; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llll", &rAdd, &gAdd, &bAdd, &aAdd) == FAILURE) { + return; + } + + SWFCXform_setColorAdd(getCXform(getThis() TSRMLS_CC), rAdd, gAdd, bAdd, aAdd); } /* }}} */ -/* {{{ internal function getButton - Returns the SWFButton object contained in zval *id */ -static SWFButton getButton(zval *id TSRMLS_DC) +/* {{{ proto void setColorMult(r, g, b, a) */ +PHP_METHOD(swfcxform, setColorMult) { - void *button = SWFgetProperty(id, "button", 6, le_swfbuttonp TSRMLS_CC); + double rMult, gMult, bMult, aMult; - if (!button) { - php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Called object is not an SWFButton"); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dddd", &rMult, &gMult, &bMult, &aMult) == FAILURE) { + return; } - return (SWFButton)button; + + SWFCXform_setColorMult(getCXform(getThis() TSRMLS_CC), rMult, gMult, bMult, aMult); } /* }}} */ -/* {{{ proto void swfbutton::setHit(object SWFCharacter) - Sets the character for this button's hit test state */ -PHP_METHOD(swfbutton, setHit) +static void destroy_SWFCXform_resource(zend_rsrc_list_entry *resource TSRMLS_DC) { - zval **zchar; - SWFButton button = getButton(getThis() TSRMLS_CC); - SWFCharacter character; + destroySWFCXform((SWFCXform)resource->ptr); +} - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zchar) == FAILURE) { - WRONG_PARAM_COUNT; - } +/* {{{ internal function getCXform */ +static SWFCXform getCXform(zval *id TSRMLS_DC) +{ + void *cx = SWFgetProperty(id, "cx", strlen("cx"), le_swfcxformp TSRMLS_CC); - convert_to_object_ex(zchar); - character = getCharacter(*zchar TSRMLS_CC); - SWFButton_addShape(button, character, SWFBUTTONRECORD_HITSTATE); + if (!cx) { + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFCXform"); + } + return (SWFCXform)cx; } /* }}} */ -/* {{{ proto void swfbutton::setOver(object SWFCharacter) - Sets the character for this button's over state */ -PHP_METHOD(swfbutton, setOver) +static zend_function_entry swfcxform_functions[] = { + PHP_ME(swfcxform, __construct, NULL, 0) + PHP_ME(swfcxform, setColorAdd, NULL, 0) + PHP_ME(swfcxform, setColorMult, NULL, 0) + { NULL, NULL, NULL } +}; +/* }}} */ + +/* {{{ SWFMatrix */ + +static SWFMatrix getMatrix(zval *id TSRMLS_DC) { - zval **zchar; - SWFButton button = getButton(getThis() TSRMLS_CC); - SWFCharacter character; + void *matrix = SWFgetProperty(id, "matrix", strlen("matrix"), le_swfmatrixp TSRMLS_CC); + + if(!matrix) + { + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFMatrix"); + } + return (SWFMatrix)matrix; +} - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zchar) == FAILURE) { +/* {{{ proto double swfmatrix::getScaleX */ +PHP_METHOD(swfmatrix, getScaleX) +{ + if (ZEND_NUM_ARGS() != 0) { WRONG_PARAM_COUNT; } - - convert_to_object_ex(zchar); - character = getCharacter(*zchar TSRMLS_CC); - SWFButton_addShape(button, character, SWFBUTTONRECORD_OVERSTATE); + RETURN_DOUBLE(SWFMatrix_getScaleX(getMatrix(getThis() TSRMLS_CC))); } /* }}} */ -/* {{{ proto void swfbutton::setUp(object SWFCharacter) - Sets the character for this button's up state */ -PHP_METHOD(swfbutton, setUp) +/* {{{ proto double swfmatrix::getScaleX */ +PHP_METHOD(swfmatrix, getScaleY) { - zval **zchar; - SWFButton button = getButton(getThis() TSRMLS_CC); - SWFCharacter character; - - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zchar) == FAILURE) { + if (ZEND_NUM_ARGS() != 0) { WRONG_PARAM_COUNT; } - - convert_to_object_ex(zchar); - character = getCharacter(*zchar TSRMLS_CC); - SWFButton_addShape(button, character, SWFBUTTONRECORD_UPSTATE); + RETURN_DOUBLE(SWFMatrix_getScaleY(getMatrix(getThis() TSRMLS_CC))); } /* }}} */ -/* {{{ proto void swfbutton::setDown(object SWFCharacter) - Sets the character for this button's down state */ -PHP_METHOD(swfbutton, setDown) +/* {{{ proto double swfmatrix::getRotate0 */ +PHP_METHOD(swfmatrix, getRotate0) { - zval **zchar; - SWFButton button = getButton(getThis() TSRMLS_CC); - SWFCharacter character; - - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zchar) == FAILURE) { + if (ZEND_NUM_ARGS() != 0) { WRONG_PARAM_COUNT; } - - convert_to_object_ex(zchar); - character = getCharacter(*zchar TSRMLS_CC); - SWFButton_addShape(button, character, SWFBUTTONRECORD_DOWNSTATE); + RETURN_DOUBLE(SWFMatrix_getRotate0(getMatrix(getThis() TSRMLS_CC))); } /* }}} */ -/* {{{ proto void swfbutton::addShape(object SWFCharacter, int flags) - Sets the character to display for the condition described in flags */ -PHP_METHOD(swfbutton, addShape) +/* {{{ proto double swfmatrix::getRotate0 */ +PHP_METHOD(swfmatrix, getRotate1) { - zval **zchar, **flags; - SWFButton button = getButton(getThis() TSRMLS_CC); - SWFCharacter character; - - if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &zchar, &flags) == FAILURE) { + if (ZEND_NUM_ARGS() != 0) { WRONG_PARAM_COUNT; } - - convert_to_object_ex(zchar); - character = getCharacter(*zchar TSRMLS_CC); - convert_to_long_ex(flags); - SWFButton_addShape(button, character, BYTE_Z_LVAL_PP(flags)); + RETURN_DOUBLE(SWFMatrix_getRotate1(getMatrix(getThis() TSRMLS_CC))); } /* }}} */ -#ifdef HAVE_NEW_MING -/* {{{ proto void swfbutton::setMenu(int flag) - enable track as menu button behaviour */ - -PHP_METHOD(swfbutton, setMenu) +/* {{{ proto double swfmatrix::getTranslateX */ +PHP_METHOD(swfmatrix, getTranslateX) { - zval **zflag; - SWFButton button = getButton(getThis() TSRMLS_CC); - if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zflag) == FAILURE) - WRONG_PARAM_COUNT; - convert_to_long_ex(zflag); - - SWFButton_setMenu(button, Z_LVAL_PP(zflag)); + if (ZEND_NUM_ARGS() != 0) { + WRONG_PARAM_COUNT; + } + RETURN_DOUBLE(SWFMatrix_getTranslateX(getMatrix(getThis() TSRMLS_CC))); } /* }}} */ -#endif -/* {{{ proto void swfbutton::setAction(object SWFAction) - Sets the action to perform when button is pressed */ -PHP_METHOD(swfbutton, setAction) +/* {{{ proto double swfmatrix::getTranslateY */ +PHP_METHOD(swfmatrix, getTranslateY) { - zval **zaction; - SWFButton button = getButton(getThis() TSRMLS_CC); - SWFAction action; - - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zaction) == FAILURE) { + if (ZEND_NUM_ARGS() != 0) { WRONG_PARAM_COUNT; } - - convert_to_object_ex(zaction); - action = getAction(*zaction TSRMLS_CC); - SWFButton_addAction(button, action, SWFBUTTON_OVERDOWNTOOVERUP); + RETURN_DOUBLE(SWFMatrix_getTranslateY(getMatrix(getThis() TSRMLS_CC))); } /* }}} */ -#ifdef HAVE_NEW_MING -/* {{{ proto SWFSoundInstance swfbutton::addASound(SWFSound sound, int flags) - associates a sound with a button transition - NOTE: the transitions are all wrong _UP, _OVER, _DOWN _HIT */ +static zend_function_entry swfmatrix_functions[] = { + PHP_ME(swfmatrix, getScaleX, NULL, 0) + PHP_ME(swfmatrix, getScaleY, NULL, 0) + PHP_ME(swfmatrix, getRotate0, NULL, 0) + PHP_ME(swfmatrix, getRotate1, NULL, 0) + PHP_ME(swfmatrix, getTranslateX, NULL, 0) + PHP_ME(swfmatrix, getTranslateY, NULL, 0) + {NULL, NULL, NULL} +}; +/* }}} */ -PHP_METHOD(swfbutton, addSound) +/* {{{ SWFInitAction +*/ +/* {{{ proto void swfinitaction::__construct(action) + Creates a new SWFInitAction object */ +PHP_METHOD(swfinitaction, __construct) { - zval **zsound, **flags; - SWFButton button = getButton(getThis() TSRMLS_CC); - SWFSound sound; - SWFSoundInstance item; + SWFInitAction init; + zval *zaction; int ret; - if(ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &zsound, &flags) == FAILURE) - WRONG_PARAM_COUNT; - - convert_to_object_ex(zsound); - sound = getSound(*zsound TSRMLS_CC); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &zaction) == FAILURE) { + return; + } + + init = newSWFInitAction(getAction(zaction TSRMLS_CC)); - convert_to_long_ex(flags); + ret = zend_list_insert(init, le_swfinitactionp); + object_init_ex(getThis(), initaction_class_entry_ptr); + add_property_resource(getThis(), "initaction", ret); + zend_list_addref(ret); +} +/* no destructor for SWFInitAction, it's not a character */ +/* }}} */ - item = SWFButton_addSound(button, sound, Z_LVAL_PP(flags)); +/* {{{ internal function getInitAction + Returns the SWFInitAction object contained in zval *id */ +static inline SWFInitAction getInitAction(zval *id TSRMLS_DC) +{ + void *action = SWFgetProperty(id, "initaction", + strlen("initaction"), le_swfinitactionp TSRMLS_CC); - if(item != NULL) { - /* try and create a soundinstance object */ - ret = zend_list_insert(item, le_swfsoundinstancep); - object_init_ex(return_value, soundinstance_class_entry_ptr); - add_property_resource(return_value, "soundinstance", ret); - zend_list_addref(ret); + if (!action) { + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFInitAction"); } + return (SWFInitAction)action; } /* }}} */ -#endif -/* {{{ proto void swfbutton::addAction(object SWFAction, int flags) - Sets the action to perform when conditions described in flags is met */ -PHP_METHOD(swfbutton, addAction) +static zend_function_entry swfinitaction_functions[] = { + PHP_ME(swfinitaction, __construct, NULL, 0) + { NULL, NULL, NULL } +}; +/* }}} */ + +/* {{{ SWFAction +*/ +/* {{{ proto void swfaction::__construct(string) + Creates a new SWFAction object, compiling the given script */ +PHP_METHOD(swfaction, __construct) { - zval **zaction, **flags; - SWFButton button = getButton(getThis() TSRMLS_CC); SWFAction action; + char *script; + int script_len; + int ret; - if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &zaction, &flags) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &script, &script_len) == FAILURE) { + return; } - convert_to_object_ex(zaction); - action = getAction(*zaction TSRMLS_CC); - convert_to_long_ex(flags); - SWFButton_addAction(button, action, Z_LVAL_PP(flags)); + action = newSWFAction(script); + + if (!action) { + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Couldn't compile actionscript"); + } + + ret = zend_list_insert(action, le_swfactionp); + + object_init_ex(getThis(), action_class_entry_ptr); + add_property_resource(getThis(), "action", ret); + zend_list_addref(ret); } +/* no destructor for SWFAction, it's not a character */ /* }}} */ -/* {{{ proto int ming_keypress(string str) - Returns the action flag for keyPress(char) */ -PHP_FUNCTION(ming_keypress) +/* {{{ proto long swfaction::compile(version) */ +PHP_METHOD(swfaction, compile) { - zval **key; - char c; + long version; + int len, ret; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &key) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &version) == FAILURE) { + return; } - convert_to_string_ex(key); + ret = SWFAction_compile(getAction(getThis() TSRMLS_CC), version, &len); - if (Z_STRLEN_PP(key) > 1) { - php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Only one character expected"); + if (ret != 0) { + RETURN_LONG(-1); + } + else { + RETURN_LONG(len); } - - c = Z_STRVAL_PP(key)[0]; - RETURN_LONG((c&0x7f)<<9); } /* }}} */ -static zend_function_entry swfbutton_functions[] = { - PHP_ME(swfbutton, __construct, NULL, 0) - PHP_ME(swfbutton, setHit, NULL, 0) - PHP_ME(swfbutton, setOver, NULL, 0) - PHP_ME(swfbutton, setUp, NULL, 0) - PHP_ME(swfbutton, setDown, NULL, 0) - PHP_ME(swfbutton, setAction, NULL, 0) - PHP_ME(swfbutton, addShape, NULL, 0) -#ifdef HAVE_NEW_MING - PHP_ME(swfbutton, setMenu, NULL, 0) -#endif - PHP_ME(swfbutton, addAction, NULL, 0) -#ifdef HAVE_NEW_MING - PHP_ME(swfbutton, addSound, NULL, 0) -#endif +/* {{{ 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_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFAction"); + } + return (SWFAction)action; +} +/* }}} */ + +static zend_function_entry swfaction_functions[] = { + PHP_ME(swfaction, __construct, NULL, 0) + PHP_ME(swfaction, compile, NULL, 0) { NULL, NULL, NULL } }; - /* }}} */ -/* {{{ SWFDisplayitem +/* {{{ SWFBitmap */ -/* {{{ internal function getDisplayItem - Returns the SWFDisplayItem contained in zval *id */ -static SWFDisplayItem getDisplayItem(zval *id TSRMLS_DC) +/* {{{ proto void swfbitmap::__construct(filename or SWFInput [, maskfilename / SWFInput]) + Creates a new SWFBitmap object from jpg (with optional mask) or dbl file */ +PHP_METHOD(swfbitmap, __construct) { - void *item = SWFgetProperty(id, "displayitem", 11, le_swfdisplayitemp TSRMLS_CC); + zval *zfile, *zmask = NULL; + SWFBitmap bitmap; + SWFJpegWithAlpha bitmap_alpha; + SWFInput input = NULL, maskinput = NULL; + int ret; - if (!item) { - php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Called object is not an SWFDisplayItem"); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|z", &zfile, &zmask) == FAILURE) { + return; } - return (SWFDisplayItem)item; -} -/* }}} */ + switch(Z_TYPE_P(zfile)) + { + case IS_RESOURCE: + input = getInput_fromFileResource(zfile TSRMLS_CC); + break; + case IS_OBJECT: + input = getInput(zfile TSRMLS_CC); + break; + case IS_STRING: + input = newSWFInput_filename(Z_STRVAL_P(zfile)); + if(input == NULL) + php_error(E_ERROR, "opening bitmap file failed"); + zend_list_addref(zend_list_insert(input, le_swfinputp)); + break; -/* {{{ proto void swfdisplayitem::moveTo(int x, int y) - Moves this SWFDisplayItem to movie coordinates (x, y) */ -PHP_METHOD(swfdisplayitem, moveTo) -{ - zval **x, **y; + default: + php_error(E_ERROR, "swfbitmap::__construct: need either a filename, " + "a file ressource or SWFInput buffer."); + } - if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &x, &y) == FAILURE) { - WRONG_PARAM_COUNT; + if (zmask != NULL) { + switch(Z_TYPE_P(zmask)) + { + case IS_RESOURCE: + maskinput = getInput_fromFileResource(zmask TSRMLS_CC); + break; + case IS_OBJECT: + maskinput = getInput(zmask TSRMLS_CC); + break; + case IS_STRING: + maskinput = newSWFInput_filename(Z_STRVAL_P(zmask)); + if(maskinput == NULL) + php_error(E_ERROR, "opening mask file failed"); + zend_list_addref(zend_list_insert(maskinput, le_swfinputp)); + break; + + default: + php_error(E_ERROR, "swfbitmap::__construct: need either a filename, " + "a file ressource or SWFInput buffer."); + } + + /* XXX: this is very optimistic! is it really a JPEG ?!? */ + bitmap_alpha = newSWFJpegWithAlpha_fromInput(input, maskinput); + if(bitmap_alpha) { + ret = zend_list_insert(bitmap_alpha, le_swfbitmapp); + object_init_ex(getThis(), bitmap_class_entry_ptr); + add_property_resource(getThis(), "bitmap", ret); + zend_list_addref(ret); + } + } else { + bitmap = newSWFBitmap_fromInput(input); + if(bitmap) { + ret = zend_list_insert(bitmap, le_swfbitmapp); + object_init_ex(getThis(), bitmap_class_entry_ptr); + add_property_resource(getThis(), "bitmap", ret); + zend_list_addref(ret); + } } +} - convert_to_double_ex(x); - convert_to_double_ex(y); - SWFDisplayItem_moveTo(getDisplayItem(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(x), FLOAT_Z_DVAL_PP(y)); +static void destroy_SWFBitmap_resource(zend_rsrc_list_entry *resource TSRMLS_DC) +{ + destroySWFBitmap((SWFBitmap)resource->ptr); } /* }}} */ -/* {{{ proto void swfdisplayitem::move(float dx, float dy) - Displaces this SWFDisplayItem by (dx, dy) in movie coordinates */ -PHP_METHOD(swfdisplayitem, move) +/* {{{ internal function getBitmap + Returns the SWFBitmap object contained in zval *id */ +static SWFBitmap getBitmap(zval *id TSRMLS_DC) { - zval **x, **y; + void *bitmap = SWFgetProperty(id, "bitmap", 6, le_swfbitmapp TSRMLS_CC); - if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &x, &y) == FAILURE) { - WRONG_PARAM_COUNT; + if (!bitmap) { + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFBitmap"); } - - convert_to_double_ex(x); - convert_to_double_ex(y); - SWFDisplayItem_move(getDisplayItem(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(x), FLOAT_Z_DVAL_PP(y)); + return (SWFBitmap)bitmap; } /* }}} */ -/* {{{ proto void swfdisplayitem::scaleTo(float xScale [, float yScale]) - Scales this SWFDisplayItem by xScale in the x direction, yScale in the y, or both to xScale if only one arg */ -PHP_METHOD(swfdisplayitem, scaleTo) +/* {{{ proto float swfbitmap::getWidth() + Returns the width of this bitmap */ +PHP_METHOD(swfbitmap, getWidth) { - zval **x, **y; - - if (ZEND_NUM_ARGS() == 1) { - if (zend_get_parameters_ex(1, &x) == FAILURE) { - WRONG_PARAM_COUNT; - } - convert_to_double_ex(x); - SWFDisplayItem_scaleTo(getDisplayItem(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(x), FLOAT_Z_DVAL_PP(x)); - } else if (ZEND_NUM_ARGS() == 2) { - if (zend_get_parameters_ex(2, &x, &y) == FAILURE) { - WRONG_PARAM_COUNT; - } - convert_to_double_ex(x); - convert_to_double_ex(y); - SWFDisplayItem_scaleTo(getDisplayItem(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(x), FLOAT_Z_DVAL_PP(y)); - } else { - WRONG_PARAM_COUNT; + if (ZEND_NUM_ARGS() != 0) { + WRONG_PARAM_COUNT; } + RETURN_DOUBLE(SWFBitmap_getWidth(getBitmap(getThis() TSRMLS_CC))); } /* }}} */ -/* {{{ proto void swfdisplayitem::scale(float xScale, float yScale) - Multiplies this SWFDisplayItem's current x scale by xScale, its y scale by yScale */ -PHP_METHOD(swfdisplayitem, scale) +/* {{{ proto float swfbitmap::getHeight() + Returns the height of this bitmap */ +PHP_METHOD(swfbitmap, getHeight) { - zval **x, **y; - - if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &x, &y) == FAILURE) { - WRONG_PARAM_COUNT; + if (ZEND_NUM_ARGS() != 0) { + WRONG_PARAM_COUNT; } - - convert_to_double_ex(x); - convert_to_double_ex(y); - SWFDisplayItem_scale(getDisplayItem(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(x), FLOAT_Z_DVAL_PP(y)); + RETURN_DOUBLE(SWFBitmap_getHeight(getBitmap(getThis() TSRMLS_CC))); } /* }}} */ -/* {{{ proto void swfdisplayitem::rotateTo(float degrees) - Rotates this SWFDisplayItem the given (clockwise) degrees from its original orientation */ -PHP_METHOD(swfdisplayitem, rotateTo) +static zend_function_entry swfbitmap_functions[] = { + PHP_ME(swfbitmap, __construct, NULL, 0) + PHP_ME(swfbitmap, getWidth, NULL, 0) + PHP_ME(swfbitmap, getHeight, NULL, 0) + { NULL, NULL, NULL } +}; + +/* }}} */ + +#ifdef HAVE_NEW_MING +/* {{{ internal function */ +static +SWFButtonRecord getButtonRecord(zval *id TSRMLS_DC) { - zval **degrees; + void *record = SWFgetProperty(id, "buttonrecord", strlen("buttonrecord"), le_swfbuttonrecordp TSRMLS_CC); - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, °rees) == FAILURE) { - WRONG_PARAM_COUNT; - } + if(!record) + php_error(E_ERROR, "called object is not an SWFButtonRecord!"); - convert_to_double_ex(degrees); - SWFDisplayItem_rotateTo(getDisplayItem(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(degrees)); + return (SWFButtonRecord)record; } /* }}} */ -/* {{{ proto void swfdisplayitem::rotate(float degrees) - Rotates this SWFDisplayItem the given (clockwise) degrees from its current orientation */ -PHP_METHOD(swfdisplayitem, rotate) +/* {{{ proto void swfbuttoncharacter::setDepth(int depth) + sets a button characters depth */ +PHP_METHOD(swfbuttonrecord, setDepth) { - zval **degrees; + long depth; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, °rees) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &depth) == FAILURE) { + return; } - - convert_to_double_ex(degrees); - SWFDisplayItem_rotate(getDisplayItem(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(degrees)); + SWFButtonRecord_setDepth(getButtonRecord(getThis() TSRMLS_CC), depth); } /* }}} */ -/* {{{ proto void swfdisplayitem::skewXTo(float xSkew) - Sets this SWFDisplayItem's x skew value to xSkew */ -PHP_METHOD(swfdisplayitem, skewXTo) +/* {{{ proto void swfbuttoncharacter::setBlendMode(int mode) + assigns a blend mode to a button's character */ +PHP_METHOD(swfbuttonrecord, setBlendMode) { - zval **x; + long mode; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &x) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &mode) == FAILURE) { + return; } - - convert_to_double_ex(x); - SWFDisplayItem_skewXTo(getDisplayItem(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(x)); + SWFButtonRecord_setBlendMode(getButtonRecord(getThis() TSRMLS_CC), mode); } /* }}} */ -/* {{{ proto void swfdisplayitem::skewX(float xSkew) - Adds xSkew to this SWFDisplayItem's x skew value */ -PHP_METHOD(swfdisplayitem, skewX) +/* {{{ proto void swfbuttoncharacter::move(double x, double y) + relative placement */ +PHP_METHOD(swfbuttonrecord, move) { - zval **x; + double x, y; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &x) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dd", &x, &y) == FAILURE) { + return; } - - convert_to_double_ex(x); - SWFDisplayItem_skewX(getDisplayItem(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(x)); + SWFButtonRecord_move(getButtonRecord(getThis() TSRMLS_CC), x, y); } /* }}} */ -/* {{{ proto void swfdisplayitem::skewYTo(float ySkew) - Sets this SWFDisplayItem's y skew value to ySkew */ -PHP_METHOD(swfdisplayitem, skewYTo) +/* {{{ proto void swfbuttoncharacter::moveTo(double x, double y) + absolute placement */ +PHP_METHOD(swfbuttonrecord, moveTo) { - zval **y; + double x, y; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &y) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dd", &x, &y) == FAILURE) { + return; } - - convert_to_double_ex(y); - SWFDisplayItem_skewYTo(getDisplayItem(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(y)); + SWFButtonRecord_moveTo(getButtonRecord(getThis() TSRMLS_CC), x, y); } /* }}} */ -/* {{{ proto void swfdisplayitem::skewY(float ySkew) - Adds ySkew to this SWFDisplayItem's y skew value */ -PHP_METHOD(swfdisplayitem, skewY) +/* {{{ proto void swfbuttoncharacter::rotate(double deg) + relative rotation */ +PHP_METHOD(swfbuttonrecord, rotate) { - zval **y; + double deg; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &y) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", °) == FAILURE) { + return; } - - convert_to_double_ex(y); - SWFDisplayItem_skewY(getDisplayItem(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(y)); + SWFButtonRecord_rotate(getButtonRecord(getThis() TSRMLS_CC), deg); } /* }}} */ -/* {{{ proto void swfdisplayitem::setMatrix(float a, float b, float c, float d, float x, float y) - Sets the item's transform matrix */ -PHP_METHOD(swfdisplayitem, setMatrix) +/* {{{ proto void swfbuttoncharacter::rotateTo(double deg) + absolute rotation */ +PHP_METHOD(swfbuttonrecord, rotateTo) { - zval **a, **b, **c, **d, **x, **y; + double deg; - if (ZEND_NUM_ARGS() != 6 || zend_get_parameters_ex(6, &a, &b, &c, &d, &x, &y) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", °) == FAILURE) { + return; } - - convert_to_double_ex(a); - convert_to_double_ex(b); - convert_to_double_ex(c); - convert_to_double_ex(d); - convert_to_double_ex(x); - convert_to_double_ex(y); - - SWFDisplayItem_setMatrix( getDisplayItem(getThis() TSRMLS_CC), - FLOAT_Z_DVAL_PP(a), FLOAT_Z_DVAL_PP(b), FLOAT_Z_DVAL_PP(c), FLOAT_Z_DVAL_PP(d), FLOAT_Z_DVAL_PP(x), FLOAT_Z_DVAL_PP(y) - ); + SWFButtonRecord_rotateTo(getButtonRecord(getThis() TSRMLS_CC), deg); } /* }}} */ -/* {{{ proto void swfdisplayitem::setDepth(int depth) - Sets this SWFDisplayItem's z-depth to depth. Items with higher depth values are drawn on top of those with lower values */ -PHP_METHOD(swfdisplayitem, setDepth) +/* {{{ proto void swfbuttoncharacter::scale(double x, double y) + relative scaling */ +PHP_METHOD(swfbuttonrecord, scale) { - zval **depth; + double x, y; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &depth) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dd", &x, &y) == FAILURE) { + return; } - - convert_to_long_ex(depth); - SWFDisplayItem_setDepth(getDisplayItem(getThis() TSRMLS_CC), Z_LVAL_PP(depth)); + SWFButtonRecord_scale(getButtonRecord(getThis() TSRMLS_CC), x, y); } /* }}} */ -/* {{{ proto void swfdisplayitem::setRatio(float ratio) - Sets this SWFDisplayItem's ratio to ratio. Obviously only does anything if displayitem was created from an SWFMorph */ -PHP_METHOD(swfdisplayitem, setRatio) +/* {{{ proto void swfbuttoncharacter::scaleTo(double x, double y) + absolute scaling */ +PHP_METHOD(swfbuttonrecord, scaleTo) { - zval **ratio; + double x, y; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &ratio) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dd", &x, &y) == FAILURE) { + return; } - - convert_to_double_ex(ratio); - SWFDisplayItem_setRatio(getDisplayItem(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(ratio)); + SWFButtonRecord_scaleTo(getButtonRecord(getThis() TSRMLS_CC), x, y); } /* }}} */ -/* {{{ proto void swfdisplayitem::addColor(int r, int g, int b [, int a]) - Sets the add color part of this SWFDisplayItem's CXform to (r, g, b [, a]), a defaults to 0 */ +/* {{{ proto void swfbuttoncharacter::skewX(double x) */ +PHP_METHOD(swfbuttonrecord, skewX) +{ + double x; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &x) == FAILURE) { + return; + } + SWFButtonRecord_skewX(getButtonRecord(getThis() TSRMLS_CC), x); +} +/* }}} */ + +/* {{{ proto void swfbuttoncharacter::skewXTo(double x) */ +PHP_METHOD(swfbuttonrecord, skewXTo) +{ + double x; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &x) == FAILURE) { + return; + } + SWFButtonRecord_skewXTo(getButtonRecord(getThis() TSRMLS_CC), x); +} +/* }}} */ + +/* {{{ proto void swfbuttoncharacter::skewY(double y) */ +PHP_METHOD(swfbuttonrecord, skewY) +{ + double y; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &y) == FAILURE) { + return; + } + SWFButtonRecord_skewY(getButtonRecord(getThis() TSRMLS_CC), y); +} +/* }}} */ + +/* {{{ proto void swfbuttoncharacter::skewYTo(double y) */ +PHP_METHOD(swfbuttonrecord, skewYTo) +{ + double y; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &y) == FAILURE) { + return; + } + SWFButtonRecord_skewYTo(getButtonRecord(getThis() TSRMLS_CC), y); +} +/* }}} */ + +/* {{{ proto void swfbuttoncharacter::addFilter(SWFFilter f) */ +PHP_METHOD(swfbuttonrecord, addFilter) +{ + zval *filter; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &filter) == FAILURE) { + return; + } + SWFButtonRecord_addFilter(getButtonRecord(getThis() TSRMLS_CC), getFilter(filter TSRMLS_CC)); +} +/* }}} */ + +static zend_function_entry swfbuttonrecord_functions[] = { + PHP_ME(swfbuttonrecord, setDepth, NULL, 0) + PHP_ME(swfbuttonrecord, setBlendMode, NULL, 0) + PHP_ME(swfbuttonrecord, move, NULL, 0) + PHP_ME(swfbuttonrecord, moveTo, NULL, 0) + PHP_ME(swfbuttonrecord, rotate, NULL, 0) + PHP_ME(swfbuttonrecord, rotateTo, NULL, 0) + PHP_ME(swfbuttonrecord, scale, NULL, 0) + PHP_ME(swfbuttonrecord, scaleTo, NULL, 0) + PHP_ME(swfbuttonrecord, skewX, NULL, 0) + PHP_ME(swfbuttonrecord, skewXTo, NULL, 0) + PHP_ME(swfbuttonrecord, skewY, NULL, 0) + PHP_ME(swfbuttonrecord, skewYTo, NULL, 0) + PHP_ME(swfbuttonrecord, addFilter, NULL, 0) + { NULL, NULL, NULL } +}; +#endif + +/* {{{ SWFButton +*/ +/* {{{ proto void swfbutton::__construct() + Creates a new SWFButton object */ +PHP_METHOD(swfbutton, __construct) +{ + SWFButton button = newSWFButton(); + int ret = zend_list_insert(button, le_swfbuttonp); + + object_init_ex(getThis(), button_class_entry_ptr); + 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_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFButton"); + } + return (SWFButton)button; +} +/* }}} */ + +/* {{{ proto void swfbutton::setHit(object SWFCharacter) + Sets the character for this button's hit test state */ +PHP_METHOD(swfbutton, setHit) +{ + zval *zchar; + SWFButton button = getButton(getThis() TSRMLS_CC); + SWFCharacter character; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &zchar) == FAILURE) { + return; + } + + character = getCharacter(zchar TSRMLS_CC); + SWFButton_addCharacter(button, character, SWFBUTTONRECORD_HITSTATE); +} +/* }}} */ + +/* {{{ proto void swfbutton::setOver(object SWFCharacter) + Sets the character for this button's over state */ +PHP_METHOD(swfbutton, setOver) +{ + zval *zchar; + SWFButton button = getButton(getThis() TSRMLS_CC); + SWFCharacter character; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &zchar) == FAILURE) { + return; + } + + character = getCharacter(zchar TSRMLS_CC); + SWFButton_addCharacter(button, character, SWFBUTTONRECORD_OVERSTATE); +} +/* }}} */ + +/* {{{ proto void swfbutton::setUp(object SWFCharacter) + Sets the character for this button's up state */ +PHP_METHOD(swfbutton, setUp) +{ + zval *zchar; + SWFButton button = getButton(getThis() TSRMLS_CC); + SWFCharacter character; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &zchar) == FAILURE) { + return; + } + + character = getCharacter(zchar TSRMLS_CC); + SWFButton_addCharacter(button, character, SWFBUTTONRECORD_UPSTATE); +} +/* }}} */ + +/* {{{ proto void swfbutton::setDown(object SWFCharacter) + Sets the character for this button's down state */ +PHP_METHOD(swfbutton, setDown) +{ + zval *zchar; + SWFButton button = getButton(getThis() TSRMLS_CC); + SWFCharacter character; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &zchar) == FAILURE) { + return; + } + + character = getCharacter(zchar TSRMLS_CC); + SWFButton_addCharacter(button, character, SWFBUTTONRECORD_DOWNSTATE); +} +/* }}} */ + +/* {{{ proto void swfbutton::addShape(object SWFCharacter, int flags) + Sets the character to display for the condition described in flags */ +PHP_METHOD(swfbutton, addShape) +{ + zval *zchar; + long flags; + SWFButton button = getButton(getThis() TSRMLS_CC); + SWFCharacter character; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ol", &zchar, &flags) == FAILURE) { + return; + } + + character = getCharacter(zchar TSRMLS_CC); + SWFButton_addCharacter(button, character, flags); +} +/* }}} */ + +#ifdef HAVE_NEW_MING +/* {{{ proto swfbuttonrecord swfbutton::addCharacter(object SWFCharacter, int flags) + Sets the character to display for the condition described in flags */ +PHP_METHOD(swfbutton, addCharacter) +{ + zval *zchar; + long flags; + SWFButtonRecord record; + SWFButton button = getButton(getThis() TSRMLS_CC); + SWFCharacter character; + int ret; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ol", &zchar, &flags) == FAILURE) { + return; + } + + character = getCharacter(zchar TSRMLS_CC); + record = SWFButton_addCharacter(button, character, flags); + + if(record != NULL) + { + ret = zend_list_insert(record, le_swfbuttonrecordp); + object_init_ex(return_value, buttonrecord_class_entry_ptr); + add_property_resource(return_value, "buttonrecord", ret); + zend_list_addref(ret); + } +} +/* }}} */ + +/* {{{ proto void swfbutton::setMenu(int flag) + enable track as menu button behaviour */ +PHP_METHOD(swfbutton, setMenu) +{ + long flag; + SWFButton button = getButton(getThis() TSRMLS_CC); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &flag) == FAILURE) { + return; + } + SWFButton_setMenu(button, flag); +} +/* }}} */ + +/* {{{ proto void swfbutton::setScalingGrid(int x, int y, int w, int h) */ +PHP_METHOD(swfbutton, setScalingGrid) +{ + long x, y, w, h; + SWFButton button = getButton(getThis() TSRMLS_CC); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llll", &x, &y, &w, &h) == FAILURE) { + return; + } + SWFButton_setScalingGrid(button, x, y, w, h); +} +/* }}} */ + +/* {{{ proto void swfbutton::removeScalingGrid() */ +PHP_METHOD(swfbutton, removeScalingGrid) +{ + SWFButton button = getButton(getThis() TSRMLS_CC); + if (ZEND_NUM_ARGS() != 0) { + WRONG_PARAM_COUNT; + } + SWFButton_removeScalingGrid(button); +} +/* }}} */ +#endif + +/* {{{ proto void swfbutton::setAction(object SWFAction) + Sets the action to perform when button is pressed */ +PHP_METHOD(swfbutton, setAction) +{ + zval *zaction; + SWFButton button = getButton(getThis() TSRMLS_CC); + SWFAction action; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &zaction) == FAILURE) { + return; + } + + action = getAction(zaction TSRMLS_CC); + SWFButton_addAction(button, action, SWFBUTTON_OVERDOWNTOOVERUP); +} +/* }}} */ + +#ifdef HAVE_NEW_MING +/* {{{ proto SWFSoundInstance swfbutton::addASound(SWFSound sound, int flags) + associates a sound with a button transition + NOTE: the transitions are all wrong _UP, _OVER, _DOWN _HIT */ + +PHP_METHOD(swfbutton, addSound) +{ + zval *zsound; + long flags; + SWFButton button = getButton(getThis() TSRMLS_CC); + SWFSound sound; + SWFSoundInstance item; + int ret; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ol", &zsound, &flags) == FAILURE) { + return; + } + + sound = getSound(zsound TSRMLS_CC); + item = SWFButton_addSound(button, sound, flags); + + if(item != NULL) { + /* try and create a soundinstance object */ + ret = zend_list_insert(item, le_swfsoundinstancep); + object_init_ex(return_value, soundinstance_class_entry_ptr); + add_property_resource(return_value, "soundinstance", ret); + zend_list_addref(ret); + } +} +/* }}} */ +#endif + +/* {{{ proto void swfbutton::addAction(object SWFAction, int flags) + Sets the action to perform when conditions described in flags is met */ +PHP_METHOD(swfbutton, addAction) +{ + zval *zaction; + long flags; + SWFButton button = getButton(getThis() TSRMLS_CC); + SWFAction action; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ol", &zaction, &flags) == FAILURE) { + return; + } + + action = getAction(zaction TSRMLS_CC); + SWFButton_addAction(button, action, flags); +} +/* }}} */ + +/* {{{ proto int ming_keypress(string str) + Returns the action flag for keyPress(char) */ +PHP_FUNCTION(ming_keypress) +{ + char *key; + int key_len; + char c; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &key, &key_len) == FAILURE) { + return; + } + + if (key_len > 1) { + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Only one character expected"); + } + + c = key[0]; + RETURN_LONG((c&0x7f)<<9); +} +/* }}} */ + +static zend_function_entry swfbutton_functions[] = { + PHP_ME(swfbutton, __construct, NULL, 0) + PHP_ME(swfbutton, setHit, NULL, 0) + PHP_ME(swfbutton, setOver, NULL, 0) + PHP_ME(swfbutton, setUp, NULL, 0) + PHP_ME(swfbutton, setDown, NULL, 0) + PHP_ME(swfbutton, setAction, NULL, 0) + PHP_ME(swfbutton, addShape, NULL, 0) +#ifdef HAVE_NEW_MING + PHP_ME(swfbutton, setMenu, NULL, 0) + PHP_ME(swfbutton, setScalingGrid, NULL, 0) + PHP_ME(swfbutton, removeScalingGrid, NULL, 0) +#endif + PHP_ME(swfbutton, addAction, NULL, 0) +#ifdef HAVE_NEW_MING + PHP_ME(swfbutton, addSound, NULL, 0) + PHP_ME(swfbutton, addCharacter, NULL, 0) +#endif + { NULL, NULL, NULL } +}; + +/* }}} */ + +/* {{{ SWFDisplayItem +*/ +/* {{{ internal function getDisplayItem + Returns the SWFDisplayItem contained in zval *id */ +static SWFDisplayItem getDisplayItem(zval *id TSRMLS_DC) +{ + void *item = SWFgetProperty(id, "displayitem", 11, le_swfdisplayitemp TSRMLS_CC); + + if (!item) { + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFDisplayItem"); + } + + return (SWFDisplayItem)item; +} +/* }}} */ + +/* {{{ proto void swfdisplayitem::moveTo(double x, double y) + Moves this SWFDisplayItem to movie coordinates (x, y) */ +PHP_METHOD(swfdisplayitem, moveTo) +{ + double x, y; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dd", &x, &y) == FAILURE) { + return; + } + + SWFDisplayItem_moveTo(getDisplayItem(getThis() TSRMLS_CC), x, y); +} +/* }}} */ + +/* {{{ proto void swfdisplayitem::move(double dx, double dy) + Displaces this SWFDisplayItem by (dx, dy) in movie coordinates */ +PHP_METHOD(swfdisplayitem, move) +{ + double x, y; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dd", &x, &y) == FAILURE) { + return; + } + + SWFDisplayItem_move(getDisplayItem(getThis() TSRMLS_CC), x, y); +} +/* }}} */ + +/* {{{ proto void swfdisplayitem::scaleTo(double xScale [, double yScale]) + Scales this SWFDisplayItem by xScale in the x direction, yScale in the y, or both to xScale if only one arg */ +PHP_METHOD(swfdisplayitem, scaleTo) +{ + double x, y; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d|d", &x, &y) == FAILURE) { + return; + } + + if (ZEND_NUM_ARGS() == 1) { + y = x; + } + SWFDisplayItem_scaleTo(getDisplayItem(getThis() TSRMLS_CC), x, y); +} +/* }}} */ + +/* {{{ proto void swfdisplayitem::scale(double xScale, double yScale) + Multiplies this SWFDisplayItem's current x scale by xScale, its y scale by yScale */ +PHP_METHOD(swfdisplayitem, scale) +{ + double x, y; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dd", &x, &y) == FAILURE) { + return; + } + + SWFDisplayItem_scale(getDisplayItem(getThis() TSRMLS_CC), x, y); +} +/* }}} */ + +/* {{{ proto void swfdisplayitem::rotateTo(double degrees) + Rotates this SWFDisplayItem the given (clockwise) degrees from its original orientation */ +PHP_METHOD(swfdisplayitem, rotateTo) +{ + double degrees; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", °rees) == FAILURE) { + return; + } + + SWFDisplayItem_rotateTo(getDisplayItem(getThis() TSRMLS_CC), degrees); +} +/* }}} */ + +/* {{{ proto void swfdisplayitem::rotate(double degrees) + Rotates this SWFDisplayItem the given (clockwise) degrees from its current orientation */ +PHP_METHOD(swfdisplayitem, rotate) +{ + double degrees; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", °rees) == FAILURE) { + return; + } + + SWFDisplayItem_rotate(getDisplayItem(getThis() TSRMLS_CC), degrees); +} +/* }}} */ + +/* {{{ proto void swfdisplayitem::skewXTo(double xSkew) + Sets this SWFDisplayItem's x skew value to xSkew */ +PHP_METHOD(swfdisplayitem, skewXTo) +{ + double x; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &x) == FAILURE) { + return; + } + + SWFDisplayItem_skewXTo(getDisplayItem(getThis() TSRMLS_CC), x); +} +/* }}} */ + +/* {{{ proto void swfdisplayitem::skewX(double xSkew) + Adds xSkew to this SWFDisplayItem's x skew value */ +PHP_METHOD(swfdisplayitem, skewX) +{ + double x; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &x) == FAILURE) { + return; + } + + SWFDisplayItem_skewX(getDisplayItem(getThis() TSRMLS_CC), x); +} +/* }}} */ + +/* {{{ proto void swfdisplayitem::skewYTo(double ySkew) + Sets this SWFDisplayItem's y skew value to ySkew */ +PHP_METHOD(swfdisplayitem, skewYTo) +{ + double y; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &y) == FAILURE) { + return; + } + + SWFDisplayItem_skewYTo(getDisplayItem(getThis() TSRMLS_CC), y); +} +/* }}} */ + +/* {{{ proto void swfdisplayitem::skewY(double ySkew) + Adds ySkew to this SWFDisplayItem's y skew value */ +PHP_METHOD(swfdisplayitem, skewY) +{ + double y; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &y) == FAILURE) { + return; + } + + SWFDisplayItem_skewY(getDisplayItem(getThis() TSRMLS_CC), y); +} +/* }}} */ + +/* {{{ proto void swfdisplayitem::setMatrix(double a, double b, double c, double d, double x, double y) + Sets the item's transform matrix */ +PHP_METHOD(swfdisplayitem, setMatrix) +{ + double a, b, c, d, x, y; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dddddd", &a, &b, &c, &d, &x, &y) == FAILURE) { + return; + } + + SWFDisplayItem_setMatrix( getDisplayItem(getThis() TSRMLS_CC), a, b, c, d, x, y); +} +/* }}} */ + +/* {{{ proto void swfdisplayitem::setDepth(int depth) + Sets this SWFDisplayItem's z-depth to depth. Items with higher depth values are drawn on top of those with lower values */ +PHP_METHOD(swfdisplayitem, setDepth) +{ + long depth; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &depth) == FAILURE) { + return; + } + + SWFDisplayItem_setDepth(getDisplayItem(getThis() TSRMLS_CC), depth); +} +/* }}} */ + +/* {{{ proto void swfdisplayitem::setRatio(float ratio) + Sets this SWFDisplayItem's ratio to ratio. Obviously only does anything if displayitem was created from an SWFMorph */ +PHP_METHOD(swfdisplayitem, setRatio) +{ + double ratio; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &ratio) == FAILURE) { + return; + } + + SWFDisplayItem_setRatio(getDisplayItem(getThis() TSRMLS_CC), ratio); +} +/* }}} */ + +/* {{{ proto void swfdisplayitem::addColor(int r, int g, int b [, int a]) + Sets the add color part of this SWFDisplayItem's CXform to (r, g, b [, a]), a defaults to 0 */ PHP_METHOD(swfdisplayitem, addColor) { - zval **r, **g, **b, **za; - int a = 0; + long r, g, b, a = 0; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll|l", &r, &g, &b, &a) == FAILURE) { + return; + } + + SWFDisplayItem_setColorAdd(getDisplayItem(getThis() TSRMLS_CC), r, g, b, (int)a); +} +/* }}} */ + +/* {{{ proto void swfdisplayitem::multColor(float r, float g, float b [, float a]) + Sets the multiply color part of this SWFDisplayItem's CXform to (r, g, b [, a]), a defaults to 1.0 */ +PHP_METHOD(swfdisplayitem, multColor) +{ + double r, g, b, a = 1.0; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ddd|d", &r, &g, &b, &a) == FAILURE) { + return; + } + + SWFDisplayItem_setColorMult(getDisplayItem(getThis() TSRMLS_CC), r, g, b, a); +} +/* }}} */ + +/* {{{ proto void swfdisplayitem::setName(string name) + Sets this SWFDisplayItem's name to name */ +PHP_METHOD(swfdisplayitem, setName) +{ + char *name; + int name_len; + SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) { + return; + } + + SWFDisplayItem_setName(item, name); +} +/* }}} */ + +/* {{{ proto void swfdisplayitem::addAction(object SWFAction, int flags) + Adds this SWFAction to the given SWFSprite instance */ +PHP_METHOD(swfdisplayitem, addAction) +{ + zval *zaction; + long flags; + SWFAction action; + SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ol", &zaction, &flags) == FAILURE) { + return; + } + + action = getAction(zaction TSRMLS_CC); + SWFDisplayItem_addAction(item, action, flags); +} +/* }}} */ + +#ifdef HAVE_NEW_MING +/* {{{ swfdisplayitem_remove */ + +PHP_METHOD(swfdisplayitem, remove) +{ + SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC); + + if (ZEND_NUM_ARGS() != 0) { + WRONG_PARAM_COUNT; + } + + SWFDisplayItem_remove(item); +} +/* }}} */ + +/* {{{ proto void swfdisplayitem::setMaskLevel(int level) + defines a MASK layer at level */ + +PHP_METHOD(swfdisplayitem, setMaskLevel) +{ + long level; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &level) == FAILURE) { + return; + } + + SWFDisplayItem_setMaskLevel(getDisplayItem(getThis() TSRMLS_CC), level); +} +/* }}} */ + +/* {{{ proto void swfdisplayitem::endMask() + another way of defining a MASK layer */ + +PHP_METHOD(swfdisplayitem, endMask) +{ + SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC); + + if (ZEND_NUM_ARGS() != 0) { + WRONG_PARAM_COUNT; + } + + SWFDisplayItem_endMask(item); +} +/* }}} */ + +/* {{{ swfdisplayitem_getX */ + +PHP_METHOD(swfdisplayitem, getX) +{ + double x, y; + SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC); + + if (ZEND_NUM_ARGS() != 0) { + WRONG_PARAM_COUNT; + } + + SWFDisplayItem_getPosition(item, &x, &y); + RETURN_DOUBLE(x); +} +/* }}} */ + +/* {{{ swfdisplayitem_getY */ + +PHP_METHOD(swfdisplayitem, getY) +{ + double x, y; + SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC); + + if (ZEND_NUM_ARGS() != 0) { + WRONG_PARAM_COUNT; + } + + SWFDisplayItem_getPosition(item, &x, &y); + RETURN_DOUBLE(y); +} +/* }}} */ + +/* {{{ swfdisplayitem_getXScale */ + +PHP_METHOD(swfdisplayitem, getXScale) +{ + double sx, sy; + SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC); + + if (ZEND_NUM_ARGS() != 0) { + WRONG_PARAM_COUNT; + } + + SWFDisplayItem_getScale(item, &sx, &sy); + RETURN_DOUBLE(sx); +} +/* }}} */ + +/* {{{ swfdisplayitem_getYScale */ + +PHP_METHOD(swfdisplayitem, getYScale) +{ + double sx, sy; + SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC); + + if (ZEND_NUM_ARGS() != 0) { + WRONG_PARAM_COUNT; + } + + SWFDisplayItem_getScale(item, &sx, &sy); + RETURN_DOUBLE(sy); +} +/* }}} */ + +/* {{{ swfdisplayitem_getXSkew */ + +PHP_METHOD(swfdisplayitem, getXSkew) +{ + double sx, sy; + SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC); + + if (ZEND_NUM_ARGS() != 0) { + WRONG_PARAM_COUNT; + } + + SWFDisplayItem_getSkew(item, &sx, &sy); + RETURN_DOUBLE(sx); +} +/* }}} */ + +/* {{{ swfdisplayitem_getYSkew */ + +PHP_METHOD(swfdisplayitem, getYSkew) +{ + double sx, sy; + SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC); + + if (ZEND_NUM_ARGS() != 0) { + WRONG_PARAM_COUNT; + } + + SWFDisplayItem_getSkew(item, &sx, &sy); + RETURN_DOUBLE(sy); +} +/* }}} */ + +/* {{{ swfdisplayitem_getRot */ + +PHP_METHOD(swfdisplayitem, getRot) +{ + double ret; + SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC); + + if (ZEND_NUM_ARGS() != 0) { + WRONG_PARAM_COUNT; + } + + SWFDisplayItem_getRotation(item, &ret); + RETURN_DOUBLE(ret); +} +/* }}} */ + +/* {{{ proto void swfdisplayitem::cacheAsBitmap(int flag) + caches item as bitmap. can improve rendering speed */ + +PHP_METHOD(swfdisplayitem, cacheAsBitmap) +{ + long flag; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &flag) == FAILURE) { + return; + } + + SWFDisplayItem_cacheAsBitmap(getDisplayItem(getThis() TSRMLS_CC), flag); +} +/* }}} */ + + +/* {{{ proto void swfdisplayitem::setBlendMode(int mode) + adds blending to item */ +PHP_METHOD(swfdisplayitem, setBlendMode) +{ + long mode; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &mode) == FAILURE) { + return; + } + + SWFDisplayItem_cacheAsBitmap(getDisplayItem(getThis() TSRMLS_CC), mode); +} +/* }}} */ + +/* {{{ proto int swfdisplayitem::setDepth() + gets the items depth */ +PHP_METHOD(swfdisplayitem, getDepth) +{ + int ret; + + if (ZEND_NUM_ARGS() != 0) { + WRONG_PARAM_COUNT; + } + + ret = SWFDisplayItem_getDepth(getDisplayItem(getThis() TSRMLS_CC)); + RETURN_LONG(ret); +} +/* }}} */ + +/* {{{ proto int swfdisplayitem::flush() */ +PHP_METHOD(swfdisplayitem, flush) +{ + if (ZEND_NUM_ARGS() != 0) { + WRONG_PARAM_COUNT; + } + + SWFDisplayItem_flush(getDisplayItem(getThis() TSRMLS_CC)); +} +/* }}} */ + +/* {{{ proto void swfdisplayitem::addFilter(SWFFilter filter) */ +PHP_METHOD(swfdisplayitem, addFilter) +{ + zval *filter; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &filter) == FAILURE) { + return; + } + + SWFDisplayItem_addFilter(getDisplayItem(getThis() TSRMLS_CC), getFilter(filter TSRMLS_CC)); + +} +/* }}} */ + +/* {{{ proto void swfdisplayitem::setCXform(cx) */ +PHP_METHOD(swfdisplayitem, setCXform) +{ + zval *cx; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &cx) == FAILURE) { + return; + } + + SWFDisplayItem_setCXform(getDisplayItem(getThis() TSRMLS_CC), getCXform(cx TSRMLS_CC)); +} +/* }}} */ + +/** {{{ proto void swfdisplayitem::getMatrix() */ +PHP_METHOD(swfdisplayitem, getMatrix) +{ + SWFMatrix m; + int ret; + + if (ZEND_NUM_ARGS() != 0) { + WRONG_PARAM_COUNT; + } + + m = SWFDisplayItem_getMatrix(getDisplayItem(getThis() TSRMLS_CC)); + if(m != NULL) + { + ret = zend_list_insert(m, le_swfmatrixp); + object_init_ex(return_value, matrix_class_entry_ptr); + add_property_resource(return_value, "matrix", ret); + zend_list_addref(ret); + } +} +/* }}} */ + +/** {{{ proto void swfdisplayitem::getCharacter() */ +PHP_METHOD(swfdisplayitem, getCharacter) +{ + SWFCharacter c; + int ret; + + if (ZEND_NUM_ARGS() != 0) { + WRONG_PARAM_COUNT; + } + + c = SWFDisplayItem_getCharacter(getDisplayItem(getThis() TSRMLS_CC)); + if(c != NULL) + { + ret = zend_list_insert(c, le_swfcharacterp); + object_init_ex(return_value, character_class_entry_ptr); + add_property_resource(return_value, "character", ret); + zend_list_addref(ret); + } +} +/* }}} */ + +#endif + +static zend_function_entry swfdisplayitem_functions[] = { + PHP_ME(swfdisplayitem, moveTo, NULL, 0) + PHP_ME(swfdisplayitem, move, NULL, 0) + PHP_ME(swfdisplayitem, scaleTo, NULL, 0) + PHP_ME(swfdisplayitem, scale, NULL, 0) + PHP_ME(swfdisplayitem, rotateTo, NULL, 0) + PHP_ME(swfdisplayitem, rotate, NULL, 0) + PHP_ME(swfdisplayitem, skewXTo, NULL, 0) + PHP_ME(swfdisplayitem, skewX, NULL, 0) + PHP_ME(swfdisplayitem, skewYTo, NULL, 0) + PHP_ME(swfdisplayitem, skewY, NULL, 0) + PHP_ME(swfdisplayitem, setMatrix, NULL, 0) + PHP_ME(swfdisplayitem, setDepth, NULL, 0) + PHP_ME(swfdisplayitem, setRatio, NULL, 0) + PHP_ME(swfdisplayitem, addColor, NULL, 0) + PHP_ME(swfdisplayitem, multColor, NULL, 0) + PHP_ME(swfdisplayitem, setName, NULL, 0) + PHP_ME(swfdisplayitem, addAction, NULL, 0) +#ifdef HAVE_NEW_MING + PHP_ME(swfdisplayitem, remove, NULL, 0) + PHP_ME(swfdisplayitem, setMaskLevel,NULL, 0) + PHP_ME(swfdisplayitem, endMask, NULL, 0) + PHP_ME(swfdisplayitem, getX, NULL, 0) + PHP_ME(swfdisplayitem, getY, NULL, 0) + PHP_ME(swfdisplayitem, getXScale, NULL, 0) + PHP_ME(swfdisplayitem, getYScale, NULL, 0) + PHP_ME(swfdisplayitem, getXSkew, NULL, 0) + PHP_ME(swfdisplayitem, getYSkew, NULL, 0) + PHP_ME(swfdisplayitem, getRot, NULL, 0) + PHP_ME(swfdisplayitem, cacheAsBitmap, NULL, 0) + PHP_ME(swfdisplayitem, setBlendMode, NULL, 0) + PHP_ME(swfdisplayitem, getDepth, NULL, 0) + PHP_ME(swfdisplayitem, flush, NULL, 0) + PHP_ME(swfdisplayitem, addFilter, NULL, 0) + PHP_ME(swfdisplayitem, setCXform, NULL, 0) + PHP_ME(swfdisplayitem, getCharacter, NULL, 0) +#endif + { NULL, NULL, NULL } +}; + +/* }}} */ + +/* {{{ SWFFill +*/ +/* {{{ proto void swffill::__construct() + Creates a new SWFFill object */ +PHP_METHOD(swffill, __construct) +{ + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Instantiating SWFFill won't do any good- use SWFShape::addFill() instead"); +} + +static void destroy_SWFFill_resource(zend_rsrc_list_entry *resource TSRMLS_DC) +{ + /* this only destroys the shallow wrapper for SWFFillStyle, + which SWFShape destroys. So everything's okay. I hope. */ + + destroySWFFill((SWFFill)resource->ptr); +} +/* }}} */ + +/* {{{ internal function getFill + Returns the SWFFill object contained in zval *id */ +static SWFFill getFill(zval *id TSRMLS_DC) +{ + void *fill = SWFgetProperty(id, "fill", 4, le_swffillp TSRMLS_CC); - if (ZEND_NUM_ARGS() == 4) { - if (zend_get_parameters_ex(4, &r, &g, &b, &za) == FAILURE) { - WRONG_PARAM_COUNT; - } - convert_to_long_ex(za); - a = Z_LVAL_PP(za); - } else if (ZEND_NUM_ARGS() == 3) { - if (zend_get_parameters_ex(3, &r, &g, &b) == FAILURE) { - WRONG_PARAM_COUNT; - } - } else { - WRONG_PARAM_COUNT; + if (!fill) { + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFFill"); + } + return (SWFFill)fill; +} +/* }}} */ + +/* {{{ proto void swffill::moveTo(float x, float y) + Moves this SWFFill to shape coordinates (x,y) */ +PHP_METHOD(swffill, moveTo) +{ + double x, y; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dd", &x, &y) == FAILURE) { + return; } - convert_to_long_ex(r); - convert_to_long_ex(g); - convert_to_long_ex(b); + SWFFill_moveTo(getFill(getThis() TSRMLS_CC), x, y); +} +/* }}} */ + +/* {{{ proto void swffill::move(float dx, float dy) + Moves this SWFFill by (dx,dy) */ +PHP_METHOD(swffill, move) +{ + double x, y; - SWFDisplayItem_setColorAdd(getDisplayItem(getThis() TSRMLS_CC), Z_LVAL_PP(r), Z_LVAL_PP(g), Z_LVAL_PP(b), a); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dd", &x, &y) == FAILURE) { + return; + } + + SWFFill_move(getFill(getThis() TSRMLS_CC), x, y); } /* }}} */ -/* {{{ proto void swfdisplayitem::multColor(float r, float g, float b [, float a]) - Sets the multiply color part of this SWFDisplayItem's CXform to (r, g, b [, a]), a defaults to 1.0 */ -PHP_METHOD(swfdisplayitem, multColor) + +/* {{{ proto void swffill::scaleTo(float xScale [, float yScale]) + Scales this SWFFill by xScale in the x direction, yScale in the y, or both to xScale if only one arg */ +PHP_METHOD(swffill, scaleTo) { - zval **r, **g, **b, **za; - float a = 1.0f; + double x, y; - if (ZEND_NUM_ARGS() == 4) { - if (zend_get_parameters_ex(4, &r, &g, &b, &za) == FAILURE) { - WRONG_PARAM_COUNT; - } - convert_to_double_ex(za); - a = FLOAT_Z_DVAL_PP(za); - } else if (ZEND_NUM_ARGS() == 3) { - if (zend_get_parameters_ex(3, &r, &g, &b) == FAILURE) { - WRONG_PARAM_COUNT; - } - } else { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d|d", &x, &y) == FAILURE) { + return; } - convert_to_double_ex(r); - convert_to_double_ex(g); - convert_to_double_ex(b); + if (ZEND_NUM_ARGS() == 1) { + y = x; + } + SWFFill_scaleXYTo(getFill(getThis() TSRMLS_CC), x, y); +} +/* }}} */ + +/* {{{ proto void swffill::scale(float xScale [, float yScale]) + Scales this SWFFill by xScale in the x direction, yScale in the y, or both to xScale if only one arg */ +PHP_METHOD(swffill, scale) +{ + double x, y; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d|d", &x, &y) == FAILURE) { + return; + } - SWFDisplayItem_setColorMult(getDisplayItem(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(r), FLOAT_Z_DVAL_PP(g), FLOAT_Z_DVAL_PP(b), a); + if (ZEND_NUM_ARGS() == 1) { + y = x; + } + SWFFill_scaleXY(getFill(getThis() TSRMLS_CC), x, y); } /* }}} */ -/* {{{ proto void swfdisplayitem::setName(string name) - Sets this SWFDisplayItem's name to name */ -PHP_METHOD(swfdisplayitem, setName) + +/* {{{ proto void swffill::rotateTo(float degrees) + Rotates this SWFFill the given (clockwise) degrees from its original orientation */ +PHP_METHOD(swffill, rotateTo) { - zval **name; - SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC); + double degrees; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &name) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", °rees) == FAILURE) { + return; } - - convert_to_string_ex(name); - SWFDisplayItem_setName(item, Z_STRVAL_PP(name)); + + SWFFill_rotateTo(getFill(getThis() TSRMLS_CC), degrees); } /* }}} */ -/* {{{ proto void swfdisplayitem::addAction(object SWFAction, int flags) - Adds this SWFAction to the given SWFSprite instance */ -PHP_METHOD(swfdisplayitem, addAction) +/* {{{ proto void swffill::rotate(float degrees) + Rotates this SWFFill the given (clockwise) degrees from its current orientation */ +PHP_METHOD(swffill, rotate) { - zval **zaction, **flags; - SWFAction action; - SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC); + double degrees; - if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &zaction, &flags) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", °rees) == FAILURE) { + return; } - convert_to_object_ex(zaction); - convert_to_long_ex(flags); - action = getAction(*zaction TSRMLS_CC); - SWFDisplayItem_addAction(item, action, Z_LVAL_PP(flags)); + SWFFill_rotate(getFill(getThis() TSRMLS_CC), degrees); } /* }}} */ -#ifdef HAVE_NEW_MING -/* {{{ swfdisplayitem_remove */ -PHP_METHOD(swfdisplayitem, remove) +/* {{{ proto void swffill::skewXTo(float xSkew) + Sets this SWFFill's x skew value to xSkew */ +PHP_METHOD(swffill, skewXTo) { - SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC); + double x; - if(ZEND_NUM_ARGS() != 0) - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &x) == FAILURE) { + return; + } - SWFDisplayItem_remove(item); + SWFFill_skewXTo(getFill(getThis() TSRMLS_CC), x); } /* }}} */ -/* {{{ proto void swfdisplayitem::setMaskLevel(int level) - defines a MASK layer at level */ - -PHP_METHOD(swfdisplayitem, setMaskLevel) +/* {{{ proto void swffill::skewX(float xSkew) + Sets this SWFFill's x skew value to xSkew */ +PHP_METHOD(swffill, skewX) { - zval **level; + double x; - if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &level) == FAILURE) - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &x) == FAILURE) { + return; + } + + SWFFill_skewX(getFill(getThis() TSRMLS_CC), x); +} +/* }}} */ + +/* {{{ proto void swffill::skewYTo(float ySkew) + Sets this SWFFill's y skew value to ySkew */ +PHP_METHOD(swffill, skewYTo) +{ + double y; - convert_to_long_ex(level); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &y) == FAILURE) { + return; + } - SWFDisplayItem_setMaskLevel(getDisplayItem(getThis() TSRMLS_CC), Z_LVAL_PP(level)); + SWFFill_skewYTo(getFill(getThis() TSRMLS_CC), y); } /* }}} */ -/* {{{ proto void swfdisplayitem::endMask() - another way of defining a MASK layer */ +/* {{{ proto void swffill::skewY(float ySkew) + Sets this SWFFill's y skew value to ySkew */ +PHP_METHOD(swffill, skewY) +{ + double y; -PHP_METHOD(swfdisplayitem, endMask) + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &y) == FAILURE) { + return; + } + + SWFFill_skewY(getFill(getThis() TSRMLS_CC), y); +} +/* }}} */ + +/* {{{ proto void swffill::setMatrix(float a, float b, float c, float d, float x, float y) + Sets this SWFFill's y matrix values */ +PHP_METHOD(swffill, setMatrix) { - SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC); + double a, b, c, d, x, y; - if(ZEND_NUM_ARGS() != 0) - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dddddd", &a, &b, &c, &d, &x, &y) == FAILURE) { + return; + } - SWFDisplayItem_endMask(item); + SWFFill_setMatrix(getFill(getThis() TSRMLS_CC), a, b, c, d, x, y); } /* }}} */ -/* {{{ swfdisplayitem_getX */ +static zend_function_entry swffill_functions[] = { + PHP_ME(swffill, __construct, NULL, 0) + PHP_ME(swffill, moveTo, NULL, 0) + PHP_ME(swffill, move, NULL, 0) + PHP_ME(swffill, scaleTo, NULL, 0) + PHP_ME(swffill, scale, NULL, 0) + PHP_ME(swffill, rotateTo, NULL, 0) + PHP_ME(swffill, rotate, NULL, 0) + PHP_ME(swffill, skewXTo, NULL, 0) + PHP_ME(swffill, skewX, NULL, 0) + PHP_ME(swffill, skewYTo, NULL, 0) + PHP_ME(swffill, skewY, NULL, 0) + PHP_ME(swffill, setMatrix, NULL, 0) + { NULL, NULL, NULL } +}; -PHP_METHOD(swfdisplayitem, getX) +/* }}} */ + +/* {{{ SWFFontCharacter */ +#ifdef HAVE_NEW_MING + +/* {{{ internal function SWFText getFont(zval *id) + Returns the Font object in zval *id */ +static +SWFFontCharacter getFontCharacter(zval *id TSRMLS_DC) { - float ret; - SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC); + void *font = SWFgetProperty(id, "fontcharacter", 13, le_swffontcharp TSRMLS_CC); - if(ZEND_NUM_ARGS() != 0) - WRONG_PARAM_COUNT; + if(!font) + php_error(E_ERROR, "called object is not an SWFFontCharacter!"); - ret = SWFDisplayItem_get_x(item); - RETURN_DOUBLE(ret); + return (SWFFontCharacter)font; } /* }}} */ -/* {{{ swfdisplayitem_getY */ +/* {{{ proto void swffontcha::raddChars(string) + adds characters to a font for exporting font */ +PHP_METHOD(swffontchar, addChars) +{ + char *string; + int string_len; -PHP_METHOD(swfdisplayitem, getY) + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &string, &string_len) == FAILURE) { + return; + } + + SWFFontCharacter_addChars(getFontCharacter(getThis() TSRMLS_CC), string); +} +/* }}} */ + +/* {{{ proto void swffontchar::addChars(string) + adds characters to a font for exporting font */ + +PHP_METHOD(swffontchar, addUTF8Chars) { - float ret; - SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC); + char *string; + int string_len; - if(ZEND_NUM_ARGS() != 0) + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &string, &string_len) == FAILURE) { + return; + } + + SWFFontCharacter_addUTF8Chars(getFontCharacter(getThis() TSRMLS_CC), string); +} +/* }}} */ + +/* {{{ proto void swffontchar::addAllChars() + * adds all characters to a font for exporting font */ + +PHP_METHOD(swffontchar, addAllChars) +{ + if (ZEND_NUM_ARGS() != 0 ) { WRONG_PARAM_COUNT; + } - ret = SWFDisplayItem_get_y(item); - RETURN_DOUBLE(ret); + SWFFontCharacter_addAllChars(getFontCharacter(getThis() TSRMLS_CC)); } /* }}} */ -/* {{{ swfdisplayitem_getXScale */ +static zend_function_entry swffontchar_functions[] = { + PHP_ME(swffontchar, addChars, NULL, 0) + PHP_ME(swffontchar, addUTF8Chars, NULL, 0) + PHP_ME(swffontchar, addAllChars, NULL, 0) + { NULL, NULL, NULL } +}; -PHP_METHOD(swfdisplayitem, getXScale) +#endif +/* }}} */ + +/* {{{ internal function SWFText getFont(zval *id) + Returns the Font object in zval *id */ +static SWFFont getFont(zval *id TSRMLS_DC) { - float ret; - SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC); + void *font = SWFgetProperty(id, "font", 4, le_swffontp TSRMLS_CC); - if(ZEND_NUM_ARGS() != 0) - WRONG_PARAM_COUNT; + if (!font) { + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFFont"); + } + return (SWFFont)font; +} +/* }}} */ - ret = SWFDisplayItem_get_xScale(item); - RETURN_DOUBLE(ret); +/* {{{ proto void swffont::__construct(string filename) + Creates a new SWFFont object from given file */ +PHP_METHOD(swffont, __construct) +{ + char *file; + int file_len; + SWFFont font; + int ret; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &file, &file_len) == FAILURE) { + return; + } + + PHP_MING_FILE_CHK(file); + font = newSWFFont_fromFile(file); + + if(font == NULL) + { + php_error(E_ERROR, "Loading font failed! " + "Please use new SWFBrowserFont(string:fontname) " + "for player/browser fonts."); + + } + + if(font) + { + ret = zend_list_insert(font, le_swffontp); + object_init_ex(getThis(), font_class_entry_ptr); + add_property_resource(getThis(), "font", ret); + zend_list_addref(ret); + } +} + +static void destroy_SWFFont_resource(zend_rsrc_list_entry *resource TSRMLS_DC) +{ + destroySWFBlock((SWFBlock)resource->ptr); } /* }}} */ -/* {{{ swfdisplayitem_getYScale */ +/* {{{ proto float swffont::getWidth(string str) + Calculates the width of the given string in this font at full height */ +PHP_METHOD(swffont, getWidth) +{ + char *string; + int string_len; + float width; -PHP_METHOD(swfdisplayitem, getYScale) + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &string, &string_len) == FAILURE) { + return; + } + + width = SWFFont_getStringWidth(getFont(getThis() TSRMLS_CC), string); + RETURN_DOUBLE(width); +} +/* }}} */ + +#ifdef HAVE_NEW_MING +/* {{{ proto int swffont::getUTF8Width(string) + Calculates the width of the given string in this font at full height */ + +PHP_METHOD(swffont, getUTF8Width) { - float ret; - SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC); + char *string; + int string_len; + float width; - if(ZEND_NUM_ARGS() != 0) - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &string, &string_len) == FAILURE) { + return; + } - ret = SWFDisplayItem_get_yScale(item); - RETURN_DOUBLE(ret); + width = SWFFont_getUTF8StringWidth(getFont(getThis() TSRMLS_CC), string); + RETURN_DOUBLE(width); +} + +/* {{{ proto int swffont::getglyphcount() */ +PHP_METHOD(swffont, getGlyphCount) +{ + RETURN_LONG(SWFFont_getGlyphCount(getFont(getThis() TSRMLS_CC))); } /* }}} */ -/* {{{ swfdisplayitem_getXSkew */ - -PHP_METHOD(swfdisplayitem, getXSkew) +/* {{{ proto string swffont::getname() */ +PHP_METHOD(swffont, getName) { - float ret; - SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC); + RETURN_STRING(SWFFont_getName(getFont(getThis() TSRMLS_CC)), 0); +} +/* }}} */ +#endif - if(ZEND_NUM_ARGS() != 0) +/* {{{ proto float swffont::getAscent() + Returns the ascent of the font, or 0 if not available */ +PHP_METHOD(swffont, getAscent) +{ + if (ZEND_NUM_ARGS() != 0) { WRONG_PARAM_COUNT; - - ret = SWFDisplayItem_get_xSkew(item); - RETURN_DOUBLE(ret); + } + RETURN_DOUBLE(SWFFont_getAscent(getFont(getThis() TSRMLS_CC))); } /* }}} */ -/* {{{ swfdisplayitem_getYSkew */ - -PHP_METHOD(swfdisplayitem, getYSkew) +/* {{{ proto float swffont::getDescent() + Returns the descent of the font, or 0 if not available */ +PHP_METHOD(swffont, getDescent) { - float ret; - SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC); - - if(ZEND_NUM_ARGS() != 0) + if (ZEND_NUM_ARGS() != 0) { WRONG_PARAM_COUNT; - - ret = SWFDisplayItem_get_ySkew(item); - RETURN_DOUBLE(ret); + } + RETURN_DOUBLE(SWFFont_getDescent(getFont(getThis() TSRMLS_CC))); } /* }}} */ -/* {{{ swfdisplayitem_getRot */ - -PHP_METHOD(swfdisplayitem, getRot) +/* {{{ proto float swffont::getLeading() + Returns the leading of the font, or 0 if not available */ +PHP_METHOD(swffont, getLeading) { - float ret; - SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC); - - if(ZEND_NUM_ARGS() != 0) + if (ZEND_NUM_ARGS() != 0) { WRONG_PARAM_COUNT; - - ret = SWFDisplayItem_get_rot(item); - RETURN_DOUBLE(ret); + } + RETURN_DOUBLE(SWFFont_getLeading(getFont(getThis() TSRMLS_CC))); } /* }}} */ -#endif -static zend_function_entry swfdisplayitem_functions[] = { - PHP_ME(swfdisplayitem, moveTo, NULL, 0) - PHP_ME(swfdisplayitem, move, NULL, 0) - PHP_ME(swfdisplayitem, scaleTo, NULL, 0) - PHP_ME(swfdisplayitem, scale, NULL, 0) - PHP_ME(swfdisplayitem, rotateTo, NULL, 0) - PHP_ME(swfdisplayitem, rotate, NULL, 0) - PHP_ME(swfdisplayitem, skewXTo, NULL, 0) - PHP_ME(swfdisplayitem, skewX, NULL, 0) - PHP_ME(swfdisplayitem, skewYTo, NULL, 0) - PHP_ME(swfdisplayitem, skewY, NULL, 0) - PHP_ME(swfdisplayitem, setMatrix, NULL, 0) - PHP_ME(swfdisplayitem, setDepth, NULL, 0) - PHP_ME(swfdisplayitem, setRatio, NULL, 0) - PHP_ME(swfdisplayitem, addColor, NULL, 0) - PHP_ME(swfdisplayitem, multColor, NULL, 0) - PHP_ME(swfdisplayitem, setName, NULL, 0) - PHP_ME(swfdisplayitem, addAction, NULL, 0) +/* {{{ proto string swffont::getShape(code) +Returns the glyph shape of a char as a text string */ +PHP_METHOD(swffont, getShape) +{ + int zcode; + char *result; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &zcode) == FAILURE) + WRONG_PARAM_COUNT; + + result = SWFFont_getShape(getFont(getThis() TSRMLS_CC), zcode); + RETURN_STRING(result, 1); + free(result); +} +/* }}} */ + +static zend_function_entry swffont_functions[] = { + PHP_ME(swffont, __construct, NULL, 0) + PHP_ME(swffont, getWidth, NULL, 0) #ifdef HAVE_NEW_MING - PHP_ME(swfdisplayitem, remove, NULL, 0) - PHP_ME(swfdisplayitem, setMaskLevel,NULL, 0) - PHP_ME(swfdisplayitem, endMask, NULL, 0) - PHP_ME(swfdisplayitem, getX, NULL, 0) - PHP_ME(swfdisplayitem, getY, NULL, 0) - PHP_ME(swfdisplayitem, getXScale, NULL, 0) - PHP_ME(swfdisplayitem, getYScale, NULL, 0) - PHP_ME(swfdisplayitem, getXSkew, NULL, 0) - PHP_ME(swfdisplayitem, getYSkew, NULL, 0) - PHP_ME(swfdisplayitem, getRot, NULL, 0) + PHP_ME(swffont, getUTF8Width, NULL, 0) +#endif + PHP_ME(swffont, getAscent, NULL, 0) + PHP_ME(swffont, getDescent, NULL, 0) + PHP_ME(swffont, getLeading, NULL, 0) +#ifdef HAVE_NEW_MING + PHP_ME(swffont, getGlyphCount, NULL, 0) + PHP_ME(swffont, getName, NULL, 0) #endif + PHP_ME(swffont, getShape, NULL, 0) { NULL, NULL, NULL } }; /* }}} */ -/* {{{ SWFFill +/* {{{ SWFFilterMatrix */ -/* {{{ proto void swffill::__construct() - Creates a new SWFFill object */ -PHP_METHOD(swffill, __construct) -{ - php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Instantiating SWFFill won't do any good- use SWFShape::addFill() instead"); +/* {{{ proto void swffiltermatrix::__construct(cols, rows, array:vals) + Creates a new SWFFilterMatrix object */ +PHP_METHOD(swffiltermatrix, __construct) +{ + long cols, rows; + zval *vals, **data; + SWFFilterMatrix matrix; + HashTable *arr_hash; + int ret, items, i; + float *values; + HashPosition pointer; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lla", &cols, &rows, &vals) == FAILURE) { + return; + } + + arr_hash = Z_ARRVAL_P(vals); + items = zend_hash_num_elements(arr_hash); + if(items != cols * rows) + { + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Can't create FilterMatrix." + "Not enough / too many items it array"); + } + values = (float *)malloc(items * sizeof(float)); + for(i = 0, zend_hash_internal_pointer_reset_ex(arr_hash, &pointer); + zend_hash_get_current_data_ex(arr_hash, (void**) &data, &pointer) == SUCCESS; + zend_hash_move_forward_ex(arr_hash, &pointer), i++) + { + zval temp; + temp = **data; + zval_copy_ctor(&temp); + convert_to_double(&temp); + values[i] = Z_DVAL(temp); + zval_dtor(&temp); + } + + matrix = newSWFFilterMatrix(cols, rows, values); + free(values); /* array is copied by libming */ + ret = zend_list_insert(matrix, le_swffiltermatrixp); + object_init_ex(getThis(), filtermatrix_class_entry_ptr); + add_property_resource(getThis(), "filtermatrix", ret); + zend_list_addref(ret); } -static void destroy_SWFFill_resource(zend_rsrc_list_entry *resource TSRMLS_DC) +static void destroy_SWFFilterMatrix_resource(zend_rsrc_list_entry *resource TSRMLS_DC) { - /* this only destroys the shallow wrapper for SWFFillStyle, - which SWFShape destroys. So everything's okay. I hope. */ - - destroySWFFill((SWFFill)resource->ptr); + destroySWFFilterMatrix((SWFFilterMatrix)resource->ptr); } /* }}} */ -/* {{{ internal function getFill - Returns the SWFFill object contained in zval *id */ -static SWFFill getFill(zval *id TSRMLS_DC) +/* {{{ internal function getFilterMatrix + Returns the SWFFilterMatrix object contained in zval *id */ +static SWFFilterMatrix getFilterMatrix(zval *id TSRMLS_DC) { - void *fill = SWFgetProperty(id, "fill", 4, le_swffillp TSRMLS_CC); + void *matrix = SWFgetProperty(id, "filtermatrix", strlen("filtermatrix"), le_swffiltermatrixp TSRMLS_CC); - if (!fill) { - php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Called object is not an SWFFill"); + if (!matrix) { + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFFilterMatrix"); } - return (SWFFill)fill; + return (SWFFilterMatrix)matrix; } /* }}} */ +static zend_function_entry swffiltermatrix_functions[] = { + PHP_ME(swffiltermatrix, __construct, NULL, 0) + { NULL, NULL, NULL } +}; +/* }}} */ -/* {{{ proto void swffill::moveTo(float x, float y) - Moves this SWFFill to shape coordinates (x,y) */ -PHP_METHOD(swffill, moveTo) +/* {{{ SWFShadow +*/ +/* {{{ proto void swfshadow::__construct(angle, distance, strength) + Creates a new SWFShadow object */ +PHP_METHOD(swfshadow, __construct) { - zval **x, **y; + double angle, distance, strength; + SWFShadow shadow; + int ret; - if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &x, &y) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ddd", &angle, &distance, &strength) == FAILURE) { + return; } - - convert_to_double_ex(x); - convert_to_double_ex(y); - SWFFill_moveTo(getFill(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(x), FLOAT_Z_DVAL_PP(y)); + + shadow = newSWFShadow(angle, distance, strength); + ret = zend_list_insert(shadow, le_swfshadowp); + object_init_ex(getThis(), shadow_class_entry_ptr); + add_property_resource(getThis(), "shadow", ret); + zend_list_addref(ret); } -/* }}} */ -/* {{{ proto void swffill::scaleTo(float xScale [, float yScale]) - Scales this SWFFill by xScale in the x direction, yScale in the y, or both to xScale if only one arg */ -PHP_METHOD(swffill, scaleTo) +static void destroy_SWFShadow_resource(zend_rsrc_list_entry *resource TSRMLS_DC) { - zval **x, **y; - - if (ZEND_NUM_ARGS() == 1) { - if (zend_get_parameters_ex(1, &x) == FAILURE) { - WRONG_PARAM_COUNT; - } - convert_to_double_ex(x); - SWFFill_scaleXYTo(getFill(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(x), FLOAT_Z_DVAL_PP(x)); - } else if (ZEND_NUM_ARGS() == 2) { - if (zend_get_parameters_ex(2, &x, &y) == FAILURE) { - WRONG_PARAM_COUNT; - } - convert_to_double_ex(x); - convert_to_double_ex(y); - SWFFill_scaleXYTo(getFill(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(x), FLOAT_Z_DVAL_PP(y)); - } else { - WRONG_PARAM_COUNT; - } + destroySWFShadow((SWFShadow)resource->ptr); } /* }}} */ -/* {{{ proto void swffill::rotateTo(float degrees) - Rotates this SWFFill the given (clockwise) degrees from its original orientation */ -PHP_METHOD(swffill, rotateTo) +/* {{{ internal function getShadow + Returns the SWFShadow object contained in zval *id */ +static SWFShadow getShadow(zval *id TSRMLS_DC) { - zval **degrees; + void *shadow = SWFgetProperty(id, "shadow", strlen("shadow"), le_swfshadowp TSRMLS_CC); - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, °rees) == FAILURE) { - WRONG_PARAM_COUNT; + if (!shadow) { + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFShadow"); } - convert_to_double_ex(degrees); - SWFFill_rotateTo(getFill(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(degrees)); + return (SWFShadow)shadow; } /* }}} */ +static zend_function_entry swfshadow_functions[] = { + PHP_ME(swfshadow, __construct, NULL, 0) + { NULL, NULL, NULL } +}; +/* }}} */ -/* {{{ proto void swffill::skewXTo(float xSkew) - Sets this SWFFill's x skew value to xSkew */ -PHP_METHOD(swffill, skewXTo) -{ - zval **x; +/* {{{ SWFBlur +*/ +/* {{{ proto void swfblur::__construct(blurX, blurY, passes) + Creates a new SWFBlur object */ +PHP_METHOD(swfblur, __construct) +{ + double blurX, blurY; + long passes; + SWFBlur blur; + int ret; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &x) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ddl", &blurX, &blurY, &passes) == FAILURE) { + return; } - convert_to_double_ex(x); - SWFFill_skewXTo(getFill(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(x)); + + blur = newSWFBlur(blurX, blurY, passes); + ret = zend_list_insert(blur, le_swfblurp); + object_init_ex(getThis(), blur_class_entry_ptr); + add_property_resource(getThis(), "blur", ret); + zend_list_addref(ret); +} + +static void destroy_SWFBlur_resource(zend_rsrc_list_entry *resource TSRMLS_DC) +{ + destroySWFBlur((SWFBlur)resource->ptr); } /* }}} */ -/* {{{ proto void swffill::skewYTo(float ySkew) - Sets this SWFFill's y skew value to ySkew */ -PHP_METHOD(swffill, skewYTo) +/* {{{ internal function getBlur + Returns the SWFBlur object contained in zval *id */ +static SWFBlur getBlur(zval *id TSRMLS_DC) { - zval **y; + void *blur = SWFgetProperty(id, "blur", strlen("blur"), le_swfblurp TSRMLS_CC); - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &y) == FAILURE) { - WRONG_PARAM_COUNT; + if (!blur) { + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFBlur"); } - convert_to_double_ex(y); - SWFFill_skewYTo(getFill(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(y)); + return (SWFBlur)blur; } /* }}} */ -static zend_function_entry swffill_functions[] = { - PHP_ME(swffill, __construct, NULL, 0) - PHP_ME(swffill, moveTo, NULL, 0) - PHP_ME(swffill, scaleTo, NULL, 0) - PHP_ME(swffill, rotateTo, NULL, 0) - PHP_ME(swffill, skewXTo, NULL, 0) - PHP_ME(swffill, skewYTo, NULL, 0) +static zend_function_entry swfblur_functions[] = { + PHP_ME(swfblur, __construct, NULL, 0) { NULL, NULL, NULL } }; - /* }}} */ -/* {{{ SWFFontCharacter */ -#ifdef HAVE_NEW_MING - -/* {{{ internal function SWFText getFont(zval *id) - Returns the Font object in zval *id */ -static -SWFFontCharacter getFontCharacter(zval *id TSRMLS_DC) +/* {{{ SWFGradient +*/ +/* {{{ proto void swfgradient::__construct() + Creates a new SWFGradient object */ +PHP_METHOD(swfgradient, __construct) { - void *font = SWFgetProperty(id, "fontcharacter", 13, le_swffontcharp TSRMLS_CC); + SWFGradient gradient = newSWFGradient(); + int ret = zend_list_insert(gradient, le_swfgradientp); - if(!font) - php_error(E_RECOVERABLE_ERROR, "called object is not an SWFFontCharacter!"); + object_init_ex(getThis(), gradient_class_entry_ptr); + add_property_resource(getThis(), "gradient", ret); + zend_list_addref(ret); +} - return (SWFFontCharacter)font; +static void destroy_SWFGradient_resource(zend_rsrc_list_entry *resource TSRMLS_DC) +{ + destroySWFGradient((SWFGradient)resource->ptr); } /* }}} */ -static void destroy_SWFFontCharacter_resource(zend_rsrc_list_entry *resource TSRMLS_DC) +/* {{{ internal function getGradient + Returns the SWFGradient object contained in zval *id */ +static SWFGradient getGradient(zval *id TSRMLS_DC) { - destroySWFBlock((SWFBlock)resource->ptr); + void *gradient = SWFgetProperty(id, "gradient", 8, le_swfgradientp TSRMLS_CC); + + if (!gradient) { + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFGradient"); + } + return (SWFGradient)gradient; } +/* }}} */ -/* {{{ proto void swffontcha::raddChars(string) - adds characters to a font for exporting font */ -PHP_METHOD(swffontchar, addChars) +/* {{{ proto void swfgradient::addEntry(float ratio, int r, int g, int b [, int a]) + Adds given entry to the gradient */ +PHP_METHOD(swfgradient, addEntry) { - zval **zstring; + double ratio; + long r, g, b, a = 0xff; - if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zstring) == FAILURE) - WRONG_PARAM_COUNT; - - convert_to_string_ex(zstring); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dlll|l", &ratio, &r, &g, &b, &a) == FAILURE) { + return; + } - SWFFontCharacter_addChars(getFontCharacter(getThis() TSRMLS_CC), Z_STRVAL_PP(zstring)); + SWFGradient_addEntry( getGradient(getThis() TSRMLS_CC), ratio, (byte)r, (byte)g, (byte)b, (byte)a); } /* }}} */ -/* {{{ proto void swffontchar::addChars(string) - adds characters to a font for exporting font */ +/* {{{ proto void swfgradient::setSpreadMode(mode) + supported mode values: + * SWF_GRADIENT_PAD + * SWF_GRADIENT_REFLECT + * SWF_GRADIENT_REPEAT +*/ +PHP_METHOD(swfgradient, setSpreadMode) +{ + long val; -PHP_METHOD(swffontchar, addUTF8Chars) + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &val) == FAILURE) { + return; + } + + SWFGradient_setSpreadMode(getGradient(getThis() TSRMLS_CC), val); +} +/* }}} */ + +/* {{{ proto void swfgradient::setInterpolationMode(mode) + * supported mode values: + * SWF_GRADIENT_NORMAL + * SWF_GRADIENT_LINEAR +*/ +PHP_METHOD(swfgradient, setInterpolationMode) { - zval **zstring; + long val; - if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zstring) == FAILURE) - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &val) == FAILURE) { + return; + } + + SWFGradient_setInterpolationMode(getGradient(getThis() TSRMLS_CC), val); +} +/* }}} */ + +/* {{{ proto void swfgradient::setFocalPoint(mode) */ +PHP_METHOD(swfgradient, setFocalPoint) +{ + long val; - convert_to_string_ex(zstring); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &val) == FAILURE) { + return; + } - SWFFontCharacter_addUTF8Chars(getFontCharacter(getThis() TSRMLS_CC), Z_STRVAL_PP(zstring)); + SWFGradient_setFocalPoint(getGradient(getThis() TSRMLS_CC), val); } /* }}} */ -static zend_function_entry swffontchar_functions[] = { - PHP_ME(swffontchar, addChars, NULL, 0) - PHP_ME(swffontchar, addUTF8Chars, NULL, 0) +static zend_function_entry swfgradient_functions[] = { + PHP_ME(swfgradient, __construct, NULL, 0) + PHP_ME(swfgradient, addEntry, NULL, 0) + PHP_ME(swfgradient, setSpreadMode, NULL, 0) + PHP_ME(swfgradient, setInterpolationMode, NULL, 0) + PHP_ME(swfgradient, setFocalPoint, NULL, 0) { NULL, NULL, NULL } }; - -#endif /* }}} */ -/* {{{ SWFFont +/* {{{ SWFFilter */ -/* {{{ internal function SWFText getFont(zval *id) - Returns the Font object in zval *id */ -static SWFFont getFont(zval *id TSRMLS_DC) -{ - void *font = SWFgetProperty(id, "font", 4, le_swffontp TSRMLS_CC); - if (!font) { - php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Called object is not an SWFFont"); - } - return (SWFFont)font; +/* helper functions */ +static SWFColor hashToColor(zval **colorHash TSRMLS_DC) +{ + zval **data; + HashPosition pointer; + HashTable *arr_hash; + SWFColor c; + + c.alpha = 0xff; + c.red = 0; + c.green = 0; + c.blue = 0; + + arr_hash = Z_ARRVAL_PP(colorHash); + if(zend_hash_num_elements(arr_hash) < 3 || zend_hash_num_elements(arr_hash) > 4) + php_error_docref(NULL TSRMLS_CC, E_ERROR, "not a valid colorHash\n"); + + for(zend_hash_internal_pointer_reset_ex(arr_hash, &pointer); + zend_hash_get_current_data_ex(arr_hash, (void**) &data, &pointer) == SUCCESS; + zend_hash_move_forward_ex(arr_hash, &pointer)) + { + zval temp; + char *key; + unsigned int key_len; + unsigned long index; + + temp = **data; + if (zend_hash_get_current_key_ex(arr_hash, &key, &key_len, &index, 0, &pointer) + == HASH_KEY_IS_STRING) + { + zval_copy_ctor(&temp); + convert_to_long(&temp); + if(strcmp(key, "red") == 0) + c.red = Z_LVAL(temp); + else if (strcmp(key, "green") == 0) + c.green = Z_LVAL(temp); + else if (strcmp(key, "blue") == 0) + c.blue = Z_LVAL(temp); + else if (strcmp(key, "alpha") == 0) + c.alpha = Z_LVAL(temp); + else + php_error_docref(NULL TSRMLS_CC, E_ERROR, "not a valid colorHash\n"); + + zval_dtor(&temp); + } + } + return c; } -/* }}} */ -/* {{{ proto void swffont::__construct(string filename) - Creates a new SWFFont object from given file */ -PHP_METHOD(swffont, __construct) +static SWFFilter createDropShadowFilter(int argc, zval **argv[] TSRMLS_DC) { - zval **zfile; - SWFFont font; - int ret; + zval **colorHash, **blur, **shadow, **flags; + SWFColor c; + + if(argc != 5) + return NULL; + + colorHash = argv[1]; + convert_to_array_ex(colorHash); + c = hashToColor(colorHash TSRMLS_CC); + + blur = argv[2]; + convert_to_object_ex(blur); + + shadow = argv[3]; + convert_to_object_ex(shadow); - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zfile) == FAILURE) { - WRONG_PARAM_COUNT; - } + flags = argv[4]; + convert_to_long_ex(flags); - convert_to_string_ex(zfile); + return newDropShadowFilter(c, getBlur(*blur TSRMLS_CC), + getShadow(*shadow TSRMLS_CC), Z_LVAL_PP(flags)); +} - if (strcmp(Z_STRVAL_PP(zfile)+Z_STRLEN_PP(zfile)-4, ".fdb") == 0) { - php_stream * stream; - FILE * file; +static SWFFilter createBlurFilter(int argc, zval **argv[] TSRMLS_DC) +{ + zval **blur; - stream = php_stream_open_wrapper(Z_STRVAL_PP(zfile), "rb", REPORT_ERRORS|ENFORCE_SAFE_MODE, NULL); + if(argc != 2) + return NULL; - if (stream == NULL) { - RETURN_FALSE; - } + blur = argv[1]; + convert_to_object_ex(blur); + + return newBlurFilter(getBlur(*blur TSRMLS_CC)); +} - if (FAILURE == php_stream_cast(stream, PHP_STREAM_AS_STDIO, (void*)&file, REPORT_ERRORS)) { - php_stream_close(stream); - RETURN_FALSE; - } +static SWFFilter createGlowFilter(int argc, zval **argv[] TSRMLS_DC) +{ + zval **color, **blur, **strength, **flags; + SWFColor c; - font = loadSWFFontFromFile(file); - php_stream_close(stream); - } else { - PHP_MING_FILE_CHK(Z_STRVAL_PP(zfile)); - font = (SWFFont)newSWFBrowserFont(Z_STRVAL_PP(zfile)); - } + if(argc != 5) + return NULL; + + color = argv[1]; + convert_to_array_ex(color); + c = hashToColor(color TSRMLS_CC); - ret = zend_list_insert(font, le_swffontp); + blur = argv[2]; + convert_to_object_ex(blur); - object_init_ex(getThis(), font_class_entry_ptr); - add_property_resource(getThis(), "font", ret); - zend_list_addref(ret); -} + strength = argv[3]; + convert_to_double_ex(strength); + + flags = argv[4]; + convert_to_long_ex(flags); -static void destroy_SWFFont_resource(zend_rsrc_list_entry *resource TSRMLS_DC) -{ - destroySWFBlock((SWFBlock)resource->ptr); + return newGlowFilter(c, getBlur(*blur TSRMLS_CC), + Z_DVAL_PP(strength), Z_LVAL_PP(flags)); } -/* }}} */ -/* {{{ proto float swffont::getWidth(string str) - Calculates the width of the given string in this font at full height */ -PHP_METHOD(swffont, getWidth) +static SWFFilter createBevelFilter(int argc, zval **argv[] TSRMLS_DC) { - zval **zstring; - float width; + zval **sColor, **hColor, **blur, **shadow, **flags; + SWFColor hc, sc; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zstring) == FAILURE) { - WRONG_PARAM_COUNT; - } - convert_to_string_ex(zstring); - width = SWFFont_getStringWidth(getFont(getThis() TSRMLS_CC), Z_STRVAL_PP(zstring)); - RETURN_DOUBLE(width); -} -/* }}} */ + if(argc != 6) + return NULL; -#ifdef HAVE_NEW_MING -/* {{{ proto int swffont::getUTF8Width(string) - Calculates the width of the given string in this font at full height */ + sColor = argv[1]; + convert_to_array_ex(sColor); + sc = hashToColor(sColor TSRMLS_CC); -PHP_METHOD(swffont, getUTF8Width) -{ - zval **zstring; - float width; + hColor = argv[2]; + convert_to_array_ex(hColor); + hc = hashToColor(hColor TSRMLS_CC); - if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zstring) == FAILURE) - WRONG_PARAM_COUNT; + blur = argv[3]; + convert_to_object_ex(blur); - convert_to_string_ex(zstring); + shadow = argv[4]; + convert_to_object_ex(shadow); - width = SWFFont_getUTF8StringWidth(getFont(getThis() TSRMLS_CC), Z_STRVAL_PP(zstring)); + flags = argv[5]; + convert_to_long_ex(flags); - RETURN_DOUBLE(width); + return newBevelFilter(sc, hc, getBlur(*blur TSRMLS_CC), + getShadow(*shadow TSRMLS_CC), Z_LVAL_PP(flags)); } -/* }}} */ -/* not sure about 0 bytes !!!!!!!!! */ -/* {{{ proto int swffont::getWideWidth(string) - Calculates the width of the given string in this font at full height */ -/* -PHP_METHOD(swffont, getWideWidth) +static SWFFilter createGradientGlowFilter(int argc, zval **argv[] TSRMLS_DC) { - zval **zstring; - float width; + zval **gradient, **blur, **shadow, **flags; - if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zstring) == FAILURE) - WRONG_PARAM_COUNT; + if(argc != 5) + return NULL; - convert_to_string_ex(zstring); + gradient = argv[1]; + convert_to_object_ex(gradient); - width = SWFFont_getWideStringWidth(getFont(getThis() TSRMLS_CC), Z_STRVAL_PP(zstring)); + blur = argv[2]; + convert_to_object_ex(blur); + + shadow = argv[3]; + convert_to_object_ex(shadow); - RETURN_DOUBLE(width); -} -*/ -/* }}} */ -#endif + flags = argv[4]; + convert_to_long_ex(flags); -/* {{{ proto float swffont::getAscent() - Returns the ascent of the font, or 0 if not available */ -PHP_METHOD(swffont, getAscent) -{ - if(ZEND_NUM_ARGS() != 0) { - WRONG_PARAM_COUNT; - } - RETURN_DOUBLE(SWFFont_getAscent(getFont(getThis() TSRMLS_CC))); + return newGradientGlowFilter(getGradient(*gradient TSRMLS_CC), + getBlur(*blur TSRMLS_CC), getShadow(*shadow TSRMLS_CC), + Z_LVAL_PP(flags)); } -/* }}} */ -/* {{{ proto float swffont::getDescent() - Returns the descent of the font, or 0 if not available */ -PHP_METHOD(swffont, getDescent) +static SWFFilter createConvolutionFilter(int argc, zval **argv[] TSRMLS_DC) { - if(ZEND_NUM_ARGS() != 0) { - WRONG_PARAM_COUNT; - } - RETURN_DOUBLE(SWFFont_getDescent(getFont(getThis() TSRMLS_CC))); -} -/* }}} */ + zval **matrix, **div, **bias, **color, **flags; + SWFColor c; -/* {{{ proto float swffont::getLeading() - Returns the leading of the font, or 0 if not available */ -PHP_METHOD(swffont, getLeading) -{ - if(ZEND_NUM_ARGS() != 0) { - WRONG_PARAM_COUNT; - } - RETURN_DOUBLE(SWFFont_getLeading(getFont(getThis() TSRMLS_CC))); -} -/* }}} */ + if(argc != 6) + return NULL; -#ifdef HAVE_NEW_MING -/* {{{ proto void swffont::addChars(string) - adds characters to a font required within textfields */ -/* -PHP_METHOD(swffont, addChars) -{ - zval **zstring; + matrix = argv[1]; + convert_to_object_ex(matrix); - if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zstring) == FAILURE) - WRONG_PARAM_COUNT; + div = argv[2]; + convert_to_double_ex(div); - convert_to_string_ex(zstring); + bias = argv[3]; + convert_to_double_ex(bias); - SWFFont_addChars(getFont(getThis() TSRMLS_CC), Z_STRVAL_PP(zstring)); + color = argv[4]; + convert_to_array_ex(color); + c = hashToColor(color TSRMLS_CC); + + flags = argv[5]; + convert_to_long_ex(flags); + + return newConvolutionFilter(getFilterMatrix(*matrix TSRMLS_CC), Z_DVAL_PP(div), + Z_DVAL_PP(bias), c, Z_LVAL_PP(flags)); } -*/ -/* }}} */ -/* {{{ proto string swffont::getShape(code) - Returns the glyph shape of a char as a text string */ -PHP_METHOD(swffont, getShape) +static SWFFilter createColorMatrixFilter(int argc, zval **argv[] TSRMLS_DC) { - zval **zcode; - char *result; + zval **matrix; - if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zcode) == FAILURE) - WRONG_PARAM_COUNT; + if(argc != 2) + return NULL; - convert_to_long_ex(zcode); + matrix = argv[1]; + convert_to_object_ex(matrix); - result = SWFFont_getShape(getFont(getThis() TSRMLS_CC), Z_LVAL_PP(zcode)); - RETVAL_STRING(result, 1); - free(result); + return newColorMatrixFilter(getFilterMatrix(*matrix TSRMLS_CC)); } -/* }}} */ -#endif +static SWFFilter createGradientBevelFilter(int argc, zval **argv[] TSRMLS_DC) +{ + zval **gradient, **blur, **shadow, **flags; -static zend_function_entry swffont_functions[] = { - PHP_ME(swffont, __construct, NULL, 0) - PHP_ME(swffont, getWidth, NULL, 0) -#ifdef HAVE_NEW_MING - PHP_ME(swffont, getUTF8Width, NULL, 0) -/* PHP_ME(swffont, getwidewidth, NULL, 0)*/ -#endif - PHP_ME(swffont, getAscent, NULL, 0) - PHP_ME(swffont, getDescent, NULL, 0) - PHP_ME(swffont, getLeading, NULL, 0) -#ifdef HAVE_NEW_MING -/* PHP_ME(swffont, addchars, NULL, 0)*/ - PHP_ME(swffont, getShape, NULL, 0) -#endif - { NULL, NULL, NULL } -}; + if(argc != 5) + return NULL; -/* }}} */ + gradient = argv[1]; + convert_to_object_ex(gradient); -/* {{{ SWFGradient + blur = argv[2]; + convert_to_object_ex(blur); + + shadow = argv[3]; + convert_to_object_ex(shadow); + + flags = argv[4]; + convert_to_long_ex(flags); + + return newGradientBevelFilter(getGradient(*gradient TSRMLS_CC), + getBlur(*blur TSRMLS_CC), getShadow(*shadow TSRMLS_CC), + Z_LVAL_PP(flags)); +} + +/* {{{ proto void swffilter::__construct(type, ...) + Creates a new SWFFilter object: + + Supported filter types: + * SWFFILTER_TYPE_DROPSHADOW + new SWFFilter(SWFFILTER_TYPE_DROPSHADOW, colorHash, blur, shadow, flags); + * SWFFILTER_TYPE_BLUR + new SWFFilter(SWFFILTER_TYPE_BLUR, blur); + * SWFFILTER_TYPE_GLOW + new SWFFilter(SWFFILTER_TYPE_GLOW, colorHash, blur, strenght:float, flags); + * SWFFILTER_TYPE_BEVEL + new SWFFilter(SWFFILTER_TYPE_BEVEL, colorHash_shadow, colorHash_highlight, blur, shadow, flags); + * SWFFILTER_TYPE_GRADIENTGLOW + new SWFFilter(SWFFILTER_TYPE_GRADIENTGLOW, gradient, blur, shadow, flags); + * SWFFILTER_TYPE_CONVOLUTION + new SWFFilter(SWFFILTER_TYPE_CONVOLUTION, filterMatrix, divisor:float, bias:float, colorHash, flags); + * SWFFILTER_TYPE_COLORMATRIX + new SWFFilter(SWFFILTER_TYPE_COLORMATRIX, filterMatrix); + * SWFFILTER_TYPE_GRADIENTBEVEL + new SWFFilter(SWFFILTER_TYPE_GRADIENTBEVEL, gradient, blur, shadow, flags); + + Supported flags are: + * SWFFILTER_FLAG_CLAMP + * SWFFILTER_FLAG_PRESERVE_ALPHA + * SWFFILTER_MODE_INNER + * SWFFILTER_MODE_KO + + A colorHash must have the following entries: + 'red' => 0...255, + 'green' => 0...255, + 'blue' => 0...255, + 'alpha' => 0...255 (optional) */ -/* {{{ proto void swfgradient::__construct() - Creates a new SWFGradient object */ -PHP_METHOD(swfgradient, __construct) +PHP_METHOD(swffilter, __construct) { - SWFGradient gradient = newSWFGradient(); - int ret = zend_list_insert(gradient, le_swfgradientp); + zval **argv[6]; + int argc = ZEND_NUM_ARGS(); + int type, ret; + SWFFilter filter = NULL; + + if (argc > 6 || argc < 2 || zend_get_parameters_array_ex(argc, argv) == FAILURE) + WRONG_PARAM_COUNT; + - object_init_ex(getThis(), gradient_class_entry_ptr); - add_property_resource(getThis(), "gradient", ret); - zend_list_addref(ret); -} + convert_to_long_ex(argv[0]); + type = Z_LVAL_PP(argv[0]); + switch(type) + { + case SWFFILTER_TYPE_DROPSHADOW: + filter = createDropShadowFilter(argc, argv TSRMLS_CC); + break; + case SWFFILTER_TYPE_BLUR: + filter = createBlurFilter(argc, argv TSRMLS_CC); + break; + case SWFFILTER_TYPE_GLOW: + filter = createGlowFilter(argc, argv TSRMLS_CC); + break; + case SWFFILTER_TYPE_BEVEL: + filter = createBevelFilter(argc, argv TSRMLS_CC); + break; + case SWFFILTER_TYPE_GRADIENTGLOW: + filter = createGradientGlowFilter(argc, argv TSRMLS_CC); + break; + case SWFFILTER_TYPE_CONVOLUTION: + filter = createConvolutionFilter(argc, argv TSRMLS_CC); + break; + case SWFFILTER_TYPE_COLORMATRIX: + filter = createColorMatrixFilter(argc, argv TSRMLS_CC); + break; + case SWFFILTER_TYPE_GRADIENTBEVEL: + filter = createGradientBevelFilter(argc, argv TSRMLS_CC); + break; + default: + php_error_docref(NULL TSRMLS_CC, E_ERROR, "new SWFFilter: unknown type"); + } + + if(filter == NULL) + WRONG_PARAM_COUNT; -static void destroy_SWFGradient_resource(zend_rsrc_list_entry *resource TSRMLS_DC) -{ - destroySWFGradient((SWFGradient)resource->ptr); + ret = zend_list_insert(filter, le_swffilterp); + object_init_ex(getThis(), filter_class_entry_ptr); + add_property_resource(getThis(), "filter", ret); + zend_list_addref(ret); } /* }}} */ -/* {{{ internal function getGradient - Returns the SWFGradient object contained in zval *id */ -static SWFGradient getGradient(zval *id TSRMLS_DC) +/* {{{ internal function getFilter + Returns the SWFFilter object contained in zval *id */ +static SWFFilter getFilter(zval *id TSRMLS_DC) { - void *gradient = SWFgetProperty(id, "gradient", 8, le_swfgradientp TSRMLS_CC); + void *filter = SWFgetProperty(id, "filter", + strlen("filter"), le_swffilterp TSRMLS_CC); - if (!gradient) { - php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Called object is not an SWFGradient"); + if (!filter) { + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFFilter"); } - return (SWFGradient)gradient; + return (SWFFilter)filter; } /* }}} */ -/* {{{ proto void swfgradient::addEntry(float ratio, int r, int g, int b [, int a]) - Adds given entry to the gradient */ -PHP_METHOD(swfgradient, addEntry) +static void destroy_SWFFilter_resource(zend_rsrc_list_entry *resource TSRMLS_DC) { - zval **ratio, **r, **g, **b; - byte a = 0xff; - - if (ZEND_NUM_ARGS() == 4) { - if (zend_get_parameters_ex(4, &ratio, &r, &g, &b) == FAILURE) { - WRONG_PARAM_COUNT; - } - } else if (ZEND_NUM_ARGS() == 5) { - zval **za; - - if (zend_get_parameters_ex(5, &ratio, &r, &g, &b, &za) == FAILURE) { - WRONG_PARAM_COUNT; - } - convert_to_long_ex(za); - a = BYTE_Z_LVAL_PP(za); - } else { - WRONG_PARAM_COUNT; - } - - convert_to_double_ex(ratio); - convert_to_long_ex(r); - convert_to_long_ex(g); - convert_to_long_ex(b); - - SWFGradient_addEntry( getGradient(getThis() TSRMLS_CC), - FLOAT_Z_DVAL_PP(ratio), BYTE_Z_LVAL_PP(r), BYTE_Z_LVAL_PP(g), BYTE_Z_LVAL_PP(b), a - ); + destroySWFFilter((SWFFilter)resource->ptr); } -/* }}} */ -static zend_function_entry swfgradient_functions[] = { - PHP_ME(swfgradient, __construct, NULL, 0) - PHP_ME(swfgradient, addEntry, NULL, 0) +static zend_function_entry swffilter_functions[] = { + PHP_ME(swffilter, __construct, NULL, 0) { NULL, NULL, NULL } }; - /* }}} */ /* {{{ SWFMorph @@ -1735,7 +3114,7 @@ void *morph = SWFgetProperty(id, "morph", 5, le_swfmorphp TSRMLS_CC); if (!morph) { - php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Called object is not an SWFMorph"); + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFMorph"); } return (SWFMorph)morph; } @@ -1778,6 +3157,91 @@ /* }}} */ +/* {{{ SWFSoundStream + */ + +/* {{{ proto class soundstream::init(file) */ +PHP_METHOD(swfsoundstream, __construct) +{ + zval *zfile; + SWFSoundStream sound = NULL; + SWFInput input = NULL; + int ret; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &zfile) == FAILURE) { + return; + } + + switch(Z_TYPE_P(zfile)) + { + case IS_RESOURCE: + input = getInput_fromFileResource(zfile TSRMLS_CC); + break; + case IS_OBJECT: + input = getInput(zfile TSRMLS_CC); + break; + case IS_STRING: + input = newSWFInput_filename(Z_STRVAL_P(zfile)); + if(input == NULL) + php_error(E_ERROR, "opening sound file failed"); + zend_list_addref(zend_list_insert(input, le_swfinputp)); + break; + + default: + php_error(E_ERROR, "soundstream::init: need either a filename, " + "a file ressource or SWFInput buffer."); + } + + sound = newSWFSoundStream_fromInput(input); + + if(sound) { + ret = zend_list_insert(sound, le_swfsoundstreamp); + object_init_ex(getThis(), soundstream_class_entry_ptr); + add_property_resource(getThis(), "soundstream", ret); + zend_list_addref(ret); + } +} +/* }}} */ + +/* {{{ internal function getSoundStream + Returns the SWFSoundStream object contained in zval *id */ +static SWFSoundStream getSoundStream(zval *id TSRMLS_DC) +{ + void *sound = SWFgetProperty(id, "soundstream", strlen("soundstream"), + le_swfsoundstreamp TSRMLS_CC); + if(!sound) + php_error(E_ERROR, "called object is not an SWFSoundStream!"); + return (SWFSoundStream)sound; +} +/* }}} */ + +/* {{{ internal function destroy_SWFSoundStream */ +static void destroy_SWFSoundStream_resource(zend_rsrc_list_entry *resource TSRMLS_DC) +{ + destroySWFSoundStream((SWFSoundStream)resource->ptr); +} +/* }}} */ + +/* {{{ + returns the duration of the sound stream */ +PHP_METHOD(swfsoundstream, getDuration) +{ + if (ZEND_NUM_ARGS() != 0) { + WRONG_PARAM_COUNT; + } + + RETURN_LONG(SWFSoundStream_getDuration(getSoundStream(getThis() TSRMLS_CC))); +} +/* }}} */ + + +static zend_function_entry swfsoundstream_functions[] = { + PHP_ME(swfsoundstream, __construct, NULL, 0) + PHP_ME(swfsoundstream, getDuration, NULL, 0) + { NULL, NULL, NULL } +}; +/* }}} */ + /* {{{ SWFSound */ /* {{{ internal function SWFSound getSound(zval *id) Returns the Sound object in zval *id */ @@ -1787,59 +3251,66 @@ void *sound = SWFgetProperty(id, "sound", 5, le_swfsoundp TSRMLS_CC); if(!sound) - php_error(E_RECOVERABLE_ERROR, "called object is not an SWFSound!"); + php_error(E_ERROR, "called object is not an SWFSound!"); return (SWFSound)sound; } /* }}} */ -/* {{{ proto void swfsound::__construct(string filename, int flags) - Creates a new SWFSound object from given file */ +/* {{{ proto void swfsound::__construct(string filename/SWFInput/SWFSoundstream[, int flags]) + Creates a new SWFSound object from given file + Takes either a Filename or SWFInput memory buffer AND flags or + a SWFSoundStream object with NO flags. +*/ PHP_METHOD(swfsound, __construct) { - zval **zfile, **zflags; - SWFSound sound; - SWFInput input; - int flags; + zval *zfile; + long flags; + SWFSound sound = NULL; + SWFInput input = NULL; + SWFSoundStream stream; int ret; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|l", &zfile, &flags) == FAILURE) { + return; + } + if(ZEND_NUM_ARGS() == 1) { - if(zend_get_parameters_ex(1, &zfile) == FAILURE) - WRONG_PARAM_COUNT; - flags = 0; + stream = getSoundStream(zfile TSRMLS_CC); + sound = newSWFSound_fromSoundStream(stream); } else if(ZEND_NUM_ARGS() == 2) { - if(zend_get_parameters_ex(2, &zfile, &zflags) == FAILURE) - WRONG_PARAM_COUNT; - convert_to_long_ex(zflags); - flags = Z_LVAL_PP(zflags); - } - else - WRONG_PARAM_COUNT; + switch(Z_TYPE_P(zfile)) + { + case IS_RESOURCE: + input = getInput_fromFileResource(zfile TSRMLS_CC); + break; + case IS_OBJECT: + input = getInput(zfile TSRMLS_CC); + break; + case IS_STRING: + input = newSWFInput_filename(Z_STRVAL_P(zfile)); + if(input == NULL) + php_error(E_ERROR, "opening sound file failed"); + zend_list_addref(zend_list_insert(input, le_swfinputp)); + break; - if(Z_TYPE_PP(zfile) != IS_RESOURCE) - { - convert_to_string_ex(zfile); - PHP_MING_FILE_CHK(Z_STRVAL_PP(zfile)); - input = newSWFInput_buffer(Z_STRVAL_PP(zfile), Z_STRLEN_PP(zfile)); - zend_list_addref(zend_list_insert(input, le_swfinputp)); + default: + php_error(E_ERROR, "swfsound::__construct: need either a filename, " + "a file ressource or SWFInput buffer."); + } + sound = newSWFSound_fromInput(input, flags); } - else - input = getInput(zfile TSRMLS_CC); - -#ifdef HAVE_NEW_MING - sound = newSWFSound_fromInput(input, flags); -#else - sound = newSWFSound_fromInput(input); -#endif - - ret = zend_list_insert(sound, le_swfsoundp); - object_init_ex(getThis(), sound_class_entry_ptr); - add_property_resource(getThis(), "sound", ret); - zend_list_addref(ret); + if(sound != NULL) + { + ret = zend_list_insert(sound, le_swfsoundp); + object_init_ex(getThis(), sound_class_entry_ptr); + add_property_resource(getThis(), "sound", ret); + zend_list_addref(ret); + } } static void destroy_SWFSound_resource(zend_rsrc_list_entry *resource TSRMLS_DC) @@ -1856,7 +3327,6 @@ /* }}} */ -/* {{{ SWFSoundInstance */ #ifdef HAVE_NEW_MING /* should handle envelope functions */ /* {{{ internal function SWFSoundInstance getSoundInstance(zval *id) @@ -1867,7 +3337,7 @@ void *inst = SWFgetProperty(id, "soundinstance", 13, le_swfsoundinstancep TSRMLS_CC); if (!inst) - php_error(E_RECOVERABLE_ERROR, "called object is not an SWFSoundInstance!"); + php_error(E_ERROR, "called object is not an SWFSoundInstance!"); return (SWFSoundInstance)inst; } @@ -1890,31 +3360,32 @@ PHP_METHOD(swfsoundinstance, loopInPoint) { - zval **zpoint; - SWFSoundInstance inst = getSoundInstance(getThis() TSRMLS_CC); + long point; - if((ZEND_NUM_ARGS() != 1) || zend_get_parameters_ex(1, &zpoint) == FAILURE) - WRONG_PARAM_COUNT; + SWFSoundInstance inst = getSoundInstance(getThis() TSRMLS_CC); - convert_to_long_ex(zpoint); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &point) == FAILURE) { + return; + } - SWFSoundInstance_setLoopInPoint(inst, Z_LVAL_PP(zpoint)); + SWFSoundInstance_setLoopInPoint(inst, point); } /* }}} */ + /* {{{ swfsoundinstance_loopoutpoint(point) */ PHP_METHOD(swfsoundinstance, loopOutPoint) { - zval **zpoint; - SWFSoundInstance inst = getSoundInstance(getThis() TSRMLS_CC); + long point; - if((ZEND_NUM_ARGS() != 1) || zend_get_parameters_ex(1, &zpoint) == FAILURE) - WRONG_PARAM_COUNT; + SWFSoundInstance inst = getSoundInstance(getThis() TSRMLS_CC); - convert_to_long_ex(zpoint); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &point) == FAILURE) { + return; + } - SWFSoundInstance_setLoopOutPoint(inst, Z_LVAL_PP(zpoint)); + SWFSoundInstance_setLoopOutPoint(inst, point); } /* }}} */ @@ -1922,15 +3393,14 @@ PHP_METHOD(swfsoundinstance, loopCount) { - zval **zcount; + long count; SWFSoundInstance inst = getSoundInstance(getThis() TSRMLS_CC); - if((ZEND_NUM_ARGS() != 1) || zend_get_parameters_ex(1, &zcount) == FAILURE) - WRONG_PARAM_COUNT; - - convert_to_long_ex(zcount); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &count) == FAILURE) { + return; + } - SWFSoundInstance_setLoopCount(inst, Z_LVAL_PP(zcount)); + SWFSoundInstance_setLoopCount(inst, count); } /* }}} */ @@ -1944,38 +3414,48 @@ /* {{{ SWFVideoStream */ -/* {{{ proto class swfvideostream_init([file]) +/* {{{ proto class swfvideostream_init([filename]) Returns a SWVideoStream object */ - PHP_METHOD(swfvideostream, __construct) { - zval **zfile = NULL; + zval *zfile = NULL; SWFVideoStream stream; - SWFInput input; + SWFInput input = NULL; int ret; - switch(ZEND_NUM_ARGS()) { - case 1: - if(zend_get_parameters_ex(1, &zfile) == FAILURE) - 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); - - stream = newSWFVideoStream_fromInput(input); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|z", &zfile) == FAILURE) { + return; + } + switch(ZEND_NUM_ARGS()) + { + case 1: + + switch(Z_TYPE_P(zfile)) + { + case IS_RESOURCE: + input = getInput_fromFileResource(zfile TSRMLS_CC); break; - case 0: - stream = newSWFVideoStream(); + case IS_OBJECT: + input = getInput(zfile TSRMLS_CC); + break; + case IS_STRING: + input = newSWFInput_filename(Z_STRVAL_P(zfile)); + if(input == NULL) + php_error(E_ERROR, "opening sound video failed"); + zend_list_addref(zend_list_insert(input, le_swfinputp)); break; + default: - WRONG_PARAM_COUNT; - break; + php_error(E_ERROR, "swfvideostream_init: need either a filename, " + "a file ressource or SWFInput buffer."); + } + stream = newSWFVideoStream_fromInput(input); + break; + case 0: + stream = newSWFVideoStream(); + break; + default: /* warn */ + return; } if(stream) { @@ -1984,7 +3464,6 @@ add_property_resource(getThis(), "videostream", ret); zend_list_addref(ret); } - } static void destroy_SWFVideoStream_resource(zend_rsrc_list_entry *resource TSRMLS_DC) @@ -1995,14 +3474,11 @@ /* {{{ internal function getVideoStream Returns the SWFVideoStream object contained in zval *id */ - static SWFVideoStream getVideoStream(zval *id TSRMLS_DC) { void *stream = SWFgetProperty(id, "videostream", 11, le_swfvideostreamp TSRMLS_CC); - if(!stream) - php_error(E_RECOVERABLE_ERROR, "called object is not an SWFVideoStream!"); - + php_error(E_ERROR, "called object is not an SWFVideoStream!"); return (SWFVideoStream)stream; } @@ -2012,80 +3488,194 @@ PHP_METHOD(swfvideostream, setdimension) { - zval **x, **y; + long x, y; SWFVideoStream stream = getVideoStream(getThis() TSRMLS_CC); if(!stream) - php_error(E_RECOVERABLE_ERROR, "getVideoSTream returned NULL"); - - if( ZEND_NUM_ARGS() != 2 - || zend_get_parameters_ex(2, &x, &y) == FAILURE ) - WRONG_PARAM_COUNT; + php_error(E_ERROR, "getVideoStream returned NULL"); - convert_to_long_ex(x); - convert_to_long_ex(y); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &x, &y) == FAILURE) { + return; + } - SWFVideoStream_setDimension(stream, Z_LVAL_PP(x), Z_LVAL_PP(y)); + SWFVideoStream_setDimension(stream, x, y); } /* }}} */ /* {{{ getNumFrames */ PHP_METHOD(swfvideostream, getnumframes) { - if(ZEND_NUM_ARGS() != 0) + if (ZEND_NUM_ARGS() != 0) { WRONG_PARAM_COUNT; + } RETURN_LONG(SWFVideoStream_getNumFrames(getVideoStream(getThis() TSRMLS_CC))); } /* }}} */ - - + +/* {{{ hasAudio */ +PHP_METHOD(swfvideostream, hasaudio) +{ + if (ZEND_NUM_ARGS() != 0) { + WRONG_PARAM_COUNT; + } + + RETURN_LONG(SWFVideoStream_hasAudio(getVideoStream(getThis() TSRMLS_CC))); +} +/* }}} */ + +#if HAVE_SWFVIDEOSTREAM_NEXTFRAME +/* {{{ proto swfvideostream::nextFrame */ +PHP_METHOD(swfvideostream, nextFrame) +{ + if (ZEND_NUM_ARGS() != 0) { + WRONG_PARAM_COUNT; + } + + RETURN_LONG(SWFVideoStream_nextFrame(getVideoStream(getThis() TSRMLS_CC))); +} +/* }}} */ +#endif + +#if HAVE_SWFVIDEOSTREAM_SETFRAMEMODE +/* {{{ proto swfvideostream::setFrameMode */ +PHP_METHOD(swfvideostream, setFrameMode) +{ + long mode; + SWFVideoStream stream = getVideoStream(getThis() TSRMLS_CC); + if(!stream) + php_error(E_ERROR, "getVideoStream returned NULL"); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &mode) == FAILURE) { + return; + } + + RETURN_LONG(SWFVideoStream_setFrameMode(stream, mode)); +} +/* }}} */ +#endif + +#if HAVE_SWFVIDEOSTREAM_SEEK +/* {{{ proto swfvideostream::seek(frame, whence) */ +PHP_METHOD(swfvideostream, seek) +{ + long frame, whence; + SWFVideoStream stream = getVideoStream(getThis() TSRMLS_CC); + if(!stream) + php_error(E_ERROR, "getVideoStream returned NULL"); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &frame, &whence) == FAILURE) { + return; + } + + RETURN_LONG(SWFVideoStream_seek(stream, frame, whence)); +} +/* }}} */ +#endif + static zend_function_entry swfvideostream_functions[] = { PHP_ME(swfvideostream, __construct, NULL, 0) PHP_ME(swfvideostream, setdimension, NULL, 0) PHP_ME(swfvideostream, getnumframes, NULL, 0) + PHP_ME(swfvideostream, hasaudio, NULL, 0) +#if HAVE_SWFVIDEOSTREAM_SETFRAMEMODE + PHP_ME(swfvideostream, setFrameMode, NULL, 0) +#endif +#if HAVE_SWFVIDEOSTREAM_NEXTFRAME + PHP_ME(swfvideostream, nextFrame, NULL, 0) +#endif +#if HAVE_SWFVIDEOSTREAM_SEEK + PHP_ME(swfvideostream, seek, NULL, 0) +#endif { NULL, NULL, NULL } }; /* }}} */ -#endif -#ifdef HAVE_SWFPREBUILTCLIP +/* {{{ SWFBinaryData + */ + +/* {{{ proto class swfbinarydata_init(string) + Returns a SWFBinaryData object */ +PHP_METHOD(swfbinarydata, __construct) +{ + char *data; + int data_len; + SWFBinaryData bd = NULL; + int ret; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &data, &data_len) == FAILURE) { + return; + } + bd = newSWFBinaryData((unsigned char *)data, data_len); + + if(bd) { + ret = zend_list_insert(bd, le_swfbinarydatap); + object_init_ex(getThis(), binarydata_class_entry_ptr); + add_property_resource(getThis(), "binarydata", ret); + zend_list_addref(ret); + } +} +/* }}} */ + +/* {{{ internal function getBinaryData + Returns the SWFBinaryData object contained in zval *id */ +static inline SWFBinaryData getBinaryData(zval *id TSRMLS_DC) +{ + void *bd = SWFgetProperty(id, "binarydata", strlen("binarydata"), le_swfbinarydatap TSRMLS_CC); + if(!bd) + php_error(E_ERROR, "called object is not an SWFBinaryData!"); + return (SWFBinaryData)bd; +} +/* }}} */ + +/* {{{ internal function destroy_SWFBinaryData */ +static void destroy_SWFBinaryData_resource(zend_rsrc_list_entry *resource TSRMLS_DC) +{ + destroySWFBinaryData((SWFBinaryData)resource->ptr); +} +/* }}} */ + +static zend_function_entry swfbinarydata_functions[] = { + PHP_ME(swfbinarydata, __construct, NULL, 0) + { NULL, NULL, NULL } +}; +/* }}} */ + /* {{{ SWFPrebuiltClip */ -/* {{{ proto class swfprebuiltclip_init([file]) +/* {{{ proto class swfprebuiltclip_init(filename / SWFInput ) Returns a SWFPrebuiltClip object */ - PHP_METHOD(swfprebuiltclip, __construct) { - zval **zfile = NULL; + zval *zfile = NULL; SWFPrebuiltClip clip; - SWFInput input; + SWFInput input = NULL; int ret; - switch(ZEND_NUM_ARGS()) { - case 1: - if(zend_get_parameters_ex(1, &zfile) == FAILURE) - 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); - - clip = newSWFPrebuiltClip_fromInput(input); - break; -/* not sure whether this makes sense - there would have to be a function to add contents - case 0: - clip = newSWFPrebuiltClip(); - break; */ - default: - WRONG_PARAM_COUNT; - break; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &zfile) == FAILURE) { + return; + } + + switch(Z_TYPE_P(zfile)) + { + case IS_RESOURCE: + input = getInput_fromFileResource(zfile TSRMLS_CC); + break; + case IS_OBJECT: + input = getInput(zfile TSRMLS_CC); + break; + case IS_STRING: + input = newSWFInput_filename(Z_STRVAL_P(zfile)); + if(input == NULL) + php_error(E_ERROR, "opening prebuilt clip file failed"); + zend_list_addref(zend_list_insert(input, le_swfinputp)); + break; + + default: + php_error(E_ERROR, "swfprebuiltclip_init: need either a filename, " + "a file ressource or SWFInput buffer."); } + + clip = newSWFPrebuiltClip_fromInput(input); if(clip) { ret = zend_list_insert(clip, le_swfprebuiltclipp); @@ -2105,18 +3695,15 @@ /* {{{ internal function getPrebuiltClip Returns the SWFPrebuiltClip object contained in zval *id */ - static SWFPrebuiltClip getPrebuiltClip(zval *id TSRMLS_DC) { void *clip = SWFgetProperty(id, "prebuiltclip", 12, le_swfprebuiltclipp TSRMLS_CC); - if(!clip) - php_error(E_RECOVERABLE_ERROR, "called object is not an SWFPrebuiltClip!"); - + php_error(E_ERROR, "called object is not an SWFPrebuiltClip!"); return (SWFPrebuiltClip)clip; } - /* }}} */ + static zend_function_entry swfprebuiltclip_functions[] = { PHP_ME(swfprebuiltclip, __construct, NULL, 0) { NULL, NULL, NULL } @@ -2125,24 +3712,21 @@ /* }}} */ #endif -/* }}} */ - /* {{{ SWFMovie */ /* {{{ proto void swfmovie::__construct(int version) Creates swfmovie object according to the passed version */ PHP_METHOD(swfmovie, __construct) { - zval **version; + long version; SWFMovie movie; int ret; if (ZEND_NUM_ARGS() == 1) { - if (zend_get_parameters_ex(1, &version) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &version) == FAILURE) { + return; } - convert_to_long_ex(version); - movie = newSWFMovieWithVersion(Z_LVAL_PP(version)); + movie = newSWFMovieWithVersion(version); } else { movie = newSWFMovie(); /* default version 4 */ } @@ -2167,7 +3751,7 @@ void *movie = SWFgetProperty(id, "movie", 5, le_swfmoviep TSRMLS_CC); if (!movie) { - php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Called object is not an SWFMovie"); + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFMovie"); } return (SWFMovie)movie; } @@ -2185,85 +3769,73 @@ Labels frame */ PHP_METHOD(swfmovie, labelFrame) { - zval **label; + char *label; + int label_len; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &label) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &label, &label_len) == FAILURE) { + return; } - convert_to_string_ex(label); - SWFMovie_labelFrame(getMovie(getThis() TSRMLS_CC), Z_STRVAL_PP(label)); + + SWFMovie_labelFrame(getMovie(getThis() TSRMLS_CC), label); } /* }}} */ -#ifdef HAVE_SWFMOVIE_NAMEDANCHOR -/* {{{ proto void swfmovie::namedanchor(string name) +/* {{{ proto void swfmovie::namedanchor() */ PHP_METHOD(swfmovie, namedAnchor) { - zval **name; - - if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &name) == FAILURE) { - WRONG_PARAM_COUNT; + char *label; + int label_len; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &label, &label_len) == FAILURE) { + return; } - - convert_to_string_ex(name); - - SWFMovie_namedAnchor(getMovie(getThis() TSRMLS_CC), Z_STRVAL_PP(name)); + + SWFMovie_namedAnchor(getMovie(getThis() TSRMLS_CC), label); } /* }}} */ -#endif /* {{{ proto void swfmovie::protect([ string pasword]) */ PHP_METHOD(swfmovie, protect) { - zval **zchar; + char *passwd = NULL; + int passwd_len; SWFMovie movie = getMovie(getThis() TSRMLS_CC); - - switch(ZEND_NUM_ARGS() ) { - case 0: - SWFMovie_protect(movie, NULL); - break; - case 1: - if( zend_get_parameters_ex(1, &zchar) == FAILURE) { - WRONG_PARAM_COUNT; - } - convert_to_string_ex(zchar); - SWFMovie_protect(movie,Z_STRVAL_PP(zchar)); - break; - default: - WRONG_PARAM_COUNT; - break; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &passwd, &passwd_len) == FAILURE) { + return; } + SWFMovie_protect(movie, passwd); } /* }}} */ - /* {{{ proto object swfmovie::add(object SWFBlock) */ PHP_METHOD(swfmovie, add) { - zval **zchar; + zval *zchar; int ret; SWFBlock block; SWFDisplayItem item; SWFMovie movie = getMovie(getThis() TSRMLS_CC); - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zchar) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &zchar) == FAILURE) { + return; } - - convert_to_object_ex(zchar); /* XXX - SWFMovie_add deals w/ all block types. Probably will need to add that.. */ - if (Z_OBJCE_PP(zchar) == action_class_entry_ptr) { - block = (SWFBlock) getAction(*zchar TSRMLS_CC); - } else { - block = (SWFBlock) getCharacter(*zchar TSRMLS_CC); + if (Z_OBJCE_P(zchar) == action_class_entry_ptr) { + block = (SWFBlock) getAction(zchar TSRMLS_CC); + } + else if(Z_OBJCE_P(zchar) == character_class_entry_ptr) { + block = (SWFBlock) getCharacterClass(zchar TSRMLS_CC); + } + else { + block = (SWFBlock) getCharacter(zchar TSRMLS_CC); } - item = SWFMovie_add(movie, block); - + item = SWFMovie_add_internal(movie, (SWFMovieBlockType)block); if (item != NULL) { /* try and create a displayitem object */ ret = zend_list_insert(item, le_swfdisplayitemp); @@ -2278,15 +3850,14 @@ */ PHP_METHOD(swfmovie, remove) { - zval **zchar; + zval *zchar; SWFDisplayItem item; SWFMovie movie = getMovie(getThis() TSRMLS_CC); - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zchar) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &zchar) == FAILURE) { + return; } - convert_to_object_ex(zchar); - item = getDisplayItem(*zchar TSRMLS_CC); + item = getDisplayItem(zchar TSRMLS_CC); SWFMovie_remove(movie, item); } /* }}} */ @@ -2303,45 +3874,28 @@ PHP_METHOD(swfmovie, output) { SWFMovie movie = getMovie(getThis() TSRMLS_CC); -#if defined(HAVE_MING_ZLIB) && !defined(HAVE_NEW_MING) - zval **zlimit = NULL; - int limit = -1; - int argc = ZEND_NUM_ARGS(); +#if !defined(HAVE_NEW_MING) + long limit = -1; int oldval = INT_MIN; long out; - if(argc) { - if (zend_get_parameters_ex(1, &zlimit) == FAILURE) { - WRONG_PARAM_COUNT; - } - - convert_to_long_ex(zlimit); - limit = Z_LVAL_PP(zlimit); - - if ((limit < 0) || (limit > 9)) { - php_error(E_WARNING,"compression level must be within 0..9"); - RETURN_FALSE; - } + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &limit) == FAILURE) { + return; } oldval = Ming_setSWFCompression(limit); out = SWFMovie_output(movie, &phpByteOutputMethod, NULL); - if (oldval >= -1 && oldval <= 9) { - Ming_setSWFCompression(oldval); - } + Ming_setSWFCompression(oldval); + RETURN_LONG(out); #elif defined(HAVE_NEW_MING) && defined(HAVE_MING_MOVIE_LEVEL) - zval **zlimit = NULL; - int limit = -1; + long limit = -1; int argc = ZEND_NUM_ARGS(); if(argc) { - if (zend_get_parameters_ex(1, &zlimit) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &limit) == FAILURE) { + return; } - convert_to_long_ex(zlimit); - limit = Z_LVAL_PP(zlimit); - if ((limit < 0) || (limit > 9)) { php_error(E_WARNING,"compression level must be within 0..9"); RETURN_FALSE; @@ -2370,53 +3924,38 @@ */ PHP_METHOD(swfmovie, saveToFile) { - zval **x; -#if defined(HAVE_MING_ZLIB) || defined(HAVE_NEW_MING) - zval **zlimit = NULL; - int limit = -1; -#endif -#if defined(HAVE_MING_ZLIB) && !defined(HAVE_NEW_MING) + zval *x; + long limit = -1; +#if !defined(HAVE_NEW_MING) int oldval = INT_MIN; - long out; #endif + long out; + SWFMovie movie = getMovie(getThis() TSRMLS_CC); php_stream *what; - switch (ZEND_NUM_ARGS()) { - case 1: - if (zend_get_parameters_ex(1, &x) == FAILURE) - WRONG_PARAM_COUNT; - break; - case 2: -#if defined(HAVE_MING_ZLIB) || defined(HAVE_NEW_MING) - if (zend_get_parameters_ex(2, &x, &zlimit) == FAILURE) - WRONG_PARAM_COUNT; - convert_to_long_ex(zlimit); - limit = Z_LVAL_PP(zlimit); - if ((limit < 0) || (limit > 9)) { - php_error(E_WARNING,"compression level must be within 0..9"); - RETURN_FALSE; - } -#endif -#if defined(HAVE_MING_ZLIB) && !defined(HAVE_NEW_MING) + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|l", &x, &limit) == FAILURE) { + return; + } + + if ((limit < 0) || (limit > 9)) { + php_error(E_WARNING,"compression level must be within 0..9"); + RETURN_FALSE; + } +#if !defined(HAVE_NEW_MING) oldval = Ming_setSWFCompression(limit); #endif - break; - default: - WRONG_PARAM_COUNT; - } - ZEND_FETCH_RESOURCE(what, php_stream *, x, -1,"File-Handle",php_file_le_stream()); -#if defined(HAVE_MING_ZLIB) && !defined(HAVE_NEW_MING) + ZEND_FETCH_RESOURCE(what, php_stream *, &x, -1,"File-Handle",php_file_le_stream()); +#if !defined(HAVE_NEW_MING) out = SWFMovie_output(getMovie(getThis() TSRMLS_CC), &phpStreamOutputMethod, what); - if (oldval >= -1 && oldval <=9) - Ming_setSWFCompression(oldval); - RETURN_LONG(out); + Ming_setSWFCompression(oldval); #elif defined(HAVE_NEW_MING) && defined(HAVE_MING_MOVIE_LEVEL) - RETURN_LONG(SWFMovie_output(movie, &phpStreamOutputMethod, what, limit)); + out = SWFMovie_output(movie, &phpStreamOutputMethod, what, limit); #else - RETURN_LONG(SWFMovie_output(movie, &phpStreamOutputMethod, what)); + out = SWFMovie_output(movie, &phpStreamOutputMethod, what); #endif + RETURN_LONG(out); } /* }}} */ @@ -2424,59 +3963,37 @@ Saves the movie. 'where' can be stream and the movie will be saved there otherwise it is treated as string and written in file with that name */ PHP_METHOD(swfmovie, save) { - zval **x; -#if defined(HAVE_MING_ZLIB) || defined(HAVE_NEW_MING) - zval **zlimit = NULL; - int limit = -1; -#endif -#if defined(HAVE_MING_ZLIB) && !defined(HAVE_NEW_MING) + zval *x; + long limit = -1; +#if !defined(HAVE_NEW_MING) int oldval = INT_MIN; #endif long retval; php_stream *stream; - switch (ZEND_NUM_ARGS()) { - case 1: - if (zend_get_parameters_ex(1, &x) == FAILURE) { - WRONG_PARAM_COUNT; - } - break; - case 2: -#if defined(HAVE_MING_ZLIB) || defined(HAVE_NEW_MING) - if (zend_get_parameters_ex(2, &x, &zlimit) == FAILURE) { - WRONG_PARAM_COUNT; - } - convert_to_long_ex(zlimit); - limit = Z_LVAL_PP(zlimit); - if ((limit < 0) || (limit > 9)) { - php_error(E_WARNING,"compression level must be within 0..9"); - RETURN_FALSE; - } -#endif -#if defined(HAVE_MING_ZLIB) && !defined(HAVE_NEW_MING) + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|l", &x, &limit) == FAILURE) { + return; + } + +#if !defined(HAVE_NEW_MING) oldval = Ming_setSWFCompression(limit); #endif - break; - default: - WRONG_PARAM_COUNT; - } - if (Z_TYPE_PP(x) == IS_RESOURCE) { - ZEND_FETCH_RESOURCE(stream, php_stream *, x, -1,"File-Handle",php_file_le_stream()); + if (Z_TYPE_P(x) == IS_RESOURCE) { + ZEND_FETCH_RESOURCE(stream, php_stream *, &x, -1,"File-Handle",php_file_le_stream()); #if defined(HAVE_NEW_MING) && defined(HAVE_MING_MOVIE_LEVEL) RETURN_LONG(SWFMovie_output(getMovie(getThis() TSRMLS_CC), &phpStreamOutputMethod, stream, limit)); #else RETVAL_LONG(SWFMovie_output(getMovie(getThis() TSRMLS_CC), &phpStreamOutputMethod, stream)); -#if defined(HAVE_MING_ZLIB) && !defined(HAVE_NEW_MING) - if(oldval >= -1 && oldval <=9) +#if !defined(HAVE_NEW_MING) Ming_setSWFCompression(oldval); #endif return; #endif } - convert_to_string_ex(x); - stream = php_stream_open_wrapper(Z_STRVAL_PP(x), "wb", REPORT_ERRORS|ENFORCE_SAFE_MODE, NULL); + convert_to_string(x); + stream = php_stream_open_wrapper(Z_STRVAL_P(x), "wb", REPORT_ERRORS|ENFORCE_SAFE_MODE, NULL); if (stream == NULL) { RETURN_FALSE; @@ -2488,121 +4005,231 @@ retval = SWFMovie_output(getMovie(getThis() TSRMLS_CC), &phpStreamOutputMethod, (void *)stream); #endif php_stream_close(stream); -#if defined(HAVE_MING_ZLIB) && !defined(HAVE_NEW_MING) - if(oldval >= -1 && oldval <=9) - Ming_setSWFCompression(oldval); +#if!defined(HAVE_NEW_MING) + Ming_setSWFCompression(oldval); #endif RETURN_LONG(retval); } /* }}} */ -/* {{{ proto void swfmovie::setBackground(int r, int g, int b) - Sets background color (r,g,b) */ -PHP_METHOD(swfmovie, setBackground) +/* {{{ proto void swfmovie::setBackground(int r, int g, int b) + Sets background color (r,g,b) */ +PHP_METHOD(swfmovie, setBackground) +{ + long r, g, b; + SWFMovie movie = getMovie(getThis() TSRMLS_CC); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll", &r, &g, &b) == FAILURE) { + return; + } + + SWFMovie_setBackground(movie, r, g, b); +} +/* }}} */ + +/* {{{ proto void swfmovie::setRate(float rate) + Sets movie rate */ +PHP_METHOD(swfmovie, setRate) +{ + double rate; + SWFMovie movie = getMovie(getThis() TSRMLS_CC); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &rate) == FAILURE) { + return; + } + + SWFMovie_setRate(movie, rate); +} +/* }}} */ + +/* {{{ proto void swfmovie::setDimension(float x, float y) + Sets movie dimension */ +PHP_METHOD(swfmovie, setDimension) +{ + double x, y; + SWFMovie movie = getMovie(getThis() TSRMLS_CC); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dd", &x, &y) == FAILURE) { + return; + } + + SWFMovie_setDimension(movie, x, y); +} +/* }}} */ + +/* {{{ proto void swfmovie::setFrames(int frames) + Sets number of frames */ +PHP_METHOD(swfmovie, setFrames) +{ + long frames; + SWFMovie movie = getMovie(getThis() TSRMLS_CC); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &frames) == FAILURE) { + return; + } + + SWFMovie_setNumberOfFrames(movie, frames); +} +/* }}} */ + +#ifdef HAVE_NEW_MING +/* {{{ proto void swfmovie::addMetadata(string xml) + * */ +PHP_METHOD(swfmovie, addMetadata) +{ + char *xml; + int xml_len; + + SWFMovie movie = getMovie(getThis() TSRMLS_CC); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &xml, &xml_len) == FAILURE) { + return; + } + + SWFMovie_addMetadata(movie, xml); +} +/* }}} */ + +/* {{{ proto void swfmovie::setScriptLimits(int maxRecursion, int timeout) +*/ +PHP_METHOD(swfmovie, setScriptLimits) +{ + long maxRecursion, timeout; + SWFMovie movie = getMovie(getThis() TSRMLS_CC); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &maxRecursion, &timeout) == FAILURE) { + return; + } + + SWFMovie_setScriptLimits(movie, maxRecursion, timeout); +} +/* }}} */ + +/* {{{ proto void swfmovie::setTabIndex(int depth, int index) + * */ +PHP_METHOD(swfmovie, setTabIndex) { - zval **r, **g, **b; + long depth, index; SWFMovie movie = getMovie(getThis() TSRMLS_CC); - - if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &r, &g, &b) == FAILURE) { - WRONG_PARAM_COUNT; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &depth, &index) == FAILURE) { + return; } - convert_to_long_ex(r); - convert_to_long_ex(g); - convert_to_long_ex(b); - SWFMovie_setBackground(movie, Z_LVAL_PP(r), Z_LVAL_PP(g), Z_LVAL_PP(b)); + SWFMovie_setTabIndex(movie, depth, index); } /* }}} */ -/* {{{ proto void swfmovie::setRate(float rate) - Sets movie rate */ -PHP_METHOD(swfmovie, setRate) +/* {{{ proto void swfmovie::assignSymbol(SWFCharacter character, string name) + * */ +PHP_METHOD(swfmovie, assignSymbol) { - zval **rate; + zval *zchar; + char *name; + int name_len; + SWFCharacter character; SWFMovie movie = getMovie(getThis() TSRMLS_CC); - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &rate) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "os", &zchar, &name, &name_len) == FAILURE) { + return; } - convert_to_double_ex(rate); - SWFMovie_setRate(movie, FLOAT_Z_DVAL_PP(rate)); + character = getCharacter(zchar TSRMLS_CC); + SWFMovie_assignSymbol(movie, character, name); } /* }}} */ -/* {{{ proto void swfmovie::setDimension(float x, float y) - Sets movie dimension */ -PHP_METHOD(swfmovie, setDimension) +/* {{{ proto void swfmovie::defineScene(int offset, string name) + * */ +PHP_METHOD(swfmovie, defineScene) { - zval **x, **y; + long offset; + char *name; + int name_len; SWFMovie movie = getMovie(getThis() TSRMLS_CC); - - if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &x, &y) == FAILURE) { - WRONG_PARAM_COUNT; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls", &offset, &name, &name_len) == FAILURE) { + return; } - convert_to_double_ex(x); - convert_to_double_ex(y); - SWFMovie_setDimension(movie, FLOAT_Z_DVAL_PP(x), FLOAT_Z_DVAL_PP(y)); + SWFMovie_defineScene(movie, offset, name); } /* }}} */ -/* {{{ proto void swfmovie::setFrames(int frames) - Sets number of frames */ -PHP_METHOD(swfmovie, setFrames) -{ - zval **frames; +/* {{{ proto void swfmovie::setNetworkAccess(int flag) + * */ +PHP_METHOD(swfmovie, setNetworkAccess) +{ + long flag; SWFMovie movie = getMovie(getThis() TSRMLS_CC); - - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &frames) == FAILURE) { - WRONG_PARAM_COUNT; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &flag) == FAILURE) { + return; } - convert_to_long_ex(frames); - SWFMovie_setNumberOfFrames(movie, Z_LVAL_PP(frames)); -} + SWFMovie_setNetworkAccess(movie, flag); +} /* }}} */ -#ifdef HAVE_NEW_MING -/* {{{ proto int swfmovie::streamMP3(mixed file [, float skip]) - Sets sound stream of the SWF movie. The parameter can be stream or string. Retuens the number of frames. */ +/* {{{ proto long swfmovie::streamMP3(mixed filename / SWFInput [, double skip]) + Sets sound stream of the SWF movie. The parameter can be stream or string. */ PHP_METHOD(swfmovie, streamMP3) { - zval **zfile, **zskip; - float skip; + zval *zfile; + double skip = 0; SWFSoundStream sound; - SWFInput input; + SWFInput input = NULL; SWFMovie movie = getMovie(getThis() TSRMLS_CC); - switch (ZEND_NUM_ARGS()) { - case 1: - if(zend_get_parameters_ex(1, &zfile) == FAILURE) - WRONG_PARAM_COUNT; - skip = 0; - break; - case 2: - if(zend_get_parameters_ex(2, &zfile, &zskip) == FAILURE) - WRONG_PARAM_COUNT; - convert_to_double_ex(zskip); - skip = Z_DVAL_PP(zskip); - break; - default: - WRONG_PARAM_COUNT; - break; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|d", &zfile, &skip) == FAILURE) { + return; } - - 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 { + + switch(Z_TYPE_P(zfile)) + { + case IS_RESOURCE: + input = getInput_fromFileResource(zfile TSRMLS_CC); + break; + case IS_OBJECT: input = getInput(zfile TSRMLS_CC); + break; + case IS_STRING: + input = newSWFInput_filename(Z_STRVAL_P(zfile)); + if (input == NULL) { + php_error(E_ERROR, "opening mp3 file failed"); + } + + zend_list_addref(zend_list_insert(input, le_swfinputp)); + break; + + default: + php_error(E_ERROR, "swfmovie::streamMP3: need either a filename, " + "a file ressource or SWFInput buffer."); } - + sound = newSWFSoundStream_fromInput(input); SWFMovie_setSoundStreamAt(movie, sound, skip); - RETURN_LONG(SWFSoundStream_getFrames(sound)); + RETURN_LONG(SWFSoundStream_getDuration(sound) / SWFMovie_getRate(movie)); +} +/* }}} */ + +/* {{{ proto long swfmovie::setSoundStream + Sets sound stream of the SWF movie. The parameter must be a SoundStream object */ +PHP_METHOD(swfmovie, setSoundStream) +{ + zval *zstream; + double skip = 0; + SWFSoundStream sound; + SWFMovie movie = getMovie(getThis() TSRMLS_CC); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o|d", &zstream, &skip) == FAILURE) { + return; + } + + sound = getSoundStream(zstream TSRMLS_CC); + SWFMovie_setSoundStreamAt(movie, sound, skip); + RETURN_LONG(SWFSoundStream_getDuration(sound) / SWFMovie_getRate(movie)); } /* }}} */ @@ -2610,19 +4237,19 @@ PHP_METHOD(swfmovie, addExport) { - zval **zchar, **zname; + zval *zchar; + char *name; + int name_len; SWFBlock block; SWFMovie movie = getMovie(getThis() TSRMLS_CC); - if(ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &zchar, &zname) == FAILURE) - WRONG_PARAM_COUNT; - - convert_to_object_ex(zchar); - convert_to_string_ex(zname); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "os", &zchar, &name, &name_len) == FAILURE) { + return; + } - block = (SWFBlock)getCharacter(*zchar TSRMLS_CC); + block = (SWFBlock)getCharacter(zchar TSRMLS_CC); - SWFMovie_addExport(movie, block, Z_STRVAL_PP(zname)); + SWFMovie_addExport(movie, block, name); } /* }}} */ @@ -2641,17 +4268,17 @@ PHP_METHOD(swfmovie, startSound) { - zval **zsound; + zval *zsound; int ret; SWFSound sound; SWFSoundInstance item; SWFMovie movie = getMovie(getThis() TSRMLS_CC); - if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zsound) == FAILURE) - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &zsound) == FAILURE) { + return; + } - convert_to_object_ex(zsound); - sound = (SWFSound)getSound(*zsound TSRMLS_CC); + sound = (SWFSound)getSound(zsound TSRMLS_CC); item = SWFMovie_startSound(movie, sound); @@ -2666,72 +4293,69 @@ } /* }}} */ -/* {{{ void swfmovie_stopsound */ - +/* {{{ void swfmovie::stopsound(sound) */ PHP_METHOD(swfmovie, stopSound) { - zval **zsound; + zval *zsound; SWFSound sound; SWFMovie movie = getMovie(getThis() TSRMLS_CC); - if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zsound) == FAILURE) - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &zsound) == FAILURE) { + return; + } - convert_to_object_ex(zsound); - sound = (SWFSound)getSound(*zsound TSRMLS_CC); + sound = (SWFSound)getSound(zsound TSRMLS_CC); SWFMovie_stopSound(movie, sound); } /* }}} */ -/* {{{ void swfmovie_importChar */ - +/* {{{ void swfmovie::importChar(filename, importname) */ PHP_METHOD(swfmovie, importChar) { SWFMovie movie; - SWFCharacter res; + SWFCharacter character; int ret; - zval **libswf, **name; + char *libswf, *name; + int libswf_len, name_len; - if(ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &libswf, &name) == FAILURE) - WRONG_PARAM_COUNT; - convert_to_string_ex(libswf); - convert_to_string_ex(name); - movie = getMovie(getThis() TSRMLS_CC); - res = SWFMovie_importCharacter(movie, Z_STRVAL_PP(libswf), Z_STRVAL_PP(name)); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &libswf, &libswf_len, &name, &name_len) == FAILURE) { + return; + } - if(res != NULL) + movie = getMovie(getThis() TSRMLS_CC); + character = SWFMovie_importCharacter(movie, libswf, name); + if(character != NULL) { - /* try and create a sprite object */ - ret = zend_list_insert(res, le_swfspritep); - object_init_ex(return_value, sprite_class_entry_ptr); - add_property_resource(return_value, "sprite", ret); + ret = zend_list_insert(character, le_swfcharacterp); + object_init_ex(return_value, character_class_entry_ptr); + add_property_resource(return_value, "character", ret); zend_list_addref(ret); - } + } } /* }}} */ /* {{{ void swfmovie_importFont */ - PHP_METHOD(swfmovie, importFont) { SWFMovie movie; SWFFontCharacter res; int ret; - zval **libswf, **name; + char *libswf, *name; + int libswf_len, name_len; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &libswf, &libswf_len, &name, &name_len) == FAILURE) { + return; + } - if(ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &libswf, &name) == FAILURE) - WRONG_PARAM_COUNT; - convert_to_string_ex(libswf); - convert_to_string_ex(name); movie = getMovie(getThis() TSRMLS_CC); - PHP_MING_FILE_CHK(Z_STRVAL_PP(libswf)); - res = SWFMovie_importFont(movie, Z_STRVAL_PP(libswf), Z_STRVAL_PP(name)); + PHP_MING_FILE_CHK(libswf); + res = SWFMovie_importFont(movie, libswf, name); if(res != NULL) { /* try and create a fontchar object */ - ret = zend_list_insert(res, le_swffontcharp); + ret = zend_list_insert(res, le_swffontcharp); object_init_ex(return_value, fontchar_class_entry_ptr); add_property_resource(return_value, "fontcharacter", ret); zend_list_addref(ret); @@ -2746,27 +4370,55 @@ SWFFontCharacter res; int ret; SWFFont font; - zval **zfont; - - if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zfont) == FAILURE) - WRONG_PARAM_COUNT; + zval *zfont; - convert_to_object_ex(zfont); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &zfont) == FAILURE) { + return; + } movie = getMovie(getThis() TSRMLS_CC); - font = getFont(*zfont TSRMLS_CC); + font = getFont(zfont TSRMLS_CC); res = SWFMovie_addFont(movie, font); - if(res != NULL) { /* try and create a fontchar object */ - ret = zend_list_insert(res, le_swffontcharp); + ret = zend_list_insert(res, le_swffontcharp); object_init_ex(return_value, fontchar_class_entry_ptr); add_property_resource(return_value, "fontcharacter", ret); zend_list_addref(ret); } } /* }}} */ + +/* {{{ void swfmovie_replace */ +PHP_METHOD(swfmovie, replace) +{ + SWFMovie movie; + zval *zitem, *zblock; + SWFDisplayItem item; + SWFBlock block; + SWFMovieBlockType ublock; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "oo", &zitem, &zblock) == FAILURE) { + return; + } + + item = getDisplayItem(zitem TSRMLS_CC); + + block = (SWFBlock) getCharacter(zblock TSRMLS_CC); + movie = getMovie(getThis() TSRMLS_CC); + ublock.block = block; + + SWFMovie_replace_internal(movie, item, ublock); +} +/* }}} */ + +/* {{{ float swfmovie::getRate() */ +PHP_METHOD(swfmovie, getRate) +{ + RETURN_DOUBLE(SWFMovie_getRate(getMovie(getThis() TSRMLS_CC))); +} +/* }}} */ #endif static zend_function_entry swfmovie_functions[] = { @@ -2784,6 +4436,7 @@ PHP_ME(swfmovie, setFrames, NULL, 0) #ifdef HAVE_NEW_MING PHP_ME(swfmovie, streamMP3, NULL, 0) + PHP_ME(swfmovie, setSoundStream, NULL, 0) PHP_ME(swfmovie, addExport, NULL, 0) PHP_ME(swfmovie, writeExports, NULL, 0) PHP_ME(swfmovie, startSound, NULL, 0) @@ -2792,9 +4445,15 @@ PHP_ME(swfmovie, importFont, NULL, 0) PHP_ME(swfmovie, addFont, NULL, 0) PHP_ME(swfmovie, protect, NULL, 0) -#endif -#ifdef HAVE_SWFMOVIE_NAMEDANCHOR - PHP_ME(swfmovie, namedAnchor, NULL, 0) + PHP_ME(swfmovie, addMetadata, NULL, 0) + PHP_ME(swfmovie, setNetworkAccess, NULL, 0) + PHP_ME(swfmovie, setScriptLimits, NULL, 0) + PHP_ME(swfmovie, setTabIndex, NULL, 0) + PHP_ME(swfmovie, assignSymbol, NULL, 0) + PHP_ME(swfmovie, defineScene, NULL, 0) + PHP_ME(swfmovie, namedAnchor, NULL, 0) + PHP_ME(swfmovie, replace, NULL, 0) + PHP_ME(swfmovie, getRate, NULL, 0) #endif { NULL, NULL, NULL } }; @@ -2828,7 +4487,7 @@ void *shape = SWFgetProperty(id, "shape", 5, le_swfshapep TSRMLS_CC); if (!shape) { - php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Called object is not an SWFShape"); + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFShape"); } return (SWFShape)shape; @@ -2839,38 +4498,13 @@ Sets the current line style for this SWFShape */ PHP_METHOD(swfshape, setLine) { - zval **w, **r, **g, **b, **a; + long w, r, g, b, a = 0xff; - if (ZEND_NUM_ARGS() == 4) { - if (zend_get_parameters_ex(4, &w, &r, &g, &b) == FAILURE) { - WRONG_PARAM_COUNT; - } - } else if (ZEND_NUM_ARGS() == 5) { - if (zend_get_parameters_ex(5, &w, &r, &g, &b, &a) == FAILURE) { - WRONG_PARAM_COUNT; - } - convert_to_long_ex(a); - } else if (ZEND_NUM_ARGS() == 1) { - SWFShape_setLine(getShape(getThis() TSRMLS_CC), 0, 0, 0, 0, 0); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llll|l", &w, &r, &g, &b, &a) == FAILURE) { return; - } else { - WRONG_PARAM_COUNT; } - convert_to_long_ex(w); - convert_to_long_ex(r); - convert_to_long_ex(g); - convert_to_long_ex(b); - - if (ZEND_NUM_ARGS() == 4) { - SWFShape_setLine(getShape(getThis() TSRMLS_CC), - (unsigned short)Z_LVAL_PP(w), BYTE_Z_LVAL_PP(r), BYTE_Z_LVAL_PP(g), BYTE_Z_LVAL_PP(b), 0xff - ); - } else { - SWFShape_setLine(getShape(getThis() TSRMLS_CC), - (unsigned short)Z_LVAL_PP(w), BYTE_Z_LVAL_PP(r), BYTE_Z_LVAL_PP(g), BYTE_Z_LVAL_PP(b), BYTE_Z_LVAL_PP(a) - ); - } + SWFShape_setLine(getShape(getThis() TSRMLS_CC), (unsigned short)w, (byte)r, (byte)g, (byte)b, (byte)a); } /* }}} */ @@ -2883,69 +4517,42 @@ if (ZEND_NUM_ARGS() == 1 || ZEND_NUM_ARGS() == 2) { /* it's a gradient or bitmap */ - zval **arg1; - unsigned char flags = 0; + zval *arg1; + long flags = 0; - if (ZEND_NUM_ARGS() == 2) { - zval **arg2; - if (zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) { - WRONG_PARAM_COUNT; - } - convert_to_long_ex(arg2); - flags = (unsigned char)Z_LVAL_PP(arg2); - } else { - if (zend_get_parameters_ex(1, &arg1) == FAILURE) { - WRONG_PARAM_COUNT; - } + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o|l", &arg1, &flags) == FAILURE) { + return; } - convert_to_object_ex(arg1); - - if (Z_OBJCE_PP(arg1) == gradient_class_entry_ptr) { + if (Z_OBJCE_P(arg1) == gradient_class_entry_ptr) { if (flags == 0) { flags = SWFFILL_LINEAR_GRADIENT; } - fill = SWFShape_addGradientFill(getShape(getThis() TSRMLS_CC), getGradient(*arg1 TSRMLS_CC), flags); - } else if (Z_OBJCE_PP(arg1) == bitmap_class_entry_ptr) { + fill = SWFShape_addGradientFill(getShape(getThis() TSRMLS_CC), getGradient(arg1 TSRMLS_CC), flags); + } else if (Z_OBJCE_P(arg1) == bitmap_class_entry_ptr) { if (flags == 0) { flags = SWFFILL_TILED_BITMAP; } - fill = SWFShape_addBitmapFill(getShape(getThis() TSRMLS_CC), getBitmap(*arg1 TSRMLS_CC), flags); + fill = SWFShape_addBitmapFill(getShape(getThis() TSRMLS_CC), getBitmap(arg1 TSRMLS_CC), flags); } else { - php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Argument is not a bitmap nor a gradient"); + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Argument is not a bitmap nor a gradient"); } } else if (ZEND_NUM_ARGS() == 3 || ZEND_NUM_ARGS() == 4) { /* it's a solid fill */ - zval **r, **g, **b, **za; - byte a = 0xff; + long r, g, b, a = 0xff; - if (ZEND_NUM_ARGS() == 3) { - if (zend_get_parameters_ex(3, &r, &g, &b) == FAILURE) { - WRONG_PARAM_COUNT; - } - } else if (ZEND_NUM_ARGS() == 4) { - if (zend_get_parameters_ex(4, &r, &g, &b, &za) == FAILURE) { - WRONG_PARAM_COUNT; - } - convert_to_long_ex(za); - a = BYTE_Z_LVAL_PP(za); - } else { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll|l", &r, &g, &b, &a) == FAILURE) { + return; } - convert_to_long_ex(r); - convert_to_long_ex(g); - convert_to_long_ex(b); - - fill = SWFShape_addSolidFill(getShape(getThis() TSRMLS_CC), - BYTE_Z_LVAL_PP(r), BYTE_Z_LVAL_PP(g), BYTE_Z_LVAL_PP(b), a - ); + + fill = SWFShape_addSolidFill(getShape(getThis() TSRMLS_CC), (byte)r, (byte)g, (byte)b, (byte)a); } else { WRONG_PARAM_COUNT; } if (!fill) { - php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Error adding fill to shape"); + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error adding fill to shape"); } /* return an SWFFill object */ @@ -2960,47 +4567,21 @@ Sets the left side fill style to fill in case only one parameter is passed. When 3 or 4 parameters are passed they are treated as : int r, int g, int b, int a . Solid fill is performed in this case before setting left side fill type. */ PHP_METHOD(swfshape, setLeftFill) { - zval **zfill, **r, **g, **b, **a; + zval *zfill; + long r, g, b, a = 0xff; SWFFill fill; - if (ZEND_NUM_ARGS() == 3) { - if (zend_get_parameters_ex(3, &r, &g, &b) == FAILURE) { - WRONG_PARAM_COUNT; - } - convert_to_long_ex(r); - convert_to_long_ex(g); - convert_to_long_ex(b); - - fill = SWFShape_addSolidFill(getShape(getThis() TSRMLS_CC), - BYTE_Z_LVAL_PP(r), BYTE_Z_LVAL_PP(g), BYTE_Z_LVAL_PP(b), 0xff - ); - - } else if (ZEND_NUM_ARGS() == 4) { - if (zend_get_parameters_ex(4, &r, &g, &b, &a) == FAILURE) { - WRONG_PARAM_COUNT; - } - convert_to_long_ex(r); - convert_to_long_ex(g); - convert_to_long_ex(b); - convert_to_long_ex(a); - - fill = SWFShape_addSolidFill(getShape(getThis() TSRMLS_CC), - BYTE_Z_LVAL_PP(r), BYTE_Z_LVAL_PP(g), BYTE_Z_LVAL_PP(b), BYTE_Z_LVAL_PP(a) - ); - - } else if (ZEND_NUM_ARGS() == 1) { - if (zend_get_parameters_ex(1, &zfill) == FAILURE) { - WRONG_PARAM_COUNT; + if (ZEND_NUM_ARGS() == 1) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &zfill) == FAILURE) { + return; } - - if (Z_LVAL_PP(zfill) != 0) { - convert_to_object_ex(zfill); - fill = getFill(*zfill TSRMLS_CC); - } else { - fill = NULL; + fill = getFill(zfill TSRMLS_CC); + } + else { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll|l", &r, &g, &b, &a) == FAILURE) { + return; } - } else { - WRONG_PARAM_COUNT; + fill = SWFShape_addSolidFill(getShape(getThis() TSRMLS_CC), (byte)r, (byte)g, (byte)b, (byte)a); } SWFShape_setLeftFill(getShape(getThis() TSRMLS_CC), fill); @@ -3011,188 +4592,129 @@ Sets the right side fill style to fill in case only one parameter is passed. When 3 or 4 parameters are passed they are treated as : int r, int g, int b, int a . Solid fill is performed in this case before setting right side fill type. */ PHP_METHOD(swfshape, setRightFill) { - zval **zfill, **r, **g, **b, **a; + zval *zfill; + long r, g, b, a = 0xff; SWFFill fill; - if (ZEND_NUM_ARGS() == 3) { - if (zend_get_parameters_ex(3, &r, &g, &b) == FAILURE) { - WRONG_PARAM_COUNT; - } - convert_to_long_ex(r); - convert_to_long_ex(g); - convert_to_long_ex(b); - - fill = SWFShape_addSolidFill(getShape(getThis() TSRMLS_CC), - BYTE_Z_LVAL_PP(r), BYTE_Z_LVAL_PP(g), BYTE_Z_LVAL_PP(b), 0xff - ); - - } else if (ZEND_NUM_ARGS() == 4) { - if (zend_get_parameters_ex(4, &r, &g, &b, &a) == FAILURE) { - WRONG_PARAM_COUNT; - } - convert_to_long_ex(r); - convert_to_long_ex(g); - convert_to_long_ex(b); - convert_to_long_ex(a); - - fill = SWFShape_addSolidFill(getShape(getThis() TSRMLS_CC), - BYTE_Z_LVAL_PP(r), BYTE_Z_LVAL_PP(g), BYTE_Z_LVAL_PP(b), BYTE_Z_LVAL_PP(a) - ); - } else if (ZEND_NUM_ARGS() == 1) { - if (zend_get_parameters_ex(1, &zfill) == FAILURE) { - WRONG_PARAM_COUNT; + if (ZEND_NUM_ARGS() == 1) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &zfill) == FAILURE) { + return; } - - if (Z_LVAL_PP(zfill) != 0) { - convert_to_object_ex(zfill); - fill = getFill(*zfill TSRMLS_CC); - } else { - fill = NULL; + fill = getFill(zfill TSRMLS_CC); + } + else { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll|l", &r, &g, &b, &a) == FAILURE) { + return; } - } else { - WRONG_PARAM_COUNT; + fill = SWFShape_addSolidFill(getShape(getThis() TSRMLS_CC), (byte)r, (byte)g, (byte)b, (byte)a); } SWFShape_setRightFill(getShape(getThis() TSRMLS_CC), fill); } /* }}} */ -/* {{{ proto void swfshape::movepento(float x, float y) +/* {{{ proto void swfshape::movepento(double x, double y) Moves the pen to shape coordinates (x, y) */ PHP_METHOD(swfshape, movePenTo) { - zval **x, **y; + double x, y; - if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &x, &y) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dd", &x, &y) == FAILURE) { + return; } - convert_to_double_ex(x); - convert_to_double_ex(y); - SWFShape_movePenTo(getShape(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(x), FLOAT_Z_DVAL_PP(y)); + + SWFShape_movePenTo(getShape(getThis() TSRMLS_CC), x, y); } /* }}} */ -/* {{{ proto void swfshape::movepen(float x, float y) +/* {{{ proto void swfshape::movepen(double x, double y) Moves the pen from its current location by vector (x, y) */ PHP_METHOD(swfshape, movePen) { - zval **x, **y; + double x, y; - if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &x, &y) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dd", &x, &y) == FAILURE) { + return; } - convert_to_double_ex(x); - convert_to_double_ex(y); - SWFShape_movePen(getShape(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(x), FLOAT_Z_DVAL_PP(y)); + + SWFShape_movePen(getShape(getThis() TSRMLS_CC), x, y); } /* }}} */ -/* {{{ proto void swfshape::drawlineto(float x, float y) +/* {{{ proto void swfshape::drawlineto(double x, double y) Draws a line from the current pen position to shape coordinates (x, y) in the current line style */ PHP_METHOD(swfshape, drawLineTo) { - zval **x, **y; + double x, y; - if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &x, &y) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dd", &x, &y) == FAILURE) { + return; } - convert_to_double_ex(x); - convert_to_double_ex(y); - SWFShape_drawLineTo(getShape(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(x), FLOAT_Z_DVAL_PP(y)); + + SWFShape_drawLineTo(getShape(getThis() TSRMLS_CC), x, y); } /* }}} */ -/* {{{ proto void swfshape::drawline(float dx, float dy) +/* {{{ proto void swfshape::drawline(double dx, double dy) Draws a line from the current pen position (x, y) to the point (x+dx, y+dy) in the current line style */ PHP_METHOD(swfshape, drawLine) { - zval **x, **y; + double x, y; - if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &x, &y) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dd", &x, &y) == FAILURE) { + return; } - convert_to_double_ex(x); - convert_to_double_ex(y); - SWFShape_drawLine(getShape(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(x), FLOAT_Z_DVAL_PP(y)); + + SWFShape_drawLine(getShape(getThis() TSRMLS_CC), x, y); } /* }}} */ -/* {{{ proto void swfshape::drawcurveto(float ax, float ay, float bx, float by [, float dx, float dy]) +/* {{{ proto void swfshape::drawcurveto(double ax, double ay, double bx, double by [, double dx, double dy]) Draws a curve from the current pen position (x,y) to the point (bx, by) in the current line style, using point (ax, ay) as a control point. Or draws a cubic bezier to point (dx, dy) with control points (ax, ay) and (bx, by) */ PHP_METHOD(swfshape, drawCurveTo) { if (ZEND_NUM_ARGS() == 4) { - zval **cx, **cy, **ax, **ay; + double cx, cy, ax, ay; - if (zend_get_parameters_ex(4, &cx, &cy, &ax, &ay) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dddd", &cx, &cy, &ax, &ay) == FAILURE) { + return; } - convert_to_double_ex(cx); - convert_to_double_ex(cy); - convert_to_double_ex(ax); - convert_to_double_ex(ay); - - SWFShape_drawCurveTo(getShape(getThis() TSRMLS_CC), - FLOAT_Z_DVAL_PP(cx), FLOAT_Z_DVAL_PP(cy), FLOAT_Z_DVAL_PP(ax), FLOAT_Z_DVAL_PP(ay) - ); - + + SWFShape_drawCurveTo(getShape(getThis() TSRMLS_CC), cx, cy, ax, ay); } else if (ZEND_NUM_ARGS() == 6) { - zval **bx, **by, **cx, **cy, **dx, **dy; + double bx, by, cx, cy, dx, dy; - if (zend_get_parameters_ex(6, &bx, &by, &cx, &cy, &dx, &dy) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dddddd", &bx, &by, &cx, &cy, &dx, &dy) == FAILURE) { + return; } - convert_to_double_ex(bx); - convert_to_double_ex(by); - convert_to_double_ex(cx); - convert_to_double_ex(cy); - convert_to_double_ex(dx); - convert_to_double_ex(dy); - - RETURN_LONG(SWFShape_drawCubicTo(getShape(getThis() TSRMLS_CC), - FLOAT_Z_DVAL_PP(bx), FLOAT_Z_DVAL_PP(by), FLOAT_Z_DVAL_PP(cx), FLOAT_Z_DVAL_PP(cy), FLOAT_Z_DVAL_PP(dx), FLOAT_Z_DVAL_PP(dy)) - ); + + RETURN_LONG(SWFShape_drawCubicTo(getShape(getThis() TSRMLS_CC), bx, by, cx, cy, dx, dy)); } else { WRONG_PARAM_COUNT; } } /* }}} */ -/* {{{ proto void swfshape::drawcurve(float adx, float ady, float bdx, float bdy [, float cdx, float cdy]) +/* {{{ proto void swfshape::drawcurve(double adx, double ady, double bdx, double bdy [, double cdx, double cdy]) Draws a curve from the current pen position (x, y) to the point (x+bdx, y+bdy) in the current line style, using point (x+adx, y+ady) as a control point or draws a cubic bezier to point (x+cdx, x+cdy) with control points (x+adx, y+ady) and (x+bdx, y+bdy) */ PHP_METHOD(swfshape, drawCurve) { if (ZEND_NUM_ARGS() == 4) { - zval **cx, **cy, **ax, **ay; + double cx, cy, ax, ay; - if (zend_get_parameters_ex(4, &cx, &cy, &ax, &ay) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dddd", &cx, &cy, &ax, &ay) == FAILURE) { + return; } - convert_to_double_ex(cx); - convert_to_double_ex(cy); - convert_to_double_ex(ax); - convert_to_double_ex(ay); - - SWFShape_drawCurve(getShape(getThis() TSRMLS_CC), - FLOAT_Z_DVAL_PP(cx), FLOAT_Z_DVAL_PP(cy), FLOAT_Z_DVAL_PP(ax), FLOAT_Z_DVAL_PP(ay) - ); + SWFShape_drawCurve(getShape(getThis() TSRMLS_CC), cx, cy, ax, ay); } else if (ZEND_NUM_ARGS() == 6) { - zval **bx, **by, **cx, **cy, **dx, **dy; + double bx, by, cx, cy, dx, dy; - if (zend_get_parameters_ex(6, &bx, &by, &cx, &cy, &dx, &dy) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dddddd", &bx, &by, &cx, &cy, &dx, &dy) == FAILURE) { + return; } - convert_to_double_ex(bx); - convert_to_double_ex(by); - convert_to_double_ex(cx); - convert_to_double_ex(cy); - convert_to_double_ex(dx); - convert_to_double_ex(dy); - - RETURN_LONG( SWFShape_drawCubic(getShape(getThis() TSRMLS_CC), - FLOAT_Z_DVAL_PP(bx), FLOAT_Z_DVAL_PP(by), FLOAT_Z_DVAL_PP(cx), FLOAT_Z_DVAL_PP(cy), FLOAT_Z_DVAL_PP(dx), FLOAT_Z_DVAL_PP(dy)) - ); + + RETURN_LONG(SWFShape_drawCubic(getShape(getThis() TSRMLS_CC), bx, by, cx, cy, dx, dy)); } else { WRONG_PARAM_COUNT; } @@ -3203,100 +4725,282 @@ Draws the first character in the given string into the shape using the glyph definition from the given font */ PHP_METHOD(swfshape, drawGlyph) { - zval **font, **c, **zsize; - int size=0; - - if (ZEND_NUM_ARGS() == 2) { - if (zend_get_parameters_ex(2, &font, &c) == FAILURE) { - WRONG_PARAM_COUNT; - } - size = (int)(1024.0f/Ming_getScale()); + zval *font; + char *c; + int c_len; + long size = (long)(1024.0f/Ming_getScale()); - } else if (ZEND_NUM_ARGS() == 3) { - if (zend_get_parameters_ex(3, &font, &c, &zsize) == FAILURE) { - WRONG_PARAM_COUNT; - } - convert_to_long_ex(zsize); - size = Z_LVAL_PP(zsize); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "os|l", &font, &c, &c_len, &size) == FAILURE) { + return; } - convert_to_string_ex(c); - SWFShape_drawSizedGlyph(getShape(getThis() TSRMLS_CC), getFont(*font TSRMLS_CC), Z_STRVAL_PP(c)[0], size); + SWFShape_drawSizedGlyph(getShape(getThis() TSRMLS_CC), getFont(font TSRMLS_CC), c[0], size); } /* }}} */ -/* {{{ proto void swfshape::drawcircle(float r) +/* {{{ proto void swfshape::drawcircle(double r) Draws a circle of radius r centered at the current location, in a counter-clockwise fashion */ PHP_METHOD(swfshape, drawCircle) { - zval **r; + double r; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &r) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &r) == FAILURE) { + return; } - convert_to_double_ex(r); - SWFShape_drawCircle(getShape(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(r)); + + SWFShape_drawCircle(getShape(getThis() TSRMLS_CC), r); } /* }}} */ -/* {{{ proto void swfshape::drawarc(float r, float startAngle, float endAngle) +/* {{{ proto void swfshape::drawarc(double r, double startAngle, double endAngle) Draws an arc of radius r centered at the current location, from angle startAngle to angle endAngle measured clockwise from 12 o'clock */ PHP_METHOD(swfshape, drawArc) { - zval **r, **start, **end; + double r, start, end; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ddd", &r, &start, &end) == FAILURE) { + return; + } + + /* convert angles to radians, since that's what php uses elsewhere */ + SWFShape_drawArc(getShape(getThis() TSRMLS_CC), r, start, end); +} +/* }}} */ + +/* {{{ proto void swfshape::drawcubic(double bx, double by, double cx, double cy, double dx, double dy) + Draws a cubic bezier curve using the current position and the three given points as control points */ +PHP_METHOD(swfshape, drawCubic) +{ + double bx, by, cx, cy, dx, dy; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dddddd", &bx, &by, &cx, &cy, &dx, &dy) == FAILURE) { + return; + } + + RETURN_LONG(SWFShape_drawCubic(getShape(getThis() TSRMLS_CC), bx, by, cx, cy, dx, dy)); +} +/* }}} */ + +/* {{{ proto void swfshape::drawcubic(double bx, double by, double cx, double cy, double dx, double dy) + Draws a cubic bezier curve using the current position and the three given points as control points */ +PHP_METHOD(swfshape, drawCubicTo) +{ + double bx, by, cx, cy, dx, dy; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dddddd", &bx, &by, &cx, &cy, &dx, &dy) == FAILURE) { + return; + } + + RETURN_LONG(SWFShape_drawCubicTo(getShape(getThis() TSRMLS_CC), bx, by, cx, cy, dx, dy)); +} +/* }}} */ + +/* {{{ proto void swfshape::end() */ +PHP_METHOD(swfshape, end) +{ + if (ZEND_NUM_ARGS() != 0) { + WRONG_PARAM_COUNT; + } + + SWFShape_end(getShape(getThis() TSRMLS_CC)); +} +/* }}} */ + +/* {{{ proto void swfshape::useVersion() + * SWF_SHAPE3 + * SWF_SHAPE4 + */ +PHP_METHOD(swfshape, useVersion) +{ + long ver; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &ver) == FAILURE) { + return; + } + + SWFShape_useVersion(getShape(getThis() TSRMLS_CC), ver); +} +/* }}} */ + +/* {{{ proto int swfshape::getVersion() */ +PHP_METHOD(swfshape, getVersion) +{ + if (ZEND_NUM_ARGS() != 0) { + WRONG_PARAM_COUNT; + } + + RETURN_LONG(SWFShape_getVersion(getShape(getThis() TSRMLS_CC))); +} +/* }}} */ + +/* {{{ proto void swfshape::setRenderHintingFlags(flags) + * SWF_SHAPE_USESCALINGSTROKES + * SWF_SHAPE_USENONSCALINGSTROKES + */ +PHP_METHOD(swfshape, setRenderHintingFlags) +{ + long flags; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &flags) == FAILURE) { + return; + } + + SWFShape_setRenderHintingFlags(getShape(getThis() TSRMLS_CC), flags); +} +/* }}} */ + +/* {{{ proto double swfshape::getPenX() */ +PHP_METHOD(swfshape, getPenX) +{ + if (ZEND_NUM_ARGS() != 0) { + WRONG_PARAM_COUNT; + } + + RETURN_DOUBLE(SWFShape_getPenX(getShape(getThis() TSRMLS_CC))); +} +/* }}} */ + +/* {{{ proto double swfshape::getPenY() */ +PHP_METHOD(swfshape, getPenY) +{ + if (ZEND_NUM_ARGS() != 0) { + WRONG_PARAM_COUNT; + } - if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &r, &start, &end) == FAILURE) { + RETURN_DOUBLE(SWFShape_getPenY(getShape(getThis() TSRMLS_CC))); +} +/* }}} */ + +/* {{{ proto void swfshape::hideLine() */ +PHP_METHOD(swfshape, hideLine) +{ + if (ZEND_NUM_ARGS() != 0) { WRONG_PARAM_COUNT; } - convert_to_double_ex(r); - convert_to_double_ex(start); - convert_to_double_ex(end); - /* convert angles to radians, since that's what php uses elsewhere */ - SWFShape_drawArc(getShape(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(r), FLOAT_Z_DVAL_PP(start), FLOAT_Z_DVAL_PP(end)); + SWFShape_hideLine(getShape(getThis() TSRMLS_CC)); +} +/* }}} */ + +/* {{{ proto void swfshape::drawCharacterBounds(character) */ +PHP_METHOD(swfshape, drawCharacterBounds) +{ + zval *character; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &character) == FAILURE) { + return; + } + + SWFShape_drawCharacterBounds(getShape(getThis() TSRMLS_CC), + getCharacter(character TSRMLS_CC)); +} +/* }}} */ + +/* {{{ proto void swfshape::setLine2(width, flags, miterLimit, r, g, b, [a]) + * Line cap style: select one of the following flags (default is round cap style) + * SWF_LINESTYLE_CAP_ROUND + * SWF_LINESTYLE_CAP_NONE + * SWF_LINESTYLE_CAP_SQUARE + * + * Line join style: select one of the following flags (default is round join style) + * SWF_LINESTYLE_JOIN_ROUND + * SWF_LINESTYLE_JOIN_BEVEL + * SWF_LINESTYLE_JOIN_MITER + * + * Scaling flags: disable horizontal / vertical scaling + * SWF_LINESTYLE_FLAG_NOHSCALE + * SWF_LINESTYLE_FLAG_NOVSCALE + * + * Enable pixel hinting to correct blurry vertical / horizontal lines + * -> all anchors will be aligned to full pixels + * SWF_LINESTYLE_FLAG_HINTING + * + * Disable stroke closure: if no-close flag is set caps will be applied + * instead of joins + * SWF_LINESTYLE_FLAG_NOCLOSE + * + * End-cap style: default round + * SWF_LINESTYLE_FLAG_ENDCAP_ROUND + * SWF_LINESTYLE_FLAG_ENDCAP_NONE + * SWF_LINESTYLE_FLAG_ENDCAP_SQUARE + * + * If join style is SWF_LINESTYLE_JOIN_MITER a miter limit factor + * must be set. Miter max length is then calculated as: + * max miter len = miter limit * width. + * If join style is not miter, this value will be ignored. + * */ +PHP_METHOD(swfshape, setLine2) +{ + long width, flags, r, g, b, a = 0xff; + double limit; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lldlll|l", &width, &flags, &limit, &r, &g, &b, &a) == FAILURE) { + return; + } + + SWFShape_setLine2(getShape(getThis() TSRMLS_CC), width, r, g, b, a, flags, limit); } /* }}} */ -/* {{{ proto void swfshape::drawcubic(float bx, float by, float cx, float cy, float dx, float dy) - Draws a cubic bezier curve using the current position and the three given points as control points */ -PHP_METHOD(swfshape, drawCubic) +/* {{{ proto void swfshape::setLine2Filled(width, fill, flags, limit) + * Line cap style: select one of the following flags (default is round cap style) + * SWF_LINESTYLE_CAP_ROUND + * SWF_LINESTYLE_CAP_NONE + * SWF_LINESTYLE_CAP_SQUARE + * + * Line join style: select one of the following flags (default is round join style) + * SWF_LINESTYLE_JOIN_ROUND + * SWF_LINESTYLE_JOIN_BEVEL + * SWF_LINESTYLE_JOIN_MITER + * + * Scaling flags: disable horizontal / vertical scaling + * SWF_LINESTYLE_FLAG_NOHSCALE + * SWF_LINESTYLE_FLAG_NOVSCALE + * + * Enable pixel hinting to correct blurry vertical / horizontal lines + * -> all anchors will be aligned to full pixels + * SWF_LINESTYLE_FLAG_HINTING + * + * Disable stroke closure: if no-close flag is set caps will be applied + * instead of joins + * SWF_LINESTYLE_FLAG_NOCLOSE + * + * End-cap style: default round + * SWF_LINESTYLE_FLAG_ENDCAP_ROUND + * SWF_LINESTYLE_FLAG_ENDCAP_NONE + * SWF_LINESTYLE_FLAG_ENDCAP_SQUARE + * + * If join style is SWF_LINESTYLE_JOIN_MITER a miter limit factor + * must be set. Miter max length is then calculated as: + * max miter len = miter limit * width. + * If join style is not miter, this value will be ignored. + */ +PHP_METHOD(swfshape, setLine2Filled) { - zval **bx, **by, **cx, **cy, **dx, **dy; + long width, flags; + zval *fill; + double limit; + SWFFill xfill; - if (ZEND_NUM_ARGS() != 6 || zend_get_parameters_ex(6, &bx, &by, &cx, &cy, &dx, &dy) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lold", &width, &fill, &flags, &limit) == FAILURE) { + return; } - convert_to_double_ex(bx); - convert_to_double_ex(by); - convert_to_double_ex(cx); - convert_to_double_ex(cy); - convert_to_double_ex(dx); - convert_to_double_ex(dy); - RETURN_LONG( SWFShape_drawCubic(getShape(getThis() TSRMLS_CC), - FLOAT_Z_DVAL_PP(bx), FLOAT_Z_DVAL_PP(by), FLOAT_Z_DVAL_PP(cx), FLOAT_Z_DVAL_PP(cy), FLOAT_Z_DVAL_PP(dx), FLOAT_Z_DVAL_PP(dy)) - ); + xfill = getFill(fill TSRMLS_CC); + SWFShape_setLine2Filled(getShape(getThis() TSRMLS_CC), width, SWFFill_getFillStyle(xfill), flags, limit); } /* }}} */ -/* {{{ proto void swfshape::drawcubic(float bx, float by, float cx, float cy, float dx, float dy) - Draws a cubic bezier curve using the current position and the three given points as control points */ -PHP_METHOD(swfshape, drawCubicTo) +/* {{{ */ +PHP_METHOD(swfshape, dumpOutline) { - zval **bx, **by, **cx, **cy, **dx, **dy; - - if (ZEND_NUM_ARGS() != 6 || zend_get_parameters_ex(6, &bx, &by, &cx, &cy, &dx, &dy) == FAILURE) { + char *out; + if (ZEND_NUM_ARGS() != 0) { WRONG_PARAM_COUNT; } - convert_to_double_ex(bx); - convert_to_double_ex(by); - convert_to_double_ex(cx); - convert_to_double_ex(cy); - convert_to_double_ex(dx); - convert_to_double_ex(dy); - RETURN_LONG( SWFShape_drawCubicTo(getShape(getThis() TSRMLS_CC), - FLOAT_Z_DVAL_PP(bx), FLOAT_Z_DVAL_PP(by), FLOAT_Z_DVAL_PP(cx), FLOAT_Z_DVAL_PP(cy), FLOAT_Z_DVAL_PP(dx), FLOAT_Z_DVAL_PP(dy)) - ); + out = SWFShape_dumpOutline(getShape(getThis() TSRMLS_CC)); + RETURN_STRING(out, 1); + free(out); } /* }}} */ @@ -3317,6 +5021,16 @@ PHP_ME(swfshape, drawArc, NULL, 0) PHP_ME(swfshape, drawCubic, NULL, 0) PHP_ME(swfshape, drawCubicTo, NULL, 0) + PHP_ME(swfshape, end, NULL, 0) + PHP_ME(swfshape, useVersion, NULL, 0) + PHP_ME(swfshape, setRenderHintingFlags, NULL, 0) + PHP_ME(swfshape, getPenX, NULL, 0) + PHP_ME(swfshape, getPenY, NULL, 0) + PHP_ME(swfshape, hideLine, NULL, 0) + PHP_ME(swfshape, drawCharacterBounds, NULL, 0) + PHP_ME(swfshape, setLine2, NULL, 0) + PHP_ME(swfshape, setLine2Filled, NULL, 0) + PHP_ME(swfshape, dumpOutline, NULL, 0) { NULL, NULL, NULL } }; @@ -3349,7 +5063,7 @@ void *sprite = SWFgetProperty(id, "sprite", 6, le_swfspritep TSRMLS_CC); if (!sprite) { - php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Called object is not an SWFSprite"); + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFSprite"); } return (SWFMovieClip)sprite; } @@ -3359,22 +5073,20 @@ Adds the character to the sprite, returns a displayitem object */ PHP_METHOD(swfsprite, add) { - zval **zchar; + zval *zchar; int ret; SWFBlock block; SWFDisplayItem item; SWFMovieClip sprite = getSprite(getThis() TSRMLS_CC); - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zchar) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &zchar) == FAILURE) { + return; } - - convert_to_object_ex(zchar); - if (Z_OBJCE_PP(zchar) == action_class_entry_ptr) { - block = (SWFBlock)getAction(*zchar TSRMLS_CC); + if (Z_OBJCE_P(zchar) == action_class_entry_ptr) { + block = (SWFBlock)getAction(zchar TSRMLS_CC); } else { - block = (SWFBlock)getCharacter(*zchar TSRMLS_CC); + block = (SWFBlock)getCharacter(zchar TSRMLS_CC); } item = SWFMovieClip_add(sprite, block); @@ -3393,15 +5105,15 @@ Remove the named character from the sprite's display list */ PHP_METHOD(swfsprite, remove) { - zval **zchar; + zval *zchar; SWFDisplayItem item; SWFMovieClip movie = getSprite(getThis() TSRMLS_CC); - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zchar) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &zchar) == FAILURE) { + return; } - convert_to_object_ex(zchar); - item = getDisplayItem(*zchar TSRMLS_CC); + + item = getDisplayItem(zchar TSRMLS_CC); SWFMovieClip_remove(movie, item); } /* }}} */ @@ -3418,13 +5130,14 @@ Labels frame */ PHP_METHOD(swfsprite, labelFrame) { - zval **label; + char *label; + int label_len; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &label) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &label, &label_len) == FAILURE) { + return; } - convert_to_string_ex(label); - SWFMovieClip_labelFrame(getSprite(getThis() TSRMLS_CC), Z_STRVAL_PP(label)); + + SWFMovieClip_labelFrame(getSprite(getThis() TSRMLS_CC), label); } /* }}} */ @@ -3432,14 +5145,14 @@ Sets the number of frames in this SWFSprite */ PHP_METHOD(swfsprite, setFrames) { - zval **frames; + long frames; SWFMovieClip sprite = getSprite(getThis() TSRMLS_CC); - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &frames) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &frames) == FAILURE) { + return; } - convert_to_long_ex(frames); - SWFMovieClip_setNumberOfFrames(sprite, Z_LVAL_PP(frames)); + + SWFMovieClip_setNumberOfFrames(sprite, frames); } /* }}} */ @@ -3448,17 +5161,16 @@ PHP_METHOD(swfsprite, startSound) { - zval **zsound; + zval *zsound; int ret; SWFSound sound; SWFSoundInstance item; SWFMovieClip sprite = getSprite(getThis() TSRMLS_CC); - if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zsound) == FAILURE) - WRONG_PARAM_COUNT; - - convert_to_object_ex(zsound); - sound = (SWFSound)getSound(*zsound TSRMLS_CC); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &zsound) == FAILURE) { + return; + } + sound = (SWFSound)getSound(zsound TSRMLS_CC); item = SWFMovieClip_startSound(sprite, sound); @@ -3476,31 +5188,136 @@ PHP_METHOD(swfsprite, stopSound) { - zval **zsound; + zval *zsound; SWFSound sound; SWFMovieClip sprite = getSprite(getThis() TSRMLS_CC); - if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zsound) == FAILURE) + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &zsound) == FAILURE) { + return; + } + sound = (SWFSound)getSound(zsound TSRMLS_CC); + + SWFMovieClip_stopSound(sprite, sound); +} +/* }}} */ + +/* {{{ proto long swfmovieclip::setSoundStream(mixed file, rate[, skip]) + Sets sound stream of the SWF movieClip. The parameter can be stream or string. */ +PHP_METHOD(swfsprite, setSoundStream) +{ + zval *zfile; + double rate, skip = 0; + SWFSoundStream sound; + SWFInput input = NULL; + SWFMovieClip mc = getSprite(getThis() TSRMLS_CC); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zd|d", &zfile, &rate, &skip) == FAILURE) { + return; + } + + switch(Z_TYPE_P(zfile)) + { + case IS_RESOURCE: + input = getInput_fromFileResource(zfile TSRMLS_CC); + break; + case IS_OBJECT: + input = getInput(zfile TSRMLS_CC); + break; + case IS_STRING: + input = newSWFInput_filename(Z_STRVAL_P(zfile)); + if(input == NULL) + php_error(E_ERROR, "opening sound file failed"); + zend_list_addref(zend_list_insert(input, le_swfinputp)); + break; + + default: + php_error(E_ERROR, "swfmovieclip::setSoundStream: need either a filename, " + "a file ressource or SWFInput buffer."); + } + sound = newSWFSoundStream_fromInput(input); + SWFMovieClip_setSoundStreamAt(mc, sound, rate, skip); + RETURN_LONG(SWFSoundStream_getDuration(sound) / rate); +} +/* }}} */ + + +/* {{{ proto void swfsprite::setScalingGrid(int x, int y, int w, int h) */ +PHP_METHOD(swfsprite, setScalingGrid) +{ + long zx, zy, zw, zh; + SWFMovieClip sprite = getSprite(getThis() TSRMLS_CC); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llll", &zx, &zy, &zw, &zh) == FAILURE) { + return; + } + + SWFMovieClip_setScalingGrid(sprite, zx, zy, zw, zh); +} +/* }}} */ + +/* {{{ proto void swfsprite::removeScalingGrid() */ +PHP_METHOD(swfsprite, removeScalingGrid) +{ + SWFMovieClip sprite = getSprite(getThis() TSRMLS_CC); + if (ZEND_NUM_ARGS() != 0) { WRONG_PARAM_COUNT; + } + + SWFMovieClip_removeScalingGrid(sprite); +} +/* }}} */ - convert_to_object_ex(zsound); - sound = (SWFSound)getSound(*zsound TSRMLS_CC); +/* {{{ proto void swfsprite::addInitAction(action) */ +PHP_METHOD(swfsprite, addInitAction) +{ + zval *zaction; - SWFMovieClip_stopSound(sprite, sound); + SWFMovieClip sprite = getSprite(getThis() TSRMLS_CC); + SWFAction action; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &zaction) == FAILURE) { + return; + } + + action = getAction(zaction TSRMLS_CC); + SWFMovieClip_addInitAction(sprite, action); } /* }}} */ #endif +// workaround to support SWFSprite and SWFMovieclip objects +static zend_function_entry swfmovieclip_functions[] = { + PHP_ME(swfsprite, __construct, NULL, 0) + PHP_ME(swfsprite, add, NULL, 0) + PHP_ME(swfsprite, remove, NULL, 0) + PHP_ME(swfsprite, nextFrame, NULL, 0) + PHP_ME(swfsprite, labelFrame, NULL, 0) + PHP_ME(swfsprite, setFrames, NULL, 0) +#ifdef HAVE_NEW_MING + PHP_ME(swfsprite, startSound, NULL, 0) + PHP_ME(swfsprite, stopSound, NULL, 0) + PHP_ME(swfsprite, setScalingGrid, NULL, 0) + PHP_ME(swfsprite, removeScalingGrid, NULL, 0) + PHP_ME(swfsprite, setSoundStream, NULL, 0) + PHP_ME(swfsprite, addInitAction, NULL, 0) +#endif + { NULL, NULL, NULL } +}; + static zend_function_entry swfsprite_functions[] = { PHP_ME(swfsprite, __construct, NULL, 0) - PHP_ME(swfsprite, add, NULL, 0) - PHP_ME(swfsprite, remove, NULL, 0) + PHP_ME(swfsprite, add, NULL, 0) + PHP_ME(swfsprite, remove, NULL, 0) PHP_ME(swfsprite, nextFrame, NULL, 0) PHP_ME(swfsprite, labelFrame, NULL, 0) PHP_ME(swfsprite, setFrames, NULL, 0) #ifdef HAVE_NEW_MING PHP_ME(swfsprite, startSound, NULL, 0) PHP_ME(swfsprite, stopSound, NULL, 0) + PHP_ME(swfsprite, setScalingGrid, NULL, 0) + PHP_ME(swfsprite, removeScalingGrid, NULL, 0) + PHP_ME(swfsprite, setSoundStream, NULL, 0) + PHP_ME(swfsprite, addInitAction, NULL, 0) #endif { NULL, NULL, NULL } }; @@ -3509,13 +5326,24 @@ /* {{{ SWFText */ -/* {{{ proto void swftext::__construct() +/* {{{ proto void swftext::__construct([version]) Creates new SWFText object */ PHP_METHOD(swftext, __construct) { - SWFText text = newSWFText2(); - int ret = zend_list_insert(text, le_swftextp); + long version = 0; + SWFText text; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &version) == FAILURE) { + return; + } + if (version == 1) { + text = newSWFText(); + } + else { + text = newSWFText2(); + } + int ret = zend_list_insert(text, le_swftextp); object_init_ex(getThis(), text_class_entry_ptr); add_property_resource(getThis(), "text", ret); zend_list_addref(ret); @@ -3534,25 +5362,25 @@ void *text = SWFgetProperty(id, "text", 4, le_swftextp TSRMLS_CC); if (!text) { - php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Called object is not an SWFText"); + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFText"); } return (SWFText)text; } /* }}} */ -/* {{{ proto void swftext::setFont(object font) +/* {{{ proto void swftext::setFont(SWFFont font) Sets this SWFText object's current font to given font */ PHP_METHOD(swftext, setFont) { - zval **zfont; + zval *zfont; SWFText text = getText(getThis() TSRMLS_CC); SWFFont font; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zfont) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &zfont) == FAILURE) { + return; } - convert_to_object_ex(zfont); - font = getFont(*zfont TSRMLS_CC); + + font = getFont(zfont TSRMLS_CC); SWFText_setFont(text, font); } /* }}} */ @@ -3561,14 +5389,14 @@ Sets this SWFText object's current height to given height */ PHP_METHOD(swftext, setHeight) { - zval **height; + double height; SWFText text = getText(getThis() TSRMLS_CC); - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &height) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &height) == FAILURE) { + return; } - convert_to_double_ex(height); - SWFText_setHeight(text, FLOAT_Z_DVAL_PP(height)); + + SWFText_setHeight(text, height); } /* }}} */ @@ -3576,14 +5404,14 @@ Sets this SWFText object's current letterspacing to given spacing */ PHP_METHOD(swftext, setSpacing) { - zval **spacing; + double spacing; SWFText text = getText(getThis() TSRMLS_CC); - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &spacing) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &spacing) == FAILURE) { + return; } - convert_to_double_ex(spacing); - SWFText_setSpacing(text, FLOAT_Z_DVAL_PP(spacing)); + + SWFText_setSpacing(text, spacing); } /* }}} */ @@ -3591,30 +5419,14 @@ Sets this SWFText object's current color to the given color */ PHP_METHOD(swftext, setColor) { - zval **r, **g, **b, **a; + long r, g, b, a = 0xff; SWFText text = getText(getThis() TSRMLS_CC); - if (ZEND_NUM_ARGS() == 3) { - if (zend_get_parameters_ex(3, &r, &g, &b) == FAILURE) { - WRONG_PARAM_COUNT; - } - } else if (ZEND_NUM_ARGS() == 4) { - if (zend_get_parameters_ex(4, &r, &g, &b, &a) == FAILURE) { - WRONG_PARAM_COUNT; - } - convert_to_long_ex(a); - } else { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll|l", &r, &g, &b, &a) == FAILURE) { + return; } - convert_to_long_ex(r); - convert_to_long_ex(g); - convert_to_long_ex(b); - if (ZEND_NUM_ARGS() == 4) { - SWFText_setColor(text, BYTE_Z_LVAL_PP(r), BYTE_Z_LVAL_PP(g), BYTE_Z_LVAL_PP(b), BYTE_Z_LVAL_PP(a)); - } else { - SWFText_setColor(text, BYTE_Z_LVAL_PP(r), BYTE_Z_LVAL_PP(g), BYTE_Z_LVAL_PP(b), 0xff); - } + SWFText_setColor(text, (byte)r, (byte)g, (byte)b, (byte)a); } /* }}} */ @@ -3622,15 +5434,14 @@ Moves this SWFText object's current pen position to (x, y) in text coordinates */ PHP_METHOD(swftext, moveTo) { - zval **x, **y; + double x, y; SWFText text = getText(getThis() TSRMLS_CC); - if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &x, &y) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dd", &x, &y) == FAILURE) { + return; } - convert_to_double_ex(x); - convert_to_double_ex(y); - SWFText_setXY(text, FLOAT_Z_DVAL_PP(x), FLOAT_Z_DVAL_PP(y)); + + SWFText_setXY(text, x, y); } /* }}} */ @@ -3638,15 +5449,15 @@ Writes the given text into this SWFText object at the current pen position, using the current font, height, spacing, and color */ PHP_METHOD(swftext, addString) { - zval **s; + char *s; + int s_len; SWFText text = getText(getThis() TSRMLS_CC); - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &s) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &s, &s_len) == FAILURE) { + return; } - convert_to_string_ex(s); - SWFText_addString(text, Z_STRVAL_PP(s), NULL); + SWFText_addString(text, s, NULL); } /* }}} */ @@ -3657,15 +5468,15 @@ PHP_METHOD(swftext, addUTF8String) { - zval **s; + char *s; + int s_len; SWFText text = getText(getThis() TSRMLS_CC); - if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &s) == FAILURE) - WRONG_PARAM_COUNT; - - convert_to_string_ex(s); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &s, &s_len) == FAILURE) { + return; + } - SWFText_addUTF8String(text, Z_STRVAL_PP(s), NULL); + SWFText_addUTF8String(text, s, NULL); } /* }}} */ @@ -3675,15 +5486,15 @@ /* PHP_METHOD(swftext, addWideString) { - zval **s; + char *s; + int s_len; SWFText text = getText(getThis() TSRMLS_CC); - if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &s) == FAILURE) - WRONG_PARAM_COUNT; - - convert_to_string_ex(s); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &s, &s_len) == FAILURE) { + return; + } - SWFText_addWideString(text, Z_STRVAL_PP(s), NULL); + SWFText_addWideString(text, s, NULL); } */ /* }}} */ @@ -3693,13 +5504,14 @@ Calculates the width of the given string in this text objects current font and size */ PHP_METHOD(swftext, getWidth) { - zval **zstring; + char *string; + int string_len; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zstring) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &string, &string_len) == FAILURE) { + return; } - convert_to_string_ex(zstring); - RETURN_DOUBLE(SWFText_getStringWidth(getText(getThis() TSRMLS_CC), Z_STRVAL_PP(zstring))); + + RETURN_DOUBLE(SWFText_getStringWidth(getText(getThis() TSRMLS_CC), string)); } /* }}} */ @@ -3709,17 +5521,14 @@ PHP_METHOD(swftext, getUTF8Width) { - zval **zstring; - int width; - - if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zstring) == FAILURE) - WRONG_PARAM_COUNT; - - convert_to_string_ex(zstring); - - width = SWFText_getUTF8StringWidth(getText(getThis() TSRMLS_CC), Z_STRVAL_PP(zstring)); + char *string; + int string_len; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &string, &string_len) == FAILURE) { + return; + } - RETURN_DOUBLE(width); + RETURN_DOUBLE(SWFText_getUTF8StringWidth(getText(getThis() TSRMLS_CC), string)); } /* }}} */ @@ -3728,17 +5537,14 @@ /* PHP_METHOD(swftext, getWideWidth) { - zval **zstring; - int width; - - if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zstring) == FAILURE) - WRONG_PARAM_COUNT; - - convert_to_string_ex(zstring); - - width = SWFText_getWideStringWidth(getText(getThis() TSRMLS_CC), Z_STRVAL_PP(zstring)); - - RETURN_DOUBLE(width); + char *string; + int string_len; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &string, &string_len) == FAILURE) { + return; + } + + RETURN_DOUBLE(SWFText_getWideStringWidth(getText(getThis() TSRMLS_CC), string)); } */ /* }}} */ @@ -3762,7 +5568,7 @@ if(ZEND_NUM_ARGS() != 0) { WRONG_PARAM_COUNT; } - RETURN_DOUBLE(SWFText_getDescent(getText(getThis() TSRMLS_CC))); + RETURN_DOUBLE(SWFText_getDescent(getText(getThis() TSRMLS_CC))); } /* }}} */ @@ -3773,7 +5579,7 @@ if(ZEND_NUM_ARGS() != 0) { WRONG_PARAM_COUNT; } - RETURN_DOUBLE(SWFText_getLeading(getText(getThis() TSRMLS_CC))); + RETURN_DOUBLE(SWFText_getLeading(getText(getThis() TSRMLS_CC))); } /* }}} */ @@ -3808,7 +5614,7 @@ Creates a new SWFTextField object */ PHP_METHOD(swftextfield, __construct) { - zval **flags; + long flags; SWFTextField field = newSWFTextField(); int ret = zend_list_insert(field, le_swftextfieldp); @@ -3816,13 +5622,11 @@ add_property_resource(getThis(), "textfield", ret); zend_list_addref(ret); - if (ZEND_NUM_ARGS() == 1) { - if (zend_get_parameters_ex(1, &flags) == FAILURE) { - WRONG_PARAM_COUNT; - } - convert_to_long_ex(flags); - SWFTextField_setFlags(field, Z_LVAL_PP(flags)); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &flags) == FAILURE) { + return; } + + SWFTextField_setFlags(field, flags); } /* }}} */ @@ -3838,7 +5642,7 @@ void *field = SWFgetProperty(id, "textfield", 9, le_swftextfieldp TSRMLS_CC); if (!field) { - php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Called object is not an SWFTextField"); + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFTextField"); } return (SWFTextField)field; } @@ -3861,14 +5665,25 @@ PHP_METHOD(swftextfield, setFont) { - zval **font; + zval *font; SWFTextField field = getTextField(getThis() TSRMLS_CC); - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &font) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &font) == FAILURE) { + return; + } + + if(Z_OBJCE_P(font) == font_class_entry_ptr + || Z_OBJCE_P(font) == fontchar_class_entry_ptr) + { + SWFTextField_setFont(field, getFontOrFontChar(font TSRMLS_CC)); + } + else if(Z_OBJCE_P(font) == browserfont_class_entry_ptr) + { + SWFTextField_setFont(field, (SWFBlock)getBrowserFont(font TSRMLS_CC)); } - convert_to_object_ex(font); - SWFTextField_setFont(field, getFontOrFontChar(*font TSRMLS_CC)); + else { + php_error(E_ERROR, "not a font object\n"); + } } /* }}} */ @@ -3876,15 +5691,13 @@ Sets the width and height of this textfield */ PHP_METHOD(swftextfield, setBounds) { - zval **width, **height; - SWFTextField field = getTextField(getThis() TSRMLS_CC); + double width, height; - if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &width, &height) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dd", &width, &height) == FAILURE) { + return; } - convert_to_double_ex(width); - convert_to_double_ex(height); - SWFTextField_setBounds(field, FLOAT_Z_DVAL_PP(width), FLOAT_Z_DVAL_PP(height)); + + SWFTextField_setBounds(getTextField(getThis() TSRMLS_CC), width, height); } /* }}} */ @@ -3892,14 +5705,13 @@ Sets the alignment of this textfield */ PHP_METHOD(swftextfield, align) { - zval **align; - SWFTextField field = getTextField(getThis() TSRMLS_CC); + long align; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &align) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &align) == FAILURE) { + return; } - convert_to_long_ex(align); - SWFTextField_setAlignment(field, Z_LVAL_PP(align)); + + SWFTextField_setAlignment(getTextField(getThis() TSRMLS_CC), align); } /* }}} */ @@ -3907,14 +5719,13 @@ Sets the font height of this textfield */ PHP_METHOD(swftextfield, setHeight) { - zval **height; - SWFTextField field = getTextField(getThis() TSRMLS_CC); + double height; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &height) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &height) == FAILURE) { + return; } - convert_to_double_ex(height); - SWFTextField_setHeight(field, FLOAT_Z_DVAL_PP(height)); + + SWFTextField_setHeight(getTextField(getThis() TSRMLS_CC), height); } /* }}} */ @@ -3922,14 +5733,13 @@ Sets the left margin of this textfield */ PHP_METHOD(swftextfield, setLeftMargin) { - zval **margin; - SWFTextField field = getTextField(getThis() TSRMLS_CC); + double margin; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &margin) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &margin) == FAILURE) { + return; } - convert_to_double_ex(margin); - SWFTextField_setLeftMargin(field, FLOAT_Z_DVAL_PP(margin)); + + SWFTextField_setLeftMargin(getTextField(getThis() TSRMLS_CC), margin); } /* }}} */ @@ -3937,14 +5747,13 @@ Sets the right margin of this textfield */ PHP_METHOD(swftextfield, setRightMargin) { - zval **margin; - SWFTextField field = getTextField(getThis() TSRMLS_CC); + double margin; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &margin) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &margin) == FAILURE) { + return; } - convert_to_double_ex(margin); - SWFTextField_setRightMargin(field, FLOAT_Z_DVAL_PP(margin)); + + SWFTextField_setRightMargin(getTextField(getThis() TSRMLS_CC), margin); } /* }}} */ @@ -3952,16 +5761,15 @@ Sets both margins of this textfield */ PHP_METHOD(swftextfield, setMargins) { - zval **left, **right; + double left, right; SWFTextField field = getTextField(getThis() TSRMLS_CC); - if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &left, &right) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dd", &left, &right) == FAILURE) { + return; } - convert_to_double_ex(left); - convert_to_double_ex(right); - SWFTextField_setLeftMargin(field, FLOAT_Z_DVAL_PP(left)); - SWFTextField_setRightMargin(field, FLOAT_Z_DVAL_PP(right)); + + SWFTextField_setLeftMargin(field, left); + SWFTextField_setRightMargin(field, right); } /* }}} */ @@ -3969,14 +5777,13 @@ Sets the indentation of the first line of this textfield */ PHP_METHOD(swftextfield, setIndentation) { - zval **indent; - SWFTextField field = getTextField(getThis() TSRMLS_CC); + double indent; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &indent) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &indent) == FAILURE) { + return; } - convert_to_double_ex(indent); - SWFTextField_setIndentation(field, FLOAT_Z_DVAL_PP(indent)); + + SWFTextField_setIndentation(getTextField(getThis() TSRMLS_CC), indent); } /* }}} */ @@ -3984,14 +5791,13 @@ Sets the line spacing of this textfield */ PHP_METHOD(swftextfield, setLineSpacing) { - zval **spacing; - SWFTextField field = getTextField(getThis() TSRMLS_CC); + double spacing; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &spacing) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &spacing) == FAILURE) { + return; } - convert_to_double_ex(spacing); - SWFTextField_setLineSpacing(field, FLOAT_Z_DVAL_PP(spacing)); + + SWFTextField_setLineSpacing(getTextField(getThis() TSRMLS_CC), spacing); } /* }}} */ @@ -3999,27 +5805,12 @@ Sets the color of this textfield */ PHP_METHOD(swftextfield, setColor) { - zval **r, **g, **b, **a; - SWFTextField field = getTextField(getThis() TSRMLS_CC); - byte alpha = 0xff; + long r, g, b, a = 0xff; - if (ZEND_NUM_ARGS() == 3) { - if (zend_get_parameters_ex(3, &r, &g, &b) == FAILURE) { - WRONG_PARAM_COUNT; - } - } else if (ZEND_NUM_ARGS() == 4) { - if (zend_get_parameters_ex(4, &r, &g, &b, &a) == FAILURE) { - WRONG_PARAM_COUNT; - } - convert_to_long_ex(a); - alpha = BYTE_Z_LVAL_PP(a); - } else { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll|l", &r, &g, &b, &a) == FAILURE) { + return; } - convert_to_long_ex(r); - convert_to_long_ex(g); - convert_to_long_ex(b); - SWFTextField_setColor(field, BYTE_Z_LVAL_PP(r), BYTE_Z_LVAL_PP(g), BYTE_Z_LVAL_PP(b), (byte)alpha); + SWFTextField_setColor(getTextField(getThis() TSRMLS_CC), (byte)r, (byte)g, (byte)b, (byte)a); } /* }}} */ @@ -4027,14 +5818,14 @@ Sets the variable name of this textfield */ PHP_METHOD(swftextfield, setName) { - zval **name; - SWFTextField field = getTextField(getThis() TSRMLS_CC); + char *name; + int name_len; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &name) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) { + return; } - convert_to_string_ex(name); - SWFTextField_setVariableName(field, Z_STRVAL_PP(name)); + + SWFTextField_setVariableName(getTextField(getThis() TSRMLS_CC), name); } /* }}} */ @@ -4042,31 +5833,45 @@ Adds the given string to this textfield */ PHP_METHOD(swftextfield, addString) { - zval **string; - SWFTextField field = getTextField(getThis() TSRMLS_CC); + char *str; + int str_len; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &string) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) { + return; + } + + SWFTextField_addString(getTextField(getThis() TSRMLS_CC), str); +} +/* }}} */ + +/* {{{ proto void swftextfield::addUTF8String(string str) + Adds the given UTF8 string to this textfield */ +PHP_METHOD(swftextfield, addUTF8String) +{ + char *str; + int str_len; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) { + return; } - convert_to_string_ex(string); - SWFTextField_addString(field, Z_STRVAL_PP(string)); + + SWFTextField_addUTF8String(getTextField(getThis() TSRMLS_CC), str); } /* }}} */ + #ifdef HAVE_NEW_MING /* {{{ proto void swftextfield::setPadding(float padding) Sets the padding of this textfield */ PHP_METHOD(swftextfield, setPadding) { - zval **padding; - SWFTextField field = getTextField(getThis() TSRMLS_CC); + double padding; - if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &padding) == FAILURE) - WRONG_PARAM_COUNT; - - convert_to_double_ex(padding); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &padding) == FAILURE) { + return; + } - SWFTextField_setPadding(field, Z_DVAL_PP(padding)); + SWFTextField_setPadding(getTextField(getThis() TSRMLS_CC), padding); } /* }}} */ @@ -4074,18 +5879,44 @@ adds characters to a font that will be available within a textfield */ PHP_METHOD(swftextfield, addChars) { - zval **zstring; - SWFTextField field = getTextField(getThis() TSRMLS_CC); + char *str; + int str_len; - if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zstring) == FAILURE) - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) { + return; + } + + SWFTextField_addChars(getTextField(getThis() TSRMLS_CC), str); + +} +/* }}} */ + +/* {{{ proto void swftextfield::setLength(int len) */ +PHP_METHOD(swftextfield, setLength) +{ + long len; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &len) == FAILURE) { + return; + } + + SWFTextField_setLength(getTextField(getThis() TSRMLS_CC), len); +} +/* }}} */ - convert_to_string_ex(zstring); +/* {{{ proto void swftextfield::setLength(len) */ +PHP_METHOD(swftextfield, setFieldHeight) +{ + long h; - SWFTextField_addChars(field, Z_STRVAL_PP(zstring)); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &h) == FAILURE) { + return; + } + SWFTextField_setFieldHeight(getTextField(getThis() TSRMLS_CC), h); } /* }}} */ + #endif static zend_function_entry swftextfield_functions[] = { @@ -4102,9 +5933,12 @@ PHP_ME(swftextfield, setColor, NULL, 0) PHP_ME(swftextfield, setName, NULL, 0) PHP_ME(swftextfield, addString, NULL, 0) + PHP_ME(swftextfield, addUTF8String, NULL, 0) #ifdef HAVE_NEW_MING PHP_ME(swftextfield, setPadding, NULL, 0) PHP_ME(swftextfield, addChars, NULL, 0) + PHP_ME(swftextfield, setLength, NULL, 0) + PHP_ME(swftextfield, setFieldHeight, NULL, 0) #endif { NULL, NULL, NULL } }; @@ -4139,11 +5973,28 @@ } /* }}} */ -/* {{{ todo PHP_MINIT_FUNCTION(ming) -*/ +#if PHP_API_VERSION == 20020918 +static php4_fix_funcnames(char *class_name, zend_function_entry *funcs) /* {{{ */ +{ + zend_function_entry *pf = funcs; + char *pname; + + while(funcs->fname) { + if( strcmp(funcs->fname,"__construct") == 0 ) { + pname=strdup(class_name); + } else { + pname=strdup(funcs->fname); + } + funcs->fname=pname; + while(*pname) { *pname=tolower(*pname);pname++;} + funcs++; + } +} +/* }}} */ +#endif /* custom error handler propagates ming errors up to php */ -static void php_ming_error(const char *msg, ...) +static void php_ming_error(const char *msg, ...) /* {{{ */ { va_list args; char *buffer; @@ -4154,21 +6005,25 @@ vspprintf(&buffer, 0, msg, args); va_end(args); - php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "%s", buffer); + php_error_docref(NULL TSRMLS_CC, E_ERROR, "%s", buffer); efree(buffer); } +/* }}} */ -PHP_RINIT_FUNCTION(ming) +PHP_RINIT_FUNCTION(ming) /* {{{ */ { /* XXX - this didn't work so well last I tried.. */ if (Ming_init() != 0) { - php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Error initializing Ming module"); + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error initializing Ming module"); return FAILURE; } return SUCCESS; } +/* }}} */ +/* {{{ todo PHP_MINIT_FUNCTION(ming) +*/ PHP_MINIT_FUNCTION(ming) { zend_class_entry shape_class_entry; @@ -4183,17 +6038,29 @@ zend_class_entry button_class_entry; zend_class_entry action_class_entry; zend_class_entry morph_class_entry; + zend_class_entry movieclip_class_entry; zend_class_entry sprite_class_entry; zend_class_entry sound_class_entry; #ifdef HAVE_NEW_MING zend_class_entry fontchar_class_entry; zend_class_entry soundinstance_class_entry; zend_class_entry videostream_class_entry; -#endif -#ifdef HAVE_SWFPREBUILTCLIP + zend_class_entry buttonrecord_class_entry; + zend_class_entry binarydata_class_entry; + zend_class_entry initaction_class_entry; zend_class_entry prebuiltclip_class_entry; + zend_class_entry soundstream_class_entry; + zend_class_entry filter_class_entry; + zend_class_entry filtermatrix_class_entry; + zend_class_entry blur_class_entry; + zend_class_entry shadow_class_entry; + zend_class_entry cxform_class_entry; + zend_class_entry matrix_class_entry; + zend_class_entry input_class_entry; + zend_class_entry browserfont_class_entry; + zend_class_entry fontcollection_class_entry; #endif - + zend_class_entry character_class_entry; Ming_setErrorFunction((void *) php_ming_error); #define CONSTANT(s,c) REGISTER_LONG_CONSTANT((s), (c), CONST_CS | CONST_PERSISTENT) @@ -4230,7 +6097,6 @@ CONSTANT("SWFFILL_CLIPPED_BITMAP", SWFFILL_CLIPPED_BITMAP); /* flags for SWFTextField_init */ - CONSTANT("SWFTEXTFIELD_HASLENGTH", SWFTEXTFIELD_HASLENGTH); CONSTANT("SWFTEXTFIELD_NOEDIT", SWFTEXTFIELD_NOEDIT); CONSTANT("SWFTEXTFIELD_PASSWORD", SWFTEXTFIELD_PASSWORD); CONSTANT("SWFTEXTFIELD_MULTILINE", SWFTEXTFIELD_MULTILINE); @@ -4238,7 +6104,6 @@ CONSTANT("SWFTEXTFIELD_DRAWBOX", SWFTEXTFIELD_DRAWBOX); CONSTANT("SWFTEXTFIELD_NOSELECT", SWFTEXTFIELD_NOSELECT); CONSTANT("SWFTEXTFIELD_HTML", SWFTEXTFIELD_HTML); - CONSTANT("SWFTEXTFIELD_USEFONT", SWFTEXTFIELD_USEFONT); CONSTANT("SWFTEXTFIELD_AUTOSIZE", SWFTEXTFIELD_AUTOSIZE); /* flags for SWFTextField_align */ @@ -4257,6 +6122,15 @@ CONSTANT("SWFACTION_KEYDOWN", SWFACTION_KEYDOWN); CONSTANT("SWFACTION_KEYUP", SWFACTION_KEYUP); CONSTANT("SWFACTION_DATA", SWFACTION_DATA); + CONSTANT("SWFACTION_INIT", SWFACTION_INIT); + CONSTANT("SWFACTION_PRESS", SWFACTION_PRESS); + CONSTANT("SWFACTION_RELEASE", SWFACTION_RELEASE); + CONSTANT("SWFACTION_RELEASEOUTSIDE", SWFACTION_RELEASEOUTSIDE); + CONSTANT("SWFACTION_ROLLOVER", SWFACTION_ROLLOVER); + CONSTANT("SWFACTION_DRAGOVER", SWFACTION_DRAGOVER); + CONSTANT("SWFACTION_DRAGOUT", SWFACTION_DRAGOUT); + CONSTANT("SWFACTION_KEYPRESS", SWFACTION_KEYPRESS); + CONSTANT("SWFACTION_CONSTRUCT", SWFACTION_CONSTRUCT); /* flags for SWFSound */ CONSTANT("SWF_SOUND_NOT_COMPRESSED", SWF_SOUND_NOT_COMPRESSED); @@ -4273,6 +6147,72 @@ CONSTANT("SWF_SOUND_MONO", SWF_SOUND_MONO); CONSTANT("SWF_SOUND_STEREO", SWF_SOUND_STEREO); +#ifdef HAVE_NEW_MING + /* Blend Modes */ + CONSTANT("SWFBLEND_MODE_NORMAL", SWFBLEND_MODE_NORMAL); + CONSTANT("SWFBLEND_MODE_LAYER", SWFBLEND_MODE_LAYER); + CONSTANT("SWFBLEND_MODE_MULT", SWFBLEND_MODE_MULT); + CONSTANT("SWFBLEND_MODE_SCREEN", SWFBLEND_MODE_SCREEN); + CONSTANT("SWFBLEND_MODE_DARKEN", SWFBLEND_MODE_DARKEN); + CONSTANT("SWFBLEND_MODE_LIGHTEN", SWFBLEND_MODE_LIGHTEN); + CONSTANT("SWFBLEND_MODE_ADD", SWFBLEND_MODE_ADD); + CONSTANT("SWFBLEND_MODE_SUB", SWFBLEND_MODE_SUB); + CONSTANT("SWFBLEND_MODE_DIFF", SWFBLEND_MODE_DIFF); + CONSTANT("SWFBLEND_MODE_INV", SWFBLEND_MODE_INV); + CONSTANT("SWFBLEND_MODE_ALPHA", SWFBLEND_MODE_ALPHA); + CONSTANT("SWFBLEND_MODE_ERASE", SWFBLEND_MODE_ERASE); + CONSTANT("SWFBLEND_MODE_OVERLAY", SWFBLEND_MODE_OVERLAY); + CONSTANT("SWFBLEND_MODE_HARDLIGHT", SWFBLEND_MODE_HARDLIGHT); + + /* filter types */ + CONSTANT("SWFFILTER_TYPE_DROPSHADOW", SWFFILTER_TYPE_DROPSHADOW); + CONSTANT("SWFFILTER_TYPE_BLUR", SWFFILTER_TYPE_BLUR); + CONSTANT("SWFFILTER_TYPE_GLOW", SWFFILTER_TYPE_GLOW); + CONSTANT("SWFFILTER_TYPE_BEVEL", SWFFILTER_TYPE_BEVEL); + CONSTANT("SWFFILTER_TYPE_GRADIENTGLOW", SWFFILTER_TYPE_GRADIENTGLOW); + CONSTANT("SWFFILTER_TYPE_CONVOLUTION", SWFFILTER_TYPE_CONVOLUTION); + CONSTANT("SWFFILTER_TYPE_COLORMATRIX", SWFFILTER_TYPE_COLORMATRIX); + CONSTANT("SWFFILTER_TYPE_GRADIENTBEVEL", SWFFILTER_TYPE_GRADIENTBEVEL); + + /* filter flags */ + CONSTANT("SWFFILTER_FLAG_CLAMP", FILTER_FLAG_CLAMP); + CONSTANT("SWFFILTER_FLAG_PRESERVE_ALPHA", FILTER_FLAG_PRESERVE_ALPHA); + + /* filter modes */ + CONSTANT("SWFFILTER_MODE_INNER", FILTER_MODE_INNER); + CONSTANT("SWFFILTER_MODE_KO", FILTER_MODE_KO); + CONSTANT("SWFFILTER_MODE_COMPOSITE", FILTER_MODE_COMPOSITE); + CONSTANT("SWFFILTER_MODE_ONTOP", FILTER_MODE_ONTOP); + + /* new gradient features */ + CONSTANT("SWF_GRADIENT_PAD", SWF_GRADIENT_PAD); + CONSTANT("SWF_GRADIENT_REFLECT", SWF_GRADIENT_REFLECT); + CONSTANT("SWF_GRADIENT_REPEAT", SWF_GRADIENT_REPEAT); + CONSTANT("SWF_GRADIENT_NORMAL", SWF_GRADIENT_NORMAL); + CONSTANT("SWF_GRADIENT_LINEAR", SWF_GRADIENT_LINEAR); + + /* shape options */ + CONSTANT("SWF_SHAPE3", SWF_SHAPE3); + CONSTANT("SWF_SHAPE4", SWF_SHAPE4); + CONSTANT("SWF_SHAPE_USESCALINGSTROKES", SWF_SHAPE_USESCALINGSTROKES); + CONSTANT("SWF_SHAPE_USENONSCALINGSTROKES", SWF_SHAPE_USENONSCALINGSTROKES); + + /* linestyle 2 flags */ + CONSTANT("SWF_LINESTYLE_CAP_ROUND", SWF_LINESTYLE_CAP_ROUND); + CONSTANT("SWF_LINESTYLE_CAP_NONE", SWF_LINESTYLE_CAP_NONE); + CONSTANT("SWF_LINESTYLE_CAP_SQUARE", SWF_LINESTYLE_CAP_SQUARE); + CONSTANT("SWF_LINESTYLE_JOIN_ROUND", SWF_LINESTYLE_JOIN_ROUND); + CONSTANT("SWF_LINESTYLE_JOIN_BEVEL", SWF_LINESTYLE_JOIN_BEVEL); + CONSTANT("SWF_LINESTYLE_JOIN_MITER", SWF_LINESTYLE_JOIN_MITER); + CONSTANT("SWF_LINESTYLE_FLAG_NOHSCALE", SWF_LINESTYLE_FLAG_NOHSCALE); + CONSTANT("SWF_LINESTYLE_FLAG_NOVSCALE", SWF_LINESTYLE_FLAG_NOVSCALE); + CONSTANT("SWF_LINESTYLE_FLAG_HINTING", SWF_LINESTYLE_FLAG_HINTING); + CONSTANT("SWF_LINESTYLE_FLAG_NOCLOSE", SWF_LINESTYLE_FLAG_NOCLOSE); + CONSTANT("SWF_LINESTYLE_FLAG_ENDCAP_ROUND", SWF_LINESTYLE_FLAG_ENDCAP_ROUND); + CONSTANT("SWF_LINESTYLE_FLAG_ENDCAP_NONE", SWF_LINESTYLE_FLAG_ENDCAP_NONE); + CONSTANT("SWF_LINESTYLE_FLAG_ENDCAP_SQUARE", SWF_LINESTYLE_FLAG_ENDCAP_SQUARE); +#endif + le_swfshapep = zend_register_list_destructors_ex(destroy_SWFShape_resource, NULL, "SWFShape", module_number); le_swffillp = zend_register_list_destructors_ex(destroy_SWFFill_resource, NULL, "SWFFill", module_number); le_swfgradientp = zend_register_list_destructors_ex(destroy_SWFGradient_resource, NULL, "SWFGradient", module_number); @@ -4285,17 +6225,29 @@ le_swfbuttonp = zend_register_list_destructors_ex(destroy_SWFButton_resource, NULL, "SWFButton", module_number); le_swfactionp = zend_register_list_destructors_ex(NULL, NULL, "SWFAction", module_number); le_swfmorphp = zend_register_list_destructors_ex(destroy_SWFMorph_resource, NULL, "SWFMorph", module_number); + le_swfmovieclipp = zend_register_list_destructors_ex(destroy_SWFSprite_resource, NULL, "SWFMovieClip", module_number); le_swfspritep = zend_register_list_destructors_ex(destroy_SWFSprite_resource, NULL, "SWFSprite", module_number); le_swfinputp = zend_register_list_destructors_ex(destroy_SWFInput_resource, NULL, "SWFInput", module_number); le_swfsoundp = zend_register_list_destructors_ex(destroy_SWFSound_resource, NULL, "SWFSound", module_number); #ifdef HAVE_NEW_MING - le_swffontcharp = zend_register_list_destructors_ex(destroy_SWFFontCharacter_resource, NULL, "SWFFontCharacter", module_number); + le_swffontcharp = zend_register_list_destructors_ex(NULL, NULL, "SWFFontCharacter", module_number); + le_swfbuttonrecordp = zend_register_list_destructors_ex(NULL, NULL, "SWFButtonRecord", module_number); le_swfsoundinstancep = zend_register_list_destructors_ex(NULL, NULL, "SWFSoundInstance", module_number); le_swfvideostreamp = zend_register_list_destructors_ex(destroy_SWFVideoStream_resource, NULL, "SWFVideoStream", module_number); -#endif -#ifdef HAVE_SWFPREBUILTCLIP + le_swfbinarydatap = zend_register_list_destructors_ex(destroy_SWFBinaryData_resource, NULL, "SWFBinaryData", module_number); + le_swfinitactionp = zend_register_list_destructors_ex(NULL, NULL, "SWFInitAction", module_number); le_swfprebuiltclipp = zend_register_list_destructors_ex(destroy_SWFPrebuiltClip_resource, NULL, "SWFPrebuiltClip", module_number); + le_swfsoundstreamp = zend_register_list_destructors_ex(destroy_SWFSoundStream_resource, NULL, "SWFSoundStream", module_number); + le_swffilterp = zend_register_list_destructors_ex(destroy_SWFFilter_resource, NULL, "SWFFilter", module_number); + le_swfblurp = zend_register_list_destructors_ex(destroy_SWFBlur_resource, NULL, "SWFBlur", module_number); + le_swfshadowp = zend_register_list_destructors_ex(destroy_SWFShadow_resource, NULL, "SWFShadow", module_number); + le_swffiltermatrixp = zend_register_list_destructors_ex(destroy_SWFFilterMatrix_resource, NULL, "SWFFilterMatrix", module_number); + le_swfcharacterp = zend_register_list_destructors_ex(NULL, NULL, "SWFCharacter", module_number); + le_swfcxformp = zend_register_list_destructors_ex(destroy_SWFCXform_resource, NULL, "SWFCXform", module_number); + le_swfmatrixp = zend_register_list_destructors_ex(NULL, NULL, "SWFMatrix", module_number); + le_swfbrowserfontp = zend_register_list_destructors_ex(destroy_SWFBrowserFont_resource, NULL, "SWFBrowserFont", module_number); + le_swffontcollectionp = zend_register_list_destructors_ex(destroy_SWFFontCollection_resource, NULL, "SWFFontCollection", module_number); #endif INIT_CLASS_ENTRY(shape_class_entry, "SWFShape", swfshape_functions); @@ -4310,16 +6262,30 @@ INIT_CLASS_ENTRY(button_class_entry, "SWFButton", swfbutton_functions); INIT_CLASS_ENTRY(action_class_entry, "SWFAction", swfaction_functions); INIT_CLASS_ENTRY(morph_class_entry, "SWFMorph", swfmorph_functions); + INIT_CLASS_ENTRY(movieclip_class_entry, "SWFMovieClip", swfmovieclip_functions); INIT_CLASS_ENTRY(sprite_class_entry, "SWFSprite", swfsprite_functions); INIT_CLASS_ENTRY(sound_class_entry, "SWFSound", swfsound_functions); #ifdef HAVE_NEW_MING INIT_CLASS_ENTRY(fontchar_class_entry, "SWFFontChar", swffontchar_functions); + INIT_CLASS_ENTRY(buttonrecord_class_entry, "SWFButtonRecord", swfbuttonrecord_functions); INIT_CLASS_ENTRY(soundinstance_class_entry, "SWFSoundInstance", swfsoundinstance_functions); INIT_CLASS_ENTRY(videostream_class_entry, "SWFVideoStream", swfvideostream_functions); -#endif -#ifdef HAVE_SWFPREBUILTCLIP + INIT_CLASS_ENTRY(binarydata_class_entry, "SWFBinaryData", swfbinarydata_functions); + INIT_CLASS_ENTRY(initaction_class_entry, "SWFInitAction", swfinitaction_functions); INIT_CLASS_ENTRY(prebuiltclip_class_entry, "SWFPrebuiltClip", swfprebuiltclip_functions); + INIT_CLASS_ENTRY(soundstream_class_entry, "SWFSoundStream", swfsoundstream_functions); + INIT_CLASS_ENTRY(filter_class_entry, "SWFFilter", swffilter_functions); + INIT_CLASS_ENTRY(filtermatrix_class_entry, "SWFFilterMatrix", swffiltermatrix_functions); + INIT_CLASS_ENTRY(shadow_class_entry, "SWFShadow", swfshadow_functions); + INIT_CLASS_ENTRY(blur_class_entry, "SWFBlur", swfblur_functions); + INIT_CLASS_ENTRY(cxform_class_entry, "SWFCXform", swfcxform_functions); + INIT_CLASS_ENTRY(matrix_class_entry, "SWFMatrix", swfmatrix_functions); + INIT_CLASS_ENTRY(input_class_entry, "SWFInput", swfinput_functions); + INIT_CLASS_ENTRY(browserfont_class_entry, "SWFBrowserFont", swfbrowserfont_functions); + INIT_CLASS_ENTRY(fontcollection_class_entry, "SWFFontCollection", swffontcollection_functions); #endif + INIT_CLASS_ENTRY(character_class_entry, "SWFCharacter", swfcharacter_functions); + shape_class_entry_ptr = zend_register_internal_class(&shape_class_entry TSRMLS_CC); fill_class_entry_ptr = zend_register_internal_class(&fill_class_entry TSRMLS_CC); @@ -4333,17 +6299,29 @@ button_class_entry_ptr = zend_register_internal_class(&button_class_entry TSRMLS_CC); action_class_entry_ptr = zend_register_internal_class(&action_class_entry TSRMLS_CC); morph_class_entry_ptr = zend_register_internal_class(&morph_class_entry TSRMLS_CC); + movieclip_class_entry_ptr = zend_register_internal_class(&movieclip_class_entry TSRMLS_CC); sprite_class_entry_ptr = zend_register_internal_class(&sprite_class_entry TSRMLS_CC); sound_class_entry_ptr = zend_register_internal_class(&sound_class_entry TSRMLS_CC); #ifdef HAVE_NEW_MING fontchar_class_entry_ptr = zend_register_internal_class(&fontchar_class_entry TSRMLS_CC); + buttonrecord_class_entry_ptr = zend_register_internal_class(&buttonrecord_class_entry TSRMLS_CC); soundinstance_class_entry_ptr = zend_register_internal_class(&soundinstance_class_entry TSRMLS_CC); videostream_class_entry_ptr = zend_register_internal_class(&videostream_class_entry TSRMLS_CC); -#endif -#ifdef HAVE_SWFPREBUILTCLIP + binarydata_class_entry_ptr = zend_register_internal_class(&binarydata_class_entry TSRMLS_CC); + initaction_class_entry_ptr = zend_register_internal_class(&initaction_class_entry TSRMLS_CC); prebuiltclip_class_entry_ptr = zend_register_internal_class(&prebuiltclip_class_entry TSRMLS_CC); + soundstream_class_entry_ptr = zend_register_internal_class(&soundstream_class_entry TSRMLS_CC); + filter_class_entry_ptr = zend_register_internal_class(&filter_class_entry TSRMLS_CC); + filtermatrix_class_entry_ptr = zend_register_internal_class(&filtermatrix_class_entry TSRMLS_CC); + shadow_class_entry_ptr = zend_register_internal_class(&shadow_class_entry TSRMLS_CC); + blur_class_entry_ptr = zend_register_internal_class(&blur_class_entry TSRMLS_CC); + cxform_class_entry_ptr = zend_register_internal_class(&cxform_class_entry TSRMLS_CC); + matrix_class_entry_ptr = zend_register_internal_class(&matrix_class_entry TSRMLS_CC); + input_class_entry_ptr = zend_register_internal_class(&input_class_entry TSRMLS_CC); + browserfont_class_entry_ptr = zend_register_internal_class(&browserfont_class_entry TSRMLS_CC); + fontcollection_class_entry_ptr = zend_register_internal_class(&fontcollection_class_entry TSRMLS_CC); #endif - + character_class_entry_ptr = zend_register_internal_class(&character_class_entry TSRMLS_CC); return SUCCESS; } /* }}} */ diff -ruN php-5.2.5.orig/ext/reflection/config.m4 php-5.2.5/ext/reflection/config.m4 --- php-5.2.5.orig/ext/reflection/config.m4 2006-08-23 03:47:21.000000000 -0600 +++ php-5.2.5/ext/reflection/config.m4 2007-12-10 22:18:28.000000000 -0700 @@ -2,7 +2,7 @@ dnl config.m4 for extension reflection PHP_ARG_ENABLE(reflection, whether to enable reflection support, -[ --disable-reflection Disable reflection support], yes, no) +[ --disable-reflection Disable reflection support], yes) if test "$PHP_REFLECTION" != "no"; then AC_DEFINE(HAVE_REFLECTION, 1, [Whether Reflection is enabled]) diff -ruN php-5.2.5.orig/ext/session/session.c php-5.2.5/ext/session/session.c --- php-5.2.5.orig/ext/session/session.c 2007-08-02 19:16:40.000000000 -0600 +++ php-5.2.5/ext/session/session.c 2007-12-10 21:42:48.000000000 -0700 @@ -678,11 +678,11 @@ PHP_INI_BEGIN() STD_PHP_INI_BOOLEAN("session.bug_compat_42", "1", PHP_INI_ALL, OnUpdateBool, bug_compat, php_ps_globals, ps_globals) STD_PHP_INI_BOOLEAN("session.bug_compat_warn", "1", PHP_INI_ALL, OnUpdateBool, bug_compat_warn, php_ps_globals, ps_globals) - STD_PHP_INI_ENTRY("session.save_path", "", PHP_INI_ALL, OnUpdateSaveDir,save_path, php_ps_globals, ps_globals) + STD_PHP_INI_ENTRY("session.save_path", "@FINKPREFIX@/var/lib/php5", PHP_INI_ALL, OnUpdateSaveDir,save_path, php_ps_globals, ps_globals) STD_PHP_INI_ENTRY("session.name", "PHPSESSID", PHP_INI_ALL, OnUpdateString, session_name, php_ps_globals, ps_globals) PHP_INI_ENTRY("session.save_handler", "files", PHP_INI_ALL, OnUpdateSaveHandler) STD_PHP_INI_BOOLEAN("session.auto_start", "0", PHP_INI_ALL, OnUpdateBool, auto_start, php_ps_globals, ps_globals) - STD_PHP_INI_ENTRY("session.gc_probability", "1", PHP_INI_ALL, OnUpdateLong, gc_probability, php_ps_globals, ps_globals) + STD_PHP_INI_ENTRY("session.gc_probability", "0", PHP_INI_ALL, OnUpdateLong, gc_probability, php_ps_globals, ps_globals) STD_PHP_INI_ENTRY("session.gc_divisor", "100", PHP_INI_ALL, OnUpdateLong, gc_divisor, php_ps_globals, ps_globals) STD_PHP_INI_ENTRY("session.gc_maxlifetime", "1440", PHP_INI_ALL, OnUpdateLong, gc_maxlifetime, php_ps_globals, ps_globals) PHP_INI_ENTRY("session.serialize_handler", "php", PHP_INI_ALL, OnUpdateSerializer) diff -ruN php-5.2.5.orig/ext/sockets/sockets.c php-5.2.5/ext/sockets/sockets.c --- php-5.2.5.orig/ext/sockets/sockets.c 2007-09-26 04:55:07.000000000 -0600 +++ php-5.2.5/ext/sockets/sockets.c 2007-12-10 22:09:11.000000000 -0700 @@ -602,6 +602,7 @@ php_sock = (php_socket*) zend_fetch_resource(element TSRMLS_CC, -1, le_socket_name, NULL, 1, le_socket); if (!php_sock) continue; /* If element is not a resource, skip it */ + if (php_sock->bsd_socket > FD_SETSIZE) continue; /* must ignore it */ if (PHP_SAFE_FD_ISSET(php_sock->bsd_socket, fds)) { /* Add fd to new array */ diff -ruN php-5.2.5.orig/ext/standard/datetime.c php-5.2.5/ext/standard/datetime.c --- php-5.2.5.orig/ext/standard/datetime.c 2007-06-07 02:59:00.000000000 -0600 +++ php-5.2.5/ext/standard/datetime.c 2007-12-10 22:19:03.000000000 -0700 @@ -20,6 +20,9 @@ /* $Id: datetime.c 272374 2008-12-31 11:17:49Z sebastian $ */ +#define _XOPEN_SOURCE /* needed to get strptime() declared */ +#define _BSD_SOURCE /* needed to get ulong declared */ + #include "php.h" #include "zend_operators.h" #include "datetime.h" diff -ruN php-5.2.5.orig/ext/standard/dl.c php-5.2.5/ext/standard/dl.c --- php-5.2.5.orig/ext/standard/dl.c 2007-09-18 14:19:34.000000000 -0600 +++ php-5.2.5/ext/standard/dl.c 2007-12-10 21:36:33.000000000 -0700 @@ -81,12 +81,7 @@ if ((strncmp(sapi_module.name, "cgi", 3)!=0) && (strcmp(sapi_module.name, "cli")!=0) && (strncmp(sapi_module.name, "embed", 5)!=0)) { -#ifdef ZTS - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Not supported in multithreaded Web servers - use extension=%s in your php.ini", Z_STRVAL_PP(file)); - RETURN_FALSE; -#else php_error_docref(NULL TSRMLS_CC, E_STRICT, "dl() is deprecated - use extension=%s in your php.ini", Z_STRVAL_PP(file)); -#endif } php_dl(*file, MODULE_TEMPORARY, return_value, 0 TSRMLS_CC); diff -ruN php-5.2.5.orig/ext/standard/dns.c php-5.2.5/ext/standard/dns.c --- php-5.2.5.orig/ext/standard/dns.c 2007-06-26 05:04:55.000000000 -0600 +++ php-5.2.5/ext/standard/dns.c 2007-12-11 08:51:54.000000000 -0700 @@ -48,21 +48,21 @@ #else /* This holds good for NetWare too, both for Winsock and Berkeley sockets */ #include #if HAVE_ARPA_INET_H -#include +#include #endif -#include +#include #ifdef _OSD_POSIX #undef STATUS #undef T_UNSPEC #endif #if HAVE_ARPA_NAMESER_COMPAT_H -#include +#include #endif #if HAVE_ARPA_NAMESER_H -#include +#include #endif #if HAVE_RESOLV_H -#include +#include #endif #endif diff -ruN php-5.2.5.orig/ext/standard/info.c php-5.2.5/ext/standard/info.c --- php-5.2.5.orig/ext/standard/info.c 2007-07-20 19:24:26.000000000 -0600 +++ php-5.2.5/ext/standard/info.c 2007-12-10 21:35:25.000000000 -0700 @@ -487,7 +487,7 @@ php_info_print_table_start(); php_info_print_table_row(2, "System", php_uname ); php_info_print_table_row(2, "Build Date", __DATE__ " " __TIME__ ); -#ifdef CONFIGURE_COMMAND +#if 0 php_info_print_table_row(2, "Configure Command", CONFIGURE_COMMAND ); #endif if (sapi_module.pretty_name) { diff -ruN php-5.2.5.orig/ext/standard/proc_open.c php-5.2.5/ext/standard/proc_open.c --- php-5.2.5.orig/ext/standard/proc_open.c 2007-09-12 05:42:43.000000000 -0600 +++ php-5.2.5/ext/standard/proc_open.c 2007-12-10 22:20:02.000000000 -0700 @@ -62,7 +62,7 @@ * */ #ifdef PHP_CAN_SUPPORT_PROC_OPEN -#if 0 && HAVE_PTSNAME && HAVE_GRANTPT && HAVE_UNLOCKPT && HAVE_SYS_IOCTL_H && HAVE_TERMIOS_H +#if HAVE_PTSNAME && HAVE_GRANTPT && HAVE_UNLOCKPT && HAVE_SYS_IOCTL_H && HAVE_TERMIOS_H # include # include # define PHP_CAN_DO_PTS 1 diff -ruN php-5.2.5.orig/ext/standard/streamsfuncs.c php-5.2.5/ext/standard/streamsfuncs.c --- php-5.2.5.orig/ext/standard/streamsfuncs.c 2007-10-04 07:31:11.000000000 -0600 +++ php-5.2.5/ext/standard/streamsfuncs.c 2007-12-10 22:09:52.000000000 -0700 @@ -603,6 +592,8 @@ * is not displayed. * */ if (SUCCESS == php_stream_cast(stream, PHP_STREAM_AS_FD_FOR_SELECT | PHP_STREAM_CAST_INTERNAL, (void*)&this_fd, 1) && this_fd >= 0) { + if (this_fd > FD_SETSIZE) + continue; PHP_SAFE_FD_SET(this_fd, fds); diff -ruN php-5.2.12.orig/ext/standard/string.c php-5.2.12/ext/standard/string.c --- php-5.2.12.orig/ext/standard/string.c 2009-08-31 08:28:46.000000000 -0400 +++ php-5.2.12/ext/standard/string.c 2013-01-15 01:04:21.000000000 -0500 @@ -39,6 +39,9 @@ #endif #ifdef HAVE_LIBINTL # include /* For LC_MESSAGES */ + #ifdef setlocale + # undef setlocale /* Uh, libintl, don't F* our symbols please */ + #endif #endif #include diff -ruN php-5.2.5.orig/fink/extramodulelist php-5.2.5/fink/extramodulelist --- php-5.2.5.orig/fink/extramodulelist 1969-12-31 17:00:00.000000000 -0700 +++ php-5.2.5/fink/extramodulelist 2007-12-11 19:09:48.000000000 -0700 @@ -0,0 +1,6 @@ +mysql MySQL mysqli +mysql MySQL pdo_mysql +common PDO pdo +odbc ODBC pdo_odbc +pgsql PostgreSQL pdo_pgsql +sqlite SQLite pdo_sqlite diff -ruN php-5.2.5.orig/fink/maxlifetime php-5.2.5/fink/maxlifetime --- php-5.2.5.orig/fink/maxlifetime 1969-12-31 17:00:00.000000000 -0700 +++ php-5.2.5/fink/maxlifetime 2007-12-10 16:19:49.000000000 -0700 @@ -0,0 +1,14 @@ +#!/bin/sh -e + +max=1440 + +for ini in @FINKPREFIX@/etc/php5/*/php.ini; do + cur=$(sed -n -e 's/^[[:space:]]*session.gc_maxlifetime[[:space:]]*=[[:space:]]*\([0-9]\+\).*$/\1/p' $ini 2>/dev/null || true); + [ -z "$cur" ] && cur=0 + [ "$cur" -gt "$max" ] && max=$cur +done + +echo $(($max/60)) + +exit 0 + diff -ruN php-5.2.5.orig/fink/modulelist php-5.2.5/fink/modulelist --- php-5.2.5.orig/fink/modulelist 1969-12-31 17:00:00.000000000 -0700 +++ php-5.2.5/fink/modulelist 2007-12-11 19:09:36.000000000 -0700 @@ -0,0 +1,17 @@ +curl CURL +gd GD +gmp GMP +imap IMAP +ldap LDAP +mcrypt MCrypt +mhash MHASH +mysql MySQL +odbc ODBC +pgsql PostgreSQL +pspell pspell +recode recode +snmp SNMP +sqlite SQLite +tidy tidy +xmlrpc XML-RPC +xsl XSL diff -ruN php-5.2.5.orig/fink/php5-module.ini php-5.2.5/fink/php5-module.ini --- php-5.2.5.orig/fink/php5-module.ini 1969-12-31 17:00:00.000000000 -0700 +++ php-5.2.5/fink/php5-module.ini 2007-12-11 19:04:28.000000000 -0700 @@ -0,0 +1,2 @@ +# configuration for php @extname@ module +extension=@dsoname@.so diff -ruN php-5.2.5.orig/fink/php5.conf php-5.2.5/fink/php5.conf --- php-5.2.5.orig/fink/php5.conf 1969-12-31 17:00:00.000000000 -0700 +++ php-5.2.5/fink/php5.conf 2007-12-10 15:56:24.000000000 -0700 @@ -0,0 +1,4 @@ + + AddType application/x-httpd-php .php .phtml .php3 + AddType application/x-httpd-php-source .phps + diff -ruN php-5.2.5.orig/fink/php5.cron php-5.2.5/fink/php5.cron --- php-5.2.5.orig/fink/php5.cron 1969-12-31 17:00:00.000000000 -0700 +++ php-5.2.5/fink/php5.cron 2007-12-10 16:31:52.000000000 -0700 @@ -0,0 +1,7 @@ +# @FINKPREFIX@/etc/cron.d/php5: crontab fragment for php5 +# This purges session files older than X, where X is defined in seconds +# as the largest value of session.gc_maxlifetime from all your php.ini +# files, or 24 minutes if not defined. See @FINKPREFIX@/lib/php5/maxlifetime + +# Look for and purge old sessions every 30 minutes +09,39 * * * * root [ -d @FINKPREFIX@/var/lib/php5 ] && find @FINKPREFIX@/var/lib/php5/ -type f -cmin +$(@FINKPREFIX@/lib/php5/maxlifetime) -print0 | xargs -r -0 rm diff -ruN php-5.2.5.orig/fink/php5.load php-5.2.5/fink/php5.load --- php-5.2.5.orig/fink/php5.load 1969-12-31 17:00:00.000000000 -0700 +++ php-5.2.5/fink/php5.load 2007-12-12 09:09:32.000000000 -0700 @@ -0,0 +1 @@ +LoadModule php5_module @FINKPREFIX@/lib/apache2/modules/libphp5.so diff -ruN php-5.2.5.orig/php.ini-dist php-5.2.5/php.ini-dist --- php-5.2.5.orig/php.ini-dist 2007-08-21 17:24:18.000000000 -0600 +++ php-5.2.5/php.ini-dist 2007-12-10 22:22:20.000000000 -0700 @@ -166,6 +166,11 @@ ; ; Safe Mode ; +; NOTE: this is considered a "broken" security measure. +; Applications relying on this feature will not recieve full +; support by the security team. For more information please +; see @FINKPREFIX@/share/doc/php5-common/README.Debian.security +; safe_mode = Off ; By default, Safe Mode does a UID compare check when @@ -202,6 +207,13 @@ ; and below. This directive makes most sense if used in a per-directory ; or per-virtualhost web server configuration file. This directive is ; *NOT* affected by whether Safe Mode is turned On or Off. + +; NOTE: this is considered a "broken" security measure. +; Applications relying on this feature will not recieve full +; support by the security team. For more information please +; see @FINKPREFIX@/share/doc/php5-common/README.Debian.security +; + ;open_basedir = ; This directive allows you to disable certain functions for security reasons. @@ -416,6 +428,11 @@ ; You should do your best to write your scripts so that they do not require ; register_globals to be on; Using form variables as globals can easily lead ; to possible security problems, if the code is not very well thought of. + +; NOTE: applications relying on this feature will not recieve full +; support by the security team. For more information please +; see @FINKPREFIX@/share/doc/php5-common/README.Debian.security +; register_globals = Off ; Whether or not to register the old-style input arrays, HTTP_GET_VARS @@ -471,7 +488,7 @@ ;;;;;;;;;;;;;;;;;;;;;;;;; ; UNIX: "/path1:/path2" -;include_path = ".:/php/includes" +;include_path = ".:@FINKPREFIX@/share/php" ; ; Windows: "\path1;\path2" ;include_path = ".;c:\php\includes" @@ -488,7 +505,7 @@ user_dir = ; Directory in which the loadable extensions (modules) reside. -extension_dir = "./" +; extension_dir = "./" ; Whether or not to enable the dl() function. The dl() function does NOT work ; properly in multithreaded servers, such as IIS or Zeus, and is automatically @@ -604,58 +621,6 @@ ; extension_dir directive above. -; Windows Extensions -; Note that ODBC support is built in, so no dll is needed for it. -; Note that many DLL files are located in the extensions/ (PHP 4) ext/ (PHP 5) -; extension folders as well as the separate PECL DLL download (PHP 5). -; Be sure to appropriately set the extension_dir directive. - -;extension=php_bz2.dll -;extension=php_curl.dll -;extension=php_dba.dll -;extension=php_dbase.dll -;extension=php_exif.dll -;extension=php_fdf.dll -;extension=php_gd2.dll -;extension=php_gettext.dll -;extension=php_gmp.dll -;extension=php_ifx.dll -;extension=php_imap.dll -;extension=php_interbase.dll -;extension=php_ldap.dll -;extension=php_mbstring.dll -;extension=php_mcrypt.dll -;extension=php_mhash.dll -;extension=php_mime_magic.dll -;extension=php_ming.dll -;extension=php_msql.dll -;extension=php_mssql.dll -;extension=php_mysql.dll -;extension=php_mysqli.dll -;extension=php_oci8.dll -;extension=php_openssl.dll -;extension=php_pdo.dll -;extension=php_pdo_firebird.dll -;extension=php_pdo_mssql.dll -;extension=php_pdo_mysql.dll -;extension=php_pdo_oci.dll -;extension=php_pdo_oci8.dll -;extension=php_pdo_odbc.dll -;extension=php_pdo_pgsql.dll -;extension=php_pdo_sqlite.dll -;extension=php_pgsql.dll -;extension=php_pspell.dll -;extension=php_shmop.dll -;extension=php_snmp.dll -;extension=php_soap.dll -;extension=php_sockets.dll -;extension=php_sqlite.dll -;extension=php_sybase_ct.dll -;extension=php_tidy.dll -;extension=php_xmlrpc.dll -;extension=php_xsl.dll -;extension=php_zip.dll - ;;;;;;;;;;;;;;;;;;; ; Module Settings ; ;;;;;;;;;;;;;;;;;;; @@ -992,7 +957,7 @@ ; ; where MODE is the octal representation of the mode. Note that this ; does not overwrite the process's umask. -;session.save_path = "/tmp" +;session.save_path = "@FINKPREFIX@/var/lib/php5" ; Whether to use cookies. session.use_cookies = 1 @@ -1030,7 +995,10 @@ ; e.g. 1/100 means there is a 1% chance that the GC process starts ; on each request. -session.gc_probability = 1 +; This is disabled in the Fink packages, due to the strict permissions +; on @FINKPREFIX@/var/lib/php5. Instead of setting this here, see the cronjob at +; @FINKPREFIX@/etc/cron.d/php5, which uses the session.gc_maxlifetime setting below +;session.gc_probability = 0 session.gc_divisor = 100 ; After this number of seconds, stored data will be seen as 'garbage' and diff -ruN php-5.2.5.orig/php.ini-paranoid php-5.2.5/php.ini-paranoid --- php-5.2.5.orig/php.ini-paranoid 1969-12-31 17:00:00.000000000 -0700 +++ php-5.2.5/php.ini-paranoid 2007-12-10 22:02:41.000000000 -0700 @@ -0,0 +1,1195 @@ +[PHP] + +;;;;;;;;;;;;;;;;;;; +; About this file ; +;;;;;;;;;;;;;;;;;;; +; +; This is the paranoid, PHP 4-style version of the php.ini-dist file. It +; sets some non standard settings, that make PHP more efficient, more secure +; in a very paranoid way. Note that these security settings will make some +; applications not work properly. +; +; The price is that with these settings, PHP may be incompatible with some +; applications, and sometimes, more difficult to develop with. Using this +; file is recommended for production sites which want a high degree of +; security. As all of the changes from the standard settings are thoroughly +; documented, you can go over each one, +; and decide whether you want to use it or not. +; +; For general information about the php.ini file, please consult the +; php.ini-dist file, included in your PHP distribution. +; +; For further information see +; http://www.php.net/features.safe-mode +; http://www.phpsecure.info/ +; +; This file is different from the php.ini-dist file in the fact that it features +; different values for several directives, in order to improve performance, while +; possibly breaking compatibility with the standard out-of-the-box behavior of +; PHP 3. Please make sure you read what's different, and modify your scripts +; accordingly, if you decide to use this file instead. +; +; - safe_mode = On [Security, Performance loss] +; Do UID checks when opening files. Enabling safe_mode also enables +; other functions related to this mode. For more information read: +; http://www.php.net/features.safe-mode +; Worthwhile reading, however, is also +; http://ilia.ws/archives/18_PHPs_safe_mode_or_how_not_to_implement_security.html +; Bottomline: Do not trust that safe_mode will drive all your security vulnerabilities +; away. +; +; - safe_mode_protected_env_vars = LD_LIBRARY_PATH PATH [Security] +; Environment variables that users will not be able to modify through +; putenv() +; +; - open_basedir = /var/www/:/usr/lib/php4/ [Security, Performance loss] +; Limits the files that PHP can access to the directories specified. +; This includes the webroot and the usual location of PHP libraries +; (e.g. PEAR). Since all file locations are checked against this list +; before any access is allowed, this impacts in the performance of all +; file operations. +; +; - disable_functions = dl, phpinfo, system, .... [Security] +; Some functions can be used by attackers and can be malversed by +; applications, the list (not complete) of functions disabled includes +; functions which might have a severe impact to the system if wrongly used +; in scripts or subverted remotely by attackers. +; +; - expose_php = Off [?Security?] +; Not exposing that PHP is used in the site (nor its version) can affect +; how some dumb worms attempt to attack the site. Many might +; not check this and attempt to compromise the server nevertheless, +; however. This setting is just 'security by obscurity' so no real +; security at all (save vs. the dumbest attackers) +; +; - error_log = syslog [Security, Performance log] +; All errors are reported to syslog so that the errors can be easily +; sent outsite the site to a syslog server. This prevents an intruder +; from tampering with them in an attempt to hide his tracks since the +; logs are stored in a different location. It also helps in forensic +; investigation or when using automatic tools to produce reports or +; generate alarms based on the syslog information. +; +; - register_globals = Off [Security, Performance] +; Global variables are no longer registered for input data (POST, GET, cookies, +; environment and other server variables). Instead of using $foo, you must use +; you can use $_REQUEST["foo"] (includes any variable that arrives through the +; request, namely, POST, GET and cookie variables), or use one of the specific +; $_GET["foo"], $_POST["foo"], $_COOKIE["foo"] or $_FILES["foo"], depending +; on where the input originates. Also, you can look at the +; import_request_variables() function. +; Note that register_globals is going to be depracated (i.e., turned off by +; default) in the next version of PHP, because it often leads to security bugs. +; Read http://php.net/manual/en/security.registerglobals.php for further +; information. +; - display_errors = Off [Security] +; With this directive set to off, errors that occur during the execution of +; scripts will no longer be displayed as a part of the script output, and thus, +; will no longer be exposed to remote users. With some errors, the error message +; content may expose information about your script, web server, or database +; server that may be exploitable for hacking. Production sites should have this +; directive set to off. +; - log_errors = On [Security] +; This directive complements the above one. Any errors that occur during the +; execution of your script will be logged (typically, to your server's error log, +; but can be configured in several ways). Along with setting display_errors to off, +; this setup gives you the ability to fully understand what may have gone wrong, +; without exposing any sensitive information to remote users. +; - output_buffering = 4096 [Performance] +; Set a 4KB output buffer. Enabling output buffering typically results in less +; writes, and sometimes less packets sent on the wire, which can often lead to +; better performance. The gain this directive actually yields greatly depends +; on which Web server you're working with, and what kind of scripts you're using. +; - register_argc_argv = Off [Performance] +; Disables registration of the somewhat redundant $argv and $argc global +; variables. +; - magic_quotes_gpc = On [Security] +; Input data is escaped with slashes so that applications that do +; not use addslashes() are not so easily subjected to SQL injection +; when talking to SQL databases. +; +; - variables_order = "GPCS" [Performance] +; The environment variables are not hashed into the $HTTP_ENV_VARS[]. To access +; environment variables, you can use getenv() instead. +; - error_reporting = E_ALL [Code Cleanliness, Security(?)] +; By default, PHP surpresses errors of type E_NOTICE. These error messages +; are emitted for non-critical errors, but that could be a symptom of a bigger +; problem. Most notably, this will cause error messages about the use +; of uninitialized variables to be displayed. +; - allow_call_time_pass_reference = Off [Code cleanliness] +; It's not possible to decide to force a variable to be passed by reference +; when calling a function. The PHP 4 style to do this is by making the +; function require the relevant argument by reference. +; +; - enable_dl = Off [Security] +; The dl() function is not needed in most environments and does introduce +; a number of security issues. +; - file_uploads = Off [Security] +; File uploads should not be allowed to the server. +; - allow_url_fopen = Off [Security] +; File calls should not transparently retrieve files from the network +; since this could be subverted by attackers in poorly coded scripts +; by forcing them to download (and execute) malicious remote content +; from compromised hosts. This behaviour has been observed in automatic +; worms/tools that use it to scan and propagate through badly written +; applications (in conjuntion with other unsafe features) +; http://myhost/myapplication.php?include=http://roguesever/rogueapp.php + + +;;;;;;;;;;;;;;;;;;;; +; Language Options ; +;;;;;;;;;;;;;;;;;;;; + +; Enable the PHP scripting language engine under Apache. +engine = On + +; Allow the tags are recognized. +; NOTE: Using short tags should be avoided when developing applications or +; libraries that are meant for redistribution, or deployment on PHP +; servers which are not under your control, because short tags may not +; be supported on the target server. For portable, redistributable code, +; be sure not to use short tags. +short_open_tag = On + +; Allow ASP-style <% %> tags. +asp_tags = Off + +; The number of significant digits displayed in floating point numbers. +precision = 14 + +; Enforce year 2000 compliance (will cause problems with non-compliant browsers) +y2k_compliance = On + +; Output buffering allows you to send header lines (including cookies) even +; after you send body content, at the price of slowing PHP's output layer a +; bit. You can enable output buffering during runtime by calling the output +; buffering functions. You can also enable output buffering for all files by +; setting this directive to On. If you wish to limit the size of the buffer +; to a certain size - you can use a maximum number of bytes instead of 'On', as +; a value for this directive (e.g., output_buffering=4096). +output_buffering = 4096 + +; You can redirect all of the output of your scripts to a function. For +; example, if you set output_handler to "mb_output_handler", character +; encoding will be transparently converted to the specified encoding. +; Setting any output handler automatically turns on output buffering. +; Note: People who wrote portable scripts should not depend on this ini +; directive. Instead, explicitly set the output handler using ob_start(). +; Using this ini directive may cause problems unless you know what script +; is doing. +; Note: You cannot use both "mb_output_handler" with "ob_iconv_handler" +; and you cannot use both "ob_gzhandler" and "zlib.output_compression". +;output_handler = + +; Transparent output compression using the zlib library +; Valid values for this option are 'off', 'on', or a specific buffer size +; to be used for compression (default is 4KB) +; Note: Resulting chunk size may vary due to nature of compression. PHP +; outputs chunks that are few handreds bytes each as a result of compression. +; If you want larger chunk size for better performence, enable output_buffering +; also. +; Note: output_handler must be empty if this is set 'On' !!!! +; Instead you must use zlib.output_handler. +zlib.output_compression = Off + +; You cannot specify additional output handlers if zlib.output_compression +; is activated here. This setting does the same as output_handler but in +; a different order. +;zlib.output_handler = + +; Implicit flush tells PHP to tell the output layer to flush itself +; automatically after every output block. This is equivalent to calling the +; PHP function flush() after each and every call to print() or echo() and each +; and every HTML block. Turning this option on has serious performance +; implications and is generally recommended for debugging purposes only. +implicit_flush = Off + +; The unserialize callback function will be called (with the undefined class' +; name as parameter), if the unserializer finds an undefined class +; which should be instanciated. +; A warning appears if the specified function is not defined, or if the +; function doesn't include/implement the missing class. +; So only set this entry, if you really want to implement such a +; callback-function. +unserialize_callback_func= + +; When floats & doubles are serialized store serialize_precision significant +; digits after the floating point. The default value ensures that when floats +; are decoded with unserialize, the data will remain the same. +serialize_precision = 100 + +; Whether to enable the ability to force arguments to be passed by reference +; at function call time. This method is deprecated and is likely to be +; unsupported in future versions of PHP/Zend. The encouraged method of +; specifying which arguments should be passed by reference is in the function +; declaration. You're encouraged to try and turn this option Off and make +; sure your scripts work properly with it in order to ensure they will work +; with future versions of the language (you will receive a warning each time +; you use this feature, and the argument will be passed by value instead of by +; reference). +allow_call_time_pass_reference = Off + +; +; Safe Mode +; +safe_mode = On + +; By default, Safe Mode does a UID compare check when +; opening files. If you want to relax this to a GID compare, +; then turn on safe_mode_gid. +safe_mode_gid = Off + +; When safe_mode is on, UID/GID checks are bypassed when +; including files from this directory and its subdirectories. +; (directory must also be in include_path or full path must +; be used when including) +safe_mode_include_dir = + +; When safe_mode is on, only executables located in the safe_mode_exec_dir +; will be allowed to be executed via the exec family of functions. +; +; Note: This should be customised per site (if exec is permitted) +safe_mode_exec_dir = + +; Setting certain environment variables may be a potential security breach. +; This directive contains a comma-delimited list of prefixes. In Safe Mode, +; the user may only alter environment variables whose names begin with the +; prefixes supplied here. By default, users will only be able to set +; environment variables that begin with PHP_ (e.g. PHP_FOO=BAR). +; +; Note: If this directive is empty, PHP will let the user modify ANY +; environment variable! +safe_mode_allowed_env_vars = PHP_ + +; This directive contains a comma-delimited list of environment variables that +; the end user won't be able to change using putenv(). These variables will be +; protected even if safe_mode_allowed_env_vars is set to allow to change them. +safe_mode_protected_env_vars = LD_LIBRARY_PATH,PATH + +; open_basedir, if set, limits all file operations to the defined directory +; and below. This directive makes most sense if used in a per-directory +; or per-virtualhost web server configuration file. This directive is +; *NOT* affected by whether Safe Mode is turned On or Off. +; +; In Fink, the WebRoot is @FINKPREFIX@/var/www/ so we limit file operations to it. +open_basedir = @FINKPREFIX@/var/www/:/usr/lib/php4/ + +; This directive allows you to disable certain functions for security reasons. +; It receives a comma-delimited list of function names. This directive is +; *NOT* affected by whether Safe Mode is turned On or Off. +; +; Note: The list of functions disabled here might break some applications +; however, they are considered dangerous and often subverted by attackers +; remotely +disable_functions = dl, phpinfo, system, mail, include, shell_exec, exec, escapeshellarg, escapeshellcmd, passthru, proc_close, proc_open, proc_get_status, proc_nice, proc_open, proc_terminate, popen, pclose, chown, disk_free_space, disk_total_space, diskfreespace, fileinode, max_execution_time, set_time_limit,highlight_file, show_source + +; This directive allows you to disable certain classes for security reasons. +; It receives a comma-delimited list of class names. This directive is +; *NOT* affected by whether Safe Mode is turned On or Off. +disable_classes = + +; Colors for Syntax Highlighting mode. Anything that's acceptable in +; would work. +;highlight.string = #DD0000 +;highlight.comment = #FF9900 +;highlight.keyword = #007700 +;highlight.bg = #FFFFFF +;highlight.default = #0000BB +;highlight.html = #000000 + + +; +; Misc +; +; Decides whether PHP may expose the fact that it is installed on the server +; (e.g. by adding its signature to the Web server header). It is no security +; threat in any way, but it makes it possible to determine whether you use PHP +; on your server or not. +expose_php = Off + + +;;;;;;;;;;;;;;;;;;; +; Resource Limits ; +;;;;;;;;;;;;;;;;;;; + +max_execution_time = 30 ; Maximum execution time of each script, in seconds +max_input_time = 60 ; Maximum amount of time each script may spend parsing request data +memory_limit = 8M ; Maximum amount of memory a script may consume (8MB) + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; Error handling and logging ; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +; error_reporting is a bit-field. Or each number up to get desired error +; reporting level +; E_ALL - All errors and warnings +; E_ERROR - fatal run-time errors +; E_WARNING - run-time warnings (non-fatal errors) +; E_PARSE - compile-time parse errors +; E_NOTICE - run-time notices (these are warnings which often result +; from a bug in your code, but it's possible that it was +; intentional (e.g., using an uninitialized variable and +; relying on the fact it's automatically initialized to an +; empty string) +; E_CORE_ERROR - fatal errors that occur during PHP's initial startup +; E_CORE_WARNING - warnings (non-fatal errors) that occur during PHP's +; initial startup +; E_COMPILE_ERROR - fatal compile-time errors +; E_COMPILE_WARNING - compile-time warnings (non-fatal errors) +; E_USER_ERROR - user-generated error message +; E_USER_WARNING - user-generated warning message +; E_USER_NOTICE - user-generated notice message +; +; Examples: +; +; - Show all errors, except for notices +; +;error_reporting = E_ALL & ~E_NOTICE +; +; - Show only errors +; +;error_reporting = E_COMPILE_ERROR|E_ERROR|E_CORE_ERROR +; +; - Show all errors +; +error_reporting = E_ALL + +; Print out errors (as a part of the output). For production web sites, +; you're strongly encouraged to turn this feature off, and use error logging +; instead (see below). Keeping display_errors enabled on a production web site +; may reveal security information to end users, such as file paths on your Web +; server, your database schema or other information. +display_errors = Off + +; Even when display_errors is on, errors that occur during PHP's startup +; sequence are not displayed. It's strongly recommended to keep +; display_startup_errors off, except for when debugging. +display_startup_errors = Off + +; Log errors into a log file (server-specific log, stderr, or error_log (below)) +; As stated above, you're strongly advised to use error logging in place of +; error displaying on production web sites. +log_errors = On + +; Set maximum length of log_errors. In error_log information about the source is +; added. The default is 1024 and 0 allows to not apply any maximum length at all. +log_errors_max_len = 1024 + +; Do not log repeated messages. Repeated errors must occur in same file on same +; line until ignore_repeated_source is set true. +ignore_repeated_errors = Off + +; Ignore source of message when ignoring repeated messages. When this setting +; is On you will not log errors with repeated messages from different files or +; sourcelines. +ignore_repeated_source = Off + +; If this parameter is set to Off, then memory leaks will not be shown (on +; stdout or in the log). This has only effect in a debug compile, and if +; error reporting includes E_WARNING in the allowed list +report_memleaks = On + +; Store the last error/warning message in $php_errormsg (boolean). +track_errors = Off + +; Disable the inclusion of HTML tags in error messages. +html_errors = Off + +; If html_errors is set On PHP produces clickable error messages that direct +; to a page describing the error or function causing the error in detail. +; You can download a copy of the PHP manual from http://www.php.net/docs.php +; and change docref_root to the base URL of your local copy including the +; leading '/'. You must also specify the file extension being used including +; the dot. +;docref_root = "/phpmanual/" +;docref_ext = .html + +; String to output before an error message. +;error_prepend_string = "" + +; String to output after an error message. +;error_append_string = "" + +; Log errors to specified file. +;error_log = filename + +; Log errors to syslog (Event Log on NT, not valid in Windows 95). +error_log = syslog + + +;;;;;;;;;;;;;;;;; +; Data Handling ; +;;;;;;;;;;;;;;;;; +; +; Note - track_vars is ALWAYS enabled as of PHP 4.0.3 + +; The separator used in PHP generated URLs to separate arguments. +; Default is "&". +;arg_separator.output = "&" + +; List of separator(s) used by PHP to parse input URLs into variables. +; Default is "&". +; NOTE: Every character in this directive is considered as separator! +;arg_separator.input = ";&" + +; This directive describes the order in which PHP registers GET, POST, Cookie, +; Environment and Built-in variables (G, P, C, E & S respectively, often +; referred to as EGPCS or GPC). Registration is done from left to right, newer +; values override older values. +variables_order = "GPCS" + +; Whether or not to register the EGPCS variables as global variables. You may +; want to turn this off if you don't want to clutter your scripts' global scope +; with user data. This makes most sense when coupled with track_vars - in which +; case you can access all of the GPC variables through the $HTTP_*_VARS[], +; variables. +; +; You should do your best to write your scripts so that they do not require +; register_globals to be on; Using form variables as globals can easily lead +; to possible security problems, if the code is not very well thought of. +register_globals = Off + +; This directive tells PHP whether to declare the argv&argc variables (that +; would contain the GET information). If you don't use these variables, you +; should turn it off for increased performance. +register_argc_argv = Off + +; Maximum size of POST data that PHP will accept. +post_max_size = 8M + +; This directive is deprecated. Use variables_order instead. +gpc_order = "GPC" + +; Magic quotes +; + +; Magic quotes for incoming GET/POST/Cookie data. +magic_quotes_gpc = On + +; Magic quotes for runtime-generated data, e.g. data from SQL, from exec(), etc. +magic_quotes_runtime = Off + +; Use Sybase-style magic quotes (escape ' with '' instead of \'). +magic_quotes_sybase = Off + +; Automatically add files before or after any PHP document. +auto_prepend_file = +auto_append_file = + +; As of 4.0b4, PHP always outputs a character encoding by default in +; the Content-type: header. To disable sending of the charset, simply +; set it to be empty. +; +; PHP's built-in default is text/html +default_mimetype = "text/html" +;default_charset = "iso-8859-1" + +; Always populate the $HTTP_RAW_POST_DATA variable. +;always_populate_raw_post_data = On + + +;;;;;;;;;;;;;;;;;;;;;;;;; +; Paths and Directories ; +;;;;;;;;;;;;;;;;;;;;;;;;; + +; UNIX: "/path1:/path2" +;include_path = ".:/php/includes" +; +; Windows: "\path1;\path2" +;include_path = ".;c:\php\includes" + +; The root of the PHP pages, used only if nonempty. +; if PHP was not compiled with FORCE_REDIRECT, you SHOULD set doc_root +; if you are running php as a CGI under any web server (other than IIS) +; see documentation for security issues. The alternate is to use the +; cgi.force_redirect configuration below +doc_root = + +; The directory under which PHP opens the script using /~usernamem used only +; if nonempty. +user_dir = + +; Directory in which the loadable extensions (modules) reside. +extension_dir = "./" + +; Whether or not to enable the dl() function. The dl() function does NOT work +; properly in multithreaded servers, such as IIS or Zeus, and is automatically +; disabled on them. +; +; The dl function also introduces security issues. +enable_dl = Off + +; cgi.force_redirect is necessary to provide security running PHP as a CGI under +; most web servers. Left undefined, PHP turns this on by default. You can +; turn it off here AT YOUR OWN RISK +; **You CAN safely turn this off for IIS, in fact, you MUST.** +; cgi.force_redirect = 1 + +; if cgi.nph is enabled it will force cgi to always sent Status: 200 with +; every request. +; cgi.nph = 1 + +; if cgi.force_redirect is turned on, and you are not running under Apache or Netscape +; (iPlanet) web servers, you MAY need to set an environment variable name that PHP +; will look for to know it is OK to continue execution. Setting this variable MAY +; cause security issues, KNOW WHAT YOU ARE DOING FIRST. +; cgi.redirect_status_env = ; + +; cgi.fix_pathinfo provides *real* PATH_INFO/PATH_TRANSLATED support for CGI. PHP's +; previous behaviour was to set PATH_TRANSLATED to SCRIPT_FILENAME, and to not grok +; what PATH_INFO is. For more information on PATH_INFO, see the cgi specs. Setting +; this to 1 will cause PHP CGI to fix it's paths to conform to the spec. A setting +; of zero causes PHP to behave as before. Default is zero. You should fix your scripts +; to use SCRIPT_FILENAME rather than PATH_TRANSLATED. +; cgi.fix_pathinfo=1 + +; FastCGI under IIS (on WINNT based OS) supports the ability to impersonate +; security tokens of the calling client. This allows IIS to define the +; security context that the request runs under. mod_fastcgi under Apache +; does not currently support this feature (03/17/2002) +; Set to 1 if running under IIS. Default is zero. +; fastcgi.impersonate = 1; + +; cgi.rfc2616_headers configuration option tells PHP what type of headers to +; use when sending HTTP response code. If it's set 0 PHP sends Status: header that +; is supported by Apache. When this option is set to 1 PHP will send +; RFC2616 compliant header. +; Default is zero. +;cgi.rfc2616_headers = 0 + + +;;;;;;;;;;;;;;;; +; File Uploads ; +;;;;;;;;;;;;;;;; + +; Whether to allow HTTP file uploads. +file_uploads = Off + +; Temporary directory for HTTP uploaded files (will use system default if not +; specified). +;upload_tmp_dir = + +; Maximum allowed size for uploaded files. +upload_max_filesize = 2M + + +;;;;;;;;;;;;;;;;;; +; Fopen wrappers ; +;;;;;;;;;;;;;;;;;; + +; Whether to allow the treatment of URLs (like http:// or ftp://) as files. +; +; This is turned off to avoid variable redefinition by remote attacker +; that attempts to have the server download (and execute) a remote file +; from a compromised host. This behaviour has been observed in automatic +; scanning against badly written applications: +; http://myhost/myapplication.php?include=http://roguesever/rogueapp.php +allow_url_fopen = Off + +; Define the anonymous ftp password (your email address) +;from="john@doe.com" + +; Define the user agent for php to send +;user_agent="PHP" + +; Default timeout for socket based streams (seconds) +default_socket_timeout = 60 + +; If your scripts have to deal with files from Macintosh systems, +; or you are running on a Mac and need to deal with files from +; unix or win32 systems, setting this flag will cause PHP to +; automatically detect the EOL character in those files so that +; fgets() and file() will work regardless of the source of the file. +; auto_detect_line_endings = Off + + +;;;;;;;;;;;;;;;;;;;;;; +; Dynamic Extensions ; +;;;;;;;;;;;;;;;;;;;;;; +; +; If you wish to have an extension loaded automatically, use the following +; syntax: +; +; extension=modulename.extension +; +; For example, on Windows: +; +; extension=msql.dll +; +; ... or under UNIX: +; +; extension=msql.so +; +; Note that it should be the name of the module only; no directory information +; needs to go here. Specify the location of the extension with the +; extension_dir directive above. + + +;Windows Extensions +;Note that MySQL and ODBC support is now built in, so no dll is needed for it. +; +;extension=php_bz2.dll +;extension=php_cpdf.dll +;extension=php_crack.dll +;extension=php_curl.dll +;extension=php_db.dll +;extension=php_dba.dll +;extension=php_dbase.dll +;extension=php_dbx.dll +;extension=php_domxml.dll +;extension=php_exif.dll +;extension=php_fdf.dll +;extension=php_filepro.dll +;extension=php_gd2.dll +;extension=php_gettext.dll +;extension=php_hyperwave.dll +;extension=php_iconv.dll +;extension=php_ifx.dll +;extension=php_iisfunc.dll +;extension=php_imap.dll +;extension=php_interbase.dll +;extension=php_java.dll +;extension=php_ldap.dll +;extension=php_mbstring.dll +;extension=php_mcrypt.dll +;extension=php_mhash.dll +;extension=php_mime_magic.dll +;extension=php_ming.dll +;extension=php_mssql.dll +;extension=php_msql.dll +;extension=php_oci8.dll +;extension=php_openssl.dll +;extension=php_oracle.dll +;extension=php_pdf.dll +;extension=php_pgsql.dll +;extension=php_printer.dll +;extension=php_shmop.dll +;extension=php_snmp.dll +;extension=php_sockets.dll +;extension=php_sybase_ct.dll +;extension=php_w32api.dll +;extension=php_xmlrpc.dll +;extension=php_xslt.dll +;extension=php_yaz.dll +;extension=php_zip.dll + + +;;;;;;;;;;;;;;;;;;; +; Module Settings ; +;;;;;;;;;;;;;;;;;;; + +[Syslog] +; Whether or not to define the various syslog variables (e.g. $LOG_PID, +; $LOG_CRON, etc.). Turning it off is a good idea performance-wise. In +; runtime, you can define these variables by calling define_syslog_variables(). +define_syslog_variables = Off + +[mail function] +; For Win32 only. +SMTP = localhost +smtp_port = 25 + +; For Win32 only. +;sendmail_from = me@example.com + +; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). +;sendmail_path = + +[Java] +;java.class.path = .\php_java.jar +;java.home = c:\jdk +;java.library = c:\jdk\jre\bin\hotspot\jvm.dll +;java.library.path = .\ + +[SQL] +sql.safe_mode = On + +[ODBC] +;odbc.default_db = Not yet implemented +;odbc.default_user = Not yet implemented +;odbc.default_pw = Not yet implemented + +; Allow or prevent persistent links. +odbc.allow_persistent = On + +; Check that a connection is still valid before reuse. +odbc.check_persistent = On + +; Maximum number of persistent links. -1 means no limit. +odbc.max_persistent = -1 + +; Maximum number of links (persistent + non-persistent). -1 means no limit. +odbc.max_links = -1 + +; Handling of LONG fields. Returns number of bytes to variables. 0 means +; passthru. +odbc.defaultlrl = 4096 + +; Handling of binary data. 0 means passthru, 1 return as is, 2 convert to char. +; See the documentation on odbc_binmode and odbc_longreadlen for an explanation +; of uodbc.defaultlrl and uodbc.defaultbinmode +odbc.defaultbinmode = 1 + +[MySQL] +; Allow or prevent persistent links. +mysql.allow_persistent = On + +; Maximum number of persistent links. -1 means no limit. +mysql.max_persistent = -1 + +; Maximum number of links (persistent + non-persistent). -1 means no limit. +mysql.max_links = -1 + +; Default port number for mysql_connect(). If unset, mysql_connect() will use +; the $MYSQL_TCP_PORT or the mysql-tcp entry in /etc/services or the +; compile-time value defined MYSQL_PORT (in that order). Win32 will only look +; at MYSQL_PORT. +mysql.default_port = + +; Default socket name for local MySQL connects. If empty, uses the built-in +; MySQL defaults. +mysql.default_socket = + +; Default host for mysql_connect() (doesn't apply in safe mode). +mysql.default_host = + +; Default user for mysql_connect() (doesn't apply in safe mode). +mysql.default_user = + +; Default password for mysql_connect() (doesn't apply in safe mode). +; Note that this is generally a *bad* idea to store passwords in this file. +; *Any* user with PHP access can run 'echo get_cfg_var("mysql.default_password") +; and reveal this password! And of course, any users with read access to this +; file will be able to reveal the password as well. +mysql.default_password = + +; Maximum time (in seconds) for connect timeout. -1 means no limit +mysql.connect_timeout = 60 + +; Trace mode. When trace_mode is active (=On), warnings for table/index scans and +; SQL-Errors will be displayed. +mysql.trace_mode = Off + +[mSQL] +; Allow or prevent persistent links. +msql.allow_persistent = On + +; Maximum number of persistent links. -1 means no limit. +msql.max_persistent = -1 + +; Maximum number of links (persistent+non persistent). -1 means no limit. +msql.max_links = -1 + +[PostgresSQL] +; Allow or prevent persistent links. +pgsql.allow_persistent = On + +; Detect broken persistent links always with pg_pconnect(). +; Auto reset feature requires a little overheads. +pgsql.auto_reset_persistent = Off + +; Maximum number of persistent links. -1 means no limit. +pgsql.max_persistent = -1 + +; Maximum number of links (persistent+non persistent). -1 means no limit. +pgsql.max_links = -1 + +; Ignore PostgreSQL backends Notice message or not. +; Notice message logging require a little overheads. +pgsql.ignore_notice = 0 + +; Log PostgreSQL backends Noitce message or not. +; Unless pgsql.ignore_notice=0, module cannot log notice message. +pgsql.log_notice = 0 + +[Sybase] +; Allow or prevent persistent links. +sybase.allow_persistent = On + +; Maximum number of persistent links. -1 means no limit. +sybase.max_persistent = -1 + +; Maximum number of links (persistent + non-persistent). -1 means no limit. +sybase.max_links = -1 + +;sybase.interface_file = "/usr/sybase/interfaces" + +; Minimum error severity to display. +sybase.min_error_severity = 10 + +; Minimum message severity to display. +sybase.min_message_severity = 10 + +; Compatability mode with old versions of PHP 3.0. +; If on, this will cause PHP to automatically assign types to results according +; to their Sybase type, instead of treating them all as strings. This +; compatibility mode will probably not stay around forever, so try applying +; whatever necessary changes to your code, and turn it off. +sybase.compatability_mode = Off + +[Sybase-CT] +; Allow or prevent persistent links. +sybct.allow_persistent = On + +; Maximum number of persistent links. -1 means no limit. +sybct.max_persistent = -1 + +; Maximum number of links (persistent + non-persistent). -1 means no limit. +sybct.max_links = -1 + +; Minimum server message severity to display. +sybct.min_server_severity = 10 + +; Minimum client message severity to display. +sybct.min_client_severity = 10 + +[dbx] +; returned column names can be converted for compatibility reasons +; possible values for dbx.colnames_case are +; "unchanged" (default, if not set) +; "lowercase" +; "uppercase" +; the recommended default is either upper- or lowercase, but +; unchanged is currently set for backwards compatibility +dbx.colnames_case = "lowercase" + +[bcmath] +; Number of decimal digits for all bcmath functions. +bcmath.scale = 0 + +[browscap] +;browscap = extra/browscap.ini + +[Informix] +; Default host for ifx_connect() (doesn't apply in safe mode). +ifx.default_host = + +; Default user for ifx_connect() (doesn't apply in safe mode). +ifx.default_user = + +; Default password for ifx_connect() (doesn't apply in safe mode). +ifx.default_password = + +; Allow or prevent persistent links. +ifx.allow_persistent = On + +; Maximum number of persistent links. -1 means no limit. +ifx.max_persistent = -1 + +; Maximum number of links (persistent + non-persistent). -1 means no limit. +ifx.max_links = -1 + +; If on, select statements return the contents of a text blob instead of its id. +ifx.textasvarchar = 0 + +; If on, select statements return the contents of a byte blob instead of its id. +ifx.byteasvarchar = 0 + +; Trailing blanks are stripped from fixed-length char columns. May help the +; life of Informix SE users. +ifx.charasvarchar = 0 + +; If on, the contents of text and byte blobs are dumped to a file instead of +; keeping them in memory. +ifx.blobinfile = 0 + +; NULL's are returned as empty strings, unless this is set to 1. In that case, +; NULL's are returned as string 'NULL'. +ifx.nullformat = 0 + +[Session] +; Handler used to store/retrieve data. +session.save_handler = files + +; Argument passed to save_handler. In the case of files, this is the path +; where data files are stored. Note: Windows users have to change this +; variable in order to use PHP's session functions. +;session.save_path = /tmp + +; Whether to use cookies. +session.use_cookies = 1 + +; This option enables administrators to make their users invulnerable to +; attacks which involve passing session ids in URLs; defaults to 0. +; session.use_only_cookies = 1 + +; Name of the session (used as cookie name). +session.name = PHPSESSID + +; Initialize session on request startup. +session.auto_start = 0 + +; Lifetime in seconds of cookie or, if 0, until browser is restarted. +session.cookie_lifetime = 0 + +; The path for which the cookie is valid. +session.cookie_path = / + +; The domain for which the cookie is valid. +session.cookie_domain = + +; Handler used to serialize data. php is the standard serializer of PHP. +session.serialize_handler = php + +; Define the probability that the 'garbage collection' process is started +; on every session initialization. +; The probability is calculated by using gc_probability/gc_divisor, +; e.g. 1/100 means there is a 1% chance that the GC process starts +; on each request. + +session.gc_probability = 1 +session.gc_divisor = 1000 + +; After this number of seconds, stored data will be seen as 'garbage' and +; cleaned up by the garbage collection process. +session.gc_maxlifetime = 1440 + +; PHP 4.2 and less have an undocumented feature/bug that allows you to +; to initialize a session variable in the global scope, albeit register_globals +; is disabled. PHP 4.3 and later will warn you, if this feature is used. +; You can disable the feature and the warning separately. At this time, +; the warning is only displayed, if bug_compat_42 is enabled. + +session.bug_compat_42 = 0 +session.bug_compat_warn = 1 + +; Check HTTP Referer to invalidate externally stored URLs containing ids. +; HTTP_REFERER has to contain this substring for the session to be +; considered as valid. +session.referer_check = + +; How many bytes to read from the file. +session.entropy_length = 0 + +; Specified here to create the session id. +session.entropy_file = + +;session.entropy_length = 16 + +;session.entropy_file = /dev/urandom + +; Set to {nocache,private,public,} to determine HTTP caching aspects. +; or leave this empty to avoid sending anti-caching headers. +session.cache_limiter = nocache + +; Document expires after n minutes. +session.cache_expire = 180 + +; trans sid support is disabled by default. +; Use of trans sid may risk your users security. +; Use this option with caution. +; - User may send URL contains active session ID +; to other person via. email/irc/etc. +; - URL that contains active session ID may be stored +; in publically accessible computer. +; - User may access your site with the same session ID +; always using URL stored in browser's history or bookmarks. +session.use_trans_sid = 0 + +; The URL rewriter will look for URLs in a defined set of HTML tags. +; form/fieldset are special; if you include them here, the rewriter will +; add a hidden field with the info which is otherwise appended +; to URLs. If you want XHTML conformity, remove the form entry. +; Note that all valid entries require a "=", even if no value follows. +url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry" + +[MSSQL] +; Allow or prevent persistent links. +mssql.allow_persistent = On + +; Maximum number of persistent links. -1 means no limit. +mssql.max_persistent = -1 + +; Maximum number of links (persistent+non persistent). -1 means no limit. +mssql.max_links = -1 + +; Minimum error severity to display. +mssql.min_error_severity = 10 + +; Minimum message severity to display. +mssql.min_message_severity = 10 + +; Compatability mode with old versions of PHP 3.0. +mssql.compatability_mode = Off + +; Connect timeout +;mssql.connect_timeout = 5 + +; Query timeout +;mssql.timeout = 60 + +; Valid range 0 - 2147483647. Default = 4096. +;mssql.textlimit = 4096 + +; Valid range 0 - 2147483647. Default = 4096. +;mssql.textsize = 4096 + +; Limits the number of records in each batch. 0 = all records in one batch. +;mssql.batchsize = 0 + +; Specify how datetime and datetim4 columns are returned +; On => Returns data converted to SQL server settings +; Off => Returns values as YYYY-MM-DD hh:mm:ss +;mssql.datetimeconvert = On + +; Use NT authentication when connecting to the server +mssql.secure_connection = On + +; Specify max number of processes. Default = 25 +;mssql.max_procs = 25 + +[Assertion] +; Assert(expr); active by default. +;assert.active = On + +; Issue a PHP warning for each failed assertion. +;assert.warning = On + +; Don't bail out by default. +;assert.bail = Off + +; User-function to be called if an assertion fails. +;assert.callback = 0 + +; Eval the expression with current error_reporting(). Set to true if you want +; error_reporting(0) around the eval(). +;assert.quiet_eval = 0 + +[Ingres II] +; Allow or prevent persistent links. +ingres.allow_persistent = On + +; Maximum number of persistent links. -1 means no limit. +ingres.max_persistent = -1 + +; Maximum number of links, including persistents. -1 means no limit. +ingres.max_links = -1 + +; Default database (format: [node_id::]dbname[/srv_class]). +ingres.default_database = + +; Default user. +ingres.default_user = + +; Default password. +ingres.default_password = + +[Verisign Payflow Pro] +; Default Payflow Pro server. +pfpro.defaulthost = "test-payflow.verisign.com" + +; Default port to connect to. +pfpro.defaultport = 443 + +; Default timeout in seconds. +pfpro.defaulttimeout = 30 + +; Default proxy IP address (if required). +;pfpro.proxyaddress = + +; Default proxy port. +;pfpro.proxyport = + +; Default proxy logon. +;pfpro.proxylogon = + +; Default proxy password. +;pfpro.proxypassword = + +[Sockets] +; Use the system read() function instead of the php_read() wrapper. +sockets.use_system_read = On + +[com] +; path to a file containing GUIDs, IIDs or filenames of files with TypeLibs +;com.typelib_file = +; allow Distributed-COM calls +;com.allow_dcom = true +; autoregister constants of a components typlib on com_load() +;com.autoregister_typelib = true +; register constants casesensitive +;com.autoregister_casesensitive = false +; show warnings on duplicate constat registrations +;com.autoregister_verbose = true + +[Printer] +;printer.default_printer = "" + +[mbstring] +; language for internal character representation. +;mbstring.language = Japanese + +; internal/script encoding. +; Some encoding cannot work as internal encoding. +; (e.g. SJIS, BIG5, ISO-2022-*) +;mbstring.internal_encoding = EUC-JP + +; http input encoding. +;mbstring.http_input = auto + +; http output encoding. mb_output_handler must be +; registered as output buffer to function +;mbstring.http_output = SJIS + +; enable automatic encoding translation accoding to +; mbstring.internal_encoding setting. Input chars are +; converted to internal encoding by setting this to On. +; Note: Do _not_ use automatic encoding translation for +; portable libs/applications. +;mbstring.encoding_translation = Off + +; automatic encoding detection order. +; auto means +;mbstring.detect_order = auto + +; substitute_character used when character cannot be converted +; one from another +;mbstring.substitute_character = none; + +; overload(replace) single byte functions by mbstring functions. +; mail(), ereg(), etc are overloaded by mb_send_mail(), mb_ereg(), +; etc. Possible values are 0,1,2,4 or combination of them. +; For example, 7 for overload everything. +; 0: No overload +; 1: Overload mail() function +; 2: Overload str*() functions +; 4: Overload ereg*() functions +;mbstring.func_overload = 0 + +[FrontBase] +;fbsql.allow_persistent = On +;fbsql.autocommit = On +;fbsql.default_database = +;fbsql.default_database_password = +;fbsql.default_host = +;fbsql.default_password = +;fbsql.default_user = "_SYSTEM" +;fbsql.generate_warnings = Off +;fbsql.max_connections = 128 +;fbsql.max_links = 128 +;fbsql.max_persistent = -1 +;fbsql.max_results = 128 +;fbsql.batchSize = 1000 + +[Crack] +; Modify the setting below to match the directory location of the cracklib +; dictionary files. Include the base filename, but not the file extension. +; crack.default_dictionary = "c:\php\lib\cracklib_dict" + +[exif] +; Exif UNICODE user comments are handled as UCS-2BE/UCS-2LE and JIS as JIS. +; With mbstring support this will automatically be converted into the encoding +; given by corresponding encode setting. When empty mbstring.internal_encoding +; is used. For the decode settings you can distinguish between motorola and +; intel byte order. A decode setting cannot be empty. +;exif.encode_unicode = ISO-8859-15 +;exif.decode_unicode_motorola = UCS-2BE +;exif.decode_unicode_intel = UCS-2LE +;exif.encode_jis = +;exif.decode_jis_motorola = JIS +;exif.decode_jis_intel = JIS + +; Local Variables: +; tab-width: 4 +; End: diff -ruN php-5.2.5.orig/php.ini-recommended php-5.2.5/php.ini-recommended --- php-5.2.5.orig/php.ini-recommended 2007-08-21 17:24:18.000000000 -0600 +++ php-5.2.5/php.ini-recommended 2007-12-10 21:48:35.000000000 -0700 @@ -522,7 +522,7 @@ ;;;;;;;;;;;;;;;;;;;;;;;;; ; UNIX: "/path1:/path2" -;include_path = ".:/php/includes" +;include_path = ".:@FINKPREFIX@/share/php" ; ; Windows: "\path1;\path2" ;include_path = ".;c:\php\includes" @@ -539,7 +539,7 @@ user_dir = ; Directory in which the loadable extensions (modules) reside. -extension_dir = "./" +;extension_dir = "./" ; Whether or not to enable the dl() function. The dl() function does NOT work ; properly in multithreaded servers, such as IIS or Zeus, and is automatically @@ -655,58 +655,6 @@ ; extension_dir directive above. -; Windows Extensions -; Note that ODBC support is built in, so no dll is needed for it. -; Note that many DLL files are located in the extensions/ (PHP 4) ext/ (PHP 5) -; extension folders as well as the separate PECL DLL download (PHP 5). -; Be sure to appropriately set the extension_dir directive. - -;extension=php_bz2.dll -;extension=php_curl.dll -;extension=php_dba.dll -;extension=php_dbase.dll -;extension=php_exif.dll -;extension=php_fdf.dll -;extension=php_gd2.dll -;extension=php_gettext.dll -;extension=php_gmp.dll -;extension=php_ifx.dll -;extension=php_imap.dll -;extension=php_interbase.dll -;extension=php_ldap.dll -;extension=php_mbstring.dll -;extension=php_mcrypt.dll -;extension=php_mhash.dll -;extension=php_mime_magic.dll -;extension=php_ming.dll -;extension=php_msql.dll -;extension=php_mssql.dll -;extension=php_mysql.dll -;extension=php_mysqli.dll -;extension=php_oci8.dll -;extension=php_openssl.dll -;extension=php_pdo.dll -;extension=php_pdo_firebird.dll -;extension=php_pdo_mssql.dll -;extension=php_pdo_mysql.dll -;extension=php_pdo_oci.dll -;extension=php_pdo_oci8.dll -;extension=php_pdo_odbc.dll -;extension=php_pdo_pgsql.dll -;extension=php_pdo_sqlite.dll -;extension=php_pgsql.dll -;extension=php_pspell.dll -;extension=php_shmop.dll -;extension=php_snmp.dll -;extension=php_soap.dll -;extension=php_sockets.dll -;extension=php_sqlite.dll -;extension=php_sybase_ct.dll -;extension=php_tidy.dll -;extension=php_xmlrpc.dll -;extension=php_xsl.dll -;extension=php_zip.dll - ;;;;;;;;;;;;;;;;;;; ; Module Settings ; ;;;;;;;;;;;;;;;;;;; @@ -1043,7 +991,7 @@ ; ; where MODE is the octal representation of the mode. Note that this ; does not overwrite the process's umask. -;session.save_path = "/tmp" +;session.save_path = "@FINKPREFIX@/var/lib/php5" ; Whether to use cookies. session.use_cookies = 1 @@ -1081,7 +1029,10 @@ ; e.g. 1/100 means there is a 1% chance that the GC process starts ; on each request. -session.gc_probability = 1 +; This is disabled in the Fink packages, due to the strict permissions +; on @FINKPREFIX@/var/lib/php5. Instead of setting this here, see the cronjob at +; @FINKPREFIX@/etc/cron.d/php5, which uses the session.gc_maxlifetime setting below +;session.gc_probability = 0 session.gc_divisor = 1000 ; After this number of seconds, stored data will be seen as 'garbage' and diff -ruN php-5.2.5.orig/sapi/apache/config.m4 php-5.2.5/sapi/apache/config.m4 --- php-5.2.5.orig/sapi/apache/config.m4 2007-07-11 17:20:36.000000000 -0600 +++ php-5.2.5/sapi/apache/config.m4 2007-12-10 22:16:01.000000000 -0700 @@ -56,11 +56,11 @@ APXS_HTTPD=`$APXS -q SBINDIR`/`$APXS -q TARGET` APACHE_INCLUDE=-I$APXS_INCLUDEDIR - # Test that we're trying to configure with apache 1.x - PHP_AP_EXTRACT_VERSION($APXS_HTTPD) - if test "$APACHE_VERSION" -ge 2000000; then - AC_MSG_ERROR([You have enabled Apache 1.3 support while your server is Apache 2. Please use the appropiate switch --with-apxs2]) - fi +dnl # Test that we're trying to configure with apache 1.x +dnl PHP_AP_EXTRACT_VERSION($APXS_HTTPD) +dnl if test "$APACHE_VERSION" -ge 2000000; then +dnl AC_MSG_ERROR([You have enabled Apache 1.3 support while your server is Apache 2. Please use the appropiate switch --with-apxs2]) +dnl fi for flag in $APXS_CFLAGS; do case $flag in diff -ruN php-5.2.5.orig/sapi/apache2filter/config.m4 php-5.2.5/sapi/apache2filter/config.m4 --- php-5.2.5.orig/sapi/apache2filter/config.m4 2007-07-11 17:20:36.000000000 -0600 +++ php-5.2.5/sapi/apache2filter/config.m4 2007-12-10 22:16:40.000000000 -0700 @@ -60,13 +60,13 @@ APACHE_CFLAGS="$APACHE_CPPFLAGS -I$APXS_INCLUDEDIR $APR_CFLAGS $APU_CFLAGS" - # Test that we're trying to configure with apache 2.x - PHP_AP_EXTRACT_VERSION($APXS_HTTPD) - if test "$APACHE_VERSION" -le 2000000; then - AC_MSG_ERROR([You have enabled Apache 2 support while your server is Apache 1.3. Please use the appropiate switch --with-apxs (without the 2)]) - elif test "$APACHE_VERSION" -lt 2000040; then - AC_MSG_ERROR([Please note that Apache version >= 2.0.40 is required]) - fi +dnl # Test that we're trying to configure with apache 2.x +dnl PHP_AP_EXTRACT_VERSION($APXS_HTTPD) +dnl if test "$APACHE_VERSION" -le 2000000; then +dnl AC_MSG_ERROR([You have enabled Apache 2 support while your server is Apache 1.3. Please use the appropiate switch --with-apxs (without the 2)]) +dnl elif test "$APACHE_VERSION" -lt 2000040; then +dnl AC_MSG_ERROR([Please note that Apache version >= 2.0.40 is required]) +dnl fi APXS_LIBEXECDIR='$(INSTALL_ROOT)'`$APXS -q LIBEXECDIR` if test -z `$APXS -q SYSCONFDIR`; then diff -ruN php-5.2.5.orig/sapi/apache2handler/config.m4 php-5.2.5/sapi/apache2handler/config.m4 --- php-5.2.5.orig/sapi/apache2handler/config.m4 2007-07-11 17:20:36.000000000 -0600 +++ php-5.2.5/sapi/apache2handler/config.m4 2007-12-10 22:15:26.000000000 -0700 @@ -59,13 +59,13 @@ APACHE_CFLAGS="$APACHE_CPPFLAGS -I$APXS_INCLUDEDIR $APR_CFLAGS $APU_CFLAGS" - # Test that we're trying to configure with apache 2.x - PHP_AP_EXTRACT_VERSION($APXS_HTTPD) - if test "$APACHE_VERSION" -le 2000000; then - AC_MSG_ERROR([You have enabled Apache 2 support while your server is Apache 1.3. Please use the appropiate switch --with-apxs (without the 2)]) - elif test "$APACHE_VERSION" -lt 2000044; then - AC_MSG_ERROR([Please note that Apache version >= 2.0.44 is required]) - fi +dnl # Test that we're trying to configure with apache 2.x +dnl PHP_AP_EXTRACT_VERSION($APXS_HTTPD) +dnl if test "$APACHE_VERSION" -le 2000000; then +dnl AC_MSG_ERROR([You have enabled Apache 2 support while your server is Apache 1.3. Please use the appropiate switch --with-apxs (without the 2)]) +dnl elif test "$APACHE_VERSION" -lt 2000044; then +dnl AC_MSG_ERROR([Please note that Apache version >= 2.0.44 is required]) +dnl fi APXS_LIBEXECDIR='$(INSTALL_ROOT)'`$APXS -q LIBEXECDIR` if test -z `$APXS -q SYSCONFDIR`; then diff -ruN php-5.2.5.orig/sapi/apache2handler/sapi_apache2.c php-5.2.5/sapi/apache2handler/sapi_apache2.c --- php-5.2.5.orig/sapi/apache2handler/sapi_apache2.c 2007-06-28 11:23:07.000000000 -0600 +++ php-5.2.5/sapi/apache2handler/sapi_apache2.c 2007-12-10 22:06:44.000000000 -0700 @@ -437,6 +437,19 @@ return APR_SUCCESS; } +static int saved_umask; + +static void php_save_umask(void) +{ + saved_umask = umask(077); + umask(saved_umask); +} + +static void php_restore_umask(void) +{ + umask(saved_umask); +} + static int php_apache_request_ctor(request_rec *r, php_struct *ctx TSRMLS_DC) { char *content_length; @@ -628,6 +641,8 @@ } else { zend_file_handle zfd; + php_save_umask(); + zfd.type = ZEND_HANDLE_FILENAME; zfd.filename = (char *) r->filename; zfd.free_filename = 0; @@ -639,6 +654,8 @@ zend_execute_scripts(ZEND_INCLUDE TSRMLS_CC, NULL, 1, &zfd); } + php_restore_umask(); + apr_table_set(r->notes, "mod_php_memory_usage", apr_psprintf(ctx->r->pool, "%u", zend_memory_peak_usage(1 TSRMLS_CC))); } diff -ruN php-5.2.5.orig/sapi/apache_hooks/config.m4 php-5.2.5/sapi/apache_hooks/config.m4 --- php-5.2.5.orig/sapi/apache_hooks/config.m4 2007-07-11 17:20:36.000000000 -0600 +++ php-5.2.5/sapi/apache_hooks/config.m4 2007-12-10 22:17:11.000000000 -0700 @@ -57,11 +57,11 @@ APXS_HTTPD=`$APXS -q SBINDIR`/`$APXS -q TARGET` APACHE_INCLUDE=-I$APXS_INCLUDEDIR - # Test that we're trying to configure with apache 1.x - PHP_AP_EXTRACT_VERSION($APXS_HTTPD) - if test "$APACHE_VERSION" -ge 2000000; then - AC_MSG_ERROR([You have enabled Apache 1.3 support while your server is Apache 2. Please use the appropiate switch --with-apxs2]) - fi +dnl # Test that we're trying to configure with apache 1.x +dnl PHP_AP_EXTRACT_VERSION($APXS_HTTPD) +dnl if test "$APACHE_VERSION" -ge 2000000; then +dnl AC_MSG_ERROR([You have enabled Apache 1.3 support while your server is Apache 2. Please use the appropiate switch --with-apxs2]) +dnl fi for flag in $APXS_CFLAGS; do case $flag in diff -ruN php-5.2.5.orig/sapi/cli/php.1.in php-5.2.5/sapi/cli/php.1.in --- php-5.2.5.orig/sapi/cli/php.1.in 2007-04-23 14:54:22.000000000 -0600 +++ php-5.2.5/sapi/cli/php.1.in 2007-12-10 21:51:51.000000000 -0700 @@ -309,13 +309,14 @@ Show configuration file names .SH FILES .TP 15 -.B php\-cli.ini +.B @FINKPREFIX@/etc/php5/cli/php.ini The configuration file for the CLI version of PHP. .TP -.B php.ini -The standard configuration file will only be used when -.B php\-cli.ini -cannot be found. +.B @FINKPREFIX@/etc/php5/cgi/php.ini +The configuration file for the CGI version of PHP. +.TP +.B @FINKPREFIX@/etc/php5/apache2/php.ini +The configuration file for the version of PHP that apache2 uses. .SH EXAMPLES .TP 5 \fIphp \-r 'echo "Hello World\\n";'\fP diff -ruN php-5.2.5.orig/scripts/Makefile.frag php-5.2.5/scripts/Makefile.frag --- php-5.2.5.orig/scripts/Makefile.frag 2005-11-21 16:08:02.000000000 -0700 +++ php-5.2.5/scripts/Makefile.frag 2007-12-10 21:52:27.000000000 -0700 @@ -3,8 +3,8 @@ # Build environment install # -phpincludedir = $(includedir)/php -phpbuilddir = $(libdir)/build +phpincludedir = $(includedir)/php5 +phpbuilddir = $(prefix)/lib/php5/build BUILD_FILES = \ scripts/phpize.m4 \ diff -ruN php-5.2.5.orig/scripts/php-config.in php-5.2.5/scripts/php-config.in --- php-5.2.5.orig/scripts/php-config.in 2007-08-24 05:44:10.000000000 -0600 +++ php-5.2.5/scripts/php-config.in 2007-12-10 21:53:49.000000000 -0700 @@ -5,8 +5,8 @@ exec_prefix="@exec_prefix@" version="@PHP_VERSION@" vernum="@PHP_VERSION_ID@" -include_dir="@includedir@/php" -includes="-I$include_dir -I$include_dir/main -I$include_dir/TSRM -I$include_dir/Zend -I$include_dir/ext -I$include_dir/ext/date/lib" +include_dir="@includedir@/php5" +includes="-I$include_dir -I$include_dir/main -I$include_dir/TSRM -I$include_dir/Zend -I$include_dir/ext -I$include_dir/ext/date/lib $(getconf LFS_CFLAGS)" ldflags="@PHP_LDFLAGS@" libs="@EXTRA_LIBS@" extension_dir='@EXTENSION_DIR@' diff -ruN php-5.2.5.orig/scripts/phpize.in php-5.2.5/scripts/phpize.in --- php-5.2.5.orig/scripts/phpize.in 2007-06-28 19:10:35.000000000 -0600 +++ php-5.2.5/scripts/phpize.in 2007-12-10 21:54:35.000000000 -0700 @@ -3,8 +3,8 @@ # Variable declaration prefix='@prefix@' exec_prefix="`eval echo @exec_prefix@`" -phpdir="`eval echo @libdir@`/build" -includedir="`eval echo @includedir@`/php" +phpdir="$prefix/lib/php5/build" +includedir="$prefix/include/php5" builddir="`pwd`" SED="@SED@"