RE: [PHP-DEV] Streams Problems

2002-10-13 Thread Mike Robinson

?php
$fp = fopen(http://www.slashdot.org/slashdot.rdf;,'r');
?

In 4.2.3 this works as expected. It redirects to
http://slashdot.org/slashdot.rdf (note the 'www.' is gone).

In 4.3.0pr1 this results in:

Warning: fopen(http://www.slashdot.org/slashdot.rdf) [function.fopen]:
failed to create stream: HTTP request failed! HTTP/1.1 301 Moved
Permanently in /home/www/htdocs/test/fopen/slash.php on line 2

Regards
Mike Robinson


 -Original Message-
 From: Wez Furlong [mailto:[EMAIL PROTECTED]] 
 Sent: Saturday, October 12, 2002 1:40 PM
 To: Mike Robinson
 Cc: [EMAIL PROTECTED]; 'Wez Furlong'
 Subject: RE: [PHP-DEV] Streams Problems
 
 
 Works for me using latest CVS.
 
 ?php
$fp = fopen(http://site.that.redirects;, r);
fpassthru($fp);
var_dump(stream_get_meta_data($fp));
 ?
 
 The var_dump shows that PHP is following the redirects.
 There used to be a bug like that, but it's been fixed for a 
 couple of weeks now.
 
 How about posting a script that reproduces the problem, and 
 the error output?
 
 --Wez.
 
 On 10/12/02, Mike Robinson [EMAIL PROTECTED] wrote:
  Im not sure if this is related, but using fopen or fsockopen to 
  retrieve a document that sends a redirect header (in this 
 case a 302 
  Moved Permanently trying to pull the slashdot headlines 
 rdf/xml file) 
  fails. Worked fine in 4.2.3. This is the case with 4.3.0pr1 and CVS 
  for a little while now.
 
 
 
 
 -- 
 PHP Development Mailing List http://www.php.net/
 To unsubscribe, visit: http://www.php.net/unsub.php
 


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP-DEV] Streams Problems

2002-10-13 Thread Wez Furlong

Works for me using latest CVS.

?php
   $fp = fopen(http://site.that.redirects;, r);
   fpassthru($fp);
   var_dump(stream_get_meta_data($fp));
?

The var_dump shows that PHP is following the redirects.
There used to be a bug like that, but it's been fixed for a couple
of weeks now.

How about posting a script that reproduces the problem, and the
error output?

--Wez.

On 10/12/02, Mike Robinson [EMAIL PROTECTED] wrote:
 Im not sure if this is related, but using fopen or fsockopen
 to retrieve a document that sends a redirect header (in this
 case a 302 Moved Permanently trying to pull the slashdot
 headlines rdf/xml file) fails. Worked fine in 4.2.3. This is
 the case with 4.3.0pr1 and CVS for a little while now.




-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP-DEV] Streams Problems

2002-10-13 Thread Wez Furlong

Fixed in CVS now.
Thanks for reporting this :-)

--Wez.

On 10/12/02, Mike Robinson [EMAIL PROTECTED] wrote:
 ?php
 $fp = fopen(http://www.slashdot.org/slashdot.rdf;,'r');
 ?
 
 In 4.2.3 this works as expected. It redirects to
 http://slashdot.org/slashdot.rdf (note the 'www.' is gone).
 
 In 4.3.0pr1 this results in:
 
 Warning: fopen(http://www.slashdot.org/slashdot.rdf) [function.fopen]:
 failed to create stream: HTTP request failed! HTTP/1.1 301 Moved
 Permanently in /home/www/htdocs/test/fopen/slash.php on line 2
 
 Regards
 Mike Robinson
 
 
  -Original Message-
  From: Wez Furlong [mailto:[EMAIL PROTECTED]] 
  Sent: Saturday, October 12, 2002 1:40 PM
  To: Mike Robinson
  Cc: [EMAIL PROTECTED]; 'Wez Furlong'
  Subject: RE: [PHP-DEV] Streams Problems
  
  
  Works for me using latest CVS.
  
  ?php
 $fp = fopen(http://site.that.redirects;, r);
 fpassthru($fp);
 var_dump(stream_get_meta_data($fp));
  ?
  
  The var_dump shows that PHP is following the redirects.
  There used to be a bug like that, but it's been fixed for a 
  couple of weeks now.
  
  How about posting a script that reproduces the problem, and 
  the error output?
  
  --Wez.
  
  On 10/12/02, Mike Robinson [EMAIL PROTECTED] wrote:
   Im not sure if this is related, but using fopen or fsockopen to 
   retrieve a document that sends a redirect header (in this 
  case a 302 
   Moved Permanently trying to pull the slashdot headlines 
  rdf/xml file) 
   fails. Worked fine in 4.2.3. This is the case with 4.3.0pr1 and CVS 
   for a little while now.
  
  
  
  
  -- 
  PHP Development Mailing List http://www.php.net/
  To unsubscribe, visit: http://www.php.net/unsub.php
 




-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP-DEV] Streams Problems

2002-10-13 Thread Mike Robinson

Im not sure if this is related, but using fopen or fsockopen
to retrieve a document that sends a redirect header (in this
case a 302 Moved Permanently trying to pull the slashdot
headlines rdf/xml file) fails. Worked fine in 4.2.3. This is
the case with 4.3.0pr1 and CVS for a little while now.

Regards
Mike Robinson


 -Original Message-
 From: Ilia A. [mailto:[EMAIL PROTECTED]] 
 Sent: Friday, October 11, 2002 10:11 PM
 To: [EMAIL PROTECTED]; Wez Furlong
 Subject: [PHP-DEV] Streams Problems
 
 
 There are 3 streams related problems I've come across today 
 while using CVS 
 code. First it seems that sending of binary data in excess of 
 8k causes some 
 of the data not to be sent. This can be easily replicated 
 with the following 
 test code:
 ?php
 $test_binary_file = file_get_contents(file_name);
 $length = strlen($test_binary_file);
 
 $fs = fsockopen(host, port);
 $written = fwrite($fs, $test_binary_file)
 fclose($fs);
 ?
 
 According to fwrite() output all the data has been written, 
 since $length 
 equals to $written. However, using a network monitoring tool, 
 Ethereal I was 
 able to see that only about 8k worth of data was sent. This 
 was confirmed by 
 another script that set on the receiving end.
 
 Another problem I've come across is about reading from 
 sockets that do no 
 terminate connection. Using the following script I've connected to a 
 webserver, in php 4.2.3 the script returns immediately after 
 the last byte 
 has been read. In CVS the script wait about 10 seconds after 
 all the data has 
 been read before finally terminating (timing out?). The 
 example script is 
 below:
 ?php
 $fp = fsockopen(host, 80);
 fwrite($fp, GET / HTTP/1.1\r\nHost: host\r\n\r\n);
 while ( ($data = fgets($fp, 1024)) ) {
 echo $data;
 }
 flose($fp);
 ?
 
 The third problem is coredump that is fairly easily replicate 
 with the script 
 below:
 ?php
 $fp = fsockopen(localhost, 80);
 fputs($fp, GET / HTTP/1.0\r\n\r\n);
 fgets($fp, 10);
 ?
 
 Ilia
 
 -- 
 PHP Development Mailing List http://www.php.net/
 To unsubscribe, visit: http://www.php.net/unsub.php
 


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DEV] Streams Problems

2002-10-12 Thread Ilia A.

There are 3 streams related problems I've come across today while using CVS 
code. First it seems that sending of binary data in excess of 8k causes some 
of the data not to be sent. This can be easily replicated with the following 
test code:
?php
$test_binary_file = file_get_contents(file_name);
$length = strlen($test_binary_file);

$fs = fsockopen(host, port);
$written = fwrite($fs, $test_binary_file)
fclose($fs);
?

According to fwrite() output all the data has been written, since $length 
equals to $written. However, using a network monitoring tool, Ethereal I was 
able to see that only about 8k worth of data was sent. This was confirmed by 
another script that set on the receiving end.

Another problem I've come across is about reading from sockets that do no 
terminate connection. Using the following script I've connected to a 
webserver, in php 4.2.3 the script returns immediately after the last byte 
has been read. In CVS the script wait about 10 seconds after all the data has 
been read before finally terminating (timing out?). The example script is 
below:
?php
$fp = fsockopen(host, 80);
fwrite($fp, GET / HTTP/1.1\r\nHost: host\r\n\r\n);
while ( ($data = fgets($fp, 1024)) ) {
echo $data;
}
flose($fp);
?

The third problem is coredump that is fairly easily replicate with the script 
below:
?php
$fp = fsockopen(localhost, 80);
fputs($fp, GET / HTTP/1.0\r\n\r\n);
fgets($fp, 10);
?

Ilia

-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DEV] Streams: Further considerations

2002-10-04 Thread Sascha Schumann

Streams' gets function does not work with stdio, because it
uses fread(3) instead of fgets(3).  Like fill_read_buffer
earlier, fread(3) does not return, unless an error occurs or
the amount of data has been read completely.  It is basically
impossible to implement an _efficient_ fgets-like function
using fread(3).

Additionally, stdio does its own buffering -- there is no
reason to add another buffer layer above it.  The streams
buffer needs to be disabled, because fgets/fread would
otherwise interact wrongly.

The attached patch does this:

- Disables buffering for stdio using PHP_STREAM_FLAG_NO_BUFFER
- Adds a gets hook to stream ops
- Adds a gets implementation to stdio ops
- Makes stream_gets use that hook, if available
- Inverts the semantic of fill_read_buffer regarding blocking

make test and entering data using stdin works.

Comments, please.

- Sascha


Index: main/network.c
===
RCS file: /repository/php4/main/network.c,v
retrieving revision 1.73
diff -u -r1.73 network.c
--- main/network.c  4 Oct 2002 19:08:43 -   1.73
+++ main/network.c  4 Oct 2002 20:29:10 -
 -542,7 +542,6 
sock-socket = socket;
 
stream = php_stream_alloc_rel(php_stream_socket_ops, sock, persistent_id, 
r+);
-   stream-flags |= PHP_STREAM_FLAG_AVOID_BLOCKING;
 
if (stream == NULL) 
pefree(sock, persistent_id ? 1 : 0);
Index: main/php_streams.h
===
RCS file: /repository/php4/main/php_streams.h,v
retrieving revision 1.53
diff -u -r1.53 php_streams.h
--- main/php_streams.h  4 Oct 2002 18:59:34 -   1.53
+++ main/php_streams.h  4 Oct 2002 20:29:10 -
 -153,6 +153,7 
int (*cast)(php_stream *stream, int castas, void **ret TSRMLS_DC);
int (*stat)(php_stream *stream, php_stream_statbuf *ssb TSRMLS_DC);
int (*set_option)(php_stream *stream, int option, int value, void *ptrparam 
TSRMLS_DC);
+   size_t (*gets)(php_stream *stream, char *buf, size_t count TSRMLS_DC);
 } php_stream_ops;
 
 typedef struct _php_stream_wrapper_ops {
 -225,11 +226,13 
 #define PHP_STREAM_FLAG_DETECT_EOL 4
 #define PHP_STREAM_FLAG_EOL_MAC8
 
-/* set this when the stream might represent interactive data.
- * When set, the read buffer will avoid certain operations that
- * might otherwise cause the read to block for much longer than
- * is strictly required. */
-#define PHP_STREAM_FLAG_AVOID_BLOCKING 16
+/*
+ * By default, your read operation will be called once to
+ * retrieve a chunk of data. If you do not immediately return
+ * all available data during one read operation and you want
+ * us to call it multiple times, use this flag.
+ */
+#define PHP_STREAM_FLAG_DO_BLOCKING16

 struct _php_stream  {
php_stream_ops *ops;
Index: main/streams.c
===
RCS file: /repository/php4/main/streams.c,v
retrieving revision 1.95
diff -u -r1.95 streams.c
--- main/streams.c  4 Oct 2002 19:48:59 -   1.95
+++ main/streams.c  4 Oct 2002 20:29:12 -
 -497,7 +497,7 

stream-writepos += justread;

-   if (stream-flags  PHP_STREAM_FLAG_AVOID_BLOCKING)
+   if (!(stream-flags  PHP_STREAM_FLAG_DO_BLOCKING))
break;
}
 }
 -657,10 +657,21 
 {
size_t avail = 0;
int did_copy = 0;
-   
+
if (maxlen == 0)
return NULL;
 
+   if (stream-ops-gets) {
+   size_t n;
+
+   n = stream-ops-gets(stream, buf, maxlen TSRMLS_CC);
+
+   if (n == 0)
+   return NULL;
+
+   return buf + n;
+   }
+
/*
 * If the underlying stream operations block when no new data is readable,
 * we need to take extra precautions.
 -1149,6 +1160,8 
 PHPAPI php_stream *_php_stream_fopen_from_file(FILE *file, const char *mode 
STREAMS_DC TSRMLS_DC)
 {
php_stdio_stream_data *self;
+   php_stream *stream;
+   
 #ifdef S_ISFIFO
int fd;
 #endif
 -1167,18 +1180,25 
}
 #endif

-   return php_stream_alloc_rel(php_stream_stdio_ops, self, 0, mode);
+   stream = php_stream_alloc_rel(php_stream_stdio_ops, self, 0, mode);
+   stream-flags |= PHP_STREAM_FLAG_NO_BUFFER;
+   return stream;
 }
 
 PHPAPI php_stream *_php_stream_fopen_from_pipe(FILE *file, const char *mode 
STREAMS_DC TSRMLS_DC)
 {
php_stdio_stream_data *self;
+   php_stream *stream;
 
self = 

[PHP-DEV] Streams-Change ?!

2002-10-03 Thread Stefan Esser

Hi,

was there a change of the streams EOF functions? I added some
functionality to ext/ftp and must see that ftp_put uploads
one byte less than the filesize.

Stefan Esser


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Streams-Change ?!

2002-10-03 Thread Marcus Börger

At 13:20 03.10.2002, Stefan Esser wrote:
Hi,

was there a change of the streams EOF functions? I added some
functionality to ext/ftp and must see that ftp_put uploads
one byte less than the filesize.

There are problems especially in the streams seeker function at least.

marcus


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Streams-Change ?!

2002-10-03 Thread Stefan Esser

On Thu, Oct 03, 2002 at 01:54:46PM +0200, Marcus Börger wrote:
 There are problems especially in the streams seeker function at least.
 
 marcus

Problem was in ext/ftp.

Thanks anyway.

Stefan

-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DEV] Streams filter API

2002-08-20 Thread Wez Furlong

I've just comitted the streams filter API to CVS.
The concept is that a series of filters can be applied to a given
stream instance (as a doubly-linked-list); writing to the stream
causes the buffer to pass through the filters from head to tail,
before finally being written to the underlying stream.

Likewise, reading from the stream also causes the data to pass
through the filters, but in the reverse order.

Filters can be attached to either the head or tail of the filter
stack for a stream using:
  php_stream_filter_prepend(stream, filter);
  php_stream_filter_append(stream, filter);

Filters are registered in a similar way as wrappers using:
  php_stream_filter_register_factory(char *filterpattern,
php_stream_filter_factory *factory);

The factory object has a method which instantiates the
actual filter.

Filter names must have the form group.name; the
filterpattern parameter is either the fully-qualified name
of the filter to create (such as string.rot13), or it can
be a wildcard such as mbstring.*.

Wildcard factories can be used when there are a large number
of possible filters, to prevent a zillion lines that just call
the register factory function; I forsee filter names such
as mbstring.sjis/utf-8 being possible (which might convert
sjis into utf-8) - the filter would match an mbstring.*
factory which would parse the sjis/utf-8 part of the filter
name and create the appropriate mbfilter converters for the
returned filter object.

Filters are created using:
  php_stream_filter_create(char *filtername, char *filterparams,
int filterparamslen, int persistent TSRMLS_DC);

filtername corresponds to the name used to register the factory;
if no exact match is found, it looks for a factory matching
group.*, and then passes the filtername to it's factory method.

Filterparams is a binary safe string parameter which can carry
some kind of options to a filter implementation.  For example,
it might specifit the compression level for a zlib filter, or it
might control the number of bits used in a cypher, or some kind
of key for cypto filters.
The filter API doesn't touch this parameter; it's interpreted only
by the factory object/method.

I've added two user-space functions to demonstrate filters in action;
they combine the filter creation and stacking into a single function:

bool stream_filter_prepend(resource stream, string filtername
 [, string filterparams]);

bool stream_filter_append(resource stream, string filtername
 [, string filterparams]);

Also for the sake of demonstraton, I've implemented a rot13 filter.
(I chose rot13 because it did not require the filter to buffer data,
and because the nice 3-line implementation of the string function
happened to be near the bottom of ext/standard/strings.c :-).

This code snippet opens a stream and then applies a rot13 filter:

$fp = fopen(file.txt, r);
stream_filter_prepend($fp, string.rot13);
// Each byte that is read undergoes a rot13 tranformation before
// being returned in $line.
$line = fgets($fp, 1024);

Once other filters have been written it would be possible to do
something like this:

stream_filter_prepend($fp, compress.zlib);
stream_filter_prepend($fp, string.toupper);
// file content is decompressed by zlib, and then
// has all characters upper-cased.
// Then it is output to browser.
fpassthru($fp);
// If we were to write to $fp instead, the inverse would happen:
// characters would be lower-cased (*) and then the
// data would be compressed and then written to the file

*: Assuming the the inverse operation for the string.toupper
filter actually lower-cased the text.  It might just pass-thru
the text unchanged - it's a filter specific thing.

This similar code produces different results (because
the filters are in a different order):

stream_filter_append($fp, compress.zlib);
stream_filter_append($fp, string.toupper);
// data is upper cased and then decompressed.
// This is probably not what is desired here
fpassthru($fp);

Possible Gotchas when using filters:

o Seeking is probably not a hot idea.  I've tried to allow
  for it in the API, but when you have a filter where the
  number of bytes for the encoded data is not a 1:1 mapping
  with the number of bytes of decoded data, you could end up
  with problems; at the end of the day, if depends on how many
  layers of filters you are using and how well they handle things.

o Casting a filtered stream to a FILE* will only work if your
  system has fopencookie.  Casting to fd's or sockets will not
  work at all.  This means that you can't (portably) pass a
  filtered stream to a third-party library.

I think the C API is just about right (there are more functions
than I've briefly mentioned here, so you can do things like remove
a given filter from a stream).

The user-space API might benefit from allowing and array to specify
a series of filters (and parameters) all in one function call.

All comments/questions are welcome, but please revisit an 

Re: [PHP-DEV] Streams filter API

2002-08-20 Thread Andi Gutmans

At 10:47 PM 8/20/2002 +0100, Wez Furlong wrote:
Filters are created using:
   php_stream_filter_create(char *filtername, char *filterparams,
 int filterparamslen, int persistent TSRMLS_DC);

filtername corresponds to the name used to register the factory;
if no exact match is found, it looks for a factory matching
group.*, and then passes the filtername to it's factory method.

Filterparams is a binary safe string parameter which can carry
some kind of options to a filter implementation.  For example,
it might specifit the compression level for a zlib filter, or it
might control the number of bits used in a cypher, or some kind
of key for cypto filters.
The filter API doesn't touch this parameter; it's interpreted only
by the factory object/method.

Hey,

I think it's probably best to make filterparams a void * because then you 
can pass whatever you want (a structure with all the params and so on). Of 
course you can do it with your current prototype too but this is how it's 
usually done.
I haven't looked into the API itself so if it doesn't make much sense 
ignore me :)

Andi


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DEV] Streams: FTP/HTTP wrapper gurus wanted

2002-08-11 Thread Wez Furlong

Hi all,

I'm making an effort to clean up the streams code ready for release.
I've already commited some docs to the phpdoc repository that will
aid extension developers use streams.

However, there is more to streams than simple file IO; the new
wrapper system provides a much richer set of operations.  For example,
stat and opendir are routed through the wrapper subsystem, which
means that it is possible for a lot of filesystem functions to
obtain information about remote files.

I've put the infrastructure in place, but now I need your help:
I need people that know the protocols to implement the stat and
readdir functionality for FTP and HTTP.

I'd like to see the remote file stat capability stuff in place
for the 4.3 release: readdir is slightly more involved, so I can
wait for that.

FTP:

From the code already written for the ftp wrapper, I can see
how to determine the file size, but I don't know how to determine
things like ctime and file type.
For opendir/readdir, we need to enumerate/list files and folders
in a dir.

HTTP:
=
Again, we need to determine file size and change time.
This seems quite easy - just do a HEAD request and parse the
relevant headers.
For readdir, I think we might need to implement a very simple
DAV client?  Opinions please!

I'm looking for 2 volunteers, one for FTP and one for HTTP,
to actually write the code - it's not much code to write,
you just need to have a clue about the protocols ! :-)

--Wez.

-- 
Wez Furlong
The Brain Room Ltd.


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Streams: FTP/HTTP wrapper gurus wanted

2002-08-11 Thread Rasmus Lerdorf

 Again, we need to determine file size and change time.
 This seems quite easy - just do a HEAD request and parse the
 relevant headers.
 For readdir, I think we might need to implement a very simple
 DAV client?  Opinions please!

Yeah, you simply send a PROPFIND request and parse the resulting XML
reply. But I am not convinced this is all that useful. DAV really hasn't
made too many inroads, so for most users this won't work.

-Rasmus


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Streams: FTP/HTTP wrapper gurus wanted

2002-08-11 Thread Sterling Hughes

 Hi all,
 
 I'm making an effort to clean up the streams code ready for release.
 I've already commited some docs to the phpdoc repository that will
 aid extension developers use streams.
 
 However, there is more to streams than simple file IO; the new
 wrapper system provides a much richer set of operations.  For example,
 stat and opendir are routed through the wrapper subsystem, which
 means that it is possible for a lot of filesystem functions to
 obtain information about remote files.
 
 I've put the infrastructure in place, but now I need your help:
 I need people that know the protocols to implement the stat and
 readdir functionality for FTP and HTTP.
 
 I'd like to see the remote file stat capability stuff in place
 for the 4.3 release: readdir is slightly more involved, so I can
 wait for that.
 
 FTP:
 
 From the code already written for the ftp wrapper, I can see
 how to determine the file size, but I don't know how to determine
 things like ctime and file type.
 For opendir/readdir, we need to enumerate/list files and folders
 in a dir.
 
 HTTP:
 =
 Again, we need to determine file size and change time.
 This seems quite easy - just do a HEAD request and parse the
 relevant headers.
 For readdir, I think we might need to implement a very simple
 DAV client?  Opinions please!
 
 I'm looking for 2 volunteers, one for FTP and one for HTTP,
 to actually write the code - it's not much code to write,
 you just need to have a clue about the protocols ! :-)


Wez,

This seems like an ideal time to me to start working on the bundling of
cURL into PHP, no?

-Sterling

 --Wez.
 
 -- 
 Wez Furlong
 The Brain Room Ltd.
 
 
 -- 
 PHP Development Mailing List http://www.php.net/
 To unsubscribe, visit: http://www.php.net/unsub.php
 

-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Streams: FTP/HTTP wrapper gurus wanted

2002-08-11 Thread Wez Furlong

On 08/11/02, Rasmus Lerdorf [EMAIL PROTECTED] wrote:
  For readdir, I think we might need to implement a very simple
  DAV client?  Opinions please!
 
 Yeah, you simply send a PROPFIND request and parse the resulting XML
 reply. But I am not convinced this is all that useful. DAV really hasn't
 made too many inroads, so for most users this won't work.

I thought that Apache 2 would result in a more widespread usage of
DAV (I'm not sure why I think that - something to do with subversion,
IIRC)?

I suppose we can leave out DAV from the HTTP wrapper; frameworks like
PEAR can always implement a DAV protocol wrapper using script anyway,
and it'll probably easier to implement an XML parser in script too.

--Wez.


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Streams: FTP/HTTP wrapper gurus wanted

2002-08-11 Thread Wez Furlong

Hi Sterling,

I'm not sure :-)
I'm 50/50 on integrating curl, because I know that it supports more features
than the current wrappers, but I'm not sure if it supports a rich enough
API to do the things that the streams API supports.

So, I need your opinion:

Does libcurl allow you to have progress notification callbacks,
so that scripts/extensions can act on notifications such as mime type,
file size, and overall progress?
(I know it can print out a progress bar, but we need something a little
bit more useful than that :-)

Can we wrap a curl handle up into a stream without too much trouble?
Is libcurl thread-safe?

The other stuff should be relatively easy (like HEAD requests and so on),
but if those two things look too hard, I'd be tempted to spend the effort
on improving the streams code instead of trying to force libcurl to fit
into streams.

Last time I looked, I didn't like the look of libcurl, but it's been
a while, so things might be better now.

Opinions please! :-)

--Wez.

On 08/11/02, Sterling Hughes [EMAIL PROTECTED] wrote:
 Wez,
 
 This seems like an ideal time to me to start working on the bundling of
 cURL into PHP, no?




-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Streams: FTP/HTTP wrapper gurus wanted

2002-08-11 Thread Justin Erenkrantz

On Sun, Aug 11, 2002 at 03:49:45PM +0100, Wez Furlong wrote:
 I thought that Apache 2 would result in a more widespread usage of
 DAV (I'm not sure why I think that - something to do with subversion,
 IIRC)?

httpd-2.0 includes mod_dav in the stock distribution.  -- justin

-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Streams: FTP/HTTP wrapper gurus wanted

2002-08-11 Thread Shane Caraveo

Wez,
I haven't looked into the streams stuff much, but have had it in the 
back of my head a lot.  Does the streams implementation support 
'filters' on streams?  With this, whatever gets written to a stream 
would go through a filter prior to going across the wire.  Reason I ask 
is that this would be a perfect fit for protocols like DIME.
Shane

Wez Furlong wrote:
 Hi Sterling,
 
 I'm not sure :-)
 I'm 50/50 on integrating curl, because I know that it supports more features
 than the current wrappers, but I'm not sure if it supports a rich enough
 API to do the things that the streams API supports.
 
 So, I need your opinion:
 
 Does libcurl allow you to have progress notification callbacks,
 so that scripts/extensions can act on notifications such as mime type,
 file size, and overall progress?
 (I know it can print out a progress bar, but we need something a little
 bit more useful than that :-)
 
 Can we wrap a curl handle up into a stream without too much trouble?
 Is libcurl thread-safe?
 
 The other stuff should be relatively easy (like HEAD requests and so on),
 but if those two things look too hard, I'd be tempted to spend the effort
 on improving the streams code instead of trying to force libcurl to fit
 into streams.
 
 Last time I looked, I didn't like the look of libcurl, but it's been
 a while, so things might be better now.
 
 Opinions please! :-)
 
 --Wez.
 
 On 08/11/02, Sterling Hughes [EMAIL PROTECTED] wrote:
 
Wez,

This seems like an ideal time to me to start working on the bundling of
cURL into PHP, no?
 
 
 
 
 




-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Streams: FTP/HTTP wrapper gurus wanted

2002-08-11 Thread Rasmus Lerdorf

 On 08/11/02, Rasmus Lerdorf [EMAIL PROTECTED] wrote:
   For readdir, I think we might need to implement a very simple
   DAV client?  Opinions please!
 
  Yeah, you simply send a PROPFIND request and parse the resulting XML
  reply. But I am not convinced this is all that useful. DAV really hasn't
  made too many inroads, so for most users this won't work.

 I thought that Apache 2 would result in a more widespread usage of
 DAV (I'm not sure why I think that - something to do with subversion,
 IIRC)?

Yes, DAV is bundled with Apache2, but Apache2 is deployed on even less
sites than mod_dav.  When, if ever, someone fixes all the 3rd party libs
on UNIX to be threadsafe and someone adds something to Apache2 that is
actually a compelling reason to migrate, then we might start seeing more
widespread deployment.  I guess my point is that there is no rush on this
one.  Skip it for 4.3.

-Rasmus


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Streams: FTP/HTTP wrapper gurus wanted

2002-08-11 Thread Sterling Hughes

 Hi Sterling,
 
 I'm not sure :-)
 I'm 50/50 on integrating curl, because I know that it supports more features
 than the current wrappers, but I'm not sure if it supports a rich enough
 API to do the things that the streams API supports.
 
 So, I need your opinion:
 
 Does libcurl allow you to have progress notification callbacks,
 so that scripts/extensions can act on notifications such as mime type,
 file size, and overall progress?
 (I know it can print out a progress bar, but we need something a little
 bit more useful than that :-)


cURL can handle such things (progress notifications can go to a function).  
I'm not sure why you would want MIME type notification, but we can add that
no problem, and maybe even cURL can be modified to make that easier...

cURL does support posting customized headers, btw, if that's where you
were going.

 Can we wrap a curl handle up into a stream without too much trouble?

Depends on how you define too-much-trouble :P

Using smart_str() and cURL's new multi interface. 

there are some things that would be different, i would say optimized,
mainly that read () requests would be optimal case, not specified case,
ie, if the user specifies 1024 bytes to read, and 4096 are available
without blocking, then 4096 will be read (it goes without saying that we
can buffer this and return 1024).

An option could theortically be added to handle specified case instead
of optimized case.  One of the great things about cURL is that the
author is very responsive  I've forwarded him this message so that
(i forget if currently he's on vacation or not, which is the only time
I've ever head a reply lag) he can answer any questions that arise as
well...

 Is libcurl thread-safe?


yes, as long as you don't make it un-threadsafe :)

When using global dns caching, then it becomes un-ts, but if you avoid
this, than you should be fine.  Daniel wrote up an API for mutexing
globals, and I've got this almost working (a bit more testing before I
post it), so this will also be an option (global DNS caching should 
*greatly* improve speed for php apps, it is already somewhat done i 
believe, but it can be handled better, and cURL does so).

You don't need to use the global dns cache, of course, and if you don't
everything else is threadsafe.  cURL is heavily used in many
multi-thread applications (more so than php, i would gander).

 The other stuff should be relatively easy (like HEAD requests and so on),
 but if those two things look too hard, I'd be tempted to spend the effort
 on improving the streams code instead of trying to force libcurl to fit
 into streams.
 
 Last time I looked, I didn't like the look of libcurl, but it's been
 a while, so things might be better now.
 

Well, if we are talking about a permanent solution, I think cURL is a
much better choice, simply because:

1) its about 3 times as fast as the code in there now
2) its already gone to the trouble of messing with fucked up http, and
has plenty of debugging going into it (its becoming the replacement for
libwww btw).
3) it offers much richer support for http and ftp, as well as a miriad
of other protocols, I want my LDAP streams and I want them now!
4) Reuse, http and friends are constantly changing, we don't have the
resources properly, the cURL folks do.  I would rather see one php
developer improving cURL to meet php's needs, than one php developer
maintaining such code in php (if that was even achievable).

-Sterling

-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Streams: FTP/HTTP wrapper gurus wanted

2002-08-11 Thread Wez Furlong

Hi Shane,

It's planned; depending on how productive I can be with my PHP time,
it might make it into PHP 4.3.

--Wez.

On 08/11/02, Shane Caraveo [EMAIL PROTECTED] wrote:
 Wez,
 I haven't looked into the streams stuff much, but have had it in the 
 back of my head a lot.  Does the streams implementation support 
 'filters' on streams?  With this, whatever gets written to a stream 
 would go through a filter prior to going across the wire.  Reason I ask 
 is that this would be a perfect fit for protocols like DIME.
 Shane



-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Streams: FTP/HTTP wrapper gurus wanted

2002-08-11 Thread Wez Furlong

Sterling,

Thats all I needed to know; I'll take a closer look at the library
and see if I can cook up a curl based stream/wrapper.
Is there a minimum version of the library (release preferred, of course)
that has this new multi-interface, or should I just use the CVS version
for now?

--Wez.

On 08/11/02, Sterling Hughes [EMAIL PROTECTED] wrote:
[ Stuff in favour of libcurl ]


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Streams: FTP/HTTP wrapper gurus wanted

2002-08-11 Thread Sterling Hughes

 Sterling,
 
 Thats all I needed to know; I'll take a closer look at the library
 and see if I can cook up a curl based stream/wrapper.
 Is there a minimum version of the library (release preferred, of course)
 that has this new multi-interface, or should I just use the CVS version
 for now?


Go with the CVS version, its been in there for a while, but I think just
CVS contains the multi version in all its glory (ie, with exported
header files).

-Sterling

-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Streams: FTP/HTTP wrapper gurus wanted

2002-08-11 Thread Wez Furlong

I'm checking it out now: I had 7.9.8 already downloaded, but I think
I ran into a bug with the multi interface (it doesn't seem to actually
follow HTTP redirects?! - and FOLLOWLOCATION is enabled).

The good news is that I have an alpha curl stream/wrapper already
working (except for not following redirects!).

--Wez.

On 08/11/02, Sterling Hughes [EMAIL PROTECTED] wrote:
 Go with the CVS version, its been in there for a while, but I think just
 CVS contains the multi version in all its glory (ie, with exported
 header files).



-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DEV] streams and options

2002-04-19 Thread Derick Rethans

Hey Wez,

I wonder if it is possible to set options after a stream has been opened. 
Something like:

$fp = fopen (crypt.des://secretfile.des, r);
stream_option ($fp, key, very secret key);

And if it's there, is there an example in the source of it?

regards,
Derick


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] streams and options

2002-04-19 Thread Wez Furlong

Hi Derick,

I'm leading up to be able to do this sort of thing, but want/need to
discuss/brainstorm it here before I do much more to it.

In a recent commit I added a context parameter to fopen.  The context
is intended to hold these kind of options, plus other data that is or
will be relevant to streams and/or wrappers.  A context may be shared
by multiple streams/wrappers, so common options can apply to a group
of streams.

At the moment, there are a couple of user-space APIs for manipulating
contexts:
file_context_create([array options]) and
file_context_set_params(array options).

I think that it would generally be useful to store context data on
3 levels:

1. The very general context level.  Here we set things like status
notification callbacks, or other stream/wrapper tuning parameters,
like default chunk size for network streams, or whatever.

2. The common wrapper level.  Here we set things that are common to
a family of wrappers.  So, net would store settings common to various
network wrappers (a bit like .netrc), compress would store settings
common to various zippers, crypt for common crypt settings etc.

3. The specific wrapper level: net.http stores http specific settings,
crypt.des stores des specific settings etc. etc.

ATM, file_context_set_params will only operate at the context level.
I think introducing a new API like this:
file_context_set_option(resource $context|resource $stream,
   string $wrapperkey, string $optionname, mixed $optionvalue);
would do that job just fine.

The reason for having a separate function is that it means that we
won't risk collisions between context level setting names and
user-registered wrapper names.

So, your example below would look like this:
$fp = fopen (crypt.des://secretfile.des, r);
file_context_set_option ($fp, crypt, key, very secret key);

Although my feeling is that setting the options before opening
might make more sense (or might be the only option, particularly
for network wrappers):

$ctx = file_context_create();
file_context_set_option ($ctx, net, proxy, myproxy:8080);
$fp = fopen (http://www.php.net;, r, false, $ctx);

Then we will need functions to retrieve those settings, both in 
the php core and in user land (for user-space wrappers).

PHPAPI int php_stream_context_get_option(
   php_stream_context *context,
   const char *wrapperkey,
   const char *optionname,
   zval **optionvalue);

This would really just be a wrapper around the zend_hash_find
function, so I might implement it as a macro.

Extension code would use it a bit like this:

php_stream *stream; // already filled in somewhere with a valid stream

if (stream-context) {
zval *keyval = NULL;
if (SUCCESS == php_stream_context_get_option(stream-context,
crypt, key, keyval)) {
// it's safe to use keyval
}
}

Any comments?

--Wez.

On 19/04/02, Derick Rethans [EMAIL PROTECTED] wrote:
 Hey Wez,
 
 I wonder if it is possible to set options after a stream has been opened. 
 Something like:
 
 $fp = fopen (crypt.des://secretfile.des, r);
 stream_option ($fp, key, very secret key);
 
 And if it's there, is there an example in the source of it?
 
 regards,
 Derick
 
 
 -- 
 PHP Development Mailing List http://www.php.net/
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] streams and options

2002-04-19 Thread l0t3k

Wez,
  scream at me if it seems dumb, but in my never-finished extension, 
each  plugin accepts an option hash in the init callback which is used 
to set up the object. the framework also stores this hash as an member 
of the object, and there are accessor methods to query the options.
  this keeps it simple for me..

Wez Furlong wrote:

 Hi Derick,
 
 I'm leading up to be able to do this sort of thing, but want/need to
 discuss/brainstorm it here before I do much more to it.
 

 
 Any comments?
 
 --Wez.
 
 On 19/04/02, Derick Rethans [EMAIL PROTECTED] wrote:
 
Hey Wez,

I wonder if it is possible to set options after a stream has been opened. 
Something like:

$fp = fopen (crypt.des://secretfile.des, r);
stream_option ($fp, key, very secret key);

And if it's there, is there an example in the source of it?

regards,
Derick


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php

 
 
 


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] streams and options

2002-04-19 Thread Wez Furlong

On 19/04/02, l0t3k [EMAIL PROTECTED] wrote:
 Wez,
   scream at me if it seems dumb, but in my never-finished extension, 
 each  plugin accepts an option hash in the init callback which is used 
 to set up the object. the framework also stores this hash as an member 
 of the object, and there are accessor methods to query the options.
   this keeps it simple for me..

It doesn't sound dumb at all; that is (in effect) what the streams are
already doing :-)
It's made a bit more complicated because we have potentially a very wide
variety of options/settings, and we also have a two or more layer system:
a stream might be wrapped, and/or it may contain other streams; the single
context parameter holds the options hash for all those associated streams
and their wrappers.

I did forget to mention that file_context_set_option($fp, array(...))
should also be supported, to reduce the number of function calls that
need to be made, and simplify the php scripts.

--Wez.
 



-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Streams are here!

2002-03-16 Thread Stefan Roehrich

On 2002-03-16 01:11:11, Wez Furlong wrote:
 Can you tell me which include files are needed to correct
 the build on your system?
 Then I can fix it :-)

Your fix to the .h file helped (even without the (long) change).

Maybe we can use a configure check for ptrdiff_t like in
ext/bcmath/libbcmath, so we can avoid the (long) workaround.

  Stefan

-- 
Stefan Röhrich   [EMAIL PROTECTED], [EMAIL PROTECTED]
 http://www.roehri.ch/~sr/

-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DEV] streams crash

2002-03-16 Thread sesser

following little script crashes now:

?
$myftp = ftp_connect(ftp.mutt.org);
?

it crashes in fflush() of libc and backtrace shows
that its called by php_stdiop_flush, which is called
from php_stream_flush, php_stream_free, 

Stefan


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Streams are here!

2002-03-16 Thread Wez Furlong

Yes; I'm not happy with (long).
Apparently, some systems have ptrdiff_t in malloc.h rather than
stddef.h.

I'll see what I can do, but it's tricky when working blind
like this :-/

--Wez.

On 16/03/02, Stefan Roehrich [EMAIL PROTECTED] wrote:
 On 2002-03-16 01:11:11, Wez Furlong wrote:
  Can you tell me which include files are needed to correct
  the build on your system?
  Then I can fix it :-)
 
 Your fix to the .h file helped (even without the (long) change).
 
 Maybe we can use a configure check for ptrdiff_t like in
 ext/bcmath/libbcmath, so we can avoid the (long) workaround.
 
   Stefan
 
 -- 
 Stefan Röhrich   [EMAIL PROTECTED], [EMAIL PROTECTED]
  http://www.roehri.ch/~sr/




-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] streams crash

2002-03-16 Thread Sander Roobol

Apache crashes when running _any_ script (even phpinfo(); segfaults). 
CLI works fine.

Backtrace:
#0  0x400e7476 in fflush () from /lib/libc.so.6
#1  0x402ff5b7 in php_stdiop_flush (stream=0x8169bc4)
 at /home/sander/php/head/php4/main/streams.c:500
#2  0x402fee39 in php_stream_flush (stream=0x8169bc4)
 at /home/sander/php/head/php4/main/streams.c:186
#3  0x402feb76 in php_stream_free (stream=0x8169bc4, call_dtor=1)
 at /home/sander/php/head/php4/main/streams.c:70
#4  0x402a44b2 in _file_stream_dtor (rsrc=0x8169c3c)
 at /home/sander/php/head/php4/ext/standard/file.c:116
#5  0x4031f56d in list_entry_destructor (ptr=0x8169c3c)
 at /home/sander/php/head/php4/Zend/zend_list.c:177
#6  0x4031f742 in zend_destroy_rsrc_list (ht=0x4043f3dc)
 at /home/sander/php/head/php4/Zend/zend_list.c:248
#7  0x40311417 in shutdown_executor ()
 at /home/sander/php/head/php4/Zend/zend_execute_API.c:196
#8  0x40319c46 in zend_deactivate () at 
/home/sander/php/head/php4/Zend/zend.c:596
#9  0x402f7d2b in php_request_shutdown (dummy=0x0)
 at /home/sander/php/head/php4/main/main.c:795
#10 0x403321b3 in apache_php_module_main (r=0x81647cc, 
display_source_mode=0)
 at /home/sander/php/head/php4/sapi/apache/sapi_apache.c:96
#11 0x40332c5e in send_php (r=0x81647cc, display_source_mode=0, 
filename=0x0)
 at /home/sander/php/head/php4/sapi/apache/mod_php4.c:575
#12 0x40332cc2 in send_parsed_php (r=0x81647cc)
 at /home/sander/php/head/php4/sapi/apache/mod_php4.c:590
#13 0x08075999 in ap_invoke_handler ()
#14 0x0808a7cf in process_request_internal ()
#15 0x0808a836 in ap_process_request ()
#16 0x080816f6 in child_main ()
#17 0x080818b1 in make_child ()
#18 0x08081a2c in startup_children ()
#19 0x080820bd in standalone_main ()
#20 0x0808291c in main ()
#21 0x4009f65f in __libc_start_main () from /lib/libc.so.6

Sander

On 2002.03.16 12:13 [EMAIL PROTECTED] wrote:
 following little script crashes now:
 
 ?
   $myftp = ftp_connect(ftp.mutt.org);
 ?
 
 it crashes in fflush() of libc and backtrace shows
 that its called by php_stdiop_flush, which is called
 from php_stream_flush, php_stream_free, 
 
 Stefan
 
 
 --
 PHP Development Mailing List http://www.php.net/
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 

-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Streams are here!

2002-03-16 Thread Derick Rethans

Markus,

please use tabs for indentation, and favor this:

if (set) {
function();
}

above this:

if (set) function();

this makes the PHP C source more consistent.

Derick

On Sat, 16 Mar 2002, Marcus Börger wrote:

 To have image.c work i had to correct the php_stream_seek and php_stream_getc
 calls. Seek caals had wrong parameter arragement - but nowhere else in code...
 getc see below...
 
 I changed both functions later.
 
 in php_stream_getc i return buf  0xFF because otherwise i get 0xFFxx 
 in return.
 
 in php_stream_seek i added code to make it much faster
 
 and i couldn't compile php_stdiop_read see diff
 
 marcus
 
 diff -u -w -r1.11 streams.c
 --- main/streams.c  16 Mar 2002 00:05:47 -  1.11
 +++ main/streams.c  16 Mar 2002 02:28:55 -
 @@ -132,7 +132,7 @@
  char buf;
 
  if (php_stream_read(stream, buf, 1)  0) {
 -   return buf;
 +   return buf  0xFF;
  }
  return EOF;
   }
 @@ -204,17 +204,19 @@
 
   PHPAPI int php_stream_seek(php_stream *stream, off_t offset, int whence)
   {
 +   static char tmp[1024];
 +
  if (stream-ops-seek) {
  return stream-ops-seek(stream, offset, whence);
  }
 
  /* emulate forward moving seeks with reads */
  if (whence == SEEK_CUR  offset  0) {
 -   while(offset--  0) {
 -   if (php_stream_getc(stream) == EOF) {
 -   return -1;
 -   }
 +   while (offset=sizeof(tmp)) {
 +   php_stream_read(stream,tmp,sizeof(tmp));
 +   offset -= sizeof(tmp);
  }
 +   if (offset) php_stream_read(stream,tmp,offset);
  return 0;
  }
 
 @@ -447,7 +449,7 @@
 
   static size_t php_stdiop_read(php_stream *stream, char *buf, size_t count)
   {
 -   php_stdio_stream_data * ata = (php_stdio_stream_data*)stream-abstract;
 +   php_stdio_stream_data * data = 
 (php_stdio_stream_data*)stream-abstract;
 
  if (buf == NULL  count == 0)  {
  /* check for EOF condition */
 
 
 At 22:12 15.03.2002, Wez Furlong wrote:
 Well, PHP finally supports fopen(https://...;) :-)
 
 Please please please test the following things in particular
 as I can't compile them or verify them here:
 
 hyperwave:
 hw_new_document_from_file
 
 gd:
 functions that create images from files.
 In particular, try creating from wrapped files over
 http, ftp etc.
 
 pfsockopen()
 copy() - particularly with wrapped source/dest
 gzopen (and friends)
 gzfile
 
 If you have a system where HAVE_FLUSHIO is important,
 please let me know if plain files work correctly when
 switching between read and write.
 
 If you have things in Pear/PECL or a third party
 extension that used the old FP_XXX or php_file_le_fopen(),
 please contact me and I can help you update your code for
 streams (it's easy).
 
 I'll check back in a couple of hours to see if anyone
 has found show stoppers; otherwise I'll be signing off
 till the morning (it is Friday after all!)
 
 --Wez.
 
 
 --
 PHP Development Mailing List http://www.php.net/
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 -- 
 PHP Development Mailing List http://www.php.net/
 To unsubscribe, visit: http://www.php.net/unsub.php
 

Derick Rethans

-
PHP: Scripting the Web - www.php.net - [EMAIL PROTECTED]
All your branches are belong to me!
SRM: Site Resource Manager - www.vl-srm.net
-


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] streams crash

2002-03-16 Thread Wez Furlong

Hi Sander,

I've added some asserts and removed a bogus php_stream_flush
call; update your streams.c let me know how you get on :-)

If this doesn't work, then it's probably to do with the
resource management in main/main.c fopen_wrapper_for_zend :-/

--Wez.

On 16/03/02, Sander Roobol [EMAIL PROTECTED] wrote:
 Apache crashes when running _any_ script (even phpinfo(); segfaults). 
 CLI works fine.
 
 Backtrace:
 #0  0x400e7476 in fflush () from /lib/libc.so.6
 #1  0x402ff5b7 in php_stdiop_flush (stream=0x8169bc4)
  at /home/sander/php/head/php4/main/streams.c:500
 #2  0x402fee39 in php_stream_flush (stream=0x8169bc4)
  at /home/sander/php/head/php4/main/streams.c:186
 #3  0x402feb76 in php_stream_free (stream=0x8169bc4, call_dtor=1)
  at /home/sander/php/head/php4/main/streams.c:70
 #4  0x402a44b2 in _file_stream_dtor (rsrc=0x8169c3c)
  at /home/sander/php/head/php4/ext/standard/file.c:116
 #5  0x4031f56d in list_entry_destructor (ptr=0x8169c3c)
  at /home/sander/php/head/php4/Zend/zend_list.c:177
 #6  0x4031f742 in zend_destroy_rsrc_list (ht=0x4043f3dc)
  at /home/sander/php/head/php4/Zend/zend_list.c:248
 #7  0x40311417 in shutdown_executor ()
  at /home/sander/php/head/php4/Zend/zend_execute_API.c:196
 #8  0x40319c46 in zend_deactivate () at 
 /home/sander/php/head/php4/Zend/zend.c:596
 #9  0x402f7d2b in php_request_shutdown (dummy=0x0)
  at /home/sander/php/head/php4/main/main.c:795
 #10 0x403321b3 in apache_php_module_main (r=0x81647cc, 
 display_source_mode=0)
  at /home/sander/php/head/php4/sapi/apache/sapi_apache.c:96
 #11 0x40332c5e in send_php (r=0x81647cc, display_source_mode=0, 
 filename=0x0)
  at /home/sander/php/head/php4/sapi/apache/mod_php4.c:575
 #12 0x40332cc2 in send_parsed_php (r=0x81647cc)
  at /home/sander/php/head/php4/sapi/apache/mod_php4.c:590
 #13 0x08075999 in ap_invoke_handler ()
 #14 0x0808a7cf in process_request_internal ()
 #15 0x0808a836 in ap_process_request ()
 #16 0x080816f6 in child_main ()
 #17 0x080818b1 in make_child ()
 #18 0x08081a2c in startup_children ()
 #19 0x080820bd in standalone_main ()
 #20 0x0808291c in main ()
 #21 0x4009f65f in __libc_start_main () from /lib/libc.so.6
 
 Sander
 
 On 2002.03.16 12:13 [EMAIL PROTECTED] wrote:
  following little script crashes now:
  
  ?
  $myftp = ftp_connect(ftp.mutt.org);
  ?
  
  it crashes in fflush() of libc and backtrace shows
  that its called by php_stdiop_flush, which is called
  from php_stream_flush, php_stream_free, 
  
  Stefan
  
  
  --
  PHP Development Mailing List http://www.php.net/
  To unsubscribe, visit: http://www.php.net/unsub.php
  
  
  
 
 -- 
 PHP Development Mailing List http://www.php.net/
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] streams crash

2002-03-16 Thread Sander Roobol

Hello,

Unfortunately, it still fails. Configures  compiles fine, but crashes 
Apache. The backtrace is still the same.

Sander

On 2002.03.16 12:25 Wez Furlong wrote:
 Hi Sander,
 
 I've added some asserts and removed a bogus php_stream_flush
 call; update your streams.c let me know how you get on :-)
 
 If this doesn't work, then it's probably to do with the
 resource management in main/main.c fopen_wrapper_for_zend :-/
 
 --Wez.
 
 On 16/03/02, Sander Roobol [EMAIL PROTECTED] wrote:
  Apache crashes when running _any_ script (even phpinfo();
 segfaults).
  CLI works fine.
 
  Backtrace:
  #0  0x400e7476 in fflush () from /lib/libc.so.6
  #1  0x402ff5b7 in php_stdiop_flush (stream=0x8169bc4)
   at /home/sander/php/head/php4/main/streams.c:500
  #2  0x402fee39 in php_stream_flush (stream=0x8169bc4)
   at /home/sander/php/head/php4/main/streams.c:186
  #3  0x402feb76 in php_stream_free (stream=0x8169bc4, call_dtor=1)
   at /home/sander/php/head/php4/main/streams.c:70
  #4  0x402a44b2 in _file_stream_dtor (rsrc=0x8169c3c)
   at /home/sander/php/head/php4/ext/standard/file.c:116
  #5  0x4031f56d in list_entry_destructor (ptr=0x8169c3c)
   at /home/sander/php/head/php4/Zend/zend_list.c:177
  #6  0x4031f742 in zend_destroy_rsrc_list (ht=0x4043f3dc)
   at /home/sander/php/head/php4/Zend/zend_list.c:248
  #7  0x40311417 in shutdown_executor ()
   at /home/sander/php/head/php4/Zend/zend_execute_API.c:196
  #8  0x40319c46 in zend_deactivate () at
  /home/sander/php/head/php4/Zend/zend.c:596
  #9  0x402f7d2b in php_request_shutdown (dummy=0x0)
   at /home/sander/php/head/php4/main/main.c:795
  #10 0x403321b3 in apache_php_module_main (r=0x81647cc,
  display_source_mode=0)
   at /home/sander/php/head/php4/sapi/apache/sapi_apache.c:96
  #11 0x40332c5e in send_php (r=0x81647cc, display_source_mode=0,
  filename=0x0)
   at /home/sander/php/head/php4/sapi/apache/mod_php4.c:575
  #12 0x40332cc2 in send_parsed_php (r=0x81647cc)
   at /home/sander/php/head/php4/sapi/apache/mod_php4.c:590
  #13 0x08075999 in ap_invoke_handler ()
  #14 0x0808a7cf in process_request_internal ()
  #15 0x0808a836 in ap_process_request ()
  #16 0x080816f6 in child_main ()
  #17 0x080818b1 in make_child ()
  #18 0x08081a2c in startup_children ()
  #19 0x080820bd in standalone_main ()
  #20 0x0808291c in main ()
  #21 0x4009f65f in __libc_start_main () from /lib/libc.so.6
 
  Sander
 
  On 2002.03.16 12:13 [EMAIL PROTECTED] wrote:
   following little script crashes now:
  
   ?
 $myftp = ftp_connect(ftp.mutt.org);
   ?
  
   it crashes in fflush() of libc and backtrace shows
   that its called by php_stdiop_flush, which is called
   from php_stream_flush, php_stream_free, 
  
   Stefan
  
  
   --
   PHP Development Mailing List http://www.php.net/
   To unsubscribe, visit: http://www.php.net/unsub.php
  
  
  
 
  --
  PHP Development Mailing List http://www.php.net/
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 
 --
 PHP Development Mailing List http://www.php.net/
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 

