diff options
Diffstat (limited to 'src/common/xchat.c')
-rw-r--r-- | src/common/xchat.c | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/src/common/xchat.c b/src/common/xchat.c index afac9a0e..22c4eddb 100644 --- a/src/common/xchat.c +++ b/src/common/xchat.c @@ -22,14 +22,16 @@ #include <time.h> #include <sys/types.h> #include <sys/stat.h> -#include <unistd.h> #define WANTSOCKET #include "inet.h" -#ifndef WIN32 +#ifdef WIN32 +#include <windows.h> +#else #include <sys/wait.h> #include <signal.h> +#include <unistd.h> #endif #include "xchat.h" @@ -590,6 +592,7 @@ static char defaultconf_commands[] = "NAME DMSG\n" "CMD msg =%2 &3\n\n"\ "NAME EXIT\n" "CMD quit\n\n"\ "NAME GREP\n" "CMD lastlog -r &2\n\n"\ + "NAME IGNALL\n" "CMD ignore %2!*@* ALL\n\n"\ "NAME J\n" "CMD join &2\n\n"\ "NAME KILL\n" "CMD quote KILL %2 :&3\n\n"\ "NAME LEAVE\n" "CMD part &2\n\n"\ @@ -903,7 +906,11 @@ int main (int argc, char *argv[]) { int ret; - + +#ifdef WIN32 + HANDLE mutex; +#endif + srand (time (0)); /* CL: do this only once! */ #ifdef SOCKS @@ -920,6 +927,21 @@ main (int argc, char *argv[]) load_config (); +#ifdef WIN32 + if (prefs.gui_one_instance && !portable_mode ()) + { + DWORD error; + + mutex = CreateMutex (NULL, TRUE, "Local\xchat"); + error = GetLastError (); + + if (error == ERROR_ALREADY_EXISTS || mutex == NULL) + { + return 1; + } + } +#endif + #ifdef USE_LIBPROXY libproxy_factory = px_proxy_factory_new(); #endif @@ -945,6 +967,11 @@ main (int argc, char *argv[]) #ifdef WIN32 WSACleanup (); + + if (prefs.gui_one_instance && !portable_mode ()) + { + CloseHandle (mutex); + } #endif return 0; |