gethostbyname_r 5th argument???

gethostbyname_r 5th argument???

Post by Dea » Sun, 05 May 2002 04:03:16



I am compiling under Linux and am using gethostbyname_r for the
thread-safe version of this call. When I do a man on this I get a
version that only has 4 arguments. After looking at the prototype in
the header file, I see where it takes an extra argument at the end.
Anyone know what this is used for? I can't seem to find any info on it
anywhere. What I ended up doing was just passing in an argument of the
correct type to satisy the compiler.

thanks,

~Dean

 
 
 

gethostbyname_r 5th argument???

Post by Dragan Cvetkovi » Sun, 05 May 2002 04:31:22



> I am compiling under Linux and am using gethostbyname_r for the
> thread-safe version of this call. When I do a man on this I get a
> version that only has 4 arguments. After looking at the prototype in
> the header file, I see where it takes an extra argument at the end.
> Anyone know what this is used for? I can't seem to find any info on it
> anywhere. What I ended up doing was just passing in an argument of the
> correct type to satisy the compiler.

> thanks,

> ~Dean

I couldn't find my Linux man page for it, but here are the parts of the
Solaris 8 one:

SYNOPSIS
     cc [ flag ... ] file ... -lnsl [ library ... ]
     #include <netdb.h>

     struct hostent *gethostbyname(const char *name);

     struct hostent  *gethostbyname_r(const  char  *name,  struct
     hostent *result, char *buffer, int buflen, int *h_errnop);

[snip]

    The  functions  gethostbyname_r(),  gethostbyaddr_r(),   and
     gethostent_r() provide reentrant interfaces for these opera-
     tions.

     Each reentrant interface performs the same operation as  its
     non-reentrant  counterpart,  named  by  removing the  ``_r''
     suffix.  The reentrant interfaces, however, use buffers sup-
     plied by the caller to store returned results, and  are safe
     for use in both single-threaded and multi-threaded  applica-
     tions.

     Each reentrant interface takes the same  parameters  as  its
     non-reentrant  counterpart,  as  well as the following addi-
     tional parameters.  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.  This  buffer  is  used  as
     storage space for the host data.  All of the pointers within
     the returned struct hostent  result  point  to  data  stored
     within  this  buffer.  See RETURN VALUES. The buffer must be
     large enough to hold all of the  data  associated  with  the
     host  entry.  The  parameter  buflen should give the size in
     bytes of the  buffer  indicated  by  buffer.  The  parameter
     h_errnop  should  be  a  pointer  to an integer.  An integer
     error status value is stored there on certain  error  condi-
     tions. See ERRORS.

[snip]

ERRORS
     The      reentrant       functions        gethostbyname_r(),
     gethostbyaddr_r(),  and  gethostent_r() will return NULL and
     set errno to ERANGE if the length of the buffer supplied  by
     caller  is  not  large  enough  to  store  the  result.  See
     Intro(2) for the proper usage and interpretation of errno in
     multithreaded applications.

     The    reentrant     functions     gethostbyname_r()     and
     gethostbyaddr_r()  set the integer pointed to by h_errnop to
     one of these values in case of error.

Btw., there is also a following note there:

WARNINGS
     The      reentrant       interfaces       gethostbyname_r(),
     gethostbyaddr_r(),  and  gethostent_r() are included in this
     release on an uncommitted basis only,  and  are  subject  to
     change or removal in future minor releases.

HTH, Dragan

--
Dragan Cvetkovic,

To be or not to be is true. G. Boole      No it isn't.  L. E. J. Brouwer

 
 
 

gethostbyname_r 5th argument???

Post by Rene Herma » Sun, 05 May 2002 22:46:12



> I am compiling under Linux and am using gethostbyname_r for the
> thread-safe version of this call. When I do a man on this I get a
> version that only has 4 arguments. After looking at the prototype in
> the header file, I see where it takes an extra argument at the end.

Only one? Over here I have a version with 6 arguments. I don't seem to
even have the manpage but try the libc info manual:

info libc, i, gethostbyname_r

Rene.

 
 
 

1. argument parser strips out " in arguments

Hi,

I would like to know how I can pass double quotes to a perl script in
a csh or sh in UNIX. ie
I have a test script which has:
#!/usr/local/bin/perl5
print "arg0\n";

print "\narg1\n";

print "\narg2\n";

print "\n";

and I say:
./test  hello  "1 2"
arg0
hello
arg1
1 2
arg2

I would like arg1 to be "1 2" and not just 1 2
It looks like the " are being stripped out of the argument by the
parser. Similarly, I would like:
./test  hello  '1 2'
arg0
hello
arg1
1 2
arg2

to print '1 2' for arg1.

the reason I need this is because I am passing "1 2" to another script
which requires these arguments to have "" around them. If the " is
missing, it only reads 1 instead of 1 2
IT is transparent to the user that this is a wrapper they are
executing and so I wnt to avoid doing things like \"1 2\" when passing
arguments.

Thanks in advance for any help,

Sam

2. Setting up a linux system with internet capabilites anyone interested?

3. script questions - passing argument as argument to another program

4. Kernel panic: VFS: Unable to mount root fs on 08:01 HELP!

5. newbie: (command and its arguments) as a sh script argument

6. Bad sector problems on an RZ56

7. Taking arguments from pipe 'plus' one more argument

8. RedHat 6.0 + Wacom Intuos pad

9. pushd <no arguments> versus cd <no arguments>

10. The argument to end all pro-Linux arguments

11. gethostbyname_r & gethostbyaddr_r don't work correctly...

12. SuSE screen freezes and gethostbyname_r() fails

13. how to use gethostbyname_r()?