-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] streams crash

2002-03-16 Thread Wez Furlong

Sander,

in main/main.c on line 576 there is a ZEND_REGISTER_RESOURCE
call.  Can you comment out that line and try again?
I'd expect a leak instead of a crash now.

We need a cleaner solution for this anyway :-/

--Wez.

On 16/03/02, Sander Roobol [EMAIL PROTECTED] wrote:
 Hello,
 
 Unfortunately, it still fails. Configures  compiles fine, but crashes 
 Apache. The backtrace is still the same.
 
 Sander
 
 On 2002.03.16 12:25 Wez Furlong wrote:
  Hi Sander,
  
  I've added some asserts and removed a bogus php_stream_flush
  call; update your streams.c let me know how you get on :-)
  
  If this doesn't work, then it's probably to do with the
  resource management in main/main.c fopen_wrapper_for_zend :-/
  
  --Wez.
  
  On 16/03/02, Sander Roobol [EMAIL PROTECTED] wrote:
   Apache crashes when running _any_ script (even phpinfo();
  segfaults).
   CLI works fine.
  
   Backtrace:
   #0  0x400e7476 in fflush () from /lib/libc.so.6
   #1  0x402ff5b7 in php_stdiop_flush (stream=0x8169bc4)
at /home/sander/php/head/php4/main/streams.c:500
   #2  0x402fee39 in php_stream_flush (stream=0x8169bc4)
