mirror of
https://github.com/unrealircd/unrealircd.git
synced 2026-07-06 13:33:13 +02:00
Made the win32 version use a dynamically linked libc
This commit is contained in:
@@ -3208,3 +3208,9 @@ This is the 3.2 fixes branch.
|
||||
- Imported TRE 0.6.8 for *nix
|
||||
- Added NICKIP to doc/technical/protoctl.txt
|
||||
- Imported TRE 0.6.8 for windows
|
||||
- Redid the win32 version to use a dynamically linked libc. This solves memory issues
|
||||
arising from the fact that dlls do not share the same heap as the exe. As a side effect,
|
||||
however, there is now a dependency on msvcr70d.dll. This DLL does not come with any
|
||||
versions of Windows except 2003. It also comes with any .NET application and the .NET
|
||||
framework. Unreal will automatically download th DLL if it is needed. Reported by Bugz
|
||||
(#0001833)
|
||||
|
||||
@@ -331,7 +331,6 @@ extern struct SLink *find_user_link( /* struct SLink *, struct Client * */ );
|
||||
* Windows' internal strerror() function doesn't work with socket errors.
|
||||
*/
|
||||
extern int DisplayString(HWND hWnd, char *InBuf, ...);
|
||||
#undef strerror
|
||||
#else
|
||||
typedef int SOCKET;
|
||||
#define INVALID_SOCKET -1
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
* Most of the externs and prototypes thrown in here to 'cleanup' things.
|
||||
* -avalon
|
||||
*/
|
||||
#include "setup.h"
|
||||
#ifndef NO_FDLIST
|
||||
#include "fdlist.h"
|
||||
#endif
|
||||
@@ -208,7 +209,11 @@ extern void reset_help();
|
||||
extern MODVAR char *debugmode, *configfile, *sbrk0;
|
||||
extern char *getfield(char *);
|
||||
extern void get_sockhost(aClient *, char *);
|
||||
#ifndef _WIN32
|
||||
extern char *strerror(int);
|
||||
#else
|
||||
extern char *sock_strerror(int);
|
||||
#endif
|
||||
extern int dgets(int, char *, int);
|
||||
extern char *inetntoa(char *);
|
||||
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@
|
||||
#endif
|
||||
|
||||
extern int inet_pton(int af, const char *src, void *dst);
|
||||
extern const char *inet_ntop(int af, const void *src, char *dst, socklen_t cnt);
|
||||
extern const char *inet_ntop(int af, const void *src, char *dst, size_t cnt);
|
||||
|
||||
#ifdef __STDC__
|
||||
# ifndef _WIN32
|
||||
|
||||
+1
-1
@@ -234,7 +234,7 @@ static const struct in6_addr in6addr_any = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
#define CLOSE_SOCK(fd) closesocket(fd)
|
||||
#define IOCTL(x, y, z) ioctlsocket((x), (y), (z))
|
||||
#define ERRNO WSAGetLastError()
|
||||
#define STRERROR(x) nt_strerror(x)
|
||||
#define STRERROR(x) sock_strerror(x)
|
||||
#define SET_ERRNO(x) WSASetLastError(x)
|
||||
/* Error constant portability */
|
||||
#define P_EMFILE WSAEMFILE
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
#undef SYSSYSLOGH
|
||||
#define NOINDEX
|
||||
#define NOBCOPY
|
||||
#define NEED_STRERROR
|
||||
#define NEED_STRTOKEN
|
||||
#undef NEED_STRTOK
|
||||
#undef NEED_INET_ADDR
|
||||
|
||||
+6
-6
@@ -101,21 +101,21 @@ OPENSSL_LIB=/LIBPATH:"$(OPENSSL_LIB_DIR)"
|
||||
!ENDIF
|
||||
|
||||
!IFDEF DEBUG
|
||||
DBGCFLAG=/MTd /Zi
|
||||
DBGCFLAG=/MDd /Zi
|
||||
DBGLFLAG=/debug /debugtype:BOTH
|
||||
MODDBGCFLAG=/LDd /Zi
|
||||
MODDBGCFLAG=/LDd /MDd /Zi
|
||||
!ELSE
|
||||
DBGCFLAG=/MT /O2 /G5
|
||||
MODDBGCFLAG=/LD
|
||||
DBGCFLAG=/MD /O2 /G5
|
||||
MODDBGCFLAG=/LD /MD
|
||||
!ENDIF
|
||||
|
||||
FD_SETSIZE=/D FD_SETSIZE=16384
|
||||
CFLAGS=$(DBGCFLAG) $(LIBCURL_INC) $(ZLIB_INC) $(OPENSSL_INC) /I ./INCLUDE /Fosrc/ /nologo \
|
||||
$(ZIPCFLAGS) $(CURLCFLAGS) $(FD_SETSIZE) $(SSLCFLAGS) $(NS_ADDRESS) /D NOSPOOF=1 /c
|
||||
LFLAGS=kernel32.lib user32.lib gdi32.lib shell32.lib ws2_32.lib advapi32.lib \
|
||||
dbghelp.lib oldnames.lib libcmt.lib comctl32.lib comdlg32.lib $(ZLIB_LIB) $(ZIPLIB) \
|
||||
dbghelp.lib oldnames.lib comctl32.lib comdlg32.lib $(ZLIB_LIB) $(ZIPLIB) \
|
||||
$(OPENSSL_LIB) $(SSLLIBS) $(LIBCURL_LIB) $(CURLLIB) /def:wircd.def /implib:wircd.lib \
|
||||
/nodefaultlib /nologo $(DBGLFLAG) /out:WIRCD.EXE
|
||||
/nologo $(DBGLFLAG) /out:WIRCD.EXE
|
||||
MODCFLAGS=$(MODDBGCFLAG) $(SSLCFLAGS) $(ZIPCFLAGS) $(CURLCFLAGS) /Fesrc/modules/ \
|
||||
/Fosrc/modules/ /nologo $(LIBCURL_INC) $(ZLIB_INC) $(OPENSSL_INC) /I ./INCLUDE /D \
|
||||
DYNAMIC_LINKING /D NOSPOOF /D MODULE_COMPILE
|
||||
|
||||
+1
-1
@@ -93,7 +93,7 @@ void DeleteTempModules(void)
|
||||
if (!fd) /* Ouch.. this is NOT good!! */
|
||||
{
|
||||
config_error("Unable to open 'tmp' directory: %s, please create one with the appropriate permissions",
|
||||
strerror(ERRNO));
|
||||
strerror(errno));
|
||||
if (!loop.ircd_booted)
|
||||
exit(7);
|
||||
return;
|
||||
|
||||
@@ -374,7 +374,7 @@ static int send_res_msg(char *msg, int len, int rcount)
|
||||
#endif
|
||||
|
||||
{
|
||||
Debug((DEBUG_DNS, "send_res_msg, errno = %s",strerror(ERRNO)));
|
||||
Debug((DEBUG_DNS, "send_res_msg, errno = %s",STRERROR(ERRNO)));
|
||||
reinfo.re_sent++;
|
||||
sent++;
|
||||
}
|
||||
|
||||
+13
-13
@@ -271,7 +271,7 @@ void report_error(char *text, aClient *cptr)
|
||||
|
||||
host = (cptr) ? get_client_name(cptr, FALSE) : "";
|
||||
|
||||
Debug((DEBUG_ERROR, text, host, strerror(errtmp)));
|
||||
Debug((DEBUG_ERROR, text, host, STRERROR(errtmp)));
|
||||
|
||||
/*
|
||||
* Get the *real* error from the socket (well try to anyway..).
|
||||
@@ -290,14 +290,14 @@ void report_error(char *text, aClient *cptr)
|
||||
* some tricks are needed because of 2x strerror() (or at least
|
||||
* according to the man page) -- Syzop.
|
||||
*/
|
||||
snprintf(xbuf, 200, "[syserr='%s'", strerror(origerr));
|
||||
snprintf(xbuf, 200, "[syserr='%s'", STRERROR(origerr));
|
||||
n = strlen(xbuf);
|
||||
snprintf(xbuf+n, 256-n, ", sockerr='%s']", strerror(errtmp));
|
||||
snprintf(xbuf+n, 256-n, ", sockerr='%s']", STRERROR(errtmp));
|
||||
sendto_snomask(SNO_JUNK, text, host, xbuf);
|
||||
ircd_log(LOG_ERROR, text, host, xbuf);
|
||||
} else {
|
||||
sendto_snomask(SNO_JUNK, text, host, strerror(errtmp));
|
||||
ircd_log(LOG_ERROR, text,host,strerror(errtmp));
|
||||
sendto_snomask(SNO_JUNK, text, host, STRERROR(errtmp));
|
||||
ircd_log(LOG_ERROR, text,host,STRERROR(errtmp));
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -316,7 +316,7 @@ void report_baderror(char *text, aClient *cptr)
|
||||
|
||||
/* fprintf(stderr, text, host, strerror(errtmp));
|
||||
fputc('\n', stderr); */
|
||||
Debug((DEBUG_ERROR, text, host, strerror(errtmp)));
|
||||
Debug((DEBUG_ERROR, text, host, STRERROR(errtmp)));
|
||||
|
||||
/*
|
||||
* Get the *real* error from the socket (well try to anyway..).
|
||||
@@ -330,7 +330,7 @@ void report_baderror(char *text, aClient *cptr)
|
||||
if (err)
|
||||
errtmp = err;
|
||||
#endif
|
||||
sendto_umode(UMODE_OPER, text, host, strerror(errtmp));
|
||||
sendto_umode(UMODE_OPER, text, host, STRERROR(errtmp));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1918,7 +1918,7 @@ deadsocket:
|
||||
}
|
||||
(void)exit_client(cptr, cptr, &me,
|
||||
((sockerr = get_sockerr(cptr))
|
||||
? strerror(sockerr) : "Client exited"));
|
||||
? STRERROR(sockerr) : "Client exited"));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -2005,7 +2005,7 @@ deadsocket:
|
||||
if (length != FLUSH_BUFFER)
|
||||
(void)exit_client(cptr, cptr, &me,
|
||||
((sockerr = get_sockerr(cptr))
|
||||
? strerror(sockerr) : "Client exited"));
|
||||
? STRERROR(sockerr) : "Client exited"));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -2290,7 +2290,7 @@ int read_message(time_t delay, fdlist *listp)
|
||||
|
||||
(void)exit_client(cptr, cptr, &me,
|
||||
((sockerr =
|
||||
get_sockerr(cptr)) ? strerror(sockerr) :
|
||||
get_sockerr(cptr)) ? STRERROR(sockerr) :
|
||||
"Client exited"));
|
||||
continue;
|
||||
}
|
||||
@@ -2312,7 +2312,7 @@ int read_message(time_t delay, fdlist *listp)
|
||||
if (IsDead(cptr))
|
||||
{
|
||||
ircsprintf(errmsg, "Read/Dead Error: %s",
|
||||
strerror(get_sockerr(cptr)));
|
||||
STRERROR(get_sockerr(cptr)));
|
||||
exit_client(cptr, cptr, &me, errmsg);
|
||||
continue;
|
||||
}
|
||||
@@ -2341,7 +2341,7 @@ int read_message(time_t delay, fdlist *listp)
|
||||
if (length != FLUSH_BUFFER)
|
||||
(void)exit_client(cptr, cptr, &me,
|
||||
((sockerr = get_sockerr(cptr))
|
||||
? strerror(sockerr) : "Client exited"));
|
||||
? STRERROR(sockerr) : "Client exited"));
|
||||
|
||||
}
|
||||
return 0;
|
||||
@@ -2624,7 +2624,7 @@ static void do_dns_async(void)
|
||||
sendto_realops("Hostname %s is unknown for server %s (!?).", aconf->hostname, aconf->servername);
|
||||
break;
|
||||
default:
|
||||
sendto_realops("Connection to %s failed: %s", aconf->servername, strerror(n));
|
||||
sendto_realops("Connection to %s failed: %s", aconf->servername, STRERROR(n));
|
||||
}
|
||||
}
|
||||
if (!hp) {
|
||||
|
||||
+1
-5
@@ -317,11 +317,7 @@ void send_usage(aClient *cptr, char *nick)
|
||||
if (times(&tmsbuf) == -1)
|
||||
{
|
||||
sendto_one(cptr, ":%s %d %s :times(2) error: %s.",
|
||||
# ifndef _WIN32
|
||||
me.name, RPL_STATSDEBUG, nick, strerror(errno));
|
||||
# else
|
||||
me.name, RPL_STATSDEBUG, nick, strerror(WSAGetLastError()));
|
||||
# endif
|
||||
me.name, RPL_STATSDEBUG, nick, STRERROR(ERRNO));
|
||||
return;
|
||||
}
|
||||
secs = tmsbuf.tms_utime + tmsbuf.tms_stime;
|
||||
|
||||
+1
-1
@@ -196,7 +196,7 @@ int send_queued(aClient *to)
|
||||
if ((rlen = deliver_it(to, msg, len)) < 0)
|
||||
{
|
||||
char buf[256];
|
||||
snprintf(buf, 256, "Write error: %s", strerror(ERRNO));
|
||||
snprintf(buf, 256, "Write error: %s", STRERROR(ERRNO));
|
||||
return dead_link(to, buf);
|
||||
}
|
||||
(void)dbuf_delete(&to->sendQ, rlen);
|
||||
|
||||
+1
-5
@@ -119,11 +119,7 @@ int deliver_it(aClient *cptr, char *str, int len)
|
||||
if (retval < 0)
|
||||
{
|
||||
writeb[0]++;
|
||||
# ifndef _WIN32
|
||||
Debug((DEBUG_ERROR, "write error (%s) to %s", strerror(errno), cptr->name));
|
||||
# else
|
||||
Debug((DEBUG_ERROR, "write error (%s) to %s", "", cptr->name));
|
||||
# endif
|
||||
Debug((DEBUG_ERROR, "write error (%s) to %s", STRERROR(ERRNO), cptr->name));
|
||||
|
||||
}
|
||||
else if (retval == 0)
|
||||
|
||||
@@ -103,7 +103,7 @@ static char ssl_errbuf[256];
|
||||
ssl_errstr = "OpenSSL requested a X509 lookup which didn`t arrive";
|
||||
break;
|
||||
case SSL_ERROR_SYSCALL:
|
||||
snprintf(ssl_errbuf, sizeof(ssl_errbuf), "Underlying syscall error [%s]", strerror(ERRNO));
|
||||
snprintf(ssl_errbuf, sizeof(ssl_errbuf), "Underlying syscall error [%s]", STRERROR(ERRNO));
|
||||
ssl_errstr = ssl_errbuf;
|
||||
break;
|
||||
case SSL_ERROR_ZERO_RETURN:
|
||||
|
||||
+19
-15
@@ -136,19 +136,8 @@ char *strerror(int err_no)
|
||||
if (errp == (char *)NULL)
|
||||
{
|
||||
errp = buff;
|
||||
#ifndef _WIN32
|
||||
(void)ircsprintf(errp, "Unknown Error %d", err_no);
|
||||
#else
|
||||
switch (err_no)
|
||||
{
|
||||
case WSAECONNRESET:
|
||||
ircsprintf(errp, "Connection reset by peer");
|
||||
break;
|
||||
default:
|
||||
ircsprintf(errp, "Unknown Error %d", err_no);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
return errp;
|
||||
}
|
||||
@@ -1704,7 +1693,7 @@ char *unreal_mktemp(char *dir, char *suffix)
|
||||
fclose(fd);
|
||||
}
|
||||
config_error("Unable to create temporary file in directory '%s': %s",
|
||||
dir, strerror(ERRNO)); /* eg: permission denied :p */
|
||||
dir, strerror(errno)); /* eg: permission denied :p */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -1758,7 +1747,7 @@ int unreal_copyfile(char *src, char *dest)
|
||||
#endif
|
||||
if (destfd < 0)
|
||||
{
|
||||
config_error("Unable to create file '%s': %s", dest, strerror(ERRNO));
|
||||
config_error("Unable to create file '%s': %s", dest, strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1772,7 +1761,7 @@ int unreal_copyfile(char *src, char *dest)
|
||||
|
||||
if (len < 0) /* very unusual.. perhaps an I/O error */
|
||||
{
|
||||
config_error("Read error from file '%s': %s", src, strerror(ERRNO));
|
||||
config_error("Read error from file '%s': %s", src, strerror(errno));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@@ -2274,3 +2263,18 @@ inet_pton6(const char *src, unsigned char *dst)
|
||||
return (1);
|
||||
}
|
||||
#endif /* !HAVE_INET_PTON */
|
||||
|
||||
#ifdef _WIN32
|
||||
char *sock_strerror(int error)
|
||||
{
|
||||
static char buf[1024];
|
||||
static HMODULE hSock = NULL;
|
||||
if (!hSock)
|
||||
hSock = LoadLibraryEx("wsock32.dll", NULL, LOAD_LIBRARY_AS_DATAFILE);
|
||||
|
||||
FormatMessage(FORMAT_MESSAGE_IGNORE_INSERTS|FORMAT_MESSAGE_FROM_HMODULE,
|
||||
hSock, error, 0, buf, 1024, NULL);
|
||||
|
||||
return buf;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -157,7 +157,7 @@ char *download_file(char *url, char **error)
|
||||
fd = fopen(tmp, "wb");
|
||||
if (!fd)
|
||||
{
|
||||
snprintf(errorbuf, CURL_ERROR_SIZE, "Cannot write to %s: %s", tmp, strerror(ERRNO));
|
||||
snprintf(errorbuf, CURL_ERROR_SIZE, "Cannot write to %s: %s", tmp, strerror(errno));
|
||||
if (file)
|
||||
free(file);
|
||||
*error = errorbuf;
|
||||
|
||||
@@ -91,12 +91,14 @@ function isxdl_Download(hWnd: Integer; URL, Filename: PChar): Integer;
|
||||
external 'isxdl_Download@files:isxdl.dll stdcall';
|
||||
function isxdl_SetOption(Option, Value: PChar): Integer;
|
||||
external 'isxdl_SetOption@files:isxdl.dll stdcall';
|
||||
const url = 'http://www.unrealircd.com/downloads/DbgHelp.Dll';
|
||||
var didDl: Boolean;
|
||||
const dbgurl = 'http://www.unrealircd.com/downloads/DbgHelp.Dll';
|
||||
const crturl = 'http://www.unrealircd.com/downloads/msvcr70d.dll';
|
||||
var didDbgDl,didCrtDl: Boolean;
|
||||
|
||||
function NextButtonClick(CurPage: Integer): Boolean;
|
||||
var
|
||||
dbghelp,tmp,output: String;
|
||||
msvcrt: String;
|
||||
m: String;
|
||||
hWnd,answer: Integer;
|
||||
begin
|
||||
@@ -104,7 +106,21 @@ begin
|
||||
if ((CurPage = wpReady)) then begin
|
||||
dbghelp := ExpandConstant('{sys}\DbgHelp.Dll');
|
||||
output := ExpandConstant('{app}\DbgHelp.Dll');
|
||||
msvcrt := ExpandConstant('{sys}\msvcr70d.Dll');
|
||||
GetVersionNumbersString(dbghelp,m);
|
||||
if (NOT FileExists(msvcrt)) then begin
|
||||
answer := MsgBox('Unreal requires the MS C Runtime 7.0 in order to run, do you wish to install it now?', mbConfirmation, MB_YESNO);
|
||||
if answer = IDYES then begin
|
||||
tmp := ExpandConstant('{tmp}\msvcr70d.Dll');
|
||||
isxdl_SetOption('title', 'Downloading msvcr70d.dll');
|
||||
hWnd := StrToInt(ExpandConstant('{wizardhwnd}'));
|
||||
if isxdl_Download(hWnd, crturl, tmp) = 0 then begin
|
||||
MsgBox('Download and installation of msvcr70d.dll failed, the file must be manually installed. The file can be downloaded at http://www.unrealircd.com/downloads/mscvr70.dll', mbInformation, MB_OK);
|
||||
end else
|
||||
didCrtDl := true;
|
||||
end else
|
||||
MsgBox('In order for Unreal to properly function, you must manually install msvcr70d.dll. The dll can be downloaded from http://www.unrealircd.com/downloads/msvcr70d.dll', mbInformation, MB_OK);
|
||||
end;
|
||||
if (NOT FileExists(output)) then begin
|
||||
if (NOT FileExists(dbghelp)) then
|
||||
m := StringOfChar('0',1);
|
||||
@@ -114,12 +130,12 @@ begin
|
||||
tmp := ExpandConstant('{tmp}\dbghelp.dll');
|
||||
isxdl_SetOption('title', 'Downloading DbgHelp.dll');
|
||||
hWnd := StrToInt(ExpandConstant('{wizardhwnd}'));
|
||||
if isxdl_Download(hWnd, url, tmp) = 0 then begin
|
||||
if isxdl_Download(hWnd, dbgurl, tmp) = 0 then begin
|
||||
MsgBox('Download and installation of DbgHelp.Dll failed, the file must be manually installed. The file can be downloaded at http://www.unrealircd.com/downloads/DbgHelp.Dll', mbInformation, MB_OK);
|
||||
end else
|
||||
didDl := true;
|
||||
didDbgDl := true;
|
||||
end else
|
||||
MsgBox('In order for Unreal to properly function you must manually install this dll. The dll can be downloaded from http://www.unrealircd.com/downloads/DbgHelp.Dll', mbInformation, MB_OK);
|
||||
MsgBox('In order for Unreal to properly function you must manually install dbghelp.dll. The dll can be downloaded from http://www.unrealircd.com/downloads/DbgHelp.Dll', mbInformation, MB_OK);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
@@ -130,11 +146,16 @@ procedure DeInitializeSetup();
|
||||
var
|
||||
input,output: String;
|
||||
begin
|
||||
if (didDl) then begin
|
||||
if (didDbgDl) then begin
|
||||
input := ExpandConstant('{tmp}\dbghelp.dll');
|
||||
output := ExpandConstant('{app}\dbghelp.dll');
|
||||
FileCopy(input, output, true);
|
||||
end;
|
||||
if (didCrtDl) then begin
|
||||
input := ExpandConstant('{tmp}\msvcr70d.dll');
|
||||
output := ExpandConstant('{sys}\msvcr70d.dll');
|
||||
FileCopy(input, output, true);
|
||||
end;
|
||||
end;
|
||||
|
||||
[Icons]
|
||||
|
||||
Reference in New Issue
Block a user