fmk Thu Jul 10 01:07:45 2003 EDT
Modified files: (Branch: PHP_4_3)
/php-src/ext/ming ming.c
Log:
Adding missing compression paramters to output functions
Index: php-src/ext/ming/ming.c
diff -u php-src/ext/ming/ming.c:1.42.2.3 php-src/ext/ming/ming.c:1.42.2.4
--- php-src/ext/ming/ming.c:1.42.2.3 Tue Jul 1 22:04:21 2003
+++ php-src/ext/ming/ming.c Thu Jul 10 01:07:45 2003
@@ -900,7 +900,7 @@
convert_to_object_ex(zaction);
convert_to_long_ex(flags);
- action = (SWFBlock)getAction(*zaction TSRMLS_CC);
+ action = getAction(*zaction TSRMLS_CC);
SWFDisplayItem_addAction(item, action, Z_LVAL_PP(flags));
}
/* }}} */
@@ -1087,7 +1087,7 @@
font = loadSWFFontFromFile(file);
php_stream_close(stream);
} else {
- font = newSWFBrowserFont(Z_STRVAL_PP(zfile));
+ font = (SWFFont)newSWFBrowserFont(Z_STRVAL_PP(zfile));
}
ret = zend_list_insert(font, le_swffontp);
@@ -1434,9 +1434,24 @@
PHP_FUNCTION(swfmovie_output)
{
- SWFMovie movie = getMovie(getThis() TSRMLS_CC);
+ zval **zlimit = NULL;
+ int limit = -1;
+ SWFMovie movie = getMovie(getThis() TSRMLS_CC);
+
+ switch (ZEND_NUM_ARGS()) {
+ case 1:
+ 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;
+ }
+ break;
+ }
- RETURN_LONG(SWFMovie_output(movie, &phpByteOutputMethod, NULL));
+ RETURN_LONG(SWFMovie_output(movie, &phpByteOutputMethod, NULL, limit));
}
/* }}} */
@@ -1452,14 +1467,32 @@
PHP_FUNCTION(swfmovie_saveToFile)
{
zval **x;
+ zval **zlimit = NULL;
+ int limit = -1;
SWFMovie movie = getMovie(getThis() TSRMLS_CC);
php_stream *what;
- if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &x) == FAILURE) {
+ switch (ZEND_NUM_ARGS()) {
+ case 1:
+ if (zend_get_parameters_ex(1, &x) == FAILURE)
+ WRONG_PARAM_COUNT;
+ break;
+ case 2:
+ 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;
+ }
+ break;
+ default:
WRONG_PARAM_COUNT;
}
- php_stream_from_zval(what, x);
- RETURN_LONG(SWFMovie_output(movie, &phpStreamOutputMethod, what));
+
+ ZEND_FETCH_RESOURCE(what, php_stream *, x,
-1,"File-Handle",php_file_le_stream());
+ RETURN_LONG(SWFMovie_output(movie, &phpStreamOutputMethod, what, limit));
}
/* }}} */
@@ -1467,17 +1500,33 @@
*/
PHP_FUNCTION(swfmovie_save)
{
- zval **x;
+ zval **x, **zlimit = NULL;
+ int limit = -1;
long retval;
php_stream *stream;
- if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &x) == FAILURE) {
+ switch (ZEND_NUM_ARGS()) {
+ case 1:
+ if (zend_get_parameters_ex(1, &x) == FAILURE)
+ WRONG_PARAM_COUNT;
+ break;
+ case 2:
+ 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;
+ }
+ break;
+ default:
WRONG_PARAM_COUNT;
}
-
+
if (Z_TYPE_PP(x) == IS_RESOURCE) {
- php_stream_from_zval(stream, x);
- RETURN_LONG(SWFMovie_output(getMovie(getThis() TSRMLS_CC),
&phpStreamOutputMethod, stream));
+ ZEND_FETCH_RESOURCE(stream, php_stream *, x,
-1,"File-Handle",php_file_le_stream());
+ RETURN_LONG(SWFMovie_output(getMovie(getThis() TSRMLS_CC),
&phpStreamOutputMethod, stream, limit));
}
convert_to_string_ex(x);
@@ -1487,7 +1536,7 @@
RETURN_FALSE;
}
- retval = SWFMovie_output(getMovie(getThis() TSRMLS_CC),
&phpStreamOutputMethod, (void *)stream);
+ retval = SWFMovie_output(getMovie(getThis() TSRMLS_CC),
&phpStreamOutputMethod, (void *)stream, limit);
php_stream_close(stream);
RETURN_LONG(retval);
}
@@ -1561,7 +1610,7 @@
PHP_FUNCTION(swfmovie_streamMp3)
{
zval **zfile;
- SWFSound sound;
+ SWFSoundStream sound;
SWFInput input;
SWFMovie movie = getMovie(getThis() TSRMLS_CC);
@@ -1577,7 +1626,7 @@
input = getInput(zfile TSRMLS_CC);
}
- sound = newSWFSound_fromInput(input);
+ sound = newSWFSoundStream_fromInput(input);
SWFMovie_setSoundStream(movie, sound);
}
/* }}} */
@@ -2382,10 +2431,6 @@
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &s) == FAILURE) {
WRONG_PARAM_COUNT;
}
- if (!getFont(getText(getThis() TSRMLS_CC))) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "You must specify a font
before writing text.");
- RETURN_FALSE;
- }
convert_to_string_ex(s);
SWFText_addString(text, Z_STRVAL_PP(s), NULL);
@@ -2719,7 +2764,7 @@
*/
/* custom error handler propagates ming errors up to php */
-static void php_ming_error(char *msg, ...)
+static void php_ming_error(const char *msg, ...)
{
va_list args;
char *buffer;
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php