From: Gurusamy Sarathy Date: Tue, 10 Mar 1998 20:33:05 +0000 (+0000) Subject: [win32] mingw32 tweaks X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e56670dde139d53fcdaec6163664f9afa257dc11;p=p5sagit%2Fp5-mst-13.2.git [win32] mingw32 tweaks p4raw-id: //depot/win32/perl@804 --- diff --git a/win32/makefile.mk b/win32/makefile.mk index 45af877..45cbe4b 100644 --- a/win32/makefile.mk +++ b/win32/makefile.mk @@ -157,8 +157,8 @@ DEFINES = -DWIN32 $(BUILDOPT) $(CRYPT_FLAG) LOCDEFS = -DPERLDLL -DPERL_CORE SUBSYS = console LIBC = -lcrtdll -LIBFILES = $(CRYPT_LIB) -ladvapi32 -luser32 -lwsock32 -lmingw32 -lgcc -lmoldname $(LIBC) \ - -lkernel32 +LIBFILES = $(CRYPT_LIB) -ladvapi32 -luser32 -lnetapi32 -lwsock32 -lmingw32 \ + -lgcc -lmoldname $(LIBC) -lkernel32 WINIOMAYBE = diff --git a/win32/win32.c b/win32/win32.c index e1192f8..9178631 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -16,6 +16,7 @@ #endif #include +#ifndef __MINGW32__ #include #include /* ugliness to work around a buggy struct definition in lmwksta.h */ @@ -24,6 +25,8 @@ #include #undef LPTSTR #define LPTSTR LPSTR +#include +#endif /* __MINGW32__ */ /* #include "config.h" */ @@ -1910,6 +1913,23 @@ static XS(w32_DomainName) { dXSARGS; +#ifdef __MINGW32__ + /* mingw32 doesn't have NetWksta*() yet, so do it the old way */ + char name[256]; + DWORD size = sizeof(name); + if (GetUserName(name,&size)) { + char sid[1024]; + DWORD sidlen = sizeof(sid); + char dname[256]; + DWORD dnamelen = sizeof(dname); + SID_NAME_USE snu; + if (LookupAccountName(NULL, name, &sid, &sidlen, + dname, &dnamelen, &snu)) { + XSRETURN_PV(dname); /* all that for this */ + } + } +#else + /* this way is more reliable, in case user has a local account */ char dname[256]; DWORD dnamelen = sizeof(dname); PWKSTA_INFO_100 pwi; @@ -1925,6 +1945,7 @@ XS(w32_DomainName) NetApiBufferFree(pwi); XSRETURN_PV(dname); } +#endif XSRETURN_UNDEF; } diff --git a/win32/win32.h b/win32/win32.h index 58a0ff3..259ffdc 100644 --- a/win32/win32.h +++ b/win32/win32.h @@ -137,6 +137,13 @@ typedef long gid_t; #define flushall _flushall #define fcloseall _fcloseall +#ifndef _O_NOINHERIT +# define _O_NOINHERIT 0x0080 +# ifndef _NO_OLDNAMES +# define O_NOINHERIT _O_NOINHERIT +# endif +#endif + #endif /* __MINGW32__ */ /* compatibility stuff for other compilers goes here */