]> PatchyGit - patchyircd.git/commitdiff
make windows ver actually build
authorEgor <egor@patchysicp.xyz>
Mon, 2 May 2022 12:51:11 +0000 (15:51 +0300)
committerEgor <egor@patchysicp.xyz>
Mon, 2 May 2022 12:51:11 +0000 (15:51 +0300)
.gitignore
Makefile
NetSock/netsock.h
config.example.mk [new file with mode: 0644]
irc.c

index ad02aa4..a1987c9 100644 (file)
@@ -1,2 +1,3 @@
 ircd
-config.mak
+ircd.exe
+config.mk
index 423f715..c37657c 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,12 +1,14 @@
 TARGET:=ircd
 SOURCES:=$(wildcard *.c NetSock/*.c)
 HEADERS:=$(wildcard *.h NetSock/*.h)
--include config.mak
+-include config.mk
 
 .PHONY: all clean
-all: $(TARGET)
+all: $(TARGET) $(if $(CC.w32),$(TARGET).exe,)
 clean:
-       $(RM) $(TARGET)
+       $(RM) $(TARGET) $(TARGET).exe
 
 $(TARGET): $(SOURCES) $(HEADERS)
        $(CC) $(CFLAGS) $(LDFLAGS) $(SOURCES) $(LDLIBS) -o $@
+$(TARGET).exe: $(SOURCES) $(HEADERS)
+       $(CC.w32) $(CFLAGS.w32) $(LDFLAGS.w32) $(SOURCES) $(LDLIBS.w32) -o $@
index ead46ed..f60cc88 100644 (file)
 
 // Windows
 #if defined(_WIN32)
+#ifndef I_KNOW_HOW_TO_USE_A_LINKER
 #pragma message("Warning: Windows detected.")
 #pragma message("IMPORTANT: COMPILE WITH -lws2_32")
 #pragma comment(lib, "ws2_32.lib")
+#endif
 //#include <WinSock2.h>
 //#include <WS2tcpip.h>
 //#include <Windows.h>
 #include <ws2tcpip.h>
 #include <windows.h>
 //#define PRISocket "llu" // The format string for SOCKET
+#ifndef PRISocket
 #define PRISocket "p" // The format string for SOCKET
+#endif
 #define net_errno() (WSAGetLastError())
 #define net_wouldblock() (WSAGetLastError() == WSAEWOULDBLOCK)
 // Funcs
 const char *net_strerror(int e);
 // Variables
 extern struct WSAData net_wd;
+#define SHUT_RD SD_RECEIVE
+#define SHUT_WR SD_SEND
+#define SHUT_RDWR SD_BOTH
 
 // POSIX
 #else
diff --git a/config.example.mk b/config.example.mk
new file mode 100644 (file)
index 0000000..ab7ebcd
--- /dev/null
@@ -0,0 +1,6 @@
+HEADERS+=config.mk
+CC=clang
+CFLAGS=-Wall -Wextra
+CC.w32=i686-w64-mingw32-gcc
+CFLAGS.w32=-Wall -Wextra -DPRISocket='"u"' -DI_KNOW_HOW_TO_USE_A_LINKER -DWINVER=0x0600 -D_WIN32_WINNT=0x0600
+LDLIBS.w32=-lws2_32
diff --git a/irc.c b/irc.c
index a62c20f..6a5fbc3 100644 (file)
--- a/irc.c
+++ b/irc.c
@@ -13,7 +13,7 @@ int processPacket(struct client_data *client) {
        } else if(strncmp(packet, "NICK ", 5) == 0) {
                // User now registered
                setNick(client, packet+5, 32);
-               printf("USER SET NICKNAME %lu %s\n", client->nickLen, client->nick);
+               printf("USER SET NICKNAME %s\n", client->nick);
                fflush(stdout);
        } else if(strncmp(packet, "USER ", 5) == 0) {
                // Send welcome