Re: Re: access to variables
| From: | David Lindstrom | Date: | Tue, 24 Apr 2007 19:13:37 +0000 |
| Subject: | Re: Re: access to variables | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-28995@lists.php.net to get a copy of this message | ||
Doesn't the zval contain info about the length of the string?
--
// DvDmanDT
mail: dvdmandt¤telia.com
msn: dvdmandt¤hotmail.com
"Ci" <ciptok@gmail.com> skrev i meddelandet
news:75.B1.60955.4F31E264@pb1.pair.com...
> Stefan Esser napisa³(a):
>> No. The correct way for getting the variable is
>>
>>
>> zval **data;
>> ...
>> if (zend_hash_find(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER]),
>> "DOCUMENT_ROOT", sizeof("DOCUMENT_ROOT"), &data)==SUCCESS) {
>> ...
>> strlcpy(buffer, Z_STRVAL_PP(data), sizeof(buffer));
>> }
> I tried to use it. I figured out that zend_hash_find function returns
> SUCCESS, but when the strlcpy is executed I can't do anything after that.
> I'm thinking about writing results to file.
> I used:
>
> FILE *log;
> log = fopen("/var/log/mail_spam", "w");
>
> fprintf(log, "data: %s", buffer);
>
> It writes any data I want but only when I don't execute strlcpy (or
> strcpy) function. What could be the problem?