Re: [PHP4BETA] *_r -functions
| From: | Sascha Schumann | Date: | Sun, 28 Nov 1999 14:20:08 +0000 |
| Subject: | Re: [PHP4BETA] *_r -functions | ||
| References: | 1 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-6988@lists.php.net to get a copy of this message | ||
On Sun, Nov 28, 1999 at 04:24:00AM +0200, Jouni Ahto wrote:
> Could someone with more knowledge please check that I have understood the
> idea right? I thought it better to ask before committing anything and
> breaking all the hell loose in repository. Besides, after looking mysql's
> source for some hints, it came clear that there are 2 quite different apis
> for even this one function (and then, the HPUX-way...), which I should
> have taken care of. I'm waiting in horror what situation is with
> getproto*, getserv* etc.
Yes, the getxxbyzz functions are not so easy to cover. For
gethostbyname_r, we should support the three APIs (Solaris,
glibc2, HP-UX) by providing a wrapper function, so that our
functions can use a php_gethostbyname_r with known semantics.
The fallback function you created does not check for error
conditions (gethostbyname() may return NULL), nor does it
respect the lowest common denominator which is:
int gethostbyname_r(const char *host, struct hostent *hostbuf,
char *tmphostbuf, size_t tmphostbuflen,
int *hosterr);
The function also does not consider that the hostent
structure contains pointers to other fields. These pointers
point to statically allocated memory, thus we need to copy
their contents as well.
--
Regards,
Sascha Schumann
Consultant