at /home/sander/php/head/php4/main/streams.c:186
   #3  0x402feb76 in php_stream_free (stream=0x8169bc4, call_dtor=1)
at /home/sander/php/head/php4/main/streams.c:70
   #4  0x402a44b2 in _file_stream_dtor (rsrc=0x8169c3c)
at /home/sander/php/head/php4/ext/standard/file.c:116
   #5  0x4031f56d in list_entry_destructor (ptr=0x8169c3c)
at /home/sander/php/head/php4/Zend/zend_list.c:177
   #6  0x4031f742 in zend_destroy_rsrc_list (ht=0x4043f3dc)
at /home/sander/php/head/php4/Zend/zend_list.c:248
   #7  0x40311417 in shutdown_executor ()
at /home/sander/php/head/php4/Zend/zend_execute_API.c:196
   #8  0x40319c46 in zend_deactivate () at
   /home/sander/php/head/php4/Zend/zend.c:596
   #9  0x402f7d2b in php_request_shutdown (dummy=0x0)
at /home/sander/php/head/php4/main/main.c:795
   #10 0x403321b3 in apache_php_module_main (r=0x81647cc,
   display_source_mode=0)
at /home/sander/php/head/php4/sapi/apache/sapi_apache.c:96
   #11 0x40332c5e in send_php (r=0x81647cc, display_source_mode=0,
   filename=0x0)
