cvs: php4 /ext/ming ming.c
| From: | Wez Furlong | Date: | Sat, 16 Mar 2002 15:15:52 +0000 |
| Subject: | cvs: php4 /ext/ming ming.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-10239@lists.php.net to get a copy of this message | ||
wez Sat Mar 16 10:15:52 2002 EDT
Modified files:
/php4/ext/ming ming.c
Log:
correct some problems with ming
Index: php4/ext/ming/ming.c
diff -u php4/ext/ming/ming.c:1.28 php4/ext/ming/ming.c:1.29
--- php4/ext/ming/ming.c:1.28 Fri Mar 15 20:26:11 2002
+++ php4/ext/ming/ming.c Sat Mar 16 10:15:50 2002
@@ -200,33 +200,6 @@
destroySWFInput((SWFInput)resource->ptr);
}
-#define SOCKBUF_INCREMENT 10240
-
-/* turn a socket into an SWFInput by copying everything to a buffer. */
-/* not pretty, but it works */
-
-static SWFInput newSWFInput_sock(int socket)
-{
- char *buffer = NULL;
- int l, offset = 0, alloced = 0;
-
- do
- {
- if(offset <= alloced)
- {
- alloced += SOCKBUF_INCREMENT;
- buffer = realloc(buffer, alloced);
- }
-
- l = SOCK_FREAD(buffer+offset, SOCKBUF_INCREMENT, socket);
-
- offset += l;
- }
- while(l > 0);
-
- return newSWFInput_allocedBuffer(buffer, offset);
-}
-
static SWFInput getInput(zval **zfile TSRMLS_DC)
{
FILE *file;
@@ -236,7 +209,7 @@
what = zend_fetch_resource(zfile TSRMLS_CC, -1, "File-Handle", &type, 1,
php_file_le_stream());
- if (!php_stream_cast((php_stream*)what, PHP_STREAM_AS_STDIO_FILE, (void*)&file,
REPORT_ERRORS)) {
+ if (!php_stream_cast((php_stream*)what, PHP_STREAM_AS_STDIO, (void*)&file, REPORT_ERRORS)) {
return NULL;
}
@@ -1170,7 +1143,6 @@
PHP_FUNCTION(swffont_init)
{
- FILE *file;
zval **zfile;
SWFFont font;
int ret;
@@ -1182,13 +1154,23 @@
if(strcmp(Z_STRVAL_PP(zfile)+Z_STRLEN_PP(zfile)-4, ".fdb") == 0)
{
- file = VCWD_FOPEN(Z_STRVAL_PP(zfile), "rb");
-
- if(!file)
- php_error(E_ERROR, "Couldn't find FDB file %s", Z_STRVAL_PP(zfile));
-
+ php_stream * stream;
+ FILE * file;
+
+ stream = php_stream_open_wrapper(Z_STRVAL_PP(zfile), "rb",
REPORT_ERRORS|ENFORCE_SAFE_MODE, NULL, TSRMLS_CC);
+
+ if(stream == NULL) {
+ RETURN_FALSE;
+ }
+
+ if (FAILURE = php_stream_cast(stream, PHP_STREAM_AS_STDIO, (void*)&file, REPORT_ERRORS))
+ {
+ php_stream_close(stream);
+ RETURN_FALSE;
+ }
+
font = loadSWFFontFromFile(file);
- fclose(file);
+ php_stream_close(stream);
}
else
font = newSWFBrowserFont(Z_STRVAL_PP(zfile));
@@ -1626,8 +1608,6 @@
retval = SWFMovie_output(getMovie(getThis() TSRMLS_CC),
&phpStreamOutputMethod, (void *)stream);
-
- fclose(file);
RETURN_LONG(retval);
}