added portability to non-BSD systems
This commit is contained in:
5
Makefile
5
Makefile
@ -44,7 +44,10 @@ $(OBJ_DIR)/threadpool.o: threadpool.c util.h threadpool.h
|
|||||||
$(OBJ_DIR)/ini.o: ini.c ini.h
|
$(OBJ_DIR)/ini.o: ini.c ini.h
|
||||||
$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
|
$(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 $@
|
$(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
|
$(OBJ_DIR)/server.o: server.c threadpool.h conn.h util.h serverWorker.h ini.h serverUtil.h fileQueue.h taglialegna.h
|
||||||
|
|||||||
36
lib/utils/strsep_gnu.c
Normal file
36
lib/utils/strsep_gnu.c
Normal file
@ -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
|
||||||
|
<http://www.gnu.org/licenses/>. */
|
||||||
|
#include <string.h>
|
||||||
|
#include <strsep_gnu.h>
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
10
lib/utils/strsep_gnu.h
Normal file
10
lib/utils/strsep_gnu.h
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#pragma once
|
||||||
|
#ifndef _STRSEP_GNU
|
||||||
|
#define _STRSEP_GNU
|
||||||
|
|
||||||
|
#include <strings.h>
|
||||||
|
|
||||||
|
extern char *strsep_gnu (char **__restrict __stringp,
|
||||||
|
const char *__restrict __delim);
|
||||||
|
|
||||||
|
#endif /* _STRSEP_GNU */
|
||||||
@ -399,7 +399,7 @@ int main(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
destroyThreadPool(pool, 0); // notifico che i thread dovranno uscire
|
destroyThreadPool(pool, 0); // notifico che i thread dovranno uscire
|
||||||
clearWaiting(&waiting);
|
clearWaiting(&waiting); // destroy waiting list
|
||||||
taglia_stats(taglia, stdout); // print stats
|
taglia_stats(taglia, stdout); // print stats
|
||||||
|
|
||||||
// print all files in storage during shutdown
|
// print all files in storage during shutdown
|
||||||
|
|||||||
@ -151,9 +151,17 @@ int parser(int len, char *command, queueT *queue, long fd_c, taglia_t* taglia, p
|
|||||||
char *token2 = NULL;
|
char *token2 = NULL;
|
||||||
char *token3 = NULL;
|
char *token3 = NULL;
|
||||||
|
|
||||||
|
#if defined(__APPLE__) || defined(__FreeBSD__)
|
||||||
token = strsep(&string, "|");
|
token = strsep(&string, "|");
|
||||||
token2 = strsep(&string, "|");
|
token2 = strsep(&string, "|");
|
||||||
token3 = 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)
|
if(!token)
|
||||||
goto _parser_cleanup;
|
goto _parser_cleanup;
|
||||||
|
|||||||
Reference in New Issue
Block a user