at /home/sander/php/head/php4/sapi/apache/mod_php4.c:575
   #12 0x40332cc2 in send_parsed_php (r=0x81647cc)
at /home/sander/php/head/php4/sapi/apache/mod_php4.c:590
   #13 0x08075999 in ap_invoke_handler ()
   #14 0x0808a7cf in process_request_internal ()
   #15 0x0808a836 in ap_process_request ()
   #16 0x080816f6 in child_main ()
   #17 0x080818b1 in make_child ()
   #18 0x08081a2c in startup_children ()
   #19 0x080820bd in standalone_main ()
   #20 0x0808291c in main ()
   #21 0x4009f65f in __libc_start_main () from /lib/libc.so.6
  
   Sander
  
   On 2002.03.16 12:13 [EMAIL PROTECTED] wrote:
following little script crashes now:
   
?
$myftp = ftp_connect(ftp.mutt.org);
?
   
it crashes in fflush() of libc and backtrace shows
that its called by php_stdiop_flush, which is called
from php_stream_flush, php_stream_free, 
   
Stefan
   
   
--
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php
   
   
   
  
   --
   PHP Development Mailing List http://www.php.net/
   To unsubscribe, visit: http://www.php.net/unsub.php
  
  
  
  
  --
  PHP Development Mailing List http://www.php.net/
  To unsubscribe, visit: http://www.php.net/unsub.php
  
  
  
 
 -- 
 PHP Development Mailing List http://www.php.net/
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] streams crash

