Re: Re: access to variables
| From: | Tijnema ! | Date: | Tue, 24 Apr 2007 18:48:29 +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-28993@lists.php.net to get a copy of this message | ||
On 4/24/07, Ci <ciptok@gmail.com> wrote:
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?
I believe that the source string needs to be 0 terminated (\0).
Don't ask me how to fix it ;)
Tijnema