Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:10450 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 12121 invoked by uid 1010); 14 Jun 2004 17:58:54 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 12097 invoked from network); 14 Jun 2004 17:58:54 -0000 Received: from unknown (HELO rot2.de) (217.160.191.196) by pb1.pair.com with SMTP; 14 Jun 2004 17:58:54 -0000 Received: from php-tools.net (p50839CC2.dip.t-dialin.net [80.131.156.194]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by rot2.de (Postfix) with ESMTP id 4E44C2CE98A; Mon, 14 Jun 2004 19:50:17 +0200 (CEST) Message-ID: <40CDE75C.3010502@php-tools.net> Date: Mon, 14 Jun 2004 19:58:52 +0200 Organization: PHP Application Tools User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4; MultiZilla v1.5.0.3g) Gecko/20031007 X-Accept-Language: en-us, de, en MIME-Version: 1.0 To: Sara Golemon Cc: internals@lists.php.net References: <40CDD0EC.5070905@php-tools.net> <20040614171119.24785.qmail@pb1.pair.com> In-Reply-To: <20040614171119.24785.qmail@pb1.pair.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Re: Need help with streams From: schst@php-tools.net (Stephan Schmidt) 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