2002-03-16 Thread Sander Roobol

Hello Wez,

You hack makes it work again. It doesn't crash anymore.

Tnx,
Sander

On 2002.03.16 12:56 Wez Furlong wrote:
 Sander,
 
 in main/main.c on line 576 there is a ZEND_REGISTER_RESOURCE
 call.  Can you comment out that line and try again?
 I'd expect a leak instead of a crash now.
 
 We need a cleaner solution for this anyway :-/
 
 --Wez.
 
 On 16/03/02, Sander Roobol [EMAIL PROTECTED] wrote:
  Hello,
 
  Unfortunately, it still fails. Configures  compiles fine, but
 crashes
  Apache. The backtrace is still the same.
 
  Sander
 
  On 2002.03.16 12:25 Wez Furlong wrote:
   Hi Sander,
  
   I've added some asserts and removed a bogus php_stream_flush
   call; update your streams.c let me know how you get on :-)
  
   If this doesn't work, then it's probably to do with the
   resource management in main/main.c fopen_wrapper_for_zend :-/
  
   --Wez.
  
   On 16/03/02, Sander Roobol [EMAIL PROTECTED] wrote:
Apache crashes when running _any_ script (even phpinfo();
   segfaults).
CLI works fine.
   
Backtrace:
#0  0x400e7476 in fflush () from /lib/libc.so.6
#1  0x402ff5b7 in php_stdiop_flush (stream=0x8169bc4)
 at /home/sander/php/head/php4/main/streams.c:500
