[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Partysip-dev] compiling partysip
From: |
Aymeric Moizard |
Subject: |
Re: [Partysip-dev] compiling partysip |
Date: |
Wed, 15 May 2002 13:15:19 +0200 (CEST) |
On Wed, 15 May 2002, Ralf Mahlo wrote:
> Aymeric Moizard wrote:
>
> > On Wed, 15 May 2002, Ralf Mahlo wrote:
> >
> > > Hi!
> > > I'm working with Solaris 2.6 . First when I tried to compile I've got the
> > > error: in pplsocket.c ,
> > > function ppl_gethostbyname : too much arguments for gethostbyname_r (in
> > > Solaris there are only 5
> > > arguments, don't know about other systems...). However, I changed
> > > result_buffer with result and
> > > deleted the old (5.) '&result'. (maybe that's wrong...)
> >
> > ... yes, this is probably wrong.
> > gethostbyname is a reentrant method: this is why I assume 'result' should
> > be a presiously allocated element and not a pointer to a non allocated
> > 'struct hostent'
> >
> > Could you try fixing it this way: (
> >
> > > PPL_DECLARE(int) ppl_gethostbyname(struct sockaddr_in *sin, char
> > > *hostname, int port)
> > > {
> > > // struct hostent result_buffer;
> > > char tmp[GETHOSTBYNAME_BUFLEN];
> > > struct hostent *result; <<- replace with 'struct hostent result'
> > > int my_error;
> > >
> > > gethostbyname_r(hostname, /* the FQDN */
> > > result, /* the result buffer */ <<- replace with '&result'
> > > tmp,
> > > GETHOSTBYNAME_BUFLEN - 1,
> > > // &result,
> > > &my_error);
> > >
> > > if (!result)
> > > return my_error;
> > > }
> > >
> >
>
> I tried, and it doesn't work:
> pplsocket.c: In function `ppl_gethostbyname':
> pplsocket.c:64: wrong type argument to unary exclamation mark
> pplsocket.c:70: invalid type argument of `->'
> pplsocket.c:72: invalid type argument of `->'
> pplsocket.c:74: invalid type argument of `->'
> pplsocket.c:75: invalid type argument of `->'
> make[3]: *** [pplsocket.lo] Error 1
>
> The manual (as attached to this mail) says the following:
>
> struct hostent *gethostbyname_r(const char *name,
> struct hostent *result, char *buffer, int buflen,
> int *h_errnop);
>
> The parameter result must be a pointer
> to a struct hostent structure allocated by the caller. On
> successful completion, the function returns the host entry
> in this structure. The parameter buffer must be a pointer
> to a buffer supplied by the caller.
>
> I'll try to find another solution...
I take a look at the apache apr library and it seems to be done this way:
struct hostent result;
gethostbyname_r(hostname, &result, tmp, GETHOSTBYNAME_BUFLEN - 1, &error);
of course, result is not any more a pointer, and the code following
this call has to be slightly modified.
You'll find the sample code in the appache source tree, in the file:
./srclib/apr/network_io/unix/sa_common.c
This is where I grabbed the initial ideas...
Aymeric
> Regards, Ralf
>
> >
> > Aymeric
> >
> > > Regards, Ralf
> > >
> > >
> > > _______________________________________________
> > > Partysip-dev mailing list
> > > address@hidden
> > > http://mail.freesoftware.fsf.org/mailman/listinfo/partysip-dev
> > >
> >
> > _______________________________________________
> > Partysip-dev mailing list
> > address@hidden
> > http://mail.freesoftware.fsf.org/mailman/listinfo/partysip-dev
>
Re: [Partysip-dev] compiling partysip, Ralf Mahlo, 2002/05/15
- Re: [Partysip-dev] compiling partysip,
Aymeric Moizard <=
Re: [Partysip-dev] compiling partysip, Tim Na, 2002/05/16
Re: [Partysip-dev] compiling partysip, Aymeric Moizard, 2002/05/15