diff options
author | Robert Gustafsson <robg@student.chalmers.se> | 2017-10-03 09:14:55 +0200 |
---|---|---|
committer | Robert Gustafsson <robg@student.chalmers.se> | 2017-10-03 09:14:55 +0200 |
commit | cd393a04244181e73599b24ac38e70778501c120 (patch) | |
tree | 214f728b6099d2d45dd69d80ea18183e49dacdc8 | |
parent | b8e28ed52cec6de9179a5bb6058def0efc6fcfa5 (diff) | |
download | midbro-cd393a04244181e73599b24ac38e70778501c120.tar.gz midbro-cd393a04244181e73599b24ac38e70778501c120.tar.bz2 |
Some refactoring
-rw-r--r-- | broccoli/Makefile | 31 | ||||
-rw-r--r-- | broccoli/includes/broevent.h | 7 | ||||
-rw-r--r-- | broccoli/includes/fifoqueue.h | 5 | ||||
-rw-r--r-- | broccoli/script/modbus.bro (renamed from broccoli/modbus.bro) | 0 | ||||
-rw-r--r-- | broccoli/src/broevent.c (renamed from broccoli/broevent.c) | 7 | ||||
-rw-r--r-- | broccoli/src/fifoqueue.c (renamed from broccoli/fifoqueue.c) | 5 | ||||
-rw-r--r-- | broccoli/src/midbropasad.c (renamed from broccoli/midbropasad.c) | 9 | ||||
-rw-r--r-- | broccoli/test/tests.c (renamed from broccoli/tests.c) | 4 |
8 files changed, 39 insertions, 29 deletions
diff --git a/broccoli/Makefile b/broccoli/Makefile index 329c60c..ea5465b 100644 --- a/broccoli/Makefile +++ b/broccoli/Makefile @@ -1,26 +1,23 @@ CC=gcc -CFLAGS = -c -Wall -I/usr/local/include -I/usr/local/include -DBROCCOLI +CFLAGS =-c -DBROCCOLI +INC =-I/usr/local/include -I/usr/local/include -I./includes LDFLAGS = -L/usr/local/lib -lbroccoli -pthread +SRC = midbropasad.c broevent.c fifoqueue.c +OBJ = $(patsubst %.c, build/%.o, $(SRC)) -all: midbropasad tests +all: bin/midbropasad bin/tests -midbropasad: midbropasad.o broevent.o fifoqueue.o - $(CC) midbropasad.o broevent.o fifoqueue.o -o midbropasad $(LDFLAGS) +bin/midbropasad: $(OBJ) + $(CC) $^ -o bin/midbropasad $(LDFLAGS) -tests: tests.o fifoqueue.o - $(CC) tests.o fifoqueue.o -o tests +build/%.o: src/%.c + $(CC) $(CFLAGS) $(INC) $< -o $@ -midbropasad.o: midbropasad.c - $(CC) $(CFLAGS) midbropasad.c +bin/tests: build/fifoqueue.o build/tests.o + $(CC) $^ -o bin/tests $(LDFLAGS) -broevent.o: broevent.c - $(CC) $(CFLAGS) broevent.c - -fifoqueue.o: fifoqueue.c - $(CC) -c -Wall fifoqueue.c - -tests.o: tests.c - $(CC) -c -Wall tests.c +build/tests.o: test/tests.c + $(CC) $(CFLAGS) $(INC) $< -o $@ clean: - rm *.o midbropasad tests + rm build/* bin/* diff --git a/broccoli/includes/broevent.h b/broccoli/includes/broevent.h index 653796e..5e34f5c 100644 --- a/broccoli/includes/broevent.h +++ b/broccoli/includes/broevent.h @@ -1,5 +1,4 @@ -#ifdef BROCCOLI -#include <broccoli.h> -#endif - +#ifndef BROEVENT_H +#define BROEVENT_H void * bro_event_listener(void * args); +#endif diff --git a/broccoli/includes/fifoqueue.h b/broccoli/includes/fifoqueue.h index 398e1e9..75b09c4 100644 --- a/broccoli/includes/fifoqueue.h +++ b/broccoli/includes/fifoqueue.h @@ -1,5 +1,5 @@ -#include <stdlib.h> -#include <stdio.h> +#ifndef FIFOQUEUE_H +#define FIFOQUEUE_H #include "types.h" Fifo_q * init_queue(int size); @@ -15,3 +15,4 @@ int add_to_queue(Fifo_q * q, Sensor_t * sensor); Sensor_t * pop_from_queue(Fifo_q * q); void print_queue(Fifo_q * q); +#endif diff --git a/broccoli/modbus.bro b/broccoli/script/modbus.bro index a2caed9..a2caed9 100644 --- a/broccoli/modbus.bro +++ b/broccoli/script/modbus.bro diff --git a/broccoli/broevent.c b/broccoli/src/broevent.c index 2b3db8d..3813270 100644 --- a/broccoli/broevent.c +++ b/broccoli/src/broevent.c @@ -1,5 +1,8 @@ -#include "includes/fifoqueue.h" -#include "includes/broevent.h" +#include "fifoqueue.h" +#include "broevent.h" +#ifdef BROCCOLI +#include <broccoli.h> +#endif char *host_default = "127.0.0.1"; char *port_default = "47760"; diff --git a/broccoli/fifoqueue.c b/broccoli/src/fifoqueue.c index e8a1525..9b972e7 100644 --- a/broccoli/fifoqueue.c +++ b/broccoli/src/fifoqueue.c @@ -1,5 +1,8 @@ -#include "includes/fifoqueue.h" #include <pthread.h> +#include <stdlib.h> +#include <stdio.h> +#include "types.h" +#include "fifoqueue.h" pthread_mutex_t lock; pthread_mutex_t bufferEmptyBlock; diff --git a/broccoli/midbropasad.c b/broccoli/src/midbropasad.c index 70a290f..756e558 100644 --- a/broccoli/midbropasad.c +++ b/broccoli/src/midbropasad.c @@ -1,5 +1,10 @@ -#include "includes/fifoqueue.h" -#include "includes/broevent.h" +#include <pthread.h> +#include <unistd.h> +#include "fifoqueue.h" +#include "broevent.h" +#ifdef BROCCOLI +#include <broccoli.h> +#endif void start_data_capture(Fifo_q * q) diff --git a/broccoli/tests.c b/broccoli/test/tests.c index 73e0346..5b91feb 100644 --- a/broccoli/tests.c +++ b/broccoli/test/tests.c @@ -1,5 +1,7 @@ -#include "includes/fifoqueue.h" +#include "fifoqueue.h" #include <assert.h> +#include <stdio.h> +#include <stdlib.h> void create_sensor_object_test() { |