#2  0x402fee39 in php_stream_flush (stream=0x8169bc4)
 at /home/sander/php/head/php4/main/streams.c:186
#3  0x402feb76 in php_stream_free (stream=0x8169bc4,
 call_dtor=1)
 at /home/sander/php/head/php4/main/streams.c:70
#4  0x402a44b2 in _file_stream_dtor (rsrc=0x8169c3c)
 at /home/sander/php/head/php4/ext/standard/file.c:116
#5  0x4031f56d in list_entry_destructor (ptr=0x8169c3c)
 at /home/sander/php/head/php4/Zend/zend_list.c:177
#6  0x4031f742 in zend_destroy_rsrc_list (ht=0x4043f3dc)
 at /home/sander/php/head/php4/Zend/zend_list.c:248
#7  0x40311417 in shutdown_executor ()
 at /home/sander/php/head/php4/Zend/zend_execute_API.c:196
#8  0x40319c46 in zend_deactivate () at
/home/sander/php/head/php4/Zend/zend.c:596
#9  0x402f7d2b in php_request_shutdown (dummy=0x0)
 at /home/sander/php/head/php4/main/main.c:795
#10 0x403321b3 in apache_php_module_main (r=0x81647cc,
display_source_mode=0)
 at /home/sander/php/head/php4/sapi/apache/sapi_apache.c:96
#11 0x40332c5e in send_php (r=0x81647cc, display_source_mode=0,
filename=0x0)
 at /home/sander/php/head/php4/sapi/apache/mod_php4.c:575
#12 0x40332cc2 in send_parsed_php (r=0x81647cc)
 at /home/sander/php/head/php4/sapi/apache/mod_php4.c:590
#13 0x08075999 in ap_invoke_handler ()
#14 0x0808a7cf in process_request_internal ()
#15 0x0808a836 in ap_process_request ()
#16 0x080816f6 in child_main ()
#17 0x080818b1 in make_child ()
#18 0x08081a2c in startup_children ()
#19 0x080820bd in standalone_main ()
#20 0x0808291c in main ()
#21 0x4009f65f in __libc_start_main () from /lib/libc.so.6
   
Sander
   
On 2002.03.16 12:13 [EMAIL PROTECTED] wrote:
 following little script crashes now:

 ?
   $myftp = ftp_connect(ftp.mutt.org);
 ?

 it crashes in fflush() of libc and backtrace shows
 that its called by php_stdiop_flush, which is called
 from php_stream_flush, php_stream_free, 

 Stefan


 --
 PHP Development Mailing List http://www.php.net/
 To unsubscribe, visit: http://www.php.net/unsub.php



   
--
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php
  
  
  
  
   --
   PHP Development Mailing List http://www.php.net/
   To unsubscribe, visit: http://www.php.net/unsub.php
  
  
  
 
  --
  PHP Development Mailing List http://www.php.net/
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 
 --
 PHP Development Mailing List http://www.php.net/
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 

-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Streams are here!

2002-03-16 Thread Sebastian Bergmann

Wez Furlong wrote:
 gd:
 functions that create images from files.
 In particular, try creating from wrapped files over
 http, ftp etc.

  ext/gd does not compile on Win32:

gd.obj: error LNK2001: Unresolved external symbol:
_php_stream_stdio_ops

-- 
  Sebastian Bergmann
  http://sebastian-bergmann.de/ http://phpOpenTracker.de/

  Did I help you? Consider a gift: http://wishlist.sebastian-bergmann.de/

-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DEV] Streams

2002-03-16 Thread Marcus Boerger

Hi Wez,

i tried the streams and memory streams now in ext/exif.

What i do is check whether a stream is an stdio stream and if not
copy it to a memory stream and work with that. But before going
on using it i close/free the original stream.

I tested with http:... and the wrapper has destroy set to NULL.
But when closing the destroy is not NULL
To have it work i set it to NULL before closing it.
Do you have any ideas?

Test command for CLI was:
php -r 
'foreach(exif_read_data(http://marcus-boerger.de/php/ext/exif/test/kodak-dc210.jpg,,true)
 
as $sect=$data) foreach($data as $key=$val) echo $sect.$key: $val\n;'

Besides that it is working.

regards
marcus

have to go to party again now.


- mailto:[EMAIL PROTECTED] 
Wir sind allzumal Tiere unter Tieren, Kinder der Materie wie sie,
nur wehrloser. Doch da wir im Unterschied zu den Tieren wissen,
dass wir sterben muessen, wollen wir uns auf jenen Augenblick vorbereiten,
indem wir das Leben geniessen, das uns durch Zufall und vom Zufall gegeben 
ist.
Umberto Eco, Die Insel des vorigen Tages
--- http://www.marcus-boerger.de ---
-- Tel. 0241 / 874 09-7 ### 0179 / 29 14 980  --


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DEV] Streams are here!

2002-03-15 Thread Wez Furlong

