From 77aab6ad6a362812de95c430f56e1a65df34c5f7 Mon Sep 17 00:00:00 2001 From: Egor Date: Mon, 2 May 2022 15:51:11 +0300 Subject: [PATCH] make windows ver actually build --- .gitignore | 3 ++- Makefile | 8 +++++--- NetSock/netsock.h | 7 +++++++ config.example.mk | 6 ++++++ irc.c | 2 +- 5 files changed, 21 insertions(+), 5 deletions(-) create mode 100644 config.example.mk diff --git a/.gitignore b/.gitignore index ad02aa4..a1987c9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ ircd -config.mak +ircd.exe +config.mk diff --git a/Makefile b/Makefile index 423f715..c37657c 100644 --- 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 $@ diff --git a/NetSock/netsock.h b/NetSock/netsock.h index ead46ed..f60cc88 100644 --- a/NetSock/netsock.h +++ b/NetSock/netsock.h @@ -10,9 +10,11 @@ // 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 //#include //#include @@ -20,13 +22,18 @@ #include #include //#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 index 0000000..ab7ebcd --- /dev/null +++ b/config.example.mk @@ -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 --- 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 -- 2.56.0