Re: Re: Need help with streams

From: Date: Mon, 14 Jun 2004 17:58:52 +0000
Subject: Re: Re: Need help with streams
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-10450@lists.php.net to get a copy of this message
Hi,
That's because you're telling it to write one character from the position POINTED TO by the integer value. (i.e. Treat the integer like a pointer) You're lucky you're getting data at all and not a segfault. Try: php_stream_putc(stream, (char)(Z_LVAL_P(*data) & 0xFF));
You are a livesaver! Thanks very much. I got one more problem though: What's the best way to create a string with a fixed length, that's padded with zero-bytes? I'm currently using: php_stream_write(stream, Z_STRVAL_P(*data), 30); As the string is terminated with a zero-byte, it already works, but it would be better to fill the unused space with zero-bytes. Do I have to create a second buffer and copy byte-by-byte and then fill the remaining bytes with zeros, or is there an easier way? The only other solution I could think of is to check for the exact length of the string, write the string and then use php_stream_putc() in a loop to write the remaining zero bytes... Stephan

« previous php.internals (#10450) next »