Index: include/conference.h
===================================================================
--- include/conference.h	(wersja 29)
+++ include/conference.h	(kopia robocza)
@@ -53,18 +53,18 @@
 #define STATUS_MUC_REM_SHUTDOWN "332"
 
 /* Error message defines */
-#define TERROR_MUC_PASSWORD	(terror){401, "Password required to join this room.", "auth", "not-authorized"}
-#define TERROR_MUC_BANNED	(terror){403, "You have been banned from this room.", "auth", "forbidden"}
-#define TERROR_MUC_VOICE	(terror){403, "You do not have permission to talk in this room.", "auth", "forbidden"}
-#define TERROR_MUC_PRIVMSG	(terror){403, "Private messages are not allowed in this room.", "auth", "forbidden"}
-#define TERROR_MUC_ROOM		(terror){403, "Room creation is disabled.", "auth", "forbidden"}
-#define TERROR_MUC_CONFIG	(terror){405, "You are disallowed access to room configuration", "cancel", "not-allowed"}
-#define TERROR_MUC_OUTSIDE	(terror){405, "You are not in this room", "cancel", "not-allowed"}
-#define TERROR_MUC_INVITED	(terror){407, "Invitation required to join this room.", "auth", "registration-required"}
-#define TERROR_MUC_FULL		(terror){503, "Room is full.", "wait", "service-unavailable"}
-#define TERROR_MUC_NICK		(terror){409, "Please choose a different nickname.", "cancel", "conflict"}
-#define TERROR_MUC_NICKREG	(terror){409, "Reserved Nick - Please choose a different nickname.", "cancel", "conflict"}
-#define TERROR_MUC_NICKLOCKED	(terror){409, "Nicknames locked: please use your username instead.", "cancel", "conflict"}
+TERROR_DEFINE(MUC_PASSWORD,   401, "Password required to join this room.", "auth", "not-authorized")
+TERROR_DEFINE(MUC_BANNED,     403, "You have been banned from this room.", "auth", "forbidden")
+TERROR_DEFINE(MUC_VOICE,      403, "You do not have permission to talk in this room.", "auth", "forbidden")
+TERROR_DEFINE(MUC_PRIVMSG,    403, "Private messages are not allowed in this room.", "auth", "forbidden")
+TERROR_DEFINE(MUC_ROOM,       403, "Room creation is disabled.", "auth", "forbidden")
+TERROR_DEFINE(MUC_CONFIG,     405, "You are disallowed access to room configuration", "cancel", "not-allowed")
+TERROR_DEFINE(MUC_OUTSIDE,    405, "You are not in this room", "cancel", "not-allowed")
+TERROR_DEFINE(MUC_INVITED,    407, "Invitation required to join this room.", "auth", "registration-required")
+TERROR_DEFINE(MUC_FULL,       408, "Room is full.", "wait", "service-unavailable")
+TERROR_DEFINE(MUC_NICK,       409, "Please choose a different nickname.", "cancel", "conflict")
+TERROR_DEFINE(MUC_NICKREG,    409, "Reserved Nick - Please choose a different nickname.", "cancel", "conflict")
+TERROR_DEFINE(MUC_NICKLOCKED, 409, "Nicknames locked: please use your username instead.", "cancel", "conflict")
 
 #define SEND_ALL		0
 #define SEND_LEGACY		1
@@ -210,17 +210,21 @@
     char msg[64];
 } taffil;
 
-#define TAFFIL_OWNER		(taffil){3, "owner"}
-#define TAFFIL_ADMIN		(taffil){2, "admin"}
-#define TAFFIL_MEMBER		(taffil){1, "member"}
-#define TAFFIL_NONE		(taffil){0, "none"}
-#define TAFFIL_OUTCAST		(taffil){-1, "outcast"}
+#define TAFFIL_DEFINE(name, code, msg) static UNUSED_DEFINE taffil TAFFIL_ ## name = {code, msg};
 
