Looks basicly alright (with a slight disagreement on how the read loop is
implemented (below). In general you've got my vote (for what it's worth
given my lack of experience with libc-client.
unsigned long i, rest = size % GETS_FETCH_SIZE;
char *buf = emalloc(GETS_FETCH_SIZE+1);
for (i = GETS_FETCH_SIZE; i < size; i += GETS_FETCH_SIZE) {
memset(buf, 0, GETS_FETCH_SIZE+1);
f(stream, GETS_FETCH_SIZE, buf);
php_stream_write_string(IMAPG(gets_stream), buf);
}
if (rest) {
memset(buf, 0, GETS_FETCH_SIZE+1);
f(stream, rest, buf);
php_stream_write_string(IMAPG(gets_stream), buf);
}
efree(buf);
return NULL;
Here's how I'd write this block, it assumed that f returns the number of
bytes actually read, but according to the proto for readfn_t it *should* do
that. Feel free to ignore:
char buf[GETS_FETCH_SIZE];
unsigned long ret = 1;
while (ret > 0) {
ret = f(stream, GETS_FETCH_SIZE, buf);
php_stream_write_stringl(IMAPG(gets_stream), buf, ret);
}
return NULL;
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php