Well, PHP finally supports fopen(https://...;) :-)

Please please please test the following things in particular
as I can't compile them or verify them here:

hyperwave:
hw_new_document_from_file

gd:
functions that create images from files.
In particular, try creating from wrapped files over
http, ftp etc.

pfsockopen()
copy() - particularly with wrapped source/dest
gzopen (and friends)
gzfile

If you have a system where HAVE_FLUSHIO is important,
please let me know if plain files work correctly when
switching between read and write.

If you have things in Pear/PECL or a third party
extension that used the old FP_XXX or php_file_le_fopen(),
please contact me and I can help you update your code for
streams (it's easy).

I'll check back in a couple of hours to see if anyone
has found show stoppers; otherwise I'll be signing off
till the morning (it is Friday after all!)

--Wez.


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Streams are here!

2002-03-15 Thread Stefan Roehrich

Hello!

On 2002-03-15 21:12:36, Wez Furlong wrote:
 Please please please test the following things in particular
 as I can't compile them or verify them here:

I can't compile, because it complains about `ptrdiff_t' undeclared in
main/network.c. I think stddef.h or similar is needed in this file.

  Stefan

-- 
Stefan Röhrich   [EMAIL PROTECTED], [EMAIL PROTECTED]
 http://www.roehri.ch/~sr/

-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Streams are here!

2002-03-15 Thread Marcus Börger

on cygwin (but i cannot finr any definition for them) ?!

ext/standard/http_fopen_wrapper.o(.text+0x17f):http_fopen_wrapper.c: 
undefined reference to `SOCK_FCLOSE'
ext/standard/http_fopen_wrapper.o(.text+0x280):http_fopen_wrapper.c: 
undefined reference to `SOCK_WRITE'
ext/standard/http_fopen_wrapper.o(.text+0x3b1):http_fopen_wrapper.c: 
undefined reference to `SOCK_WRITE'
ext/standard/http_fopen_wrapper.o(.text+0x430):http_fopen_wrapper.c: 
undefined reference to `SOCK_WRITE'
ext/standard/http_fopen_wrapper.o(.text+0x4d0):http_fopen_wrapper.c: 
undefined reference to `SOCK_WRITE'
ext/standard/http_fopen_wrapper.o(.text+0x4e6):http_fopen_wrapper.c: 
undefined reference to `SOCK_WRITE'
ext/standard/http_fopen_wrapper.o(.text+0x543):http_fopen_wrapper.c: 
undefined reference to `SOCK_FEOF'
ext/standard/http_fopen_wrapper.o(.text+0x567):http_fopen_wrapper.c: 
undefined reference to `SOCK_FGETS'
ext/standard/http_fopen_wrapper.o(.text+0x6cf):http_fopen_wrapper.c: 
undefined reference to `SOCK_FEOF'
ext/standard/http_fopen_wrapper.o(.text+0x728):http_fopen_wrapper.c: 
undefined reference to `SOCK_FGETS'
ext/standard/http_fopen_wrapper.o(.text+0x818):http_fopen_wrapper.c: 
undefined reference to `SOCK_FGETS'
ext/standard/http_fopen_wrapper.o(.text+0x96b):http_fopen_wrapper.c: 
undefined reference to `SOCK_FCLOSE'

At 22:12 15.03.2002, Wez Furlong wrote:
Well, PHP finally supports fopen(https://...;) :-)

Please please please test the following things in particular
as I can't compile them or verify them here:

hyperwave:
hw_new_document_from_file

gd:
functions that create images from files.
In particular, try creating from wrapped files over
http, ftp etc.

pfsockopen()
copy() - particularly with wrapped source/dest
gzopen (and friends)
gzfile

If you have a system where HAVE_FLUSHIO is important,
please let me know if plain files work correctly when
switching between read and write.

If you have things in Pear/PECL or a third party
extension that used the old FP_XXX or php_file_le_fopen(),
please contact me and I can help you update your code for
streams (it's easy).

I'll check back in a couple of hours to see if anyone
has found show stoppers; otherwise I'll be signing off
till the morning (it is Friday after all!)

--Wez.


--
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Streams are here!

2002-03-15 Thread Marcus Börger

SORRY,

had to reconfigure with --enable-php-streams

now it compiles and works
but getimagesize is broken for jpegs i will fix that tomorrow - think it's 
a problem of the latest features (argh)

marcus

At 22:53 15.03.2002, Marcus Börger wrote:
on cygwin (but i cannot finr any definition for them) ?!

ext/standard/http_fopen_wrapper.o(.text+0x17f):http_fopen_wrapper.c: 
undefined reference to `SOCK_FCLOSE'
ext/standard/http_fopen_wrapper.o(.text+0x280):http_fopen_wrapper.c: 
undefined reference to `SOCK_WRITE'
ext/standard/http_fopen_wrapper.o(.text+0x3b1):http_fopen_wrapper.c: 
undefined reference to `SOCK_WRITE'
ext/standard/http_fopen_wrapper.o(.text+0x430):http_fopen_wrapper.c: 
undefined reference to `SOCK_WRITE'
ext/standard/http_fopen_wrapper.o(.text+0x4d0):http_fopen_wrapper.c: 
undefined reference to `SOCK_WRITE'
ext/standard/http_fopen_wrapper.o(.text+0x4e6):http_fopen_wrapper.c: 
undefined reference to `SOCK_WRITE'
ext/standard/http_fopen_wrapper.o(.text+0x543):http_fopen_wrapper.c: 
undefined reference to `SOCK_FEOF'
ext/standard/http_fopen_wrapper.o(.text+0x567):http_fopen_wrapper.c: 
undefined reference to `SOCK_FGETS'
ext/standard/http_fopen_wrapper.o(.text+0x6cf):http_fopen_wrapper.c: 
undefined reference to `SOCK_FEOF'
ext/standard/http_fopen_wrapper.o(.text+0x728):http_fopen_wrapper.c: 
undefined reference to `SOCK_FGETS'
ext/standard/http_fopen_wrapper.o(.text+0x818):http_fopen_wrapper.c: 
undefined reference to `SOCK_FGETS'
ext/standard/http_fopen_wrapper.o(.text+0x96b):http_fopen_wrapper.c: 
undefined reference to `SOCK_FCLOSE'

At 22:12 15.03.2002, Wez Furlong wrote:
Well, PHP finally supports fopen(https://...;) :-)

Please please please test the following things in particular
as I can't compile them or verify them here:

hyperwave:
hw_new_document_from_file

gd:
functions that create images from files.
In particular, try creating from wrapped files over
http, ftp etc.

pfsockopen()
copy() - particularly with wrapped source/dest
gzopen (and friends)
gzfile

If you have a system where HAVE_FLUSHIO is important,
please let me know if plain files work correctly when
switching between read and write.

If you have things in Pear/PECL or a third party
extension that used the old FP_XXX or php_file_le_fopen(),
please contact me and I can help you update your code for
streams (it's easy).

I'll check back in a couple of hours to see if anyone
has found show stoppers; otherwise I'll be signing off
till the morning (it is Friday after all!)

--Wez.


--
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Streams are here!

2002-03-15 Thread Philip Olson


  Please please please test the following things in particular
  as I can't compile them or verify them here:
 
 I can't compile, because it complains about `ptrdiff_t' undeclared in
 main/network.c. I think stddef.h or similar is needed in this file.

this also affects --enable-sockets, please fix soon i'm trying 
to test something ;))

philip


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Streams are here!

2002-03-15 Thread Wez Furlong

Hmmm,

There is no configure option any longer; but a make clean followed
by a reconfigure and rebuild should fix most problems like that.

I think you might need to look at the php_stream_seek stuff in
image.c in particular.

--Wez.



On 16/03/02, Marcus Börger [EMAIL PROTECTED] wrote:
 SORRY,
 
 had to reconfigure with --enable-php-streams
 
 now it compiles and works
 but getimagesize is broken for jpegs i will fix that tomorrow - think it's 
 a problem of the latest features (argh)
 
 marcus
 
 At 22:53 15.03.2002, Marcus Börger wrote:
 on cygwin (but i cannot finr any definition for them) ?!
 
 ext/standard/http_fopen_wrapper.o(.text+0x17f):http_fopen_wrapper.c: 
 undefined reference to `SOCK_FCLOSE'
 ext/standard/http_fopen_wrapper.o(.text+0x280):http_fopen_wrapper.c: 
 undefined reference to `SOCK_WRITE'
 ext/standard/http_fopen_wrapper.o(.text+0x3b1):http_fopen_wrapper.c: 
 undefined reference to `SOCK_WRITE'
 ext/standard/http_fopen_wrapper.o(.text+0x430):http_fopen_wrapper.c: 
 undefined reference to `SOCK_WRITE'
 ext/standard/http_fopen_wrapper.o(.text+0x4d0):http_fopen_wrapper.c: 
 undefined reference to `SOCK_WRITE'
 ext/standard/http_fopen_wrapper.o(.text+0x4e6):http_fopen_wrapper.c: 
 undefined reference to `SOCK_WRITE'
 ext/standard/http_fopen_wrapper.o(.text+0x543):http_fopen_wrapper.c: 
 undefined reference to `SOCK_FEOF'
 ext/standard/http_fopen_wrapper.o(.text+0x567):http_fopen_wrapper.c: 
 undefined reference to `SOCK_FGETS'
 ext/standard/http_fopen_wrapper.o(.text+0x6cf):http_fopen_wrapper.c: 
 undefined reference to `SOCK_FEOF'
 ext/standard/http_fopen_wrapper.o(.text+0x728):http_fopen_wrapper.c: 
 undefined reference to `SOCK_FGETS'
 ext/standard/http_fopen_wrapper.o(.text+0x818):http_fopen_wrapper.c: 
 undefined reference to `SOCK_FGETS'
 ext/standard/http_fopen_wrapper.o(.text+0x96b):http_fopen_wrapper.c: 
 undefined reference to `SOCK_FCLOSE'
 
 At 22:12 15.03.2002, Wez Furlong wrote:
 Well, PHP finally supports fopen(https://...;) :-)
 
 Please please please test the following things in particular
 as I can't compile them or verify them here:
 
 hyperwave:
 hw_new_document_from_file
 
 gd:
 functions that create images from files.
 In particular, try creating from wrapped files over
 http, ftp etc.
 
 pfsockopen()
 copy() - particularly with wrapped source/dest
 gzopen (and friends)
 gzfile
 
 If you have a system where HAVE_FLUSHIO is important,
 please let me know if plain files work correctly when
 switching between read and write.
 
 If you have things in Pear/PECL or a third party
 extension that used the old FP_XXX or php_file_le_fopen(),
 please contact me and I can help you update your code for
 streams (it's easy).
 
 I'll check back in a couple of hours to see if anyone
 has found show stoppers; otherwise I'll be signing off
 till the morning (it is Friday after all!)
 
 --Wez.
 
 
 --
 PHP Development Mailing List http://www.php.net/
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 --
 PHP Development Mailing List http://www.php.net/
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 -- 
 PHP Development Mailing List http://www.php.net/
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Streams are here!

2002-03-15 Thread Wez Furlong

Can you tell me which include files are needed to correct
the build on your system?
Then I can fix it :-)

--Wez.

On 16/03/02, Stefan Roehrich [EMAIL PROTECTED] wrote:
 Hello!
 
 On 2002-03-15 21:12:36, Wez Furlong wrote:
  Please please please test the following things in particular
  as I can't compile them or verify them here:
 
 I can't compile, because it complains about `ptrdiff_t' undeclared in
 main/network.c. I think stddef.h or similar is needed in this file.
 
   Stefan
 
 -- 
 Stefan Röhrich   [EMAIL PROTECTED], [EMAIL PROTECTED]
  http://www.roehri.ch/~sr/
 
 -- 
 PHP Development Mailing List http://www.php.net/
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Streams are here!

2002-03-15 Thread Marcus Börger

To have image.c work i had to correct the php_stream_seek and php_stream_getc
calls. Seek caals had wrong parameter arragement - but nowhere else in code...
getc see below...

I changed both functions later.

in php_stream_getc i return buf  0xFF because otherwise i get 0xFFxx 
in return.

in php_stream_seek i added code to make it much faster

and i couldn't compile php_stdiop_read see diff

marcus

diff -u -w -r1.11 streams.c
--- main/streams.c  16 Mar 2002 00:05:47 -  1.11
+++ main/streams.c  16 Mar 2002 02:28:55 -
 -132,7 +132,7 
 char buf;

 if (php_stream_read(stream, buf, 1)  0) {
-   return buf;
+   return buf  0xFF;
 }
 return EOF;
  }
 -204,17 +204,19 

  PHPAPI int php_stream_seek(php_stream *stream, off_t offset, int whence)
  {
+   static char tmp[1024];
+
 if (stream-ops-seek) {
 return stream-ops-seek(stream, offset, whence);
 }

 /* emulate forward moving seeks with reads */
 if (whence == SEEK_CUR  offset  0) {
-   while(offset--  0) {
-   if (php_stream_getc(stream) == EOF) {
-   return -1;
-   }
+   while (offset=sizeof(tmp)) {
+   php_stream_read(stream,tmp,sizeof(tmp));
+   offset -= sizeof(tmp);
 }
+   if (offset) php_stream_read(stream,tmp,offset);
 return 0;
 }

 -447,7 +449,7 

  static size_t php_stdiop_read(php_stream *stream, char *buf, size_t count)
  {
-   php_stdio_stream_data * ata = (php_stdio_stream_data*)stream-abstract;
+   php_stdio_stream_data * data = 
(php_stdio_stream_data*)stream-abstract;

 if (buf == NULL  count == 0)  {
 /* check for EOF condition */


At 22:12 15.03.2002, Wez Furlong wrote:
Well, PHP finally supports fopen(https://...;) :-)

Please please please test the following things in particular
as I can't compile them or verify them here:

hyperwave:
hw_new_document_from_file

gd:
functions that create images from files.
In particular, try creating from wrapped files over
http, ftp etc.

pfsockopen()
copy() - particularly with wrapped source/dest
gzopen (and friends)
gzfile

If you have a system where HAVE_FLUSHIO is important,
please let me know if plain files work correctly when
switching between read and write.

If you have things in Pear/PECL or a third party
extension that used the old FP_XXX or php_file_le_fopen(),
please contact me and I can help you update your code for
streams (it's easy).

I'll check back in a couple of hours to see if anyone
has found show stoppers; otherwise I'll be signing off
till the morning (it is Friday after all!)

--Wez.


--
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Streams are here!

2002-03-15 Thread Marcus Börger

What do you think about havin php_stream_seek emulate
other methods than forward seeking? We could do this by
opening the stream again if something before current
position has to be read...

That would allow using streams in every file based function!

Of cause we should have flags that we are about to emulate
and it should be a feature that can be turned off or even better
one that can be enabled by function call

marcus

At 22:12 15.03.2002, Wez Furlong wrote:
Well, PHP finally supports fopen(https://...;) :-)

Please please please test the following things in particular
as I can't compile them or verify them here:

hyperwave:
hw_new_document_from_file

gd:
functions that create images from files.
In particular, try creating from wrapped files over
http, ftp etc.

pfsockopen()
copy() - particularly with wrapped source/dest
gzopen (and friends)
gzfile

If you have a system where HAVE_FLUSHIO is important,
please let me know if plain files work correctly when
switching between read and write.

If you have things in Pear/PECL or a third party
extension that used the old FP_XXX or php_file_le_fopen(),
please contact me and I can help you update your code for
streams (it's easy).

I'll check back in a couple of hours to see if anyone
has found show stoppers; otherwise I'll be signing off
till the morning (it is Friday after all!)

--Wez.


--
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Streams are here!

2002-03-15 Thread Wez Furlong

I had thought about it, but it's making the streams abstraction do
too much; it will have to remember too much information, and what if
the data changes each time the stream is opened?

If you really need to seek around in a stream that might not support
it, you should open a temporary stream (php_stream_fopen_tmpfile())
and then php_stream_copy_to_stream(src, tmp, PHP_STREAM_COPY_ALL)
to get a copy on disk.

When do you need to do this? Well, a general rule is when
php_stream_is(src, PHP_STREAM_IS_STDIO) is false.

--Wez.

On 16/03/02, Marcus Börger [EMAIL PROTECTED] wrote:
 What do you think about havin php_stream_seek emulate
 other methods than forward seeking? We could do this by
 opening the stream again if something before current
 position has to be read...
 
 That would allow using streams in every file based function!
 
 Of cause we should have flags that we are about to emulate
 and it should be a feature that can be turned off or even better
 one that can be enabled by function call
 
 marcus
 
 At 22:12 15.03.2002, Wez Furlong wrote:
 Well, PHP finally supports fopen(https://...;) :-)
 
 Please please please test the following things in particular
 as I can't compile them or verify them here:
 
 hyperwave:
 hw_new_document_from_file
 
 gd:
 functions that create images from files.
 In particular, try creating from wrapped files over
 http, ftp etc.
 
 pfsockopen()
 copy() - particularly with wrapped source/dest
 gzopen (and friends)
 gzfile
 
 If you have a system where HAVE_FLUSHIO is important,
 please let me know if plain files work correctly when
 switching between read and write.
 
 If you have things in Pear/PECL or a third party
 extension that used the old FP_XXX or php_file_le_fopen(),
 please contact me and I can help you update your code for
 streams (it's easy).
 
 I'll check back in a couple of hours to see if anyone
 has found show stoppers; otherwise I'll be signing off
 till the morning (it is Friday after all!)
 
 --Wez.
 
 
 --
 PHP Development Mailing List http://www.php.net/
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Streams are here!

2002-03-15 Thread Marcus Börger

At 03:56 16.03.2002, Wez Furlong wrote:
I had thought about it, but it's making the streams abstraction do
too much; it will have to remember too much information, and what if
the data changes each time the stream is opened?

YES it has to remember much and YES streams may change on next
open - you're right. Was just a quick idea while changing image.c, whether
or not i would get able to read more from tiff files.


If you really need to seek around in a stream that might not support
it, you should open a temporary stream (php_stream_fopen_tmpfile())
and then php_stream_copy_to_stream(src, tmp, PHP_STREAM_COPY_ALL)
to get a copy on disk.

Do we have a memory stream already? Anybody like this idea?


When do you need to do this? Well, a general rule is when
php_stream_is(src, PHP_STREAM_IS_STDIO) is false.

--Wez.

On 16/03/02, Marcus Börger [EMAIL PROTECTED] wrote:
  What do you think about havin php_stream_seek emulate
  other methods than forward seeking? We could do this by
  opening the stream again if something before current
  position has to be read...
 
  That would allow using streams in every file based function!
 
  Of cause we should have flags that we are about to emulate
  and it should be a feature that can be turned off or even better
  one that can be enabled by function call
 
  marcus
 
  At 22:12 15.03.2002, Wez Furlong wrote:
  Well, PHP finally supports fopen(https://...;) :-)
  
  Please please please test the following things in particular
  as I can't compile them or verify them here:
  
  hyperwave:
  hw_new_document_from_file
  
  gd:
  functions that create images from files.
  In particular, try creating from wrapped files over
  http, ftp etc.
  
  pfsockopen()
  copy() - particularly with wrapped source/dest
  gzopen (and friends)
  gzfile
  
  If you have a system where HAVE_FLUSHIO is important,
  please let me know if plain files work correctly when
  switching between read and write.
  
  If you have things in Pear/PECL or a third party
  extension that used the old FP_XXX or php_file_le_fopen(),
  please contact me and I can help you update your code for
  streams (it's easy).
  
  I'll check back in a couple of hours to see if anyone
  has found show stoppers; otherwise I'll be signing off
  till the morning (it is Friday after all!)
  
  --Wez.
  
  
  --
  PHP Development Mailing List http://www.php.net/
  To unsubscribe, visit: http://www.php.net/unsub.php




--
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DEV] streams support for interbase

2001-05-12 Thread Wez Furlong

Hi,

Could someone with interbase test this patch that provides streams
support?

I would like to know the outcome of doing a regular compile (with no
streams support) and a compile with --enable-php-streams before I commit.

I'm just being overly cautious...

--Wez.



Index: ext/interbase/interbase.c
===
RCS file: /repository/php4/ext/interbase/interbase.c,v
retrieving revision 1.54
diff -u -r1.54 interbase.c
--- ext/interbase/interbase.c   2001/05/02 22:41:09 1.54
+++ ext/interbase/interbase.c   2001/05/12 21:52:59
@@ -2876,6 +2876,8 @@
char bl_data[IBASE_BLOB_SEG]; /* FIXME? blob_seg_size parameter? */
FILE *fp;
IBLS_FETCH();
+   void * what;
+   int type;
 
RESET_ERRMSG;
 
@@ -2903,8 +2905,12 @@
RETURN_FALSE;
}
 
-   ZEND_FETCH_RESOURCE(fp, FILE *, file_arg, -1, File-Handle, 
php_file_le_fopen());
+   what = zend_fetch_resource(arg1, -1, File-Handle, type, 2, 
+php_file_le_fopen(), php_file_le_stream());
+   ZEND_VERIFY_RESOURCE(what);
 
+   if (type == php_file_le_fopen())
+   fp = (FILE*)what;
+   
ib_blob.link = ib_link-link;
ib_blob.trans_handle = ib_link-trans[trans_n];
ib_blob.bl_handle = NULL;
@@ -2917,6 +2923,21 @@
}
 
size = 0;
+
+#if HAVE_PHP_STREAM
+   if (type == php_file_le_stream())   {
+   while(b = php_stream_read((php_stream*)what, bl_data, 1, 
+sizeof(bl_data))  0)  {
+   if (isc_put_segment(IB_STATUS, ib_blob.bl_handle, b, 
+bl_data)) {
+   _php_ibase_error();
+   RETURN_FALSE;
+   }
+   size += b;
+
+   }
+   }
+   else{
+#endif
+   /* Can't see much use for the issock stuff here, it should be nuked --Wez */
while (issock?(b=SOCK_FREAD(bl_data,sizeof(bl_data),socketd)):(b = 
fread(bl_data, 1, sizeof(bl_data), fp))  0) {
if (isc_put_segment(IB_STATUS, ib_blob.bl_handle, b, bl_data)) {
_php_ibase_error();
@@ -2924,6 +2945,10 @@
}
size += b;
}
+   
+#if HAVE_PHP_STREAM
+   }
+#endif

if (isc_close_blob(IB_STATUS, ib_blob.bl_handle)) {
_php_ibase_error();





-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]