compiling on linux

This commit is contained in:
elvis
2022-04-24 13:01:13 +02:00
parent 9eaf9cdd49
commit d7f555bf21
4 changed files with 13 additions and 6 deletions

View File

@ -2,7 +2,7 @@ CC = gcc
CFLAGS += -std=c99 -Wall -Werror -pedantic #-g
INCDIR = ./lib/utils ./lib/ini ./lib/threadpool ./src ./lib/log ./lib/api
INCLUDES := $(patsubst %,-I %,$(INCDIR))
LDFLAGS = -L .
LDFLAGS = -L . -lm
OPTFLAGS = #-O3
LIBS = -lpthread
SOCKET = ./cs_sock
@ -66,7 +66,7 @@ $(OBJ_DIR)/server.o: server.c threadpool.h conn.h util.h serverWorker.h ini.h se
@echo $@
$(BUILD_DIR)/server: $(OBJ_SERVER)
@$(CC) $(CFLAGS) $(OPTFLAGS) $(OPTFLAGS) $(LIBS) $(OBJ_SERVER) -o $(BUILD_DIR)/server
@$(CC) $(CFLAGS) $(OPTFLAGS) $(OPTFLAGS) $(LIBS) $(OBJ_SERVER) $(LDFLAGS) -o $(BUILD_DIR)/server
@echo $@
@ -80,7 +80,7 @@ $(OBJ_DIR)/client.o: client.c api.h
@echo $@
$(BUILD_DIR)/client: $(OBJ_CLIENT)
@$(CC) $(CFLAGS) $(OPTFLAGS) $(LIBS) $(OBJ_CLIENT) -o $(BUILD_DIR)/client
@$(CC) $(CFLAGS) $(OPTFLAGS) $(LIBS) $(OBJ_CLIENT) $(LDFLAGS) -o $(BUILD_DIR)/client
@echo $@

View File

@ -1,3 +1,5 @@
#define _POSIX_C_SOURCE 200809L
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
@ -6,6 +8,7 @@
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <time.h>
#include <sys/un.h>
#include <unistd.h>
#include <math.h>
@ -1431,7 +1434,7 @@ int storeFilesInDirectory(const char *dirname, int n, recivedFile_t *rf) {
return -1;
}
strcpy(basepath, dirname);
strlcat(basepath, "/", basepathlen);
strncat(basepath, "/", basepathlen);
// for each file, create and write
for(int i=0;i<n;++i) {
@ -1442,7 +1445,7 @@ int storeFilesInDirectory(const char *dirname, int n, recivedFile_t *rf) {
return -1;
}
strcpy(filename, basepath);
strlcat(filename, rf[i].path, basepathlen + rf[i].pathlen);
strncat(filename, rf[i].path, basepathlen + rf[i].pathlen);
int fdo;
if((fdo = open(filename, O_WRONLY | O_CREAT, 0666)) == -1) { // open
@ -1527,7 +1530,7 @@ int addOpenFile(const char *pathname) {
return -1;
}
strlcpy(new->filename, pathname, len);
strncpy(new->filename, pathname, len);
new->next = NULL;
if(openedFiles->f == NULL) {

View File

@ -4,6 +4,8 @@
#include <time.h>
struct timespec;
#define O_CREATE 1
#define O_LOCK 2

View File

@ -1,3 +1,5 @@
#define _POSIX_C_SOURCE 200809L
#include <ctype.h>
#include <errno.h>
#include <fts.h>