Re: gethostname on Windows

2009-08-03 Thread Simon Josefsson
Bruno Haible writes: > You are right. In summary: > >- GetComputerNameEx(ComputerNameDnsHostname,...) returns the right > hostname, > but it hard to use portably: >- It requires defining _WIN32_WINNT to at least 0x0500. >- With mingw, it also requires > "#define

Re: gethostname on Windows

2009-08-02 Thread Bruno Haible
Martin Lambers wrote: > This requires to include limits.h in gethostname.c, to get INT_MAX. > > Martin > > > diff --git a/lib/gethostname.c b/lib/gethostname.c > index ef58a40..422184a 100644 > --- a/lib/gethostname.c > +++ b/lib/gethostname.c > @@ -76,6 +76,9 @@ gethostname (char *name, size_t

Re: gethostname on Windows

2009-08-02 Thread Martin Lambers
On Sun, 02. Aug 2009, 12:04:53 +0200, Bruno Haible wrote: > Simon Josefsson wrote: > > Avoiding -lws2_32 is good, but if the application links to -lws2_32 > > anyway, there will be no saving. > > [...] > > [...] > I'm now convinced that linking with -lws2_32 is the least evil. > I have applied you

Re: gethostname on Windows

2009-08-02 Thread Bruno Haible
Simon Josefsson wrote: > > I'm undecided. > > Avoiding -lws2_32 is good, but if the application links to -lws2_32 > anyway, there will be no saving. > ... > Some additional questions: > > 1) How do I use it? This doesn't seem to work: > > j...@mocca:~$ cat foo.c > #define WINVER 0x0500 > #inclu

Re: gethostname on Windows

2009-04-02 Thread Simon Josefsson
I managed to rewrite the code in GSS to not need the gethostname function at all, so I don't care strongly about the patch to make gethostname work under mingw anymore. My initial patch could be used, but Bruno's concern about linking to -lws2_32 may be a reason against. /Simon

Re: gethostname on Windows

2009-04-02 Thread Simon Josefsson
Bruno Haible writes: > Simon Josefsson wrote: >> The current gethostname module will return an empty string on mingw: >> >> strcpy (name, ""); /* Hardcode your system name if you want. */ >> >> This is sub-optimal since Windows has a gethostname function in >> -lws2_32. >> >> The fo

Re: gethostname on Windows

2009-04-01 Thread Bruno Haible
Simon Josefsson wrote: > The current gethostname module will return an empty string on mingw: > > strcpy (name, ""); /* Hardcode your system name if you want. */ > > This is sub-optimal since Windows has a gethostname function in > -lws2_32. > > The following patch should make gethos

gethostname on Windows

2009-03-31 Thread Simon Josefsson
The current gethostname module will return an empty string on mingw: strcpy (name, "");/* Hardcode your system name if you want. */ This is sub-optimal since Windows has a gethostname function in -lws2_32. The following patch should make gethostname return proper values. Tested on