Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:26505 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 77010 invoked by uid 1010); 11 Nov 2006 00:06:09 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 76995 invoked from network); 11 Nov 2006 00:06:09 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Nov 2006 00:06:09 -0000 Authentication-Results: pb1.pair.com smtp.mail=info@adaniels.nl; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=info@adaniels.nl; sender-id=unknown Received-SPF: error (pb1.pair.com: domain adaniels.nl from 82.94.235.198 cause and error) X-PHP-List-Original-Sender: info@adaniels.nl X-Host-Fingerprint: 82.94.235.198 hyak.bean-it.nl Received: from [82.94.235.198] ([82.94.235.198:42830] helo=hyak.bean-it.nl) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A8/F4-27611-EE315554 for ; Fri, 10 Nov 2006 19:06:08 -0500 Received: from [127.0.0.1] (bean-it.xs4all.nl [213.84.27.165]) (authenticated bits=0) by hyak.bean-it.nl (8.13.4/8.13.4/Debian-3sarge3) with ESMTP id kAB05qB7005277; Sat, 11 Nov 2006 01:05:56 +0100 Message-ID: <455513D7.1080306@adaniels.nl> Date: Sat, 11 Nov 2006 01:05:43 +0100 User-Agent: Thunderbird 1.5.0.8 (Windows/20061025) MIME-Version: 1.0 To: =?UTF-8?B?Sm9oYW5uZXMgU2NobMO8dGVy?= CC: internals@lists.php.net References: <4554DB25.4010701@adaniels.nl> <1163190929.1701.182.camel@johannes.nop> <45550187.6000106@adaniels.nl> <1163202286.1701.245.camel@johannes.nop> In-Reply-To: <1163202286.1701.245.camel@johannes.nop> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new X-Spam-Status: No, score=-1.7 required=4.0 tests=BAYES_00,URI_NOVOWEL autolearn=no version=3.1.3 X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on hyak.bean-it.nl Subject: Re: [PHP-DEV] newbie question nr 2: compile error when using php_stream_get_line From: info@adaniels.nl (Arnold Daniels) Hi again, I thought that this might not be interesting enough for the list. But I'll be sure CC it in the future. Thanks for your help, the extension now builds. It doesn't run however. I crashes on PHP_STREAM_TO_ZVAL(stream, in). But I'm sure I'm able to fix that problem myself. Thanks again and best regards, Arnold Johannes Schlüter schreef: > Hi Arnold, > > fist of all: Please use "Reply to all" and the lists in future. This way > you might get a faster/better answer or additional input, but since I'm > in a good mood currently I'll answer you this way, too. > > To your question: As you already found out your problem is the > php_stream_get_line() thingy. So let's see where this comes from and > what it looks like: > > php_streams.h:326 > > #define php_stream_get_line(stream, buf, maxlen, retlen) > _php_stream_get_line((stream), IS_STRING, buf, (maxlen), 0, > (retlen) TSRMLS_CC) > > So it's a macro which expands to a call of the _php_stream_get_line() > function and that's where TSRMLS_CC comes into play. As you read in > Sara's article this get's expanded to tsrm_ls as an additional > parameter. Since that parameter is passed to the function we need to get > it in declared inside the function. > > There are two possible ways to fix this: > > - Add TSRMLS_DC to your function's declaration and TSRMLS_CC to the > calls. This is preferred but might not always work (thinking about > callbacks used by other libraries) > > - Add TSRMLS_FETCH(); after the last local variable declaration. This > macro does some magic to provide the tsrm_ls but costs some additional > performance. > > Hope it helped and yes it's bad that there is no real online > documentation, > johannes > > On Fri, 2006-11-10 at 23:47 +0100, Arnold Daniels wrote: > >> Hi, >> >> First of all thanks the link. It explains what tsrm is quite clearly. >> Unfortunately I don't seem to be able to understand it well enough to >> see the context this error. >> >> What I understand is (please correct me where I'm wrong) >> - option --enable-maintainer-zts is only for testing purposes to see >> if the extension is thread-safe >> - I need to include "TSRM.h" in thread-safe mode (#ifdef ZTS) >> - I need to include some other (unkown) file where tsrm_ls is defined >> and the macro's are defined when not in thread-safe mode. >> >> I don't understand what kind the php_stream_get_line function expects. >> Do I need to define a locale storage in PHP_MINIT_FUNCTION which is >> used by the function or perhaps I need to include ext/standard/file.h? >> >> I'm looking at it for several hours now and I'm starting to feel >> really stupid. I'm hoping you are willing to have a look at my source >> code and tell me what and why. I understand that you guys at PHP have >> better thing to do than answering newbie questions, though I hope >> you'll help me still. I've attached the source-code of the extension. >> >> I'm programming with MySQL and PHP for about 3 years (since the first >> beta of PHP5) and I'm trying to take it to another level. My first >> open source project ware MySQL UDF's to output XML directly from an >> SQL query (http://libmysqlbnxml.sourceforge.net). >> I indeed tent do write more PHP extensions and I'll be sure to buy to >> book you recommended. >> >> Thanks for all you help. >> >> Best regards, >> Arnold >> >> >> Johannes Schlüter schreef: >> >>> Hi, >>> >>> errors complaining about something related to tsrm_ls mean that you're >>> building a thread-safe PHP and forgot some TSRMLS[_...] macros. >>> >>> See for example >>> http://blog.libssh2.org/index.php?/archives/22-What-the-heck-is-TSRMLS_CC-anyway.html for more about these macros. This should help you, but the book from Sara, mentioned in that article, is really worth buying (and being read) if you tend to do some more PHP extending stuff. >>> >>> johannes >>> >>> On Fri, 2006-11-10 at 21:03 +0100, Arnold Daniels wrote: >>> >>> >>>> Hi, >>>> >>>> I've got another newbie question. My .ini parser now works correctly >>>> when parsing a string (thanks to help of Matt Wilmas). With the same >>>> function I want to be able to parse content of a stream. I looked at >>>> fgets to see how to read a line from a stream. Unfortunately when I call >>>> php_stream_get_line. I get the following error: >>>> >>>> /root/php-5.1.6/ext/qconf/qconf_common.c: In function >>>> `qconf_readline_stream': >>>> /root/php-5.1.6/ext/qconf/qconf_common.c:42: error: `tsrm_ls' undeclared >>>> (first use in this function) >>>> /root/php-5.1.6/ext/qconf/qconf_common.c:42: error: (Each undeclared >>>> identifier is reported only once >>>> /root/php-5.1.6/ext/qconf/qconf_common.c:42: error: for each function it >>>> appears in.) >>>> make: *** [qconf_common.lo] Error 1 >>>> >>>> Googling the error returns lot's of websites, be I couldn't make out a >>>> real solution. >>>> >>>> This is the function: >>>> >>>> /** >>>> * Read a line out of a stream. >>>> */ >>>> char *qconf_readline_stream(zval *in, char **c) >>>> { >>>> char *line; >>>> php_stream *stream; >>>> size_t line_len = 0; >>>> >>>> PHP_STREAM_TO_ZVAL(stream, in); >>>> line = php_stream_get_line(stream, NULL, 0, &line_len); >>>> if (line != NULL) *(line + line_len) = (char)0; /* make the line >>>> into a null terminated string to use string functions link sscan */ >>>> >>>> return line; >>>> } >>>> >>>> Thanks a lot, >>>> Arnold >>>> >>>> >>>> >>> >>>