-#define TROLE_MODERATOR		(trole){3, "moderator"}
-#define TROLE_PARTICIPANT	(trole){2, "participant"}
-#define TROLE_VISITOR		(trole){1, "visitor"}
-#define TROLE_NONE		(trole){0, "none"}
+TAFFIL_DEFINE(OWNER,    3, "owner")
+TAFFIL_DEFINE(ADMIN,    2, "admin")
+TAFFIL_DEFINE(MEMBER,   1, "member")
+TAFFIL_DEFINE(NONE,     0, "none")
+TAFFIL_DEFINE(OUTCAST, -1, "outcast")
 
+#define TROLE_DEFINE(name, code, msg) static UNUSED_DEFINE trole TROLE_ ## name = {code, msg};
+
+TROLE_DEFINE(MODERATOR,   3, "moderator")
+TROLE_DEFINE(PARTICIPANT, 2, "participant")
+TROLE_DEFINE(VISITOR,     1, "visitor")
+TROLE_DEFINE(NONE,        0, "none")
+
 /* Functions in conference_room.c */
 void con_room_log(cnr room, char *nick, char *message);	/* Log messages */
 void con_room_log_new(cnr room);			/* New Log */
@@ -272,7 +276,11 @@
 void con_send_room_status(cnr room, char *status);	/* For sending status messages */
 char *linesplit(char **entry);				/* Splitting '/n' delimited string */
 char *funcstr(const char *file, const char *function, int line);	/* Custom log_debug define */
+#ifndef _WIN32
 char *itoa(int number, char *result);			/* Reverse of atoi command */
+#else
+#define itoa(x, y) _itoa(x, y, 10)
+#endif
 int minuteget(time_t tin);				/* Get current minute */
 char *timeget(time_t tin);				/* Get current time */
 char *dateget(time_t tin);				/* Get current date */
Index: include/lib.h
===================================================================
--- include/lib.h	(wersja 29)
+++ include/lib.h	(kopia robocza)
@@ -8,20 +8,27 @@
 #include <fcntl.h>
 #include <errno.h>
 #include <signal.h>
-#include <syslog.h>
 #include <strings.h>
 #include <unistd.h>
 #include <sys/param.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#include <arpa/inet.h>
 #include <sys/time.h>
 #include <stdarg.h>
 #include <ctype.h>
 #include <time.h>
 #include <glib.h>
 
