diff --git a/Makefile b/Makefile
index 16a4f00..a0334d5 100644
--- a/Makefile
+++ b/Makefile
@@ -44,7 +44,10 @@ $(OBJ_DIR)/threadpool.o: threadpool.c util.h threadpool.h
$(OBJ_DIR)/ini.o: ini.c ini.h
$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
-$(OBJ_DIR)/serverWorker.o: serverWorker.c serverWorker.h apiFile.h fileQueue.h taglialegna.h threadpool.h conn.h message.h
+$(OBJ_DIR)/strsep_gnu.o: strsep_gnu.c strsep_gnu.h
+ $(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
+
+$(OBJ_DIR)/serverWorker.o: serverWorker.c serverWorker.h apiFile.h fileQueue.h taglialegna.h threadpool.h conn.h message.h strsep_gnu.h
$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
$(OBJ_DIR)/server.o: server.c threadpool.h conn.h util.h serverWorker.h ini.h serverUtil.h fileQueue.h taglialegna.h
diff --git a/lib/utils/strsep_gnu.c b/lib/utils/strsep_gnu.c
new file mode 100644
index 0000000..edd9e8f
--- /dev/null
+++ b/lib/utils/strsep_gnu.c
@@ -0,0 +1,36 @@
+/* Copyright (C) 1992-2019 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ . */
+#include
+#include
+
+char *
+strsep_gnu (char **stringp, const char *delim)
+{
+ char *begin, *end;
+ begin = *stringp;
+ if (begin == NULL)
+ return NULL;
+ /* Find the end of the token. */
+ end = begin + strcspn (begin, delim);
+ if (*end)
+ {
+ /* Terminate the token and set *STRINGP past NUL character. */
+ *end++ = '\0';
+ *stringp = end;
+ }
+ else
+ /* No more delimiters; this is the last token. */
+ *stringp = NULL;
+ return begin;
+}
diff --git a/lib/utils/strsep_gnu.h b/lib/utils/strsep_gnu.h
new file mode 100644
index 0000000..f47ac34
--- /dev/null
+++ b/lib/utils/strsep_gnu.h
@@ -0,0 +1,10 @@
+#pragma once
+#ifndef _STRSEP_GNU
+#define _STRSEP_GNU
+
+#include
+
+extern char *strsep_gnu (char **__restrict __stringp,
+ const char *__restrict __delim);
+
+#endif /* _STRSEP_GNU */
diff --git a/src/server.c b/src/server.c
index b0ec8f7..3841489 100644
--- a/src/server.c
+++ b/src/server.c
@@ -399,7 +399,7 @@ int main(int argc, char *argv[]) {
}
destroyThreadPool(pool, 0); // notifico che i thread dovranno uscire
- clearWaiting(&waiting);
+ clearWaiting(&waiting); // destroy waiting list
taglia_stats(taglia, stdout); // print stats
// print all files in storage during shutdown
diff --git a/src/serverWorker.c b/src/serverWorker.c
index c09c2b8..7bc7f7f 100644
--- a/src/serverWorker.c
+++ b/src/serverWorker.c
@@ -151,9 +151,17 @@ int parser(int len, char *command, queueT *queue, long fd_c, taglia_t* taglia, p
char *token2 = NULL;
char *token3 = NULL;
+#if defined(__APPLE__) || defined(__FreeBSD__)
token = strsep(&string, "|");
token2 = strsep(&string, "|");
token3 = strsep(&string, "|");
+#endif /* __APPLE__ or __FreeBSD__ */
+#if defined(__linux__)
+ token = strsep_gnu(&string, "|");
+ token2 = strsep_gnu(&string, "|");
+ token3 = strsep_gnu(&string, "|");
+#endif
+
if(!token)
goto _parser_cleanup;