+#ifndef _WIN32
+# include <syslog.h>
+# include <sys/socket.h>
+# include <netinet/in.h>
+# include <netdb.h>
+# include <arpa/inet.h>
+#else
+# include <winsock2.h>
+# include <io.h>
+# include <direct.h>
+#endif
+
 #include <expat.h>
 
 /*
@@ -424,24 +431,32 @@
     char condition[30];
 } terror;
 
-#define TERROR_BAD            (terror){400, "Bad Request", "modify", "bad-request"}
-#define TERROR_AUTH           (terror){401, "Unauthorized", "auth", "not-authorized"}
-#define TERROR_PAY            (terror){402, "Payment Required", "auth", "payment-required"}
-#define TERROR_FORBIDDEN      (terror){403, "Forbidden", "auth", "forbidden"}
-#define TERROR_NOTFOUND       (terror){404, "Not Found", "cancel", "item-not-found"}
-#define TERROR_NOTALLOWED     (terror){405, "Not Allowed", "cancel", "not-allowed"}
-#define TERROR_NOTACCEPTABLE  (terror){406, "Not Acceptable", "modify", "not-acceptable"}
-#define TERROR_REGISTER       (terror){407, "Registration Required", "auth", "registration-required"}
-#define TERROR_REQTIMEOUT     (terror){408, "Request Timeout", "wait", "remote-server-timeout"}
-#define TERROR_CONFLICT       (terror){409, "Conflict", "cancel", "conflict"}
+#if __GNUC__>=3
+# define UNUSED_DEFINE __attribute__((unused))
+#else
+# define UNUSED_DEFINE
+#endif
 
-#define TERROR_INTERNAL       (terror){500, "Internal Server Error", "wait", "internal-server-error"}
-#define TERROR_NOTIMPL        (terror){501, "Not Implemented", "cancel", "feature-not-implemented"}
-#define TERROR_EXTERNAL       (terror){502, "Remote Server Error", "wait", "service-unavailable"}
-#define TERROR_UNAVAIL        (terror){503, "Service Unavailable", "cancel", "service-unavailable"}
-#define TERROR_EXTTIMEOUT     (terror){504, "Remote Server Timeout", "wait", "remote-server-timeout"}
-#define TERROR_DISCONNECTED   (terror){510, "Disconnected", "cancel", "service-unavailable"}
+#define TERROR_DEFINE(name, code, msg, type, condition) static UNUSED_DEFINE terror TERROR_ ## name = {code, msg, type, condition};
 
+TERROR_DEFINE(BAD,           400, "Bad Request", "modify", "bad-request")
+TERROR_DEFINE(AUTH,          401, "Unauthorized", "auth", "not-authorized")
+TERROR_DEFINE(PAY,           402, "Payment Required", "auth", "payment-required")
+TERROR_DEFINE(FORBIDDEN,     403, "Forbidden", "auth", "forbidden")
+TERROR_DEFINE(NOTFOUND,      404, "Not Found", "cancel", "item-not-found")
+TERROR_DEFINE(NOTALLOWED,    405, "Not Allowed", "cancel", "not-allowed")
+TERROR_DEFINE(NOTACCEPTABLE, 406, "Not Acceptable", "modify", "not-acceptable")
+TERROR_DEFINE(REGISTER,      407, "Registration Required", "auth", "registration-required")
+TERROR_DEFINE(REQTIMEOUT,    408, "Request Timeout", "wait", "remote-server-timeout")
+TERROR_DEFINE(CONFLICT,      409, "Conflict", "cancel", "conflict")
+                               
+TERROR_DEFINE(INTERNAL,      500, "Internal Server Error", "wait", "internal-server-error")
+TERROR_DEFINE(NOTIMPL,       501, "Not Implemented", "cancel", "feature-not-implemented")
+TERROR_DEFINE(EXTERNAL,      502, "Remote Server Error", "wait", "service-unavailable")
+TERROR_DEFINE(UNAVAIL,       503, "Service Unavailable", "cancel", "service-unavailable")
+TERROR_DEFINE(EXTTIMEOUT,    504, "Remote Server Timeout", "wait", "remote-server-timeout")
+TERROR_DEFINE(DISCONNECTED,  510, "Disconnected", "cancel", "service-unavailable")
+
 /* --------------------------------------------------------- */
 /*                                                           */
 /* Namespace constants                                       */
@@ -504,7 +519,39 @@
 void    jutil_delay(xmlnode msg, char *reason);		 /* Append a delay packet to msg */
 char*   jutil_regkey(char *key, char *seed);		 /* pass a seed to generate a key, pass the key again to validate (returns it) */
 
+/* Portable signal function */
+typedef void jsighandler_t(int);
+jsighandler_t* jabber_signal(int signo, jsighandler_t *func);
 
+#ifdef _WIN32
+/* Windows service wrapper function */
+typedef int (jmainhandler_t)(int argc, char** argv);
+int jabber_wrap_service(int argc, char** argv, jmainhandler_t *wrapper, LPCTSTR name, LPCTSTR display, LPCTSTR description, LPCTSTR depends);
+#define JABBER_MAIN(name, display, description, depends) jabber_main(int argc, char** argv); \
+                    main(int argc, char** argv) { return jabber_wrap_service(argc, argv, jabber_main, name, display, description, depends); } \
+                    jabber_main(int argc, char** argv)
+#else /* _WIN32 */
+#define JABBER_MAIN(name, display, description, depends) main(int argc, char** argv)
+#endif /* _WIN32 */
+
+#ifdef _WIN32
+#define sleep(x) SleepEx((x)*1000, TRUE)
+#define strcasecmp stricmp
+#define strncasecmp strnicmp
+#define bzero(x, y) memset(x, 0, y)
+#endif /* _WIN32 */
+
+/* getopt & strptime win32 wrappers */
+#ifdef _WIN32
+#ifndef _GETOPT_H
+extern char *optarg;
+int getopt (int argc, char *const *argv, const char *shortopts);
+#endif
+#ifndef _STRPTIME_H
+char * strptime (const char *buf, const char *format, struct tm *timeptr);
+#endif
+#endif
+
 #ifdef __cplusplus
 }
 #endif
Index: src/conference_room.c
===================================================================
--- src/conference_room.c	(wersja 29)
+++ src/conference_room.c	(kopia robocza)
@@ -180,7 +180,13 @@
 
   filename = spool_print(sp);
 
-  if(stat(filename,&fileinfo) < 0 && mkdir(filename, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) < 0)
+  if(stat(filename,&fileinfo) < 0 
+#ifndef _WIN32
+     && mkdir(filename, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) < 0
+#else
+     && mkdir(filename) < 0
+#endif
+  )
   {
     log_warn(NAME, "[%s] ERR: unable to open log directory >%s<", FZONE, filename);
     return;
Index: src/iq.c
===================================================================
--- src/iq.c	(wersja 29)
+++ src/iq.c	(kopia robocza)
@@ -20,12 +20,16 @@
 
 /* Functions used be both conference.c and conference_room.c to respond to IQ requests */
 #include "conference.h"
-#include <sys/utsname.h>
+#ifndef _WIN32
+# include <sys/utsname.h>
+#endif
 
 /* Take an iq request for version and send the response directly */
 void iq_get_version(jpacket jp){
+#ifndef _WIN32
   struct utsname un;
   xmlnode x;
+#endif
   jutil_iqresult(jp->x);
   xmlnode_put_attrib(xmlnode_insert_tag(jp->x, "query"), "xmlns", NS_VERSION);
   jpacket_reset(jp);
@@ -33,11 +37,15 @@
   xmlnode_insert_cdata(xmlnode_insert_tag(jp->iq, "name"), NAME, -1);
   xmlnode_insert_cdata(xmlnode_insert_tag(jp->iq, "version"), VERSION, -1);
 
+#ifndef _WIN32
   uname(&un);
   x = xmlnode_insert_tag(jp->iq,"os");
   xmlnode_insert_cdata(x, pstrdup(jp->p, un.sysname),-1);
   xmlnode_insert_cdata(x," ",1);
   xmlnode_insert_cdata(x,pstrdup(jp->p, un.release),-1);
+#else
+  xmlnode_insert_cdata(xmlnode_insert_tag(jp->iq, "os"), "win32", -1);
+#endif
 
   deliver(dpacket_new(jp->x),NULL);
   return;
Index: src/jabberd/expat.c
===================================================================
--- src/jabberd/expat.c	(wersja 29)
+++ src/jabberd/expat.c	(kopia robocza)
@@ -120,7 +120,11 @@
     if(NULL == file)
         return NULL;
 
+#ifndef _WIN32
     fd = open(file,O_RDONLY);
+#else
+	fd = open(file,O_RDONLY|O_BINARY);
+#endif
     if(fd < 0)
         return NULL;
 
@@ -160,7 +164,11 @@
     if(NULL == file)
         return "no file specified";
 
+#ifndef _WIN32
     fd = open(file,O_RDONLY);
+#else
+	fd = open(file,O_RDONLY|O_BINARY);
+#endif
     if(fd < 0)
         return "unable to open file";
 
@@ -199,7 +207,11 @@
 
     close(fd);
 
+#ifndef _WIN32
     if(rename(ftmp,file) < 0)
+#else
+    if(MoveFileEx(ftmp,file,MOVEFILE_REPLACE_EXISTING|MOVEFILE_WRITE_THROUGH) == 0)
+#endif
     {
         unlink(ftmp);
         return -1;
Index: src/jabberd/Makefile
===================================================================
--- src/jabberd/Makefile	(wersja 29)
+++ src/jabberd/Makefile	(kopia robocza)
@@ -6,6 +6,7 @@
 JCOMP_LIB_OBJECTS=expat.o \
 	jid.o \
 	jpacket.o \
+	jsignal.o \
 	jutil.o \
 	pool.o \
 	sha.o \
@@ -13,6 +14,11 @@
 	str.o \
 	xmlnode.o 
 
+ifeq ($(OS),Windows_NT)
+JCOMP_LIB_OBJECTS:=$(JCOMP_LIB_OBJECTS) \
+	strptime.o \
+	getopt.o
+endif
 
 all: $(JCOMP_LIB_OBJECTS)
 	ar rv ../libjcomp.a $(JCOMP_LIB_OBJECTS)
Index: src/jcomp/jcr_base_connect.c
===================================================================
--- src/jcomp/jcr_base_connect.c	(wersja 29)
+++ src/jcomp/jcr_base_connect.c	(kopia robocza)
@@ -22,6 +22,15 @@
 
 #include "jcomp.h"
 
+#ifdef _WIN32
+# define EINPROGRESS WSAEWOULDBLOCK
+# ifdef errno
+#  undef errno
+# endif
+# define errno WSAGetLastError()
+# define close closesocket
+#endif
+
 int jcr_socket_connect(void) {
   int rc;
   struct sockaddr_in from;
Index: src/jcomp/jcr_main_stream_error.c
===================================================================
--- src/jcomp/jcr_main_stream_error.c	(wersja 29)
+++ src/jcomp/jcr_main_stream_error.c	(kopia robocza)
@@ -22,6 +22,10 @@
 
 #include "jcomp.h"
 
+#ifdef _WIN32
+# define close closesocket
+#endif
+
 void jcr_main_new_stream(void) {
  
   jcr->current = NULL;
@@ -62,8 +66,9 @@
   g_io_channel_unref(jcr->gio);
   g_io_channel_unref(jcr->gio);
   close(jcr->fd);
-  
 
+  if(jcr->in_shutdown)
+    return;
   sleep(2);
   jcr_main_new_stream();
 }
Index: src/jcomp/jcr_mio.c
===================================================================
--- src/jcomp/jcr_mio.c	(wersja 29)
+++ src/jcomp/jcr_mio.c	(kopia robocza)
@@ -22,6 +22,15 @@
 
 #include "jcomp.h"
 
+#ifdef _WIN32
+# define EINPROGRESS WSAEWOULDBLOCK
+# ifdef errno
+#  undef errno
+# endif
+# define errno WSAGetLastError()
+# define close closesocket
+#endif
+
 void jcr_mio_close(mio m) {
 
    if (m == NULL)
@@ -139,7 +148,12 @@
    struct hostent *hp;
    struct timeval t;
    fd_set wfds;
-   int flag = 1, flags, flag_len, rc;
+   int flag = 1, flag_len, rc;
+#ifndef _WIN32
+   int flags;
+#else
+   u_long flags;
+#endif
    guint watch_src;
 
    /* create a socket to connect with */
@@ -158,9 +172,14 @@
    }
 
    /* set the socket to non-blocking */
+#ifndef _WIN32
    flags =  fcntl(new->fd, F_GETFL, 0);
    flags |= O_NONBLOCK;
    fcntl(new->fd, F_SETFL, flags);
+#else
+   flags = 1;
+   ioctlsocket(new->fd, FIONBIO, &flags);
+#endif
 
    sa.sin_addr.s_addr = inet_addr(new->ip);
    if (sa.sin_addr.s_addr == (u_int) - 1) {
@@ -177,7 +196,11 @@
             pool_free(new->p);
          return;
       }
+#ifdef _WIN32
+      memcpy(&sa.sin_addr, hp->h_addr, hp->h_length);
+#else
       memcpy((caddr_t) &sa.sin_addr, hp->h_addr, hp->h_length);
+#endif
    }
 
    sa.sin_family = AF_INET;
Index: src/jcomp/jcr_shutdown.c
===================================================================
--- src/jcomp/jcr_shutdown.c	(wersja 29)
+++ src/jcomp/jcr_shutdown.c	(kopia robocza)
@@ -62,7 +62,11 @@
     free(jcr->pid_file);
   }
 
-  exit(0); 
+#ifdef _WIN32
+  return;
+#else
+  exit(0);
+#endif
 }
 
 void jcr_server_hangup(int signum) {
Index: src/main.c
===================================================================
--- src/main.c	(wersja 29)
+++ src/main.c	(kopia robocza)
@@ -23,15 +23,17 @@
 #include "jcomp.h"
 #include "lib.h"
 
-int main(int argc, char *argv[]) {
+JABBER_MAIN("jabbermuc", "Jabber MUC", "Multi-User Conferencing component for Jabber", "jabberd2router\0")
+{
   extern char *optarg;
   extern int optind, opterr, optopt;
   int inBackground = 0;
   int rc, pid, c;
   int message_mask_set = 0;
   int message_stderr_set = 0;
+#ifndef _WIN32
   int fdlimit, fd;
-  struct sigaction act, act_hup;
+#endif
   FILE *pid_stream;
   struct stat st;
   char *config_file = NULL;
@@ -67,11 +69,14 @@
 
     }
 
-
   /* The configuration file must be specified, and there is no default */
   if (config_file == NULL) {
+#ifndef _WIN32
     fprintf(stderr, "%s: Configuration file not specified, exiting.\n", JDBG);
     return 1;
+#else
+    config_file = "./muc.xml";
+#endif
   }
 
   /* Parse the XML in the config file -- store it as a node */
@@ -90,7 +95,13 @@
   rc = stat(jcr->spool_dir, &st);
   if (rc < 0) {
     /* Directory doesn't seem to exist, we try to create it */
-    if (mkdir(jcr->spool_dir,S_IRUSR | S_IWUSR | S_IXUSR)==0){
+    if (
+#ifndef _WIN32
+      mkdir(jcr->spool_dir,S_IRUSR | S_IWUSR | S_IXUSR)==0
+#else
+      mkdir(jcr->spool_dir)==0
+#endif
+    ) {
       fprintf(stdout, "%s: <spool> '%s': directory created.\n", JDBG, jcr->spool_dir);
       rc = stat(jcr->spool_dir, &st);
     }
@@ -100,10 +111,12 @@
       return 1;
     }
   }
+#ifndef _MSC_VER
   if (!(S_ISDIR(st.st_mode))) {
     fprintf(stderr, "%s: <spool> '%s' is not a directory.\n", JDBG, jcr->spool_dir);
     return 1;
   }
+#endif
 
   /* The log directory --- for the log_* functions */
   if ((xmlnode_get_type(xmlnode_get_tag(jcr->config,"logdir")) == NTYPE_TAG) == 0) {
@@ -117,17 +130,19 @@
     perror(NULL);
     return 1;
   }
+#ifndef _MSC_VER
   if (!(S_ISDIR(st.st_mode))) {
     fprintf(stderr, "%s: <logdir> '%s' is not a directory.\n", JDBG, jcr->log_dir);
     return 1;
   }
+#endif
 
   if (!message_mask_set)
     jcr->message_mask = j_atoi(xmlnode_get_data(xmlnode_get_tag(jcr->config,"loglevel")), 124);
   if (!message_stderr_set)
     jcr->message_stderr = (xmlnode_get_type(xmlnode_get_tag(jcr->config,"logstderr")) == NTYPE_TAG);
 
-
+#ifndef _WIN32
   if (inBackground == 1) {
     if ((pid = fork()) == -1) {
       fprintf(stderr, "%s: Could not start in background\n", JDBG);
@@ -146,6 +161,7 @@
     dup(0);
     dup(0);
   }
+#endif
   pid = getpid();
 
   /* We now can initialize the resources */
@@ -172,25 +188,13 @@
   jcr->recv_buffer = (char *)malloc(jcr->recv_buffer_size);
   jcr->in_shutdown = 0;
 
-  sigemptyset(&act.sa_mask);
-  sigaddset(&act.sa_mask, SIGTERM);
-  sigaddset(&act.sa_mask, SIGINT);
-  sigaddset(&act.sa_mask, SIGKILL);
-  act.sa_handler = jcr_server_shutdown;
-  //act.sa_restorer = NULL;
-  act.sa_flags = 0;
+  jabber_signal(SIGTERM, jcr_server_shutdown);
+  jabber_signal(SIGINT, jcr_server_shutdown);
+#ifndef _WIN32
+  jabber_signal(SIGKILL, jcr_server_shutdown);
+  jabber_signal(SIGHUP, jcr_server_hangup);
+#endif
 
-  sigemptyset(&act_hup.sa_mask);
-  sigaddset(&act_hup.sa_mask, SIGHUP);
-  act_hup.sa_handler = jcr_server_hangup;
-  act_hup.sa_flags = 0;
-
-  sigaction(SIGINT, &act, NULL);
-  sigaction(SIGTERM, &act, NULL);
-  sigaction(SIGKILL, &act, NULL);
-
-  sigaction(SIGHUP, &act_hup, NULL);
-
 #ifdef LIBIDN
   /* init the stringprep caches for jid manipulation */
   jid_init_cache();
Index: src/Makefile
===================================================================
--- src/Makefile	(wersja 29)
+++ src/Makefile	(kopia robocza)
@@ -2,9 +2,18 @@
 CC:=gcc
 CFLAGS:=$(CFLAGS) -O2 -Wall -I../../lib -I../include `pkg-config --cflags glib-2.0` -D_JCOMP -D_REENTRANT -DLIBIDN
 #CFLAGS:=$(CFLAGS) -O2 -Wall -I../../lib -I../include `pkg-config --cflags glib-2.0` -D_JCOMP -D_REENTRANT -DLIBIDN -DHAVE_MYSQL
-LIBS:=$(LIBS) -ljcomp -lm `pkg-config --libs glib-2.0` `pkg-config --libs gthread-2.0` -lexpat -lidn `mysql_config --libs`
+LIBS:=$(LIBS) -ljcomp -lm `pkg-config --libs glib-2.0` `pkg-config --libs gthread-2.0` -lexpat -lidn
 LDFLAGS:=-L.
 
+ifeq ($(OS),Windows_NT)
+LIBS:=$(LIBS) -lws2_32 -Wl,-s
+RES:=../win32/muc.res
+RC:=windres
+RCFLAGS:=--input-format rc --output-format coff
+else
+LIBS:=$(LIBS) `mysql_config --libs`
+endif
+
 # Debug/Experimental
 #CFLAGS:=$(CFLAGS) -pipe -Os -I../../jabberd -I../include 
 #LIBS:=$(LIBS) /usr/local/lib/ccmalloc-gcc.o -lccmalloc 
@@ -15,8 +24,8 @@
 
 all: mu-conference
 
-mu-conference: $(conference_OBJECTS)
-	$(CC) $(CFLAGS) $(MCFLAGS) -o mu-conference $(conference_OBJECTS) $(LDFLAGS) $(LIBS)
+mu-conference: $(conference_OBJECTS) $(RES)
+	$(CC) $(CFLAGS) $(MCFLAGS) -o mu-conference $(conference_OBJECTS) $(LDFLAGS) $(LIBS) $(RES)
 
 libjcomp.a:
 	cd jabberd ; make 
@@ -30,3 +39,8 @@
 	rm -f $(conference_OBJECTS) mu-conference *~
 	cd jcomp ; make clean
 	cd jabberd ; make clean
+
+ifeq ($(OS),Windows_NT)
+$(RES) : $(RES:.res=.rc) Makefile
+	$(RC) $(RCFLAGS) -o $(RES) -i $(RES:.res=.rc)
+endif
Index: src/utils.c
===================================================================
--- src/utils.c	(wersja 29)
+++ src/utils.c	(kopia robocza)
@@ -608,12 +608,14 @@
   return line;
 }
 
+#ifndef _WIN32
 /* Integer to String conversion */
 char *itoa(int number, char *result)
 {
   sprintf(result, "%d", number);
   return result;
 }
+#endif
 
 /* Custom Debug message */
 char *funcstr(const char *file, const char *function, int line)
@@ -759,7 +761,7 @@
     xmlnode_free(node);
   }
 
-  g_hash_table_insert(room->roster, g_strdup(ujid), store);
+  g_hash_table_insert(room->roster, j_strdup(ujid), store);
 
   return 1;
 }
